Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb

+10715 -5153
+2 -1
Documentation/dvb/avermedia.txt
··· 150 150 151 151 The frontend module sp887x.o, requires an external firmware. 152 152 Please use the command "get_dvb_firmware sp887x" to download 153 - it. Then copy it to /usr/lib/hotplug/firmware. 153 + it. Then copy it to /usr/lib/hotplug/firmware or /lib/firmware/ 154 + (depending on configuration of firmware hotplug). 154 155 155 156 Receiving DVB-T in Australia 156 157
+20 -3
Documentation/dvb/get_dvb_firmware
··· 23 23 24 24 @components = ( "sp8870", "sp887x", "tda10045", "tda10046", "av7110", "dec2000t", 25 25 "dec2540t", "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004", 26 - "or51211", "or51132_qam", "or51132_vsb"); 26 + "or51211", "or51132_qam", "or51132_vsb", "bluebird"); 27 27 28 28 # Check args 29 29 syntax() if (scalar(@ARGV) != 1); ··· 34 34 if ($cid eq $components[$i]) { 35 35 $outfile = eval($cid); 36 36 die $@ if $@; 37 - print STDERR "Firmware $outfile extracted successfully. Now copy it to either /lib/firmware or /usr/lib/hotplug/firmware/ (depending on your hotplug version).\n"; 37 + print STDERR <<EOF; 38 + Firmware $outfile extracted successfully. 39 + Now copy it to either /usr/lib/hotplug/firmware or /lib/firmware 40 + (depending on configuration of firmware hotplug). 41 + EOF 38 42 exit(0); 39 43 } 40 44 } ··· 247 243 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 248 244 249 245 checkstandard(); 250 - 246 + 251 247 wgetfile($sourcefile, $url); 252 248 unzip($sourcefile, $tmpdir); 253 249 verify("$tmpdir/SkyNETU.sys", $hash); ··· 310 306 verify($fwfile, $hash); 311 307 312 308 $fwfile; 309 + } 310 + 311 + sub bluebird { 312 + my $url = "http://www.linuxtv.org/download/dvb/firmware/dvb-usb-bluebird-01.fw"; 313 + my $outfile = "dvb-usb-bluebird-01.fw"; 314 + my $hash = "658397cb9eba9101af9031302671f49d"; 315 + 316 + checkstandard(); 317 + 318 + wgetfile($outfile, $url); 319 + verify($outfile,$hash); 320 + 321 + $outfile; 313 322 } 314 323 315 324 # ---------------------------------------------------------------
+2 -1
Documentation/dvb/ttusb-dec.txt
··· 41 41 For 2.6 kernels the firmware is loaded at the point that the driver module is 42 42 loaded. See linux/Documentation/dvb/firmware.txt for more information. 43 43 44 - Copy the three files downloaded above into the /usr/lib/hotplug/firmware directory. 44 + Copy the three files downloaded above into the /usr/lib/hotplug/firmware or 45 + /lib/firmware directory (depending on configuration of firmware hotplug).
+1
Documentation/video4linux/CARDLIST.bttv
··· 141 141 140 -> Osprey 440 [0070:ff07] 142 142 141 -> Asound Skyeye PCTV 143 143 142 -> Sabrent TV-FM (bttv version) 144 + 143 -> Hauppauge ImpactVCB (bt878) [0070:13eb]
+9 -1
Documentation/video4linux/CARDLIST.cx88
··· 16 16 15 -> DViCO FusionHDTV DVB-T1 [18ac:db00] 17 17 16 -> KWorld LTV883RF 18 18 17 -> DViCO FusionHDTV 3 Gold-Q [18ac:d810] 19 - 18 -> Hauppauge Nova-T DVB-T [0070:9002] 19 + 18 -> Hauppauge Nova-T DVB-T [0070:9002,0070:9001] 20 20 19 -> Conexant DVB-T reference design [14f1:0187] 21 21 20 -> Provideo PV259 [1540:2580] 22 22 21 -> DViCO FusionHDTV DVB-T Plus [18ac:db10] ··· 35 35 34 -> ATI HDTV Wonder [1002:a101] 36 36 35 -> WinFast DTV1000-T [107d:665f] 37 37 36 -> AVerTV 303 (M126) [1461:000a] 38 + 37 -> Hauppauge Nova-S-Plus DVB-S [0070:9201,0070:9202] 39 + 38 -> Hauppauge Nova-SE2 DVB-S [0070:9200] 40 + 39 -> KWorld DVB-S 100 [17de:08b2] 41 + 40 -> Hauppauge WinTV-HVR1100 DVB-T/Hybrid [0070:9400,0070:9402] 42 + 41 -> Hauppauge WinTV-HVR1100 DVB-T/Hybrid (Low Profile) [0070:9800,0070:9802] 43 + 42 -> digitalnow DNTV Live! DVB-T Pro [1822:0025] 44 + 43 -> KWorld/VStream XPert DVB-T with cx22702 [17de:08a1] 45 + 44 -> DViCO FusionHDTV DVB-T Dual Digital [18ac:db50]
+3 -2
Documentation/video4linux/CARDLIST.saa7134
··· 56 56 55 -> LifeView FlyDVB-T DUO [5168:0502,5168:0306] 57 57 56 -> Avermedia AVerTV 307 [1461:a70a] 58 58 57 -> Avermedia AVerTV GO 007 FM [1461:f31f] 59 - 58 -> ADS Tech Instant TV (saa7135) [1421:0350,1421:0370,1421:1370] 59 + 58 -> ADS Tech Instant TV (saa7135) [1421:0350,1421:0351,1421:0370,1421:1370] 60 60 59 -> Kworld/Tevion V-Stream Xpert TV PVR7134 61 61 60 -> Typhoon DVB-T Duo Digital/Analog Cardbus [4e42:0502] 62 62 61 -> Philips TOUGH DVB-T reference design [1131:2004] ··· 81 81 80 -> ASUS Digimatrix TV [1043:0210] 82 82 81 -> Philips Tiger reference design [1131:2018] 83 83 82 -> MSI TV@Anywhere plus [1462:6231] 84 - 84 + 83 -> Terratec Cinergy 250 PCI TV [153b:1160] 85 + 84 -> LifeView FlyDVB Trio [5168:0319]
+3 -3
Documentation/video4linux/CARDLIST.tuner
··· 40 40 tuner=39 - LG NTSC (newer TAPC series) 41 41 tuner=40 - HITACHI V7-J180AT 42 42 tuner=41 - Philips PAL_MK (FI1216 MK) 43 - tuner=42 - Philips 1236D ATSC/NTSC daul in 43 + tuner=42 - Philips 1236D ATSC/NTSC dual in 44 44 tuner=43 - Philips NTSC MK3 (FM1236MK3 or FM1236/F) 45 45 tuner=44 - Philips 4 in 1 (ATI TV Wonder Pro/Conexant) 46 46 tuner=45 - Microtune 4049 FM5 ··· 50 50 tuner=49 - Microtune 4042 FI5 ATSC/NTSC dual in 51 51 tuner=50 - TCL 2002N 52 52 tuner=51 - Philips PAL/SECAM_D (FM 1256 I-H3) 53 - tuner=52 - Thomson DDT 7610 (ATSC/NTSC) 53 + tuner=52 - Thomson DTT 7610 (ATSC/NTSC) 54 54 tuner=53 - Philips FQ1286 55 55 tuner=54 - tda8290+75 56 56 tuner=55 - TCL 2002MB ··· 58 58 tuner=57 - Philips FQ1236A MK4 59 59 tuner=58 - Ymec TVision TVF-8531MF/8831MF/8731MF 60 60 tuner=59 - Ymec TVision TVF-5533MF 61 - tuner=60 - Thomson DDT 7611 (ATSC/NTSC) 61 + tuner=60 - Thomson DTT 761X (ATSC/NTSC) 62 62 tuner=61 - Tena TNF9533-D/IF/TNF9533-B/DF 63 63 tuner=62 - Philips TEA5767HN FM Radio 64 64 tuner=63 - Philips FMD1216ME MK3 Hybrid Tuner
+34 -4
drivers/media/common/saa7146_fops.c
··· 253 253 254 254 if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { 255 255 DEB_S(("initializing vbi...\n")); 256 - result = saa7146_vbi_uops.open(dev,file); 256 + if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) 257 + result = saa7146_vbi_uops.open(dev,file); 258 + if (dev->ext_vv_data->vbi_fops.open) 259 + dev->ext_vv_data->vbi_fops.open(inode, file); 257 260 } else { 258 261 DEB_S(("initializing video...\n")); 259 262 result = saa7146_video_uops.open(dev,file); ··· 292 289 return -ERESTARTSYS; 293 290 294 291 if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { 295 - saa7146_vbi_uops.release(dev,file); 292 + if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) 293 + saa7146_vbi_uops.release(dev,file); 294 + if (dev->ext_vv_data->vbi_fops.release) 295 + dev->ext_vv_data->vbi_fops.release(inode, file); 296 296 } else { 297 297 saa7146_video_uops.release(dev,file); 298 298 } ··· 338 332 BUG(); 339 333 return 0; 340 334 } 335 + 341 336 return videobuf_mmap_mapper(q,vma); 342 337 } 343 338 ··· 388 381 } 389 382 case V4L2_BUF_TYPE_VBI_CAPTURE: { 390 383 // DEB_EE(("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, data:%p, count:%lu\n", file, data, (unsigned long)count)); 391 - return saa7146_vbi_uops.read(file,data,count,ppos); 384 + if (fh->dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) 385 + return saa7146_vbi_uops.read(file,data,count,ppos); 386 + else 387 + return -EINVAL; 392 388 } 393 389 break; 394 390 default: 395 391 BUG(); 396 392 return 0; 393 + } 394 + } 395 + 396 + static ssize_t fops_write(struct file *file, const char __user *data, size_t count, loff_t *ppos) 397 + { 398 + struct saa7146_fh *fh = file->private_data; 399 + 400 + switch (fh->type) { 401 + case V4L2_BUF_TYPE_VIDEO_CAPTURE: 402 + return -EINVAL; 403 + case V4L2_BUF_TYPE_VBI_CAPTURE: 404 + if (fh->dev->ext_vv_data->vbi_fops.write) 405 + return fh->dev->ext_vv_data->vbi_fops.write(file, data, count, ppos); 406 + else 407 + return -EINVAL; 408 + default: 409 + BUG(); 410 + return -EINVAL; 397 411 } 398 412 } 399 413 ··· 424 396 .open = fops_open, 425 397 .release = fops_release, 426 398 .read = fops_read, 399 + .write = fops_write, 427 400 .poll = fops_poll, 428 401 .mmap = fops_mmap, 429 402 .ioctl = fops_ioctl, ··· 496 467 memset(vv->d_clipping.cpu_addr, 0x0, SAA7146_CLIPPING_MEM); 497 468 498 469 saa7146_video_uops.init(dev,vv); 499 - saa7146_vbi_uops.init(dev,vv); 470 + if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) 471 + saa7146_vbi_uops.init(dev,vv); 500 472 501 473 dev->vv_data = vv; 502 474 dev->vv_callback = &vv_callback;
+10 -3
drivers/media/common/saa7146_hlp.c
··· 562 562 563 563 int b_depth = vv->ov_fmt->depth; 564 564 int b_bpl = vv->ov_fb.fmt.bytesperline; 565 - u32 base = (u32)vv->ov_fb.base; 565 + /* The unsigned long cast is to remove a 64-bit compile warning since 566 + it looks like a 64-bit address is cast to a 32-bit value, even 567 + though the base pointer is really a 32-bit physical address that 568 + goes into a 32-bit DMA register. 569 + FIXME: might not work on some 64-bit platforms, but see the FIXME 570 + in struct v4l2_framebuffer (videodev2.h) for that. 571 + */ 572 + u32 base = (u32)(unsigned long)vv->ov_fb.base; 566 573 567 574 struct saa7146_video_dma vdma1; 568 575 569 576 /* calculate memory offsets for picture, look if we shall top-down-flip */ 570 577 vdma1.pitch = 2*b_bpl; 571 578 if ( 0 == vv->vflip ) { 572 - vdma1.base_even = (u32)base + (w_y * (vdma1.pitch/2)) + (w_x * (b_depth / 8)); 579 + vdma1.base_even = base + (w_y * (vdma1.pitch/2)) + (w_x * (b_depth / 8)); 573 580 vdma1.base_odd = vdma1.base_even + (vdma1.pitch / 2); 574 581 vdma1.prot_addr = vdma1.base_even + (w_height * (vdma1.pitch / 2)); 575 582 } 576 583 else { 577 - vdma1.base_even = (u32)base + ((w_y+w_height) * (vdma1.pitch/2)) + (w_x * (b_depth / 8)); 584 + vdma1.base_even = base + ((w_y+w_height) * (vdma1.pitch/2)) + (w_x * (b_depth / 8)); 578 585 vdma1.base_odd = vdma1.base_even - (vdma1.pitch / 2); 579 586 vdma1.prot_addr = vdma1.base_odd - (w_height * (vdma1.pitch / 2)); 580 587 }
+3 -3
drivers/media/common/saa7146_vbi.c
··· 500 500 } 501 501 502 502 struct saa7146_use_ops saa7146_vbi_uops = { 503 - .init = vbi_init, 504 - .open = vbi_open, 503 + .init = vbi_init, 504 + .open = vbi_open, 505 505 .release = vbi_close, 506 506 .irq_done = vbi_irq_done, 507 - .read = vbi_read, 507 + .read = vbi_read, 508 508 };
+2 -7
drivers/media/common/saa7146_video.c
··· 151 151 152 152 if (V4L2_FIELD_ANY == field) { 153 153 field = (win->w.height > maxh/2) 154 - ? V4L2_FIELD_INTERLACED 155 - : V4L2_FIELD_TOP; 154 + ? V4L2_FIELD_INTERLACED 155 + : V4L2_FIELD_TOP; 156 156 } 157 157 switch (field) { 158 158 case V4L2_FIELD_TOP: ··· 1114 1114 return 0; 1115 1115 } 1116 1116 case VIDIOC_OVERLAY: 1117 - 1118 - 1119 - 1120 - 1121 1117 { 1122 1118 int on = *(int *)arg; 1123 1119 int err = 0; ··· 1354 1358 DEB_CAP(("vbuf:%p\n",vb)); 1355 1359 saa7146_buffer_queue(fh->dev,&vv->video_q,buf); 1356 1360 } 1357 - 1358 1361 1359 1362 static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 1360 1363 {
+20 -13
drivers/media/dvb/b2c2/flexcop-fe-tuner.c
··· 298 298 } 299 299 300 300 static int lgdt3303_pll_set(struct dvb_frontend* fe, 301 - struct dvb_frontend_parameters* params) 301 + struct dvb_frontend_parameters* params) 302 302 { 303 303 struct flexcop_device *fc = fe->dvb->priv; 304 304 u8 buf[4]; ··· 485 485 /* try to figure out the frontend, each card/box can have on of the following list */ 486 486 int flexcop_frontend_init(struct flexcop_device *fc) 487 487 { 488 + struct dvb_frontend_ops *ops; 489 + 488 490 /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */ 489 491 if ((fc->fe = stv0299_attach(&samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) { 490 - fc->fe->ops->set_voltage = flexcop_set_voltage; 492 + ops = fc->fe->ops; 491 493 492 - fc->fe_sleep = fc->fe->ops->sleep; 493 - fc->fe->ops->sleep = flexcop_sleep; 494 + ops->set_voltage = flexcop_set_voltage; 495 + 496 + fc->fe_sleep = ops->sleep; 497 + ops->sleep = flexcop_sleep; 494 498 495 499 fc->dev_type = FC_SKY; 496 500 info("found the stv0299 at i2c address: 0x%02x",samsung_tbmu24112_config.demod_address); ··· 526 522 } else 527 523 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ 528 524 if ((fc->fe = vp310_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) { 529 - fc->fe->ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd; 530 - fc->fe->ops->diseqc_send_burst = flexcop_diseqc_send_burst; 531 - fc->fe->ops->set_tone = flexcop_set_tone; 532 - fc->fe->ops->set_voltage = flexcop_set_voltage; 525 + ops = fc->fe->ops; 533 526 534 - fc->fe_sleep = fc->fe->ops->sleep; 535 - fc->fe->ops->sleep = flexcop_sleep; 527 + ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd; 528 + ops->diseqc_send_burst = flexcop_diseqc_send_burst; 529 + ops->set_tone = flexcop_set_tone; 530 + ops->set_voltage = flexcop_set_voltage; 536 531 537 - fc->dev_type = FC_SKY_OLD; 532 + fc->fe_sleep = ops->sleep; 533 + ops->sleep = flexcop_sleep; 534 + 535 + fc->dev_type = FC_SKY_OLD; 538 536 info("found the vp310 (aka mt312) at i2c address: 0x%02x",skystar23_samsung_tbdu18132_config.demod_address); 539 537 } 540 538 ··· 546 540 } else { 547 541 if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) { 548 542 err("frontend registration failed!"); 549 - if (fc->fe->ops->release != NULL) 550 - fc->fe->ops->release(fc->fe); 543 + ops = fc->fe->ops; 544 + if (ops->release != NULL) 545 + ops->release(fc->fe); 551 546 fc->fe = NULL; 552 547 return -EINVAL; 553 548 }
+3 -1
drivers/media/dvb/b2c2/flexcop-reg.h
··· 39 39 /* FlexCop IBI Registers */ 40 40 #if defined(__LITTLE_ENDIAN) 41 41 #include "flexcop_ibi_value_le.h" 42 - #elif defined(__BIG_ENDIAN) 42 + #else 43 + #if defined(__BIG_ENDIAN) 43 44 #include "flexcop_ibi_value_be.h" 44 45 #else 45 46 #error no endian defined 47 + #endif 46 48 #endif 47 49 48 50 #define fc_data_Tag_ID_DVB 0x3e
+30 -20
drivers/media/dvb/bt8xx/dst.c
··· 1341 1341 return 0; 1342 1342 } 1343 1343 1344 - static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) 1344 + static int dst_set_frontend(struct dvb_frontend* fe, 1345 + struct dvb_frontend_parameters* p, 1346 + unsigned int mode_flags, 1347 + int *delay, 1348 + fe_status_t *status) 1345 1349 { 1346 1350 struct dst_state *state = fe->demodulator_priv; 1347 1351 1348 - dst_set_freq(state, p->frequency); 1349 - dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency); 1352 + if (p != NULL) { 1353 + dst_set_freq(state, p->frequency); 1354 + dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency); 1350 1355 1351 - if (state->dst_type == DST_TYPE_IS_SAT) { 1352 - if (state->type_flags & DST_TYPE_HAS_OBS_REGS) 1353 - dst_set_inversion(state, p->inversion); 1354 - dst_set_fec(state, p->u.qpsk.fec_inner); 1355 - dst_set_symbolrate(state, p->u.qpsk.symbol_rate); 1356 - dst_set_polarization(state); 1357 - dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate); 1356 + if (state->dst_type == DST_TYPE_IS_SAT) { 1357 + if (state->type_flags & DST_TYPE_HAS_OBS_REGS) 1358 + dst_set_inversion(state, p->inversion); 1359 + dst_set_fec(state, p->u.qpsk.fec_inner); 1360 + dst_set_symbolrate(state, p->u.qpsk.symbol_rate); 1361 + dst_set_polarization(state); 1362 + dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate); 1358 1363 1359 - } else if (state->dst_type == DST_TYPE_IS_TERR) 1360 - dst_set_bandwidth(state, p->u.ofdm.bandwidth); 1361 - else if (state->dst_type == DST_TYPE_IS_CABLE) { 1362 - dst_set_fec(state, p->u.qam.fec_inner); 1363 - dst_set_symbolrate(state, p->u.qam.symbol_rate); 1364 - dst_set_modulation(state, p->u.qam.modulation); 1364 + } else if (state->dst_type == DST_TYPE_IS_TERR) 1365 + dst_set_bandwidth(state, p->u.ofdm.bandwidth); 1366 + else if (state->dst_type == DST_TYPE_IS_CABLE) { 1367 + dst_set_fec(state, p->u.qam.fec_inner); 1368 + dst_set_symbolrate(state, p->u.qam.symbol_rate); 1369 + dst_set_modulation(state, p->u.qam.modulation); 1370 + } 1371 + dst_write_tuna(fe); 1365 1372 } 1366 - dst_write_tuna(fe); 1367 1373 1374 + if (!(mode_flags & FE_TUNE_MODE_ONESHOT)) 1375 + dst_read_status(fe, status); 1376 + 1377 + *delay = HZ/10; 1368 1378 return 0; 1369 1379 } 1370 1380 ··· 1455 1445 1456 1446 .release = dst_release, 1457 1447 .init = dst_init, 1458 - .set_frontend = dst_set_frontend, 1448 + .tune = dst_set_frontend, 1459 1449 .get_frontend = dst_get_frontend, 1460 1450 .read_status = dst_read_status, 1461 1451 .read_signal_strength = dst_read_signal_strength, ··· 1479 1469 1480 1470 .release = dst_release, 1481 1471 .init = dst_init, 1482 - .set_frontend = dst_set_frontend, 1472 + .tune = dst_set_frontend, 1483 1473 .get_frontend = dst_get_frontend, 1484 1474 .read_status = dst_read_status, 1485 1475 .read_signal_strength = dst_read_signal_strength, ··· 1506 1496 1507 1497 .release = dst_release, 1508 1498 .init = dst_init, 1509 - .set_frontend = dst_set_frontend, 1499 + .tune = dst_set_frontend, 1510 1500 .get_frontend = dst_get_frontend, 1511 1501 .read_status = dst_read_status, 1512 1502 .read_signal_strength = dst_read_signal_strength,
+2 -1
drivers/media/dvb/bt8xx/dst_ca.c
··· 283 283 hw_buffer->msg[4] = 0x03; 284 284 hw_buffer->msg[5] = length & 0xff; 285 285 hw_buffer->msg[6] = 0x00; 286 + 286 287 /* 287 288 * Need to compute length for EN50221 section 8.3.2, for the time being 288 289 * assuming 8.3.2 is not applicable 289 290 */ 290 291 memcpy(&hw_buffer->msg[7], &p_ca_message->msg[4], length); 291 292 } 293 + 292 294 return 0; 293 295 } 294 - 295 296 296 297 static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply) 297 298 {
-16
drivers/media/dvb/bt8xx/dvb-bt8xx.c
··· 600 600 struct dst_state* state = NULL; 601 601 602 602 switch(type) { 603 - #ifdef BTTV_BOARD_DVICO_DVBT_LITE 604 603 case BTTV_BOARD_DVICO_DVBT_LITE: 605 604 card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter); 606 605 if (card->fe != NULL) { ··· 607 608 card->fe->ops->info.frequency_max = 862000000; 608 609 } 609 610 break; 610 - #endif 611 611 612 - #ifdef BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE 613 612 case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE: 614 613 lgdt330x_reset(card); 615 614 card->fe = lgdt330x_attach(&tdvs_tua6034_config, card->i2c_adapter); 616 615 if (card->fe != NULL) 617 616 dprintk ("dvb_bt8xx: lgdt330x detected\n"); 618 617 break; 619 - #endif 620 618 621 - #ifdef BTTV_BOARD_TWINHAN_VP3021 622 - case BTTV_BOARD_TWINHAN_VP3021: 623 - #else 624 619 case BTTV_BOARD_NEBULA_DIGITV: 625 - #endif 626 620 /* 627 621 * It is possible to determine the correct frontend using the I2C bus (see the Nebula SDK); 628 622 * this would be a cleaner solution than trying each frontend in turn. ··· 804 812 card->irq_err_ignore = 0; 805 813 break; 806 814 807 - #ifdef BTTV_BOARD_DVICO_DVBT_LITE 808 815 case BTTV_BOARD_DVICO_DVBT_LITE: 809 - #endif 810 816 card->gpio_mode = 0x0400C060; 811 817 card->op_sync_orin = 0; 812 818 card->irq_err_ignore = 0; ··· 813 823 * DA_APP(parallel) */ 814 824 break; 815 825 816 - #ifdef BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE 817 826 case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE: 818 - #endif 819 827 card->gpio_mode = 0x0400c060; 820 828 card->op_sync_orin = BT878_RISC_SYNC_MASK; 821 829 card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR; 822 830 break; 823 831 824 - #ifdef BTTV_BOARD_TWINHAN_VP3021 825 - case BTTV_BOARD_TWINHAN_VP3021: 826 - #else 827 832 case BTTV_BOARD_NEBULA_DIGITV: 828 - #endif 829 833 case BTTV_BOARD_AVDVBT_761: 830 834 card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5); 831 835 card->op_sync_orin = 0;
+10 -10
drivers/media/dvb/cinergyT2/Kconfig
··· 21 21 config DVB_CINERGYT2_STREAM_URB_COUNT 22 22 int "Number of queued USB Request Blocks for Highspeed Stream Transfers" 23 23 depends on DVB_CINERGYT2_TUNING 24 - default "32" 24 + default "32" 25 25 help 26 26 USB Request Blocks for Highspeed Stream transfers are scheduled in 27 27 a queue for the Host Controller. 28 28 29 29 Usually the default value is a safe choice. 30 30 31 - You may increase this number if you are using this device in a 32 - Server Environment with many high-traffic USB Highspeed devices 31 + You may increase this number if you are using this device in a 32 + Server Environment with many high-traffic USB Highspeed devices 33 33 sharing the same USB bus. 34 34 35 35 36 36 config DVB_CINERGYT2_STREAM_BUF_SIZE 37 37 int "Size of URB Stream Buffers for Highspeed Transfers" 38 38 depends on DVB_CINERGYT2_TUNING 39 - default "512" 39 + default "512" 40 40 help 41 41 Should be a multiple of native buffer size of 512 bytes. 42 42 Default value is a safe choice. 43 43 44 - You may increase this number if you are using this device in a 45 - Server Environment with many high-traffic USB Highspeed devices 44 + You may increase this number if you are using this device in a 45 + Server Environment with many high-traffic USB Highspeed devices 46 46 sharing the same USB bus. 47 47 48 48 49 49 config DVB_CINERGYT2_QUERY_INTERVAL 50 50 int "Status update interval [milliseconds]" 51 51 depends on DVB_CINERGYT2_TUNING 52 - default "250" 52 + default "250" 53 53 help 54 54 This is the interval for status readouts from the demodulator. 55 55 You may try lower values if you need more responsive signal quality ··· 64 64 config DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE 65 65 bool "Register the onboard IR Remote Control Receiver as Input Device" 66 66 depends on DVB_CINERGYT2_TUNING 67 - default "yes" 67 + default "yes" 68 68 help 69 - Enable this option if you want to use the onboard Infrared Remote 69 + Enable this option if you want to use the onboard Infrared Remote 70 70 Control Receiver as Linux-Input device. 71 71 72 72 Right now only the keycode table for the default Remote Control ··· 77 77 config DVB_CINERGYT2_RC_QUERY_INTERVAL 78 78 int "Infrared Remote Controller update interval [milliseconds]" 79 79 depends on DVB_CINERGYT2_TUNING && DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE 80 - default "50" 80 + default "50" 81 81 help 82 82 If you have a very fast-repeating remote control you can try lower 83 83 values, for normal consumer receivers the default value should be
+57 -29
drivers/media/dvb/cinergyT2/cinergyT2.c
··· 131 131 132 132 wait_queue_head_t poll_wq; 133 133 int pending_fe_events; 134 + int disconnect_pending; 135 + atomic_t inuse; 134 136 135 137 void *streambuf; 136 138 dma_addr_t streambuf_dmahandle; ··· 345 343 struct dvb_demux *demux = dvbdmxfeed->demux; 346 344 struct cinergyt2 *cinergyt2 = demux->priv; 347 345 348 - if (down_interruptible(&cinergyt2->sem)) 346 + if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 349 347 return -ERESTARTSYS; 350 348 351 349 if (cinergyt2->streaming == 0) ··· 361 359 struct dvb_demux *demux = dvbdmxfeed->demux; 362 360 struct cinergyt2 *cinergyt2 = demux->priv; 363 361 364 - if (down_interruptible(&cinergyt2->sem)) 362 + if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 365 363 return -ERESTARTSYS; 366 364 367 365 if (--cinergyt2->streaming == 0) ··· 481 479 { 482 480 struct dvb_device *dvbdev = file->private_data; 483 481 struct cinergyt2 *cinergyt2 = dvbdev->priv; 484 - int err; 482 + int err = -ERESTARTSYS; 485 483 486 - if ((err = dvb_generic_open(inode, file))) 487 - return err; 488 - 489 - if (down_interruptible(&cinergyt2->sem)) 484 + if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 490 485 return -ERESTARTSYS; 486 + 487 + if ((err = dvb_generic_open(inode, file))) { 488 + up(&cinergyt2->sem); 489 + return err; 490 + } 491 + 491 492 492 493 if ((file->f_flags & O_ACCMODE) != O_RDONLY) { 493 494 cinergyt2_sleep(cinergyt2, 0); 494 495 schedule_delayed_work(&cinergyt2->query_work, HZ/2); 495 496 } 496 497 498 + atomic_inc(&cinergyt2->inuse); 499 + 497 500 up(&cinergyt2->sem); 498 501 return 0; 502 + } 503 + 504 + static void cinergyt2_unregister(struct cinergyt2 *cinergyt2) 505 + { 506 + dvb_unregister_device(cinergyt2->fedev); 507 + dvb_unregister_adapter(&cinergyt2->adapter); 508 + 509 + cinergyt2_free_stream_urbs(cinergyt2); 510 + kfree(cinergyt2); 499 511 } 500 512 501 513 static int cinergyt2_release (struct inode *inode, struct file *file) ··· 520 504 if (down_interruptible(&cinergyt2->sem)) 521 505 return -ERESTARTSYS; 522 506 523 - if ((file->f_flags & O_ACCMODE) != O_RDONLY) { 507 + if (!cinergyt2->disconnect_pending && (file->f_flags & O_ACCMODE) != O_RDONLY) { 524 508 cancel_delayed_work(&cinergyt2->query_work); 525 509 flush_scheduled_work(); 526 510 cinergyt2_sleep(cinergyt2, 1); 527 511 } 528 512 529 513 up(&cinergyt2->sem); 514 + 515 + if (atomic_dec_and_test(&cinergyt2->inuse) && cinergyt2->disconnect_pending) { 516 + warn("delayed unregister in release"); 517 + cinergyt2_unregister(cinergyt2); 518 + } 530 519 531 520 return dvb_generic_release(inode, file); 532 521 } ··· 540 519 { 541 520 struct dvb_device *dvbdev = file->private_data; 542 521 struct cinergyt2 *cinergyt2 = dvbdev->priv; 522 + 523 + if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 524 + return -ERESTARTSYS; 525 + 543 526 poll_wait(file, &cinergyt2->poll_wq, wait); 527 + 528 + up(&cinergyt2->sem); 529 + 544 530 return (POLLIN | POLLRDNORM | POLLPRI); 545 531 } 546 532 ··· 592 564 (__u16 __user *) arg); 593 565 594 566 case FE_READ_UNCORRECTED_BLOCKS: 595 - /* UNC are already converted to host byte order... */ 596 - return put_user(stat->uncorrected_block_count, 597 - (__u32 __user *) arg); 567 + { 568 + uint32_t unc_count; 598 569 570 + unc_count = stat->uncorrected_block_count; 571 + stat->uncorrected_block_count = 0; 572 + 573 + /* UNC are already converted to host byte order... */ 574 + return put_user(unc_count,(__u32 __user *) arg); 575 + } 599 576 case FE_SET_FRONTEND: 600 577 { 601 578 struct dvbt_set_parameters_msg *param = &cinergyt2->param; ··· 613 580 if (copy_from_user(&p, (void __user*) arg, sizeof(p))) 614 581 return -EFAULT; 615 582 616 - if (down_interruptible(&cinergyt2->sem)) 583 + if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 617 584 return -ERESTARTSYS; 618 585 619 586 param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; ··· 724 691 struct cinergyt2_rc_event rc_events[12]; 725 692 int n, len, i; 726 693 727 - if (down_interruptible(&cinergyt2->sem)) 694 + if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 728 695 return; 729 696 730 697 len = cinergyt2_command(cinergyt2, buf, sizeof(buf), ··· 819 786 static void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2) 820 787 { 821 788 cancel_delayed_work(&cinergyt2->rc_query_work); 822 - flush_scheduled_work(); 823 789 input_unregister_device(cinergyt2->rc_input_dev); 824 790 } 825 791 ··· 849 817 uint8_t lock_bits; 850 818 uint32_t unc; 851 819 852 - if (down_interruptible(&cinergyt2->sem)) 820 + if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 853 821 return; 854 822 855 823 unc = s->uncorrected_block_count; ··· 949 917 { 950 918 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); 951 919 952 - if (down_interruptible(&cinergyt2->sem)) 953 - return; 920 + flush_scheduled_work(); 954 921 955 922 cinergyt2_unregister_rc(cinergyt2); 956 923 957 - cinergyt2->demux.dmx.close(&cinergyt2->demux.dmx); 958 - dvb_net_release(&cinergyt2->dvbnet); 959 - dvb_dmxdev_release(&cinergyt2->dmxdev); 960 - dvb_dmx_release(&cinergyt2->demux); 961 - dvb_unregister_device(cinergyt2->fedev); 962 - dvb_unregister_adapter(&cinergyt2->adapter); 924 + cancel_delayed_work(&cinergyt2->query_work); 925 + wake_up_interruptible(&cinergyt2->poll_wq); 963 926 964 - cinergyt2_free_stream_urbs(cinergyt2); 965 - up(&cinergyt2->sem); 966 - kfree(cinergyt2); 927 + cinergyt2->demux.dmx.close(&cinergyt2->demux.dmx); 928 + cinergyt2->disconnect_pending = 1; 929 + 930 + if (!atomic_read(&cinergyt2->inuse)) 931 + cinergyt2_unregister(cinergyt2); 967 932 } 968 933 969 934 static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state) 970 935 { 971 936 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); 972 937 973 - if (down_interruptible(&cinergyt2->sem)) 938 + if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 974 939 return -ERESTARTSYS; 975 940 976 941 if (state.event > PM_EVENT_ON) { ··· 990 961 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); 991 962 struct dvbt_set_parameters_msg *param = &cinergyt2->param; 992 963 993 - if (down_interruptible(&cinergyt2->sem)) 964 + if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 994 965 return -ERESTARTSYS; 995 966 996 967 if (!cinergyt2->sleeping) { ··· 1043 1014 1044 1015 MODULE_LICENSE("GPL"); 1045 1016 MODULE_AUTHOR("Holger Waechtler, Daniel Mack"); 1046 -
+1 -1
drivers/media/dvb/dvb-core/Kconfig
··· 5 5 help 6 6 DVB core utility functions for device handling, software fallbacks etc. 7 7 Say Y when you have a DVB card and want to use it. Say Y if your want 8 - to build your drivers outside the kernel, but need the DVB core. All 8 + to build your drivers outside the kernel, but need the DVB core. All 9 9 in-kernel drivers will select this automatically if needed. 10 10 If unsure say N. 11 11
+1 -1
drivers/media/dvb/dvb-core/Makefile
··· 3 3 # 4 4 5 5 dvb-core-objs = dvbdev.o dmxdev.o dvb_demux.o dvb_filter.o \ 6 - dvb_ca_en50221.o dvb_frontend.o \ 6 + dvb_ca_en50221.o dvb_frontend.o \ 7 7 dvb_net.o dvb_ringbuffer.o 8 8 9 9 obj-$(CONFIG_DVB_CORE) += dvb-core.o
+1 -3
drivers/media/dvb/dvb-core/dvb_ca_en50221.c
··· 1745 1745 1746 1746 for (i = 0; i < ca->slot_count; i++) { 1747 1747 dvb_ca_en50221_slot_shutdown(ca, i); 1748 - if (ca->slot_info[i].rx_buffer.data != NULL) { 1749 - vfree(ca->slot_info[i].rx_buffer.data); 1750 - } 1748 + vfree(ca->slot_info[i].rx_buffer.data); 1751 1749 } 1752 1750 kfree(ca->slot_info); 1753 1751 dvb_unregister_device(ca->dvbdev);
+8 -8
drivers/media/dvb/dvb-core/dvb_filter.c
··· 409 409 410 410 if ((inbuf[6] & 0xc0) == 0x80){ /* mpeg2 */ 411 411 if (buf[7] & PTS_ONLY) 412 - pts = buf+9; 412 + pts = buf+9; 413 413 else pts = NULL; 414 414 buf = inbuf + 9 + inbuf[8]; 415 415 } else { /* mpeg1 */ 416 416 for (buf = inbuf + 6; *buf == 0xff; buf++) 417 - if (buf == inbuf + 6 + 16) { 418 - break; 419 - } 417 + if (buf == inbuf + 6 + 16) { 418 + break; 419 + } 420 420 if ((*buf & 0xc0) == 0x40) 421 - buf += 2; 421 + buf += 2; 422 422 skip = mpeg1_skip_table [*buf >> 4]; 423 423 if (skip == 5 || skip == 10) pts = buf; 424 424 else pts = NULL; ··· 529 529 pic->picture_header = 0; 530 530 pic->sequence_header_data 531 531 = ( INIT_HORIZONTAL_SIZE << 20 ) 532 - | ( INIT_VERTICAL_SIZE << 8 ) 533 - | ( INIT_ASPECT_RATIO << 4 ) 534 - | ( INIT_FRAME_RATE ); 532 + | ( INIT_VERTICAL_SIZE << 8 ) 533 + | ( INIT_ASPECT_RATIO << 4 ) 534 + | ( INIT_FRAME_RATE ); 535 535 pic->mpeg1_flag = 0; 536 536 pic->vinfo.horizontal_size 537 537 = INIT_DISP_HORIZONTAL_SIZE;
+181 -134
drivers/media/dvb/dvb-core/dvb_frontend.c
··· 92 92 93 93 struct dvb_frontend_private { 94 94 95 + /* thread/frontend values */ 95 96 struct dvb_device *dvbdev; 96 97 struct dvb_frontend_parameters parameters; 97 98 struct dvb_fe_events events; ··· 101 100 wait_queue_head_t wait_queue; 102 101 pid_t thread_pid; 103 102 unsigned long release_jiffies; 104 - int state; 105 - int bending; 106 - int lnb_drift; 107 - int inversion; 108 - int auto_step; 109 - int auto_sub_step; 110 - int started_auto_step; 111 - int min_delay; 112 - int max_drift; 113 - int step_size; 114 - int exit; 115 - int wakeup; 103 + unsigned int exit; 104 + unsigned int wakeup; 116 105 fe_status_t status; 117 - fe_sec_tone_mode_t tone; 106 + unsigned long tune_mode_flags; 107 + unsigned int delay; 108 + 109 + /* swzigzag values */ 110 + unsigned int state; 111 + unsigned int bending; 112 + int lnb_drift; 113 + unsigned int inversion; 114 + unsigned int auto_step; 115 + unsigned int auto_sub_step; 116 + unsigned int started_auto_step; 117 + unsigned int min_delay; 118 + unsigned int max_drift; 119 + unsigned int step_size; 120 + int quality; 121 + unsigned int check_wrapped; 118 122 }; 119 123 120 124 ··· 214 208 fe->ops->init(fe); 215 209 } 216 210 217 - static void update_delay(int *quality, int *delay, int min_delay, int locked) 211 + static void dvb_frontend_swzigzag_update_delay(struct dvb_frontend_private *fepriv, int locked) 218 212 { 219 - int q2; 213 + int q2; 220 214 221 - dprintk ("%s\n", __FUNCTION__); 215 + dprintk ("%s\n", __FUNCTION__); 222 216 223 - if (locked) 224 - (*quality) = (*quality * 220 + 36*256) / 256; 225 - else 226 - (*quality) = (*quality * 220 + 0) / 256; 217 + if (locked) 218 + (fepriv->quality) = (fepriv->quality * 220 + 36*256) / 256; 219 + else 220 + (fepriv->quality) = (fepriv->quality * 220 + 0) / 256; 227 221 228 - q2 = *quality - 128; 229 - q2 *= q2; 222 + q2 = fepriv->quality - 128; 223 + q2 *= q2; 230 224 231 - *delay = min_delay + q2 * HZ / (128*128); 225 + fepriv->delay = fepriv->min_delay + q2 * HZ / (128*128); 232 226 } 233 227 234 228 /** ··· 238 232 * @param check_wrapped Checks if an iteration has completed. DO NOT SET ON THE FIRST ATTEMPT 239 233 * @returns Number of complete iterations that have been performed. 240 234 */ 241 - static int dvb_frontend_autotune(struct dvb_frontend *fe, int check_wrapped) 235 + static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wrapped) 242 236 { 243 237 int autoinversion; 244 238 int ready = 0; ··· 327 321 return 0; 328 322 } 329 323 324 + static void dvb_frontend_swzigzag(struct dvb_frontend *fe) 325 + { 326 + fe_status_t s; 327 + struct dvb_frontend_private *fepriv = fe->frontend_priv; 328 + 329 + /* if we've got no parameters, just keep idling */ 330 + if (fepriv->state & FESTATE_IDLE) { 331 + fepriv->delay = 3*HZ; 332 + fepriv->quality = 0; 333 + return; 334 + } 335 + 336 + /* in SCAN mode, we just set the frontend when asked and leave it alone */ 337 + if (fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT) { 338 + if (fepriv->state & FESTATE_RETUNE) { 339 + if (fe->ops->set_frontend) 340 + fe->ops->set_frontend(fe, &fepriv->parameters); 341 + fepriv->state = FESTATE_TUNED; 342 + } 343 + fepriv->delay = 3*HZ; 344 + fepriv->quality = 0; 345 + return; 346 + } 347 + 348 + /* get the frontend status */ 349 + if (fepriv->state & FESTATE_RETUNE) { 350 + s = 0; 351 + } else { 352 + if (fe->ops->read_status) 353 + fe->ops->read_status(fe, &s); 354 + if (s != fepriv->status) { 355 + dvb_frontend_add_event(fe, s); 356 + fepriv->status = s; 357 + } 358 + } 359 + 360 + /* if we're not tuned, and we have a lock, move to the TUNED state */ 361 + if ((fepriv->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) { 362 + dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK); 363 + fepriv->state = FESTATE_TUNED; 364 + 365 + /* if we're tuned, then we have determined the correct inversion */ 366 + if ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) && 367 + (fepriv->parameters.inversion == INVERSION_AUTO)) { 368 + fepriv->parameters.inversion = fepriv->inversion; 369 + } 370 + return; 371 + } 372 + 373 + /* if we are tuned already, check we're still locked */ 374 + if (fepriv->state & FESTATE_TUNED) { 375 + dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK); 376 + 377 + /* we're tuned, and the lock is still good... */ 378 + if (s & FE_HAS_LOCK) { 379 + return; 380 + } else { /* if we _WERE_ tuned, but now don't have a lock */ 381 + fepriv->state = FESTATE_ZIGZAG_FAST; 382 + fepriv->started_auto_step = fepriv->auto_step; 383 + fepriv->check_wrapped = 0; 384 + } 385 + } 386 + 387 + /* don't actually do anything if we're in the LOSTLOCK state, 388 + * the frontend is set to FE_CAN_RECOVER, and the max_drift is 0 */ 389 + if ((fepriv->state & FESTATE_LOSTLOCK) && 390 + (fe->ops->info.caps & FE_CAN_RECOVER) && (fepriv->max_drift == 0)) { 391 + dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK); 392 + return; 393 + } 394 + 395 + /* don't do anything if we're in the DISEQC state, since this 396 + * might be someone with a motorized dish controlled by DISEQC. 397 + * If its actually a re-tune, there will be a SET_FRONTEND soon enough. */ 398 + if (fepriv->state & FESTATE_DISEQC) { 399 + dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK); 400 + return; 401 + } 402 + 403 + /* if we're in the RETUNE state, set everything up for a brand 404 + * new scan, keeping the current inversion setting, as the next 405 + * tune is _very_ likely to require the same */ 406 + if (fepriv->state & FESTATE_RETUNE) { 407 + fepriv->lnb_drift = 0; 408 + fepriv->auto_step = 0; 409 + fepriv->auto_sub_step = 0; 410 + fepriv->started_auto_step = 0; 411 + fepriv->check_wrapped = 0; 412 + } 413 + 414 + /* fast zigzag. */ 415 + if ((fepriv->state & FESTATE_SEARCHING_FAST) || (fepriv->state & FESTATE_RETUNE)) { 416 + fepriv->delay = fepriv->min_delay; 417 + 418 + /* peform a tune */ 419 + if (dvb_frontend_swzigzag_autotune(fe, fepriv->check_wrapped)) { 420 + /* OK, if we've run out of trials at the fast speed. 421 + * Drop back to slow for the _next_ attempt */ 422 + fepriv->state = FESTATE_SEARCHING_SLOW; 423 + fepriv->started_auto_step = fepriv->auto_step; 424 + return; 425 + } 426 + fepriv->check_wrapped = 1; 427 + 428 + /* if we've just retuned, enter the ZIGZAG_FAST state. 429 + * This ensures we cannot return from an 430 + * FE_SET_FRONTEND ioctl before the first frontend tune 431 + * occurs */ 432 + if (fepriv->state & FESTATE_RETUNE) { 433 + fepriv->state = FESTATE_TUNING_FAST; 434 + } 435 + } 436 + 437 + /* slow zigzag */ 438 + if (fepriv->state & FESTATE_SEARCHING_SLOW) { 439 + dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK); 440 + 441 + /* Note: don't bother checking for wrapping; we stay in this 442 + * state until we get a lock */ 443 + dvb_frontend_swzigzag_autotune(fe, 0); 444 + } 445 + } 446 + 330 447 static int dvb_frontend_is_exiting(struct dvb_frontend *fe) 331 448 { 332 449 struct dvb_frontend_private *fepriv = fe->frontend_priv; ··· 459 330 460 331 if (fepriv->dvbdev->writers == 1) 461 332 if (time_after(jiffies, fepriv->release_jiffies + 462 - dvb_shutdown_timeout * HZ)) 333 + dvb_shutdown_timeout * HZ)) 463 334 return 1; 464 335 465 336 return 0; ··· 484 355 wake_up_interruptible(&fepriv->wait_queue); 485 356 } 486 357 487 - /* 488 - * FIXME: use linux/kthread.h 489 - */ 490 358 static int dvb_frontend_thread(void *data) 491 359 { 492 360 struct dvb_frontend *fe = data; 493 361 struct dvb_frontend_private *fepriv = fe->frontend_priv; 494 362 unsigned long timeout; 495 363 char name [15]; 496 - int quality = 0, delay = 3*HZ; 497 364 fe_status_t s; 498 - int check_wrapped = 0; 365 + struct dvb_frontend_parameters *params; 499 366 500 367 dprintk("%s\n", __FUNCTION__); 501 368 ··· 502 377 sigfillset(&current->blocked); 503 378 unlock_kernel(); 504 379 380 + fepriv->check_wrapped = 0; 381 + fepriv->quality = 0; 382 + fepriv->delay = 3*HZ; 505 383 fepriv->status = 0; 506 384 dvb_frontend_init(fe); 507 385 fepriv->wakeup = 0; ··· 514 386 515 387 timeout = wait_event_interruptible_timeout(fepriv->wait_queue, 516 388 dvb_frontend_should_wakeup(fe), 517 - delay); 389 + fepriv->delay); 518 390 if (0 != dvb_frontend_is_exiting(fe)) { 519 391 /* got signal or quitting */ 520 392 break; ··· 525 397 if (down_interruptible(&fepriv->sem)) 526 398 break; 527 399 528 - /* if we've got no parameters, just keep idling */ 529 - if (fepriv->state & FESTATE_IDLE) { 530 - delay = 3*HZ; 531 - quality = 0; 532 - continue; 533 - } 400 + /* do an iteration of the tuning loop */ 401 + if (fe->ops->tune) { 402 + /* have we been asked to retune? */ 403 + params = NULL; 404 + if (fepriv->state & FESTATE_RETUNE) { 405 + params = &fepriv->parameters; 406 + fepriv->state = FESTATE_TUNED; 407 + } 534 408 535 - /* get the frontend status */ 536 - if (fepriv->state & FESTATE_RETUNE) { 537 - s = 0; 538 - } else { 539 - if (fe->ops->read_status) 540 - fe->ops->read_status(fe, &s); 409 + fe->ops->tune(fe, params, fepriv->tune_mode_flags, &fepriv->delay, &s); 541 410 if (s != fepriv->status) { 542 411 dvb_frontend_add_event(fe, s); 543 412 fepriv->status = s; 544 413 } 545 - } 546 - /* if we're not tuned, and we have a lock, move to the TUNED state */ 547 - if ((fepriv->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) { 548 - update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK); 549 - fepriv->state = FESTATE_TUNED; 550 - 551 - /* if we're tuned, then we have determined the correct inversion */ 552 - if ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) && 553 - (fepriv->parameters.inversion == INVERSION_AUTO)) { 554 - fepriv->parameters.inversion = fepriv->inversion; 555 - } 556 - continue; 557 - } 558 - 559 - /* if we are tuned already, check we're still locked */ 560 - if (fepriv->state & FESTATE_TUNED) { 561 - update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK); 562 - 563 - /* we're tuned, and the lock is still good... */ 564 - if (s & FE_HAS_LOCK) 565 - continue; 566 - else { /* if we _WERE_ tuned, but now don't have a lock */ 567 - fepriv->state = FESTATE_ZIGZAG_FAST; 568 - fepriv->started_auto_step = fepriv->auto_step; 569 - check_wrapped = 0; 570 - } 571 - } 572 - 573 - /* don't actually do anything if we're in the LOSTLOCK state, 574 - * the frontend is set to FE_CAN_RECOVER, and the max_drift is 0 */ 575 - if ((fepriv->state & FESTATE_LOSTLOCK) && 576 - (fe->ops->info.caps & FE_CAN_RECOVER) && (fepriv->max_drift == 0)) { 577 - update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK); 578 - continue; 579 - } 580 - 581 - /* don't do anything if we're in the DISEQC state, since this 582 - * might be someone with a motorized dish controlled by DISEQC. 583 - * If its actually a re-tune, there will be a SET_FRONTEND soon enough. */ 584 - if (fepriv->state & FESTATE_DISEQC) { 585 - update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK); 586 - continue; 587 - } 588 - 589 - /* if we're in the RETUNE state, set everything up for a brand 590 - * new scan, keeping the current inversion setting, as the next 591 - * tune is _very_ likely to require the same */ 592 - if (fepriv->state & FESTATE_RETUNE) { 593 - fepriv->lnb_drift = 0; 594 - fepriv->auto_step = 0; 595 - fepriv->auto_sub_step = 0; 596 - fepriv->started_auto_step = 0; 597 - check_wrapped = 0; 598 - } 599 - 600 - /* fast zigzag. */ 601 - if ((fepriv->state & FESTATE_SEARCHING_FAST) || (fepriv->state & FESTATE_RETUNE)) { 602 - delay = fepriv->min_delay; 603 - 604 - /* peform a tune */ 605 - if (dvb_frontend_autotune(fe, check_wrapped)) { 606 - /* OK, if we've run out of trials at the fast speed. 607 - * Drop back to slow for the _next_ attempt */ 608 - fepriv->state = FESTATE_SEARCHING_SLOW; 609 - fepriv->started_auto_step = fepriv->auto_step; 610 - continue; 611 - } 612 - check_wrapped = 1; 613 - 614 - /* if we've just retuned, enter the ZIGZAG_FAST state. 615 - * This ensures we cannot return from an 616 - * FE_SET_FRONTEND ioctl before the first frontend tune 617 - * occurs */ 618 - if (fepriv->state & FESTATE_RETUNE) { 619 - fepriv->state = FESTATE_TUNING_FAST; 620 - } 621 - } 622 - 623 - /* slow zigzag */ 624 - if (fepriv->state & FESTATE_SEARCHING_SLOW) { 625 - update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK); 626 - 627 - /* Note: don't bother checking for wrapping; we stay in this 628 - * state until we get a lock */ 629 - dvb_frontend_autotune(fe, 0); 414 + } else { 415 + dvb_frontend_swzigzag(fe); 630 416 } 631 417 } 632 418 ··· 775 733 err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg); 776 734 fepriv->state = FESTATE_DISEQC; 777 735 fepriv->status = 0; 778 - fepriv->tone = (fe_sec_tone_mode_t) parg; 779 736 } 780 737 break; 781 738 ··· 788 747 789 748 case FE_DISHNETWORK_SEND_LEGACY_CMD: 790 749 if (fe->ops->dishnetwork_send_legacy_command) { 791 - err = fe->ops->dishnetwork_send_legacy_command(fe, (unsigned int) parg); 750 + err = fe->ops->dishnetwork_send_legacy_command(fe, (unsigned long) parg); 792 751 fepriv->state = FESTATE_DISEQC; 793 752 fepriv->status = 0; 794 753 } else if (fe->ops->set_voltage) { ··· 808 767 * initialization, so parg is 8 bits and does not 809 768 * include the initialization or start bit 810 769 */ 811 - unsigned int cmd = ((unsigned int) parg) << 1; 770 + unsigned long cmd = ((unsigned long) parg) << 1; 812 771 struct timeval nexttime; 813 772 struct timeval tv[10]; 814 773 int i; 815 774 u8 last = 1; 816 775 if (dvb_frontend_debug) 817 - printk("%s switch command: 0x%04x\n", __FUNCTION__, cmd); 776 + printk("%s switch command: 0x%04lx\n", __FUNCTION__, cmd); 818 777 do_gettimeofday(&nexttime); 819 778 if (dvb_frontend_debug) 820 779 memcpy(&tv[0], &nexttime, sizeof(struct timeval)); ··· 855 814 856 815 case FE_ENABLE_HIGH_LNB_VOLTAGE: 857 816 if (fe->ops->enable_high_lnb_voltage) 858 - err = fe->ops->enable_high_lnb_voltage(fe, (int) parg); 817 + err = fe->ops->enable_high_lnb_voltage(fe, (long) parg); 859 818 break; 860 819 861 820 case FE_SET_FRONTEND: { ··· 932 891 err = fe->ops->get_frontend(fe, (struct dvb_frontend_parameters*) parg); 933 892 } 934 893 break; 894 + 895 + case FE_SET_FRONTEND_TUNE_MODE: 896 + fepriv->tune_mode_flags = (unsigned long) parg; 897 + break; 935 898 }; 936 899 937 900 up (&fepriv->sem); ··· 977 932 978 933 /* empty event queue */ 979 934 fepriv->events.eventr = fepriv->events.eventw = 0; 935 + 936 + /* normal tune mode when opened R/W */ 937 + fepriv->tune_mode_flags &= ~FE_TUNE_MODE_ONESHOT; 980 938 } 981 939 982 940 return ret; ··· 1038 990 init_MUTEX (&fepriv->events.sem); 1039 991 fe->dvb = dvb; 1040 992 fepriv->inversion = INVERSION_OFF; 1041 - fepriv->tone = SEC_TONE_OFF; 1042 993 1043 994 printk ("DVB: registering frontend %i (%s)...\n", 1044 995 fe->dvb->num,
+13 -3
drivers/media/dvb/dvb-core/dvb_frontend.h
··· 58 58 int (*init)(struct dvb_frontend* fe); 59 59 int (*sleep)(struct dvb_frontend* fe); 60 60 61 + /* if this is set, it overrides the default swzigzag */ 62 + int (*tune)(struct dvb_frontend* fe, 63 + struct dvb_frontend_parameters* params, 64 + unsigned int mode_flags, 65 + int *delay, 66 + fe_status_t *status); 67 + 68 + /* these two are only used for the swzigzag code */ 61 69 int (*set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); 62 - int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); 63 70 int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings); 71 + 72 + int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); 64 73 65 74 int (*read_status)(struct dvb_frontend* fe, fe_status_t* status); 66 75 int (*read_ber)(struct dvb_frontend* fe, u32* ber); ··· 83 74 int (*diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd); 84 75 int (*set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone); 85 76 int (*set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage); 86 - int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, int arg); 87 - int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned int cmd); 77 + int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg); 78 + int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd); 79 + int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable); 88 80 }; 89 81 90 82 #define MAX_EVENT 8
+3 -3
drivers/media/dvb/dvb-core/dvb_net.c
··· 1222 1222 return if_num; 1223 1223 } 1224 1224 1225 - static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned int num) 1225 + static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned long num) 1226 1226 { 1227 1227 struct net_device *net = dvbnet->device[num]; 1228 1228 struct dvb_net_priv *priv; ··· 1296 1296 1297 1297 if (!capable(CAP_SYS_ADMIN)) 1298 1298 return -EPERM; 1299 - if ((unsigned int) parg >= DVB_NET_DEVICES_MAX) 1299 + if ((unsigned long) parg >= DVB_NET_DEVICES_MAX) 1300 1300 return -EINVAL; 1301 - ret = dvb_net_remove_if(dvbnet, (unsigned int) parg); 1301 + ret = dvb_net_remove_if(dvbnet, (unsigned long) parg); 1302 1302 if (!ret) 1303 1303 module_put(dvbdev->adapter->module); 1304 1304 return ret;
+16 -16
drivers/media/dvb/dvb-core/dvb_ringbuffer.c
··· 112 112 split = (rbuf->pread + len > rbuf->size) ? rbuf->size - rbuf->pread : 0; 113 113 if (split > 0) { 114 114 if (!usermem) 115 - memcpy(buf, rbuf->data+rbuf->pread, split); 115 + memcpy(buf, rbuf->data+rbuf->pread, split); 116 116 else 117 - if (copy_to_user(buf, rbuf->data+rbuf->pread, split)) 118 - return -EFAULT; 117 + if (copy_to_user(buf, rbuf->data+rbuf->pread, split)) 118 + return -EFAULT; 119 119 buf += split; 120 120 todo -= split; 121 121 rbuf->pread = 0; ··· 124 124 memcpy(buf, rbuf->data+rbuf->pread, todo); 125 125 else 126 126 if (copy_to_user(buf, rbuf->data+rbuf->pread, todo)) 127 - return -EFAULT; 127 + return -EFAULT; 128 128 129 129 rbuf->pread = (rbuf->pread + todo) % rbuf->size; 130 130 ··· 167 167 } 168 168 169 169 ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx, 170 - int offset, u8* buf, size_t len, int usermem) 170 + int offset, u8* buf, size_t len, int usermem) 171 171 { 172 172 size_t todo; 173 173 size_t split; ··· 183 183 split = ((idx + len) > rbuf->size) ? rbuf->size - idx : 0; 184 184 if (split > 0) { 185 185 if (!usermem) 186 - memcpy(buf, rbuf->data+idx, split); 186 + memcpy(buf, rbuf->data+idx, split); 187 187 else 188 - if (copy_to_user(buf, rbuf->data+idx, split)) 189 - return -EFAULT; 188 + if (copy_to_user(buf, rbuf->data+idx, split)) 189 + return -EFAULT; 190 190 buf += split; 191 191 todo -= split; 192 192 idx = 0; ··· 195 195 memcpy(buf, rbuf->data+idx, todo); 196 196 else 197 197 if (copy_to_user(buf, rbuf->data+idx, todo)) 198 - return -EFAULT; 198 + return -EFAULT; 199 199 200 200 return len; 201 201 } ··· 209 209 // clean up disposed packets 210 210 while(dvb_ringbuffer_avail(rbuf) > DVB_RINGBUFFER_PKTHDRSIZE) { 211 211 if (DVB_RINGBUFFER_PEEK(rbuf, 2) == PKT_DISPOSED) { 212 - pktlen = DVB_RINGBUFFER_PEEK(rbuf, 0) << 8; 213 - pktlen |= DVB_RINGBUFFER_PEEK(rbuf, 1); 214 - DVB_RINGBUFFER_SKIP(rbuf, pktlen + DVB_RINGBUFFER_PKTHDRSIZE); 212 + pktlen = DVB_RINGBUFFER_PEEK(rbuf, 0) << 8; 213 + pktlen |= DVB_RINGBUFFER_PEEK(rbuf, 1); 214 + DVB_RINGBUFFER_SKIP(rbuf, pktlen + DVB_RINGBUFFER_PKTHDRSIZE); 215 215 } else { 216 - // first packet is not disposed, so we stop cleaning now 217 - break; 216 + // first packet is not disposed, so we stop cleaning now 217 + break; 218 218 } 219 219 } 220 220 } ··· 242 242 curpktstatus = rbuf->data[(idx + 2) % rbuf->size]; 243 243 244 244 if (curpktstatus == PKT_READY) { 245 - *pktlen = curpktlen; 246 - return idx; 245 + *pktlen = curpktlen; 246 + return idx; 247 247 } 248 248 249 249 consumed += curpktlen + DVB_RINGBUFFER_PKTHDRSIZE;
+4 -4
drivers/media/dvb/dvb-core/dvb_ringbuffer.h
··· 106 106 ** returns number of bytes transferred or -EFAULT 107 107 */ 108 108 extern ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf, 109 - size_t len, int usermem); 109 + size_t len, int usermem); 110 110 111 111 112 112 /* write routines & macros */ ··· 121 121 ** returns number of bytes transferred or -EFAULT 122 122 */ 123 123 extern ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf, 124 - size_t len); 124 + size_t len); 125 125 126 126 127 127 /** ··· 133 133 * returns Number of bytes written, or -EFAULT, -ENOMEM, -EVINAL. 134 134 */ 135 135 extern ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf, 136 - size_t len); 136 + size_t len); 137 137 138 138 /** 139 139 * Read from a packet in the ringbuffer. Note: unlike dvb_ringbuffer_read(), this ··· 149 149 * returns Number of bytes read, or -EFAULT. 150 150 */ 151 151 extern ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx, 152 - int offset, u8* buf, size_t len, int usermem); 152 + int offset, u8* buf, size_t len, int usermem); 153 153 154 154 /** 155 155 * Dispose of a packet in the ring buffer.
+11 -11
drivers/media/dvb/dvb-core/dvbdev.c
··· 92 92 old_fops = file->f_op; 93 93 file->f_op = fops_get(dvbdev->fops); 94 94 if(file->f_op->open) 95 - err = file->f_op->open(inode,file); 95 + err = file->f_op->open(inode,file); 96 96 if (err) { 97 - fops_put(file->f_op); 98 - file->f_op = fops_get(old_fops); 97 + fops_put(file->f_op); 98 + file->f_op = fops_get(old_fops); 99 99 } 100 100 fops_put(old_fops); 101 101 return err; ··· 356 356 case _IOC_WRITE: 357 357 case (_IOC_WRITE | _IOC_READ): 358 358 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) { 359 - parg = sbuf; 359 + parg = sbuf; 360 360 } else { 361 - /* too big to allocate from stack */ 362 - mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL); 363 - if (NULL == mbuf) 364 - return -ENOMEM; 365 - parg = mbuf; 361 + /* too big to allocate from stack */ 362 + mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL); 363 + if (NULL == mbuf) 364 + return -ENOMEM; 365 + parg = mbuf; 366 366 } 367 367 368 368 err = -EFAULT; 369 369 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd))) 370 - goto out; 370 + goto out; 371 371 break; 372 372 } 373 373 ··· 384 384 case _IOC_READ: 385 385 case (_IOC_WRITE | _IOC_READ): 386 386 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd))) 387 - err = -EFAULT; 387 + err = -EFAULT; 388 388 break; 389 389 } 390 390
+1 -1
drivers/media/dvb/dvb-core/dvbdev.h
··· 97 97 generic_usercopy() someday... */ 98 98 99 99 extern int dvb_usercopy(struct inode *inode, struct file *file, 100 - unsigned int cmd, unsigned long arg, 100 + unsigned int cmd, unsigned long arg, 101 101 int (*func)(struct inode *inode, struct file *file, 102 102 unsigned int cmd, void *arg)); 103 103
+16 -10
drivers/media/dvb/dvb-usb/Kconfig
··· 37 37 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator. 38 38 39 39 Devices supported by this driver: 40 - TwinhanDTV USB-Ter (VP7041) 41 - TwinhanDTV Magic Box (VP7041e) 42 - KWorld/JetWay/ADSTech V-Stream XPERT DTV - DVB-T USB1.1 and USB2.0 43 - Hama DVB-T USB1.1-Box 44 - DiBcom USB1.1 reference devices (non-public) 45 - Ultima Electronic/Artec T1 USB TVBOX 46 - Compro Videomate DVB-U2000 - DVB-T USB 47 - Grandtec DVB-T USB 48 - Avermedia AverTV DVBT USB1.1 49 40 Artec T1 USB1.1 boxes 41 + Avermedia AverTV DVBT USB1.1 42 + Compro Videomate DVB-U2000 - DVB-T USB 43 + DiBcom USB1.1 reference devices (non-public) 44 + Grandtec DVB-T USB 45 + Hama DVB-T USB1.1-Box 46 + KWorld/JetWay/ADSTech V-Stream XPERT DTV - DVB-T USB1.1 and USB2.0 47 + TwinhanDTV Magic Box (VP7041e) 48 + TwinhanDTV USB-Ter (VP7041) 49 + Ultima Electronic/Artec T1 USB TVBOX 50 50 51 51 The VP7041 seems to be identical to "CTS Portable" (Chinese 52 52 Television System). 53 53 54 54 Say Y if you own such a device and want to use it. You should build it as 55 55 a module. 56 + 57 + config DVB_USB_DIBUSB_MB_FAULTY 58 + bool "Support faulty USB IDs" 59 + depends on DVB_USB_DIBUSB_MB 60 + help 61 + Support for faulty USB IDs due to an invalid EEPROM on some Artec devices. 56 62 57 63 config DVB_USB_DIBUSB_MC 58 64 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)" ··· 69 63 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator. 70 64 71 65 Devices supported by this driver: 72 - DiBcom USB2.0 reference devices (non-public) 73 66 Artec T1 USB2.0 boxes 67 + DiBcom USB2.0 reference devices (non-public) 74 68 75 69 Say Y if you own such a device and want to use it. You should build it as 76 70 a module.
+284 -10
drivers/media/dvb/dvb-usb/cxusb.c
··· 11 11 * design, so it can be reused for the "analogue-only" device (if it will 12 12 * appear at all). 13 13 * 14 - * TODO: check if the cx25840-driver (from ivtv) can be used for the analogue 15 - * part 14 + * TODO: Use the cx25840-driver for the analogue part 16 15 * 17 16 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de) 17 + * Copyright (C) 2005 Michael Krufky (mkrufky@m1k.net) 18 + * Copyright (C) 2006 Chris Pascoe (c.pascoe@itee.uq.edu.au) 18 19 * 19 20 * This program is free software; you can redistribute it and/or modify it 20 21 * under the terms of the GNU General Public License as published by the Free ··· 26 25 #include "cxusb.h" 27 26 28 27 #include "cx22702.h" 28 + #include "lgdt330x.h" 29 + #include "mt352.h" 30 + #include "mt352_priv.h" 29 31 30 32 /* debug */ 31 33 int dvb_usb_cxusb_debug; ··· 160 156 return 0; 161 157 } 162 158 159 + static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 160 + { 161 + struct dvb_usb_rc_key *keymap = d->props.rc_key_map; 162 + u8 ircode[4]; 163 + int i; 164 + 165 + cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4); 166 + 167 + *event = 0; 168 + *state = REMOTE_NO_KEY_PRESSED; 169 + 170 + for (i = 0; i < d->props.rc_key_map_size; i++) { 171 + if (keymap[i].custom == ircode[2] && 172 + keymap[i].data == ircode[3]) { 173 + *event = keymap[i].event; 174 + *state = REMOTE_KEY_PRESSED; 175 + 176 + return 0; 177 + } 178 + } 179 + 180 + return 0; 181 + } 182 + 183 + struct dvb_usb_rc_key dvico_mce_rc_keys[] = { 184 + { 0xfe, 0x02, KEY_TV }, 185 + { 0xfe, 0x0e, KEY_MP3 }, 186 + { 0xfe, 0x1a, KEY_DVD }, 187 + { 0xfe, 0x1e, KEY_FAVORITES }, 188 + { 0xfe, 0x16, KEY_SETUP }, 189 + { 0xfe, 0x46, KEY_POWER2 }, 190 + { 0xfe, 0x0a, KEY_EPG }, 191 + { 0xfe, 0x49, KEY_BACK }, 192 + { 0xfe, 0x4d, KEY_MENU }, 193 + { 0xfe, 0x51, KEY_UP }, 194 + { 0xfe, 0x5b, KEY_LEFT }, 195 + { 0xfe, 0x5f, KEY_RIGHT }, 196 + { 0xfe, 0x53, KEY_DOWN }, 197 + { 0xfe, 0x5e, KEY_OK }, 198 + { 0xfe, 0x59, KEY_INFO }, 199 + { 0xfe, 0x55, KEY_TAB }, 200 + { 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */ 201 + { 0xfe, 0x12, KEY_NEXTSONG }, /* Skip */ 202 + { 0xfe, 0x42, KEY_ENTER }, /* Windows/Start */ 203 + { 0xfe, 0x15, KEY_VOLUMEUP }, 204 + { 0xfe, 0x05, KEY_VOLUMEDOWN }, 205 + { 0xfe, 0x11, KEY_CHANNELUP }, 206 + { 0xfe, 0x09, KEY_CHANNELDOWN }, 207 + { 0xfe, 0x52, KEY_CAMERA }, 208 + { 0xfe, 0x5a, KEY_TUNER }, /* Live */ 209 + { 0xfe, 0x19, KEY_OPEN }, 210 + { 0xfe, 0x0b, KEY_1 }, 211 + { 0xfe, 0x17, KEY_2 }, 212 + { 0xfe, 0x1b, KEY_3 }, 213 + { 0xfe, 0x07, KEY_4 }, 214 + { 0xfe, 0x50, KEY_5 }, 215 + { 0xfe, 0x54, KEY_6 }, 216 + { 0xfe, 0x48, KEY_7 }, 217 + { 0xfe, 0x4c, KEY_8 }, 218 + { 0xfe, 0x58, KEY_9 }, 219 + { 0xfe, 0x13, KEY_ANGLE }, /* Aspect */ 220 + { 0xfe, 0x03, KEY_0 }, 221 + { 0xfe, 0x1f, KEY_ZOOM }, 222 + { 0xfe, 0x43, KEY_REWIND }, 223 + { 0xfe, 0x47, KEY_PLAYPAUSE }, 224 + { 0xfe, 0x4f, KEY_FASTFORWARD }, 225 + { 0xfe, 0x57, KEY_MUTE }, 226 + { 0xfe, 0x0d, KEY_STOP }, 227 + { 0xfe, 0x01, KEY_RECORD }, 228 + { 0xfe, 0x4e, KEY_POWER }, 229 + }; 230 + 231 + static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) 232 + { 233 + static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 }; 234 + static u8 reset [] = { RESET, 0x80 }; 235 + static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; 236 + static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 }; 237 + static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; 238 + static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; 239 + 240 + mt352_write(fe, clock_config, sizeof(clock_config)); 241 + udelay(200); 242 + mt352_write(fe, reset, sizeof(reset)); 243 + mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); 244 + 245 + mt352_write(fe, agc_cfg, sizeof(agc_cfg)); 246 + mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); 247 + mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); 248 + 249 + return 0; 250 + } 251 + 163 252 struct cx22702_config cxusb_cx22702_config = { 164 253 .demod_address = 0x63, 165 254 ··· 262 165 .pll_set = dvb_usb_pll_set_i2c, 263 166 }; 264 167 168 + struct lgdt330x_config cxusb_lgdt330x_config = { 169 + .demod_address = 0x0e, 170 + .demod_chip = LGDT3303, 171 + .pll_set = dvb_usb_pll_set_i2c, 172 + }; 173 + 174 + struct mt352_config cxusb_dee1601_config = { 175 + .demod_address = 0x0f, 176 + .demod_init = cxusb_dee1601_demod_init, 177 + .pll_set = dvb_usb_pll_set, 178 + }; 179 + 265 180 /* Callbacks for DVB USB */ 266 - static int cxusb_tuner_attach(struct dvb_usb_device *d) 181 + static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_device *d) 267 182 { 268 183 u8 bpll[4] = { 0x0b, 0xdc, 0x9c, 0xa0 }; 269 184 d->pll_addr = 0x61; 270 - memcpy(d->pll_init,bpll,4); 185 + memcpy(d->pll_init, bpll, 4); 271 186 d->pll_desc = &dvb_pll_fmd1216me; 272 187 return 0; 273 188 } 274 189 275 - static int cxusb_frontend_attach(struct dvb_usb_device *d) 190 + static int cxusb_lgh064f_tuner_attach(struct dvb_usb_device *d) 191 + { 192 + u8 bpll[4] = { 0x00, 0x00, 0x18, 0x50 }; 193 + /* bpll[2] : unset bit 3, set bits 4&5 194 + bpll[3] : 0x50 - digital, 0x20 - analog */ 195 + d->pll_addr = 0x61; 196 + memcpy(d->pll_init, bpll, 4); 197 + d->pll_desc = &dvb_pll_tdvs_tua6034; 198 + return 0; 199 + } 200 + 201 + static int cxusb_dee1601_tuner_attach(struct dvb_usb_device *d) 202 + { 203 + d->pll_addr = 0x61; 204 + d->pll_desc = &dvb_pll_thomson_dtt7579; 205 + return 0; 206 + } 207 + 208 + static int cxusb_cx22702_frontend_attach(struct dvb_usb_device *d) 276 209 { 277 210 u8 b; 278 211 if (usb_set_interface(d->udev,0,6) < 0) ··· 316 189 return -EIO; 317 190 } 318 191 192 + static int cxusb_lgdt330x_frontend_attach(struct dvb_usb_device *d) 193 + { 194 + if (usb_set_interface(d->udev,0,7) < 0) 195 + err("set interface failed"); 196 + 197 + cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 198 + 199 + if ((d->fe = lgdt330x_attach(&cxusb_lgdt330x_config, &d->i2c_adap)) != NULL) 200 + return 0; 201 + 202 + return -EIO; 203 + } 204 + 205 + static int cxusb_dee1601_frontend_attach(struct dvb_usb_device *d) 206 + { 207 + if (usb_set_interface(d->udev,0,0) < 0) 208 + err("set interface failed"); 209 + 210 + cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 211 + 212 + if ((d->fe = mt352_attach(&cxusb_dee1601_config, &d->i2c_adap)) != NULL) 213 + return 0; 214 + 215 + return -EIO; 216 + } 217 + 218 + /* 219 + * DViCO bluebird firmware needs the "warm" product ID to be patched into the 220 + * firmware file before download. 221 + */ 222 + 223 + #define BLUEBIRD_01_ID_OFFSET 6638 224 + static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, const struct firmware *fw) 225 + { 226 + if (fw->size < BLUEBIRD_01_ID_OFFSET + 4) 227 + return -EINVAL; 228 + 229 + if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) && 230 + fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) { 231 + 232 + /* FIXME: are we allowed to change the fw-data ? */ 233 + fw->data[BLUEBIRD_01_ID_OFFSET + 2] = udev->descriptor.idProduct + 1; 234 + fw->data[BLUEBIRD_01_ID_OFFSET + 3] = udev->descriptor.idProduct >> 8; 235 + 236 + return usb_cypress_load_firmware(udev,fw,CYPRESS_FX2); 237 + } 238 + 239 + return -EINVAL; 240 + } 241 + 319 242 /* DVB USB Driver stuff */ 320 - static struct dvb_usb_properties cxusb_properties; 243 + static struct dvb_usb_properties cxusb_medion_properties; 244 + static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties; 245 + static struct dvb_usb_properties cxusb_bluebird_dee1601_properties; 321 246 322 247 static int cxusb_probe(struct usb_interface *intf, 323 248 const struct usb_device_id *id) 324 249 { 325 - return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE,NULL); 250 + if (dvb_usb_device_init(intf,&cxusb_medion_properties,THIS_MODULE,NULL) == 0 || 251 + dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0 || 252 + dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0) { 253 + return 0; 254 + } 255 + 256 + return -EINVAL; 326 257 } 327 258 328 259 static struct usb_device_id cxusb_table [] = { 329 260 { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) }, 261 + { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) }, 262 + { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) }, 263 + { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_COLD) }, 264 + { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_WARM) }, 330 265 {} /* Terminating entry */ 331 266 }; 332 267 MODULE_DEVICE_TABLE (usb, cxusb_table); 333 268 334 - static struct dvb_usb_properties cxusb_properties = { 269 + static struct dvb_usb_properties cxusb_medion_properties = { 335 270 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 336 271 337 272 .usb_ctrl = CYPRESS_FX2, ··· 402 213 403 214 .streaming_ctrl = cxusb_streaming_ctrl, 404 215 .power_ctrl = cxusb_power_ctrl, 405 - .frontend_attach = cxusb_frontend_attach, 406 - .tuner_attach = cxusb_tuner_attach, 216 + .frontend_attach = cxusb_cx22702_frontend_attach, 217 + .tuner_attach = cxusb_fmd1216me_tuner_attach, 407 218 408 219 .i2c_algo = &cxusb_i2c_algo, 409 220 ··· 425 236 { "Medion MD95700 (MDUSBTV-HYBRID)", 426 237 { NULL }, 427 238 { &cxusb_table[0], NULL }, 239 + }, 240 + } 241 + }; 242 + 243 + static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = { 244 + .caps = DVB_USB_IS_AN_I2C_ADAPTER, 245 + 246 + .usb_ctrl = DEVICE_SPECIFIC, 247 + .firmware = "dvb-usb-bluebird-01.fw", 248 + .download_firmware = bluebird_patch_dvico_firmware_download, 249 + /* use usb alt setting 0 for EP4 transfer (dvb-t), 250 + use usb alt setting 7 for EP2 transfer (atsc) */ 251 + 252 + .size_of_priv = sizeof(struct cxusb_state), 253 + 254 + .streaming_ctrl = cxusb_streaming_ctrl, 255 + .power_ctrl = cxusb_power_ctrl, 256 + .frontend_attach = cxusb_lgdt330x_frontend_attach, 257 + .tuner_attach = cxusb_lgh064f_tuner_attach, 258 + 259 + .i2c_algo = &cxusb_i2c_algo, 260 + 261 + .generic_bulk_ctrl_endpoint = 0x01, 262 + /* parameter for the MPEG2-data transfer */ 263 + .urb = { 264 + .type = DVB_USB_BULK, 265 + .count = 5, 266 + .endpoint = 0x02, 267 + .u = { 268 + .bulk = { 269 + .buffersize = 8192, 270 + } 271 + } 272 + }, 273 + 274 + .num_device_descs = 1, 275 + .devices = { 276 + { "DViCO FusionHDTV5 USB Gold", 277 + { &cxusb_table[1], NULL }, 278 + { &cxusb_table[2], NULL }, 279 + }, 280 + } 281 + }; 282 + 283 + static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = { 284 + .caps = DVB_USB_IS_AN_I2C_ADAPTER, 285 + 286 + .usb_ctrl = DEVICE_SPECIFIC, 287 + .firmware = "dvb-usb-bluebird-01.fw", 288 + .download_firmware = bluebird_patch_dvico_firmware_download, 289 + /* use usb alt setting 0 for EP4 transfer (dvb-t), 290 + use usb alt setting 7 for EP2 transfer (atsc) */ 291 + 292 + .size_of_priv = sizeof(struct cxusb_state), 293 + 294 + .streaming_ctrl = cxusb_streaming_ctrl, 295 + .power_ctrl = cxusb_power_ctrl, 296 + .frontend_attach = cxusb_dee1601_frontend_attach, 297 + .tuner_attach = cxusb_dee1601_tuner_attach, 298 + 299 + .i2c_algo = &cxusb_i2c_algo, 300 + 301 + .rc_interval = 150, 302 + .rc_key_map = dvico_mce_rc_keys, 303 + .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys), 304 + .rc_query = cxusb_rc_query, 305 + 306 + .generic_bulk_ctrl_endpoint = 0x01, 307 + /* parameter for the MPEG2-data transfer */ 308 + .urb = { 309 + .type = DVB_USB_BULK, 310 + .count = 5, 311 + .endpoint = 0x04, 312 + .u = { 313 + .bulk = { 314 + .buffersize = 8192, 315 + } 316 + } 317 + }, 318 + 319 + .num_device_descs = 1, 320 + .devices = { 321 + { "DViCO FusionHDTV DVB-T Dual USB", 322 + { &cxusb_table[3], NULL }, 323 + { &cxusb_table[4], NULL }, 428 324 }, 429 325 } 430 326 };
+2
drivers/media/dvb/dvb-usb/cxusb.h
··· 21 21 #define CMD_STREAMING_ON 0x36 22 22 #define CMD_STREAMING_OFF 0x37 23 23 24 + #define CMD_GET_IR_CODE 0x47 25 + 24 26 #define CMD_ANALOG 0x50 25 27 #define CMD_DIGITAL 0x51 26 28
+28 -18
drivers/media/dvb/dvb-usb/dibusb-mb.c
··· 65 65 d->tuner_pass_ctrl(d->fe,0,msg[0].addr); 66 66 67 67 if (b2[0] == 0xfe) { 68 - info("this device has the Thomson Cable onboard. Which is default."); 68 + info("This device has the Thomson Cable onboard. Which is default."); 69 69 dibusb_thomson_tuner_attach(d); 70 70 } else { 71 71 u8 bpll[4] = { 0x0b, 0xf5, 0x85, 0xab }; 72 - info("this device has the Panasonic ENV77H11D5 onboard."); 72 + info("This device has the Panasonic ENV77H11D5 onboard."); 73 73 d->pll_addr = 0x60; 74 74 memcpy(d->pll_init,bpll,4); 75 75 d->pll_desc = &dvb_pll_tda665x; ··· 98 98 99 99 /* do not change the order of the ID table */ 100 100 static struct usb_device_id dibusb_dib3000mb_table [] = { 101 - /* 00 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_COLD)}, 102 - /* 01 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_WARM)}, 101 + /* 00 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_COLD) }, 102 + /* 01 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_WARM) }, 103 103 /* 02 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_COLD) }, 104 104 /* 03 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_WARM) }, 105 105 /* 04 */ { USB_DEVICE(USB_VID_COMPRO_UNK, USB_PID_COMPRO_DVBU2000_UNK_COLD) }, 106 106 /* 05 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_COLD) }, 107 107 /* 06 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_WARM) }, 108 - /* 07 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_COLD) }, 109 - /* 08 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_WARM) }, 108 + /* 07 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_COLD) }, 109 + /* 08 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_WARM) }, 110 110 /* 09 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_COLD) }, 111 111 /* 10 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_WARM) }, 112 112 /* 11 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_DIBCOM_MOD3000_COLD) }, ··· 117 117 /* 16 */ { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7041_WARM) }, 118 118 /* 17 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_COLD) }, 119 119 /* 18 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_WARM) }, 120 - /* 19 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_COLD) }, 121 - /* 20 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_WARM) }, 122 - /* 21 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_COLD) }, 123 - /* 22 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_WARM) }, 120 + /* 19 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_COLD) }, 121 + /* 20 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_WARM) }, 122 + /* 21 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_COLD) }, 123 + /* 22 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_WARM) }, 124 124 /* 23 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_COLD) }, 125 125 126 126 /* device ID with default DIBUSB2_0-firmware and with the hacked firmware */ 127 127 /* 24 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_WARM) }, 128 - /* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) }, 129 - /* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) }, 128 + /* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) }, 129 + /* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) }, 130 130 131 131 /* 27 */ { USB_DEVICE(USB_VID_KWORLD, USB_PID_KWORLD_VSTREAM_COLD) }, 132 132 133 - /* 28 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_COLD) }, 134 - /* 29 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_WARM) }, 133 + /* 28 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_COLD) }, 134 + /* 29 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_WARM) }, 135 135 136 - // #define DVB_USB_DIBUSB_MB_FAULTY_USB_IDs 136 + /* 137 + * XXX: As Artec just 'forgot' to program the EEPROM on some Artec T1 devices 138 + * we don't catch these faulty IDs (namely 'Cypress FX1 USB controller') that 139 + * have been left on the device. If you don't have such a device but an Artec 140 + * device that's supposed to work with this driver but is not detected by it, 141 + * free to enable CONFIG_DVB_USB_DIBUSB_MB_FAULTY via your kernel config. 142 + */ 137 143 138 - #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs 144 + #ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY 139 145 /* 30 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) }, 140 146 #endif 147 + 141 148 { } /* Terminating entry */ 142 149 }; 143 150 MODULE_DEVICE_TABLE (usb, dibusb_dib3000mb_table); ··· 264 257 } 265 258 }, 266 259 267 - #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs 260 + #ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY 268 261 .num_device_descs = 2, 269 262 #else 270 263 .num_device_descs = 1, ··· 274 267 { &dibusb_dib3000mb_table[20], NULL }, 275 268 { &dibusb_dib3000mb_table[21], NULL }, 276 269 }, 277 - #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs 270 + #ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY 278 271 { "Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)", 279 272 { &dibusb_dib3000mb_table[30], NULL }, 280 273 { NULL }, 281 274 }, 275 + { NULL }, 282 276 #endif 283 277 } 284 278 }; ··· 331 323 { &dibusb_dib3000mb_table[27], NULL }, 332 324 { NULL } 333 325 }, 326 + { NULL }, 334 327 } 335 328 }; 336 329 ··· 378 369 { &dibusb_dib3000mb_table[28], NULL }, 379 370 { &dibusb_dib3000mb_table[29], NULL }, 380 371 }, 372 + { NULL }, 381 373 } 382 374 }; 383 375
+1 -1
drivers/media/dvb/dvb-usb/digitv.c
··· 32 32 sndbuf[1] = vv; 33 33 sndbuf[2] = wo ? wlen : rlen; 34 34 35 - if (!wo) { 35 + if (wo) { 36 36 memcpy(&sndbuf[3],wbuf,wlen); 37 37 dvb_usb_generic_write(d,sndbuf,7); 38 38 } else {
+3 -3
drivers/media/dvb/dvb-usb/dtt200u.c
··· 151 151 .cold_ids = { &dtt200u_usb_table[0], NULL }, 152 152 .warm_ids = { &dtt200u_usb_table[1], NULL }, 153 153 }, 154 - { NULL }, 154 + { 0 }, 155 155 } 156 156 }; 157 157 ··· 160 160 .pid_filter_count = 15, 161 161 162 162 .usb_ctrl = CYPRESS_FX2, 163 - .firmware = "dvb-usb-wt220u-01.fw", 163 + .firmware = "dvb-usb-wt220u-02.fw", 164 164 165 165 .power_ctrl = dtt200u_power_ctrl, 166 166 .streaming_ctrl = dtt200u_streaming_ctrl, ··· 192 192 .cold_ids = { &dtt200u_usb_table[2], NULL }, 193 193 .warm_ids = { &dtt200u_usb_table[3], NULL }, 194 194 }, 195 - { NULL }, 195 + { 0 }, 196 196 } 197 197 }; 198 198
+16 -15
drivers/media/dvb/dvb-usb/dtt200u.h
··· 13 13 #define _DVB_USB_DTT200U_H_ 14 14 15 15 #define DVB_USB_LOG_PREFIX "dtt200u" 16 + 16 17 #include "dvb-usb.h" 17 18 18 19 extern int dvb_usb_dtt200u_debug; ··· 26 25 * 88 - locking 2 bytes (0x80 0x40 == no signal, 0x89 0x20 == nice signal) 27 26 */ 28 27 29 - #define GET_SPEED 0x00 30 - #define GET_TUNE_STATUS 0x81 31 - #define GET_RC_CODE 0x84 32 - #define GET_CONFIGURATION 0x88 33 - #define GET_AGC 0x89 34 - #define GET_SNR 0x8a 35 - #define GET_VIT_ERR_CNT 0x8c 36 - #define GET_RS_ERR_CNT 0x8d 37 - #define GET_RS_UNCOR_BLK_CNT 0x8e 28 + #define GET_SPEED 0x00 29 + #define GET_TUNE_STATUS 0x81 30 + #define GET_RC_CODE 0x84 31 + #define GET_CONFIGURATION 0x88 32 + #define GET_AGC 0x89 33 + #define GET_SNR 0x8a 34 + #define GET_VIT_ERR_CNT 0x8c 35 + #define GET_RS_ERR_CNT 0x8d 36 + #define GET_RS_UNCOR_BLK_CNT 0x8e 38 37 39 38 /* write 40 39 * 01 - init ··· 45 44 * 08 - transfer switch 46 45 */ 47 46 48 - #define SET_INIT 0x01 49 - #define SET_RF_FREQ 0x02 50 - #define SET_BANDWIDTH 0x03 51 - #define SET_PID_FILTER 0x04 52 - #define RESET_PID_FILTER 0x05 53 - #define SET_STREAMING 0x08 47 + #define SET_INIT 0x01 48 + #define SET_RF_FREQ 0x02 49 + #define SET_BANDWIDTH 0x03 50 + #define SET_PID_FILTER 0x04 51 + #define RESET_PID_FILTER 0x05 52 + #define SET_STREAMING 0x08 54 53 55 54 extern struct dvb_frontend * dtt200u_fe_attach(struct dvb_usb_device *d); 56 55
+1 -1
drivers/media/dvb/dvb-usb/dvb-usb-common.h
··· 24 24 #define deb_mem(args...) dprintk(dvb_usb_debug,0x80,args) 25 25 26 26 /* commonly used methods */ 27 - extern int usb_cypress_load_firmware(struct usb_device *, const char *, int); 27 + extern int dvb_usb_download_firmware(struct usb_device *, struct dvb_usb_properties *); 28 28 29 29 extern int dvb_usb_urb_submit(struct dvb_usb_device *); 30 30 extern int dvb_usb_urb_kill(struct dvb_usb_device *);
+102 -56
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
··· 9 9 */ 10 10 #include "dvb-usb-common.h" 11 11 12 - #include <linux/firmware.h> 13 12 #include <linux/usb.h> 14 13 15 14 struct usb_cypress_controller { ··· 18 19 }; 19 20 20 21 static struct usb_cypress_controller cypress[] = { 21 - { .id = CYPRESS_AN2135, .name = "Cypress AN2135", .cpu_cs_register = 0x7f92 }, 22 - { .id = CYPRESS_AN2235, .name = "Cypress AN2235", .cpu_cs_register = 0x7f92 }, 23 - { .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 }, 22 + { .id = DEVICE_SPECIFIC, .name = "Device specific", .cpu_cs_register = 0 }, 23 + { .id = CYPRESS_AN2135, .name = "Cypress AN2135", .cpu_cs_register = 0x7f92 }, 24 + { .id = CYPRESS_AN2235, .name = "Cypress AN2235", .cpu_cs_register = 0x7f92 }, 25 + { .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 }, 24 26 }; 25 27 26 28 /* ··· 30 30 static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 len) 31 31 { 32 32 return usb_control_msg(udev, usb_sndctrlpipe(udev,0), 33 - 0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5*HZ); 33 + 0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5000); 34 34 } 35 35 36 - int usb_cypress_load_firmware(struct usb_device *udev, const char *filename, int type) 36 + int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) 37 37 { 38 - const struct firmware *fw = NULL; 39 - u16 addr; 40 - u8 *b,*p; 41 - int ret = 0,i; 38 + struct hexline hx; 39 + u8 reset; 40 + int ret,pos=0; 42 41 43 - if ((ret = request_firmware(&fw, filename, &udev->dev)) != 0) { 44 - err("did not find the firmware file. (%s) " 45 - "Please see linux/Documentation/dvb/ for more details on firmware-problems.", 46 - filename); 42 + /* stop the CPU */ 43 + reset = 1; 44 + if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1) 45 + err("could not stop the USB controller CPU."); 46 + 47 + while ((ret = dvb_usb_get_hexline(fw,&hx,&pos)) > 0) { 48 + deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk); 49 + ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len); 50 + 51 + if (ret != hx.len) { 52 + err("error while transferring firmware " 53 + "(transferred size: %d, block size: %d)", 54 + ret,hx.len); 55 + ret = -EINVAL; 56 + break; 57 + } 58 + } 59 + if (ret < 0) { 60 + err("firmware download failed at %d with %d",pos,ret); 47 61 return ret; 48 62 } 49 63 50 - info("downloading firmware from file '%s' to the '%s'",filename,cypress[type].name); 51 - 52 - p = kmalloc(fw->size,GFP_KERNEL); 53 - if (p != NULL) { 54 - u8 reset; 55 - /* 56 - * you cannot use the fw->data as buffer for 57 - * usb_control_msg, a new buffer has to be 58 - * created 59 - */ 60 - memcpy(p,fw->data,fw->size); 61 - 62 - /* stop the CPU */ 63 - reset = 1; 64 - if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1) 65 - err("could not stop the USB controller CPU."); 66 - for(i = 0; p[i+3] == 0 && i < fw->size; ) { 67 - b = (u8 *) &p[i]; 68 - addr = cpu_to_le16( *((u16 *) &b[1]) ); 69 - 70 - deb_fw("writing to address 0x%04x (buffer: 0x%02x%02x)\n",addr,b[1],b[2]); 71 - 72 - ret = usb_cypress_writemem(udev,addr,&b[4],b[0]); 73 - 74 - if (ret != b[0]) { 75 - err("error while transferring firmware " 76 - "(transferred size: %d, block size: %d)", 77 - ret,b[0]); 78 - ret = -EINVAL; 79 - break; 80 - } 81 - i += 5 + b[0]; 82 - } 83 - /* length in ret */ 84 - if (ret > 0) 85 - ret = 0; 64 + if (ret == 0) { 86 65 /* restart the CPU */ 87 66 reset = 0; 88 67 if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) { 89 68 err("could not restart the USB controller CPU."); 90 69 ret = -EINVAL; 91 70 } 92 - 93 - kfree(p); 94 - } else { 95 - ret = -ENOMEM; 96 - } 97 - release_firmware(fw); 71 + } else 72 + ret = -EIO; 98 73 99 74 return ret; 100 75 } 76 + EXPORT_SYMBOL(usb_cypress_load_firmware); 77 + 78 + int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties *props) 79 + { 80 + int ret; 81 + const struct firmware *fw = NULL; 82 + 83 + if ((ret = request_firmware(&fw, props->firmware, &udev->dev)) != 0) { 84 + err("did not find the firmware file. (%s) " 85 + "Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)", 86 + props->firmware,ret); 87 + return ret; 88 + } 89 + 90 + info("downloading firmware from file '%s'",props->firmware); 91 + 92 + switch (props->usb_ctrl) { 93 + case CYPRESS_AN2135: 94 + case CYPRESS_AN2235: 95 + case CYPRESS_FX2: 96 + ret = usb_cypress_load_firmware(udev, fw, props->usb_ctrl); 97 + break; 98 + case DEVICE_SPECIFIC: 99 + if (props->download_firmware) 100 + ret = props->download_firmware(udev,fw); 101 + else { 102 + err("BUG: driver didn't specified a download_firmware-callback, although it claims to have a DEVICE_SPECIFIC one."); 103 + ret = -EINVAL; 104 + } 105 + break; 106 + default: 107 + ret = -EINVAL; 108 + break; 109 + } 110 + 111 + release_firmware(fw); 112 + return ret; 113 + } 114 + 115 + int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos) 116 + { 117 + u8 *b = (u8 *) &fw->data[*pos]; 118 + int data_offs = 4; 119 + if (*pos >= fw->size) 120 + return 0; 121 + 122 + memset(hx,0,sizeof(struct hexline)); 123 + 124 + hx->len = b[0]; 125 + 126 + if ((*pos + hx->len + 4) >= fw->size) 127 + return -EINVAL; 128 + 129 + hx->addr = le16_to_cpu( *((u16 *) &b[1]) ); 130 + hx->type = b[3]; 131 + 132 + if (hx->type == 0x04) { 133 + /* b[4] and b[5] are the Extended linear address record data field */ 134 + hx->addr |= (b[4] << 24) | (b[5] << 16); 135 + /* hx->len -= 2; 136 + data_offs += 2; */ 137 + } 138 + memcpy(hx->data,&b[data_offs],hx->len); 139 + hx->chk = b[hx->len + data_offs]; 140 + 141 + *pos += hx->len + 5; 142 + 143 + return *pos; 144 + } 145 + EXPORT_SYMBOL(dvb_usb_get_hexline); 146 +
+5 -3
drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
··· 52 52 struct i2c_msg msg = { .addr = d->pll_addr, .flags = 0, .buf = d->pll_init, .len = 4 }; 53 53 int ret = 0; 54 54 55 - /* if there is nothing to initialize */ 56 - if (d->pll_init[0] == 0x00 && d->pll_init[1] == 0x00 && 57 - d->pll_init[2] == 0x00 && d->pll_init[3] == 0x00) 55 + /* if pll_desc is not used */ 56 + if (d->pll_desc == NULL) 58 57 return 0; 59 58 60 59 if (d->tuner_pass_ctrl) ··· 78 79 int dvb_usb_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep, u8 b[5]) 79 80 { 80 81 struct dvb_usb_device *d = fe->dvb->priv; 82 + 83 + if (d->pll_desc == NULL) 84 + return 0; 81 85 82 86 deb_pll("pll addr: %x, freq: %d %p\n",d->pll_addr,fep->frequency,d->pll_desc); 83 87
+8 -4
drivers/media/dvb/dvb-usb/dvb-usb-ids.h
··· 86 86 #define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300 87 87 #define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301 88 88 #define USB_PID_NEBULA_DIGITV 0x0201 89 - #define USB_PID_DVICO_BLUEBIRD_LGZ201 0xdb00 90 - #define USB_PID_DVICO_BLUEBIRD_TH7579 0xdb10 91 89 #define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820 92 - #define USB_PID_DVICO_BLUEBIRD_LGZ201_1 0xdb01 93 - #define USB_PID_DVICO_BLUEBIRD_TH7579_2 0xdb11 90 + #define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500 91 + #define USB_PID_DVICO_BLUEBIRD_LG064F_WARM 0xd501 92 + #define USB_PID_DVICO_BLUEBIRD_LGZ201_COLD 0xdb00 93 + #define USB_PID_DVICO_BLUEBIRD_LGZ201_WARM 0xdb01 94 + #define USB_PID_DVICO_BLUEBIRD_TH7579_COLD 0xdb10 95 + #define USB_PID_DVICO_BLUEBIRD_TH7579_WARM 0xdb11 96 + #define USB_PID_DVICO_BLUEBIRD_DEE1601_COLD 0xdb50 97 + #define USB_PID_DVICO_BLUEBIRD_DEE1601_WARM 0xdb51 94 98 #define USB_PID_MEDION_MD95700 0x0932 95 99 #define USB_PID_KYE_DVB_T_COLD 0x701e 96 100 #define USB_PID_KYE_DVB_T_WARM 0x701f
+35 -30
drivers/media/dvb/dvb-usb/dvb-usb-init.c
··· 138 138 139 139 int ret = -ENOMEM,cold=0; 140 140 141 + if (du != NULL) 142 + *du = NULL; 143 + 141 144 if ((desc = dvb_usb_find_device(udev,props,&cold)) == NULL) { 142 145 deb_err("something went very wrong, device was not found in current device list - let's see what comes next.\n"); 143 146 return -ENODEV; ··· 148 145 149 146 if (cold) { 150 147 info("found a '%s' in cold state, will try to load a firmware",desc->name); 151 - ret = usb_cypress_load_firmware(udev,props->firmware,props->usb_ctrl); 152 - } else { 153 - info("found a '%s' in warm state.",desc->name); 154 - d = kmalloc(sizeof(struct dvb_usb_device),GFP_KERNEL); 155 - if (d == NULL) { 156 - err("no memory for 'struct dvb_usb_device'"); 148 + ret = dvb_usb_download_firmware(udev,props); 149 + if (!props->no_reconnect) 157 150 return ret; 158 - } 159 - memset(d,0,sizeof(struct dvb_usb_device)); 160 - 161 - d->udev = udev; 162 - memcpy(&d->props,props,sizeof(struct dvb_usb_properties)); 163 - d->desc = desc; 164 - d->owner = owner; 165 - 166 - if (d->props.size_of_priv > 0) { 167 - d->priv = kmalloc(d->props.size_of_priv,GFP_KERNEL); 168 - if (d->priv == NULL) { 169 - err("no memory for priv in 'struct dvb_usb_device'"); 170 - kfree(d); 171 - return -ENOMEM; 172 - } 173 - memset(d->priv,0,d->props.size_of_priv); 174 - } 175 - 176 - usb_set_intfdata(intf, d); 177 - 178 - if (du != NULL) 179 - *du = d; 180 - 181 - ret = dvb_usb_init(d); 182 151 } 152 + 153 + info("found a '%s' in warm state.",desc->name); 154 + d = kmalloc(sizeof(struct dvb_usb_device),GFP_KERNEL); 155 + if (d == NULL) { 156 + err("no memory for 'struct dvb_usb_device'"); 157 + return ret; 158 + } 159 + memset(d,0,sizeof(struct dvb_usb_device)); 160 + 161 + d->udev = udev; 162 + memcpy(&d->props,props,sizeof(struct dvb_usb_properties)); 163 + d->desc = desc; 164 + d->owner = owner; 165 + 166 + if (d->props.size_of_priv > 0) { 167 + d->priv = kmalloc(d->props.size_of_priv,GFP_KERNEL); 168 + if (d->priv == NULL) { 169 + err("no memory for priv in 'struct dvb_usb_device'"); 170 + kfree(d); 171 + return -ENOMEM; 172 + } 173 + memset(d->priv,0,d->props.size_of_priv); 174 + } 175 + 176 + usb_set_intfdata(intf, d); 177 + 178 + if (du != NULL) 179 + *du = d; 180 + 181 + ret = dvb_usb_init(d); 183 182 184 183 if (ret == 0) 185 184 info("%s successfully initialized and connected.",desc->name);
+23 -6
drivers/media/dvb/dvb-usb/dvb-usb.h
··· 10 10 11 11 #include <linux/config.h> 12 12 #include <linux/input.h> 13 - #include <linux/module.h> 14 13 #include <linux/usb.h> 14 + #include <linux/firmware.h> 15 15 16 16 #include "dvb_frontend.h" 17 17 #include "dvb_demux.h" ··· 94 94 * @usb_ctrl: which USB device-side controller is in use. Needed for firmware 95 95 * download. 96 96 * @firmware: name of the firmware file. 97 - * 97 + * @download_firmware: called to download the firmware when the usb_ctrl is 98 + * DEVICE_SPECIFIC. 99 + * @no_reconnect: device doesn't do a reconnect after downloading the firmware, 100 + so do the warm initialization right after it 101 + 98 102 * @size_of_priv: how many bytes shall be allocated for the private field 99 103 * of struct dvb_usb_device. 100 104 * ··· 146 142 int caps; 147 143 int pid_filter_count; 148 144 149 - #define CYPRESS_AN2135 0 150 - #define CYPRESS_AN2235 1 151 - #define CYPRESS_FX2 2 145 + #define DEVICE_SPECIFIC 0 146 + #define CYPRESS_AN2135 1 147 + #define CYPRESS_AN2235 2 148 + #define CYPRESS_FX2 3 152 149 int usb_ctrl; 153 - const char *firmware; 150 + const char firmware[FIRMWARE_NAME_MAX]; 151 + int (*download_firmware) (struct usb_device *, const struct firmware *); 152 + int no_reconnect; 154 153 155 154 int size_of_priv; 156 155 ··· 333 326 extern int dvb_usb_pll_set(struct dvb_frontend *, struct dvb_frontend_parameters *, u8[]); 334 327 extern int dvb_usb_pll_set_i2c(struct dvb_frontend *, struct dvb_frontend_parameters *); 335 328 329 + /* commonly used firmware download types and function */ 330 + struct hexline { 331 + u8 len; 332 + u32 addr; 333 + u8 type; 334 + u8 data[255]; 335 + u8 chk; 336 + }; 337 + extern int dvb_usb_get_hexline(const struct firmware *, struct hexline *, int *); 338 + extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type); 336 339 337 340 #endif
+2 -5
drivers/media/dvb/dvb-usb/nova-t-usb2.c
··· 129 129 dibusb_read_eeprom_byte(d,i, &b); 130 130 131 131 mac[5 - (i - 136)] = b; 132 - 133 - /* deb_ee("%02x ",b); 134 - if ((i+1) % 16 == 0) 135 - deb_ee("\n");*/ 136 132 } 137 133 138 134 return 0; ··· 149 153 /* 01 */ { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_WINTV_NOVA_T_USB2_WARM) }, 150 154 { } /* Terminating entry */ 151 155 }; 152 - MODULE_DEVICE_TABLE (usb, nova_t_table); 156 + MODULE_DEVICE_TABLE(usb, nova_t_table); 153 157 154 158 static struct dvb_usb_properties nova_t_properties = { 155 159 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, ··· 194 198 { &nova_t_table[0], NULL }, 195 199 { &nova_t_table[1], NULL }, 196 200 }, 201 + { NULL }, 197 202 } 198 203 }; 199 204
+1 -1
drivers/media/dvb/dvb-usb/vp702x-fe.c
··· 190 190 } 191 191 192 192 static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, 193 - struct dvb_diseqc_master_cmd *m) 193 + struct dvb_diseqc_master_cmd *m) 194 194 { 195 195 struct vp702x_fe_state *st = fe->demodulator_priv; 196 196 u8 cmd[8],ibuf[10];
+21 -22
drivers/media/dvb/dvb-usb/vp702x.h
··· 13 13 /* commands are read and written with USB control messages */ 14 14 15 15 /* consecutive read/write operation */ 16 - #define REQUEST_OUT 0xB2 17 - #define REQUEST_IN 0xB3 16 + #define REQUEST_OUT 0xB2 17 + #define REQUEST_IN 0xB3 18 18 19 19 /* the out-buffer of these consecutive operations contain sub-commands when b[0] = 0 20 20 * request: 0xB2; i: 0; v: 0; b[0] = 0, b[1] = subcmd, additional buffer 21 21 * the returning buffer looks as follows 22 22 * request: 0xB3; i: 0; v: 0; b[0] = 0xB3, additional buffer */ 23 23 24 - #define GET_TUNER_STATUS 0x05 24 + #define GET_TUNER_STATUS 0x05 25 25 /* additional in buffer: 26 26 * 0 1 2 3 4 5 6 7 8 27 27 * N/A N/A 0x05 signal-quality N/A N/A signal-strength lock==0 N/A */ 28 28 29 - #define GET_SYSTEM_STRING 0x06 29 + #define GET_SYSTEM_STRING 0x06 30 30 /* additional in buffer: 31 31 * 0 1 2 3 4 5 6 7 8 32 32 * N/A 'U' 'S' 'B' '7' '0' '2' 'X' N/A */ 33 33 34 - #define SET_DISEQC_CMD 0x08 34 + #define SET_DISEQC_CMD 0x08 35 35 /* additional out buffer: 36 36 * 0 1 2 3 4 37 37 * len X1 X2 X3 X4 38 38 * additional in buffer: 39 39 * 0 1 2 40 - * N/A 0 0 b[1] == b[2] == 0 -> success otherwise not */ 40 + * N/A 0 0 b[1] == b[2] == 0 -> success, failure otherwise */ 41 41 42 - #define SET_LNB_POWER 0x09 42 + #define SET_LNB_POWER 0x09 43 43 /* additional out buffer: 44 44 * 0 1 2 45 45 * 0x00 0xff 1 = on, 0 = off 46 46 * additional in buffer: 47 47 * 0 1 2 48 - * N/A 0 0 b[1] == b[2] == 0 -> success otherwise not */ 48 + * N/A 0 0 b[1] == b[2] == 0 -> success failure otherwise */ 49 49 50 - #define GET_MAC_ADDRESS 0x0A 50 + #define GET_MAC_ADDRESS 0x0A 51 51 /* #define GET_MAC_ADDRESS 0x0B */ 52 52 /* additional in buffer: 53 53 * 0 1 2 3 4 5 6 7 8 54 54 * N/A N/A 0x0A or 0x0B MAC0 MAC1 MAC2 MAC3 MAC4 MAC5 */ 55 55 56 - #define SET_PID_FILTER 0x11 56 + #define SET_PID_FILTER 0x11 57 57 /* additional in buffer: 58 58 * 0 1 ... 14 15 16 59 59 * PID0_MSB PID0_LSB ... PID7_MSB PID7_LSB PID_active (bits) */ ··· 64 64 * freq0 freq1 divstep srate0 srate1 srate2 flag chksum 65 65 */ 66 66 67 - 68 67 /* one direction requests */ 69 - #define READ_REMOTE_REQ 0xB4 68 + #define READ_REMOTE_REQ 0xB4 70 69 /* IN i: 0; v: 0; b[0] == request, b[1] == key */ 71 70 72 - #define READ_PID_NUMBER_REQ 0xB5 71 + #define READ_PID_NUMBER_REQ 0xB5 73 72 /* IN i: 0; v: 0; b[0] == request, b[1] == 0, b[2] = pid number */ 74 73 75 - #define WRITE_EEPROM_REQ 0xB6 74 + #define WRITE_EEPROM_REQ 0xB6 76 75 /* OUT i: offset; v: value to write; no extra buffer */ 77 76 78 - #define READ_EEPROM_REQ 0xB7 77 + #define READ_EEPROM_REQ 0xB7 79 78 /* IN i: bufferlen; v: offset; buffer with bufferlen bytes */ 80 79 81 - #define READ_STATUS 0xB8 80 + #define READ_STATUS 0xB8 82 81 /* IN i: 0; v: 0; bufferlen 10 */ 83 82 84 - #define READ_TUNER_REG_REQ 0xB9 83 + #define READ_TUNER_REG_REQ 0xB9 85 84 /* IN i: 0; v: register; b[0] = value */ 86 85 87 - #define READ_FX2_REG_REQ 0xBA 86 + #define READ_FX2_REG_REQ 0xBA 88 87 /* IN i: offset; v: 0; b[0] = value */ 89 88 90 - #define WRITE_FX2_REG_REQ 0xBB 89 + #define WRITE_FX2_REG_REQ 0xBB 91 90 /* OUT i: offset; v: value to write; 1 byte extra buffer */ 92 91 93 - #define SET_TUNER_POWER_REQ 0xBC 92 + #define SET_TUNER_POWER_REQ 0xBC 94 93 /* IN i: 0 = power off, 1 = power on */ 95 94 96 - #define WRITE_TUNER_REG_REQ 0xBD 95 + #define WRITE_TUNER_REG_REQ 0xBD 97 96 /* IN i: register, v: value to write, no extra buffer */ 98 97 99 - #define RESET_TUNER 0xBE 98 + #define RESET_TUNER 0xBE 100 99 /* IN i: 0, v: 0, no extra buffer */ 101 100 102 101 extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d);
+1 -1
drivers/media/dvb/dvb-usb/vp7045.c
··· 247 247 .cold_ids = { &vp7045_usb_table[2], NULL }, 248 248 .warm_ids = { &vp7045_usb_table[3], NULL }, 249 249 }, 250 - { NULL }, 250 + { 0 }, 251 251 } 252 252 }; 253 253
+33 -13
drivers/media/dvb/frontends/Kconfig
··· 16 16 help 17 17 A DVB-S tuner module. Say Y when you want to support this frontend. 18 18 19 + config DVB_CX24123 20 + tristate "Conexant CX24123 based" 21 + depends on DVB_CORE 22 + help 23 + A DVB-S tuner module. Say Y when you want to support this frontend. 24 + 19 25 config DVB_TDA8083 20 26 tristate "Philips TDA8083 based" 21 27 depends on DVB_CORE ··· 56 50 depends on DVB_CORE 57 51 58 52 config DVB_SP8870 59 - tristate "Spase sp8870 based" 53 + tristate "Spase sp8870 based" 60 54 depends on DVB_CORE 61 55 select FW_LOADER 62 56 help 63 - A DVB-T tuner module. Say Y when you want to support this frontend. 57 + A DVB-T tuner module. Say Y when you want to support this frontend. 64 58 65 59 This driver needs external firmware. Please use the command 66 60 "<kerneldir>/Documentation/dvb/get_dvb_firmware sp8870" to 67 - download/extract it, and then copy it to /usr/lib/hotplug/firmware. 61 + download/extract it, and then copy it to /usr/lib/hotplug/firmware 62 + or /lib/firmware (depending on configuration of firmware hotplug). 68 63 69 64 config DVB_SP887X 70 - tristate "Spase sp887x based" 65 + tristate "Spase sp887x based" 71 66 depends on DVB_CORE 72 67 select FW_LOADER 73 68 help ··· 76 69 77 70 This driver needs external firmware. Please use the command 78 71 "<kerneldir>/Documentation/dvb/get_dvb_firmware sp887x" to 79 - download/extract it, and then copy it to /usr/lib/hotplug/firmware. 72 + download/extract it, and then copy it to /usr/lib/hotplug/firmware 73 + or /lib/firmware (depending on configuration of firmware hotplug). 80 74 81 75 config DVB_CX22700 82 76 tristate "Conexant CX22700 based" ··· 86 78 A DVB-T tuner module. Say Y when you want to support this frontend. 87 79 88 80 config DVB_CX22702 89 - tristate "Conexant cx22702 demodulator (OFDM)" 90 - depends on DVB_CORE 91 - help 92 - A DVB-T tuner module. Say Y when you want to support this frontend. 81 + tristate "Conexant cx22702 demodulator (OFDM)" 82 + depends on DVB_CORE 83 + help 84 + A DVB-T tuner module. Say Y when you want to support this frontend. 93 85 94 86 config DVB_L64781 95 87 tristate "LSI L64781" ··· 106 98 107 99 This driver needs external firmware. Please use the commands 108 100 "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045", 109 - "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to 110 - download/extract them, and then copy them to /usr/lib/hotplug/firmware. 101 + "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to 102 + download/extract them, and then copy them to /usr/lib/hotplug/firmware 103 + or /lib/firmware (depending on configuration of firmware hotplug). 111 104 112 105 config DVB_NXT6000 113 106 tristate "NxtWave Communications NXT6000 based" ··· 149 140 tristate "VLSI VES1820 based" 150 141 depends on DVB_CORE 151 142 help 152 - A DVB-C tuner module. Say Y when you want to support this frontend. 143 + A DVB-C tuner module. Say Y when you want to support this frontend. 153 144 154 145 config DVB_TDA10021 155 146 tristate "Philips TDA10021 based" 156 147 depends on DVB_CORE 157 148 help 158 - A DVB-C tuner module. Say Y when you want to support this frontend. 149 + A DVB-C tuner module. Say Y when you want to support this frontend. 159 150 160 151 config DVB_STV0297 161 152 tristate "ST STV0297 based" ··· 173 164 help 174 165 An ATSC 8VSB tuner module. Say Y when you want to support this frontend. 175 166 167 + This driver needs external firmware. Please use the command 168 + "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" to 169 + download/extract it, and then copy it to /usr/lib/hotplug/firmware 170 + or /lib/firmware (depending on configuration of firmware hotplug). 171 + 176 172 config DVB_NXT200X 177 173 tristate "Nextwave NXT2002/NXT2004 based" 178 174 depends on DVB_CORE ··· 185 171 help 186 172 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want 187 173 to support this frontend. 174 + 175 + This driver needs external firmware. Please use the commands 176 + "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" and 177 + "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2004" to 178 + download/extract them, and then copy them to /usr/lib/hotplug/firmware 179 + or /lib/firmware (depending on configuration of firmware hotplug). 188 180 189 181 config DVB_OR51211 190 182 tristate "or51211 based (pcHDTV HD2000 card)"
+1
drivers/media/dvb/frontends/Makefile
··· 32 32 obj-$(CONFIG_DVB_BCM3510) += bcm3510.o 33 33 obj-$(CONFIG_DVB_S5H1420) += s5h1420.o 34 34 obj-$(CONFIG_DVB_LGDT330X) += lgdt330x.o 35 + obj-$(CONFIG_DVB_CX24123) += cx24123.o
+3 -3
drivers/media/dvb/frontends/bcm3510.c
··· 255 255 bcm3510_register_value b; 256 256 int ret; 257 257 258 - if ((ret < bcm3510_readB(st,0xfa,&b)) < 0) 258 + if ((ret = bcm3510_readB(st,0xfa,&b)) < 0) 259 259 return ret; 260 260 261 261 b.BERCTL_fa.RESYNC = 0; bcm3510_writeB(st,0xfa,b); ··· 623 623 err("could not load firmware (%s): %d",BCM3510_DEFAULT_FIRMWARE,ret); 624 624 return ret; 625 625 } 626 - deb_info("got firmware: %d\n",fw->size); 626 + deb_info("got firmware: %zd\n",fw->size); 627 627 628 628 b = fw->data; 629 629 for (i = 0; i < fw->size;) { 630 630 addr = le16_to_cpu( *( (u16 *)&b[i] ) ); 631 631 len = le16_to_cpu( *( (u16 *)&b[i+2] ) ); 632 - deb_info("firmware chunk, addr: 0x%04x, len: 0x%04x, total length: 0x%04x\n",addr,len,fw->size); 632 + deb_info("firmware chunk, addr: 0x%04x, len: 0x%04x, total length: 0x%04zx\n",addr,len,fw->size); 633 633 if ((ret = bcm3510_write_ram(st,addr,&b[i+4],len)) < 0) { 634 634 err("firmware download failed: %d\n",ret); 635 635 return ret;
+16 -6
drivers/media/dvb/frontends/cx22702.c
··· 195 195 return 0; 196 196 } 197 197 198 + static int cx22702_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) 199 + { 200 + struct cx22702_state* state = fe->demodulator_priv; 201 + dprintk ("%s(%d)\n", __FUNCTION__, enable); 202 + if (enable) 203 + return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) & 0xfe); 204 + else 205 + return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) | 1); 206 + } 207 + 198 208 /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ 199 209 static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 200 210 { ··· 212 202 struct cx22702_state* state = fe->demodulator_priv; 213 203 214 204 /* set PLL */ 215 - cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe); 205 + cx22702_i2c_gate_ctrl(fe, 1); 216 206 if (state->config->pll_set) { 217 207 state->config->pll_set(fe, p); 218 208 } else if (state->config->pll_desc) { ··· 226 216 } else { 227 217 BUG(); 228 218 } 229 - cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1); 219 + cx22702_i2c_gate_ctrl(fe, 0); 230 220 231 221 /* set inversion */ 232 222 cx22702_set_inversion (state, p->inversion); ··· 359 349 cx22702_writereg (state, 0xf8, (state->config->output_mode << 1) & 0x02); 360 350 361 351 /* init PLL */ 362 - if (state->config->pll_init) { 363 - cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) & 0xfe); 352 + if (state->config->pll_init) 364 353 state->config->pll_init(fe); 365 - cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1); 366 - } 354 + 355 + cx22702_i2c_gate_ctrl(fe, 0); 367 356 368 357 return 0; 369 358 } ··· 540 531 .read_signal_strength = cx22702_read_signal_strength, 541 532 .read_snr = cx22702_read_snr, 542 533 .read_ucblocks = cx22702_read_ucblocks, 534 + .i2c_gate_ctrl = cx22702_i2c_gate_ctrl, 543 535 }; 544 536 545 537 module_param(debug, int, 0644);
+11 -12
drivers/media/dvb/frontends/cx24110.c
··· 27 27 #include <linux/module.h> 28 28 #include <linux/moduleparam.h> 29 29 #include <linux/init.h> 30 - #include <linux/jiffies.h> 31 30 32 31 #include "dvb_frontend.h" 33 32 #include "cx24110.h" ··· 55 56 56 57 static struct {u8 reg; u8 data;} cx24110_regdata[]= 57 58 /* Comments beginning with @ denote this value should 58 - be the default */ 59 + be the default */ 59 60 {{0x09,0x01}, /* SoftResetAll */ 60 61 {0x09,0x00}, /* release reset */ 61 62 {0x01,0xe8}, /* MSB of code rate 27.5MS/s */ ··· 66 67 {0x07,0x01}, /* @ Fclk, i.e. sampling clock, 60MHz */ 67 68 {0x0a,0x00}, /* @ partial chip disables, do not set */ 68 69 {0x0b,0x01}, /* set output clock in gapped mode, start signal low 69 - active for first byte */ 70 + active for first byte */ 70 71 {0x0c,0x11}, /* no parity bytes, large hold time, serial data out */ 71 72 {0x0d,0x6f}, /* @ RS Sync/Unsync thresholds */ 72 73 {0x10,0x40}, /* chip doc is misleading here: write bit 6 as 1 73 - to avoid starting the BER counter. Reset the 74 - CRC test bit. Finite counting selected */ 74 + to avoid starting the BER counter. Reset the 75 + CRC test bit. Finite counting selected */ 75 76 {0x15,0xff}, /* @ size of the limited time window for RS BER 76 - estimation. It is <value>*256 RS blocks, this 77 - gives approx. 2.6 sec at 27.5MS/s, rate 3/4 */ 77 + estimation. It is <value>*256 RS blocks, this 78 + gives approx. 2.6 sec at 27.5MS/s, rate 3/4 */ 78 79 {0x16,0x00}, /* @ enable all RS output ports */ 79 80 {0x17,0x04}, /* @ time window allowed for the RS to sync */ 80 81 {0x18,0xae}, /* @ allow all standard DVB code rates to be scanned 81 - for automatically */ 82 + for automatically */ 82 83 /* leave the current code rate and normalization 83 - registers as they are after reset... */ 84 + registers as they are after reset... */ 84 85 {0x21,0x10}, /* @ during AutoAcq, search each viterbi setting 85 - only once */ 86 + only once */ 86 87 {0x23,0x18}, /* @ size of the limited time window for Viterbi BER 87 - estimation. It is <value>*65536 channel bits, i.e. 88 - approx. 38ms at 27.5MS/s, rate 3/4 */ 88 + estimation. It is <value>*65536 channel bits, i.e. 89 + approx. 38ms at 27.5MS/s, rate 3/4 */ 89 90 {0x24,0x24}, /* do not trigger Viterbi CRC test. Finite count window */ 90 91 /* leave front-end AGC parameters at default values */ 91 92 /* leave decimation AGC parameters at default values */
+889
drivers/media/dvb/frontends/cx24123.c
··· 1 + /* 2 + Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver 3 + 4 + Copyright (C) 2005 Steven Toth <stoth@hauppauge.com> 5 + 6 + Support for KWorld DVB-S 100 by Vadim Catana <skystar@moldova.cc> 7 + 8 + This program is free software; you can redistribute it and/or modify 9 + it under the terms of the GNU General Public License as published by 10 + the Free Software Foundation; either version 2 of the License, or 11 + (at your option) any later version. 12 + 13 + This program is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 + GNU General Public License for more details. 17 + 18 + You should have received a copy of the GNU General Public License 19 + along with this program; if not, write to the Free Software 20 + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 + */ 22 + 23 + #include <linux/slab.h> 24 + #include <linux/kernel.h> 25 + #include <linux/module.h> 26 + #include <linux/moduleparam.h> 27 + #include <linux/init.h> 28 + 29 + #include "dvb_frontend.h" 30 + #include "cx24123.h" 31 + 32 + static int debug; 33 + #define dprintk(args...) \ 34 + do { \ 35 + if (debug) printk (KERN_DEBUG "cx24123: " args); \ 36 + } while (0) 37 + 38 + struct cx24123_state 39 + { 40 + struct i2c_adapter* i2c; 41 + struct dvb_frontend_ops ops; 42 + const struct cx24123_config* config; 43 + 44 + struct dvb_frontend frontend; 45 + 46 + u32 lastber; 47 + u16 snr; 48 + u8 lnbreg; 49 + 50 + /* Some PLL specifics for tuning */ 51 + u32 VCAarg; 52 + u32 VGAarg; 53 + u32 bandselectarg; 54 + u32 pllarg; 55 + 56 + /* The Demod/Tuner can't easily provide these, we cache them */ 57 + u32 currentfreq; 58 + u32 currentsymbolrate; 59 + }; 60 + 61 + /* Various tuner defaults need to be established for a given symbol rate Sps */ 62 + static struct 63 + { 64 + u32 symbolrate_low; 65 + u32 symbolrate_high; 66 + u32 VCAslope; 67 + u32 VCAoffset; 68 + u32 VGA1offset; 69 + u32 VGA2offset; 70 + u32 VCAprogdata; 71 + u32 VGAprogdata; 72 + } cx24123_AGC_vals[] = 73 + { 74 + { 75 + .symbolrate_low = 1000000, 76 + .symbolrate_high = 4999999, 77 + .VCAslope = 0x07, 78 + .VCAoffset = 0x0f, 79 + .VGA1offset = 0x1f8, 80 + .VGA2offset = 0x1f8, 81 + .VGAprogdata = (2 << 18) | (0x1f8 << 9) | 0x1f8, 82 + .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x07, 83 + }, 84 + { 85 + .symbolrate_low = 5000000, 86 + .symbolrate_high = 14999999, 87 + .VCAslope = 0x1f, 88 + .VCAoffset = 0x1f, 89 + .VGA1offset = 0x1e0, 90 + .VGA2offset = 0x180, 91 + .VGAprogdata = (2 << 18) | (0x180 << 9) | 0x1e0, 92 + .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x1f, 93 + }, 94 + { 95 + .symbolrate_low = 15000000, 96 + .symbolrate_high = 45000000, 97 + .VCAslope = 0x3f, 98 + .VCAoffset = 0x3f, 99 + .VGA1offset = 0x180, 100 + .VGA2offset = 0x100, 101 + .VGAprogdata = (2 << 18) | (0x100 << 9) | 0x180, 102 + .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x3f, 103 + }, 104 + }; 105 + 106 + /* 107 + * Various tuner defaults need to be established for a given frequency kHz. 108 + * fixme: The bounds on the bands do not match the doc in real life. 109 + * fixme: Some of them have been moved, other might need adjustment. 110 + */ 111 + static struct 112 + { 113 + u32 freq_low; 114 + u32 freq_high; 115 + u32 bandselect; 116 + u32 VCOdivider; 117 + u32 VCOnumber; 118 + u32 progdata; 119 + } cx24123_bandselect_vals[] = 120 + { 121 + { 122 + .freq_low = 950000, 123 + .freq_high = 1018999, 124 + .bandselect = 0x40, 125 + .VCOdivider = 4, 126 + .VCOnumber = 7, 127 + .progdata = (0 << 18) | (0 << 9) | 0x40, 128 + }, 129 + { 130 + .freq_low = 1019000, 131 + .freq_high = 1074999, 132 + .bandselect = 0x80, 133 + .VCOdivider = 4, 134 + .VCOnumber = 8, 135 + .progdata = (0 << 18) | (0 << 9) | 0x80, 136 + }, 137 + { 138 + .freq_low = 1075000, 139 + .freq_high = 1227999, 140 + .bandselect = 0x01, 141 + .VCOdivider = 2, 142 + .VCOnumber = 1, 143 + .progdata = (0 << 18) | (1 << 9) | 0x01, 144 + }, 145 + { 146 + .freq_low = 1228000, 147 + .freq_high = 1349999, 148 + .bandselect = 0x02, 149 + .VCOdivider = 2, 150 + .VCOnumber = 2, 151 + .progdata = (0 << 18) | (1 << 9) | 0x02, 152 + }, 153 + { 154 + .freq_low = 1350000, 155 + .freq_high = 1481999, 156 + .bandselect = 0x04, 157 + .VCOdivider = 2, 158 + .VCOnumber = 3, 159 + .progdata = (0 << 18) | (1 << 9) | 0x04, 160 + }, 161 + { 162 + .freq_low = 1482000, 163 + .freq_high = 1595999, 164 + .bandselect = 0x08, 165 + .VCOdivider = 2, 166 + .VCOnumber = 4, 167 + .progdata = (0 << 18) | (1 << 9) | 0x08, 168 + }, 169 + { 170 + .freq_low = 1596000, 171 + .freq_high = 1717999, 172 + .bandselect = 0x10, 173 + .VCOdivider = 2, 174 + .VCOnumber = 5, 175 + .progdata = (0 << 18) | (1 << 9) | 0x10, 176 + }, 177 + { 178 + .freq_low = 1718000, 179 + .freq_high = 1855999, 180 + .bandselect = 0x20, 181 + .VCOdivider = 2, 182 + .VCOnumber = 6, 183 + .progdata = (0 << 18) | (1 << 9) | 0x20, 184 + }, 185 + { 186 + .freq_low = 1856000, 187 + .freq_high = 2035999, 188 + .bandselect = 0x40, 189 + .VCOdivider = 2, 190 + .VCOnumber = 7, 191 + .progdata = (0 << 18) | (1 << 9) | 0x40, 192 + }, 193 + { 194 + .freq_low = 2036000, 195 + .freq_high = 2149999, 196 + .bandselect = 0x80, 197 + .VCOdivider = 2, 198 + .VCOnumber = 8, 199 + .progdata = (0 << 18) | (1 << 9) | 0x80, 200 + }, 201 + }; 202 + 203 + static struct { 204 + u8 reg; 205 + u8 data; 206 + } cx24123_regdata[] = 207 + { 208 + {0x00, 0x03}, /* Reset system */ 209 + {0x00, 0x00}, /* Clear reset */ 210 + {0x01, 0x3b}, /* Apply sensible defaults, from an i2c sniffer */ 211 + {0x03, 0x07}, 212 + {0x04, 0x10}, 213 + {0x05, 0x04}, 214 + {0x06, 0x31}, 215 + {0x0d, 0x02}, 216 + {0x0e, 0x03}, 217 + {0x0f, 0xfe}, 218 + {0x10, 0x01}, 219 + {0x14, 0x01}, 220 + {0x15, 0x98}, 221 + {0x16, 0x00}, 222 + {0x17, 0x01}, 223 + {0x1b, 0x05}, 224 + {0x1c, 0x80}, 225 + {0x1d, 0x00}, 226 + {0x1e, 0x00}, 227 + {0x20, 0x41}, 228 + {0x21, 0x15}, 229 + {0x27, 0x14}, 230 + {0x28, 0x46}, 231 + {0x29, 0x00}, 232 + {0x2a, 0xb0}, 233 + {0x2b, 0x73}, 234 + {0x2c, 0x00}, 235 + {0x2d, 0x00}, 236 + {0x2e, 0x00}, 237 + {0x2f, 0x00}, 238 + {0x30, 0x00}, 239 + {0x31, 0x00}, 240 + {0x32, 0x8c}, 241 + {0x33, 0x00}, 242 + {0x34, 0x00}, 243 + {0x35, 0x03}, 244 + {0x36, 0x02}, 245 + {0x37, 0x3a}, 246 + {0x3a, 0x00}, /* Enable AGC accumulator */ 247 + {0x44, 0x00}, 248 + {0x45, 0x00}, 249 + {0x46, 0x05}, 250 + {0x56, 0x41}, 251 + {0x57, 0xff}, 252 + {0x67, 0x83}, 253 + }; 254 + 255 + static int cx24123_writereg(struct cx24123_state* state, int reg, int data) 256 + { 257 + u8 buf[] = { reg, data }; 258 + struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; 259 + int err; 260 + 261 + if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 262 + printk("%s: writereg error(err == %i, reg == 0x%02x," 263 + " data == 0x%02x)\n", __FUNCTION__, err, reg, data); 264 + return -EREMOTEIO; 265 + } 266 + 267 + return 0; 268 + } 269 + 270 + static int cx24123_writelnbreg(struct cx24123_state* state, int reg, int data) 271 + { 272 + u8 buf[] = { reg, data }; 273 + /* fixme: put the intersil addr int the config */ 274 + struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = buf, .len = 2 }; 275 + int err; 276 + 277 + if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 278 + printk("%s: writelnbreg error (err == %i, reg == 0x%02x," 279 + " data == 0x%02x)\n", __FUNCTION__, err, reg, data); 280 + return -EREMOTEIO; 281 + } 282 + 283 + /* cache the write, no way to read back */ 284 + state->lnbreg = data; 285 + 286 + return 0; 287 + } 288 + 289 + static int cx24123_readreg(struct cx24123_state* state, u8 reg) 290 + { 291 + int ret; 292 + u8 b0[] = { reg }; 293 + u8 b1[] = { 0 }; 294 + struct i2c_msg msg[] = { 295 + { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, 296 + { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } 297 + }; 298 + 299 + ret = i2c_transfer(state->i2c, msg, 2); 300 + 301 + if (ret != 2) { 302 + printk("%s: reg=0x%x (error=%d)\n", __FUNCTION__, reg, ret); 303 + return ret; 304 + } 305 + 306 + return b1[0]; 307 + } 308 + 309 + static int cx24123_readlnbreg(struct cx24123_state* state, u8 reg) 310 + { 311 + return state->lnbreg; 312 + } 313 + 314 + static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) 315 + { 316 + switch (inversion) { 317 + case INVERSION_OFF: 318 + cx24123_writereg(state, 0x0e, cx24123_readreg(state, 0x0e) & 0x7f); 319 + cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) | 0x80); 320 + break; 321 + case INVERSION_ON: 322 + cx24123_writereg(state, 0x0e, cx24123_readreg(state, 0x0e) | 0x80); 323 + cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) | 0x80); 324 + break; 325 + case INVERSION_AUTO: 326 + cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) & 0x7f); 327 + break; 328 + default: 329 + return -EINVAL; 330 + } 331 + 332 + return 0; 333 + } 334 + 335 + static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_inversion_t *inversion) 336 + { 337 + u8 val; 338 + 339 + val = cx24123_readreg(state, 0x1b) >> 7; 340 + 341 + if (val == 0) 342 + *inversion = INVERSION_OFF; 343 + else 344 + *inversion = INVERSION_ON; 345 + 346 + return 0; 347 + } 348 + 349 + static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) 350 + { 351 + if ( (fec < FEC_NONE) || (fec > FEC_AUTO) ) 352 + fec = FEC_AUTO; 353 + 354 + /* Hardware has 5/11 and 3/5 but are never unused */ 355 + switch (fec) { 356 + case FEC_NONE: 357 + return cx24123_writereg(state, 0x0f, 0x01); 358 + case FEC_1_2: 359 + return cx24123_writereg(state, 0x0f, 0x02); 360 + case FEC_2_3: 361 + return cx24123_writereg(state, 0x0f, 0x04); 362 + case FEC_3_4: 363 + return cx24123_writereg(state, 0x0f, 0x08); 364 + case FEC_5_6: 365 + return cx24123_writereg(state, 0x0f, 0x20); 366 + case FEC_7_8: 367 + return cx24123_writereg(state, 0x0f, 0x80); 368 + case FEC_AUTO: 369 + return cx24123_writereg(state, 0x0f, 0xae); 370 + default: 371 + return -EOPNOTSUPP; 372 + } 373 + } 374 + 375 + static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec) 376 + { 377 + int ret; 378 + u8 val; 379 + 380 + ret = cx24123_readreg (state, 0x1b); 381 + if (ret < 0) 382 + return ret; 383 + val = ret & 0x07; 384 + switch (val) { 385 + case 1: 386 + *fec = FEC_1_2; 387 + break; 388 + case 3: 389 + *fec = FEC_2_3; 390 + break; 391 + case 4: 392 + *fec = FEC_3_4; 393 + break; 394 + case 5: 395 + *fec = FEC_4_5; 396 + break; 397 + case 6: 398 + *fec = FEC_5_6; 399 + break; 400 + case 7: 401 + *fec = FEC_7_8; 402 + break; 403 + case 2: /* *fec = FEC_3_5; break; */ 404 + case 0: /* *fec = FEC_5_11; break; */ 405 + *fec = FEC_AUTO; 406 + break; 407 + default: 408 + *fec = FEC_NONE; // can't happen 409 + } 410 + 411 + return 0; 412 + } 413 + 414 + /* fixme: Symbol rates < 3MSps may not work because of precision loss */ 415 + static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) 416 + { 417 + u32 val; 418 + 419 + val = (srate / 1185) * 100; 420 + 421 + /* Compensate for scaling up, by removing 17 symbols per 1Msps */ 422 + val = val - (17 * (srate / 1000000)); 423 + 424 + cx24123_writereg(state, 0x08, (val >> 16) & 0xff ); 425 + cx24123_writereg(state, 0x09, (val >> 8) & 0xff ); 426 + cx24123_writereg(state, 0x0a, (val ) & 0xff ); 427 + 428 + return 0; 429 + } 430 + 431 + /* 432 + * Based on the required frequency and symbolrate, the tuner AGC has to be configured 433 + * and the correct band selected. Calculate those values 434 + */ 435 + static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 436 + { 437 + struct cx24123_state *state = fe->demodulator_priv; 438 + u32 ndiv = 0, adiv = 0, vco_div = 0; 439 + int i = 0; 440 + 441 + /* Defaults for low freq, low rate */ 442 + state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; 443 + state->VGAarg = cx24123_AGC_vals[0].VGAprogdata; 444 + state->bandselectarg = cx24123_bandselect_vals[0].progdata; 445 + vco_div = cx24123_bandselect_vals[0].VCOdivider; 446 + 447 + /* For the given symbolerate, determine the VCA and VGA programming bits */ 448 + for (i = 0; i < sizeof(cx24123_AGC_vals) / sizeof(cx24123_AGC_vals[0]); i++) 449 + { 450 + if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) && 451 + (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) { 452 + state->VCAarg = cx24123_AGC_vals[i].VCAprogdata; 453 + state->VGAarg = cx24123_AGC_vals[i].VGAprogdata; 454 + } 455 + } 456 + 457 + /* For the given frequency, determine the bandselect programming bits */ 458 + for (i = 0; i < sizeof(cx24123_bandselect_vals) / sizeof(cx24123_bandselect_vals[0]); i++) 459 + { 460 + if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) && 461 + (cx24123_bandselect_vals[i].freq_high >= p->frequency) ) { 462 + state->bandselectarg = cx24123_bandselect_vals[i].progdata; 463 + vco_div = cx24123_bandselect_vals[i].VCOdivider; 464 + } 465 + } 466 + 467 + /* Determine the N/A dividers for the requested lband freq (in kHz). */ 468 + /* Note: 10111 (kHz) is the Crystal Freq and divider of 10. */ 469 + ndiv = ( ((p->frequency * vco_div) / (10111 / 10) / 2) / 32) & 0x1ff; 470 + adiv = ( ((p->frequency * vco_div) / (10111 / 10) / 2) % 32) & 0x1f; 471 + 472 + if (adiv == 0) 473 + adiv++; 474 + 475 + /* determine the correct pll frequency values. */ 476 + /* Command 11, refdiv 11, cpump polarity 1, cpump current 3mA 10. */ 477 + state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (2 << 14); 478 + state->pllarg |= (ndiv << 5) | adiv; 479 + 480 + return 0; 481 + } 482 + 483 + /* 484 + * Tuner data is 21 bits long, must be left-aligned in data. 485 + * Tuner cx24109 is written through a dedicated 3wire interface on the demod chip. 486 + */ 487 + static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_parameters *p, u32 data) 488 + { 489 + struct cx24123_state *state = fe->demodulator_priv; 490 + unsigned long timeout; 491 + 492 + /* align the 21 bytes into to bit23 boundary */ 493 + data = data << 3; 494 + 495 + /* Reset the demod pll word length to 0x15 bits */ 496 + cx24123_writereg(state, 0x21, 0x15); 497 + 498 + /* write the msb 8 bits, wait for the send to be completed */ 499 + timeout = jiffies + msecs_to_jiffies(40); 500 + cx24123_writereg(state, 0x22, (data >> 16) & 0xff); 501 + while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { 502 + if (time_after(jiffies, timeout)) { 503 + printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__); 504 + return -EREMOTEIO; 505 + } 506 + msleep(10); 507 + } 508 + 509 + /* send another 8 bytes, wait for the send to be completed */ 510 + timeout = jiffies + msecs_to_jiffies(40); 511 + cx24123_writereg(state, 0x22, (data>>8) & 0xff ); 512 + while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { 513 + if (time_after(jiffies, timeout)) { 514 + printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__); 515 + return -EREMOTEIO; 516 + } 517 + msleep(10); 518 + } 519 + 520 + /* send the lower 5 bits of this byte, padded with 3 LBB, wait for the send to be completed */ 521 + timeout = jiffies + msecs_to_jiffies(40); 522 + cx24123_writereg(state, 0x22, (data) & 0xff ); 523 + while ((cx24123_readreg(state, 0x20) & 0x80)) { 524 + if (time_after(jiffies, timeout)) { 525 + printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__); 526 + return -EREMOTEIO; 527 + } 528 + msleep(10); 529 + } 530 + 531 + /* Trigger the demod to configure the tuner */ 532 + cx24123_writereg(state, 0x20, cx24123_readreg(state, 0x20) | 2); 533 + cx24123_writereg(state, 0x20, cx24123_readreg(state, 0x20) & 0xfd); 534 + 535 + return 0; 536 + } 537 + 538 + static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 539 + { 540 + struct cx24123_state *state = fe->demodulator_priv; 541 + 542 + if (cx24123_pll_calculate(fe, p) != 0) { 543 + printk("%s: cx24123_pll_calcutate failed\n",__FUNCTION__); 544 + return -EINVAL; 545 + } 546 + 547 + /* Write the new VCO/VGA */ 548 + cx24123_pll_writereg(fe, p, state->VCAarg); 549 + cx24123_pll_writereg(fe, p, state->VGAarg); 550 + 551 + /* Write the new bandselect and pll args */ 552 + cx24123_pll_writereg(fe, p, state->bandselectarg); 553 + cx24123_pll_writereg(fe, p, state->pllarg); 554 + 555 + return 0; 556 + } 557 + 558 + static int cx24123_initfe(struct dvb_frontend* fe) 559 + { 560 + struct cx24123_state *state = fe->demodulator_priv; 561 + int i; 562 + 563 + /* Configure the demod to a good set of defaults */ 564 + for (i = 0; i < sizeof(cx24123_regdata) / sizeof(cx24123_regdata[0]); i++) 565 + cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); 566 + 567 + if (state->config->pll_init) 568 + state->config->pll_init(fe); 569 + 570 + /* Configure the LNB for 14V */ 571 + if (state->config->use_isl6421) 572 + cx24123_writelnbreg(state, 0x0, 0x2a); 573 + 574 + return 0; 575 + } 576 + 577 + static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 578 + { 579 + struct cx24123_state *state = fe->demodulator_priv; 580 + u8 val; 581 + 582 + switch (state->config->use_isl6421) { 583 + 584 + case 1: 585 + 586 + val = cx24123_readlnbreg(state, 0x0); 587 + 588 + switch (voltage) { 589 + case SEC_VOLTAGE_13: 590 + return cx24123_writelnbreg(state, 0x0, val & 0x32); /* V 13v */ 591 + case SEC_VOLTAGE_18: 592 + return cx24123_writelnbreg(state, 0x0, val | 0x04); /* H 18v */ 593 + case SEC_VOLTAGE_OFF: 594 + return cx24123_writelnbreg(state, 0x0, val & 0x30); 595 + default: 596 + return -EINVAL; 597 + }; 598 + 599 + case 0: 600 + 601 + val = cx24123_readreg(state, 0x29); 602 + 603 + switch (voltage) { 604 + case SEC_VOLTAGE_13: 605 + dprintk("%s: setting voltage 13V\n", __FUNCTION__); 606 + if (state->config->enable_lnb_voltage) 607 + state->config->enable_lnb_voltage(fe, 1); 608 + return cx24123_writereg(state, 0x29, val | 0x80); 609 + case SEC_VOLTAGE_18: 610 + dprintk("%s: setting voltage 18V\n", __FUNCTION__); 611 + if (state->config->enable_lnb_voltage) 612 + state->config->enable_lnb_voltage(fe, 1); 613 + return cx24123_writereg(state, 0x29, val & 0x7f); 614 + case SEC_VOLTAGE_OFF: 615 + dprintk("%s: setting voltage off\n", __FUNCTION__); 616 + if (state->config->enable_lnb_voltage) 617 + state->config->enable_lnb_voltage(fe, 0); 618 + return 0; 619 + default: 620 + return -EINVAL; 621 + }; 622 + } 623 + 624 + return 0; 625 + } 626 + 627 + static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, 628 + struct dvb_diseqc_master_cmd *cmd) 629 + { 630 + /* fixme: Implement diseqc */ 631 + printk("%s: No support yet\n",__FUNCTION__); 632 + 633 + return -ENOTSUPP; 634 + } 635 + 636 + static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) 637 + { 638 + struct cx24123_state *state = fe->demodulator_priv; 639 + 640 + int sync = cx24123_readreg(state, 0x14); 641 + int lock = cx24123_readreg(state, 0x20); 642 + 643 + *status = 0; 644 + if (lock & 0x01) 645 + *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; 646 + if (sync & 0x04) 647 + *status |= FE_HAS_VITERBI; 648 + if (sync & 0x08) 649 + *status |= FE_HAS_CARRIER; 650 + if (sync & 0x80) 651 + *status |= FE_HAS_SYNC | FE_HAS_LOCK; 652 + 653 + return 0; 654 + } 655 + 656 + /* 657 + * Configured to return the measurement of errors in blocks, because no UCBLOCKS value 658 + * is available, so this value doubles up to satisfy both measurements 659 + */ 660 + static int cx24123_read_ber(struct dvb_frontend* fe, u32* ber) 661 + { 662 + struct cx24123_state *state = fe->demodulator_priv; 663 + 664 + state->lastber = 665 + ((cx24123_readreg(state, 0x1c) & 0x3f) << 16) | 666 + (cx24123_readreg(state, 0x1d) << 8 | 667 + cx24123_readreg(state, 0x1e)); 668 + 669 + /* Do the signal quality processing here, it's derived from the BER. */ 670 + /* Scale the BER from a 24bit to a SNR 16 bit where higher = better */ 671 + if (state->lastber < 5000) 672 + state->snr = 655*100; 673 + else if ( (state->lastber >= 5000) && (state->lastber < 55000) ) 674 + state->snr = 655*90; 675 + else if ( (state->lastber >= 55000) && (state->lastber < 150000) ) 676 + state->snr = 655*80; 677 + else if ( (state->lastber >= 150000) && (state->lastber < 250000) ) 678 + state->snr = 655*70; 679 + else if ( (state->lastber >= 250000) && (state->lastber < 450000) ) 680 + state->snr = 655*65; 681 + else 682 + state->snr = 0; 683 + 684 + *ber = state->lastber; 685 + 686 + return 0; 687 + } 688 + 689 + static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) 690 + { 691 + struct cx24123_state *state = fe->demodulator_priv; 692 + *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ 693 + 694 + return 0; 695 + } 696 + 697 + static int cx24123_read_snr(struct dvb_frontend* fe, u16* snr) 698 + { 699 + struct cx24123_state *state = fe->demodulator_priv; 700 + *snr = state->snr; 701 + 702 + return 0; 703 + } 704 + 705 + static int cx24123_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 706 + { 707 + struct cx24123_state *state = fe->demodulator_priv; 708 + *ucblocks = state->lastber; 709 + 710 + return 0; 711 + } 712 + 713 + static int cx24123_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 714 + { 715 + struct cx24123_state *state = fe->demodulator_priv; 716 + 717 + if (state->config->set_ts_params) 718 + state->config->set_ts_params(fe, 0); 719 + 720 + state->currentfreq=p->frequency; 721 + state->currentsymbolrate = p->u.qpsk.symbol_rate; 722 + 723 + cx24123_set_inversion(state, p->inversion); 724 + cx24123_set_fec(state, p->u.qpsk.fec_inner); 725 + cx24123_set_symbolrate(state, p->u.qpsk.symbol_rate); 726 + cx24123_pll_tune(fe, p); 727 + 728 + /* Enable automatic aquisition and reset cycle */ 729 + cx24123_writereg(state, 0x03, (cx24123_readreg(state, 0x03) | 0x07)); 730 + cx24123_writereg(state, 0x00, 0x10); 731 + cx24123_writereg(state, 0x00, 0); 732 + 733 + return 0; 734 + } 735 + 736 + static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 737 + { 738 + struct cx24123_state *state = fe->demodulator_priv; 739 + 740 + if (cx24123_get_inversion(state, &p->inversion) != 0) { 741 + printk("%s: Failed to get inversion status\n",__FUNCTION__); 742 + return -EREMOTEIO; 743 + } 744 + if (cx24123_get_fec(state, &p->u.qpsk.fec_inner) != 0) { 745 + printk("%s: Failed to get fec status\n",__FUNCTION__); 746 + return -EREMOTEIO; 747 + } 748 + p->frequency = state->currentfreq; 749 + p->u.qpsk.symbol_rate = state->currentsymbolrate; 750 + 751 + return 0; 752 + } 753 + 754 + static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 755 + { 756 + struct cx24123_state *state = fe->demodulator_priv; 757 + u8 val; 758 + 759 + switch (state->config->use_isl6421) { 760 + case 1: 761 + 762 + val = cx24123_readlnbreg(state, 0x0); 763 + 764 + switch (tone) { 765 + case SEC_TONE_ON: 766 + return cx24123_writelnbreg(state, 0x0, val | 0x10); 767 + case SEC_TONE_OFF: 768 + return cx24123_writelnbreg(state, 0x0, val & 0x2f); 769 + default: 770 + printk("%s: CASE reached default with tone=%d\n", __FUNCTION__, tone); 771 + return -EINVAL; 772 + } 773 + 774 + case 0: 775 + 776 + val = cx24123_readreg(state, 0x29); 777 + 778 + switch (tone) { 779 + case SEC_TONE_ON: 780 + dprintk("%s: setting tone on\n", __FUNCTION__); 781 + return cx24123_writereg(state, 0x29, val | 0x10); 782 + case SEC_TONE_OFF: 783 + dprintk("%s: setting tone off\n",__FUNCTION__); 784 + return cx24123_writereg(state, 0x29, val & 0xef); 785 + default: 786 + printk("%s: CASE reached default with tone=%d\n", __FUNCTION__, tone); 787 + return -EINVAL; 788 + } 789 + } 790 + 791 + return 0; 792 + } 793 + 794 + static void cx24123_release(struct dvb_frontend* fe) 795 + { 796 + struct cx24123_state* state = fe->demodulator_priv; 797 + dprintk("%s\n",__FUNCTION__); 798 + kfree(state); 799 + } 800 + 801 + static struct dvb_frontend_ops cx24123_ops; 802 + 803 + struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, 804 + struct i2c_adapter* i2c) 805 + { 806 + struct cx24123_state* state = NULL; 807 + int ret; 808 + 809 + dprintk("%s\n",__FUNCTION__); 810 + 811 + /* allocate memory for the internal state */ 812 + state = kmalloc(sizeof(struct cx24123_state), GFP_KERNEL); 813 + if (state == NULL) { 814 + printk("Unable to kmalloc\n"); 815 + goto error; 816 + } 817 + 818 + /* setup the state */ 819 + state->config = config; 820 + state->i2c = i2c; 821 + memcpy(&state->ops, &cx24123_ops, sizeof(struct dvb_frontend_ops)); 822 + state->lastber = 0; 823 + state->snr = 0; 824 + state->lnbreg = 0; 825 + state->VCAarg = 0; 826 + state->VGAarg = 0; 827 + state->bandselectarg = 0; 828 + state->pllarg = 0; 829 + state->currentfreq = 0; 830 + state->currentsymbolrate = 0; 831 + 832 + /* check if the demod is there */ 833 + ret = cx24123_readreg(state, 0x00); 834 + if ((ret != 0xd1) && (ret != 0xe1)) { 835 + printk("Version != d1 or e1\n"); 836 + goto error; 837 + } 838 + 839 + /* create dvb_frontend */ 840 + state->frontend.ops = &state->ops; 841 + state->frontend.demodulator_priv = state; 842 + return &state->frontend; 843 + 844 + error: 845 + kfree(state); 846 + 847 + return NULL; 848 + } 849 + 850 + static struct dvb_frontend_ops cx24123_ops = { 851 + 852 + .info = { 853 + .name = "Conexant CX24123/CX24109", 854 + .type = FE_QPSK, 855 + .frequency_min = 950000, 856 + .frequency_max = 2150000, 857 + .frequency_stepsize = 1011, /* kHz for QPSK frontends */ 858 + .frequency_tolerance = 29500, 859 + .symbol_rate_min = 1000000, 860 + .symbol_rate_max = 45000000, 861 + .caps = FE_CAN_INVERSION_AUTO | 862 + FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 863 + FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | 864 + FE_CAN_QPSK | FE_CAN_RECOVER 865 + }, 866 + 867 + .release = cx24123_release, 868 + 869 + .init = cx24123_initfe, 870 + .set_frontend = cx24123_set_frontend, 871 + .get_frontend = cx24123_get_frontend, 872 + .read_status = cx24123_read_status, 873 + .read_ber = cx24123_read_ber, 874 + .read_signal_strength = cx24123_read_signal_strength, 875 + .read_snr = cx24123_read_snr, 876 + .read_ucblocks = cx24123_read_ucblocks, 877 + .diseqc_send_master_cmd = cx24123_send_diseqc_msg, 878 + .set_tone = cx24123_set_tone, 879 + .set_voltage = cx24123_set_voltage, 880 + }; 881 + 882 + module_param(debug, int, 0644); 883 + MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); 884 + 885 + MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24123/cx24109 hardware"); 886 + MODULE_AUTHOR("Steven Toth"); 887 + MODULE_LICENSE("GPL"); 888 + 889 + EXPORT_SYMBOL(cx24123_attach);
+51
drivers/media/dvb/frontends/cx24123.h
··· 1 + /* 2 + Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver 3 + 4 + Copyright (C) 2005 Steven Toth <stoth@hauppauge.com> 5 + 6 + This program is free software; you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation; either version 2 of the License, or 9 + (at your option) any later version. 10 + 11 + This program is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with this program; if not, write to the Free Software 18 + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 + */ 20 + 21 + #ifndef CX24123_H 22 + #define CX24123_H 23 + 24 + #include <linux/dvb/frontend.h> 25 + 26 + struct cx24123_config 27 + { 28 + /* the demodulator's i2c address */ 29 + u8 demod_address; 30 + 31 + /* 32 + cards like Hauppauge Nova-S Plus/Nova-SE2 use an Intersil ISL6421 chip 33 + for LNB control, while KWorld DVB-S 100 use the LNBDC and LNBTone bits 34 + from register 0x29 of the CX24123 demodulator 35 + */ 36 + int use_isl6421; 37 + 38 + /* PLL maintenance */ 39 + int (*pll_init)(struct dvb_frontend* fe); 40 + int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); 41 + 42 + /* Need to set device param for start_dma */ 43 + int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 44 + 45 + void (*enable_lnb_voltage)(struct dvb_frontend* fe, int on); 46 + }; 47 + 48 + extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, 49 + struct i2c_adapter* i2c); 50 + 51 + #endif /* CX24123_H */
+8 -7
drivers/media/dvb/frontends/dvb-pll.c
··· 107 107 }; 108 108 EXPORT_SYMBOL(dvb_pll_microtune_4042); 109 109 110 - struct dvb_pll_desc dvb_pll_thomson_dtt7611 = { 111 - .name = "Thomson dtt7611", 112 - .min = 44000000, 113 - .max = 958000000, 110 + struct dvb_pll_desc dvb_pll_thomson_dtt761x = { 111 + /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */ 112 + .name = "Thomson dtt761x", 113 + .min = 57000000, 114 + .max = 863000000, 114 115 .count = 3, 115 116 .entries = { 116 - { 157250000, 44000000, 62500, 0x8e, 0x39 }, 117 - { 454000000, 44000000, 62500, 0x8e, 0x3a }, 117 + { 147000000, 44000000, 62500, 0x8e, 0x39 }, 118 + { 417000000, 44000000, 62500, 0x8e, 0x3a }, 118 119 { 999999999, 44000000, 62500, 0x8e, 0x3c }, 119 120 }, 120 121 }; 121 - EXPORT_SYMBOL(dvb_pll_thomson_dtt7611); 122 + EXPORT_SYMBOL(dvb_pll_thomson_dtt761x); 122 123 123 124 struct dvb_pll_desc dvb_pll_unknown_1 = { 124 125 .name = "unknown 1", /* used by dntv live dvb-t */
+1 -1
drivers/media/dvb/frontends/dvb-pll.h
··· 25 25 extern struct dvb_pll_desc dvb_pll_thomson_dtt7610; 26 26 extern struct dvb_pll_desc dvb_pll_lg_z201; 27 27 extern struct dvb_pll_desc dvb_pll_microtune_4042; 28 - extern struct dvb_pll_desc dvb_pll_thomson_dtt7611; 28 + extern struct dvb_pll_desc dvb_pll_thomson_dtt761x; 29 29 extern struct dvb_pll_desc dvb_pll_unknown_1; 30 30 31 31 extern struct dvb_pll_desc dvb_pll_tua6010xs;
+3
drivers/media/dvb/frontends/lgdt330x.c
··· 27 27 * DViCO FusionHDTV 3 Gold-T 28 28 * DViCO FusionHDTV 5 Gold 29 29 * DViCO FusionHDTV 5 Lite 30 + * DViCO FusionHDTV 5 USB Gold 30 31 * Air2PC/AirStar 2 ATSC 3rd generation (HD5000) 31 32 * 32 33 * TODO: ··· 403 402 state->config->pll_set(fe, param); 404 403 405 404 /* Keep track of the new frequency */ 405 + /* FIXME this is the wrong way to do this... */ 406 + /* The tuner is shared with the video4linux analog API */ 406 407 state->current_frequency = param->frequency; 407 408 408 409 lgdt330x_SwReset(state);
+2 -1
drivers/media/dvb/frontends/nxt2002.c
··· 22 22 /* 23 23 * This driver needs external firmware. Please use the command 24 24 * "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" to 25 - * download/extract it, and then copy it to /usr/lib/hotplug/firmware. 25 + * download/extract it, and then copy it to /usr/lib/hotplug/firmware 26 + * or /lib/firmware (depending on configuration of firmware hotplug). 26 27 */ 27 28 #define NXT2002_DEFAULT_FIRMWARE "dvb-fe-nxt2002.fw" 28 29 #define CRC_CCIT_MASK 0x1021
+5 -5
drivers/media/dvb/frontends/nxt6000.c
··· 574 574 .symbol_rate_max = 9360000, /* FIXME */ 575 575 .symbol_rate_tolerance = 4000, 576 576 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 577 - FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | 578 - FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO | 579 - FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | 580 - FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | 581 - FE_CAN_HIERARCHY_AUTO, 577 + FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | 578 + FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO | 579 + FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | 580 + FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | 581 + FE_CAN_HIERARCHY_AUTO, 582 582 }, 583 583 584 584 .release = nxt6000_release,
+3 -2
drivers/media/dvb/frontends/or51211.c
··· 25 25 /* 26 26 * This driver needs external firmware. Please use the command 27 27 * "<kerneldir>/Documentation/dvb/get_dvb_firmware or51211" to 28 - * download/extract it, and then copy it to /usr/lib/hotplug/firmware. 28 + * download/extract it, and then copy it to /usr/lib/hotplug/firmware 29 + * or /lib/firmware (depending on configuration of firmware hotplug). 29 30 */ 30 31 #define OR51211_DEFAULT_FIRMWARE "dvb-fe-or51211.fw" 31 32 ··· 113 112 u8 tudata[585]; 114 113 int i; 115 114 116 - dprintk("Firmware is %d bytes\n",fw->size); 115 + dprintk("Firmware is %zd bytes\n",fw->size); 117 116 118 117 /* Get eprom data */ 119 118 tudata[0] = 17;
+2 -2
drivers/media/dvb/frontends/s5h1420.c
··· 521 521 522 522 case FEC_3_4: 523 523 s5h1420_writereg(state, 0x30, 0x04); 524 - s5h1420_writereg(state, 0x31, 0x12 | inversion); 525 - break; 524 + s5h1420_writereg(state, 0x31, 0x12 | inversion); 525 + break; 526 526 527 527 case FEC_5_6: 528 528 s5h1420_writereg(state, 0x30, 0x08);
+2 -1
drivers/media/dvb/frontends/sp8870.c
··· 22 22 /* 23 23 * This driver needs external firmware. Please use the command 24 24 * "<kerneldir>/Documentation/dvb/get_dvb_firmware alps_tdlb7" to 25 - * download/extract it, and then copy it to /usr/lib/hotplug/firmware. 25 + * download/extract it, and then copy it to /usr/lib/hotplug/firmware 26 + * or /lib/firmware (depending on configuration of firmware hotplug). 26 27 */ 27 28 #define SP8870_DEFAULT_FIRMWARE "dvb-fe-sp8870.fw" 28 29
+3 -2
drivers/media/dvb/frontends/sp887x.c
··· 5 5 /* 6 6 * This driver needs external firmware. Please use the command 7 7 * "<kerneldir>/Documentation/dvb/get_dvb_firmware sp887x" to 8 - * download/extract it, and then copy it to /usr/lib/hotplug/firmware. 8 + * download/extract it, and then copy it to /usr/lib/hotplug/firmware 9 + * or /lib/firmware (depending on configuration of firmware hotplug). 9 10 */ 10 11 #define SP887X_DEFAULT_FIRMWARE "dvb-fe-sp887x.fw" 11 12 ··· 582 581 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 583 582 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | 584 583 FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | 585 - FE_CAN_RECOVER 584 + FE_CAN_RECOVER 586 585 }, 587 586 588 587 .release = sp887x_release,
+10 -2
drivers/media/dvb/frontends/stv0299.c
··· 131 131 return ret == 2 ? 0 : ret; 132 132 } 133 133 134 + int stv0299_enable_plli2c (struct dvb_frontend* fe) 135 + { 136 + struct stv0299_state* state = fe->demodulator_priv; 137 + 138 + return stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ 139 + } 140 + 134 141 static int stv0299_set_FEC (struct stv0299_state* state, fe_code_rate_t fec) 135 142 { 136 143 dprintk ("%s\n", __FUNCTION__); ··· 394 387 }; 395 388 } 396 389 397 - static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, u32 cmd) 390 + static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long cmd) 398 391 { 399 392 struct stv0299_state* state = fe->demodulator_priv; 400 393 u8 reg0x08; ··· 414 407 415 408 cmd = cmd << 1; 416 409 if (debug_legacy_dish_switch) 417 - printk ("%s switch command: 0x%04x\n",__FUNCTION__, cmd); 410 + printk ("%s switch command: 0x%04lx\n",__FUNCTION__, cmd); 418 411 419 412 do_gettimeofday (&nexttime); 420 413 if (debug_legacy_dish_switch) ··· 724 717 "Andreas Oberritter, Andrew de Quincey, Kenneth Aafl�y"); 725 718 MODULE_LICENSE("GPL"); 726 719 720 + EXPORT_SYMBOL(stv0299_enable_plli2c); 727 721 EXPORT_SYMBOL(stv0299_writereg); 728 722 EXPORT_SYMBOL(stv0299_attach);
+1
drivers/media/dvb/frontends/stv0299.h
··· 94 94 }; 95 95 96 96 extern int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data); 97 + extern int stv0299_enable_plli2c (struct dvb_frontend* fe); 97 98 98 99 extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, 99 100 struct i2c_adapter* i2c);
+2 -2
drivers/media/dvb/frontends/tda10021.c
··· 95 95 u8 b0 [] = { reg }; 96 96 u8 b1 [] = { 0 }; 97 97 struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, 98 - { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; 98 + { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; 99 99 int ret; 100 100 101 101 ret = i2c_transfer (state->i2c, msg, 2); ··· 434 434 .frequency_max = 858000000, 435 435 .symbol_rate_min = (XIN/2)/64, /* SACLK/64 == (XIN/2)/64 */ 436 436 .symbol_rate_max = (XIN/2)/4, /* SACLK/4 */ 437 - #if 0 437 + #if 0 438 438 .frequency_tolerance = ???, 439 439 .symbol_rate_tolerance = ???, /* ppm */ /* == 8% (spec p. 5) */ 440 440 #endif
+91 -48
drivers/media/dvb/frontends/tda1004x.c
··· 23 23 * This driver needs external firmware. Please use the commands 24 24 * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045", 25 25 * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to 26 - * download/extract them, and then copy them to /usr/lib/hotplug/firmware. 26 + * download/extract them, and then copy them to /usr/lib/hotplug/firmware 27 + * or /lib/firmware (depending on configuration of firmware hotplug). 27 28 */ 28 29 #define TDA10045_DEFAULT_FIRMWARE "dvb-fe-tda10045.fw" 29 30 #define TDA10046_DEFAULT_FIRMWARE "dvb-fe-tda10046.fw" ··· 272 271 static int tda10046h_set_bandwidth(struct tda1004x_state *state, 273 272 fe_bandwidth_t bandwidth) 274 273 { 275 - static u8 bandwidth_6mhz[] = { 0x80, 0x15, 0xfe, 0xab, 0x8e }; 276 - static u8 bandwidth_7mhz[] = { 0x6e, 0x02, 0x53, 0xc8, 0x25 }; 277 - static u8 bandwidth_8mhz[] = { 0x60, 0x12, 0xa8, 0xe4, 0xbd }; 274 + static u8 bandwidth_6mhz_53M[] = { 0x7b, 0x2e, 0x11, 0xf0, 0xd2 }; 275 + static u8 bandwidth_7mhz_53M[] = { 0x6a, 0x02, 0x6a, 0x43, 0x9f }; 276 + static u8 bandwidth_8mhz_53M[] = { 0x5c, 0x32, 0xc2, 0x96, 0x6d }; 278 277 278 + static u8 bandwidth_6mhz_48M[] = { 0x70, 0x02, 0x49, 0x24, 0x92 }; 279 + static u8 bandwidth_7mhz_48M[] = { 0x60, 0x02, 0xaa, 0xaa, 0xab }; 280 + static u8 bandwidth_8mhz_48M[] = { 0x54, 0x03, 0x0c, 0x30, 0xc3 }; 281 + int tda10046_clk53m; 282 + 283 + if ((state->config->if_freq == TDA10046_FREQ_045) || 284 + (state->config->if_freq == TDA10046_FREQ_052)) 285 + tda10046_clk53m = 0; 286 + else 287 + tda10046_clk53m = 1; 279 288 switch (bandwidth) { 280 289 case BANDWIDTH_6_MHZ: 281 - tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz, sizeof(bandwidth_6mhz)); 290 + if (tda10046_clk53m) 291 + tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz_53M, 292 + sizeof(bandwidth_6mhz_53M)); 293 + else 294 + tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz_48M, 295 + sizeof(bandwidth_6mhz_48M)); 282 296 if (state->config->if_freq == TDA10046_FREQ_045) { 283 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x09); 284 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x4f); 297 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0a); 298 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xab); 285 299 } 286 300 break; 287 301 288 302 case BANDWIDTH_7_MHZ: 289 - tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz, sizeof(bandwidth_7mhz)); 303 + if (tda10046_clk53m) 304 + tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz_53M, 305 + sizeof(bandwidth_7mhz_53M)); 306 + else 307 + tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz_48M, 308 + sizeof(bandwidth_7mhz_48M)); 290 309 if (state->config->if_freq == TDA10046_FREQ_045) { 291 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0a); 292 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x79); 310 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c); 311 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x00); 293 312 } 294 313 break; 295 314 296 315 case BANDWIDTH_8_MHZ: 297 - tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz, sizeof(bandwidth_8mhz)); 316 + if (tda10046_clk53m) 317 + tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz_53M, 318 + sizeof(bandwidth_8mhz_53M)); 319 + else 320 + tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz_48M, 321 + sizeof(bandwidth_8mhz_48M)); 298 322 if (state->config->if_freq == TDA10046_FREQ_045) { 299 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0b); 300 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xa3); 323 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0d); 324 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x55); 301 325 } 302 326 break; 303 327 ··· 444 418 static void tda10046_init_plls(struct dvb_frontend* fe) 445 419 { 446 420 struct tda1004x_state* state = fe->demodulator_priv; 421 + int tda10046_clk53m; 422 + 423 + if ((state->config->if_freq == TDA10046_FREQ_045) || 424 + (state->config->if_freq == TDA10046_FREQ_052)) 425 + tda10046_clk53m = 0; 426 + else 427 + tda10046_clk53m = 1; 447 428 448 429 tda1004x_write_byteI(state, TDA10046H_CONFPLL1, 0xf0); 449 - tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x0a); // PLL M = 10 430 + if(tda10046_clk53m) { 431 + printk(KERN_INFO "tda1004x: setting up plls for 53MHz sampling clock\n"); 432 + tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x08); // PLL M = 8 433 + } else { 434 + printk(KERN_INFO "tda1004x: setting up plls for 48MHz sampling clock\n"); 435 + tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x03); // PLL M = 3 436 + } 450 437 if (state->config->xtal_freq == TDA10046_XTAL_4M ) { 451 438 dprintk("%s: setting up PLLs for a 4 MHz Xtal\n", __FUNCTION__); 452 439 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0); // PLL P = N = 0 ··· 467 428 dprintk("%s: setting up PLLs for a 16 MHz Xtal\n", __FUNCTION__); 468 429 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 3); // PLL P = 0, N = 3 469 430 } 470 - tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99); 431 + if(tda10046_clk53m) 432 + tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 0x67); 433 + else 434 + tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 0x72); 435 + /* Note clock frequency is handled implicitly */ 471 436 switch (state->config->if_freq) { 472 - case TDA10046_FREQ_3617: 473 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4); 474 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c); 475 - break; 476 - case TDA10046_FREQ_3613: 477 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4); 478 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x13); 479 - break; 480 437 case TDA10046_FREQ_045: 481 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0b); 482 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xa3); 438 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c); 439 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x00); 483 440 break; 484 441 case TDA10046_FREQ_052: 485 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c); 486 - tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x06); 442 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0d); 443 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xc7); 444 + break; 445 + case TDA10046_FREQ_3617: 446 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd7); 447 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x59); 448 + break; 449 + case TDA10046_FREQ_3613: 450 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd7); 451 + tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x3f); 487 452 break; 488 453 } 489 454 tda10046h_set_bandwidth(state, BANDWIDTH_8_MHZ); // default bandwidth 8 MHz 455 + /* let the PLLs settle */ 456 + msleep(120); 490 457 } 491 458 492 459 static int tda10046_fwupload(struct dvb_frontend* fe) ··· 507 462 /* let the clocks recover from sleep */ 508 463 msleep(5); 509 464 465 + /* The PLLs need to be reprogrammed after sleep */ 466 + tda10046_init_plls(fe); 467 + 510 468 /* don't re-upload unless necessary */ 511 469 if (tda1004x_check_upload_ok(state) == 0) 512 470 return 0; 513 - 514 - /* set parameters */ 515 - tda10046_init_plls(fe); 516 471 517 472 if (state->config->request_firmware != NULL) { 518 473 /* request the firmware, this will block until someone uploads it */ ··· 529 484 return ret; 530 485 } else { 531 486 /* boot from firmware eeprom */ 532 - /* Hac Note: we might need to do some GPIO Magic here */ 533 487 printk(KERN_INFO "tda1004x: booting from eeprom\n"); 534 488 tda1004x_write_mask(state, TDA1004X_CONFC4, 4, 4); 535 489 msleep(300); ··· 650 606 651 607 // tda setup 652 608 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer 653 - tda1004x_write_byteI(state, TDA1004X_AUTO, 7); // select HP stream 654 - tda1004x_write_byteI(state, TDA1004X_CONFC1, 8); // disable pulse killer 609 + tda1004x_write_byteI(state, TDA1004X_AUTO, 0x87); // 100 ppm crystal, select HP stream 610 + tda1004x_write_byteI(state, TDA1004X_CONFC1, 8); // disable pulse killer 655 611 656 - tda10046_init_plls(fe); 657 612 switch (state->config->agc_config) { 658 613 case TDA10046_AGC_DEFAULT: 659 614 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x00); // AGC setup ··· 669 626 case TDA10046_AGC_TDA827X: 670 627 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup 671 628 tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold 672 - tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x0E); // Gain Renormalize 673 - tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities 629 + tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize 630 + tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x6a); // set AGC polarities 674 631 break; 675 632 } 633 + tda1004x_write_byteI(state, TDA1004X_CONFADC2, 0x38); 676 634 tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0x61); // Turn both AGC outputs on 677 635 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MIN, 0); // } 678 636 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MAX, 0xff); // } AGC min/max values 679 637 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MIN, 0); // } 680 638 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MAX, 0xff); // } 681 - tda1004x_write_byteI(state, TDA10046H_AGC_GAINS, 1); // IF gain 2, TUN gain 1 639 + tda1004x_write_byteI(state, TDA10046H_AGC_GAINS, 0x12); // IF gain 2, TUN gain 1 682 640 tda1004x_write_byteI(state, TDA10046H_CVBER_CTRL, 0x1a); // 10^6 VBER measurement bits 683 641 tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 7); // MPEG2 interface config 684 642 tda1004x_write_byteI(state, TDA1004X_CONF_TS2, 0xc0); // MPEG2 interface config 685 643 tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7); 686 - 687 - tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE2, 0xe1); // tristate setup 688 - tda1004x_write_byteI(state, TDA10046H_GPIO_OUT_SEL, 0xcc); // GPIO output config 689 - tda1004x_write_byteI(state, TDA10046H_GPIO_SELECT, 8); // GPIO select 690 644 691 645 state->initialised = 1; 692 646 return 0; ··· 726 686 727 687 // Set standard params.. or put them to auto 728 688 if ((fe_params->u.ofdm.code_rate_HP == FEC_AUTO) || 729 - (fe_params->u.ofdm.code_rate_LP == FEC_AUTO) || 730 - (fe_params->u.ofdm.constellation == QAM_AUTO) || 731 - (fe_params->u.ofdm.hierarchy_information == HIERARCHY_AUTO)) { 689 + (fe_params->u.ofdm.code_rate_LP == FEC_AUTO) || 690 + (fe_params->u.ofdm.constellation == QAM_AUTO) || 691 + (fe_params->u.ofdm.hierarchy_information == HIERARCHY_AUTO)) { 732 692 tda1004x_write_mask(state, TDA1004X_AUTO, 1, 1); // enable auto 733 693 tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x03, 0); // turn off constellation bits 734 694 tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 0); // turn off hierarchy bits ··· 891 851 static int tda1004x_get_fe(struct dvb_frontend* fe, struct dvb_frontend_parameters *fe_params) 892 852 { 893 853 struct tda1004x_state* state = fe->demodulator_priv; 854 + 894 855 dprintk("%s\n", __FUNCTION__); 895 856 896 857 // inversion status ··· 916 875 break; 917 876 } 918 877 break; 919 - 920 878 case TDA1004X_DEMOD_TDA10046: 921 879 switch (tda1004x_read_byte(state, TDA10046H_TIME_WREF1)) { 922 - case 0x60: 880 + case 0x5c: 881 + case 0x54: 923 882 fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ; 924 883 break; 925 - case 0x6e: 884 + case 0x6a: 885 + case 0x60: 926 886 fe_params->u.ofdm.bandwidth = BANDWIDTH_7_MHZ; 927 887 break; 928 - case 0x80: 888 + case 0x7b: 889 + case 0x70: 929 890 fe_params->u.ofdm.bandwidth = BANDWIDTH_6_MHZ; 930 891 break; 931 892 }
+1 -1
drivers/media/dvb/pluto2/Kconfig
··· 8 8 Support for PCI cards based on the Pluto2 FPGA like the Satelco 9 9 Easywatch Mobile Terrestrial DVB-T Receiver. 10 10 11 - Since these cards have no MPEG decoder onboard, they transmit 11 + Since these cards have no MPEG decoder onboard, they transmit 12 12 only compressed MPEG data over the PCI bus, so you need 13 13 an external software decoder to watch TV on your computer. 14 14
+4 -3
drivers/media/dvb/ttpci/Kconfig
··· 18 18 This driver only supports the fullfeatured cards with 19 19 onboard MPEG2 decoder. 20 20 21 - This driver needs an external firmware. Please use the script 22 - "<kerneldir>/Documentation/dvb/get_dvb_firmware av7110" to 23 - download/extract it, and then copy it to /usr/lib/hotplug/firmware. 21 + This driver needs an external firmware. Please use the script 22 + "<kerneldir>/Documentation/dvb/get_dvb_firmware av7110" to 23 + download/extract it, and then copy it to /usr/lib/hotplug/firmware 24 + or /lib/firmware (depending on configuration of firmware hotplug). 24 25 25 26 Say Y if you own such a card and want to use it. 26 27
+1 -1
drivers/media/dvb/ttpci/Makefile
··· 16 16 hostprogs-y := fdump 17 17 18 18 ifdef CONFIG_DVB_AV7110_FIRMWARE 19 - $(obj)/av7110.o: $(obj)/fdump $(obj)/av7110_firm.h 19 + $(obj)/av7110.o: $(obj)/fdump $(obj)/av7110_firm.h 20 20 21 21 $(obj)/av7110_firm.h: 22 22 $(obj)/fdump $(CONFIG_DVB_AV7110_FIRMWARE_FILE) dvb_ttpci_fw $@
+92 -41
drivers/media/dvb/ttpci/av7110.c
··· 133 133 /* remaining inits according to card and frontend type */ 134 134 av7110->analog_tuner_flags = 0; 135 135 av7110->current_input = 0; 136 - if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) { 136 + if (dev->pci->subsystem_vendor == 0x13c2 && dev->pci->subsystem_device == 0x000a) { 137 + printk("dvb-ttpci: MSP3415 audio DAC @ card %d\n", 138 + av7110->dvb_adapter.num); 139 + av7110->adac_type = DVB_ADAC_MSP34x5; 140 + av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 0); // SPDIF on 141 + } 142 + else if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) { 137 143 printk ("dvb-ttpci: Crystal audio DAC @ card %d detected\n", 138 144 av7110->dvb_adapter.num); 139 145 av7110->adac_type = DVB_ADAC_CRYSTAL; ··· 162 156 else { 163 157 av7110->adac_type = adac; 164 158 printk("dvb-ttpci: adac type set to %d @ card %d\n", 165 - av7110->dvb_adapter.num, av7110->adac_type); 159 + av7110->adac_type, av7110->dvb_adapter.num); 166 160 } 167 161 168 - if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) { 162 + if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP34x0) { 169 163 // switch DVB SCART on 170 164 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0); 171 165 if (ret < 0) ··· 196 190 197 191 av7110_bootarm(av7110); 198 192 msleep(100); 193 + 194 + init_av7110_av(av7110); 195 + 196 + /* card-specific recovery */ 197 + if (av7110->recover) 198 + av7110->recover(av7110); 199 + 199 200 restart_feeds(av7110); 200 201 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, av7110->ir_config); 201 - } 202 - 203 - static void arm_error(struct av7110 *av7110) 204 - { 205 - dprintk(4, "%p\n",av7110); 206 - 207 - av7110->arm_errors++; 208 - av7110->arm_ready = 0; 209 - recover_arm(av7110); 210 202 } 211 203 212 204 static void av7110_arm_sync(struct av7110 *av7110) ··· 244 240 245 241 if (down_interruptible(&av7110->dcomlock)) 246 242 break; 247 - 248 243 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2); 249 244 up(&av7110->dcomlock); 250 245 251 - if (newloops == av7110->arm_loops) { 246 + if (newloops == av7110->arm_loops || av7110->arm_errors > 3) { 252 247 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n", 253 248 av7110->dvb_adapter.num); 254 249 255 - arm_error(av7110); 256 - av7710_set_video_mode(av7110, vidmode); 257 - 258 - init_av7110_av(av7110); 250 + recover_arm(av7110); 259 251 260 252 if (down_interruptible(&av7110->dcomlock)) 261 253 break; 262 - 263 254 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1; 264 255 up(&av7110->dcomlock); 265 256 } 266 257 av7110->arm_loops = newloops; 258 + av7110->arm_errors = 0; 267 259 } 268 260 269 261 av7110->arm_thread = NULL; ··· 510 510 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); 511 511 512 512 av7110->video_size.h = h_ar & 0xfff; 513 - dprintk(8, "GPIO0 irq: DATA_MPEG_VIDEO_EVENT: w/h/ar = %u/%u/%u\n", 514 - av7110->video_size.w, 515 - av7110->video_size.h, 516 - av7110->video_size.aspect_ratio); 517 513 518 514 event.type = VIDEO_EVENT_SIZE_CHANGED; 519 515 event.u.size.w = av7110->video_size.w; ··· 531 535 event.u.size.aspect_ratio = VIDEO_FORMAT_4_3; 532 536 av7110->videostate.video_format = VIDEO_FORMAT_4_3; 533 537 } 538 + 539 + dprintk(8, "GPIO0 irq: DATA_MPEG_VIDEO_EVENT: w/h/ar = %u/%u/%u\n", 540 + av7110->video_size.w, av7110->video_size.h, 541 + av7110->video_size.aspect_ratio); 542 + 534 543 dvb_video_add_event(av7110, &event); 535 544 break; 536 545 } ··· 715 714 static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, 716 715 u16 subpid, u16 pcrpid) 717 716 { 717 + u16 aflags = 0; 718 + 718 719 dprintk(4, "%p\n", av7110); 719 720 720 721 if (vpid == 0x1fff || apid == 0x1fff || ··· 728 725 av7110->pids[DMX_PES_PCR] = 0; 729 726 } 730 727 731 - return av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, MultiPID, 5, 732 - pcrpid, vpid, apid, ttpid, subpid); 728 + if (av7110->audiostate.bypass_mode) 729 + aflags |= 0x8000; 730 + 731 + return av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, MultiPID, 6, 732 + pcrpid, vpid, apid, ttpid, subpid, aflags); 733 733 } 734 734 735 735 int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, ··· 1049 1043 struct dvb_demux *dvbdmx = &av7110->demux; 1050 1044 struct dvb_demux_feed *feed; 1051 1045 int mode; 1052 - int i; 1046 + int i, j; 1053 1047 1054 1048 dprintk(4, "%p\n", av7110); 1055 1049 ··· 1057 1051 av7110->playing = 0; 1058 1052 av7110->rec_mode = 0; 1059 1053 1060 - for (i = 0; i < dvbdmx->filternum; i++) { 1054 + for (i = 0; i < dvbdmx->feednum; i++) { 1061 1055 feed = &dvbdmx->feed[i]; 1062 - if (feed->state == DMX_STATE_GO) 1056 + if (feed->state == DMX_STATE_GO) { 1057 + if (feed->type == DMX_TYPE_SEC) { 1058 + for (j = 0; j < dvbdmx->filternum; j++) { 1059 + if (dvbdmx->filter[j].type != DMX_TYPE_SEC) 1060 + continue; 1061 + if (dvbdmx->filter[j].filter.parent != &feed->feed.sec) 1062 + continue; 1063 + if (dvbdmx->filter[j].state == DMX_STATE_GO) 1064 + dvbdmx->filter[j].state = DMX_STATE_READY; 1065 + } 1066 + } 1063 1067 av7110_start_feed(feed); 1068 + } 1064 1069 } 1065 1070 1066 1071 if (mode) ··· 1500 1483 if (ret == -ENOENT) { 1501 1484 printk(KERN_ERR "dvb-ttpci: could not load firmware," 1502 1485 " file not found: dvb-ttpci-01.fw\n"); 1503 - printk(KERN_ERR "dvb-ttpci: usually this should be in" 1504 - " /usr/lib/hotplug/firmware\n"); 1505 - printk(KERN_ERR "dvb-ttpci: and can be downloaded here" 1486 + printk(KERN_ERR "dvb-ttpci: usually this should be in " 1487 + "/usr/lib/hotplug/firmware or /lib/firmware\n"); 1488 + printk(KERN_ERR "dvb-ttpci: and can be downloaded from" 1506 1489 " http://www.linuxtv.org/download/dvb/firmware/\n"); 1507 1490 } else 1508 1491 printk(KERN_ERR "dvb-ttpci: cannot request firmware" ··· 2127 2110 struct av7110* av7110 = fe->dvb->priv; 2128 2111 2129 2112 int ret = av7110_fe_lock_fix(av7110, 0); 2130 - if (!ret) 2113 + if (!ret) { 2114 + av7110->saved_fe_params = *params; 2131 2115 ret = av7110->fe_set_frontend(fe, params); 2116 + } 2132 2117 return ret; 2133 2118 } 2134 2119 ··· 2172 2153 struct av7110* av7110 = fe->dvb->priv; 2173 2154 2174 2155 int ret = av7110_fe_lock_fix(av7110, 0); 2175 - if (!ret) 2156 + if (!ret) { 2157 + av7110->saved_master_cmd = *cmd; 2176 2158 ret = av7110->fe_diseqc_send_master_cmd(fe, cmd); 2159 + } 2177 2160 return ret; 2178 2161 } 2179 2162 ··· 2184 2163 struct av7110* av7110 = fe->dvb->priv; 2185 2164 2186 2165 int ret = av7110_fe_lock_fix(av7110, 0); 2187 - if (!ret) 2166 + if (!ret) { 2167 + av7110->saved_minicmd = minicmd; 2188 2168 ret = av7110->fe_diseqc_send_burst(fe, minicmd); 2169 + } 2189 2170 return ret; 2190 2171 } 2191 2172 ··· 2196 2173 struct av7110* av7110 = fe->dvb->priv; 2197 2174 2198 2175 int ret = av7110_fe_lock_fix(av7110, 0); 2199 - if (!ret) 2176 + if (!ret) { 2177 + av7110->saved_tone = tone; 2200 2178 ret = av7110->fe_set_tone(fe, tone); 2179 + } 2201 2180 return ret; 2202 2181 } 2203 2182 ··· 2208 2183 struct av7110* av7110 = fe->dvb->priv; 2209 2184 2210 2185 int ret = av7110_fe_lock_fix(av7110, 0); 2211 - if (!ret) 2186 + if (!ret) { 2187 + av7110->saved_voltage = voltage; 2212 2188 ret = av7110->fe_set_voltage(fe, voltage); 2189 + } 2213 2190 return ret; 2214 2191 } 2215 2192 2216 - static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned int cmd) 2193 + static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned long cmd) 2217 2194 { 2218 2195 struct av7110* av7110 = fe->dvb->priv; 2219 2196 ··· 2223 2196 if (!ret) 2224 2197 ret = av7110->fe_dishnetwork_send_legacy_command(fe, cmd); 2225 2198 return ret; 2199 + } 2200 + 2201 + static void dvb_s_recover(struct av7110* av7110) 2202 + { 2203 + av7110_fe_init(av7110->fe); 2204 + 2205 + av7110_fe_set_voltage(av7110->fe, av7110->saved_voltage); 2206 + if (av7110->saved_master_cmd.msg_len) { 2207 + msleep(20); 2208 + av7110_fe_diseqc_send_master_cmd(av7110->fe, &av7110->saved_master_cmd); 2209 + } 2210 + msleep(20); 2211 + av7110_fe_diseqc_send_burst(av7110->fe, av7110->saved_minicmd); 2212 + msleep(20); 2213 + av7110_fe_set_tone(av7110->fe, av7110->saved_tone); 2214 + 2215 + av7110_fe_set_frontend(av7110->fe, &av7110->saved_fe_params); 2226 2216 } 2227 2217 2228 2218 static u8 read_pwm(struct av7110* av7110) ··· 2279 2235 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2280 2236 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; 2281 2237 av7110->fe->ops->set_tone = av7110_set_tone; 2238 + av7110->recover = dvb_s_recover; 2282 2239 break; 2283 2240 } 2284 2241 ··· 2289 2244 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2290 2245 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; 2291 2246 av7110->fe->ops->set_tone = av7110_set_tone; 2247 + av7110->recover = dvb_s_recover; 2292 2248 break; 2293 2249 } 2294 2250 2295 2251 // Try the grundig 29504-451 2296 - av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap); 2252 + av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap); 2297 2253 if (av7110->fe) { 2298 2254 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2299 2255 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; 2300 2256 av7110->fe->ops->set_tone = av7110_set_tone; 2257 + av7110->recover = dvb_s_recover; 2301 2258 break; 2302 2259 } 2303 2260 ··· 2321 2274 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X 2322 2275 2323 2276 // ALPS TDLB7 2324 - av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap); 2277 + av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap); 2325 2278 break; 2326 2279 2327 2280 case 0x0002: // Hauppauge/TT DVB-C premium rev2.X 2328 2281 2329 - av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110)); 2282 + av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110)); 2330 2283 break; 2331 2284 2332 2285 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */ ··· 2336 2289 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2337 2290 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; 2338 2291 av7110->fe->ops->set_tone = av7110_set_tone; 2292 + av7110->recover = dvb_s_recover; 2339 2293 } 2340 2294 break; 2341 2295 ··· 2362 2314 case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */ 2363 2315 /* ALPS BSBE1 */ 2364 2316 av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap); 2365 - if (av7110->fe) 2317 + if (av7110->fe) { 2366 2318 av7110->fe->ops->set_voltage = lnbp21_set_voltage; 2319 + av7110->fe->ops->dishnetwork_send_legacy_command = NULL; 2320 + av7110->recover = dvb_s_recover; 2321 + } 2367 2322 break; 2368 2323 } 2369 2324 }
+15 -2
drivers/media/dvb/ttpci/av7110.h
··· 98 98 int adac_type; /* audio DAC type */ 99 99 #define DVB_ADAC_TI 0 100 100 #define DVB_ADAC_CRYSTAL 1 101 - #define DVB_ADAC_MSP 2 101 + #define DVB_ADAC_MSP34x0 2 102 + #define DVB_ADAC_MSP34x5 3 102 103 #define DVB_ADAC_NONE -1 103 104 104 105 ··· 229 228 struct dvb_video_events video_events; 230 229 video_size_t video_size; 231 230 231 + u16 wssMode; 232 + u16 wssData; 233 + 232 234 u32 ir_config; 233 235 u32 ir_command; 234 236 void (*ir_handler)(struct av7110 *av7110, u32 ircom); ··· 249 245 250 246 struct dvb_frontend* fe; 251 247 fe_status_t fe_status; 248 + 249 + /* crash recovery */ 250 + void (*recover)(struct av7110* av7110); 251 + struct dvb_frontend_parameters saved_fe_params; 252 + fe_sec_voltage_t saved_voltage; 253 + fe_sec_tone_mode_t saved_tone; 254 + struct dvb_diseqc_master_cmd saved_master_cmd; 255 + fe_sec_mini_cmd_t saved_minicmd; 256 + 252 257 int (*fe_init)(struct dvb_frontend* fe); 253 258 int (*fe_read_status)(struct dvb_frontend* fe, fe_status_t* status); 254 259 int (*fe_diseqc_reset_overload)(struct dvb_frontend* fe); ··· 265 252 int (*fe_diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd); 266 253 int (*fe_set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone); 267 254 int (*fe_set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage); 268 - int (*fe_dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned int cmd); 255 + int (*fe_dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd); 269 256 int (*fe_set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); 270 257 }; 271 258
+9 -3
drivers/media/dvb/ttpci/av7110_av.c
··· 309 309 i2c_writereg(av7110, 0x20, 0x04, volright); 310 310 return 0; 311 311 312 - case DVB_ADAC_MSP: 312 + case DVB_ADAC_MSP34x0: 313 313 vol = (volleft > volright) ? volleft : volright; 314 314 val = (vol * 0x73 / 255) << 8; 315 315 if (vol > 0) ··· 1256 1256 break; 1257 1257 1258 1258 case AUDIO_SET_BYPASS_MODE: 1259 - ret = -EINVAL; 1259 + if (FW_VERSION(av7110->arm_app) < 0x2621) 1260 + ret = -EINVAL; 1261 + av7110->audiostate.bypass_mode = (int)arg; 1260 1262 break; 1261 1263 1262 1264 case AUDIO_CHANNEL_SELECT: ··· 1297 1295 break; 1298 1296 1299 1297 case AUDIO_GET_CAPABILITIES: 1300 - *(int *)parg = AUDIO_CAP_LPCM | AUDIO_CAP_MP1 | AUDIO_CAP_MP2; 1298 + if (FW_VERSION(av7110->arm_app) < 0x2621) 1299 + *(unsigned int *)parg = AUDIO_CAP_LPCM | AUDIO_CAP_MP1 | AUDIO_CAP_MP2; 1300 + else 1301 + *(unsigned int *)parg = AUDIO_CAP_LPCM | AUDIO_CAP_DTS | AUDIO_CAP_AC3 | 1302 + AUDIO_CAP_MP1 | AUDIO_CAP_MP2; 1301 1303 break; 1302 1304 1303 1305 case AUDIO_CLEAR_BUFFER:
+5 -2
drivers/media/dvb/ttpci/av7110_hw.c
··· 230 230 231 231 dprintk(4, "%p\n", av7110); 232 232 233 + av7110->arm_ready = 0; 234 + 233 235 saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTLO); 234 236 235 237 /* Disable DEBI and GPIO irq */ ··· 363 361 break; 364 362 if (err) { 365 363 printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND idle\n", __FUNCTION__); 364 + av7110->arm_errors++; 366 365 return -ETIMEDOUT; 367 366 } 368 367 msleep(1); ··· 1209 1206 switch (cap->cmd) { 1210 1207 case OSD_CAP_MEMSIZE: 1211 1208 if (FW_4M_SDRAM(av7110->arm_app)) 1212 - cap->val = 1000000; 1209 + cap->val = 1000000; 1213 1210 else 1214 - cap->val = 92000; 1211 + cap->val = 92000; 1215 1212 return 0; 1216 1213 default: 1217 1214 return -EINVAL;
+2 -1
drivers/media/dvb/ttpci/av7110_hw.h
··· 167 167 LoadVidCode, 168 168 SetMonitorType, 169 169 SetPanScanType, 170 - SetFreezeMode 170 + SetFreezeMode, 171 + SetWSSConfig 171 172 }; 172 173 173 174 enum av7110_rec_play_state {
+10 -4
drivers/media/dvb/ttpci/av7110_ir.c
··· 17 17 static struct av7110 *av_list[4]; 18 18 static struct input_dev *input_dev; 19 19 20 + static u8 delay_timer_finished; 21 + 20 22 static u16 key_map [256] = { 21 23 KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, 22 24 KEY_8, KEY_9, KEY_BACK, 0, KEY_POWER, KEY_MUTE, 0, KEY_INFO, ··· 114 112 if (timer_pending(&keyup_timer)) { 115 113 del_timer(&keyup_timer); 116 114 if (keyup_timer.data != keycode || new_toggle != old_toggle) { 115 + delay_timer_finished = 0; 117 116 input_event(input_dev, EV_KEY, keyup_timer.data, !!0); 118 117 input_event(input_dev, EV_KEY, keycode, !0); 119 118 } else 120 - input_event(input_dev, EV_KEY, keycode, 2); 121 - 122 - } else 119 + if (delay_timer_finished) 120 + input_event(input_dev, EV_KEY, keycode, 2); 121 + } else { 122 + delay_timer_finished = 0; 123 123 input_event(input_dev, EV_KEY, keycode, !0); 124 + } 124 125 125 126 keyup_timer.expires = jiffies + UP_TIMEOUT; 126 127 keyup_timer.data = keycode; ··· 150 145 151 146 static void input_repeat_key(unsigned long data) 152 147 { 153 - /* dummy routine to disable autorepeat in the input driver */ 148 + /* called by the input driver after rep[REP_DELAY] ms */ 149 + delay_timer_finished = 1; 154 150 } 155 151 156 152
+110 -8
drivers/media/dvb/ttpci/av7110_v4l.c
··· 490 490 dprintk(2, "VIDIOC_S_AUDIO: %d\n", a->index); 491 491 break; 492 492 } 493 + case VIDIOC_G_SLICED_VBI_CAP: 494 + { 495 + struct v4l2_sliced_vbi_cap *cap = arg; 496 + dprintk(2, "VIDIOC_G_SLICED_VBI_CAP\n"); 497 + memset(cap, 0, sizeof *cap); 498 + if (FW_VERSION(av7110->arm_app) >= 0x2623) { 499 + cap->service_set = V4L2_SLICED_WSS_625; 500 + cap->service_lines[0][23] = V4L2_SLICED_WSS_625; 501 + } 502 + break; 503 + } 504 + case VIDIOC_G_FMT: 505 + { 506 + struct v4l2_format *f = arg; 507 + dprintk(2, "VIDIOC_G_FMT:\n"); 508 + if (f->type != V4L2_BUF_TYPE_SLICED_VBI_OUTPUT || 509 + FW_VERSION(av7110->arm_app) < 0x2623) 510 + return -EAGAIN; /* handled by core driver */ 511 + memset(&f->fmt.sliced, 0, sizeof f->fmt.sliced); 512 + if (av7110->wssMode) { 513 + f->fmt.sliced.service_set = V4L2_SLICED_WSS_625; 514 + f->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625; 515 + f->fmt.sliced.io_size = sizeof (struct v4l2_sliced_vbi_data); 516 + } 517 + break; 518 + } 519 + case VIDIOC_S_FMT: 520 + { 521 + struct v4l2_format *f = arg; 522 + dprintk(2, "VIDIOC_S_FMT\n"); 523 + if (f->type != V4L2_BUF_TYPE_SLICED_VBI_OUTPUT || 524 + FW_VERSION(av7110->arm_app) < 0x2623) 525 + return -EAGAIN; /* handled by core driver */ 526 + if (f->fmt.sliced.service_set != V4L2_SLICED_WSS_625 && 527 + f->fmt.sliced.service_lines[0][23] != V4L2_SLICED_WSS_625) { 528 + memset(&f->fmt.sliced, 0, sizeof f->fmt.sliced); 529 + /* WSS controlled by firmware */ 530 + av7110->wssMode = 0; 531 + av7110->wssData = 0; 532 + return av7110_fw_cmd(av7110, COMTYPE_ENCODER, 533 + SetWSSConfig, 1, 0); 534 + } else { 535 + memset(&f->fmt.sliced, 0, sizeof f->fmt.sliced); 536 + f->fmt.sliced.service_set = V4L2_SLICED_WSS_625; 537 + f->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625; 538 + f->fmt.sliced.io_size = sizeof (struct v4l2_sliced_vbi_data); 539 + /* WSS controlled by userspace */ 540 + av7110->wssMode = 1; 541 + av7110->wssData = 0; 542 + } 543 + break; 544 + } 493 545 default: 494 546 printk("no such ioctl\n"); 495 547 return -ENOIOCTLCMD; ··· 549 497 return 0; 550 498 } 551 499 500 + static int av7110_vbi_reset(struct inode *inode, struct file *file) 501 + { 502 + struct saa7146_fh *fh = file->private_data; 503 + struct saa7146_dev *dev = fh->dev; 504 + struct av7110 *av7110 = (struct av7110*) dev->ext_priv; 505 + 506 + dprintk(2, "%s\n", __FUNCTION__); 507 + av7110->wssMode = 0; 508 + av7110->wssData = 0; 509 + if (FW_VERSION(av7110->arm_app) < 0x2623) 510 + return 0; 511 + else 512 + return av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 1, 0); 513 + } 514 + 515 + static ssize_t av7110_vbi_write(struct file *file, const char __user *data, size_t count, loff_t *ppos) 516 + { 517 + struct saa7146_fh *fh = file->private_data; 518 + struct saa7146_dev *dev = fh->dev; 519 + struct av7110 *av7110 = (struct av7110*) dev->ext_priv; 520 + struct v4l2_sliced_vbi_data d; 521 + int rc; 522 + 523 + dprintk(2, "%s\n", __FUNCTION__); 524 + if (FW_VERSION(av7110->arm_app) < 0x2623 || !av7110->wssMode || count != sizeof d) 525 + return -EINVAL; 526 + if (copy_from_user(&d, data, count)) 527 + return -EFAULT; 528 + if ((d.id != 0 && d.id != V4L2_SLICED_WSS_625) || d.field != 0 || d.line != 23) 529 + return -EINVAL; 530 + if (d.id) { 531 + av7110->wssData = ((d.data[1] << 8) & 0x3f00) | d.data[0]; 532 + rc = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 533 + 2, 1, av7110->wssData); 534 + } else { 535 + av7110->wssData = 0; 536 + rc = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 1, 0); 537 + } 538 + return (rc < 0) ? rc : count; 539 + } 552 540 553 541 /**************************************************************************** 554 542 * INITIALIZATION ··· 604 512 { VIDIOC_S_TUNER, SAA7146_EXCLUSIVE }, 605 513 { VIDIOC_G_AUDIO, SAA7146_EXCLUSIVE }, 606 514 { VIDIOC_S_AUDIO, SAA7146_EXCLUSIVE }, 515 + { VIDIOC_G_SLICED_VBI_CAP, SAA7146_EXCLUSIVE }, 516 + { VIDIOC_G_FMT, SAA7146_BEFORE }, 517 + { VIDIOC_S_FMT, SAA7146_BEFORE }, 607 518 { 0, 0 } 608 519 }; 609 520 ··· 682 587 683 588 printk("dvb-ttpci: DVB-C analog module @ card %d detected, initializing MSP3400\n", 684 589 av7110->dvb_adapter.num); 685 - av7110->adac_type = DVB_ADAC_MSP; 590 + av7110->adac_type = DVB_ADAC_MSP34x0; 686 591 msleep(100); // the probing above resets the msp... 687 592 msp_readreg(av7110, MSP_RD_DSP, 0x001e, &version1); 688 593 msp_readreg(av7110, MSP_RD_DSP, 0x001f, &version2); ··· 787 692 saa7146_vv_release(dev); 788 693 return -ENODEV; 789 694 } 790 - if (av7110->analog_tuner_flags) { 791 - if (saa7146_register_device(&av7110->vbi_dev, dev, "av7110", VFL_TYPE_VBI)) { 792 - ERR(("cannot register vbi v4l2 device. skipping.\n")); 793 - } else { 695 + if (saa7146_register_device(&av7110->vbi_dev, dev, "av7110", VFL_TYPE_VBI)) { 696 + ERR(("cannot register vbi v4l2 device. skipping.\n")); 697 + } else { 698 + if (av7110->analog_tuner_flags) 794 699 av7110->analog_tuner_flags |= ANALOG_TUNER_VBI; 795 - } 796 700 } 797 701 return 0; 798 702 } ··· 872 778 static struct saa7146_ext_vv av7110_vv_data_st = { 873 779 .inputs = 1, 874 780 .audios = 1, 875 - .capabilities = 0, 781 + .capabilities = V4L2_CAP_SLICED_VBI_OUTPUT, 876 782 .flags = 0, 877 783 878 784 .stds = &standard[0], ··· 881 787 882 788 .ioctls = &ioctls[0], 883 789 .ioctl = av7110_ioctl, 790 + 791 + .vbi_fops.open = av7110_vbi_reset, 792 + .vbi_fops.release = av7110_vbi_reset, 793 + .vbi_fops.write = av7110_vbi_write, 884 794 }; 885 795 886 796 static struct saa7146_ext_vv av7110_vv_data_c = { 887 797 .inputs = 1, 888 798 .audios = 1, 889 - .capabilities = V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE, 799 + .capabilities = V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_OUTPUT, 890 800 .flags = SAA7146_USE_PORT_B_FOR_VBI, 891 801 892 802 .stds = &standard[0], ··· 899 801 900 802 .ioctls = &ioctls[0], 901 803 .ioctl = av7110_ioctl, 804 + 805 + .vbi_fops.open = av7110_vbi_reset, 806 + .vbi_fops.release = av7110_vbi_reset, 807 + .vbi_fops.write = av7110_vbi_write, 902 808 }; 903 809
+179 -5
drivers/media/dvb/ttpci/budget-av.c
··· 127 127 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI); 128 128 udelay(1); 129 129 130 - result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 0); 130 + result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 1); 131 131 132 132 if (result == -ETIMEDOUT) 133 133 budget_av->slot_status = 0; ··· 145 145 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI); 146 146 udelay(1); 147 147 148 - result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 0); 148 + result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 1); 149 149 150 150 if (result == -ETIMEDOUT) 151 151 budget_av->slot_status = 0; ··· 192 192 { 193 193 struct budget_av *budget_av = (struct budget_av *) ca->data; 194 194 struct saa7146_dev *saa = budget_av->budget.dev; 195 - int timeout = 500; // 5 seconds (4.4.6 Ready) 195 + int timeout = 50; // 5 seconds (4.4.6 Ready) 196 196 197 197 if (slot != 0) 198 198 return -EINVAL; ··· 256 256 { 257 257 struct budget_av *budget_av = (struct budget_av *) ca->data; 258 258 struct saa7146_dev *saa = budget_av->budget.dev; 259 + int cam_present = 0; 259 260 260 261 if (slot != 0) 261 262 return -EINVAL; 262 263 263 - if (!budget_av->slot_status) { 264 + if (!budget_av->slot_status) 265 + { 266 + // first of all test the card detect line 264 267 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); 265 268 udelay(1); 266 269 if (saa7146_read(saa, PSR) & MASK_06) 267 270 { 271 + cam_present = 1; 272 + } 273 + saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO); 274 + 275 + // that is unreliable however, so try and read from IO memory 276 + if (!cam_present) 277 + { 278 + saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO); 279 + if (ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1) != -ETIMEDOUT) 280 + { 281 + cam_present = 1; 282 + } 283 + } 284 + 285 + // did we find something? 286 + if (cam_present) { 268 287 printk(KERN_INFO "budget-av: cam inserted\n"); 269 288 budget_av->slot_status = 1; 270 289 } 271 - saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO); 272 290 } else if (!open) { 273 291 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO); 274 292 if (ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1) == -ETIMEDOUT) ··· 502 484 return 0; 503 485 } 504 486 487 + #define MIN2(a,b) ((a) < (b) ? (a) : (b)) 488 + #define MIN3(a,b,c) MIN2(MIN2(a,b),c) 489 + 490 + static int philips_su1278sh2_tua6100_pll_set(struct dvb_frontend *fe, 491 + struct i2c_adapter *i2c, 492 + struct dvb_frontend_parameters *params) 493 + { 494 + u8 reg0 [2] = { 0x00, 0x00 }; 495 + u8 reg1 [4] = { 0x01, 0x00, 0x00, 0x00 }; 496 + u8 reg2 [3] = { 0x02, 0x00, 0x00 }; 497 + int _fband; 498 + int first_ZF; 499 + int R, A, N, P, M; 500 + struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = NULL,.len = 0 }; 501 + int freq = params->frequency; 502 + 503 + first_ZF = (freq) / 1000; 504 + 505 + if (abs(MIN2(abs(first_ZF-1190),abs(first_ZF-1790))) < 506 + abs(MIN3(abs(first_ZF-1202),abs(first_ZF-1542),abs(first_ZF-1890)))) 507 + _fband = 2; 508 + else 509 + _fband = 3; 510 + 511 + if (_fband == 2) { 512 + if (((first_ZF >= 950) && (first_ZF < 1350)) || 513 + ((first_ZF >= 1430) && (first_ZF < 1950))) 514 + reg0[1] = 0x07; 515 + else if (((first_ZF >= 1350) && (first_ZF < 1430)) || 516 + ((first_ZF >= 1950) && (first_ZF < 2150))) 517 + reg0[1] = 0x0B; 518 + } 519 + 520 + if(_fband == 3) { 521 + if (((first_ZF >= 950) && (first_ZF < 1350)) || 522 + ((first_ZF >= 1455) && (first_ZF < 1950))) 523 + reg0[1] = 0x07; 524 + else if (((first_ZF >= 1350) && (first_ZF < 1420)) || 525 + ((first_ZF >= 1950) && (first_ZF < 2150))) 526 + reg0[1] = 0x0B; 527 + else if ((first_ZF >= 1420) && (first_ZF < 1455)) 528 + reg0[1] = 0x0F; 529 + } 530 + 531 + if (first_ZF > 1525) 532 + reg1[1] |= 0x80; 533 + else 534 + reg1[1] &= 0x7F; 535 + 536 + if (_fband == 2) { 537 + if (first_ZF > 1430) { /* 1430MHZ */ 538 + reg1[1] &= 0xCF; /* N2 */ 539 + reg2[1] &= 0xCF; /* R2 */ 540 + reg2[1] |= 0x10; 541 + } else { 542 + reg1[1] &= 0xCF; /* N2 */ 543 + reg1[1] |= 0x20; 544 + reg2[1] &= 0xCF; /* R2 */ 545 + reg2[1] |= 0x10; 546 + } 547 + } 548 + 549 + if (_fband == 3) { 550 + if ((first_ZF >= 1455) && 551 + (first_ZF < 1630)) { 552 + reg1[1] &= 0xCF; /* N2 */ 553 + reg1[1] |= 0x20; 554 + reg2[1] &= 0xCF; /* R2 */ 555 + } else { 556 + if (first_ZF < 1455) { 557 + reg1[1] &= 0xCF; /* N2 */ 558 + reg1[1] |= 0x20; 559 + reg2[1] &= 0xCF; /* R2 */ 560 + reg2[1] |= 0x10; 561 + } else { 562 + if (first_ZF >= 1630) { 563 + reg1[1] &= 0xCF; /* N2 */ 564 + reg2[1] &= 0xCF; /* R2 */ 565 + reg2[1] |= 0x10; 566 + } 567 + } 568 + } 569 + } 570 + 571 + /* set ports, enable P0 for symbol rates > 4Ms/s */ 572 + if (params->u.qpsk.symbol_rate >= 4000000) 573 + reg1[1] |= 0x0c; 574 + else 575 + reg1[1] |= 0x04; 576 + 577 + reg2[1] |= 0x0c; 578 + 579 + R = 64; 580 + A = 64; 581 + P = 64; //32 582 + 583 + M = (freq * R) / 4; /* in Mhz */ 584 + N = (M - A * 1000) / (P * 1000); 585 + 586 + reg1[1] |= (N >> 9) & 0x03; 587 + reg1[2] = (N >> 1) & 0xff; 588 + reg1[3] = (N << 7) & 0x80; 589 + 590 + reg2[1] |= (R >> 8) & 0x03; 591 + reg2[2] = R & 0xFF; /* R */ 592 + 593 + reg1[3] |= A & 0x7f; /* A */ 594 + 595 + if (P == 64) 596 + reg1[1] |= 0x40; /* Prescaler 64/65 */ 597 + 598 + reg0[1] |= 0x03; 599 + 600 + /* already enabled - do not reenable i2c repeater or TX fails */ 601 + msg.buf = reg0; 602 + msg.len = sizeof(reg0); 603 + if (i2c_transfer(i2c, &msg, 1) != 1) 604 + return -EIO; 605 + 606 + stv0299_enable_plli2c(fe); 607 + msg.buf = reg1; 608 + msg.len = sizeof(reg1); 609 + if (i2c_transfer(i2c, &msg, 1) != 1) 610 + return -EIO; 611 + 612 + stv0299_enable_plli2c(fe); 613 + msg.buf = reg2; 614 + msg.len = sizeof(reg2); 615 + if (i2c_transfer(i2c, &msg, 1) != 1) 616 + return -EIO; 617 + 618 + return 0; 619 + } 620 + 505 621 static u8 typhoon_cinergy1200s_inittab[] = { 506 622 0x01, 0x15, 507 623 0x02, 0x30, ··· 705 553 .pll_set = philips_su1278_ty_ci_pll_set, 706 554 }; 707 555 556 + static struct stv0299_config cinergy_1200s_1894_0010_config = { 557 + .demod_address = 0x68, 558 + .inittab = typhoon_cinergy1200s_inittab, 559 + .mclk = 88000000UL, 560 + .invert = 1, 561 + .skip_reinit = 0, 562 + .lock_output = STV0229_LOCKOUTPUT_1, 563 + .volt13_op0_op1 = STV0299_VOLT13_OP0, 564 + .min_delay_ms = 100, 565 + .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, 566 + .pll_set = philips_su1278sh2_tua6100_pll_set, 567 + }; 708 568 709 569 static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 710 570 { ··· 913 749 switch (saa->pci->subsystem_device) { 914 750 915 751 case SUBID_DVBS_KNC1: 752 + if (saa->pci->subsystem_vendor == 0x1894) { 753 + fe = stv0299_attach(&cinergy_1200s_1894_0010_config, 754 + &budget_av->budget.i2c_adap); 755 + } else { 756 + fe = stv0299_attach(&typhoon_config, 757 + &budget_av->budget.i2c_adap); 758 + } 759 + break; 760 + 916 761 case SUBID_DVBS_KNC1_PLUS: 917 762 case SUBID_DVBS_TYPHOON: 918 763 fe = stv0299_attach(&typhoon_config, ··· 1176 1003 static struct pci_device_id pci_tbl[] = { 1177 1004 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56), 1178 1005 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010), 1006 + MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010), 1179 1007 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011), 1180 1008 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020), 1181 1009 MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),
+1 -3
drivers/media/dvb/ttpci/budget-core.c
··· 404 404 tasklet_init(&budget->vpe_tasklet, vpeirq, (unsigned long) budget); 405 405 406 406 /* frontend power on */ 407 - if (bi->type == BUDGET_FS_ACTIVY) 408 - saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); 409 - else 407 + if (bi->type != BUDGET_FS_ACTIVY) 410 408 saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI); 411 409 412 410 if (budget_register(budget) == 0) {
+10 -3
drivers/media/dvb/ttpci/budget.c
··· 112 112 * Routines for the Fujitsu Siemens Activy budget card 113 113 * 22 kHz tone and DiSEqC are handled by the frontend. 114 114 * Voltage must be set here. 115 + * GPIO 1: LNBP EN, GPIO 2: LNBP VSEL 115 116 */ 116 117 static int SetVoltage_Activy (struct budget *budget, fe_sec_voltage_t voltage) 117 118 { ··· 122 121 123 122 switch (voltage) { 124 123 case SEC_VOLTAGE_13: 124 + saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); 125 125 saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTLO); 126 126 break; 127 127 case SEC_VOLTAGE_18: 128 + saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); 128 129 saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI); 130 + break; 131 + case SEC_VOLTAGE_OFF: 132 + saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTLO); 129 133 break; 130 134 default: 131 135 return -EINVAL; ··· 212 206 return 0; 213 207 } 214 208 215 - static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend* fe, int arg) 209 + static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend* fe, long arg) 216 210 { 217 211 struct budget* budget = (struct budget*) fe->dvb->priv; 218 212 u8 buf; ··· 586 580 if (budget->dvb_frontend) { 587 581 budget->dvb_frontend->ops->set_voltage = lnbp21_set_voltage; 588 582 budget->dvb_frontend->ops->enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage; 583 + budget->dvb_frontend->ops->dishnetwork_send_legacy_command = NULL; 589 584 if (lnbp21_init(budget)) { 590 585 printk("%s: No LNBP21 found!\n", __FUNCTION__); 591 586 goto error_out; ··· 631 624 budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); 632 625 if (budget->dvb_frontend) { 633 626 budget->dvb_frontend->ops->set_voltage = siemens_budget_set_voltage; 634 - break; 627 + budget->dvb_frontend->ops->dishnetwork_send_legacy_command = NULL; 635 628 } 636 629 break; 637 630 ··· 639 632 budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap); 640 633 if (budget->dvb_frontend) { 641 634 budget->dvb_frontend->ops->set_voltage = siemens_budget_set_voltage; 642 - break; 635 + budget->dvb_frontend->ops->dishnetwork_send_legacy_command = NULL; 643 636 } 644 637 break; 645 638
+1 -1
drivers/media/dvb/ttpci/ttpci-eeprom.c
··· 13 13 Holger Waechtler Convergence 14 14 15 15 Copyright (C) 2002-2003 Ralph Metzler <rjkm@metzlerbros.de> 16 - Metzler Brothers Systementwicklung GbR 16 + Metzler Brothers Systementwicklung GbR 17 17 18 18 This program is free software; you can redistribute it and/or modify 19 19 it under the terms of the GNU General Public License as published by
+1 -1
drivers/media/dvb/ttusb-budget/Kconfig
··· 10 10 Support for external USB adapters designed by Technotrend and 11 11 produced by Hauppauge, shipped under the brand name 'Nova-USB'. 12 12 13 - These devices don't have a MPEG decoder built in, so you need 13 + These devices don't have a MPEG decoder built in, so you need 14 14 an external software decoder to watch TV. 15 15 16 16 Say Y if you own such a device and want to use it.
+7 -6
drivers/media/dvb/ttusb-dec/Kconfig
··· 8 8 produced by Hauppauge, shipped under the brand name 'DEC2000-t' 9 9 and 'DEC3000-s'. 10 10 11 - Even if these devices have a MPEG decoder built in, they transmit 11 + Even if these devices have a MPEG decoder built in, they transmit 12 12 only compressed MPEG data over the USB bus, so you need 13 13 an external software decoder to watch TV on your computer. 14 14 15 - This driver needs external firmware. Please use the commands 16 - "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2000t", 17 - "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2540t", 18 - "<kerneldir>/Documentation/dvb/get_dvb_firmware dec3000s", 19 - download/extract them, and then copy them to /usr/lib/hotplug/firmware. 15 + This driver needs external firmware. Please use the commands 16 + "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2000t", 17 + "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2540t", 18 + "<kerneldir>/Documentation/dvb/get_dvb_firmware dec3000s", 19 + download/extract them, and then copy them to /usr/lib/hotplug/firmware 20 + or /lib/firmware (depending on configuration of firmware hotplug). 20 21 21 22 Say Y if you own such a device and want to use it.
+10 -10
drivers/media/dvb/ttusb-dec/ttusb_dec.c
··· 369 369 370 370 static int ttusb_dec_audio_pes2ts_cb(void *priv, unsigned char *data) 371 371 { 372 - struct ttusb_dec *dec = (struct ttusb_dec *)priv; 372 + struct ttusb_dec *dec = priv; 373 373 374 374 dec->audio_filter->feed->cb.ts(data, 188, NULL, 0, 375 375 &dec->audio_filter->feed->feed.ts, ··· 380 380 381 381 static int ttusb_dec_video_pes2ts_cb(void *priv, unsigned char *data) 382 382 { 383 - struct ttusb_dec *dec = (struct ttusb_dec *)priv; 383 + struct ttusb_dec *dec = priv; 384 384 385 385 dec->video_filter->feed->cb.ts(data, 188, NULL, 0, 386 386 &dec->video_filter->feed->feed.ts, ··· 965 965 966 966 case DMX_TS_PES_TELETEXT: 967 967 dec->pid[DMX_PES_TELETEXT] = dvbdmxfeed->pid; 968 - dprintk(" pes_type: DMX_TS_PES_TELETEXT\n"); 969 - break; 968 + dprintk(" pes_type: DMX_TS_PES_TELETEXT(not supported)\n"); 969 + return -ENOSYS; 970 970 971 971 case DMX_TS_PES_PCR: 972 972 dprintk(" pes_type: DMX_TS_PES_PCR\n"); ··· 975 975 break; 976 976 977 977 case DMX_TS_PES_OTHER: 978 - dprintk(" pes_type: DMX_TS_PES_OTHER\n"); 979 - break; 978 + dprintk(" pes_type: DMX_TS_PES_OTHER(not supported)\n"); 979 + return -ENOSYS; 980 980 981 981 default: 982 982 dprintk(" pes_type: unknown (%d)\n", dvbdmxfeed->pes_type); ··· 1182 1182 (unsigned long)dec); 1183 1183 } 1184 1184 1185 - static int ttusb_init_rc(struct ttusb_dec *dec) 1185 + static int ttusb_init_rc( struct ttusb_dec *dec) 1186 1186 { 1187 1187 struct input_dev *input_dev; 1188 1188 u8 b[] = { 0x00, 0x01 }; ··· 1203 1203 input_dev->keycode = rc_keys; 1204 1204 1205 1205 for (i = 0; i < ARRAY_SIZE(rc_keys); i++) 1206 - set_bit(rc_keys[i], input_dev->keybit); 1206 + set_bit(rc_keys[i], input_dev->keybit); 1207 1207 1208 1208 input_register_device(input_dev); 1209 1209 1210 1210 if (usb_submit_urb(dec->irq_urb, GFP_KERNEL)) 1211 1211 printk("%s: usb_submit_urb failed\n",__FUNCTION__); 1212 - 1213 1212 /* enable irq pipe */ 1214 1213 ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL); 1215 1214 ··· 1394 1395 /* We can't trust the USB IDs that some firmwares 1395 1396 give the box */ 1396 1397 switch (model) { 1398 + case 0x00070001: 1397 1399 case 0x00070008: 1398 1400 case 0x0007000c: 1399 1401 ttusb_dec_set_model(dec, TTUSB_DEC3000S); ··· 1588 1588 int param_length, const u8 params[], 1589 1589 int *result_length, u8 cmd_result[]) 1590 1590 { 1591 - struct ttusb_dec* dec = (struct ttusb_dec*) fe->dvb->priv; 1591 + struct ttusb_dec* dec = fe->dvb->priv; 1592 1592 return ttusb_dec_send_command(dec, command, param_length, params, result_length, cmd_result); 1593 1593 } 1594 1594
+48 -5
drivers/media/dvb/ttusb-dec/ttusbdecfe.c
··· 42 42 43 43 static int ttusbdecfe_read_status(struct dvb_frontend* fe, fe_status_t* status) 44 44 { 45 - *status = FE_HAS_SIGNAL | FE_HAS_VITERBI | 46 - FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK; 45 + struct ttusbdecfe_state* state = fe->demodulator_priv; 46 + u8 b[] = { 0x00, 0x00, 0x00, 0x00, 47 + 0x00, 0x00, 0x00, 0x00 }; 48 + u8 result[4]; 49 + int len, ret; 50 + 51 + *status=0; 52 + 53 + ret=state->config->send_command(fe, 0x73, sizeof(b), b, &len, result); 54 + if(ret) 55 + return ret; 56 + 57 + if(len != 4) { 58 + printk(KERN_ERR "%s: unexpected reply\n", __FUNCTION__); 59 + return -EIO; 60 + } 61 + 62 + switch(result[3]) { 63 + case 1: /* not tuned yet */ 64 + case 2: /* no signal/no lock*/ 65 + break; 66 + case 3: /* signal found and locked*/ 67 + *status = FE_HAS_SIGNAL | FE_HAS_VITERBI | 68 + FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK; 69 + break; 70 + case 4: 71 + *status = FE_TIMEDOUT; 72 + break; 73 + default: 74 + pr_info("%s: returned unknown value: %d\n", 75 + __FUNCTION__, result[3]); 76 + return -EIO; 77 + } 47 78 48 79 return 0; 49 80 } ··· 93 62 state->config->send_command(fe, 0x71, sizeof(b), b, NULL, NULL); 94 63 95 64 return 0; 65 + } 66 + 67 + static int ttusbdecfe_dvbt_get_tune_settings(struct dvb_frontend* fe, 68 + struct dvb_frontend_tune_settings* fesettings) 69 + { 70 + fesettings->min_delay_ms = 1500; 71 + /* Drift compensation makes no sense for DVB-T */ 72 + fesettings->step_size = 0; 73 + fesettings->max_drift = 0; 74 + return 0; 96 75 } 97 76 98 77 static int ttusbdecfe_dvbs_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) ··· 253 212 254 213 .set_frontend = ttusbdecfe_dvbt_set_frontend, 255 214 215 + .get_tune_settings = ttusbdecfe_dvbt_get_tune_settings, 216 + 256 217 .read_status = ttusbdecfe_read_status, 257 218 }; 258 219 ··· 266 223 .frequency_min = 950000, 267 224 .frequency_max = 2150000, 268 225 .frequency_stepsize = 125, 226 + .symbol_rate_min = 1000000, /* guessed */ 227 + .symbol_rate_max = 45000000, /* guessed */ 269 228 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 270 229 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | 271 - FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | 272 - FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | 273 - FE_CAN_HIERARCHY_AUTO, 230 + FE_CAN_QPSK 274 231 }, 275 232 276 233 .release = ttusbdecfe_release,
+1
drivers/media/radio/miropcm20-radio.c
··· 220 220 .open = video_exclusive_open, 221 221 .release = video_exclusive_release, 222 222 .ioctl = pcm20_ioctl, 223 + .compat_ioctl = v4l_compat_ioctl32, 223 224 .llseek = no_llseek, 224 225 }; 225 226
+1
drivers/media/radio/radio-aimslab.c
··· 299 299 .open = video_exclusive_open, 300 300 .release = video_exclusive_release, 301 301 .ioctl = rt_ioctl, 302 + .compat_ioctl = v4l_compat_ioctl32, 302 303 .llseek = no_llseek, 303 304 }; 304 305
+1
drivers/media/radio/radio-aztech.c
··· 256 256 .open = video_exclusive_open, 257 257 .release = video_exclusive_release, 258 258 .ioctl = az_ioctl, 259 + .compat_ioctl = v4l_compat_ioctl32, 259 260 .llseek = no_llseek, 260 261 }; 261 262
+1
drivers/media/radio/radio-cadet.c
··· 490 490 .release = cadet_release, 491 491 .read = cadet_read, 492 492 .ioctl = cadet_ioctl, 493 + .compat_ioctl = v4l_compat_ioctl32, 493 494 .llseek = no_llseek, 494 495 }; 495 496
+1
drivers/media/radio/radio-gemtek-pci.c
··· 301 301 .open = video_exclusive_open, 302 302 .release = video_exclusive_release, 303 303 .ioctl = gemtek_pci_ioctl, 304 + .compat_ioctl = v4l_compat_ioctl32, 304 305 .llseek = no_llseek, 305 306 }; 306 307
+1
drivers/media/radio/radio-gemtek.c
··· 233 233 .open = video_exclusive_open, 234 234 .release = video_exclusive_release, 235 235 .ioctl = gemtek_ioctl, 236 + .compat_ioctl = v4l_compat_ioctl32, 236 237 .llseek = no_llseek, 237 238 }; 238 239
+1
drivers/media/radio/radio-maestro.c
··· 72 72 .open = video_exclusive_open, 73 73 .release = video_exclusive_release, 74 74 .ioctl = radio_ioctl, 75 + .compat_ioctl = v4l_compat_ioctl32, 75 76 .llseek = no_llseek, 76 77 }; 77 78
+1
drivers/media/radio/radio-maxiradio.c
··· 80 80 .open = video_exclusive_open, 81 81 .release = video_exclusive_release, 82 82 .ioctl = radio_ioctl, 83 + .compat_ioctl = v4l_compat_ioctl32, 83 84 .llseek = no_llseek, 84 85 }; 85 86 static struct video_device maxiradio_radio =
+1
drivers/media/radio/radio-rtrack2.c
··· 199 199 .open = video_exclusive_open, 200 200 .release = video_exclusive_release, 201 201 .ioctl = rt_ioctl, 202 + .compat_ioctl = v4l_compat_ioctl32, 202 203 .llseek = no_llseek, 203 204 }; 204 205
+1
drivers/media/radio/radio-sf16fmi.c
··· 225 225 .open = video_exclusive_open, 226 226 .release = video_exclusive_release, 227 227 .ioctl = fmi_ioctl, 228 + .compat_ioctl = v4l_compat_ioctl32, 228 229 .llseek = no_llseek, 229 230 }; 230 231
+1
drivers/media/radio/radio-sf16fmr2.c
··· 356 356 .open = video_exclusive_open, 357 357 .release = video_exclusive_release, 358 358 .ioctl = fmr2_ioctl, 359 + .compat_ioctl = v4l_compat_ioctl32, 359 360 .llseek = no_llseek, 360 361 }; 361 362
+1
drivers/media/radio/radio-terratec.c
··· 276 276 .open = video_exclusive_open, 277 277 .release = video_exclusive_release, 278 278 .ioctl = tt_ioctl, 279 + .compat_ioctl = v4l_compat_ioctl32, 279 280 .llseek = no_llseek, 280 281 }; 281 282
+1
drivers/media/radio/radio-trust.c
··· 255 255 .open = video_exclusive_open, 256 256 .release = video_exclusive_release, 257 257 .ioctl = tr_ioctl, 258 + .compat_ioctl = v4l_compat_ioctl32, 258 259 .llseek = no_llseek, 259 260 }; 260 261
+1
drivers/media/radio/radio-typhoon.c
··· 261 261 .open = video_exclusive_open, 262 262 .release = video_exclusive_release, 263 263 .ioctl = typhoon_ioctl, 264 + .compat_ioctl = v4l_compat_ioctl32, 264 265 .llseek = no_llseek, 265 266 }; 266 267
+1
drivers/media/radio/radio-zoltrix.c
··· 313 313 .open = video_exclusive_open, 314 314 .release = video_exclusive_release, 315 315 .ioctl = zol_ioctl, 316 + .compat_ioctl = v4l_compat_ioctl32, 316 317 .llseek = no_llseek, 317 318 }; 318 319
+10 -1
drivers/media/video/Kconfig
··· 7 7 8 8 comment "Video Adapters" 9 9 10 + config VIDEO_ADV_DEBUG 11 + bool "Enable advanced debug functionality" 12 + depends on VIDEO_DEV 13 + default n 14 + ---help--- 15 + Say Y here to enable advanced debugging functionality on some 16 + V4L devices. 17 + In doubt, say N. 18 + 10 19 config VIDEO_BT848 11 20 tristate "BT848 Video For Linux" 12 21 depends on VIDEO_DEV && PCI && I2C ··· 351 342 depends on VIDEO_DEV && I2C && EXPERIMENTAL 352 343 ---help--- 353 344 Say Y here to compile drivers for SAA7115, SAA7127 and CX25840 354 - video decoders. 345 + video decoders. 355 346 356 347 endmenu
+7 -3
drivers/media/video/Makefile
··· 3 3 # 4 4 5 5 bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \ 6 - bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o 6 + bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o \ 7 + bttv-input.o 7 8 zoran-objs := zr36120.o zr36120_i2c.o zr36120_mem.o 8 9 zr36067-objs := zoran_procfs.o zoran_device.o \ 9 10 zoran_driver.o zoran_card.o 10 11 tuner-objs := tuner-core.o tuner-simple.o mt20xx.o tda8290.o tea5767.o 11 - obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o 12 + 13 + msp3400-objs := msp3400-driver.o msp3400-kthreads.o 14 + 15 + obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o compat_ioctl32.o 12 16 13 17 obj-$(CONFIG_VIDEO_BT848) += bttv.o msp3400.o tvaudio.o \ 14 - tda7432.o tda9875.o ir-kbd-i2c.o ir-kbd-gpio.o 18 + tda7432.o tda9875.o ir-kbd-i2c.o 15 19 obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o 16 20 17 21 obj-$(CONFIG_VIDEO_ZR36120) += zoran.o
+1
drivers/media/video/arv.c
··· 749 749 .release = video_exclusive_release, 750 750 .read = ar_read, 751 751 .ioctl = ar_ioctl, 752 + .compat_ioctl = v4l_compat_ioctl32, 752 753 .llseek = no_llseek, 753 754 }; 754 755
+35 -35
drivers/media/video/bt832.c
··· 30 30 #include <linux/init.h> 31 31 #include <linux/errno.h> 32 32 #include <linux/slab.h> 33 - 34 33 #include <media/audiochip.h> 34 + #include <media/v4l2-common.h> 35 + 35 36 #include "bttv.h" 36 37 #include "bt832.h" 37 38 ··· 43 42 I2C_CLIENT_END }; 44 43 I2C_CLIENT_INSMOD; 45 44 46 - /* ---------------------------------------------------------------------- */ 45 + int debug = 0; /* debug output */ 46 + module_param(debug, int, 0644); 47 47 48 - #define dprintk if (debug) printk 48 + /* ---------------------------------------------------------------------- */ 49 49 50 50 static int bt832_detach(struct i2c_client *client); 51 51 ··· 63 61 int i,rc; 64 62 buf[0]=0x80; // start at register 0 with auto-increment 65 63 if (1 != (rc = i2c_master_send(i2c_client_s,buf,1))) 66 - printk("bt832: i2c i/o error: rc == %d (should be 1)\n",rc); 64 + v4l_err(i2c_client_s,"i2c i/o error: rc == %d (should be 1)\n",rc); 67 65 68 66 for(i=0;i<65;i++) 69 67 buf[i]=0; 70 68 if (65 != (rc=i2c_master_recv(i2c_client_s,buf,65))) 71 - printk("bt832: i2c i/o error: rc == %d (should be 65)\n",rc); 69 + v4l_err(i2c_client_s,"i2c i/o error: rc == %d (should be 65)\n",rc); 72 70 73 71 // Note: On READ the first byte is the current index 74 72 // (e.g. 0x80, what we just wrote) 75 73 76 - if(1) { 74 + if(debug>1) { 77 75 int i; 78 - printk("BT832 hexdump:\n"); 76 + v4l_dbg(2,i2c_client_s,"hexdump:"); 79 77 for(i=1;i<65;i++) { 80 78 if(i!=1) { 81 - if(((i-1)%8)==0) printk(" "); 82 - if(((i-1)%16)==0) printk("\n"); 79 + if(((i-1)%8)==0) printk(" "); 80 + if(((i-1)%16)==0) { 81 + printk("\n"); 82 + v4l_dbg(2,i2c_client_s,"hexdump:"); 83 + } 83 84 } 84 85 printk(" %02x",buf[i]); 85 86 } ··· 101 96 bt832_hexdump(i2c_client_s,buf); 102 97 103 98 if(buf[0x40] != 0x31) { 104 - printk("bt832: this i2c chip is no bt832 (id=%02x). Detaching.\n",buf[0x40]); 99 + v4l_err(i2c_client_s,"This i2c chip is no bt832 (id=%02x). Detaching.\n",buf[0x40]); 105 100 kfree(buf); 106 101 return 0; 107 102 } 108 103 109 - printk("Write 0 tp VPSTATUS\n"); 104 + v4l_err(i2c_client_s,"Write 0 tp VPSTATUS\n"); 110 105 buf[0]=BT832_VP_STATUS; // Reg.52 111 106 buf[1]= 0x00; 112 107 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 113 - printk("bt832: i2c i/o error VPS: rc == %d (should be 2)\n",rc); 108 + v4l_err(i2c_client_s,"i2c i/o error VPS: rc == %d (should be 2)\n",rc); 114 109 115 110 bt832_hexdump(i2c_client_s,buf); 116 111 117 112 118 113 // Leave low power mode: 119 - printk("Bt832: leave low power mode.\n"); 114 + v4l_err(i2c_client_s,"leave low power mode.\n"); 120 115 buf[0]=BT832_CAM_SETUP0; //0x39 57 121 116 buf[1]=0x08; 122 117 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 123 - printk("bt832: i2c i/o error LLPM: rc == %d (should be 2)\n",rc); 118 + v4l_err(i2c_client_s,"i2c i/o error LLPM: rc == %d (should be 2)\n",rc); 124 119 125 120 bt832_hexdump(i2c_client_s,buf); 126 121 127 - printk("Write 0 tp VPSTATUS\n"); 122 + v4l_info(i2c_client_s,"Write 0 tp VPSTATUS\n"); 128 123 buf[0]=BT832_VP_STATUS; // Reg.52 129 124 buf[1]= 0x00; 130 125 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 131 - printk("bt832: i2c i/o error VPS: rc == %d (should be 2)\n",rc); 126 + v4l_err(i2c_client_s,"i2c i/o error VPS: rc == %d (should be 2)\n",rc); 132 127 133 128 bt832_hexdump(i2c_client_s,buf); 134 129 135 130 136 131 // Enable Output 137 - printk("Enable Output\n"); 132 + v4l_info(i2c_client_s,"Enable Output\n"); 138 133 buf[0]=BT832_VP_CONTROL1; // Reg.40 139 134 buf[1]= 0x27 & (~0x01); // Default | !skip 140 135 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 141 - printk("bt832: i2c i/o error EO: rc == %d (should be 2)\n",rc); 136 + v4l_err(i2c_client_s,"i2c i/o error EO: rc == %d (should be 2)\n",rc); 142 137 143 138 bt832_hexdump(i2c_client_s,buf); 144 139 145 140 146 141 // for testing (even works when no camera attached) 147 - printk("bt832: *** Generate NTSC M Bars *****\n"); 142 + v4l_info(i2c_client_s,"*** Generate NTSC M Bars *****\n"); 148 143 buf[0]=BT832_VP_TESTCONTROL0; // Reg. 42 149 144 buf[1]=3; // Generate NTSC System M bars, Generate Frame timing internally 150 145 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 151 - printk("bt832: i2c i/o error MBAR: rc == %d (should be 2)\n",rc); 146 + v4l_info(i2c_client_s,"i2c i/o error MBAR: rc == %d (should be 2)\n",rc); 152 147 153 - printk("Bt832: Camera Present: %s\n", 148 + v4l_info(i2c_client_s,"Camera Present: %s\n", 154 149 (buf[1+BT832_CAM_STATUS] & BT832_56_CAMERA_PRESENT) ? "yes":"no"); 155 150 156 151 bt832_hexdump(i2c_client_s,buf); ··· 164 159 { 165 160 struct bt832 *t; 166 161 167 - printk("bt832_attach\n"); 168 - 169 162 client_template.adapter = adap; 170 163 client_template.addr = addr; 171 - 172 - printk("bt832: chip found @ 0x%x\n", addr<<1); 173 164 174 165 if (NULL == (t = kmalloc(sizeof(*t), GFP_KERNEL))) 175 166 return -ENOMEM; ··· 173 172 t->client = client_template; 174 173 i2c_set_clientdata(&t->client, t); 175 174 i2c_attach_client(&t->client); 175 + 176 + v4l_info(&t->client,"chip found @ 0x%x\n", addr<<1); 177 + 176 178 177 179 if(! bt832_init(&t->client)) { 178 180 bt832_detach(&t->client); ··· 187 183 188 184 static int bt832_probe(struct i2c_adapter *adap) 189 185 { 190 - #ifdef I2C_CLASS_TV_ANALOG 191 186 if (adap->class & I2C_CLASS_TV_ANALOG) 192 187 return i2c_probe(adap, &addr_data, bt832_attach); 193 - #else 194 - if (adap->id == I2C_HW_B_BT848) 195 - return i2c_probe(adap, &addr_data, bt832_attach); 196 - #endif 197 188 return 0; 198 189 } 199 190 ··· 196 197 { 197 198 struct bt832 *t = i2c_get_clientdata(client); 198 199 199 - printk("bt832: detach.\n"); 200 + v4l_info(&t->client,"dettach\n"); 200 201 i2c_detach_client(client); 201 202 kfree(t); 202 203 return 0; ··· 207 208 { 208 209 struct bt832 *t = i2c_get_clientdata(client); 209 210 210 - printk("bt832: command %x\n",cmd); 211 + if (debug>1) 212 + v4l_i2c_print_ioctl(&t->client,cmd); 211 213 212 214 switch (cmd) { 213 215 case BT832_HEXDUMP: { ··· 219 219 } 220 220 break; 221 221 case BT832_REATTACH: 222 - printk("bt832: re-attach\n"); 222 + v4l_info(&t->client,"re-attach\n"); 223 223 i2c_del_driver(&driver); 224 224 i2c_add_driver(&driver); 225 225 break; ··· 231 231 232 232 static struct i2c_driver driver = { 233 233 .driver = { 234 - .name = "i2c bt832 driver", 234 + .name = "bt832", 235 235 }, 236 - .id = -1, /* FIXME */ 236 + .id = 0, /* FIXME */ 237 237 .attach_adapter = bt832_probe, 238 238 .detach_client = bt832_detach, 239 239 .command = bt832_command,
+47 -9
drivers/media/video/bttv-cards.c
··· 38 38 #include <asm/io.h> 39 39 40 40 #include "bttvp.h" 41 + #include <media/v4l2-common.h> 41 42 42 43 /* fwd decl */ 43 44 static void boot_msp34xx(struct bttv *btv, int pin); ··· 292 291 293 292 /* likely broken, vendor id doesn't match the other magic views ... 294 293 * { 0xa0fca04f, BTTV_BOARD_MAGICTVIEW063, "Guillemot Maxi TV Video 3" }, */ 294 + 295 + /* Duplicate PCI ID, reconfigure for this board during the eeprom read. 296 + * { 0x13eb0070, BTTV_BOARD_HAUPPAUGE_IMPACTVCB, "Hauppauge ImpactVCB" }, */ 295 297 296 298 /* DVB cards (using pci function .1 for mpeg data xfer) */ 297 299 { 0x01010071, BTTV_BOARD_NEBULA_DIGITV, "Nebula Electronics DigiTV" }, ··· 2140 2136 .has_remote = 1, 2141 2137 .gpiomask = 0x1b, 2142 2138 .no_gpioirq = 1, 2143 - .any_irq = 1, 2144 2139 }, 2145 2140 [BTTV_BOARD_PV143] = { 2146 2141 /* Jorge Boncompte - DTI2 <jorge@dti2.net> */ ··· 2820 2817 .tuner_addr = ADDR_UNSET, 2821 2818 .has_radio = 1, 2822 2819 }, 2820 + /* ---- card 0x8f ---------------------------------- */ 2821 + [BTTV_BOARD_HAUPPAUGE_IMPACTVCB] = { 2822 + .name = "Hauppauge ImpactVCB (bt878)", 2823 + .video_inputs = 4, 2824 + .audio_inputs = 0, 2825 + .tuner = -1, 2826 + .svhs = -1, 2827 + .gpiomask = 0x0f, /* old: 7 */ 2828 + .muxsel = { 0, 1, 3, 2}, /* Composite 0-3 */ 2829 + .no_msp34xx = 1, 2830 + .no_tda9875 = 1, 2831 + .no_tda7432 = 1, 2832 + .tuner_type = -1, 2833 + .tuner_addr = ADDR_UNSET, 2834 + .radio_addr = ADDR_UNSET, 2835 + }, 2823 2836 }; 2824 2837 2825 2838 static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards); ··· 3056 3037 switch (id) { 3057 3038 case 1: 3058 3039 info = "PAL / mono"; 3040 + btv->tda9887_conf = TDA9887_INTERCARRIER; 3059 3041 break; 3060 3042 case 2: 3061 3043 info = "PAL+SECAM / stereo"; 3062 3044 btv->has_radio = 1; 3045 + btv->tda9887_conf = TDA9887_QSS; 3063 3046 break; 3064 3047 case 3: 3065 3048 info = "NTSC / stereo"; 3066 3049 btv->has_radio = 1; 3050 + btv->tda9887_conf = TDA9887_QSS; 3067 3051 break; 3068 3052 case 4: 3069 3053 info = "PAL+SECAM / mono"; 3054 + btv->tda9887_conf = TDA9887_QSS; 3070 3055 break; 3071 3056 case 5: 3072 3057 info = "NTSC / mono"; 3058 + btv->tda9887_conf = TDA9887_INTERCARRIER; 3073 3059 break; 3074 3060 case 6: 3075 3061 info = "NTSC / stereo"; 3062 + btv->tda9887_conf = TDA9887_INTERCARRIER; 3076 3063 break; 3077 3064 case 7: 3078 3065 info = "PAL / stereo"; 3066 + btv->tda9887_conf = TDA9887_INTERCARRIER; 3079 3067 break; 3080 3068 default: 3081 3069 info = "oops: unknown card"; ··· 3093 3067 printk(KERN_INFO 3094 3068 "bttv%d: pinnacle/mt: id=%d info=\"%s\" radio=%s\n", 3095 3069 btv->c.nr, id, info, btv->has_radio ? "yes" : "no"); 3096 - btv->tuner_type = 33; 3097 - btv->pinnacle_id = id; 3070 + btv->tuner_type = TUNER_MT2032; 3098 3071 } 3099 3072 } 3100 3073 ··· 3395 3370 bttv_call_i2c_clients(btv, TUNER_SET_TYPE_ADDR, &tun_setup); 3396 3371 } 3397 3372 3398 - if (btv->pinnacle_id != UNSET) { 3399 - bttv_call_i2c_clients(btv, AUDC_CONFIG_PINNACLE, 3400 - &btv->pinnacle_id); 3373 + if (btv->tda9887_conf) { 3374 + bttv_call_i2c_clients(btv, TDA9887_SET_CONFIG, 3375 + &btv->tda9887_conf); 3401 3376 } 3402 3377 3403 3378 btv->svhs = bttv_tvcards[btv->c.type].svhs; ··· 3412 3387 btv->has_remote=1; 3413 3388 if (!bttv_tvcards[btv->c.type].no_gpioirq) 3414 3389 btv->gpioirq=1; 3415 - if (bttv_tvcards[btv->c.type].any_irq) 3416 - btv->any_irq = 1; 3417 3390 if (bttv_tvcards[btv->c.type].audio_hook) 3418 3391 btv->audio_hook=bttv_tvcards[btv->c.type].audio_hook; 3419 3392 ··· 3447 3424 3448 3425 /* tuner modules */ 3449 3426 tda9887 = 0; 3450 - if (btv->pinnacle_id != UNSET) 3427 + if (btv->tda9887_conf) 3451 3428 tda9887 = 1; 3452 3429 if (0 == tda9887 && 0 == bttv_tvcards[btv->c.type].has_dvb && 3453 3430 bttv_I2CRead(btv, I2C_TDA9887, "TDA9887") >=0) ··· 3494 3471 tveeprom_hauppauge_analog(&btv->i2c_client, &tv, eeprom_data); 3495 3472 btv->tuner_type = tv.tuner_type; 3496 3473 btv->has_radio = tv.has_radio; 3474 + 3475 + printk("bttv%d: Hauppauge eeprom indicates model#%d\n", 3476 + btv->c.nr, tv.model); 3477 + 3478 + /* 3479 + * Some of the 878 boards have duplicate PCI IDs. Switch the board 3480 + * type based on model #. 3481 + */ 3482 + if(tv.model == 64900) { 3483 + printk("bttv%d: Switching board type from %s to %s\n", 3484 + btv->c.nr, 3485 + bttv_tvcards[btv->c.type].name, 3486 + bttv_tvcards[BTTV_BOARD_HAUPPAUGE_IMPACTVCB].name); 3487 + btv->c.type = BTTV_BOARD_HAUPPAUGE_IMPACTVCB; 3488 + } 3497 3489 } 3498 3490 3499 3491 static int terratec_active_radio_upgrade(struct bttv *btv)
+30 -38
drivers/media/video/bttv-driver.c
··· 34 34 #include <linux/sched.h> 35 35 #include <linux/interrupt.h> 36 36 #include <linux/kdev_t.h> 37 + #include "bttvp.h" 38 + #include <media/v4l2-common.h> 39 + 37 40 #include <linux/dma-mapping.h> 38 41 39 42 #include <asm/io.h> 40 43 #include <asm/byteorder.h> 41 - 42 - #include "bttvp.h" 43 44 44 45 #include "rds.h" 45 46 ··· 211 210 .vdelay = 0x20, 212 211 .vbipack = 255, 213 212 .sram = 0, 213 + /* ITU-R frame line number of the first VBI line 214 + we can capture, of the first and second field. */ 215 + .vbistart = { 7,320 }, 214 216 },{ 215 217 .v4l2_id = V4L2_STD_NTSC_M, 216 218 .name = "NTSC", ··· 230 226 .vdelay = 0x1a, 231 227 .vbipack = 144, 232 228 .sram = 1, 229 + .vbistart = { 10, 273 }, 233 230 },{ 234 231 .v4l2_id = V4L2_STD_SECAM, 235 232 .name = "SECAM", ··· 247 242 .vdelay = 0x20, 248 243 .vbipack = 255, 249 244 .sram = 0, /* like PAL, correct? */ 245 + .vbistart = { 7, 320 }, 250 246 },{ 251 247 .v4l2_id = V4L2_STD_PAL_Nc, 252 248 .name = "PAL-Nc", ··· 264 258 .vdelay = 0x1a, 265 259 .vbipack = 144, 266 260 .sram = -1, 261 + .vbistart = { 7, 320 }, 267 262 },{ 268 263 .v4l2_id = V4L2_STD_PAL_M, 269 264 .name = "PAL-M", ··· 281 274 .vdelay = 0x1a, 282 275 .vbipack = 144, 283 276 .sram = -1, 277 + .vbistart = { 10, 273 }, 284 278 },{ 285 279 .v4l2_id = V4L2_STD_PAL_N, 286 280 .name = "PAL-N", ··· 298 290 .vdelay = 0x20, 299 291 .vbipack = 144, 300 292 .sram = -1, 293 + .vbistart = { 7, 320}, 301 294 },{ 302 295 .v4l2_id = V4L2_STD_NTSC_M_JP, 303 296 .name = "NTSC-JP", ··· 315 306 .vdelay = 0x16, 316 307 .vbipack = 144, 317 308 .sram = -1, 309 + .vbistart = {10, 273}, 318 310 },{ 319 311 /* that one hopefully works with the strange timing 320 312 * which video recorders produce when playing a NTSC ··· 336 326 .vbipack = 255, 337 327 .vtotal = 524, 338 328 .sram = -1, 329 + .vbistart = { 10, 273 }, 339 330 } 340 331 }; 341 332 static const unsigned int BTTV_TVNORMS = ARRAY_SIZE(bttv_tvnorms); ··· 1521 1510 .buf_release = buffer_release, 1522 1511 }; 1523 1512 1524 - static const char *v4l1_ioctls[] = { 1525 - "?", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER", "GPICT", "SPICT", 1526 - "CCAPTURE", "GWIN", "SWIN", "GFBUF", "SFBUF", "KEY", "GFREQ", 1527 - "SFREQ", "GAUDIO", "SAUDIO", "SYNC", "MCAPTURE", "GMBUF", "GUNIT", 1528 - "GCAPTURE", "SCAPTURE", "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", 1529 - "SMICROCODE", "GVBIFMT", "SVBIFMT" }; 1530 - #define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls) 1531 - 1532 1513 static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) 1533 1514 { 1534 1515 switch (cmd) { ··· 2209 2206 unsigned long flags; 2210 2207 int retval = 0; 2211 2208 2212 - if (bttv_debug > 1) { 2213 - switch (_IOC_TYPE(cmd)) { 2214 - case 'v': 2215 - printk("bttv%d: ioctl 0x%x (v4l1, VIDIOC%s)\n", 2216 - btv->c.nr, cmd, (_IOC_NR(cmd) < V4L1_IOCTLS) ? 2217 - v4l1_ioctls[_IOC_NR(cmd)] : "???"); 2218 - break; 2219 - case 'V': 2220 - printk("bttv%d: ioctl 0x%x (v4l2, %s)\n", 2221 - btv->c.nr, cmd, v4l2_ioctl_names[_IOC_NR(cmd)]); 2222 - break; 2223 - default: 2224 - printk("bttv%d: ioctl 0x%x (???)\n", 2225 - btv->c.nr, cmd); 2226 - } 2227 - } 2209 + if (bttv_debug > 1) 2210 + v4l_print_ioctl(btv->c.name, cmd); 2211 + 2228 2212 if (btv->errors) 2229 2213 bttv_reinit_bt848(btv); 2230 2214 ··· 2560 2570 fmt->count[0] = fmt2.fmt.vbi.count[0]; 2561 2571 fmt->start[1] = fmt2.fmt.vbi.start[1]; 2562 2572 fmt->count[1] = fmt2.fmt.vbi.count[1]; 2563 - if (fmt2.fmt.vbi.flags & VBI_UNSYNC) 2564 - fmt->flags |= V4L2_VBI_UNSYNC; 2565 - if (fmt2.fmt.vbi.flags & VBI_INTERLACED) 2566 - fmt->flags |= V4L2_VBI_INTERLACED; 2573 + if (fmt2.fmt.vbi.flags & V4L2_VBI_UNSYNC) 2574 + fmt->flags |= VBI_UNSYNC; 2575 + if (fmt2.fmt.vbi.flags & V4L2_VBI_INTERLACED) 2576 + fmt->flags |= VBI_INTERLACED; 2567 2577 return 0; 2568 2578 } 2569 2579 case VIDIOCSVBIFMT: ··· 3110 3120 .open = bttv_open, 3111 3121 .release = bttv_release, 3112 3122 .ioctl = bttv_ioctl, 3123 + .compat_ioctl = v4l_compat_ioctl32, 3113 3124 .llseek = no_llseek, 3114 3125 .read = bttv_read, 3115 3126 .mmap = bttv_mmap, ··· 3220 3229 case VIDIOCSFREQ: 3221 3230 case VIDIOCGAUDIO: 3222 3231 case VIDIOCSAUDIO: 3232 + case VIDIOC_LOG_STATUS: 3223 3233 return bttv_common_ioctls(btv,cmd,arg); 3224 3234 3225 3235 default: ··· 3693 3701 3694 3702 btv=(struct bttv *)dev_id; 3695 3703 3696 - if (btv->any_irq) 3697 - handled = bttv_any_irq(&btv->c); 3704 + if (btv->custom_irq) 3705 + handled = btv->custom_irq(btv); 3698 3706 3699 3707 count=0; 3700 3708 while (1) { ··· 3730 3738 if (astat&BT848_INT_VSYNC) 3731 3739 btv->field_count++; 3732 3740 3733 - if (astat & BT848_INT_GPINT) { 3741 + if ((astat & BT848_INT_GPINT) && btv->remote) { 3734 3742 wake_up(&btv->gpioq); 3735 - bttv_gpio_irq(&btv->c); 3743 + bttv_input_irq(btv); 3736 3744 } 3737 3745 3738 3746 if (astat & BT848_INT_I2CDONE) { ··· 3938 3946 3939 3947 btv->i2c_rc = -1; 3940 3948 btv->tuner_type = UNSET; 3941 - btv->pinnacle_id = UNSET; 3942 3949 btv->new_input = UNSET; 3943 3950 btv->has_radio=radio[btv->c.nr]; 3944 3951 ··· 4056 4065 } 4057 4066 4058 4067 /* add subdevices */ 4059 - if (btv->has_remote) 4060 - bttv_sub_add_device(&btv->c, "remote"); 4061 4068 if (bttv_tvcards[btv->c.type].has_dvb) 4062 4069 bttv_sub_add_device(&btv->c, "dvb"); 4070 + 4071 + bttv_input_init(btv); 4063 4072 4064 4073 /* everything is fine */ 4065 4074 bttv_num++; ··· 4095 4104 /* tell gpio modules we are leaving ... */ 4096 4105 btv->shutdown=1; 4097 4106 wake_up(&btv->gpioq); 4107 + bttv_input_fini(btv); 4098 4108 bttv_sub_del_devices(&btv->c); 4099 4109 4100 4110 /* unregister i2c_bus + input */ ··· 4245 4253 bttv_check_chipset(); 4246 4254 4247 4255 bus_register(&bttv_sub_bus_type); 4248 - return pci_module_init(&bttv_pci_driver); 4256 + return pci_register_driver(&bttv_pci_driver); 4249 4257 } 4250 4258 4251 4259 static void bttv_cleanup_module(void)
-18
drivers/media/video/bttv-gpio.c
··· 113 113 } 114 114 } 115 115 116 - int bttv_any_irq(struct bttv_core *core) 117 - { 118 - struct bttv_sub_driver *drv; 119 - struct bttv_sub_device *dev; 120 - struct list_head *item; 121 - int handled = 0; 122 - 123 - list_for_each(item,&core->subs) { 124 - dev = list_entry(item,struct bttv_sub_device,list); 125 - drv = to_bttv_sub_drv(dev->dev.driver); 126 - if (drv && drv->any_irq) { 127 - if (drv->any_irq(dev)) 128 - handled = 1; 129 - } 130 - } 131 - return handled; 132 - } 133 - 134 116 /* ----------------------------------------------------------------------- */ 135 117 /* external: sub-driver register/unregister */ 136 118
+5 -10
drivers/media/video/bttv-i2c.c
··· 28 28 #include <linux/moduleparam.h> 29 29 #include <linux/init.h> 30 30 #include <linux/delay.h> 31 - #include <linux/jiffies.h> 32 - #include <asm/io.h> 33 31 34 32 #include "bttvp.h" 33 + #include <media/v4l2-common.h> 34 + #include <linux/jiffies.h> 35 + #include <asm/io.h> 35 36 36 37 static struct i2c_algo_bit_data bttv_i2c_algo_bit_template; 37 38 static struct i2c_adapter bttv_i2c_adap_sw_template; ··· 106 105 107 106 static struct i2c_adapter bttv_i2c_adap_sw_template = { 108 107 .owner = THIS_MODULE, 109 - #ifdef I2C_CLASS_TV_ANALOG 110 108 .class = I2C_CLASS_TV_ANALOG, 111 - #endif 112 - .name = "bt848", 109 + .name = "bttv", 113 110 .id = I2C_HW_B_BT848, 114 111 .client_register = attach_inform, 115 112 }; ··· 274 275 }; 275 276 276 277 static struct i2c_adapter bttv_i2c_adap_hw_template = { 277 - .owner = THIS_MODULE, 278 - #ifdef I2C_CLASS_TV_ANALOG 278 + .owner = THIS_MODULE, 279 279 .class = I2C_CLASS_TV_ANALOG, 280 - #endif 281 280 .name = "bt878", 282 281 .id = I2C_HW_B_BT848 /* FIXME */, 283 282 .algo = &bttv_algo, ··· 438 441 i2c_set_adapdata(&btv->c.i2c_adap, btv); 439 442 btv->i2c_client.adapter = &btv->c.i2c_adap; 440 443 441 - #ifdef I2C_CLASS_TV_ANALOG 442 444 if (bttv_tvcards[btv->c.type].no_video) 443 445 btv->c.i2c_adap.class &= ~I2C_CLASS_TV_ANALOG; 444 446 if (bttv_tvcards[btv->c.type].has_dvb) 445 447 btv->c.i2c_adap.class |= I2C_CLASS_TV_DIGITAL; 446 - #endif 447 448 448 449 if (btv->use_i2c_hw) { 449 450 btv->i2c_rc = i2c_add_adapter(&btv->c.i2c_adap);
+22 -35
drivers/media/video/bttv-vbi.c
··· 31 31 #include <asm/io.h> 32 32 #include "bttvp.h" 33 33 34 + /* Offset from line sync pulse leading edge (0H) in 1 / sampling_rate: 35 + bt8x8 /HRESET pulse starts at 0H and has length 64 / fCLKx1 (E|O_VTC 36 + HSFMT = 0). VBI_HDELAY (always 0) is an offset from the trailing edge 37 + of /HRESET in 1 / fCLKx1, and the sampling_rate tvnorm->Fsc is fCLKx2. */ 38 + #define VBI_OFFSET ((64 + 0) * 2) 39 + 34 40 #define VBI_DEFLINES 16 35 41 #define VBI_MAXLINES 32 36 42 ··· 169 163 void bttv_vbi_try_fmt(struct bttv_fh *fh, struct v4l2_format *f) 170 164 { 171 165 const struct bttv_tvnorm *tvnorm; 172 - u32 start0,start1; 173 - s32 count0,count1,count; 166 + s64 count0,count1,count; 174 167 175 168 tvnorm = &bttv_tvnorms[fh->btv->tvnorm]; 176 169 f->type = V4L2_BUF_TYPE_VBI_CAPTURE; 177 170 f->fmt.vbi.sampling_rate = tvnorm->Fsc; 178 171 f->fmt.vbi.samples_per_line = 2048; 179 172 f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; 180 - f->fmt.vbi.offset = 244; 173 + f->fmt.vbi.offset = VBI_OFFSET; 181 174 f->fmt.vbi.flags = 0; 182 - switch (fh->btv->tvnorm) { 183 - case 1: /* NTSC */ 184 - start0 = 10; 185 - start1 = 273; 186 - break; 187 - case 0: /* PAL */ 188 - case 2: /* SECAM */ 189 - default: 190 - start0 = 7; 191 - start1 = 320; 192 - } 193 175 194 - count0 = (f->fmt.vbi.start[0] + f->fmt.vbi.count[0]) - start0; 195 - count1 = (f->fmt.vbi.start[1] + f->fmt.vbi.count[1]) - start1; 196 - count = max(count0,count1); 197 - if (count > VBI_MAXLINES) 198 - count = VBI_MAXLINES; 199 - if (count < 1) 200 - count = 1; 176 + /* s64 to prevent overflow. */ 177 + count0 = (s64) f->fmt.vbi.start[0] + f->fmt.vbi.count[0] 178 + - tvnorm->vbistart[0]; 179 + count1 = (s64) f->fmt.vbi.start[1] + f->fmt.vbi.count[1] 180 + - tvnorm->vbistart[1]; 181 + count = clamp (max (count0, count1), 1LL, (s64) VBI_MAXLINES); 201 182 202 - f->fmt.vbi.start[0] = start0; 203 - f->fmt.vbi.start[1] = start1; 183 + f->fmt.vbi.start[0] = tvnorm->vbistart[0]; 184 + f->fmt.vbi.start[1] = tvnorm->vbistart[1]; 204 185 f->fmt.vbi.count[0] = count; 205 186 f->fmt.vbi.count[1] = count; 187 + 188 + f->fmt.vbi.reserved[0] = 0; 189 + f->fmt.vbi.reserved[1] = 0; 206 190 } 207 191 208 192 void bttv_vbi_get_fmt(struct bttv_fh *fh, struct v4l2_format *f) ··· 205 209 f->fmt.vbi.sampling_rate = tvnorm->Fsc; 206 210 f->fmt.vbi.samples_per_line = 2048; 207 211 f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; 208 - f->fmt.vbi.offset = 244; 212 + f->fmt.vbi.offset = VBI_OFFSET; 213 + f->fmt.vbi.start[0] = tvnorm->vbistart[0]; 214 + f->fmt.vbi.start[1] = tvnorm->vbistart[1]; 209 215 f->fmt.vbi.count[0] = fh->lines; 210 216 f->fmt.vbi.count[1] = fh->lines; 211 217 f->fmt.vbi.flags = 0; 212 - switch (fh->btv->tvnorm) { 213 - case 1: /* NTSC */ 214 - f->fmt.vbi.start[0] = 10; 215 - f->fmt.vbi.start[1] = 273; 216 - break; 217 - case 0: /* PAL */ 218 - case 2: /* SECAM */ 219 - default: 220 - f->fmt.vbi.start[0] = 7; 221 - f->fmt.vbi.start[1] = 319; 222 - } 223 218 } 224 219 225 220 /* ----------------------------------------------------------------------- */
+35 -2
drivers/media/video/bttv.h
··· 16 16 17 17 #include <linux/videodev.h> 18 18 #include <linux/i2c.h> 19 + #include <media/ir-common.h> 20 + #include <media/ir-kbd-i2c.h> 19 21 20 22 /* ---------------------------------------------------------- */ 21 23 /* exported by bttv-cards.c */ ··· 165 163 #define BTTV_BOARD_OSPREY440 0x8c 166 164 #define BTTV_BOARD_ASOUND_SKYEYE 0x8d 167 165 #define BTTV_BOARD_SABRENT_TVFM 0x8e 166 + #define BTTV_BOARD_HAUPPAUGE_IMPACTVCB 0x8f 168 167 169 168 /* i2c address list */ 170 169 #define I2C_TSA5522 0xc2 ··· 213 210 214 211 struct bttv; 215 212 213 + 214 + struct bttv_ir { 215 + struct input_dev *dev; 216 + struct ir_input_state ir; 217 + char name[32]; 218 + char phys[32]; 219 + 220 + /* Usual gpio signalling */ 221 + 222 + u32 mask_keycode; 223 + u32 mask_keydown; 224 + u32 mask_keyup; 225 + u32 polling; 226 + u32 last_gpio; 227 + struct work_struct work; 228 + struct timer_list timer; 229 + 230 + /* RC5 gpio */ 231 + u32 rc5_gpio; 232 + struct timer_list timer_end; /* timer_end for code completion */ 233 + struct timer_list timer_keyup; /* timer_end for key release */ 234 + u32 last_rc5; /* last good rc5 code */ 235 + u32 last_bit; /* last raw bit seen */ 236 + u32 code; /* raw code under construction */ 237 + struct timeval base_time; /* time of last seen code */ 238 + int active; /* building raw code */ 239 + }; 240 + 216 241 struct tvcard 217 242 { 218 243 char *name; ··· 266 235 unsigned int has_dvb:1; 267 236 unsigned int has_remote:1; 268 237 unsigned int no_gpioirq:1; 269 - unsigned int any_irq:1; 270 238 271 239 /* other settings */ 272 240 unsigned int pll; ··· 365 335 struct device_driver drv; 366 336 char wanted[BUS_ID_SIZE]; 367 337 void (*gpio_irq)(struct bttv_sub_device *sub); 368 - int (*any_irq)(struct bttv_sub_device *sub); 369 338 }; 370 339 #define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv) 371 340 ··· 391 362 extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1, 392 363 unsigned char b2, int both); 393 364 extern void bttv_readee(struct bttv *btv, unsigned char *eedata, int addr); 365 + 366 + extern int bttv_input_init(struct bttv *dev); 367 + extern void bttv_input_fini(struct bttv *dev); 368 + extern void bttv_input_irq(struct bttv *dev); 394 369 395 370 #endif /* _BTTV_H_ */ 396 371 /*
+9 -4
drivers/media/video/bttvp.h
··· 73 73 74 74 #define UNSET (-1U) 75 75 76 + #define clamp(x, low, high) min (max (low, x), high) 77 + 76 78 /* ---------------------------------------------------------- */ 77 79 78 80 struct bttv_tvnorm { ··· 90 88 u8 vbipack; 91 89 u16 vtotal; 92 90 int sram; 91 + /* ITU-R frame line number of the first VBI line we can 92 + capture, of the first and second field. */ 93 + u16 vbistart[2]; 93 94 }; 94 95 extern const struct bttv_tvnorm bttv_tvnorms[]; 95 96 ··· 214 209 int bttv_sub_add_device(struct bttv_core *core, char *name); 215 210 int bttv_sub_del_devices(struct bttv_core *core); 216 211 void bttv_gpio_irq(struct bttv_core *core); 217 - int bttv_any_irq(struct bttv_core *core); 218 212 219 213 220 214 /* ---------------------------------------------------------- */ ··· 274 270 /* card configuration info */ 275 271 unsigned int cardid; /* pci subsystem id (bt878 based ones) */ 276 272 unsigned int tuner_type; /* tuner chip type */ 277 - unsigned int pinnacle_id; 273 + unsigned int tda9887_conf; 278 274 unsigned int svhs; 279 275 struct bttv_pll_info pll; 280 276 int triton1; 281 277 int gpioirq; 282 - int any_irq; 278 + int (*custom_irq)(struct bttv *btv); 279 + 283 280 int use_i2c_hw; 284 281 285 282 /* old gpio interface */ ··· 305 300 306 301 /* infrared remote */ 307 302 int has_remote; 308 - struct bttv_input *remote; 303 + struct bttv_ir *remote; 309 304 310 305 /* locking */ 311 306 spinlock_t s_lock;
+1
drivers/media/video/bw-qcam.c
··· 875 875 .open = video_exclusive_open, 876 876 .release = video_exclusive_release, 877 877 .ioctl = qcam_ioctl, 878 + .compat_ioctl = v4l_compat_ioctl32, 878 879 .read = qcam_read, 879 880 .llseek = no_llseek, 880 881 };
+1
drivers/media/video/c-qcam.c
··· 687 687 .open = video_exclusive_open, 688 688 .release = video_exclusive_release, 689 689 .ioctl = qcam_ioctl, 690 + .compat_ioctl = v4l_compat_ioctl32, 690 691 .read = qcam_read, 691 692 .llseek = no_llseek, 692 693 };
+732
drivers/media/video/compat_ioctl32.c
··· 1 + /* 2 + * ioctl32.c: Conversion between 32bit and 64bit native ioctls. 3 + * Separated from fs stuff by Arnd Bergmann <arnd@arndb.de> 4 + * 5 + * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com) 6 + * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) 7 + * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs 8 + * Copyright (C) 2003 Pavel Machek (pavel@suse.cz) 9 + * Copyright (C) 2005 Philippe De Muyter (phdm@macqel.be) 10 + * 11 + * These routines maintain argument size conversion between 32bit and 64bit 12 + * ioctls. 13 + */ 14 + 15 + #include <linux/config.h> 16 + #include <linux/compat.h> 17 + #include <linux/videodev.h> 18 + #include <linux/videodev2.h> 19 + #include <linux/module.h> 20 + #include <linux/smp_lock.h> 21 + 22 + #ifdef CONFIG_COMPAT 23 + struct video_tuner32 { 24 + compat_int_t tuner; 25 + char name[32]; 26 + compat_ulong_t rangelow, rangehigh; 27 + u32 flags; /* It is really u32 in videodev.h */ 28 + u16 mode, signal; 29 + }; 30 + 31 + static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) 32 + { 33 + if(get_user(kp->tuner, &up->tuner)) 34 + return -EFAULT; 35 + __copy_from_user(kp->name, up->name, 32); 36 + __get_user(kp->rangelow, &up->rangelow); 37 + __get_user(kp->rangehigh, &up->rangehigh); 38 + __get_user(kp->flags, &up->flags); 39 + __get_user(kp->mode, &up->mode); 40 + __get_user(kp->signal, &up->signal); 41 + return 0; 42 + } 43 + 44 + static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) 45 + { 46 + if(put_user(kp->tuner, &up->tuner)) 47 + return -EFAULT; 48 + __copy_to_user(up->name, kp->name, 32); 49 + __put_user(kp->rangelow, &up->rangelow); 50 + __put_user(kp->rangehigh, &up->rangehigh); 51 + __put_user(kp->flags, &up->flags); 52 + __put_user(kp->mode, &up->mode); 53 + __put_user(kp->signal, &up->signal); 54 + return 0; 55 + } 56 + 57 + struct video_buffer32 { 58 + compat_caddr_t base; 59 + compat_int_t height, width, depth, bytesperline; 60 + }; 61 + 62 + static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up) 63 + { 64 + u32 tmp; 65 + 66 + if (get_user(tmp, &up->base)) 67 + return -EFAULT; 68 + 69 + /* This is actually a physical address stored 70 + * as a void pointer. 71 + */ 72 + kp->base = (void *)(unsigned long) tmp; 73 + 74 + __get_user(kp->height, &up->height); 75 + __get_user(kp->width, &up->width); 76 + __get_user(kp->depth, &up->depth); 77 + __get_user(kp->bytesperline, &up->bytesperline); 78 + return 0; 79 + } 80 + 81 + static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up) 82 + { 83 + u32 tmp = (u32)((unsigned long)kp->base); 84 + 85 + if(put_user(tmp, &up->base)) 86 + return -EFAULT; 87 + __put_user(kp->height, &up->height); 88 + __put_user(kp->width, &up->width); 89 + __put_user(kp->depth, &up->depth); 90 + __put_user(kp->bytesperline, &up->bytesperline); 91 + return 0; 92 + } 93 + 94 + struct video_clip32 { 95 + s32 x, y, width, height; /* Its really s32 in videodev.h */ 96 + compat_caddr_t next; 97 + }; 98 + 99 + struct video_window32 { 100 + u32 x, y, width, height, chromakey, flags; 101 + compat_caddr_t clips; 102 + compat_int_t clipcount; 103 + }; 104 + 105 + static int native_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 106 + { 107 + int ret = -ENOIOCTLCMD; 108 + 109 + if (file->f_op->unlocked_ioctl) 110 + ret = file->f_op->unlocked_ioctl(file, cmd, arg); 111 + else if (file->f_op->ioctl) { 112 + lock_kernel(); 113 + ret = file->f_op->ioctl(file->f_dentry->d_inode, file, cmd, arg); 114 + unlock_kernel(); 115 + } 116 + 117 + return ret; 118 + } 119 + 120 + 121 + /* You get back everything except the clips... */ 122 + static int put_video_window32(struct video_window *kp, struct video_window32 __user *up) 123 + { 124 + if(put_user(kp->x, &up->x)) 125 + return -EFAULT; 126 + __put_user(kp->y, &up->y); 127 + __put_user(kp->width, &up->width); 128 + __put_user(kp->height, &up->height); 129 + __put_user(kp->chromakey, &up->chromakey); 130 + __put_user(kp->flags, &up->flags); 131 + __put_user(kp->clipcount, &up->clipcount); 132 + return 0; 133 + } 134 + 135 + struct v4l2_clip32 136 + { 137 + struct v4l2_rect c; 138 + compat_caddr_t next; 139 + }; 140 + 141 + struct v4l2_window32 142 + { 143 + struct v4l2_rect w; 144 + enum v4l2_field field; 145 + __u32 chromakey; 146 + compat_caddr_t clips; /* actually struct v4l2_clip32 * */ 147 + __u32 clipcount; 148 + compat_caddr_t bitmap; 149 + }; 150 + 151 + static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up) 152 + { 153 + if (copy_from_user(&kp->w, &up->w, sizeof(up->w))) 154 + return -EFAULT; 155 + __get_user(kp->field, &up->field); 156 + __get_user(kp->chromakey, &up->chromakey); 157 + __get_user(kp->clipcount, &up->clipcount); 158 + if (kp->clipcount > 2048) 159 + return -EINVAL; 160 + if (kp->clipcount) { 161 + struct v4l2_clip32 *uclips = compat_ptr(up->clips); 162 + struct v4l2_clip *kclips; 163 + int n = kp->clipcount; 164 + 165 + kclips = compat_alloc_user_space(n * sizeof(struct v4l2_clip)); 166 + kp->clips = kclips; 167 + while (--n >= 0) { 168 + copy_from_user(&kclips->c, &uclips->c, sizeof(uclips->c)); 169 + kclips->next = n ? kclips + 1 : 0; 170 + uclips += 1; 171 + kclips += 1; 172 + } 173 + } else 174 + kp->clips = 0; 175 + return 0; 176 + } 177 + 178 + static int put_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up) 179 + { 180 + if (copy_to_user(&up->w, &kp->w, sizeof(up->w))) 181 + return -EFAULT; 182 + __put_user(kp->field, &up->field); 183 + __put_user(kp->chromakey, &up->chromakey); 184 + __put_user(kp->clipcount, &up->clipcount); 185 + return 0; 186 + } 187 + 188 + static inline int get_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up) 189 + { 190 + return copy_from_user(kp, up, sizeof(struct v4l2_pix_format)); 191 + } 192 + 193 + static inline int put_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up) 194 + { 195 + return copy_to_user(up, kp, sizeof(struct v4l2_pix_format)); 196 + } 197 + 198 + static inline int get_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up) 199 + { 200 + return copy_from_user(kp, up, sizeof(struct v4l2_vbi_format)); 201 + } 202 + 203 + static inline int put_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up) 204 + { 205 + return copy_to_user(up, kp, sizeof(struct v4l2_vbi_format)); 206 + } 207 + 208 + struct v4l2_format32 209 + { 210 + enum v4l2_buf_type type; 211 + union 212 + { 213 + struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE 214 + struct v4l2_window32 win; // V4L2_BUF_TYPE_VIDEO_OVERLAY 215 + struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE 216 + __u8 raw_data[200]; // user-defined 217 + } fmt; 218 + }; 219 + 220 + static int get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) 221 + { 222 + if(get_user(kp->type, &up->type)) 223 + return -EFAULT; 224 + switch (kp->type) { 225 + case V4L2_BUF_TYPE_VIDEO_CAPTURE: 226 + return get_v4l2_pix_format(&kp->fmt.pix, &up->fmt.pix); 227 + case V4L2_BUF_TYPE_VIDEO_OVERLAY: 228 + return get_v4l2_window32(&kp->fmt.win, &up->fmt.win); 229 + case V4L2_BUF_TYPE_VBI_CAPTURE: 230 + return get_v4l2_vbi_format(&kp->fmt.vbi, &up->fmt.vbi); 231 + default: 232 + printk("compat_ioctl : unexpected VIDIOC_FMT type %d\n", 233 + kp->type); 234 + return -ENXIO; 235 + } 236 + } 237 + 238 + static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) 239 + { 240 + if(put_user(kp->type, &up->type)) 241 + return -EFAULT; 242 + switch (kp->type) { 243 + case V4L2_BUF_TYPE_VIDEO_CAPTURE: 244 + return put_v4l2_pix_format(&kp->fmt.pix, &up->fmt.pix); 245 + case V4L2_BUF_TYPE_VIDEO_OVERLAY: 246 + return put_v4l2_window32(&kp->fmt.win, &up->fmt.win); 247 + case V4L2_BUF_TYPE_VBI_CAPTURE: 248 + return put_v4l2_vbi_format(&kp->fmt.vbi, &up->fmt.vbi); 249 + default: 250 + return -ENXIO; 251 + } 252 + } 253 + 254 + struct v4l2_standard32 255 + { 256 + __u32 index; 257 + __u32 id[2]; /* __u64 would get the alignment wrong */ 258 + __u8 name[24]; 259 + struct v4l2_fract frameperiod; /* Frames, not fields */ 260 + __u32 framelines; 261 + __u32 reserved[4]; 262 + }; 263 + 264 + static int get_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 __user *up) 265 + { 266 + /* other fields are not set by the user, nor used by the driver */ 267 + return get_user(kp->index, &up->index); 268 + } 269 + 270 + static int put_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 __user *up) 271 + { 272 + if(put_user(kp->index, &up->index)) 273 + return -EFAULT; 274 + __copy_to_user(up->id, &kp->id, sizeof(__u64)); 275 + __copy_to_user(up->name, kp->name, 24); 276 + __put_user(kp->frameperiod, &up->frameperiod); 277 + __put_user(kp->framelines, &up->framelines); 278 + __copy_to_user(up->reserved, kp->reserved, 4 * sizeof(__u32)); 279 + return 0; 280 + } 281 + 282 + struct v4l2_buffer32 283 + { 284 + __u32 index; 285 + enum v4l2_buf_type type; 286 + __u32 bytesused; 287 + __u32 flags; 288 + enum v4l2_field field; 289 + struct compat_timeval timestamp; 290 + struct v4l2_timecode timecode; 291 + __u32 sequence; 292 + 293 + /* memory location */ 294 + enum v4l2_memory memory; 295 + union { 296 + __u32 offset; 297 + compat_long_t userptr; 298 + } m; 299 + __u32 length; 300 + __u32 input; 301 + __u32 reserved; 302 + }; 303 + 304 + static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user *up) 305 + { 306 + 307 + if (get_user(kp->index, &up->index)) 308 + return -EFAULT; 309 + __get_user(kp->type, &up->type); 310 + __get_user(kp->flags, &up->flags); 311 + __get_user(kp->memory, &up->memory); 312 + __get_user(kp->input, &up->input); 313 + switch(kp->memory) { 314 + case V4L2_MEMORY_MMAP: 315 + break; 316 + case V4L2_MEMORY_USERPTR: 317 + { 318 + unsigned long tmp = (unsigned long)compat_ptr(up->m.userptr); 319 + 320 + __get_user(kp->length, &up->length); 321 + __get_user(kp->m.userptr, &tmp); 322 + } 323 + break; 324 + case V4L2_MEMORY_OVERLAY: 325 + __get_user(kp->m.offset, &up->m.offset); 326 + break; 327 + } 328 + return 0; 329 + } 330 + 331 + static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user *up) 332 + { 333 + if (put_user(kp->index, &up->index)) 334 + return -EFAULT; 335 + __put_user(kp->type, &up->type); 336 + __put_user(kp->flags, &up->flags); 337 + __put_user(kp->memory, &up->memory); 338 + __put_user(kp->input, &up->input); 339 + switch(kp->memory) { 340 + case V4L2_MEMORY_MMAP: 341 + __put_user(kp->length, &up->length); 342 + __put_user(kp->m.offset, &up->m.offset); 343 + break; 344 + case V4L2_MEMORY_USERPTR: 345 + __put_user(kp->length, &up->length); 346 + __put_user(kp->m.userptr, &up->m.userptr); 347 + break; 348 + case V4L2_MEMORY_OVERLAY: 349 + __put_user(kp->m.offset, &up->m.offset); 350 + break; 351 + } 352 + __put_user(kp->bytesused, &up->bytesused); 353 + __put_user(kp->field, &up->field); 354 + __put_user(kp->timestamp.tv_sec, &up->timestamp.tv_sec); 355 + __put_user(kp->timestamp.tv_usec, &up->timestamp.tv_usec); 356 + __copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)); 357 + __put_user(kp->sequence, &up->sequence); 358 + __put_user(kp->reserved, &up->reserved); 359 + return 0; 360 + } 361 + 362 + struct v4l2_framebuffer32 363 + { 364 + __u32 capability; 365 + __u32 flags; 366 + compat_caddr_t base; 367 + struct v4l2_pix_format fmt; 368 + }; 369 + 370 + static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_framebuffer32 __user *up) 371 + { 372 + u32 tmp; 373 + 374 + if (get_user(tmp, &up->base)) 375 + return -EFAULT; 376 + kp->base = compat_ptr(tmp); 377 + __get_user(kp->capability, &up->capability); 378 + __get_user(kp->flags, &up->flags); 379 + get_v4l2_pix_format(&kp->fmt, &up->fmt); 380 + return 0; 381 + } 382 + 383 + static int put_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_framebuffer32 __user *up) 384 + { 385 + u32 tmp = (u32)((unsigned long)kp->base); 386 + 387 + if(put_user(tmp, &up->base)) 388 + return -EFAULT; 389 + __put_user(kp->capability, &up->capability); 390 + __put_user(kp->flags, &up->flags); 391 + put_v4l2_pix_format(&kp->fmt, &up->fmt); 392 + return 0; 393 + } 394 + 395 + struct v4l2_input32 /* identical layout, but different size */ 396 + { 397 + __u32 index; /* Which input */ 398 + __u8 name[32]; /* Label */ 399 + __u32 type; /* Type of input */ 400 + __u32 audioset; /* Associated audios (bitfield) */ 401 + __u32 tuner; /* Associated tuner */ 402 + __u32 std[2]; /* __u64 would get the padding wrong */ 403 + __u32 status; 404 + __u32 reserved[4]; 405 + }; 406 + 407 + #define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32) 408 + #define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32) 409 + #define VIDIOCGWIN32 _IOR('v',9, struct video_window32) 410 + #define VIDIOCSWIN32 _IOW('v',10, struct video_window32) 411 + #define VIDIOCGFBUF32 _IOR('v',11, struct video_buffer32) 412 + #define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32) 413 + #define VIDIOCGFREQ32 _IOR('v',14, u32) 414 + #define VIDIOCSFREQ32 _IOW('v',15, u32) 415 + 416 + #define VIDIOC_G_FMT32 _IOWR ('V', 4, struct v4l2_format32) 417 + #define VIDIOC_S_FMT32 _IOWR ('V', 5, struct v4l2_format32) 418 + #define VIDIOC_QUERYBUF32 _IOWR ('V', 9, struct v4l2_buffer32) 419 + #define VIDIOC_G_FBUF32 _IOR ('V', 10, struct v4l2_framebuffer32) 420 + #define VIDIOC_S_FBUF32 _IOW ('V', 11, struct v4l2_framebuffer32) 421 + /* VIDIOC_OVERLAY is now _IOW, but was _IOWR */ 422 + #define VIDIOC_OVERLAY32 _IOWR ('V', 14, compat_int_t) 423 + #define VIDIOC_QBUF32 _IOWR ('V', 15, struct v4l2_buffer32) 424 + #define VIDIOC_DQBUF32 _IOWR ('V', 17, struct v4l2_buffer32) 425 + #define VIDIOC_STREAMON32 _IOW ('V', 18, compat_int_t) 426 + #define VIDIOC_STREAMOFF32 _IOW ('V', 19, compat_int_t) 427 + #define VIDIOC_ENUMSTD32 _IOWR ('V', 25, struct v4l2_standard32) 428 + #define VIDIOC_ENUMINPUT32 _IOWR ('V', 26, struct v4l2_input32) 429 + /* VIDIOC_S_CTRL is now _IOWR, but was _IOW */ 430 + #define VIDIOC_S_CTRL32 _IOW ('V', 28, struct v4l2_control) 431 + #define VIDIOC_G_INPUT32 _IOR ('V', 38, compat_int_t) 432 + #define VIDIOC_S_INPUT32 _IOWR ('V', 39, compat_int_t) 433 + #define VIDIOC_TRY_FMT32 _IOWR ('V', 64, struct v4l2_format32) 434 + 435 + enum { 436 + MaxClips = (~0U-sizeof(struct video_window))/sizeof(struct video_clip) 437 + }; 438 + 439 + static int do_set_window(struct file *file, unsigned int cmd, unsigned long arg) 440 + { 441 + struct video_window32 __user *up = compat_ptr(arg); 442 + struct video_window __user *vw; 443 + struct video_clip __user *p; 444 + int nclips; 445 + u32 n; 446 + 447 + if (get_user(nclips, &up->clipcount)) 448 + return -EFAULT; 449 + 450 + /* Peculiar interface... */ 451 + if (nclips < 0) 452 + nclips = VIDEO_CLIPMAP_SIZE; 453 + 454 + if (nclips > MaxClips) 455 + return -ENOMEM; 456 + 457 + vw = compat_alloc_user_space(sizeof(struct video_window) + 458 + nclips * sizeof(struct video_clip)); 459 + 460 + p = nclips ? (struct video_clip __user *)(vw + 1) : NULL; 461 + 462 + if (get_user(n, &up->x) || put_user(n, &vw->x) || 463 + get_user(n, &up->y) || put_user(n, &vw->y) || 464 + get_user(n, &up->width) || put_user(n, &vw->width) || 465 + get_user(n, &up->height) || put_user(n, &vw->height) || 466 + get_user(n, &up->chromakey) || put_user(n, &vw->chromakey) || 467 + get_user(n, &up->flags) || put_user(n, &vw->flags) || 468 + get_user(n, &up->clipcount) || put_user(n, &vw->clipcount) || 469 + get_user(n, &up->clips) || put_user(p, &vw->clips)) 470 + return -EFAULT; 471 + 472 + if (nclips) { 473 + struct video_clip32 __user *u = compat_ptr(n); 474 + int i; 475 + if (!u) 476 + return -EINVAL; 477 + for (i = 0; i < nclips; i++, u++, p++) { 478 + s32 v; 479 + if (get_user(v, &u->x) || 480 + put_user(v, &p->x) || 481 + get_user(v, &u->y) || 482 + put_user(v, &p->y) || 483 + get_user(v, &u->width) || 484 + put_user(v, &p->width) || 485 + get_user(v, &u->height) || 486 + put_user(v, &p->height) || 487 + put_user(NULL, &p->next)) 488 + return -EFAULT; 489 + } 490 + } 491 + 492 + return native_ioctl(file, VIDIOCSWIN, (unsigned long)vw); 493 + } 494 + 495 + static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 496 + { 497 + union { 498 + struct video_tuner vt; 499 + struct video_buffer vb; 500 + struct video_window vw; 501 + struct v4l2_format v2f; 502 + struct v4l2_buffer v2b; 503 + struct v4l2_framebuffer v2fb; 504 + struct v4l2_standard v2s; 505 + unsigned long vx; 506 + } karg; 507 + void __user *up = compat_ptr(arg); 508 + int compatible_arg = 1; 509 + int err = 0; 510 + 511 + /* First, convert the command. */ 512 + switch(cmd) { 513 + case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break; 514 + case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break; 515 + case VIDIOCGWIN32: cmd = VIDIOCGWIN; break; 516 + case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break; 517 + case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break; 518 + case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break; 519 + case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break; 520 + case VIDIOC_G_FMT32: cmd = VIDIOC_G_FMT; break; 521 + case VIDIOC_S_FMT32: cmd = VIDIOC_S_FMT; break; 522 + case VIDIOC_QUERYBUF32: cmd = VIDIOC_QUERYBUF; break; 523 + case VIDIOC_QBUF32: cmd = VIDIOC_QBUF; break; 524 + case VIDIOC_DQBUF32: cmd = VIDIOC_DQBUF; break; 525 + case VIDIOC_STREAMON32: cmd = VIDIOC_STREAMON; break; 526 + case VIDIOC_STREAMOFF32: cmd = VIDIOC_STREAMOFF; break; 527 + case VIDIOC_G_FBUF32: cmd = VIDIOC_G_FBUF; break; 528 + case VIDIOC_S_FBUF32: cmd = VIDIOC_S_FBUF; break; 529 + case VIDIOC_OVERLAY32: cmd = VIDIOC_OVERLAY; break; 530 + case VIDIOC_ENUMSTD32: cmd = VIDIOC_ENUMSTD; break; 531 + case VIDIOC_ENUMINPUT32: cmd = VIDIOC_ENUMINPUT; break; 532 + case VIDIOC_S_CTRL32: cmd = VIDIOC_S_CTRL; break; 533 + case VIDIOC_G_INPUT32: cmd = VIDIOC_G_INPUT; break; 534 + case VIDIOC_S_INPUT32: cmd = VIDIOC_S_INPUT; break; 535 + case VIDIOC_TRY_FMT32: cmd = VIDIOC_TRY_FMT; break; 536 + }; 537 + 538 + switch(cmd) { 539 + case VIDIOCSTUNER: 540 + case VIDIOCGTUNER: 541 + err = get_video_tuner32(&karg.vt, up); 542 + compatible_arg = 0; 543 + 544 + break; 545 + 546 + case VIDIOCSFBUF: 547 + err = get_video_buffer32(&karg.vb, up); 548 + compatible_arg = 0; 549 + break; 550 + 551 + case VIDIOCSFREQ: 552 + case VIDIOC_S_INPUT: 553 + case VIDIOC_OVERLAY: 554 + case VIDIOC_STREAMON: 555 + case VIDIOC_STREAMOFF: 556 + err = get_user(karg.vx, (u32 __user *)up); 557 + compatible_arg = 0; 558 + break; 559 + 560 + case VIDIOC_S_FBUF: 561 + err = get_v4l2_framebuffer32(&karg.v2fb, up); 562 + compatible_arg = 0; 563 + break; 564 + 565 + case VIDIOC_G_FMT: 566 + case VIDIOC_S_FMT: 567 + case VIDIOC_TRY_FMT: 568 + err = get_v4l2_format32(&karg.v2f, up); 569 + compatible_arg = 0; 570 + break; 571 + 572 + case VIDIOC_QUERYBUF: 573 + case VIDIOC_QBUF: 574 + case VIDIOC_DQBUF: 575 + err = get_v4l2_buffer32(&karg.v2b, up); 576 + compatible_arg = 0; 577 + break; 578 + 579 + case VIDIOC_ENUMSTD: 580 + err = get_v4l2_standard32(&karg.v2s, up); 581 + compatible_arg = 0; 582 + break; 583 + 584 + case VIDIOCGWIN: 585 + case VIDIOCGFBUF: 586 + case VIDIOCGFREQ: 587 + case VIDIOC_G_FBUF: 588 + case VIDIOC_G_INPUT: 589 + compatible_arg = 0; 590 + }; 591 + 592 + if(err) 593 + goto out; 594 + 595 + if(compatible_arg) 596 + err = native_ioctl(file, cmd, (unsigned long)up); 597 + else { 598 + mm_segment_t old_fs = get_fs(); 599 + 600 + set_fs(KERNEL_DS); 601 + err = native_ioctl(file, cmd, (unsigned long)&karg); 602 + set_fs(old_fs); 603 + } 604 + if(err == 0) { 605 + switch(cmd) { 606 + case VIDIOCGTUNER: 607 + err = put_video_tuner32(&karg.vt, up); 608 + break; 609 + 610 + case VIDIOCGWIN: 611 + err = put_video_window32(&karg.vw, up); 612 + break; 613 + 614 + case VIDIOCGFBUF: 615 + err = put_video_buffer32(&karg.vb, up); 616 + break; 617 + 618 + case VIDIOC_G_FBUF: 619 + err = put_v4l2_framebuffer32(&karg.v2fb, up); 620 + break; 621 + 622 + case VIDIOC_G_FMT: 623 + case VIDIOC_S_FMT: 624 + case VIDIOC_TRY_FMT: 625 + err = put_v4l2_format32(&karg.v2f, up); 626 + break; 627 + 628 + case VIDIOC_QUERYBUF: 629 + case VIDIOC_QBUF: 630 + case VIDIOC_DQBUF: 631 + err = put_v4l2_buffer32(&karg.v2b, up); 632 + break; 633 + 634 + case VIDIOC_ENUMSTD: 635 + err = put_v4l2_standard32(&karg.v2s, up); 636 + break; 637 + 638 + case VIDIOCGFREQ: 639 + case VIDIOC_G_INPUT: 640 + err = put_user(((u32)karg.vx), (u32 __user *)up); 641 + break; 642 + }; 643 + } 644 + out: 645 + return err; 646 + } 647 + 648 + long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) 649 + { 650 + int ret = -ENOIOCTLCMD; 651 + 652 + if (!file->f_op->ioctl) 653 + return ret; 654 + 655 + switch (cmd) { 656 + case VIDIOCSWIN32: 657 + ret = do_set_window(file, cmd, arg); 658 + break; 659 + case VIDIOCGTUNER32: 660 + case VIDIOCSTUNER32: 661 + case VIDIOCGWIN32: 662 + case VIDIOCGFBUF32: 663 + case VIDIOCSFBUF32: 664 + case VIDIOCGFREQ32: 665 + case VIDIOCSFREQ32: 666 + case VIDIOC_QUERYCAP: 667 + case VIDIOC_ENUM_FMT: 668 + case VIDIOC_G_FMT32: 669 + case VIDIOC_S_FMT32: 670 + case VIDIOC_REQBUFS: 671 + case VIDIOC_QUERYBUF32: 672 + case VIDIOC_G_FBUF32: 673 + case VIDIOC_S_FBUF32: 674 + case VIDIOC_OVERLAY32: 675 + case VIDIOC_QBUF32: 676 + case VIDIOC_DQBUF32: 677 + case VIDIOC_STREAMON32: 678 + case VIDIOC_STREAMOFF32: 679 + case VIDIOC_G_PARM: 680 + case VIDIOC_G_STD: 681 + case VIDIOC_S_STD: 682 + case VIDIOC_ENUMSTD32: 683 + case VIDIOC_ENUMINPUT32: 684 + case VIDIOC_G_CTRL: 685 + case VIDIOC_S_CTRL32: 686 + case VIDIOC_QUERYCTRL: 687 + case VIDIOC_G_INPUT32: 688 + case VIDIOC_S_INPUT32: 689 + case VIDIOC_TRY_FMT32: 690 + ret = do_video_ioctl(file, cmd, arg); 691 + break; 692 + 693 + /* Little v, the video4linux ioctls (conflict?) */ 694 + case VIDIOCGCAP: 695 + case VIDIOCGCHAN: 696 + case VIDIOCSCHAN: 697 + case VIDIOCGPICT: 698 + case VIDIOCSPICT: 699 + case VIDIOCCAPTURE: 700 + case VIDIOCKEY: 701 + case VIDIOCGAUDIO: 702 + case VIDIOCSAUDIO: 703 + case VIDIOCSYNC: 704 + case VIDIOCMCAPTURE: 705 + case VIDIOCGMBUF: 706 + case VIDIOCGUNIT: 707 + case VIDIOCGCAPTURE: 708 + case VIDIOCSCAPTURE: 709 + 710 + /* BTTV specific... */ 711 + case _IOW('v', BASE_VIDIOCPRIVATE+0, char [256]): 712 + case _IOR('v', BASE_VIDIOCPRIVATE+1, char [256]): 713 + case _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int): 714 + case _IOW('v' , BASE_VIDIOCPRIVATE+3, char [16]): /* struct bttv_pll_info */ 715 + case _IOR('v' , BASE_VIDIOCPRIVATE+4, int): 716 + case _IOR('v' , BASE_VIDIOCPRIVATE+5, int): 717 + case _IOR('v' , BASE_VIDIOCPRIVATE+6, int): 718 + case _IOR('v' , BASE_VIDIOCPRIVATE+7, int): 719 + ret = native_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); 720 + break; 721 + } 722 + return ret; 723 + } 724 + #else 725 + long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) 726 + { 727 + return -ENOIOCTLCMD; 728 + } 729 + #endif 730 + EXPORT_SYMBOL_GPL(v4l_compat_ioctl32); 731 + 732 + MODULE_LICENSE("GPL");
+1
drivers/media/video/cpia.c
··· 3807 3807 .read = cpia_read, 3808 3808 .mmap = cpia_mmap, 3809 3809 .ioctl = cpia_ioctl, 3810 + .compat_ioctl = v4l_compat_ioctl32, 3810 3811 .llseek = no_llseek, 3811 3812 }; 3812 3813
+41 -51
drivers/media/video/cs53l32a.c
··· 27 27 #include <linux/i2c.h> 28 28 #include <linux/i2c-id.h> 29 29 #include <linux/videodev.h> 30 - #include <media/audiochip.h> 30 + #include <media/v4l2-common.h> 31 31 32 32 MODULE_DESCRIPTION("i2c device driver for cs53l32a Audio ADC"); 33 33 MODULE_AUTHOR("Martin Vaughan"); ··· 38 38 module_param(debug, bool, 0644); 39 39 40 40 MODULE_PARM_DESC(debug, "Debugging messages\n\t\t\t0=Off (default), 1=On"); 41 - 42 - #define cs53l32a_dbg(fmt, arg...) \ 43 - do { \ 44 - if (debug) \ 45 - printk(KERN_INFO "%s debug %d-%04x: " fmt, \ 46 - client->driver->driver.name, \ 47 - i2c_adapter_id(client->adapter), client->addr , ## arg); \ 48 - } while (0) 49 - 50 - #define cs53l32a_err(fmt, arg...) do { \ 51 - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ 52 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 53 - #define cs53l32a_info(fmt, arg...) do { \ 54 - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ 55 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 56 41 57 42 static unsigned short normal_i2c[] = { 0x22 >> 1, I2C_CLIENT_END }; 58 43 ··· 59 74 static int cs53l32a_command(struct i2c_client *client, unsigned int cmd, 60 75 void *arg) 61 76 { 62 - int *input = arg; 77 + struct v4l2_audio *input = arg; 78 + struct v4l2_control *ctrl = arg; 63 79 64 80 switch (cmd) { 65 - case AUDC_SET_INPUT: 66 - switch (*input) { 67 - case AUDIO_TUNER: 68 - cs53l32a_write(client, 0x01, 0x01); 69 - break; 70 - case AUDIO_EXTERN: 71 - cs53l32a_write(client, 0x01, 0x21); 72 - break; 73 - case AUDIO_MUTE: 74 - cs53l32a_write(client, 0x03, 0xF0); 75 - break; 76 - case AUDIO_UNMUTE: 77 - cs53l32a_write(client, 0x03, 0x30); 78 - break; 79 - default: 80 - cs53l32a_err("Invalid input %d.\n", *input); 81 + case VIDIOC_S_AUDIO: 82 + /* There are 2 physical inputs, but the second input can be 83 + placed in two modes, the first mode bypasses the PGA (gain), 84 + the second goes through the PGA. Hence there are three 85 + possible inputs to choose from. */ 86 + if (input->index > 2) { 87 + v4l_err(client, "Invalid input %d.\n", input->index); 81 88 return -EINVAL; 82 89 } 90 + cs53l32a_write(client, 0x01, 0x01 + (input->index << 4)); 91 + break; 92 + 93 + case VIDIOC_G_AUDIO: 94 + memset(input, 0, sizeof(*input)); 95 + input->index = (cs53l32a_read(client, 0x01) >> 4) & 3; 96 + break; 97 + 98 + case VIDIOC_G_CTRL: 99 + if (ctrl->id == V4L2_CID_AUDIO_MUTE) { 100 + ctrl->value = (cs53l32a_read(client, 0x03) & 0xc0) != 0; 101 + break; 102 + } 103 + if (ctrl->id != V4L2_CID_AUDIO_VOLUME) 104 + return -EINVAL; 105 + ctrl->value = (s8)cs53l32a_read(client, 0x04); 83 106 break; 84 107 85 108 case VIDIOC_S_CTRL: 86 - { 87 - struct v4l2_control *ctrl = arg; 88 - 89 - if (ctrl->id != V4L2_CID_AUDIO_VOLUME) 90 - return -EINVAL; 91 - if (ctrl->value > 12 || ctrl->value < -90) 92 - return -EINVAL; 93 - cs53l32a_write(client, 0x04, (u8) ctrl->value); 94 - cs53l32a_write(client, 0x05, (u8) ctrl->value); 109 + if (ctrl->id == V4L2_CID_AUDIO_MUTE) { 110 + cs53l32a_write(client, 0x03, ctrl->value ? 0xf0 : 0x30); 95 111 break; 96 112 } 113 + if (ctrl->id != V4L2_CID_AUDIO_VOLUME) 114 + return -EINVAL; 115 + if (ctrl->value > 12 || ctrl->value < -96) 116 + return -EINVAL; 117 + cs53l32a_write(client, 0x04, (u8) ctrl->value); 118 + cs53l32a_write(client, 0x05, (u8) ctrl->value); 119 + break; 97 120 98 121 case VIDIOC_LOG_STATUS: 99 122 { 100 123 u8 v = cs53l32a_read(client, 0x01); 101 124 u8 m = cs53l32a_read(client, 0x03); 125 + s8 vol = cs53l32a_read(client, 0x04); 102 126 103 - cs53l32a_info("Input: %s%s\n", 104 - v == 0x21 ? "external line in" : "tuner", 127 + v4l_info(client, "Input: %d%s\n", (v >> 4) & 3, 105 128 (m & 0xC0) ? " (muted)" : ""); 129 + v4l_info(client, "Volume: %d dB\n", vol); 106 130 break; 107 131 } 108 132 ··· 151 157 client->driver = &i2c_driver; 152 158 snprintf(client->name, sizeof(client->name) - 1, "cs53l32a"); 153 159 154 - cs53l32a_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name); 160 + v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name); 155 161 156 162 for (i = 1; i <= 7; i++) { 157 163 u8 v = cs53l32a_read(client, i); 158 164 159 - cs53l32a_dbg("Read Reg %d %02x\n", i, v); 165 + v4l_dbg(1, client, "Read Reg %d %02x\n", i, v); 160 166 } 161 167 162 168 /* Set cs53l32a internal register for Adaptec 2010/2410 setup */ ··· 174 180 for (i = 1; i <= 7; i++) { 175 181 u8 v = cs53l32a_read(client, i); 176 182 177 - cs53l32a_dbg("Read Reg %d %02x\n", i, v); 183 + v4l_dbg(1, client, "Read Reg %d %02x\n", i, v); 178 184 } 179 185 180 186 i2c_attach_client(client); ··· 184 190 185 191 static int cs53l32a_probe(struct i2c_adapter *adapter) 186 192 { 187 - #ifdef I2C_CLASS_TV_ANALOG 188 193 if (adapter->class & I2C_CLASS_TV_ANALOG) 189 - #else 190 - if (adapter->id == I2C_HW_B_BT848) 191 - #endif 192 194 return i2c_probe(adapter, &addr_data, cs53l32a_attach); 193 195 return 0; 194 196 }
+36 -55
drivers/media/video/cx25840/cx25840-audio.c
··· 23 23 24 24 #include "cx25840.h" 25 25 26 - inline static int set_audclk_freq(struct i2c_client *client, 27 - enum v4l2_audio_clock_freq freq) 26 + static int set_audclk_freq(struct i2c_client *client, u32 freq) 28 27 { 29 28 struct cx25840_state *state = i2c_get_clientdata(client); 29 + 30 + if (freq != 32000 && freq != 44100 && freq != 48000) 31 + return -EINVAL; 30 32 31 33 /* assert soft reset */ 32 34 cx25840_and_or(client, 0x810, ~0x1, 0x01); ··· 37 35 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */ 38 36 cx25840_write(client, 0x127, 0x50); 39 37 40 - switch (state->audio_input) { 41 - case AUDIO_TUNER: 38 + if (state->aud_input != CX25840_AUDIO_SERIAL) { 42 39 switch (freq) { 43 - case V4L2_AUDCLK_32_KHZ: 40 + case 32000: 44 41 /* VID_PLL and AUX_PLL */ 45 42 cx25840_write4(client, 0x108, 0x0f040610); 46 43 ··· 52 51 cx25840_write4(client, 0x90c, 0x7ff70108); 53 52 break; 54 53 55 - case V4L2_AUDCLK_441_KHZ: 54 + case 44100: 56 55 /* VID_PLL and AUX_PLL */ 57 56 cx25840_write4(client, 0x108, 0x0f040910); 58 57 ··· 65 64 cx25840_write4(client, 0x90c, 0x596d0108); 66 65 break; 67 66 68 - case V4L2_AUDCLK_48_KHZ: 67 + case 48000: 69 68 /* VID_PLL and AUX_PLL */ 70 69 cx25840_write4(client, 0x108, 0x0f040a10); 71 70 ··· 78 77 cx25840_write4(client, 0x90c, 0xaa4f0108); 79 78 break; 80 79 } 81 - break; 82 - 83 - case AUDIO_EXTERN_1: 84 - case AUDIO_EXTERN_2: 85 - case AUDIO_INTERN: 86 - case AUDIO_RADIO: 80 + } else { 87 81 switch (freq) { 88 - case V4L2_AUDCLK_32_KHZ: 82 + case 32000: 89 83 /* VID_PLL and AUX_PLL */ 90 84 cx25840_write4(client, 0x108, 0x0f04081e); 91 85 ··· 99 103 cx25840_write(client, 0x127, 0x54); 100 104 break; 101 105 102 - case V4L2_AUDCLK_441_KHZ: 106 + case 44100: 103 107 /* VID_PLL and AUX_PLL */ 104 108 cx25840_write4(client, 0x108, 0x0f040918); 105 109 ··· 115 119 cx25840_write4(client, 0x90c, 0x85730108); 116 120 break; 117 121 118 - case V4L2_AUDCLK_48_KHZ: 122 + case 48000: 119 123 /* VID_PLL and AUX_PLL */ 120 124 cx25840_write4(client, 0x108, 0x0f040a18); 121 125 ··· 131 135 cx25840_write4(client, 0x90c, 0x55550108); 132 136 break; 133 137 } 134 - break; 135 138 } 136 139 137 140 /* deassert soft reset */ ··· 141 146 return 0; 142 147 } 143 148 144 - static int set_input(struct i2c_client *client, int audio_input) 149 + void cx25840_audio_set_path(struct i2c_client *client) 145 150 { 146 151 struct cx25840_state *state = i2c_get_clientdata(client); 147 - 148 - cx25840_dbg("set audio input (%d)\n", audio_input); 149 152 150 153 /* stop microcontroller */ 151 154 cx25840_and_or(client, 0x803, ~0x10, 0); ··· 151 158 /* Mute everything to prevent the PFFT! */ 152 159 cx25840_write(client, 0x8d3, 0x1f); 153 160 154 - switch (audio_input) { 155 - case AUDIO_TUNER: 156 - /* Set Path1 to Analog Demod Main Channel */ 157 - cx25840_write4(client, 0x8d0, 0x7038061f); 158 - 159 - /* When the microcontroller detects the 160 - * audio format, it will unmute the lines */ 161 - cx25840_and_or(client, 0x803, ~0x10, 0x10); 162 - break; 163 - 164 - case AUDIO_EXTERN_1: 165 - case AUDIO_EXTERN_2: 166 - case AUDIO_INTERN: 167 - case AUDIO_RADIO: 161 + if (state->aud_input == CX25840_AUDIO_SERIAL) { 168 162 /* Set Path1 to Serial Audio Input */ 169 163 cx25840_write4(client, 0x8d0, 0x12100101); 170 164 171 165 /* The microcontroller should not be started for the 172 166 * non-tuner inputs: autodetection is specific for 173 167 * TV audio. */ 174 - break; 168 + } else { 169 + /* Set Path1 to Analog Demod Main Channel */ 170 + cx25840_write4(client, 0x8d0, 0x7038061f); 175 171 176 - default: 177 - cx25840_dbg("Invalid audio input selection %d\n", audio_input); 178 - return -EINVAL; 172 + /* When the microcontroller detects the 173 + * audio format, it will unmute the lines */ 174 + cx25840_and_or(client, 0x803, ~0x10, 0x10); 179 175 } 180 176 181 - state->audio_input = audio_input; 182 - 183 - return set_audclk_freq(client, state->audclk_freq); 177 + set_audclk_freq(client, state->audclk_freq); 184 178 } 185 179 186 - inline static int get_volume(struct i2c_client *client) 180 + static int get_volume(struct i2c_client *client) 187 181 { 188 182 /* Volume runs +18dB to -96dB in 1/2dB steps 189 183 * change to fit the msp3400 -114dB to +12dB range */ ··· 181 201 return vol << 9; 182 202 } 183 203 184 - inline static void set_volume(struct i2c_client *client, int volume) 204 + static void set_volume(struct i2c_client *client, int volume) 185 205 { 186 206 /* First convert the volume to msp3400 values (0-127) */ 187 207 int vol = volume >> 9; ··· 198 218 cx25840_write(client, 0x8d4, 228 - (vol * 2)); 199 219 } 200 220 201 - inline static int get_bass(struct i2c_client *client) 221 + static int get_bass(struct i2c_client *client) 202 222 { 203 223 /* bass is 49 steps +12dB to -12dB */ 204 224 ··· 208 228 return bass; 209 229 } 210 230 211 - inline static void set_bass(struct i2c_client *client, int bass) 231 + static void set_bass(struct i2c_client *client, int bass) 212 232 { 213 233 /* PATH1_EQ_BASS_VOL */ 214 234 cx25840_and_or(client, 0x8d9, ~0x3f, 48 - (bass * 48 / 0xffff)); 215 235 } 216 236 217 - inline static int get_treble(struct i2c_client *client) 237 + static int get_treble(struct i2c_client *client) 218 238 { 219 239 /* treble is 49 steps +12dB to -12dB */ 220 240 ··· 224 244 return treble; 225 245 } 226 246 227 - inline static void set_treble(struct i2c_client *client, int treble) 247 + static void set_treble(struct i2c_client *client, int treble) 228 248 { 229 249 /* PATH1_EQ_TREBLE_VOL */ 230 250 cx25840_and_or(client, 0x8db, ~0x3f, 48 - (treble * 48 / 0xffff)); 231 251 } 232 252 233 - inline static int get_balance(struct i2c_client *client) 253 + static int get_balance(struct i2c_client *client) 234 254 { 235 255 /* balance is 7 bit, 0 to -96dB */ 236 256 ··· 244 264 return balance << 8; 245 265 } 246 266 247 - inline static void set_balance(struct i2c_client *client, int balance) 267 + static void set_balance(struct i2c_client *client, int balance) 248 268 { 249 269 int bal = balance >> 8; 250 270 if (bal > 0x80) { ··· 260 280 } 261 281 } 262 282 263 - inline static int get_mute(struct i2c_client *client) 283 + static int get_mute(struct i2c_client *client) 264 284 { 265 285 /* check SRC1_MUTE_EN */ 266 286 return cx25840_read(client, 0x8d3) & 0x2 ? 1 : 0; 267 287 } 268 288 269 - inline static void set_mute(struct i2c_client *client, int mute) 289 + static void set_mute(struct i2c_client *client, int mute) 270 290 { 271 291 struct cx25840_state *state = i2c_get_clientdata(client); 272 292 273 - if (state->audio_input == AUDIO_TUNER) { 293 + if (state->aud_input != CX25840_AUDIO_SERIAL) { 274 294 /* Must turn off microcontroller in order to mute sound. 275 295 * Not sure if this is the best method, but it does work. 276 296 * If the microcontroller is running, then it will undo any ··· 294 314 struct v4l2_control *ctrl = arg; 295 315 296 316 switch (cmd) { 297 - case AUDC_SET_INPUT: 298 - return set_input(client, *(int *)arg); 299 317 case VIDIOC_INT_AUDIO_CLOCK_FREQ: 300 - return set_audclk_freq(client, *(enum v4l2_audio_clock_freq *)arg); 318 + return set_audclk_freq(client, *(u32 *)arg); 319 + 301 320 case VIDIOC_G_CTRL: 302 321 switch (ctrl->id) { 303 322 case V4L2_CID_AUDIO_VOLUME: ··· 318 339 return -EINVAL; 319 340 } 320 341 break; 342 + 321 343 case VIDIOC_S_CTRL: 322 344 switch (ctrl->id) { 323 345 case V4L2_CID_AUDIO_VOLUME: ··· 340 360 return -EINVAL; 341 361 } 342 362 break; 363 + 343 364 default: 344 365 return -EINVAL; 345 366 }
+239 -149
drivers/media/video/cx25840/cx25840-core.c
··· 43 43 static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; 44 44 45 45 46 - int cx25840_debug = 0; 46 + int debug = 0; 47 47 48 - module_param(cx25840_debug, bool, 0644); 48 + module_param(debug, bool, 0644); 49 49 50 - MODULE_PARM_DESC(cx25840_debug, "Debugging messages [0=Off (default) 1=On]"); 50 + MODULE_PARM_DESC(debug, "Debugging messages [0=Off (default) 1=On]"); 51 51 52 52 I2C_CLIENT_INSMOD; 53 53 ··· 115 115 116 116 /* ----------------------------------------------------------------------- */ 117 117 118 - static int set_input(struct i2c_client *, enum cx25840_input); 119 - static void input_change(struct i2c_client *); 118 + static int set_input(struct i2c_client *client, enum cx25840_video_input vid_input, 119 + enum cx25840_audio_input aud_input); 120 120 static void log_status(struct i2c_client *client); 121 121 122 122 /* ----------------------------------------------------------------------- */ 123 123 124 - static inline void init_dll1(struct i2c_client *client) 124 + static void init_dll1(struct i2c_client *client) 125 125 { 126 126 /* This is the Hauppauge sequence used to 127 127 * initialize the Delay Lock Loop 1 (ADC DLL). */ ··· 135 135 cx25840_write(client, 0x15b, 0x10); 136 136 } 137 137 138 - static inline void init_dll2(struct i2c_client *client) 138 + static void init_dll2(struct i2c_client *client) 139 139 { 140 140 /* This is the Hauppauge sequence used to 141 141 * initialize the Delay Lock Loop 2 (ADC DLL). */ ··· 195 195 /* AC97 shift */ 196 196 cx25840_write(client, 0x8cf, 0x0f); 197 197 198 - /* (re)set video input */ 199 - set_input(client, state->input); 200 - /* (re)set audio input */ 201 - cx25840_audio(client, AUDC_SET_INPUT, &state->audio_input); 198 + /* (re)set input */ 199 + set_input(client, state->vid_input, state->aud_input); 202 200 203 201 /* start microcontroller */ 204 202 cx25840_and_or(client, 0x803, ~0x10, 0x10); ··· 221 223 cx25840_write(client, 0x80b, 0x10); 222 224 } else if (std & V4L2_STD_NTSC) { 223 225 /* NTSC */ 224 - if (state->cardtype == CARDTYPE_PVR150_WORKAROUND) { 226 + if (state->pvr150_workaround) { 225 227 /* Certain Hauppauge PVR150 models have a hardware bug 226 228 that causes audio to drop out. For these models the 227 229 audio standard must be set explicitly. ··· 257 259 } 258 260 } 259 261 260 - static int set_input(struct i2c_client *client, enum cx25840_input input) 262 + static int set_input(struct i2c_client *client, enum cx25840_video_input vid_input, 263 + enum cx25840_audio_input aud_input) 261 264 { 262 265 struct cx25840_state *state = i2c_get_clientdata(client); 266 + u8 is_composite = (vid_input >= CX25840_COMPOSITE1 && 267 + vid_input <= CX25840_COMPOSITE8); 268 + u8 reg; 263 269 264 - cx25840_dbg("decoder set input (%d)\n", input); 270 + v4l_dbg(1, client, "decoder set video input %d, audio input %d\n", 271 + vid_input, aud_input); 265 272 266 - switch (input) { 267 - case CX25840_TUNER: 268 - cx25840_dbg("now setting Tuner input\n"); 273 + if (is_composite) { 274 + reg = 0xf0 + (vid_input - CX25840_COMPOSITE1); 275 + } else { 276 + int luma = vid_input & 0xf0; 277 + int chroma = vid_input & 0xf00; 269 278 270 - if (state->cardtype == CARDTYPE_PVR150 || 271 - state->cardtype == CARDTYPE_PVR150_WORKAROUND) { 272 - /* CH_SEL_ADC2=1 */ 273 - cx25840_and_or(client, 0x102, ~0x2, 0x02); 279 + if ((vid_input & ~0xff0) || 280 + luma < CX25840_SVIDEO_LUMA1 || luma > CX25840_SVIDEO_LUMA4 || 281 + chroma < CX25840_SVIDEO_CHROMA4 || chroma > CX25840_SVIDEO_CHROMA8) { 282 + v4l_err(client, "0x%04x is not a valid video input!\n", vid_input); 283 + return -EINVAL; 274 284 } 275 - 276 - /* Video Input Control */ 277 - if (state->cardtype == CARDTYPE_PG600) { 278 - cx25840_write(client, 0x103, 0x11); 285 + reg = 0xf0 + ((luma - CX25840_SVIDEO_LUMA1) >> 4); 286 + if (chroma >= CX25840_SVIDEO_CHROMA7) { 287 + reg &= 0x3f; 288 + reg |= (chroma - CX25840_SVIDEO_CHROMA7) >> 2; 279 289 } else { 280 - cx25840_write(client, 0x103, 0x46); 290 + reg &= 0xcf; 291 + reg |= (chroma - CX25840_SVIDEO_CHROMA4) >> 4; 281 292 } 293 + } 282 294 283 - /* INPUT_MODE=0 */ 284 - cx25840_and_or(client, 0x401, ~0x6, 0x00); 295 + switch (aud_input) { 296 + case CX25840_AUDIO_SERIAL: 297 + /* do nothing, use serial audio input */ 285 298 break; 286 - 287 - case CX25840_COMPOSITE0: 288 - case CX25840_COMPOSITE1: 289 - cx25840_dbg("now setting Composite input\n"); 290 - 291 - /* Video Input Control */ 292 - if (state->cardtype == CARDTYPE_PG600) { 293 - cx25840_write(client, 0x103, 0x00); 294 - } else { 295 - cx25840_write(client, 0x103, 0x02); 296 - } 297 - 298 - /* INPUT_MODE=0 */ 299 - cx25840_and_or(client, 0x401, ~0x6, 0x00); 300 - break; 301 - 302 - case CX25840_SVIDEO0: 303 - case CX25840_SVIDEO1: 304 - cx25840_dbg("now setting S-Video input\n"); 305 - 306 - /* CH_SEL_ADC2=0 */ 307 - cx25840_and_or(client, 0x102, ~0x2, 0x00); 308 - 309 - /* Video Input Control */ 310 - if (state->cardtype == CARDTYPE_PG600) { 311 - cx25840_write(client, 0x103, 0x02); 312 - } else { 313 - cx25840_write(client, 0x103, 0x10); 314 - } 315 - 316 - /* INPUT_MODE=1 */ 317 - cx25840_and_or(client, 0x401, ~0x6, 0x02); 318 - break; 299 + case CX25840_AUDIO4: reg &= ~0x30; break; 300 + case CX25840_AUDIO5: reg &= ~0x30; reg |= 0x10; break; 301 + case CX25840_AUDIO6: reg &= ~0x30; reg |= 0x20; break; 302 + case CX25840_AUDIO7: reg &= ~0xc0; break; 303 + case CX25840_AUDIO8: reg &= ~0xc0; reg |= 0x40; break; 319 304 320 305 default: 321 - cx25840_err("%d is not a valid input!\n", input); 306 + v4l_err(client, "0x%04x is not a valid audio input!\n", aud_input); 322 307 return -EINVAL; 323 308 } 324 309 325 - state->input = input; 310 + cx25840_write(client, 0x103, reg); 311 + /* Set INPUT_MODE to Composite (0) or S-Video (1) */ 312 + cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02); 313 + /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */ 314 + cx25840_and_or(client, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0); 315 + /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2 and CH3 */ 316 + if ((reg & 0xc0) != 0xc0 && (reg & 0x30) != 0x30) 317 + cx25840_and_or(client, 0x102, ~0x4, 4); 318 + else 319 + cx25840_and_or(client, 0x102, ~0x4, 0); 320 + 321 + state->vid_input = vid_input; 322 + state->aud_input = aud_input; 323 + cx25840_audio_set_path(client); 326 324 input_change(client); 327 325 return 0; 328 326 } ··· 389 395 struct cx25840_state *state = i2c_get_clientdata(client); 390 396 391 397 switch (ctrl->id) { 392 - case CX25840_CID_CARDTYPE: 393 - switch (ctrl->value) { 394 - case CARDTYPE_PVR150: 395 - case CARDTYPE_PVR150_WORKAROUND: 396 - case CARDTYPE_PG600: 397 - state->cardtype = ctrl->value; 398 - break; 399 - default: 400 - return -ERANGE; 401 - } 402 - 403 - set_input(client, state->input); 398 + case CX25840_CID_ENABLE_PVR150_WORKAROUND: 399 + state->pvr150_workaround = ctrl->value; 400 + set_input(client, state->vid_input, state->aud_input); 404 401 break; 405 402 406 403 case V4L2_CID_BRIGHTNESS: 407 404 if (ctrl->value < 0 || ctrl->value > 255) { 408 - cx25840_err("invalid brightness setting %d\n", 405 + v4l_err(client, "invalid brightness setting %d\n", 409 406 ctrl->value); 410 407 return -ERANGE; 411 408 } ··· 406 421 407 422 case V4L2_CID_CONTRAST: 408 423 if (ctrl->value < 0 || ctrl->value > 127) { 409 - cx25840_err("invalid contrast setting %d\n", 424 + v4l_err(client, "invalid contrast setting %d\n", 410 425 ctrl->value); 411 426 return -ERANGE; 412 427 } ··· 416 431 417 432 case V4L2_CID_SATURATION: 418 433 if (ctrl->value < 0 || ctrl->value > 127) { 419 - cx25840_err("invalid saturation setting %d\n", 434 + v4l_err(client, "invalid saturation setting %d\n", 420 435 ctrl->value); 421 436 return -ERANGE; 422 437 } ··· 427 442 428 443 case V4L2_CID_HUE: 429 444 if (ctrl->value < -127 || ctrl->value > 127) { 430 - cx25840_err("invalid hue setting %d\n", ctrl->value); 445 + v4l_err(client, "invalid hue setting %d\n", ctrl->value); 431 446 return -ERANGE; 432 447 } 433 448 ··· 440 455 case V4L2_CID_AUDIO_BALANCE: 441 456 case V4L2_CID_AUDIO_MUTE: 442 457 return cx25840_audio(client, VIDIOC_S_CTRL, ctrl); 458 + 459 + default: 460 + return -EINVAL; 443 461 } 444 462 445 463 return 0; ··· 453 465 struct cx25840_state *state = i2c_get_clientdata(client); 454 466 455 467 switch (ctrl->id) { 456 - case CX25840_CID_CARDTYPE: 457 - ctrl->value = state->cardtype; 468 + case CX25840_CID_ENABLE_PVR150_WORKAROUND: 469 + ctrl->value = state->pvr150_workaround; 458 470 break; 459 471 case V4L2_CID_BRIGHTNESS: 460 - ctrl->value = cx25840_read(client, 0x414) + 128; 472 + ctrl->value = (s8)cx25840_read(client, 0x414) + 128; 461 473 break; 462 474 case V4L2_CID_CONTRAST: 463 475 ctrl->value = cx25840_read(client, 0x415) >> 1; ··· 466 478 ctrl->value = cx25840_read(client, 0x420) >> 1; 467 479 break; 468 480 case V4L2_CID_HUE: 469 - ctrl->value = cx25840_read(client, 0x422); 481 + ctrl->value = (s8)cx25840_read(client, 0x422); 470 482 break; 471 483 case V4L2_CID_AUDIO_VOLUME: 472 484 case V4L2_CID_AUDIO_BASS: ··· 515 527 516 528 if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) || 517 529 (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) { 518 - cx25840_err("%dx%d is not a valid size!\n", 530 + v4l_err(client, "%dx%d is not a valid size!\n", 519 531 pix->width, pix->height); 520 532 return -ERANGE; 521 533 } ··· 533 545 else 534 546 filter = 3; 535 547 536 - cx25840_dbg("decoder set size %dx%d -> scale %ux%u\n", 548 + v4l_dbg(1, client, "decoder set size %dx%d -> scale %ux%u\n", 537 549 pix->width, pix->height, HSC, VSC); 538 550 539 551 /* HSCALE=HSC */ ··· 562 574 563 575 /* ----------------------------------------------------------------------- */ 564 576 577 + static struct v4l2_queryctrl cx25840_qctrl[] = { 578 + { 579 + .id = V4L2_CID_BRIGHTNESS, 580 + .type = V4L2_CTRL_TYPE_INTEGER, 581 + .name = "Brightness", 582 + .minimum = 0, 583 + .maximum = 255, 584 + .step = 1, 585 + .default_value = 128, 586 + .flags = 0, 587 + }, { 588 + .id = V4L2_CID_CONTRAST, 589 + .type = V4L2_CTRL_TYPE_INTEGER, 590 + .name = "Contrast", 591 + .minimum = 0, 592 + .maximum = 255, 593 + .step = 1, 594 + .default_value = 64, 595 + .flags = 0, 596 + }, { 597 + .id = V4L2_CID_SATURATION, 598 + .type = V4L2_CTRL_TYPE_INTEGER, 599 + .name = "Saturation", 600 + .minimum = 0, 601 + .maximum = 255, 602 + .step = 1, 603 + .default_value = 64, 604 + .flags = 0, 605 + }, { 606 + .id = V4L2_CID_HUE, 607 + .type = V4L2_CTRL_TYPE_INTEGER, 608 + .name = "Hue", 609 + .minimum = -128, 610 + .maximum = 127, 611 + .step = 1, 612 + .default_value = 0, 613 + .flags = 0, 614 + }, { 615 + .id = V4L2_CID_AUDIO_VOLUME, 616 + .type = V4L2_CTRL_TYPE_INTEGER, 617 + .name = "Volume", 618 + .minimum = 0, 619 + .maximum = 65535, 620 + .step = 65535/100, 621 + .default_value = 58880, 622 + .flags = 0, 623 + }, { 624 + .id = V4L2_CID_AUDIO_BALANCE, 625 + .type = V4L2_CTRL_TYPE_INTEGER, 626 + .name = "Balance", 627 + .minimum = 0, 628 + .maximum = 65535, 629 + .step = 65535/100, 630 + .default_value = 32768, 631 + .flags = 0, 632 + }, { 633 + .id = V4L2_CID_AUDIO_MUTE, 634 + .type = V4L2_CTRL_TYPE_BOOLEAN, 635 + .name = "Mute", 636 + .minimum = 0, 637 + .maximum = 1, 638 + .step = 1, 639 + .default_value = 1, 640 + .flags = 0, 641 + }, { 642 + .id = V4L2_CID_AUDIO_BASS, 643 + .type = V4L2_CTRL_TYPE_INTEGER, 644 + .name = "Bass", 645 + .minimum = 0, 646 + .maximum = 65535, 647 + .step = 65535/100, 648 + .default_value = 32768, 649 + }, { 650 + .id = V4L2_CID_AUDIO_TREBLE, 651 + .type = V4L2_CTRL_TYPE_INTEGER, 652 + .name = "Treble", 653 + .minimum = 0, 654 + .maximum = 65535, 655 + .step = 65535/100, 656 + .default_value = 32768, 657 + }, 658 + }; 659 + 660 + /* ----------------------------------------------------------------------- */ 661 + 565 662 static int cx25840_command(struct i2c_client *client, unsigned int cmd, 566 663 void *arg) 567 664 { 568 665 struct cx25840_state *state = i2c_get_clientdata(client); 569 666 struct v4l2_tuner *vt = arg; 570 - int result = 0; 571 667 572 668 switch (cmd) { 573 - case 0: 574 - break; 575 - 576 669 #ifdef CONFIG_VIDEO_ADV_DEBUG 577 670 /* ioctls to allow direct access to the 578 671 * cx25840 registers for testing */ ··· 684 615 return cx25840_vbi(client, cmd, arg); 685 616 686 617 case VIDIOC_INT_AUDIO_CLOCK_FREQ: 687 - case AUDC_SET_INPUT: 688 - result = cx25840_audio(client, cmd, arg); 689 - break; 618 + return cx25840_audio(client, cmd, arg); 690 619 691 620 case VIDIOC_STREAMON: 692 - cx25840_dbg("enable output\n"); 621 + v4l_dbg(1, client, "enable output\n"); 693 622 cx25840_write(client, 0x115, 0x8c); 694 623 cx25840_write(client, 0x116, 0x07); 695 624 break; 696 625 697 626 case VIDIOC_STREAMOFF: 698 - cx25840_dbg("disable output\n"); 627 + v4l_dbg(1, client, "disable output\n"); 699 628 cx25840_write(client, 0x115, 0x00); 700 629 cx25840_write(client, 0x116, 0x00); 701 630 break; ··· 703 636 break; 704 637 705 638 case VIDIOC_G_CTRL: 706 - result = get_v4lctrl(client, (struct v4l2_control *)arg); 707 - break; 639 + return get_v4lctrl(client, (struct v4l2_control *)arg); 708 640 709 641 case VIDIOC_S_CTRL: 710 - result = set_v4lctrl(client, (struct v4l2_control *)arg); 711 - break; 642 + return set_v4lctrl(client, (struct v4l2_control *)arg); 643 + 644 + case VIDIOC_QUERYCTRL: 645 + { 646 + struct v4l2_queryctrl *qc = arg; 647 + int i; 648 + 649 + for (i = 0; i < ARRAY_SIZE(cx25840_qctrl); i++) 650 + if (qc->id && qc->id == cx25840_qctrl[i].id) { 651 + memcpy(qc, &cx25840_qctrl[i], sizeof(*qc)); 652 + return 0; 653 + } 654 + return -EINVAL; 655 + } 712 656 713 657 case VIDIOC_G_STD: 714 658 *(v4l2_std_id *)arg = cx25840_get_v4lstd(client); 715 659 break; 716 660 717 661 case VIDIOC_S_STD: 718 - result = set_v4lstd(client, *(v4l2_std_id *)arg); 662 + state->radio = 0; 663 + return set_v4lstd(client, *(v4l2_std_id *)arg); 664 + 665 + case AUDC_SET_RADIO: 666 + state->radio = 1; 719 667 break; 720 668 721 669 case VIDIOC_G_INPUT: 722 - *(int *)arg = state->input; 670 + *(int *)arg = state->vid_input; 723 671 break; 724 672 725 673 case VIDIOC_S_INPUT: 726 - result = set_input(client, *(int *)arg); 674 + return set_input(client, *(enum cx25840_video_input *)arg, state->aud_input); 675 + 676 + case VIDIOC_S_AUDIO: 677 + { 678 + struct v4l2_audio *input = arg; 679 + 680 + return set_input(client, state->vid_input, input->index); 681 + } 682 + 683 + case VIDIOC_G_AUDIO: 684 + { 685 + struct v4l2_audio *input = arg; 686 + 687 + memset(input, 0, sizeof(*input)); 688 + input->index = state->aud_input; 727 689 break; 690 + } 728 691 729 692 case VIDIOC_S_FREQUENCY: 730 693 input_change(client); ··· 766 669 u8 pref = cx25840_read(client, 0x809) & 0xf; 767 670 u8 vpres = cx25840_read(client, 0x80a) & 0x10; 768 671 int val = 0; 672 + 673 + if (state->radio) 674 + break; 769 675 770 676 vt->capability |= 771 677 V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 | ··· 824 724 break; 825 725 826 726 case VIDIOC_G_FMT: 827 - result = get_v4lfmt(client, (struct v4l2_format *)arg); 828 - break; 727 + return get_v4lfmt(client, (struct v4l2_format *)arg); 829 728 830 729 case VIDIOC_S_FMT: 831 - result = set_v4lfmt(client, (struct v4l2_format *)arg); 832 - break; 730 + return set_v4lfmt(client, (struct v4l2_format *)arg); 833 731 834 732 case VIDIOC_INT_RESET: 835 733 cx25840_initialize(client, 0); ··· 839 741 break; 840 742 841 743 default: 842 - cx25840_err("invalid ioctl %x\n", cmd); 843 744 return -EINVAL; 844 745 } 845 746 846 - return result; 747 + return 0; 847 748 } 848 749 849 750 /* ----------------------------------------------------------------------- */ ··· 872 775 client->driver = &i2c_driver_cx25840; 873 776 snprintf(client->name, sizeof(client->name) - 1, "cx25840"); 874 777 875 - cx25840_dbg("detecting cx25840 client on address 0x%x\n", address << 1); 778 + v4l_dbg(1, client, "detecting cx25840 client on address 0x%x\n", address << 1); 876 779 877 780 device_id = cx25840_read(client, 0x101) << 8; 878 781 device_id |= cx25840_read(client, 0x100); ··· 880 783 /* The high byte of the device ID should be 881 784 * 0x84 if chip is present */ 882 785 if ((device_id & 0xff00) != 0x8400) { 883 - cx25840_dbg("cx25840 not found\n"); 786 + v4l_dbg(1, client, "cx25840 not found\n"); 884 787 kfree(client); 885 788 return 0; 886 789 } 887 790 888 - cx25840_info("cx25%3x-2%x found @ 0x%x (%s)\n", 791 + v4l_info(client, "cx25%3x-2%x found @ 0x%x (%s)\n", 889 792 (device_id & 0xfff0) >> 4, 890 793 (device_id & 0x0f) < 3 ? (device_id & 0x0f) + 1 : 3, 891 794 address << 1, adapter->name); ··· 898 801 899 802 i2c_set_clientdata(client, state); 900 803 memset(state, 0, sizeof(struct cx25840_state)); 901 - state->input = CX25840_TUNER; 902 - state->audclk_freq = V4L2_AUDCLK_48_KHZ; 903 - state->audio_input = AUDIO_TUNER; 904 - state->cardtype = CARDTYPE_PVR150; 804 + state->vid_input = CX25840_COMPOSITE7; 805 + state->aud_input = CX25840_AUDIO8; 806 + state->audclk_freq = 48000; 807 + state->pvr150_workaround = 0; 905 808 906 809 cx25840_initialize(client, 1); 907 810 ··· 912 815 913 816 static int cx25840_attach_adapter(struct i2c_adapter *adapter) 914 817 { 915 - #ifdef I2C_CLASS_TV_ANALOG 916 818 if (adapter->class & I2C_CLASS_TV_ANALOG) 917 - #else 918 - if (adapter->id == I2C_HW_B_BT848) 919 - #endif 920 819 return i2c_probe(adapter, &addr_data, &cx25840_detect_client); 921 820 return 0; 922 821 } ··· 939 846 .driver = { 940 847 .name = "cx25840", 941 848 }, 942 - 943 849 .id = I2C_DRIVERID_CX25840, 944 - 945 850 .attach_adapter = cx25840_attach_adapter, 946 851 .detach_client = cx25840_detach_client, 947 852 .command = cx25840_command, ··· 983 892 u8 pref_mode = cx25840_read(client, 0x809); 984 893 u8 afc0 = cx25840_read(client, 0x80b); 985 894 u8 mute_ctl = cx25840_read(client, 0x8d3); 895 + int vid_input = state->vid_input; 896 + int aud_input = state->aud_input; 986 897 char *p; 987 898 988 - cx25840_info("Video signal: %spresent\n", 899 + v4l_info(client, "Video signal: %spresent\n", 989 900 (microctrl_vidfmt & 0x10) ? "" : "not "); 990 - cx25840_info("Detected format: %s\n", 901 + v4l_info(client, "Detected format: %s\n", 991 902 fmt_strs[gen_stat1 & 0xf]); 992 903 993 904 switch (mod_det_stat0) { ··· 1004 911 case 0xfe: p = "forced mode"; break; 1005 912 default: p = "not defined"; 1006 913 } 1007 - cx25840_info("Detected audio mode: %s\n", p); 914 + v4l_info(client, "Detected audio mode: %s\n", p); 1008 915 1009 916 switch (mod_det_stat1) { 1010 917 case 0x00: p = "not defined"; break; ··· 1030 937 case 0xff: p = "no detected audio standard"; break; 1031 938 default: p = "not defined"; 1032 939 } 1033 - cx25840_info("Detected audio standard: %s\n", p); 1034 - cx25840_info("Audio muted: %s\n", 940 + v4l_info(client, "Detected audio standard: %s\n", p); 941 + v4l_info(client, "Audio muted: %s\n", 1035 942 (mute_ctl & 0x2) ? "yes" : "no"); 1036 - cx25840_info("Audio microcontroller: %s\n", 943 + v4l_info(client, "Audio microcontroller: %s\n", 1037 944 (download_ctl & 0x10) ? "running" : "stopped"); 1038 945 1039 946 switch (audio_config >> 4) { ··· 1055 962 case 0x0f: p = "automatic detection"; break; 1056 963 default: p = "undefined"; 1057 964 } 1058 - cx25840_info("Configured audio standard: %s\n", p); 965 + v4l_info(client, "Configured audio standard: %s\n", p); 1059 966 1060 967 if ((audio_config >> 4) < 0xF) { 1061 968 switch (audio_config & 0xF) { ··· 1072 979 case 0x0a: p = "SAP"; break; 1073 980 default: p = "undefined"; 1074 981 } 1075 - cx25840_info("Configured audio mode: %s\n", p); 982 + v4l_info(client, "Configured audio mode: %s\n", p); 1076 983 } else { 1077 984 switch (audio_config & 0xF) { 1078 985 case 0x00: p = "BG"; break; ··· 1088 995 case 0x0f: p = "automatic standard and mode detection"; break; 1089 996 default: p = "undefined"; 1090 997 } 1091 - cx25840_info("Configured audio system: %s\n", p); 998 + v4l_info(client, "Configured audio system: %s\n", p); 1092 999 } 1093 1000 1094 - cx25840_info("Specified standard: %s\n", 1001 + v4l_info(client, "Specified standard: %s\n", 1095 1002 vidfmt_sel ? fmt_strs[vidfmt_sel] : "automatic detection"); 1096 1003 1097 - switch (state->input) { 1098 - case CX25840_COMPOSITE0: p = "Composite 0"; break; 1099 - case CX25840_COMPOSITE1: p = "Composite 1"; break; 1100 - case CX25840_SVIDEO0: p = "S-Video 0"; break; 1101 - case CX25840_SVIDEO1: p = "S-Video 1"; break; 1102 - case CX25840_TUNER: p = "Tuner"; break; 1004 + if (vid_input >= CX25840_COMPOSITE1 && 1005 + vid_input <= CX25840_COMPOSITE8) { 1006 + v4l_info(client, "Specified video input: Composite %d\n", 1007 + vid_input - CX25840_COMPOSITE1 + 1); 1008 + } else { 1009 + v4l_info(client, "Specified video input: S-Video (Luma In%d, Chroma In%d)\n", 1010 + (vid_input & 0xf0) >> 4, (vid_input & 0xf00) >> 8); 1103 1011 } 1104 - cx25840_info("Specified input: %s\n", p); 1105 - cx25840_info("Specified audio input: %s\n", 1106 - state->audio_input == 0 ? "Tuner" : "External"); 1012 + if (aud_input) { 1013 + v4l_info(client, "Specified audio input: Tuner (In%d)\n", aud_input); 1014 + } else { 1015 + v4l_info(client, "Specified audio input: External\n"); 1016 + } 1107 1017 1108 - switch (state->audclk_freq) { 1109 - case V4L2_AUDCLK_441_KHZ: p = "44.1 kHz"; break; 1110 - case V4L2_AUDCLK_48_KHZ: p = "48 kHz"; break; 1111 - case V4L2_AUDCLK_32_KHZ: p = "32 kHz"; break; 1112 - default: p = "undefined"; 1113 - } 1114 - cx25840_info("Specified audioclock freq: %s\n", p); 1018 + v4l_info(client, "Specified audioclock freq: %d Hz\n", state->audclk_freq); 1115 1019 1116 1020 switch (pref_mode & 0xf) { 1117 1021 case 0: p = "mono/language A"; break; ··· 1121 1031 case 7: p = "language AB"; break; 1122 1032 default: p = "undefined"; 1123 1033 } 1124 - cx25840_info("Preferred audio mode: %s\n", p); 1034 + v4l_info(client, "Preferred audio mode: %s\n", p); 1125 1035 1126 1036 if ((audio_config & 0xf) == 0xf) { 1127 1037 switch ((afc0 >> 3) & 0x3) { ··· 1130 1040 case 2: p = "autodetect"; break; 1131 1041 default: p = "undefined"; 1132 1042 } 1133 - cx25840_info("Selected 65 MHz format: %s\n", p); 1043 + v4l_info(client, "Selected 65 MHz format: %s\n", p); 1134 1044 1135 1045 switch (afc0 & 0x7) { 1136 1046 case 0: p = "chroma"; break; ··· 1140 1050 case 4: p = "autodetect"; break; 1141 1051 default: p = "undefined"; 1142 1052 } 1143 - cx25840_info("Selected 45 MHz format: %s\n", p); 1053 + v4l_info(client, "Selected 45 MHz format: %s\n", p); 1144 1054 } 1145 1055 }
+22 -14
drivers/media/video/cx25840/cx25840-firmware.c
··· 15 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 16 */ 17 17 18 - 19 18 #include <linux/module.h> 20 19 #include <linux/i2c.h> 21 20 #include <linux/i2c-algo-bit.h> ··· 37 38 MODULE_PARM_DESC(fastfw, "Load firmware fast [0=100MHz 1=333MHz (default)]"); 38 39 MODULE_PARM_DESC(firmware, "Firmware image [default: " FWFILE "]"); 39 40 40 - static inline void set_i2c_delay(struct i2c_client *client, int delay) 41 + static void set_i2c_delay(struct i2c_client *client, int delay) 41 42 { 42 43 struct i2c_algo_bit_data *algod = client->adapter->algo_data; 43 44 ··· 51 52 } 52 53 } 53 54 54 - static inline void start_fw_load(struct i2c_client *client) 55 + static void start_fw_load(struct i2c_client *client) 55 56 { 56 57 /* DL_ADDR_LB=0 DL_ADDR_HB=0 */ 57 58 cx25840_write(client, 0x800, 0x00); ··· 65 66 set_i2c_delay(client, 3); 66 67 } 67 68 68 - static inline void end_fw_load(struct i2c_client *client) 69 + static void end_fw_load(struct i2c_client *client) 69 70 { 70 71 if (fastfw) 71 72 set_i2c_delay(client, 10); ··· 76 77 cx25840_write(client, 0x803, 0x03); 77 78 } 78 79 79 - static inline int check_fw_load(struct i2c_client *client, int size) 80 + static int check_fw_load(struct i2c_client *client, int size) 80 81 { 81 82 /* DL_ADDR_HB DL_ADDR_LB */ 82 83 int s = cx25840_read(client, 0x801) << 8; 83 84 s |= cx25840_read(client, 0x800); 84 85 85 86 if (size != s) { 86 - cx25840_err("firmware %s load failed\n", firmware); 87 + v4l_err(client, "firmware %s load failed\n", firmware); 87 88 return -EINVAL; 88 89 } 89 90 90 - cx25840_info("loaded %s firmware (%d bytes)\n", firmware, size); 91 + v4l_info(client, "loaded %s firmware (%d bytes)\n", firmware, size); 91 92 return 0; 92 93 } 93 94 94 - static inline int fw_write(struct i2c_client *client, u8 * data, int size) 95 + static int fw_write(struct i2c_client *client, u8 * data, int size) 95 96 { 96 - if (i2c_master_send(client, data, size) < size) { 97 + int sent; 98 + 99 + if ((sent = i2c_master_send(client, data, size)) < size) { 97 100 98 101 if (fastfw) { 99 - cx25840_err("333MHz i2c firmware load failed\n"); 102 + v4l_err(client, "333MHz i2c firmware load failed\n"); 100 103 fastfw = 0; 101 104 set_i2c_delay(client, 10); 102 105 106 + if (sent > 2) { 107 + u16 dl_addr = cx25840_read(client, 0x801) << 8; 108 + dl_addr |= cx25840_read(client, 0x800); 109 + dl_addr -= sent - 2; 110 + cx25840_write(client, 0x801, dl_addr >> 8); 111 + cx25840_write(client, 0x800, dl_addr & 0xff); 112 + } 113 + 103 114 if (i2c_master_send(client, data, size) < size) { 104 - cx25840_err 105 - ("100MHz i2c firmware load failed\n"); 115 + v4l_err(client, "100MHz i2c firmware load failed\n"); 106 116 return -ENOSYS; 107 117 } 108 118 109 119 } else { 110 - cx25840_err("firmware load i2c failure\n"); 120 + v4l_err(client, "firmware load i2c failure\n"); 111 121 return -ENOSYS; 112 122 } 113 123 ··· 132 124 int size, send, retval; 133 125 134 126 if (request_firmware(&fw, firmware, FWDEV(client)) != 0) { 135 - cx25840_err("unable to open firmware %s\n", firmware); 127 + v4l_err(client, "unable to open firmware %s\n", firmware); 136 128 return -EINVAL; 137 129 } 138 130
+2 -2
drivers/media/video/cx25840/cx25840-vbi.c
··· 22 22 23 23 #include "cx25840.h" 24 24 25 - static inline int odd_parity(u8 c) 25 + static int odd_parity(u8 c) 26 26 { 27 27 c ^= (c >> 4); 28 28 c ^= (c >> 2); ··· 31 31 return c & 1; 32 32 } 33 33 34 - static inline int decode_vps(u8 * dst, u8 * p) 34 + static int decode_vps(u8 * dst, u8 * p) 35 35 { 36 36 static const u8 biphase_tbl[] = { 37 37 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
+47 -34
drivers/media/video/cx25840/cx25840.h
··· 24 24 #include <linux/videodev2.h> 25 25 #include <linux/i2c.h> 26 26 27 - extern int cx25840_debug; 28 - 29 - #define cx25840_dbg(fmt, arg...) do { if (cx25840_debug) \ 30 - printk(KERN_INFO "%s debug %d-%04x: " fmt, \ 31 - client->driver->driver.name, \ 32 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 33 - 34 - #define cx25840_err(fmt, arg...) do { \ 35 - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ 36 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 37 - 38 - #define cx25840_info(fmt, arg...) do { \ 39 - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ 40 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 41 - 42 - #define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0) 43 - 44 - /* The CARDTYPE_PVR150_WORKAROUND cardtype activates a workaround for a 45 - hardware bug that is present in PVR150 (and possible PVR500) cards that 46 - have certain NTSC tuners (tveeprom model numbers 85, 99 and 112). The 27 + /* ENABLE_PVR150_WORKAROUND activates a workaround for a hardware bug that is 28 + present in Hauppauge PVR-150 (and possibly PVR-500) cards that have 29 + certain NTSC tuners (tveeprom tuner model numbers 85, 99 and 112). The 47 30 audio autodetect fails on some channels for these models and the workaround 48 31 is to select the audio standard explicitly. Many thanks to Hauppauge for 49 32 providing this information. */ 50 - enum cx25840_cardtype { 51 - CARDTYPE_PVR150, 52 - CARDTYPE_PG600, 53 - CARDTYPE_PVR150_WORKAROUND, 33 + #define CX25840_CID_ENABLE_PVR150_WORKAROUND (V4L2_CID_PRIVATE_BASE+0) 34 + 35 + enum cx25840_video_input { 36 + /* Composite video inputs In1-In8 */ 37 + CX25840_COMPOSITE1 = 1, 38 + CX25840_COMPOSITE2, 39 + CX25840_COMPOSITE3, 40 + CX25840_COMPOSITE4, 41 + CX25840_COMPOSITE5, 42 + CX25840_COMPOSITE6, 43 + CX25840_COMPOSITE7, 44 + CX25840_COMPOSITE8, 45 + 46 + /* S-Video inputs consist of one luma input (In1-In4) ORed with one 47 + chroma input (In5-In8) */ 48 + CX25840_SVIDEO_LUMA1 = 0x10, 49 + CX25840_SVIDEO_LUMA2 = 0x20, 50 + CX25840_SVIDEO_LUMA3 = 0x30, 51 + CX25840_SVIDEO_LUMA4 = 0x40, 52 + CX25840_SVIDEO_CHROMA4 = 0x400, 53 + CX25840_SVIDEO_CHROMA5 = 0x500, 54 + CX25840_SVIDEO_CHROMA6 = 0x600, 55 + CX25840_SVIDEO_CHROMA7 = 0x700, 56 + CX25840_SVIDEO_CHROMA8 = 0x800, 57 + 58 + /* S-Video aliases for common luma/chroma combinations */ 59 + CX25840_SVIDEO1 = 0x510, 60 + CX25840_SVIDEO2 = 0x620, 61 + CX25840_SVIDEO3 = 0x730, 62 + CX25840_SVIDEO4 = 0x840, 54 63 }; 55 64 56 - enum cx25840_input { 57 - CX25840_TUNER, 58 - CX25840_COMPOSITE0, 59 - CX25840_COMPOSITE1, 60 - CX25840_SVIDEO0, 61 - CX25840_SVIDEO1 65 + enum cx25840_audio_input { 66 + /* Audio inputs: serial or In4-In8 */ 67 + CX25840_AUDIO_SERIAL, 68 + CX25840_AUDIO4 = 4, 69 + CX25840_AUDIO5, 70 + CX25840_AUDIO6, 71 + CX25840_AUDIO7, 72 + CX25840_AUDIO8, 62 73 }; 63 74 64 75 struct cx25840_state { 65 - enum cx25840_cardtype cardtype; 66 - enum cx25840_input input; 67 - int audio_input; 68 - enum v4l2_audio_clock_freq audclk_freq; 76 + int pvr150_workaround; 77 + int radio; 78 + enum cx25840_video_input vid_input; 79 + enum cx25840_audio_input aud_input; 80 + u32 audclk_freq; 69 81 }; 70 82 71 83 /* ----------------------------------------------------------------------- */ ··· 96 84 /* ----------------------------------------------------------------------- */ 97 85 /* cx25850-audio.c */ 98 86 int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg); 87 + void cx25840_audio_set_path(struct i2c_client *client); 99 88 100 89 /* ----------------------------------------------------------------------- */ 101 90 /* cx25850-vbi.c */
+25
drivers/media/video/cx88/Kconfig
··· 29 29 You must also select one or more DVB/ATSC demodulators. 30 30 If you are unsure which you need, choose all of them. 31 31 32 + config VIDEO_CX88_ALSA 33 + tristate "ALSA DMA audio support" 34 + depends on VIDEO_CX88 && SND 35 + select SND_PCM_OSS 36 + ---help--- 37 + This is a video4linux driver for direct (DMA) audio on 38 + Conexant 2388x based TV cards. 39 + It only works with boards with function 01 enabled. 40 + To check if your board supports, use lspci -n. 41 + If supported, you should see 1471:8801 or 1471:8811 42 + PCI device. 43 + 44 + To compile this driver as a module, choose M here: the 45 + module will be called cx88-alsa. 46 + 32 47 config VIDEO_CX88_DVB_ALL_FRONTENDS 33 48 bool "Build all supported frontends for cx2388x based TV cards" 34 49 default y ··· 53 38 select DVB_CX22702 54 39 select DVB_LGDT330X 55 40 select DVB_NXT200X 41 + select DVB_CX24123 56 42 ---help--- 57 43 This builds cx88-dvb with all currently supported frontend 58 44 demodulators. If you wish to tweak your configuration, and ··· 105 89 ---help--- 106 90 This adds ATSC 8VSB and QAM64/256 support for cards based on the 107 91 Connexant 2388x chip and the NXT2002/NXT2004 demodulator. 92 + 93 + config VIDEO_CX88_DVB_CX24123 94 + bool "Conexant CX24123 DVB-S Support" 95 + default y 96 + depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 97 + select DVB_CX24123 98 + ---help--- 99 + This adds DVB-S support for cards based on the 100 + Connexant 2388x chip and the CX24123 demodulator.
+3 -1
drivers/media/video/cx88/Makefile
··· 4 4 cx8802-objs := cx88-mpeg.o 5 5 6 6 obj-$(CONFIG_VIDEO_CX88) += cx88xx.o cx8800.o cx8802.o cx88-blackbird.o 7 - obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o 7 + obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o cx88-vp3054-i2c.o 8 8 9 9 EXTRA_CFLAGS += -I$(src)/.. 10 10 EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core ··· 16 16 extra-cflags-$(CONFIG_DVB_LGDT330X) += -DHAVE_LGDT330X=1 17 17 extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1 18 18 extra-cflags-$(CONFIG_DVB_NXT200X) += -DHAVE_NXT200X=1 19 + extra-cflags-$(CONFIG_DVB_CX24123) += -DHAVE_CX24123=1 20 + extra-cflags-$(CONFIG_VIDEO_CX88_DVB)+= -DHAVE_VP3054_I2C=1 19 21 20 22 EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m)
+848
drivers/media/video/cx88/cx88-alsa.c
··· 1 + /* 2 + * 3 + * Support for audio capture 4 + * PCI function #1 of the cx2388x. 5 + * 6 + * (c) 2005,2006 Ricardo Cerqueira <v4l@cerqueira.org> 7 + * (c) 2005 Mauro Carvalho Chehab <mchehab@brturbo.com.br> 8 + * Based on a dummy cx88 module by Gerd Knorr <kraxel@bytesex.org> 9 + * Based on dummy.c by Jaroslav Kysela <perex@suse.cz> 10 + * 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. 15 + * 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. 20 + * 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. 24 + */ 25 + 26 + #include <linux/module.h> 27 + #include <linux/init.h> 28 + #include <linux/device.h> 29 + #include <linux/interrupt.h> 30 + #include <asm/delay.h> 31 + #include <sound/driver.h> 32 + #include <sound/core.h> 33 + #include <sound/pcm.h> 34 + #include <sound/pcm_params.h> 35 + #include <sound/control.h> 36 + #include <sound/initval.h> 37 + 38 + #include "cx88.h" 39 + #include "cx88-reg.h" 40 + 41 + #define dprintk(level,fmt, arg...) if (debug >= level) \ 42 + printk(KERN_INFO "%s/1: " fmt, chip->core->name , ## arg) 43 + 44 + #define dprintk_core(level,fmt, arg...) if (debug >= level) \ 45 + printk(KERN_DEBUG "%s/1: " fmt, chip->core->name , ## arg) 46 + 47 + 48 + /**************************************************************************** 49 + Data type declarations - Can be moded to a header file later 50 + ****************************************************************************/ 51 + 52 + /* These can be replaced after done */ 53 + #define MIXER_ADDR_LAST MAX_CX88_INPUT 54 + 55 + struct cx88_audio_dev { 56 + struct cx88_core *core; 57 + struct cx88_dmaqueue q; 58 + 59 + /* pci i/o */ 60 + struct pci_dev *pci; 61 + unsigned char pci_rev,pci_lat; 62 + 63 + /* audio controls */ 64 + int irq; 65 + 66 + snd_card_t *card; 67 + 68 + spinlock_t reg_lock; 69 + 70 + unsigned int dma_size; 71 + unsigned int period_size; 72 + unsigned int num_periods; 73 + 74 + struct videobuf_dmabuf dma_risc; 75 + 76 + int mixer_volume[MIXER_ADDR_LAST+1][2]; 77 + int capture_source[MIXER_ADDR_LAST+1][2]; 78 + 79 + long int read_count; 80 + long int read_offset; 81 + 82 + struct cx88_buffer *buf; 83 + 84 + long opened; 85 + snd_pcm_substream_t *substream; 86 + 87 + }; 88 + typedef struct cx88_audio_dev snd_cx88_card_t; 89 + 90 + 91 + 92 + /**************************************************************************** 93 + Module global static vars 94 + ****************************************************************************/ 95 + 96 + static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 97 + static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 98 + static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 1}; 99 + static snd_card_t *snd_cx88_cards[SNDRV_CARDS]; 100 + 101 + module_param_array(enable, bool, NULL, 0444); 102 + MODULE_PARM_DESC(enable, "Enable cx88x soundcard. default enabled."); 103 + 104 + module_param_array(index, int, NULL, 0444); 105 + MODULE_PARM_DESC(index, "Index value for cx88x capture interface(s)."); 106 + 107 + 108 + /**************************************************************************** 109 + Module macros 110 + ****************************************************************************/ 111 + 112 + MODULE_DESCRIPTION("ALSA driver module for cx2388x based TV cards"); 113 + MODULE_AUTHOR("Ricardo Cerqueira"); 114 + MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@brturbo.com.br>"); 115 + MODULE_LICENSE("GPL"); 116 + MODULE_SUPPORTED_DEVICE("{{Conexant,23881}," 117 + "{{Conexant,23882}," 118 + "{{Conexant,23883}"); 119 + static unsigned int debug = 0; 120 + module_param(debug,int,0644); 121 + MODULE_PARM_DESC(debug,"enable debug messages"); 122 + 123 + /**************************************************************************** 124 + Module specific funtions 125 + ****************************************************************************/ 126 + 127 + /* 128 + * BOARD Specific: Sets audio DMA 129 + */ 130 + 131 + int _cx88_start_audio_dma(snd_cx88_card_t *chip) 132 + { 133 + struct cx88_buffer *buf = chip->buf; 134 + struct cx88_core *core=chip->core; 135 + struct sram_channel *audio_ch = &cx88_sram_channels[SRAM_CH25]; 136 + 137 + 138 + dprintk(1, "Starting audio DMA for %i bytes/line and %i (%i) lines at address %08x\n",buf->bpl, chip->num_periods, audio_ch->fifo_size / buf->bpl, audio_ch->fifo_start); 139 + 140 + /* setup fifo + format - out channel */ 141 + cx88_sram_channel_setup(chip->core, &cx88_sram_channels[SRAM_CH25], 142 + buf->bpl, buf->risc.dma); 143 + 144 + /* sets bpl size */ 145 + cx_write(MO_AUDD_LNGTH, buf->bpl); 146 + 147 + /* reset counter */ 148 + cx_write(MO_AUDD_GPCNTRL,GP_COUNT_CONTROL_RESET); 149 + 150 + dprintk(1,"Enabling IRQ, setting mask from 0x%x to 0x%x\n",chip->core->pci_irqmask,(chip->core->pci_irqmask | 0x02)); 151 + /* enable irqs */ 152 + cx_set(MO_PCI_INTMSK, chip->core->pci_irqmask | 0x02); 153 + 154 + 155 + /* Enables corresponding bits at AUD_INT_STAT */ 156 + cx_write(MO_AUD_INTMSK, 157 + (1<<16)| 158 + (1<<12)| 159 + (1<<4)| 160 + (1<<0) 161 + ); 162 + 163 + /* start dma */ 164 + cx_set(MO_DEV_CNTRL2, (1<<5)); /* Enables Risc Processor */ 165 + cx_set(MO_AUD_DMACNTRL, 0x11); /* audio downstream FIFO and RISC enable */ 166 + 167 + if (debug) 168 + cx88_sram_channel_dump(chip->core, &cx88_sram_channels[SRAM_CH25]); 169 + 170 + return 0; 171 + } 172 + 173 + /* 174 + * BOARD Specific: Resets audio DMA 175 + */ 176 + int _cx88_stop_audio_dma(snd_cx88_card_t *chip) 177 + { 178 + struct cx88_core *core=chip->core; 179 + dprintk(1, "Stopping audio DMA\n"); 180 + 181 + /* stop dma */ 182 + cx_clear(MO_AUD_DMACNTRL, 0x11); 183 + 184 + /* disable irqs */ 185 + cx_clear(MO_PCI_INTMSK, 0x02); 186 + cx_clear(MO_AUD_INTMSK, 187 + (1<<16)| 188 + (1<<12)| 189 + (1<<4)| 190 + (1<<0) 191 + ); 192 + 193 + if (debug) 194 + cx88_sram_channel_dump(chip->core, &cx88_sram_channels[SRAM_CH25]); 195 + 196 + return 0; 197 + } 198 + 199 + #define MAX_IRQ_LOOP 10 200 + 201 + /* 202 + * BOARD Specific: IRQ dma bits 203 + */ 204 + static char *cx88_aud_irqs[32] = { 205 + "dn_risci1", "up_risci1", "rds_dn_risc1", /* 0-2 */ 206 + NULL, /* reserved */ 207 + "dn_risci2", "up_risci2", "rds_dn_risc2", /* 4-6 */ 208 + NULL, /* reserved */ 209 + "dnf_of", "upf_uf", "rds_dnf_uf", /* 8-10 */ 210 + NULL, /* reserved */ 211 + "dn_sync", "up_sync", "rds_dn_sync", /* 12-14 */ 212 + NULL, /* reserved */ 213 + "opc_err", "par_err", "rip_err", /* 16-18 */ 214 + "pci_abort", "ber_irq", "mchg_irq" /* 19-21 */ 215 + }; 216 + 217 + /* 218 + * BOARD Specific: Threats IRQ audio specific calls 219 + */ 220 + static void cx8801_aud_irq(snd_cx88_card_t *chip) 221 + { 222 + struct cx88_core *core = chip->core; 223 + u32 status, mask; 224 + u32 count; 225 + 226 + status = cx_read(MO_AUD_INTSTAT); 227 + mask = cx_read(MO_AUD_INTMSK); 228 + if (0 == (status & mask)) { 229 + spin_unlock(&chip->reg_lock); 230 + return; 231 + } 232 + cx_write(MO_AUD_INTSTAT, status); 233 + if (debug > 1 || (status & mask & ~0xff)) 234 + cx88_print_irqbits(core->name, "irq aud", 235 + cx88_aud_irqs, status, mask); 236 + /* risc op code error */ 237 + if (status & (1 << 16)) { 238 + printk(KERN_WARNING "%s/0: audio risc op code error\n",core->name); 239 + cx_clear(MO_AUD_DMACNTRL, 0x11); 240 + cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH25]); 241 + } 242 + 243 + /* risc1 downstream */ 244 + if (status & 0x01) { 245 + spin_lock(&chip->reg_lock); 246 + count = cx_read(MO_AUDD_GPCNT); 247 + spin_unlock(&chip->reg_lock); 248 + if (chip->read_count == 0) 249 + chip->read_count += chip->dma_size; 250 + } 251 + 252 + if (chip->read_count >= chip->period_size) { 253 + dprintk(2, "Elapsing period\n"); 254 + snd_pcm_period_elapsed(chip->substream); 255 + } 256 + 257 + dprintk(3,"Leaving audio IRQ handler...\n"); 258 + 259 + /* FIXME: Any other status should deserve a special handling? */ 260 + } 261 + 262 + /* 263 + * BOARD Specific: Handles IRQ calls 264 + */ 265 + static irqreturn_t cx8801_irq(int irq, void *dev_id, struct pt_regs *regs) 266 + { 267 + snd_cx88_card_t *chip = dev_id; 268 + struct cx88_core *core = chip->core; 269 + u32 status; 270 + int loop, handled = 0; 271 + 272 + for (loop = 0; loop < MAX_IRQ_LOOP; loop++) { 273 + status = cx_read(MO_PCI_INTSTAT) & (core->pci_irqmask | 0x02); 274 + if (0 == status) 275 + goto out; 276 + dprintk( 3, "cx8801_irq\n" ); 277 + dprintk( 3, " loop: %d/%d\n", loop, MAX_IRQ_LOOP ); 278 + dprintk( 3, " status: %d\n", status ); 279 + handled = 1; 280 + cx_write(MO_PCI_INTSTAT, status); 281 + 282 + if (status & 0x02) 283 + { 284 + dprintk( 2, " ALSA IRQ handling\n" ); 285 + cx8801_aud_irq(chip); 286 + } 287 + }; 288 + 289 + if (MAX_IRQ_LOOP == loop) { 290 + dprintk( 0, "clearing mask\n" ); 291 + dprintk(1,"%s/0: irq loop -- clearing mask\n", 292 + core->name); 293 + cx_clear(MO_PCI_INTMSK,0x02); 294 + } 295 + 296 + out: 297 + return IRQ_RETVAL(handled); 298 + } 299 + 300 + 301 + static int dsp_buffer_free(snd_cx88_card_t *chip) 302 + { 303 + BUG_ON(!chip->dma_size); 304 + 305 + dprintk(2,"Freeing buffer\n"); 306 + videobuf_dma_pci_unmap(chip->pci, &chip->dma_risc); 307 + videobuf_dma_free(&chip->dma_risc); 308 + btcx_riscmem_free(chip->pci,&chip->buf->risc); 309 + kfree(chip->buf); 310 + 311 + chip->dma_size = 0; 312 + 313 + return 0; 314 + } 315 + 316 + /**************************************************************************** 317 + ALSA PCM Interface 318 + ****************************************************************************/ 319 + 320 + /* 321 + * Digital hardware definition 322 + */ 323 + static snd_pcm_hardware_t snd_cx88_digital_hw = { 324 + .info = SNDRV_PCM_INFO_MMAP | 325 + SNDRV_PCM_INFO_INTERLEAVED | 326 + SNDRV_PCM_INFO_BLOCK_TRANSFER | 327 + SNDRV_PCM_INFO_MMAP_VALID, 328 + .formats = SNDRV_PCM_FMTBIT_S16_LE, 329 + 330 + .rates = SNDRV_PCM_RATE_48000, 331 + .rate_min = 48000, 332 + .rate_max = 48000, 333 + .channels_min = 1, 334 + .channels_max = 2, 335 + .buffer_bytes_max = (2*2048), 336 + .period_bytes_min = 256, 337 + .period_bytes_max = 2048, 338 + .periods_min = 2, 339 + .periods_max = 16, 340 + }; 341 + 342 + /* 343 + * audio pcm capture runtime free 344 + */ 345 + static void snd_card_cx88_runtime_free(snd_pcm_runtime_t *runtime) 346 + { 347 + } 348 + /* 349 + * audio pcm capture open callback 350 + */ 351 + static int snd_cx88_pcm_open(snd_pcm_substream_t *substream) 352 + { 353 + snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 354 + snd_pcm_runtime_t *runtime = substream->runtime; 355 + int err; 356 + 357 + if (test_and_set_bit(0, &chip->opened)) 358 + return -EBUSY; 359 + 360 + err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 361 + if (err < 0) 362 + goto _error; 363 + 364 + chip->substream = substream; 365 + 366 + chip->read_count = 0; 367 + chip->read_offset = 0; 368 + 369 + runtime->private_free = snd_card_cx88_runtime_free; 370 + runtime->hw = snd_cx88_digital_hw; 371 + 372 + return 0; 373 + _error: 374 + dprintk(1,"Error opening PCM!\n"); 375 + clear_bit(0, &chip->opened); 376 + smp_mb__after_clear_bit(); 377 + return err; 378 + } 379 + 380 + /* 381 + * audio close callback 382 + */ 383 + static int snd_cx88_close(snd_pcm_substream_t *substream) 384 + { 385 + snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 386 + 387 + clear_bit(0, &chip->opened); 388 + smp_mb__after_clear_bit(); 389 + 390 + return 0; 391 + } 392 + 393 + /* 394 + * hw_params callback 395 + */ 396 + static int snd_cx88_hw_params(snd_pcm_substream_t * substream, 397 + snd_pcm_hw_params_t * hw_params) 398 + { 399 + snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 400 + struct cx88_buffer *buf; 401 + 402 + if (substream->runtime->dma_area) { 403 + dsp_buffer_free(chip); 404 + substream->runtime->dma_area = NULL; 405 + } 406 + 407 + 408 + chip->period_size = params_period_bytes(hw_params); 409 + chip->num_periods = params_periods(hw_params); 410 + chip->dma_size = chip->period_size * params_periods(hw_params); 411 + 412 + BUG_ON(!chip->dma_size); 413 + 414 + dprintk(1,"Setting buffer\n"); 415 + 416 + buf = kmalloc(sizeof(*buf),GFP_KERNEL); 417 + if (NULL == buf) 418 + return -ENOMEM; 419 + memset(buf,0,sizeof(*buf)); 420 + 421 + 422 + buf->vb.memory = V4L2_MEMORY_MMAP; 423 + buf->vb.width = chip->period_size; 424 + buf->vb.height = chip->num_periods; 425 + buf->vb.size = chip->dma_size; 426 + buf->vb.field = V4L2_FIELD_NONE; 427 + 428 + videobuf_dma_init(&buf->vb.dma); 429 + videobuf_dma_init_kernel(&buf->vb.dma,PCI_DMA_FROMDEVICE, 430 + (PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT)); 431 + 432 + videobuf_dma_pci_map(chip->pci,&buf->vb.dma); 433 + 434 + 435 + cx88_risc_databuffer(chip->pci, &buf->risc, 436 + buf->vb.dma.sglist, 437 + buf->vb.width, buf->vb.height); 438 + 439 + buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); 440 + buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 441 + 442 + buf->vb.state = STATE_PREPARED; 443 + 444 + buf->bpl = chip->period_size; 445 + chip->buf = buf; 446 + chip->dma_risc = buf->vb.dma; 447 + 448 + dprintk(1,"Buffer ready at %u\n",chip->dma_risc.nr_pages); 449 + substream->runtime->dma_area = chip->dma_risc.vmalloc; 450 + return 0; 451 + } 452 + 453 + /* 454 + * hw free callback 455 + */ 456 + static int snd_cx88_hw_free(snd_pcm_substream_t * substream) 457 + { 458 + 459 + snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 460 + 461 + if (substream->runtime->dma_area) { 462 + dsp_buffer_free(chip); 463 + substream->runtime->dma_area = NULL; 464 + } 465 + 466 + return 0; 467 + } 468 + 469 + /* 470 + * prepare callback 471 + */ 472 + static int snd_cx88_prepare(snd_pcm_substream_t *substream) 473 + { 474 + return 0; 475 + } 476 + 477 + 478 + /* 479 + * trigger callback 480 + */ 481 + static int snd_cx88_card_trigger(snd_pcm_substream_t *substream, int cmd) 482 + { 483 + snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 484 + int err; 485 + 486 + spin_lock(&chip->reg_lock); 487 + 488 + switch (cmd) { 489 + case SNDRV_PCM_TRIGGER_START: 490 + err=_cx88_start_audio_dma(chip); 491 + break; 492 + case SNDRV_PCM_TRIGGER_STOP: 493 + err=_cx88_stop_audio_dma(chip); 494 + break; 495 + default: 496 + err=-EINVAL; 497 + break; 498 + } 499 + 500 + spin_unlock(&chip->reg_lock); 501 + 502 + return err; 503 + } 504 + 505 + /* 506 + * pointer callback 507 + */ 508 + static snd_pcm_uframes_t snd_cx88_pointer(snd_pcm_substream_t *substream) 509 + { 510 + snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 511 + snd_pcm_runtime_t *runtime = substream->runtime; 512 + 513 + if (chip->read_count) { 514 + chip->read_count -= snd_pcm_lib_period_bytes(substream); 515 + chip->read_offset += snd_pcm_lib_period_bytes(substream); 516 + if (chip->read_offset == chip->dma_size) 517 + chip->read_offset = 0; 518 + } 519 + 520 + dprintk(2, "Pointer time, will return %li, read %li\n",chip->read_offset,chip->read_count); 521 + return bytes_to_frames(runtime, chip->read_offset); 522 + 523 + } 524 + 525 + /* 526 + * operators 527 + */ 528 + static snd_pcm_ops_t snd_cx88_pcm_ops = { 529 + .open = snd_cx88_pcm_open, 530 + .close = snd_cx88_close, 531 + .ioctl = snd_pcm_lib_ioctl, 532 + .hw_params = snd_cx88_hw_params, 533 + .hw_free = snd_cx88_hw_free, 534 + .prepare = snd_cx88_prepare, 535 + .trigger = snd_cx88_card_trigger, 536 + .pointer = snd_cx88_pointer, 537 + }; 538 + 539 + /* 540 + * create a PCM device 541 + */ 542 + static int __devinit snd_cx88_pcm(snd_cx88_card_t *chip, int device, char *name) 543 + { 544 + int err; 545 + snd_pcm_t *pcm; 546 + 547 + err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm); 548 + if (err < 0) 549 + return err; 550 + pcm->private_data = chip; 551 + strcpy(pcm->name, name); 552 + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cx88_pcm_ops); 553 + 554 + return 0; 555 + } 556 + 557 + /**************************************************************************** 558 + CONTROL INTERFACE 559 + ****************************************************************************/ 560 + static int snd_cx88_capture_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *info) 561 + { 562 + info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 563 + info->count = 1; 564 + info->value.integer.min = 0; 565 + info->value.integer.max = 0x3f; 566 + 567 + return 0; 568 + } 569 + 570 + /* OK - TODO: test it */ 571 + static int snd_cx88_capture_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) 572 + { 573 + snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 574 + struct cx88_core *core=chip->core; 575 + 576 + value->value.integer.value[0] = 0x3f - (cx_read(AUD_VOL_CTL) & 0x3f); 577 + 578 + return 0; 579 + } 580 + 581 + /* OK - TODO: test it */ 582 + static int snd_cx88_capture_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) 583 + { 584 + snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 585 + struct cx88_core *core=chip->core; 586 + int v; 587 + u32 old_control; 588 + 589 + spin_lock_irq(&chip->reg_lock); 590 + old_control = 0x3f - (cx_read(AUD_VOL_CTL) & 0x3f); 591 + v = 0x3f - (value->value.integer.value[0] & 0x3f); 592 + cx_andor(AUD_VOL_CTL, 0x3f, v); 593 + spin_unlock_irq(&chip->reg_lock); 594 + 595 + return v != old_control; 596 + } 597 + 598 + static snd_kcontrol_new_t snd_cx88_capture_volume = { 599 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 600 + .name = "Capture Volume", 601 + .info = snd_cx88_capture_volume_info, 602 + .get = snd_cx88_capture_volume_get, 603 + .put = snd_cx88_capture_volume_put, 604 + }; 605 + 606 + 607 + /**************************************************************************** 608 + Basic Flow for Sound Devices 609 + ****************************************************************************/ 610 + 611 + /* 612 + * PCI ID Table - 14f1:8801 and 14f1:8811 means function 1: Audio 613 + * Only boards with eeprom and byte 1 at eeprom=1 have it 614 + */ 615 + 616 + struct pci_device_id cx88_audio_pci_tbl[] = { 617 + {0x14f1,0x8801,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, 618 + {0x14f1,0x8811,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, 619 + {0, } 620 + }; 621 + MODULE_DEVICE_TABLE(pci, cx88_audio_pci_tbl); 622 + 623 + /* 624 + * Chip-specific destructor 625 + */ 626 + 627 + static int snd_cx88_free(snd_cx88_card_t *chip) 628 + { 629 + 630 + if (chip->irq >= 0){ 631 + synchronize_irq(chip->irq); 632 + free_irq(chip->irq, chip); 633 + } 634 + 635 + cx88_core_put(chip->core,chip->pci); 636 + 637 + pci_disable_device(chip->pci); 638 + return 0; 639 + } 640 + 641 + /* 642 + * Component Destructor 643 + */ 644 + static void snd_cx88_dev_free(snd_card_t * card) 645 + { 646 + snd_cx88_card_t *chip = card->private_data; 647 + 648 + snd_cx88_free(chip); 649 + } 650 + 651 + 652 + /* 653 + * Alsa Constructor - Component probe 654 + */ 655 + 656 + static int devno=0; 657 + static int __devinit snd_cx88_create(snd_card_t *card, struct pci_dev *pci, 658 + snd_cx88_card_t **rchip) 659 + { 660 + snd_cx88_card_t *chip; 661 + struct cx88_core *core; 662 + int err; 663 + 664 + *rchip = NULL; 665 + 666 + err = pci_enable_device(pci); 667 + if (err < 0) 668 + return err; 669 + 670 + pci_set_master(pci); 671 + 672 + chip = (snd_cx88_card_t *) card->private_data; 673 + 674 + core = cx88_core_get(pci); 675 + 676 + if (!pci_dma_supported(pci,0xffffffff)) { 677 + dprintk(0, "%s/1: Oops: no 32bit PCI DMA ???\n",core->name); 678 + err = -EIO; 679 + cx88_core_put(core,pci); 680 + return err; 681 + } 682 + 683 + 684 + /* pci init */ 685 + chip->card = card; 686 + chip->pci = pci; 687 + chip->irq = -1; 688 + spin_lock_init(&chip->reg_lock); 689 + 690 + cx88_reset(core); 691 + if (NULL == core) { 692 + err = -EINVAL; 693 + kfree (chip); 694 + return err; 695 + } 696 + chip->core = core; 697 + 698 + /* get irq */ 699 + err = request_irq(chip->pci->irq, cx8801_irq, 700 + SA_SHIRQ | SA_INTERRUPT, chip->core->name, chip); 701 + if (err < 0) { 702 + dprintk(0, "%s: can't get IRQ %d\n", 703 + chip->core->name, chip->pci->irq); 704 + return err; 705 + } 706 + 707 + /* print pci info */ 708 + pci_read_config_byte(pci, PCI_CLASS_REVISION, &chip->pci_rev); 709 + pci_read_config_byte(pci, PCI_LATENCY_TIMER, &chip->pci_lat); 710 + 711 + dprintk(1,"ALSA %s/%i: found at %s, rev: %d, irq: %d, " 712 + "latency: %d, mmio: 0x%lx\n", core->name, devno, 713 + pci_name(pci), chip->pci_rev, pci->irq, 714 + chip->pci_lat,pci_resource_start(pci,0)); 715 + 716 + chip->irq = pci->irq; 717 + synchronize_irq(chip->irq); 718 + 719 + snd_card_set_dev(card, &pci->dev); 720 + 721 + *rchip = chip; 722 + 723 + return 0; 724 + } 725 + 726 + static int __devinit cx88_audio_initdev(struct pci_dev *pci, 727 + const struct pci_device_id *pci_id) 728 + { 729 + snd_card_t *card; 730 + snd_cx88_card_t *chip; 731 + int err; 732 + 733 + if (devno >= SNDRV_CARDS) 734 + return (-ENODEV); 735 + 736 + if (!enable[devno]) { 737 + ++devno; 738 + return (-ENOENT); 739 + } 740 + 741 + card = snd_card_new(index[devno], id[devno], THIS_MODULE, sizeof(snd_cx88_card_t)); 742 + if (!card) 743 + return (-ENOMEM); 744 + 745 + card->private_free = snd_cx88_dev_free; 746 + 747 + err = snd_cx88_create(card, pci, &chip); 748 + if (err < 0) 749 + return (err); 750 + 751 + err = snd_cx88_pcm(chip, 0, "CX88 Digital"); 752 + 753 + if (err < 0) { 754 + snd_card_free(card); 755 + return (err); 756 + } 757 + 758 + err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_capture_volume, chip)); 759 + if (err < 0) { 760 + snd_card_free(card); 761 + return (err); 762 + } 763 + 764 + strcpy (card->driver, "CX88x"); 765 + sprintf(card->shortname, "Conexant CX%x", pci->device); 766 + sprintf(card->longname, "%s at %#lx", 767 + card->shortname, pci_resource_start(pci, 0)); 768 + strcpy (card->mixername, "CX88"); 769 + 770 + dprintk (0, "%s/%i: ALSA support for cx2388x boards\n", 771 + card->driver,devno); 772 + 773 + err = snd_card_register(card); 774 + if (err < 0) { 775 + snd_card_free(card); 776 + return (err); 777 + } 778 + snd_cx88_cards[devno] = card; 779 + 780 + pci_set_drvdata(pci,card); 781 + 782 + devno++; 783 + return 0; 784 + } 785 + /* 786 + * ALSA destructor 787 + */ 788 + static void __devexit cx88_audio_finidev(struct pci_dev *pci) 789 + { 790 + struct cx88_audio_dev *card = pci_get_drvdata(pci); 791 + 792 + snd_card_free((void *)card); 793 + 794 + pci_set_drvdata(pci, NULL); 795 + 796 + devno--; 797 + } 798 + 799 + /* 800 + * PCI driver definition 801 + */ 802 + 803 + static struct pci_driver cx88_audio_pci_driver = { 804 + .name = "cx88_audio", 805 + .id_table = cx88_audio_pci_tbl, 806 + .probe = cx88_audio_initdev, 807 + .remove = cx88_audio_finidev, 808 + SND_PCI_PM_CALLBACKS 809 + }; 810 + 811 + /**************************************************************************** 812 + LINUX MODULE INIT 813 + ****************************************************************************/ 814 + 815 + /* 816 + * module init 817 + */ 818 + static int cx88_audio_init(void) 819 + { 820 + printk(KERN_INFO "cx2388x alsa driver version %d.%d.%d loaded\n", 821 + (CX88_VERSION_CODE >> 16) & 0xff, 822 + (CX88_VERSION_CODE >> 8) & 0xff, 823 + CX88_VERSION_CODE & 0xff); 824 + #ifdef SNAPSHOT 825 + printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n", 826 + SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100); 827 + #endif 828 + return pci_register_driver(&cx88_audio_pci_driver); 829 + } 830 + 831 + /* 832 + * module remove 833 + */ 834 + static void cx88_audio_fini(void) 835 + { 836 + 837 + pci_unregister_driver(&cx88_audio_pci_driver); 838 + } 839 + 840 + module_init(cx88_audio_init); 841 + module_exit(cx88_audio_fini); 842 + 843 + /* ----------------------------------------------------------- */ 844 + /* 845 + * Local variables: 846 + * c-basic-offset: 8 847 + * End: 848 + */
+15 -3
drivers/media/video/cx88/cx88-blackbird.c
··· 32 32 #include <linux/firmware.h> 33 33 34 34 #include "cx88.h" 35 + #include <media/v4l2-common.h> 35 36 36 37 MODULE_DESCRIPTION("driver for cx2388x/cx23416 based mpeg encoder cards"); 37 - MODULE_AUTHOR("Jelle Foks <jelle@foks.8m.com>"); 38 - MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 38 + MODULE_AUTHOR("Jelle Foks <jelle@foks.8m.com>, Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 39 39 MODULE_LICENSE("GPL"); 40 40 41 41 static unsigned int mpegbufs = 32; ··· 1375 1375 struct cx88_core *core = dev->core; 1376 1376 1377 1377 if (debug > 1) 1378 - cx88_print_ioctl(core->name,cmd); 1378 + v4l_print_ioctl(core->name,cmd); 1379 1379 1380 1380 switch (cmd) { 1381 1381 ··· 1688 1688 dev->height = 576; 1689 1689 memcpy(&dev->params,&default_mpeg_params,sizeof(default_mpeg_params)); 1690 1690 memcpy(&dev->dnr_params,&default_dnr_params,sizeof(default_dnr_params)); 1691 + 1692 + if (core->board == CX88_BOARD_HAUPPAUGE_ROSLYN) { 1693 + 1694 + if (core->tuner_formats & V4L2_STD_525_60) { 1695 + dev->height = 480; 1696 + dev->params.vi_frame_rate = 30; 1697 + } else { 1698 + dev->height = 576; 1699 + dev->params.vi_frame_rate = 25; 1700 + } 1701 + 1702 + } 1691 1703 1692 1704 err = cx8802_init_common(dev); 1693 1705 if (0 != err)
+220 -7
drivers/media/video/cx88/cx88-cards.c
··· 611 611 .input = {{ 612 612 .type = CX88_VMUX_TELEVISION, 613 613 .vmux = 0, 614 - .gpio0 = 0xed12, /* internal decoder */ 614 + .gpio0 = 0xed1a, 615 615 .gpio2 = 0x00ff, 616 616 },{ 617 617 .type = CX88_VMUX_DEBUG, 618 618 .vmux = 0, 619 - .gpio0 = 0xff01, /* mono from tuner chip */ 619 + .gpio0 = 0xff01, 620 620 },{ 621 621 .type = CX88_VMUX_COMPOSITE1, 622 622 .vmux = 1, ··· 708 708 }, 709 709 [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T] = { 710 710 .name = "DViCO FusionHDTV 3 Gold-T", 711 - .tuner_type = TUNER_THOMSON_DTT7611, 711 + .tuner_type = TUNER_THOMSON_DTT761X, 712 712 .radio_type = UNSET, 713 713 .tuner_addr = ADDR_UNSET, 714 714 .radio_addr = ADDR_UNSET, ··· 897 897 .gpio3 = 0x0000, 898 898 }}, 899 899 }, 900 + [CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1] = { 901 + .name = "Hauppauge Nova-S-Plus DVB-S", 902 + .tuner_type = TUNER_ABSENT, 903 + .radio_type = UNSET, 904 + .tuner_addr = ADDR_UNSET, 905 + .radio_addr = ADDR_UNSET, 906 + .input = {{ 907 + .type = CX88_VMUX_DVB, 908 + .vmux = 0, 909 + },{ 910 + .type = CX88_VMUX_COMPOSITE1, 911 + .vmux = 1, 912 + },{ 913 + .type = CX88_VMUX_SVIDEO, 914 + .vmux = 2, 915 + }}, 916 + .dvb = 1, 917 + }, 918 + [CX88_BOARD_HAUPPAUGE_NOVASE2_S1] = { 919 + .name = "Hauppauge Nova-SE2 DVB-S", 920 + .tuner_type = TUNER_ABSENT, 921 + .radio_type = UNSET, 922 + .tuner_addr = ADDR_UNSET, 923 + .radio_addr = ADDR_UNSET, 924 + .input = {{ 925 + .type = CX88_VMUX_DVB, 926 + .vmux = 0, 927 + }}, 928 + .dvb = 1, 929 + }, 930 + [CX88_BOARD_KWORLD_DVBS_100] = { 931 + .name = "KWorld DVB-S 100", 932 + .tuner_type = TUNER_ABSENT, 933 + .radio_type = UNSET, 934 + .tuner_addr = ADDR_UNSET, 935 + .radio_addr = ADDR_UNSET, 936 + .input = {{ 937 + .type = CX88_VMUX_DVB, 938 + .vmux = 0, 939 + },{ 940 + .type = CX88_VMUX_COMPOSITE1, 941 + .vmux = 1, 942 + },{ 943 + .type = CX88_VMUX_SVIDEO, 944 + .vmux = 2, 945 + }}, 946 + .dvb = 1, 947 + }, 948 + [CX88_BOARD_HAUPPAUGE_HVR1100] = { 949 + .name = "Hauppauge WinTV-HVR1100 DVB-T/Hybrid", 950 + .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3, 951 + .radio_type = UNSET, 952 + .tuner_addr = ADDR_UNSET, 953 + .radio_addr = ADDR_UNSET, 954 + .tda9887_conf = TDA9887_PRESENT, 955 + .input = {{ 956 + .type = CX88_VMUX_TELEVISION, 957 + .vmux = 0, 958 + },{ 959 + .type = CX88_VMUX_COMPOSITE1, 960 + .vmux = 1, 961 + },{ 962 + .type = CX88_VMUX_SVIDEO, 963 + .vmux = 2, 964 + }}, 965 + /* fixme: Add radio support */ 966 + .dvb = 1, 967 + }, 968 + [CX88_BOARD_HAUPPAUGE_HVR1100LP] = { 969 + .name = "Hauppauge WinTV-HVR1100 DVB-T/Hybrid (Low Profile)", 970 + .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3, 971 + .radio_type = UNSET, 972 + .tuner_addr = ADDR_UNSET, 973 + .radio_addr = ADDR_UNSET, 974 + .tda9887_conf = TDA9887_PRESENT, 975 + .input = {{ 976 + .type = CX88_VMUX_TELEVISION, 977 + .vmux = 0, 978 + },{ 979 + .type = CX88_VMUX_COMPOSITE1, 980 + .vmux = 1, 981 + }}, 982 + /* fixme: Add radio support */ 983 + .dvb = 1, 984 + }, 985 + [CX88_BOARD_DNTV_LIVE_DVB_T_PRO] = { 986 + .name = "digitalnow DNTV Live! DVB-T Pro", 987 + .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3, 988 + .radio_type = UNSET, 989 + .tuner_addr = ADDR_UNSET, 990 + .radio_addr = ADDR_UNSET, 991 + .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE | 992 + TDA9887_PORT2_ACTIVE, 993 + .input = {{ 994 + .type = CX88_VMUX_TELEVISION, 995 + .vmux = 0, 996 + .gpio0 = 0xf80808, 997 + },{ 998 + .type = CX88_VMUX_COMPOSITE1, 999 + .vmux = 1, 1000 + .gpio0 = 0xf80808, 1001 + },{ 1002 + .type = CX88_VMUX_SVIDEO, 1003 + .vmux = 2, 1004 + .gpio0 = 0xf80808, 1005 + }}, 1006 + .radio = { 1007 + .type = CX88_RADIO, 1008 + .gpio0 = 0xf80808, 1009 + }, 1010 + .dvb = 1, 1011 + }, 1012 + [CX88_BOARD_KWORLD_DVB_T_CX22702] = { 1013 + /* Kworld V-stream Xpert DVB-T with Thomson tuner */ 1014 + /* DTT 7579 Conexant CX22702-19 Conexant CX2388x */ 1015 + /* Manenti Marco <marco_manenti@colman.it> */ 1016 + .name = "KWorld/VStream XPert DVB-T with cx22702", 1017 + .tuner_type = TUNER_ABSENT, 1018 + .radio_type = UNSET, 1019 + .tuner_addr = ADDR_UNSET, 1020 + .radio_addr = ADDR_UNSET, 1021 + .input = {{ 1022 + .type = CX88_VMUX_COMPOSITE1, 1023 + .vmux = 1, 1024 + .gpio0 = 0x0700, 1025 + .gpio2 = 0x0101, 1026 + },{ 1027 + .type = CX88_VMUX_SVIDEO, 1028 + .vmux = 2, 1029 + .gpio0 = 0x0700, 1030 + .gpio2 = 0x0101, 1031 + }}, 1032 + .dvb = 1, 1033 + }, 1034 + [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL] = { 1035 + .name = "DViCO FusionHDTV DVB-T Dual Digital", 1036 + .tuner_type = TUNER_ABSENT, /* No analog tuner */ 1037 + .radio_type = UNSET, 1038 + .tuner_addr = ADDR_UNSET, 1039 + .radio_addr = ADDR_UNSET, 1040 + .input = {{ 1041 + .type = CX88_VMUX_COMPOSITE1, 1042 + .vmux = 1, 1043 + .gpio0 = 0x000027df, 1044 + },{ 1045 + .type = CX88_VMUX_SVIDEO, 1046 + .vmux = 2, 1047 + .gpio0 = 0x000027df, 1048 + }}, 1049 + .dvb = 1, 1050 + }, 1051 + 900 1052 }; 901 1053 const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards); 902 1054 ··· 1196 1044 .subvendor = 0x1461, 1197 1045 .subdevice = 0x000a, 1198 1046 .card = CX88_BOARD_AVERTV_303, 1047 + },{ 1048 + .subvendor = 0x0070, 1049 + .subdevice = 0x9200, 1050 + .card = CX88_BOARD_HAUPPAUGE_NOVASE2_S1, 1051 + },{ 1052 + .subvendor = 0x0070, 1053 + .subdevice = 0x9201, 1054 + .card = CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1, 1055 + },{ 1056 + .subvendor = 0x0070, 1057 + .subdevice = 0x9202, 1058 + .card = CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1, 1059 + },{ 1060 + .subvendor = 0x17de, 1061 + .subdevice = 0x08b2, 1062 + .card = CX88_BOARD_KWORLD_DVBS_100, 1063 + },{ 1064 + .subvendor = 0x0070, 1065 + .subdevice = 0x9400, 1066 + .card = CX88_BOARD_HAUPPAUGE_HVR1100, 1067 + },{ 1068 + .subvendor = 0x0070, 1069 + .subdevice = 0x9402, 1070 + .card = CX88_BOARD_HAUPPAUGE_HVR1100, 1071 + },{ 1072 + .subvendor = 0x0070, 1073 + .subdevice = 0x9800, 1074 + .card = CX88_BOARD_HAUPPAUGE_HVR1100LP, 1075 + },{ 1076 + .subvendor = 0x0070, 1077 + .subdevice = 0x9802, 1078 + .card = CX88_BOARD_HAUPPAUGE_HVR1100LP, 1079 + },{ 1080 + .subvendor = 0x0070, 1081 + .subdevice = 0x9001, 1082 + .card = CX88_BOARD_HAUPPAUGE_DVB_T1, 1083 + },{ 1084 + .subvendor = 0x1822, 1085 + .subdevice = 0x0025, 1086 + .card = CX88_BOARD_DNTV_LIVE_DVB_T_PRO, 1087 + },{ 1088 + .subvendor = 0x17de, 1089 + .subdevice = 0x08a1, 1090 + .card = CX88_BOARD_KWORLD_DVB_T_CX22702, 1091 + },{ 1092 + .subvendor = 0x18ac, 1093 + .subdevice = 0xdb50, 1094 + .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL, 1199 1095 }, 1200 1096 }; 1201 1097 const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids); ··· 1275 1075 core->name, core->tuner_type, eeprom_data[0]); 1276 1076 } 1277 1077 1278 - 1279 - /* ----------------------------------------------------------------------- */ 1280 - 1281 1078 static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) 1282 1079 { 1283 1080 struct tveeprom tv; 1284 1081 1285 1082 tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data); 1286 1083 core->tuner_type = tv.tuner_type; 1084 + core->tuner_formats = tv.tuner_formats; 1287 1085 core->has_radio = tv.has_radio; 1288 1086 1289 1087 /* Make sure we support the board model */ 1290 1088 switch (tv.model) 1291 1089 { 1090 + case 28552: /* WinTV-PVR 'Roslyn' (No IR) */ 1292 1091 case 90002: /* Nova-T-PCI (9002) */ 1293 1092 case 92001: /* Nova-S-Plus (Video and IR) */ 1294 1093 case 92002: /* Nova-S-Plus (Video and IR) */ ··· 1295 1096 case 90500: /* Nova-T-PCI (oem) */ 1296 1097 case 90501: /* Nova-T-PCI (oem/IR) */ 1297 1098 case 92000: /* Nova-SE2 (OEM, No Video or IR) */ 1298 - 1099 + case 94009: /* WinTV-HVR1100 (Video and IR Retail) */ 1100 + case 94501: /* WinTV-HVR1100 (Video and IR OEM) */ 1101 + case 98559: /* WinTV-HVR1100LP (Video no IR, Retail - Low Profile) */ 1299 1102 /* known */ 1300 1103 break; 1301 1104 default: ··· 1412 1211 if (0 == core->i2c_rc) 1413 1212 leadtek_eeprom(core,eeprom); 1414 1213 break; 1214 + case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 1215 + case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 1415 1216 case CX88_BOARD_HAUPPAUGE_DVB_T1: 1217 + case CX88_BOARD_HAUPPAUGE_HVR1100: 1218 + case CX88_BOARD_HAUPPAUGE_HVR1100LP: 1416 1219 if (0 == core->i2c_rc) 1417 1220 hauppauge_eeprom(core,eeprom); 1418 1221 break; 1222 + case CX88_BOARD_KWORLD_DVBS_100: 1223 + cx_write(MO_GP0_IO, 0x000007f8); 1224 + cx_write(MO_GP1_IO, 0x00000001); 1225 + break; 1419 1226 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 1420 1227 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 1228 + case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 1421 1229 /* GPIO0:0 is hooked to mt352 reset pin */ 1422 1230 cx_set(MO_GP0_IO, 0x00000101); 1423 1231 cx_clear(MO_GP0_IO, 0x00000001); ··· 1441 1231 msleep(1); 1442 1232 cx_clear(MO_GP0_IO, 0x00000007); 1443 1233 cx_set(MO_GP2_IO, 0x00000101); 1234 + break; 1235 + case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 1236 + cx_write(MO_GP0_IO, 0x00080808); 1444 1237 break; 1445 1238 case CX88_BOARD_ATI_HDTVWONDER: 1446 1239 if (0 == core->i2c_rc) {
+6 -61
drivers/media/video/cx88/cx88-core.c
··· 34 34 #include <linux/videodev2.h> 35 35 36 36 #include "cx88.h" 37 + #include <media/v4l2-common.h> 37 38 38 39 MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards"); 39 40 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); ··· 77 76 static LIST_HEAD(cx88_devlist); 78 77 static DECLARE_MUTEX(devlist); 79 78 80 - /* ------------------------------------------------------------------ */ 81 - /* debug help functions */ 82 - 83 - static const char *v4l1_ioctls[] = { 84 - "0", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER", "GPICT", "SPICT", 85 - "CCAPTURE", "GWIN", "SWIN", "GFBUF", "SFBUF", "KEY", "GFREQ", 86 - "SFREQ", "GAUDIO", "SAUDIO", "SYNC", "MCAPTURE", "GMBUF", "GUNIT", 87 - "GCAPTURE", "SCAPTURE", "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", 88 - "SMICROCODE", "GVBIFMT", "SVBIFMT" }; 89 - #define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls) 90 - 91 - static const char *v4l2_ioctls[] = { 92 - "QUERYCAP", "1", "ENUM_PIXFMT", "ENUM_FBUFFMT", "G_FMT", "S_FMT", 93 - "G_COMP", "S_COMP", "REQBUFS", "QUERYBUF", "G_FBUF", "S_FBUF", 94 - "G_WIN", "S_WIN", "PREVIEW", "QBUF", "16", "DQBUF", "STREAMON", 95 - "STREAMOFF", "G_PERF", "G_PARM", "S_PARM", "G_STD", "S_STD", 96 - "ENUMSTD", "ENUMINPUT", "G_CTRL", "S_CTRL", "G_TUNER", "S_TUNER", 97 - "G_FREQ", "S_FREQ", "G_AUDIO", "S_AUDIO", "35", "QUERYCTRL", 98 - "QUERYMENU", "G_INPUT", "S_INPUT", "ENUMCVT", "41", "42", "43", 99 - "44", "45", "G_OUTPUT", "S_OUTPUT", "ENUMOUTPUT", "G_AUDOUT", 100 - "S_AUDOUT", "ENUMFX", "G_EFFECT", "S_EFFECT", "G_MODULATOR", 101 - "S_MODULATOR" 102 - }; 103 - #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) 104 - 105 - void cx88_print_ioctl(char *name, unsigned int cmd) 106 - { 107 - char *dir; 108 - 109 - switch (_IOC_DIR(cmd)) { 110 - case _IOC_NONE: dir = "--"; break; 111 - case _IOC_READ: dir = "r-"; break; 112 - case _IOC_WRITE: dir = "-w"; break; 113 - case _IOC_READ | _IOC_WRITE: dir = "rw"; break; 114 - default: dir = "??"; break; 115 - } 116 - switch (_IOC_TYPE(cmd)) { 117 - case 'v': 118 - printk(KERN_DEBUG "%s: ioctl 0x%08x (v4l1, %s, VIDIOC%s)\n", 119 - name, cmd, dir, (_IOC_NR(cmd) < V4L1_IOCTLS) ? 120 - v4l1_ioctls[_IOC_NR(cmd)] : "???"); 121 - break; 122 - case 'V': 123 - printk(KERN_DEBUG "%s: ioctl 0x%08x (v4l2, %s, VIDIOC_%s)\n", 124 - name, cmd, dir, (_IOC_NR(cmd) < V4L2_IOCTLS) ? 125 - v4l2_ioctls[_IOC_NR(cmd)] : "???"); 126 - break; 127 - default: 128 - printk(KERN_DEBUG "%s: ioctl 0x%08x (???, %s, #%d)\n", 129 - name, cmd, dir, _IOC_NR(cmd)); 130 - } 131 - } 132 - 133 - /* ------------------------------------------------------------------ */ 134 79 #define NO_SYNC_LINE (-1U) 135 80 136 81 static u32* cx88_risc_field(u32 *rp, struct scatterlist *sglist, ··· 238 291 * channel 22 (u video) - 2.0k 239 292 * channel 23 (v video) - 2.0k 240 293 * channel 24 (vbi) - 4.0k 241 - * channels 25+26 (audio) - 0.5k 294 + * channels 25+26 (audio) - 4.0k 242 295 * channel 28 (mpeg) - 4.0k 243 - * TOTAL = 25.5k 296 + * TOTAL = 29.0k 244 297 * 245 298 * Every channel has 160 bytes control data (64 bytes instruction 246 299 * queue and 6 CDT entries), which is close to 2k total. ··· 306 359 .ctrl_start = 0x180680, 307 360 .cdt = 0x180680 + 64, 308 361 .fifo_start = 0x185400, 309 - .fifo_size = 0x000200, 362 + .fifo_size = 0x001000, 310 363 .ptr1_reg = MO_DMA25_PTR1, 311 364 .ptr2_reg = MO_DMA25_PTR2, 312 365 .cnt1_reg = MO_DMA25_CNT1, ··· 318 371 .ctrl_start = 0x180720, 319 372 .cdt = 0x180680 + 64, /* same as audio IN */ 320 373 .fifo_start = 0x185400, /* same as audio IN */ 321 - .fifo_size = 0x000200, /* same as audio IN */ 374 + .fifo_size = 0x001000, /* same as audio IN */ 322 375 .ptr1_reg = MO_DMA26_PTR1, 323 376 .ptr2_reg = MO_DMA26_PTR2, 324 377 .cnt1_reg = MO_DMA26_CNT1, ··· 329 382 .cmds_start = 0x180200, 330 383 .ctrl_start = 0x1807C0, 331 384 .cdt = 0x1807C0 + 64, 332 - .fifo_start = 0x185600, 385 + .fifo_start = 0x186400, 333 386 .fifo_size = 0x001000, 334 387 .ptr1_reg = MO_DMA28_PTR1, 335 388 .ptr2_reg = MO_DMA28_PTR2, ··· 795 848 796 849 /* start dma */ 797 850 cx_write(MO_AUD_DMACNTRL, 0x0003); /* Up and Down fifo enable */ 798 - 799 851 return 0; 800 852 } 801 853 ··· 1154 1208 1155 1209 /* ------------------------------------------------------------------ */ 1156 1210 1157 - EXPORT_SYMBOL(cx88_print_ioctl); 1158 1211 EXPORT_SYMBOL(cx88_print_irqbits); 1159 1212 1160 1213 EXPORT_SYMBOL(cx88_core_irq);
+213 -2
drivers/media/video/cx88/cx88-dvb.c
··· 3 3 * device driver for Conexant 2388x based TV cards 4 4 * MPEG Transport Stream (DVB) routines 5 5 * 6 - * (c) 2004 Chris Pascoe <c.pascoe@itee.uq.edu.au> 6 + * (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> 7 7 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] 8 8 * 9 9 * This program is free software; you can redistribute it and/or modify ··· 31 31 32 32 #include "cx88.h" 33 33 #include "dvb-pll.h" 34 + #include <media/v4l2-common.h> 34 35 35 36 #ifdef HAVE_MT352 36 37 # include "mt352.h" 37 38 # include "mt352_priv.h" 39 + # ifdef HAVE_VP3054_I2C 40 + # include "cx88-vp3054-i2c.h" 41 + # endif 38 42 #endif 39 43 #ifdef HAVE_CX22702 40 44 # include "cx22702.h" ··· 51 47 #endif 52 48 #ifdef HAVE_NXT200X 53 49 # include "nxt200x.h" 50 + #endif 51 + #ifdef HAVE_CX24123 52 + # include "cx24123.h" 54 53 #endif 55 54 56 55 MODULE_DESCRIPTION("driver for cx2388x based DVB cards"); ··· 132 125 return 0; 133 126 } 134 127 128 + static int dvico_dual_demod_init(struct dvb_frontend *fe) 129 + { 130 + static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 }; 131 + static u8 reset [] = { RESET, 0x80 }; 132 + static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; 133 + static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 }; 134 + static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; 135 + static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; 136 + 137 + mt352_write(fe, clock_config, sizeof(clock_config)); 138 + udelay(200); 139 + mt352_write(fe, reset, sizeof(reset)); 140 + mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); 141 + 142 + mt352_write(fe, agc_cfg, sizeof(agc_cfg)); 143 + mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); 144 + mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); 145 + 146 + return 0; 147 + } 148 + 135 149 static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe) 136 150 { 137 151 static u8 clock_config [] = { 0x89, 0x38, 0x39 }; ··· 200 172 .demod_init = dntv_live_dvbt_demod_init, 201 173 .pll_set = mt352_pll_set, 202 174 }; 175 + 176 + static struct mt352_config dvico_fusionhdtv_dual = { 177 + .demod_address = 0x0F, 178 + .demod_init = dvico_dual_demod_init, 179 + .pll_set = mt352_pll_set, 180 + }; 181 + 182 + #ifdef HAVE_VP3054_I2C 183 + static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe) 184 + { 185 + static u8 clock_config [] = { 0x89, 0x38, 0x38 }; 186 + static u8 reset [] = { 0x50, 0x80 }; 187 + static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 }; 188 + static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF, 189 + 0x00, 0xFF, 0x00, 0x40, 0x40 }; 190 + static u8 dntv_extra[] = { 0xB5, 0x7A }; 191 + static u8 capt_range_cfg[] = { 0x75, 0x32 }; 192 + 193 + mt352_write(fe, clock_config, sizeof(clock_config)); 194 + udelay(2000); 195 + mt352_write(fe, reset, sizeof(reset)); 196 + mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); 197 + 198 + mt352_write(fe, agc_cfg, sizeof(agc_cfg)); 199 + udelay(2000); 200 + mt352_write(fe, dntv_extra, sizeof(dntv_extra)); 201 + mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); 202 + 203 + return 0; 204 + } 205 + 206 + static int philips_fmd1216_pll_init(struct dvb_frontend *fe) 207 + { 208 + struct cx8802_dev *dev= fe->dvb->priv; 209 + 210 + /* this message is to set up ATC and ALC */ 211 + static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 }; 212 + struct i2c_msg msg = 213 + { .addr = dev->core->pll_addr, .flags = 0, 214 + .buf = fmd1216_init, .len = sizeof(fmd1216_init) }; 215 + int err; 216 + 217 + if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { 218 + if (err < 0) 219 + return err; 220 + else 221 + return -EREMOTEIO; 222 + } 223 + 224 + return 0; 225 + } 226 + 227 + static int dntv_live_dvbt_pro_pll_set(struct dvb_frontend* fe, 228 + struct dvb_frontend_parameters* params, 229 + u8* pllbuf) 230 + { 231 + struct cx8802_dev *dev= fe->dvb->priv; 232 + struct i2c_msg msg = 233 + { .addr = dev->core->pll_addr, .flags = 0, 234 + .buf = pllbuf+1, .len = 4 }; 235 + int err; 236 + 237 + /* Switch PLL to DVB mode */ 238 + err = philips_fmd1216_pll_init(fe); 239 + if (err) 240 + return err; 241 + 242 + /* Tune PLL */ 243 + pllbuf[0] = dev->core->pll_addr << 1; 244 + dvb_pll_configure(dev->core->pll_desc, pllbuf+1, 245 + params->frequency, 246 + params->u.ofdm.bandwidth); 247 + if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { 248 + printk(KERN_WARNING "cx88-dvb: %s error " 249 + "(addr %02x <- %02x, err = %i)\n", 250 + __FUNCTION__, pllbuf[0], pllbuf[1], err); 251 + if (err < 0) 252 + return err; 253 + else 254 + return -EREMOTEIO; 255 + } 256 + 257 + return 0; 258 + } 259 + 260 + static struct mt352_config dntv_live_dvbt_pro_config = { 261 + .demod_address = 0x0f, 262 + .no_tuner = 1, 263 + .demod_init = dntv_live_dvbt_pro_demod_init, 264 + .pll_set = dntv_live_dvbt_pro_pll_set, 265 + }; 266 + #endif 203 267 #endif 204 268 205 269 #ifdef HAVE_CX22702 ··· 307 187 .output_mode = CX22702_SERIAL_OUTPUT, 308 188 .pll_address = 0x61, 309 189 .pll_desc = &dvb_pll_thomson_dtt759x, 190 + }; 191 + static struct cx22702_config hauppauge_hvr1100_config = { 192 + .demod_address = 0x63, 193 + .output_mode = CX22702_SERIAL_OUTPUT, 194 + .pll_address = 0x61, 195 + .pll_desc = &dvb_pll_fmd1216me, 310 196 }; 311 197 #endif 312 198 ··· 440 314 }; 441 315 #endif 442 316 317 + #ifdef HAVE_CX24123 318 + static int cx24123_set_ts_param(struct dvb_frontend* fe, 319 + int is_punctured) 320 + { 321 + struct cx8802_dev *dev= fe->dvb->priv; 322 + dev->ts_gen_cntrl = 0x2; 323 + return 0; 324 + } 325 + 326 + static void cx24123_enable_lnb_voltage(struct dvb_frontend* fe, int on) 327 + { 328 + struct cx8802_dev *dev= fe->dvb->priv; 329 + struct cx88_core *core = dev->core; 330 + 331 + if (on) 332 + cx_write(MO_GP0_IO, 0x000006f9); 333 + else 334 + cx_write(MO_GP0_IO, 0x000006fB); 335 + } 336 + 337 + static struct cx24123_config hauppauge_novas_config = { 338 + .demod_address = 0x55, 339 + .use_isl6421 = 1, 340 + .set_ts_params = cx24123_set_ts_param, 341 + }; 342 + 343 + static struct cx24123_config kworld_dvbs_100_config = { 344 + .demod_address = 0x15, 345 + .use_isl6421 = 0, 346 + .set_ts_params = cx24123_set_ts_param, 347 + .enable_lnb_voltage = cx24123_enable_lnb_voltage, 348 + }; 349 + #endif 350 + 443 351 static int dvb_register(struct cx8802_dev *dev) 444 352 { 445 353 /* init struct videobuf_dvb */ ··· 489 329 break; 490 330 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: 491 331 case CX88_BOARD_CONEXANT_DVB_T1: 332 + case CX88_BOARD_KWORLD_DVB_T_CX22702: 492 333 case CX88_BOARD_WINFAST_DTV1000: 493 334 dev->dvb.frontend = cx22702_attach(&connexant_refboard_config, 335 + &dev->core->i2c_adap); 336 + break; 337 + case CX88_BOARD_HAUPPAUGE_HVR1100: 338 + case CX88_BOARD_HAUPPAUGE_HVR1100LP: 339 + dev->dvb.frontend = cx22702_attach(&hauppauge_hvr1100_config, 494 340 &dev->core->i2c_adap); 495 341 break; 496 342 #endif ··· 519 353 dev->core->pll_addr = 0x61; 520 354 dev->core->pll_desc = &dvb_pll_unknown_1; 521 355 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config, 356 + &dev->core->i2c_adap); 357 + break; 358 + case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 359 + #ifdef HAVE_VP3054_I2C 360 + dev->core->pll_addr = 0x61; 361 + dev->core->pll_desc = &dvb_pll_fmd1216me; 362 + dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_pro_config, 363 + &((struct vp3054_i2c_state *)dev->card_priv)->adap); 364 + #else 365 + printk("%s: built without vp3054 support\n", dev->core->name); 366 + #endif 367 + break; 368 + case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 369 + /* The tin box says DEE1601, but it seems to be DTT7579 370 + * compatible, with a slightly different MT352 AGC gain. */ 371 + dev->core->pll_addr = 0x61; 372 + dev->core->pll_desc = &dvb_pll_thomson_dtt7579; 373 + dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dual, 522 374 &dev->core->i2c_adap); 523 375 break; 524 376 #endif ··· 577 393 cx_set(MO_GP0_IO, 9); 578 394 mdelay(200); 579 395 dev->core->pll_addr = 0x61; 580 - dev->core->pll_desc = &dvb_pll_thomson_dtt7611; 396 + dev->core->pll_desc = &dvb_pll_thomson_dtt761x; 581 397 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold, 582 398 &dev->core->i2c_adap); 583 399 } ··· 603 419 case CX88_BOARD_ATI_HDTVWONDER: 604 420 dev->dvb.frontend = nxt200x_attach(&ati_hdtvwonder, 605 421 &dev->core->i2c_adap); 422 + break; 423 + #endif 424 + #ifdef HAVE_CX24123 425 + case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 426 + case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 427 + dev->dvb.frontend = cx24123_attach(&hauppauge_novas_config, 428 + &dev->core->i2c_adap); 429 + break; 430 + case CX88_BOARD_KWORLD_DVBS_100: 431 + dev->dvb.frontend = cx24123_attach(&kworld_dvbs_100_config, 432 + &dev->core->i2c_adap); 606 433 break; 607 434 #endif 608 435 default: ··· 668 473 if (0 != err) 669 474 goto fail_free; 670 475 476 + #ifdef HAVE_VP3054_I2C 477 + err = vp3054_i2c_probe(dev); 478 + if (0 != err) 479 + goto fail_free; 480 + #endif 481 + 671 482 /* dvb stuff */ 672 483 printk("%s/2: cx2388x based dvb card\n", core->name); 673 484 videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops, ··· 685 484 err = dvb_register(dev); 686 485 if (0 != err) 687 486 goto fail_fini; 487 + 488 + /* Maintain a reference to cx88-video can query the 8802 device. */ 489 + core->dvbdev = dev; 688 490 return 0; 689 491 690 492 fail_fini: ··· 703 499 { 704 500 struct cx8802_dev *dev = pci_get_drvdata(pci_dev); 705 501 502 + /* Destroy any 8802 reference. */ 503 + dev->core->dvbdev = NULL; 504 + 706 505 /* dvb */ 707 506 videobuf_dvb_unregister(&dev->dvb); 507 + 508 + #ifdef HAVE_VP3054_I2C 509 + vp3054_i2c_remove(dev); 510 + #endif 708 511 709 512 /* common */ 710 513 cx8802_fini_common(dev);
+12 -1
drivers/media/video/cx88/cx88-i2c.c
··· 30 30 #include <asm/io.h> 31 31 32 32 #include "cx88.h" 33 + #include <media/v4l2-common.h> 33 34 34 35 static unsigned int i2c_debug = 0; 35 36 module_param(i2c_debug, int, 0644); ··· 136 135 { 137 136 if (0 != core->i2c_rc) 138 137 return; 139 - i2c_clients_command(&core->i2c_adap, cmd, arg); 138 + 139 + if (core->dvbdev) { 140 + if (core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl) 141 + core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl(core->dvbdev->dvb.frontend, 1); 142 + 143 + i2c_clients_command(&core->i2c_adap, cmd, arg); 144 + 145 + if (core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl) 146 + core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl(core->dvbdev->dvb.frontend, 0); 147 + } else 148 + i2c_clients_command(&core->i2c_adap, cmd, arg); 140 149 } 141 150 142 151 static struct i2c_algo_bit_data cx8800_i2c_algo_template = {
+136 -6
drivers/media/video/cx88/cx88-input.c
··· 5 5 * 6 6 * Copyright (c) 2003 Pavel Machek 7 7 * Copyright (c) 2004 Gerd Knorr 8 - * Copyright (c) 2004 Chris Pascoe 8 + * Copyright (c) 2004, 2005 Chris Pascoe 9 9 * 10 10 * This program is free software; you can redistribute it and/or modify 11 11 * it under the terms of the GNU General Public License as published by ··· 29 29 #include <linux/module.h> 30 30 #include <linux/moduleparam.h> 31 31 32 - #include <media/ir-common.h> 33 - 34 32 #include "cx88.h" 33 + #include <media/ir-common.h> 35 34 36 35 /* ---------------------------------------------------------------------- */ 37 36 ··· 257 258 258 259 /* ---------------------------------------------------------------------- */ 259 260 261 + /* AVERTV STUDIO 303 Remote */ 262 + static IR_KEYTAB_TYPE ir_codes_avertv_303[IR_KEYTAB_SIZE] = { 263 + [ 0x2a ] = KEY_KP1, 264 + [ 0x32 ] = KEY_KP2, 265 + [ 0x3a ] = KEY_KP3, 266 + [ 0x4a ] = KEY_KP4, 267 + [ 0x52 ] = KEY_KP5, 268 + [ 0x5a ] = KEY_KP6, 269 + [ 0x6a ] = KEY_KP7, 270 + [ 0x72 ] = KEY_KP8, 271 + [ 0x7a ] = KEY_KP9, 272 + [ 0x0e ] = KEY_KP0, 273 + 274 + [ 0x02 ] = KEY_POWER, 275 + [ 0x22 ] = KEY_VIDEO, 276 + [ 0x42 ] = KEY_AUDIO, 277 + [ 0x62 ] = KEY_ZOOM, 278 + [ 0x0a ] = KEY_TV, 279 + [ 0x12 ] = KEY_CD, 280 + [ 0x1a ] = KEY_TEXT, 281 + 282 + [ 0x16 ] = KEY_SUBTITLE, 283 + [ 0x1e ] = KEY_REWIND, 284 + [ 0x06 ] = KEY_PRINT, 285 + 286 + [ 0x2e ] = KEY_SEARCH, 287 + [ 0x36 ] = KEY_SLEEP, 288 + [ 0x3e ] = KEY_SHUFFLE, 289 + [ 0x26 ] = KEY_MUTE, 290 + 291 + [ 0x4e ] = KEY_RECORD, 292 + [ 0x56 ] = KEY_PAUSE, 293 + [ 0x5e ] = KEY_STOP, 294 + [ 0x46 ] = KEY_PLAY, 295 + 296 + [ 0x6e ] = KEY_RED, 297 + [ 0x0b ] = KEY_GREEN, 298 + [ 0x66 ] = KEY_YELLOW, 299 + [ 0x03 ] = KEY_BLUE, 300 + 301 + [ 0x76 ] = KEY_LEFT, 302 + [ 0x7e ] = KEY_RIGHT, 303 + [ 0x13 ] = KEY_DOWN, 304 + [ 0x1b ] = KEY_UP, 305 + }; 306 + 307 + /* ---------------------------------------------------------------------- */ 308 + 309 + /* DigitalNow DNTV Live! DVB-T Pro Remote */ 310 + static IR_KEYTAB_TYPE ir_codes_dntv_live_dvbt_pro[IR_KEYTAB_SIZE] = { 311 + [ 0x16 ] = KEY_POWER, 312 + [ 0x5b ] = KEY_HOME, 313 + 314 + [ 0x55 ] = KEY_TV, /* live tv */ 315 + [ 0x58 ] = KEY_TUNER, /* digital Radio */ 316 + [ 0x5a ] = KEY_RADIO, /* FM radio */ 317 + [ 0x59 ] = KEY_DVD, /* dvd menu */ 318 + [ 0x03 ] = KEY_1, 319 + [ 0x01 ] = KEY_2, 320 + [ 0x06 ] = KEY_3, 321 + [ 0x09 ] = KEY_4, 322 + [ 0x1d ] = KEY_5, 323 + [ 0x1f ] = KEY_6, 324 + [ 0x0d ] = KEY_7, 325 + [ 0x19 ] = KEY_8, 326 + [ 0x1b ] = KEY_9, 327 + [ 0x0c ] = KEY_CANCEL, 328 + [ 0x15 ] = KEY_0, 329 + [ 0x4a ] = KEY_CLEAR, 330 + [ 0x13 ] = KEY_BACK, 331 + [ 0x00 ] = KEY_TAB, 332 + [ 0x4b ] = KEY_UP, 333 + [ 0x4e ] = KEY_LEFT, 334 + [ 0x4f ] = KEY_OK, 335 + [ 0x52 ] = KEY_RIGHT, 336 + [ 0x51 ] = KEY_DOWN, 337 + [ 0x1e ] = KEY_VOLUMEUP, 338 + [ 0x0a ] = KEY_VOLUMEDOWN, 339 + [ 0x02 ] = KEY_CHANNELDOWN, 340 + [ 0x05 ] = KEY_CHANNELUP, 341 + [ 0x11 ] = KEY_RECORD, 342 + [ 0x14 ] = KEY_PLAY, 343 + [ 0x4c ] = KEY_PAUSE, 344 + [ 0x1a ] = KEY_STOP, 345 + [ 0x40 ] = KEY_REWIND, 346 + [ 0x12 ] = KEY_FASTFORWARD, 347 + [ 0x41 ] = KEY_PREVIOUSSONG, /* replay |< */ 348 + [ 0x42 ] = KEY_NEXTSONG, /* skip >| */ 349 + [ 0x54 ] = KEY_CAMERA, /* capture */ 350 + [ 0x50 ] = KEY_LANGUAGE, /* sap */ 351 + [ 0x47 ] = KEY_TV2, /* pip */ 352 + [ 0x4d ] = KEY_SCREEN, 353 + [ 0x43 ] = KEY_SUBTITLE, 354 + [ 0x10 ] = KEY_MUTE, 355 + [ 0x49 ] = KEY_AUDIO, /* l/r */ 356 + [ 0x07 ] = KEY_SLEEP, 357 + [ 0x08 ] = KEY_VIDEO, /* a/v */ 358 + [ 0x0e ] = KEY_PREVIOUS, /* recall */ 359 + [ 0x45 ] = KEY_ZOOM, /* zoom + */ 360 + [ 0x46 ] = KEY_ANGLE, /* zoom - */ 361 + [ 0x56 ] = KEY_RED, 362 + [ 0x57 ] = KEY_GREEN, 363 + [ 0x5c ] = KEY_YELLOW, 364 + [ 0x5d ] = KEY_BLUE, 365 + }; 366 + 367 + /* ---------------------------------------------------------------------- */ 368 + 260 369 struct cx88_IR { 261 370 struct cx88_core *core; 262 371 struct input_dev *input; ··· 373 266 char phys[32]; 374 267 375 268 /* sample from gpio pin 16 */ 376 - int sampling; 269 + u32 sampling; 377 270 u32 samples[16]; 378 271 int scount; 379 272 unsigned long release; ··· 491 384 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: 492 385 ir_codes = ir_codes_cinergy_1400; 493 386 ir_type = IR_TYPE_PD; 494 - ir->sampling = 1; 387 + ir->sampling = 0xeb04; /* address */ 495 388 break; 496 389 case CX88_BOARD_HAUPPAUGE: 497 390 case CX88_BOARD_HAUPPAUGE_DVB_T1: 391 + case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 392 + case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 393 + case CX88_BOARD_HAUPPAUGE_HVR1100: 498 394 ir_codes = ir_codes_hauppauge_new; 499 395 ir_type = IR_TYPE_RC5; 500 396 ir->sampling = 1; ··· 536 426 ir->mask_keycode = 0x1f; 537 427 ir->mask_keyup = 0x40; 538 428 ir->polling = 1; /* ms */ 429 + break; 430 + case CX88_BOARD_AVERTV_303: 431 + case CX88_BOARD_AVERTV_STUDIO_303: 432 + ir_codes = ir_codes_avertv_303; 433 + ir->gpio_addr = MO_GP2_IO; 434 + ir->mask_keycode = 0xfb; 435 + ir->mask_keydown = 0x02; 436 + ir->polling = 50; /* ms */ 437 + break; 438 + case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 439 + ir_codes = ir_codes_dntv_live_dvbt_pro; 440 + ir_type = IR_TYPE_PD; 441 + ir->sampling = 0xff00; /* address */ 539 442 break; 540 443 } 541 444 ··· 607 484 if (NULL == ir) 608 485 return 0; 609 486 487 + if (ir->sampling) { 488 + cx_write(MO_DDSCFG_IO, 0x0); 489 + core->pci_irqmask &= ~(1 << 18); 490 + } 610 491 if (ir->polling) { 611 492 del_timer(&ir->timer); 612 493 flush_scheduled_work(); ··· 662 535 /* decode it */ 663 536 switch (core->board) { 664 537 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: 538 + case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 665 539 ircode = ir_decode_pulsedistance(ir->samples, ir->scount, 1, 4); 666 540 667 541 if (ircode == 0xffffffff) { /* decoding error */ ··· 678 550 break; 679 551 } 680 552 681 - if ((ircode & 0xffff) != 0xeb04) { /* wrong address */ 553 + if ((ircode & 0xffff) != (ir->sampling & 0xffff)) { /* wrong address */ 682 554 ir_dprintk("pulse distance decoded wrong address\n"); 683 555 break; 684 556 } ··· 695 567 break; 696 568 case CX88_BOARD_HAUPPAUGE: 697 569 case CX88_BOARD_HAUPPAUGE_DVB_T1: 570 + case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 571 + case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 698 572 ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7); 699 573 ir_dprintk("biphase decoded: %x\n", ircode); 700 574 if ((ircode & 0xfffff000) != 0x3000)
+5
drivers/media/video/cx88/cx88-mpeg.c
··· 78 78 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: 79 79 cx_write(TS_SOP_STAT, 1<<13); 80 80 break; 81 + case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 82 + case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 83 + cx_write(MO_PINMUX_IO, 0x88); /* Enable MPEG parallel IO and video signal pins */ 84 + udelay(100); 85 + break; 81 86 default: 82 87 cx_write(TS_SOP_STAT, 0x00); 83 88 break;
+9 -1
drivers/media/video/cx88/cx88-tvaudio.c
··· 132 132 { 133 133 u32 volume; 134 134 135 + #ifndef USING_CX88_ALSA 135 136 /* restart dma; This avoids buzz in NICAM and is good in others */ 136 137 cx88_stop_audio_dma(core); 138 + #endif 137 139 cx_write(AUD_RATE_THRES_DMD, 0x000000C0); 140 + #ifndef USING_CX88_ALSA 138 141 cx88_start_audio_dma(core); 142 + #endif 139 143 140 144 if (cx88_boards[core->board].blackbird) { 141 145 /* sets sound input from external adc */ 142 - cx_set(AUD_CTL, EN_I2SIN_ENABLE); 146 + if (core->board == CX88_BOARD_HAUPPAUGE_ROSLYN) 147 + cx_clear(AUD_CTL, EN_I2SIN_ENABLE); 148 + else 149 + cx_set(AUD_CTL, EN_I2SIN_ENABLE); 150 + 143 151 cx_write(AUD_I2SINPUTCNTL, 4); 144 152 cx_write(AUD_BAUDRATE, 1); 145 153 /* 'pass-thru mode': this enables the i2s output to the mpeg encoder */
+45 -49
drivers/media/video/cx88/cx88-video.c
··· 33 33 #include <asm/div64.h> 34 34 35 35 #include "cx88.h" 36 + #include <media/v4l2-common.h> 36 37 37 38 /* Include V4L1 specific functions. Should be removed soon */ 38 39 #include <linux/videodev.h> ··· 241 240 .minimum = 0, 242 241 .maximum = 0xff, 243 242 .step = 1, 244 - .default_value = 0, 243 + .default_value = 0x3f, 245 244 .type = V4L2_CTRL_TYPE_INTEGER, 246 245 }, 247 246 .off = 0, ··· 272 271 .minimum = 0, 273 272 .maximum = 0xff, 274 273 .step = 1, 275 - .default_value = 0, 274 + .default_value = 0x7f, 276 275 .type = V4L2_CTRL_TYPE_INTEGER, 277 276 }, 278 277 .off = 0, ··· 286 285 .name = "Mute", 287 286 .minimum = 0, 288 287 .maximum = 1, 288 + .default_value = 1, 289 289 .type = V4L2_CTRL_TYPE_BOOLEAN, 290 290 }, 291 291 .reg = AUD_VOL_CTL, ··· 300 298 .minimum = 0, 301 299 .maximum = 0x3f, 302 300 .step = 1, 303 - .default_value = 0, 301 + .default_value = 0x1f, 304 302 .type = V4L2_CTRL_TYPE_INTEGER, 305 303 }, 306 304 .reg = AUD_VOL_CTL, ··· 919 917 ctl->value = ((value + (c->off << c->shift)) & c->mask) >> c->shift; 920 918 break; 921 919 } 920 + printk("get_control id=0x%X reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", 921 + ctl->id, c->reg, ctl->value, 922 + c->mask, c->sreg ? " [shadowed]" : ""); 922 923 return 0; 923 924 } 924 925 ··· 930 925 { 931 926 /* struct cx88_core *core = dev->core; */ 932 927 struct cx88_ctrl *c = NULL; 933 - u32 v_sat_value; 934 - u32 value; 928 + u32 value,mask; 935 929 int i; 936 - 937 - for (i = 0; i < CX8800_CTLS; i++) 938 - if (cx8800_ctls[i].v.id == ctl->id) 930 + for (i = 0; i < CX8800_CTLS; i++) { 931 + if (cx8800_ctls[i].v.id == ctl->id) { 939 932 c = &cx8800_ctls[i]; 933 + } 934 + } 940 935 if (NULL == c) 941 936 return -EINVAL; 942 937 ··· 944 939 ctl->value = c->v.minimum; 945 940 if (ctl->value > c->v.maximum) 946 941 ctl->value = c->v.maximum; 942 + mask=c->mask; 947 943 switch (ctl->id) { 948 944 case V4L2_CID_AUDIO_BALANCE: 949 945 value = (ctl->value < 0x40) ? (0x40 - ctl->value) : ctl->value; ··· 954 948 break; 955 949 case V4L2_CID_SATURATION: 956 950 /* special v_sat handling */ 957 - v_sat_value = ctl->value - (0x7f - 0x5a); 958 - if (v_sat_value > 0xff) 959 - v_sat_value = 0xff; 960 - if (v_sat_value < 0x00) 961 - v_sat_value = 0x00; 962 - cx_andor(MO_UV_SATURATION, 0xff00, v_sat_value << 8); 963 - /* fall through to default route for u_sat */ 951 + 952 + value = ((ctl->value - c->off) << c->shift) & c->mask; 953 + 954 + if (core->tvnorm->id & V4L2_STD_SECAM) { 955 + /* For SECAM, both U and V sat should be equal */ 956 + value=value<<8|value; 957 + } else { 958 + /* Keeps U Saturation proportional to V Sat */ 959 + value=(value*0x5a)/0x7f<<8|value; 960 + } 961 + mask=0xffff; 962 + break; 964 963 default: 965 964 value = ((ctl->value - c->off) << c->shift) & c->mask; 966 965 break; 967 966 } 968 - dprintk(1,"set_control id=0x%X reg=0x%x val=0x%x%s\n", 969 - ctl->id, c->reg, value, c->sreg ? " [shadowed]" : ""); 967 + printk("set_control id=0x%X reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", 968 + ctl->id, c->reg, value, 969 + mask, c->sreg ? " [shadowed]" : ""); 970 970 if (c->sreg) { 971 - cx_sandor(c->sreg, c->reg, c->mask, value); 971 + cx_sandor(c->sreg, c->reg, mask, value); 972 972 } else { 973 - cx_andor(c->reg, c->mask, value); 973 + cx_andor(c->reg, mask, value); 974 974 } 975 975 return 0; 976 976 } 977 977 978 - /* static void init_controls(struct cx8800_dev *dev) */ 979 978 static void init_controls(struct cx88_core *core) 980 979 { 981 - static struct v4l2_control mute = { 982 - .id = V4L2_CID_AUDIO_MUTE, 983 - .value = 1, 984 - }; 985 - static struct v4l2_control volume = { 986 - .id = V4L2_CID_AUDIO_VOLUME, 987 - .value = 0x3f, 988 - }; 989 - static struct v4l2_control hue = { 990 - .id = V4L2_CID_HUE, 991 - .value = 0x80, 992 - }; 993 - static struct v4l2_control contrast = { 994 - .id = V4L2_CID_CONTRAST, 995 - .value = 0x80, 996 - }; 997 - static struct v4l2_control brightness = { 998 - .id = V4L2_CID_BRIGHTNESS, 999 - .value = 0x80, 1000 - }; 980 + struct v4l2_control ctrl; 981 + int i; 1001 982 1002 - set_control(core,&mute); 1003 - set_control(core,&volume); 1004 - set_control(core,&hue); 1005 - set_control(core,&contrast); 1006 - set_control(core,&brightness); 983 + for (i = 0; i < CX8800_CTLS; i++) { 984 + ctrl.id=cx8800_ctls[i].v.id; 985 + ctrl.value=cx8800_ctls[i].v.default_value 986 + +cx8800_ctls[i].off; 987 + set_control(core, &ctrl); 988 + } 1007 989 } 1008 990 1009 991 /* ------------------------------------------------------------------ */ ··· 1119 1125 int err; 1120 1126 1121 1127 if (video_debug > 1) 1122 - cx88_print_ioctl(core->name,cmd); 1128 + v4l_print_ioctl(core->name,cmd); 1123 1129 switch (cmd) { 1124 1130 1125 1131 /* --- capabilities ------------------------------------------ */ ··· 1255 1261 1256 1262 dprintk( 1, "CORE IOCTL: 0x%x\n", cmd ); 1257 1263 if (video_debug > 1) 1258 - cx88_print_ioctl(core->name,cmd); 1264 + v4l_print_ioctl(core->name,cmd); 1259 1265 1260 1266 switch (cmd) { 1261 1267 /* ---------- tv norms ---------- */ ··· 1475 1481 struct cx88_core *core = dev->core; 1476 1482 1477 1483 if (video_debug > 1) 1478 - cx88_print_ioctl(core->name,cmd); 1484 + v4l_print_ioctl(core->name,cmd); 1479 1485 1480 1486 switch (cmd) { 1481 1487 case VIDIOC_QUERYCAP: ··· 1734 1740 .poll = video_poll, 1735 1741 .mmap = video_mmap, 1736 1742 .ioctl = video_ioctl, 1743 + .compat_ioctl = v4l_compat_ioctl32, 1737 1744 .llseek = no_llseek, 1738 1745 }; 1739 1746 ··· 1762 1767 .open = video_open, 1763 1768 .release = video_release, 1764 1769 .ioctl = radio_ioctl, 1770 + .compat_ioctl = v4l_compat_ioctl32, 1765 1771 .llseek = no_llseek, 1766 1772 }; 1767 1773 ··· 1924 1928 1925 1929 /* initial device configuration */ 1926 1930 down(&core->lock); 1927 - init_controls(core); 1928 1931 cx88_set_tvnorm(core,tvnorms); 1932 + init_controls(core); 1929 1933 video_mux(core,0); 1930 1934 up(&core->lock); 1931 1935
+173
drivers/media/video/cx88/cx88-vp3054-i2c.c
··· 1 + /* 2 + 3 + cx88-vp3054-i2c.c -- support for the secondary I2C bus of the 4 + DNTV Live! DVB-T Pro (VP-3054), wired as: 5 + GPIO[0] -> SCL, GPIO[1] -> SDA 6 + 7 + (c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> 8 + 9 + This program is free software; you can redistribute it and/or modify 10 + it under the terms of the GNU General Public License as published by 11 + the Free Software Foundation; either version 2 of the License, or 12 + (at your option) any later version. 13 + 14 + This program is distributed in the hope that it will be useful, 15 + but WITHOUT ANY WARRANTY; without even the implied warranty of 16 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 + GNU General Public License for more details. 18 + 19 + You should have received a copy of the GNU General Public License 20 + along with this program; if not, write to the Free Software 21 + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 + 23 + */ 24 + 25 + #include <linux/module.h> 26 + #include <linux/moduleparam.h> 27 + #include <linux/init.h> 28 + 29 + #include <asm/io.h> 30 + 31 + #include "cx88.h" 32 + #include "cx88-vp3054-i2c.h" 33 + 34 + 35 + /* ----------------------------------------------------------------------- */ 36 + 37 + static void vp3054_bit_setscl(void *data, int state) 38 + { 39 + struct cx8802_dev *dev = data; 40 + struct cx88_core *core = dev->core; 41 + struct vp3054_i2c_state *vp3054_i2c = dev->card_priv; 42 + 43 + if (state) { 44 + vp3054_i2c->state |= 0x0001; /* SCL high */ 45 + vp3054_i2c->state &= ~0x0100; /* external pullup */ 46 + } else { 47 + vp3054_i2c->state &= ~0x0001; /* SCL low */ 48 + vp3054_i2c->state |= 0x0100; /* drive pin */ 49 + } 50 + cx_write(MO_GP0_IO, 0x010000 | vp3054_i2c->state); 51 + cx_read(MO_GP0_IO); 52 + } 53 + 54 + static void vp3054_bit_setsda(void *data, int state) 55 + { 56 + struct cx8802_dev *dev = data; 57 + struct cx88_core *core = dev->core; 58 + struct vp3054_i2c_state *vp3054_i2c = dev->card_priv; 59 + 60 + if (state) { 61 + vp3054_i2c->state |= 0x0002; /* SDA high */ 62 + vp3054_i2c->state &= ~0x0200; /* tristate pin */ 63 + } else { 64 + vp3054_i2c->state &= ~0x0002; /* SDA low */ 65 + vp3054_i2c->state |= 0x0200; /* drive pin */ 66 + } 67 + cx_write(MO_GP0_IO, 0x020000 | vp3054_i2c->state); 68 + cx_read(MO_GP0_IO); 69 + } 70 + 71 + static int vp3054_bit_getscl(void *data) 72 + { 73 + struct cx8802_dev *dev = data; 74 + struct cx88_core *core = dev->core; 75 + u32 state; 76 + 77 + state = cx_read(MO_GP0_IO); 78 + return (state & 0x01) ? 1 : 0; 79 + } 80 + 81 + static int vp3054_bit_getsda(void *data) 82 + { 83 + struct cx8802_dev *dev = data; 84 + struct cx88_core *core = dev->core; 85 + u32 state; 86 + 87 + state = cx_read(MO_GP0_IO); 88 + return (state & 0x02) ? 1 : 0; 89 + } 90 + 91 + /* ----------------------------------------------------------------------- */ 92 + 93 + static struct i2c_algo_bit_data vp3054_i2c_algo_template = { 94 + .setsda = vp3054_bit_setsda, 95 + .setscl = vp3054_bit_setscl, 96 + .getsda = vp3054_bit_getsda, 97 + .getscl = vp3054_bit_getscl, 98 + .udelay = 16, 99 + .mdelay = 10, 100 + .timeout = 200, 101 + }; 102 + 103 + /* ----------------------------------------------------------------------- */ 104 + 105 + static struct i2c_adapter vp3054_i2c_adap_template = { 106 + .name = "cx2388x", 107 + .owner = THIS_MODULE, 108 + .id = I2C_HW_B_CX2388x, 109 + }; 110 + 111 + static struct i2c_client vp3054_i2c_client_template = { 112 + .name = "VP-3054", 113 + }; 114 + 115 + int vp3054_i2c_probe(struct cx8802_dev *dev) 116 + { 117 + struct cx88_core *core = dev->core; 118 + struct vp3054_i2c_state *vp3054_i2c; 119 + int rc; 120 + 121 + if (core->board != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) 122 + return 0; 123 + 124 + dev->card_priv = kzalloc(sizeof(*vp3054_i2c), GFP_KERNEL); 125 + if (dev->card_priv == NULL) 126 + return -ENOMEM; 127 + vp3054_i2c = dev->card_priv; 128 + 129 + memcpy(&vp3054_i2c->adap, &vp3054_i2c_adap_template, 130 + sizeof(vp3054_i2c->adap)); 131 + memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, 132 + sizeof(vp3054_i2c->algo)); 133 + memcpy(&vp3054_i2c->client, &vp3054_i2c_client_template, 134 + sizeof(vp3054_i2c->client)); 135 + 136 + vp3054_i2c->adap.class |= I2C_CLASS_TV_DIGITAL; 137 + 138 + vp3054_i2c->adap.dev.parent = &dev->pci->dev; 139 + strlcpy(vp3054_i2c->adap.name, core->name, 140 + sizeof(vp3054_i2c->adap.name)); 141 + vp3054_i2c->algo.data = dev; 142 + i2c_set_adapdata(&vp3054_i2c->adap, dev); 143 + vp3054_i2c->adap.algo_data = &vp3054_i2c->algo; 144 + vp3054_i2c->client.adapter = &vp3054_i2c->adap; 145 + 146 + vp3054_bit_setscl(dev,1); 147 + vp3054_bit_setsda(dev,1); 148 + 149 + rc = i2c_bit_add_bus(&vp3054_i2c->adap); 150 + if (0 != rc) { 151 + printk("%s: vp3054_i2c register FAILED\n", core->name); 152 + 153 + kfree(dev->card_priv); 154 + dev->card_priv = NULL; 155 + } 156 + 157 + return rc; 158 + } 159 + 160 + void vp3054_i2c_remove(struct cx8802_dev *dev) 161 + { 162 + struct vp3054_i2c_state *vp3054_i2c = dev->card_priv; 163 + 164 + if (vp3054_i2c == NULL || 165 + dev->core->board != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) 166 + return; 167 + 168 + i2c_bit_del_bus(&vp3054_i2c->adap); 169 + kfree(vp3054_i2c); 170 + } 171 + 172 + EXPORT_SYMBOL(vp3054_i2c_probe); 173 + EXPORT_SYMBOL(vp3054_i2c_remove);
+35
drivers/media/video/cx88/cx88-vp3054-i2c.h
··· 1 + /* 2 + 3 + cx88-vp3054-i2c.h -- support for the secondary I2C bus of the 4 + DNTV Live! DVB-T Pro (VP-3054), wired as: 5 + GPIO[0] -> SCL, GPIO[1] -> SDA 6 + 7 + (c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> 8 + 9 + This program is free software; you can redistribute it and/or modify 10 + it under the terms of the GNU General Public License as published by 11 + the Free Software Foundation; either version 2 of the License, or 12 + (at your option) any later version. 13 + 14 + This program is distributed in the hope that it will be useful, 15 + but WITHOUT ANY WARRANTY; without even the implied warranty of 16 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 + GNU General Public License for more details. 18 + 19 + You should have received a copy of the GNU General Public License 20 + along with this program; if not, write to the Free Software 21 + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 + 23 + */ 24 + 25 + /* ----------------------------------------------------------------------- */ 26 + struct vp3054_i2c_state { 27 + struct i2c_adapter adap; 28 + struct i2c_algo_bit_data algo; 29 + struct i2c_client client; 30 + u32 state; 31 + }; 32 + 33 + /* ----------------------------------------------------------------------- */ 34 + int vp3054_i2c_probe(struct cx8802_dev *dev); 35 + void vp3054_i2c_remove(struct cx8802_dev *dev);
+16 -1
drivers/media/video/cx88/cx88.h
··· 179 179 #define CX88_BOARD_ATI_HDTVWONDER 34 180 180 #define CX88_BOARD_WINFAST_DTV1000 35 181 181 #define CX88_BOARD_AVERTV_303 36 182 + #define CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1 37 183 + #define CX88_BOARD_HAUPPAUGE_NOVASE2_S1 38 184 + #define CX88_BOARD_KWORLD_DVBS_100 39 185 + #define CX88_BOARD_HAUPPAUGE_HVR1100 40 186 + #define CX88_BOARD_HAUPPAUGE_HVR1100LP 41 187 + #define CX88_BOARD_DNTV_LIVE_DVB_T_PRO 42 188 + #define CX88_BOARD_KWORLD_DVB_T_CX22702 43 189 + #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL 44 182 190 183 191 enum cx88_itype { 184 192 CX88_VMUX_COMPOSITE1 = 1, ··· 288 280 unsigned int tda9887_conf; 289 281 unsigned int has_radio; 290 282 283 + /* Supported V4L _STD_ tuner formats */ 284 + unsigned int tuner_formats; 285 + 291 286 /* config info -- dvb */ 292 287 struct dvb_pll_desc *pll_desc; 293 288 unsigned int pll_addr; ··· 312 301 313 302 /* various v4l controls */ 314 303 u32 freq; 304 + 305 + /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ 306 + struct cx8802_dev *dvbdev; 315 307 }; 316 308 317 309 struct cx8800_dev; ··· 425 411 struct videobuf_dvb dvb; 426 412 void* fe_handle; 427 413 int (*fe_release)(void *handle); 414 + 415 + void *card_priv; 428 416 /* for switching modulation types */ 429 417 unsigned char ts_gen_cntrl; 430 418 ··· 463 447 464 448 extern void cx88_print_irqbits(char *name, char *tag, char **strings, 465 449 u32 bits, u32 mask); 466 - extern void cx88_print_ioctl(char *name, unsigned int cmd); 467 450 468 451 extern int cx88_core_irq(struct cx88_core *core, u32 status); 469 452 extern void cx88_wakeup(struct cx88_core *core,
+2 -6
drivers/media/video/em28xx/em28xx-cards.c
··· 30 30 #include <media/tuner.h> 31 31 #include <media/audiochip.h> 32 32 #include <media/tveeprom.h> 33 + #include <media/v4l2-common.h> 33 34 #include "msp3400.h" 34 35 35 36 #include "em28xx.h" ··· 262 261 /* request some modules */ 263 262 if (dev->model == EM2820_BOARD_HAUPPAUGE_WINTV_USB_2) { 264 263 struct tveeprom tv; 265 - struct v4l2_audioout ao; 266 264 #ifdef CONFIG_MODULES 267 265 request_module("tveeprom"); 268 266 request_module("ir-kbd-i2c"); ··· 274 274 275 275 dev->tuner_type= tv.tuner_type; 276 276 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) { 277 + dev->i2s_speed=2048000; 277 278 dev->has_msp34xx=1; 278 - memset (&ao,0,sizeof(ao)); 279 - 280 - ao.index=2; 281 - ao.mode=V4L2_AUDMODE_32BITS; 282 - em28xx_i2c_call_clients(dev, VIDIOC_S_AUDOUT, &ao); 283 279 } else 284 280 dev->has_msp34xx=0; 285 281 }
+4 -57
drivers/media/video/em28xx/em28xx-core.c
··· 32 32 33 33 /* #define ENABLE_DEBUG_ISOC_FRAMES */ 34 34 35 - static unsigned int core_debug; 35 + static unsigned int core_debug = 0; 36 36 module_param(core_debug,int,0644); 37 37 MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); 38 38 ··· 41 41 printk(KERN_INFO "%s %s :"fmt, \ 42 42 dev->name, __FUNCTION__ , ##arg); } while (0) 43 43 44 - static unsigned int reg_debug; 44 + static unsigned int reg_debug = 0; 45 45 module_param(reg_debug,int,0644); 46 46 MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]"); 47 47 ··· 50 50 printk(KERN_INFO "%s %s :"fmt, \ 51 51 dev->name, __FUNCTION__ , ##arg); } while (0) 52 52 53 - static unsigned int isoc_debug; 53 + static unsigned int isoc_debug = 0; 54 54 module_param(isoc_debug,int,0644); 55 55 MODULE_PARM_DESC(isoc_debug,"enable debug messages [isoc transfers]"); 56 56 ··· 63 63 module_param(alt, int, 0644); 64 64 MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); 65 65 66 - /* ------------------------------------------------------------------ */ 67 - /* debug help functions */ 68 - 69 - static const char *v4l1_ioctls[] = { 70 - "0", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER", "GPICT", "SPICT", 71 - "CCAPTURE", "GWIN", "SWIN", "GFBUF", "SFBUF", "KEY", "GFREQ", 72 - "SFREQ", "GAUDIO", "SAUDIO", "SYNC", "MCAPTURE", "GMBUF", "GUNIT", 73 - "GCAPTURE", "SCAPTURE", "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", 74 - "SMICROCODE", "GVBIFMT", "SVBIFMT" }; 75 - #define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls) 76 - 77 - static const char *v4l2_ioctls[] = { 78 - "QUERYCAP", "1", "ENUM_PIXFMT", "ENUM_FBUFFMT", "G_FMT", "S_FMT", 79 - "G_COMP", "S_COMP", "REQBUFS", "QUERYBUF", "G_FBUF", "S_FBUF", 80 - "G_WIN", "S_WIN", "PREVIEW", "QBUF", "16", "DQBUF", "STREAMON", 81 - "STREAMOFF", "G_PERF", "G_PARM", "S_PARM", "G_STD", "S_STD", 82 - "ENUMSTD", "ENUMINPUT", "G_CTRL", "S_CTRL", "G_TUNER", "S_TUNER", 83 - "G_FREQ", "S_FREQ", "G_AUDIO", "S_AUDIO", "35", "QUERYCTRL", 84 - "QUERYMENU", "G_INPUT", "S_INPUT", "ENUMCVT", "41", "42", "43", 85 - "44", "45", "G_OUTPUT", "S_OUTPUT", "ENUMOUTPUT", "G_AUDOUT", 86 - "S_AUDOUT", "ENUMFX", "G_EFFECT", "S_EFFECT", "G_MODULATOR", 87 - "S_MODULATOR" 88 - }; 89 - #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) 90 - 91 - void em28xx_print_ioctl(char *name, unsigned int cmd) 92 - { 93 - char *dir; 94 - 95 - switch (_IOC_DIR(cmd)) { 96 - case _IOC_NONE: dir = "--"; break; 97 - case _IOC_READ: dir = "r-"; break; 98 - case _IOC_WRITE: dir = "-w"; break; 99 - case _IOC_READ | _IOC_WRITE: dir = "rw"; break; 100 - default: dir = "??"; break; 101 - } 102 - switch (_IOC_TYPE(cmd)) { 103 - case 'v': 104 - printk(KERN_DEBUG "%s: ioctl 0x%08x (v4l1, %s, VIDIOC%s)\n", 105 - name, cmd, dir, (_IOC_NR(cmd) < V4L1_IOCTLS) ? 106 - v4l1_ioctls[_IOC_NR(cmd)] : "???"); 107 - break; 108 - case 'V': 109 - printk(KERN_DEBUG "%s: ioctl 0x%08x (v4l2, %s, VIDIOC_%s)\n", 110 - name, cmd, dir, (_IOC_NR(cmd) < V4L2_IOCTLS) ? 111 - v4l2_ioctls[_IOC_NR(cmd)] : "???"); 112 - break; 113 - default: 114 - printk(KERN_DEBUG "%s: ioctl 0x%08x (???, %s, #%d)\n", 115 - name, cmd, dir, _IOC_NR(cmd)); 116 - } 117 - } 118 - 119 66 120 67 /* 121 68 * em28xx_request_buffers() ··· 73 126 const size_t imagesize = PAGE_ALIGN(dev->frame_size); /*needs to be page aligned cause the buffers can be mapped individually! */ 74 127 void *buff = NULL; 75 128 u32 i; 76 - em28xx_coredbg("requested %i buffers with size %zd", count, imagesize); 129 + em28xx_coredbg("requested %i buffers with size %zi", count, imagesize); 77 130 if (count > EM28XX_NUM_FRAMES) 78 131 count = EM28XX_NUM_FRAMES; 79 132
+1 -2
drivers/media/video/em28xx/em28xx-i2c.c
··· 28 28 #include <linux/video_decoder.h> 29 29 30 30 #include "em28xx.h" 31 + #include <media/v4l2-common.h> 31 32 #include <media/tuner.h> 32 33 33 34 /* ----------------------------------------------------------- */ ··· 487 486 .inc_use = inc_use, 488 487 .dec_use = dec_use, 489 488 #endif 490 - #ifdef I2C_CLASS_TV_ANALOG 491 489 .class = I2C_CLASS_TV_ANALOG, 492 - #endif 493 490 .name = "em28xx", 494 491 .id = I2C_HW_B_EM28XX, 495 492 .algo = &em28xx_algo,
+127 -40
drivers/media/video/em28xx/em28xx-video.c
··· 32 32 33 33 #include "em28xx.h" 34 34 #include <media/tuner.h> 35 + #include <media/v4l2-common.h> 35 36 36 37 #define DRIVER_AUTHOR "Ludovico Cavedon <cavedon@sssup.it>, " \ 37 38 "Markus Rechberger <mrechberger@gmail.com>, " \ ··· 107 106 #define TVNORMS ARRAY_SIZE(tvnorms) 108 107 109 108 /* supported controls */ 109 + /* Common to all boards */ 110 110 static struct v4l2_queryctrl em28xx_qctrl[] = { 111 + { 112 + .id = V4L2_CID_AUDIO_VOLUME, 113 + .type = V4L2_CTRL_TYPE_INTEGER, 114 + .name = "Volume", 115 + .minimum = 0x0, 116 + .maximum = 0x1f, 117 + .step = 0x1, 118 + .default_value = 0x1f, 119 + .flags = 0, 120 + },{ 121 + .id = V4L2_CID_AUDIO_MUTE, 122 + .type = V4L2_CTRL_TYPE_BOOLEAN, 123 + .name = "Mute", 124 + .minimum = 0, 125 + .maximum = 1, 126 + .step = 1, 127 + .default_value = 1, 128 + .flags = 0, 129 + } 130 + }; 131 + 132 + /* FIXME: These are specific to saa711x - should be moved to its code */ 133 + static struct v4l2_queryctrl saa711x_qctrl[] = { 111 134 { 112 135 .id = V4L2_CID_BRIGHTNESS, 113 136 .type = V4L2_CTRL_TYPE_INTEGER, ··· 160 135 .default_value = 0x10, 161 136 .flags = 0, 162 137 },{ 163 - .id = V4L2_CID_AUDIO_VOLUME, 164 - .type = V4L2_CTRL_TYPE_INTEGER, 165 - .name = "Volume", 166 - .minimum = 0x0, 167 - .maximum = 0x1f, 168 - .step = 0x1, 169 - .default_value = 0x1f, 170 - .flags = 0, 171 - },{ 172 - .id = V4L2_CID_AUDIO_MUTE, 173 - .type = V4L2_CTRL_TYPE_BOOLEAN, 174 - .name = "Mute", 175 - .minimum = 0, 176 - .maximum = 1, 177 - .step = 1, 178 - .default_value = 1, 179 - .flags = 0, 180 - },{ 181 138 .id = V4L2_CID_RED_BALANCE, 182 139 .type = V4L2_CTRL_TYPE_INTEGER, 183 140 .name = "Red chroma balance", ··· 186 179 .step = 0x1, 187 180 .default_value = 0x20, 188 181 .flags = 0, 189 - } 182 + } 190 183 }; 191 184 192 185 static struct usb_driver em28xx_usb_driver; ··· 287 280 em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,input,dev->ctl_ainput); 288 281 289 282 if (dev->has_msp34xx) { 283 + if (dev->i2s_speed) 284 + em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed); 290 285 em28xx_i2c_call_clients(dev, VIDIOC_S_AUDIO, &dev->ctl_ainput); 291 286 ainput = EM28XX_AUDIO_SRC_TUNER; 292 287 em28xx_audio_source(dev, ainput); ··· 683 674 */ 684 675 static int em28xx_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl) 685 676 { 686 - s32 tmp; 687 677 switch (ctrl->id) { 688 678 case V4L2_CID_AUDIO_MUTE: 689 679 ctrl->value = dev->mute; ··· 690 682 case V4L2_CID_AUDIO_VOLUME: 691 683 ctrl->value = dev->volume; 692 684 return 0; 685 + default: 686 + return -EINVAL; 687 + } 688 + } 689 + 690 + /*FIXME: should be moved to saa711x */ 691 + static int saa711x_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl) 692 + { 693 + s32 tmp; 694 + switch (ctrl->id) { 693 695 case V4L2_CID_BRIGHTNESS: 694 696 if ((tmp = em28xx_brightness_get(dev)) < 0) 695 697 return -EIO; ··· 749 731 case V4L2_CID_AUDIO_VOLUME: 750 732 dev->volume = ctrl->value; 751 733 return em28xx_audio_analog_set(dev); 734 + default: 735 + return -EINVAL; 736 + } 737 + } 738 + 739 + /*FIXME: should be moved to saa711x */ 740 + static int saa711x_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl) 741 + { 742 + switch (ctrl->id) { 752 743 case V4L2_CID_BRIGHTNESS: 753 744 return em28xx_brightness_set(dev, ctrl->value); 754 745 case V4L2_CID_CONTRAST: ··· 1021 994 case VIDIOC_QUERYCTRL: 1022 995 { 1023 996 struct v4l2_queryctrl *qc = arg; 1024 - u8 i, n; 1025 - n = sizeof(em28xx_qctrl) / sizeof(em28xx_qctrl[0]); 1026 - for (i = 0; i < n; i++) 1027 - if (qc->id && qc->id == em28xx_qctrl[i].id) { 1028 - memcpy(qc, &(em28xx_qctrl[i]), 997 + int i, id=qc->id; 998 + 999 + memset(qc,0,sizeof(*qc)); 1000 + qc->id=id; 1001 + 1002 + if (!dev->has_msp34xx) { 1003 + for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { 1004 + if (qc->id && qc->id == em28xx_qctrl[i].id) { 1005 + memcpy(qc, &(em28xx_qctrl[i]), 1006 + sizeof(*qc)); 1007 + return 0; 1008 + } 1009 + } 1010 + } 1011 + if (dev->decoder == EM28XX_TVP5150) { 1012 + em28xx_i2c_call_clients(dev,cmd,qc); 1013 + if (qc->type) 1014 + return 0; 1015 + else 1016 + return -EINVAL; 1017 + } 1018 + for (i = 0; i < ARRAY_SIZE(saa711x_qctrl); i++) { 1019 + if (qc->id && qc->id == saa711x_qctrl[i].id) { 1020 + memcpy(qc, &(saa711x_qctrl[i]), 1029 1021 sizeof(*qc)); 1030 1022 return 0; 1031 1023 } 1024 + } 1032 1025 1033 1026 return -EINVAL; 1034 1027 } ··· 1056 1009 case VIDIOC_G_CTRL: 1057 1010 { 1058 1011 struct v4l2_control *ctrl = arg; 1012 + int retval=-EINVAL; 1059 1013 1014 + if (!dev->has_msp34xx) 1015 + retval=em28xx_get_ctrl(dev, ctrl); 1016 + if (retval==-EINVAL) { 1017 + if (dev->decoder == EM28XX_TVP5150) { 1018 + em28xx_i2c_call_clients(dev,cmd,arg); 1019 + return 0; 1020 + } 1060 1021 1061 - return em28xx_get_ctrl(dev, ctrl); 1022 + return saa711x_get_ctrl(dev, ctrl); 1023 + } else return retval; 1062 1024 } 1063 1025 1064 - case VIDIOC_S_CTRL_OLD: /* ??? */ 1065 1026 case VIDIOC_S_CTRL: 1066 1027 { 1067 1028 struct v4l2_control *ctrl = arg; 1068 - u8 i, n; 1029 + u8 i; 1069 1030 1070 - 1071 - n = sizeof(em28xx_qctrl) / sizeof(em28xx_qctrl[0]); 1072 - for (i = 0; i < n; i++) 1073 - if (ctrl->id == em28xx_qctrl[i].id) { 1074 - if (ctrl->value < 1075 - em28xx_qctrl[i].minimum 1076 - || ctrl->value > 1077 - em28xx_qctrl[i].maximum) 1078 - return -ERANGE; 1079 - 1080 - return em28xx_set_ctrl(dev, ctrl); 1031 + if (!dev->has_msp34xx){ 1032 + for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { 1033 + if (ctrl->id == em28xx_qctrl[i].id) { 1034 + if (ctrl->value < 1035 + em28xx_qctrl[i].minimum 1036 + || ctrl->value > 1037 + em28xx_qctrl[i].maximum) 1038 + return -ERANGE; 1039 + return em28xx_set_ctrl(dev, ctrl); 1040 + } 1081 1041 } 1042 + } 1043 + 1044 + if (dev->decoder == EM28XX_TVP5150) { 1045 + em28xx_i2c_call_clients(dev,cmd,arg); 1046 + return 0; 1047 + } else if (!dev->has_msp34xx) { 1048 + for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { 1049 + if (ctrl->id == em28xx_qctrl[i].id) { 1050 + if (ctrl->value < 1051 + em28xx_qctrl[i].minimum 1052 + || ctrl->value > 1053 + em28xx_qctrl[i].maximum) 1054 + return -ERANGE; 1055 + return em28xx_set_ctrl(dev, ctrl); 1056 + } 1057 + } 1058 + for (i = 0; i < ARRAY_SIZE(saa711x_qctrl); i++) { 1059 + if (ctrl->id == saa711x_qctrl[i].id) { 1060 + if (ctrl->value < 1061 + saa711x_qctrl[i].minimum 1062 + || ctrl->value > 1063 + saa711x_qctrl[i].maximum) 1064 + return -ERANGE; 1065 + return saa711x_set_ctrl(dev, ctrl); 1066 + } 1067 + } 1068 + } 1069 + 1082 1070 return -EINVAL; 1083 1071 } 1084 1072 ··· 1269 1187 return -ENODEV; 1270 1188 1271 1189 if (video_debug > 1) 1272 - em28xx_print_ioctl(dev->name,cmd); 1190 + v4l_print_ioctl(dev->name,cmd); 1273 1191 1274 1192 switch (cmd) { 1275 1193 ··· 1646 1564 .poll = em28xx_v4l2_poll, 1647 1565 .mmap = em28xx_v4l2_mmap, 1648 1566 .llseek = no_llseek, 1567 + .compat_ioctl = v4l_compat_ioctl32, 1568 + 1649 1569 }; 1650 1570 1651 1571 /******************************** usb interface *****************************************/ ··· 1932 1848 struct em28xx *dev = usb_get_intfdata(interface); 1933 1849 usb_set_intfdata(interface, NULL); 1934 1850 1851 + /*FIXME: IR should be disconnected */ 1852 + 1935 1853 if (!dev) 1936 1854 return; 1855 + 1937 1856 1938 1857 down_write(&em28xx_disconnect); 1939 1858
+3 -3
drivers/media/video/em28xx/em28xx.h
··· 1 1 /* 2 - em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB video capture devices 2 + em28xx.h - driver for Empia EM2800/EM2820/2840 USB video capture devices 3 3 4 4 Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com> 5 5 Ludovico Cavedon <cavedon@sssup.it> ··· 216 216 unsigned int has_msp34xx:1; 217 217 unsigned int has_tda9887:1; 218 218 219 + u32 i2s_speed; /* I2S speed for audio digital stream */ 220 + 219 221 enum em28xx_decoder decoder; 220 222 221 223 int tuner_type; /* type of the tuner */ ··· 294 292 void em28xx_set_ir(struct em28xx * dev,struct IR_i2c *ir); 295 293 296 294 /* Provided by em28xx-core.c */ 297 - 298 - void em28xx_print_ioctl(char *name, unsigned int cmd); 299 295 300 296 u32 em28xx_request_buffers(struct em28xx *dev, u32 count); 301 297 void em28xx_queue_unusedframes(struct em28xx *dev);
+88 -168
drivers/media/video/ir-kbd-gpio.c drivers/media/video/bttv-input.c
··· 24 24 #include <linux/delay.h> 25 25 #include <linux/interrupt.h> 26 26 #include <linux/input.h> 27 - #include <linux/pci.h> 28 - 29 - #include <media/ir-common.h> 30 27 31 28 #include "bttv.h" 29 + #include "bttvp.h" 32 30 33 31 /* ---------------------------------------------------------------------- */ 34 32 ··· 154 156 155 157 /* ---------------------------------------------------------------------- */ 156 158 157 - /* Ricardo Cerqueira <v4l@cerqueira.org> */ 158 - /* Weird matching, since the remote has "uncommon" keys */ 159 - 160 159 static IR_KEYTAB_TYPE ir_codes_conceptronic[IR_KEYTAB_SIZE] = { 161 160 162 161 [ 30 ] = KEY_POWER, // power ··· 274 279 [0x36] = KEY_PC 275 280 }; 276 281 277 - struct IR { 278 - struct bttv_sub_device *sub; 279 - struct input_dev *input; 280 - struct ir_input_state ir; 281 - char name[32]; 282 - char phys[32]; 283 - 284 - /* Usual gpio signalling */ 285 - 286 - u32 mask_keycode; 287 - u32 mask_keydown; 288 - u32 mask_keyup; 289 - u32 polling; 290 - u32 last_gpio; 291 - struct work_struct work; 292 - struct timer_list timer; 293 - 294 - /* RC5 gpio */ 295 - u32 rc5_gpio; 296 - struct timer_list timer_end; /* timer_end for code completion */ 297 - struct timer_list timer_keyup; /* timer_end for key release */ 298 - u32 last_rc5; /* last good rc5 code */ 299 - u32 last_bit; /* last raw bit seen */ 300 - u32 code; /* raw code under construction */ 301 - struct timeval base_time; /* time of last seen code */ 302 - int active; /* building raw code */ 303 - }; 304 - 305 282 static int debug; 306 283 module_param(debug, int, 0644); /* debug level (0,1,2) */ 307 284 static int repeat_delay = 500; ··· 281 314 static int repeat_period = 33; 282 315 module_param(repeat_period, int, 0644); 283 316 284 - #define DEVNAME "ir-kbd-gpio" 285 - #define dprintk(fmt, arg...) if (debug) \ 286 - printk(KERN_DEBUG DEVNAME ": " fmt , ## arg) 287 - 288 - static void ir_irq(struct bttv_sub_device *sub); 289 - static int ir_probe(struct device *dev); 290 - static int ir_remove(struct device *dev); 291 - 292 - static struct bttv_sub_driver driver = { 293 - .drv = { 294 - .name = DEVNAME, 295 - .probe = ir_probe, 296 - .remove = ir_remove, 297 - }, 298 - .gpio_irq = ir_irq, 299 - }; 317 + #define DEVNAME "bttv-input" 300 318 301 319 /* ---------------------------------------------------------------------- */ 302 320 303 - static void ir_handle_key(struct IR *ir) 321 + static void ir_handle_key(struct bttv *btv) 304 322 { 323 + struct bttv_ir *ir = btv->remote; 305 324 u32 gpio,data; 306 325 307 326 /* read gpio value */ 308 - gpio = bttv_gpio_read(ir->sub->core); 327 + gpio = bttv_gpio_read(&btv->c); 309 328 if (ir->polling) { 310 329 if (ir->last_gpio == gpio) 311 330 return; ··· 300 347 301 348 /* extract data */ 302 349 data = ir_extract_bits(gpio, ir->mask_keycode); 303 - dprintk(DEVNAME ": irq gpio=0x%x code=%d | %s%s%s\n", 350 + dprintk(KERN_INFO DEVNAME ": irq gpio=0x%x code=%d | %s%s%s\n", 304 351 gpio, data, 305 352 ir->polling ? "poll" : "irq", 306 353 (gpio & ir->mask_keydown) ? " down" : "", 307 354 (gpio & ir->mask_keyup) ? " up" : ""); 308 355 309 - if (ir->mask_keydown) { 310 - /* bit set on keydown */ 311 - if (gpio & ir->mask_keydown) { 312 - ir_input_keydown(ir->input, &ir->ir, data, data); 313 - } else { 314 - ir_input_nokey(ir->input, &ir->ir); 315 - } 316 - 317 - } else if (ir->mask_keyup) { 318 - /* bit cleared on keydown */ 319 - if (0 == (gpio & ir->mask_keyup)) { 320 - ir_input_keydown(ir->input, &ir->ir, data, data); 321 - } else { 322 - ir_input_nokey(ir->input, &ir->ir); 323 - } 324 - 356 + if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 357 + (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 358 + ir_input_keydown(ir->dev,&ir->ir,data,data); 325 359 } else { 326 - /* can't disturgissh keydown/up :-/ */ 327 - ir_input_keydown(ir->input, &ir->ir, data, data); 328 - ir_input_nokey(ir->input, &ir->ir); 360 + ir_input_nokey(ir->dev,&ir->ir); 329 361 } 362 + 330 363 } 331 364 332 - static void ir_irq(struct bttv_sub_device *sub) 365 + void bttv_input_irq(struct bttv *btv) 333 366 { 334 - struct IR *ir = dev_get_drvdata(&sub->dev); 367 + struct bttv_ir *ir = btv->remote; 335 368 336 369 if (!ir->polling) 337 - ir_handle_key(ir); 370 + ir_handle_key(btv); 338 371 } 339 372 340 - static void ir_timer(unsigned long data) 373 + static void bttv_input_timer(unsigned long data) 341 374 { 342 - struct IR *ir = (struct IR*)data; 343 - 344 - schedule_work(&ir->work); 345 - } 346 - 347 - static void ir_work(void *data) 348 - { 349 - struct IR *ir = data; 375 + struct bttv *btv = (struct bttv*)data; 376 + struct bttv_ir *ir = btv->remote; 350 377 unsigned long timeout; 351 378 352 - ir_handle_key(ir); 379 + ir_handle_key(btv); 353 380 timeout = jiffies + (ir->polling * HZ / 1000); 354 381 mod_timer(&ir->timer, timeout); 355 382 } ··· 368 435 rc5 |= 1; 369 436 break; 370 437 case 3: 371 - dprintk("bad code: %x\n", org_code); 438 + dprintk(KERN_WARNING "bad code: %x\n", org_code); 372 439 return 0; 373 440 } 374 441 } 375 - dprintk("code=%x, rc5=%x, start=%x, toggle=%x, address=%x, " 442 + dprintk(KERN_WARNING "code=%x, rc5=%x, start=%x, toggle=%x, address=%x, " 376 443 "instr=%x\n", rc5, org_code, RC5_START(rc5), 377 444 RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5)); 378 445 return rc5; 379 446 } 380 447 381 - static int ir_rc5_irq(struct bttv_sub_device *sub) 448 + static int bttv_rc5_irq(struct bttv *btv) 382 449 { 383 - struct IR *ir = dev_get_drvdata(&sub->dev); 450 + struct bttv_ir *ir = btv->remote; 384 451 struct timeval tv; 385 452 u32 gpio; 386 453 u32 gap; 387 454 unsigned long current_jiffies, timeout; 388 455 389 456 /* read gpio port */ 390 - gpio = bttv_gpio_read(ir->sub->core); 457 + gpio = bttv_gpio_read(&btv->c); 391 458 392 459 /* remote IRQ? */ 393 460 if (!(gpio & 0x20)) ··· 426 493 } 427 494 428 495 /* toggle GPIO pin 4 to reset the irq */ 429 - bttv_gpio_write(ir->sub->core, gpio & ~(1 << 4)); 430 - bttv_gpio_write(ir->sub->core, gpio | (1 << 4)); 496 + bttv_gpio_write(&btv->c, gpio & ~(1 << 4)); 497 + bttv_gpio_write(&btv->c, gpio | (1 << 4)); 431 498 return 1; 432 499 } 433 500 434 - static void ir_rc5_timer_end(unsigned long data) 501 + 502 + static void bttv_rc5_timer_end(unsigned long data) 435 503 { 436 - struct IR *ir = (struct IR *)data; 504 + struct bttv_ir *ir = (struct bttv_ir *)data; 437 505 struct timeval tv; 438 506 unsigned long current_jiffies, timeout; 439 507 u32 gap; ··· 453 519 454 520 /* Allow some timmer jitter (RC5 is ~24ms anyway so this is ok) */ 455 521 if (gap < 28000) { 456 - dprintk("spurious timer_end\n"); 522 + dprintk(KERN_WARNING "spurious timer_end\n"); 457 523 return; 458 524 } 459 525 460 526 ir->active = 0; 461 527 if (ir->last_bit < 20) { 462 528 /* ignore spurious codes (caused by light/other remotes) */ 463 - dprintk("short code: %x\n", ir->code); 529 + dprintk(KERN_WARNING "short code: %x\n", ir->code); 464 530 } else { 465 531 u32 rc5 = rc5_decode(ir->code); 466 532 467 533 /* two start bits? */ 468 534 if (RC5_START(rc5) != 3) { 469 - dprintk("rc5 start bits invalid: %u\n", RC5_START(rc5)); 535 + dprintk(KERN_WARNING "rc5 start bits invalid: %u\n", RC5_START(rc5)); 470 536 471 537 /* right address? */ 472 538 } else if (RC5_ADDR(rc5) == 0x0) { ··· 476 542 /* Good code, decide if repeat/repress */ 477 543 if (toggle != RC5_TOGGLE(ir->last_rc5) || 478 544 instr != RC5_INSTR(ir->last_rc5)) { 479 - dprintk("instruction %x, toggle %x\n", instr, 545 + dprintk(KERN_WARNING "instruction %x, toggle %x\n", instr, 480 546 toggle); 481 - ir_input_nokey(ir->input, &ir->ir); 482 - ir_input_keydown(ir->input, &ir->ir, instr, 547 + ir_input_nokey(ir->dev, &ir->ir); 548 + ir_input_keydown(ir->dev, &ir->ir, instr, 483 549 instr); 484 550 } 485 551 ··· 494 560 } 495 561 } 496 562 497 - static void ir_rc5_timer_keyup(unsigned long data) 563 + static void bttv_rc5_timer_keyup(unsigned long data) 498 564 { 499 - struct IR *ir = (struct IR *)data; 565 + struct bttv_ir *ir = (struct bttv_ir *)data; 500 566 501 - dprintk("key released\n"); 502 - ir_input_nokey(ir->input, &ir->ir); 567 + dprintk(KERN_DEBUG "key released\n"); 568 + ir_input_nokey(ir->dev, &ir->ir); 503 569 } 504 570 505 571 /* ---------------------------------------------------------------------- */ 506 572 507 - static int ir_probe(struct device *dev) 573 + int bttv_input_init(struct bttv *btv) 508 574 { 509 - struct bttv_sub_device *sub = to_bttv_sub_dev(dev); 510 - struct IR *ir; 511 - struct input_dev *input_dev; 575 + struct bttv_ir *ir; 512 576 IR_KEYTAB_TYPE *ir_codes = NULL; 577 + struct input_dev *input_dev; 513 578 int ir_type = IR_TYPE_OTHER; 514 579 515 - ir = kzalloc(sizeof(*ir), GFP_KERNEL); 580 + if (!btv->has_remote) 581 + return -ENODEV; 582 + 583 + ir = kzalloc(sizeof(*ir),GFP_KERNEL); 516 584 input_dev = input_allocate_device(); 517 585 if (!ir || !input_dev) { 518 586 kfree(ir); 519 587 input_free_device(input_dev); 520 588 return -ENOMEM; 521 589 } 590 + memset(ir,0,sizeof(*ir)); 522 591 523 592 /* detect & configure */ 524 - switch (sub->core->type) { 593 + switch (btv->c.type) { 525 594 case BTTV_BOARD_AVERMEDIA: 526 595 case BTTV_BOARD_AVPHONE98: 527 596 case BTTV_BOARD_AVERMEDIA98: ··· 580 643 break; 581 644 case BTTV_BOARD_NEBULA_DIGITV: 582 645 ir_codes = ir_codes_nebula; 583 - driver.any_irq = ir_rc5_irq; 584 - driver.gpio_irq = NULL; 646 + btv->custom_irq = bttv_rc5_irq; 585 647 ir->rc5_gpio = 1; 586 648 break; 587 649 } 588 650 if (NULL == ir_codes) { 651 + dprintk(KERN_INFO "Ooops: IR config error [card=%d]\n",btv->c.type); 589 652 kfree(ir); 590 653 input_free_device(input_dev); 591 654 return -ENODEV; ··· 594 657 if (ir->rc5_gpio) { 595 658 u32 gpio; 596 659 /* enable remote irq */ 597 - bttv_gpio_inout(sub->core, (1 << 4), 1 << 4); 598 - gpio = bttv_gpio_read(sub->core); 599 - bttv_gpio_write(sub->core, gpio & ~(1 << 4)); 600 - bttv_gpio_write(sub->core, gpio | (1 << 4)); 660 + bttv_gpio_inout(&btv->c, (1 << 4), 1 << 4); 661 + gpio = bttv_gpio_read(&btv->c); 662 + bttv_gpio_write(&btv->c, gpio & ~(1 << 4)); 663 + bttv_gpio_write(&btv->c, gpio | (1 << 4)); 601 664 } else { 602 665 /* init hardware-specific stuff */ 603 - bttv_gpio_inout(sub->core, ir->mask_keycode | ir->mask_keydown, 0); 666 + bttv_gpio_inout(&btv->c, ir->mask_keycode | ir->mask_keydown, 0); 604 667 } 605 668 606 669 /* init input device */ 670 + ir->dev = input_dev; 671 + 607 672 snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)", 608 - sub->core->type); 673 + btv->c.type); 609 674 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 610 - pci_name(sub->core->pci)); 675 + pci_name(btv->c.pci)); 611 676 612 677 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); 613 678 input_dev->name = ir->name; 614 679 input_dev->phys = ir->phys; 615 680 input_dev->id.bustype = BUS_PCI; 616 681 input_dev->id.version = 1; 617 - if (sub->core->pci->subsystem_vendor) { 618 - input_dev->id.vendor = sub->core->pci->subsystem_vendor; 619 - input_dev->id.product = sub->core->pci->subsystem_device; 682 + if (btv->c.pci->subsystem_vendor) { 683 + input_dev->id.vendor = btv->c.pci->subsystem_vendor; 684 + input_dev->id.product = btv->c.pci->subsystem_device; 620 685 } else { 621 - input_dev->id.vendor = sub->core->pci->vendor; 622 - input_dev->id.product = sub->core->pci->device; 686 + input_dev->id.vendor = btv->c.pci->vendor; 687 + input_dev->id.product = btv->c.pci->device; 623 688 } 624 - input_dev->cdev.dev = &sub->core->pci->dev; 689 + input_dev->cdev.dev = &btv->c.pci->dev; 625 690 626 - ir->input = input_dev; 627 - ir->sub = sub; 628 - 691 + btv->remote = ir; 629 692 if (ir->polling) { 630 - INIT_WORK(&ir->work, ir_work, ir); 631 693 init_timer(&ir->timer); 632 - ir->timer.function = ir_timer; 633 - ir->timer.data = (unsigned long)ir; 634 - schedule_work(&ir->work); 694 + ir->timer.function = bttv_input_timer; 695 + ir->timer.data = (unsigned long)btv; 696 + ir->timer.expires = jiffies + HZ; 697 + add_timer(&ir->timer); 635 698 } else if (ir->rc5_gpio) { 636 699 /* set timer_end for code completion */ 637 700 init_timer(&ir->timer_end); 638 - ir->timer_end.function = ir_rc5_timer_end; 701 + ir->timer_end.function = bttv_rc5_timer_end; 639 702 ir->timer_end.data = (unsigned long)ir; 640 703 641 704 init_timer(&ir->timer_keyup); 642 - ir->timer_keyup.function = ir_rc5_timer_keyup; 705 + ir->timer_keyup.function = bttv_rc5_timer_keyup; 643 706 ir->timer_keyup.data = (unsigned long)ir; 644 707 } 645 708 646 709 /* all done */ 647 - dev_set_drvdata(dev, ir); 648 - input_register_device(ir->input); 710 + input_register_device(btv->remote->dev); 711 + printk(DEVNAME ": %s detected at %s\n",ir->name,ir->phys); 649 712 650 713 /* the remote isn't as bouncy as a keyboard */ 651 - ir->input->rep[REP_DELAY] = repeat_delay; 652 - ir->input->rep[REP_PERIOD] = repeat_period; 714 + ir->dev->rep[REP_DELAY] = repeat_delay; 715 + ir->dev->rep[REP_PERIOD] = repeat_period; 653 716 654 717 return 0; 655 718 } 656 719 657 - static int ir_remove(struct device *dev) 720 + void bttv_input_fini(struct bttv *btv) 658 721 { 659 - struct IR *ir = dev_get_drvdata(dev); 722 + if (btv->remote == NULL) 723 + return; 660 724 661 - if (ir->polling) { 662 - del_timer(&ir->timer); 725 + if (btv->remote->polling) { 726 + del_timer_sync(&btv->remote->timer); 663 727 flush_scheduled_work(); 664 728 } 665 729 666 - if (ir->rc5_gpio) { 730 + 731 + if (btv->remote->rc5_gpio) { 667 732 u32 gpio; 668 733 669 - del_timer(&ir->timer_end); 734 + del_timer_sync(&btv->remote->timer_end); 670 735 flush_scheduled_work(); 671 736 672 - gpio = bttv_gpio_read(ir->sub->core); 673 - bttv_gpio_write(ir->sub->core, gpio & ~(1 << 4)); 737 + gpio = bttv_gpio_read(&btv->c); 738 + bttv_gpio_write(&btv->c, gpio & ~(1 << 4)); 674 739 } 675 740 676 - input_unregister_device(ir->input); 677 - kfree(ir); 678 - return 0; 741 + input_unregister_device(btv->remote->dev); 742 + kfree(btv->remote); 743 + btv->remote = NULL; 679 744 } 680 - 681 - /* ---------------------------------------------------------------------- */ 682 - 683 - MODULE_AUTHOR("Gerd Knorr, Pavel Machek"); 684 - MODULE_DESCRIPTION("input driver for bt8x8 gpio IR remote controls"); 685 - MODULE_LICENSE("GPL"); 686 - 687 - static int ir_init(void) 688 - { 689 - return bttv_sub_register(&driver, "remote"); 690 - } 691 - 692 - static void ir_fini(void) 693 - { 694 - bttv_sub_unregister(&driver); 695 - } 696 - 697 - module_init(ir_init); 698 - module_exit(ir_fini); 699 745 700 746 701 747 /*
+11 -7
drivers/media/video/ir-kbd-i2c.c
··· 279 279 280 280 static struct i2c_driver driver = { 281 281 .driver = { 282 - .name = "ir remote kbd driver", 282 + .name = "ir-kbd-i2c", 283 283 }, 284 284 .id = I2C_DRIVERID_INFRARED, 285 285 .attach_adapter = ir_probe, ··· 304 304 ir = kzalloc(sizeof(struct IR_i2c),GFP_KERNEL); 305 305 input_dev = input_allocate_device(); 306 306 if (!ir || !input_dev) { 307 - kfree(ir); 308 307 input_free_device(input_dev); 308 + kfree(ir); 309 309 return -ENOMEM; 310 310 } 311 + memset(ir,0,sizeof(*ir)); 311 312 312 313 ir->c = client_template; 313 314 ir->input = input_dev; 314 315 315 - i2c_set_clientdata(&ir->c, ir); 316 316 ir->c.adapter = adap; 317 317 ir->c.addr = addr; 318 + 319 + i2c_set_clientdata(&ir->c, ir); 318 320 319 321 switch(addr) { 320 322 case 0x64: ··· 380 378 ir->c.dev.bus_id); 381 379 382 380 /* init + register input device */ 383 - ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); 384 - input_dev->id.bustype = BUS_I2C; 385 - input_dev->name = ir->c.name; 386 - input_dev->phys = ir->phys; 381 + ir_input_init(input_dev,&ir->ir,ir_type,ir->ir_codes); 382 + input_dev->id.bustype = BUS_I2C; 383 + input_dev->name = ir->c.name; 384 + input_dev->phys = ir->phys; 387 385 388 386 /* register event device */ 389 387 input_register_device(ir->input); 388 + printk(DEVNAME ": %s detected at %s [%s]\n", 389 + ir->input->name,ir->input->phys,adap->name); 390 390 391 391 /* start polling via eventd */ 392 392 INIT_WORK(&ir->work, ir_work, ir);
+1
drivers/media/video/meye.c
··· 1754 1754 .release = meye_release, 1755 1755 .mmap = meye_mmap, 1756 1756 .ioctl = meye_ioctl, 1757 + .compat_ioctl = v4l_compat_ioctl32, 1757 1758 .poll = meye_poll, 1758 1759 .llseek = no_llseek, 1759 1760 };
+1274
drivers/media/video/msp3400-driver.c
··· 1 + /* 2 + * Programming the mspx4xx sound processor family 3 + * 4 + * (c) 1997-2001 Gerd Knorr <kraxel@bytesex.org> 5 + * 6 + * what works and what doesn't: 7 + * 8 + * AM-Mono 9 + * Support for Hauppauge cards added (decoding handled by tuner) added by 10 + * Frederic Crozat <fcrozat@mail.dotcom.fr> 11 + * 12 + * FM-Mono 13 + * should work. The stereo modes are backward compatible to FM-mono, 14 + * therefore FM-Mono should be allways available. 15 + * 16 + * FM-Stereo (B/G, used in germany) 17 + * should work, with autodetect 18 + * 19 + * FM-Stereo (satellite) 20 + * should work, no autodetect (i.e. default is mono, but you can 21 + * switch to stereo -- untested) 22 + * 23 + * NICAM (B/G, L , used in UK, Scandinavia, Spain and France) 24 + * should work, with autodetect. Support for NICAM was added by 25 + * Pekka Pietikainen <pp@netppl.fi> 26 + * 27 + * TODO: 28 + * - better SAT support 29 + * 30 + * 980623 Thomas Sailer (sailer@ife.ee.ethz.ch) 31 + * using soundcore instead of OSS 32 + * 33 + * This program is free software; you can redistribute it and/or 34 + * modify it under the terms of the GNU General Public License 35 + * as published by the Free Software Foundation; either version 2 36 + * of the License, or (at your option) any later version. 37 + * 38 + * This program is distributed in the hope that it will be useful, 39 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 40 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 41 + * GNU General Public License for more details. 42 + * 43 + * You should have received a copy of the GNU General Public License 44 + * along with this program; if not, write to the Free Software 45 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 46 + */ 47 + 48 + 49 + #include <linux/kernel.h> 50 + #include <linux/module.h> 51 + #include <linux/slab.h> 52 + #include <linux/i2c.h> 53 + #include <linux/videodev.h> 54 + #include <linux/videodev2.h> 55 + #include <media/v4l2-common.h> 56 + #include <media/audiochip.h> 57 + #include <linux/kthread.h> 58 + #include <linux/suspend.h> 59 + #include "msp3400.h" 60 + 61 + /* ---------------------------------------------------------------------- */ 62 + 63 + MODULE_DESCRIPTION("device driver for msp34xx TV sound processor"); 64 + MODULE_AUTHOR("Gerd Knorr"); 65 + MODULE_LICENSE("GPL"); 66 + 67 + /* module parameters */ 68 + static int opmode = OPMODE_AUTO; 69 + int debug = 0; /* debug output */ 70 + int once = 0; /* no continous stereo monitoring */ 71 + int amsound = 0; /* hard-wire AM sound at 6.5 Hz (france), 72 + the autoscan seems work well only with FM... */ 73 + int standard = 1; /* Override auto detect of audio standard, if needed. */ 74 + int dolby = 0; 75 + 76 + int stereo_threshold = 0x190; /* a2 threshold for stereo/bilingual 77 + (msp34xxg only) 0x00a0-0x03c0 */ 78 + 79 + /* read-only */ 80 + module_param(opmode, int, 0444); 81 + 82 + /* read-write */ 83 + module_param(once, bool, 0644); 84 + module_param(debug, int, 0644); 85 + module_param(stereo_threshold, int, 0644); 86 + module_param(standard, int, 0644); 87 + module_param(amsound, bool, 0644); 88 + module_param(dolby, bool, 0644); 89 + 90 + MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Autodetect, 2=Autodetect and autoselect"); 91 + MODULE_PARM_DESC(once, "No continuous stereo monitoring"); 92 + MODULE_PARM_DESC(debug, "Enable debug messages [0-3]"); 93 + MODULE_PARM_DESC(stereo_threshold, "Sets signal threshold to activate stereo"); 94 + MODULE_PARM_DESC(standard, "Specify audio standard: 32 = NTSC, 64 = radio, Default: Autodetect"); 95 + MODULE_PARM_DESC(amsound, "Hardwire AM sound at 6.5Hz (France), FM can autoscan"); 96 + MODULE_PARM_DESC(dolby, "Activates Dolby processsing"); 97 + 98 + /* ---------------------------------------------------------------------- */ 99 + 100 + /* control subaddress */ 101 + #define I2C_MSP_CONTROL 0x00 102 + /* demodulator unit subaddress */ 103 + #define I2C_MSP_DEM 0x10 104 + /* DSP unit subaddress */ 105 + #define I2C_MSP_DSP 0x12 106 + 107 + /* Addresses to scan */ 108 + static unsigned short normal_i2c[] = { 0x80 >> 1, 0x88 >> 1, I2C_CLIENT_END }; 109 + I2C_CLIENT_INSMOD; 110 + 111 + /* ----------------------------------------------------------------------- */ 112 + /* functions for talking to the MSP3400C Sound processor */ 113 + 114 + int msp_reset(struct i2c_client *client) 115 + { 116 + /* reset and read revision code */ 117 + static u8 reset_off[3] = { I2C_MSP_CONTROL, 0x80, 0x00 }; 118 + static u8 reset_on[3] = { I2C_MSP_CONTROL, 0x00, 0x00 }; 119 + static u8 write[3] = { I2C_MSP_DSP + 1, 0x00, 0x1e }; 120 + u8 read[2]; 121 + struct i2c_msg reset[2] = { 122 + { client->addr, I2C_M_IGNORE_NAK, 3, reset_off }, 123 + { client->addr, I2C_M_IGNORE_NAK, 3, reset_on }, 124 + }; 125 + struct i2c_msg test[2] = { 126 + { client->addr, 0, 3, write }, 127 + { client->addr, I2C_M_RD, 2, read }, 128 + }; 129 + 130 + v4l_dbg(3, client, "msp_reset\n"); 131 + if (i2c_transfer(client->adapter, &reset[0], 1) != 1 || 132 + i2c_transfer(client->adapter, &reset[1], 1) != 1 || 133 + i2c_transfer(client->adapter, test, 2) != 2) { 134 + v4l_err(client, "chip reset failed\n"); 135 + return -1; 136 + } 137 + return 0; 138 + } 139 + 140 + static int msp_read(struct i2c_client *client, int dev, int addr) 141 + { 142 + int err, retval; 143 + u8 write[3]; 144 + u8 read[2]; 145 + struct i2c_msg msgs[2] = { 146 + { client->addr, 0, 3, write }, 147 + { client->addr, I2C_M_RD, 2, read } 148 + }; 149 + 150 + write[0] = dev + 1; 151 + write[1] = addr >> 8; 152 + write[2] = addr & 0xff; 153 + 154 + for (err = 0; err < 3; err++) { 155 + if (i2c_transfer(client->adapter, msgs, 2) == 2) 156 + break; 157 + v4l_warn(client, "I/O error #%d (read 0x%02x/0x%02x)\n", err, 158 + dev, addr); 159 + current->state = TASK_INTERRUPTIBLE; 160 + schedule_timeout(msecs_to_jiffies(10)); 161 + } 162 + if (err == 3) { 163 + v4l_warn(client, "giving up, resetting chip. Sound will go off, sorry folks :-|\n"); 164 + msp_reset(client); 165 + return -1; 166 + } 167 + retval = read[0] << 8 | read[1]; 168 + v4l_dbg(3, client, "msp_read(0x%x, 0x%x): 0x%x\n", dev, addr, retval); 169 + return retval; 170 + } 171 + 172 + int msp_read_dem(struct i2c_client *client, int addr) 173 + { 174 + return msp_read(client, I2C_MSP_DEM, addr); 175 + } 176 + 177 + int msp_read_dsp(struct i2c_client *client, int addr) 178 + { 179 + return msp_read(client, I2C_MSP_DSP, addr); 180 + } 181 + 182 + static int msp_write(struct i2c_client *client, int dev, int addr, int val) 183 + { 184 + int err; 185 + u8 buffer[5]; 186 + 187 + buffer[0] = dev; 188 + buffer[1] = addr >> 8; 189 + buffer[2] = addr & 0xff; 190 + buffer[3] = val >> 8; 191 + buffer[4] = val & 0xff; 192 + 193 + v4l_dbg(3, client, "msp_write(0x%x, 0x%x, 0x%x)\n", dev, addr, val); 194 + for (err = 0; err < 3; err++) { 195 + if (i2c_master_send(client, buffer, 5) == 5) 196 + break; 197 + v4l_warn(client, "I/O error #%d (write 0x%02x/0x%02x)\n", err, 198 + dev, addr); 199 + current->state = TASK_INTERRUPTIBLE; 200 + schedule_timeout(msecs_to_jiffies(10)); 201 + } 202 + if (err == 3) { 203 + v4l_warn(client, "giving up, resetting chip. Sound will go off, sorry folks :-|\n"); 204 + msp_reset(client); 205 + return -1; 206 + } 207 + return 0; 208 + } 209 + 210 + int msp_write_dem(struct i2c_client *client, int addr, int val) 211 + { 212 + return msp_write(client, I2C_MSP_DEM, addr, val); 213 + } 214 + 215 + int msp_write_dsp(struct i2c_client *client, int addr, int val) 216 + { 217 + return msp_write(client, I2C_MSP_DSP, addr, val); 218 + } 219 + 220 + /* ----------------------------------------------------------------------- * 221 + * bits 9 8 5 - SCART DSP input Select: 222 + * 0 0 0 - SCART 1 to DSP input (reset position) 223 + * 0 1 0 - MONO to DSP input 224 + * 1 0 0 - SCART 2 to DSP input 225 + * 1 1 1 - Mute DSP input 226 + * 227 + * bits 11 10 6 - SCART 1 Output Select: 228 + * 0 0 0 - undefined (reset position) 229 + * 0 1 0 - SCART 2 Input to SCART 1 Output (for devices with 2 SCARTS) 230 + * 1 0 0 - MONO input to SCART 1 Output 231 + * 1 1 0 - SCART 1 DA to SCART 1 Output 232 + * 0 0 1 - SCART 2 DA to SCART 1 Output 233 + * 0 1 1 - SCART 1 Input to SCART 1 Output 234 + * 1 1 1 - Mute SCART 1 Output 235 + * 236 + * bits 13 12 7 - SCART 2 Output Select (for devices with 2 Output SCART): 237 + * 0 0 0 - SCART 1 DA to SCART 2 Output (reset position) 238 + * 0 1 0 - SCART 1 Input to SCART 2 Output 239 + * 1 0 0 - MONO input to SCART 2 Output 240 + * 0 0 1 - SCART 2 DA to SCART 2 Output 241 + * 0 1 1 - SCART 2 Input to SCART 2 Output 242 + * 1 1 0 - Mute SCART 2 Output 243 + * 244 + * Bits 4 to 0 should be zero. 245 + * ----------------------------------------------------------------------- */ 246 + 247 + static int scarts[3][9] = { 248 + /* MASK IN1 IN2 IN1_DA IN2_DA IN3 IN4 MONO MUTE */ 249 + /* SCART DSP Input select */ 250 + { 0x0320, 0x0000, 0x0200, -1, -1, 0x0300, 0x0020, 0x0100, 0x0320 }, 251 + /* SCART1 Output select */ 252 + { 0x0c40, 0x0440, 0x0400, 0x0c00, 0x0040, 0x0000, 0x0840, 0x0800, 0x0c40 }, 253 + /* SCART2 Output select */ 254 + { 0x3080, 0x1000, 0x1080, 0x0000, 0x0080, 0x2080, 0x3080, 0x2000, 0x3000 }, 255 + }; 256 + 257 + static char *scart_names[] = { 258 + "mask", "in1", "in2", "in1 da", "in2 da", "in3", "in4", "mono", "mute" 259 + }; 260 + 261 + void msp_set_scart(struct i2c_client *client, int in, int out) 262 + { 263 + struct msp_state *state = i2c_get_clientdata(client); 264 + 265 + state->in_scart=in; 266 + 267 + if (in >= 1 && in <= 8 && out >= 0 && out <= 2) { 268 + if (-1 == scarts[out][in]) 269 + return; 270 + 271 + state->acb &= ~scarts[out][SCART_MASK]; 272 + state->acb |= scarts[out][in]; 273 + } else 274 + state->acb = 0xf60; /* Mute Input and SCART 1 Output */ 275 + 276 + v4l_dbg(1, client, "scart switch: %s => %d (ACB=0x%04x)\n", 277 + scart_names[in], out, state->acb); 278 + msp_write_dsp(client, 0x13, state->acb); 279 + 280 + /* Sets I2S speed 0 = 1.024 Mbps, 1 = 2.048 Mbps */ 281 + msp_write_dem(client, 0x40, state->i2s_mode); 282 + } 283 + 284 + void msp_set_mute(struct i2c_client *client) 285 + { 286 + struct msp_state *state = i2c_get_clientdata(client); 287 + 288 + v4l_dbg(1, client, "mute audio\n"); 289 + msp_write_dsp(client, 0x0000, 0); 290 + msp_write_dsp(client, 0x0007, 1); 291 + if (state->has_scart2_out_volume) 292 + msp_write_dsp(client, 0x0040, 1); 293 + if (state->has_headphones) 294 + msp_write_dsp(client, 0x0006, 0); 295 + } 296 + 297 + void msp_set_audio(struct i2c_client *client) 298 + { 299 + struct msp_state *state = i2c_get_clientdata(client); 300 + int bal = 0, bass, treble, loudness; 301 + int val = 0; 302 + 303 + if (!state->muted) 304 + val = (state->volume * 0x7f / 65535) << 8; 305 + 306 + v4l_dbg(1, client, "mute=%s volume=%d\n", 307 + state->muted ? "on" : "off", state->volume); 308 + 309 + msp_write_dsp(client, 0x0000, val); 310 + msp_write_dsp(client, 0x0007, state->muted ? 0x1 : (val | 0x1)); 311 + if (state->has_scart2_out_volume) 312 + msp_write_dsp(client, 0x0040, state->muted ? 0x1 : (val | 0x1)); 313 + if (state->has_headphones) 314 + msp_write_dsp(client, 0x0006, val); 315 + if (!state->has_sound_processing) 316 + return; 317 + 318 + if (val) 319 + bal = (u8)((state->balance / 256) - 128); 320 + bass = ((state->bass - 32768) * 0x60 / 65535) << 8; 321 + treble = ((state->treble - 32768) * 0x60 / 65535) << 8; 322 + loudness = state->loudness ? ((5 * 4) << 8) : 0; 323 + 324 + v4l_dbg(1, client, "balance=%d bass=%d treble=%d loudness=%d\n", 325 + state->balance, state->bass, state->treble, state->loudness); 326 + 327 + msp_write_dsp(client, 0x0001, bal << 8); 328 + msp_write_dsp(client, 0x0002, bass); 329 + msp_write_dsp(client, 0x0003, treble); 330 + msp_write_dsp(client, 0x0004, loudness); 331 + if (!state->has_headphones) 332 + return; 333 + msp_write_dsp(client, 0x0030, bal << 8); 334 + msp_write_dsp(client, 0x0031, bass); 335 + msp_write_dsp(client, 0x0032, treble); 336 + msp_write_dsp(client, 0x0033, loudness); 337 + } 338 + 339 + int msp_modus(struct i2c_client *client) 340 + { 341 + struct msp_state *state = i2c_get_clientdata(client); 342 + 343 + if (state->radio) { 344 + v4l_dbg(1, client, "video mode selected to Radio\n"); 345 + return 0x0003; 346 + } 347 + 348 + if (state->v4l2_std & V4L2_STD_PAL) { 349 + v4l_dbg(1, client, "video mode selected to PAL\n"); 350 + 351 + #if 1 352 + /* experimental: not sure this works with all chip versions */ 353 + return 0x7003; 354 + #else 355 + /* previous value, try this if it breaks ... */ 356 + return 0x1003; 357 + #endif 358 + } 359 + if (state->v4l2_std & V4L2_STD_NTSC) { 360 + v4l_dbg(1, client, "video mode selected to NTSC\n"); 361 + return 0x2003; 362 + } 363 + if (state->v4l2_std & V4L2_STD_SECAM) { 364 + v4l_dbg(1, client, "video mode selected to SECAM\n"); 365 + return 0x0003; 366 + } 367 + return 0x0003; 368 + } 369 + 370 + /* ------------------------------------------------------------------------ */ 371 + 372 + 373 + static void msp_wake_thread(struct i2c_client *client) 374 + { 375 + struct msp_state *state = i2c_get_clientdata(client); 376 + 377 + if (NULL == state->kthread) 378 + return; 379 + msp_set_mute(client); 380 + state->watch_stereo = 0; 381 + state->restart = 1; 382 + wake_up_interruptible(&state->wq); 383 + } 384 + 385 + int msp_sleep(struct msp_state *state, int timeout) 386 + { 387 + DECLARE_WAITQUEUE(wait, current); 388 + 389 + add_wait_queue(&state->wq, &wait); 390 + if (!kthread_should_stop()) { 391 + if (timeout < 0) { 392 + set_current_state(TASK_INTERRUPTIBLE); 393 + schedule(); 394 + } else { 395 + schedule_timeout_interruptible 396 + (msecs_to_jiffies(timeout)); 397 + } 398 + } 399 + 400 + remove_wait_queue(&state->wq, &wait); 401 + try_to_freeze(); 402 + return state->restart; 403 + } 404 + 405 + /* ------------------------------------------------------------------------ */ 406 + 407 + static int msp_mode_v4l2_to_v4l1(int rxsubchans) 408 + { 409 + int mode = 0; 410 + 411 + if (rxsubchans & V4L2_TUNER_SUB_STEREO) 412 + mode |= VIDEO_SOUND_STEREO; 413 + if (rxsubchans & V4L2_TUNER_SUB_LANG2) 414 + mode |= VIDEO_SOUND_LANG2; 415 + if (rxsubchans & V4L2_TUNER_SUB_LANG1) 416 + mode |= VIDEO_SOUND_LANG1; 417 + if (mode == 0) 418 + mode |= VIDEO_SOUND_MONO; 419 + return mode; 420 + } 421 + 422 + static int msp_mode_v4l1_to_v4l2(int mode) 423 + { 424 + if (mode & VIDEO_SOUND_STEREO) 425 + return V4L2_TUNER_MODE_STEREO; 426 + if (mode & VIDEO_SOUND_LANG2) 427 + return V4L2_TUNER_MODE_LANG2; 428 + if (mode & VIDEO_SOUND_LANG1) 429 + return V4L2_TUNER_MODE_LANG1; 430 + return V4L2_TUNER_MODE_MONO; 431 + } 432 + 433 + static void msp_any_detect_stereo(struct i2c_client *client) 434 + { 435 + struct msp_state *state = i2c_get_clientdata(client); 436 + 437 + switch (state->opmode) { 438 + case OPMODE_MANUAL: 439 + case OPMODE_AUTODETECT: 440 + autodetect_stereo(client); 441 + break; 442 + case OPMODE_AUTOSELECT: 443 + msp34xxg_detect_stereo(client); 444 + break; 445 + } 446 + } 447 + 448 + static struct v4l2_queryctrl msp_qctrl_std[] = { 449 + { 450 + .id = V4L2_CID_AUDIO_VOLUME, 451 + .name = "Volume", 452 + .minimum = 0, 453 + .maximum = 65535, 454 + .step = 65535/100, 455 + .default_value = 58880, 456 + .flags = 0, 457 + .type = V4L2_CTRL_TYPE_INTEGER, 458 + },{ 459 + .id = V4L2_CID_AUDIO_MUTE, 460 + .name = "Mute", 461 + .minimum = 0, 462 + .maximum = 1, 463 + .step = 1, 464 + .default_value = 1, 465 + .flags = 0, 466 + .type = V4L2_CTRL_TYPE_BOOLEAN, 467 + }, 468 + }; 469 + 470 + static struct v4l2_queryctrl msp_qctrl_sound_processing[] = { 471 + { 472 + .id = V4L2_CID_AUDIO_BALANCE, 473 + .name = "Balance", 474 + .minimum = 0, 475 + .maximum = 65535, 476 + .step = 65535/100, 477 + .default_value = 32768, 478 + .flags = 0, 479 + .type = V4L2_CTRL_TYPE_INTEGER, 480 + },{ 481 + .id = V4L2_CID_AUDIO_BASS, 482 + .name = "Bass", 483 + .minimum = 0, 484 + .maximum = 65535, 485 + .step = 65535/100, 486 + .default_value = 32768, 487 + .type = V4L2_CTRL_TYPE_INTEGER, 488 + },{ 489 + .id = V4L2_CID_AUDIO_TREBLE, 490 + .name = "Treble", 491 + .minimum = 0, 492 + .maximum = 65535, 493 + .step = 65535/100, 494 + .default_value = 32768, 495 + .type = V4L2_CTRL_TYPE_INTEGER, 496 + },{ 497 + .id = V4L2_CID_AUDIO_LOUDNESS, 498 + .name = "Loudness", 499 + .minimum = 0, 500 + .maximum = 1, 501 + .step = 1, 502 + .default_value = 1, 503 + .flags = 0, 504 + .type = V4L2_CTRL_TYPE_BOOLEAN, 505 + }, 506 + }; 507 + 508 + 509 + static void msp_any_set_audmode(struct i2c_client *client, int audmode) 510 + { 511 + struct msp_state *state = i2c_get_clientdata(client); 512 + 513 + switch (state->opmode) { 514 + case OPMODE_MANUAL: 515 + case OPMODE_AUTODETECT: 516 + state->watch_stereo = 0; 517 + msp3400c_setstereo(client, audmode); 518 + break; 519 + case OPMODE_AUTOSELECT: 520 + msp34xxg_set_audmode(client, audmode); 521 + break; 522 + } 523 + } 524 + 525 + static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl) 526 + { 527 + struct msp_state *state = i2c_get_clientdata(client); 528 + 529 + switch (ctrl->id) { 530 + case V4L2_CID_AUDIO_VOLUME: 531 + ctrl->value = state->volume; 532 + break; 533 + 534 + case V4L2_CID_AUDIO_MUTE: 535 + ctrl->value = state->muted; 536 + break; 537 + 538 + case V4L2_CID_AUDIO_BALANCE: 539 + if (!state->has_sound_processing) 540 + return -EINVAL; 541 + ctrl->value = state->balance; 542 + break; 543 + 544 + case V4L2_CID_AUDIO_BASS: 545 + if (!state->has_sound_processing) 546 + return -EINVAL; 547 + ctrl->value = state->bass; 548 + break; 549 + 550 + case V4L2_CID_AUDIO_TREBLE: 551 + if (!state->has_sound_processing) 552 + return -EINVAL; 553 + ctrl->value = state->treble; 554 + break; 555 + 556 + case V4L2_CID_AUDIO_LOUDNESS: 557 + if (!state->has_sound_processing) 558 + return -EINVAL; 559 + ctrl->value = state->loudness; 560 + break; 561 + 562 + default: 563 + return -EINVAL; 564 + } 565 + return 0; 566 + } 567 + 568 + static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl) 569 + { 570 + struct msp_state *state = i2c_get_clientdata(client); 571 + 572 + switch (ctrl->id) { 573 + case V4L2_CID_AUDIO_VOLUME: 574 + state->volume = ctrl->value; 575 + if (state->volume == 0) 576 + state->balance = 32768; 577 + break; 578 + 579 + case V4L2_CID_AUDIO_MUTE: 580 + if (ctrl->value < 0 || ctrl->value >= 2) 581 + return -ERANGE; 582 + state->muted = ctrl->value; 583 + break; 584 + 585 + case V4L2_CID_AUDIO_BASS: 586 + if (!state->has_sound_processing) 587 + return -EINVAL; 588 + state->bass = ctrl->value; 589 + break; 590 + 591 + case V4L2_CID_AUDIO_TREBLE: 592 + if (!state->has_sound_processing) 593 + return -EINVAL; 594 + state->treble = ctrl->value; 595 + break; 596 + 597 + case V4L2_CID_AUDIO_LOUDNESS: 598 + if (!state->has_sound_processing) 599 + return -EINVAL; 600 + state->loudness = ctrl->value; 601 + break; 602 + 603 + case V4L2_CID_AUDIO_BALANCE: 604 + if (!state->has_sound_processing) 605 + return -EINVAL; 606 + state->balance = ctrl->value; 607 + break; 608 + 609 + default: 610 + return -EINVAL; 611 + } 612 + msp_set_audio(client); 613 + return 0; 614 + } 615 + 616 + static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) 617 + { 618 + struct msp_state *state = i2c_get_clientdata(client); 619 + u16 *sarg = arg; 620 + int scart = 0; 621 + 622 + if (debug >= 2) 623 + v4l_i2c_print_ioctl(client, cmd); 624 + 625 + switch (cmd) { 626 + case AUDC_SET_INPUT: 627 + if (*sarg == state->input) 628 + break; 629 + state->input = *sarg; 630 + switch (*sarg) { 631 + case AUDIO_RADIO: 632 + /* Hauppauge uses IN2 for the radio */ 633 + state->mode = MSP_MODE_FM_RADIO; 634 + scart = SCART_IN2; 635 + break; 636 + case AUDIO_EXTERN_1: 637 + /* IN1 is often used for external input ... */ 638 + state->mode = MSP_MODE_EXTERN; 639 + scart = SCART_IN1; 640 + break; 641 + case AUDIO_EXTERN_2: 642 + /* ... sometimes it is IN2 through ;) */ 643 + state->mode = MSP_MODE_EXTERN; 644 + scart = SCART_IN2; 645 + break; 646 + case AUDIO_TUNER: 647 + state->mode = -1; 648 + break; 649 + default: 650 + if (*sarg & AUDIO_MUTE) 651 + msp_set_scart(client, SCART_MUTE, 0); 652 + break; 653 + } 654 + if (scart) { 655 + state->rxsubchans = V4L2_TUNER_SUB_STEREO; 656 + state->audmode = V4L2_TUNER_MODE_STEREO; 657 + msp_set_scart(client, scart, 0); 658 + msp_write_dsp(client, 0x000d, 0x1900); 659 + if (state->opmode != OPMODE_AUTOSELECT) 660 + msp3400c_setstereo(client, state->audmode); 661 + } 662 + msp_wake_thread(client); 663 + break; 664 + 665 + case AUDC_SET_RADIO: 666 + if (state->radio) 667 + return 0; 668 + state->radio = 1; 669 + v4l_dbg(1, client, "switching to radio mode\n"); 670 + state->watch_stereo = 0; 671 + switch (state->opmode) { 672 + case OPMODE_MANUAL: 673 + /* set msp3400 to FM radio mode */ 674 + msp3400c_setmode(client, MSP_MODE_FM_RADIO); 675 + msp3400c_setcarrier(client, MSP_CARRIER(10.7), 676 + MSP_CARRIER(10.7)); 677 + msp_set_audio(client); 678 + break; 679 + case OPMODE_AUTODETECT: 680 + case OPMODE_AUTOSELECT: 681 + /* the thread will do for us */ 682 + msp_wake_thread(client); 683 + break; 684 + } 685 + break; 686 + 687 + /* --- v4l ioctls --- */ 688 + /* take care: bttv does userspace copying, we'll get a 689 + kernel pointer here... */ 690 + case VIDIOCGAUDIO: 691 + { 692 + struct video_audio *va = arg; 693 + 694 + va->flags |= VIDEO_AUDIO_VOLUME | VIDEO_AUDIO_MUTABLE; 695 + if (state->has_sound_processing) 696 + va->flags |= VIDEO_AUDIO_BALANCE | 697 + VIDEO_AUDIO_BASS | 698 + VIDEO_AUDIO_TREBLE; 699 + if (state->muted) 700 + va->flags |= VIDEO_AUDIO_MUTE; 701 + va->volume = state->volume; 702 + va->balance = state->volume ? state->balance : 32768; 703 + va->bass = state->bass; 704 + va->treble = state->treble; 705 + 706 + if (state->radio) 707 + break; 708 + if (state->opmode == OPMODE_AUTOSELECT) 709 + msp_any_detect_stereo(client); 710 + va->mode = msp_mode_v4l2_to_v4l1(state->rxsubchans); 711 + break; 712 + } 713 + 714 + case VIDIOCSAUDIO: 715 + { 716 + struct video_audio *va = arg; 717 + 718 + state->muted = (va->flags & VIDEO_AUDIO_MUTE); 719 + state->volume = va->volume; 720 + state->balance = va->balance; 721 + state->bass = va->bass; 722 + state->treble = va->treble; 723 + msp_set_audio(client); 724 + 725 + if (va->mode != 0 && state->radio == 0) 726 + msp_any_set_audmode(client, msp_mode_v4l1_to_v4l2(va->mode)); 727 + break; 728 + } 729 + 730 + case VIDIOCSCHAN: 731 + { 732 + struct video_channel *vc = arg; 733 + int update = 0; 734 + v4l2_std_id std; 735 + 736 + if (state->radio) 737 + update = 1; 738 + state->radio = 0; 739 + if (vc->norm == VIDEO_MODE_PAL) 740 + std = V4L2_STD_PAL; 741 + else if (vc->norm == VIDEO_MODE_SECAM) 742 + std = V4L2_STD_SECAM; 743 + else 744 + std = V4L2_STD_NTSC; 745 + if (std != state->v4l2_std) { 746 + state->v4l2_std = std; 747 + update = 1; 748 + } 749 + if (update) 750 + msp_wake_thread(client); 751 + break; 752 + } 753 + 754 + case VIDIOCSFREQ: 755 + case VIDIOC_S_FREQUENCY: 756 + { 757 + /* new channel -- kick audio carrier scan */ 758 + msp_wake_thread(client); 759 + break; 760 + } 761 + 762 + /* msp34xx specific */ 763 + case MSP_SET_MATRIX: 764 + { 765 + struct msp_matrix *mspm = arg; 766 + 767 + msp_set_scart(client, mspm->input, mspm->output); 768 + break; 769 + } 770 + 771 + /* --- v4l2 ioctls --- */ 772 + case VIDIOC_S_STD: 773 + { 774 + v4l2_std_id *id = arg; 775 + int update = state->radio || state->v4l2_std != *id; 776 + 777 + state->v4l2_std = *id; 778 + state->radio = 0; 779 + if (update) 780 + msp_wake_thread(client); 781 + return 0; 782 + } 783 + 784 + case VIDIOC_ENUMINPUT: 785 + { 786 + struct v4l2_input *i = arg; 787 + 788 + if (i->index != 0) 789 + return -EINVAL; 790 + 791 + i->type = V4L2_INPUT_TYPE_TUNER; 792 + switch (i->index) { 793 + case AUDIO_RADIO: 794 + strcpy(i->name, "Radio"); 795 + break; 796 + case AUDIO_EXTERN_1: 797 + strcpy(i->name, "Extern 1"); 798 + break; 799 + case AUDIO_EXTERN_2: 800 + strcpy(i->name, "Extern 2"); 801 + break; 802 + case AUDIO_TUNER: 803 + strcpy(i->name, "Television"); 804 + break; 805 + default: 806 + return -EINVAL; 807 + } 808 + return 0; 809 + } 810 + 811 + case VIDIOC_G_AUDIO: 812 + { 813 + struct v4l2_audio *a = arg; 814 + 815 + memset(a, 0, sizeof(*a)); 816 + 817 + switch (a->index) { 818 + case AUDIO_RADIO: 819 + strcpy(a->name, "Radio"); 820 + break; 821 + case AUDIO_EXTERN_1: 822 + strcpy(a->name, "Extern 1"); 823 + break; 824 + case AUDIO_EXTERN_2: 825 + strcpy(a->name, "Extern 2"); 826 + break; 827 + case AUDIO_TUNER: 828 + strcpy(a->name, "Television"); 829 + break; 830 + default: 831 + return -EINVAL; 832 + } 833 + 834 + msp_any_detect_stereo(client); 835 + if (state->audmode == V4L2_TUNER_MODE_STEREO) { 836 + a->capability = V4L2_AUDCAP_STEREO; 837 + } 838 + 839 + break; 840 + } 841 + 842 + case VIDIOC_S_AUDIO: 843 + { 844 + struct v4l2_audio *sarg = arg; 845 + 846 + switch (sarg->index) { 847 + case AUDIO_RADIO: 848 + /* Hauppauge uses IN2 for the radio */ 849 + state->mode = MSP_MODE_FM_RADIO; 850 + scart = SCART_IN2; 851 + break; 852 + case AUDIO_EXTERN_1: 853 + /* IN1 is often used for external input ... */ 854 + state->mode = MSP_MODE_EXTERN; 855 + scart = SCART_IN1; 856 + break; 857 + case AUDIO_EXTERN_2: 858 + /* ... sometimes it is IN2 through ;) */ 859 + state->mode = MSP_MODE_EXTERN; 860 + scart = SCART_IN2; 861 + break; 862 + case AUDIO_TUNER: 863 + state->mode = -1; 864 + break; 865 + } 866 + if (scart) { 867 + state->rxsubchans = V4L2_TUNER_SUB_STEREO; 868 + state->audmode = V4L2_TUNER_MODE_STEREO; 869 + msp_set_scart(client, scart, 0); 870 + msp_write_dsp(client, 0x000d, 0x1900); 871 + } 872 + if (sarg->capability == V4L2_AUDCAP_STEREO) { 873 + state->audmode = V4L2_TUNER_MODE_STEREO; 874 + } else { 875 + state->audmode &= ~V4L2_TUNER_MODE_STEREO; 876 + } 877 + msp_any_set_audmode(client, state->audmode); 878 + msp_wake_thread(client); 879 + break; 880 + } 881 + 882 + case VIDIOC_G_TUNER: 883 + { 884 + struct v4l2_tuner *vt = arg; 885 + 886 + if (state->radio) 887 + break; 888 + if (state->opmode == OPMODE_AUTOSELECT) 889 + msp_any_detect_stereo(client); 890 + vt->audmode = state->audmode; 891 + vt->rxsubchans = state->rxsubchans; 892 + vt->capability = V4L2_TUNER_CAP_STEREO | 893 + V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; 894 + break; 895 + } 896 + 897 + case VIDIOC_S_TUNER: 898 + { 899 + struct v4l2_tuner *vt = (struct v4l2_tuner *)arg; 900 + 901 + if (state->radio) 902 + break; 903 + /* only set audmode */ 904 + if (vt->audmode != -1 && vt->audmode != 0) 905 + msp_any_set_audmode(client, vt->audmode); 906 + break; 907 + } 908 + 909 + case VIDIOC_G_AUDOUT: 910 + { 911 + struct v4l2_audioout *a = (struct v4l2_audioout *)arg; 912 + int idx = a->index; 913 + 914 + memset(a, 0, sizeof(*a)); 915 + 916 + switch (idx) { 917 + case 0: 918 + strcpy(a->name, "Scart1 Out"); 919 + break; 920 + case 1: 921 + strcpy(a->name, "Scart2 Out"); 922 + break; 923 + case 2: 924 + strcpy(a->name, "I2S Out"); 925 + break; 926 + default: 927 + return -EINVAL; 928 + } 929 + break; 930 + 931 + } 932 + 933 + case VIDIOC_S_AUDOUT: 934 + { 935 + struct v4l2_audioout *a = (struct v4l2_audioout *)arg; 936 + 937 + if (a->index < 0 || a->index > 2) 938 + return -EINVAL; 939 + 940 + v4l_dbg(1, client, "Setting audio out on msp34xx to input %i\n", a->index); 941 + msp_set_scart(client, state->in_scart, a->index + 1); 942 + 943 + break; 944 + } 945 + 946 + case VIDIOC_INT_I2S_CLOCK_FREQ: 947 + { 948 + u32 *a = (u32 *)arg; 949 + 950 + v4l_dbg(1, client, "Setting I2S speed to %d\n", *a); 951 + 952 + switch (*a) { 953 + case 1024000: 954 + state->i2s_mode = 0; 955 + break; 956 + case 2048000: 957 + state->i2s_mode = 1; 958 + break; 959 + default: 960 + return -EINVAL; 961 + } 962 + break; 963 + } 964 + 965 + case VIDIOC_QUERYCTRL: 966 + { 967 + struct v4l2_queryctrl *qc = arg; 968 + int i; 969 + 970 + for (i = 0; i < ARRAY_SIZE(msp_qctrl_std); i++) 971 + if (qc->id && qc->id == msp_qctrl_std[i].id) { 972 + memcpy(qc, &msp_qctrl_std[i], sizeof(*qc)); 973 + return 0; 974 + } 975 + if (!state->has_sound_processing) 976 + return -EINVAL; 977 + for (i = 0; i < ARRAY_SIZE(msp_qctrl_sound_processing); i++) 978 + if (qc->id && qc->id == msp_qctrl_sound_processing[i].id) { 979 + memcpy(qc, &msp_qctrl_sound_processing[i], sizeof(*qc)); 980 + return 0; 981 + } 982 + return -EINVAL; 983 + } 984 + 985 + case VIDIOC_G_CTRL: 986 + return msp_get_ctrl(client, arg); 987 + 988 + case VIDIOC_S_CTRL: 989 + return msp_set_ctrl(client, arg); 990 + 991 + case VIDIOC_LOG_STATUS: 992 + { 993 + const char *p; 994 + 995 + if (state->opmode == OPMODE_AUTOSELECT) 996 + msp_any_detect_stereo(client); 997 + v4l_info(client, "%s rev1 = 0x%04x rev2 = 0x%04x\n", 998 + client->name, state->rev1, state->rev2); 999 + v4l_info(client, "Audio: volume %d%s\n", 1000 + state->volume, state->muted ? " (muted)" : ""); 1001 + if (state->has_sound_processing) { 1002 + v4l_info(client, "Audio: balance %d bass %d treble %d loudness %s\n", 1003 + state->balance, state->bass, state->treble, 1004 + state->loudness ? "on" : "off"); 1005 + } 1006 + switch (state->mode) { 1007 + case MSP_MODE_AM_DETECT: p = "AM (for carrier detect)"; break; 1008 + case MSP_MODE_FM_RADIO: p = "FM Radio"; break; 1009 + case MSP_MODE_FM_TERRA: p = "Terrestial FM-mono + FM-stereo"; break; 1010 + case MSP_MODE_FM_SAT: p = "Satellite FM-mono"; break; 1011 + case MSP_MODE_FM_NICAM1: p = "NICAM/FM (B/G, D/K)"; break; 1012 + case MSP_MODE_FM_NICAM2: p = "NICAM/FM (I)"; break; 1013 + case MSP_MODE_AM_NICAM: p = "NICAM/AM (L)"; break; 1014 + case MSP_MODE_BTSC: p = "BTSC"; break; 1015 + case MSP_MODE_EXTERN: p = "External input"; break; 1016 + default: p = "unknown"; break; 1017 + } 1018 + if (state->opmode == OPMODE_MANUAL) { 1019 + v4l_info(client, "Mode: %s (%s%s)\n", p, 1020 + (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono", 1021 + (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : ""); 1022 + } else { 1023 + v4l_info(client, "Mode: %s\n", p); 1024 + v4l_info(client, "Standard: %s (%s%s)\n", 1025 + msp_standard_std_name(state->std), 1026 + (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono", 1027 + (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : ""); 1028 + } 1029 + v4l_info(client, "ACB: 0x%04x\n", state->acb); 1030 + break; 1031 + } 1032 + 1033 + default: 1034 + /* nothing */ 1035 + break; 1036 + } 1037 + return 0; 1038 + } 1039 + 1040 + static int msp_suspend(struct device * dev, pm_message_t state) 1041 + { 1042 + struct i2c_client *client = container_of(dev, struct i2c_client, dev); 1043 + 1044 + v4l_dbg(1, client, "suspend\n"); 1045 + msp_reset(client); 1046 + return 0; 1047 + } 1048 + 1049 + static int msp_resume(struct device * dev) 1050 + { 1051 + struct i2c_client *client = container_of(dev, struct i2c_client, dev); 1052 + 1053 + v4l_dbg(1, client, "resume\n"); 1054 + msp_wake_thread(client); 1055 + return 0; 1056 + } 1057 + 1058 + /* ----------------------------------------------------------------------- */ 1059 + 1060 + static struct i2c_driver i2c_driver; 1061 + 1062 + static int msp_attach(struct i2c_adapter *adapter, int address, int kind) 1063 + { 1064 + struct i2c_client *client; 1065 + struct msp_state *state; 1066 + int (*thread_func)(void *data) = NULL; 1067 + int msp_hard; 1068 + int msp_family; 1069 + int msp_revision; 1070 + int msp_product, msp_prod_hi, msp_prod_lo; 1071 + int msp_rom; 1072 + 1073 + client = kmalloc(sizeof(*client), GFP_KERNEL); 1074 + if (client == NULL) 1075 + return -ENOMEM; 1076 + memset(client, 0, sizeof(*client)); 1077 + client->addr = address; 1078 + client->adapter = adapter; 1079 + client->driver = &i2c_driver; 1080 + snprintf(client->name, sizeof(client->name) - 1, "msp3400"); 1081 + 1082 + if (msp_reset(client) == -1) { 1083 + v4l_dbg(1, client, "msp3400 not found\n"); 1084 + kfree(client); 1085 + return -1; 1086 + } 1087 + 1088 + state = kmalloc(sizeof(*state), GFP_KERNEL); 1089 + if (state == NULL) { 1090 + kfree(client); 1091 + return -ENOMEM; 1092 + } 1093 + i2c_set_clientdata(client, state); 1094 + 1095 + memset(state, 0, sizeof(*state)); 1096 + state->v4l2_std = V4L2_STD_NTSC; 1097 + state->volume = 58880; /* 0db gain */ 1098 + state->balance = 32768; /* 0db gain */ 1099 + state->bass = 32768; 1100 + state->treble = 32768; 1101 + state->loudness = 0; 1102 + state->input = -1; 1103 + state->muted = 0; 1104 + state->i2s_mode = 0; 1105 + init_waitqueue_head(&state->wq); 1106 + 1107 + state->rev1 = msp_read_dsp(client, 0x1e); 1108 + if (state->rev1 != -1) 1109 + state->rev2 = msp_read_dsp(client, 0x1f); 1110 + v4l_dbg(1, client, "rev1=0x%04x, rev2=0x%04x\n", state->rev1, state->rev2); 1111 + if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { 1112 + v4l_dbg(1, client, "not an msp3400 (cannot read chip version)\n"); 1113 + kfree(state); 1114 + kfree(client); 1115 + return -1; 1116 + } 1117 + 1118 + msp_set_audio(client); 1119 + 1120 + msp_family = ((state->rev1 >> 4) & 0x0f) + 3; 1121 + msp_product = (state->rev2 >> 8) & 0xff; 1122 + msp_prod_hi = msp_product / 10; 1123 + msp_prod_lo = msp_product % 10; 1124 + msp_revision = (state->rev1 & 0x0f) + '@'; 1125 + msp_hard = ((state->rev1 >> 8) & 0xff) + '@'; 1126 + msp_rom = state->rev2 & 0x1f; 1127 + snprintf(client->name, sizeof(client->name), "MSP%d4%02d%c-%c%d", 1128 + msp_family, msp_product, 1129 + msp_revision, msp_hard, msp_rom); 1130 + 1131 + /* Has NICAM support: all mspx41x and mspx45x products have NICAM */ 1132 + state->has_nicam = msp_prod_hi == 1 || msp_prod_hi == 5; 1133 + /* Has radio support: was added with revision G */ 1134 + state->has_radio = msp_revision >= 'G'; 1135 + /* Has headphones output: not for stripped down products */ 1136 + state->has_headphones = msp_prod_lo < 5; 1137 + /* Has scart4 input: not in pre D revisions, not in stripped D revs */ 1138 + state->has_scart4 = msp_family >= 4 || (msp_revision >= 'D' && msp_prod_lo < 5); 1139 + /* Has scart2 and scart3 inputs and scart2 output: not in stripped 1140 + down products of the '3' family */ 1141 + state->has_scart23_in_scart2_out = msp_family >= 4 || msp_prod_lo < 5; 1142 + /* Has scart2 a volume control? Not in pre-D revisions. */ 1143 + state->has_scart2_out_volume = msp_revision > 'C' && state->has_scart23_in_scart2_out; 1144 + /* Has a configurable i2s out? */ 1145 + state->has_i2s_conf = msp_revision >= 'G' && msp_prod_lo < 7; 1146 + /* Has subwoofer output: not in pre-D revs and not in stripped down products */ 1147 + state->has_subwoofer = msp_revision >= 'D' && msp_prod_lo < 5; 1148 + /* Has soundprocessing (bass/treble/balance/loudness/equalizer): not in 1149 + stripped down products */ 1150 + state->has_sound_processing = msp_prod_lo < 7; 1151 + /* Has Virtual Dolby Surround: only in msp34x1 */ 1152 + state->has_virtual_dolby_surround = msp_revision == 'G' && msp_prod_lo == 1; 1153 + /* Has Virtual Dolby Surround & Dolby Pro Logic: only in msp34x2 */ 1154 + state->has_dolby_pro_logic = msp_revision == 'G' && msp_prod_lo == 2; 1155 + 1156 + state->opmode = opmode; 1157 + if (state->opmode == OPMODE_AUTO) { 1158 + /* MSP revision G and up have both autodetect and autoselect */ 1159 + if (msp_revision >= 'G') 1160 + state->opmode = OPMODE_AUTOSELECT; 1161 + /* MSP revision D and up have autodetect */ 1162 + else if (msp_revision >= 'D') 1163 + state->opmode = OPMODE_AUTODETECT; 1164 + else 1165 + state->opmode = OPMODE_MANUAL; 1166 + } 1167 + 1168 + /* hello world :-) */ 1169 + v4l_info(client, "%s found @ 0x%x (%s)\n", client->name, address << 1, adapter->name); 1170 + v4l_info(client, "%s ", client->name); 1171 + if (state->has_nicam && state->has_radio) 1172 + printk("supports nicam and radio, "); 1173 + else if (state->has_nicam) 1174 + printk("supports nicam, "); 1175 + else if (state->has_radio) 1176 + printk("supports radio, "); 1177 + printk("mode is "); 1178 + 1179 + /* version-specific initialization */ 1180 + switch (state->opmode) { 1181 + case OPMODE_MANUAL: 1182 + printk("manual"); 1183 + thread_func = msp3400c_thread; 1184 + break; 1185 + case OPMODE_AUTODETECT: 1186 + printk("autodetect"); 1187 + thread_func = msp3410d_thread; 1188 + break; 1189 + case OPMODE_AUTOSELECT: 1190 + printk("autodetect and autoselect"); 1191 + thread_func = msp34xxg_thread; 1192 + break; 1193 + } 1194 + printk("\n"); 1195 + 1196 + /* startup control thread if needed */ 1197 + if (thread_func) { 1198 + state->kthread = kthread_run(thread_func, client, "msp34xx"); 1199 + 1200 + if (state->kthread == NULL) 1201 + v4l_warn(client, "kernel_thread() failed\n"); 1202 + msp_wake_thread(client); 1203 + } 1204 + 1205 + /* done */ 1206 + i2c_attach_client(client); 1207 + 1208 + return 0; 1209 + } 1210 + 1211 + static int msp_probe(struct i2c_adapter *adapter) 1212 + { 1213 + if (adapter->class & I2C_CLASS_TV_ANALOG) 1214 + return i2c_probe(adapter, &addr_data, msp_attach); 1215 + return 0; 1216 + } 1217 + 1218 + static int msp_detach(struct i2c_client *client) 1219 + { 1220 + struct msp_state *state = i2c_get_clientdata(client); 1221 + int err; 1222 + 1223 + /* shutdown control thread */ 1224 + if (state->kthread) { 1225 + state->restart = 1; 1226 + kthread_stop(state->kthread); 1227 + } 1228 + msp_reset(client); 1229 + 1230 + err = i2c_detach_client(client); 1231 + if (err) { 1232 + return err; 1233 + } 1234 + 1235 + kfree(state); 1236 + kfree(client); 1237 + return 0; 1238 + } 1239 + 1240 + /* ----------------------------------------------------------------------- */ 1241 + 1242 + /* i2c implementation */ 1243 + static struct i2c_driver i2c_driver = { 1244 + .id = I2C_DRIVERID_MSP3400, 1245 + .attach_adapter = msp_probe, 1246 + .detach_client = msp_detach, 1247 + .command = msp_command, 1248 + .driver = { 1249 + .name = "msp3400", 1250 + .suspend = msp_suspend, 1251 + .resume = msp_resume, 1252 + }, 1253 + }; 1254 + 1255 + static int __init msp3400_init_module(void) 1256 + { 1257 + return i2c_add_driver(&i2c_driver); 1258 + } 1259 + 1260 + static void __exit msp3400_cleanup_module(void) 1261 + { 1262 + i2c_del_driver(&i2c_driver); 1263 + } 1264 + 1265 + module_init(msp3400_init_module); 1266 + module_exit(msp3400_cleanup_module); 1267 + 1268 + /* 1269 + * Overrides for Emacs so that we follow Linus's tabbing style. 1270 + * --------------------------------------------------------------------------- 1271 + * Local variables: 1272 + * c-basic-offset: 8 1273 + * End: 1274 + */
+1010
drivers/media/video/msp3400-kthreads.c
··· 1 + /* 2 + * Programming the mspx4xx sound processor family 3 + * 4 + * (c) 1997-2001 Gerd Knorr <kraxel@bytesex.org> 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License 8 + * as published by the Free Software Foundation; either version 2 9 + * of the License, or (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License for more details. 15 + * 16 + * You should have received a copy of the GNU General Public License 17 + * along with this program; if not, write to the Free Software 18 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 + */ 20 + 21 + 22 + #include <linux/kernel.h> 23 + #include <linux/module.h> 24 + #include <linux/slab.h> 25 + #include <linux/i2c.h> 26 + #include <linux/videodev.h> 27 + #include <linux/videodev2.h> 28 + #include <media/v4l2-common.h> 29 + #include <media/audiochip.h> 30 + #include <linux/kthread.h> 31 + #include <linux/suspend.h> 32 + #include "msp3400.h" 33 + 34 + /* this one uses the automatic sound standard detection of newer msp34xx 35 + chip versions */ 36 + static struct { 37 + int retval; 38 + int main, second; 39 + char *name; 40 + } msp_stdlist[] = { 41 + { 0x0000, 0, 0, "could not detect sound standard" }, 42 + { 0x0001, 0, 0, "autodetect start" }, 43 + { 0x0002, MSP_CARRIER(4.5), MSP_CARRIER(4.72), "4.5/4.72 M Dual FM-Stereo" }, 44 + { 0x0003, MSP_CARRIER(5.5), MSP_CARRIER(5.7421875), "5.5/5.74 B/G Dual FM-Stereo" }, 45 + { 0x0004, MSP_CARRIER(6.5), MSP_CARRIER(6.2578125), "6.5/6.25 D/K1 Dual FM-Stereo" }, 46 + { 0x0005, MSP_CARRIER(6.5), MSP_CARRIER(6.7421875), "6.5/6.74 D/K2 Dual FM-Stereo" }, 47 + { 0x0006, MSP_CARRIER(6.5), MSP_CARRIER(6.5), "6.5 D/K FM-Mono (HDEV3)" }, 48 + { 0x0008, MSP_CARRIER(5.5), MSP_CARRIER(5.85), "5.5/5.85 B/G NICAM FM" }, 49 + { 0x0009, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 L NICAM AM" }, 50 + { 0x000a, MSP_CARRIER(6.0), MSP_CARRIER(6.55), "6.0/6.55 I NICAM FM" }, 51 + { 0x000b, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM" }, 52 + { 0x000c, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM (HDEV2)" }, 53 + { 0x0020, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Stereo" }, 54 + { 0x0021, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Mono + SAP" }, 55 + { 0x0030, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M EIA-J Japan Stereo" }, 56 + { 0x0040, MSP_CARRIER(10.7), MSP_CARRIER(10.7), "10.7 FM-Stereo Radio" }, 57 + { 0x0050, MSP_CARRIER(6.5), MSP_CARRIER(6.5), "6.5 SAT-Mono" }, 58 + { 0x0051, MSP_CARRIER(7.02), MSP_CARRIER(7.20), "7.02/7.20 SAT-Stereo" }, 59 + { 0x0060, MSP_CARRIER(7.2), MSP_CARRIER(7.2), "7.2 SAT ADR" }, 60 + { -1, 0, 0, NULL }, /* EOF */ 61 + }; 62 + 63 + static struct msp3400c_init_data_dem { 64 + int fir1[6]; 65 + int fir2[6]; 66 + int cdo1; 67 + int cdo2; 68 + int ad_cv; 69 + int mode_reg; 70 + int dsp_src; 71 + int dsp_matrix; 72 + } msp3400c_init_data[] = { 73 + { /* AM (for carrier detect / msp3400) */ 74 + {75, 19, 36, 35, 39, 40}, 75 + {75, 19, 36, 35, 39, 40}, 76 + MSP_CARRIER(5.5), MSP_CARRIER(5.5), 77 + 0x00d0, 0x0500, 0x0020, 0x3000 78 + },{ /* AM (for carrier detect / msp3410) */ 79 + {-1, -1, -8, 2, 59, 126}, 80 + {-1, -1, -8, 2, 59, 126}, 81 + MSP_CARRIER(5.5), MSP_CARRIER(5.5), 82 + 0x00d0, 0x0100, 0x0020, 0x3000 83 + },{ /* FM Radio */ 84 + {-8, -8, 4, 6, 78, 107}, 85 + {-8, -8, 4, 6, 78, 107}, 86 + MSP_CARRIER(10.7), MSP_CARRIER(10.7), 87 + 0x00d0, 0x0480, 0x0020, 0x3000 88 + },{ /* Terrestial FM-mono + FM-stereo */ 89 + {3, 18, 27, 48, 66, 72}, 90 + {3, 18, 27, 48, 66, 72}, 91 + MSP_CARRIER(5.5), MSP_CARRIER(5.5), 92 + 0x00d0, 0x0480, 0x0030, 0x3000 93 + },{ /* Sat FM-mono */ 94 + { 1, 9, 14, 24, 33, 37}, 95 + { 3, 18, 27, 48, 66, 72}, 96 + MSP_CARRIER(6.5), MSP_CARRIER(6.5), 97 + 0x00c6, 0x0480, 0x0000, 0x3000 98 + },{ /* NICAM/FM -- B/G (5.5/5.85), D/K (6.5/5.85) */ 99 + {-2, -8, -10, 10, 50, 86}, 100 + {3, 18, 27, 48, 66, 72}, 101 + MSP_CARRIER(5.5), MSP_CARRIER(5.5), 102 + 0x00d0, 0x0040, 0x0120, 0x3000 103 + },{ /* NICAM/FM -- I (6.0/6.552) */ 104 + {2, 4, -6, -4, 40, 94}, 105 + {3, 18, 27, 48, 66, 72}, 106 + MSP_CARRIER(6.0), MSP_CARRIER(6.0), 107 + 0x00d0, 0x0040, 0x0120, 0x3000 108 + },{ /* NICAM/AM -- L (6.5/5.85) */ 109 + {-2, -8, -10, 10, 50, 86}, 110 + {-4, -12, -9, 23, 79, 126}, 111 + MSP_CARRIER(6.5), MSP_CARRIER(6.5), 112 + 0x00c6, 0x0140, 0x0120, 0x7c03 113 + }, 114 + }; 115 + 116 + struct msp3400c_carrier_detect { 117 + int cdo; 118 + char *name; 119 + }; 120 + 121 + static struct msp3400c_carrier_detect msp3400c_carrier_detect_main[] = { 122 + /* main carrier */ 123 + { MSP_CARRIER(4.5), "4.5 NTSC" }, 124 + { MSP_CARRIER(5.5), "5.5 PAL B/G" }, 125 + { MSP_CARRIER(6.0), "6.0 PAL I" }, 126 + { MSP_CARRIER(6.5), "6.5 PAL D/K + SAT + SECAM" } 127 + }; 128 + 129 + static struct msp3400c_carrier_detect msp3400c_carrier_detect_55[] = { 130 + /* PAL B/G */ 131 + { MSP_CARRIER(5.7421875), "5.742 PAL B/G FM-stereo" }, 132 + { MSP_CARRIER(5.85), "5.85 PAL B/G NICAM" } 133 + }; 134 + 135 + static struct msp3400c_carrier_detect msp3400c_carrier_detect_65[] = { 136 + /* PAL SAT / SECAM */ 137 + { MSP_CARRIER(5.85), "5.85 PAL D/K + SECAM NICAM" }, 138 + { MSP_CARRIER(6.2578125), "6.25 PAL D/K1 FM-stereo" }, 139 + { MSP_CARRIER(6.7421875), "6.74 PAL D/K2 FM-stereo" }, 140 + { MSP_CARRIER(7.02), "7.02 PAL SAT FM-stereo s/b" }, 141 + { MSP_CARRIER(7.20), "7.20 PAL SAT FM-stereo s" }, 142 + { MSP_CARRIER(7.38), "7.38 PAL SAT FM-stereo b" }, 143 + }; 144 + 145 + /* ------------------------------------------------------------------------ */ 146 + 147 + const char *msp_standard_std_name(int std) 148 + { 149 + int i; 150 + 151 + for (i = 0; msp_stdlist[i].name != NULL; i++) 152 + if (msp_stdlist[i].retval == std) 153 + return msp_stdlist[i].name; 154 + return "unknown"; 155 + } 156 + 157 + void msp3400c_setcarrier(struct i2c_client *client, int cdo1, int cdo2) 158 + { 159 + msp_write_dem(client, 0x0093, cdo1 & 0xfff); 160 + msp_write_dem(client, 0x009b, cdo1 >> 12); 161 + msp_write_dem(client, 0x00a3, cdo2 & 0xfff); 162 + msp_write_dem(client, 0x00ab, cdo2 >> 12); 163 + msp_write_dem(client, 0x0056, 0); /*LOAD_REG_1/2*/ 164 + } 165 + 166 + void msp3400c_setmode(struct i2c_client *client, int type) 167 + { 168 + struct msp_state *state = i2c_get_clientdata(client); 169 + int i; 170 + 171 + v4l_dbg(1, client, "setmode: %d\n", type); 172 + state->mode = type; 173 + state->audmode = V4L2_TUNER_MODE_MONO; 174 + state->rxsubchans = V4L2_TUNER_SUB_MONO; 175 + 176 + msp_write_dem(client, 0x00bb, msp3400c_init_data[type].ad_cv); 177 + 178 + for (i = 5; i >= 0; i--) /* fir 1 */ 179 + msp_write_dem(client, 0x0001, msp3400c_init_data[type].fir1[i]); 180 + 181 + msp_write_dem(client, 0x0005, 0x0004); /* fir 2 */ 182 + msp_write_dem(client, 0x0005, 0x0040); 183 + msp_write_dem(client, 0x0005, 0x0000); 184 + for (i = 5; i >= 0; i--) 185 + msp_write_dem(client, 0x0005, msp3400c_init_data[type].fir2[i]); 186 + 187 + msp_write_dem(client, 0x0083, msp3400c_init_data[type].mode_reg); 188 + 189 + msp3400c_setcarrier(client, msp3400c_init_data[type].cdo1, 190 + msp3400c_init_data[type].cdo2); 191 + 192 + msp_write_dem(client, 0x0056, 0); /*LOAD_REG_1/2*/ 193 + 194 + if (dolby) { 195 + msp_write_dsp(client, 0x0008, 0x0520); /* I2S1 */ 196 + msp_write_dsp(client, 0x0009, 0x0620); /* I2S2 */ 197 + msp_write_dsp(client, 0x000b, msp3400c_init_data[type].dsp_src); 198 + } else { 199 + msp_write_dsp(client, 0x0008, msp3400c_init_data[type].dsp_src); 200 + msp_write_dsp(client, 0x0009, msp3400c_init_data[type].dsp_src); 201 + msp_write_dsp(client, 0x000b, msp3400c_init_data[type].dsp_src); 202 + } 203 + msp_write_dsp(client, 0x000a, msp3400c_init_data[type].dsp_src); 204 + msp_write_dsp(client, 0x000e, msp3400c_init_data[type].dsp_matrix); 205 + 206 + if (state->has_nicam) { 207 + /* nicam prescale */ 208 + msp_write_dsp(client, 0x0010, 0x5a00); /* was: 0x3000 */ 209 + } 210 + } 211 + 212 + /* turn on/off nicam + stereo */ 213 + void msp3400c_setstereo(struct i2c_client *client, int mode) 214 + { 215 + static char *strmode[] = { "mono", "stereo", "lang2", "lang1" }; 216 + struct msp_state *state = i2c_get_clientdata(client); 217 + int nicam = 0; /* channel source: FM/AM or nicam */ 218 + int src = 0; 219 + 220 + if (state->opmode == OPMODE_AUTOSELECT) { 221 + /* this method would break everything, let's make sure 222 + * it's never called 223 + */ 224 + v4l_dbg(1, client, "setstereo called with mode=%d instead of set_source (ignored)\n", 225 + mode); 226 + return; 227 + } 228 + 229 + /* switch demodulator */ 230 + switch (state->mode) { 231 + case MSP_MODE_FM_TERRA: 232 + v4l_dbg(1, client, "FM setstereo: %s\n", strmode[mode]); 233 + msp3400c_setcarrier(client, state->second, state->main); 234 + switch (mode) { 235 + case V4L2_TUNER_MODE_STEREO: 236 + msp_write_dsp(client, 0x000e, 0x3001); 237 + break; 238 + case V4L2_TUNER_MODE_MONO: 239 + case V4L2_TUNER_MODE_LANG1: 240 + case V4L2_TUNER_MODE_LANG2: 241 + msp_write_dsp(client, 0x000e, 0x3000); 242 + break; 243 + } 244 + break; 245 + case MSP_MODE_FM_SAT: 246 + v4l_dbg(1, client, "SAT setstereo: %s\n", strmode[mode]); 247 + switch (mode) { 248 + case V4L2_TUNER_MODE_MONO: 249 + msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); 250 + break; 251 + case V4L2_TUNER_MODE_STEREO: 252 + msp3400c_setcarrier(client, MSP_CARRIER(7.2), MSP_CARRIER(7.02)); 253 + break; 254 + case V4L2_TUNER_MODE_LANG1: 255 + msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02)); 256 + break; 257 + case V4L2_TUNER_MODE_LANG2: 258 + msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02)); 259 + break; 260 + } 261 + break; 262 + case MSP_MODE_FM_NICAM1: 263 + case MSP_MODE_FM_NICAM2: 264 + case MSP_MODE_AM_NICAM: 265 + v4l_dbg(1, client, "NICAM setstereo: %s\n",strmode[mode]); 266 + msp3400c_setcarrier(client,state->second,state->main); 267 + if (state->nicam_on) 268 + nicam=0x0100; 269 + break; 270 + case MSP_MODE_BTSC: 271 + v4l_dbg(1, client, "BTSC setstereo: %s\n",strmode[mode]); 272 + nicam=0x0300; 273 + break; 274 + case MSP_MODE_EXTERN: 275 + v4l_dbg(1, client, "extern setstereo: %s\n",strmode[mode]); 276 + nicam = 0x0200; 277 + break; 278 + case MSP_MODE_FM_RADIO: 279 + v4l_dbg(1, client, "FM-Radio setstereo: %s\n",strmode[mode]); 280 + break; 281 + default: 282 + v4l_dbg(1, client, "mono setstereo\n"); 283 + return; 284 + } 285 + 286 + /* switch audio */ 287 + switch (mode) { 288 + case V4L2_TUNER_MODE_STEREO: 289 + src = 0x0020 | nicam; 290 + break; 291 + case V4L2_TUNER_MODE_MONO: 292 + if (state->mode == MSP_MODE_AM_NICAM) { 293 + v4l_dbg(1, client, "switching to AM mono\n"); 294 + /* AM mono decoding is handled by tuner, not MSP chip */ 295 + /* SCART switching control register */ 296 + msp_set_scart(client, SCART_MONO, 0); 297 + src = 0x0200; 298 + break; 299 + } 300 + case V4L2_TUNER_MODE_LANG1: 301 + src = 0x0000 | nicam; 302 + break; 303 + case V4L2_TUNER_MODE_LANG2: 304 + src = 0x0010 | nicam; 305 + break; 306 + } 307 + v4l_dbg(1, client, "setstereo final source/matrix = 0x%x\n", src); 308 + 309 + if (dolby) { 310 + msp_write_dsp(client, 0x0008, 0x0520); 311 + msp_write_dsp(client, 0x0009, 0x0620); 312 + msp_write_dsp(client, 0x000a, src); 313 + msp_write_dsp(client, 0x000b, src); 314 + } else { 315 + msp_write_dsp(client, 0x0008, src); 316 + msp_write_dsp(client, 0x0009, src); 317 + msp_write_dsp(client, 0x000a, src); 318 + msp_write_dsp(client, 0x000b, src); 319 + msp_write_dsp(client, 0x000c, src); 320 + if (state->has_scart23_in_scart2_out) 321 + msp_write_dsp(client, 0x0041, src); 322 + } 323 + } 324 + 325 + static void msp3400c_print_mode(struct i2c_client *client) 326 + { 327 + struct msp_state *state = i2c_get_clientdata(client); 328 + 329 + if (state->main == state->second) { 330 + v4l_dbg(1, client, "mono sound carrier: %d.%03d MHz\n", 331 + state->main / 910000, (state->main / 910) % 1000); 332 + } else { 333 + v4l_dbg(1, client, "main sound carrier: %d.%03d MHz\n", 334 + state->main / 910000, (state->main / 910) % 1000); 335 + } 336 + if (state->mode == MSP_MODE_FM_NICAM1 || state->mode == MSP_MODE_FM_NICAM2) 337 + v4l_dbg(1, client, "NICAM/FM carrier : %d.%03d MHz\n", 338 + state->second / 910000, (state->second/910) % 1000); 339 + if (state->mode == MSP_MODE_AM_NICAM) 340 + v4l_dbg(1, client, "NICAM/AM carrier : %d.%03d MHz\n", 341 + state->second / 910000, (state->second / 910) % 1000); 342 + if (state->mode == MSP_MODE_FM_TERRA && state->main != state->second) { 343 + v4l_dbg(1, client, "FM-stereo carrier : %d.%03d MHz\n", 344 + state->second / 910000, (state->second / 910) % 1000); 345 + } 346 + } 347 + 348 + /* ----------------------------------------------------------------------- */ 349 + 350 + int autodetect_stereo(struct i2c_client *client) 351 + { 352 + struct msp_state *state = i2c_get_clientdata(client); 353 + int val; 354 + int rxsubchans = state->rxsubchans; 355 + int newnicam = state->nicam_on; 356 + int update = 0; 357 + 358 + switch (state->mode) { 359 + case MSP_MODE_FM_TERRA: 360 + val = msp_read_dsp(client, 0x18); 361 + if (val > 32767) 362 + val -= 65536; 363 + v4l_dbg(2, client, "stereo detect register: %d\n", val); 364 + if (val > 4096) { 365 + rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO; 366 + } else if (val < -4096) { 367 + rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; 368 + } else { 369 + rxsubchans = V4L2_TUNER_SUB_MONO; 370 + } 371 + newnicam = 0; 372 + break; 373 + case MSP_MODE_FM_NICAM1: 374 + case MSP_MODE_FM_NICAM2: 375 + case MSP_MODE_AM_NICAM: 376 + val = msp_read_dem(client, 0x23); 377 + v4l_dbg(2, client, "nicam sync=%d, mode=%d\n", 378 + val & 1, (val & 0x1e) >> 1); 379 + 380 + if (val & 1) { 381 + /* nicam synced */ 382 + switch ((val & 0x1e) >> 1) { 383 + case 0: 384 + case 8: 385 + rxsubchans = V4L2_TUNER_SUB_STEREO; 386 + break; 387 + case 1: 388 + case 9: 389 + rxsubchans = V4L2_TUNER_SUB_MONO 390 + | V4L2_TUNER_SUB_LANG1; 391 + break; 392 + case 2: 393 + case 10: 394 + rxsubchans = V4L2_TUNER_SUB_MONO 395 + | V4L2_TUNER_SUB_LANG1 396 + | V4L2_TUNER_SUB_LANG2; 397 + break; 398 + default: 399 + rxsubchans = V4L2_TUNER_SUB_MONO; 400 + break; 401 + } 402 + newnicam = 1; 403 + } else { 404 + newnicam = 0; 405 + rxsubchans = V4L2_TUNER_SUB_MONO; 406 + } 407 + break; 408 + case MSP_MODE_BTSC: 409 + val = msp_read_dem(client, 0x200); 410 + v4l_dbg(2, client, "status=0x%x (pri=%s, sec=%s, %s%s%s)\n", 411 + val, 412 + (val & 0x0002) ? "no" : "yes", 413 + (val & 0x0004) ? "no" : "yes", 414 + (val & 0x0040) ? "stereo" : "mono", 415 + (val & 0x0080) ? ", nicam 2nd mono" : "", 416 + (val & 0x0100) ? ", bilingual/SAP" : ""); 417 + rxsubchans = V4L2_TUNER_SUB_MONO; 418 + if (val & 0x0040) rxsubchans |= V4L2_TUNER_SUB_STEREO; 419 + if (val & 0x0100) rxsubchans |= V4L2_TUNER_SUB_LANG1; 420 + break; 421 + } 422 + if (rxsubchans != state->rxsubchans) { 423 + update = 1; 424 + v4l_dbg(1, client, "watch: rxsubchans %d => %d\n", 425 + state->rxsubchans,rxsubchans); 426 + state->rxsubchans = rxsubchans; 427 + } 428 + if (newnicam != state->nicam_on) { 429 + update = 1; 430 + v4l_dbg(1, client, "watch: nicam %d => %d\n", 431 + state->nicam_on,newnicam); 432 + state->nicam_on = newnicam; 433 + } 434 + return update; 435 + } 436 + 437 + /* 438 + * A kernel thread for msp3400 control -- we don't want to block the 439 + * in the ioctl while doing the sound carrier & stereo detect 440 + */ 441 + /* stereo/multilang monitoring */ 442 + static void watch_stereo(struct i2c_client *client) 443 + { 444 + struct msp_state *state = i2c_get_clientdata(client); 445 + 446 + if (autodetect_stereo(client)) { 447 + if (state->rxsubchans & V4L2_TUNER_SUB_STEREO) 448 + msp3400c_setstereo(client, V4L2_TUNER_MODE_STEREO); 449 + else if (state->rxsubchans & V4L2_TUNER_SUB_LANG1) 450 + msp3400c_setstereo(client, V4L2_TUNER_MODE_LANG1); 451 + else 452 + msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 453 + } 454 + 455 + if (once) 456 + state->watch_stereo = 0; 457 + } 458 + 459 + int msp3400c_thread(void *data) 460 + { 461 + struct i2c_client *client = data; 462 + struct msp_state *state = i2c_get_clientdata(client); 463 + struct msp3400c_carrier_detect *cd; 464 + int count, max1,max2,val1,val2, val,this; 465 + 466 + 467 + v4l_dbg(1, client, "msp3400 daemon started\n"); 468 + for (;;) { 469 + v4l_dbg(2, client, "msp3400 thread: sleep\n"); 470 + msp_sleep(state, -1); 471 + v4l_dbg(2, client, "msp3400 thread: wakeup\n"); 472 + 473 + restart: 474 + v4l_dbg(1, client, "thread: restart scan\n"); 475 + state->restart = 0; 476 + if (kthread_should_stop()) 477 + break; 478 + 479 + if (state->radio || MSP_MODE_EXTERN == state->mode) { 480 + /* no carrier scan, just unmute */ 481 + v4l_dbg(1, client, "thread: no carrier scan\n"); 482 + msp_set_audio(client); 483 + continue; 484 + } 485 + 486 + /* mute */ 487 + msp_set_mute(client); 488 + msp3400c_setmode(client, MSP_MODE_AM_DETECT /* +1 */ ); 489 + val1 = val2 = 0; 490 + max1 = max2 = -1; 491 + state->watch_stereo = 0; 492 + 493 + /* some time for the tuner to sync */ 494 + if (msp_sleep(state,200)) 495 + goto restart; 496 + 497 + /* carrier detect pass #1 -- main carrier */ 498 + cd = msp3400c_carrier_detect_main; 499 + count = ARRAY_SIZE(msp3400c_carrier_detect_main); 500 + 501 + if (amsound && (state->v4l2_std & V4L2_STD_SECAM)) { 502 + /* autodetect doesn't work well with AM ... */ 503 + max1 = 3; 504 + count = 0; 505 + v4l_dbg(1, client, "AM sound override\n"); 506 + } 507 + 508 + for (this = 0; this < count; this++) { 509 + msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo); 510 + if (msp_sleep(state,100)) 511 + goto restart; 512 + val = msp_read_dsp(client, 0x1b); 513 + if (val > 32767) 514 + val -= 65536; 515 + if (val1 < val) 516 + val1 = val, max1 = this; 517 + v4l_dbg(1, client, "carrier1 val: %5d / %s\n", val,cd[this].name); 518 + } 519 + 520 + /* carrier detect pass #2 -- second (stereo) carrier */ 521 + switch (max1) { 522 + case 1: /* 5.5 */ 523 + cd = msp3400c_carrier_detect_55; 524 + count = ARRAY_SIZE(msp3400c_carrier_detect_55); 525 + break; 526 + case 3: /* 6.5 */ 527 + cd = msp3400c_carrier_detect_65; 528 + count = ARRAY_SIZE(msp3400c_carrier_detect_65); 529 + break; 530 + case 0: /* 4.5 */ 531 + case 2: /* 6.0 */ 532 + default: 533 + cd = NULL; 534 + count = 0; 535 + break; 536 + } 537 + 538 + if (amsound && (state->v4l2_std & V4L2_STD_SECAM)) { 539 + /* autodetect doesn't work well with AM ... */ 540 + cd = NULL; 541 + count = 0; 542 + max2 = 0; 543 + } 544 + for (this = 0; this < count; this++) { 545 + msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo); 546 + if (msp_sleep(state,100)) 547 + goto restart; 548 + val = msp_read_dsp(client, 0x1b); 549 + if (val > 32767) 550 + val -= 65536; 551 + if (val2 < val) 552 + val2 = val, max2 = this; 553 + v4l_dbg(1, client, "carrier2 val: %5d / %s\n", val,cd[this].name); 554 + } 555 + 556 + /* program the msp3400 according to the results */ 557 + state->main = msp3400c_carrier_detect_main[max1].cdo; 558 + switch (max1) { 559 + case 1: /* 5.5 */ 560 + if (max2 == 0) { 561 + /* B/G FM-stereo */ 562 + state->second = msp3400c_carrier_detect_55[max2].cdo; 563 + msp3400c_setmode(client, MSP_MODE_FM_TERRA); 564 + state->nicam_on = 0; 565 + msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 566 + state->watch_stereo = 1; 567 + } else if (max2 == 1 && state->has_nicam) { 568 + /* B/G NICAM */ 569 + state->second = msp3400c_carrier_detect_55[max2].cdo; 570 + msp3400c_setmode(client, MSP_MODE_FM_NICAM1); 571 + state->nicam_on = 1; 572 + msp3400c_setcarrier(client, state->second, state->main); 573 + state->watch_stereo = 1; 574 + } else { 575 + goto no_second; 576 + } 577 + break; 578 + case 2: /* 6.0 */ 579 + /* PAL I NICAM */ 580 + state->second = MSP_CARRIER(6.552); 581 + msp3400c_setmode(client, MSP_MODE_FM_NICAM2); 582 + state->nicam_on = 1; 583 + msp3400c_setcarrier(client, state->second, state->main); 584 + state->watch_stereo = 1; 585 + break; 586 + case 3: /* 6.5 */ 587 + if (max2 == 1 || max2 == 2) { 588 + /* D/K FM-stereo */ 589 + state->second = msp3400c_carrier_detect_65[max2].cdo; 590 + msp3400c_setmode(client, MSP_MODE_FM_TERRA); 591 + state->nicam_on = 0; 592 + msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 593 + state->watch_stereo = 1; 594 + } else if (max2 == 0 && (state->v4l2_std & V4L2_STD_SECAM)) { 595 + /* L NICAM or AM-mono */ 596 + state->second = msp3400c_carrier_detect_65[max2].cdo; 597 + msp3400c_setmode(client, MSP_MODE_AM_NICAM); 598 + state->nicam_on = 0; 599 + msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 600 + msp3400c_setcarrier(client, state->second, state->main); 601 + /* volume prescale for SCART (AM mono input) */ 602 + msp_write_dsp(client, 0x000d, 0x1900); 603 + state->watch_stereo = 1; 604 + } else if (max2 == 0 && state->has_nicam) { 605 + /* D/K NICAM */ 606 + state->second = msp3400c_carrier_detect_65[max2].cdo; 607 + msp3400c_setmode(client, MSP_MODE_FM_NICAM1); 608 + state->nicam_on = 1; 609 + msp3400c_setcarrier(client, state->second, state->main); 610 + state->watch_stereo = 1; 611 + } else { 612 + goto no_second; 613 + } 614 + break; 615 + case 0: /* 4.5 */ 616 + default: 617 + no_second: 618 + state->second = msp3400c_carrier_detect_main[max1].cdo; 619 + msp3400c_setmode(client, MSP_MODE_FM_TERRA); 620 + state->nicam_on = 0; 621 + msp3400c_setcarrier(client, state->second, state->main); 622 + state->rxsubchans = V4L2_TUNER_SUB_MONO; 623 + msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 624 + break; 625 + } 626 + 627 + /* unmute */ 628 + msp_set_audio(client); 629 + 630 + if (debug) 631 + msp3400c_print_mode(client); 632 + 633 + /* monitor tv audio mode */ 634 + while (state->watch_stereo) { 635 + if (msp_sleep(state,5000)) 636 + goto restart; 637 + watch_stereo(client); 638 + } 639 + } 640 + v4l_dbg(1, client, "thread: exit\n"); 641 + return 0; 642 + } 643 + 644 + 645 + int msp3410d_thread(void *data) 646 + { 647 + struct i2c_client *client = data; 648 + struct msp_state *state = i2c_get_clientdata(client); 649 + int val, i, std; 650 + 651 + v4l_dbg(1, client, "msp3410 daemon started\n"); 652 + 653 + for (;;) { 654 + v4l_dbg(2, client, "msp3410 thread: sleep\n"); 655 + msp_sleep(state,-1); 656 + v4l_dbg(2, client, "msp3410 thread: wakeup\n"); 657 + 658 + restart: 659 + v4l_dbg(1, client, "thread: restart scan\n"); 660 + state->restart = 0; 661 + if (kthread_should_stop()) 662 + break; 663 + 664 + if (state->mode == MSP_MODE_EXTERN) { 665 + /* no carrier scan needed, just unmute */ 666 + v4l_dbg(1, client, "thread: no carrier scan\n"); 667 + msp_set_audio(client); 668 + continue; 669 + } 670 + 671 + /* put into sane state (and mute) */ 672 + msp_reset(client); 673 + 674 + /* some time for the tuner to sync */ 675 + if (msp_sleep(state,200)) 676 + goto restart; 677 + 678 + /* start autodetect */ 679 + if (state->radio) 680 + std = 0x40; 681 + else 682 + std = (state->v4l2_std & V4L2_STD_NTSC) ? 0x20 : 1; 683 + state->watch_stereo = 0; 684 + 685 + if (debug) 686 + v4l_dbg(1, client, "setting standard: %s (0x%04x)\n", 687 + msp_standard_std_name(std), std); 688 + 689 + if (std != 1) { 690 + /* programmed some specific mode */ 691 + val = std; 692 + } else { 693 + /* triggered autodetect */ 694 + msp_write_dem(client, 0x20, std); 695 + for (;;) { 696 + if (msp_sleep(state, 100)) 697 + goto restart; 698 + 699 + /* check results */ 700 + val = msp_read_dem(client, 0x7e); 701 + if (val < 0x07ff) 702 + break; 703 + v4l_dbg(1, client, "detection still in progress\n"); 704 + } 705 + } 706 + for (i = 0; msp_stdlist[i].name != NULL; i++) 707 + if (msp_stdlist[i].retval == val) 708 + break; 709 + v4l_dbg(1, client, "current standard: %s (0x%04x)\n", 710 + msp_standard_std_name(val), val); 711 + state->main = msp_stdlist[i].main; 712 + state->second = msp_stdlist[i].second; 713 + state->std = val; 714 + 715 + if (amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) && 716 + (val != 0x0009)) { 717 + /* autodetection has failed, let backup */ 718 + v4l_dbg(1, client, "autodetection failed," 719 + " switching to backup standard: %s (0x%04x)\n", 720 + msp_stdlist[8].name ? msp_stdlist[8].name : "unknown",val); 721 + val = 0x0009; 722 + msp_write_dem(client, 0x20, val); 723 + } 724 + 725 + /* set various prescales */ 726 + msp_write_dsp(client, 0x0d, 0x1900); /* scart */ 727 + msp_write_dsp(client, 0x0e, 0x2403); /* FM */ 728 + msp_write_dsp(client, 0x10, 0x5a00); /* nicam */ 729 + 730 + /* set stereo */ 731 + switch (val) { 732 + case 0x0008: /* B/G NICAM */ 733 + case 0x000a: /* I NICAM */ 734 + if (val == 0x0008) 735 + state->mode = MSP_MODE_FM_NICAM1; 736 + else 737 + state->mode = MSP_MODE_FM_NICAM2; 738 + /* just turn on stereo */ 739 + state->rxsubchans = V4L2_TUNER_SUB_STEREO; 740 + state->nicam_on = 1; 741 + state->watch_stereo = 1; 742 + msp3400c_setstereo(client,V4L2_TUNER_MODE_STEREO); 743 + break; 744 + case 0x0009: 745 + state->mode = MSP_MODE_AM_NICAM; 746 + state->rxsubchans = V4L2_TUNER_SUB_MONO; 747 + state->nicam_on = 1; 748 + msp3400c_setstereo(client,V4L2_TUNER_MODE_MONO); 749 + state->watch_stereo = 1; 750 + break; 751 + case 0x0020: /* BTSC */ 752 + /* just turn on stereo */ 753 + state->mode = MSP_MODE_BTSC; 754 + state->rxsubchans = V4L2_TUNER_SUB_STEREO; 755 + state->nicam_on = 0; 756 + state->watch_stereo = 1; 757 + msp3400c_setstereo(client,V4L2_TUNER_MODE_STEREO); 758 + break; 759 + case 0x0040: /* FM radio */ 760 + state->mode = MSP_MODE_FM_RADIO; 761 + state->rxsubchans = V4L2_TUNER_SUB_STEREO; 762 + state->audmode = V4L2_TUNER_MODE_STEREO; 763 + state->nicam_on = 0; 764 + state->watch_stereo = 0; 765 + /* not needed in theory if we have radio, but 766 + short programming enables carrier mute */ 767 + msp3400c_setmode(client, MSP_MODE_FM_RADIO); 768 + msp3400c_setcarrier(client, MSP_CARRIER(10.7), 769 + MSP_CARRIER(10.7)); 770 + /* scart routing */ 771 + msp_set_scart(client,SCART_IN2,0); 772 + /* msp34xx does radio decoding */ 773 + msp_write_dsp(client, 0x08, 0x0020); 774 + msp_write_dsp(client, 0x09, 0x0020); 775 + msp_write_dsp(client, 0x0b, 0x0020); 776 + break; 777 + case 0x0003: 778 + case 0x0004: 779 + case 0x0005: 780 + state->mode = MSP_MODE_FM_TERRA; 781 + state->rxsubchans = V4L2_TUNER_SUB_MONO; 782 + state->audmode = V4L2_TUNER_MODE_MONO; 783 + state->nicam_on = 0; 784 + state->watch_stereo = 1; 785 + break; 786 + } 787 + 788 + /* unmute, restore misc registers */ 789 + msp_set_audio(client); 790 + msp_write_dsp(client, 0x13, state->acb); 791 + if (state->has_i2s_conf) 792 + msp_write_dem(client, 0x40, state->i2s_mode); 793 + 794 + /* monitor tv audio mode */ 795 + while (state->watch_stereo) { 796 + if (msp_sleep(state,5000)) 797 + goto restart; 798 + watch_stereo(client); 799 + } 800 + } 801 + v4l_dbg(1, client, "thread: exit\n"); 802 + return 0; 803 + } 804 + 805 + /* ----------------------------------------------------------------------- */ 806 + 807 + /* msp34xxG + (autoselect no-thread) */ 808 + /* this one uses both automatic standard detection and automatic sound */ 809 + /* select which are available in the newer G versions */ 810 + /* struct msp: only norm, acb and source are really used in this mode */ 811 + 812 + /* set the same 'source' for the loudspeaker, scart and quasi-peak detector 813 + * the value for source is the same as bit 15:8 of DSP registers 0x08, 814 + * 0x0a and 0x0c: 0=mono, 1=stereo or A|B, 2=SCART, 3=stereo or A, 4=stereo or B 815 + * 816 + * this function replaces msp3400c_setstereo 817 + */ 818 + static void msp34xxg_set_source(struct i2c_client *client, int source) 819 + { 820 + struct msp_state *state = i2c_get_clientdata(client); 821 + 822 + /* fix matrix mode to stereo and let the msp choose what 823 + * to output according to 'source', as recommended 824 + * for MONO (source==0) downmixing set bit[7:0] to 0x30 825 + */ 826 + int value = (source & 0x07) << 8 | (source == 0 ? 0x30 : 0x20); 827 + 828 + v4l_dbg(1, client, "set source to %d (0x%x)\n", source, value); 829 + /* Loudspeaker Output */ 830 + msp_write_dsp(client, 0x08, value); 831 + /* SCART1 DA Output */ 832 + msp_write_dsp(client, 0x0a, value); 833 + /* Quasi-peak detector */ 834 + msp_write_dsp(client, 0x0c, value); 835 + /* 836 + * set identification threshold. Personally, I 837 + * I set it to a higher value that the default 838 + * of 0x190 to ignore noisy stereo signals. 839 + * this needs tuning. (recommended range 0x00a0-0x03c0) 840 + * 0x7f0 = forced mono mode 841 + */ 842 + /* a2 threshold for stereo/bilingual */ 843 + msp_write_dem(client, 0x22, stereo_threshold); 844 + state->source = source; 845 + } 846 + 847 + /* (re-)initialize the msp34xxg, according to the current norm in state->norm 848 + * return 0 if it worked, -1 if it failed 849 + */ 850 + static int msp34xxg_reset(struct i2c_client *client) 851 + { 852 + struct msp_state *state = i2c_get_clientdata(client); 853 + int modus, std; 854 + 855 + if (msp_reset(client)) 856 + return -1; 857 + 858 + /* make sure that input/output is muted (paranoid mode) */ 859 + /* ACB, mute DSP input, mute SCART 1 */ 860 + if (msp_write_dsp(client, 0x13, 0x0f20)) 861 + return -1; 862 + 863 + if (state->has_i2s_conf) 864 + msp_write_dem(client, 0x40, state->i2s_mode); 865 + 866 + /* step-by-step initialisation, as described in the manual */ 867 + modus = msp_modus(client); 868 + if (state->radio) 869 + std = 0x40; 870 + else 871 + std = (state->v4l2_std & V4L2_STD_NTSC) ? 0x20 : 1; 872 + modus &= ~0x03; /* STATUS_CHANGE = 0 */ 873 + modus |= 0x01; /* AUTOMATIC_SOUND_DETECTION = 1 */ 874 + if (msp_write_dem(client, 0x30, modus)) 875 + return -1; 876 + if (msp_write_dem(client, 0x20, std)) 877 + return -1; 878 + 879 + /* write the dsps that may have an influence on 880 + standard/audio autodetection right now */ 881 + msp34xxg_set_source(client, state->source); 882 + 883 + /* AM/FM Prescale [15:8] 75khz deviation */ 884 + if (msp_write_dsp(client, 0x0e, 0x3000)) 885 + return -1; 886 + 887 + /* NICAM Prescale 9db gain (as recommended) */ 888 + if (msp_write_dsp(client, 0x10, 0x5a00)) 889 + return -1; 890 + 891 + return 0; 892 + } 893 + 894 + int msp34xxg_thread(void *data) 895 + { 896 + struct i2c_client *client = data; 897 + struct msp_state *state = i2c_get_clientdata(client); 898 + int val, std, i; 899 + 900 + v4l_dbg(1, client, "msp34xxg daemon started\n"); 901 + 902 + state->source = 1; /* default */ 903 + for (;;) { 904 + v4l_dbg(2, client, "msp34xxg thread: sleep\n"); 905 + msp_sleep(state, -1); 906 + v4l_dbg(2, client, "msp34xxg thread: wakeup\n"); 907 + 908 + restart: 909 + v4l_dbg(1, client, "thread: restart scan\n"); 910 + state->restart = 0; 911 + if (kthread_should_stop()) 912 + break; 913 + 914 + /* setup the chip*/ 915 + msp34xxg_reset(client); 916 + std = standard; 917 + if (std != 0x01) 918 + goto unmute; 919 + 920 + /* watch autodetect */ 921 + v4l_dbg(1, client, "triggered autodetect, waiting for result\n"); 922 + for (i = 0; i < 10; i++) { 923 + if (msp_sleep(state, 100)) 924 + goto restart; 925 + 926 + /* check results */ 927 + val = msp_read_dem(client, 0x7e); 928 + if (val < 0x07ff) { 929 + std = val; 930 + break; 931 + } 932 + v4l_dbg(2, client, "detection still in progress\n"); 933 + } 934 + if (std == 1) { 935 + v4l_dbg(1, client, "detection still in progress after 10 tries. giving up.\n"); 936 + continue; 937 + } 938 + 939 + unmute: 940 + state->std = std; 941 + v4l_dbg(1, client, "current standard: %s (0x%04x)\n", 942 + msp_standard_std_name(std), std); 943 + 944 + /* unmute: dispatch sound to scart output, set scart volume */ 945 + msp_set_audio(client); 946 + 947 + /* restore ACB */ 948 + if (msp_write_dsp(client, 0x13, state->acb)) 949 + return -1; 950 + 951 + msp_write_dem(client, 0x40, state->i2s_mode); 952 + } 953 + v4l_dbg(1, client, "thread: exit\n"); 954 + return 0; 955 + } 956 + 957 + void msp34xxg_detect_stereo(struct i2c_client *client) 958 + { 959 + struct msp_state *state = i2c_get_clientdata(client); 960 + 961 + int status = msp_read_dem(client, 0x0200); 962 + int is_bilingual = status & 0x100; 963 + int is_stereo = status & 0x40; 964 + 965 + state->rxsubchans = 0; 966 + if (is_stereo) 967 + state->rxsubchans |= V4L2_TUNER_SUB_STEREO; 968 + else 969 + state->rxsubchans |= V4L2_TUNER_SUB_MONO; 970 + if (is_bilingual) { 971 + state->rxsubchans |= V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; 972 + /* I'm supposed to check whether it's SAP or not 973 + * and set only LANG2/SAP in this case. Yet, the MSP 974 + * does a lot of work to hide this and handle everything 975 + * the same way. I don't want to work around it so unless 976 + * this is a problem, I'll handle SAP just like lang1/lang2. 977 + */ 978 + } 979 + v4l_dbg(1, client, "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n", 980 + status, is_stereo, is_bilingual, state->rxsubchans); 981 + } 982 + 983 + void msp34xxg_set_audmode(struct i2c_client *client, int audmode) 984 + { 985 + struct msp_state *state = i2c_get_clientdata(client); 986 + int source; 987 + 988 + switch (audmode) { 989 + case V4L2_TUNER_MODE_MONO: 990 + source = 0; /* mono only */ 991 + break; 992 + case V4L2_TUNER_MODE_STEREO: 993 + source = 1; /* stereo or A|B, see comment in msp34xxg_get_v4l2_stereo() */ 994 + /* problem: that could also mean 2 (scart input) */ 995 + break; 996 + case V4L2_TUNER_MODE_LANG1: 997 + source = 3; /* stereo or A */ 998 + break; 999 + case V4L2_TUNER_MODE_LANG2: 1000 + source = 4; /* stereo or B */ 1001 + break; 1002 + default: 1003 + audmode = 0; 1004 + source = 1; 1005 + break; 1006 + } 1007 + state->audmode = audmode; 1008 + msp34xxg_set_source(client, source); 1009 + } 1010 +
-2229
drivers/media/video/msp3400.c
··· 1 - /* 2 - * programming the msp34* sound processor family 3 - * 4 - * (c) 1997-2001 Gerd Knorr <kraxel@bytesex.org> 5 - * 6 - * what works and what doesn't: 7 - * 8 - * AM-Mono 9 - * Support for Hauppauge cards added (decoding handled by tuner) added by 10 - * Frederic Crozat <fcrozat@mail.dotcom.fr> 11 - * 12 - * FM-Mono 13 - * should work. The stereo modes are backward compatible to FM-mono, 14 - * therefore FM-Mono should be allways available. 15 - * 16 - * FM-Stereo (B/G, used in germany) 17 - * should work, with autodetect 18 - * 19 - * FM-Stereo (satellite) 20 - * should work, no autodetect (i.e. default is mono, but you can 21 - * switch to stereo -- untested) 22 - * 23 - * NICAM (B/G, L , used in UK, Scandinavia, Spain and France) 24 - * should work, with autodetect. Support for NICAM was added by 25 - * Pekka Pietikainen <pp@netppl.fi> 26 - * 27 - * 28 - * TODO: 29 - * - better SAT support 30 - * 31 - * 32 - * 980623 Thomas Sailer (sailer@ife.ee.ethz.ch) 33 - * using soundcore instead of OSS 34 - * 35 - */ 36 - 37 - #include <linux/config.h> 38 - #include <linux/module.h> 39 - #include <linux/moduleparam.h> 40 - #include <linux/kernel.h> 41 - #include <linux/sched.h> 42 - #include <linux/string.h> 43 - #include <linux/timer.h> 44 - #include <linux/delay.h> 45 - #include <linux/errno.h> 46 - #include <linux/slab.h> 47 - #include <linux/i2c.h> 48 - #include <linux/videodev.h> 49 - #include <linux/init.h> 50 - #include <linux/smp_lock.h> 51 - #include <linux/kthread.h> 52 - #include <linux/suspend.h> 53 - #include <asm/semaphore.h> 54 - #include <asm/pgtable.h> 55 - 56 - #include <media/audiochip.h> 57 - #include "msp3400.h" 58 - 59 - #define msp3400_dbg(fmt, arg...) \ 60 - do { \ 61 - if (debug) \ 62 - printk(KERN_INFO "%s debug %d-%04x: " fmt, \ 63 - client->driver->driver.name, \ 64 - i2c_adapter_id(client->adapter), client->addr , ## arg); \ 65 - } while (0) 66 - 67 - /* Medium volume debug. */ 68 - #define msp3400_dbg_mediumvol(fmt, arg...) \ 69 - do { \ 70 - if (debug >= 2) \ 71 - printk(KERN_INFO "%s debug %d-%04x: " fmt, \ 72 - client->driver->driver.name, \ 73 - i2c_adapter_id(client->adapter), client->addr , ## arg); \ 74 - } while (0) 75 - 76 - /* High volume debug. Use with care. */ 77 - #define msp3400_dbg_highvol(fmt, arg...) \ 78 - do { \ 79 - if (debug >= 16) \ 80 - printk(KERN_INFO "%s debug %d-%04x: " fmt, \ 81 - client->driver->driver.name, \ 82 - i2c_adapter_id(client->adapter), client->addr , ## arg); \ 83 - } while (0) 84 - 85 - #define msp3400_err(fmt, arg...) do { \ 86 - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ 87 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 88 - #define msp3400_warn(fmt, arg...) do { \ 89 - printk(KERN_WARNING "%s %d-%04x: " fmt, client->driver->driver.name, \ 90 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 91 - #define msp3400_info(fmt, arg...) do { \ 92 - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ 93 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 94 - 95 - #define OPMODE_AUTO -1 96 - #define OPMODE_MANUAL 0 97 - #define OPMODE_SIMPLE 1 /* use short programming (>= msp3410 only) */ 98 - #define OPMODE_SIMPLER 2 /* use shorter programming (>= msp34xxG) */ 99 - 100 - /* insmod parameters */ 101 - static int opmode = OPMODE_AUTO; 102 - static int debug = 0; /* debug output */ 103 - static int once = 0; /* no continous stereo monitoring */ 104 - static int amsound = 0; /* hard-wire AM sound at 6.5 Hz (france), 105 - the autoscan seems work well only with FM... */ 106 - static int standard = 1; /* Override auto detect of audio standard, if needed. */ 107 - static int dolby = 0; 108 - 109 - static int stereo_threshold = 0x190; /* a2 threshold for stereo/bilingual 110 - (msp34xxg only) 0x00a0-0x03c0 */ 111 - #define DFP_COUNT 0x41 112 - static const int bl_dfp[] = { 113 - 0x00, 0x01, 0x02, 0x03, 0x06, 0x08, 0x09, 0x0a, 114 - 0x0b, 0x0d, 0x0e, 0x10 115 - }; 116 - 117 - #define IS_MSP34XX_G(msp) ((msp)->opmode==2) 118 - 119 - struct msp3400c { 120 - int rev1,rev2; 121 - 122 - int opmode; 123 - int nicam; 124 - int mode; 125 - int norm; 126 - int stereo; 127 - int nicam_on; 128 - int acb; 129 - int in_scart; 130 - int i2s_mode; 131 - int main, second; /* sound carrier */ 132 - int input; 133 - int source; /* see msp34xxg_set_source */ 134 - 135 - /* v4l2 */ 136 - int audmode; 137 - int rxsubchans; 138 - 139 - int muted; 140 - int left, right; /* volume */ 141 - int bass, treble; 142 - 143 - /* shadow register set */ 144 - int dfp_regs[DFP_COUNT]; 145 - 146 - /* thread */ 147 - struct task_struct *kthread; 148 - wait_queue_head_t wq; 149 - int restart:1; 150 - int watch_stereo:1; 151 - }; 152 - 153 - #define MIN(a,b) (((a)>(b))?(b):(a)) 154 - #define MAX(a,b) (((a)>(b))?(a):(b)) 155 - #define HAVE_NICAM(msp) (((msp->rev2>>8) & 0xff) != 00) 156 - #define HAVE_SIMPLE(msp) ((msp->rev1 & 0xff) >= 'D'-'@') 157 - #define HAVE_SIMPLER(msp) ((msp->rev1 & 0xff) >= 'G'-'@') 158 - #define HAVE_RADIO(msp) ((msp->rev1 & 0xff) >= 'G'-'@') 159 - 160 - #define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */ 161 - 162 - /* ---------------------------------------------------------------------- */ 163 - 164 - /* read-only */ 165 - module_param(opmode, int, 0444); 166 - 167 - /* read-write */ 168 - module_param(once, int, 0644); 169 - module_param(debug, int, 0644); 170 - module_param(stereo_threshold, int, 0644); 171 - module_param(standard, int, 0644); 172 - module_param(amsound, int, 0644); 173 - module_param(dolby, int, 0644); 174 - 175 - MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Simple, 2=Simpler"); 176 - MODULE_PARM_DESC(once, "No continuous stereo monitoring"); 177 - MODULE_PARM_DESC(debug, "Enable debug messages"); 178 - MODULE_PARM_DESC(stereo_threshold, "Sets signal threshold to activate stereo"); 179 - MODULE_PARM_DESC(standard, "Specify audio standard: 32 = NTSC, 64 = radio, Default: Autodetect"); 180 - MODULE_PARM_DESC(amsound, "Hardwire AM sound at 6.5Hz (France), FM can autoscan"); 181 - MODULE_PARM_DESC(dolby, "Activates Dolby processsing"); 182 - 183 - /* ---------------------------------------------------------------------- */ 184 - 185 - #define I2C_MSP3400C 0x80 186 - #define I2C_MSP3400C_ALT 0x88 187 - 188 - #define I2C_MSP3400C_DEM 0x10 189 - #define I2C_MSP3400C_DFP 0x12 190 - 191 - /* Addresses to scan */ 192 - static unsigned short normal_i2c[] = { 193 - I2C_MSP3400C >> 1, 194 - I2C_MSP3400C_ALT >> 1, 195 - I2C_CLIENT_END 196 - }; 197 - I2C_CLIENT_INSMOD; 198 - 199 - MODULE_DESCRIPTION("device driver for msp34xx TV sound processor"); 200 - MODULE_AUTHOR("Gerd Knorr"); 201 - MODULE_LICENSE("GPL"); 202 - 203 - /* ----------------------------------------------------------------------- */ 204 - /* functions for talking to the MSP3400C Sound processor */ 205 - 206 - static int msp3400c_reset(struct i2c_client *client) 207 - { 208 - /* reset and read revision code */ 209 - static char reset_off[3] = { 0x00, 0x80, 0x00 }; 210 - static char reset_on[3] = { 0x00, 0x00, 0x00 }; 211 - static char write[3] = { I2C_MSP3400C_DFP + 1, 0x00, 0x1e }; 212 - char read[2]; 213 - struct i2c_msg reset[2] = { 214 - { client->addr, I2C_M_IGNORE_NAK, 3, reset_off }, 215 - { client->addr, I2C_M_IGNORE_NAK, 3, reset_on }, 216 - }; 217 - struct i2c_msg test[2] = { 218 - { client->addr, 0, 3, write }, 219 - { client->addr, I2C_M_RD, 2, read }, 220 - }; 221 - 222 - msp3400_dbg_highvol("msp3400c_reset\n"); 223 - if ( (1 != i2c_transfer(client->adapter,&reset[0],1)) || 224 - (1 != i2c_transfer(client->adapter,&reset[1],1)) || 225 - (2 != i2c_transfer(client->adapter,test,2)) ) { 226 - msp3400_err("chip reset failed\n"); 227 - return -1; 228 - } 229 - return 0; 230 - } 231 - 232 - static int msp3400c_read(struct i2c_client *client, int dev, int addr) 233 - { 234 - int err,retval; 235 - 236 - unsigned char write[3]; 237 - unsigned char read[2]; 238 - struct i2c_msg msgs[2] = { 239 - { client->addr, 0, 3, write }, 240 - { client->addr, I2C_M_RD, 2, read } 241 - }; 242 - 243 - write[0] = dev+1; 244 - write[1] = addr >> 8; 245 - write[2] = addr & 0xff; 246 - 247 - for (err = 0; err < 3;) { 248 - if (2 == i2c_transfer(client->adapter,msgs,2)) 249 - break; 250 - err++; 251 - msp3400_warn("I/O error #%d (read 0x%02x/0x%02x)\n", err, 252 - dev, addr); 253 - current->state = TASK_INTERRUPTIBLE; 254 - schedule_timeout(msecs_to_jiffies(10)); 255 - } 256 - if (3 == err) { 257 - msp3400_warn("giving up, resetting chip. Sound will go off, sorry folks :-|\n"); 258 - msp3400c_reset(client); 259 - return -1; 260 - } 261 - retval = read[0] << 8 | read[1]; 262 - msp3400_dbg_highvol("msp3400c_read(0x%x, 0x%x): 0x%x\n", dev, addr, retval); 263 - return retval; 264 - } 265 - 266 - static int msp3400c_write(struct i2c_client *client, int dev, int addr, int val) 267 - { 268 - int err; 269 - unsigned char buffer[5]; 270 - 271 - buffer[0] = dev; 272 - buffer[1] = addr >> 8; 273 - buffer[2] = addr & 0xff; 274 - buffer[3] = val >> 8; 275 - buffer[4] = val & 0xff; 276 - 277 - msp3400_dbg_highvol("msp3400c_write(0x%x, 0x%x, 0x%x)\n", dev, addr, val); 278 - for (err = 0; err < 3;) { 279 - if (5 == i2c_master_send(client, buffer, 5)) 280 - break; 281 - err++; 282 - msp3400_warn("I/O error #%d (write 0x%02x/0x%02x)\n", err, 283 - dev, addr); 284 - current->state = TASK_INTERRUPTIBLE; 285 - schedule_timeout(msecs_to_jiffies(10)); 286 - } 287 - if (3 == err) { 288 - msp3400_warn("giving up, reseting chip. Sound will go off, sorry folks :-|\n"); 289 - msp3400c_reset(client); 290 - return -1; 291 - } 292 - return 0; 293 - } 294 - 295 - /* ------------------------------------------------------------------------ */ 296 - 297 - /* This macro is allowed for *constants* only, gcc must calculate it 298 - at compile time. Remember -- no floats in kernel mode */ 299 - #define MSP_CARRIER(freq) ((int)((float)(freq/18.432)*(1<<24))) 300 - 301 - #define MSP_MODE_AM_DETECT 0 302 - #define MSP_MODE_FM_RADIO 2 303 - #define MSP_MODE_FM_TERRA 3 304 - #define MSP_MODE_FM_SAT 4 305 - #define MSP_MODE_FM_NICAM1 5 306 - #define MSP_MODE_FM_NICAM2 6 307 - #define MSP_MODE_AM_NICAM 7 308 - #define MSP_MODE_BTSC 8 309 - #define MSP_MODE_EXTERN 9 310 - 311 - static struct MSP_INIT_DATA_DEM { 312 - int fir1[6]; 313 - int fir2[6]; 314 - int cdo1; 315 - int cdo2; 316 - int ad_cv; 317 - int mode_reg; 318 - int dfp_src; 319 - int dfp_matrix; 320 - } msp_init_data[] = { 321 - { /* AM (for carrier detect / msp3400) */ 322 - {75, 19, 36, 35, 39, 40}, 323 - {75, 19, 36, 35, 39, 40}, 324 - MSP_CARRIER(5.5), MSP_CARRIER(5.5), 325 - 0x00d0, 0x0500, 0x0020, 0x3000 326 - },{ /* AM (for carrier detect / msp3410) */ 327 - {-1, -1, -8, 2, 59, 126}, 328 - {-1, -1, -8, 2, 59, 126}, 329 - MSP_CARRIER(5.5), MSP_CARRIER(5.5), 330 - 0x00d0, 0x0100, 0x0020, 0x3000 331 - },{ /* FM Radio */ 332 - {-8, -8, 4, 6, 78, 107}, 333 - {-8, -8, 4, 6, 78, 107}, 334 - MSP_CARRIER(10.7), MSP_CARRIER(10.7), 335 - 0x00d0, 0x0480, 0x0020, 0x3000 336 - },{ /* Terrestial FM-mono + FM-stereo */ 337 - {3, 18, 27, 48, 66, 72}, 338 - {3, 18, 27, 48, 66, 72}, 339 - MSP_CARRIER(5.5), MSP_CARRIER(5.5), 340 - 0x00d0, 0x0480, 0x0030, 0x3000 341 - },{ /* Sat FM-mono */ 342 - { 1, 9, 14, 24, 33, 37}, 343 - { 3, 18, 27, 48, 66, 72}, 344 - MSP_CARRIER(6.5), MSP_CARRIER(6.5), 345 - 0x00c6, 0x0480, 0x0000, 0x3000 346 - },{ /* NICAM/FM -- B/G (5.5/5.85), D/K (6.5/5.85) */ 347 - {-2, -8, -10, 10, 50, 86}, 348 - {3, 18, 27, 48, 66, 72}, 349 - MSP_CARRIER(5.5), MSP_CARRIER(5.5), 350 - 0x00d0, 0x0040, 0x0120, 0x3000 351 - },{ /* NICAM/FM -- I (6.0/6.552) */ 352 - {2, 4, -6, -4, 40, 94}, 353 - {3, 18, 27, 48, 66, 72}, 354 - MSP_CARRIER(6.0), MSP_CARRIER(6.0), 355 - 0x00d0, 0x0040, 0x0120, 0x3000 356 - },{ /* NICAM/AM -- L (6.5/5.85) */ 357 - {-2, -8, -10, 10, 50, 86}, 358 - {-4, -12, -9, 23, 79, 126}, 359 - MSP_CARRIER(6.5), MSP_CARRIER(6.5), 360 - 0x00c6, 0x0140, 0x0120, 0x7c03 361 - }, 362 - }; 363 - 364 - struct CARRIER_DETECT { 365 - int cdo; 366 - char *name; 367 - }; 368 - 369 - static struct CARRIER_DETECT carrier_detect_main[] = { 370 - /* main carrier */ 371 - { MSP_CARRIER(4.5), "4.5 NTSC" }, 372 - { MSP_CARRIER(5.5), "5.5 PAL B/G" }, 373 - { MSP_CARRIER(6.0), "6.0 PAL I" }, 374 - { MSP_CARRIER(6.5), "6.5 PAL D/K + SAT + SECAM" } 375 - }; 376 - 377 - static struct CARRIER_DETECT carrier_detect_55[] = { 378 - /* PAL B/G */ 379 - { MSP_CARRIER(5.7421875), "5.742 PAL B/G FM-stereo" }, 380 - { MSP_CARRIER(5.85), "5.85 PAL B/G NICAM" } 381 - }; 382 - 383 - static struct CARRIER_DETECT carrier_detect_65[] = { 384 - /* PAL SAT / SECAM */ 385 - { MSP_CARRIER(5.85), "5.85 PAL D/K + SECAM NICAM" }, 386 - { MSP_CARRIER(6.2578125), "6.25 PAL D/K1 FM-stereo" }, 387 - { MSP_CARRIER(6.7421875), "6.74 PAL D/K2 FM-stereo" }, 388 - { MSP_CARRIER(7.02), "7.02 PAL SAT FM-stereo s/b" }, 389 - { MSP_CARRIER(7.20), "7.20 PAL SAT FM-stereo s" }, 390 - { MSP_CARRIER(7.38), "7.38 PAL SAT FM-stereo b" }, 391 - }; 392 - 393 - #define CARRIER_COUNT(x) (sizeof(x)/sizeof(struct CARRIER_DETECT)) 394 - 395 - /* ----------------------------------------------------------------------- * 396 - * bits 9 8 5 - SCART DSP input Select: 397 - * 0 0 0 - SCART 1 to DSP input (reset position) 398 - * 0 1 0 - MONO to DSP input 399 - * 1 0 0 - SCART 2 to DSP input 400 - * 1 1 1 - Mute DSP input 401 - * 402 - * bits 11 10 6 - SCART 1 Output Select: 403 - * 0 0 0 - undefined (reset position) 404 - * 0 1 0 - SCART 2 Input to SCART 1 Output (for devices with 2 SCARTS) 405 - * 1 0 0 - MONO input to SCART 1 Output 406 - * 1 1 0 - SCART 1 DA to SCART 1 Output 407 - * 0 0 1 - SCART 2 DA to SCART 1 Output 408 - * 0 1 1 - SCART 1 Input to SCART 1 Output 409 - * 1 1 1 - Mute SCART 1 Output 410 - * 411 - * bits 13 12 7 - SCART 2 Output Select (for devices with 2 Output SCART): 412 - * 0 0 0 - SCART 1 DA to SCART 2 Output (reset position) 413 - * 0 1 0 - SCART 1 Input to SCART 2 Output 414 - * 1 0 0 - MONO input to SCART 2 Output 415 - * 0 0 1 - SCART 2 DA to SCART 2 Output 416 - * 0 1 1 - SCART 2 Input to SCART 2 Output 417 - * 1 1 0 - Mute SCART 2 Output 418 - * 419 - * Bits 4 to 0 should be zero. 420 - * ----------------------------------------------------------------------- */ 421 - 422 - static int scarts[3][9] = { 423 - /* MASK IN1 IN2 IN1_DA IN2_DA IN3 IN4 MONO MUTE */ 424 - /* SCART DSP Input select */ 425 - { 0x0320, 0x0000, 0x0200, -1, -1, 0x0300, 0x0020, 0x0100, 0x0320 }, 426 - /* SCART1 Output select */ 427 - { 0x0c40, 0x0440, 0x0400, 0x0c00, 0x0040, 0x0000, 0x0840, 0x0800, 0x0c40 }, 428 - /* SCART2 Output select */ 429 - { 0x3080, 0x1000, 0x1080, 0x0000, 0x0080, 0x2080, 0x3080, 0x2000, 0x3000 }, 430 - }; 431 - 432 - static char *scart_names[] = { 433 - "mask", "in1", "in2", "in1 da", "in2 da", "in3", "in4", "mono", "mute" 434 - }; 435 - 436 - static void msp3400c_set_scart(struct i2c_client *client, int in, int out) 437 - { 438 - struct msp3400c *msp = i2c_get_clientdata(client); 439 - 440 - msp->in_scart=in; 441 - 442 - if (in >= 1 && in <= 8 && out >= 0 && out <= 2) { 443 - if (-1 == scarts[out][in]) 444 - return; 445 - 446 - msp->acb &= ~scarts[out][SCART_MASK]; 447 - msp->acb |= scarts[out][in]; 448 - } else 449 - msp->acb = 0xf60; /* Mute Input and SCART 1 Output */ 450 - 451 - msp3400_dbg("scart switch: %s => %d (ACB=0x%04x)\n", 452 - scart_names[in], out, msp->acb); 453 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x13, msp->acb); 454 - 455 - /* Sets I2S speed 0 = 1.024 Mbps, 1 = 2.048 Mbps */ 456 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); 457 - } 458 - 459 - /* ------------------------------------------------------------------------ */ 460 - 461 - static void msp3400c_setcarrier(struct i2c_client *client, int cdo1, int cdo2) 462 - { 463 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x0093, cdo1 & 0xfff); 464 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x009b, cdo1 >> 12); 465 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x00a3, cdo2 & 0xfff); 466 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x00ab, cdo2 >> 12); 467 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x0056, 0); /*LOAD_REG_1/2*/ 468 - } 469 - 470 - static void msp3400c_setvolume(struct i2c_client *client, 471 - int muted, int left, int right) 472 - { 473 - int vol = 0, val = 0, balance = 0; 474 - 475 - if (!muted) { 476 - /* 0x7f instead if 0x73 here has sound quality issues, 477 - * probably due to overmodulation + clipping ... */ 478 - vol = (left > right) ? left : right; 479 - val = (vol * 0x73 / 65535) << 8; 480 - } 481 - if (vol > 0) { 482 - balance = ((right - left) * 127) / vol; 483 - } 484 - 485 - msp3400_dbg("setvolume: mute=%s %d:%d v=0x%02x b=0x%02x\n", 486 - muted ? "on" : "off", left, right, val >> 8, balance); 487 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0000, val); /* loudspeaker */ 488 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0006, val); /* headphones */ 489 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0007, 490 - muted ? 0x1 : (val | 0x1)); 491 - msp3400c_write(client, I2C_MSP3400C_DFP, 0x0001, balance << 8); 492 - } 493 - 494 - static void msp3400c_setbass(struct i2c_client *client, int bass) 495 - { 496 - int val = ((bass-32768) * 0x60 / 65535) << 8; 497 - 498 - msp3400_dbg("setbass: %d 0x%02x\n", bass, val >> 8); 499 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0002, val); /* loudspeaker */ 500 - } 501 - 502 - static void msp3400c_settreble(struct i2c_client *client, int treble) 503 - { 504 - int val = ((treble-32768) * 0x60 / 65535) << 8; 505 - 506 - msp3400_dbg("settreble: %d 0x%02x\n",treble, val>>8); 507 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0003, val); /* loudspeaker */ 508 - } 509 - 510 - static void msp3400c_setmode(struct i2c_client *client, int type) 511 - { 512 - struct msp3400c *msp = i2c_get_clientdata(client); 513 - int i; 514 - 515 - msp3400_dbg("setmode: %d\n",type); 516 - msp->mode = type; 517 - msp->audmode = V4L2_TUNER_MODE_MONO; 518 - msp->rxsubchans = V4L2_TUNER_SUB_MONO; 519 - 520 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x00bb, /* ad_cv */ 521 - msp_init_data[type].ad_cv); 522 - 523 - for (i = 5; i >= 0; i--) /* fir 1 */ 524 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x0001, 525 - msp_init_data[type].fir1[i]); 526 - 527 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0004); /* fir 2 */ 528 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0040); 529 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0000); 530 - for (i = 5; i >= 0; i--) 531 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 532 - msp_init_data[type].fir2[i]); 533 - 534 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x0083, /* MODE_REG */ 535 - msp_init_data[type].mode_reg); 536 - 537 - msp3400c_setcarrier(client, msp_init_data[type].cdo1, 538 - msp_init_data[type].cdo2); 539 - 540 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x0056, 0); /*LOAD_REG_1/2*/ 541 - 542 - if (dolby) { 543 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008, 544 - 0x0520); /* I2S1 */ 545 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009, 546 - 0x0620); /* I2S2 */ 547 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b, 548 - msp_init_data[type].dfp_src); 549 - } else { 550 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008, 551 - msp_init_data[type].dfp_src); 552 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009, 553 - msp_init_data[type].dfp_src); 554 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b, 555 - msp_init_data[type].dfp_src); 556 - } 557 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x000a, 558 - msp_init_data[type].dfp_src); 559 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, 560 - msp_init_data[type].dfp_matrix); 561 - 562 - if (HAVE_NICAM(msp)) { 563 - /* nicam prescale */ 564 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0010, 0x5a00); /* was: 0x3000 */ 565 - } 566 - } 567 - 568 - /* given a bitmask of VIDEO_SOUND_XXX returns the "best" in the bitmask */ 569 - static int best_video_sound(int rxsubchans) 570 - { 571 - if (rxsubchans & V4L2_TUNER_SUB_STEREO) 572 - return V4L2_TUNER_MODE_STEREO; 573 - if (rxsubchans & V4L2_TUNER_SUB_LANG1) 574 - return V4L2_TUNER_MODE_LANG1; 575 - if (rxsubchans & V4L2_TUNER_SUB_LANG2) 576 - return V4L2_TUNER_MODE_LANG2; 577 - return V4L2_TUNER_MODE_MONO; 578 - } 579 - 580 - /* turn on/off nicam + stereo */ 581 - static void msp3400c_setstereo(struct i2c_client *client, int mode) 582 - { 583 - static char *strmode[] = { "0", "mono", "stereo", "3", 584 - "lang1", "5", "6", "7", "lang2" 585 - }; 586 - struct msp3400c *msp = i2c_get_clientdata(client); 587 - int nicam = 0; /* channel source: FM/AM or nicam */ 588 - int src = 0; 589 - 590 - if (IS_MSP34XX_G(msp)) { 591 - /* this method would break everything, let's make sure 592 - * it's never called 593 - */ 594 - msp3400_dbg 595 - ("DEBUG WARNING setstereo called with mode=%d instead of set_source (ignored)\n", 596 - mode); 597 - return; 598 - } 599 - 600 - /* switch demodulator */ 601 - switch (msp->mode) { 602 - case MSP_MODE_FM_TERRA: 603 - msp3400_dbg("FM setstereo: %s\n", strmode[mode]); 604 - msp3400c_setcarrier(client,msp->second,msp->main); 605 - switch (mode) { 606 - case V4L2_TUNER_MODE_STEREO: 607 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, 0x3001); 608 - break; 609 - case V4L2_TUNER_MODE_MONO: 610 - case V4L2_TUNER_MODE_LANG1: 611 - case V4L2_TUNER_MODE_LANG2: 612 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, 0x3000); 613 - break; 614 - } 615 - break; 616 - case MSP_MODE_FM_SAT: 617 - msp3400_dbg("SAT setstereo: %s\n", strmode[mode]); 618 - switch (mode) { 619 - case V4L2_TUNER_MODE_MONO: 620 - msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); 621 - break; 622 - case V4L2_TUNER_MODE_STEREO: 623 - msp3400c_setcarrier(client, MSP_CARRIER(7.2), MSP_CARRIER(7.02)); 624 - break; 625 - case V4L2_TUNER_MODE_LANG1: 626 - msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02)); 627 - break; 628 - case V4L2_TUNER_MODE_LANG2: 629 - msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02)); 630 - break; 631 - } 632 - break; 633 - case MSP_MODE_FM_NICAM1: 634 - case MSP_MODE_FM_NICAM2: 635 - case MSP_MODE_AM_NICAM: 636 - msp3400_dbg("NICAM setstereo: %s\n",strmode[mode]); 637 - msp3400c_setcarrier(client,msp->second,msp->main); 638 - if (msp->nicam_on) 639 - nicam=0x0100; 640 - break; 641 - case MSP_MODE_BTSC: 642 - msp3400_dbg("BTSC setstereo: %s\n",strmode[mode]); 643 - nicam=0x0300; 644 - break; 645 - case MSP_MODE_EXTERN: 646 - msp3400_dbg("extern setstereo: %s\n",strmode[mode]); 647 - nicam = 0x0200; 648 - break; 649 - case MSP_MODE_FM_RADIO: 650 - msp3400_dbg("FM-Radio setstereo: %s\n",strmode[mode]); 651 - break; 652 - default: 653 - msp3400_dbg("mono setstereo\n"); 654 - return; 655 - } 656 - 657 - /* switch audio */ 658 - switch (best_video_sound(mode)) { 659 - case V4L2_TUNER_MODE_STEREO: 660 - src = 0x0020 | nicam; 661 - break; 662 - case V4L2_TUNER_MODE_MONO: 663 - if (msp->mode == MSP_MODE_AM_NICAM) { 664 - msp3400_dbg("switching to AM mono\n"); 665 - /* AM mono decoding is handled by tuner, not MSP chip */ 666 - /* SCART switching control register */ 667 - msp3400c_set_scart(client,SCART_MONO,0); 668 - src = 0x0200; 669 - break; 670 - } 671 - case V4L2_TUNER_MODE_LANG1: 672 - src = 0x0000 | nicam; 673 - break; 674 - case V4L2_TUNER_MODE_LANG2: 675 - src = 0x0010 | nicam; 676 - break; 677 - } 678 - msp3400_dbg("setstereo final source/matrix = 0x%x\n", src); 679 - 680 - if (dolby) { 681 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,0x0520); 682 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009,0x0620); 683 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x000a,src); 684 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b,src); 685 - } else { 686 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,src); 687 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009,src); 688 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x000a,src); 689 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b,src); 690 - } 691 - } 692 - 693 - static void 694 - msp3400c_print_mode(struct i2c_client *client) 695 - { 696 - struct msp3400c *msp = i2c_get_clientdata(client); 697 - 698 - if (msp->main == msp->second) { 699 - msp3400_dbg("mono sound carrier: %d.%03d MHz\n", 700 - msp->main/910000,(msp->main/910)%1000); 701 - } else { 702 - msp3400_dbg("main sound carrier: %d.%03d MHz\n", 703 - msp->main/910000,(msp->main/910)%1000); 704 - } 705 - if (msp->mode == MSP_MODE_FM_NICAM1 || msp->mode == MSP_MODE_FM_NICAM2) 706 - msp3400_dbg("NICAM/FM carrier : %d.%03d MHz\n", 707 - msp->second/910000,(msp->second/910)%1000); 708 - if (msp->mode == MSP_MODE_AM_NICAM) 709 - msp3400_dbg("NICAM/AM carrier : %d.%03d MHz\n", 710 - msp->second/910000,(msp->second/910)%1000); 711 - if (msp->mode == MSP_MODE_FM_TERRA && 712 - msp->main != msp->second) { 713 - msp3400_dbg("FM-stereo carrier : %d.%03d MHz\n", 714 - msp->second/910000,(msp->second/910)%1000); 715 - } 716 - } 717 - 718 - #define MSP3400_MAX 4 719 - static struct i2c_client *msps[MSP3400_MAX]; 720 - static void msp3400c_restore_dfp(struct i2c_client *client) 721 - { 722 - struct msp3400c *msp = i2c_get_clientdata(client); 723 - int i; 724 - 725 - for (i = 0; i < DFP_COUNT; i++) { 726 - if (-1 == msp->dfp_regs[i]) 727 - continue; 728 - msp3400c_write(client, I2C_MSP3400C_DFP, i, msp->dfp_regs[i]); 729 - } 730 - } 731 - 732 - /* if the dfp_regs is set, set what's in there. Otherwise, set the default value */ 733 - static int msp3400c_write_dfp_with_default(struct i2c_client *client, 734 - int addr, int default_value) 735 - { 736 - struct msp3400c *msp = i2c_get_clientdata(client); 737 - int value = default_value; 738 - if (addr < DFP_COUNT && -1 != msp->dfp_regs[addr]) 739 - value = msp->dfp_regs[addr]; 740 - return msp3400c_write(client, I2C_MSP3400C_DFP, addr, value); 741 - } 742 - 743 - /* ----------------------------------------------------------------------- */ 744 - 745 - struct REGISTER_DUMP { 746 - int addr; 747 - char *name; 748 - }; 749 - 750 - struct REGISTER_DUMP d1[] = { 751 - {0x007e, "autodetect"}, 752 - {0x0023, "C_AD_BITS "}, 753 - {0x0038, "ADD_BITS "}, 754 - {0x003e, "CIB_BITS "}, 755 - {0x0057, "ERROR_RATE"}, 756 - }; 757 - 758 - static int autodetect_stereo(struct i2c_client *client) 759 - { 760 - struct msp3400c *msp = i2c_get_clientdata(client); 761 - int val; 762 - int rxsubchans = msp->rxsubchans; 763 - int newnicam = msp->nicam_on; 764 - int update = 0; 765 - 766 - switch (msp->mode) { 767 - case MSP_MODE_FM_TERRA: 768 - val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x18); 769 - if (val > 32767) 770 - val -= 65536; 771 - msp3400_dbg("stereo detect register: %d\n",val); 772 - if (val > 4096) { 773 - rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO; 774 - } else if (val < -4096) { 775 - rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; 776 - } else { 777 - rxsubchans = V4L2_TUNER_SUB_MONO; 778 - } 779 - newnicam = 0; 780 - break; 781 - case MSP_MODE_FM_NICAM1: 782 - case MSP_MODE_FM_NICAM2: 783 - case MSP_MODE_AM_NICAM: 784 - val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x23); 785 - msp3400_dbg("nicam sync=%d, mode=%d\n", 786 - val & 1, (val & 0x1e) >> 1); 787 - 788 - if (val & 1) { 789 - /* nicam synced */ 790 - switch ((val & 0x1e) >> 1) { 791 - case 0: 792 - case 8: 793 - rxsubchans = V4L2_TUNER_SUB_STEREO; 794 - break; 795 - case 1: 796 - case 9: 797 - rxsubchans = V4L2_TUNER_SUB_MONO 798 - | V4L2_TUNER_SUB_LANG1; 799 - break; 800 - case 2: 801 - case 10: 802 - rxsubchans = V4L2_TUNER_SUB_MONO 803 - | V4L2_TUNER_SUB_LANG1 804 - | V4L2_TUNER_SUB_LANG2; 805 - break; 806 - default: 807 - rxsubchans = V4L2_TUNER_SUB_MONO; 808 - break; 809 - } 810 - newnicam=1; 811 - } else { 812 - newnicam = 0; 813 - rxsubchans = V4L2_TUNER_SUB_MONO; 814 - } 815 - break; 816 - case MSP_MODE_BTSC: 817 - val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x200); 818 - msp3400_dbg("status=0x%x (pri=%s, sec=%s, %s%s%s)\n", 819 - val, 820 - (val & 0x0002) ? "no" : "yes", 821 - (val & 0x0004) ? "no" : "yes", 822 - (val & 0x0040) ? "stereo" : "mono", 823 - (val & 0x0080) ? ", nicam 2nd mono" : "", 824 - (val & 0x0100) ? ", bilingual/SAP" : ""); 825 - rxsubchans = V4L2_TUNER_SUB_MONO; 826 - if (val & 0x0040) rxsubchans |= V4L2_TUNER_SUB_STEREO; 827 - if (val & 0x0100) rxsubchans |= V4L2_TUNER_SUB_LANG1; 828 - break; 829 - } 830 - if (rxsubchans != msp->rxsubchans) { 831 - update = 1; 832 - msp3400_dbg("watch: rxsubchans %d => %d\n", 833 - msp->rxsubchans,rxsubchans); 834 - msp->rxsubchans = rxsubchans; 835 - } 836 - if (newnicam != msp->nicam_on) { 837 - update = 1; 838 - msp3400_dbg("watch: nicam %d => %d\n", 839 - msp->nicam_on,newnicam); 840 - msp->nicam_on = newnicam; 841 - } 842 - return update; 843 - } 844 - 845 - /* 846 - * A kernel thread for msp3400 control -- we don't want to block the 847 - * in the ioctl while doing the sound carrier & stereo detect 848 - */ 849 - 850 - static int msp34xx_sleep(struct msp3400c *msp, int timeout) 851 - { 852 - DECLARE_WAITQUEUE(wait, current); 853 - 854 - add_wait_queue(&msp->wq, &wait); 855 - if (!kthread_should_stop()) { 856 - if (timeout < 0) { 857 - set_current_state(TASK_INTERRUPTIBLE); 858 - schedule(); 859 - } else { 860 - schedule_timeout_interruptible 861 - (msecs_to_jiffies(timeout)); 862 - } 863 - } 864 - 865 - remove_wait_queue(&msp->wq, &wait); 866 - try_to_freeze(); 867 - return msp->restart; 868 - } 869 - 870 - /* stereo/multilang monitoring */ 871 - static void watch_stereo(struct i2c_client *client) 872 - { 873 - struct msp3400c *msp = i2c_get_clientdata(client); 874 - 875 - if (autodetect_stereo(client)) { 876 - if (msp->stereo & V4L2_TUNER_MODE_STEREO) 877 - msp3400c_setstereo(client, V4L2_TUNER_MODE_STEREO); 878 - else if (msp->stereo & VIDEO_SOUND_LANG1) 879 - msp3400c_setstereo(client, V4L2_TUNER_MODE_LANG1); 880 - else 881 - msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 882 - } 883 - 884 - if (once) 885 - msp->watch_stereo = 0; 886 - } 887 - 888 - 889 - static int msp3400c_thread(void *data) 890 - { 891 - struct i2c_client *client = data; 892 - struct msp3400c *msp = i2c_get_clientdata(client); 893 - struct CARRIER_DETECT *cd; 894 - int count, max1,max2,val1,val2, val,this; 895 - 896 - 897 - msp3400_info("msp3400 daemon started\n"); 898 - for (;;) { 899 - msp3400_dbg_mediumvol("msp3400 thread: sleep\n"); 900 - msp34xx_sleep(msp,-1); 901 - msp3400_dbg_mediumvol("msp3400 thread: wakeup\n"); 902 - 903 - restart: 904 - msp3400_dbg("thread: restart scan\n"); 905 - msp->restart = 0; 906 - if (kthread_should_stop()) 907 - break; 908 - 909 - if (VIDEO_MODE_RADIO == msp->norm || 910 - MSP_MODE_EXTERN == msp->mode) { 911 - /* no carrier scan, just unmute */ 912 - msp3400_info("thread: no carrier scan\n"); 913 - msp3400c_setvolume(client, msp->muted, msp->left, msp->right); 914 - continue; 915 - } 916 - 917 - /* mute */ 918 - msp3400c_setvolume(client, msp->muted, 0, 0); 919 - msp3400c_setmode(client, MSP_MODE_AM_DETECT /* +1 */ ); 920 - val1 = val2 = 0; 921 - max1 = max2 = -1; 922 - msp->watch_stereo = 0; 923 - 924 - /* some time for the tuner to sync */ 925 - if (msp34xx_sleep(msp,200)) 926 - goto restart; 927 - 928 - /* carrier detect pass #1 -- main carrier */ 929 - cd = carrier_detect_main; 930 - count = CARRIER_COUNT(carrier_detect_main); 931 - 932 - if (amsound && (msp->norm == VIDEO_MODE_SECAM)) { 933 - /* autodetect doesn't work well with AM ... */ 934 - max1 = 3; 935 - count = 0; 936 - msp3400_dbg("AM sound override\n"); 937 - } 938 - 939 - for (this = 0; this < count; this++) { 940 - msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo); 941 - if (msp34xx_sleep(msp,100)) 942 - goto restart; 943 - val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1b); 944 - if (val > 32767) 945 - val -= 65536; 946 - if (val1 < val) 947 - val1 = val, max1 = this; 948 - msp3400_dbg("carrier1 val: %5d / %s\n", val,cd[this].name); 949 - } 950 - 951 - /* carrier detect pass #2 -- second (stereo) carrier */ 952 - switch (max1) { 953 - case 1: /* 5.5 */ 954 - cd = carrier_detect_55; 955 - count = CARRIER_COUNT(carrier_detect_55); 956 - break; 957 - case 3: /* 6.5 */ 958 - cd = carrier_detect_65; 959 - count = CARRIER_COUNT(carrier_detect_65); 960 - break; 961 - case 0: /* 4.5 */ 962 - case 2: /* 6.0 */ 963 - default: 964 - cd = NULL; 965 - count = 0; 966 - break; 967 - } 968 - 969 - if (amsound && (msp->norm == VIDEO_MODE_SECAM)) { 970 - /* autodetect doesn't work well with AM ... */ 971 - cd = NULL; 972 - count = 0; 973 - max2 = 0; 974 - } 975 - for (this = 0; this < count; this++) { 976 - msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo); 977 - if (msp34xx_sleep(msp,100)) 978 - goto restart; 979 - val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1b); 980 - if (val > 32767) 981 - val -= 65536; 982 - if (val2 < val) 983 - val2 = val, max2 = this; 984 - msp3400_dbg("carrier2 val: %5d / %s\n", val,cd[this].name); 985 - } 986 - 987 - /* programm the msp3400 according to the results */ 988 - msp->main = carrier_detect_main[max1].cdo; 989 - switch (max1) { 990 - case 1: /* 5.5 */ 991 - if (max2 == 0) { 992 - /* B/G FM-stereo */ 993 - msp->second = carrier_detect_55[max2].cdo; 994 - msp3400c_setmode(client, MSP_MODE_FM_TERRA); 995 - msp->nicam_on = 0; 996 - msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 997 - msp->watch_stereo = 1; 998 - } else if (max2 == 1 && HAVE_NICAM(msp)) { 999 - /* B/G NICAM */ 1000 - msp->second = carrier_detect_55[max2].cdo; 1001 - msp3400c_setmode(client, MSP_MODE_FM_NICAM1); 1002 - msp->nicam_on = 1; 1003 - msp3400c_setcarrier(client, msp->second, msp->main); 1004 - msp->watch_stereo = 1; 1005 - } else { 1006 - goto no_second; 1007 - } 1008 - break; 1009 - case 2: /* 6.0 */ 1010 - /* PAL I NICAM */ 1011 - msp->second = MSP_CARRIER(6.552); 1012 - msp3400c_setmode(client, MSP_MODE_FM_NICAM2); 1013 - msp->nicam_on = 1; 1014 - msp3400c_setcarrier(client, msp->second, msp->main); 1015 - msp->watch_stereo = 1; 1016 - break; 1017 - case 3: /* 6.5 */ 1018 - if (max2 == 1 || max2 == 2) { 1019 - /* D/K FM-stereo */ 1020 - msp->second = carrier_detect_65[max2].cdo; 1021 - msp3400c_setmode(client, MSP_MODE_FM_TERRA); 1022 - msp->nicam_on = 0; 1023 - msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 1024 - msp->watch_stereo = 1; 1025 - } else if (max2 == 0 && 1026 - msp->norm == VIDEO_MODE_SECAM) { 1027 - /* L NICAM or AM-mono */ 1028 - msp->second = carrier_detect_65[max2].cdo; 1029 - msp3400c_setmode(client, MSP_MODE_AM_NICAM); 1030 - msp->nicam_on = 0; 1031 - msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 1032 - msp3400c_setcarrier(client, msp->second, msp->main); 1033 - /* volume prescale for SCART (AM mono input) */ 1034 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x000d, 0x1900); 1035 - msp->watch_stereo = 1; 1036 - } else if (max2 == 0 && HAVE_NICAM(msp)) { 1037 - /* D/K NICAM */ 1038 - msp->second = carrier_detect_65[max2].cdo; 1039 - msp3400c_setmode(client, MSP_MODE_FM_NICAM1); 1040 - msp->nicam_on = 1; 1041 - msp3400c_setcarrier(client, msp->second, msp->main); 1042 - msp->watch_stereo = 1; 1043 - } else { 1044 - goto no_second; 1045 - } 1046 - break; 1047 - case 0: /* 4.5 */ 1048 - default: 1049 - no_second: 1050 - msp->second = carrier_detect_main[max1].cdo; 1051 - msp3400c_setmode(client, MSP_MODE_FM_TERRA); 1052 - msp->nicam_on = 0; 1053 - msp3400c_setcarrier(client, msp->second, msp->main); 1054 - msp->rxsubchans = V4L2_TUNER_SUB_MONO; 1055 - msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 1056 - break; 1057 - } 1058 - 1059 - /* unmute */ 1060 - msp3400c_setvolume(client, msp->muted, msp->left, msp->right); 1061 - msp3400c_restore_dfp(client); 1062 - 1063 - if (debug) 1064 - msp3400c_print_mode(client); 1065 - 1066 - /* monitor tv audio mode */ 1067 - while (msp->watch_stereo) { 1068 - if (msp34xx_sleep(msp,5000)) 1069 - goto restart; 1070 - watch_stereo(client); 1071 - } 1072 - } 1073 - msp3400_dbg("thread: exit\n"); 1074 - return 0; 1075 - } 1076 - 1077 - /* ----------------------------------------------------------------------- */ 1078 - /* this one uses the automatic sound standard detection of newer */ 1079 - /* msp34xx chip versions */ 1080 - 1081 - static struct MODES { 1082 - int retval; 1083 - int main, second; 1084 - char *name; 1085 - } modelist[] = { 1086 - { 0x0000, 0, 0, "ERROR" }, 1087 - { 0x0001, 0, 0, "autodetect start" }, 1088 - { 0x0002, MSP_CARRIER(4.5), MSP_CARRIER(4.72), "4.5/4.72 M Dual FM-Stereo" }, 1089 - { 0x0003, MSP_CARRIER(5.5), MSP_CARRIER(5.7421875), "5.5/5.74 B/G Dual FM-Stereo" }, 1090 - { 0x0004, MSP_CARRIER(6.5), MSP_CARRIER(6.2578125), "6.5/6.25 D/K1 Dual FM-Stereo" }, 1091 - { 0x0005, MSP_CARRIER(6.5), MSP_CARRIER(6.7421875), "6.5/6.74 D/K2 Dual FM-Stereo" }, 1092 - { 0x0006, MSP_CARRIER(6.5), MSP_CARRIER(6.5), "6.5 D/K FM-Mono (HDEV3)" }, 1093 - { 0x0008, MSP_CARRIER(5.5), MSP_CARRIER(5.85), "5.5/5.85 B/G NICAM FM" }, 1094 - { 0x0009, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 L NICAM AM" }, 1095 - { 0x000a, MSP_CARRIER(6.0), MSP_CARRIER(6.55), "6.0/6.55 I NICAM FM" }, 1096 - { 0x000b, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM" }, 1097 - { 0x000c, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM (HDEV2)" }, 1098 - { 0x0020, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Stereo" }, 1099 - { 0x0021, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Mono + SAP" }, 1100 - { 0x0030, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M EIA-J Japan Stereo" }, 1101 - { 0x0040, MSP_CARRIER(10.7), MSP_CARRIER(10.7), "10.7 FM-Stereo Radio" }, 1102 - { 0x0050, MSP_CARRIER(6.5), MSP_CARRIER(6.5), "6.5 SAT-Mono" }, 1103 - { 0x0051, MSP_CARRIER(7.02), MSP_CARRIER(7.20), "7.02/7.20 SAT-Stereo" }, 1104 - { 0x0060, MSP_CARRIER(7.2), MSP_CARRIER(7.2), "7.2 SAT ADR" }, 1105 - { -1, 0, 0, NULL }, /* EOF */ 1106 - }; 1107 - 1108 - static inline const char *msp34xx_standard_mode_name(int mode) 1109 - { 1110 - int i; 1111 - for (i = 0; modelist[i].name != NULL; i++) 1112 - if (modelist[i].retval == mode) 1113 - return modelist[i].name; 1114 - return "unknown"; 1115 - } 1116 - 1117 - static int msp34xx_modus(struct i2c_client *client, int norm) 1118 - { 1119 - switch (norm) { 1120 - case VIDEO_MODE_PAL: 1121 - msp3400_dbg("video mode selected to PAL\n"); 1122 - 1123 - #if 1 1124 - /* experimental: not sure this works with all chip versions */ 1125 - return 0x7003; 1126 - #else 1127 - /* previous value, try this if it breaks ... */ 1128 - return 0x1003; 1129 - #endif 1130 - case VIDEO_MODE_NTSC: /* BTSC */ 1131 - msp3400_dbg("video mode selected to NTSC\n"); 1132 - return 0x2003; 1133 - case VIDEO_MODE_SECAM: 1134 - msp3400_dbg("video mode selected to SECAM\n"); 1135 - return 0x0003; 1136 - case VIDEO_MODE_RADIO: 1137 - msp3400_dbg("video mode selected to Radio\n"); 1138 - return 0x0003; 1139 - case VIDEO_MODE_AUTO: 1140 - msp3400_dbg("video mode selected to Auto\n"); 1141 - return 0x2003; 1142 - default: 1143 - return 0x0003; 1144 - } 1145 - } 1146 - 1147 - static int msp34xx_standard(int norm) 1148 - { 1149 - switch (norm) { 1150 - case VIDEO_MODE_PAL: 1151 - return 1; 1152 - case VIDEO_MODE_NTSC: /* BTSC */ 1153 - return 0x0020; 1154 - case VIDEO_MODE_SECAM: 1155 - return 1; 1156 - case VIDEO_MODE_RADIO: 1157 - return 0x0040; 1158 - default: 1159 - return 1; 1160 - } 1161 - } 1162 - 1163 - static int msp3410d_thread(void *data) 1164 - { 1165 - struct i2c_client *client = data; 1166 - struct msp3400c *msp = i2c_get_clientdata(client); 1167 - int mode,val,i,std; 1168 - 1169 - msp3400_info("msp3410 daemon started\n"); 1170 - 1171 - for (;;) { 1172 - msp3400_dbg_mediumvol("msp3410 thread: sleep\n"); 1173 - msp34xx_sleep(msp,-1); 1174 - msp3400_dbg_mediumvol("msp3410 thread: wakeup\n"); 1175 - 1176 - restart: 1177 - msp3400_dbg("thread: restart scan\n"); 1178 - msp->restart = 0; 1179 - if (kthread_should_stop()) 1180 - break; 1181 - 1182 - if (msp->mode == MSP_MODE_EXTERN) { 1183 - /* no carrier scan needed, just unmute */ 1184 - msp3400_dbg("thread: no carrier scan\n"); 1185 - msp3400c_setvolume(client, msp->muted, msp->left, msp->right); 1186 - continue; 1187 - } 1188 - 1189 - /* put into sane state (and mute) */ 1190 - msp3400c_reset(client); 1191 - 1192 - /* some time for the tuner to sync */ 1193 - if (msp34xx_sleep(msp,200)) 1194 - goto restart; 1195 - 1196 - /* start autodetect */ 1197 - mode = msp34xx_modus(client, msp->norm); 1198 - std = msp34xx_standard(msp->norm); 1199 - msp3400c_write(client, I2C_MSP3400C_DEM, 0x30, mode); 1200 - msp3400c_write(client, I2C_MSP3400C_DEM, 0x20, std); 1201 - msp->watch_stereo = 0; 1202 - 1203 - if (debug) 1204 - msp3400_dbg("setting mode: %s (0x%04x)\n", 1205 - msp34xx_standard_mode_name(std) ,std); 1206 - 1207 - if (std != 1) { 1208 - /* programmed some specific mode */ 1209 - val = std; 1210 - } else { 1211 - /* triggered autodetect */ 1212 - for (;;) { 1213 - if (msp34xx_sleep(msp,100)) 1214 - goto restart; 1215 - 1216 - /* check results */ 1217 - val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x7e); 1218 - if (val < 0x07ff) 1219 - break; 1220 - msp3400_dbg("detection still in progress\n"); 1221 - } 1222 - } 1223 - for (i = 0; modelist[i].name != NULL; i++) 1224 - if (modelist[i].retval == val) 1225 - break; 1226 - msp3400_dbg("current mode: %s (0x%04x)\n", 1227 - modelist[i].name ? modelist[i].name : "unknown", 1228 - val); 1229 - msp->main = modelist[i].main; 1230 - msp->second = modelist[i].second; 1231 - 1232 - if (amsound && (msp->norm == VIDEO_MODE_SECAM) && (val != 0x0009)) { 1233 - /* autodetection has failed, let backup */ 1234 - msp3400_dbg("autodetection failed," 1235 - " switching to backup mode: %s (0x%04x)\n", 1236 - modelist[8].name ? modelist[8].name : "unknown",val); 1237 - val = 0x0009; 1238 - msp3400c_write(client, I2C_MSP3400C_DEM, 0x20, val); 1239 - } 1240 - 1241 - /* set various prescales */ 1242 - msp3400c_write(client, I2C_MSP3400C_DFP, 0x0d, 0x1900); /* scart */ 1243 - msp3400c_write(client, I2C_MSP3400C_DFP, 0x0e, 0x2403); /* FM */ 1244 - msp3400c_write(client, I2C_MSP3400C_DFP, 0x10, 0x5a00); /* nicam */ 1245 - 1246 - /* set stereo */ 1247 - switch (val) { 1248 - case 0x0008: /* B/G NICAM */ 1249 - case 0x000a: /* I NICAM */ 1250 - if (val == 0x0008) 1251 - msp->mode = MSP_MODE_FM_NICAM1; 1252 - else 1253 - msp->mode = MSP_MODE_FM_NICAM2; 1254 - /* just turn on stereo */ 1255 - msp->rxsubchans = V4L2_TUNER_SUB_STEREO; 1256 - msp->nicam_on = 1; 1257 - msp->watch_stereo = 1; 1258 - msp3400c_setstereo(client,V4L2_TUNER_MODE_STEREO); 1259 - break; 1260 - case 0x0009: 1261 - msp->mode = MSP_MODE_AM_NICAM; 1262 - msp->rxsubchans = V4L2_TUNER_SUB_MONO; 1263 - msp->nicam_on = 1; 1264 - msp3400c_setstereo(client,V4L2_TUNER_MODE_MONO); 1265 - msp->watch_stereo = 1; 1266 - break; 1267 - case 0x0020: /* BTSC */ 1268 - /* just turn on stereo */ 1269 - msp->mode = MSP_MODE_BTSC; 1270 - msp->rxsubchans = V4L2_TUNER_SUB_STEREO; 1271 - msp->nicam_on = 0; 1272 - msp->watch_stereo = 1; 1273 - msp3400c_setstereo(client,V4L2_TUNER_MODE_STEREO); 1274 - break; 1275 - case 0x0040: /* FM radio */ 1276 - msp->mode = MSP_MODE_FM_RADIO; 1277 - msp->rxsubchans = V4L2_TUNER_SUB_STEREO; 1278 - msp->audmode = V4L2_TUNER_MODE_STEREO; 1279 - msp->nicam_on = 0; 1280 - msp->watch_stereo = 0; 1281 - /* not needed in theory if HAVE_RADIO(), but 1282 - short programming enables carrier mute */ 1283 - msp3400c_setmode(client,MSP_MODE_FM_RADIO); 1284 - msp3400c_setcarrier(client, MSP_CARRIER(10.7), 1285 - MSP_CARRIER(10.7)); 1286 - /* scart routing */ 1287 - msp3400c_set_scart(client,SCART_IN2,0); 1288 - /* msp34xx does radio decoding */ 1289 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x08, 0x0020); 1290 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x09, 0x0020); 1291 - msp3400c_write(client,I2C_MSP3400C_DFP, 0x0b, 0x0020); 1292 - break; 1293 - case 0x0003: 1294 - case 0x0004: 1295 - case 0x0005: 1296 - msp->mode = MSP_MODE_FM_TERRA; 1297 - msp->rxsubchans = V4L2_TUNER_SUB_MONO; 1298 - msp->audmode = V4L2_TUNER_MODE_MONO; 1299 - msp->nicam_on = 0; 1300 - msp->watch_stereo = 1; 1301 - break; 1302 - } 1303 - 1304 - /* unmute, restore misc registers */ 1305 - msp3400c_setbass(client, msp->bass); 1306 - msp3400c_settreble(client, msp->treble); 1307 - msp3400c_setvolume(client, msp->muted, msp->left, msp->right); 1308 - msp3400c_write(client, I2C_MSP3400C_DFP, 0x13, msp->acb); 1309 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); 1310 - msp3400c_restore_dfp(client); 1311 - 1312 - /* monitor tv audio mode */ 1313 - while (msp->watch_stereo) { 1314 - if (msp34xx_sleep(msp,5000)) 1315 - goto restart; 1316 - watch_stereo(client); 1317 - } 1318 - } 1319 - msp3400_dbg("thread: exit\n"); 1320 - return 0; 1321 - } 1322 - 1323 - /* ----------------------------------------------------------------------- */ 1324 - /* msp34xxG + (simpler no-thread) */ 1325 - /* this one uses both automatic standard detection and automatic sound */ 1326 - /* select which are available in the newer G versions */ 1327 - /* struct msp: only norm, acb and source are really used in this mode */ 1328 - 1329 - static void msp34xxg_set_source(struct i2c_client *client, int source); 1330 - 1331 - /* (re-)initialize the msp34xxg, according to the current norm in msp->norm 1332 - * return 0 if it worked, -1 if it failed 1333 - */ 1334 - static int msp34xxg_reset(struct i2c_client *client) 1335 - { 1336 - struct msp3400c *msp = i2c_get_clientdata(client); 1337 - int modus,std; 1338 - 1339 - if (msp3400c_reset(client)) 1340 - return -1; 1341 - 1342 - /* make sure that input/output is muted (paranoid mode) */ 1343 - if (msp3400c_write(client, 1344 - I2C_MSP3400C_DFP, 1345 - 0x13, /* ACB */ 1346 - 0x0f20 /* mute DSP input, mute SCART 1 */)) 1347 - return -1; 1348 - 1349 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); 1350 - 1351 - /* step-by-step initialisation, as described in the manual */ 1352 - modus = msp34xx_modus(client, msp->norm); 1353 - std = msp34xx_standard(msp->norm); 1354 - modus &= ~0x03; /* STATUS_CHANGE=0 */ 1355 - modus |= 0x01; /* AUTOMATIC_SOUND_DETECTION=1 */ 1356 - if (msp3400c_write(client, 1357 - I2C_MSP3400C_DEM, 1358 - 0x30/*MODUS*/, 1359 - modus)) 1360 - return -1; 1361 - if (msp3400c_write(client, 1362 - I2C_MSP3400C_DEM, 1363 - 0x20/*standard*/, 1364 - std)) 1365 - return -1; 1366 - 1367 - /* write the dfps that may have an influence on 1368 - standard/audio autodetection right now */ 1369 - msp34xxg_set_source(client, msp->source); 1370 - 1371 - if (msp3400c_write_dfp_with_default(client, 0x0e, /* AM/FM Prescale */ 1372 - 0x3000 1373 - /* default: [15:8] 75khz deviation */ 1374 - )) 1375 - return -1; 1376 - 1377 - if (msp3400c_write_dfp_with_default(client, 0x10, /* NICAM Prescale */ 1378 - 0x5a00 1379 - /* default: 9db gain (as recommended) */ 1380 - )) 1381 - return -1; 1382 - 1383 - return 0; 1384 - } 1385 - 1386 - static int msp34xxg_thread(void *data) 1387 - { 1388 - struct i2c_client *client = data; 1389 - struct msp3400c *msp = i2c_get_clientdata(client); 1390 - int val, std, i; 1391 - 1392 - msp3400_info("msp34xxg daemon started\n"); 1393 - 1394 - msp->source = 1; /* default */ 1395 - for (;;) { 1396 - msp3400_dbg_mediumvol("msp34xxg thread: sleep\n"); 1397 - msp34xx_sleep(msp,-1); 1398 - msp3400_dbg_mediumvol("msp34xxg thread: wakeup\n"); 1399 - 1400 - restart: 1401 - msp3400_dbg("thread: restart scan\n"); 1402 - msp->restart = 0; 1403 - if (kthread_should_stop()) 1404 - break; 1405 - 1406 - /* setup the chip*/ 1407 - msp34xxg_reset(client); 1408 - std = standard; 1409 - if (std != 0x01) 1410 - goto unmute; 1411 - 1412 - /* watch autodetect */ 1413 - msp3400_dbg("triggered autodetect, waiting for result\n"); 1414 - for (i = 0; i < 10; i++) { 1415 - if (msp34xx_sleep(msp,100)) 1416 - goto restart; 1417 - 1418 - /* check results */ 1419 - val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x7e); 1420 - if (val < 0x07ff) { 1421 - std = val; 1422 - break; 1423 - } 1424 - msp3400_dbg("detection still in progress\n"); 1425 - } 1426 - if (0x01 == std) { 1427 - msp3400_dbg("detection still in progress after 10 tries. giving up.\n"); 1428 - continue; 1429 - } 1430 - 1431 - unmute: 1432 - msp3400_dbg("current mode: %s (0x%04x)\n", 1433 - msp34xx_standard_mode_name(std), std); 1434 - 1435 - /* unmute: dispatch sound to scart output, set scart volume */ 1436 - msp3400_dbg("unmute\n"); 1437 - 1438 - msp3400c_setbass(client, msp->bass); 1439 - msp3400c_settreble(client, msp->treble); 1440 - msp3400c_setvolume(client, msp->muted, msp->left, msp->right); 1441 - 1442 - /* restore ACB */ 1443 - if (msp3400c_write(client, 1444 - I2C_MSP3400C_DFP, 1445 - 0x13, /* ACB */ 1446 - msp->acb)) 1447 - return -1; 1448 - 1449 - msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode); 1450 - } 1451 - msp3400_dbg("thread: exit\n"); 1452 - return 0; 1453 - } 1454 - 1455 - /* set the same 'source' for the loudspeaker, scart and quasi-peak detector 1456 - * the value for source is the same as bit 15:8 of DFP registers 0x08, 1457 - * 0x0a and 0x0c: 0=mono, 1=stereo or A|B, 2=SCART, 3=stereo or A, 4=stereo or B 1458 - * 1459 - * this function replaces msp3400c_setstereo 1460 - */ 1461 - static void msp34xxg_set_source(struct i2c_client *client, int source) 1462 - { 1463 - struct msp3400c *msp = i2c_get_clientdata(client); 1464 - 1465 - /* fix matrix mode to stereo and let the msp choose what 1466 - * to output according to 'source', as recommended 1467 - * for MONO (source==0) downmixing set bit[7:0] to 0x30 1468 - */ 1469 - int value = (source&0x07)<<8|(source==0 ? 0x30:0x20); 1470 - msp3400_dbg("set source to %d (0x%x)\n", source, value); 1471 - msp3400c_write(client, 1472 - I2C_MSP3400C_DFP, 1473 - 0x08, /* Loudspeaker Output */ 1474 - value); 1475 - msp3400c_write(client, 1476 - I2C_MSP3400C_DFP, 1477 - 0x0a, /* SCART1 DA Output */ 1478 - value); 1479 - msp3400c_write(client, 1480 - I2C_MSP3400C_DFP, 1481 - 0x0c, /* Quasi-peak detector */ 1482 - value); 1483 - /* 1484 - * set identification threshold. Personally, I 1485 - * I set it to a higher value that the default 1486 - * of 0x190 to ignore noisy stereo signals. 1487 - * this needs tuning. (recommended range 0x00a0-0x03c0) 1488 - * 0x7f0 = forced mono mode 1489 - */ 1490 - msp3400c_write(client, 1491 - I2C_MSP3400C_DEM, 1492 - 0x22, /* a2 threshold for stereo/bilingual */ 1493 - stereo_threshold); 1494 - msp->source=source; 1495 - } 1496 - 1497 - static void msp34xxg_detect_stereo(struct i2c_client *client) 1498 - { 1499 - struct msp3400c *msp = i2c_get_clientdata(client); 1500 - 1501 - int status = msp3400c_read(client, 1502 - I2C_MSP3400C_DEM, 1503 - 0x0200 /* STATUS */); 1504 - int is_bilingual = status&0x100; 1505 - int is_stereo = status&0x40; 1506 - 1507 - msp->rxsubchans = 0; 1508 - if (is_stereo) 1509 - msp->rxsubchans |= V4L2_TUNER_SUB_STEREO; 1510 - else 1511 - msp->rxsubchans |= V4L2_TUNER_SUB_MONO; 1512 - if (is_bilingual) { 1513 - msp->rxsubchans |= V4L2_TUNER_SUB_LANG1|V4L2_TUNER_SUB_LANG2; 1514 - /* I'm supposed to check whether it's SAP or not 1515 - * and set only LANG2/SAP in this case. Yet, the MSP 1516 - * does a lot of work to hide this and handle everything 1517 - * the same way. I don't want to work around it so unless 1518 - * this is a problem, I'll handle SAP just like lang1/lang2. 1519 - */ 1520 - } 1521 - msp3400_dbg("status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n", 1522 - status, is_stereo, is_bilingual, msp->rxsubchans); 1523 - } 1524 - 1525 - static void msp34xxg_set_audmode(struct i2c_client *client, int audmode) 1526 - { 1527 - struct msp3400c *msp = i2c_get_clientdata(client); 1528 - int source; 1529 - 1530 - switch (audmode) { 1531 - case V4L2_TUNER_MODE_MONO: 1532 - source=0; /* mono only */ 1533 - break; 1534 - case V4L2_TUNER_MODE_STEREO: 1535 - source=1; /* stereo or A|B, see comment in msp34xxg_get_v4l2_stereo() */ 1536 - /* problem: that could also mean 2 (scart input) */ 1537 - break; 1538 - case V4L2_TUNER_MODE_LANG1: 1539 - source=3; /* stereo or A */ 1540 - break; 1541 - case V4L2_TUNER_MODE_LANG2: 1542 - source=4; /* stereo or B */ 1543 - break; 1544 - default: 1545 - audmode = 0; 1546 - source = 1; 1547 - break; 1548 - } 1549 - msp->audmode = audmode; 1550 - msp34xxg_set_source(client, source); 1551 - } 1552 - 1553 - 1554 - /* ----------------------------------------------------------------------- */ 1555 - 1556 - static int msp_attach(struct i2c_adapter *adap, int addr, int kind); 1557 - static int msp_detach(struct i2c_client *client); 1558 - static int msp_probe(struct i2c_adapter *adap); 1559 - static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg); 1560 - 1561 - static int msp_suspend(struct device * dev, pm_message_t state); 1562 - static int msp_resume(struct device * dev); 1563 - 1564 - static void msp_wake_thread(struct i2c_client *client); 1565 - 1566 - static struct i2c_driver driver = { 1567 - .id = I2C_DRIVERID_MSP3400, 1568 - .attach_adapter = msp_probe, 1569 - .detach_client = msp_detach, 1570 - .command = msp_command, 1571 - .driver = { 1572 - .name = "i2c msp3400 driver", 1573 - .suspend = msp_suspend, 1574 - .resume = msp_resume, 1575 - }, 1576 - }; 1577 - 1578 - static struct i2c_client client_template = 1579 - { 1580 - .name = "(unset)", 1581 - .driver = &driver, 1582 - }; 1583 - 1584 - static int msp_attach(struct i2c_adapter *adap, int addr, int kind) 1585 - { 1586 - struct msp3400c *msp; 1587 - struct i2c_client *client = &client_template; 1588 - int (*thread_func)(void *data) = NULL; 1589 - int i; 1590 - 1591 - client_template.adapter = adap; 1592 - client_template.addr = addr; 1593 - 1594 - if (-1 == msp3400c_reset(&client_template)) { 1595 - msp3400_dbg("no chip found\n"); 1596 - return -1; 1597 - } 1598 - 1599 - if (NULL == (client = kmalloc(sizeof(struct i2c_client),GFP_KERNEL))) 1600 - return -ENOMEM; 1601 - memcpy(client,&client_template,sizeof(struct i2c_client)); 1602 - if (NULL == (msp = kmalloc(sizeof(struct msp3400c),GFP_KERNEL))) { 1603 - kfree(client); 1604 - return -ENOMEM; 1605 - } 1606 - 1607 - memset(msp,0,sizeof(struct msp3400c)); 1608 - msp->norm = VIDEO_MODE_NTSC; 1609 - msp->left = 58880; /* 0db gain */ 1610 - msp->right = 58880; /* 0db gain */ 1611 - msp->bass = 32768; 1612 - msp->treble = 32768; 1613 - msp->input = -1; 1614 - msp->muted = 0; 1615 - msp->i2s_mode = 0; 1616 - for (i = 0; i < DFP_COUNT; i++) 1617 - msp->dfp_regs[i] = -1; 1618 - 1619 - i2c_set_clientdata(client, msp); 1620 - init_waitqueue_head(&msp->wq); 1621 - 1622 - if (-1 == msp3400c_reset(client)) { 1623 - kfree(msp); 1624 - kfree(client); 1625 - msp3400_dbg("no chip found\n"); 1626 - return -1; 1627 - } 1628 - 1629 - msp->rev1 = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1e); 1630 - if (-1 != msp->rev1) 1631 - msp->rev2 = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1f); 1632 - if ((-1 == msp->rev1) || (0 == msp->rev1 && 0 == msp->rev2)) { 1633 - kfree(msp); 1634 - kfree(client); 1635 - msp3400_dbg("error while reading chip version\n"); 1636 - return -1; 1637 - } 1638 - msp3400_dbg("rev1=0x%04x, rev2=0x%04x\n", msp->rev1, msp->rev2); 1639 - 1640 - msp3400c_setvolume(client, msp->muted, msp->left, msp->right); 1641 - 1642 - snprintf(client->name, sizeof(client->name), "MSP%c4%02d%c-%c%d", 1643 - ((msp->rev1>>4)&0x0f) + '3', 1644 - (msp->rev2>>8)&0xff, (msp->rev1&0x0f)+'@', 1645 - ((msp->rev1>>8)&0xff)+'@', msp->rev2&0x1f); 1646 - 1647 - msp->opmode = opmode; 1648 - if (OPMODE_AUTO == msp->opmode) { 1649 - if (HAVE_SIMPLER(msp)) 1650 - msp->opmode = OPMODE_SIMPLER; 1651 - else if (HAVE_SIMPLE(msp)) 1652 - msp->opmode = OPMODE_SIMPLE; 1653 - else 1654 - msp->opmode = OPMODE_MANUAL; 1655 - } 1656 - 1657 - /* hello world :-) */ 1658 - msp3400_info("chip=%s", client->name); 1659 - if (HAVE_NICAM(msp)) 1660 - printk(" +nicam"); 1661 - if (HAVE_SIMPLE(msp)) 1662 - printk(" +simple"); 1663 - if (HAVE_SIMPLER(msp)) 1664 - printk(" +simpler"); 1665 - if (HAVE_RADIO(msp)) 1666 - printk(" +radio"); 1667 - 1668 - /* version-specific initialization */ 1669 - switch (msp->opmode) { 1670 - case OPMODE_MANUAL: 1671 - printk(" mode=manual"); 1672 - thread_func = msp3400c_thread; 1673 - break; 1674 - case OPMODE_SIMPLE: 1675 - printk(" mode=simple"); 1676 - thread_func = msp3410d_thread; 1677 - break; 1678 - case OPMODE_SIMPLER: 1679 - printk(" mode=simpler"); 1680 - thread_func = msp34xxg_thread; 1681 - break; 1682 - } 1683 - printk("\n"); 1684 - 1685 - /* startup control thread if needed */ 1686 - if (thread_func) { 1687 - msp->kthread = kthread_run(thread_func, client, "msp34xx"); 1688 - 1689 - if (NULL == msp->kthread) 1690 - msp3400_warn("kernel_thread() failed\n"); 1691 - msp_wake_thread(client); 1692 - } 1693 - 1694 - /* done */ 1695 - i2c_attach_client(client); 1696 - 1697 - /* update our own array */ 1698 - for (i = 0; i < MSP3400_MAX; i++) { 1699 - if (NULL == msps[i]) { 1700 - msps[i] = client; 1701 - break; 1702 - } 1703 - } 1704 - 1705 - return 0; 1706 - } 1707 - 1708 - static int msp_detach(struct i2c_client *client) 1709 - { 1710 - struct msp3400c *msp = i2c_get_clientdata(client); 1711 - int i; 1712 - 1713 - /* shutdown control thread */ 1714 - if (msp->kthread) { 1715 - msp->restart = 1; 1716 - kthread_stop(msp->kthread); 1717 - } 1718 - msp3400c_reset(client); 1719 - 1720 - /* update our own array */ 1721 - for (i = 0; i < MSP3400_MAX; i++) { 1722 - if (client == msps[i]) { 1723 - msps[i] = NULL; 1724 - break; 1725 - } 1726 - } 1727 - 1728 - i2c_detach_client(client); 1729 - 1730 - kfree(msp); 1731 - kfree(client); 1732 - return 0; 1733 - } 1734 - 1735 - static int msp_probe(struct i2c_adapter *adap) 1736 - { 1737 - if (adap->class & I2C_CLASS_TV_ANALOG) 1738 - return i2c_probe(adap, &addr_data, msp_attach); 1739 - return 0; 1740 - } 1741 - 1742 - static void msp_wake_thread(struct i2c_client *client) 1743 - { 1744 - struct msp3400c *msp = i2c_get_clientdata(client); 1745 - 1746 - if (NULL == msp->kthread) 1747 - return; 1748 - msp3400c_setvolume(client,msp->muted,0,0); 1749 - msp->watch_stereo = 0; 1750 - msp->restart = 1; 1751 - wake_up_interruptible(&msp->wq); 1752 - } 1753 - 1754 - /* ----------------------------------------------------------------------- */ 1755 - 1756 - static int mode_v4l2_to_v4l1(int rxsubchans) 1757 - { 1758 - int mode = 0; 1759 - 1760 - if (rxsubchans & V4L2_TUNER_SUB_STEREO) 1761 - mode |= VIDEO_SOUND_STEREO; 1762 - if (rxsubchans & V4L2_TUNER_SUB_LANG2) 1763 - mode |= VIDEO_SOUND_LANG2; 1764 - if (rxsubchans & V4L2_TUNER_SUB_LANG1) 1765 - mode |= VIDEO_SOUND_LANG1; 1766 - if (0 == mode) 1767 - mode |= VIDEO_SOUND_MONO; 1768 - return mode; 1769 - } 1770 - 1771 - static int mode_v4l1_to_v4l2(int mode) 1772 - { 1773 - if (mode & VIDEO_SOUND_STEREO) 1774 - return V4L2_TUNER_MODE_STEREO; 1775 - if (mode & VIDEO_SOUND_LANG2) 1776 - return V4L2_TUNER_MODE_LANG2; 1777 - if (mode & VIDEO_SOUND_LANG1) 1778 - return V4L2_TUNER_MODE_LANG1; 1779 - return V4L2_TUNER_MODE_MONO; 1780 - } 1781 - 1782 - static void msp_any_detect_stereo(struct i2c_client *client) 1783 - { 1784 - struct msp3400c *msp = i2c_get_clientdata(client); 1785 - 1786 - switch (msp->opmode) { 1787 - case OPMODE_MANUAL: 1788 - case OPMODE_SIMPLE: 1789 - autodetect_stereo(client); 1790 - break; 1791 - case OPMODE_SIMPLER: 1792 - msp34xxg_detect_stereo(client); 1793 - break; 1794 - } 1795 - } 1796 - 1797 - static void msp_any_set_audmode(struct i2c_client *client, int audmode) 1798 - { 1799 - struct msp3400c *msp = i2c_get_clientdata(client); 1800 - 1801 - switch (msp->opmode) { 1802 - case OPMODE_MANUAL: 1803 - case OPMODE_SIMPLE: 1804 - msp->watch_stereo = 0; 1805 - msp3400c_setstereo(client, audmode); 1806 - break; 1807 - case OPMODE_SIMPLER: 1808 - msp34xxg_set_audmode(client, audmode); 1809 - break; 1810 - } 1811 - } 1812 - 1813 - 1814 - static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) 1815 - { 1816 - struct msp3400c *msp = i2c_get_clientdata(client); 1817 - __u16 *sarg = arg; 1818 - int scart = 0; 1819 - 1820 - switch (cmd) { 1821 - 1822 - case AUDC_SET_INPUT: 1823 - msp3400_dbg("AUDC_SET_INPUT(%d)\n",*sarg); 1824 - 1825 - if (*sarg == msp->input) 1826 - break; 1827 - msp->input = *sarg; 1828 - switch (*sarg) { 1829 - case AUDIO_RADIO: 1830 - /* Hauppauge uses IN2 for the radio */ 1831 - msp->mode = MSP_MODE_FM_RADIO; 1832 - scart = SCART_IN2; 1833 - break; 1834 - case AUDIO_EXTERN_1: 1835 - /* IN1 is often used for external input ... */ 1836 - msp->mode = MSP_MODE_EXTERN; 1837 - scart = SCART_IN1; 1838 - break; 1839 - case AUDIO_EXTERN_2: 1840 - /* ... sometimes it is IN2 through ;) */ 1841 - msp->mode = MSP_MODE_EXTERN; 1842 - scart = SCART_IN2; 1843 - break; 1844 - case AUDIO_TUNER: 1845 - msp->mode = -1; 1846 - break; 1847 - default: 1848 - if (*sarg & AUDIO_MUTE) 1849 - msp3400c_set_scart(client,SCART_MUTE,0); 1850 - break; 1851 - } 1852 - if (scart) { 1853 - msp->rxsubchans = V4L2_TUNER_SUB_STEREO; 1854 - msp->audmode = V4L2_TUNER_MODE_STEREO; 1855 - msp3400c_set_scart(client,scart,0); 1856 - msp3400c_write(client,I2C_MSP3400C_DFP,0x000d,0x1900); 1857 - if (msp->opmode != OPMODE_SIMPLER) 1858 - msp3400c_setstereo(client, msp->audmode); 1859 - } 1860 - msp_wake_thread(client); 1861 - break; 1862 - 1863 - case AUDC_SET_RADIO: 1864 - msp3400_dbg("AUDC_SET_RADIO\n"); 1865 - msp->norm = VIDEO_MODE_RADIO; 1866 - msp3400_dbg("switching to radio mode\n"); 1867 - msp->watch_stereo = 0; 1868 - switch (msp->opmode) { 1869 - case OPMODE_MANUAL: 1870 - /* set msp3400 to FM radio mode */ 1871 - msp3400c_setmode(client,MSP_MODE_FM_RADIO); 1872 - msp3400c_setcarrier(client, MSP_CARRIER(10.7), 1873 - MSP_CARRIER(10.7)); 1874 - msp3400c_setvolume(client, msp->muted, msp->left, msp->right); 1875 - break; 1876 - case OPMODE_SIMPLE: 1877 - case OPMODE_SIMPLER: 1878 - /* the thread will do for us */ 1879 - msp_wake_thread(client); 1880 - break; 1881 - } 1882 - break; 1883 - /* work-in-progress: hook to control the DFP registers */ 1884 - case MSP_SET_DFPREG: 1885 - { 1886 - struct msp_dfpreg *r = arg; 1887 - int i; 1888 - 1889 - if (r->reg < 0 || r->reg >= DFP_COUNT) 1890 - return -EINVAL; 1891 - for (i = 0; i < sizeof(bl_dfp) / sizeof(int); i++) 1892 - if (r->reg == bl_dfp[i]) 1893 - return -EINVAL; 1894 - msp->dfp_regs[r->reg] = r->value; 1895 - msp3400c_write(client, I2C_MSP3400C_DFP, r->reg, r->value); 1896 - return 0; 1897 - } 1898 - case MSP_GET_DFPREG: 1899 - { 1900 - struct msp_dfpreg *r = arg; 1901 - 1902 - if (r->reg < 0 || r->reg >= DFP_COUNT) 1903 - return -EINVAL; 1904 - r->value = msp3400c_read(client, I2C_MSP3400C_DFP, r->reg); 1905 - return 0; 1906 - } 1907 - 1908 - /* --- v4l ioctls --- */ 1909 - /* take care: bttv does userspace copying, we'll get a 1910 - kernel pointer here... */ 1911 - case VIDIOCGAUDIO: 1912 - { 1913 - struct video_audio *va = arg; 1914 - 1915 - msp3400_dbg("VIDIOCGAUDIO\n"); 1916 - va->flags |= VIDEO_AUDIO_VOLUME | 1917 - VIDEO_AUDIO_BASS | 1918 - VIDEO_AUDIO_TREBLE | 1919 - VIDEO_AUDIO_MUTABLE; 1920 - if (msp->muted) 1921 - va->flags |= VIDEO_AUDIO_MUTE; 1922 - 1923 - if (msp->muted) 1924 - va->flags |= VIDEO_AUDIO_MUTE; 1925 - va->volume = MAX(msp->left, msp->right); 1926 - va->balance = (32768 * MIN(msp->left, msp->right)) / 1927 - (va->volume ? va->volume : 1); 1928 - va->balance = (msp->left < msp->right) ? 1929 - (65535 - va->balance) : va->balance; 1930 - if (0 == va->volume) 1931 - va->balance = 32768; 1932 - va->bass = msp->bass; 1933 - va->treble = msp->treble; 1934 - 1935 - msp_any_detect_stereo(client); 1936 - va->mode = mode_v4l2_to_v4l1(msp->rxsubchans); 1937 - break; 1938 - } 1939 - case VIDIOCSAUDIO: 1940 - { 1941 - struct video_audio *va = arg; 1942 - 1943 - msp3400_dbg("VIDIOCSAUDIO\n"); 1944 - msp->muted = (va->flags & VIDEO_AUDIO_MUTE); 1945 - msp->left = (MIN(65536 - va->balance, 32768) * 1946 - va->volume) / 32768; 1947 - msp->right = (MIN(va->balance, 32768) * va->volume) / 32768; 1948 - msp->bass = va->bass; 1949 - msp->treble = va->treble; 1950 - msp3400_dbg("VIDIOCSAUDIO setting va->volume to %d\n", 1951 - va->volume); 1952 - msp3400_dbg("VIDIOCSAUDIO setting va->balance to %d\n", 1953 - va->balance); 1954 - msp3400_dbg("VIDIOCSAUDIO setting va->flags to %d\n", 1955 - va->flags); 1956 - msp3400_dbg("VIDIOCSAUDIO setting msp->left to %d\n", 1957 - msp->left); 1958 - msp3400_dbg("VIDIOCSAUDIO setting msp->right to %d\n", 1959 - msp->right); 1960 - msp3400_dbg("VIDIOCSAUDIO setting msp->bass to %d\n", 1961 - msp->bass); 1962 - msp3400_dbg("VIDIOCSAUDIO setting msp->treble to %d\n", 1963 - msp->treble); 1964 - msp3400_dbg("VIDIOCSAUDIO setting msp->mode to %d\n", 1965 - msp->mode); 1966 - msp3400c_setvolume(client, msp->muted, msp->left, msp->right); 1967 - msp3400c_setbass(client, msp->bass); 1968 - msp3400c_settreble(client, msp->treble); 1969 - 1970 - if (va->mode != 0 && msp->norm != VIDEO_MODE_RADIO) 1971 - msp_any_set_audmode(client,mode_v4l1_to_v4l2(va->mode)); 1972 - break; 1973 - } 1974 - 1975 - case VIDIOCSCHAN: 1976 - { 1977 - struct video_channel *vc = arg; 1978 - 1979 - msp3400_dbg("VIDIOCSCHAN (norm=%d)\n",vc->norm); 1980 - msp->norm = vc->norm; 1981 - msp_wake_thread(client); 1982 - break; 1983 - } 1984 - 1985 - case VIDIOCSFREQ: 1986 - case VIDIOC_S_FREQUENCY: 1987 - { 1988 - /* new channel -- kick audio carrier scan */ 1989 - msp3400_dbg("VIDIOCSFREQ\n"); 1990 - msp_wake_thread(client); 1991 - break; 1992 - } 1993 - 1994 - /* msp34xx specific */ 1995 - case MSP_SET_MATRIX: 1996 - { 1997 - struct msp_matrix *mspm = arg; 1998 - 1999 - msp3400_dbg("MSP_SET_MATRIX\n"); 2000 - msp3400c_set_scart(client, mspm->input, mspm->output); 2001 - break; 2002 - } 2003 - 2004 - /* --- v4l2 ioctls --- */ 2005 - case VIDIOC_S_STD: 2006 - { 2007 - v4l2_std_id *id = arg; 2008 - 2009 - /*FIXME: use V4L2 mode flags on msp3400 instead of V4L1*/ 2010 - if (*id & V4L2_STD_PAL) { 2011 - msp->norm=VIDEO_MODE_PAL; 2012 - } else if (*id & V4L2_STD_SECAM) { 2013 - msp->norm=VIDEO_MODE_SECAM; 2014 - } else { 2015 - msp->norm=VIDEO_MODE_NTSC; 2016 - } 2017 - 2018 - msp_wake_thread(client); 2019 - return 0; 2020 - } 2021 - 2022 - case VIDIOC_ENUMINPUT: 2023 - { 2024 - struct v4l2_input *i = arg; 2025 - 2026 - if (i->index != 0) 2027 - return -EINVAL; 2028 - 2029 - i->type = V4L2_INPUT_TYPE_TUNER; 2030 - switch (i->index) { 2031 - case AUDIO_RADIO: 2032 - strcpy(i->name,"Radio"); 2033 - break; 2034 - case AUDIO_EXTERN_1: 2035 - strcpy(i->name,"Extern 1"); 2036 - break; 2037 - case AUDIO_EXTERN_2: 2038 - strcpy(i->name,"Extern 2"); 2039 - break; 2040 - case AUDIO_TUNER: 2041 - strcpy(i->name,"Television"); 2042 - break; 2043 - default: 2044 - return -EINVAL; 2045 - } 2046 - return 0; 2047 - } 2048 - 2049 - case VIDIOC_G_AUDIO: 2050 - { 2051 - struct v4l2_audio *a = arg; 2052 - 2053 - memset(a,0,sizeof(*a)); 2054 - 2055 - switch (a->index) { 2056 - case AUDIO_RADIO: 2057 - strcpy(a->name,"Radio"); 2058 - break; 2059 - case AUDIO_EXTERN_1: 2060 - strcpy(a->name,"Extern 1"); 2061 - break; 2062 - case AUDIO_EXTERN_2: 2063 - strcpy(a->name,"Extern 2"); 2064 - break; 2065 - case AUDIO_TUNER: 2066 - strcpy(a->name,"Television"); 2067 - break; 2068 - default: 2069 - return -EINVAL; 2070 - } 2071 - 2072 - msp_any_detect_stereo(client); 2073 - if (msp->audmode == V4L2_TUNER_MODE_STEREO) { 2074 - a->capability=V4L2_AUDCAP_STEREO; 2075 - } 2076 - 2077 - break; 2078 - } 2079 - case VIDIOC_S_AUDIO: 2080 - { 2081 - struct v4l2_audio *sarg = arg; 2082 - 2083 - switch (sarg->index) { 2084 - case AUDIO_RADIO: 2085 - /* Hauppauge uses IN2 for the radio */ 2086 - msp->mode = MSP_MODE_FM_RADIO; 2087 - scart = SCART_IN2; 2088 - break; 2089 - case AUDIO_EXTERN_1: 2090 - /* IN1 is often used for external input ... */ 2091 - msp->mode = MSP_MODE_EXTERN; 2092 - scart = SCART_IN1; 2093 - break; 2094 - case AUDIO_EXTERN_2: 2095 - /* ... sometimes it is IN2 through ;) */ 2096 - msp->mode = MSP_MODE_EXTERN; 2097 - scart = SCART_IN2; 2098 - break; 2099 - case AUDIO_TUNER: 2100 - msp->mode = -1; 2101 - break; 2102 - } 2103 - if (scart) { 2104 - msp->rxsubchans = V4L2_TUNER_SUB_STEREO; 2105 - msp->audmode = V4L2_TUNER_MODE_STEREO; 2106 - msp3400c_set_scart(client,scart,0); 2107 - msp3400c_write(client,I2C_MSP3400C_DFP,0x000d,0x1900); 2108 - } 2109 - if (sarg->capability==V4L2_AUDCAP_STEREO) { 2110 - msp->audmode = V4L2_TUNER_MODE_STEREO; 2111 - } else { 2112 - msp->audmode &= ~V4L2_TUNER_MODE_STEREO; 2113 - } 2114 - msp_any_set_audmode(client, msp->audmode); 2115 - msp_wake_thread(client); 2116 - break; 2117 - } 2118 - case VIDIOC_G_TUNER: 2119 - { 2120 - struct v4l2_tuner *vt = arg; 2121 - 2122 - msp_any_detect_stereo(client); 2123 - vt->audmode = msp->audmode; 2124 - vt->rxsubchans = msp->rxsubchans; 2125 - vt->capability = V4L2_TUNER_CAP_STEREO | 2126 - V4L2_TUNER_CAP_LANG1| 2127 - V4L2_TUNER_CAP_LANG2; 2128 - break; 2129 - } 2130 - case VIDIOC_S_TUNER: 2131 - { 2132 - struct v4l2_tuner *vt=(struct v4l2_tuner *)arg; 2133 - 2134 - /* only set audmode */ 2135 - if (vt->audmode != -1 && vt->audmode != 0) 2136 - msp_any_set_audmode(client, vt->audmode); 2137 - break; 2138 - } 2139 - 2140 - case VIDIOC_G_AUDOUT: 2141 - { 2142 - struct v4l2_audioout *a=(struct v4l2_audioout *)arg; 2143 - int idx=a->index; 2144 - 2145 - memset(a,0,sizeof(*a)); 2146 - 2147 - switch (idx) { 2148 - case 0: 2149 - strcpy(a->name,"Scart1 Out"); 2150 - break; 2151 - case 1: 2152 - strcpy(a->name,"Scart2 Out"); 2153 - break; 2154 - case 2: 2155 - strcpy(a->name,"I2S Out"); 2156 - break; 2157 - default: 2158 - return -EINVAL; 2159 - } 2160 - break; 2161 - 2162 - } 2163 - case VIDIOC_S_AUDOUT: 2164 - { 2165 - struct v4l2_audioout *a=(struct v4l2_audioout *)arg; 2166 - 2167 - if (a->index<0||a->index>2) 2168 - return -EINVAL; 2169 - 2170 - if (a->index==2) { 2171 - if (a->mode == V4L2_AUDMODE_32BITS) 2172 - msp->i2s_mode=1; 2173 - else 2174 - msp->i2s_mode=0; 2175 - } 2176 - msp3400_dbg("Setting audio out on msp34xx to input %i, mode %i\n", 2177 - a->index,msp->i2s_mode); 2178 - msp3400c_set_scart(client,msp->in_scart,a->index+1); 2179 - 2180 - break; 2181 - } 2182 - 2183 - default: 2184 - /* nothing */ 2185 - break; 2186 - } 2187 - return 0; 2188 - } 2189 - 2190 - static int msp_suspend(struct device * dev, pm_message_t state) 2191 - { 2192 - struct i2c_client *client = container_of(dev, struct i2c_client, dev); 2193 - 2194 - msp3400_dbg("msp34xx: suspend\n"); 2195 - msp3400c_reset(client); 2196 - return 0; 2197 - } 2198 - 2199 - static int msp_resume(struct device * dev) 2200 - { 2201 - struct i2c_client *client = container_of(dev, struct i2c_client, dev); 2202 - 2203 - msp3400_dbg("msp34xx: resume\n"); 2204 - msp_wake_thread(client); 2205 - return 0; 2206 - } 2207 - 2208 - /* ----------------------------------------------------------------------- */ 2209 - 2210 - static int __init msp3400_init_module(void) 2211 - { 2212 - return i2c_add_driver(&driver); 2213 - } 2214 - 2215 - static void __exit msp3400_cleanup_module(void) 2216 - { 2217 - i2c_del_driver(&driver); 2218 - } 2219 - 2220 - module_init(msp3400_init_module); 2221 - module_exit(msp3400_cleanup_module); 2222 - 2223 - /* 2224 - * Overrides for Emacs so that we follow Linus's tabbing style. 2225 - * --------------------------------------------------------------------------- 2226 - * Local variables: 2227 - * c-basic-offset: 8 2228 - * End: 2229 - */
+94 -8
drivers/media/video/msp3400.h
··· 6 6 7 7 /* ---------------------------------------------------------------------- */ 8 8 9 - struct msp_dfpreg { 10 - int reg; 11 - int value; 12 - }; 13 - 14 9 struct msp_matrix { 15 10 int input; 16 11 int output; 17 12 }; 18 13 19 - #define MSP_SET_DFPREG _IOW('m',15,struct msp_dfpreg) 20 - #define MSP_GET_DFPREG _IOW('m',16,struct msp_dfpreg) 21 - 22 14 /* ioctl for MSP_SET_MATRIX will have to be registered */ 23 15 #define MSP_SET_MATRIX _IOW('m',17,struct msp_matrix) 16 + 17 + /* This macro is allowed for *constants* only, gcc must calculate it 18 + at compile time. Remember -- no floats in kernel mode */ 19 + #define MSP_CARRIER(freq) ((int)((float)(freq / 18.432) * (1 << 24))) 20 + 21 + #define MSP_MODE_AM_DETECT 0 22 + #define MSP_MODE_FM_RADIO 2 23 + #define MSP_MODE_FM_TERRA 3 24 + #define MSP_MODE_FM_SAT 4 25 + #define MSP_MODE_FM_NICAM1 5 26 + #define MSP_MODE_FM_NICAM2 6 27 + #define MSP_MODE_AM_NICAM 7 28 + #define MSP_MODE_BTSC 8 29 + #define MSP_MODE_EXTERN 9 24 30 25 31 #define SCART_MASK 0 26 32 #define SCART_IN1 1 ··· 41 35 #define SCART_DSP_IN 0 42 36 #define SCART1_OUT 1 43 37 #define SCART2_OUT 2 38 + 39 + #define OPMODE_AUTO -1 40 + #define OPMODE_MANUAL 0 41 + #define OPMODE_AUTODETECT 1 /* use autodetect (>= msp3410 only) */ 42 + #define OPMODE_AUTOSELECT 2 /* use autodetect & autoselect (>= msp34xxG) */ 43 + 44 + /* module parameters */ 45 + extern int debug; 46 + extern int once; 47 + extern int amsound; 48 + extern int standard; 49 + extern int dolby; 50 + extern int stereo_threshold; 51 + 52 + struct msp_state { 53 + int rev1, rev2; 54 + u8 has_nicam; 55 + u8 has_radio; 56 + u8 has_headphones; 57 + u8 has_ntsc_jp_d_k3; 58 + u8 has_scart4; 59 + u8 has_scart23_in_scart2_out; 60 + u8 has_scart2_out_volume; 61 + u8 has_i2s_conf; 62 + u8 has_subwoofer; 63 + u8 has_sound_processing; 64 + u8 has_virtual_dolby_surround; 65 + u8 has_dolby_pro_logic; 66 + 67 + int radio; 68 + int opmode; 69 + int std; 70 + int mode; 71 + v4l2_std_id v4l2_std; 72 + int nicam_on; 73 + int acb; 74 + int in_scart; 75 + int i2s_mode; 76 + int main, second; /* sound carrier */ 77 + int input; 78 + int source; /* see msp34xxg_set_source */ 79 + 80 + /* v4l2 */ 81 + int audmode; 82 + int rxsubchans; 83 + 84 + int volume, muted; 85 + int balance, loudness; 86 + int bass, treble; 87 + 88 + /* thread */ 89 + struct task_struct *kthread; 90 + wait_queue_head_t wq; 91 + int restart:1; 92 + int watch_stereo:1; 93 + }; 94 + 95 + /* msp3400-driver.c */ 96 + int msp_write_dem(struct i2c_client *client, int addr, int val); 97 + int msp_write_dsp(struct i2c_client *client, int addr, int val); 98 + int msp_read_dem(struct i2c_client *client, int addr); 99 + int msp_read_dsp(struct i2c_client *client, int addr); 100 + int msp_reset(struct i2c_client *client); 101 + void msp_set_scart(struct i2c_client *client, int in, int out); 102 + void msp_set_mute(struct i2c_client *client); 103 + void msp_set_audio(struct i2c_client *client); 104 + int msp_modus(struct i2c_client *client); 105 + int msp_sleep(struct msp_state *state, int timeout); 106 + 107 + /* msp3400-kthreads.c */ 108 + const char *msp_standard_std_name(int std); 109 + void msp3400c_setcarrier(struct i2c_client *client, int cdo1, int cdo2); 110 + void msp3400c_setmode(struct i2c_client *client, int type); 111 + void msp3400c_setstereo(struct i2c_client *client, int mode); 112 + int autodetect_stereo(struct i2c_client *client); 113 + int msp3400c_thread(void *data); 114 + int msp3410d_thread(void *data); 115 + int msp34xxg_thread(void *data); 116 + void msp34xxg_detect_stereo(struct i2c_client *client); 117 + void msp34xxg_set_audmode(struct i2c_client *client, int audmode); 44 118 45 119 #endif /* MSP3400_H */
+13 -3
drivers/media/video/mt20xx.c
··· 20 20 static unsigned int radio_antenna = 0; 21 21 module_param(radio_antenna, int, 0644); 22 22 23 + /* from tuner-core.c */ 24 + extern int debug; 25 + 23 26 /* ---------------------------------------------------------------------- */ 24 27 25 28 #define MT2032 0x04 ··· 404 401 div2a=(lo2/8)-1; 405 402 div2b=lo2-(div2a+1)*8; 406 403 407 - if (tuner_debug > 1) { 404 + if (debug > 1) { 408 405 tuner_dbg("lo1 lo2 = %d %d\n", lo1, lo2); 409 406 tuner_dbg("num1 num2 div1a div1b div2a div2b= %x %x %x %x %x %x\n", 410 407 num1,num2,div1a,div1b,div2a,div2b); ··· 420 417 buf[5]=div2a; 421 418 if(num2!=0) buf[5]=buf[5]|0x40; 422 419 423 - if (tuner_debug > 1) { 420 + if (debug > 1) { 424 421 int i; 425 422 tuner_dbg("bufs is: "); 426 423 for(i=0;i<6;i++) ··· 497 494 t->tv_freq = NULL; 498 495 t->radio_freq = NULL; 499 496 t->standby = NULL; 497 + if (t->std & V4L2_STD_525_60) { 498 + tuner_dbg("pinnacle ntsc\n"); 499 + t->radio_if2 = 41300 * 1000; 500 + } else { 501 + tuner_dbg("pinnacle pal\n"); 502 + t->radio_if2 = 33300 * 1000; 503 + } 500 504 name = "unknown"; 501 505 502 506 i2c_master_send(c,buf,1); 503 507 i2c_master_recv(c,buf,21); 504 - if (tuner_debug) { 508 + if (debug) { 505 509 int i; 506 510 tuner_dbg("MT20xx hexdump:"); 507 511 for(i=0;i<21;i++) {
+1
drivers/media/video/mxb.c
··· 26 26 #include <media/saa7146_vv.h> 27 27 #include <media/tuner.h> 28 28 #include <linux/video_decoder.h> 29 + #include <media/v4l2-common.h> 29 30 30 31 #include "mxb.h" 31 32 #include "tea6415c.h"
+1
drivers/media/video/pms.c
··· 883 883 .open = video_exclusive_open, 884 884 .release = video_exclusive_release, 885 885 .ioctl = pms_ioctl, 886 + .compat_ioctl = v4l_compat_ioctl32, 886 887 .read = pms_read, 887 888 .llseek = no_llseek, 888 889 };
+1
drivers/media/video/saa5249.c
··· 702 702 .open = saa5249_open, 703 703 .release = saa5249_release, 704 704 .ioctl = saa5249_ioctl, 705 + .compat_ioctl = v4l_compat_ioctl32, 705 706 .llseek = no_llseek, 706 707 }; 707 708
+1 -11
drivers/media/video/saa6588.c
··· 427 427 428 428 static int saa6588_probe(struct i2c_adapter *adap) 429 429 { 430 - #ifdef I2C_CLASS_TV_ANALOG 431 430 if (adap->class & I2C_CLASS_TV_ANALOG) 432 431 return i2c_probe(adap, &addr_data, saa6588_attach); 433 - #else 434 - switch (adap->id) { 435 - case I2C_HW_B_BT848: 436 - case I2C_HW_B_RIVA: 437 - case I2C_HW_SAA7134: 438 - return i2c_probe(adap, &addr_data, saa6588_attach); 439 - break; 440 - } 441 - #endif 442 432 return 0; 443 433 } 444 434 ··· 486 496 487 497 static struct i2c_driver driver = { 488 498 .driver = { 489 - .name = "i2c saa6588 driver", 499 + .name = "saa6588", 490 500 }, 491 501 .id = -1, /* FIXME */ 492 502 .attach_adapter = saa6588_probe,
+150 -169
drivers/media/video/saa7115.c
··· 39 39 #include <linux/i2c.h> 40 40 #include <linux/videodev2.h> 41 41 #include <media/v4l2-common.h> 42 + #include <media/audiochip.h> 43 + #include <asm/div64.h> 42 44 43 45 MODULE_DESCRIPTION("Philips SAA7114/SAA7115 video decoder driver"); 44 46 MODULE_AUTHOR("Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, Hans Verkuil"); 45 47 MODULE_LICENSE("GPL"); 46 48 47 49 static int debug = 0; 48 - module_param(debug, int, 0644); 50 + module_param(debug, bool, 0644); 49 51 50 52 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 51 - 52 - #define saa7115_dbg(fmt,arg...) \ 53 - do { \ 54 - if (debug) \ 55 - printk(KERN_INFO "%s debug %d-%04x: " fmt, \ 56 - client->driver->driver.name, \ 57 - i2c_adapter_id(client->adapter), client->addr , ## arg); \ 58 - } while (0) 59 - 60 - #define saa7115_err(fmt, arg...) do { \ 61 - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ 62 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 63 - #define saa7115_info(fmt, arg...) do { \ 64 - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ 65 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 66 53 67 54 static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END }; 68 55 ··· 60 73 v4l2_std_id std; 61 74 int input; 62 75 int enable; 76 + int radio; 63 77 int bright; 64 78 int contrast; 65 79 int hue; 66 80 int sat; 67 81 enum v4l2_chip_ident ident; 68 - enum v4l2_audio_clock_freq audclk_freq; 82 + u32 audclk_freq; 69 83 }; 70 84 71 85 /* ----------------------------------------------------------------------- */ ··· 457 469 0x00, 0x00 458 470 }; 459 471 460 - /* ============== SAA7715 AUDIO settings ============= */ 461 - 462 - /* 48.0 kHz */ 463 - static const unsigned char saa7115_cfg_48_audio[] = { 464 - 0x34, 0xce, 465 - 0x35, 0xfb, 466 - 0x36, 0x30, 467 - 0x00, 0x00 468 - }; 469 - 470 - /* 44.1 kHz */ 471 - static const unsigned char saa7115_cfg_441_audio[] = { 472 - 0x34, 0xf2, 473 - 0x35, 0x00, 474 - 0x36, 0x2d, 475 - 0x00, 0x00 476 - }; 477 - 478 - /* 32.0 kHz */ 479 - static const unsigned char saa7115_cfg_32_audio[] = { 480 - 0x34, 0xdf, 481 - 0x35, 0xa7, 482 - 0x36, 0x20, 483 - 0x00, 0x00 484 - }; 485 - 486 - /* 48.0 kHz 60hz */ 487 - static const unsigned char saa7115_cfg_60hz_48_audio[] = { 488 - 0x30, 0xcd, 489 - 0x31, 0x20, 490 - 0x32, 0x03, 491 - 0x00, 0x00 492 - }; 493 - 494 - /* 48.0 kHz 50hz */ 495 - static const unsigned char saa7115_cfg_50hz_48_audio[] = { 496 - 0x30, 0x00, 497 - 0x31, 0xc0, 498 - 0x32, 0x03, 499 - 0x00, 0x00 500 - }; 501 - 502 - /* 44.1 kHz 60hz */ 503 - static const unsigned char saa7115_cfg_60hz_441_audio[] = { 504 - 0x30, 0xbc, 505 - 0x31, 0xdf, 506 - 0x32, 0x02, 507 - 0x00, 0x00 508 - }; 509 - 510 - /* 44.1 kHz 50hz */ 511 - static const unsigned char saa7115_cfg_50hz_441_audio[] = { 512 - 0x30, 0x00, 513 - 0x31, 0x72, 514 - 0x32, 0x03, 515 - 0x00, 0x00 516 - }; 517 - 518 - /* 32.0 kHz 60hz */ 519 - static const unsigned char saa7115_cfg_60hz_32_audio[] = { 520 - 0x30, 0xde, 521 - 0x31, 0x15, 522 - 0x32, 0x02, 523 - 0x00, 0x00 524 - }; 525 - 526 - /* 32.0 kHz 50hz */ 527 - static const unsigned char saa7115_cfg_50hz_32_audio[] = { 528 - 0x30, 0x00, 529 - 0x31, 0x80, 530 - 0x32, 0x02, 531 - 0x00, 0x00 532 - }; 533 - 534 472 static int saa7115_odd_parity(u8 c) 535 473 { 536 474 c ^= (c >> 4); ··· 541 627 } 542 628 543 629 544 - static int saa7115_set_audio_clock_freq(struct i2c_client *client, enum v4l2_audio_clock_freq freq) 630 + static int saa7115_set_audio_clock_freq(struct i2c_client *client, u32 freq) 545 631 { 546 632 struct saa7115_state *state = i2c_get_clientdata(client); 633 + u32 acpf; 634 + u32 acni; 635 + u32 hz; 636 + u64 f; 547 637 548 - saa7115_dbg("set audio clock freq: %d\n", freq); 549 - switch (freq) { 550 - case V4L2_AUDCLK_32_KHZ: 551 - saa7115_writeregs(client, saa7115_cfg_32_audio); 552 - if (state->std & V4L2_STD_525_60) { 553 - saa7115_writeregs(client, saa7115_cfg_60hz_32_audio); 554 - } else { 555 - saa7115_writeregs(client, saa7115_cfg_50hz_32_audio); 556 - } 557 - break; 558 - case V4L2_AUDCLK_441_KHZ: 559 - saa7115_writeregs(client, saa7115_cfg_441_audio); 560 - if (state->std & V4L2_STD_525_60) { 561 - saa7115_writeregs(client, saa7115_cfg_60hz_441_audio); 562 - } else { 563 - saa7115_writeregs(client, saa7115_cfg_50hz_441_audio); 564 - } 565 - break; 566 - case V4L2_AUDCLK_48_KHZ: 567 - saa7115_writeregs(client, saa7115_cfg_48_audio); 568 - if (state->std & V4L2_STD_525_60) { 569 - saa7115_writeregs(client, saa7115_cfg_60hz_48_audio); 570 - } else { 571 - saa7115_writeregs(client, saa7115_cfg_50hz_48_audio); 572 - } 573 - break; 574 - default: 575 - saa7115_dbg("invalid audio setting %d\n", freq); 576 - return -EINVAL; 577 - } 638 + v4l_dbg(1, client, "set audio clock freq: %d\n", freq); 639 + 640 + /* sanity check */ 641 + if (freq < 32000 || freq > 48000) 642 + return -EINVAL; 643 + 644 + /* hz is the refresh rate times 100 */ 645 + hz = (state->std & V4L2_STD_525_60) ? 5994 : 5000; 646 + /* acpf = (256 * freq) / field_frequency == (256 * 100 * freq) / hz */ 647 + acpf = (25600 * freq) / hz; 648 + /* acni = (256 * freq * 2^23) / crystal_frequency = 649 + (freq * 2^(8+23)) / crystal_frequency = 650 + (freq << 31) / 32.11 MHz */ 651 + f = freq; 652 + f = f << 31; 653 + do_div(f, 32110000); 654 + acni = f; 655 + 656 + saa7115_write(client, 0x30, acpf & 0xff); 657 + saa7115_write(client, 0x31, (acpf >> 8) & 0xff); 658 + saa7115_write(client, 0x32, (acpf >> 16) & 0x03); 659 + saa7115_write(client, 0x34, acni & 0xff); 660 + saa7115_write(client, 0x35, (acni >> 8) & 0xff); 661 + saa7115_write(client, 0x36, (acni >> 16) & 0x3f); 578 662 state->audclk_freq = freq; 579 663 return 0; 580 664 } ··· 584 672 switch (ctrl->id) { 585 673 case V4L2_CID_BRIGHTNESS: 586 674 if (ctrl->value < 0 || ctrl->value > 255) { 587 - saa7115_err("invalid brightness setting %d\n", ctrl->value); 675 + v4l_err(client, "invalid brightness setting %d\n", ctrl->value); 588 676 return -ERANGE; 589 677 } 590 678 ··· 594 682 595 683 case V4L2_CID_CONTRAST: 596 684 if (ctrl->value < 0 || ctrl->value > 127) { 597 - saa7115_err("invalid contrast setting %d\n", ctrl->value); 685 + v4l_err(client, "invalid contrast setting %d\n", ctrl->value); 598 686 return -ERANGE; 599 687 } 600 688 ··· 604 692 605 693 case V4L2_CID_SATURATION: 606 694 if (ctrl->value < 0 || ctrl->value > 127) { 607 - saa7115_err("invalid saturation setting %d\n", ctrl->value); 695 + v4l_err(client, "invalid saturation setting %d\n", ctrl->value); 608 696 return -ERANGE; 609 697 } 610 698 ··· 614 702 615 703 case V4L2_CID_HUE: 616 704 if (ctrl->value < -127 || ctrl->value > 127) { 617 - saa7115_err("invalid hue setting %d\n", ctrl->value); 705 + v4l_err(client, "invalid hue setting %d\n", ctrl->value); 618 706 return -ERANGE; 619 707 } 620 708 621 709 state->hue = ctrl->value; 622 710 saa7115_write(client, 0x0d, state->hue); 623 711 break; 712 + 713 + default: 714 + return -EINVAL; 624 715 } 625 716 626 717 return 0; ··· 658 743 struct saa7115_state *state = i2c_get_clientdata(client); 659 744 int taskb = saa7115_read(client, 0x80) & 0x10; 660 745 746 + /* Prevent unnecessary standard changes. During a standard 747 + change the I-Port is temporarily disabled. Any devices 748 + reading from that port can get confused. 749 + Note that VIDIOC_S_STD is also used to switch from 750 + radio to TV mode, so if a VIDIOC_S_STD is broadcast to 751 + all I2C devices then you do not want to have an unwanted 752 + side-effect here. */ 753 + if (std == state->std) 754 + return; 755 + 661 756 // This works for NTSC-M, SECAM-L and the 50Hz PAL variants. 662 757 if (std & V4L2_STD_525_60) { 663 - saa7115_dbg("decoder set standard 60 Hz\n"); 758 + v4l_dbg(1, client, "decoder set standard 60 Hz\n"); 664 759 saa7115_writeregs(client, saa7115_cfg_60hz_video); 665 760 } else { 666 - saa7115_dbg("decoder set standard 50 Hz\n"); 761 + v4l_dbg(1, client, "decoder set standard 50 Hz\n"); 667 762 saa7115_writeregs(client, saa7115_cfg_50hz_video); 668 763 } 669 764 ··· 698 773 static void saa7115_log_status(struct i2c_client *client) 699 774 { 700 775 struct saa7115_state *state = i2c_get_clientdata(client); 701 - char *audfreq = "undefined"; 702 776 int reg1e, reg1f; 703 777 int signalOk; 704 778 int vcr; 705 779 706 - switch (state->audclk_freq) { 707 - case V4L2_AUDCLK_32_KHZ: audfreq = "32 kHz"; break; 708 - case V4L2_AUDCLK_441_KHZ: audfreq = "44.1 kHz"; break; 709 - case V4L2_AUDCLK_48_KHZ: audfreq = "48 kHz"; break; 710 - } 711 - 712 - saa7115_info("Audio frequency: %s\n", audfreq); 780 + v4l_info(client, "Audio frequency: %d Hz\n", state->audclk_freq); 713 781 if (client->name[6] == '4') { 714 782 /* status for the saa7114 */ 715 783 reg1f = saa7115_read(client, 0x1f); 716 784 signalOk = (reg1f & 0xc1) == 0x81; 717 - saa7115_info("Video signal: %s\n", signalOk ? "ok" : "bad"); 718 - saa7115_info("Frequency: %s\n", (reg1f & 0x20) ? "60Hz" : "50Hz"); 785 + v4l_info(client, "Video signal: %s\n", signalOk ? "ok" : "bad"); 786 + v4l_info(client, "Frequency: %s\n", (reg1f & 0x20) ? "60 Hz" : "50 Hz"); 719 787 return; 720 788 } 721 789 ··· 719 801 signalOk = (reg1f & 0xc1) == 0x81 && (reg1e & 0xc0) == 0x80; 720 802 vcr = !(reg1f & 0x10); 721 803 722 - saa7115_info("Video signal: %s\n", signalOk ? (vcr ? "VCR" : "broadcast/DVD") : "bad"); 723 - saa7115_info("Frequency: %s\n", (reg1f & 0x20) ? "60Hz" : "50Hz"); 804 + if (state->input >= 6) { 805 + v4l_info(client, "Input: S-Video %d\n", state->input - 6); 806 + } else { 807 + v4l_info(client, "Input: Composite %d\n", state->input); 808 + } 809 + v4l_info(client, "Video signal: %s\n", signalOk ? (vcr ? "VCR" : "broadcast/DVD") : "bad"); 810 + v4l_info(client, "Frequency: %s\n", (reg1f & 0x20) ? "60 Hz" : "50 Hz"); 724 811 725 812 switch (reg1e & 0x03) { 726 813 case 1: 727 - saa7115_info("Detected format: NTSC\n"); 814 + v4l_info(client, "Detected format: NTSC\n"); 728 815 break; 729 816 case 2: 730 - saa7115_info("Detected format: PAL\n"); 817 + v4l_info(client, "Detected format: PAL\n"); 731 818 break; 732 819 case 3: 733 - saa7115_info("Detected format: SECAM\n"); 820 + v4l_info(client, "Detected format: SECAM\n"); 734 821 break; 735 822 default: 736 - saa7115_info("Detected format: BW/No color\n"); 823 + v4l_info(client, "Detected format: BW/No color\n"); 737 824 break; 738 825 } 739 826 } ··· 863 940 864 941 pix = &(fmt->fmt.pix); 865 942 866 - saa7115_dbg("decoder set size\n"); 943 + v4l_dbg(1, client, "decoder set size\n"); 867 944 868 945 /* FIXME need better bounds checking here */ 869 946 if ((pix->width < 1) || (pix->width > 1440)) ··· 889 966 HPSC = HPSC ? HPSC : 1; 890 967 HFSC = (int)((1024 * 720) / (HPSC * pix->width)); 891 968 892 - saa7115_dbg("Hpsc: 0x%05x, Hfsc: 0x%05x\n", HPSC, HFSC); 969 + v4l_dbg(1, client, "Hpsc: 0x%05x, Hfsc: 0x%05x\n", HPSC, HFSC); 893 970 /* FIXME hardcodes to "Task B" 894 971 * write H prescaler integer */ 895 972 saa7115_write(client, 0xd0, (u8) (HPSC & 0x3f)); ··· 903 980 saa7115_write(client, 0xDD, (u8) ((HFSC >> 9) & 0xff)); 904 981 } else { 905 982 if (is_50hz) { 906 - saa7115_dbg("Setting full 50hz width\n"); 983 + v4l_dbg(1, client, "Setting full 50hz width\n"); 907 984 saa7115_writeregs(client, saa7115_cfg_50hz_fullres_x); 908 985 } else { 909 - saa7115_dbg("Setting full 60hz width\n"); 986 + v4l_dbg(1, client, "Setting full 60hz width\n"); 910 987 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x); 911 988 } 912 989 } ··· 915 992 916 993 if (pix->height != Vsrc) { 917 994 VSCY = (int)((1024 * Vsrc) / pix->height); 918 - saa7115_dbg("Vsrc: %d, Vscy: 0x%05x\n", Vsrc, VSCY); 995 + v4l_dbg(1, client, "Vsrc: %d, Vscy: 0x%05x\n", Vsrc, VSCY); 919 996 920 997 /* Correct Contrast and Luminance */ 921 998 saa7115_write(client, 0xd5, (u8) (64 * 1024 / VSCY)); ··· 929 1006 saa7115_write(client, 0xe3, (u8) ((VSCY >> 8) & 0xff)); 930 1007 } else { 931 1008 if (is_50hz) { 932 - saa7115_dbg("Setting full 50Hz height\n"); 1009 + v4l_dbg(1, client, "Setting full 50Hz height\n"); 933 1010 saa7115_writeregs(client, saa7115_cfg_50hz_fullres_y); 934 1011 } else { 935 - saa7115_dbg("Setting full 60hz height\n"); 1012 + v4l_dbg(1, client, "Setting full 60hz height\n"); 936 1013 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y); 937 1014 } 938 1015 } ··· 1012 1089 1013 1090 /* ============ SAA7115 AUDIO settings (end) ============= */ 1014 1091 1092 + static struct v4l2_queryctrl saa7115_qctrl[] = { 1093 + { 1094 + .id = V4L2_CID_BRIGHTNESS, 1095 + .type = V4L2_CTRL_TYPE_INTEGER, 1096 + .name = "Brightness", 1097 + .minimum = 0, 1098 + .maximum = 255, 1099 + .step = 1, 1100 + .default_value = 128, 1101 + .flags = 0, 1102 + }, { 1103 + .id = V4L2_CID_CONTRAST, 1104 + .type = V4L2_CTRL_TYPE_INTEGER, 1105 + .name = "Contrast", 1106 + .minimum = 0, 1107 + .maximum = 255, 1108 + .step = 1, 1109 + .default_value = 64, 1110 + .flags = 0, 1111 + }, { 1112 + .id = V4L2_CID_SATURATION, 1113 + .type = V4L2_CTRL_TYPE_INTEGER, 1114 + .name = "Saturation", 1115 + .minimum = 0, 1116 + .maximum = 255, 1117 + .step = 1, 1118 + .default_value = 64, 1119 + .flags = 0, 1120 + }, { 1121 + .id = V4L2_CID_HUE, 1122 + .type = V4L2_CTRL_TYPE_INTEGER, 1123 + .name = "Hue", 1124 + .minimum = -128, 1125 + .maximum = 127, 1126 + .step = 1, 1127 + .default_value = 0, 1128 + .flags = 0, 1129 + }, 1130 + }; 1131 + 1132 + /* ----------------------------------------------------------------------- */ 1133 + 1015 1134 static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *arg) 1016 1135 { 1017 1136 struct saa7115_state *state = i2c_get_clientdata(client); ··· 1068 1103 return saa7115_get_v4lfmt(client, (struct v4l2_format *)arg); 1069 1104 1070 1105 case VIDIOC_INT_AUDIO_CLOCK_FREQ: 1071 - return saa7115_set_audio_clock_freq(client, *(enum v4l2_audio_clock_freq *)arg); 1106 + return saa7115_set_audio_clock_freq(client, *(u32 *)arg); 1072 1107 1073 1108 case VIDIOC_G_TUNER: 1074 1109 { 1075 1110 struct v4l2_tuner *vt = arg; 1076 1111 int status; 1077 1112 1113 + if (state->radio) 1114 + break; 1078 1115 status = saa7115_read(client, 0x1f); 1079 1116 1080 - saa7115_dbg("status: 0x%02x\n", status); 1117 + v4l_dbg(1, client, "status: 0x%02x\n", status); 1081 1118 vt->signal = ((status & (1 << 6)) == 0) ? 0xffff : 0x0; 1082 1119 break; 1083 1120 } ··· 1094 1127 case VIDIOC_S_CTRL: 1095 1128 return saa7115_set_v4lctrl(client, (struct v4l2_control *)arg); 1096 1129 1130 + case VIDIOC_QUERYCTRL: 1131 + { 1132 + struct v4l2_queryctrl *qc = arg; 1133 + int i; 1134 + 1135 + for (i = 0; i < ARRAY_SIZE(saa7115_qctrl); i++) 1136 + if (qc->id && qc->id == saa7115_qctrl[i].id) { 1137 + memcpy(qc, &saa7115_qctrl[i], sizeof(*qc)); 1138 + return 0; 1139 + } 1140 + return -EINVAL; 1141 + } 1142 + 1097 1143 case VIDIOC_G_STD: 1098 1144 *(v4l2_std_id *)arg = saa7115_get_v4lstd(client); 1099 1145 break; 1100 1146 1101 1147 case VIDIOC_S_STD: 1148 + state->radio = 0; 1102 1149 saa7115_set_v4lstd(client, *(v4l2_std_id *)arg); 1150 + break; 1151 + 1152 + case AUDC_SET_RADIO: 1153 + state->radio = 1; 1103 1154 break; 1104 1155 1105 1156 case VIDIOC_G_INPUT: ··· 1125 1140 break; 1126 1141 1127 1142 case VIDIOC_S_INPUT: 1128 - saa7115_dbg("decoder set input %d\n", *iarg); 1143 + v4l_dbg(1, client, "decoder set input %d\n", *iarg); 1129 1144 /* inputs from 0-9 are available */ 1130 1145 if (*iarg < 0 || *iarg > 9) { 1131 1146 return -EINVAL; ··· 1133 1148 1134 1149 if (state->input == *iarg) 1135 1150 break; 1136 - saa7115_dbg("now setting %s input\n", 1151 + v4l_dbg(1, client, "now setting %s input\n", 1137 1152 *iarg >= 6 ? "S-Video" : "Composite"); 1138 1153 state->input = *iarg; 1139 1154 ··· 1150 1165 1151 1166 case VIDIOC_STREAMON: 1152 1167 case VIDIOC_STREAMOFF: 1153 - saa7115_dbg("%s output\n", 1168 + v4l_dbg(1, client, "%s output\n", 1154 1169 (cmd == VIDIOC_STREAMON) ? "enable" : "disable"); 1155 1170 1156 1171 if (state->enable != (cmd == VIDIOC_STREAMON)) { ··· 1164 1179 break; 1165 1180 1166 1181 case VIDIOC_INT_RESET: 1167 - saa7115_dbg("decoder RESET\n"); 1182 + v4l_dbg(1, client, "decoder RESET\n"); 1168 1183 saa7115_writeregs(client, saa7115_cfg_reset_scaler); 1169 1184 break; 1170 1185 ··· 1258 1273 client->driver = &i2c_driver_saa7115; 1259 1274 snprintf(client->name, sizeof(client->name) - 1, "saa7115"); 1260 1275 1261 - saa7115_dbg("detecting saa7115 client on address 0x%x\n", address << 1); 1276 + v4l_dbg(1, client, "detecting saa7115 client on address 0x%x\n", address << 1); 1262 1277 1263 1278 saa7115_write(client, 0, 5); 1264 1279 chip_id = saa7115_read(client, 0) & 0x0f; 1265 1280 if (chip_id != 4 && chip_id != 5) { 1266 - saa7115_dbg("saa7115 not found\n"); 1281 + v4l_dbg(1, client, "saa7115 not found\n"); 1267 1282 kfree(client); 1268 1283 return 0; 1269 1284 } 1270 1285 if (chip_id == 4) { 1271 1286 snprintf(client->name, sizeof(client->name) - 1, "saa7114"); 1272 1287 } 1273 - saa7115_info("saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name); 1288 + v4l_info(client, "saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name); 1274 1289 1275 1290 state = kmalloc(sizeof(struct saa7115_state), GFP_KERNEL); 1276 1291 i2c_set_clientdata(client, state); ··· 1282 1297 state->std = V4L2_STD_NTSC; 1283 1298 state->input = -1; 1284 1299 state->enable = 1; 1300 + state->radio = 0; 1285 1301 state->bright = 128; 1286 1302 state->contrast = 64; 1287 1303 state->hue = 0; 1288 1304 state->sat = 64; 1289 1305 state->ident = (chip_id == 4) ? V4L2_IDENT_SAA7114 : V4L2_IDENT_SAA7115; 1290 - state->audclk_freq = V4L2_AUDCLK_48_KHZ; 1306 + state->audclk_freq = 48000; 1291 1307 1292 - saa7115_dbg("writing init values\n"); 1308 + v4l_dbg(1, client, "writing init values\n"); 1293 1309 1294 1310 /* init to 60hz/48khz */ 1295 1311 saa7115_writeregs(client, saa7115_init_auto_input); ··· 1298 1312 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x); 1299 1313 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y); 1300 1314 saa7115_writeregs(client, saa7115_cfg_60hz_video); 1301 - saa7115_writeregs(client, saa7115_cfg_48_audio); 1302 - saa7115_writeregs(client, saa7115_cfg_60hz_48_audio); 1315 + saa7115_set_audio_clock_freq(client, state->audclk_freq); 1303 1316 saa7115_writeregs(client, saa7115_cfg_reset_scaler); 1304 1317 1305 1318 i2c_attach_client(client); 1306 1319 1307 - saa7115_dbg("status: (1E) 0x%02x, (1F) 0x%02x\n", 1320 + v4l_dbg(1, client, "status: (1E) 0x%02x, (1F) 0x%02x\n", 1308 1321 saa7115_read(client, 0x1e), saa7115_read(client, 0x1f)); 1309 1322 1310 1323 return 0; ··· 1311 1326 1312 1327 static int saa7115_probe(struct i2c_adapter *adapter) 1313 1328 { 1314 - #ifdef I2C_CLASS_TV_ANALOG 1315 1329 if (adapter->class & I2C_CLASS_TV_ANALOG) 1316 - #else 1317 - if (adapter->id == I2C_HW_B_BT848) 1318 - #endif 1319 1330 return i2c_probe(adapter, &addr_data, &saa7115_attach); 1320 1331 return 0; 1321 1332 }
-2
drivers/media/video/saa711x.c
··· 567 567 .driver = { 568 568 .name = "saa711x", 569 569 }, 570 - 571 570 .id = I2C_DRIVERID_SAA711X, 572 - 573 571 .attach_adapter = saa711x_attach_adapter, 574 572 .detach_client = saa711x_detach_client, 575 573 .command = saa711x_command,
+27 -55
drivers/media/video/saa7127.c
··· 66 66 MODULE_PARM_DESC(debug, "debug level (0-2)"); 67 67 MODULE_PARM_DESC(test_image, "test_image (0-1)"); 68 68 69 - #define saa7127_dbg(fmt, arg...) \ 70 - do { \ 71 - if (debug >= 1) \ 72 - printk(KERN_INFO "%s debug %d-%04x: " fmt, \ 73 - client->driver->driver.name, \ 74 - i2c_adapter_id(client->adapter), client->addr , ## arg); \ 75 - } while (0) 76 - 77 - /* High volume debug. Use with care. */ 78 - #define saa7127_dbg_highvol(fmt, arg...) \ 79 - do { \ 80 - if (debug == 2) \ 81 - printk(KERN_INFO "%s debug %d-%04x: " fmt, \ 82 - client->driver->driver.name, \ 83 - i2c_adapter_id(client->adapter), client->addr , ## arg); \ 84 - } while (0) 85 - 86 - #define saa7127_err(fmt, arg...) do { \ 87 - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ 88 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 89 - #define saa7127_info(fmt, arg...) do { \ 90 - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ 91 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 92 - 93 69 static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; 94 70 95 71 ··· 312 336 if (i2c_smbus_write_byte_data(client, reg, val) == 0) 313 337 return 0; 314 338 } 315 - saa7127_err("I2C Write Problem\n"); 339 + v4l_err(client, "I2C Write Problem\n"); 316 340 return -1; 317 341 } 318 342 ··· 338 362 if (enable && (data->field != 0 || data->line != 16)) 339 363 return -EINVAL; 340 364 if (state->vps_enable != enable) { 341 - saa7127_dbg("Turn VPS Signal %s\n", enable ? "on" : "off"); 365 + v4l_dbg(1, client, "Turn VPS Signal %s\n", enable ? "on" : "off"); 342 366 saa7127_write(client, 0x54, enable << 7); 343 367 state->vps_enable = enable; 344 368 } ··· 350 374 state->vps_data[2] = data->data[11]; 351 375 state->vps_data[3] = data->data[12]; 352 376 state->vps_data[4] = data->data[13]; 353 - saa7127_dbg("Set VPS data %02x %02x %02x %02x %02x\n", 377 + v4l_dbg(1, client, "Set VPS data %02x %02x %02x %02x %02x\n", 354 378 state->vps_data[0], state->vps_data[1], 355 379 state->vps_data[2], state->vps_data[3], 356 380 state->vps_data[4]); ··· 373 397 if (enable && (data->field != 0 || data->line != 21)) 374 398 return -EINVAL; 375 399 if (state->cc_enable != enable) { 376 - saa7127_dbg("Turn CC %s\n", enable ? "on" : "off"); 400 + v4l_dbg(1, client, "Turn CC %s\n", enable ? "on" : "off"); 377 401 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION, 378 402 (state->xds_enable << 7) | (enable << 6) | 0x11); 379 403 state->cc_enable = enable; ··· 381 405 if (!enable) 382 406 return 0; 383 407 384 - saa7127_dbg_highvol("CC data: %04x\n", cc); 408 + v4l_dbg(2, client, "CC data: %04x\n", cc); 385 409 saa7127_write(client, SAA7127_REG_LINE_21_ODD_0, cc & 0xff); 386 410 saa7127_write(client, SAA7127_REG_LINE_21_ODD_1, cc >> 8); 387 411 state->cc_data = cc; ··· 399 423 if (enable && (data->field != 1 || data->line != 21)) 400 424 return -EINVAL; 401 425 if (state->xds_enable != enable) { 402 - saa7127_dbg("Turn XDS %s\n", enable ? "on" : "off"); 426 + v4l_dbg(1, client, "Turn XDS %s\n", enable ? "on" : "off"); 403 427 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION, 404 428 (enable << 7) | (state->cc_enable << 6) | 0x11); 405 429 state->xds_enable = enable; ··· 407 431 if (!enable) 408 432 return 0; 409 433 410 - saa7127_dbg_highvol("XDS data: %04x\n", xds); 434 + v4l_dbg(2, client, "XDS data: %04x\n", xds); 411 435 saa7127_write(client, SAA7127_REG_LINE_21_EVEN_0, xds & 0xff); 412 436 saa7127_write(client, SAA7127_REG_LINE_21_EVEN_1, xds >> 8); 413 437 state->xds_data = xds; ··· 424 448 if (enable && (data->field != 0 || data->line != 23)) 425 449 return -EINVAL; 426 450 if (state->wss_enable != enable) { 427 - saa7127_dbg("Turn WSS %s\n", enable ? "on" : "off"); 451 + v4l_dbg(1, client, "Turn WSS %s\n", enable ? "on" : "off"); 428 452 saa7127_write(client, 0x27, enable << 7); 429 453 state->wss_enable = enable; 430 454 } ··· 433 457 434 458 saa7127_write(client, 0x26, data->data[0]); 435 459 saa7127_write(client, 0x27, 0x80 | (data->data[1] & 0x3f)); 436 - saa7127_dbg("WSS mode: %s\n", wss_strs[data->data[0] & 0xf]); 460 + v4l_dbg(1, client, "WSS mode: %s\n", wss_strs[data->data[0] & 0xf]); 437 461 state->wss_mode = (data->data[1] & 0x3f) << 8 | data->data[0]; 438 462 return 0; 439 463 } ··· 445 469 struct saa7127_state *state = i2c_get_clientdata(client); 446 470 447 471 if (enable) { 448 - saa7127_dbg("Enable Video Output\n"); 472 + v4l_dbg(1, client, "Enable Video Output\n"); 449 473 saa7127_write(client, 0x2d, state->reg_2d); 450 474 saa7127_write(client, 0x61, state->reg_61); 451 475 } else { 452 - saa7127_dbg("Disable Video Output\n"); 476 + v4l_dbg(1, client, "Disable Video Output\n"); 453 477 saa7127_write(client, 0x2d, (state->reg_2d & 0xf0)); 454 478 saa7127_write(client, 0x61, (state->reg_61 | 0xc0)); 455 479 } ··· 465 489 const struct i2c_reg_value *inittab; 466 490 467 491 if (std & V4L2_STD_525_60) { 468 - saa7127_dbg("Selecting 60 Hz video Standard\n"); 492 + v4l_dbg(1, client, "Selecting 60 Hz video Standard\n"); 469 493 inittab = saa7127_init_config_60hz; 470 494 state->reg_61 = SAA7127_60HZ_DAC_CONTROL; 471 495 } else { 472 - saa7127_dbg("Selecting 50 Hz video Standard\n"); 496 + v4l_dbg(1, client, "Selecting 50 Hz video Standard\n"); 473 497 inittab = saa7127_init_config_50hz; 474 498 state->reg_61 = SAA7127_50HZ_DAC_CONTROL; 475 499 } ··· 520 544 default: 521 545 return -EINVAL; 522 546 } 523 - saa7127_dbg("Selecting %s output type\n", output_strs[output]); 547 + v4l_dbg(1, client, "Selecting %s output type\n", output_strs[output]); 524 548 525 549 /* Configure Encoder */ 526 550 saa7127_write(client, 0x2d, state->reg_2d); ··· 537 561 538 562 switch (input) { 539 563 case SAA7127_INPUT_TYPE_NORMAL: /* avia */ 540 - saa7127_dbg("Selecting Normal Encoder Input\n"); 564 + v4l_dbg(1, client, "Selecting Normal Encoder Input\n"); 541 565 state->reg_3a_cb = 0; 542 566 break; 543 567 544 568 case SAA7127_INPUT_TYPE_TEST_IMAGE: /* color bar */ 545 - saa7127_dbg("Selecting Color Bar generator\n"); 569 + v4l_dbg(1, client, "Selecting Color Bar generator\n"); 546 570 state->reg_3a_cb = 0x80; 547 571 break; 548 572 ··· 609 633 break; 610 634 611 635 case VIDIOC_LOG_STATUS: 612 - saa7127_info("Standard: %s\n", (state->std & V4L2_STD_525_60) ? "60 Hz" : "50 Hz"); 613 - saa7127_info("Input: %s\n", state->input_type ? "color bars" : "normal"); 614 - saa7127_info("Output: %s\n", state->video_enable ? 636 + v4l_info(client, "Standard: %s\n", (state->std & V4L2_STD_525_60) ? "60 Hz" : "50 Hz"); 637 + v4l_info(client, "Input: %s\n", state->input_type ? "color bars" : "normal"); 638 + v4l_info(client, "Output: %s\n", state->video_enable ? 615 639 output_strs[state->output_type] : "disabled"); 616 - saa7127_info("WSS: %s\n", state->wss_enable ? 640 + v4l_info(client, "WSS: %s\n", state->wss_enable ? 617 641 wss_strs[state->wss_mode] : "disabled"); 618 - saa7127_info("VPS: %s\n", state->vps_enable ? "enabled" : "disabled"); 619 - saa7127_info("CC: %s\n", state->cc_enable ? "enabled" : "disabled"); 642 + v4l_info(client, "VPS: %s\n", state->vps_enable ? "enabled" : "disabled"); 643 + v4l_info(client, "CC: %s\n", state->cc_enable ? "enabled" : "disabled"); 620 644 break; 621 645 622 646 #ifdef CONFIG_VIDEO_ADV_DEBUG ··· 699 723 client->driver = &i2c_driver_saa7127; 700 724 snprintf(client->name, sizeof(client->name) - 1, "saa7127"); 701 725 702 - saa7127_dbg("detecting saa7127 client on address 0x%x\n", address << 1); 726 + v4l_dbg(1, client, "detecting saa7127 client on address 0x%x\n", address << 1); 703 727 704 728 /* First test register 0: Bits 5-7 are a version ID (should be 0), 705 729 and bit 2 should also be 0. ··· 708 732 0x1d after a reset and not expected to ever change. */ 709 733 if ((saa7127_read(client, 0) & 0xe4) != 0 || 710 734 (saa7127_read(client, 0x29) & 0x3f) != 0x1d) { 711 - saa7127_dbg("saa7127 not found\n"); 735 + v4l_dbg(1, client, "saa7127 not found\n"); 712 736 kfree(client); 713 737 return 0; 714 738 } ··· 724 748 725 749 /* Configure Encoder */ 726 750 727 - saa7127_dbg("Configuring encoder\n"); 751 + v4l_dbg(1, client, "Configuring encoder\n"); 728 752 saa7127_write_inittab(client, saa7127_init_config_common); 729 753 saa7127_set_std(client, V4L2_STD_NTSC); 730 754 saa7127_set_output_type(client, SAA7127_OUTPUT_TYPE_BOTH); ··· 745 769 read_result = saa7127_read(client, SAA7129_REG_FADE_KEY_COL2); 746 770 saa7127_write(client, SAA7129_REG_FADE_KEY_COL2, 0xaa); 747 771 if (saa7127_read(client, SAA7129_REG_FADE_KEY_COL2) == 0xaa) { 748 - saa7127_info("saa7129 found @ 0x%x (%s)\n", address << 1, adapter->name); 772 + v4l_info(client, "saa7129 found @ 0x%x (%s)\n", address << 1, adapter->name); 749 773 saa7127_write(client, SAA7129_REG_FADE_KEY_COL2, read_result); 750 774 saa7127_write_inittab(client, saa7129_init_config_extra); 751 775 state->ident = V4L2_IDENT_SAA7129; 752 776 } else { 753 - saa7127_info("saa7127 found @ 0x%x (%s)\n", address << 1, adapter->name); 777 + v4l_info(client, "saa7127 found @ 0x%x (%s)\n", address << 1, adapter->name); 754 778 state->ident = V4L2_IDENT_SAA7127; 755 779 } 756 780 ··· 763 787 764 788 static int saa7127_probe(struct i2c_adapter *adapter) 765 789 { 766 - #ifdef I2C_CLASS_TV_ANALOG 767 790 if (adapter->class & I2C_CLASS_TV_ANALOG) 768 - #else 769 - if (adapter->id == I2C_HW_B_BT848) 770 - #endif 771 791 return i2c_probe(adapter, &addr_data, saa7127_attach); 772 792 return 0; 773 793 }
+5 -3
drivers/media/video/saa7134/saa6752hs.c
··· 9 9 #include <linux/poll.h> 10 10 #include <linux/i2c.h> 11 11 #include <linux/types.h> 12 - #include <linux/videodev.h> 12 + #include <linux/videodev2.h> 13 + #include <media/v4l2-common.h> 13 14 #include <linux/init.h> 14 15 #include <linux/crc32.h> 15 16 ··· 510 509 { 511 510 struct saa6752hs_state *h; 512 511 513 - printk("saa6752hs: chip found @ 0x%x\n", addr<<1); 514 512 515 513 if (NULL == (h = kmalloc(sizeof(*h), GFP_KERNEL))) 516 514 return -ENOMEM; ··· 524 524 525 525 i2c_set_clientdata(&h->client, h); 526 526 i2c_attach_client(&h->client); 527 + 528 + v4l_info(&h->client,"saa6752hs: chip found @ 0x%x\n", addr<<1); 527 529 528 530 return 0; 529 531 } ··· 600 598 601 599 static struct i2c_driver driver = { 602 600 .driver = { 603 - .name = "i2c saa6752hs MPEG encoder", 601 + .name = "saa6752hs", 604 602 }, 605 603 .id = I2C_DRIVERID_SAA6752HS, 606 604 .attach_adapter = saa6752hs_probe,
+1 -1
drivers/media/video/saa7134/saa7134-alsa.c
··· 20 20 * 21 21 */ 22 22 23 - #include <sound/driver.h> 24 23 #include <linux/init.h> 25 24 #include <linux/slab.h> 26 25 #include <linux/time.h> 27 26 #include <linux/wait.h> 28 27 #include <linux/moduleparam.h> 29 28 #include <linux/module.h> 29 + #include <sound/driver.h> 30 30 #include <sound/core.h> 31 31 #include <sound/control.h> 32 32 #include <sound/pcm.h>
+83
drivers/media/video/saa7134/saa7134-cards.c
··· 25 25 26 26 #include "saa7134-reg.h" 27 27 #include "saa7134.h" 28 + #include <media/v4l2-common.h> 28 29 29 30 /* commly used strings */ 30 31 static char name_mute[] = "mute"; ··· 2556 2555 .amux = LINE1, 2557 2556 }, 2558 2557 }, 2558 + [SAA7134_BOARD_CINERGY250PCI] = { 2559 + /* remote-control does not work. The signal about a 2560 + key press comes in via gpio, but the key code 2561 + doesn't. Neither does it have an i2c remote control 2562 + interface. */ 2563 + .name = "Terratec Cinergy 250 PCI TV", 2564 + .audio_clock = 0x00187de7, 2565 + .tuner_type = TUNER_PHILIPS_TDA8290, 2566 + .radio_type = UNSET, 2567 + .tuner_addr = ADDR_UNSET, 2568 + .radio_addr = ADDR_UNSET, 2569 + .gpiomask = 0x80200000, 2570 + .inputs = {{ 2571 + .name = name_tv, 2572 + .vmux = 1, 2573 + .amux = TV, 2574 + .tv = 1, 2575 + },{ 2576 + .name = name_svideo, /* NOT tested */ 2577 + .vmux = 8, 2578 + .amux = LINE1, 2579 + }}, 2580 + .radio = { 2581 + .name = name_radio, 2582 + .amux = LINE1, 2583 + .gpio = 0x0200000, 2584 + }, 2585 + }, 2586 + [SAA7134_BOARD_FLYDVB_TRIO] = { 2587 + /* LifeView LR319 FlyDVB Trio */ 2588 + /* Peter Missel <peter.missel@onlinehome.de> */ 2589 + .name = "LifeView FlyDVB Trio", 2590 + .audio_clock = 0x00200000, 2591 + .tuner_type = TUNER_PHILIPS_TDA8290, 2592 + .radio_type = UNSET, 2593 + .tuner_addr = ADDR_UNSET, 2594 + .radio_addr = ADDR_UNSET, 2595 + .gpiomask = 0x00200000, 2596 + .inputs = {{ 2597 + .name = name_tv, /* Analog broadcast/cable TV */ 2598 + .vmux = 1, 2599 + .amux = TV, 2600 + .gpio = 0x200000, /* GPIO21=High for TV input */ 2601 + .tv = 1, 2602 + },{ 2603 + .name = name_svideo, /* S-Video signal on S-Video input */ 2604 + .vmux = 8, 2605 + .amux = LINE2, 2606 + },{ 2607 + .name = name_comp1, /* Composite signal on S-Video input */ 2608 + .vmux = 0, 2609 + .amux = LINE2, 2610 + },{ 2611 + .name = name_comp2, /* Composite input */ 2612 + .vmux = 3, 2613 + .amux = LINE2, 2614 + }}, 2615 + .radio = { 2616 + .name = name_radio, 2617 + .amux = TV, 2618 + .gpio = 0x000000, /* GPIO21=Low for FM radio antenna */ 2619 + }, 2620 + }, 2559 2621 }; 2560 2622 2561 2623 const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); ··· 2959 2895 .vendor = PCI_VENDOR_ID_PHILIPS, 2960 2896 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2961 2897 .subvendor = 0x1421, 2898 + .subdevice = 0x0351, /* PCI version, new revision */ 2899 + .driver_data = SAA7134_BOARD_ADS_INSTANT_TV, 2900 + },{ 2901 + .vendor = PCI_VENDOR_ID_PHILIPS, 2902 + .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2903 + .subvendor = 0x1421, 2962 2904 .subdevice = 0x0370, /* cardbus version */ 2963 2905 .driver_data = SAA7134_BOARD_ADS_INSTANT_TV, 2964 2906 },{ ··· 3072 3002 .subdevice = 0x6231, 3073 3003 .driver_data = SAA7134_BOARD_MSI_TVATANYWHERE_PLUS, 3074 3004 },{ 3005 + .vendor = PCI_VENDOR_ID_PHILIPS, 3006 + .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 3007 + .subvendor = 0x153b, 3008 + .subdevice = 0x1160, 3009 + .driver_data = SAA7134_BOARD_CINERGY250PCI, 3010 + },{ 3011 + .vendor = PCI_VENDOR_ID_PHILIPS, 3012 + .device = PCI_DEVICE_ID_PHILIPS_SAA7133, /* SAA 7131E */ 3013 + .subvendor = 0x5168, 3014 + .subdevice = 0x0319, 3015 + .driver_data = SAA7134_BOARD_FLYDVB_TRIO, 3016 + },{ 3075 3017 /* --- boards without eeprom + subsystem ID --- */ 3076 3018 .vendor = PCI_VENDOR_ID_PHILIPS, 3077 3019 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, ··· 3172 3090 case SAA7134_BOARD_AVERMEDIA_GO_007_FM: 3173 3091 /* case SAA7134_BOARD_SABRENT_SBTTVFM: */ /* not finished yet */ 3174 3092 case SAA7134_BOARD_VIDEOMATE_TV_PVR: 3093 + case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: 3175 3094 case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII: 3176 3095 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 3177 3096 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
+50 -88
drivers/media/video/saa7134/saa7134-core.c
··· 95 95 #define dprintk(fmt, arg...) if (core_debug) \ 96 96 printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg) 97 97 98 - /* ------------------------------------------------------------------ */ 99 - /* debug help functions */ 100 - 101 - static const char *v4l1_ioctls[] = { 102 - "0", "GCAP", "GCHAN", "SCHAN", "GTUNER", "STUNER", "GPICT", "SPICT", 103 - "CCAPTURE", "GWIN", "SWIN", "GFBUF", "SFBUF", "KEY", "GFREQ", 104 - "SFREQ", "GAUDIO", "SAUDIO", "SYNC", "MCAPTURE", "GMBUF", "GUNIT", 105 - "GCAPTURE", "SCAPTURE", "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", 106 - "SMICROCODE", "GVBIFMT", "SVBIFMT" }; 107 - #define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls) 108 - 109 - static const char *v4l2_ioctls[] = { 110 - "QUERYCAP", "1", "ENUM_PIXFMT", "ENUM_FBUFFMT", "G_FMT", "S_FMT", 111 - "G_COMP", "S_COMP", "REQBUFS", "QUERYBUF", "G_FBUF", "S_FBUF", 112 - "G_WIN", "S_WIN", "PREVIEW", "QBUF", "16", "DQBUF", "STREAMON", 113 - "STREAMOFF", "G_PERF", "G_PARM", "S_PARM", "G_STD", "S_STD", 114 - "ENUMSTD", "ENUMINPUT", "G_CTRL", "S_CTRL", "G_TUNER", "S_TUNER", 115 - "G_FREQ", "S_FREQ", "G_AUDIO", "S_AUDIO", "35", "QUERYCTRL", 116 - "QUERYMENU", "G_INPUT", "S_INPUT", "ENUMCVT", "41", "42", "43", 117 - "44", "45", "G_OUTPUT", "S_OUTPUT", "ENUMOUTPUT", "G_AUDOUT", 118 - "S_AUDOUT", "ENUMFX", "G_EFFECT", "S_EFFECT", "G_MODULATOR", 119 - "S_MODULATOR" 120 - }; 121 - #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) 122 - 123 - static const char *osspcm_ioctls[] = { 124 - "RESET", "SYNC", "SPEED", "STEREO", "GETBLKSIZE", "SETFMT", 125 - "CHANNELS", "?", "POST", "SUBDIVIDE", "SETFRAGMENT", "GETFMTS", 126 - "GETOSPACE", "GETISPACE", "NONBLOCK", "GETCAPS", "GET/SETTRIGGER", 127 - "GETIPTR", "GETOPTR", "MAPINBUF", "MAPOUTBUF", "SETSYNCRO", 128 - "SETDUPLEX", "GETODELAY" 129 - }; 130 - #define OSSPCM_IOCTLS ARRAY_SIZE(v4l2_ioctls) 131 - 132 - void saa7134_print_ioctl(char *name, unsigned int cmd) 133 - { 134 - char *dir; 135 - 136 - switch (_IOC_DIR(cmd)) { 137 - case _IOC_NONE: dir = "--"; break; 138 - case _IOC_READ: dir = "r-"; break; 139 - case _IOC_WRITE: dir = "-w"; break; 140 - case _IOC_READ | _IOC_WRITE: dir = "rw"; break; 141 - default: dir = "??"; break; 142 - } 143 - switch (_IOC_TYPE(cmd)) { 144 - case 'v': 145 - printk(KERN_DEBUG "%s: ioctl 0x%08x (v4l1, %s, VIDIOC%s)\n", 146 - name, cmd, dir, (_IOC_NR(cmd) < V4L1_IOCTLS) ? 147 - v4l1_ioctls[_IOC_NR(cmd)] : "???"); 148 - break; 149 - case 'V': 150 - printk(KERN_DEBUG "%s: ioctl 0x%08x (v4l2, %s, VIDIOC_%s)\n", 151 - name, cmd, dir, (_IOC_NR(cmd) < V4L2_IOCTLS) ? 152 - v4l2_ioctls[_IOC_NR(cmd)] : "???"); 153 - break; 154 - case 'P': 155 - printk(KERN_DEBUG "%s: ioctl 0x%08x (oss dsp, %s, SNDCTL_DSP_%s)\n", 156 - name, cmd, dir, (_IOC_NR(cmd) < OSSPCM_IOCTLS) ? 157 - osspcm_ioctls[_IOC_NR(cmd)] : "???"); 158 - break; 159 - case 'M': 160 - printk(KERN_DEBUG "%s: ioctl 0x%08x (oss mixer, %s, #%d)\n", 161 - name, cmd, dir, _IOC_NR(cmd)); 162 - break; 163 - default: 164 - printk(KERN_DEBUG "%s: ioctl 0x%08x (???, %s, #%d)\n", 165 - name, cmd, dir, _IOC_NR(cmd)); 166 - } 167 - } 168 - 169 98 void saa7134_track_gpio(struct saa7134_dev *dev, char *msg) 170 99 { 171 100 unsigned long mode,status; ··· 140 211 return NOTIFY_DONE; 141 212 } 142 213 143 - static int pending_registered; 214 + static int pending_registered=0; 144 215 static struct notifier_block pending_notifier = { 145 216 .notifier_call = pending_call, 146 217 }; ··· 539 610 card_has_mpeg(dev)) 540 611 saa7134_irq_ts_done(dev,status); 541 612 542 - if ((report & (SAA7134_IRQ_REPORT_GPIO16 | 543 - SAA7134_IRQ_REPORT_GPIO18)) && 544 - dev->remote) 545 - saa7134_input_irq(dev); 613 + if (report & SAA7134_IRQ_REPORT_GPIO16) { 614 + switch (dev->has_remote) { 615 + case SAA7134_REMOTE_GPIO: 616 + if (dev->remote->mask_keydown & 0x10000) { 617 + saa7134_input_irq(dev); 618 + } 619 + break; 546 620 621 + case SAA7134_REMOTE_I2C: 622 + break; /* FIXME: invoke I2C get_key() */ 623 + 624 + default: /* GPIO16 not used by IR remote */ 625 + break; 626 + } 627 + } 628 + 629 + if (report & SAA7134_IRQ_REPORT_GPIO18) { 630 + switch (dev->has_remote) { 631 + case SAA7134_REMOTE_GPIO: 632 + if ((dev->remote->mask_keydown & 0x40000) || 633 + (dev->remote->mask_keyup & 0x40000)) { 634 + saa7134_input_irq(dev); 635 + } 636 + break; 637 + 638 + case SAA7134_REMOTE_I2C: 639 + break; /* FIXME: invoke I2C get_key() */ 640 + 641 + default: /* GPIO18 not used by IR remote */ 642 + break; 643 + } 644 + } 547 645 } 548 646 549 647 if (10 == loop) { ··· 580 624 printk(KERN_WARNING "%s/irq: looping -- " 581 625 "clearing PE (parity error!) enable bit\n",dev->name); 582 626 saa_clearl(SAA7134_IRQ2,SAA7134_IRQ2_INTE_PE); 583 - } else if (report & (SAA7134_IRQ_REPORT_GPIO16 | 584 - SAA7134_IRQ_REPORT_GPIO18)) { 585 - /* disable gpio IRQs */ 627 + } else if (report & SAA7134_IRQ_REPORT_GPIO16) { 628 + /* disable gpio16 IRQ */ 586 629 printk(KERN_WARNING "%s/irq: looping -- " 587 - "clearing GPIO enable bits\n",dev->name); 588 - saa_clearl(SAA7134_IRQ2, (SAA7134_IRQ2_INTE_GPIO16 | 589 - SAA7134_IRQ2_INTE_GPIO18)); 630 + "clearing GPIO16 enable bit\n",dev->name); 631 + saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO16); 632 + } else if (report & SAA7134_IRQ_REPORT_GPIO18) { 633 + /* disable gpio18 IRQs */ 634 + printk(KERN_WARNING "%s/irq: looping -- " 635 + "clearing GPIO18 enable bit\n",dev->name); 636 + saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18); 590 637 } else { 591 638 /* disable all irqs */ 592 639 printk(KERN_WARNING "%s/irq: looping -- " ··· 670 711 SAA7134_IRQ2_INTE_PE | 671 712 SAA7134_IRQ2_INTE_AR; 672 713 673 - if (dev->has_remote == SAA7134_REMOTE_GPIO) 674 - irq2_mask |= (SAA7134_IRQ2_INTE_GPIO18 | 675 - SAA7134_IRQ2_INTE_GPIO18A | 676 - SAA7134_IRQ2_INTE_GPIO16 ); 714 + if (dev->has_remote == SAA7134_REMOTE_GPIO) { 715 + if (dev->remote->mask_keydown & 0x10000) 716 + irq2_mask |= SAA7134_IRQ2_INTE_GPIO16; 717 + else if (dev->remote->mask_keydown & 0x40000) 718 + irq2_mask |= SAA7134_IRQ2_INTE_GPIO18; 719 + else if (dev->remote->mask_keyup & 0x40000) 720 + irq2_mask |= SAA7134_IRQ2_INTE_GPIO18A; 721 + } 677 722 678 723 saa_writel(SAA7134_IRQ1, 0); 679 724 saa_writel(SAA7134_IRQ2, irq2_mask); ··· 1119 1156 printk(KERN_INFO "saa7130/34: snapshot date %04d-%02d-%02d\n", 1120 1157 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100); 1121 1158 #endif 1122 - return pci_module_init(&saa7134_pci_driver); 1159 + return pci_register_driver(&saa7134_pci_driver); 1123 1160 } 1124 1161 1125 1162 static void saa7134_fini(void) ··· 1136 1173 1137 1174 /* ----------------------------------------------------------- */ 1138 1175 1139 - EXPORT_SYMBOL(saa7134_print_ioctl); 1140 1176 EXPORT_SYMBOL(saa7134_i2c_call_clients); 1141 1177 EXPORT_SYMBOL(saa7134_devlist); 1142 1178 EXPORT_SYMBOL(saa7134_boards);
+1
drivers/media/video/saa7134/saa7134-dvb.c
··· 31 31 32 32 #include "saa7134-reg.h" 33 33 #include "saa7134.h" 34 + #include <media/v4l2-common.h> 34 35 35 36 #ifdef HAVE_MT352 36 37 # include "mt352.h"
+2 -1
drivers/media/video/saa7134/saa7134-empress.c
··· 29 29 #include "saa7134.h" 30 30 31 31 #include <media/saa6752hs.h> 32 + #include <media/v4l2-common.h> 32 33 33 34 /* ------------------------------------------------------------------ */ 34 35 ··· 164 163 struct saa7134_dev *dev = file->private_data; 165 164 166 165 if (debug > 1) 167 - saa7134_print_ioctl(dev->name,cmd); 166 + v4l_print_ioctl(dev->name,cmd); 168 167 switch (cmd) { 169 168 case VIDIOC_QUERYCAP: 170 169 {
+1 -2
drivers/media/video/saa7134/saa7134-i2c.c
··· 30 30 31 31 #include "saa7134-reg.h" 32 32 #include "saa7134.h" 33 + #include <media/v4l2-common.h> 33 34 34 35 /* ----------------------------------------------------------- */ 35 36 ··· 391 390 392 391 static struct i2c_adapter saa7134_adap_template = { 393 392 .owner = THIS_MODULE, 394 - #ifdef I2C_CLASS_TV_ANALOG 395 393 .class = I2C_CLASS_TV_ANALOG, 396 - #endif 397 394 .name = "saa7134", 398 395 .id = I2C_HW_SAA7134, 399 396 .algo = &saa7134_algo,
+25 -14
drivers/media/video/saa7134/saa7134-input.c
··· 56 56 [ 12 ] = KEY_KP8, 57 57 [ 13 ] = KEY_KP9, 58 58 59 - [ 14 ] = KEY_TUNER, // Air/Cable 59 + [ 14 ] = KEY_MODE, // Air/Cable 60 60 [ 17 ] = KEY_VIDEO, // Video 61 61 [ 21 ] = KEY_AUDIO, // Audio 62 - [ 0 ] = KEY_POWER, // Pover 62 + [ 0 ] = KEY_POWER, // Power 63 + [ 24 ] = KEY_TUNER, // AV Source 63 64 [ 2 ] = KEY_ZOOM, // Fullscreen 65 + [ 26 ] = KEY_LANGUAGE, // Stereo 64 66 [ 27 ] = KEY_MUTE, // Mute 65 - [ 20 ] = KEY_VOLUMEUP, 66 - [ 23 ] = KEY_VOLUMEDOWN, 67 + [ 20 ] = KEY_VOLUMEUP, // Volume + 68 + [ 23 ] = KEY_VOLUMEDOWN, // Volume - 67 69 [ 18 ] = KEY_CHANNELUP, // Channel + 68 70 [ 19 ] = KEY_CHANNELDOWN, // Channel - 69 - [ 6 ] = KEY_AGAIN, // Recal 70 - [ 16 ] = KEY_KPENTER, // Enter 71 - 72 - [ 26 ] = KEY_F22, // Stereo 73 - [ 24 ] = KEY_EDIT, // AV Source 71 + [ 6 ] = KEY_AGAIN, // Recall 72 + [ 16 ] = KEY_ENTER, // Enter 74 73 }; 74 + 75 75 76 76 static IR_KEYTAB_TYPE cinergy_codes[IR_KEYTAB_SIZE] = { 77 77 [ 0 ] = KEY_KP0, ··· 543 543 dprintk("build_key gpio=0x%x mask=0x%x data=%d\n", 544 544 gpio, ir->mask_keycode, data); 545 545 546 - if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 547 - (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 548 - ir_input_keydown(ir->dev, &ir->ir, data, data); 549 - } else { 550 - ir_input_nokey(ir->dev, &ir->ir); 546 + if (ir->polling) { 547 + if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 548 + (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 549 + ir_input_keydown(ir->dev, &ir->ir, data, data); 550 + } else { 551 + ir_input_nokey(ir->dev, &ir->ir); 552 + } 551 553 } 554 + else { /* IRQ driven mode - handle key press and release in one go */ 555 + if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 556 + (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 557 + ir_input_keydown(ir->dev, &ir->ir, data, data); 558 + ir_input_nokey(ir->dev, &ir->ir); 559 + } 560 + } 561 + 552 562 return 0; 553 563 } 554 564 ··· 696 686 polling = 50; // ms 697 687 break; 698 688 case SAA7134_BOARD_VIDEOMATE_TV_PVR: 689 + case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: 699 690 case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII: 700 691 ir_codes = videomate_tv_pvr_codes; 701 692 mask_keycode = 0x00003F;
+38 -2
drivers/media/video/saa7134/saa7134-oss.c
··· 373 373 return -EINVAL; 374 374 } 375 375 376 + static const char *osspcm_ioctls[] = { 377 + "RESET", "SYNC", "SPEED", "STEREO", "GETBLKSIZE", "SETFMT", 378 + "CHANNELS", "?", "POST", "SUBDIVIDE", "SETFRAGMENT", "GETFMTS", 379 + "GETOSPACE", "GETISPACE", "NONBLOCK", "GETCAPS", "GET/SETTRIGGER", 380 + "GETIPTR", "GETOPTR", "MAPINBUF", "MAPOUTBUF", "SETSYNCRO", 381 + "SETDUPLEX", "GETODELAY" 382 + }; 383 + #define OSSPCM_IOCTLS ARRAY_SIZE(osspcm_ioctls) 384 + 385 + static void saa7134_oss_print_ioctl(char *name, unsigned int cmd) 386 + { 387 + char *dir; 388 + 389 + switch (_IOC_DIR(cmd)) { 390 + case _IOC_NONE: dir = "--"; break; 391 + case _IOC_READ: dir = "r-"; break; 392 + case _IOC_WRITE: dir = "-w"; break; 393 + case _IOC_READ | _IOC_WRITE: dir = "rw"; break; 394 + default: dir = "??"; break; 395 + } 396 + switch (_IOC_TYPE(cmd)) { 397 + case 'P': 398 + printk(KERN_DEBUG "%s: ioctl 0x%08x (oss dsp, %s, SNDCTL_DSP_%s)\n", 399 + name, cmd, dir, (_IOC_NR(cmd) < OSSPCM_IOCTLS) ? 400 + osspcm_ioctls[_IOC_NR(cmd)] : "???"); 401 + break; 402 + case 'M': 403 + printk(KERN_DEBUG "%s: ioctl 0x%08x (oss mixer, %s, #%d)\n", 404 + name, cmd, dir, _IOC_NR(cmd)); 405 + break; 406 + default: 407 + printk(KERN_DEBUG "%s: ioctl 0x%08x (???, %s, #%d)\n", 408 + name, cmd, dir, _IOC_NR(cmd)); 409 + } 410 + } 411 + 376 412 static int dsp_ioctl(struct inode *inode, struct file *file, 377 413 unsigned int cmd, unsigned long arg) 378 414 { ··· 418 382 int val = 0; 419 383 420 384 if (debug > 1) 421 - saa7134_print_ioctl(dev->name,cmd); 385 + saa7134_oss_print_ioctl(dev->name,cmd); 422 386 switch (cmd) { 423 387 case OSS_GETVERSION: 424 388 return put_user(SOUND_VERSION, p); ··· 714 678 int __user *p = argp; 715 679 716 680 if (debug > 1) 717 - saa7134_print_ioctl(dev->name,cmd); 681 + saa7134_oss_print_ioctl(dev->name,cmd); 718 682 switch (cmd) { 719 683 case OSS_GETVERSION: 720 684 return put_user(SOUND_VERSION, p);
+5 -2
drivers/media/video/saa7134/saa7134-video.c
··· 29 29 30 30 #include "saa7134-reg.h" 31 31 #include "saa7134.h" 32 + #include <media/v4l2-common.h> 32 33 33 34 /* Include V4L1 specific functions. Should be removed soon */ 34 35 #include <linux/videodev.h> ··· 1690 1689 int err; 1691 1690 1692 1691 if (video_debug > 1) 1693 - saa7134_print_ioctl(dev->name,cmd); 1692 + v4l_print_ioctl(dev->name,cmd); 1694 1693 1695 1694 switch (cmd) { 1696 1695 case VIDIOC_S_CTRL: ··· 2143 2142 struct saa7134_dev *dev = fh->dev; 2144 2143 2145 2144 if (video_debug > 1) 2146 - saa7134_print_ioctl(dev->name,cmd); 2145 + v4l_print_ioctl(dev->name,cmd); 2147 2146 switch (cmd) { 2148 2147 case VIDIOC_QUERYCAP: 2149 2148 { ··· 2263 2262 .poll = video_poll, 2264 2263 .mmap = video_mmap, 2265 2264 .ioctl = video_ioctl, 2265 + .compat_ioctl = v4l_compat_ioctl32, 2266 2266 .llseek = no_llseek, 2267 2267 }; 2268 2268 ··· 2273 2271 .open = video_open, 2274 2272 .release = video_release, 2275 2273 .ioctl = radio_ioctl, 2274 + .compat_ioctl = v4l_compat_ioctl32, 2276 2275 .llseek = no_llseek, 2277 2276 }; 2278 2277
+5 -5
drivers/media/video/saa7134/saa7134.h
··· 37 37 #include <media/ir-common.h> 38 38 #include <media/ir-kbd-i2c.h> 39 39 #include <media/video-buf.h> 40 + #include <sound/driver.h> 41 + #include <sound/core.h> 42 + #include <sound/pcm.h> 40 43 #include <media/video-buf-dvb.h> 41 44 42 45 #ifndef TRUE ··· 49 46 # define FALSE (1==0) 50 47 #endif 51 48 #define UNSET (-1U) 52 - 53 - #include <sound/driver.h> 54 - #include <sound/core.h> 55 - #include <sound/pcm.h> 56 49 57 50 /* ----------------------------------------------------------- */ 58 51 /* enums */ ··· 208 209 #define SAA7134_BOARD_ASUSTEK_DIGIMATRIX_TV 80 209 210 #define SAA7134_BOARD_PHILIPS_TIGER 81 210 211 #define SAA7134_BOARD_MSI_TVATANYWHERE_PLUS 82 212 + #define SAA7134_BOARD_CINERGY250PCI 83 213 + #define SAA7134_BOARD_FLYDVB_TRIO 84 211 214 212 215 #define SAA7134_MAXBOARDS 8 213 216 #define SAA7134_INPUT_MAX 8 ··· 547 546 548 547 extern struct list_head saa7134_devlist; 549 548 550 - void saa7134_print_ioctl(char *name, unsigned int cmd); 551 549 void saa7134_track_gpio(struct saa7134_dev *dev, char *msg); 552 550 553 551 #define SAA7134_PGTABLE_SIZE 4096
+1
drivers/media/video/stradis.c
··· 1974 1974 .open = saa_open, 1975 1975 .release = saa_release, 1976 1976 .ioctl = saa_ioctl, 1977 + .compat_ioctl = v4l_compat_ioctl32, 1977 1978 .read = saa_read, 1978 1979 .llseek = no_llseek, 1979 1980 .write = saa_write,
+15 -28
drivers/media/video/tda7432.c
··· 50 50 51 51 #include "bttv.h" 52 52 #include <media/audiochip.h> 53 + #include <media/v4l2-common.h> 53 54 54 55 #ifndef VIDEO_AUDIO_BALANCE 55 56 # define VIDEO_AUDIO_BALANCE 32 ··· 90 89 }; 91 90 static struct i2c_driver driver; 92 91 static struct i2c_client client_template; 93 - 94 - #define dprintk if (debug) printk 95 - #define d2printk if (debug > 1) printk 96 92 97 93 /* The TDA7432 is made by STS-Thompson 98 94 * http://www.st.com ··· 227 229 static int tda7432_write(struct i2c_client *client, int subaddr, int val) 228 230 { 229 231 unsigned char buffer[2]; 230 - d2printk("tda7432: In tda7432_write\n"); 231 - dprintk("tda7432: Writing %d 0x%x\n", subaddr, val); 232 + v4l_dbg(2,client,"In tda7432_write\n"); 233 + v4l_dbg(1,client,"Writing %d 0x%x\n", subaddr, val); 232 234 buffer[0] = subaddr; 233 235 buffer[1] = val; 234 236 if (2 != i2c_master_send(client,buffer,2)) { 235 - printk(KERN_WARNING "tda7432: I/O error, trying (write %d 0x%x)\n", 237 + v4l_err(client,"I/O error, trying (write %d 0x%x)\n", 236 238 subaddr, val); 237 239 return -1; 238 240 } ··· 245 247 { 246 248 struct tda7432 *t = i2c_get_clientdata(client); 247 249 unsigned char buf[16]; 248 - d2printk("tda7432: In tda7432_set\n"); 250 + v4l_dbg(2,client,"In tda7432_set\n"); 249 251 250 - dprintk(KERN_INFO 252 + v4l_dbg(1,client, 251 253 "tda7432: 7432_set(0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)\n", 252 254 t->input,t->volume,t->bass,t->treble,t->lf,t->lr,t->rf,t->rr,t->loud); 253 255 buf[0] = TDA7432_IN; ··· 261 263 buf[8] = t->rr; 262 264 buf[9] = t->loud; 263 265 if (10 != i2c_master_send(client,buf,10)) { 264 - printk(KERN_WARNING "tda7432: I/O error, trying tda7432_set\n"); 266 + v4l_err(client,"I/O error, trying tda7432_set\n"); 265 267 return -1; 266 268 } 267 269 ··· 271 273 static void do_tda7432_init(struct i2c_client *client) 272 274 { 273 275 struct tda7432 *t = i2c_get_clientdata(client); 274 - d2printk("tda7432: In tda7432_init\n"); 276 + v4l_dbg(2,client,"In tda7432_init\n"); 275 277 276 278 t->input = TDA7432_STEREO_IN | /* Main (stereo) input */ 277 279 TDA7432_BASS_SYM | /* Symmetric bass cut */ ··· 299 301 { 300 302 struct tda7432 *t; 301 303 struct i2c_client *client; 302 - d2printk("tda7432: In tda7432_attach\n"); 303 304 304 305 t = kmalloc(sizeof *t,GFP_KERNEL); 305 306 if (!t) ··· 312 315 i2c_set_clientdata(client, t); 313 316 314 317 do_tda7432_init(client); 315 - printk(KERN_INFO "tda7432: init\n"); 316 - 317 318 i2c_attach_client(client); 319 + 320 + v4l_info(client, "chip found @ 0x%x (%s)\n", addr << 1, adap->name); 318 321 return 0; 319 322 } 320 323 321 324 static int tda7432_probe(struct i2c_adapter *adap) 322 325 { 323 - #ifdef I2C_CLASS_TV_ANALOG 324 326 if (adap->class & I2C_CLASS_TV_ANALOG) 325 327 return i2c_probe(adap, &addr_data, tda7432_attach); 326 - #else 327 - if (adap->id == I2C_HW_B_BT848) 328 - return i2c_probe(adap, &addr_data, tda7432_attach); 329 - #endif 330 328 return 0; 331 329 } 332 330 ··· 340 348 unsigned int cmd, void *arg) 341 349 { 342 350 struct tda7432 *t = i2c_get_clientdata(client); 343 - d2printk("tda7432: In tda7432_command\n"); 351 + v4l_dbg(2,client,"In tda7432_command\n"); 352 + if (debug>1) 353 + v4l_i2c_print_ioctl(client,cmd); 344 354 345 355 switch (cmd) { 346 356 /* --- v4l ioctls --- */ ··· 353 359 case VIDIOCGAUDIO: 354 360 { 355 361 struct video_audio *va = arg; 356 - dprintk("tda7432: VIDIOCGAUDIO\n"); 357 362 358 363 va->flags |= VIDEO_AUDIO_VOLUME | 359 364 VIDEO_AUDIO_BASS | ··· 407 414 case VIDIOCSAUDIO: 408 415 { 409 416 struct video_audio *va = arg; 410 - dprintk("tda7432: VIDEOCSAUDIO\n"); 411 417 412 418 if(va->flags & VIDEO_AUDIO_VOLUME){ 413 419 if(!maxvol){ /* max +20db */ ··· 482 490 483 491 } /* end of VIDEOCSAUDIO case */ 484 492 485 - default: /* Not VIDEOCGAUDIO or VIDEOCSAUDIO */ 486 - 487 - /* nothing */ 488 - d2printk("tda7432: Default\n"); 489 - 490 493 } /* end of (cmd) switch */ 491 494 492 495 return 0; ··· 489 502 490 503 static struct i2c_driver driver = { 491 504 .driver = { 492 - .name = "i2c tda7432 driver", 505 + .name = "tda7432", 493 506 }, 494 507 .id = I2C_DRIVERID_TDA7432, 495 508 .attach_adapter = tda7432_probe, ··· 506 519 static int __init tda7432_init(void) 507 520 { 508 521 if ( (loudness < 0) || (loudness > 15) ) { 509 - printk(KERN_ERR "tda7432: loudness parameter must be between 0 and 15\n"); 522 + printk(KERN_ERR "loudness parameter must be between 0 and 15\n"); 510 523 return -EINVAL; 511 524 } 512 525
-6
drivers/media/video/tda8290.c
··· 398 398 return 0; 399 399 } 400 400 401 - 402 401 /*---------------------------------------------------------------------*/ 403 - 404 - #define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC) 405 - #define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B) 406 - #define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H) 407 - #define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK) 408 402 409 403 static void set_audio(struct tuner *t) 410 404 {
+1 -6
drivers/media/video/tda9875.c
··· 257 257 258 258 static int tda9875_probe(struct i2c_adapter *adap) 259 259 { 260 - #ifdef I2C_CLASS_TV_ANALOG 261 260 if (adap->class & I2C_CLASS_TV_ANALOG) 262 261 return i2c_probe(adap, &addr_data, tda9875_attach); 263 - #else 264 - if (adap->id == I2C_HW_B_BT848) 265 - return i2c_probe(adap, &addr_data, tda9875_attach); 266 - #endif 267 262 return 0; 268 263 } 269 264 ··· 368 373 369 374 static struct i2c_driver driver = { 370 375 .driver = { 371 - .name = "i2c tda9875 driver", 376 + .name = "tda9875", 372 377 }, 373 378 .id = I2C_DRIVERID_TDA9875, 374 379 .attach_adapter = tda9875_probe,
+143 -85
drivers/media/video/tda9887.c
··· 9 9 #include <linux/slab.h> 10 10 #include <linux/delay.h> 11 11 12 - #include <media/audiochip.h> 12 + #include <media/v4l2-common.h> 13 13 #include <media/tuner.h> 14 14 15 15 ··· 57 57 v4l2_std_id std; 58 58 enum tuner_mode mode; 59 59 unsigned int config; 60 - unsigned int pinnacle_id; 61 60 unsigned int using_v4l2; 62 61 unsigned int radio_mode; 63 62 unsigned char data[4]; ··· 114 115 #define cAudioGain0 0x00 // bit c7 115 116 #define cAudioGain6 0x80 // bit c7 116 117 118 + #define cTopMask 0x1f // bit c0:4 119 + #define cTopPalSecamDefault 0x14 // bit c0:4 120 + #define cTopNtscRadioDefault 0x10 // bit c0:4 117 121 118 122 //// third reg (e) 119 123 #define cAudioIF_4_5 0x00 // bit e0:1 ··· 148 146 149 147 static struct tvnorm tvnorms[] = { 150 148 { 151 - .std = V4L2_STD_PAL_BG, 152 - .name = "PAL-BG", 149 + .std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H | V4L2_STD_PAL_N, 150 + .name = "PAL-BGHN", 153 151 .b = ( cNegativeFmTV | 154 152 cQSS ), 155 153 .c = ( cDeemphasisON | 156 - cDeemphasis50 ), 157 - .e = ( cAudioIF_5_5 | 154 + cDeemphasis50 | 155 + cTopPalSecamDefault), 156 + .e = ( cGating_36 | 157 + cAudioIF_5_5 | 158 158 cVideoIF_38_90 ), 159 159 },{ 160 160 .std = V4L2_STD_PAL_I, ··· 164 160 .b = ( cNegativeFmTV | 165 161 cQSS ), 166 162 .c = ( cDeemphasisON | 167 - cDeemphasis50 ), 168 - .e = ( cAudioIF_6_0 | 163 + cDeemphasis50 | 164 + cTopPalSecamDefault), 165 + .e = ( cGating_36 | 166 + cAudioIF_6_0 | 169 167 cVideoIF_38_90 ), 170 168 },{ 171 169 .std = V4L2_STD_PAL_DK, ··· 175 169 .b = ( cNegativeFmTV | 176 170 cQSS ), 177 171 .c = ( cDeemphasisON | 178 - cDeemphasis50 ), 179 - .e = ( cAudioIF_6_5 | 180 - cVideoIF_38_00 ), 172 + cDeemphasis50 | 173 + cTopPalSecamDefault), 174 + .e = ( cGating_36 | 175 + cAudioIF_6_5 | 176 + cVideoIF_38_90 ), 181 177 },{ 182 - .std = V4L2_STD_PAL_M | V4L2_STD_PAL_N, 183 - .name = "PAL-M/N", 178 + .std = V4L2_STD_PAL_M | V4L2_STD_PAL_Nc, 179 + .name = "PAL-M/Nc", 184 180 .b = ( cNegativeFmTV | 185 181 cQSS ), 186 182 .c = ( cDeemphasisON | 187 - cDeemphasis75 ), 188 - .e = ( cAudioIF_4_5 | 183 + cDeemphasis75 | 184 + cTopNtscRadioDefault), 185 + .e = ( cGating_36 | 186 + cAudioIF_4_5 | 189 187 cVideoIF_45_75 ), 188 + },{ 189 + .std = V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H, 190 + .name = "SECAM-BGH", 191 + .b = ( cPositiveAmTV | 192 + cQSS ), 193 + .c = ( cTopPalSecamDefault), 194 + .e = ( cGating_36 | 195 + cAudioIF_5_5 | 196 + cVideoIF_38_90 ), 190 197 },{ 191 198 .std = V4L2_STD_SECAM_L, 192 199 .name = "SECAM-L", 193 200 .b = ( cPositiveAmTV | 194 201 cQSS ), 202 + .c = ( cTopPalSecamDefault), 195 203 .e = ( cGating_36 | 196 204 cAudioIF_6_5 | 197 205 cVideoIF_38_90 ), 206 + },{ 207 + .std = V4L2_STD_SECAM_LC, 208 + .name = "SECAM-L'", 209 + .b = ( cOutputPort2Inactive | 210 + cPositiveAmTV | 211 + cQSS ), 212 + .c = ( cTopPalSecamDefault), 213 + .e = ( cGating_36 | 214 + cAudioIF_6_5 | 215 + cVideoIF_33_90 ), 198 216 },{ 199 217 .std = V4L2_STD_SECAM_DK, 200 218 .name = "SECAM-DK", 201 219 .b = ( cNegativeFmTV | 202 220 cQSS ), 203 221 .c = ( cDeemphasisON | 204 - cDeemphasis50 ), 205 - .e = ( cAudioIF_6_5 | 206 - cVideoIF_38_00 ), 222 + cDeemphasis50 | 223 + cTopPalSecamDefault), 224 + .e = ( cGating_36 | 225 + cAudioIF_6_5 | 226 + cVideoIF_38_90 ), 207 227 },{ 208 228 .std = V4L2_STD_NTSC_M, 209 229 .name = "NTSC-M", 210 230 .b = ( cNegativeFmTV | 211 231 cQSS ), 212 232 .c = ( cDeemphasisON | 213 - cDeemphasis75 ), 233 + cDeemphasis75 | 234 + cTopNtscRadioDefault), 214 235 .e = ( cGating_36 | 215 236 cAudioIF_4_5 | 216 237 cVideoIF_45_75 ), 217 238 },{ 218 239 .std = V4L2_STD_NTSC_M_JP, 219 - .name = "NTSC-JP", 240 + .name = "NTSC-M-JP", 220 241 .b = ( cNegativeFmTV | 221 242 cQSS ), 222 243 .c = ( cDeemphasisON | 223 - cDeemphasis50 ), 244 + cDeemphasis50 | 245 + cTopNtscRadioDefault), 224 246 .e = ( cGating_36 | 225 247 cAudioIF_4_5 | 226 248 cVideoIF_58_75 ), ··· 260 226 .b = ( cFmRadio | 261 227 cQSS ), 262 228 .c = ( cDeemphasisOFF | 263 - cAudioGain6 ), 264 - .e = ( cAudioIF_5_5 | 229 + cAudioGain6 | 230 + cTopNtscRadioDefault), 231 + .e = ( cTunerGainLow | 232 + cAudioIF_5_5 | 265 233 cRadioIF_38_90 ), 266 234 }; 267 235 ··· 272 236 .b = ( cFmRadio | 273 237 cQSS ), 274 238 .c = ( cDeemphasisON | 275 - cDeemphasis50), 276 - .e = ( cAudioIF_5_5 | 239 + cDeemphasis75 | 240 + cTopNtscRadioDefault), 241 + .e = ( cTunerGainLow | 242 + cAudioIF_5_5 | 277 243 cRadioIF_38_90 ), 278 244 }; 279 245 ··· 438 400 static unsigned int port1 = UNSET; 439 401 static unsigned int port2 = UNSET; 440 402 static unsigned int qss = UNSET; 441 - static unsigned int adjust = 0x10; 403 + static unsigned int adjust = UNSET; 404 + 442 405 module_param(port1, int, 0644); 443 406 module_param(port2, int, 0644); 444 407 module_param(qss, int, 0644); ··· 467 428 buf[1] &= ~cQSS; 468 429 } 469 430 470 - if (adjust >= 0x00 && adjust < 0x20) 431 + if (adjust >= 0x00 && adjust < 0x20) { 432 + buf[2] &= ~cTopMask; 471 433 buf[2] |= adjust; 434 + } 472 435 return 0; 473 436 } 474 437 ··· 506 465 break; 507 466 } 508 467 } 468 + if (t->config & TDA9887_TOP_SET) { 469 + buf[2] &= ~cTopMask; 470 + buf[2] |= (t->config >> 8) & cTopMask; 471 + } 509 472 if ((t->config & TDA9887_INTERCARRIER_NTSC) && (t->std & V4L2_STD_NTSC)) 510 473 buf[1] &= ~cQSS; 511 474 return 0; ··· 517 472 518 473 /* ---------------------------------------------------------------------- */ 519 474 520 - static int tda9887_set_pinnacle(struct tda9887 *t, char *buf) 521 - { 522 - unsigned int bCarrierMode = UNSET; 475 + static char pal[] = "--"; 476 + static char secam[] = "--"; 477 + static char ntsc[] = "-"; 523 478 524 - if (t->std & V4L2_STD_625_50) { 525 - if ((1 == t->pinnacle_id) || (7 == t->pinnacle_id)) { 526 - bCarrierMode = cIntercarrier; 527 - } else { 528 - bCarrierMode = cQSS; 529 - } 530 - } 531 - if (t->std & V4L2_STD_525_60) { 532 - if ((5 == t->pinnacle_id) || (6 == t->pinnacle_id)) { 533 - bCarrierMode = cIntercarrier; 534 - } else { 535 - bCarrierMode = cQSS; 536 - } 537 - } 538 - 539 - if (bCarrierMode != UNSET) { 540 - buf[1] &= ~0x04; 541 - buf[1] |= bCarrierMode; 542 - } 543 - return 0; 544 - } 545 - 546 - /* ---------------------------------------------------------------------- */ 547 - 548 - static char pal[] = "-"; 549 479 module_param_string(pal, pal, sizeof(pal), 0644); 550 - static char secam[] = "-"; 551 480 module_param_string(secam, secam, sizeof(secam), 0644); 481 + module_param_string(ntsc, ntsc, sizeof(ntsc), 0644); 552 482 553 483 static int tda9887_fixup_std(struct tda9887 *t) 554 484 { ··· 534 514 case 'B': 535 515 case 'g': 536 516 case 'G': 537 - tda9887_dbg("insmod fixup: PAL => PAL-BG\n"); 538 - t->std = V4L2_STD_PAL_BG; 517 + case 'h': 518 + case 'H': 519 + case 'n': 520 + case 'N': 521 + if (pal[1] == 'c' || pal[1] == 'C') { 522 + tda9887_dbg("insmod fixup: PAL => PAL-Nc\n"); 523 + t->std = V4L2_STD_PAL_Nc; 524 + } else { 525 + tda9887_dbg("insmod fixup: PAL => PAL-BGHN\n"); 526 + t->std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H | V4L2_STD_PAL_N; 527 + } 539 528 break; 540 529 case 'i': 541 530 case 'I': ··· 558 529 tda9887_dbg("insmod fixup: PAL => PAL-DK\n"); 559 530 t->std = V4L2_STD_PAL_DK; 560 531 break; 532 + case 'm': 533 + case 'M': 534 + tda9887_dbg("insmod fixup: PAL => PAL-M\n"); 535 + t->std = V4L2_STD_PAL_M; 536 + break; 561 537 case '-': 562 538 /* default parameter, do nothing */ 563 539 break; ··· 573 539 } 574 540 if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { 575 541 switch (secam[0]) { 542 + case 'b': 543 + case 'B': 544 + case 'g': 545 + case 'G': 546 + case 'h': 547 + case 'H': 548 + tda9887_dbg("insmod fixup: SECAM => SECAM-BGH\n"); 549 + t->std = V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H; 550 + break; 576 551 case 'd': 577 552 case 'D': 578 553 case 'k': ··· 591 548 break; 592 549 case 'l': 593 550 case 'L': 594 - tda9887_dbg("insmod fixup: SECAM => SECAM-L\n"); 595 - t->std = V4L2_STD_SECAM_L; 551 + if (secam[1] == 'c' || secam[1] == 'C') { 552 + tda9887_dbg("insmod fixup: SECAM => SECAM-L'\n"); 553 + t->std = V4L2_STD_SECAM_LC; 554 + } else { 555 + tda9887_dbg("insmod fixup: SECAM => SECAM-L\n"); 556 + t->std = V4L2_STD_SECAM_L; 557 + } 596 558 break; 597 559 case '-': 598 560 /* default parameter, do nothing */ 599 561 break; 600 562 default: 601 563 tda9887_info("secam= argument not recognised\n"); 564 + break; 565 + } 566 + } 567 + if ((t->std & V4L2_STD_NTSC) == V4L2_STD_NTSC) { 568 + switch (ntsc[0]) { 569 + case 'm': 570 + case 'M': 571 + tda9887_dbg("insmod fixup: NTSC => NTSC-M\n"); 572 + t->std = V4L2_STD_NTSC_M; 573 + break; 574 + case 'j': 575 + case 'J': 576 + tda9887_dbg("insmod fixup: NTSC => NTSC_M_JP\n"); 577 + t->std = V4L2_STD_NTSC_M_JP; 578 + break; 579 + case '-': 580 + /* default parameter, do nothing */ 581 + break; 582 + default: 583 + tda9887_info("ntsc= argument not recognised\n"); 602 584 break; 603 585 } 604 586 } ··· 649 581 memset(t->data,0,sizeof(t->data)); 650 582 tda9887_set_tvnorm(t,t->data); 651 583 584 + /* A note on the port settings: 585 + These settings tend to depend on the specifics of the board. 586 + By default they are set to inactive (bit value 1) by this driver, 587 + overwriting any changes made by the tvnorm. This means that it 588 + is the responsibility of the module using the tda9887 to set 589 + these values in case of changes in the tvnorm. 590 + In many cases port 2 should be made active (0) when selecting 591 + SECAM-L, and port 2 should remain inactive (1) for SECAM-L'. 592 + 593 + For the other standards the tda9887 application note says that 594 + the ports should be set to active (0), but, again, that may 595 + differ depending on the precise hardware configuration. 596 + */ 652 597 t->data[1] |= cOutputPort1Inactive; 653 598 t->data[1] |= cOutputPort2Inactive; 654 599 655 - if (UNSET != t->pinnacle_id) { 656 - tda9887_set_pinnacle(t,t->data); 657 - } 658 600 tda9887_set_config(t,t->data); 659 601 tda9887_set_insmod(t,t->data); 660 602 661 603 if (t->mode == T_STANDBY) { 662 604 t->data[1] |= cForcedMuteAudioON; 663 605 } 664 - 665 606 666 607 tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n", 667 608 t->data[1],t->data[2],t->data[3]); ··· 702 625 703 626 t->client = client_template; 704 627 t->std = 0; 705 - t->pinnacle_id = UNSET; 706 628 t->radio_mode = V4L2_TUNER_MODE_STEREO; 707 629 708 630 tda9887_info("chip found @ 0x%x (%s)\n", addr<<1, adap->name); ··· 714 638 715 639 static int tda9887_probe(struct i2c_adapter *adap) 716 640 { 717 - #ifdef I2C_CLASS_TV_ANALOG 718 641 if (adap->class & I2C_CLASS_TV_ANALOG) 719 642 return i2c_probe(adap, &addr_data, tda9887_attach); 720 - #else 721 - switch (adap->id) { 722 - case I2C_HW_B_BT848: 723 - case I2C_HW_B_RIVA: 724 - case I2C_HW_SAA7134: 725 - return i2c_probe(adap, &addr_data, tda9887_attach); 726 - break; 727 - } 728 - #endif 729 643 return 0; 730 644 } 731 645 ··· 752 686 case TUNER_SET_STANDBY: 753 687 { 754 688 t->mode = T_STANDBY; 755 - tda9887_configure(t); 756 - break; 757 - } 758 - case AUDC_CONFIG_PINNACLE: 759 - { 760 - int *i = arg; 761 - 762 - t->pinnacle_id = *i; 763 689 tda9887_configure(t); 764 690 break; 765 691 } ··· 845 787 } 846 788 case VIDIOC_LOG_STATUS: 847 789 { 848 - tda9887_info("Data bytes: b=%02x c=%02x e=%02x\n", t->data[1], t->data[2], t->data[3]); 790 + tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", t->data[1], t->data[2], t->data[3]); 849 791 break; 850 792 } 851 793 default: ··· 882 824 .detach_client = tda9887_detach, 883 825 .command = tda9887_command, 884 826 .driver = { 885 - .name = "i2c tda9887 driver", 827 + .name = "tda9887", 886 828 .suspend = tda9887_suspend, 887 829 .resume = tda9887_resume, 888 830 },
+5 -2
drivers/media/video/tea5767.c
··· 17 17 18 18 #define PREFIX "TEA5767 " 19 19 20 + /* from tuner-core.c */ 21 + extern int debug; 22 + 20 23 /*****************************************************************************/ 21 24 22 25 /****************************** ··· 249 246 if (5 != (rc = i2c_master_send(c, buffer, 5))) 250 247 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); 251 248 252 - if (tuner_debug) { 249 + if (debug) { 253 250 if (5 != (rc = i2c_master_recv(c, buffer, 5))) 254 251 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); 255 252 else ··· 267 264 if (5 != (rc = i2c_master_recv(c, buffer, 5))) 268 265 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); 269 266 270 - return ((buffer[3] & TEA5767_ADC_LEVEL_MASK) << (13 - 4)); 267 + return ((buffer[3] & TEA5767_ADC_LEVEL_MASK) << 8); 271 268 } 272 269 273 270 static int tea5767_stereo(struct i2c_client *c)
+98 -40
drivers/media/video/tuner-core.c
··· 20 20 #include <linux/init.h> 21 21 22 22 #include <media/tuner.h> 23 + #include <media/v4l2-common.h> 23 24 #include <media/audiochip.h> 24 - 25 - #include "msp3400.h" 26 25 27 26 #define UNSET (-1U) 28 27 ··· 37 38 38 39 /* insmod options used at init time => read/only */ 39 40 static unsigned int addr = 0; 40 - module_param(addr, int, 0444); 41 - 42 41 static unsigned int no_autodetect = 0; 43 - module_param(no_autodetect, int, 0444); 44 - 45 42 static unsigned int show_i2c = 0; 46 - module_param(show_i2c, int, 0444); 47 43 48 44 /* insmod options used at runtime => read/write */ 49 - unsigned int tuner_debug = 0; 50 - module_param(tuner_debug, int, 0644); 45 + static unsigned int tuner_debug = 0; 46 + int debug = 0; 51 47 52 48 static unsigned int tv_range[2] = { 44, 958 }; 53 49 static unsigned int radio_range[2] = { 65, 108 }; 54 50 51 + static char pal[] = "--"; 52 + static char secam[] = "--"; 53 + static char ntsc[] = "-"; 54 + 55 + module_param(addr, int, 0444); 56 + module_param(no_autodetect, int, 0444); 57 + module_param(show_i2c, int, 0444); 58 + /* Note: tuner_debug is deprecated and will be removed in 2.6.17 */ 59 + module_param(tuner_debug, int, 0444); 60 + module_param(debug, int, 0644); 61 + 62 + module_param_string(pal, pal, sizeof(pal), 0644); 63 + module_param_string(secam, secam, sizeof(secam), 0644); 64 + module_param_string(ntsc, ntsc, sizeof(ntsc), 0644); 55 65 module_param_array(tv_range, int, NULL, 0644); 56 66 module_param_array(radio_range, int, NULL, 0644); 57 67 ··· 257 249 return 0; 258 250 } 259 251 260 - static char pal[] = "-"; 261 - module_param_string(pal, pal, sizeof(pal), 0644); 262 - static char secam[] = "--"; 263 - module_param_string(secam, secam, sizeof(secam), 0644); 264 - 265 252 /* get more precise norm info from insmod option */ 266 253 static int tuner_fixup_std(struct tuner *t) 267 254 { ··· 288 285 break; 289 286 case 'N': 290 287 case 'n': 291 - tuner_dbg ("insmod fixup: PAL => PAL-N\n"); 292 - t->std = V4L2_STD_PAL_N; 288 + if (pal[1] == 'c' || pal[1] == 'C') { 289 + tuner_dbg("insmod fixup: PAL => PAL-Nc\n"); 290 + t->std = V4L2_STD_PAL_Nc; 291 + } else { 292 + tuner_dbg ("insmod fixup: PAL => PAL-N\n"); 293 + t->std = V4L2_STD_PAL_N; 294 + } 293 295 break; 294 296 case '-': 295 297 /* default parameter, do nothing */ ··· 306 298 } 307 299 if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { 308 300 switch (secam[0]) { 301 + case 'b': 302 + case 'B': 303 + case 'g': 304 + case 'G': 305 + case 'h': 306 + case 'H': 307 + tuner_dbg("insmod fixup: SECAM => SECAM-BGH\n"); 308 + t->std = V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H; 309 + break; 309 310 case 'd': 310 311 case 'D': 311 312 case 'k': ··· 341 324 } 342 325 } 343 326 327 + if ((t->std & V4L2_STD_NTSC) == V4L2_STD_NTSC) { 328 + switch (ntsc[0]) { 329 + case 'm': 330 + case 'M': 331 + tuner_dbg("insmod fixup: NTSC => NTSC-M\n"); 332 + t->std = V4L2_STD_NTSC_M; 333 + break; 334 + case 'j': 335 + case 'J': 336 + tuner_dbg("insmod fixup: NTSC => NTSC_M_JP\n"); 337 + t->std = V4L2_STD_NTSC_M_JP; 338 + break; 339 + case '-': 340 + /* default parameter, do nothing */ 341 + break; 342 + default: 343 + tuner_info("ntsc= argument not recognised\n"); 344 + break; 345 + } 346 + } 344 347 return 0; 345 348 } 346 349 350 + static void tuner_status(struct i2c_client *client) 351 + { 352 + struct tuner *t = i2c_get_clientdata(client); 353 + unsigned long freq, freq_fraction; 354 + const char *p; 355 + 356 + switch (t->mode) { 357 + case V4L2_TUNER_RADIO: p = "radio"; break; 358 + case V4L2_TUNER_ANALOG_TV: p = "analog TV"; break; 359 + case V4L2_TUNER_DIGITAL_TV: p = "digital TV"; break; 360 + default: p = "undefined"; break; 361 + } 362 + if (t->mode == V4L2_TUNER_RADIO) { 363 + freq = t->freq / 16000; 364 + freq_fraction = (t->freq % 16000) * 100 / 16000; 365 + } else { 366 + freq = t->freq / 16; 367 + freq_fraction = (t->freq % 16) * 100 / 16; 368 + } 369 + tuner_info("Tuner mode: %s\n", p); 370 + tuner_info("Frequency: %lu.%02lu MHz\n", freq, freq_fraction); 371 + tuner_info("Standard: 0x%08llx\n", t->std); 372 + if (t->mode == V4L2_TUNER_RADIO) { 373 + if (t->has_signal) { 374 + tuner_info("Signal strength: %d\n", t->has_signal(client)); 375 + } 376 + if (t->is_stereo) { 377 + tuner_info("Stereo: %s\n", t->is_stereo(client) ? "yes" : "no"); 378 + } 379 + } 380 + } 347 381 /* ---------------------------------------------------------------------- */ 348 382 349 383 /* static var Used only in tuner_attach and tuner_probe */ ··· 420 352 t->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */ 421 353 t->audmode = V4L2_TUNER_MODE_STEREO; 422 354 t->mode_mask = T_UNINITIALIZED; 355 + if (tuner_debug) { 356 + debug = tuner_debug; 357 + printk(KERN_ERR "tuner: tuner_debug is deprecated and will be removed in 2.6.17.\n"); 358 + printk(KERN_ERR "tuner: use the debug option instead.\n"); 359 + } 423 360 424 361 if (show_i2c) { 425 362 unsigned char buffer[16]; ··· 551 478 static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) 552 479 { 553 480 struct tuner *t = i2c_get_clientdata(client); 554 - unsigned int *iarg = (int *)arg; 481 + 482 + if (debug>1) 483 + v4l_i2c_print_ioctl(&(t->i2c),cmd); 555 484 556 485 switch (cmd) { 557 486 /* --- configuration --- */ ··· 576 501 t->standby (client); 577 502 break; 578 503 } 579 - case AUDC_CONFIG_PINNACLE: 580 - switch (*iarg) { 581 - case 2: 582 - tuner_dbg("pinnacle pal\n"); 583 - t->radio_if2 = 33300 * 1000; 584 - break; 585 - case 3: 586 - tuner_dbg("pinnacle ntsc\n"); 587 - t->radio_if2 = 41300 * 1000; 588 - break; 589 - } 590 - break; 591 504 case VIDIOCSAUDIO: 592 505 if (check_mode(t, "VIDIOCSAUDIO") == EINVAL) 593 506 return 0; ··· 585 522 /* Should be implemented, since bttv calls it */ 586 523 tuner_dbg("VIDIOCSAUDIO not implemented.\n"); 587 524 588 - break; 589 - case MSP_SET_MATRIX: 590 - case TDA9887_SET_CONFIG: 591 525 break; 592 526 /* --- v4l ioctls --- */ 593 527 /* take care: bttv does userspace copying, we'll get a ··· 768 708 } 769 709 break; 770 710 } 771 - default: 772 - tuner_dbg("Unimplemented IOCTL 0x%08x(dir=%d,tp='%c',nr=%d,sz=%d)\n", 773 - cmd, _IOC_DIR(cmd), _IOC_TYPE(cmd), 774 - _IOC_NR(cmd), _IOC_SIZE(cmd)); 711 + case VIDIOC_LOG_STATUS: 712 + tuner_status(client); 775 713 break; 776 714 } 777 715 ··· 805 747 .detach_client = tuner_detach, 806 748 .command = tuner_command, 807 749 .driver = { 808 - .name = "tuner", 809 - .suspend = tuner_suspend, 810 - .resume = tuner_resume, 811 - }, 750 + .name = "tuner", 751 + .suspend = tuner_suspend, 752 + .resume = tuner_resume, 753 + }, 812 754 }; 813 755 static struct i2c_client client_template = { 814 756 .name = "(tuner unset)",
+727 -160
drivers/media/video/tuner-simple.c
··· 8 8 #include <linux/videodev.h> 9 9 #include <media/tuner.h> 10 10 11 + static int offset = 0; 12 + module_param(offset, int, 0666); 13 + MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner"); 14 + 11 15 /* ---------------------------------------------------------------------- */ 12 16 13 17 /* tv standard selection for Temic 4046 FM5 ··· 79 75 #define TUNER_PLL_LOCKED 0x40 80 76 #define TUNER_STEREO_MK3 0x04 81 77 78 + #define TUNER_MAX_RANGES 3 79 + 82 80 /* ---------------------------------------------------------------------- */ 83 81 84 82 struct tunertype 85 83 { 86 84 char *name; 87 - unsigned char Vendor; 88 - unsigned char Type; 89 85 90 - unsigned short thresh1; /* band switch VHF_LO <=> VHF_HI */ 91 - unsigned short thresh2; /* band switch VHF_HI <=> UHF */ 92 - unsigned char VHF_L; 93 - unsigned char VHF_H; 94 - unsigned char UHF; 86 + int count; 87 + struct { 88 + unsigned short thresh; 89 + unsigned char cb; 90 + } ranges[TUNER_MAX_RANGES]; 95 91 unsigned char config; 96 - unsigned short IFPCoff; /* 622.4=16*38.90 MHz PAL, 97 - 732 =16*45.75 NTSCi, 98 - 940 =16*58.75 NTSC-Japan 99 - 704 =16*44 ATSC */ 100 92 }; 101 93 102 94 /* ··· 102 102 */ 103 103 static struct tunertype tuners[] = { 104 104 /* 0-9 */ 105 - { "Temic PAL (4002 FH5)", TEMIC, PAL, 106 - 16*140.25,16*463.25,0x02,0x04,0x01,0x8e,623}, 107 - { "Philips PAL_I (FI1246 and compatibles)", Philips, PAL_I, 108 - 16*140.25,16*463.25,0xa0,0x90,0x30,0x8e,623}, 109 - { "Philips NTSC (FI1236,FM1236 and compatibles)", Philips, NTSC, 110 - 16*157.25,16*451.25,0xA0,0x90,0x30,0x8e,732}, 111 - { "Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)", Philips, SECAM, 112 - 16*168.25,16*447.25,0xA7,0x97,0x37,0x8e,623}, 113 - { "NoTuner", NoTuner, NOTUNER, 114 - 0,0,0x00,0x00,0x00,0x00,0x00}, 115 - { "Philips PAL_BG (FI1216 and compatibles)", Philips, PAL, 116 - 16*168.25,16*447.25,0xA0,0x90,0x30,0x8e,623}, 117 - { "Temic NTSC (4032 FY5)", TEMIC, NTSC, 118 - 16*157.25,16*463.25,0x02,0x04,0x01,0x8e,732}, 119 - { "Temic PAL_I (4062 FY5)", TEMIC, PAL_I, 120 - 16*170.00,16*450.00,0x02,0x04,0x01,0x8e,623}, 121 - { "Temic NTSC (4036 FY5)", TEMIC, NTSC, 122 - 16*157.25,16*463.25,0xa0,0x90,0x30,0x8e,732}, 123 - { "Alps HSBH1", TEMIC, NTSC, 124 - 16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732}, 105 + [TUNER_TEMIC_PAL] = { /* TEMIC PAL */ 106 + .name = "Temic PAL (4002 FH5)", 107 + .count = 3, 108 + .ranges = { 109 + { 16 * 140.25 /*MHz*/, 0x02, }, 110 + { 16 * 463.25 /*MHz*/, 0x04, }, 111 + { 16 * 999.99 , 0x01, }, 112 + }, 113 + .config = 0x8e, 114 + }, 115 + [TUNER_PHILIPS_PAL_I] = { /* Philips PAL_I */ 116 + .name = "Philips PAL_I (FI1246 and compatibles)", 117 + .count = 3, 118 + .ranges = { 119 + { 16 * 140.25 /*MHz*/, 0xa0, }, 120 + { 16 * 463.25 /*MHz*/, 0x90, }, 121 + { 16 * 999.99 , 0x30, }, 122 + }, 123 + .config = 0x8e, 124 + }, 125 + [TUNER_PHILIPS_NTSC] = { /* Philips NTSC */ 126 + .name = "Philips NTSC (FI1236,FM1236 and compatibles)", 127 + .count = 3, 128 + .ranges = { 129 + { 16 * 157.25 /*MHz*/, 0xa0, }, 130 + { 16 * 451.25 /*MHz*/, 0x90, }, 131 + { 16 * 999.99 , 0x30, }, 132 + }, 133 + .config = 0x8e, 134 + }, 135 + [TUNER_PHILIPS_SECAM] = { /* Philips SECAM */ 136 + .name = "Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)", 137 + .count = 3, 138 + .ranges = { 139 + { 16 * 168.25 /*MHz*/, 0xa7, }, 140 + { 16 * 447.25 /*MHz*/, 0x97, }, 141 + { 16 * 999.99 , 0x37, }, 142 + }, 143 + .config = 0x8e, 144 + }, 145 + [TUNER_ABSENT] = { /* Tuner Absent */ 146 + .name = "NoTuner", 147 + .count = 1, 148 + .ranges = { 149 + { 0, 0x00, }, 150 + }, 151 + .config = 0x00, 152 + }, 153 + [TUNER_PHILIPS_PAL] = { /* Philips PAL */ 154 + .name = "Philips PAL_BG (FI1216 and compatibles)", 155 + .count = 3, 156 + .ranges = { 157 + { 16 * 168.25 /*MHz*/, 0xa0, }, 158 + { 16 * 447.25 /*MHz*/, 0x90, }, 159 + { 16 * 999.99 , 0x30, }, 160 + }, 161 + .config = 0x8e, 162 + }, 163 + [TUNER_TEMIC_NTSC] = { /* TEMIC NTSC */ 164 + .name = "Temic NTSC (4032 FY5)", 165 + .count = 3, 166 + .ranges = { 167 + { 16 * 157.25 /*MHz*/, 0x02, }, 168 + { 16 * 463.25 /*MHz*/, 0x04, }, 169 + { 16 * 999.99 , 0x01, }, 170 + }, 171 + .config = 0x8e, 172 + }, 173 + [TUNER_TEMIC_PAL_I] = { /* TEMIC PAL_I */ 174 + .name = "Temic PAL_I (4062 FY5)", 175 + .count = 3, 176 + .ranges = { 177 + { 16 * 170.00 /*MHz*/, 0x02, }, 178 + { 16 * 450.00 /*MHz*/, 0x04, }, 179 + { 16 * 999.99 , 0x01, }, 180 + }, 181 + .config = 0x8e, 182 + }, 183 + [TUNER_TEMIC_4036FY5_NTSC] = { /* TEMIC NTSC */ 184 + .name = "Temic NTSC (4036 FY5)", 185 + .count = 3, 186 + .ranges = { 187 + { 16 * 157.25 /*MHz*/, 0xa0, }, 188 + { 16 * 463.25 /*MHz*/, 0x90, }, 189 + { 16 * 999.99 , 0x30, }, 190 + }, 191 + .config = 0x8e, 192 + }, 193 + [TUNER_ALPS_TSBH1_NTSC] = { /* TEMIC NTSC */ 194 + .name = "Alps HSBH1", 195 + .count = 3, 196 + .ranges = { 197 + { 16 * 137.25 /*MHz*/, 0x01, }, 198 + { 16 * 385.25 /*MHz*/, 0x02, }, 199 + { 16 * 999.99 , 0x08, }, 200 + }, 201 + .config = 0x8e, 202 + }, 125 203 126 204 /* 10-19 */ 127 - { "Alps TSBE1", TEMIC, PAL, 128 - 16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732}, 129 - { "Alps TSBB5", Alps, PAL_I, /* tested (UK UHF) with Modulartech MM205 */ 130 - 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,632}, 131 - { "Alps TSBE5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */ 132 - 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,622}, 133 - { "Alps TSBC5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */ 134 - 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,608}, 135 - { "Temic PAL_BG (4006FH5)", TEMIC, PAL, 136 - 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, 137 - { "Alps TSCH6", Alps, NTSC, 138 - 16*137.25,16*385.25,0x14,0x12,0x11,0x8e,732}, 139 - { "Temic PAL_DK (4016 FY5)", TEMIC, PAL, 140 - 16*168.25,16*456.25,0xa0,0x90,0x30,0x8e,623}, 141 - { "Philips NTSC_M (MK2)", Philips, NTSC, 142 - 16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732}, 143 - { "Temic PAL_I (4066 FY5)", TEMIC, PAL_I, 144 - 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, 145 - { "Temic PAL* auto (4006 FN5)", TEMIC, PAL, 146 - 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, 205 + [TUNER_ALPS_TSBE1_PAL] = { /* TEMIC PAL */ 206 + .name = "Alps TSBE1", 207 + .count = 3, 208 + .ranges = { 209 + { 16 * 137.25 /*MHz*/, 0x01, }, 210 + { 16 * 385.25 /*MHz*/, 0x02, }, 211 + { 16 * 999.99 , 0x08, }, 212 + }, 213 + .config = 0x8e, 214 + }, 215 + [TUNER_ALPS_TSBB5_PAL_I] = { /* Alps PAL_I */ 216 + .name = "Alps TSBB5", 217 + .count = 3, 218 + .ranges = { 219 + { 16 * 133.25 /*MHz*/, 0x01, }, 220 + { 16 * 351.25 /*MHz*/, 0x02, }, 221 + { 16 * 999.99 , 0x08, }, 222 + }, 223 + .config = 0x8e, 224 + }, 225 + [TUNER_ALPS_TSBE5_PAL] = { /* Alps PAL */ 226 + .name = "Alps TSBE5", 227 + .count = 3, 228 + .ranges = { 229 + { 16 * 133.25 /*MHz*/, 0x01, }, 230 + { 16 * 351.25 /*MHz*/, 0x02, }, 231 + { 16 * 999.99 , 0x08, }, 232 + }, 233 + .config = 0x8e, 234 + }, 235 + [TUNER_ALPS_TSBC5_PAL] = { /* Alps PAL */ 236 + .name = "Alps TSBC5", 237 + .count = 3, 238 + .ranges = { 239 + { 16 * 133.25 /*MHz*/, 0x01, }, 240 + { 16 * 351.25 /*MHz*/, 0x02, }, 241 + { 16 * 999.99 , 0x08, }, 242 + }, 243 + .config = 0x8e, 244 + }, 245 + [TUNER_TEMIC_4006FH5_PAL] = { /* TEMIC PAL */ 246 + .name = "Temic PAL_BG (4006FH5)", 247 + .count = 3, 248 + .ranges = { 249 + { 16 * 170.00 /*MHz*/, 0xa0, }, 250 + { 16 * 450.00 /*MHz*/, 0x90, }, 251 + { 16 * 999.99 , 0x30, }, 252 + }, 253 + .config = 0x8e, 254 + }, 255 + [TUNER_ALPS_TSHC6_NTSC] = { /* Alps NTSC */ 256 + .name = "Alps TSCH6", 257 + .count = 3, 258 + .ranges = { 259 + { 16 * 137.25 /*MHz*/, 0x14, }, 260 + { 16 * 385.25 /*MHz*/, 0x12, }, 261 + { 16 * 999.99 , 0x11, }, 262 + }, 263 + .config = 0x8e, 264 + }, 265 + [TUNER_TEMIC_PAL_DK] = { /* TEMIC PAL */ 266 + .name = "Temic PAL_DK (4016 FY5)", 267 + .count = 3, 268 + .ranges = { 269 + { 16 * 168.25 /*MHz*/, 0xa0, }, 270 + { 16 * 456.25 /*MHz*/, 0x90, }, 271 + { 16 * 999.99 , 0x30, }, 272 + }, 273 + .config = 0x8e, 274 + }, 275 + [TUNER_PHILIPS_NTSC_M] = { /* Philips NTSC */ 276 + .name = "Philips NTSC_M (MK2)", 277 + .count = 3, 278 + .ranges = { 279 + { 16 * 160.00 /*MHz*/, 0xa0, }, 280 + { 16 * 454.00 /*MHz*/, 0x90, }, 281 + { 16 * 999.99 , 0x30, }, 282 + }, 283 + .config = 0x8e, 284 + }, 285 + [TUNER_TEMIC_4066FY5_PAL_I] = { /* TEMIC PAL_I */ 286 + .name = "Temic PAL_I (4066 FY5)", 287 + .count = 3, 288 + .ranges = { 289 + { 16 * 169.00 /*MHz*/, 0xa0, }, 290 + { 16 * 454.00 /*MHz*/, 0x90, }, 291 + { 16 * 999.99 , 0x30, }, 292 + }, 293 + .config = 0x8e, 294 + }, 295 + [TUNER_TEMIC_4006FN5_MULTI_PAL] = { /* TEMIC PAL */ 296 + .name = "Temic PAL* auto (4006 FN5)", 297 + .count = 3, 298 + .ranges = { 299 + { 16 * 169.00 /*MHz*/, 0xa0, }, 300 + { 16 * 454.00 /*MHz*/, 0x90, }, 301 + { 16 * 999.99 , 0x30, }, 302 + }, 303 + .config = 0x8e, 304 + }, 147 305 148 306 /* 20-29 */ 149 - { "Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)", TEMIC, PAL, 150 - 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, 151 - { "Temic NTSC (4039 FR5)", TEMIC, NTSC, 152 - 16*158.00, 16*453.00, 0xa0,0x90,0x30,0x8e,732}, 153 - { "Temic PAL/SECAM multi (4046 FM5)", TEMIC, PAL, 154 - 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, 155 - { "Philips PAL_DK (FI1256 and compatibles)", Philips, PAL, 156 - 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, 157 - { "Philips PAL/SECAM multi (FQ1216ME)", Philips, PAL, 158 - 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, 159 - { "LG PAL_I+FM (TAPC-I001D)", LGINNOTEK, PAL_I, 160 - 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, 161 - { "LG PAL_I (TAPC-I701D)", LGINNOTEK, PAL_I, 162 - 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, 163 - { "LG NTSC+FM (TPI8NSR01F)", LGINNOTEK, NTSC, 164 - 16*210.00,16*497.00,0xa0,0x90,0x30,0x8e,732}, 165 - { "LG PAL_BG+FM (TPI8PSB01D)", LGINNOTEK, PAL, 166 - 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, 167 - { "LG PAL_BG (TPI8PSB11D)", LGINNOTEK, PAL, 168 - 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, 307 + [TUNER_TEMIC_4009FR5_PAL] = { /* TEMIC PAL */ 308 + .name = "Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)", 309 + .count = 3, 310 + .ranges = { 311 + { 16 * 141.00 /*MHz*/, 0xa0, }, 312 + { 16 * 464.00 /*MHz*/, 0x90, }, 313 + { 16 * 999.99 , 0x30, }, 314 + }, 315 + .config = 0x8e, 316 + }, 317 + [TUNER_TEMIC_4039FR5_NTSC] = { /* TEMIC NTSC */ 318 + .name = "Temic NTSC (4039 FR5)", 319 + .count = 3, 320 + .ranges = { 321 + { 16 * 158.00 /*MHz*/, 0xa0, }, 322 + { 16 * 453.00 /*MHz*/, 0x90, }, 323 + { 16 * 999.99 , 0x30, }, 324 + }, 325 + .config = 0x8e, 326 + }, 327 + [TUNER_TEMIC_4046FM5] = { /* TEMIC PAL */ 328 + .name = "Temic PAL/SECAM multi (4046 FM5)", 329 + .count = 3, 330 + .ranges = { 331 + { 16 * 169.00 /*MHz*/, 0xa0, }, 332 + { 16 * 454.00 /*MHz*/, 0x90, }, 333 + { 16 * 999.99 , 0x30, }, 334 + }, 335 + .config = 0x8e, 336 + }, 337 + [TUNER_PHILIPS_PAL_DK] = { /* Philips PAL */ 338 + .name = "Philips PAL_DK (FI1256 and compatibles)", 339 + .count = 3, 340 + .ranges = { 341 + { 16 * 170.00 /*MHz*/, 0xa0, }, 342 + { 16 * 450.00 /*MHz*/, 0x90, }, 343 + { 16 * 999.99 , 0x30, }, 344 + }, 345 + .config = 0x8e, 346 + }, 347 + [TUNER_PHILIPS_FQ1216ME] = { /* Philips PAL */ 348 + .name = "Philips PAL/SECAM multi (FQ1216ME)", 349 + .count = 3, 350 + .ranges = { 351 + { 16 * 170.00 /*MHz*/, 0xa0, }, 352 + { 16 * 450.00 /*MHz*/, 0x90, }, 353 + { 16 * 999.99 , 0x30, }, 354 + }, 355 + .config = 0x8e, 356 + }, 357 + [TUNER_LG_PAL_I_FM] = { /* LGINNOTEK PAL_I */ 358 + .name = "LG PAL_I+FM (TAPC-I001D)", 359 + .count = 3, 360 + .ranges = { 361 + { 16 * 170.00 /*MHz*/, 0xa0, }, 362 + { 16 * 450.00 /*MHz*/, 0x90, }, 363 + { 16 * 999.99 , 0x30, }, 364 + }, 365 + .config = 0x8e, 366 + }, 367 + [TUNER_LG_PAL_I] = { /* LGINNOTEK PAL_I */ 368 + .name = "LG PAL_I (TAPC-I701D)", 369 + .count = 3, 370 + .ranges = { 371 + { 16 * 170.00 /*MHz*/, 0xa0, }, 372 + { 16 * 450.00 /*MHz*/, 0x90, }, 373 + { 16 * 999.99 , 0x30, }, 374 + }, 375 + .config = 0x8e, 376 + }, 377 + [TUNER_LG_NTSC_FM] = { /* LGINNOTEK NTSC */ 378 + .name = "LG NTSC+FM (TPI8NSR01F)", 379 + .count = 3, 380 + .ranges = { 381 + { 16 * 210.00 /*MHz*/, 0xa0, }, 382 + { 16 * 497.00 /*MHz*/, 0x90, }, 383 + { 16 * 999.99 , 0x30, }, 384 + }, 385 + .config = 0x8e, 386 + }, 387 + [TUNER_LG_PAL_FM] = { /* LGINNOTEK PAL */ 388 + .name = "LG PAL_BG+FM (TPI8PSB01D)", 389 + .count = 3, 390 + .ranges = { 391 + { 16 * 170.00 /*MHz*/, 0xa0, }, 392 + { 16 * 450.00 /*MHz*/, 0x90, }, 393 + { 16 * 999.99 , 0x30, }, 394 + }, 395 + .config = 0x8e, 396 + }, 397 + [TUNER_LG_PAL] = { /* LGINNOTEK PAL */ 398 + .name = "LG PAL_BG (TPI8PSB11D)", 399 + .count = 3, 400 + .ranges = { 401 + { 16 * 170.00 /*MHz*/, 0xa0, }, 402 + { 16 * 450.00 /*MHz*/, 0x90, }, 403 + { 16 * 999.99 , 0x30, }, 404 + }, 405 + .config = 0x8e, 406 + }, 169 407 170 408 /* 30-39 */ 171 - { "Temic PAL* auto + FM (4009 FN5)", TEMIC, PAL, 172 - 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, 173 - { "SHARP NTSC_JP (2U5JF5540)", SHARP, NTSC, /* 940=16*58.75 NTSC@Japan */ 174 - 16*137.25,16*317.25,0x01,0x02,0x08,0x8e,940 }, 175 - { "Samsung PAL TCPM9091PD27", Samsung, PAL, /* from sourceforge v3tv */ 176 - 16*169,16*464,0xA0,0x90,0x30,0x8e,623}, 177 - { "MT20xx universal", Microtune, PAL|NTSC, 409 + [TUNER_TEMIC_4009FN5_MULTI_PAL_FM] = { /* TEMIC PAL */ 410 + .name = "Temic PAL* auto + FM (4009 FN5)", 411 + .count = 3, 412 + .ranges = { 413 + { 16 * 141.00 /*MHz*/, 0xa0, }, 414 + { 16 * 464.00 /*MHz*/, 0x90, }, 415 + { 16 * 999.99 , 0x30, }, 416 + }, 417 + .config = 0x8e, 418 + }, 419 + [TUNER_SHARP_2U5JF5540_NTSC] = { /* SHARP NTSC */ 420 + .name = "SHARP NTSC_JP (2U5JF5540)", 421 + .count = 3, 422 + .ranges = { 423 + { 16 * 137.25 /*MHz*/, 0x01, }, 424 + { 16 * 317.25 /*MHz*/, 0x02, }, 425 + { 16 * 999.99 , 0x08, }, 426 + }, 427 + .config = 0x8e, 428 + }, 429 + [TUNER_Samsung_PAL_TCPM9091PD27] = { /* Samsung PAL */ 430 + .name = "Samsung PAL TCPM9091PD27", 431 + .count = 3, 432 + .ranges = { 433 + { 16 * 169 /*MHz*/, 0xa0, }, 434 + { 16 * 464 /*MHz*/, 0x90, }, 435 + { 16 * 999.99 , 0x30, }, 436 + }, 437 + .config = 0x8e, 438 + }, 439 + [TUNER_MT2032] = { /* Microtune PAL|NTSC */ 440 + .name = "MT20xx universal", 178 441 /* see mt20xx.c for details */ }, 179 - { "Temic PAL_BG (4106 FH5)", TEMIC, PAL, 180 - 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, 181 - { "Temic PAL_DK/SECAM_L (4012 FY5)", TEMIC, PAL, 182 - 16*140.25, 16*463.25, 0x02,0x04,0x01,0x8e,623}, 183 - { "Temic NTSC (4136 FY5)", TEMIC, NTSC, 184 - 16*158.00, 16*453.00, 0xa0,0x90,0x30,0x8e,732}, 185 - { "LG PAL (newer TAPC series)", LGINNOTEK, PAL, 186 - 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,623}, 187 - { "Philips PAL/SECAM multi (FM1216ME MK3)", Philips, PAL, 188 - 16*158.00,16*442.00,0x01,0x02,0x04,0x8e,623 }, 189 - { "LG NTSC (newer TAPC series)", LGINNOTEK, NTSC, 190 - 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,732}, 442 + [TUNER_TEMIC_4106FH5] = { /* TEMIC PAL */ 443 + .name = "Temic PAL_BG (4106 FH5)", 444 + .count = 3, 445 + .ranges = { 446 + { 16 * 141.00 /*MHz*/, 0xa0, }, 447 + { 16 * 464.00 /*MHz*/, 0x90, }, 448 + { 16 * 999.99 , 0x30, }, 449 + }, 450 + .config = 0x8e, 451 + }, 452 + [TUNER_TEMIC_4012FY5] = { /* TEMIC PAL */ 453 + .name = "Temic PAL_DK/SECAM_L (4012 FY5)", 454 + .count = 3, 455 + .ranges = { 456 + { 16 * 140.25 /*MHz*/, 0x02, }, 457 + { 16 * 463.25 /*MHz*/, 0x04, }, 458 + { 16 * 999.99 , 0x01, }, 459 + }, 460 + .config = 0x8e, 461 + }, 462 + [TUNER_TEMIC_4136FY5] = { /* TEMIC NTSC */ 463 + .name = "Temic NTSC (4136 FY5)", 464 + .count = 3, 465 + .ranges = { 466 + { 16 * 158.00 /*MHz*/, 0xa0, }, 467 + { 16 * 453.00 /*MHz*/, 0x90, }, 468 + { 16 * 999.99 , 0x30, }, 469 + }, 470 + .config = 0x8e, 471 + }, 472 + [TUNER_LG_PAL_NEW_TAPC] = { /* LGINNOTEK PAL */ 473 + .name = "LG PAL (newer TAPC series)", 474 + .count = 3, 475 + .ranges = { 476 + { 16 * 170.00 /*MHz*/, 0x01, }, 477 + { 16 * 450.00 /*MHz*/, 0x02, }, 478 + { 16 * 999.99 , 0x08, }, 479 + }, 480 + .config = 0x8e, 481 + }, 482 + [TUNER_PHILIPS_FM1216ME_MK3] = { /* Philips PAL */ 483 + .name = "Philips PAL/SECAM multi (FM1216ME MK3)", 484 + .count = 3, 485 + .ranges = { 486 + { 16 * 158.00 /*MHz*/, 0x01, }, 487 + { 16 * 442.00 /*MHz*/, 0x02, }, 488 + { 16 * 999.99 , 0x04, }, 489 + }, 490 + .config = 0x8e, 491 + }, 492 + [TUNER_LG_NTSC_NEW_TAPC] = { /* LGINNOTEK NTSC */ 493 + .name = "LG NTSC (newer TAPC series)", 494 + .count = 3, 495 + .ranges = { 496 + { 16 * 170.00 /*MHz*/, 0x01, }, 497 + { 16 * 450.00 /*MHz*/, 0x02, }, 498 + { 16 * 999.99 , 0x08, }, 499 + }, 500 + .config = 0x8e, 501 + }, 191 502 192 503 /* 40-49 */ 193 - { "HITACHI V7-J180AT", HITACHI, NTSC, 194 - 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,940 }, 195 - { "Philips PAL_MK (FI1216 MK)", Philips, PAL, 196 - 16*140.25,16*463.25,0x01,0xc2,0xcf,0x8e,623}, 197 - { "Philips 1236D ATSC/NTSC daul in", Philips, ATSC, 198 - 16*157.25,16*454.00,0xa0,0x90,0x30,0x8e,732}, 199 - { "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", Philips, NTSC, 200 - 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732}, 201 - { "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)", Philips, NTSC, 202 - 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732}, 203 - { "Microtune 4049 FM5", Microtune, PAL, 204 - 16*141.00,16*464.00,0xa0,0x90,0x30,0x8e,623}, 205 - { "Panasonic VP27s/ENGE4324D", Panasonic, NTSC, 206 - 16*160.00,16*454.00,0x01,0x02,0x08,0xce,940}, 207 - { "LG NTSC (TAPE series)", LGINNOTEK, NTSC, 208 - 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 }, 209 - { "Tenna TNF 8831 BGFF)", Philips, PAL, 210 - 16*161.25,16*463.25,0xa0,0x90,0x30,0x8e,623}, 211 - { "Microtune 4042 FI5 ATSC/NTSC dual in", Microtune, NTSC, 212 - 16*162.00,16*457.00,0xa2,0x94,0x31,0x8e,732}, 504 + [TUNER_HITACHI_NTSC] = { /* HITACHI NTSC */ 505 + .name = "HITACHI V7-J180AT", 506 + .count = 3, 507 + .ranges = { 508 + { 16 * 170.00 /*MHz*/, 0x01, }, 509 + { 16 * 450.00 /*MHz*/, 0x02, }, 510 + { 16 * 999.99 , 0x08, }, 511 + }, 512 + .config = 0x8e, 513 + }, 514 + [TUNER_PHILIPS_PAL_MK] = { /* Philips PAL */ 515 + .name = "Philips PAL_MK (FI1216 MK)", 516 + .count = 3, 517 + .ranges = { 518 + { 16 * 140.25 /*MHz*/, 0x01, }, 519 + { 16 * 463.25 /*MHz*/, 0xc2, }, 520 + { 16 * 999.99 , 0xcf, }, 521 + }, 522 + .config = 0x8e, 523 + }, 524 + [TUNER_PHILIPS_ATSC] = { /* Philips ATSC */ 525 + .name = "Philips 1236D ATSC/NTSC dual in", 526 + .count = 3, 527 + .ranges = { 528 + { 16 * 157.25 /*MHz*/, 0xa0, }, 529 + { 16 * 454.00 /*MHz*/, 0x90, }, 530 + { 16 * 999.99 , 0x30, }, 531 + }, 532 + .config = 0x8e, 533 + }, 534 + [TUNER_PHILIPS_FM1236_MK3] = { /* Philips NTSC */ 535 + .name = "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", 536 + .count = 3, 537 + .ranges = { 538 + { 16 * 160.00 /*MHz*/, 0x01, }, 539 + { 16 * 442.00 /*MHz*/, 0x02, }, 540 + { 16 * 999.99 , 0x04, }, 541 + }, 542 + .config = 0x8e, 543 + }, 544 + [TUNER_PHILIPS_4IN1] = { /* Philips NTSC */ 545 + .name = "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)", 546 + .count = 3, 547 + .ranges = { 548 + { 16 * 160.00 /*MHz*/, 0x01, }, 549 + { 16 * 442.00 /*MHz*/, 0x02, }, 550 + { 16 * 999.99 , 0x04, }, 551 + }, 552 + .config = 0x8e, 553 + }, 554 + [TUNER_MICROTUNE_4049FM5] = { /* Microtune PAL */ 555 + .name = "Microtune 4049 FM5", 556 + .count = 3, 557 + .ranges = { 558 + { 16 * 141.00 /*MHz*/, 0xa0, }, 559 + { 16 * 464.00 /*MHz*/, 0x90, }, 560 + { 16 * 999.99 , 0x30, }, 561 + }, 562 + .config = 0x8e, 563 + }, 564 + [TUNER_PANASONIC_VP27] = { /* Panasonic NTSC */ 565 + .name = "Panasonic VP27s/ENGE4324D", 566 + .count = 3, 567 + .ranges = { 568 + { 16 * 160.00 /*MHz*/, 0x01, }, 569 + { 16 * 454.00 /*MHz*/, 0x02, }, 570 + { 16 * 999.99 , 0x08, }, 571 + }, 572 + .config = 0xce, 573 + }, 574 + [TUNER_LG_NTSC_TAPE] = { /* LGINNOTEK NTSC */ 575 + .name = "LG NTSC (TAPE series)", 576 + .count = 3, 577 + .ranges = { 578 + { 16 * 160.00 /*MHz*/, 0x01, }, 579 + { 16 * 442.00 /*MHz*/, 0x02, }, 580 + { 16 * 999.99 , 0x04, }, 581 + }, 582 + .config = 0x8e, 583 + }, 584 + [TUNER_TNF_8831BGFF] = { /* Philips PAL */ 585 + .name = "Tenna TNF 8831 BGFF)", 586 + .count = 3, 587 + .ranges = { 588 + { 16 * 161.25 /*MHz*/, 0xa0, }, 589 + { 16 * 463.25 /*MHz*/, 0x90, }, 590 + { 16 * 999.99 , 0x30, }, 591 + }, 592 + .config = 0x8e, 593 + }, 594 + [TUNER_MICROTUNE_4042FI5] = { /* Microtune NTSC */ 595 + .name = "Microtune 4042 FI5 ATSC/NTSC dual in", 596 + .count = 3, 597 + .ranges = { 598 + { 16 * 162.00 /*MHz*/, 0xa2, }, 599 + { 16 * 457.00 /*MHz*/, 0x94, }, 600 + { 16 * 999.99 , 0x31, }, 601 + }, 602 + .config = 0x8e, 603 + }, 213 604 214 605 /* 50-59 */ 215 - { "TCL 2002N", TCL, NTSC, 216 - 16*172.00,16*448.00,0x01,0x02,0x08,0x8e,732}, 217 - { "Philips PAL/SECAM_D (FM 1256 I-H3)", Philips, PAL, 218 - 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,623 }, 219 - { "Thomson DDT 7610 (ATSC/NTSC)", THOMSON, ATSC, 220 - 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, 221 - { "Philips FQ1286", Philips, NTSC, 222 - 16*160.00,16*454.00,0x41,0x42,0x04,0x8e,940}, /* UHF band untested */ 223 - { "tda8290+75", Philips, PAL|NTSC, 606 + [TUNER_TCL_2002N] = { /* TCL NTSC */ 607 + .name = "TCL 2002N", 608 + .count = 3, 609 + .ranges = { 610 + { 16 * 172.00 /*MHz*/, 0x01, }, 611 + { 16 * 448.00 /*MHz*/, 0x02, }, 612 + { 16 * 999.99 , 0x08, }, 613 + }, 614 + .config = 0x8e, 615 + }, 616 + [TUNER_PHILIPS_FM1256_IH3] = { /* Philips PAL */ 617 + .name = "Philips PAL/SECAM_D (FM 1256 I-H3)", 618 + .count = 3, 619 + .ranges = { 620 + { 16 * 160.00 /*MHz*/, 0x01, }, 621 + { 16 * 442.00 /*MHz*/, 0x02, }, 622 + { 16 * 999.99 , 0x04, }, 623 + }, 624 + .config = 0x8e, 625 + }, 626 + [TUNER_THOMSON_DTT7610] = { /* THOMSON ATSC */ 627 + .name = "Thomson DTT 7610 (ATSC/NTSC)", 628 + .count = 3, 629 + .ranges = { 630 + { 16 * 157.25 /*MHz*/, 0x39, }, 631 + { 16 * 454.00 /*MHz*/, 0x3a, }, 632 + { 16 * 999.99 , 0x3c, }, 633 + }, 634 + .config = 0x8e, 635 + }, 636 + [TUNER_PHILIPS_FQ1286] = { /* Philips NTSC */ 637 + .name = "Philips FQ1286", 638 + .count = 3, 639 + .ranges = { 640 + { 16 * 160.00 /*MHz*/, 0x41, }, 641 + { 16 * 454.00 /*MHz*/, 0x42, }, 642 + { 16 * 999.99 , 0x04, }, 643 + }, 644 + .config = 0x8e, 645 + }, 646 + [TUNER_PHILIPS_TDA8290] = { /* Philips PAL|NTSC */ 647 + .name = "tda8290+75", 224 648 /* see tda8290.c for details */ }, 225 - { "TCL 2002MB", TCL, PAL, 226 - 16*170.00, 16*450.00, 0x01,0x02,0x08,0xce,623}, 227 - { "Philips PAL/SECAM multi (FQ1216AME MK4)", Philips, PAL, 228 - 16*160.00,16*442.00,0x01,0x02,0x04,0xce,623 }, 229 - { "Philips FQ1236A MK4", Philips, NTSC, 230 - 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 }, 231 - { "Ymec TVision TVF-8531MF/8831MF/8731MF", Philips, NTSC, 232 - 16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732}, 233 - { "Ymec TVision TVF-5533MF", Philips, NTSC, 234 - 16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732}, 649 + [TUNER_TCL_2002MB] = { /* TCL PAL */ 650 + .name = "TCL 2002MB", 651 + .count = 3, 652 + .ranges = { 653 + { 16 * 170.00 /*MHz*/, 0x01, }, 654 + { 16 * 450.00 /*MHz*/, 0x02, }, 655 + { 16 * 999.99 , 0x08, }, 656 + }, 657 + .config = 0xce, 658 + }, 659 + [TUNER_PHILIPS_FQ1216AME_MK4] = { /* Philips PAL */ 660 + .name = "Philips PAL/SECAM multi (FQ1216AME MK4)", 661 + .count = 3, 662 + .ranges = { 663 + { 16 * 160.00 /*MHz*/, 0x01, }, 664 + { 16 * 442.00 /*MHz*/, 0x02, }, 665 + { 16 * 999.99 , 0x04, }, 666 + }, 667 + .config = 0xce, 668 + }, 669 + [TUNER_PHILIPS_FQ1236A_MK4] = { /* Philips NTSC */ 670 + .name = "Philips FQ1236A MK4", 671 + .count = 3, 672 + .ranges = { 673 + { 16 * 160.00 /*MHz*/, 0x01, }, 674 + { 16 * 442.00 /*MHz*/, 0x02, }, 675 + { 16 * 999.99 , 0x04, }, 676 + }, 677 + .config = 0x8e, 678 + }, 679 + [TUNER_YMEC_TVF_8531MF] = { /* Philips NTSC */ 680 + .name = "Ymec TVision TVF-8531MF/8831MF/8731MF", 681 + .count = 3, 682 + .ranges = { 683 + { 16 * 160.00 /*MHz*/, 0xa0, }, 684 + { 16 * 454.00 /*MHz*/, 0x90, }, 685 + { 16 * 999.99 , 0x30, }, 686 + }, 687 + .config = 0x8e, 688 + }, 689 + [TUNER_YMEC_TVF_5533MF] = { /* Philips NTSC */ 690 + .name = "Ymec TVision TVF-5533MF", 691 + .count = 3, 692 + .ranges = { 693 + { 16 * 160.00 /*MHz*/, 0x01, }, 694 + { 16 * 454.00 /*MHz*/, 0x02, }, 695 + { 16 * 999.99 , 0x04, }, 696 + }, 697 + .config = 0x8e, 698 + }, 235 699 236 700 /* 60-69 */ 237 - { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC, 238 - 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, 239 - { "Tena TNF9533-D/IF/TNF9533-B/DF", Philips, PAL, 240 - 16*160.25,16*464.25,0x01,0x02,0x04,0x8e,623}, 241 - { "Philips TEA5767HN FM Radio", Philips, RADIO, 701 + [TUNER_THOMSON_DTT761X] = { /* THOMSON ATSC */ 702 + /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */ 703 + .name = "Thomson DTT 761X (ATSC/NTSC)", 704 + .count = 3, 705 + .ranges = { 706 + { 16 * 145.25 /*MHz*/, 0x39, }, 707 + { 16 * 415.25 /*MHz*/, 0x3a, }, 708 + { 16 * 999.99 , 0x3c, }, 709 + }, 710 + .config = 0x8e, 711 + }, 712 + [TUNER_TENA_9533_DI] = { /* Philips PAL */ 713 + .name = "Tena TNF9533-D/IF/TNF9533-B/DF", 714 + .count = 3, 715 + .ranges = { 716 + { 16 * 160.25 /*MHz*/, 0x01, }, 717 + { 16 * 464.25 /*MHz*/, 0x02, }, 718 + { 16 * 999.99 , 0x04, }, 719 + }, 720 + .config = 0x8e, 721 + }, 722 + [TUNER_TEA5767] = { /* Philips RADIO */ 723 + .name = "Philips TEA5767HN FM Radio", 242 724 /* see tea5767.c for details */}, 243 - { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL, 244 - 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 }, 245 - { "LG TDVS-H062F/TUA6034", LGINNOTEK, ATSC, 246 - 16*160.00,16*455.00,0x01,0x02,0x04,0x8e,732}, 247 - { "Ymec TVF66T5-B/DFF", Philips, PAL, 248 - 16*160.25,16*464.25,0x01,0x02,0x08,0x8e,623}, 249 - { "LG NTSC (TALN mini series)", LGINNOTEK, NTSC, 250 - 16*137.25,16*373.25,0x01,0x02,0x08,0x8e,732 }, 251 - { "Philips TD1316 Hybrid Tuner", Philips, PAL, 252 - 16*160.00,16*442.00,0xa1,0xa2,0xa4,0xc8,623 }, 253 - { "Philips TUV1236D ATSC/NTSC dual in", Philips, ATSC, 254 - 16*157.25,16*454.00,0x01,0x02,0x04,0xce,732 }, 255 - { "Tena TNF 5335 MF", Philips, NTSC, 256 - 16*157.25,16*454.00,0x01,0x02,0x04,0x8e,732 }, 725 + [TUNER_PHILIPS_FMD1216ME_MK3] = { /* Philips PAL */ 726 + .name = "Philips FMD1216ME MK3 Hybrid Tuner", 727 + .count = 3, 728 + .ranges = { 729 + { 16 * 160.00 /*MHz*/, 0x51, }, 730 + { 16 * 442.00 /*MHz*/, 0x52, }, 731 + { 16 * 999.99 , 0x54, }, 732 + }, 733 + .config = 0x86, 734 + }, 735 + [TUNER_LG_TDVS_H062F] = { /* LGINNOTEK ATSC */ 736 + .name = "LG TDVS-H062F/TUA6034", 737 + .count = 3, 738 + .ranges = { 739 + { 16 * 160.00 /*MHz*/, 0x01 }, 740 + { 16 * 455.00 /*MHz*/, 0x02 }, 741 + { 16 * 999.99 , 0x04 }, 742 + }, 743 + .config = 0x8e, 744 + }, 745 + [TUNER_YMEC_TVF66T5_B_DFF] = { /* Philips PAL */ 746 + .name = "Ymec TVF66T5-B/DFF", 747 + .count = 3, 748 + .ranges = { 749 + { 16 * 160.25 /*MHz*/, 0x01, }, 750 + { 16 * 464.25 /*MHz*/, 0x02, }, 751 + { 16 * 999.99 , 0x08, }, 752 + }, 753 + .config = 0x8e, 754 + }, 755 + [TUNER_LG_NTSC_TALN_MINI] = { /* LGINNOTEK NTSC */ 756 + .name = "LG NTSC (TALN mini series)", 757 + .count = 3, 758 + .ranges = { 759 + { 16 * 137.25 /*MHz*/, 0x01, }, 760 + { 16 * 373.25 /*MHz*/, 0x02, }, 761 + { 16 * 999.99 , 0x08, }, 762 + }, 763 + .config = 0x8e, 764 + }, 765 + [TUNER_PHILIPS_TD1316] = { /* Philips PAL */ 766 + .name = "Philips TD1316 Hybrid Tuner", 767 + .count = 3, 768 + .ranges = { 769 + { 16 * 160.00 /*MHz*/, 0xa1, }, 770 + { 16 * 442.00 /*MHz*/, 0xa2, }, 771 + { 16 * 999.99 , 0xa4, }, 772 + }, 773 + .config = 0xc8, 774 + }, 775 + [TUNER_PHILIPS_TUV1236D] = { /* Philips ATSC */ 776 + .name = "Philips TUV1236D ATSC/NTSC dual in", 777 + .count = 3, 778 + .ranges = { 779 + { 16 * 157.25 /*MHz*/, 0x01, }, 780 + { 16 * 454.00 /*MHz*/, 0x02, }, 781 + { 16 * 999.99 , 0x04, }, 782 + }, 783 + .config = 0xce, 784 + }, 785 + [TUNER_TNF_5335MF] = { /* Philips NTSC */ 786 + .name = "Tena TNF 5335 MF", 787 + .count = 3, 788 + .ranges = { 789 + { 16 * 157.25 /*MHz*/, 0x01, }, 790 + { 16 * 454.00 /*MHz*/, 0x02, }, 791 + { 16 * 999.99 , 0x04, }, 792 + }, 793 + .config = 0x8e, 794 + }, 257 795 }; 258 796 259 797 unsigned const int tuner_count = ARRAY_SIZE(tuners); ··· 843 305 u16 div; 844 306 struct tunertype *tun; 845 307 unsigned char buffer[4]; 846 - int rc; 308 + int rc, IFPCoff, i; 847 309 848 310 tun = &tuners[t->type]; 849 - if (freq < tun->thresh1) { 850 - config = tun->VHF_L; 851 - tuner_dbg("tv: VHF lowrange\n"); 852 - } else if (freq < tun->thresh2) { 853 - config = tun->VHF_H; 854 - tuner_dbg("tv: VHF high range\n"); 855 - } else { 856 - config = tun->UHF; 857 - tuner_dbg("tv: UHF range\n"); 311 + for (i = 0; i < tun->count; i++) { 312 + if (freq > tun->ranges[i].thresh) 313 + continue; 314 + break; 858 315 } 859 - 316 + config = tun->ranges[i].cb; 317 + /* i == 0 -> VHF_LO */ 318 + /* i == 1 -> VHF_HI */ 319 + /* i == 2 -> UHF */ 320 + tuner_dbg("tv: range %d\n",i); 860 321 861 322 /* tv norm specific stuff for multi-norm tuners */ 862 323 switch (t->type) { ··· 957 420 * frequency in case (wanted frequency < current frequency). 958 421 */ 959 422 960 - div=freq + tun->IFPCoff; 423 + /* IFPCoff = Video Intermediate Frequency - Vif: 424 + 940 =16*58.75 NTSC/J (Japan) 425 + 732 =16*45.75 M/N STD 426 + 704 =16*44 ATSC (at DVB code) 427 + 632 =16*39.50 I U.K. 428 + 622.4=16*38.90 B/G D/K I, L STD 429 + 592 =16*37.00 D China 430 + 590 =16.36.875 B Australia 431 + 543.2=16*33.95 L' STD 432 + 171.2=16*10.70 FM Radio (at set_radio_freq) 433 + */ 434 + 435 + if (t->std == V4L2_STD_NTSC_M_JP) { 436 + IFPCoff = 940; 437 + } else if ((t->std & V4L2_STD_MN) && 438 + !(t->std & ~V4L2_STD_MN)) { 439 + IFPCoff = 732; 440 + } else if (t->std == V4L2_STD_SECAM_LC) { 441 + IFPCoff = 543; 442 + } else { 443 + IFPCoff = 623; 444 + } 445 + 446 + div=freq + IFPCoff + offset; 447 + 448 + tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, Offset=%d.%02d MHz, div=%0d\n", 449 + freq / 16, freq % 16 * 100 / 16, 450 + IFPCoff / 16, IFPCoff % 16 * 100 / 16, 451 + offset / 16, offset % 16 * 100 / 16, 452 + div); 453 + 961 454 if (t->type == TUNER_PHILIPS_SECAM && freq < t->freq) { 962 455 buffer[0] = tun->config; 963 456 buffer[1] = config;
+111 -68
drivers/media/video/tvaudio.c
··· 31 31 #include <linux/smp_lock.h> 32 32 33 33 #include <media/audiochip.h> 34 + #include <media/v4l2-common.h> 34 35 35 36 #include "tvaudio.h" 36 37 ··· 46 45 MODULE_LICENSE("GPL"); 47 46 48 47 #define UNSET (-1U) 49 - 50 - #define tvaudio_info(fmt, arg...) do {\ 51 - printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ 52 - chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) 53 - #define tvaudio_warn(fmt, arg...) do {\ 54 - printk(KERN_WARNING "tvaudio %d-%04x: " fmt, \ 55 - chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) 56 - #define tvaudio_dbg(fmt, arg...) do {\ 57 - if (debug) \ 58 - printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ 59 - chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) 60 48 61 49 /* ---------------------------------------------------------------------- */ 62 50 /* our structs */ ··· 121 131 /* current settings */ 122 132 __u16 left,right,treble,bass,mode; 123 133 int prevmode; 124 - int norm; 134 + int radio; 125 135 126 136 /* thread */ 127 137 pid_t tpid; ··· 131 141 int done; 132 142 int watch_stereo; 133 143 }; 134 - 135 - #define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */ 136 144 137 145 /* ---------------------------------------------------------------------- */ 138 146 /* i2c addresses */ ··· 159 171 unsigned char buffer[2]; 160 172 161 173 if (-1 == subaddr) { 162 - tvaudio_dbg("%s: chip_write: 0x%x\n", 174 + v4l_dbg(1, &chip->c, "%s: chip_write: 0x%x\n", 163 175 chip->c.name, val); 164 176 chip->shadow.bytes[1] = val; 165 177 buffer[0] = val; 166 178 if (1 != i2c_master_send(&chip->c,buffer,1)) { 167 - tvaudio_warn("%s: I/O error (write 0x%x)\n", 179 + v4l_warn(&chip->c, "%s: I/O error (write 0x%x)\n", 168 180 chip->c.name, val); 169 181 return -1; 170 182 } 171 183 } else { 172 - tvaudio_dbg("%s: chip_write: reg%d=0x%x\n", 184 + v4l_dbg(1, &chip->c, "%s: chip_write: reg%d=0x%x\n", 173 185 chip->c.name, subaddr, val); 174 186 chip->shadow.bytes[subaddr+1] = val; 175 187 buffer[0] = subaddr; 176 188 buffer[1] = val; 177 189 if (2 != i2c_master_send(&chip->c,buffer,2)) { 178 - tvaudio_warn("%s: I/O error (write reg%d=0x%x)\n", 190 + v4l_warn(&chip->c, "%s: I/O error (write reg%d=0x%x)\n", 179 191 chip->c.name, subaddr, val); 180 192 return -1; 181 193 } ··· 200 212 unsigned char buffer; 201 213 202 214 if (1 != i2c_master_recv(&chip->c,&buffer,1)) { 203 - tvaudio_warn("%s: I/O error (read)\n", 215 + v4l_warn(&chip->c, "%s: I/O error (read)\n", 204 216 chip->c.name); 205 217 return -1; 206 218 } 207 - tvaudio_dbg("%s: chip_read: 0x%x\n",chip->c.name, buffer); 219 + v4l_dbg(1, &chip->c, "%s: chip_read: 0x%x\n",chip->c.name, buffer); 208 220 return buffer; 209 221 } 210 222 ··· 219 231 write[0] = subaddr; 220 232 221 233 if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { 222 - tvaudio_warn("%s: I/O error (read2)\n", chip->c.name); 234 + v4l_warn(&chip->c, "%s: I/O error (read2)\n", chip->c.name); 223 235 return -1; 224 236 } 225 - tvaudio_dbg("%s: chip_read2: reg%d=0x%x\n", 237 + v4l_dbg(1, &chip->c, "%s: chip_read2: reg%d=0x%x\n", 226 238 chip->c.name, subaddr,read[0]); 227 239 return read[0]; 228 240 } ··· 235 247 return 0; 236 248 237 249 /* update our shadow register set; print bytes if (debug > 0) */ 238 - tvaudio_dbg("%s: chip_cmd(%s): reg=%d, data:", 250 + v4l_dbg(1, &chip->c, "%s: chip_cmd(%s): reg=%d, data:", 239 251 chip->c.name, name,cmd->bytes[0]); 240 252 for (i = 1; i < cmd->count; i++) { 241 253 if (debug) ··· 247 259 248 260 /* send data to the chip */ 249 261 if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) { 250 - tvaudio_warn("%s: I/O error (%s)\n", chip->c.name, name); 262 + v4l_warn(&chip->c, "%s: I/O error (%s)\n", chip->c.name, name); 251 263 return -1; 252 264 } 253 265 return 0; ··· 274 286 275 287 daemonize("%s", chip->c.name); 276 288 allow_signal(SIGTERM); 277 - tvaudio_dbg("%s: thread started\n", chip->c.name); 289 + v4l_dbg(1, &chip->c, "%s: thread started\n", chip->c.name); 278 290 279 291 for (;;) { 280 292 add_wait_queue(&chip->wq, &wait); ··· 286 298 try_to_freeze(); 287 299 if (chip->done || signal_pending(current)) 288 300 break; 289 - tvaudio_dbg("%s: thread wakeup\n", chip->c.name); 301 + v4l_dbg(1, &chip->c, "%s: thread wakeup\n", chip->c.name); 290 302 291 303 /* don't do anything for radio or if mode != auto */ 292 - if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0) 304 + if (chip->radio || chip->mode != 0) 293 305 continue; 294 306 295 307 /* have a look what's going on */ ··· 299 311 mod_timer(&chip->wt, jiffies+2*HZ); 300 312 } 301 313 302 - tvaudio_dbg("%s: thread exiting\n", chip->c.name); 314 + v4l_dbg(1, &chip->c, "%s: thread exiting\n", chip->c.name); 303 315 complete_and_exit(&chip->texit, 0); 304 316 return 0; 305 317 } ··· 312 324 if (mode == chip->prevmode) 313 325 return; 314 326 315 - tvaudio_dbg("%s: thread checkmode\n", chip->c.name); 327 + v4l_dbg(1, &chip->c, "%s: thread checkmode\n", chip->c.name); 316 328 chip->prevmode = mode; 317 329 318 330 if (mode & VIDEO_SOUND_STEREO) ··· 359 371 if (val & TDA9840_ST_STEREO) 360 372 mode |= VIDEO_SOUND_STEREO; 361 373 362 - tvaudio_dbg ("tda9840_getmode(): raw chip read: %d, return: %d\n", 374 + v4l_dbg(1, &chip->c, "tda9840_getmode(): raw chip read: %d, return: %d\n", 363 375 val, mode); 364 376 return mode; 365 377 } ··· 655 667 mode |= VIDEO_SOUND_STEREO; 656 668 if (val & TDA9873_DUAL) 657 669 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; 658 - tvaudio_dbg ("tda9873_getmode(): raw chip read: %d, return: %d\n", 670 + v4l_dbg(1, &chip->c, "tda9873_getmode(): raw chip read: %d, return: %d\n", 659 671 val, mode); 660 672 return mode; 661 673 } ··· 666 678 /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ 667 679 668 680 if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { 669 - tvaudio_dbg("tda9873_setmode(): external input\n"); 681 + v4l_dbg(1, &chip->c, "tda9873_setmode(): external input\n"); 670 682 return; 671 683 } 672 684 673 - tvaudio_dbg("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); 674 - tvaudio_dbg("tda9873_setmode(): sw_data = %d\n", sw_data); 685 + v4l_dbg(1, &chip->c, "tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); 686 + v4l_dbg(1, &chip->c, "tda9873_setmode(): sw_data = %d\n", sw_data); 675 687 676 688 switch (mode) { 677 689 case VIDEO_SOUND_MONO: ··· 692 704 } 693 705 694 706 chip_write(chip, TDA9873_SW, sw_data); 695 - tvaudio_dbg("tda9873_setmode(): req. mode %d; chip_write: %d\n", 707 + v4l_dbg(1, &chip->c, "tda9873_setmode(): req. mode %d; chip_write: %d\n", 696 708 mode, sw_data); 697 709 } 698 710 ··· 831 843 chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); 832 844 chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */ 833 845 } 834 - tvaudio_dbg("tda9874a_setup(): %s [0x%02X].\n", 846 + v4l_dbg(1, &chip->c, "tda9874a_setup(): %s [0x%02X].\n", 835 847 tda9874a_modelist[tda9874a_STD].name,tda9874a_STD); 836 848 return 1; 837 849 } ··· 874 886 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; 875 887 } 876 888 877 - tvaudio_dbg("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", 889 + v4l_dbg(1, &chip->c, "tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", 878 890 dsr, nsr, necr, mode); 879 891 return mode; 880 892 } ··· 920 932 chip_write(chip, TDA9874A_AOSR, aosr); 921 933 chip_write(chip, TDA9874A_MDACOSR, mdacosr); 922 934 923 - tvaudio_dbg("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", 935 + v4l_dbg(1, &chip->c, "tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", 924 936 mode, aosr, mdacosr); 925 937 926 938 } else { /* dic == 0x07 */ ··· 955 967 chip_write(chip, TDA9874A_FMMR, fmmr); 956 968 chip_write(chip, TDA9874A_AOSR, aosr); 957 969 958 - tvaudio_dbg("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", 970 + v4l_dbg(1, &chip->c, "tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", 959 971 mode, fmmr, aosr); 960 972 } 961 973 } ··· 969 981 if(-1 == (sic = chip_read2(chip,TDA9874A_SIC))) 970 982 return 0; 971 983 972 - tvaudio_dbg("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); 984 + v4l_dbg(1, &chip->c, "tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); 973 985 974 986 if((dic == 0x11)||(dic == 0x07)) { 975 - tvaudio_info("found tda9874%s.\n", (dic == 0x11) ? "a":"h"); 987 + v4l_info(&chip->c, "found tda9874%s.\n", (dic == 0x11) ? "a":"h"); 976 988 tda9874a_dic = dic; /* remember device id. */ 977 989 return 1; 978 990 } ··· 1184 1196 }else if (!(val & TA8874Z_B0)){ 1185 1197 mode |= VIDEO_SOUND_STEREO; 1186 1198 } 1187 - /* tvaudio_dbg ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */ 1199 + /* v4l_dbg(1, &chip->c, "ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */ 1188 1200 return mode; 1189 1201 } 1190 1202 ··· 1197 1209 { 1198 1210 int update = 1; 1199 1211 audiocmd *t = NULL; 1200 - tvaudio_dbg("ta8874z_setmode(): mode: 0x%02x\n", mode); 1212 + v4l_dbg(1, &chip->c, "ta8874z_setmode(): mode: 0x%02x\n", mode); 1201 1213 1202 1214 switch(mode){ 1203 1215 case VIDEO_SOUND_MONO: ··· 1478 1490 i2c_set_clientdata(&chip->c, chip); 1479 1491 1480 1492 /* find description for the chip */ 1481 - tvaudio_dbg("chip found @ 0x%x\n", addr<<1); 1493 + v4l_dbg(1, &chip->c, "chip found @ 0x%x\n", addr<<1); 1482 1494 for (desc = chiplist; desc->name != NULL; desc++) { 1483 1495 if (0 == *(desc->insmodopt)) 1484 1496 continue; ··· 1490 1502 break; 1491 1503 } 1492 1504 if (desc->name == NULL) { 1493 - tvaudio_dbg("no matching chip description found\n"); 1505 + v4l_dbg(1, &chip->c, "no matching chip description found\n"); 1494 1506 return -EIO; 1495 1507 } 1496 - tvaudio_info("%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name); 1508 + v4l_info(&chip->c, "%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name); 1497 1509 if (desc->flags) { 1498 - tvaudio_dbg("matches:%s%s%s.\n", 1510 + v4l_dbg(1, &chip->c, "matches:%s%s%s.\n", 1499 1511 (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", 1500 1512 (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", 1501 1513 (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); ··· 1538 1550 init_completion(&chip->texit); 1539 1551 chip->tpid = kernel_thread(chip_thread,(void *)chip,0); 1540 1552 if (chip->tpid < 0) 1541 - tvaudio_warn("%s: kernel_thread() failed\n", 1553 + v4l_warn(&chip->c, "%s: kernel_thread() failed\n", 1542 1554 chip->c.name); 1543 1555 wake_up_interruptible(&chip->wq); 1544 1556 } ··· 1551 1563 because dedicated drivers are used */ 1552 1564 if ((adap->id == I2C_HW_SAA7146)) 1553 1565 return 0; 1554 - #ifdef I2C_CLASS_TV_ANALOG 1555 1566 if (adap->class & I2C_CLASS_TV_ANALOG) 1556 1567 return i2c_probe(adap, &addr_data, chip_attach); 1557 - #else 1558 - switch (adap->id) { 1559 - case I2C_HW_B_BT848: 1560 - case I2C_HW_B_RIVA: 1561 - case I2C_HW_SAA7134: 1562 - return i2c_probe(adap, &addr_data, chip_attach); 1563 - } 1564 - #endif 1565 1568 return 0; 1566 1569 } 1567 1570 ··· 1583 1604 struct CHIPSTATE *chip = i2c_get_clientdata(client); 1584 1605 struct CHIPDESC *desc = chiplist + chip->type; 1585 1606 1586 - tvaudio_dbg("%s: chip_command 0x%x\n", chip->c.name, cmd); 1607 + v4l_dbg(1, &chip->c, "%s: chip_command 0x%x\n", chip->c.name, cmd); 1587 1608 1588 1609 switch (cmd) { 1589 1610 case AUDC_SET_INPUT: ··· 1596 1617 break; 1597 1618 1598 1619 case AUDC_SET_RADIO: 1599 - chip->norm = VIDEO_MODE_RADIO; 1620 + chip->radio = 1; 1600 1621 chip->watch_stereo = 0; 1601 1622 /* del_timer(&chip->wt); */ 1602 1623 break; ··· 1622 1643 va->bass = chip->bass; 1623 1644 va->treble = chip->treble; 1624 1645 } 1625 - if (chip->norm != VIDEO_MODE_RADIO) { 1646 + if (!chip->radio) { 1626 1647 if (desc->getmode) 1627 1648 va->mode = desc->getmode(chip); 1628 1649 else ··· 1657 1678 } 1658 1679 break; 1659 1680 } 1660 - case VIDIOCSCHAN: 1661 - { 1662 - struct video_channel *vc = arg; 1663 1681 1664 - chip->norm = vc->norm; 1682 + case VIDIOC_S_TUNER: 1683 + { 1684 + struct v4l2_tuner *vt = arg; 1685 + int mode = 0; 1686 + 1687 + switch (vt->audmode) { 1688 + case V4L2_TUNER_MODE_MONO: 1689 + mode = VIDEO_SOUND_MONO; 1690 + break; 1691 + case V4L2_TUNER_MODE_STEREO: 1692 + mode = VIDEO_SOUND_STEREO; 1693 + break; 1694 + case V4L2_TUNER_MODE_LANG1: 1695 + mode = VIDEO_SOUND_LANG1; 1696 + break; 1697 + case V4L2_TUNER_MODE_LANG2: 1698 + mode = VIDEO_SOUND_LANG2; 1699 + break; 1700 + default: 1701 + break; 1702 + } 1703 + 1704 + if (desc->setmode && mode) { 1705 + chip->watch_stereo = 0; 1706 + /* del_timer(&chip->wt); */ 1707 + chip->mode = mode; 1708 + desc->setmode(chip, mode); 1709 + } 1665 1710 break; 1666 1711 } 1667 - case VIDIOCSFREQ: 1712 + 1713 + case VIDIOC_G_TUNER: 1668 1714 { 1715 + struct v4l2_tuner *vt = arg; 1716 + int mode = VIDEO_SOUND_MONO; 1717 + 1718 + if (chip->radio) 1719 + break; 1720 + vt->audmode = 0; 1721 + vt->rxsubchans = 0; 1722 + vt->capability = V4L2_TUNER_CAP_STEREO | 1723 + V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; 1724 + 1725 + if (desc->getmode) 1726 + mode = desc->getmode(chip); 1727 + 1728 + if (mode & VIDEO_SOUND_MONO) 1729 + vt->rxsubchans |= V4L2_TUNER_SUB_MONO; 1730 + if (mode & VIDEO_SOUND_STEREO) 1731 + vt->rxsubchans |= V4L2_TUNER_SUB_STEREO; 1732 + if (mode & VIDEO_SOUND_LANG1) 1733 + vt->rxsubchans |= V4L2_TUNER_SUB_LANG1 | 1734 + V4L2_TUNER_SUB_LANG2; 1735 + 1736 + mode = chip->mode; 1737 + if (mode & VIDEO_SOUND_MONO) 1738 + vt->audmode = V4L2_TUNER_MODE_MONO; 1739 + if (mode & VIDEO_SOUND_STEREO) 1740 + vt->audmode = V4L2_TUNER_MODE_STEREO; 1741 + if (mode & VIDEO_SOUND_LANG1) 1742 + vt->audmode = V4L2_TUNER_MODE_LANG1; 1743 + if (mode & VIDEO_SOUND_LANG2) 1744 + vt->audmode = V4L2_TUNER_MODE_LANG2; 1745 + break; 1746 + } 1747 + 1748 + case VIDIOCSCHAN: 1749 + case VIDIOC_S_STD: 1750 + chip->radio = 0; 1751 + break; 1752 + 1753 + case VIDIOCSFREQ: 1754 + case VIDIOC_S_FREQUENCY: 1669 1755 chip->mode = 0; /* automatic */ 1670 1756 if (desc->checkmode) { 1671 1757 desc->setmode(chip,VIDEO_SOUND_MONO); ··· 1739 1695 mod_timer(&chip->wt, jiffies+2*HZ); 1740 1696 /* the thread will call checkmode() later */ 1741 1697 } 1742 - } 1698 + break; 1743 1699 } 1744 1700 return 0; 1745 1701 } 1746 1702 1747 - 1748 1703 static struct i2c_driver driver = { 1749 1704 .driver = { 1750 - .name = "generic i2c audio driver", 1705 + .name = "tvaudio", 1751 1706 }, 1752 1707 .id = I2C_DRIVERID_TVAUDIO, 1753 1708 .attach_adapter = chip_probe,
+21 -22
drivers/media/video/tveeprom.c
··· 40 40 41 41 #include <media/tuner.h> 42 42 #include <media/tveeprom.h> 43 + #include <media/v4l2-common.h> 43 44 #include <media/audiochip.h> 44 45 45 46 MODULE_DESCRIPTION("i2c Hauppauge eeprom decoder driver"); ··· 53 52 54 53 #define STRM(array,i) (i < sizeof(array)/sizeof(char*) ? array[i] : "unknown") 55 54 56 - #define tveeprom_info(fmt, arg...) do {\ 57 - printk(KERN_INFO "tveeprom %d-%04x: " fmt, \ 58 - c->adapter->nr, c->addr , ##arg); } while (0) 59 - #define tveeprom_warn(fmt, arg...) do {\ 60 - printk(KERN_WARNING "tveeprom %d-%04x: " fmt, \ 61 - c->adapter->nr, c->addr , ##arg); } while (0) 62 - #define tveeprom_dbg(fmt, arg...) do {\ 55 + #define tveeprom_info(fmt, arg...) \ 56 + v4l_printk(KERN_INFO, "tveeprom", c->adapter, c->addr, fmt , ## arg) 57 + #define tveeprom_warn(fmt, arg...) \ 58 + v4l_printk(KERN_WARNING, "tveeprom", c->adapter, c->addr, fmt , ## arg) 59 + #define tveeprom_dbg(fmt, arg...) do { \ 63 60 if (debug) \ 64 - printk(KERN_INFO "tveeprom %d-%04x: " fmt, \ 65 - c->adapter->nr, c->addr , ##arg); } while (0) 61 + v4l_printk(KERN_DEBUG, "tveeprom", c->adapter, c->addr, fmt , ## arg); \ 62 + } while (0) 66 63 67 - 68 - /* ----------------------------------------------------------------------- */ 69 - /* some hauppauge specific stuff */ 70 - 64 + /* 65 + * The Hauppauge eeprom uses an 8bit field to determine which 66 + * tuner formats the tuner supports. 67 + */ 71 68 static struct HAUPPAUGE_TUNER_FMT 72 69 { 73 70 int id; ··· 73 74 } 74 75 hauppauge_tuner_fmt[] = 75 76 { 76 - { 0x00000000, " unknown1" }, 77 - { 0x00000000, " unknown2" }, 78 - { 0x00000007, " PAL(B/G)" }, 79 - { 0x00001000, " NTSC(M)" }, 80 - { 0x00000010, " PAL(I)" }, 81 - { 0x00400000, " SECAM(L/L')" }, 82 - { 0x00000e00, " PAL(D/K)" }, 83 - { 0x03000000, " ATSC/DVB Digital" }, 77 + { V4L2_STD_UNKNOWN," UNKNOWN" }, 78 + { V4L2_STD_UNKNOWN," FM" }, 79 + { V4L2_STD_PAL_BG, " PAL(B/G)" }, 80 + { V4L2_STD_NTSC_M, " NTSC(M)" }, 81 + { V4L2_STD_PAL_I, " PAL(I)" }, 82 + { V4L2_STD_SECAM_L," SECAM(L/L')" }, 83 + { V4L2_STD_PAL_DK, " PAL(D/D1/K)" }, 84 + { V4L2_STD_ATSC, " ATSC/DVB Digital" }, 84 85 }; 85 86 86 87 /* This is the full list of possible tuners. Many thanks to Hauppauge for ··· 386 387 if ((eeprom_data[0] == 0x1a) && (eeprom_data[1] == 0xeb) && 387 388 (eeprom_data[2] == 0x67) && (eeprom_data[3] == 0x95)) 388 389 start=0xa0; /* Generic em28xx offset */ 389 - else if (((eeprom_data[0] & 0xf0) == 0x10) && 390 + else if (((eeprom_data[0] & 0xe1) == 0x01) && 390 391 (eeprom_data[1] == 0x00) && 391 392 (eeprom_data[2] == 0x00) && 392 393 (eeprom_data[8] == 0x84))
+1 -19
drivers/media/video/tvmixer.c
··· 227 227 } 228 228 229 229 static struct i2c_driver driver = { 230 - #ifdef I2C_PEC 231 230 .driver = { 232 - .name = "tv card mixer driver", 231 + .name = "tvmixer", 233 232 }, 234 - #else 235 - .name = "tv card mixer driver", 236 - #endif 237 233 .id = I2C_DRIVERID_TVMIXER, 238 234 .detach_adapter = tvmixer_adapters, 239 235 .attach_adapter = tvmixer_adapters, ··· 263 267 struct video_audio va; 264 268 int i,minor; 265 269 266 - #ifdef I2C_CLASS_TV_ANALOG 267 270 if (!(client->adapter->class & I2C_CLASS_TV_ANALOG)) 268 271 return -1; 269 - #else 270 - /* TV card ??? */ 271 - switch (client->adapter->id) { 272 - case I2C_HW_SMBUS_VOODOO3: 273 - case I2C_HW_B_BT848: 274 - case I2C_HW_B_RIVA: 275 - /* ok, have a look ... */ 276 - break; 277 - default: 278 - /* ignore that one */ 279 - return -1; 280 - } 281 - #endif 282 272 283 273 /* unregister ?? */ 284 274 for (i = 0; i < DEV_MAX; i++) {
+434 -101
drivers/media/video/tvp5150.c
··· 9 9 #include <linux/videodev.h> 10 10 #include <linux/delay.h> 11 11 #include <linux/video_decoder.h> 12 + #include <media/v4l2-common.h> 12 13 13 14 #include "tvp5150_reg.h" 14 15 ··· 29 28 module_param(debug, int, 0); 30 29 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 31 30 32 - #define dprintk(num, format, args...) \ 31 + #define tvp5150_info(fmt, arg...) do { \ 32 + printk(KERN_INFO "%s %d-%04x: " fmt, c->driver->driver.name, \ 33 + i2c_adapter_id(c->adapter), c->addr , ## arg); } while (0) 34 + #define tvp5150_dbg(num, fmt, arg...) \ 33 35 do { \ 34 36 if (debug >= num) \ 35 - printk(format, ##args); \ 36 - } while (0) 37 + printk(KERN_DEBUG "%s debug %d-%04x: " fmt,\ 38 + c->driver->driver.name, \ 39 + i2c_adapter_id(c->adapter), \ 40 + c->addr , ## arg); } while (0) 37 41 38 42 /* supported controls */ 39 43 static struct v4l2_queryctrl tvp5150_qctrl[] = { 40 44 { 41 - .id = V4L2_CID_BRIGHTNESS, 42 - .type = V4L2_CTRL_TYPE_INTEGER, 43 - .name = "Brightness", 44 - .minimum = 0, 45 - .maximum = 255, 46 - .step = 1, 47 - .default_value = 0, 48 - .flags = 0, 49 - }, { 50 - .id = V4L2_CID_CONTRAST, 51 - .type = V4L2_CTRL_TYPE_INTEGER, 52 - .name = "Contrast", 53 - .minimum = 0, 54 - .maximum = 255, 55 - .step = 0x1, 56 - .default_value = 0x10, 57 - .flags = 0, 58 - }, { 45 + .id = V4L2_CID_BRIGHTNESS, 46 + .type = V4L2_CTRL_TYPE_INTEGER, 47 + .name = "Brightness", 48 + .minimum = 0, 49 + .maximum = 255, 50 + .step = 1, 51 + .default_value = 0, 52 + .flags = 0, 53 + }, { 54 + .id = V4L2_CID_CONTRAST, 55 + .type = V4L2_CTRL_TYPE_INTEGER, 56 + .name = "Contrast", 57 + .minimum = 0, 58 + .maximum = 255, 59 + .step = 0x1, 60 + .default_value = 0x10, 61 + .flags = 0, 62 + }, { 59 63 .id = V4L2_CID_SATURATION, 60 64 .type = V4L2_CTRL_TYPE_INTEGER, 61 65 .name = "Saturation", ··· 69 63 .step = 0x1, 70 64 .default_value = 0x10, 71 65 .flags = 0, 72 - }, { 73 - .id = V4L2_CID_HUE, 74 - .type = V4L2_CTRL_TYPE_INTEGER, 75 - .name = "Hue", 76 - .minimum = -128, 77 - .maximum = 127, 78 - .step = 0x1, 79 - .default_value = 0x10, 80 - .flags = 0, 81 - } 66 + }, { 67 + .id = V4L2_CID_HUE, 68 + .type = V4L2_CTRL_TYPE_INTEGER, 69 + .name = "Hue", 70 + .minimum = -128, 71 + .maximum = 127, 72 + .step = 0x1, 73 + .default_value = 0x10, 74 + .flags = 0, 75 + } 82 76 }; 83 77 84 78 struct tvp5150 { ··· 100 94 101 95 buffer[0] = addr; 102 96 if (1 != (rc = i2c_master_send(c, buffer, 1))) 103 - dprintk(0, "i2c i/o error: rc == %d (should be 1)\n", rc); 97 + tvp5150_dbg(0, "i2c i/o error: rc == %d (should be 1)\n", rc); 104 98 105 99 msleep(10); 106 100 107 101 if (1 != (rc = i2c_master_recv(c, buffer, 1))) 108 - dprintk(0, "i2c i/o error: rc == %d (should be 1)\n", rc); 102 + tvp5150_dbg(0, "i2c i/o error: rc == %d (should be 1)\n", rc); 103 + 104 + tvp5150_dbg(2, "tvp5150: read 0x%02x = 0x%02x\n", addr, buffer[0]); 109 105 110 106 return (buffer[0]); 111 107 } ··· 117 109 { 118 110 unsigned char buffer[2]; 119 111 int rc; 120 - /* struct tvp5150 *core = i2c_get_clientdata(c); */ 121 112 122 113 buffer[0] = addr; 123 114 buffer[1] = value; 124 - dprintk(1, "tvp5150: writing 0x%02x 0x%02x\n", buffer[0], buffer[1]); 115 + tvp5150_dbg(2, "tvp5150: writing 0x%02x 0x%02x\n", buffer[0], buffer[1]); 125 116 if (2 != (rc = i2c_master_send(c, buffer, 2))) 126 - dprintk(0, "i2c i/o error: rc == %d (should be 2)\n", rc); 117 + tvp5150_dbg(0, "i2c i/o error: rc == %d (should be 2)\n", rc); 127 118 } 128 119 129 120 static void dump_reg(struct i2c_client *c) ··· 444 437 static inline void tvp5150_selmux(struct i2c_client *c, 445 438 enum tvp5150_input input) 446 439 { 440 + int opmode=0; 441 + 447 442 struct tvp5150 *decoder = i2c_get_clientdata(c); 448 443 449 444 if (!decoder->enable) 450 445 input |= TVP5150_BLACK_SCREEN; 451 446 447 + switch (input) { 448 + case TVP5150_ANALOG_CH0: 449 + case TVP5150_ANALOG_CH1: 450 + opmode=0x30; /* TV Mode */ 451 + break; 452 + default: 453 + opmode=0; /* Auto Mode */ 454 + break; 455 + } 456 + 457 + tvp5150_write(c, TVP5150_OP_MODE_CTL, opmode); 452 458 tvp5150_write(c, TVP5150_VD_IN_SRC_SEL_1, input); 453 459 }; 454 460 455 - static inline void tvp5150_reset(struct i2c_client *c) 461 + struct i2c_reg_value { 462 + unsigned char reg; 463 + unsigned char value; 464 + }; 465 + 466 + /* Default values as sugested at TVP5150AM1 datasheet */ 467 + static const struct i2c_reg_value tvp5150_init_default[] = { 468 + { /* 0x00 */ 469 + TVP5150_VD_IN_SRC_SEL_1,0x00 470 + }, 471 + { /* 0x01 */ 472 + TVP5150_ANAL_CHL_CTL,0x15 473 + }, 474 + { /* 0x02 */ 475 + TVP5150_OP_MODE_CTL,0x00 476 + }, 477 + { /* 0x03 */ 478 + TVP5150_MISC_CTL,0x01 479 + }, 480 + { /* 0x06 */ 481 + TVP5150_COLOR_KIL_THSH_CTL,0x10 482 + }, 483 + { /* 0x07 */ 484 + TVP5150_LUMA_PROC_CTL_1,0x60 485 + }, 486 + { /* 0x08 */ 487 + TVP5150_LUMA_PROC_CTL_2,0x00 488 + }, 489 + { /* 0x09 */ 490 + TVP5150_BRIGHT_CTL,0x80 491 + }, 492 + { /* 0x0a */ 493 + TVP5150_SATURATION_CTL,0x80 494 + }, 495 + { /* 0x0b */ 496 + TVP5150_HUE_CTL,0x00 497 + }, 498 + { /* 0x0c */ 499 + TVP5150_CONTRAST_CTL,0x80 500 + }, 501 + { /* 0x0d */ 502 + TVP5150_DATA_RATE_SEL,0x47 503 + }, 504 + { /* 0x0e */ 505 + TVP5150_LUMA_PROC_CTL_3,0x00 506 + }, 507 + { /* 0x0f */ 508 + TVP5150_CONF_SHARED_PIN,0x08 509 + }, 510 + { /* 0x11 */ 511 + TVP5150_ACT_VD_CROP_ST_MSB,0x00 512 + }, 513 + { /* 0x12 */ 514 + TVP5150_ACT_VD_CROP_ST_LSB,0x00 515 + }, 516 + { /* 0x13 */ 517 + TVP5150_ACT_VD_CROP_STP_MSB,0x00 518 + }, 519 + { /* 0x14 */ 520 + TVP5150_ACT_VD_CROP_STP_LSB,0x00 521 + }, 522 + { /* 0x15 */ 523 + TVP5150_GENLOCK,0x01 524 + }, 525 + { /* 0x16 */ 526 + TVP5150_HORIZ_SYNC_START,0x80 527 + }, 528 + { /* 0x18 */ 529 + TVP5150_VERT_BLANKING_START,0x00 530 + }, 531 + { /* 0x19 */ 532 + TVP5150_VERT_BLANKING_STOP,0x00 533 + }, 534 + { /* 0x1a */ 535 + TVP5150_CHROMA_PROC_CTL_1,0x0c 536 + }, 537 + { /* 0x1b */ 538 + TVP5150_CHROMA_PROC_CTL_2,0x14 539 + }, 540 + { /* 0x1c */ 541 + TVP5150_INT_RESET_REG_B,0x00 542 + }, 543 + { /* 0x1d */ 544 + TVP5150_INT_ENABLE_REG_B,0x00 545 + }, 546 + { /* 0x1e */ 547 + TVP5150_INTT_CONFIG_REG_B,0x00 548 + }, 549 + { /* 0x28 */ 550 + TVP5150_VIDEO_STD,0x00 551 + }, 552 + { /* 0x2e */ 553 + TVP5150_MACROVISION_ON_CTR,0x0f 554 + }, 555 + { /* 0x2f */ 556 + TVP5150_MACROVISION_OFF_CTR,0x01 557 + }, 558 + { /* 0xbb */ 559 + TVP5150_TELETEXT_FIL_ENA,0x00 560 + }, 561 + { /* 0xc0 */ 562 + TVP5150_INT_STATUS_REG_A,0x00 563 + }, 564 + { /* 0xc1 */ 565 + TVP5150_INT_ENABLE_REG_A,0x00 566 + }, 567 + { /* 0xc2 */ 568 + TVP5150_INT_CONF,0x04 569 + }, 570 + { /* 0xc8 */ 571 + TVP5150_FIFO_INT_THRESHOLD,0x80 572 + }, 573 + { /* 0xc9 */ 574 + TVP5150_FIFO_RESET,0x00 575 + }, 576 + { /* 0xca */ 577 + TVP5150_LINE_NUMBER_INT,0x00 578 + }, 579 + { /* 0xcb */ 580 + TVP5150_PIX_ALIGN_REG_LOW,0x4e 581 + }, 582 + { /* 0xcc */ 583 + TVP5150_PIX_ALIGN_REG_HIGH,0x00 584 + }, 585 + { /* 0xcd */ 586 + TVP5150_FIFO_OUT_CTRL,0x01 587 + }, 588 + { /* 0xcf */ 589 + TVP5150_FULL_FIELD_ENA_1,0x00 590 + }, 591 + { /* 0xd0 */ 592 + TVP5150_FULL_FIELD_ENA_2,0x00 593 + }, 594 + { /* 0xfc */ 595 + TVP5150_FULL_FIELD_MODE_REG,0x7f 596 + }, 597 + { /* end of data */ 598 + 0xff,0xff 599 + } 600 + }; 601 + 602 + /* Default values as sugested at TVP5150AM1 datasheet */ 603 + static const struct i2c_reg_value tvp5150_init_enable[] = { 604 + { 605 + TVP5150_CONF_SHARED_PIN, 2 606 + },{ /* Automatic offset and AGC enabled */ 607 + TVP5150_ANAL_CHL_CTL, 0x15 608 + },{ /* Activate YCrCb output 0x9 or 0xd ? */ 609 + TVP5150_MISC_CTL, 0x6f 610 + },{ /* Activates video std autodetection for all standards */ 611 + TVP5150_AUTOSW_MSK, 0x0 612 + },{ /* Default format: 0x47. For 4:2:2: 0x40 */ 613 + TVP5150_DATA_RATE_SEL, 0x47 614 + },{ 615 + TVP5150_CHROMA_PROC_CTL_1, 0x0c 616 + },{ 617 + TVP5150_CHROMA_PROC_CTL_2, 0x54 618 + },{ /* Non documented, but initialized on WinTV USB2 */ 619 + 0x27, 0x20 620 + },{ 621 + 0xff,0xff 622 + } 623 + }; 624 + 625 + struct i2c_vbi_ram_value { 626 + u16 reg; 627 + unsigned char values[26]; 628 + }; 629 + 630 + struct i2c_vbi_ram_value vbi_ram_default[] = 631 + { 632 + {0x010, /* WST SECAM 6 */ 633 + { 0xaa, 0xaa, 0xff, 0xff , 0xe7, 0x2e, 0x20, 0x26, 0xe6, 0xb4, 0x0e, 0x0, 0x0, 0x0, 0x10, 0x0 } 634 + }, 635 + {0x030, /* WST PAL B 6 */ 636 + { 0xaa, 0xaa, 0xff, 0xff , 0x27, 0x2e, 0x20, 0x2b, 0xa6, 0x72, 0x10, 0x0, 0x0, 0x0, 0x10, 0x0 } 637 + }, 638 + {0x050, /* WST PAL C 6 */ 639 + { 0xaa, 0xaa, 0xff, 0xff , 0xe7, 0x2e, 0x20, 0x22, 0xa6, 0x98, 0x0d, 0x0, 0x0, 0x0, 0x10, 0x0 } 640 + }, 641 + {0x070, /* WST NTSC 6 */ 642 + { 0xaa, 0xaa, 0xff, 0xff , 0x27, 0x2e, 0x20, 0x23, 0x69, 0x93, 0x0d, 0x0, 0x0, 0x0, 0x10, 0x0 } 643 + }, 644 + {0x090, /* NABTS, NTSC 6 */ 645 + { 0xaa, 0xaa, 0xff, 0xff , 0xe7, 0x2e, 0x20, 0x22, 0x69, 0x93, 0x0d, 0x0, 0x0, 0x0, 0x15, 0x0 } 646 + }, 647 + {0x0b0, /* NABTS, NTSC-J 6 */ 648 + { 0xaa, 0xaa, 0xff, 0xff , 0xa7, 0x2e, 0x20, 0x23, 0x69, 0x93, 0x0d, 0x0, 0x0, 0x0, 0x10, 0x0 } 649 + }, 650 + {0x0d0, /* CC, PAL/SECAM 6 */ 651 + { 0xaa, 0x2a, 0xff, 0x3f , 0x04, 0x51, 0x6e, 0x02, 0xa6, 0x7b, 0x09, 0x0, 0x0, 0x0, 0x27, 0x0 } 652 + }, 653 + {0x0f0, /* CC, NTSC 6 */ 654 + { 0xaa, 0x2a, 0xff, 0x3f , 0x04, 0x51, 0x6e, 0x02, 0x69, 0x8c, 0x09, 0x0, 0x0, 0x0, 0x27, 0x0 } 655 + }, 656 + {0x110, /* WSS, PAL/SECAM 6 */ 657 + { 0x5b, 0x55, 0xc5, 0xff , 0x0, 0x71, 0x6e, 0x42, 0xa6, 0xcd, 0x0f, 0x0, 0x0, 0x0, 0x3a, 0x0 } 658 + }, 659 + {0x130, /* WSS, NTSC C */ 660 + { 0x38, 0x00, 0x3f, 0x00 , 0x0, 0x71, 0x6e, 0x43, 0x69, 0x7c, 0x08, 0x0, 0x0, 0x0, 0x39, 0x0 } 661 + }, 662 + {0x150, /* VITC, PAL/SECAM 6 */ 663 + { 0x0, 0x0, 0x0, 0x0 , 0x0, 0x8f, 0x6d, 0x49, 0xa6, 0x85, 0x08, 0x0, 0x0, 0x0, 0x4c, 0x0 } 664 + }, 665 + {0x170, /* VITC, NTSC 6 */ 666 + { 0x0, 0x0, 0x0, 0x0 , 0x0, 0x8f, 0x6d, 0x49, 0x69, 0x94, 0x08, 0x0, 0x0, 0x0, 0x4c, 0x0 } 667 + }, 668 + { (u16)-1 } 669 + }; 670 + 671 + static int tvp5150_write_inittab(struct i2c_client *c, 672 + const struct i2c_reg_value *regs) 673 + { 674 + while (regs->reg != 0xff) { 675 + tvp5150_write(c, regs->reg, regs->value); 676 + regs++; 677 + } 678 + return 0; 679 + } 680 + 681 + static int tvp5150_vdp_init(struct i2c_client *c, 682 + const struct i2c_vbi_ram_value *regs) 683 + { 684 + unsigned int i; 685 + 686 + /* Disable Full Field */ 687 + tvp5150_write(c, TVP5150_FULL_FIELD_ENA_1, 0); 688 + 689 + /* Before programming, Line mode should be at 0xff */ 690 + for (i=TVP5150_FULL_FIELD_ENA_2; i<=TVP5150_LINE_MODE_REG_44; i++) 691 + tvp5150_write(c, i, 0xff); 692 + 693 + /* Load Ram Table */ 694 + while (regs->reg != (u16)-1 ) { 695 + tvp5150_write(c, TVP5150_CONF_RAM_ADDR_HIGH,regs->reg>>8); 696 + tvp5150_write(c, TVP5150_CONF_RAM_ADDR_LOW,regs->reg); 697 + 698 + for (i=0;i<16;i++) 699 + tvp5150_write(c, TVP5150_VDP_CONF_RAM_DATA,regs->values[i]); 700 + 701 + regs++; 702 + } 703 + return 0; 704 + } 705 + 706 + static int tvp5150_set_std(struct i2c_client *c, v4l2_std_id std) 456 707 { 457 708 struct tvp5150 *decoder = i2c_get_clientdata(c); 709 + int fmt=0; 458 710 459 - tvp5150_write(c, TVP5150_CONF_SHARED_PIN, 2); 711 + decoder->norm=std; 460 712 461 - /* Automatic offset and AGC enabled */ 462 - tvp5150_write(c, TVP5150_ANAL_CHL_CTL, 0x15); 713 + /* First tests should be against specific std */ 463 714 464 - /* Normal Operation */ 465 - // tvp5150_write(c, TVP5150_OP_MODE_CTL, 0x00); 715 + if (std == V4L2_STD_ALL) { 716 + fmt=0; /* Autodetect mode */ 717 + } else if (std & V4L2_STD_NTSC_443) { 718 + fmt=0xa; 719 + } else if (std & V4L2_STD_PAL_M) { 720 + fmt=0x6; 721 + } else if (std & (V4L2_STD_PAL_N| V4L2_STD_PAL_Nc)) { 722 + fmt=0x8; 723 + } else { 724 + /* Then, test against generic ones */ 725 + if (std & V4L2_STD_NTSC) { 726 + fmt=0x2; 727 + } else if (std & V4L2_STD_PAL) { 728 + fmt=0x4; 729 + } else if (std & V4L2_STD_SECAM) { 730 + fmt=0xc; 731 + } 732 + } 466 733 467 - /* Activate YCrCb output 0x9 or 0xd ? */ 468 - tvp5150_write(c, TVP5150_MISC_CTL, 0x6f); 734 + tvp5150_dbg(1,"Set video std register to %d.\n",fmt); 735 + tvp5150_write(c, TVP5150_VIDEO_STD, fmt); 469 736 470 - /* Activates video std autodetection for all standards */ 471 - tvp5150_write(c, TVP5150_AUTOSW_MSK, 0x0); 737 + return 0; 738 + } 472 739 473 - /* Default format: 0x47, 4:2:2: 0x40 */ 474 - tvp5150_write(c, TVP5150_DATA_RATE_SEL, 0x47); 740 + static inline void tvp5150_reset(struct i2c_client *c) 741 + { 742 + u8 type, ver_656, msb_id, lsb_id, msb_rom, lsb_rom; 743 + struct tvp5150 *decoder = i2c_get_clientdata(c); 475 744 745 + type=tvp5150_read(c,TVP5150_AUTOSW_MSK); 746 + msb_id=tvp5150_read(c,TVP5150_MSB_DEV_ID); 747 + lsb_id=tvp5150_read(c,TVP5150_LSB_DEV_ID); 748 + msb_rom=tvp5150_read(c,TVP5150_ROM_MAJOR_VER); 749 + lsb_rom=tvp5150_read(c,TVP5150_ROM_MINOR_VER); 750 + 751 + if (type==0xdc) { 752 + ver_656=tvp5150_read(c,TVP5150_REV_SELECT); 753 + tvp5150_info("tvp%02x%02xam1 detected 656 version is %d.\n",msb_id, lsb_id,ver_656); 754 + } else if (type==0xfc) { 755 + tvp5150_info("tvp%02x%02xa detected.\n",msb_id, lsb_id); 756 + } else { 757 + tvp5150_info("unknown tvp%02x%02x chip detected(%d).\n",msb_id,lsb_id,type); 758 + } 759 + tvp5150_info("Rom ver is %d.%d\n",msb_rom,lsb_rom); 760 + 761 + /* Initializes TVP5150 to its default values */ 762 + tvp5150_write_inittab(c, tvp5150_init_default); 763 + 764 + /* Initializes VDP registers */ 765 + tvp5150_vdp_init(c, vbi_ram_default); 766 + 767 + /* Selects decoder input */ 476 768 tvp5150_selmux(c, decoder->input); 477 769 478 - tvp5150_write(c, TVP5150_CHROMA_PROC_CTL_1, 0x0c); 479 - tvp5150_write(c, TVP5150_CHROMA_PROC_CTL_2, 0x54); 770 + /* Initializes TVP5150 to stream enabled values */ 771 + tvp5150_write_inittab(c, tvp5150_init_enable); 480 772 481 - tvp5150_write(c, 0x27, 0x20); /* ?????????? */ 482 - 483 - tvp5150_write(c, TVP5150_VIDEO_STD, 0x0); /* Auto switch */ 484 - 773 + /* Initialize image preferences */ 485 774 tvp5150_write(c, TVP5150_BRIGHT_CTL, decoder->bright >> 8); 486 775 tvp5150_write(c, TVP5150_CONTRAST_CTL, decoder->contrast >> 8); 487 776 tvp5150_write(c, TVP5150_SATURATION_CTL, decoder->contrast >> 8); 488 777 tvp5150_write(c, TVP5150_HUE_CTL, (decoder->hue - 32768) >> 8); 778 + 779 + tvp5150_set_std(c, decoder->norm); 489 780 }; 490 781 491 782 static int tvp5150_get_ctrl(struct i2c_client *c, struct v4l2_control *ctrl) ··· 803 498 case V4L2_CID_HUE: 804 499 ctrl->value = tvp5150_read(c, TVP5150_HUE_CTL); 805 500 return 0; 806 - default: 807 - return -EINVAL; 808 501 } 502 + return -EINVAL; 809 503 } 810 504 811 505 static int tvp5150_set_ctrl(struct i2c_client *c, struct v4l2_control *ctrl) ··· 824 520 case V4L2_CID_HUE: 825 521 tvp5150_write(c, TVP5150_HUE_CTL, ctrl->value); 826 522 return 0; 827 - default: 828 - return -EINVAL; 829 523 } 524 + return -EINVAL; 830 525 } 831 526 832 527 /**************************************************************************** 833 528 I2C Command 834 529 ****************************************************************************/ 835 - static int tvp5150_command(struct i2c_client *client, 530 + static int tvp5150_command(struct i2c_client *c, 836 531 unsigned int cmd, void *arg) 837 532 { 838 - struct tvp5150 *decoder = i2c_get_clientdata(client); 533 + struct tvp5150 *decoder = i2c_get_clientdata(c); 839 534 840 535 switch (cmd) { 841 536 842 537 case 0: 538 + case VIDIOC_INT_RESET: 843 539 case DECODER_INIT: 844 - tvp5150_reset(client); 540 + tvp5150_reset(c); 541 + break; 542 + case VIDIOC_S_STD: 543 + if (decoder->norm == *(v4l2_std_id *)arg) 544 + break; 545 + return tvp5150_set_std(c, *(v4l2_std_id *)arg); 546 + case VIDIOC_G_STD: 547 + *(v4l2_std_id *)arg = decoder->norm; 845 548 break; 846 549 550 + #ifdef CONFIG_VIDEO_ADV_DEBUG 551 + case VIDIOC_INT_G_REGISTER: 552 + { 553 + struct v4l2_register *reg = arg; 554 + 555 + if (reg->i2c_id != I2C_DRIVERID_TVP5150) 556 + return -EINVAL; 557 + reg->val = tvp5150_read(c, reg->reg & 0xff); 558 + break; 559 + } 560 + 561 + case VIDIOC_INT_S_REGISTER: 562 + { 563 + struct v4l2_register *reg = arg; 564 + 565 + if (reg->i2c_id != I2C_DRIVERID_TVP5150) 566 + return -EINVAL; 567 + if (!capable(CAP_SYS_ADMIN)) 568 + return -EPERM; 569 + tvp5150_write(c, reg->reg & 0xff, reg->val & 0xff); 570 + break; 571 + } 572 + #endif 573 + 847 574 case DECODER_DUMP: 848 - dump_reg(client); 575 + dump_reg(c); 849 576 break; 850 577 851 578 case DECODER_GET_CAPABILITIES: ··· 935 600 } 936 601 937 602 decoder->input = *iarg; 938 - tvp5150_selmux(client, decoder->input); 603 + tvp5150_selmux(c, decoder->input); 939 604 940 605 break; 941 606 } ··· 955 620 956 621 decoder->enable = (*iarg != 0); 957 622 958 - tvp5150_selmux(client, decoder->input); 623 + tvp5150_selmux(c, decoder->input); 959 624 960 625 break; 961 626 } 962 627 case VIDIOC_QUERYCTRL: 963 628 { 964 629 struct v4l2_queryctrl *qc = arg; 965 - u8 i, n; 630 + int i; 966 631 967 - dprintk(1, KERN_DEBUG "VIDIOC_QUERYCTRL"); 632 + tvp5150_dbg(1, "VIDIOC_QUERYCTRL called\n"); 968 633 969 - n = sizeof(tvp5150_qctrl) / sizeof(tvp5150_qctrl[0]); 970 - for (i = 0; i < n; i++) 634 + for (i = 0; i < ARRAY_SIZE(tvp5150_qctrl); i++) 971 635 if (qc->id && qc->id == tvp5150_qctrl[i].id) { 972 636 memcpy(qc, &(tvp5150_qctrl[i]), 973 637 sizeof(*qc)); ··· 978 644 case VIDIOC_G_CTRL: 979 645 { 980 646 struct v4l2_control *ctrl = arg; 981 - dprintk(1, KERN_DEBUG "VIDIOC_G_CTRL"); 647 + tvp5150_dbg(1, "VIDIOC_G_CTRL called\n"); 982 648 983 - return tvp5150_get_ctrl(client, ctrl); 649 + return tvp5150_get_ctrl(c, ctrl); 984 650 } 985 - case VIDIOC_S_CTRL_OLD: /* ??? */ 986 651 case VIDIOC_S_CTRL: 987 652 { 988 653 struct v4l2_control *ctrl = arg; 989 654 u8 i, n; 990 - dprintk(1, KERN_DEBUG "VIDIOC_S_CTRL"); 991 655 n = sizeof(tvp5150_qctrl) / sizeof(tvp5150_qctrl[0]); 992 656 for (i = 0; i < n; i++) 993 657 if (ctrl->id == tvp5150_qctrl[i].id) { ··· 994 662 || ctrl->value > 995 663 tvp5150_qctrl[i].maximum) 996 664 return -ERANGE; 997 - dprintk(1, 998 - KERN_DEBUG 999 - "VIDIOC_S_CTRL: id=%d, value=%d", 665 + tvp5150_dbg(1, 666 + "VIDIOC_S_CTRL: id=%d, value=%d\n", 1000 667 ctrl->id, ctrl->value); 1001 - return tvp5150_set_ctrl(client, ctrl); 668 + return tvp5150_set_ctrl(c, ctrl); 1002 669 } 1003 670 return -EINVAL; 1004 671 } ··· 1008 677 if (decoder->bright != pic->brightness) { 1009 678 /* We want 0 to 255 we get 0-65535 */ 1010 679 decoder->bright = pic->brightness; 1011 - tvp5150_write(client, TVP5150_BRIGHT_CTL, 680 + tvp5150_write(c, TVP5150_BRIGHT_CTL, 1012 681 decoder->bright >> 8); 1013 682 } 1014 683 if (decoder->contrast != pic->contrast) { 1015 684 /* We want 0 to 255 we get 0-65535 */ 1016 685 decoder->contrast = pic->contrast; 1017 - tvp5150_write(client, TVP5150_CONTRAST_CTL, 686 + tvp5150_write(c, TVP5150_CONTRAST_CTL, 1018 687 decoder->contrast >> 8); 1019 688 } 1020 689 if (decoder->sat != pic->colour) { 1021 690 /* We want 0 to 255 we get 0-65535 */ 1022 691 decoder->sat = pic->colour; 1023 - tvp5150_write(client, TVP5150_SATURATION_CTL, 692 + tvp5150_write(c, TVP5150_SATURATION_CTL, 1024 693 decoder->contrast >> 8); 1025 694 } 1026 695 if (decoder->hue != pic->hue) { 1027 696 /* We want -128 to 127 we get 0-65535 */ 1028 697 decoder->hue = pic->hue; 1029 - tvp5150_write(client, TVP5150_HUE_CTL, 698 + tvp5150_write(c, TVP5150_HUE_CTL, 1030 699 (decoder->hue - 32768) >> 8); 1031 700 } 1032 701 break; ··· 1051 720 static int tvp5150_detect_client(struct i2c_adapter *adapter, 1052 721 int address, int kind) 1053 722 { 1054 - struct i2c_client *client; 723 + struct i2c_client *c; 1055 724 struct tvp5150 *core; 1056 725 int rv; 1057 726 1058 - dprintk(1, 1059 - KERN_INFO 727 + if (debug) 728 + printk( KERN_INFO 1060 729 "tvp5150.c: detecting tvp5150 client on address 0x%x\n", 1061 730 address << 1); 1062 731 ··· 1069 738 I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) 1070 739 return 0; 1071 740 1072 - client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 1073 - if (client == 0) 741 + c = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 742 + if (c == 0) 1074 743 return -ENOMEM; 1075 - memcpy(client, &client_template, sizeof(struct i2c_client)); 744 + memcpy(c, &client_template, sizeof(struct i2c_client)); 1076 745 1077 746 core = kmalloc(sizeof(struct tvp5150), GFP_KERNEL); 1078 747 if (core == 0) { 1079 - kfree(client); 748 + kfree(c); 1080 749 return -ENOMEM; 1081 750 } 1082 751 memset(core, 0, sizeof(struct tvp5150)); 1083 - i2c_set_clientdata(client, core); 752 + i2c_set_clientdata(c, core); 1084 753 1085 - rv = i2c_attach_client(client); 754 + rv = i2c_attach_client(c); 1086 755 1087 - core->norm = VIDEO_MODE_AUTO; 756 + core->norm = V4L2_STD_ALL; 1088 757 core->input = 2; 1089 758 core->enable = 1; 1090 759 core->bright = 32768; ··· 1093 762 core->sat = 32768; 1094 763 1095 764 if (rv) { 1096 - kfree(client); 765 + kfree(c); 1097 766 kfree(core); 1098 767 return rv; 1099 768 } 1100 769 1101 770 if (debug > 1) 1102 - dump_reg(client); 771 + dump_reg(c); 1103 772 return 0; 1104 773 } 1105 774 1106 775 static int tvp5150_attach_adapter(struct i2c_adapter *adapter) 1107 776 { 1108 - dprintk(1, 1109 - KERN_INFO 777 + if (debug) 778 + printk( KERN_INFO 1110 779 "tvp5150.c: starting probe for adapter %s (0x%x)\n", 1111 780 adapter->name, adapter->id); 1112 781 return i2c_probe(adapter, &addr_data, &tvp5150_detect_client); 1113 782 } 1114 783 1115 - static int tvp5150_detach_client(struct i2c_client *client) 784 + static int tvp5150_detach_client(struct i2c_client *c) 1116 785 { 1117 - struct tvp5150 *decoder = i2c_get_clientdata(client); 786 + struct tvp5150 *decoder = i2c_get_clientdata(c); 1118 787 int err; 1119 788 1120 - err = i2c_detach_client(client); 789 + tvp5150_dbg(1, 790 + "tvp5150.c: removing tvp5150 adapter on address 0x%x\n", 791 + c->addr << 1); 792 + 793 + err = i2c_detach_client(c); 1121 794 if (err) { 1122 795 return err; 1123 796 } 1124 797 1125 798 kfree(decoder); 1126 - kfree(client); 799 + kfree(c); 1127 800 1128 801 return 0; 1129 802 } ··· 1138 803 .driver = { 1139 804 .name = "tvp5150", 1140 805 }, 1141 - 1142 - /* FIXME */ 1143 - .id = I2C_DRIVERID_SAA7110, 806 + .id = I2C_DRIVERID_TVP5150, 1144 807 1145 808 .attach_adapter = tvp5150_attach_adapter, 1146 809 .detach_client = tvp5150_detach_client,
+10 -1
drivers/media/video/v4l1-compat.c
··· 951 951 dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %d\n", err); 952 952 break; 953 953 } 954 + if (fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) { 955 + err = -EINVAL; 956 + break; 957 + } 954 958 memset(fmt, 0, sizeof(*fmt)); 955 959 fmt->samples_per_line = fmt2->fmt.vbi.samples_per_line; 956 960 fmt->sampling_rate = fmt2->fmt.vbi.sampling_rate; ··· 969 965 case VIDIOCSVBIFMT: 970 966 { 971 967 struct vbi_format *fmt = arg; 968 + 969 + if (VIDEO_PALETTE_RAW != fmt->sample_format) { 970 + err = -EINVAL; 971 + break; 972 + } 972 973 973 974 fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL); 974 975 memset(fmt2, 0, sizeof(*fmt2)); ··· 995 986 996 987 if (fmt2->fmt.vbi.samples_per_line != fmt->samples_per_line || 997 988 fmt2->fmt.vbi.sampling_rate != fmt->sampling_rate || 998 - VIDEO_PALETTE_RAW != fmt->sample_format || 989 + fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY || 999 990 fmt2->fmt.vbi.start[0] != fmt->start[0] || 1000 991 fmt2->fmt.vbi.count[0] != fmt->count[0] || 1001 992 fmt2->fmt.vbi.start[1] != fmt->start[1] ||
+170 -49
drivers/media/video/v4l2-common.c
··· 58 58 #include <asm/pgtable.h> 59 59 #include <asm/io.h> 60 60 #include <asm/div64.h> 61 + #include <linux/video_decoder.h> 62 + #include <media/v4l2-common.h> 61 63 62 64 #ifdef CONFIG_KMOD 63 65 #include <linux/kmod.h> ··· 192 190 [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out", 193 191 }; 194 192 195 - char *v4l2_ioctl_names[256] = { 196 - [0 ... 255] = "UNKNOWN", 197 - [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP", 198 - [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED", 199 - [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", 200 - [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", 201 - [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", 202 - [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", 203 - [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", 204 - [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", 205 - [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF", 206 - [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY", 207 - [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF", 208 - [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF", 209 - [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON", 210 - [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF", 211 - [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM", 212 - [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM", 213 - [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD", 214 - [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD", 215 - [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD", 216 - [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT", 217 - [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL", 218 - [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL", 219 - [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER", 220 - [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER", 221 - [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO", 222 - [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO", 223 - [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL", 224 - [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU", 225 - [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT", 226 - [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT", 227 - [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT", 228 - [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT", 229 - [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT", 230 - [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT", 231 - [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT", 232 - [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR", 233 - [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR", 234 - [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY", 235 - [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY", 236 - [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP", 237 - [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP", 238 - [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP", 239 - [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP", 240 - [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP", 241 - [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD", 242 - [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT", 193 + /* ------------------------------------------------------------------ */ 194 + /* debug help functions */ 195 + 196 + #ifdef HAVE_V4L1 197 + static const char *v4l1_ioctls[] = { 198 + [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP", 199 + [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN", 200 + [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN", 201 + [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER", 202 + [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER", 203 + [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT", 204 + [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT", 205 + [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE", 206 + [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN", 207 + [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN", 208 + [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF", 209 + [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF", 210 + [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY", 211 + [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ", 212 + [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ", 213 + [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO", 214 + [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO", 215 + [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC", 216 + [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE", 217 + [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF", 218 + [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT", 219 + [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE", 220 + [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE", 221 + [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE", 222 + [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE", 223 + [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO", 224 + [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE", 225 + [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT", 226 + [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT" 243 227 }; 228 + #define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls) 229 + #endif 230 + 231 + static const char *v4l2_ioctls[] = { 232 + [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP", 233 + [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED", 234 + [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", 235 + [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", 236 + [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", 237 + [_IOC_NR(VIDIOC_G_MPEGCOMP)] = "VIDIOC_G_MPEGCOMP", 238 + [_IOC_NR(VIDIOC_S_MPEGCOMP)] = "VIDIOC_S_MPEGCOMP", 239 + [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", 240 + [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", 241 + [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", 242 + [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF", 243 + [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY", 244 + [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF", 245 + [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF", 246 + [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON", 247 + [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF", 248 + [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM", 249 + [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM", 250 + [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD", 251 + [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD", 252 + [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD", 253 + [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT", 254 + [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL", 255 + [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL", 256 + [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER", 257 + [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER", 258 + [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO", 259 + [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO", 260 + [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL", 261 + [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU", 262 + [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT", 263 + [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT", 264 + [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT", 265 + [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT", 266 + [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT", 267 + [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT", 268 + [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT", 269 + [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR", 270 + [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR", 271 + [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY", 272 + [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY", 273 + [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP", 274 + [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP", 275 + [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP", 276 + [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP", 277 + [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP", 278 + [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD", 279 + [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT", 280 + [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO", 281 + [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT", 282 + [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY", 283 + [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY", 284 + #if 1 285 + [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP", 286 + #endif 287 + [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS" 288 + }; 289 + #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) 290 + 291 + static const char *v4l2_int_ioctls[] = { 292 + #ifdef HAVE_VIDEO_DECODER 293 + [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES", 294 + [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS", 295 + [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM", 296 + [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT", 297 + [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT", 298 + [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT", 299 + [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE", 300 + [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO", 301 + [_IOC_NR(DECODER_INIT)] = "DECODER_INIT", 302 + [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS", 303 + [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP", 304 + #endif 305 + [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO", 306 + [_IOC_NR(AUDC_SET_INPUT)] = "AUDC_SET_INPUT", 307 + 308 + [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR", 309 + [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY", 310 + [_IOC_NR(TDA9887_SET_CONFIG)] = "TDA9887_SET_CONFIG", 311 + 312 + [_IOC_NR(VIDIOC_INT_S_REGISTER)] = "VIDIOC_INT_S_REGISTER", 313 + [_IOC_NR(VIDIOC_INT_G_REGISTER)] = "VIDIOC_INT_G_REGISTER", 314 + [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET", 315 + [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ", 316 + [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE", 317 + [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA", 318 + [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA", 319 + [_IOC_NR(VIDIOC_INT_G_CHIP_IDENT)] = "VIDIOC_INT_G_CHIP_IDENT", 320 + [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ" 321 + }; 322 + #define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls) 323 + 324 + /* Common ioctl debug function. This function can be used by 325 + external ioctl messages as well as internal V4L ioctl */ 326 + void v4l_printk_ioctl(unsigned int cmd) 327 + { 328 + char *dir; 329 + 330 + switch (_IOC_DIR(cmd)) { 331 + case _IOC_NONE: dir = "--"; break; 332 + case _IOC_READ: dir = "r-"; break; 333 + case _IOC_WRITE: dir = "-w"; break; 334 + case _IOC_READ | _IOC_WRITE: dir = "rw"; break; 335 + default: dir = "*ERR*"; break; 336 + } 337 + switch (_IOC_TYPE(cmd)) { 338 + case 'd': 339 + printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n", 340 + (_IOC_NR(cmd) < V4L2_INT_IOCTLS) ? 341 + v4l2_int_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); 342 + break; 343 + #ifdef HAVE_V4L1 344 + case 'v': 345 + printk("v4l1 ioctl %s, dir=%s (0x%08x)\n", 346 + (_IOC_NR(cmd) < V4L1_IOCTLS) ? 347 + v4l1_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); 348 + break; 349 + #endif 350 + case 'V': 351 + printk("v4l2 ioctl %s, dir=%s (0x%08x)\n", 352 + (_IOC_NR(cmd) < V4L2_IOCTLS) ? 353 + v4l2_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); 354 + break; 355 + 356 + default: 357 + printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n", 358 + _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd); 359 + } 360 + } 244 361 245 362 /* ----------------------------------------------------------------- */ 246 363 ··· 374 253 375 254 EXPORT_SYMBOL(v4l2_field_names); 376 255 EXPORT_SYMBOL(v4l2_type_names); 377 - EXPORT_SYMBOL(v4l2_ioctl_names); 256 + EXPORT_SYMBOL(v4l_printk_ioctl); 378 257 379 258 /* 380 259 * Local variables:
+6 -4
drivers/media/video/videodev.c
··· 68 68 { 69 69 struct video_device *vfd = container_of(cd, struct video_device, class_dev); 70 70 71 - #if 1 /* needed until all drivers are fixed */ 71 + #if 1 72 + /* needed until all drivers are fixed */ 72 73 if (!vfd->release) 73 74 return; 74 75 #endif ··· 339 338 if (vfd->dev) 340 339 vfd->class_dev.dev = vfd->dev; 341 340 vfd->class_dev.class = &video_class; 342 - vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor); 341 + vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor); 343 342 strlcpy(vfd->class_dev.class_id, vfd->devfs_name + 4, BUS_ID_SIZE); 344 343 class_device_register(&vfd->class_dev); 345 344 class_device_create_file(&vfd->class_dev, 346 - &class_device_attr_name); 345 + &class_device_attr_name); 347 346 348 - #if 1 /* needed until all drivers are fixed */ 347 + #if 1 348 + /* needed until all drivers are fixed */ 349 349 if (!vfd->release) 350 350 printk(KERN_WARNING "videodev: \"%s\" has no release callback. " 351 351 "Please fix your driver for proper sysfs support, see "
+1
drivers/media/video/w9966.c
··· 187 187 .open = video_exclusive_open, 188 188 .release = video_exclusive_release, 189 189 .ioctl = w9966_v4l_ioctl, 190 + .compat_ioctl = v4l_compat_ioctl32, 190 191 .read = w9966_v4l_read, 191 192 .llseek = no_llseek, 192 193 };
+44 -44
drivers/media/video/wm8775.c
··· 25 25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 26 */ 27 27 28 - 29 28 #include <linux/module.h> 30 29 #include <linux/types.h> 31 30 #include <linux/ioctl.h> ··· 32 33 #include <linux/i2c.h> 33 34 #include <linux/i2c-id.h> 34 35 #include <linux/videodev.h> 35 - #include <media/audiochip.h> 36 + #include <media/v4l2-common.h> 36 37 37 38 MODULE_DESCRIPTION("wm8775 driver"); 38 39 MODULE_AUTHOR("Ulf Eklund, Hans Verkuil"); 39 40 MODULE_LICENSE("GPL"); 40 - 41 - #define wm8775_err(fmt, arg...) do { \ 42 - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ 43 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 44 - #define wm8775_info(fmt, arg...) do { \ 45 - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ 46 - i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 47 - 48 41 49 42 static unsigned short normal_i2c[] = { 0x36 >> 1, I2C_CLIENT_END }; 50 43 ··· 61 70 int i; 62 71 63 72 if (reg < 0 || reg >= TOT_REGS) { 64 - wm8775_err("Invalid register R%d\n", reg); 73 + v4l_err(client, "Invalid register R%d\n", reg); 65 74 return -1; 66 75 } 67 76 ··· 71 80 return 0; 72 81 } 73 82 } 74 - wm8775_err("I2C: cannot write %03x to register R%d\n", val, reg); 83 + v4l_err(client, "I2C: cannot write %03x to register R%d\n", val, reg); 75 84 return -1; 76 85 } 77 86 ··· 79 88 void *arg) 80 89 { 81 90 struct wm8775_state *state = i2c_get_clientdata(client); 82 - int *input = arg; 91 + struct v4l2_audio *input = arg; 92 + struct v4l2_control *ctrl = arg; 83 93 84 94 switch (cmd) { 85 - case AUDC_SET_INPUT: 95 + case VIDIOC_S_AUDIO: 96 + /* There are 4 inputs and one output. Zero or more inputs 97 + are multiplexed together to the output. Hence there are 98 + 16 combinations. 99 + If only one input is active (the normal case) then the 100 + input values 1, 2, 4 or 8 should be used. */ 101 + if (input->index > 15) { 102 + v4l_err(client, "Invalid input %d.\n", input->index); 103 + return -EINVAL; 104 + } 105 + state->input = input->index; 106 + if (state->muted) 107 + break; 86 108 wm8775_write(client, R21, 0x0c0); 87 109 wm8775_write(client, R14, 0x1d4); 88 110 wm8775_write(client, R15, 0x1d4); 111 + wm8775_write(client, R21, 0x100 + state->input); 112 + break; 89 113 90 - if (*input == AUDIO_RADIO) { 91 - wm8775_write(client, R21, 0x108); 92 - state->input = 8; 93 - state->muted = 0; 94 - break; 95 - } 96 - if (*input == AUDIO_MUTE) { 97 - state->muted = 1; 98 - break; 99 - } 100 - if (*input == AUDIO_UNMUTE) { 114 + case VIDIOC_G_AUDIO: 115 + memset(input, 0, sizeof(*input)); 116 + input->index = state->input; 117 + break; 118 + 119 + case VIDIOC_G_CTRL: 120 + if (ctrl->id != V4L2_CID_AUDIO_MUTE) 121 + return -EINVAL; 122 + ctrl->value = state->muted; 123 + break; 124 + 125 + case VIDIOC_S_CTRL: 126 + if (ctrl->id != V4L2_CID_AUDIO_MUTE) 127 + return -EINVAL; 128 + state->muted = ctrl->value; 129 + wm8775_write(client, R21, 0x0c0); 130 + wm8775_write(client, R14, 0x1d4); 131 + wm8775_write(client, R15, 0x1d4); 132 + if (!state->muted) 101 133 wm8775_write(client, R21, 0x100 + state->input); 102 - state->muted = 0; 103 - break; 104 - } 105 - /* All other inputs... */ 106 - wm8775_write(client, R21, 0x102); 107 - state->input = 2; 108 - state->muted = 0; 109 134 break; 110 135 111 136 case VIDIOC_LOG_STATUS: 112 - wm8775_info("Input: %s%s\n", 113 - state->input == 8 ? "radio" : "default", 137 + v4l_info(client, "Input: %d%s\n", state->input, 114 138 state->muted ? " (muted)" : ""); 115 139 break; 116 140 ··· 176 170 client->driver = &i2c_driver; 177 171 snprintf(client->name, sizeof(client->name) - 1, "wm8775"); 178 172 179 - wm8775_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name); 173 + v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name); 180 174 181 175 state = kmalloc(sizeof(struct wm8775_state), GFP_KERNEL); 182 176 if (state == NULL) { ··· 212 206 213 207 static int wm8775_probe(struct i2c_adapter *adapter) 214 208 { 215 - #ifdef I2C_CLASS_TV_ANALOG 216 209 if (adapter->class & I2C_CLASS_TV_ANALOG) 217 - #else 218 - if (adapter->id == I2C_HW_B_BT848) 219 - #endif 220 210 return i2c_probe(adapter, &addr_data, wm8775_attach); 221 211 return 0; 222 212 } ··· 237 235 .driver = { 238 236 .name = "wm8775", 239 237 }, 240 - 241 - .id = I2C_DRIVERID_WM8775, 242 - 238 + .id = I2C_DRIVERID_WM8775, 243 239 .attach_adapter = wm8775_probe, 244 - .detach_client = wm8775_detach, 245 - .command = wm8775_command, 240 + .detach_client = wm8775_detach, 241 + .command = wm8775_command, 246 242 }; 247 243 248 244
+1
drivers/media/video/zoran_driver.c
··· 4678 4678 .open = zoran_open, 4679 4679 .release = zoran_close, 4680 4680 .ioctl = zoran_ioctl, 4681 + .compat_ioctl = v4l_compat_ioctl32, 4681 4682 .llseek = no_llseek, 4682 4683 .read = zoran_read, 4683 4684 .write = zoran_write,
+1
drivers/media/video/zr36120.c
··· 1490 1490 .write = zoran_write, 1491 1491 .poll = zoran_poll, 1492 1492 .ioctl = zoran_ioctl, 1493 + .compat_ioctl = v4l_compat_ioctl32, 1493 1494 .mmap = zoran_mmap, 1494 1495 .minor = -1, 1495 1496 };
+1
drivers/usb/media/dsbr100.c
··· 127 127 .open = usb_dsbr100_open, 128 128 .release = usb_dsbr100_close, 129 129 .ioctl = usb_dsbr100_ioctl, 130 + .compat_ioctl = v4l_compat_ioctl32, 130 131 .llseek = no_llseek, 131 132 }; 132 133
+1
drivers/usb/media/ov511.c
··· 4774 4774 .read = ov51x_v4l1_read, 4775 4775 .mmap = ov51x_v4l1_mmap, 4776 4776 .ioctl = ov51x_v4l1_ioctl, 4777 + .compat_ioctl = v4l_compat_ioctl32, 4777 4778 .llseek = no_llseek, 4778 4779 }; 4779 4780
+1
drivers/usb/media/pwc/pwc-if.c
··· 154 154 .poll = pwc_video_poll, 155 155 .mmap = pwc_video_mmap, 156 156 .ioctl = pwc_video_ioctl, 157 + .compat_ioctl = v4l_compat_ioctl32, 157 158 .llseek = no_llseek, 158 159 }; 159 160 static struct video_device pwc_template = {
+1
drivers/usb/media/se401.c
··· 1193 1193 .read = se401_read, 1194 1194 .mmap = se401_mmap, 1195 1195 .ioctl = se401_ioctl, 1196 + .compat_ioctl = v4l_compat_ioctl32, 1196 1197 .llseek = no_llseek, 1197 1198 }; 1198 1199 static struct video_device se401_template = {
+1
drivers/usb/media/stv680.c
··· 1343 1343 .read = stv680_read, 1344 1344 .mmap = stv680_mmap, 1345 1345 .ioctl = stv680_ioctl, 1346 + .compat_ioctl = v4l_compat_ioctl32, 1346 1347 .llseek = no_llseek, 1347 1348 }; 1348 1349 static struct video_device stv680_template = {
+1
drivers/usb/media/usbvideo.c
··· 953 953 .read = usbvideo_v4l_read, 954 954 .mmap = usbvideo_v4l_mmap, 955 955 .ioctl = usbvideo_v4l_ioctl, 956 + .compat_ioctl = v4l_compat_ioctl32, 956 957 .llseek = no_llseek, 957 958 }; 958 959 static const struct video_device usbvideo_template = {
+1
drivers/usb/media/vicam.c
··· 1236 1236 .read = vicam_read, 1237 1237 .mmap = vicam_mmap, 1238 1238 .ioctl = vicam_ioctl, 1239 + .compat_ioctl = v4l_compat_ioctl32, 1239 1240 .llseek = no_llseek, 1240 1241 }; 1241 1242
+1
drivers/usb/media/w9968cf.c
··· 3490 3490 .release = w9968cf_release, 3491 3491 .read = w9968cf_read, 3492 3492 .ioctl = w9968cf_ioctl, 3493 + .compat_ioctl = v4l_compat_ioctl32, 3493 3494 .mmap = w9968cf_mmap, 3494 3495 .llseek = no_llseek, 3495 3496 };
-246
fs/compat_ioctl.c
··· 207 207 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg)); 208 208 } 209 209 210 - struct video_tuner32 { 211 - compat_int_t tuner; 212 - char name[32]; 213 - compat_ulong_t rangelow, rangehigh; 214 - u32 flags; /* It is really u32 in videodev.h */ 215 - u16 mode, signal; 216 - }; 217 - 218 - static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) 219 - { 220 - int i; 221 - 222 - if(get_user(kp->tuner, &up->tuner)) 223 - return -EFAULT; 224 - for(i = 0; i < 32; i++) 225 - __get_user(kp->name[i], &up->name[i]); 226 - __get_user(kp->rangelow, &up->rangelow); 227 - __get_user(kp->rangehigh, &up->rangehigh); 228 - __get_user(kp->flags, &up->flags); 229 - __get_user(kp->mode, &up->mode); 230 - __get_user(kp->signal, &up->signal); 231 - return 0; 232 - } 233 - 234 - static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) 235 - { 236 - int i; 237 - 238 - if(put_user(kp->tuner, &up->tuner)) 239 - return -EFAULT; 240 - for(i = 0; i < 32; i++) 241 - __put_user(kp->name[i], &up->name[i]); 242 - __put_user(kp->rangelow, &up->rangelow); 243 - __put_user(kp->rangehigh, &up->rangehigh); 244 - __put_user(kp->flags, &up->flags); 245 - __put_user(kp->mode, &up->mode); 246 - __put_user(kp->signal, &up->signal); 247 - return 0; 248 - } 249 - 250 - struct video_buffer32 { 251 - compat_caddr_t base; 252 - compat_int_t height, width, depth, bytesperline; 253 - }; 254 - 255 - static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up) 256 - { 257 - u32 tmp; 258 - 259 - if (get_user(tmp, &up->base)) 260 - return -EFAULT; 261 - 262 - /* This is actually a physical address stored 263 - * as a void pointer. 264 - */ 265 - kp->base = (void *)(unsigned long) tmp; 266 - 267 - __get_user(kp->height, &up->height); 268 - __get_user(kp->width, &up->width); 269 - __get_user(kp->depth, &up->depth); 270 - __get_user(kp->bytesperline, &up->bytesperline); 271 - return 0; 272 - } 273 - 274 - static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up) 275 - { 276 - u32 tmp = (u32)((unsigned long)kp->base); 277 - 278 - if(put_user(tmp, &up->base)) 279 - return -EFAULT; 280 - __put_user(kp->height, &up->height); 281 - __put_user(kp->width, &up->width); 282 - __put_user(kp->depth, &up->depth); 283 - __put_user(kp->bytesperline, &up->bytesperline); 284 - return 0; 285 - } 286 - 287 - struct video_clip32 { 288 - s32 x, y, width, height; /* Its really s32 in videodev.h */ 289 - compat_caddr_t next; 290 - }; 291 - 292 - struct video_window32 { 293 - u32 x, y, width, height, chromakey, flags; 294 - compat_caddr_t clips; 295 - compat_int_t clipcount; 296 - }; 297 - 298 - /* You get back everything except the clips... */ 299 - static int put_video_window32(struct video_window *kp, struct video_window32 __user *up) 300 - { 301 - if(put_user(kp->x, &up->x)) 302 - return -EFAULT; 303 - __put_user(kp->y, &up->y); 304 - __put_user(kp->width, &up->width); 305 - __put_user(kp->height, &up->height); 306 - __put_user(kp->chromakey, &up->chromakey); 307 - __put_user(kp->flags, &up->flags); 308 - __put_user(kp->clipcount, &up->clipcount); 309 - return 0; 310 - } 311 - 312 - #define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32) 313 - #define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32) 314 - #define VIDIOCGWIN32 _IOR('v',9, struct video_window32) 315 - #define VIDIOCSWIN32 _IOW('v',10, struct video_window32) 316 - #define VIDIOCGFBUF32 _IOR('v',11, struct video_buffer32) 317 - #define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32) 318 - #define VIDIOCGFREQ32 _IOR('v',14, u32) 319 - #define VIDIOCSFREQ32 _IOW('v',15, u32) 320 - 321 - enum { 322 - MaxClips = (~0U-sizeof(struct video_window))/sizeof(struct video_clip) 323 - }; 324 - 325 - static int do_set_window(unsigned int fd, unsigned int cmd, unsigned long arg) 326 - { 327 - struct video_window32 __user *up = compat_ptr(arg); 328 - struct video_window __user *vw; 329 - struct video_clip __user *p; 330 - int nclips; 331 - u32 n; 332 - 333 - if (get_user(nclips, &up->clipcount)) 334 - return -EFAULT; 335 - 336 - /* Peculiar interface... */ 337 - if (nclips < 0) 338 - nclips = VIDEO_CLIPMAP_SIZE; 339 - 340 - if (nclips > MaxClips) 341 - return -ENOMEM; 342 - 343 - vw = compat_alloc_user_space(sizeof(struct video_window) + 344 - nclips * sizeof(struct video_clip)); 345 - 346 - p = nclips ? (struct video_clip __user *)(vw + 1) : NULL; 347 - 348 - if (get_user(n, &up->x) || put_user(n, &vw->x) || 349 - get_user(n, &up->y) || put_user(n, &vw->y) || 350 - get_user(n, &up->width) || put_user(n, &vw->width) || 351 - get_user(n, &up->height) || put_user(n, &vw->height) || 352 - get_user(n, &up->chromakey) || put_user(n, &vw->chromakey) || 353 - get_user(n, &up->flags) || put_user(n, &vw->flags) || 354 - get_user(n, &up->clipcount) || put_user(n, &vw->clipcount) || 355 - get_user(n, &up->clips) || put_user(p, &vw->clips)) 356 - return -EFAULT; 357 - 358 - if (nclips) { 359 - struct video_clip32 __user *u = compat_ptr(n); 360 - int i; 361 - if (!u) 362 - return -EINVAL; 363 - for (i = 0; i < nclips; i++, u++, p++) { 364 - s32 v; 365 - if (get_user(v, &u->x) || 366 - put_user(v, &p->x) || 367 - get_user(v, &u->y) || 368 - put_user(v, &p->y) || 369 - get_user(v, &u->width) || 370 - put_user(v, &p->width) || 371 - get_user(v, &u->height) || 372 - put_user(v, &p->height) || 373 - put_user(NULL, &p->next)) 374 - return -EFAULT; 375 - } 376 - } 377 - 378 - return sys_ioctl(fd, VIDIOCSWIN, (unsigned long)p); 379 - } 380 - 381 - static int do_video_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) 382 - { 383 - union { 384 - struct video_tuner vt; 385 - struct video_buffer vb; 386 - struct video_window vw; 387 - unsigned long vx; 388 - } karg; 389 - mm_segment_t old_fs = get_fs(); 390 - void __user *up = compat_ptr(arg); 391 - int err = 0; 392 - 393 - /* First, convert the command. */ 394 - switch(cmd) { 395 - case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break; 396 - case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break; 397 - case VIDIOCGWIN32: cmd = VIDIOCGWIN; break; 398 - case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break; 399 - case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break; 400 - case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break; 401 - case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break; 402 - }; 403 - 404 - switch(cmd) { 405 - case VIDIOCSTUNER: 406 - case VIDIOCGTUNER: 407 - err = get_video_tuner32(&karg.vt, up); 408 - break; 409 - 410 - case VIDIOCSFBUF: 411 - err = get_video_buffer32(&karg.vb, up); 412 - break; 413 - 414 - case VIDIOCSFREQ: 415 - err = get_user(karg.vx, (u32 __user *)up); 416 - break; 417 - }; 418 - if(err) 419 - goto out; 420 - 421 - set_fs(KERNEL_DS); 422 - err = sys_ioctl(fd, cmd, (unsigned long)&karg); 423 - set_fs(old_fs); 424 - 425 - if(err == 0) { 426 - switch(cmd) { 427 - case VIDIOCGTUNER: 428 - err = put_video_tuner32(&karg.vt, up); 429 - break; 430 - 431 - case VIDIOCGWIN: 432 - err = put_video_window32(&karg.vw, up); 433 - break; 434 - 435 - case VIDIOCGFBUF: 436 - err = put_video_buffer32(&karg.vb, up); 437 - break; 438 - 439 - case VIDIOCGFREQ: 440 - err = put_user(((u32)karg.vx), (u32 __user *)up); 441 - break; 442 - }; 443 - } 444 - out: 445 - return err; 446 - } 447 - 448 210 struct compat_dmx_event { 449 211 dmx_event_t event; 450 212 compat_time_t timeStamp; ··· 2777 3015 #ifdef CONFIG_JBD_DEBUG 2778 3016 HANDLE_IOCTL(EXT3_IOC32_WAIT_FOR_READONLY, do_ext3_ioctl) 2779 3017 #endif 2780 - HANDLE_IOCTL(VIDIOCGTUNER32, do_video_ioctl) 2781 - HANDLE_IOCTL(VIDIOCSTUNER32, do_video_ioctl) 2782 - HANDLE_IOCTL(VIDIOCGWIN32, do_video_ioctl) 2783 - HANDLE_IOCTL(VIDIOCSWIN32, do_set_window) 2784 - HANDLE_IOCTL(VIDIOCGFBUF32, do_video_ioctl) 2785 - HANDLE_IOCTL(VIDIOCSFBUF32, do_video_ioctl) 2786 - HANDLE_IOCTL(VIDIOCGFREQ32, do_video_ioctl) 2787 - HANDLE_IOCTL(VIDIOCSFREQ32, do_video_ioctl) 2788 3018 /* One SMB ioctl needs translations. */ 2789 3019 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) 2790 3020 HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
-26
include/linux/compat_ioctl.h
··· 218 218 COMPATIBLE_IOCTL(VT_RESIZEX) 219 219 COMPATIBLE_IOCTL(VT_LOCKSWITCH) 220 220 COMPATIBLE_IOCTL(VT_UNLOCKSWITCH) 221 - /* Little v */ 222 - /* Little v, the video4linux ioctls (conflict?) */ 223 - COMPATIBLE_IOCTL(VIDIOCGCAP) 224 - COMPATIBLE_IOCTL(VIDIOCGCHAN) 225 - COMPATIBLE_IOCTL(VIDIOCSCHAN) 226 - COMPATIBLE_IOCTL(VIDIOCGPICT) 227 - COMPATIBLE_IOCTL(VIDIOCSPICT) 228 - COMPATIBLE_IOCTL(VIDIOCCAPTURE) 229 - COMPATIBLE_IOCTL(VIDIOCKEY) 230 - COMPATIBLE_IOCTL(VIDIOCGAUDIO) 231 - COMPATIBLE_IOCTL(VIDIOCSAUDIO) 232 - COMPATIBLE_IOCTL(VIDIOCSYNC) 233 - COMPATIBLE_IOCTL(VIDIOCMCAPTURE) 234 - COMPATIBLE_IOCTL(VIDIOCGMBUF) 235 - COMPATIBLE_IOCTL(VIDIOCGUNIT) 236 - COMPATIBLE_IOCTL(VIDIOCGCAPTURE) 237 - COMPATIBLE_IOCTL(VIDIOCSCAPTURE) 238 - /* BTTV specific... */ 239 - COMPATIBLE_IOCTL(_IOW('v', BASE_VIDIOCPRIVATE+0, char [256])) 240 - COMPATIBLE_IOCTL(_IOR('v', BASE_VIDIOCPRIVATE+1, char [256])) 241 - COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)) 242 - COMPATIBLE_IOCTL(_IOW('v' , BASE_VIDIOCPRIVATE+3, char [16])) /* struct bttv_pll_info */ 243 - COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+4, int)) 244 - COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+5, int)) 245 - COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+6, int)) 246 - COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+7, int)) 247 221 /* Little p (/dev/rtc, /dev/envctrl, etc.) */ 248 222 COMPATIBLE_IOCTL(RTC_AIE_ON) 249 223 COMPATIBLE_IOCTL(RTC_AIE_OFF)
+10
include/linux/dvb/frontend.h
··· 240 240 }; 241 241 242 242 243 + /** 244 + * When set, this flag will disable any zigzagging or other "normal" tuning 245 + * behaviour. Additionally, there will be no automatic monitoring of the lock 246 + * status, and hence no frontend events will be generated. If a frontend device 247 + * is closed, this flag will be automatically turned off when the device is 248 + * reopened read-write. 249 + */ 250 + #define FE_TUNE_MODE_ONESHOT 0x01 251 + 243 252 244 253 #define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info) 245 254 ··· 269 260 270 261 #define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters) 271 262 #define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters) 263 + #define FE_SET_FRONTEND_TUNE_MODE _IO('o', 81) /* unsigned int */ 272 264 #define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event) 273 265 274 266 #define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
+1
include/linux/i2c-id.h
··· 103 103 #define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */ 104 104 #define I2C_DRIVERID_AKITAIOEXP 74 /* IO Expander on Sharp SL-C1000 */ 105 105 #define I2C_DRIVERID_INFRARED 75 /* I2C InfraRed on Video boards */ 106 + #define I2C_DRIVERID_TVP5150 76 /* TVP5150 video decoder */ 106 107 107 108 #define I2C_DRIVERID_I2CDEV 900 108 109 #define I2C_DRIVERID_ARP 902 /* SMBus ARP Client */
+2
include/linux/video_decoder.h
··· 1 1 #ifndef _LINUX_VIDEO_DECODER_H 2 2 #define _LINUX_VIDEO_DECODER_H 3 3 4 + #define HAVE_VIDEO_DECODER 1 5 + 4 6 struct video_decoder_capability { /* this name is too long */ 5 7 __u32 flags; 6 8 #define VIDEO_DECODER_PAL 1 /* can decode PAL signal */
+13 -3
include/linux/videodev2.h
··· 642 642 #define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000) 643 643 #define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000) 644 644 645 + /* some merged standards */ 646 + #define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC) 647 + #define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B) 648 + #define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H) 649 + #define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK) 650 + 645 651 /* some common needed stuff */ 646 652 #define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\ 647 653 V4L2_STD_PAL_B1 |\ ··· 668 662 V4L2_STD_SECAM_G |\ 669 663 V4L2_STD_SECAM_H |\ 670 664 V4L2_STD_SECAM_DK |\ 671 - V4L2_STD_SECAM_L) 665 + V4L2_STD_SECAM_L |\ 666 + V4L2_STD_SECAM_LC) 672 667 673 668 #define V4L2_STD_525_60 (V4L2_STD_PAL_M |\ 674 669 V4L2_STD_PAL_60 |\ ··· 895 888 896 889 /* Flags for the 'mode' field */ 897 890 #define V4L2_AUDMODE_AVL 0x00001 898 - #define V4L2_AUDMODE_32BITS 0x00002 899 891 900 892 struct v4l2_audioout 901 893 { ··· 1116 1110 /* names for fancy debug output */ 1117 1111 extern char *v4l2_field_names[]; 1118 1112 extern char *v4l2_type_names[]; 1119 - extern char *v4l2_ioctl_names[]; 1120 1113 1121 1114 /* Compatibility layer interface -- v4l1-compat module */ 1122 1115 typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file, 1123 1116 unsigned int cmd, void *arg); 1124 1117 int v4l_compat_translate_ioctl(struct inode *inode, struct file *file, 1125 1118 int cmd, void *arg, v4l2_kioctl driver_ioctl); 1119 + 1120 + /* 32 Bits compatibility layer for 64 bits processors */ 1121 + extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd, 1122 + unsigned long arg); 1123 + 1126 1124 1127 1125 #endif /* __KERNEL__ */ 1128 1126 #endif /* __LINUX_VIDEODEV2_H */
-16
include/media/audiochip.h
··· 23 23 24 24 /* ---------------------------------------------------------------------- */ 25 25 26 - /* v4l device was opened in Radio mode */ 27 - #define AUDC_SET_RADIO _IO('m',2) 28 - /* select from TV,radio,extern,MUTE */ 29 - #define AUDC_SET_INPUT _IOW('m',17,int) 30 - 31 26 /* audio inputs */ 32 27 #define AUDIO_TUNER 0x00 33 28 #define AUDIO_RADIO 0x01 ··· 35 40 #define AUDIO_MUTE 0x80 36 41 #define AUDIO_UNMUTE 0x81 37 42 38 - /* all the stuff below is obsolete and just here for reference. I'll 39 - * remove it once the driver is tested and works fine. 40 - * 41 - * Instead creating alot of tiny API's for all kinds of different 42 - * chips, we'll just pass throuth the v4l ioctl structs (v4l2 not 43 - * yet...). It is a bit less flexible, but most/all used i2c chips 44 - * make sense in v4l context only. So I think that's acceptable... 45 - */ 46 - 47 - /* misc stuff to pass around config info to i2c chips */ 48 - #define AUDC_CONFIG_PINNACLE _IOW('m',32,int) 49 43 #endif /* AUDIOCHIP_H */
+2
include/media/saa7146_vv.h
··· 178 178 179 179 struct saa7146_extension_ioctls *ioctls; 180 180 int (*ioctl)(struct saa7146_fh*, unsigned int cmd, void *arg); 181 + 182 + struct file_operations vbi_fops; 181 183 }; 182 184 183 185 struct saa7146_use_ops {
+46 -52
include/media/tuner.h
··· 82 82 #define TUNER_PHILIPS_FM1236_MK3 43 83 83 84 84 #define TUNER_PHILIPS_4IN1 44 /* ATI TV Wonder Pro - Conexant */ 85 - /* Microtune mergeged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */ 85 + /* Microtune merged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */ 86 86 #define TUNER_MICROTUNE_4049FM5 45 87 - #define TUNER_MICROTUNE_4042_FI5 46 87 + #define TUNER_PANASONIC_VP27 46 88 88 #define TUNER_LG_NTSC_TAPE 47 89 89 90 90 #define TUNER_TNF_8831BGFF 48 ··· 102 102 #define TUNER_YMEC_TVF_8531MF 58 103 103 #define TUNER_YMEC_TVF_5533MF 59 /* Pixelview Pro Ultra NTSC */ 104 104 105 - #define TUNER_THOMSON_DTT7611 60 /* DViCO FusionHDTV 3 Gold-T */ 105 + #define TUNER_THOMSON_DTT761X 60 /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */ 106 106 #define TUNER_TENA_9533_DI 61 107 107 #define TUNER_TEA5767 62 /* Only FM Radio Tuner */ 108 108 #define TUNER_PHILIPS_FMD1216ME_MK3 63 ··· 115 115 #define TUNER_PHILIPS_TUV1236D 68 /* ATI HDTV Wonder */ 116 116 #define TUNER_TNF_5335MF 69 /* Sabrent Bt848 */ 117 117 118 - #define NOTUNER 0 119 - #define PAL 1 /* PAL_BG */ 120 - #define PAL_I 2 121 - #define NTSC 3 122 - #define SECAM 4 123 - #define ATSC 5 124 - #define RADIO 6 125 - 126 - #define NoTuner 0 127 - #define Philips 1 128 - #define TEMIC 2 129 - #define Sony 3 130 - #define Alps 4 131 - #define LGINNOTEK 5 132 - #define SHARP 6 133 - #define Samsung 7 134 - #define Microtune 8 135 - #define HITACHI 9 136 - #define Panasonic 10 137 - #define TCL 11 138 - #define THOMSON 12 139 - 140 - #define TUNER_SET_TYPE_ADDR _IOW('T',3,int) 141 - #define TUNER_SET_STANDBY _IOW('T',4,int) 142 - #define TDA9887_SET_CONFIG _IOW('t',5,int) 143 - 144 118 /* tv card specific */ 145 - # define TDA9887_PRESENT (1<<0) 146 - # define TDA9887_PORT1_INACTIVE (1<<1) 147 - # define TDA9887_PORT2_INACTIVE (1<<2) 148 - # define TDA9887_QSS (1<<3) 149 - # define TDA9887_INTERCARRIER (1<<4) 150 - # define TDA9887_PORT1_ACTIVE (1<<5) 151 - # define TDA9887_PORT2_ACTIVE (1<<6) 152 - # define TDA9887_INTERCARRIER_NTSC (1<<7) 119 + #define TDA9887_PRESENT (1<<0) 120 + #define TDA9887_PORT1_INACTIVE (1<<1) 121 + #define TDA9887_PORT2_INACTIVE (1<<2) 122 + #define TDA9887_QSS (1<<3) 123 + #define TDA9887_INTERCARRIER (1<<4) 124 + #define TDA9887_PORT1_ACTIVE (1<<5) 125 + #define TDA9887_PORT2_ACTIVE (1<<6) 126 + #define TDA9887_INTERCARRIER_NTSC (1<<7) 127 + /* Tuner takeover point adjustment, in dB, -16 <= top <= 15 */ 128 + #define TDA9887_TOP_MASK (0x3f << 8) 129 + #define TDA9887_TOP_SET (1 << 13) 130 + #define TDA9887_TOP(top) (TDA9887_TOP_SET | (((16 + (top)) & 0x1f) << 8)) 131 + 153 132 /* config options */ 154 - # define TDA9887_DEEMPHASIS_MASK (3<<16) 155 - # define TDA9887_DEEMPHASIS_NONE (1<<16) 156 - # define TDA9887_DEEMPHASIS_50 (2<<16) 157 - # define TDA9887_DEEMPHASIS_75 (3<<16) 158 - # define TDA9887_AUTOMUTE (1<<18) 133 + #define TDA9887_DEEMPHASIS_MASK (3<<16) 134 + #define TDA9887_DEEMPHASIS_NONE (1<<16) 135 + #define TDA9887_DEEMPHASIS_50 (2<<16) 136 + #define TDA9887_DEEMPHASIS_75 (3<<16) 137 + #define TDA9887_AUTOMUTE (1<<18) 159 138 160 139 #ifdef __KERNEL__ 161 140 ··· 146 167 T_STANDBY = 1 << 31 147 168 }; 148 169 170 + /* Older boards only had a single tuner device. Nowadays multiple tuner 171 + devices may be present on a single board. Using TUNER_SET_TYPE_ADDR 172 + to pass the tuner_setup structure it is possible to setup each tuner 173 + device in turn. 174 + 175 + Since multiple devices may be present it is no longer sufficient to 176 + send a command to a single i2c device. Instead you should broadcast 177 + the command to all i2c devices. 178 + 179 + By setting the mode_mask correctly you can select which commands are 180 + accepted by a specific tuner device. For example, set mode_mask to 181 + T_RADIO if the device is a radio-only tuner. That specific tuner will 182 + only accept commands when the tuner is in radio mode and ignore them 183 + when the tuner is set to TV mode. 184 + */ 185 + 149 186 struct tuner_setup { 150 - unsigned short addr; 151 - unsigned int type; 152 - unsigned int mode_mask; 187 + unsigned short addr; /* I2C address */ 188 + unsigned int type; /* Tuner type */ 189 + unsigned int mode_mask; /* Allowed tuner modes */ 153 190 }; 154 191 155 192 struct tuner { ··· 202 207 void (*standby)(struct i2c_client *c); 203 208 }; 204 209 205 - extern unsigned int tuner_debug; 206 210 extern unsigned const int tuner_count; 207 211 208 212 extern int microtune_init(struct i2c_client *c); ··· 213 219 214 220 #define tuner_warn(fmt, arg...) do {\ 215 221 printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ 216 - t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) 222 + i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) 217 223 #define tuner_info(fmt, arg...) do {\ 218 224 printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ 219 - t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) 225 + i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) 220 226 #define tuner_dbg(fmt, arg...) do {\ 221 - if (tuner_debug) \ 222 - printk(KERN_DEBUG "%s %d-%04x: " fmt, \ 223 - t->i2c.driver->driver.name, \ 224 - t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) 227 + extern int debug; \ 228 + if (debug) \ 229 + printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ 230 + i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) 225 231 226 232 #endif /* __KERNEL__ */ 227 233
+76 -9
include/media/v4l2-common.h
··· 26 26 #ifndef V4L2_COMMON_H_ 27 27 #define V4L2_COMMON_H_ 28 28 29 - /* VIDIOC_INT_AUDIO_CLOCK_FREQ */ 30 - enum v4l2_audio_clock_freq { 31 - V4L2_AUDCLK_32_KHZ = 32000, 32 - V4L2_AUDCLK_441_KHZ = 44100, 33 - V4L2_AUDCLK_48_KHZ = 48000, 34 - }; 29 + /* v4l debugging and diagnostics */ 30 + 31 + /* Common printk constucts for v4l-i2c drivers. These macros create a unique 32 + prefix consisting of the driver name, the adapter number and the i2c 33 + address. */ 34 + #define v4l_printk(level, name, adapter, addr, fmt, arg...) \ 35 + printk(level "%s %d-%04x: " fmt, name, i2c_adapter_id(adapter), addr , ## arg) 36 + 37 + #define v4l_client_printk(level, client, fmt, arg...) \ 38 + v4l_printk(level, (client)->driver->driver.name, (client)->adapter, \ 39 + (client)->addr, fmt , ## arg) 40 + 41 + #define v4l_err(client, fmt, arg...) \ 42 + v4l_client_printk(KERN_ERR, client, fmt , ## arg) 43 + 44 + #define v4l_warn(client, fmt, arg...) \ 45 + v4l_client_printk(KERN_WARNING, client, fmt , ## arg) 46 + 47 + #define v4l_info(client, fmt, arg...) \ 48 + v4l_client_printk(KERN_INFO, client, fmt , ## arg) 49 + 50 + /* These three macros assume that the debug level is set with a module 51 + parameter called 'debug'. */ 52 + #define v4l_dbg(level, client, fmt, arg...) \ 53 + do { \ 54 + extern int debug; \ 55 + if (debug >= (level)) \ 56 + v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \ 57 + } while (0) 58 + 59 + /* Prints the ioctl in a human-readable format */ 60 + extern void v4l_printk_ioctl(unsigned int cmd); 61 + 62 + /* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */ 63 + #define v4l_print_ioctl(name, cmd) \ 64 + do { \ 65 + printk(KERN_DEBUG "%s: ", name); \ 66 + v4l_printk_ioctl(cmd); \ 67 + } while (0) 68 + 69 + /* Use this macro in I2C drivers where 'client' is the struct i2c_client 70 + pointer */ 71 + #define v4l_i2c_print_ioctl(client, cmd) \ 72 + do { \ 73 + v4l_client_printk(KERN_DEBUG, client, ""); \ 74 + v4l_printk_ioctl(cmd); \ 75 + } while (0) 76 + 77 + /* ------------------------------------------------------------------------- */ 78 + 79 + /* Internal ioctls */ 35 80 36 81 /* VIDIOC_INT_G_REGISTER and VIDIOC_INT_S_REGISTER */ 37 82 struct v4l2_register { ··· 115 70 V4L2_IDENT_CX25843 = 243, 116 71 }; 117 72 73 + /* audio ioctls */ 74 + /* v4l device was opened in Radio mode */ 75 + #define AUDC_SET_RADIO _IO('d',88) 76 + /* select from TV,radio,extern,MUTE */ 77 + #define AUDC_SET_INPUT _IOW('d',89,int) 78 + 79 + /* tuner ioctls */ 80 + /* Sets tuner type and its I2C addr */ 81 + #define TUNER_SET_TYPE_ADDR _IOW('d',90,int) 82 + /* Puts tuner on powersaving state, disabling it, except for i2c */ 83 + #define TUNER_SET_STANDBY _IOW('d',91,int) 84 + /* Sets tda9887 specific stuff, like port1, port2 and qss */ 85 + #define TDA9887_SET_CONFIG _IOW('d',92,int) 86 + 118 87 /* only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */ 119 88 #define VIDIOC_INT_S_REGISTER _IOR ('d', 100, struct v4l2_register) 120 89 #define VIDIOC_INT_G_REGISTER _IOWR('d', 101, struct v4l2_register) ··· 136 77 /* Reset the I2C chip */ 137 78 #define VIDIOC_INT_RESET _IO ('d', 102) 138 79 139 - /* Set the frequency of the audio clock output. 80 + /* Set the frequency (in Hz) of the audio clock output. 140 81 Used to slave an audio processor to the video decoder, ensuring that audio 141 - and video remain synchronized. */ 142 - #define VIDIOC_INT_AUDIO_CLOCK_FREQ _IOR ('d', 103, enum v4l2_audio_clock_freq) 82 + and video remain synchronized. 83 + Usual values for the frequency are 48000, 44100 or 32000 Hz. 84 + If the frequency is not supported, then -EINVAL is returned. */ 85 + #define VIDIOC_INT_AUDIO_CLOCK_FREQ _IOW ('d', 103, u32) 143 86 144 87 /* Video decoders that support sliced VBI need to implement this ioctl. 145 88 Field p of the v4l2_sliced_vbi_line struct is set to the start of the VBI ··· 167 106 /* Returns the chip identifier or V4L2_IDENT_UNKNOWN if no identification can 168 107 be made. */ 169 108 #define VIDIOC_INT_G_CHIP_IDENT _IOR ('d', 107, enum v4l2_chip_ident *) 109 + 110 + /* Sets I2S speed in bps. This is used to provide a standard way to select I2S 111 + clock used by driving digital audio streams at some board designs. 112 + Usual values for the frequency are 1024000 and 2048000. 113 + If the frequency is not supported, then -EINVAL is returned. */ 114 + #define VIDIOC_INT_I2S_CLOCK_FREQ _IOW ('d', 108, u32) 170 115 171 116 #endif /* V4L2_COMMON_H_ */