69 -1, -1, -1, -1, -1, -1, -1, -1,
70 -1, -1, -1, -1, -1, -1, -1, -1,
71 -1, -1, -1, -1, -1, -1, -1, -1 };
72 static int radio[
CX18_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1,
73 -1, -1, -1, -1, -1, -1, -1, -1,
74 -1, -1, -1, -1, -1, -1, -1, -1,
75 -1, -1, -1, -1, -1, -1, -1, -1 };
76 static unsigned cardtype_c = 1;
77 static unsigned tuner_c = 1;
78 static unsigned radio_c = 1;
79 static char pal[] =
"--";
80 static char secam[] =
"--";
81 static char ntsc[] =
"-";
97 static int enc_ts_bufs = -1;
98 static int enc_mpg_bufs = -1;
100 static int enc_yuv_bufs = -1;
101 static int enc_vbi_bufs = -1;
102 static int enc_pcm_bufs = -1;
105 static int cx18_pci_latency = 1;
107 static int mmio_ndelay;
108 static int retry_mmio = 1;
145 "\t\t\tsee tuner.h for values");
147 "Enable or disable the radio. Use only if autodetection\n"
148 "\t\t\tfails. 0 = disable, 1 = enable");
150 "Only use this option if your card is not detected properly.\n"
151 "\t\tSpecify card type:\n"
152 "\t\t\t 1 = Hauppauge HVR 1600 (ESMT memory)\n"
153 "\t\t\t 2 = Hauppauge HVR 1600 (Samsung memory)\n"
154 "\t\t\t 3 = Compro VideoMate H900\n"
155 "\t\t\t 4 = Yuan MPC718\n"
156 "\t\t\t 5 = Conexant Raptor PAL/SECAM\n"
157 "\t\t\t 6 = Toshiba Qosmio DVB-T/Analog\n"
158 "\t\t\t 7 = Leadtek WinFast PVR2100\n"
159 "\t\t\t 8 = Leadtek WinFast DVR3100 H\n"
160 "\t\t\t 9 = GoTView PCI DVD3 Hybrid\n"
161 "\t\t\t 10 = Hauppauge HVR 1600 (S5H1411)\n"
162 "\t\t\t 0 = Autodetect (default)\n"
163 "\t\t\t-1 = Ignore this card\n\t\t");
164 MODULE_PARM_DESC(
pal,
"Set PAL standard: B, G, H, D, K, I, M, N, Nc, 60");
168 "Debug level (bitmask). Default: 0\n"
169 "\t\t\t 1/0x0001: warning\n"
170 "\t\t\t 2/0x0002: info\n"
171 "\t\t\t 4/0x0004: mailbox\n"
172 "\t\t\t 8/0x0008: dma\n"
173 "\t\t\t 16/0x0010: ioctl\n"
174 "\t\t\t 32/0x0020: file\n"
175 "\t\t\t 64/0x0040: i2c\n"
176 "\t\t\t128/0x0080: irq\n"
177 "\t\t\t256/0x0100: high volume\n");
179 "Change the PCI latency to 64 if lower: 0 = No, 1 = Yes,\n"
180 "\t\t\tDefault: Yes");
182 "(Deprecated) MMIO writes are now always checked and retried\n"
183 "\t\t\tEffectively: 1 [Yes]");
185 "(Deprecated) MMIO accesses are now never purposely delayed\n"
186 "\t\t\tEffectively: 0 ns");
188 "Encoder TS buffer memory (MB). (enc_ts_bufs can override)\n"
191 "Size of an encoder TS buffer (kB)\n"
194 "Number of encoder TS buffers\n"
195 "\t\t\tDefault is computed from other enc_ts_* parameters");
197 "Encoder MPG buffer memory (MB). (enc_mpg_bufs can override)\n"
200 "Size of an encoder MPG buffer (kB)\n"
203 "Number of encoder MPG buffers\n"
204 "\t\t\tDefault is computed from other enc_mpg_* parameters");
206 "(Deprecated) Encoder IDX buffer memory (MB)\n"
207 "\t\t\tIgnored, except 0 disables IDX buffer allocations\n"
208 "\t\t\tDefault: 1 [Enabled]");
210 "Size of an encoder IDX buffer (kB)\n"
211 "\t\t\tAllowed values are multiples of 1.5 kB rounded up\n"
212 "\t\t\t(multiples of size required for 64 index entries)\n"
215 "Number of encoder IDX buffers\n"
218 "Encoder YUV buffer memory (MB). (enc_yuv_bufs can override)\n"
221 "Size of an encoder YUV buffer (kB)\n"
222 "\t\t\tAllowed values are multiples of 33.75 kB rounded up\n"
223 "\t\t\t(multiples of size required for 32 screen lines)\n"
224 "\t\t\tDefault: 102");
226 "Number of encoder YUV buffers\n"
227 "\t\t\tDefault is computed from other enc_yuv_* parameters");
229 "Encoder VBI buffer memory (MB). (enc_vbi_bufs can override)\n"
232 "Number of encoder VBI buffers\n"
233 "\t\t\tDefault is computed from enc_vbi_buffers");
235 "Encoder PCM buffer memory (MB). (enc_pcm_bufs can override)\n"
238 "Size of an encoder PCM buffer (kB)\n"
241 "Number of encoder PCM buffers\n"
242 "\t\t\tDefault is computed from other enc_pcm_* parameters");
245 "Set device node number assigned to first card");
254 #if defined(CONFIG_MODULES) && defined(MODULE)
260 request_module(
"cx18-alsa");
278 #define request_modules(dev)
279 #define flush_request_modules(dev)
291 sig = intr ? signal_pending(
current) : 0;
292 }
while (!sig && timeout);
297 static void cx18_iounmap(
struct cx18 *cx)
310 static void cx18_eeprom_dump(
struct cx18 *cx,
unsigned char *eedata,
int len)
315 for (i = 0; i < len; i++) {
335 memset(tv, 0,
sizeof(*tv));
339 switch (cx->
card->type) {
348 cx18_eeprom_dump(cx, eedata,
sizeof(eedata));
349 CX18_INFO(
"eeprom PCI ID: %02x%02x:%02x%02x\n",
350 eedata[2], eedata[1], eedata[4], eedata[3]);
353 tv->
model = 0xffffffff;
354 cx18_eeprom_dump(cx, eedata,
sizeof(eedata));
359 static void cx18_process_eeprom(
struct cx18 *cx)
401 CX18_ERR(
"Unknown model %d, defaulting to original HVR-1600 "
402 "(cardtype=1)\n", tv.model);
413 if (tv.tuner_type == TUNER_ABSENT)
414 CX18_ERR(
"tveeprom cannot autodetect tuner!\n");
417 cx->
options.tuner = tv.tuner_type;
419 cx->
options.radio = (tv.has_radio != 0);
426 #define TVEEPROM_TUNER_FORMAT_ALL (V4L2_STD_B | V4L2_STD_GH | \
429 V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC | \
431 if ((tv.tuner_formats & TVEEPROM_TUNER_FORMAT_ALL)
445 CX18_INFO(
"No tuner detected, default to NTSC-M\n");
465 if (
pal[1] ==
'c' ||
pal[1] ==
'C')
482 CX18_WARN(
"pal= argument not recognised\n");
501 if (secam[1] ==
'C' || secam[1] ==
'c')
507 CX18_WARN(
"secam= argument not recognised\n");
524 CX18_WARN(
"ntsc= argument not recognised\n");
532 static void cx18_process_options(
struct cx18 *cx)
563 cx->
options.megabytes[i] <= 0 ||
608 cx->
options.megabytes[
i] * 1024 * 1024
632 "%d bytes\n", i, cx->
options.megabytes[i],
640 cx->
std = cx18_parse_std(cx);
641 if (cx->
options.cardtype == -1) {
648 else if (cx->
options.cardtype != 0)
649 CX18_ERR(
"Unknown user specified type, trying to autodetect card\n");
653 CX18_INFO(
"Autodetected Hauppauge card\n");
660 for (j = 0; cx->
card->pci_list[
j].device; j++) {
662 cx->
card->pci_list[j].device)
664 if (cx->
pci_dev->subsystem_vendor !=
665 cx->
card->pci_list[j].subsystem_vendor)
667 if (cx->
pci_dev->subsystem_device !=
668 cx->
card->pci_list[j].subsystem_device)
679 CX18_ERR(
"Unknown card: vendor/device: [%04x:%04x]\n",
681 CX18_ERR(
" subsystem vendor/device: [%04x:%04x]\n",
683 cx->
pci_dev->subsystem_device);
685 CX18_ERR(
"Please mail the vendor/device and subsystem vendor/device IDs and what kind of\n");
686 CX18_ERR(
"card you have to the ivtv-devel mailinglist (www.ivtvdriver.org)\n");
687 CX18_ERR(
"Prefix your subject line with [UNKNOWN CX18 CARD].\n");
700 CX18_ERR(
"Unable to create incoming mailbox handler thread\n");
706 static void __devinit cx18_init_in_work_orders(
struct cx18 *cx)
732 ret = cx18_create_in_workq(cx);
736 cx18_init_in_work_orders(cx);
755 (cx->
cxhdl.video_temporal_filter_mode->cur.val << 1) |
756 (cx->
cxhdl.video_median_filter_type->cur.val << 2);
765 cx->
vbi.sliced_in = &cx->
vbi.in.fmt.sliced;
768 INIT_LIST_HEAD(&cx->
vbi.sliced_mpeg_buf.list);
769 INIT_LIST_HEAD(&cx->
vbi.sliced_mpeg_mdl.list);
770 INIT_LIST_HEAD(&cx->
vbi.sliced_mpeg_mdl.buf_list);
771 list_add(&cx->
vbi.sliced_mpeg_buf.list,
772 &cx->
vbi.sliced_mpeg_mdl.buf_list);
783 if (cx->
card->video_inputs[i].video_type == 0)
787 if (cx->
card->audio_inputs[i].audio_type == 0)
793 if (cx->
card->video_inputs[i].video_type ==
807 unsigned char pci_latency;
820 CX18_ERR(
"Cannot request encoder memory region, card %d\n",
833 if (pci_latency < 64 && cx18_pci_latency) {
834 CX18_INFO(
"Unreasonably low latency timer, "
835 "setting to 64 (was %d)\n", pci_latency);
841 "irq: %d, latency: %d, memory: 0x%llx\n",
849 static void cx18_init_subdevs(
struct cx18 *cx)
855 for (i = 0, device = 1; i < 32; i++, device <<= 1) {
891 if (cx->
card->hw_muxer != 0)
895 static int __devinit cx18_probe(
struct pci_dev *pci_dev,
931 cx18_process_options(cx);
932 if (cx->
options.cardtype == -1) {
937 retval = cx18_init_struct1(cx);
944 retval = cx18_setup_pci(cx, pci_dev, pci_id);
946 goto free_workqueues;
954 CX18_ERR(
"ioremap failed. Can't get a window into CX23418 "
955 "memory and register space\n");
956 CX18_ERR(
"Each capture card with a CX23418 needs 64 MB of "
957 "vmalloc address space for the window\n");
958 CX18_ERR(
"Check the output of 'grep Vmalloc /proc/meminfo'\n");
959 CX18_ERR(
"Use the vmalloc= kernel command line option to set "
960 "VmallocTotal to a larger value\n");
965 devtype = cx18_read_reg(cx, 0xC72028);
966 switch (devtype & 0xff000000) {
968 CX18_INFO(
"cx23418 revision %08x (A)\n", devtype);
971 CX18_INFO(
"cx23418 revision %08x (B)\n", devtype);
974 CX18_INFO(
"cx23418 revision %08x (Unknown)\n", devtype);
989 CX18_ERR(
"Could not register A/V decoder subdevice\n");
996 CX18_WARN(
"Could not register GPIO reset controller"
997 "subdevice; proceeding anyway.\n");
1006 CX18_ERR(
"Could not initialize i2c\n");
1014 cx18_process_eeprom(cx);
1016 if (cx->
card != orig_card) {
1023 if (cx->
card->comment)
1025 if (cx->
card->v4l2_capabilities == 0) {
1037 CX18_ERR(
"Failed to register irq %d\n", retval);
1044 if (cx->
options.tuner == -1) {
1046 if ((cx->
std & cx->
card->tuners[i].std) == 0)
1053 if (cx->
options.tuner == -1 && cx->
card->tuners[0].std) {
1054 cx->
std = cx->
card->tuners[0].std;
1064 cx->
options.radio = (cx->
card->radio_input.audio_type != 0);
1068 cx18_init_struct2(cx);
1070 cx18_init_subdevs(cx);
1083 struct tuner_setup
setup;
1085 setup.addr = ADDR_UNSET;
1087 setup.mode_mask = T_ANALOG_TV;
1089 setup.mode_mask |= T_RADIO;
1090 setup.tuner_callback = (
setup.type == TUNER_XC2028) ?
1093 if (
setup.type == TUNER_XC2028) {
1114 CX18_ERR(
"Error %d setting up streams\n", retval);
1119 CX18_ERR(
"Error %d registering devices\n", retval);
1144 CX18_ERR(
"Error %d on initialization\n", retval);
1154 int fw_retry_count = 3;
1167 while (--fw_retry_count > 0) {
1171 if (fw_retry_count > 1)
1175 if (fw_retry_count == 0) {
1198 while (--fw_retry_count > 0) {
1202 if (fw_retry_count > 1)
1206 if (fw_retry_count == 0) {
1251 static void cx18_cancel_in_work_orders(
struct cx18 *cx)
1258 static void cx18_cancel_out_work_orders(
struct cx18 *cx)
1266 static void cx18_remove(
struct pci_dev *pci_dev)
1268 struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
1269 struct cx18 *cx = to_cx18(v4l2_dev);
1285 cx18_cancel_in_work_orders(cx);
1286 cx18_cancel_out_work_orders(cx);
1307 if (cx->
vbi.sliced_mpeg_data[0] !=
NULL)
1309 kfree(cx->
vbi.sliced_mpeg_data[i]);
1323 .id_table = cx18_pci_tbl,
1324 .probe = cx18_probe,
1325 .remove = cx18_remove,
1328 static int __init module_start(
void)
1334 if (cx18_first_minor < 0 || cx18_first_minor >=
CX18_MAX_CARDS) {
1335 printk(
KERN_ERR "cx18: Exiting, cx18_first_minor must be between 0 and %d\n",
1340 if (cx18_debug < 0 || cx18_debug > 511) {
1345 if (pci_register_driver(&cx18_pci_driver)) {
1353 static void __exit module_cleanup(
void)