3 * Support for a cx23416 mpeg encoder via cx2388x host port.
4 * "blackbird" reference design.
6 * (c) 2004 Jelle Foks <jelle@foks.8m.com>
7 * (c) 2004 Gerd Knorr <kraxel@bytesex.org>
9 * Includes parts from the ivtv driver( http://ivtv.sourceforge.net/),
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <linux/module.h>
27 #include <linux/moduleparam.h>
28 #include <linux/init.h>
30 #include <linux/delay.h>
31 #include <linux/device.h>
32 #include <linux/firmware.h>
33 #include <media/v4l2-common.h>
34 #include <media/cx2341x.h>
38 MODULE_DESCRIPTION("driver for cx2388x/cx23416 based mpeg encoder cards");
39 MODULE_AUTHOR("Jelle Foks <jelle@foks.8m.com>, Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
40 MODULE_LICENSE("GPL");
42 static unsigned int mpegbufs = 32;
43 module_param(mpegbufs,int,0644);
44 MODULE_PARM_DESC(mpegbufs,"number of mpeg buffers, range 2-32");
46 static unsigned int debug = 0;
47 module_param(debug,int,0644);
48 MODULE_PARM_DESC(debug,"enable debug messages [blackbird]");
50 #define dprintk(level,fmt, arg...) if (debug >= level) \
51 printk(KERN_DEBUG "%s/2-bb: " fmt, dev->core->name , ## arg)
53 static LIST_HEAD(cx8802_devlist);
55 /* ------------------------------------------------------------------ */
57 #define BLACKBIRD_FIRM_ENC_FILENAME "v4l-cx2341x-enc.fw"
58 #define BLACKBIRD_FIRM_IMAGE_SIZE 256*1024
60 /* defines below are from ivtv-driver.h */
62 #define IVTV_CMD_HW_BLOCKS_RST 0xFFFFFFFF
64 /* Firmware API commands */
65 #define IVTV_API_STD_TIMEOUT 500
67 enum blackbird_capture_type {
68 BLACKBIRD_MPEG_CAPTURE,
69 BLACKBIRD_RAW_CAPTURE,
70 BLACKBIRD_RAW_PASSTHRU_CAPTURE
72 enum blackbird_capture_bits {
73 BLACKBIRD_RAW_BITS_NONE = 0x00,
74 BLACKBIRD_RAW_BITS_YUV_CAPTURE = 0x01,
75 BLACKBIRD_RAW_BITS_PCM_CAPTURE = 0x02,
76 BLACKBIRD_RAW_BITS_VBI_CAPTURE = 0x04,
77 BLACKBIRD_RAW_BITS_PASSTHRU_CAPTURE = 0x08,
78 BLACKBIRD_RAW_BITS_TO_HOST_CAPTURE = 0x10
80 enum blackbird_capture_end {
81 BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */
82 BLACKBIRD_END_NOW, /* stop immediately, no irq */
84 enum blackbird_framerate {
85 BLACKBIRD_FRAMERATE_NTSC_30, /* NTSC: 30fps */
86 BLACKBIRD_FRAMERATE_PAL_25 /* PAL: 25fps */
88 enum blackbird_video_bitrate_type {
92 #define BLACKBIRD_PEAK_RATE_DIVISOR 400
93 enum blackbird_mux_rate {
94 BLACKBIRD_MUX_RATE_DEFAULT,
95 /* dvd mux rate: multiply by 400 to get the actual rate */
96 BLACKBIRD_MUX_RATE_DVD = 25200
98 enum blackbird_aspect_ratio {
99 BLACKBIRD_ASPECT_RATIO_FORBIDDEN,
100 BLACKBIRD_ASPECT_RATIO_1_1_SQUARE,
101 BLACKBIRD_ASPECT_RATIO_4_3,
102 BLACKBIRD_ASPECT_RATIO_16_9,
103 BLACKBIRD_ASPECT_RATIO_221_100,
104 BLACKBIRD_ASPECT_RATIO_RESERVED
106 enum blackbird_dnr_bits {
107 BLACKBIRD_DNR_BITS_MANUAL,
108 BLACKBIRD_DNR_BITS_AUTO_SPATIAL,
109 BLACKBIRD_DNR_BITS_AUTO_TEMPORAL,
110 BLACKBIRD_DNR_BITS_AUTO
112 enum blackbird_median_filter {
113 BLACKBIRD_MEDIAN_FILTER_DISABLED,
114 BLACKBIRD_MEDIAN_FILTER_HORIZONTAL,
115 BLACKBIRD_MEDIAN_FILTER_VERTICAL,
116 BLACKBIRD_MEDIAN_FILTER_HV,
117 BLACKBIRD_MEDIAN_FILTER_DIAGONAL
119 enum blackbird_spatial_filter_luma {
120 BLACKBIRD_SPATIAL_FILTER_LUMA_DISABLED,
121 BLACKBIRD_SPATIAL_FILTER_LUMA_1D_HORIZ,
122 BLACKBIRD_SPATIAL_FILTER_LUMA_1D_VERT,
123 BLACKBIRD_SPATIAL_FILTER_LUMA_2D_HV, /* separable, default */
124 BLACKBIRD_SPATIAL_FILTER_LUMA_2D_SYMM /* symmetric non-separable */
126 enum blackbird_spatial_filter_chroma {
127 BLACKBIRD_SPATIAL_FILTER_CHROMA_DISABLED,
128 BLACKBIRD_SPATIAL_FILTER_CHROMA_1D_HORIZ /* default */
130 enum blackbird_pulldown {
131 BLACKBIRD_3_2_PULLDOWN_DISABLED,
132 BLACKBIRD_3_2_PULLDOWN_ENABLED
134 enum blackbird_vbi_line_bits {
135 BLACKBIRD_VBI_LINE_BITS_TOP_FIELD,
136 BLACKBIRD_VBI_LINE_BITS_BOT_FIELD = (1 << 31),
137 BLACKBIRD_VBI_LINE_BITS_ALL_LINES = 0xFFFFFFFF
139 enum blackbird_vbi_line {
140 BLACKBIRD_VBI_LINE_DISABLED,
141 BLACKBIRD_VBI_LINE_ENABLED
143 enum blackbird_vbi_slicing {
144 BLACKBIRD_VBI_SLICING_NONE,
145 BLACKBIRD_VBI_SLICING_CLOSED_CAPTION
147 enum blackbird_stream_type {
148 BLACKBIRD_STREAM_PROGRAM,
149 BLACKBIRD_STREAM_TRANSPORT,
150 BLACKBIRD_STREAM_MPEG1,
151 BLACKBIRD_STREAM_PES_AV,
152 BLACKBIRD_STREAM_UNKNOWN4,
153 BLACKBIRD_STREAM_PES_VIDEO,
154 BLACKBIRD_STREAM_UNKNOWN6,
155 BLACKBIRD_STREAM_PES_AUDIO,
156 BLACKBIRD_STREAM_UNKNOWN8,
157 BLACKBIRD_STREAM_UNKNOWN9, /* audio/pcm ? */
158 BLACKBIRD_STREAM_DVD,
159 BLACKBIRD_STREAM_VCD,
160 BLACKBIRD_STREAM_UNKNOWN12 /* svcd/xvcd ? */
162 enum blackbird_stream_port {
163 BLACKBIRD_OUTPUT_PORT_MEMORY,
164 BLACKBIRD_OUTPUT_PORT_STREAMING,
165 BLACKBIRD_OUTPUT_PORT_SERIAL
167 enum blackbird_audio_bits_sample_rate {
168 BLACKBIRD_AUDIO_BITS_44100HZ,
169 BLACKBIRD_AUDIO_BITS_48000HZ,
170 BLACKBIRD_AUDIO_BITS_32000HZ,
171 BLACKBIRD_AUDIO_BITS_RESERVED_HZ,
173 enum blackbird_audio_bits_encoding {
174 BLACKBIRD_AUDIO_BITS_LAYER_1 = 0x1 << 2,
175 BLACKBIRD_AUDIO_BITS_LAYER_2 = 0x2 << 2,
177 enum blackbird_audio_bits_bitrate_layer_1 {
178 BLACKBIRD_AUDIO_BITS_LAYER_1_FREE_FORMAT,
179 BLACKBIRD_AUDIO_BITS_LAYER_1_32 = 0x01 << 4,
180 BLACKBIRD_AUDIO_BITS_LAYER_1_64 = 0x02 << 4,
181 BLACKBIRD_AUDIO_BITS_LAYER_1_96 = 0x03 << 4,
182 BLACKBIRD_AUDIO_BITS_LAYER_1_128 = 0x04 << 4,
183 BLACKBIRD_AUDIO_BITS_LAYER_1_160 = 0x05 << 4,
184 BLACKBIRD_AUDIO_BITS_LAYER_1_192 = 0x06 << 4,
185 BLACKBIRD_AUDIO_BITS_LAYER_1_224 = 0x07 << 4,
186 BLACKBIRD_AUDIO_BITS_LAYER_1_256 = 0x08 << 4,
187 BLACKBIRD_AUDIO_BITS_LAYER_1_288 = 0x09 << 4,
188 BLACKBIRD_AUDIO_BITS_LAYER_1_320 = 0x0A << 4,
189 BLACKBIRD_AUDIO_BITS_LAYER_1_352 = 0x0B << 4,
190 BLACKBIRD_AUDIO_BITS_LAYER_1_384 = 0x0C << 4,
191 BLACKBIRD_AUDIO_BITS_LAYER_1_416 = 0x0D << 4,
192 BLACKBIRD_AUDIO_BITS_LAYER_1_448 = 0x0E << 4,
194 enum blackbird_audio_bits_bitrate_layer_2 {
195 BLACKBIRD_AUDIO_BITS_LAYER_2_FREE_FORMAT,
196 BLACKBIRD_AUDIO_BITS_LAYER_2_32 = 0x01 << 4,
197 BLACKBIRD_AUDIO_BITS_LAYER_2_48 = 0x02 << 4,
198 BLACKBIRD_AUDIO_BITS_LAYER_2_56 = 0x03 << 4,
199 BLACKBIRD_AUDIO_BITS_LAYER_2_64 = 0x04 << 4,
200 BLACKBIRD_AUDIO_BITS_LAYER_2_80 = 0x05 << 4,
201 BLACKBIRD_AUDIO_BITS_LAYER_2_96 = 0x06 << 4,
202 BLACKBIRD_AUDIO_BITS_LAYER_2_112 = 0x07 << 4,
203 BLACKBIRD_AUDIO_BITS_LAYER_2_128 = 0x08 << 4,
204 BLACKBIRD_AUDIO_BITS_LAYER_2_160 = 0x09 << 4,
205 BLACKBIRD_AUDIO_BITS_LAYER_2_192 = 0x0A << 4,
206 BLACKBIRD_AUDIO_BITS_LAYER_2_224 = 0x0B << 4,
207 BLACKBIRD_AUDIO_BITS_LAYER_2_256 = 0x0C << 4,
208 BLACKBIRD_AUDIO_BITS_LAYER_2_320 = 0x0D << 4,
209 BLACKBIRD_AUDIO_BITS_LAYER_2_384 = 0x0E << 4,
211 enum blackbird_audio_bits_mode {
212 BLACKBIRD_AUDIO_BITS_STEREO,
213 BLACKBIRD_AUDIO_BITS_JOINT_STEREO = 0x1 << 8,
214 BLACKBIRD_AUDIO_BITS_DUAL = 0x2 << 8,
215 BLACKBIRD_AUDIO_BITS_MONO = 0x3 << 8,
217 enum blackbird_audio_bits_mode_extension {
218 BLACKBIRD_AUDIO_BITS_BOUND_4,
219 BLACKBIRD_AUDIO_BITS_BOUND_8 = 0x1 << 10,
220 BLACKBIRD_AUDIO_BITS_BOUND_12 = 0x2 << 10,
221 BLACKBIRD_AUDIO_BITS_BOUND_16 = 0x3 << 10,
223 enum blackbird_audio_bits_emphasis {
224 BLACKBIRD_AUDIO_BITS_EMPHASIS_NONE,
225 BLACKBIRD_AUDIO_BITS_EMPHASIS_50_15 = 0x1 << 12,
226 BLACKBIRD_AUDIO_BITS_EMPHASIS_RESERVED = 0x2 << 12,
227 BLACKBIRD_AUDIO_BITS_EMPHASIS_CCITT_J17 = 0x3 << 12,
229 enum blackbird_audio_bits_crc {
230 BLACKBIRD_AUDIO_BITS_CRC_OFF,
231 BLACKBIRD_AUDIO_BITS_CRC_ON = 0x1 << 14,
233 enum blackbird_audio_bits_copyright {
234 BLACKBIRD_AUDIO_BITS_COPYRIGHT_OFF,
235 BLACKBIRD_AUDIO_BITS_COPYRIGHT_ON = 0x1 << 15,
237 enum blackbird_audio_bits_original {
238 BLACKBIRD_AUDIO_BITS_COPY,
239 BLACKBIRD_AUDIO_BITS_ORIGINAL = 0x1 << 16,
241 enum blackbird_gop_closure {
242 BLACKBIRD_GOP_CLOSURE_OFF,
243 BLACKBIRD_GOP_CLOSURE_ON,
245 enum blackbird_data_xfer_status {
246 BLACKBIRD_MORE_BUFFERS_FOLLOW,
247 BLACKBIRD_LAST_BUFFER,
249 enum blackbird_picture_mask {
250 BLACKBIRD_PICTURE_MASK_NONE,
251 BLACKBIRD_PICTURE_MASK_I_FRAMES,
252 BLACKBIRD_PICTURE_MASK_I_P_FRAMES = 0x3,
253 BLACKBIRD_PICTURE_MASK_ALL_FRAMES = 0x7,
255 enum blackbird_vbi_mode_bits {
256 BLACKBIRD_VBI_BITS_SLICED,
257 BLACKBIRD_VBI_BITS_RAW,
259 enum blackbird_vbi_insertion_bits {
260 BLACKBIRD_VBI_BITS_INSERT_IN_XTENSION_USR_DATA,
261 BLACKBIRD_VBI_BITS_INSERT_IN_PRIVATE_PACKETS = 0x1 << 1,
262 BLACKBIRD_VBI_BITS_SEPARATE_STREAM = 0x2 << 1,
263 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1,
264 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1,
266 enum blackbird_dma_unit {
268 BLACKBIRD_DMA_FRAMES,
270 enum blackbird_dma_transfer_status_bits {
271 BLACKBIRD_DMA_TRANSFER_BITS_DONE = 0x01,
272 BLACKBIRD_DMA_TRANSFER_BITS_ERROR = 0x04,
273 BLACKBIRD_DMA_TRANSFER_BITS_LL_ERROR = 0x10,
275 enum blackbird_pause {
276 BLACKBIRD_PAUSE_ENCODING,
277 BLACKBIRD_RESUME_ENCODING,
279 enum blackbird_copyright {
280 BLACKBIRD_COPYRIGHT_OFF,
281 BLACKBIRD_COPYRIGHT_ON,
283 enum blackbird_notification_type {
284 BLACKBIRD_NOTIFICATION_REFRESH,
286 enum blackbird_notification_status {
287 BLACKBIRD_NOTIFICATION_OFF,
288 BLACKBIRD_NOTIFICATION_ON,
290 enum blackbird_notification_mailbox {
291 BLACKBIRD_NOTIFICATION_NO_MAILBOX = -1,
293 enum blackbird_field1_lines {
294 BLACKBIRD_FIELD1_SAA7114 = 0x00EF, /* 239 */
295 BLACKBIRD_FIELD1_SAA7115 = 0x00F0, /* 240 */
296 BLACKBIRD_FIELD1_MICRONAS = 0x0105, /* 261 */
298 enum blackbird_field2_lines {
299 BLACKBIRD_FIELD2_SAA7114 = 0x00EF, /* 239 */
300 BLACKBIRD_FIELD2_SAA7115 = 0x00F0, /* 240 */
301 BLACKBIRD_FIELD2_MICRONAS = 0x0106, /* 262 */
303 enum blackbird_custom_data_type {
304 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,
305 BLACKBIRD_CUSTOM_PRIVATE_PACKET,
307 enum blackbird_mute {
311 enum blackbird_mute_video_mask {
312 BLACKBIRD_MUTE_VIDEO_V_MASK = 0x0000FF00,
313 BLACKBIRD_MUTE_VIDEO_U_MASK = 0x00FF0000,
314 BLACKBIRD_MUTE_VIDEO_Y_MASK = 0xFF000000,
316 enum blackbird_mute_video_shift {
317 BLACKBIRD_MUTE_VIDEO_V_SHIFT = 8,
318 BLACKBIRD_MUTE_VIDEO_U_SHIFT = 16,
319 BLACKBIRD_MUTE_VIDEO_Y_SHIFT = 24,
323 #define IVTV_REG_ENC_SDRAM_REFRESH (0x07F8 /*| IVTV_REG_OFFSET*/)
324 #define IVTV_REG_ENC_SDRAM_PRECHARGE (0x07FC /*| IVTV_REG_OFFSET*/)
325 #define IVTV_REG_SPU (0x9050 /*| IVTV_REG_OFFSET*/)
326 #define IVTV_REG_HW_BLOCKS (0x9054 /*| IVTV_REG_OFFSET*/)
327 #define IVTV_REG_VPU (0x9058 /*| IVTV_REG_OFFSET*/)
328 #define IVTV_REG_APU (0xA064 /*| IVTV_REG_OFFSET*/)
330 /* ------------------------------------------------------------------ */
332 static void host_setup(struct cx88_core *core)
334 /* toggle reset of the host */
335 cx_write(MO_GPHST_SOFT_RST, 1);
337 cx_write(MO_GPHST_SOFT_RST, 0);
340 /* host port setup */
341 cx_write(MO_GPHST_WSC, 0x44444444U);
342 cx_write(MO_GPHST_XFR, 0);
343 cx_write(MO_GPHST_WDTH, 15);
344 cx_write(MO_GPHST_HDSHK, 0);
345 cx_write(MO_GPHST_MUX16, 0x44448888U);
346 cx_write(MO_GPHST_MODE, 0);
349 /* ------------------------------------------------------------------ */
351 #define P1_MDATA0 0x390000
352 #define P1_MDATA1 0x390001
353 #define P1_MDATA2 0x390002
354 #define P1_MDATA3 0x390003
355 #define P1_MADDR2 0x390004
356 #define P1_MADDR1 0x390005
357 #define P1_MADDR0 0x390006
358 #define P1_RDATA0 0x390008
359 #define P1_RDATA1 0x390009
360 #define P1_RDATA2 0x39000A
361 #define P1_RDATA3 0x39000B
362 #define P1_RADDR0 0x39000C
363 #define P1_RADDR1 0x39000D
364 #define P1_RRDWR 0x39000E
366 static int wait_ready_gpio0_bit1(struct cx88_core *core, u32 state)
368 unsigned long timeout = jiffies + msecs_to_jiffies(1);
371 need = state ? 2 : 0;
373 gpio0 = cx_read(MO_GP0_IO) & 2;
376 if (time_after(jiffies,timeout))
382 static int memory_write(struct cx88_core *core, u32 address, u32 value)
384 /* Warning: address is dword address (4 bytes) */
385 cx_writeb(P1_MDATA0, (unsigned int)value);
386 cx_writeb(P1_MDATA1, (unsigned int)(value >> 8));
387 cx_writeb(P1_MDATA2, (unsigned int)(value >> 16));
388 cx_writeb(P1_MDATA3, (unsigned int)(value >> 24));
389 cx_writeb(P1_MADDR2, (unsigned int)(address >> 16) | 0x40);
390 cx_writeb(P1_MADDR1, (unsigned int)(address >> 8));
391 cx_writeb(P1_MADDR0, (unsigned int)address);
395 return wait_ready_gpio0_bit1(core,1);
398 static int memory_read(struct cx88_core *core, u32 address, u32 *value)
403 /* Warning: address is dword address (4 bytes) */
404 cx_writeb(P1_MADDR2, (unsigned int)(address >> 16) & ~0xC0);
405 cx_writeb(P1_MADDR1, (unsigned int)(address >> 8));
406 cx_writeb(P1_MADDR0, (unsigned int)address);
409 retval = wait_ready_gpio0_bit1(core,1);
411 cx_writeb(P1_MDATA3, 0);
412 val = (unsigned char)cx_read(P1_MDATA3) << 24;
413 cx_writeb(P1_MDATA2, 0);
414 val |= (unsigned char)cx_read(P1_MDATA2) << 16;
415 cx_writeb(P1_MDATA1, 0);
416 val |= (unsigned char)cx_read(P1_MDATA1) << 8;
417 cx_writeb(P1_MDATA0, 0);
418 val |= (unsigned char)cx_read(P1_MDATA0);
424 static int register_write(struct cx88_core *core, u32 address, u32 value)
426 cx_writeb(P1_RDATA0, (unsigned int)value);
427 cx_writeb(P1_RDATA1, (unsigned int)(value >> 8));
428 cx_writeb(P1_RDATA2, (unsigned int)(value >> 16));
429 cx_writeb(P1_RDATA3, (unsigned int)(value >> 24));
430 cx_writeb(P1_RADDR0, (unsigned int)address);
431 cx_writeb(P1_RADDR1, (unsigned int)(address >> 8));
432 cx_writeb(P1_RRDWR, 1);
436 return wait_ready_gpio0_bit1(core,1);
440 static int register_read(struct cx88_core *core, u32 address, u32 *value)
445 cx_writeb(P1_RADDR0, (unsigned int)address);
446 cx_writeb(P1_RADDR1, (unsigned int)(address >> 8));
447 cx_writeb(P1_RRDWR, 0);
450 retval = wait_ready_gpio0_bit1(core,1);
451 val = (unsigned char)cx_read(P1_RDATA0);
452 val |= (unsigned char)cx_read(P1_RDATA1) << 8;
453 val |= (unsigned char)cx_read(P1_RDATA2) << 16;
454 val |= (unsigned char)cx_read(P1_RDATA3) << 24;
460 /* ------------------------------------------------------------------ */
462 /* We don't need to call the API often, so using just one mailbox will probably suffice */
463 static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
464 u32 inputcnt, u32 outputcnt, ...)
466 unsigned long timeout;
467 u32 value, flag, retval;
470 va_start(args, outputcnt);
472 dprintk(1,"%s: 0x%X\n", __FUNCTION__, command);
474 /* this may not be 100% safe if we can't read any memory location
475 without side effects */
476 memory_read(dev->core, dev->mailbox - 4, &value);
477 if (value != 0x12345678) {
478 dprintk(0, "Firmware and/or mailbox pointer not initialized or corrupted\n");
482 memory_read(dev->core, dev->mailbox, &flag);
484 dprintk(0, "ERROR: Mailbox appears to be in use (%x)\n", flag);
488 flag |= 1; /* tell 'em we're working on it */
489 memory_write(dev->core, dev->mailbox, flag);
491 /* write command + args + fill remaining with zeros */
492 memory_write(dev->core, dev->mailbox + 1, command); /* command code */
493 memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT); /* timeout */
494 for (i = 0; i < inputcnt ; i++) {
495 value = va_arg(args, int);
496 memory_write(dev->core, dev->mailbox + 4 + i, value);
497 dprintk(1, "API Input %d = %d\n", i, value);
500 memory_write(dev->core, dev->mailbox + 4 + i, 0);
502 flag |= 3; /* tell 'em we're done writing */
503 memory_write(dev->core, dev->mailbox, flag);
505 /* wait for firmware to handle the API command */
506 timeout = jiffies + msecs_to_jiffies(10);
508 memory_read(dev->core, dev->mailbox, &flag);
511 if (time_after(jiffies,timeout)) {
512 dprintk(0, "ERROR: API Mailbox timeout\n");
518 /* read output values */
519 for (i = 0; i < outputcnt ; i++) {
520 int *vptr = va_arg(args, int *);
521 memory_read(dev->core, dev->mailbox + 4 + i, vptr);
522 dprintk(1, "API Output %d = %d\n", i, *vptr);
526 memory_read(dev->core, dev->mailbox + 2, &retval);
527 dprintk(1, "API result = %d\n",retval);
530 memory_write(dev->core, dev->mailbox, flag);
535 static int blackbird_find_mailbox(struct cx8802_dev *dev)
537 u32 signature[4]={0x12345678, 0x34567812, 0x56781234, 0x78123456};
542 for (i = 0; i < BLACKBIRD_FIRM_IMAGE_SIZE; i++) {
543 memory_read(dev->core, i, &value);
544 if (value == signature[signaturecnt])
548 if (4 == signaturecnt) {
549 dprintk(1, "Mailbox signature found\n");
553 dprintk(0, "Mailbox signature values not found!\n");
557 static int blackbird_load_firmware(struct cx8802_dev *dev)
559 static const unsigned char magic[8] = {
560 0xa7, 0x0d, 0x00, 0x00, 0x66, 0xbb, 0x55, 0xaa
562 const struct firmware *firmware;
568 retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED);
569 retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST);
570 retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH, 0x80000640);
571 retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE, 0x1A);
573 retval |= register_write(dev->core, IVTV_REG_APU, 0);
576 dprintk(0, "Error with register_write\n");
578 retval = request_firmware(&firmware, BLACKBIRD_FIRM_ENC_FILENAME,
583 dprintk(0, "ERROR: Hotplug firmware request failed (%s).\n",
584 BLACKBIRD_FIRM_ENC_FILENAME);
585 dprintk(0, "Please fix your hotplug setup, the board will "
586 "not work without firmware loaded!\n");
590 if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) {
591 dprintk(0, "ERROR: Firmware size mismatch (have %zd, expected %d)\n",
592 firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE);
596 if (0 != memcmp(firmware->data, magic, 8)) {
597 dprintk(0, "ERROR: Firmware magic mismatch, wrong file?\n");
601 /* transfer to the chip */
602 dprintk(1,"Loading firmware ...\n");
603 dataptr = (u32*)firmware->data;
604 for (i = 0; i < (firmware->size >> 2); i++) {
607 memory_write(dev->core, i, value);
611 /* read back to verify with the checksum */
612 for (i--; i >= 0; i--) {
613 memory_read(dev->core, i, &value);
617 dprintk(0, "ERROR: Firmware load failed (checksum mismatch).\n");
620 release_firmware(firmware);
621 dprintk(0, "Firmware upload successful.\n");
623 retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST);
624 retval |= register_read(dev->core, IVTV_REG_SPU, &value);
625 retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE);
628 retval |= register_read(dev->core, IVTV_REG_VPU, &value);
629 retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8);
632 dprintk(0, "Error with register_write\n");
637 Settings used by the windows tv app for PVR2000:
638 =================================================================================================================
639 Profile | Codec | Resolution | CBR/VBR | Video Qlty | V. Bitrate | Frmrate | Audio Codec | A. Bitrate | A. Mode
640 -----------------------------------------------------------------------------------------------------------------
641 MPEG-1 | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 2000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
642 MPEG-2 | MPEG2 | 720x576PAL | VBR | 600 :Good | 4000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
643 VCD | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 1150 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
644 DVD | MPEG2 | 720x576PAL | VBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
645 DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
646 =================================================================================================================
650 static struct blackbird_dnr default_dnr_params = {
651 .mode = BLACKBIRD_DNR_BITS_MANUAL,
652 .type = BLACKBIRD_MEDIAN_FILTER_DISABLED,
656 static struct v4l2_mpeg_compression default_mpeg_params = {
657 .st_type = V4L2_MPEG_PS_2,
659 .mode = V4L2_BITRATE_CBR,
669 .au_type = V4L2_MPEG_AU_2_II,
671 .mode = V4L2_BITRATE_CBR,
676 .au_sample_rate = 44100,
678 .vi_type = V4L2_MPEG_VI_2,
679 .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3,
681 .mode = V4L2_BITRATE_CBR,
687 .vi_frames_per_gop = 15,
688 .vi_bframes_count = 2,
694 static enum blackbird_stream_type mpeg_stream_types[] = {
695 [V4L2_MPEG_SS_1] = BLACKBIRD_STREAM_MPEG1,
696 [V4L2_MPEG_PS_2] = BLACKBIRD_STREAM_PROGRAM,
697 [V4L2_MPEG_TS_2] = BLACKBIRD_STREAM_TRANSPORT,
698 [V4L2_MPEG_PS_DVD] = BLACKBIRD_STREAM_DVD,
700 static enum blackbird_aspect_ratio mpeg_stream_ratios[] = {
701 [V4L2_MPEG_ASPECT_SQUARE] = BLACKBIRD_ASPECT_RATIO_1_1_SQUARE,
702 [V4L2_MPEG_ASPECT_4_3] = BLACKBIRD_ASPECT_RATIO_4_3,
703 [V4L2_MPEG_ASPECT_16_9] = BLACKBIRD_ASPECT_RATIO_16_9,
704 [V4L2_MPEG_ASPECT_1_221] = BLACKBIRD_ASPECT_RATIO_221_100,
706 static enum blackbird_video_bitrate_type mpeg_video_bitrates[] = {
707 [V4L2_BITRATE_NONE] = BLACKBIRD_VIDEO_CBR,
708 [V4L2_BITRATE_CBR] = BLACKBIRD_VIDEO_CBR,
709 [V4L2_BITRATE_VBR] = BLACKBIRD_VIDEO_VBR,
711 /* find the best layer I/II bitrate to fit a given numeric value */
712 struct bitrate_bits {
713 u32 bits; /* layer bits for the best fit */
714 u32 rate; /* actual numeric value for the layer best fit */
716 struct bitrate_approximation {
717 u32 target; /* numeric value of the rate we want */
718 struct bitrate_bits layer[2];
720 static struct bitrate_approximation mpeg_audio_bitrates[] = {
721 /* target layer[0].bits layer[0].rate layer[1].bits layer[1].rate */
722 { 0, { { 0, 0, }, { 0, 0, }, }, },
723 { 32, { { BLACKBIRD_AUDIO_BITS_LAYER_1_32 , 32, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_32 , 32, }, }, },
724 { 48, { { BLACKBIRD_AUDIO_BITS_LAYER_1_64 , 64, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_48 , 48, }, }, },
725 { 56, { { BLACKBIRD_AUDIO_BITS_LAYER_1_64 , 64, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_56 , 56, }, }, },
726 { 64, { { BLACKBIRD_AUDIO_BITS_LAYER_1_64 , 64, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_64 , 64, }, }, },
727 { 80, { { BLACKBIRD_AUDIO_BITS_LAYER_1_96 , 96, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_80 , 80, }, }, },
728 { 96, { { BLACKBIRD_AUDIO_BITS_LAYER_1_96 , 96, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_96 , 96, }, }, },
729 { 112, { { BLACKBIRD_AUDIO_BITS_LAYER_1_128, 128, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_112, 112, }, }, },
730 { 128, { { BLACKBIRD_AUDIO_BITS_LAYER_1_128, 128, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_128, 128, }, }, },
731 { 160, { { BLACKBIRD_AUDIO_BITS_LAYER_1_160, 160, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_160, 160, }, }, },
732 { 192, { { BLACKBIRD_AUDIO_BITS_LAYER_1_192, 192, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_192, 192, }, }, },
733 { 224, { { BLACKBIRD_AUDIO_BITS_LAYER_1_224, 224, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_224, 224, }, }, },
734 { 256, { { BLACKBIRD_AUDIO_BITS_LAYER_1_256, 256, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_256, 256, }, }, },
735 { 288, { { BLACKBIRD_AUDIO_BITS_LAYER_1_288, 288, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_320, 320, }, }, },
736 { 320, { { BLACKBIRD_AUDIO_BITS_LAYER_1_320, 320, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_320, 320, }, }, },
737 { 352, { { BLACKBIRD_AUDIO_BITS_LAYER_1_352, 352, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, },
738 { 384, { { BLACKBIRD_AUDIO_BITS_LAYER_1_384, 384, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, },
739 { 416, { { BLACKBIRD_AUDIO_BITS_LAYER_1_416, 416, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, },
740 { 448, { { BLACKBIRD_AUDIO_BITS_LAYER_1_448, 448, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, },
742 static const int BITRATES_SIZE = ARRAY_SIZE(mpeg_audio_bitrates);
744 static void blackbird_set_default_params(struct cx8802_dev *dev)
746 struct v4l2_mpeg_compression *params = &dev->params;
749 /* assign stream type */
750 if( params->st_type >= ARRAY_SIZE(mpeg_stream_types) )
751 params->st_type = V4L2_MPEG_PS_2;
752 if( params->st_type == V4L2_MPEG_SS_1 )
753 params->vi_type = V4L2_MPEG_VI_1;
755 params->vi_type = V4L2_MPEG_VI_2;
756 blackbird_api_cmd(dev, CX2341X_ENC_SET_STREAM_TYPE, 1, 0, mpeg_stream_types[params->st_type]);
758 /* assign framerate */
759 if( params->vi_frame_rate <= 25 )
761 params->vi_frame_rate = 25;
762 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_RATE, 1, 0, BLACKBIRD_FRAMERATE_PAL_25);
766 params->vi_frame_rate = 30;
767 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_RATE, 1, 0, BLACKBIRD_FRAMERATE_NTSC_30);
770 /* assign aspect ratio */
771 if( params->vi_aspect_ratio >= ARRAY_SIZE(mpeg_stream_ratios) )
772 params->vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3;
773 blackbird_api_cmd(dev, CX2341X_ENC_SET_ASPECT_RATIO, 1, 0, mpeg_stream_ratios[params->vi_aspect_ratio]);
775 /* assign gop properties */
776 blackbird_api_cmd(dev, CX2341X_ENC_SET_GOP_PROPERTIES, 2, 0, params->vi_frames_per_gop, params->vi_bframes_count+1);
778 /* assign gop closure */
779 blackbird_api_cmd(dev, CX2341X_ENC_SET_GOP_CLOSURE, 1, 0, params->closed_gops);
781 /* assign 3 2 pulldown */
782 blackbird_api_cmd(dev, CX2341X_ENC_SET_3_2_PULLDOWN, 1, 0, params->pulldown);
784 /* make sure the params are within bounds */
785 if( params->st_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
786 params->vi_bitrate.mode = V4L2_BITRATE_NONE;
787 if( params->vi_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
788 params->vi_bitrate.mode = V4L2_BITRATE_NONE;
789 if( params->au_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
790 params->au_bitrate.mode = V4L2_BITRATE_NONE;
792 /* assign audio properties */
793 /* note: it's not necessary to set the samplerate, the mpeg encoder seems to autodetect/adjust */
794 au_params = BLACKBIRD_AUDIO_BITS_STEREO |
795 /* BLACKBIRD_AUDIO_BITS_BOUND_4 | */
796 BLACKBIRD_AUDIO_BITS_EMPHASIS_NONE |
797 BLACKBIRD_AUDIO_BITS_CRC_OFF |
798 BLACKBIRD_AUDIO_BITS_COPYRIGHT_OFF |
799 BLACKBIRD_AUDIO_BITS_COPY |
801 if( params->au_sample_rate <= 32000 )
803 params->au_sample_rate = 32000;
804 au_params |= BLACKBIRD_AUDIO_BITS_32000HZ;
806 else if( params->au_sample_rate <= 44100 )
808 params->au_sample_rate = 44100;
809 au_params |= BLACKBIRD_AUDIO_BITS_44100HZ;
813 params->au_sample_rate = 48000;
814 au_params |= BLACKBIRD_AUDIO_BITS_48000HZ;
816 if( params->au_type == V4L2_MPEG_AU_2_I )
818 au_params |= BLACKBIRD_AUDIO_BITS_LAYER_1;
822 /* TODO: try to handle the other formats more gracefully */
823 params->au_type = V4L2_MPEG_AU_2_II;
824 au_params |= BLACKBIRD_AUDIO_BITS_LAYER_2;
826 if( params->au_bitrate.mode )
830 if( params->au_bitrate.mode == V4L2_BITRATE_CBR )
831 params->au_bitrate.max = params->vi_bitrate.target;
833 params->au_bitrate.target = params->vi_bitrate.max;
835 layer = params->au_type;
836 if( params->au_bitrate.target == 0 )
838 /* TODO: use the minimum possible bitrate instead of 0 ? */
841 else if( params->au_bitrate.target >=
842 mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate )
844 /* clamp the bitrate to the max supported by the standard */
845 params->au_bitrate.target = mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate;
846 params->au_bitrate.max = params->au_bitrate.target;
847 au_params |= mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].bits;
851 /* round up to the nearest supported bitrate */
853 for(i = 1; i < BITRATES_SIZE; i++)
855 if( params->au_bitrate.target > mpeg_audio_bitrates[i-1].layer[layer].rate &&
856 params->au_bitrate.target <= mpeg_audio_bitrates[i].layer[layer].rate )
858 params->au_bitrate.target = mpeg_audio_bitrates[i].layer[layer].rate;
859 params->au_bitrate.max = params->au_bitrate.target;
860 au_params |= mpeg_audio_bitrates[i].layer[layer].bits;
869 params->au_bitrate.target = params->au_bitrate.max = 0;
872 blackbird_api_cmd(dev, CX2341X_ENC_SET_AUDIO_PROPERTIES, 1, 0, au_params );
874 /* assign bitrates */
875 if( params->vi_bitrate.mode )
877 /* bitrate is set, let's figure out the cbr/vbr mess */
878 if( params->vi_bitrate.max < params->vi_bitrate.target )
880 if( params->vi_bitrate.mode == V4L2_BITRATE_CBR )
881 params->vi_bitrate.max = params->vi_bitrate.target;
883 params->vi_bitrate.target = params->vi_bitrate.max;
888 if( params->st_bitrate.max < params->st_bitrate.target )
890 if( params->st_bitrate.mode == V4L2_BITRATE_VBR )
891 params->st_bitrate.target = params->st_bitrate.max;
893 params->st_bitrate.max = params->st_bitrate.target;
895 /* calculate vi_bitrate = st_bitrate - au_bitrate */
896 params->vi_bitrate.max = params->st_bitrate.max - params->au_bitrate.max;
897 params->vi_bitrate.target = params->st_bitrate.target - params->au_bitrate.target;
899 blackbird_api_cmd(dev, CX2341X_ENC_SET_BIT_RATE, 4, 0,
900 mpeg_video_bitrates[params->vi_bitrate.mode],
901 params->vi_bitrate.target * 1000, /* kbps -> bps */
902 params->vi_bitrate.max * 1000 / BLACKBIRD_PEAK_RATE_DIVISOR, /* peak/400 */
903 BLACKBIRD_MUX_RATE_DEFAULT /*, 0x70*/); /* encoding buffer, ckennedy */
905 /* TODO: implement the stream ID stuff:
906 ts_pid_pmt, ts_pid_audio, ts_pid_video, ts_pid_pcr,
907 ps_size, au_pesid, vi_pesid
910 #define CHECK_PARAM( name ) ( dev->params.name != params->name )
911 #define IF_PARAM( name ) if( CHECK_PARAM( name ) )
912 #define UPDATE_PARAM( name ) dev->params.name = params->name
913 void blackbird_set_params(struct cx8802_dev *dev, struct v4l2_mpeg_compression *params)
917 /* assign stream type */
918 if( params->st_type >= ARRAY_SIZE(mpeg_stream_types) )
919 params->st_type = V4L2_MPEG_PS_2;
920 if( params->st_type == V4L2_MPEG_SS_1 )
921 params->vi_type = V4L2_MPEG_VI_1;
923 params->vi_type = V4L2_MPEG_VI_2;
924 if( CHECK_PARAM( st_type ) || CHECK_PARAM( vi_type ) )
926 UPDATE_PARAM( st_type );
927 UPDATE_PARAM( vi_type );
928 blackbird_api_cmd(dev, CX2341X_ENC_SET_STREAM_TYPE, 1, 0, mpeg_stream_types[params->st_type]);
931 /* assign framerate */
932 if( params->vi_frame_rate <= 25 )
933 params->vi_frame_rate = 25;
935 params->vi_frame_rate = 30;
936 IF_PARAM( vi_frame_rate )
938 UPDATE_PARAM( vi_frame_rate );
939 if( params->vi_frame_rate == 25 )
940 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_RATE, 1, 0, BLACKBIRD_FRAMERATE_PAL_25);
942 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_RATE, 1, 0, BLACKBIRD_FRAMERATE_NTSC_30);
945 /* assign aspect ratio */
946 if( params->vi_aspect_ratio >= ARRAY_SIZE(mpeg_stream_ratios) )
947 params->vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3;
948 IF_PARAM( vi_aspect_ratio )
950 UPDATE_PARAM( vi_aspect_ratio );
951 blackbird_api_cmd(dev, CX2341X_ENC_SET_ASPECT_RATIO, 1, 0, mpeg_stream_ratios[params->vi_aspect_ratio]);
954 /* assign gop properties */
955 if( CHECK_PARAM( vi_frames_per_gop ) || CHECK_PARAM( vi_bframes_count ) )
957 UPDATE_PARAM( vi_frames_per_gop );
958 UPDATE_PARAM( vi_bframes_count );
959 blackbird_api_cmd(dev, CX2341X_ENC_SET_GOP_PROPERTIES, 2, 0, params->vi_frames_per_gop, params->vi_bframes_count+1);
962 /* assign gop closure */
963 IF_PARAM( closed_gops )
965 UPDATE_PARAM( closed_gops );
966 blackbird_api_cmd(dev, CX2341X_ENC_SET_GOP_CLOSURE, 1, 0, params->closed_gops);
969 /* assign 3 2 pulldown */
972 UPDATE_PARAM( pulldown );
973 blackbird_api_cmd(dev, CX2341X_ENC_SET_3_2_PULLDOWN, 1, 0, params->pulldown);
976 /* make sure the params are within bounds */
977 if( params->st_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
978 params->vi_bitrate.mode = V4L2_BITRATE_NONE;
979 if( params->vi_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
980 params->vi_bitrate.mode = V4L2_BITRATE_NONE;
981 if( params->au_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
982 params->au_bitrate.mode = V4L2_BITRATE_NONE;
984 /* assign audio properties */
985 /* note: it's not necessary to set the samplerate, the mpeg encoder seems to autodetect/adjust */
986 au_params = BLACKBIRD_AUDIO_BITS_STEREO |
987 /* BLACKBIRD_AUDIO_BITS_BOUND_4 | */
988 BLACKBIRD_AUDIO_BITS_EMPHASIS_NONE |
989 BLACKBIRD_AUDIO_BITS_CRC_OFF |
990 BLACKBIRD_AUDIO_BITS_COPYRIGHT_OFF |
991 BLACKBIRD_AUDIO_BITS_COPY |
993 if( params->au_sample_rate < 32000 )
995 params->au_sample_rate = 32000;
996 au_params |= BLACKBIRD_AUDIO_BITS_32000HZ;
998 else if( params->au_sample_rate < 44100 )
1000 params->au_sample_rate = 44100;
1001 au_params |= BLACKBIRD_AUDIO_BITS_44100HZ;
1005 params->au_sample_rate = 48000;
1006 au_params |= BLACKBIRD_AUDIO_BITS_48000HZ;
1008 if( params->au_type == V4L2_MPEG_AU_2_I )
1010 au_params |= BLACKBIRD_AUDIO_BITS_LAYER_1;
1014 /* TODO: try to handle the other formats more gracefully */
1015 params->au_type = V4L2_MPEG_AU_2_II;
1016 au_params |= BLACKBIRD_AUDIO_BITS_LAYER_2;
1018 if( params->au_bitrate.mode )
1022 if( params->au_bitrate.mode == V4L2_BITRATE_CBR )
1023 params->au_bitrate.max = params->vi_bitrate.target;
1025 params->au_bitrate.target = params->vi_bitrate.max;
1027 layer = params->au_type;
1028 if( params->au_bitrate.target == 0 )
1030 /* TODO: use the minimum possible bitrate instead of 0 ? */
1033 else if( params->au_bitrate.target >=
1034 mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate )
1036 /* clamp the bitrate to the max supported by the standard */
1037 params->au_bitrate.target = mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate;
1038 params->au_bitrate.max = params->au_bitrate.target;
1039 au_params |= mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].bits;
1043 /* round up to the nearest supported bitrate */
1045 for(i = 1; i < BITRATES_SIZE; i++)
1047 if( params->au_bitrate.target > mpeg_audio_bitrates[i-1].layer[layer].rate &&
1048 params->au_bitrate.target <= mpeg_audio_bitrates[i].layer[layer].rate )
1050 params->au_bitrate.target = mpeg_audio_bitrates[i].layer[layer].rate;
1051 params->au_bitrate.max = params->au_bitrate.target;
1052 au_params |= mpeg_audio_bitrates[i].layer[layer].bits;
1061 params->au_bitrate.target = params->au_bitrate.max = 0;
1064 if( CHECK_PARAM( au_type ) || CHECK_PARAM( au_sample_rate )
1065 || CHECK_PARAM( au_bitrate.mode ) || CHECK_PARAM( au_bitrate.max )
1066 || CHECK_PARAM( au_bitrate.target )
1069 UPDATE_PARAM( au_type );
1070 UPDATE_PARAM( au_sample_rate );
1071 UPDATE_PARAM( au_bitrate );
1072 blackbird_api_cmd(dev, CX2341X_ENC_SET_AUDIO_PROPERTIES, 1, 0, au_params );
1075 /* assign bitrates */
1076 if( params->vi_bitrate.mode )
1078 /* bitrate is set, let's figure out the cbr/vbr mess */
1079 if( params->vi_bitrate.max < params->vi_bitrate.target )
1081 if( params->vi_bitrate.mode == V4L2_BITRATE_CBR )
1082 params->vi_bitrate.max = params->vi_bitrate.target;
1084 params->vi_bitrate.target = params->vi_bitrate.max;
1089 if( params->st_bitrate.max < params->st_bitrate.target )
1091 if( params->st_bitrate.mode == V4L2_BITRATE_VBR )
1092 params->st_bitrate.target = params->st_bitrate.max;
1094 params->st_bitrate.max = params->st_bitrate.target;
1096 /* calculate vi_bitrate = st_bitrate - au_bitrate */
1097 params->vi_bitrate.max = params->st_bitrate.max - params->au_bitrate.max;
1098 params->vi_bitrate.target = params->st_bitrate.target - params->au_bitrate.target;
1100 UPDATE_PARAM( st_bitrate );
1101 if( CHECK_PARAM( vi_bitrate.mode ) || CHECK_PARAM( vi_bitrate.max )
1102 || CHECK_PARAM( vi_bitrate.target )
1105 UPDATE_PARAM( vi_bitrate );
1106 blackbird_api_cmd(dev, CX2341X_ENC_SET_BIT_RATE, 4, 0,
1107 mpeg_video_bitrates[params->vi_bitrate.mode],
1108 params->vi_bitrate.target * 1000, /* kbps -> bps */
1109 params->vi_bitrate.max * 1000 / BLACKBIRD_PEAK_RATE_DIVISOR, /* peak/400 */
1110 BLACKBIRD_MUX_RATE_DEFAULT /*, 0x70*/); /* encoding buffer, ckennedy */
1113 /* TODO: implement the stream ID stuff:
1114 ts_pid_pmt, ts_pid_audio, ts_pid_video, ts_pid_pcr,
1115 ps_size, au_pesid, vi_pesid
1117 UPDATE_PARAM( ts_pid_pmt );
1118 UPDATE_PARAM( ts_pid_audio );
1119 UPDATE_PARAM( ts_pid_video );
1120 UPDATE_PARAM( ts_pid_pcr );
1121 UPDATE_PARAM( ps_size );
1122 UPDATE_PARAM( au_pesid );
1123 UPDATE_PARAM( vi_pesid );
1126 static void blackbird_set_default_dnr_params(struct cx8802_dev *dev)
1128 /* assign dnr filter mode */
1129 if( dev->dnr_params.mode > BLACKBIRD_DNR_BITS_AUTO )
1130 dev->dnr_params.mode = BLACKBIRD_DNR_BITS_MANUAL;
1131 if( dev->dnr_params.type > BLACKBIRD_MEDIAN_FILTER_DIAGONAL )
1132 dev->dnr_params.type = BLACKBIRD_MEDIAN_FILTER_DISABLED;
1133 blackbird_api_cmd(dev, CX2341X_ENC_SET_DNR_FILTER_MODE, 2, 0,
1134 dev->dnr_params.mode,
1135 dev->dnr_params.type
1138 /* assign dnr filter props*/
1139 if( dev->dnr_params.spatial > 15 )
1140 dev->dnr_params.spatial = 15;
1141 if( dev->dnr_params.temporal > 31 )
1142 dev->dnr_params.temporal = 31;
1143 blackbird_api_cmd(dev, CX2341X_ENC_SET_DNR_FILTER_PROPS, 2, 0,
1144 dev->dnr_params.spatial,
1145 dev->dnr_params.temporal
1148 #define CHECK_DNR_PARAM( name ) ( dev->dnr_params.name != dnr_params->name )
1149 #define UPDATE_DNR_PARAM( name ) dev->dnr_params.name = dnr_params->name
1150 void blackbird_set_dnr_params(struct cx8802_dev *dev, struct blackbird_dnr* dnr_params)
1152 /* assign dnr filter mode */
1154 if( dnr_params->mode > BLACKBIRD_DNR_BITS_AUTO )
1155 dnr_params->mode = BLACKBIRD_DNR_BITS_MANUAL;
1156 if( dnr_params->type > BLACKBIRD_MEDIAN_FILTER_DIAGONAL )
1157 dnr_params->type = BLACKBIRD_MEDIAN_FILTER_DISABLED;
1158 /* check if the params actually changed */
1159 if( CHECK_DNR_PARAM( mode ) || CHECK_DNR_PARAM( type ) )
1161 UPDATE_DNR_PARAM( mode );
1162 UPDATE_DNR_PARAM( type );
1163 blackbird_api_cmd(dev, CX2341X_ENC_SET_DNR_FILTER_MODE, 2, 0, dnr_params->mode, dnr_params->type);
1166 /* assign dnr filter props*/
1167 if( dnr_params->spatial > 15 )
1168 dnr_params->spatial = 15;
1169 if( dnr_params->temporal > 31 )
1170 dnr_params->temporal = 31;
1171 if( CHECK_DNR_PARAM( spatial ) || CHECK_DNR_PARAM( temporal ) )
1173 UPDATE_DNR_PARAM( spatial );
1174 UPDATE_DNR_PARAM( temporal );
1175 blackbird_api_cmd(dev, CX2341X_ENC_SET_DNR_FILTER_PROPS, 2, 0, dnr_params->spatial, dnr_params->temporal);
1179 static void blackbird_codec_settings(struct cx8802_dev *dev)
1182 /* assign output port */
1183 blackbird_api_cmd(dev, CX2341X_ENC_SET_OUTPUT_PORT, 1, 0, BLACKBIRD_OUTPUT_PORT_STREAMING); /* Host */
1185 /* assign frame size */
1186 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0,
1187 dev->height, dev->width);
1189 /* assign coring levels (luma_h, luma_l, chroma_h, chroma_l) */
1190 blackbird_api_cmd(dev, CX2341X_ENC_SET_CORING_LEVELS, 4, 0, 0, 255, 0, 255);
1192 /* assign spatial filter type: luma_t: horiz_only, chroma_t: horiz_only */
1193 blackbird_api_cmd(dev, CX2341X_ENC_SET_SPATIAL_FILTER_TYPE, 2, 0,
1194 BLACKBIRD_SPATIAL_FILTER_LUMA_1D_HORIZ,
1195 BLACKBIRD_SPATIAL_FILTER_CHROMA_1D_HORIZ
1198 /* assign frame drop rate */
1199 /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAME_DROP_RATE, 1, 0, 0); */
1201 blackbird_set_default_params(dev);
1202 blackbird_set_default_dnr_params(dev);
1205 static int blackbird_initialize_codec(struct cx8802_dev *dev)
1207 struct cx88_core *core = dev->core;
1211 dprintk(1,"Initialize codec\n");
1212 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */
1214 /* ping was not successful, reset and upload firmware */
1215 cx_write(MO_SRST_IO, 0); /* SYS_RSTO=0 */
1217 cx_write(MO_SRST_IO, 1); /* SYS_RSTO=1 */
1219 retval = blackbird_load_firmware(dev);
1223 dev->mailbox = blackbird_find_mailbox(dev);
1224 if (dev->mailbox < 0)
1227 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */
1229 dprintk(0, "ERROR: Firmware ping failed!\n");
1233 retval = blackbird_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, &version);
1235 dprintk(0, "ERROR: Firmware get encoder version failed!\n");
1238 dprintk(0, "Firmware version is 0x%08x\n", version);
1242 cx_write(MO_PINMUX_IO, 0x88); /* 656-8bit IO and enable MPEG parallel IO */
1243 cx_clear(MO_INPUT_FORMAT, 0x100); /* chroma subcarrier lock to normal? */
1244 cx_write(MO_VBOS_CONTROL, 0x84A00); /* no 656 mode, 8-bit pixels, disable VBI */
1245 cx_clear(MO_OUTPUT_FORMAT, 0x0008); /* Normal Y-limits to let the mpeg encoder sync */
1247 blackbird_codec_settings(dev);
1250 /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0xef, 0xef);
1251 blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0xf0, 0xf0);
1252 blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0x180, 0x180); */
1253 blackbird_api_cmd(dev, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 0,
1254 BLACKBIRD_FIELD1_SAA7115,
1255 BLACKBIRD_FIELD2_SAA7115
1258 /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_PLACEHOLDER, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); */
1259 blackbird_api_cmd(dev, CX2341X_ENC_SET_PLACEHOLDER, 12, 0,
1260 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,
1261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1263 /* initialize the video input */
1264 blackbird_api_cmd(dev, CX2341X_ENC_INITIALIZE_INPUT, 0, 0);
1268 blackbird_api_cmd(dev, CX2341X_ENC_MUTE_VIDEO, 1, 0, BLACKBIRD_UNMUTE);
1270 blackbird_api_cmd(dev, CX2341X_ENC_MUTE_AUDIO, 1, 0, BLACKBIRD_UNMUTE);
1273 /* start capturing to the host interface */
1274 /* blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0, 0, 0x13); */
1275 blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0,
1276 BLACKBIRD_MPEG_CAPTURE,
1277 BLACKBIRD_RAW_BITS_NONE
1281 blackbird_api_cmd(dev, CX2341X_ENC_REFRESH_INPUT, 0,0);
1285 /* ------------------------------------------------------------------ */
1287 static int bb_buf_setup(struct videobuf_queue *q,
1288 unsigned int *count, unsigned int *size)
1290 struct cx8802_fh *fh = q->priv_data;
1292 fh->dev->ts_packet_size = 188 * 4; /* was: 512 */
1293 fh->dev->ts_packet_count = mpegbufs; /* was: 100 */
1295 *size = fh->dev->ts_packet_size * fh->dev->ts_packet_count;
1296 *count = fh->dev->ts_packet_count;
1301 bb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
1302 enum v4l2_field field)
1304 struct cx8802_fh *fh = q->priv_data;
1305 return cx8802_buf_prepare(q, fh->dev, (struct cx88_buffer*)vb, field);
1309 bb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
1311 struct cx8802_fh *fh = q->priv_data;
1312 cx8802_buf_queue(fh->dev, (struct cx88_buffer*)vb);
1316 bb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1318 cx88_free_buffer(q, (struct cx88_buffer*)vb);
1321 static struct videobuf_queue_ops blackbird_qops = {
1322 .buf_setup = bb_buf_setup,
1323 .buf_prepare = bb_buf_prepare,
1324 .buf_queue = bb_buf_queue,
1325 .buf_release = bb_buf_release,
1328 /* ------------------------------------------------------------------ */
1330 static int mpeg_do_ioctl(struct inode *inode, struct file *file,
1331 unsigned int cmd, void *arg)
1333 struct cx8802_fh *fh = file->private_data;
1334 struct cx8802_dev *dev = fh->dev;
1335 struct cx88_core *core = dev->core;
1338 v4l_print_ioctl(core->name,cmd);
1342 /* --- capabilities ------------------------------------------ */
1343 case VIDIOC_QUERYCAP:
1345 struct v4l2_capability *cap = arg;
1347 memset(cap,0,sizeof(*cap));
1348 strcpy(cap->driver, "cx88_blackbird");
1349 strlcpy(cap->card, cx88_boards[core->board].name,sizeof(cap->card));
1350 sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));
1351 cap->version = CX88_VERSION_CODE;
1353 V4L2_CAP_VIDEO_CAPTURE |
1354 V4L2_CAP_READWRITE |
1355 V4L2_CAP_STREAMING |
1357 if (UNSET != core->tuner_type)
1358 cap->capabilities |= V4L2_CAP_TUNER;
1363 /* --- capture ioctls ---------------------------------------- */
1364 case VIDIOC_ENUM_FMT:
1366 struct v4l2_fmtdesc *f = arg;
1373 memset(f,0,sizeof(*f));
1375 strlcpy(f->description, "MPEG", sizeof(f->description));
1376 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1377 f->pixelformat = V4L2_PIX_FMT_MPEG;
1382 struct v4l2_format *f = arg;
1384 memset(f,0,sizeof(*f));
1385 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1386 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1387 f->fmt.pix.bytesperline = 0;
1388 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */
1389 f->fmt.pix.colorspace = 0;
1390 f->fmt.pix.width = dev->width;
1391 f->fmt.pix.height = dev->height;
1392 f->fmt.pix.field = fh->mpegq.field;
1393 dprintk(0,"VIDIOC_G_FMT: w: %d, h: %d, f: %d\n",
1394 dev->width, dev->height, fh->mpegq.field );
1397 case VIDIOC_TRY_FMT:
1399 struct v4l2_format *f = arg;
1401 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1402 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1403 f->fmt.pix.bytesperline = 0;
1404 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */;
1405 f->fmt.pix.colorspace = 0;
1406 dprintk(0,"VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",
1407 dev->width, dev->height, fh->mpegq.field );
1412 struct v4l2_format *f = arg;
1414 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1415 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1416 f->fmt.pix.bytesperline = 0;
1417 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */;
1418 f->fmt.pix.colorspace = 0;
1419 dprintk(0,"VIDIOC_S_FMT: w: %d, h: %d, f: %d\n",
1420 f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field );
1424 /* --- streaming capture ------------------------------------- */
1425 case VIDIOC_REQBUFS:
1426 return videobuf_reqbufs(&fh->mpegq, arg);
1428 case VIDIOC_QUERYBUF:
1429 return videobuf_querybuf(&fh->mpegq, arg);
1432 return videobuf_qbuf(&fh->mpegq, arg);
1435 return videobuf_dqbuf(&fh->mpegq, arg,
1436 file->f_flags & O_NONBLOCK);
1438 case VIDIOC_STREAMON:
1439 return videobuf_streamon(&fh->mpegq);
1441 case VIDIOC_STREAMOFF:
1442 return videobuf_streamoff(&fh->mpegq);
1444 /* --- mpeg compression -------------------------------------- */
1445 case VIDIOC_G_MPEGCOMP:
1447 struct v4l2_mpeg_compression *f = arg;
1449 memcpy(f,&dev->params,sizeof(*f));
1452 case VIDIOC_S_MPEGCOMP:
1454 struct v4l2_mpeg_compression *f = arg;
1456 blackbird_set_params(dev, f);
1461 return cx88_do_ioctl( inode, file, 0, dev->core, cmd, arg, cx88_ioctl_hook );
1466 int (*cx88_ioctl_hook)(struct inode *inode, struct file *file,
1467 unsigned int cmd, void *arg);
1468 unsigned int (*cx88_ioctl_translator)(unsigned int cmd);
1470 static unsigned int mpeg_translate_ioctl(unsigned int cmd)
1475 static int mpeg_ioctl(struct inode *inode, struct file *file,
1476 unsigned int cmd, unsigned long arg)
1478 cmd = cx88_ioctl_translator( cmd );
1479 return video_usercopy(inode, file, cmd, arg, cx88_ioctl_hook);
1482 static int mpeg_open(struct inode *inode, struct file *file)
1484 int minor = iminor(inode);
1485 struct cx8802_dev *h,*dev = NULL;
1486 struct cx8802_fh *fh;
1487 struct list_head *list;
1489 list_for_each(list,&cx8802_devlist) {
1490 h = list_entry(list, struct cx8802_dev, devlist);
1491 if (h->mpeg_dev->minor == minor)
1497 if (blackbird_initialize_codec(dev) < 0)
1499 dprintk(1,"open minor=%d\n",minor);
1501 /* allocate + initialize per filehandle data */
1502 fh = kzalloc(sizeof(*fh),GFP_KERNEL);
1505 file->private_data = fh;
1508 videobuf_queue_init(&fh->mpegq, &blackbird_qops,
1509 dev->pci, &dev->slock,
1510 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1511 V4L2_FIELD_INTERLACED,
1512 sizeof(struct cx88_buffer),
1515 /* FIXME: locking against other video device */
1516 cx88_set_scale(dev->core, dev->width, dev->height,
1522 static int mpeg_release(struct inode *inode, struct file *file)
1524 struct cx8802_fh *fh = file->private_data;
1526 /* blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, BLACKBIRD_END_NOW, 0, 0x13); */
1527 blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
1529 BLACKBIRD_MPEG_CAPTURE,
1530 BLACKBIRD_RAW_BITS_NONE
1533 cx8802_cancel_buffers(fh->dev);
1534 /* stop mpeg capture */
1535 if (fh->mpegq.streaming)
1536 videobuf_streamoff(&fh->mpegq);
1537 if (fh->mpegq.reading)
1538 videobuf_read_stop(&fh->mpegq);
1540 videobuf_mmap_free(&fh->mpegq);
1541 file->private_data = NULL;
1547 mpeg_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
1549 struct cx8802_fh *fh = file->private_data;
1551 return videobuf_read_stream(&fh->mpegq, data, count, ppos, 0,
1552 file->f_flags & O_NONBLOCK);
1556 mpeg_poll(struct file *file, struct poll_table_struct *wait)
1558 struct cx8802_fh *fh = file->private_data;
1560 return videobuf_poll_stream(file, &fh->mpegq, wait);
1564 mpeg_mmap(struct file *file, struct vm_area_struct * vma)
1566 struct cx8802_fh *fh = file->private_data;
1568 return videobuf_mmap_mapper(&fh->mpegq, vma);
1571 static struct file_operations mpeg_fops =
1573 .owner = THIS_MODULE,
1575 .release = mpeg_release,
1579 .ioctl = mpeg_ioctl,
1580 .llseek = no_llseek,
1583 static struct video_device cx8802_mpeg_template =
1586 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES|VID_TYPE_MPEG_ENCODER,
1592 /* ------------------------------------------------------------------ */
1594 static void blackbird_unregister_video(struct cx8802_dev *dev)
1596 if (dev->mpeg_dev) {
1597 if (-1 != dev->mpeg_dev->minor)
1598 video_unregister_device(dev->mpeg_dev);
1600 video_device_release(dev->mpeg_dev);
1601 dev->mpeg_dev = NULL;
1605 static int blackbird_register_video(struct cx8802_dev *dev)
1609 dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci,
1610 &cx8802_mpeg_template,"mpeg");
1611 err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1);
1613 printk(KERN_INFO "%s/2: can't register mpeg device\n",
1617 printk(KERN_INFO "%s/2: registered device video%d [mpeg]\n",
1618 dev->core->name,dev->mpeg_dev->minor & 0x1f);
1622 /* ----------------------------------------------------------- */
1624 static int __devinit blackbird_probe(struct pci_dev *pci_dev,
1625 const struct pci_device_id *pci_id)
1627 struct cx8802_dev *dev;
1628 struct cx88_core *core;
1632 core = cx88_core_get(pci_dev);
1637 if (!cx88_boards[core->board].blackbird)
1641 dev = kzalloc(sizeof(*dev),GFP_KERNEL);
1648 memcpy(&dev->params,&default_mpeg_params,sizeof(default_mpeg_params));
1649 memcpy(&dev->dnr_params,&default_dnr_params,sizeof(default_dnr_params));
1651 switch (core->board) {
1652 case CX88_BOARD_HAUPPAUGE_ROSLYN:
1653 if (core->tuner_formats & V4L2_STD_525_60) {
1655 dev->params.vi_frame_rate = 30;
1658 dev->params.vi_frame_rate = 25;
1661 case CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT:
1662 if (core->tvnorm->id & V4L2_STD_525_60) {
1664 dev->params.vi_frame_rate = 30;
1667 dev->params.vi_frame_rate = 25;
1672 err = cx8802_init_common(dev);
1676 /* blackbird stuff */
1677 printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n",
1679 host_setup(dev->core);
1681 list_add_tail(&dev->devlist,&cx8802_devlist);
1682 blackbird_register_video(dev);
1684 /* initial device configuration: needed ? */
1691 cx88_core_put(core,pci_dev);
1695 static void __devexit blackbird_remove(struct pci_dev *pci_dev)
1697 struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
1700 blackbird_unregister_video(dev);
1701 list_del(&dev->devlist);
1704 cx8802_fini_common(dev);
1705 cx88_core_put(dev->core,dev->pci);
1709 static struct pci_device_id cx8802_pci_tbl[] = {
1713 .subvendor = PCI_ANY_ID,
1714 .subdevice = PCI_ANY_ID,
1716 /* --- end of list --- */
1719 MODULE_DEVICE_TABLE(pci, cx8802_pci_tbl);
1721 static struct pci_driver blackbird_pci_driver = {
1722 .name = "cx88-blackbird",
1723 .id_table = cx8802_pci_tbl,
1724 .probe = blackbird_probe,
1725 .remove = __devexit_p(blackbird_remove),
1726 .suspend = cx8802_suspend_common,
1727 .resume = cx8802_resume_common,
1730 static int blackbird_init(void)
1732 printk(KERN_INFO "cx2388x blackbird driver version %d.%d.%d loaded\n",
1733 (CX88_VERSION_CODE >> 16) & 0xff,
1734 (CX88_VERSION_CODE >> 8) & 0xff,
1735 CX88_VERSION_CODE & 0xff);
1737 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1738 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1740 cx88_ioctl_hook = mpeg_do_ioctl;
1741 cx88_ioctl_translator = mpeg_translate_ioctl;
1742 return pci_register_driver(&blackbird_pci_driver);
1745 static void blackbird_fini(void)
1747 pci_unregister_driver(&blackbird_pci_driver);
1750 module_init(blackbird_init);
1751 module_exit(blackbird_fini);
1753 EXPORT_SYMBOL(cx88_ioctl_hook);
1754 EXPORT_SYMBOL(cx88_ioctl_translator);
1755 EXPORT_SYMBOL(blackbird_set_params);
1756 EXPORT_SYMBOL(blackbird_set_dnr_params);
1758 /* ----------------------------------------------------------- */
1763 * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off