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)
54 /* ------------------------------------------------------------------ */
64 static struct cx88_tvnorm tvnorms[] = {
67 .id = V4L2_STD_NTSC_M,
68 .cxiformat = VideoFormatNTSC,
69 .cxoformat = 0x181f0008,
72 .id = V4L2_STD_NTSC_M_JP,
73 .cxiformat = VideoFormatNTSCJapan,
74 .cxoformat = 0x181f0008,
77 .id = V4L2_STD_PAL_BG,
78 .cxiformat = VideoFormatPAL,
79 .cxoformat = 0x181f0008,
82 .id = V4L2_STD_PAL_DK,
83 .cxiformat = VideoFormatPAL,
84 .cxoformat = 0x181f0008,
88 .cxiformat = VideoFormatPAL,
89 .cxoformat = 0x181f0008,
93 .cxiformat = VideoFormatPALM,
94 .cxoformat = 0x1c1f0008,
98 .cxiformat = VideoFormatPALN,
99 .cxoformat = 0x1c1f0008,
102 .id = V4L2_STD_PAL_Nc,
103 .cxiformat = VideoFormatPALNC,
104 .cxoformat = 0x1c1f0008,
107 .id = V4L2_STD_PAL_60,
108 .cxiformat = VideoFormatPAL60,
109 .cxoformat = 0x181f0008,
112 .id = V4L2_STD_SECAM_L,
113 .cxiformat = VideoFormatSECAM,
114 .cxoformat = 0x181f0008,
117 .id = V4L2_STD_SECAM_DK,
118 .cxiformat = VideoFormatSECAM,
119 .cxoformat = 0x181f0008,
122 int cx88_do_ioctl( struct inode *inode, struct file *file,
123 int radio, struct cx88_core *core, unsigned int cmd,
124 void *arg, v4l2_kioctl driver_ioctl );
126 #define BLACKBIRD_FIRM_IMAGE_SIZE 256*1024
128 /* defines below are from ivtv-driver.h */
130 #define IVTV_CMD_HW_BLOCKS_RST 0xFFFFFFFF
132 /* Firmware API commands */
133 #define IVTV_API_STD_TIMEOUT 500
135 enum blackbird_capture_type {
136 BLACKBIRD_MPEG_CAPTURE,
137 BLACKBIRD_RAW_CAPTURE,
138 BLACKBIRD_RAW_PASSTHRU_CAPTURE
140 enum blackbird_capture_bits {
141 BLACKBIRD_RAW_BITS_NONE = 0x00,
142 BLACKBIRD_RAW_BITS_YUV_CAPTURE = 0x01,
143 BLACKBIRD_RAW_BITS_PCM_CAPTURE = 0x02,
144 BLACKBIRD_RAW_BITS_VBI_CAPTURE = 0x04,
145 BLACKBIRD_RAW_BITS_PASSTHRU_CAPTURE = 0x08,
146 BLACKBIRD_RAW_BITS_TO_HOST_CAPTURE = 0x10
148 enum blackbird_capture_end {
149 BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */
150 BLACKBIRD_END_NOW, /* stop immediately, no irq */
152 enum blackbird_framerate {
153 BLACKBIRD_FRAMERATE_NTSC_30, /* NTSC: 30fps */
154 BLACKBIRD_FRAMERATE_PAL_25 /* PAL: 25fps */
156 enum blackbird_stream_port {
157 BLACKBIRD_OUTPUT_PORT_MEMORY,
158 BLACKBIRD_OUTPUT_PORT_STREAMING,
159 BLACKBIRD_OUTPUT_PORT_SERIAL
161 enum blackbird_data_xfer_status {
162 BLACKBIRD_MORE_BUFFERS_FOLLOW,
163 BLACKBIRD_LAST_BUFFER,
165 enum blackbird_picture_mask {
166 BLACKBIRD_PICTURE_MASK_NONE,
167 BLACKBIRD_PICTURE_MASK_I_FRAMES,
168 BLACKBIRD_PICTURE_MASK_I_P_FRAMES = 0x3,
169 BLACKBIRD_PICTURE_MASK_ALL_FRAMES = 0x7,
171 enum blackbird_vbi_mode_bits {
172 BLACKBIRD_VBI_BITS_SLICED,
173 BLACKBIRD_VBI_BITS_RAW,
175 enum blackbird_vbi_insertion_bits {
176 BLACKBIRD_VBI_BITS_INSERT_IN_XTENSION_USR_DATA,
177 BLACKBIRD_VBI_BITS_INSERT_IN_PRIVATE_PACKETS = 0x1 << 1,
178 BLACKBIRD_VBI_BITS_SEPARATE_STREAM = 0x2 << 1,
179 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1,
180 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1,
182 enum blackbird_dma_unit {
184 BLACKBIRD_DMA_FRAMES,
186 enum blackbird_dma_transfer_status_bits {
187 BLACKBIRD_DMA_TRANSFER_BITS_DONE = 0x01,
188 BLACKBIRD_DMA_TRANSFER_BITS_ERROR = 0x04,
189 BLACKBIRD_DMA_TRANSFER_BITS_LL_ERROR = 0x10,
191 enum blackbird_pause {
192 BLACKBIRD_PAUSE_ENCODING,
193 BLACKBIRD_RESUME_ENCODING,
195 enum blackbird_copyright {
196 BLACKBIRD_COPYRIGHT_OFF,
197 BLACKBIRD_COPYRIGHT_ON,
199 enum blackbird_notification_type {
200 BLACKBIRD_NOTIFICATION_REFRESH,
202 enum blackbird_notification_status {
203 BLACKBIRD_NOTIFICATION_OFF,
204 BLACKBIRD_NOTIFICATION_ON,
206 enum blackbird_notification_mailbox {
207 BLACKBIRD_NOTIFICATION_NO_MAILBOX = -1,
209 enum blackbird_field1_lines {
210 BLACKBIRD_FIELD1_SAA7114 = 0x00EF, /* 239 */
211 BLACKBIRD_FIELD1_SAA7115 = 0x00F0, /* 240 */
212 BLACKBIRD_FIELD1_MICRONAS = 0x0105, /* 261 */
214 enum blackbird_field2_lines {
215 BLACKBIRD_FIELD2_SAA7114 = 0x00EF, /* 239 */
216 BLACKBIRD_FIELD2_SAA7115 = 0x00F0, /* 240 */
217 BLACKBIRD_FIELD2_MICRONAS = 0x0106, /* 262 */
219 enum blackbird_custom_data_type {
220 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,
221 BLACKBIRD_CUSTOM_PRIVATE_PACKET,
223 enum blackbird_mute {
227 enum blackbird_mute_video_mask {
228 BLACKBIRD_MUTE_VIDEO_V_MASK = 0x0000FF00,
229 BLACKBIRD_MUTE_VIDEO_U_MASK = 0x00FF0000,
230 BLACKBIRD_MUTE_VIDEO_Y_MASK = 0xFF000000,
232 enum blackbird_mute_video_shift {
233 BLACKBIRD_MUTE_VIDEO_V_SHIFT = 8,
234 BLACKBIRD_MUTE_VIDEO_U_SHIFT = 16,
235 BLACKBIRD_MUTE_VIDEO_Y_SHIFT = 24,
239 #define IVTV_REG_ENC_SDRAM_REFRESH (0x07F8 /*| IVTV_REG_OFFSET*/)
240 #define IVTV_REG_ENC_SDRAM_PRECHARGE (0x07FC /*| IVTV_REG_OFFSET*/)
241 #define IVTV_REG_SPU (0x9050 /*| IVTV_REG_OFFSET*/)
242 #define IVTV_REG_HW_BLOCKS (0x9054 /*| IVTV_REG_OFFSET*/)
243 #define IVTV_REG_VPU (0x9058 /*| IVTV_REG_OFFSET*/)
244 #define IVTV_REG_APU (0xA064 /*| IVTV_REG_OFFSET*/)
246 /* ------------------------------------------------------------------ */
248 static void host_setup(struct cx88_core *core)
250 /* toggle reset of the host */
251 cx_write(MO_GPHST_SOFT_RST, 1);
253 cx_write(MO_GPHST_SOFT_RST, 0);
256 /* host port setup */
257 cx_write(MO_GPHST_WSC, 0x44444444U);
258 cx_write(MO_GPHST_XFR, 0);
259 cx_write(MO_GPHST_WDTH, 15);
260 cx_write(MO_GPHST_HDSHK, 0);
261 cx_write(MO_GPHST_MUX16, 0x44448888U);
262 cx_write(MO_GPHST_MODE, 0);
265 /* ------------------------------------------------------------------ */
267 #define P1_MDATA0 0x390000
268 #define P1_MDATA1 0x390001
269 #define P1_MDATA2 0x390002
270 #define P1_MDATA3 0x390003
271 #define P1_MADDR2 0x390004
272 #define P1_MADDR1 0x390005
273 #define P1_MADDR0 0x390006
274 #define P1_RDATA0 0x390008
275 #define P1_RDATA1 0x390009
276 #define P1_RDATA2 0x39000A
277 #define P1_RDATA3 0x39000B
278 #define P1_RADDR0 0x39000C
279 #define P1_RADDR1 0x39000D
280 #define P1_RRDWR 0x39000E
282 static int wait_ready_gpio0_bit1(struct cx88_core *core, u32 state)
284 unsigned long timeout = jiffies + msecs_to_jiffies(1);
287 need = state ? 2 : 0;
289 gpio0 = cx_read(MO_GP0_IO) & 2;
292 if (time_after(jiffies,timeout))
298 static int memory_write(struct cx88_core *core, u32 address, u32 value)
300 /* Warning: address is dword address (4 bytes) */
301 cx_writeb(P1_MDATA0, (unsigned int)value);
302 cx_writeb(P1_MDATA1, (unsigned int)(value >> 8));
303 cx_writeb(P1_MDATA2, (unsigned int)(value >> 16));
304 cx_writeb(P1_MDATA3, (unsigned int)(value >> 24));
305 cx_writeb(P1_MADDR2, (unsigned int)(address >> 16) | 0x40);
306 cx_writeb(P1_MADDR1, (unsigned int)(address >> 8));
307 cx_writeb(P1_MADDR0, (unsigned int)address);
311 return wait_ready_gpio0_bit1(core,1);
314 static int memory_read(struct cx88_core *core, u32 address, u32 *value)
319 /* Warning: address is dword address (4 bytes) */
320 cx_writeb(P1_MADDR2, (unsigned int)(address >> 16) & ~0xC0);
321 cx_writeb(P1_MADDR1, (unsigned int)(address >> 8));
322 cx_writeb(P1_MADDR0, (unsigned int)address);
325 retval = wait_ready_gpio0_bit1(core,1);
327 cx_writeb(P1_MDATA3, 0);
328 val = (unsigned char)cx_read(P1_MDATA3) << 24;
329 cx_writeb(P1_MDATA2, 0);
330 val |= (unsigned char)cx_read(P1_MDATA2) << 16;
331 cx_writeb(P1_MDATA1, 0);
332 val |= (unsigned char)cx_read(P1_MDATA1) << 8;
333 cx_writeb(P1_MDATA0, 0);
334 val |= (unsigned char)cx_read(P1_MDATA0);
340 static int register_write(struct cx88_core *core, u32 address, u32 value)
342 cx_writeb(P1_RDATA0, (unsigned int)value);
343 cx_writeb(P1_RDATA1, (unsigned int)(value >> 8));
344 cx_writeb(P1_RDATA2, (unsigned int)(value >> 16));
345 cx_writeb(P1_RDATA3, (unsigned int)(value >> 24));
346 cx_writeb(P1_RADDR0, (unsigned int)address);
347 cx_writeb(P1_RADDR1, (unsigned int)(address >> 8));
348 cx_writeb(P1_RRDWR, 1);
352 return wait_ready_gpio0_bit1(core,1);
356 static int register_read(struct cx88_core *core, u32 address, u32 *value)
361 cx_writeb(P1_RADDR0, (unsigned int)address);
362 cx_writeb(P1_RADDR1, (unsigned int)(address >> 8));
363 cx_writeb(P1_RRDWR, 0);
366 retval = wait_ready_gpio0_bit1(core,1);
367 val = (unsigned char)cx_read(P1_RDATA0);
368 val |= (unsigned char)cx_read(P1_RDATA1) << 8;
369 val |= (unsigned char)cx_read(P1_RDATA2) << 16;
370 val |= (unsigned char)cx_read(P1_RDATA3) << 24;
376 /* ------------------------------------------------------------------ */
378 static int blackbird_mbox_func(void *priv, int command, int in, int out, u32 data[CX2341X_MBOX_MAX_DATA])
380 struct cx8802_dev *dev = priv;
381 unsigned long timeout;
382 u32 value, flag, retval;
385 dprintk(1,"%s: 0x%X\n", __FUNCTION__, command);
387 /* this may not be 100% safe if we can't read any memory location
388 without side effects */
389 memory_read(dev->core, dev->mailbox - 4, &value);
390 if (value != 0x12345678) {
391 dprintk(0, "Firmware and/or mailbox pointer not initialized or corrupted\n");
395 memory_read(dev->core, dev->mailbox, &flag);
397 dprintk(0, "ERROR: Mailbox appears to be in use (%x)\n", flag);
401 flag |= 1; /* tell 'em we're working on it */
402 memory_write(dev->core, dev->mailbox, flag);
404 /* write command + args + fill remaining with zeros */
405 memory_write(dev->core, dev->mailbox + 1, command); /* command code */
406 memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT); /* timeout */
407 for (i = 0; i < in; i++) {
408 memory_write(dev->core, dev->mailbox + 4 + i, data[i]);
409 dprintk(1, "API Input %d = %d\n", i, data[i]);
411 for (; i < CX2341X_MBOX_MAX_DATA; i++)
412 memory_write(dev->core, dev->mailbox + 4 + i, 0);
414 flag |= 3; /* tell 'em we're done writing */
415 memory_write(dev->core, dev->mailbox, flag);
417 /* wait for firmware to handle the API command */
418 timeout = jiffies + msecs_to_jiffies(10);
420 memory_read(dev->core, dev->mailbox, &flag);
423 if (time_after(jiffies,timeout)) {
424 dprintk(0, "ERROR: API Mailbox timeout\n");
430 /* read output values */
431 for (i = 0; i < out; i++) {
432 memory_read(dev->core, dev->mailbox + 4 + i, data + i);
433 dprintk(1, "API Output %d = %d\n", i, data[i]);
436 memory_read(dev->core, dev->mailbox + 2, &retval);
437 dprintk(1, "API result = %d\n",retval);
440 memory_write(dev->core, dev->mailbox, flag);
443 /* ------------------------------------------------------------------ */
445 /* We don't need to call the API often, so using just one mailbox will probably suffice */
446 static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
447 u32 inputcnt, u32 outputcnt, ...)
449 u32 data[CX2341X_MBOX_MAX_DATA];
453 va_start(vargs, outputcnt);
455 for (i = 0; i < inputcnt; i++) {
456 data[i] = va_arg(vargs, int);
458 err = blackbird_mbox_func(dev, command, inputcnt, outputcnt, data);
459 for (i = 0; i < outputcnt; i++) {
460 int *vptr = va_arg(vargs, int *);
467 static int blackbird_find_mailbox(struct cx8802_dev *dev)
469 u32 signature[4]={0x12345678, 0x34567812, 0x56781234, 0x78123456};
474 for (i = 0; i < BLACKBIRD_FIRM_IMAGE_SIZE; i++) {
475 memory_read(dev->core, i, &value);
476 if (value == signature[signaturecnt])
480 if (4 == signaturecnt) {
481 dprintk(1, "Mailbox signature found\n");
485 dprintk(0, "Mailbox signature values not found!\n");
489 static int blackbird_load_firmware(struct cx8802_dev *dev)
491 static const unsigned char magic[8] = {
492 0xa7, 0x0d, 0x00, 0x00, 0x66, 0xbb, 0x55, 0xaa
494 const struct firmware *firmware;
500 retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED);
501 retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST);
502 retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH, 0x80000640);
503 retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE, 0x1A);
505 retval |= register_write(dev->core, IVTV_REG_APU, 0);
508 dprintk(0, "Error with register_write\n");
510 retval = request_firmware(&firmware, CX2341X_FIRM_ENC_FILENAME,
515 dprintk(0, "ERROR: Hotplug firmware request failed (%s).\n",
516 CX2341X_FIRM_ENC_FILENAME);
517 dprintk(0, "Please fix your hotplug setup, the board will "
518 "not work without firmware loaded!\n");
522 if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) {
523 dprintk(0, "ERROR: Firmware size mismatch (have %zd, expected %d)\n",
524 firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE);
525 release_firmware(firmware);
529 if (0 != memcmp(firmware->data, magic, 8)) {
530 dprintk(0, "ERROR: Firmware magic mismatch, wrong file?\n");
531 release_firmware(firmware);
535 /* transfer to the chip */
536 dprintk(1,"Loading firmware ...\n");
537 dataptr = (u32*)firmware->data;
538 for (i = 0; i < (firmware->size >> 2); i++) {
541 memory_write(dev->core, i, value);
545 /* read back to verify with the checksum */
546 for (i--; i >= 0; i--) {
547 memory_read(dev->core, i, &value);
551 dprintk(0, "ERROR: Firmware load failed (checksum mismatch).\n");
552 release_firmware(firmware);
555 release_firmware(firmware);
556 dprintk(0, "Firmware upload successful.\n");
558 retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST);
559 retval |= register_read(dev->core, IVTV_REG_SPU, &value);
560 retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE);
563 retval |= register_read(dev->core, IVTV_REG_VPU, &value);
564 retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8);
567 dprintk(0, "Error with register_write\n");
572 Settings used by the windows tv app for PVR2000:
573 =================================================================================================================
574 Profile | Codec | Resolution | CBR/VBR | Video Qlty | V. Bitrate | Frmrate | Audio Codec | A. Bitrate | A. Mode
575 -----------------------------------------------------------------------------------------------------------------
576 MPEG-1 | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 2000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
577 MPEG-2 | MPEG2 | 720x576PAL | VBR | 600 :Good | 4000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
578 VCD | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 1150 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
579 DVD | MPEG2 | 720x576PAL | VBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
580 DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo
581 =================================================================================================================
585 static void blackbird_codec_settings(struct cx8802_dev *dev)
587 /* assign frame size */
588 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0,
589 dev->height, dev->width);
591 dev->params.width = dev->width;
592 dev->params.height = dev->height;
593 dev->params.is_50hz = (dev->core->tvnorm & V4L2_STD_625_50) != 0;
595 cx2341x_update(dev, blackbird_mbox_func, NULL, &dev->params);
598 static struct v4l2_mpeg_compression default_mpeg_params = {
599 .st_type = V4L2_MPEG_PS_2,
601 .mode = V4L2_BITRATE_CBR,
611 .au_type = V4L2_MPEG_AU_2_II,
613 .mode = V4L2_BITRATE_CBR,
618 .au_sample_rate = 48000,
620 .vi_type = V4L2_MPEG_VI_2,
621 .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3,
623 .mode = V4L2_BITRATE_CBR,
629 .vi_frames_per_gop = 12,
630 .vi_bframes_count = 2,
636 static int blackbird_initialize_codec(struct cx8802_dev *dev)
638 struct cx88_core *core = dev->core;
642 dprintk(1,"Initialize codec\n");
643 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */
645 /* ping was not successful, reset and upload firmware */
646 cx_write(MO_SRST_IO, 0); /* SYS_RSTO=0 */
648 cx_write(MO_SRST_IO, 1); /* SYS_RSTO=1 */
650 retval = blackbird_load_firmware(dev);
654 dev->mailbox = blackbird_find_mailbox(dev);
655 if (dev->mailbox < 0)
658 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */
660 dprintk(0, "ERROR: Firmware ping failed!\n");
664 retval = blackbird_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, &version);
666 dprintk(0, "ERROR: Firmware get encoder version failed!\n");
669 dprintk(0, "Firmware version is 0x%08x\n", version);
673 cx_write(MO_PINMUX_IO, 0x88); /* 656-8bit IO and enable MPEG parallel IO */
674 cx_clear(MO_INPUT_FORMAT, 0x100); /* chroma subcarrier lock to normal? */
675 cx_write(MO_VBOS_CONTROL, 0x84A00); /* no 656 mode, 8-bit pixels, disable VBI */
676 cx_clear(MO_OUTPUT_FORMAT, 0x0008); /* Normal Y-limits to let the mpeg encoder sync */
678 blackbird_codec_settings(dev);
681 /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0xef, 0xef);
682 blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0xf0, 0xf0);
683 blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0x180, 0x180); */
684 blackbird_api_cmd(dev, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 0,
685 BLACKBIRD_FIELD1_SAA7115,
686 BLACKBIRD_FIELD2_SAA7115
689 /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_PLACEHOLDER, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); */
690 blackbird_api_cmd(dev, CX2341X_ENC_SET_PLACEHOLDER, 12, 0,
691 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,
692 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
694 /* initialize the video input */
695 blackbird_api_cmd(dev, CX2341X_ENC_INITIALIZE_INPUT, 0, 0);
699 blackbird_api_cmd(dev, CX2341X_ENC_MUTE_VIDEO, 1, 0, BLACKBIRD_UNMUTE);
701 blackbird_api_cmd(dev, CX2341X_ENC_MUTE_AUDIO, 1, 0, BLACKBIRD_UNMUTE);
704 /* start capturing to the host interface */
705 /* blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0, 0, 0x13); */
706 blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0,
707 BLACKBIRD_MPEG_CAPTURE,
708 BLACKBIRD_RAW_BITS_NONE
712 blackbird_api_cmd(dev, CX2341X_ENC_REFRESH_INPUT, 0,0);
716 /* ------------------------------------------------------------------ */
718 static int bb_buf_setup(struct videobuf_queue *q,
719 unsigned int *count, unsigned int *size)
721 struct cx8802_fh *fh = q->priv_data;
723 fh->dev->ts_packet_size = 188 * 4; /* was: 512 */
724 fh->dev->ts_packet_count = mpegbufs; /* was: 100 */
726 *size = fh->dev->ts_packet_size * fh->dev->ts_packet_count;
727 *count = fh->dev->ts_packet_count;
732 bb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
733 enum v4l2_field field)
735 struct cx8802_fh *fh = q->priv_data;
736 return cx8802_buf_prepare(q, fh->dev, (struct cx88_buffer*)vb, field);
740 bb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
742 struct cx8802_fh *fh = q->priv_data;
743 cx8802_buf_queue(fh->dev, (struct cx88_buffer*)vb);
747 bb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
749 cx88_free_buffer(q, (struct cx88_buffer*)vb);
752 static struct videobuf_queue_ops blackbird_qops = {
753 .buf_setup = bb_buf_setup,
754 .buf_prepare = bb_buf_prepare,
755 .buf_queue = bb_buf_queue,
756 .buf_release = bb_buf_release,
759 /* ------------------------------------------------------------------ */
761 static const u32 *ctrl_classes[] = {
767 static int blackbird_queryctrl(struct cx8802_dev *dev, struct v4l2_queryctrl *qctrl)
769 qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
773 /* Standard V4L2 controls */
774 if (cx8800_ctrl_query(qctrl) == 0)
777 /* MPEG V4L2 controls */
778 if (cx2341x_ctrl_query(&dev->params, qctrl))
779 qctrl->flags |= V4L2_CTRL_FLAG_DISABLED;
783 static int blackbird_querymenu(struct cx8802_dev *dev, struct v4l2_querymenu *qmenu)
785 struct v4l2_queryctrl qctrl;
787 qctrl.id = qmenu->id;
788 blackbird_queryctrl(dev, &qctrl);
789 return v4l2_ctrl_query_menu(qmenu, &qctrl, cx2341x_ctrl_get_menu(qmenu->id));
792 /* ------------------------------------------------------------------ */
794 static int mpeg_do_ioctl(struct inode *inode, struct file *file,
795 unsigned int cmd, void *arg)
797 struct cx8802_fh *fh = file->private_data;
798 struct cx8802_dev *dev = fh->dev;
799 struct cx88_core *core = dev->core;
802 v4l_print_ioctl(core->name,cmd);
806 /* --- capabilities ------------------------------------------ */
807 case VIDIOC_QUERYCAP:
809 struct v4l2_capability *cap = arg;
811 memset(cap,0,sizeof(*cap));
812 strcpy(cap->driver, "cx88_blackbird");
813 strlcpy(cap->card, cx88_boards[core->board].name,sizeof(cap->card));
814 sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));
815 cap->version = CX88_VERSION_CODE;
817 V4L2_CAP_VIDEO_CAPTURE |
821 if (UNSET != core->tuner_type)
822 cap->capabilities |= V4L2_CAP_TUNER;
827 /* --- capture ioctls ---------------------------------------- */
828 case VIDIOC_ENUM_FMT:
830 struct v4l2_fmtdesc *f = arg;
837 memset(f,0,sizeof(*f));
839 strlcpy(f->description, "MPEG", sizeof(f->description));
840 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
841 f->pixelformat = V4L2_PIX_FMT_MPEG;
846 struct v4l2_format *f = arg;
848 memset(f,0,sizeof(*f));
849 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
850 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
851 f->fmt.pix.bytesperline = 0;
852 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */
853 f->fmt.pix.colorspace = 0;
854 f->fmt.pix.width = dev->width;
855 f->fmt.pix.height = dev->height;
856 f->fmt.pix.field = fh->mpegq.field;
857 dprintk(0,"VIDIOC_G_FMT: w: %d, h: %d, f: %d\n",
858 dev->width, dev->height, fh->mpegq.field );
863 struct v4l2_format *f = arg;
865 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
866 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
867 f->fmt.pix.bytesperline = 0;
868 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */;
869 f->fmt.pix.colorspace = 0;
870 dprintk(0,"VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",
871 dev->width, dev->height, fh->mpegq.field );
876 struct v4l2_format *f = arg;
878 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
879 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
880 f->fmt.pix.bytesperline = 0;
881 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */;
882 f->fmt.pix.colorspace = 0;
883 dprintk(0,"VIDIOC_S_FMT: w: %d, h: %d, f: %d\n",
884 f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field );
888 /* --- streaming capture ------------------------------------- */
890 return videobuf_reqbufs(&fh->mpegq, arg);
892 case VIDIOC_QUERYBUF:
893 return videobuf_querybuf(&fh->mpegq, arg);
896 return videobuf_qbuf(&fh->mpegq, arg);
899 return videobuf_dqbuf(&fh->mpegq, arg,
900 file->f_flags & O_NONBLOCK);
902 case VIDIOC_STREAMON:
903 return videobuf_streamon(&fh->mpegq);
905 case VIDIOC_STREAMOFF:
906 return videobuf_streamoff(&fh->mpegq);
908 /* --- mpeg compression -------------------------------------- */
909 case VIDIOC_G_MPEGCOMP:
911 struct v4l2_mpeg_compression *f = arg;
913 printk(KERN_WARNING "VIDIOC_G_MPEGCOMP is obsolete. "
914 "Replace with VIDIOC_G_EXT_CTRLS!");
915 memcpy(f,&default_mpeg_params,sizeof(*f));
918 case VIDIOC_S_MPEGCOMP:
919 printk(KERN_WARNING "VIDIOC_S_MPEGCOMP is obsolete. "
920 "Replace with VIDIOC_S_EXT_CTRLS!");
922 case VIDIOC_G_EXT_CTRLS:
924 struct v4l2_ext_controls *f = arg;
926 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
928 return cx2341x_ext_ctrls(&dev->params, f, cmd);
930 case VIDIOC_S_EXT_CTRLS:
931 case VIDIOC_TRY_EXT_CTRLS:
933 struct v4l2_ext_controls *f = arg;
934 struct cx2341x_mpeg_params p;
937 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
940 err = cx2341x_ext_ctrls(&p, f, cmd);
941 if (err == 0 && cmd == VIDIOC_S_EXT_CTRLS) {
942 err = cx2341x_update(dev, blackbird_mbox_func, &dev->params, &p);
947 case VIDIOC_S_FREQUENCY:
949 blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
951 BLACKBIRD_MPEG_CAPTURE,
952 BLACKBIRD_RAW_BITS_NONE);
954 cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, cx88_ioctl_hook);
956 blackbird_initialize_codec(dev);
957 cx88_set_scale(dev->core, dev->width, dev->height,
961 case VIDIOC_LOG_STATUS:
965 snprintf(name, sizeof(name), "%s/2", core->name);
966 printk("%s/2: ============ START LOG STATUS ============\n",
968 cx88_call_i2c_clients(core, VIDIOC_LOG_STATUS, NULL);
969 cx2341x_log_status(&dev->params, name);
970 printk("%s/2: ============= END LOG STATUS =============\n",
974 case VIDIOC_QUERYMENU:
975 return blackbird_querymenu(dev, arg);
976 case VIDIOC_QUERYCTRL:
978 struct v4l2_queryctrl *c = arg;
980 if (blackbird_queryctrl(dev, c) == 0)
982 return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl);
986 return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, cx88_ioctl_hook);
991 int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
992 struct cx88_core *core, unsigned int cmd, void *arg, v4l2_kioctl driver_ioctl)
998 if (_IOC_DIR(cmd) & _IOC_WRITE)
999 v4l_printk_ioctl_arg("cx88(w)",cmd, arg);
1000 else if (!_IOC_DIR(cmd) & _IOC_READ) {
1001 v4l_print_ioctl("cx88", cmd);
1004 v4l_print_ioctl(core->name,cmd);
1009 /* ---------- tv norms ---------- */
1010 case VIDIOC_ENUMSTD:
1012 struct v4l2_standard *e = arg;
1016 if (i >= ARRAY_SIZE(tvnorms))
1018 err = v4l2_video_std_construct(e, tvnorms[e->index].id,
1019 tvnorms[e->index].name);
1027 v4l2_std_id *id = arg;
1034 v4l2_std_id *id = arg;
1037 for(i = 0; i < ARRAY_SIZE(tvnorms); i++)
1038 if (*id & tvnorms[i].id)
1040 if (i == ARRAY_SIZE(tvnorms))
1043 mutex_lock(&core->lock);
1044 cx88_set_tvnorm(core,tvnorms[i].id);
1045 mutex_unlock(&core->lock);
1049 /* ------ input switching ---------- */
1050 case VIDIOC_ENUMINPUT:
1052 static const char *iname[] = {
1053 [ CX88_VMUX_COMPOSITE1 ] = "Composite1",
1054 [ CX88_VMUX_COMPOSITE2 ] = "Composite2",
1055 [ CX88_VMUX_COMPOSITE3 ] = "Composite3",
1056 [ CX88_VMUX_COMPOSITE4 ] = "Composite4",
1057 [ CX88_VMUX_SVIDEO ] = "S-Video",
1058 [ CX88_VMUX_TELEVISION ] = "Television",
1059 [ CX88_VMUX_CABLE ] = "Cable TV",
1060 [ CX88_VMUX_DVB ] = "DVB",
1061 [ CX88_VMUX_DEBUG ] = "for debug only",
1063 struct v4l2_input *i = arg;
1069 if (0 == INPUT(n)->type)
1071 memset(i,0,sizeof(*i));
1073 i->type = V4L2_INPUT_TYPE_CAMERA;
1074 strcpy(i->name,iname[INPUT(n)->type]);
1075 if ((CX88_VMUX_TELEVISION == INPUT(n)->type) ||
1076 (CX88_VMUX_CABLE == INPUT(n)->type))
1077 i->type = V4L2_INPUT_TYPE_TUNER;
1078 for (n = 0; n < ARRAY_SIZE(tvnorms); n++)
1079 i->std |= tvnorms[n].id;
1082 case VIDIOC_G_INPUT:
1084 unsigned int *i = arg;
1089 case VIDIOC_S_INPUT:
1091 unsigned int *i = arg;
1095 mutex_lock(&core->lock);
1096 cx88_newstation(core);
1097 cx88_video_mux(core,*i);
1098 mutex_unlock(&core->lock);
1104 /* --- controls ---------------------------------------------- */
1105 case VIDIOC_QUERYCTRL:
1107 struct v4l2_queryctrl *qctrl = arg;
1109 qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
1110 if (unlikely(qctrl->id == 0))
1112 return cx8800_ctrl_query(qctrl);
1115 return cx88_get_control(core,arg);
1117 return cx88_set_control(core,arg);
1119 /* --- tuner ioctls ------------------------------------------ */
1120 case VIDIOC_G_TUNER:
1122 struct v4l2_tuner *t = arg;
1125 if (UNSET == core->tuner_type)
1130 memset(t,0,sizeof(*t));
1131 strcpy(t->name, "Television");
1132 t->type = V4L2_TUNER_ANALOG_TV;
1133 t->capability = V4L2_TUNER_CAP_NORM;
1134 t->rangehigh = 0xffffffffUL;
1136 cx88_get_stereo(core ,t);
1137 reg = cx_read(MO_DEVICE_STATUS);
1138 t->signal = (reg & (1<<5)) ? 0xffff : 0x0000;
1141 case VIDIOC_S_TUNER:
1143 struct v4l2_tuner *t = arg;
1145 if (UNSET == core->tuner_type)
1149 cx88_set_stereo(core, t->audmode, 1);
1152 case VIDIOC_G_FREQUENCY:
1154 struct v4l2_frequency *f = arg;
1156 memset(f,0,sizeof(*f));
1158 if (UNSET == core->tuner_type)
1161 /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */
1162 f->type = radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1163 f->frequency = core->freq;
1165 cx88_call_i2c_clients(core,VIDIOC_G_FREQUENCY,f);
1169 case VIDIOC_S_FREQUENCY:
1171 struct v4l2_frequency *f = arg;
1173 if (UNSET == core->tuner_type)
1177 if (0 == radio && f->type != V4L2_TUNER_ANALOG_TV)
1179 if (1 == radio && f->type != V4L2_TUNER_RADIO)
1181 mutex_lock(&core->lock);
1182 core->freq = f->frequency;
1183 cx88_newstation(core);
1184 cx88_call_i2c_clients(core,VIDIOC_S_FREQUENCY,f);
1186 /* When changing channels it is required to reset TVAUDIO */
1188 cx88_set_tvaudio(core);
1190 mutex_unlock(&core->lock);
1193 #ifdef CONFIG_VIDEO_ADV_DEBUG
1194 /* ioctls to allow direct acces to the cx2388x registers */
1195 case VIDIOC_INT_G_REGISTER:
1197 struct v4l2_register *reg = arg;
1199 if (reg->i2c_id != 0)
1201 /* cx2388x has a 24-bit register space */
1202 reg->val = cx_read(reg->reg&0xffffff);
1205 case VIDIOC_INT_S_REGISTER:
1207 struct v4l2_register *reg = arg;
1209 if (reg->i2c_id != 0)
1211 if (!capable(CAP_SYS_ADMIN))
1213 cx_write(reg->reg&0xffffff, reg->val);
1219 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
1225 int (*cx88_ioctl_hook)(struct inode *inode, struct file *file,
1226 unsigned int cmd, void *arg);
1227 unsigned int (*cx88_ioctl_translator)(unsigned int cmd);
1229 static unsigned int mpeg_translate_ioctl(unsigned int cmd)
1234 static int mpeg_ioctl(struct inode *inode, struct file *file,
1235 unsigned int cmd, unsigned long arg)
1237 cmd = cx88_ioctl_translator( cmd );
1238 return video_usercopy(inode, file, cmd, arg, cx88_ioctl_hook);
1241 static int mpeg_open(struct inode *inode, struct file *file)
1243 int minor = iminor(inode);
1244 struct cx8802_dev *dev = NULL;
1245 struct cx8802_fh *fh;
1246 struct cx8802_driver *drv = NULL;
1249 dev = cx8802_get_device(inode);
1251 dprintk( 1, "%s\n", __FUNCTION__);
1256 /* Make sure we can acquire the hardware */
1257 drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);
1259 err = drv->request_acquire(drv);
1261 dprintk(1,"%s: Unable to acquire hardware, %d\n", __FUNCTION__, err);
1266 if (blackbird_initialize_codec(dev) < 0) {
1268 drv->request_release(drv);
1271 dprintk(1,"open minor=%d\n",minor);
1273 /* allocate + initialize per filehandle data */
1274 fh = kzalloc(sizeof(*fh),GFP_KERNEL);
1277 drv->request_release(drv);
1280 file->private_data = fh;
1283 videobuf_queue_init(&fh->mpegq, &blackbird_qops,
1284 dev->pci, &dev->slock,
1285 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1286 V4L2_FIELD_INTERLACED,
1287 sizeof(struct cx88_buffer),
1290 /* FIXME: locking against other video device */
1291 cx88_set_scale(dev->core, dev->width, dev->height,
1297 static int mpeg_release(struct inode *inode, struct file *file)
1299 struct cx8802_fh *fh = file->private_data;
1300 struct cx8802_dev *dev = NULL;
1301 struct cx8802_driver *drv = NULL;
1303 /* blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, BLACKBIRD_END_NOW, 0, 0x13); */
1304 blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
1306 BLACKBIRD_MPEG_CAPTURE,
1307 BLACKBIRD_RAW_BITS_NONE
1310 cx8802_cancel_buffers(fh->dev);
1311 /* stop mpeg capture */
1312 if (fh->mpegq.streaming)
1313 videobuf_streamoff(&fh->mpegq);
1314 if (fh->mpegq.reading)
1315 videobuf_read_stop(&fh->mpegq);
1317 videobuf_mmap_free(&fh->mpegq);
1318 file->private_data = NULL;
1321 /* Make sure we release the hardware */
1322 dev = cx8802_get_device(inode);
1326 drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);
1328 drv->request_release(drv);
1334 mpeg_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
1336 struct cx8802_fh *fh = file->private_data;
1338 return videobuf_read_stream(&fh->mpegq, data, count, ppos, 0,
1339 file->f_flags & O_NONBLOCK);
1343 mpeg_poll(struct file *file, struct poll_table_struct *wait)
1345 struct cx8802_fh *fh = file->private_data;
1347 return videobuf_poll_stream(file, &fh->mpegq, wait);
1351 mpeg_mmap(struct file *file, struct vm_area_struct * vma)
1353 struct cx8802_fh *fh = file->private_data;
1355 return videobuf_mmap_mapper(&fh->mpegq, vma);
1358 static const struct file_operations mpeg_fops =
1360 .owner = THIS_MODULE,
1362 .release = mpeg_release,
1366 .ioctl = mpeg_ioctl,
1367 .llseek = no_llseek,
1370 static struct video_device cx8802_mpeg_template =
1373 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES|VID_TYPE_MPEG_ENCODER,
1379 /* ------------------------------------------------------------------ */
1381 /* The CX8802 MPEG API will call this when we can use the hardware */
1382 static int cx8802_blackbird_advise_acquire(struct cx8802_driver *drv)
1384 struct cx88_core *core = drv->core;
1387 switch (core->board) {
1388 case CX88_BOARD_HAUPPAUGE_HVR1300:
1389 /* By default, core setup will leave the cx22702 out of reset, on the bus.
1390 * We left the hardware on power up with the cx22702 active.
1391 * We're being given access to re-arrange the GPIOs.
1392 * Take the bus off the cx22702 and put the cx23416 on it.
1394 cx_clear(MO_GP0_IO, 0x00000080); /* cx22702 in reset */
1395 cx_set(MO_GP0_IO, 0x00000004); /* Disable the cx22702 */
1403 /* The CX8802 MPEG API will call this when we need to release the hardware */
1404 static int cx8802_blackbird_advise_release(struct cx8802_driver *drv)
1406 struct cx88_core *core = drv->core;
1409 switch (core->board) {
1410 case CX88_BOARD_HAUPPAUGE_HVR1300:
1411 /* Exit leaving the cx23416 on the bus */
1419 static void blackbird_unregister_video(struct cx8802_dev *dev)
1421 if (dev->mpeg_dev) {
1422 if (-1 != dev->mpeg_dev->minor)
1423 video_unregister_device(dev->mpeg_dev);
1425 video_device_release(dev->mpeg_dev);
1426 dev->mpeg_dev = NULL;
1430 static int blackbird_register_video(struct cx8802_dev *dev)
1434 dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci,
1435 &cx8802_mpeg_template,"mpeg");
1436 err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1);
1438 printk(KERN_INFO "%s/2: can't register mpeg device\n",
1442 printk(KERN_INFO "%s/2: registered device video%d [mpeg]\n",
1443 dev->core->name,dev->mpeg_dev->minor & 0x1f);
1447 /* ----------------------------------------------------------- */
1449 static int cx8802_blackbird_probe(struct cx8802_driver *drv)
1451 struct cx88_core *core = drv->core;
1452 struct cx8802_dev *dev = core->dvbdev;
1455 dprintk( 1, "%s\n", __FUNCTION__);
1456 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1463 if (!(cx88_boards[core->board].mpeg & CX88_MPEG_BLACKBIRD))
1468 cx2341x_fill_defaults(&dev->params);
1469 dev->params.port = CX2341X_PORT_STREAMING;
1471 if (core->tvnorm & V4L2_STD_525_60) {
1477 /* blackbird stuff */
1478 printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n",
1480 host_setup(dev->core);
1482 blackbird_register_video(dev);
1484 /* initial device configuration: needed ? */
1492 static int cx8802_blackbird_remove(struct cx8802_driver *drv)
1495 blackbird_unregister_video(drv->core->dvbdev);
1500 static struct cx8802_driver cx8802_blackbird_driver = {
1501 .type_id = CX88_MPEG_BLACKBIRD,
1502 .hw_access = CX8802_DRVCTL_SHARED,
1503 .probe = cx8802_blackbird_probe,
1504 .remove = cx8802_blackbird_remove,
1505 .advise_acquire = cx8802_blackbird_advise_acquire,
1506 .advise_release = cx8802_blackbird_advise_release,
1509 static int blackbird_init(void)
1511 printk(KERN_INFO "cx2388x blackbird driver version %d.%d.%d loaded\n",
1512 (CX88_VERSION_CODE >> 16) & 0xff,
1513 (CX88_VERSION_CODE >> 8) & 0xff,
1514 CX88_VERSION_CODE & 0xff);
1516 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1517 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1519 cx88_ioctl_hook = mpeg_do_ioctl;
1520 cx88_ioctl_translator = mpeg_translate_ioctl;
1521 return cx8802_register_driver(&cx8802_blackbird_driver);
1524 static void blackbird_fini(void)
1526 cx8802_unregister_driver(&cx8802_blackbird_driver);
1529 module_init(blackbird_init);
1530 module_exit(blackbird_fini);
1532 EXPORT_SYMBOL(cx88_ioctl_hook);
1533 EXPORT_SYMBOL(cx88_ioctl_translator);
1535 /* ----------------------------------------------------------- */
1540 * 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