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 |
820 if (UNSET != core->tuner_type)
821 cap->capabilities |= V4L2_CAP_TUNER;
826 /* --- capture ioctls ---------------------------------------- */
827 case VIDIOC_ENUM_FMT:
829 struct v4l2_fmtdesc *f = arg;
836 memset(f,0,sizeof(*f));
838 strlcpy(f->description, "MPEG", sizeof(f->description));
839 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
840 f->pixelformat = V4L2_PIX_FMT_MPEG;
845 struct v4l2_format *f = arg;
847 memset(f,0,sizeof(*f));
848 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
849 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
850 f->fmt.pix.bytesperline = 0;
851 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */
852 f->fmt.pix.colorspace = 0;
853 f->fmt.pix.width = dev->width;
854 f->fmt.pix.height = dev->height;
855 f->fmt.pix.field = fh->mpegq.field;
856 dprintk(0,"VIDIOC_G_FMT: w: %d, h: %d, f: %d\n",
857 dev->width, dev->height, fh->mpegq.field );
862 struct v4l2_format *f = arg;
864 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
865 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
866 f->fmt.pix.bytesperline = 0;
867 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */;
868 f->fmt.pix.colorspace = 0;
869 dprintk(0,"VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",
870 dev->width, dev->height, fh->mpegq.field );
875 struct v4l2_format *f = arg;
877 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
878 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
879 f->fmt.pix.bytesperline = 0;
880 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */;
881 f->fmt.pix.colorspace = 0;
882 dprintk(0,"VIDIOC_S_FMT: w: %d, h: %d, f: %d\n",
883 f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field );
887 /* --- streaming capture ------------------------------------- */
889 return videobuf_reqbufs(&fh->mpegq, arg);
891 case VIDIOC_QUERYBUF:
892 return videobuf_querybuf(&fh->mpegq, arg);
895 return videobuf_qbuf(&fh->mpegq, arg);
898 return videobuf_dqbuf(&fh->mpegq, arg,
899 file->f_flags & O_NONBLOCK);
901 case VIDIOC_STREAMON:
902 return videobuf_streamon(&fh->mpegq);
904 case VIDIOC_STREAMOFF:
905 return videobuf_streamoff(&fh->mpegq);
907 /* --- mpeg compression -------------------------------------- */
908 case VIDIOC_G_MPEGCOMP:
910 struct v4l2_mpeg_compression *f = arg;
912 printk(KERN_WARNING "VIDIOC_G_MPEGCOMP is obsolete. "
913 "Replace with VIDIOC_G_EXT_CTRLS!");
914 memcpy(f,&default_mpeg_params,sizeof(*f));
917 case VIDIOC_S_MPEGCOMP:
918 printk(KERN_WARNING "VIDIOC_S_MPEGCOMP is obsolete. "
919 "Replace with VIDIOC_S_EXT_CTRLS!");
921 case VIDIOC_G_EXT_CTRLS:
923 struct v4l2_ext_controls *f = arg;
925 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
927 return cx2341x_ext_ctrls(&dev->params, f, cmd);
929 case VIDIOC_S_EXT_CTRLS:
931 struct v4l2_ext_controls *f = arg;
932 struct cx2341x_mpeg_params p;
935 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
938 err = cx2341x_ext_ctrls(&p, VIDIOC_S_EXT_CTRLS, cmd);
939 if (err == 0 && cmd == VIDIOC_S_EXT_CTRLS) {
940 err = cx2341x_update(dev, blackbird_mbox_func, &dev->params, &p);
945 case VIDIOC_TRY_EXT_CTRLS:
947 struct v4l2_ext_controls *f = arg;
948 struct cx2341x_mpeg_params p;
951 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
954 err = cx2341x_ext_ctrls(&p, VIDIOC_TRY_EXT_CTRLS, cmd);
957 case VIDIOC_S_FREQUENCY:
959 blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
961 BLACKBIRD_MPEG_CAPTURE,
962 BLACKBIRD_RAW_BITS_NONE);
964 cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, cx88_ioctl_hook);
966 blackbird_initialize_codec(dev);
967 cx88_set_scale(dev->core, dev->width, dev->height,
971 case VIDIOC_LOG_STATUS:
975 snprintf(name, sizeof(name), "%s/2", core->name);
976 printk("%s/2: ============ START LOG STATUS ============\n",
978 cx88_call_i2c_clients(core, VIDIOC_LOG_STATUS, NULL);
979 cx2341x_log_status(&dev->params, name);
980 printk("%s/2: ============= END LOG STATUS =============\n",
984 case VIDIOC_QUERYMENU:
985 return blackbird_querymenu(dev, arg);
986 case VIDIOC_QUERYCTRL:
988 struct v4l2_queryctrl *c = arg;
990 if (blackbird_queryctrl(dev, c) == 0)
992 return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl);
996 return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, cx88_ioctl_hook);
1001 int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
1002 struct cx88_core *core, unsigned int cmd, void *arg, v4l2_kioctl driver_ioctl)
1008 if (_IOC_DIR(cmd) & _IOC_WRITE)
1009 v4l_printk_ioctl_arg("cx88(w)",cmd, arg);
1010 else if (!_IOC_DIR(cmd) & _IOC_READ) {
1011 v4l_print_ioctl("cx88", cmd);
1014 v4l_print_ioctl(core->name,cmd);
1019 /* ------ input switching ---------- */
1020 case VIDIOC_ENUMINPUT:
1022 static const char *iname[] = {
1023 [ CX88_VMUX_COMPOSITE1 ] = "Composite1",
1024 [ CX88_VMUX_COMPOSITE2 ] = "Composite2",
1025 [ CX88_VMUX_COMPOSITE3 ] = "Composite3",
1026 [ CX88_VMUX_COMPOSITE4 ] = "Composite4",
1027 [ CX88_VMUX_SVIDEO ] = "S-Video",
1028 [ CX88_VMUX_TELEVISION ] = "Television",
1029 [ CX88_VMUX_CABLE ] = "Cable TV",
1030 [ CX88_VMUX_DVB ] = "DVB",
1031 [ CX88_VMUX_DEBUG ] = "for debug only",
1033 struct v4l2_input *i = arg;
1039 if (0 == INPUT(n)->type)
1041 memset(i,0,sizeof(*i));
1043 i->type = V4L2_INPUT_TYPE_CAMERA;
1044 strcpy(i->name,iname[INPUT(n)->type]);
1045 if ((CX88_VMUX_TELEVISION == INPUT(n)->type) ||
1046 (CX88_VMUX_CABLE == INPUT(n)->type))
1047 i->type = V4L2_INPUT_TYPE_TUNER;
1048 for (n = 0; n < ARRAY_SIZE(tvnorms); n++)
1049 i->std |= tvnorms[n].id;
1053 return cx88_get_control(core,arg);
1055 return cx88_set_control(core,arg);
1057 case VIDIOC_G_FREQUENCY:
1059 struct v4l2_frequency *f = arg;
1061 memset(f,0,sizeof(*f));
1063 if (UNSET == core->tuner_type)
1066 /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */
1067 f->type = radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1068 f->frequency = core->freq;
1070 cx88_call_i2c_clients(core,VIDIOC_G_FREQUENCY,f);
1074 case VIDIOC_G_INPUT:
1076 unsigned int *i = arg;
1081 case VIDIOC_S_INPUT:
1083 unsigned int *i = arg;
1087 mutex_lock(&core->lock);
1088 cx88_newstation(core);
1089 cx88_video_mux(core,*i);
1090 mutex_unlock(&core->lock);
1095 case VIDIOC_G_TUNER:
1097 struct v4l2_tuner *t = arg;
1100 if (UNSET == core->tuner_type)
1105 memset(t,0,sizeof(*t));
1106 strcpy(t->name, "Television");
1107 t->type = V4L2_TUNER_ANALOG_TV;
1108 t->capability = V4L2_TUNER_CAP_NORM;
1109 t->rangehigh = 0xffffffffUL;
1111 cx88_get_stereo(core ,t);
1112 reg = cx_read(MO_DEVICE_STATUS);
1113 t->signal = (reg & (1<<5)) ? 0xffff : 0x0000;
1116 case VIDIOC_S_TUNER:
1118 struct v4l2_tuner *t = arg;
1120 if (UNSET == core->tuner_type)
1124 cx88_set_stereo(core, t->audmode, 1);
1127 /* ---------- tv norms ---------- */
1130 v4l2_std_id *id = arg;
1133 for(i = 0; i < ARRAY_SIZE(tvnorms); i++)
1134 if (*id & tvnorms[i].id)
1136 if (i == ARRAY_SIZE(tvnorms))
1139 mutex_lock(&core->lock);
1140 cx88_set_tvnorm(core,tvnorms[i].id);
1141 mutex_unlock(&core->lock);
1144 case VIDIOC_ENUMSTD:
1146 struct v4l2_standard *e = arg;
1150 if (i >= ARRAY_SIZE(tvnorms))
1152 err = v4l2_video_std_construct(e, tvnorms[e->index].id,
1153 tvnorms[e->index].name);
1161 v4l2_std_id *id = arg;
1168 /* --- controls ---------------------------------------------- */
1169 case VIDIOC_QUERYCTRL:
1171 struct v4l2_queryctrl *qctrl = arg;
1173 qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
1174 if (unlikely(qctrl->id == 0))
1176 return cx8800_ctrl_query(qctrl);
1178 /* --- tuner ioctls ------------------------------------------ */
1179 case VIDIOC_S_FREQUENCY:
1181 struct v4l2_frequency *f = arg;
1183 if (UNSET == core->tuner_type)
1187 if (0 == radio && f->type != V4L2_TUNER_ANALOG_TV)
1189 if (1 == radio && f->type != V4L2_TUNER_RADIO)
1191 mutex_lock(&core->lock);
1192 core->freq = f->frequency;
1193 cx88_newstation(core);
1194 cx88_call_i2c_clients(core,VIDIOC_S_FREQUENCY,f);
1196 /* When changing channels it is required to reset TVAUDIO */
1198 cx88_set_tvaudio(core);
1200 mutex_unlock(&core->lock);
1203 #ifdef CONFIG_VIDEO_ADV_DEBUG
1204 /* ioctls to allow direct acces to the cx2388x registers */
1205 case VIDIOC_INT_G_REGISTER:
1207 struct v4l2_register *reg = arg;
1209 if (reg->i2c_id != 0)
1211 /* cx2388x has a 24-bit register space */
1212 reg->val = cx_read(reg->reg&0xffffff);
1215 case VIDIOC_INT_S_REGISTER:
1217 struct v4l2_register *reg = arg;
1219 if (reg->i2c_id != 0)
1221 if (!capable(CAP_SYS_ADMIN))
1223 cx_write(reg->reg&0xffffff, reg->val);
1229 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
1235 int (*cx88_ioctl_hook)(struct inode *inode, struct file *file,
1236 unsigned int cmd, void *arg);
1237 unsigned int (*cx88_ioctl_translator)(unsigned int cmd);
1239 static unsigned int mpeg_translate_ioctl(unsigned int cmd)
1244 static int mpeg_ioctl(struct inode *inode, struct file *file,
1245 unsigned int cmd, unsigned long arg)
1247 cmd = cx88_ioctl_translator( cmd );
1248 return video_usercopy(inode, file, cmd, arg, cx88_ioctl_hook);
1251 static int mpeg_open(struct inode *inode, struct file *file)
1253 int minor = iminor(inode);
1254 struct cx8802_dev *dev = NULL;
1255 struct cx8802_fh *fh;
1256 struct cx8802_driver *drv = NULL;
1259 dev = cx8802_get_device(inode);
1261 dprintk( 1, "%s\n", __FUNCTION__);
1266 /* Make sure we can acquire the hardware */
1267 drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);
1269 err = drv->request_acquire(drv);
1271 dprintk(1,"%s: Unable to acquire hardware, %d\n", __FUNCTION__, err);
1276 if (blackbird_initialize_codec(dev) < 0) {
1278 drv->request_release(drv);
1281 dprintk(1,"open minor=%d\n",minor);
1283 /* allocate + initialize per filehandle data */
1284 fh = kzalloc(sizeof(*fh),GFP_KERNEL);
1287 drv->request_release(drv);
1290 file->private_data = fh;
1293 videobuf_queue_init(&fh->mpegq, &blackbird_qops,
1294 dev->pci, &dev->slock,
1295 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1296 V4L2_FIELD_INTERLACED,
1297 sizeof(struct cx88_buffer),
1300 /* FIXME: locking against other video device */
1301 cx88_set_scale(dev->core, dev->width, dev->height,
1307 static int mpeg_release(struct inode *inode, struct file *file)
1309 struct cx8802_fh *fh = file->private_data;
1310 struct cx8802_dev *dev = NULL;
1311 struct cx8802_driver *drv = NULL;
1313 /* blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, BLACKBIRD_END_NOW, 0, 0x13); */
1314 blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
1316 BLACKBIRD_MPEG_CAPTURE,
1317 BLACKBIRD_RAW_BITS_NONE
1320 cx8802_cancel_buffers(fh->dev);
1321 /* stop mpeg capture */
1322 if (fh->mpegq.streaming)
1323 videobuf_streamoff(&fh->mpegq);
1324 if (fh->mpegq.reading)
1325 videobuf_read_stop(&fh->mpegq);
1327 videobuf_mmap_free(&fh->mpegq);
1328 file->private_data = NULL;
1331 /* Make sure we release the hardware */
1332 dev = cx8802_get_device(inode);
1336 drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);
1338 drv->request_release(drv);
1344 mpeg_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
1346 struct cx8802_fh *fh = file->private_data;
1348 return videobuf_read_stream(&fh->mpegq, data, count, ppos, 0,
1349 file->f_flags & O_NONBLOCK);
1353 mpeg_poll(struct file *file, struct poll_table_struct *wait)
1355 struct cx8802_fh *fh = file->private_data;
1357 return videobuf_poll_stream(file, &fh->mpegq, wait);
1361 mpeg_mmap(struct file *file, struct vm_area_struct * vma)
1363 struct cx8802_fh *fh = file->private_data;
1365 return videobuf_mmap_mapper(&fh->mpegq, vma);
1368 static const struct file_operations mpeg_fops =
1370 .owner = THIS_MODULE,
1372 .release = mpeg_release,
1376 .ioctl = mpeg_ioctl,
1377 .llseek = no_llseek,
1380 static struct video_device cx8802_mpeg_template =
1383 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES|VID_TYPE_MPEG_ENCODER,
1389 /* ------------------------------------------------------------------ */
1391 /* The CX8802 MPEG API will call this when we can use the hardware */
1392 static int cx8802_blackbird_advise_acquire(struct cx8802_driver *drv)
1394 struct cx88_core *core = drv->core;
1397 switch (core->board) {
1398 case CX88_BOARD_HAUPPAUGE_HVR1300:
1399 /* By default, core setup will leave the cx22702 out of reset, on the bus.
1400 * We left the hardware on power up with the cx22702 active.
1401 * We're being given access to re-arrange the GPIOs.
1402 * Take the bus off the cx22702 and put the cx23416 on it.
1404 cx_clear(MO_GP0_IO, 0x00000080); /* cx22702 in reset */
1405 cx_set(MO_GP0_IO, 0x00000004); /* Disable the cx22702 */
1413 /* The CX8802 MPEG API will call this when we need to release the hardware */
1414 static int cx8802_blackbird_advise_release(struct cx8802_driver *drv)
1416 struct cx88_core *core = drv->core;
1419 switch (core->board) {
1420 case CX88_BOARD_HAUPPAUGE_HVR1300:
1421 /* Exit leaving the cx23416 on the bus */
1429 static void blackbird_unregister_video(struct cx8802_dev *dev)
1431 if (dev->mpeg_dev) {
1432 if (-1 != dev->mpeg_dev->minor)
1433 video_unregister_device(dev->mpeg_dev);
1435 video_device_release(dev->mpeg_dev);
1436 dev->mpeg_dev = NULL;
1440 static int blackbird_register_video(struct cx8802_dev *dev)
1444 dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci,
1445 &cx8802_mpeg_template,"mpeg");
1446 err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1);
1448 printk(KERN_INFO "%s/2: can't register mpeg device\n",
1452 printk(KERN_INFO "%s/2: registered device video%d [mpeg]\n",
1453 dev->core->name,dev->mpeg_dev->minor & 0x1f);
1457 /* ----------------------------------------------------------- */
1459 static int cx8802_blackbird_probe(struct cx8802_driver *drv)
1461 struct cx88_core *core = drv->core;
1462 struct cx8802_dev *dev = core->dvbdev;
1465 dprintk( 1, "%s\n", __FUNCTION__);
1466 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1473 if (!(cx88_boards[core->board].mpeg & CX88_MPEG_BLACKBIRD))
1478 cx2341x_fill_defaults(&dev->params);
1479 dev->params.port = CX2341X_PORT_STREAMING;
1481 if (core->tvnorm & V4L2_STD_525_60) {
1487 /* blackbird stuff */
1488 printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n",
1490 host_setup(dev->core);
1492 blackbird_register_video(dev);
1494 /* initial device configuration: needed ? */
1502 static int cx8802_blackbird_remove(struct cx8802_driver *drv)
1505 blackbird_unregister_video(drv->core->dvbdev);
1510 static struct cx8802_driver cx8802_blackbird_driver = {
1511 .type_id = CX88_MPEG_BLACKBIRD,
1512 .hw_access = CX8802_DRVCTL_SHARED,
1513 .probe = cx8802_blackbird_probe,
1514 .remove = cx8802_blackbird_remove,
1515 .advise_acquire = cx8802_blackbird_advise_acquire,
1516 .advise_release = cx8802_blackbird_advise_release,
1519 static int blackbird_init(void)
1521 printk(KERN_INFO "cx2388x blackbird driver version %d.%d.%d loaded\n",
1522 (CX88_VERSION_CODE >> 16) & 0xff,
1523 (CX88_VERSION_CODE >> 8) & 0xff,
1524 CX88_VERSION_CODE & 0xff);
1526 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1527 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1529 cx88_ioctl_hook = mpeg_do_ioctl;
1530 cx88_ioctl_translator = mpeg_translate_ioctl;
1531 return cx8802_register_driver(&cx8802_blackbird_driver);
1534 static void blackbird_fini(void)
1536 cx8802_unregister_driver(&cx8802_blackbird_driver);
1539 module_init(blackbird_init);
1540 module_exit(blackbird_fini);
1542 EXPORT_SYMBOL(cx88_ioctl_hook);
1543 EXPORT_SYMBOL(cx88_ioctl_translator);
1545 /* ----------------------------------------------------------- */
1550 * 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