92 -1, -1, -1, -1, -1, -1, -1, -1,
93 -1, -1, -1, -1, -1, -1, -1, -1,
94 -1, -1, -1, -1, -1, -1, -1, -1 };
95 static int radio[
IVTV_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1,
96 -1, -1, -1, -1, -1, -1, -1, -1,
97 -1, -1, -1, -1, -1, -1, -1, -1,
98 -1, -1, -1, -1, -1, -1, -1, -1 };
99 static int i2c_clock_period[
IVTV_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1,
100 -1, -1, -1, -1, -1, -1, -1, -1,
101 -1, -1, -1, -1, -1, -1, -1, -1,
102 -1, -1, -1, -1, -1, -1, -1, -1 };
104 static unsigned int cardtype_c = 1;
105 static unsigned int tuner_c = 1;
106 static int radio_c = 1;
107 static unsigned int i2c_clock_period_c = 1;
108 static char pal[] =
"---";
109 static char secam[] =
"--";
110 static char ntsc[] =
"-";
115 #define IVTV_DEFAULT_ENC_MPG_BUFFERS 4
116 #define IVTV_DEFAULT_ENC_YUV_BUFFERS 2
117 #define IVTV_DEFAULT_ENC_VBI_BUFFERS 1
119 #define IVTV_DEFAULT_ENC_PCM_BUFFERS 320
120 #define IVTV_DEFAULT_DEC_MPG_BUFFERS 1
121 #define IVTV_DEFAULT_DEC_YUV_BUFFERS 1
123 #define IVTV_DEFAULT_DEC_VBI_BUFFERS 64
133 static int ivtv_yuv_mode;
134 static int ivtv_yuv_threshold = -1;
135 static int ivtv_pci_latency = 1;
138 #ifdef CONFIG_VIDEO_ADV_DEBUG
143 static int newi2c = -1;
152 #ifdef CONFIG_VIDEO_ADV_DEBUG
173 "\t\t\tsee tuner.h for values");
175 "Enable or disable the radio. Use only if autodetection\n"
176 "\t\t\tfails. 0 = disable, 1 = enable");
178 "Only use this option if your card is not detected properly.\n"
179 "\t\tSpecify card type:\n"
180 "\t\t\t 1 = WinTV PVR 250\n"
181 "\t\t\t 2 = WinTV PVR 350\n"
182 "\t\t\t 3 = WinTV PVR-150 or PVR-500\n"
183 "\t\t\t 4 = AVerMedia M179\n"
184 "\t\t\t 5 = YUAN MPG600/Kuroutoshikou iTVC16-STVLP\n"
185 "\t\t\t 6 = YUAN MPG160/Kuroutoshikou iTVC15-STVLP\n"
186 "\t\t\t 7 = YUAN PG600/DIAMONDMM PVR-550 (CX Falcon 2)\n"
187 "\t\t\t 8 = Adaptec AVC-2410\n"
188 "\t\t\t 9 = Adaptec AVC-2010\n"
189 "\t\t\t10 = NAGASE TRANSGEAR 5000TV\n"
190 "\t\t\t11 = AOpen VA2000MAX-STN6\n"
191 "\t\t\t12 = YUAN MPG600GR/Kuroutoshikou CX23416GYC-STVLP\n"
192 "\t\t\t13 = I/O Data GV-MVP/RX\n"
193 "\t\t\t14 = I/O Data GV-MVP/RX2E\n"
194 "\t\t\t15 = GOTVIEW PCI DVD\n"
195 "\t\t\t16 = GOTVIEW PCI DVD2 Deluxe\n"
196 "\t\t\t17 = Yuan MPC622\n"
197 "\t\t\t18 = Digital Cowboy DCT-MTVP1\n"
198 "\t\t\t19 = Yuan PG600V2/GotView PCI DVD Lite\n"
199 "\t\t\t20 = Club3D ZAP-TV1x01\n"
200 "\t\t\t21 = AverTV MCE 116 Plus\n"
201 "\t\t\t22 = ASUS Falcon2\n"
202 "\t\t\t23 = AverMedia PVR-150 Plus\n"
203 "\t\t\t24 = AverMedia EZMaker PCI Deluxe\n"
204 "\t\t\t25 = AverMedia M104 (not yet working)\n"
205 "\t\t\t26 = Buffalo PC-MV5L/PCI\n"
206 "\t\t\t27 = AVerMedia UltraTV 1500 MCE\n"
207 "\t\t\t28 = Sony VAIO Giga Pocket (ENX Kikyou)\n"
208 "\t\t\t 0 = Autodetect (default)\n"
209 "\t\t\t-1 = Ignore this card\n\t\t");
214 "Specify tuner type:\n"
215 "\t\t\t 0 = tuner for PAL-B/G/H/D/K/I, SECAM-B/G/H/D/K/L/Lc\n"
216 "\t\t\t 1 = tuner for NTSC-M/J/K, PAL-M/N/Nc\n"
217 "\t\t\t-1 = Autodetect (default)\n");
219 "Debug level (bitmask). Default: 0\n"
220 "\t\t\t 1/0x0001: warning\n"
221 "\t\t\t 2/0x0002: info\n"
222 "\t\t\t 4/0x0004: mailbox\n"
223 "\t\t\t 8/0x0008: ioctl\n"
224 "\t\t\t 16/0x0010: file\n"
225 "\t\t\t 32/0x0020: dma\n"
226 "\t\t\t 64/0x0040: irq\n"
227 "\t\t\t 128/0x0080: decoder\n"
228 "\t\t\t 256/0x0100: yuv\n"
229 "\t\t\t 512/0x0200: i2c\n"
230 "\t\t\t1024/0x0400: high volume\n");
231 #ifdef CONFIG_VIDEO_ADV_DEBUG
233 "Enable code for debugging firmware problems. Default: 0\n");
236 "Change the PCI latency to 64 if lower: 0 = No, 1 = Yes,\n"
237 "\t\t\tDefault: Yes");
239 "Specify the yuv playback mode:\n"
240 "\t\t\t0 = interlaced\n\t\t\t1 = progressive\n\t\t\t2 = auto\n"
241 "\t\t\tDefault: 0 (interlaced)");
243 "If ivtv_yuv_mode is 2 (auto) then playback content as\n\t\tprogressive if src height <= ivtv_yuvthreshold\n"
244 "\t\t\tDefault: 480");
246 "Encoder MPG Buffers (in MB)\n"
249 "Encoder YUV Buffers (in MB)\n"
252 "Encoder VBI Buffers (in MB)\n"
255 "Encoder PCM buffers (in kB)\n"
258 "Decoder MPG buffers (in MB)\n"
261 "Decoder YUV buffers (in MB)\n"
264 "Decoder VBI buffers (in kB)\n"
267 "Use new I2C implementation\n"
268 "\t\t\t-1 is autodetect, 0 is off, 1 is on\n"
269 "\t\t\tDefault is autodetect");
271 "Period of SCL for the I2C bus controlled by the CX23415/6\n"
272 "\t\t\tMin: 10 usec (100 kHz), Max: 4500 usec (222 Hz)\n"
280 (
"CX23415/CX23416 MPEG2 encoder (WinTV PVR-150/250/350/500,\n"
281 "\t\t\tYuan MPG series and similar)");
286 #if defined(CONFIG_MODULES) && defined(MODULE)
292 request_module(
"ivtv-alsa");
310 #define request_modules(dev)
311 #define flush_request_modules(dev)
330 spin_lock(&itv->
lock);
334 spin_unlock(&itv->
lock);
379 static void ivtv_iounmap(
struct ivtv *
itv)
415 static void ivtv_process_eeprom(
struct ivtv *itv)
428 case 30012 ... 30039:
429 case 32000 ... 32999:
430 case 48000 ... 48099:
431 case 48400 ... 48599:
434 case 48100 ... 48399:
435 case 48600 ... 48999:
438 case 23000 ... 23999:
439 case 25000 ... 25999:
440 case 26000 ... 26999:
447 IVTV_ERR(
"Unknown model %d, defaulting to PVR-150\n", tv.model);
481 if (tv.model / 1000 == 23) {
490 if (pci_slot == 8 || pci_slot == 9) {
491 int is_first = (pci_slot & 1) == 0;
493 itv->
card_name = is_first ?
"WinTV PVR 500 (unit #1)" :
494 "WinTV PVR 500 (unit #2)";
496 IVTV_INFO(
"Correcting tveeprom data: no radio present on second unit\n");
503 switch (
tv.tuner_hauppauge_model) {
512 if (
tv.tuner_type == TUNER_ABSENT)
513 IVTV_ERR(
"tveeprom cannot autodetect tuner!\n");
518 itv->
options.radio = (
tv.has_radio != 0);
520 if (itv->
options.newi2c == -1 &&
tv.has_ir) {
521 itv->
options.newi2c = (
tv.has_ir & 4) ? 1 : 0;
523 IVTV_INFO(
"Reopen i2c bus for IR-blaster support\n");
544 IVTV_INFO(
"No tuner detected, default to NTSC-M\n");
566 if (
pal[1] ==
'c' ||
pal[1] ==
'C')
586 IVTV_WARN(
"pal= argument not recognised\n");
608 if (secam[1] ==
'C' || secam[1] ==
'c')
614 IVTV_WARN(
"secam= argument not recognised\n");
634 IVTV_WARN(
"ntsc= argument not recognised\n");
642 static void ivtv_process_options(
struct ivtv *itv)
644 const char *chipname;
659 if (itv->
options.i2c_clock_period == -1)
661 else if (itv->
options.i2c_clock_period < 10)
662 itv->
options.i2c_clock_period = 10;
663 else if (itv->
options.i2c_clock_period > 4500)
664 itv->
options.i2c_clock_period = 4500;
668 IVTV_WARN(
"Invalid tunertype argument, will autodetect instead\n");
671 itv->
std = ivtv_parse_std(itv);
675 chipname = itv->
has_cx23415 ?
"cx23415" :
"cx23416";
676 if (itv->
options.cardtype == -1) {
677 IVTV_INFO(
"Ignore card (detected %s based chip)\n", chipname);
681 IVTV_INFO(
"User specified %s card (detected %s based chip)\n",
682 itv->
card->name, chipname);
683 }
else if (itv->
options.cardtype != 0) {
684 IVTV_ERR(
"Unknown user specified type, trying to autodetect card\n");
691 IVTV_INFO(
"Autodetected Hauppauge card (%s based)\n",
699 for (j = 0; itv->
card->pci_list[
j].device; j++) {
700 if (itv->
pdev->device !=
701 itv->
card->pci_list[j].device)
703 if (itv->
pdev->subsystem_vendor !=
704 itv->
card->pci_list[j].subsystem_vendor)
706 if (itv->
pdev->subsystem_device !=
707 itv->
card->pci_list[j].subsystem_device)
709 IVTV_INFO(
"Autodetected %s card (%s based)\n",
710 itv->
card->name, chipname);
719 IVTV_ERR(
"Unknown card: vendor/device: [%04x:%04x]\n",
720 itv->
pdev->vendor, itv->
pdev->device);
721 IVTV_ERR(
" subsystem vendor/device: [%04x:%04x]\n",
722 itv->
pdev->subsystem_vendor, itv->
pdev->subsystem_device);
725 IVTV_ERR(
"Please mail the vendor/device and subsystem vendor/device IDs and what kind of\n");
726 IVTV_ERR(
"card you have to the ivtv-devel mailinglist (www.ivtvdriver.org)\n");
727 IVTV_ERR(
"Prefix your subject line with [UNKNOWN IVTV CARD].\n");
758 IVTV_ERR(
"Could not create ivtv task\n");
785 itv->
vbi.sliced_in = &itv->
vbi.in.fmt.sliced;
796 itv->
yuv_info.lace_mode = ivtv_yuv_mode;
797 itv->
yuv_info.lace_threshold = ivtv_yuv_threshold;
798 itv->
yuv_info.max_frames_buffered = 3;
810 if (itv->
card->video_inputs[i].video_type == 0)
814 if (itv->
card->audio_inputs[i].audio_type == 0)
819 itv->
vbi.sliced_size = 288;
821 itv->
vbi.sliced_size = 64;
826 if (itv->
card->video_inputs[i].video_type ==
836 static int ivtv_setup_pci(
struct ivtv *itv,
struct pci_dev *pdev,
840 unsigned char pci_latency;
849 IVTV_ERR(
"No suitable DMA available.\n");
853 IVTV_ERR(
"Cannot request encoder memory region.\n");
859 IVTV_ERR(
"Cannot request register memory region.\n");
867 IVTV_ERR(
"Cannot request decoder memory region.\n");
879 if (!(cmd & PCI_COMMAND_MASTER)) {
880 IVTV_ERR(
"Bus Mastering is not enabled\n");
888 if (pci_latency < 64 && ivtv_pci_latency) {
889 IVTV_INFO(
"Unreasonably low latency timer, "
890 "setting to 64 (was %d)\n", pci_latency);
898 pci_write_config_dword(pdev, 0x40, 0xffff);
901 "irq: %d, latency: %d, memory: 0x%llx\n",
909 static void ivtv_load_and_init_modules(
struct ivtv *itv)
915 for (i = 0; i < 32; i++) {
962 itv->
vbi.raw_decoder_line_size = 1444;
963 itv->
vbi.raw_decoder_sav_odd_field = 0x20;
964 itv->
vbi.raw_decoder_sav_even_field = 0x60;
965 itv->
vbi.sliced_decoder_line_size = 272;
966 itv->
vbi.sliced_decoder_sav_odd_field = 0xB0;
967 itv->
vbi.sliced_decoder_sav_even_field = 0xF0;
977 strlcpy(
v.match.name,
"saa7115",
sizeof(
v.match.name));
986 itv->
vbi.raw_decoder_line_size = 1443;
987 itv->
vbi.raw_decoder_sav_odd_field = 0x25;
988 itv->
vbi.raw_decoder_sav_even_field = 0x62;
989 itv->
vbi.sliced_decoder_line_size = 51;
990 itv->
vbi.sliced_decoder_sav_odd_field = 0xAB;
991 itv->
vbi.sliced_decoder_sav_even_field = 0xEC;
995 itv->
vbi.raw_decoder_line_size = 1443;
996 itv->
vbi.raw_decoder_sav_odd_field = 0x25;
997 itv->
vbi.raw_decoder_sav_even_field = 0x62;
998 itv->
vbi.sliced_decoder_line_size = 51;
999 itv->
vbi.sliced_decoder_sav_odd_field = 0xAB;
1000 itv->
vbi.sliced_decoder_sav_even_field = 0xEC;
1025 ivtv_process_options(itv);
1026 if (itv->
options.cardtype == -1) {
1030 if (ivtv_init_struct1(itv)) {
1039 itv->
cxhdl.priv = itv;
1045 retval = ivtv_setup_pci(itv, pdev, pci_id);
1048 if (retval == -
ENXIO)
1057 IVTV_ERR(
"ioremap failed. Can't get a window into CX23415/6 "
1058 "encoder memory\n");
1059 IVTV_ERR(
"Each capture card with a CX23415/6 needs 8 MB of "
1060 "vmalloc address space for this window\n");
1061 IVTV_ERR(
"Check the output of 'grep Vmalloc /proc/meminfo'\n");
1062 IVTV_ERR(
"Use the vmalloc= kernel command line option to set "
1063 "VmallocTotal to a larger value\n");
1074 IVTV_ERR(
"ioremap failed. Can't get a window into "
1075 "CX23415 decoder memory\n");
1076 IVTV_ERR(
"Each capture card with a CX23415 needs 8 MB "
1077 "of vmalloc address space for this window\n");
1078 IVTV_ERR(
"Check the output of 'grep Vmalloc "
1079 "/proc/meminfo'\n");
1080 IVTV_ERR(
"Use the vmalloc= kernel command line option "
1081 "to set VmallocTotal to a larger value\n");
1096 IVTV_ERR(
"ioremap failed. Can't get a window into CX23415/6 "
1097 "register space\n");
1098 IVTV_ERR(
"Each capture card with a CX23415/6 needs 64 kB of "
1099 "vmalloc address space for this window\n");
1100 IVTV_ERR(
"Check the output of 'grep Vmalloc /proc/meminfo'\n");
1101 IVTV_ERR(
"Use the vmalloc= kernel command line option to set "
1102 "VmallocTotal to a larger value\n");
1114 IVTV_ERR(
"Could not initialize i2c\n");
1121 ivtv_process_eeprom(itv);
1123 if (itv->
card->comment)
1125 if (itv->
card->v4l2_capabilities == 0) {
1131 if (itv->
std == 0) {
1135 if (itv->
options.tuner == -1) {
1139 if ((itv->
std & itv->
card->tuners[i].std) == 0)
1146 if (itv->
options.tuner == -1 && itv->
card->tuners[0].std) {
1147 itv->
std = itv->
card->tuners[0].std;
1157 itv->
options.radio = (itv->
card->radio_input.audio_type != 0);
1161 ivtv_init_struct2(itv);
1163 ivtv_load_and_init_modules(itv);
1190 itv->
vbi.raw_size = 1456;
1197 vbi_buf_size = itv->
vbi.raw_size * (itv->
is_60hz ? 24 : 36) / 2;
1204 if (itv->
options.tuner > -1) {
1205 struct tuner_setup
setup;
1207 setup.addr = ADDR_UNSET;
1209 setup.mode_mask = T_ANALOG_TV;
1211 setup.mode_mask |= T_RADIO;
1212 setup.tuner_callback = (
setup.type == TUNER_XC2028) ?
1215 if (
setup.type == TUNER_XC2028) {
1254 retval = hdl->
error;
1273 IVTV_ERR(
"Failed to register irq %d\n", retval);
1279 IVTV_ERR(
"Error %d setting up streams\n", retval);
1284 IVTV_ERR(
"Error %d registering devices\n", retval);
1312 IVTV_ERR(
"Error %d on initialization\n", retval);
1324 int fw_retry_count = 3;
1336 while (--fw_retry_count > 0) {
1340 if (fw_retry_count > 1)
1344 if (fw_retry_count == 0) {
1353 if (itv->
card->hw_all & IVTV_HW_CX25840)
1411 static void ivtv_remove(
struct pci_dev *pdev)
1414 struct ivtv *itv = to_ivtv(v4l2_dev);
1471 kfree(itv->
vbi.sliced_mpeg_data[i]);
1482 .id_table = ivtv_pci_tbl,
1483 .probe = ivtv_probe,
1484 .remove = ivtv_remove,
1487 static int __init module_start(
void)
1492 if (ivtv_first_minor < 0 || ivtv_first_minor >=
IVTV_MAX_CARDS) {
1493 printk(
KERN_ERR "ivtv: Exiting, ivtv_first_minor must be between 0 and %d\n",
1498 if (ivtv_debug < 0 || ivtv_debug > 2047) {
1503 if (pci_register_driver(&ivtv_pci_driver)) {
1511 static void __exit module_cleanup(
void)
1524 #ifdef CONFIG_VIDEO_ADV_DEBUG