Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (95 commits)
V4L/DVB (9296): Patch to remove warning message during cx88-dvb compilation
V4L/DVB (9294): gspca: Add a stop sequence in t613.
V4L/DVB (9293): gspca: Separate and fix the sensor dependant sequences in t613.
V4L/DVB (9292): gspca: Call the control setting functions at init time in t613.
V4L/DVB (9291): gspca: Do not set the white balance temperature by default in t613.
V4L/DVB (9290): gspca: Adjust the sensor init sequences in t613.
V4L/DVB (9289): gspca: Other sensor identified as om6802 in t613.
V4L/DVB (9288): gspca: Write to the USB device and not USB interface in t613.
V4L/DVB (9287): gspca: Change the name of the multi bytes write function in t613.
V4L/DVB (9286): gspca: Compilation problem of gspca.c and the kernel version.
V4L/DVB (9283): Correct typo and enable setting the gain on the mt9m111 sensor
V4L/DVB (9282): Properly iterate the urbs when destroying them.
V4L/DVB (9281): gspca: Add hflip and vflip to the po1030 sensor
V4L/DVB (9280): gspca: Use the gspca debug macros
V4L/DVB (9279): gspca: Correct some copyright headers
V4L/DVB (9278): gspca: Remove the m5602_debug variable
V4L/DVB (9277): gspca: propagate an error in m5602_start_transfer()
V4L/DVB (9276): videobuf-dvb: two functions are now static
V4L/DVB (9275): dvb: input data pointer of cx24116_writeregN() should be const
V4L/DVB (9274): Remove spurious messages and turn into debug.
...

+4101 -4203
+1 -1
Documentation/video4linux/CARDLIST.au0828
··· 1 1 0 -> Unknown board (au0828) 2 - 1 -> Hauppauge HVR950Q (au0828) [2040:7200,2040:7210,2040:7217,2040:721b,2040:721f,2040:7280,0fd9:0008] 2 + 1 -> Hauppauge HVR950Q (au0828) [2040:7200,2040:7210,2040:7217,2040:721b,2040:721e,2040:721f,2040:7280,0fd9:0008] 3 3 2 -> Hauppauge HVR850 (au0828) [2040:7240] 4 4 3 -> DViCO FusionHDTV USB (au0828) [0fe9:d620] 5 5 4 -> Hauppauge HVR950Q rev xxF8 (au0828) [2040:7201,2040:7211,2040:7281]
+1
Documentation/video4linux/CARDLIST.tuner
··· 75 75 tuner=75 - Philips TEA5761 FM Radio 76 76 tuner=76 - Xceive 5000 tuner 77 77 tuner=77 - TCL tuner MF02GIP-5N-E 78 + tuner=78 - Philips FMD1216MEX MK3 Hybrid Tuner
+7 -3
drivers/media/common/tuners/mxl5005s.c
··· 3481 3481 } 3482 3482 ctrlVal = 0; 3483 3483 for (k = 0; k < state->MXL_Ctrl[i].size; k++) 3484 - ctrlVal += state->MXL_Ctrl[i].val[k] * (1 << k); 3484 + ctrlVal += state-> 3485 + MXL_Ctrl[i].val[k] * 3486 + (1 << k); 3485 3487 } else 3486 3488 return -1; 3487 3489 } ··· 3583 3581 3584 3582 static u32 MXL_Ceiling(u32 value, u32 resolution) 3585 3583 { 3586 - return (value/resolution + (value % resolution > 0 ? 1 : 0)); 3584 + return value / resolution + (value % resolution > 0 ? 1 : 0); 3587 3585 } 3588 3586 3589 3587 /* Retrieve the Initialzation Registers */ ··· 3912 3910 3913 3911 static int mxl5005s_init(struct dvb_frontend *fe) 3914 3912 { 3913 + struct mxl5005s_state *state = fe->tuner_priv; 3914 + 3915 3915 dprintk(1, "%s()\n", __func__); 3916 + state->current_mode = MXL_QAM; 3916 3917 return mxl5005s_reconfigure(fe, MXL_QAM, MXL5005S_BANDWIDTH_6MHZ); 3917 3918 } 3918 3919 ··· 4097 4092 state->frontend = fe; 4098 4093 state->config = config; 4099 4094 state->i2c = i2c; 4100 - state->current_mode = MXL_QAM; 4101 4095 4102 4096 printk(KERN_INFO "MXL5005S: Attached at address 0x%02x\n", 4103 4097 config->i2c_address);
+2
drivers/media/common/tuners/tuner-simple.c
··· 493 493 case TUNER_PHILIPS_FM1216ME_MK3: 494 494 case TUNER_PHILIPS_FM1236_MK3: 495 495 case TUNER_PHILIPS_FMD1216ME_MK3: 496 + case TUNER_PHILIPS_FMD1216MEX_MK3: 496 497 case TUNER_LG_NTSC_TAPE: 497 498 case TUNER_PHILIPS_FM1256_IH3: 498 499 case TUNER_TCL_MF02GIP_5N: ··· 768 767 769 768 switch (priv->type) { 770 769 case TUNER_PHILIPS_FMD1216ME_MK3: 770 + case TUNER_PHILIPS_FMD1216MEX_MK3: 771 771 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ && 772 772 params->frequency >= 158870000) 773 773 buf[3] |= 0x08;
+32 -1
drivers/media/common/tuners/tuner-types.c
··· 946 946 }, 947 947 }; 948 948 949 - /* ------------ TUNER_PHILIPS_FMD1216ME_MK3 - Philips PAL ------------ */ 949 + /* ------------ TUNER_PHILIPS_FMD1216ME(X)_MK3 - Philips PAL ------------ */ 950 950 951 951 static struct tuner_range tuner_philips_fmd1216me_mk3_pal_ranges[] = { 952 952 { 16 * 160.00 /*MHz*/, 0x86, 0x51, }, ··· 984 984 }, 985 985 }; 986 986 987 + static struct tuner_params tuner_philips_fmd1216mex_mk3_params[] = { 988 + { 989 + .type = TUNER_PARAM_TYPE_PAL, 990 + .ranges = tuner_philips_fmd1216me_mk3_pal_ranges, 991 + .count = ARRAY_SIZE(tuner_philips_fmd1216me_mk3_pal_ranges), 992 + .has_tda9887 = 1, 993 + .port1_active = 1, 994 + .port2_active = 1, 995 + .port2_fm_high_sensitivity = 1, 996 + .port2_invert_for_secam_lc = 1, 997 + .port1_set_for_fm_mono = 1, 998 + .radio_if = 1, 999 + .fm_gain_normal = 1, 1000 + }, 1001 + { 1002 + .type = TUNER_PARAM_TYPE_DIGITAL, 1003 + .ranges = tuner_philips_fmd1216me_mk3_dvb_ranges, 1004 + .count = ARRAY_SIZE(tuner_philips_fmd1216me_mk3_dvb_ranges), 1005 + .iffreq = 16 * 36.125, /*MHz*/ 1006 + }, 1007 + }; 987 1008 988 1009 /* ------ TUNER_LG_TDVS_H06XF - LG INNOTEK / INFINEON ATSC ----- */ 989 1010 ··· 1683 1662 .name = "TCL tuner MF02GIP-5N-E", 1684 1663 .params = tuner_tcl_mf02gip_5n_params, 1685 1664 .count = ARRAY_SIZE(tuner_tcl_mf02gip_5n_params), 1665 + }, 1666 + [TUNER_PHILIPS_FMD1216MEX_MK3] = { /* Philips PAL */ 1667 + .name = "Philips FMD1216MEX MK3 Hybrid Tuner", 1668 + .params = tuner_philips_fmd1216mex_mk3_params, 1669 + .count = ARRAY_SIZE(tuner_philips_fmd1216mex_mk3_params), 1670 + .min = 16 * 50.87, 1671 + .max = 16 * 858.00, 1672 + .stepsize = 166667, 1673 + .initdata = tua603x_agc112, 1674 + .sleepdata = (u8[]){ 4, 0x9c, 0x60, 0x85, 0x54 }, 1686 1675 }, 1687 1676 }; 1688 1677 EXPORT_SYMBOL(tuners);
+37 -36
drivers/media/common/tuners/xc5000.c
··· 43 43 static DEFINE_MUTEX(xc5000_list_mutex); 44 44 static LIST_HEAD(hybrid_tuner_instance_list); 45 45 46 - #define dprintk(level,fmt, arg...) if (debug >= level) \ 46 + #define dprintk(level, fmt, arg...) if (debug >= level) \ 47 47 printk(KERN_INFO "%s: " fmt, "xc5000", ## arg) 48 48 49 49 #define XC5000_DEFAULT_FIRMWARE "dvb-fe-xc5000-1.1.fw" ··· 138 138 immediately the length of the following transaction. 139 139 140 140 */ 141 - typedef struct { 141 + struct XC_TV_STANDARD { 142 142 char *Name; 143 143 u16 AudioMode; 144 144 u16 VideoMode; 145 - } XC_TV_STANDARD; 145 + }; 146 146 147 147 /* Tuner standards */ 148 148 #define MN_NTSC_PAL_BTSC 0 ··· 169 169 #define FM_Radio_INPUT2 21 170 170 #define FM_Radio_INPUT1 22 171 171 172 - static XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = { 172 + static struct XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = { 173 173 {"M/N-NTSC/PAL-BTSC", 0x0400, 0x8020}, 174 174 {"M/N-NTSC/PAL-A2", 0x0600, 0x8020}, 175 175 {"M/N-NTSC/PAL-EIAJ", 0x0440, 0x8020}, ··· 183 183 {"D/K-PAL-NICAM", 0x0E80, 0x8009}, 184 184 {"D/K-PAL-MONO", 0x1478, 0x8009}, 185 185 {"D/K-SECAM-A2 DK1", 0x1200, 0x8009}, 186 - {"D/K-SECAM-A2 L/DK3",0x0E00, 0x8009}, 186 + {"D/K-SECAM-A2 L/DK3", 0x0E00, 0x8009}, 187 187 {"D/K-SECAM-A2 MONO", 0x1478, 0x8009}, 188 188 {"L-SECAM-NICAM", 0x8E82, 0x0009}, 189 189 {"L'-SECAM-NICAM", 0x8E82, 0x4009}, ··· 307 307 unsigned int len, pos, index; 308 308 u8 buf[XC_MAX_I2C_WRITE_LENGTH]; 309 309 310 - index=0; 311 - while ((i2c_sequence[index]!=0xFF) || (i2c_sequence[index+1]!=0xFF)) { 312 - len = i2c_sequence[index]* 256 + i2c_sequence[index+1]; 310 + index = 0; 311 + while ((i2c_sequence[index] != 0xFF) || 312 + (i2c_sequence[index + 1] != 0xFF)) { 313 + len = i2c_sequence[index] * 256 + i2c_sequence[index+1]; 313 314 if (len == 0x0000) { 314 315 /* RESET command */ 315 316 result = xc_reset(fe); ··· 330 329 buf[1] = i2c_sequence[index + 1]; 331 330 pos = 2; 332 331 while (pos < len) { 333 - if ((len - pos) > XC_MAX_I2C_WRITE_LENGTH - 2) { 334 - nbytes_to_send = XC_MAX_I2C_WRITE_LENGTH; 335 - } else { 332 + if ((len - pos) > XC_MAX_I2C_WRITE_LENGTH - 2) 333 + nbytes_to_send = 334 + XC_MAX_I2C_WRITE_LENGTH; 335 + else 336 336 nbytes_to_send = (len - pos + 2); 337 + for (i = 2; i < nbytes_to_send; i++) { 338 + buf[i] = i2c_sequence[index + pos + 339 + i - 2]; 337 340 } 338 - for (i=2; i<nbytes_to_send; i++) { 339 - buf[i] = i2c_sequence[index + pos + i - 2]; 340 - } 341 - result = xc_send_i2c_data(priv, buf, nbytes_to_send); 341 + result = xc_send_i2c_data(priv, buf, 342 + nbytes_to_send); 342 343 343 344 if (result != XC_RESULT_SUCCESS) 344 345 return result; ··· 389 386 dprintk(1, "%s(%d) Source = %s\n", __func__, rf_mode, 390 387 rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE"); 391 388 392 - if ((rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE)) 393 - { 389 + if ((rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE)) { 394 390 rf_mode = XC_RF_MODE_CABLE; 395 391 printk(KERN_ERR 396 392 "%s(), Invalid mode, defaulting to CABLE", ··· 562 560 .flags = I2C_M_RD, .buf = buf, .len = len }; 563 561 564 562 if (i2c_transfer(priv->i2c_props.adap, &msg, 1) != 1) { 565 - printk(KERN_ERR "xc5000 I2C read failed (len=%i)\n",(int)len); 563 + printk(KERN_ERR "xc5000 I2C read failed (len=%i)\n", (int)len); 566 564 return -EREMOTEIO; 567 565 } 568 566 return 0; 569 567 } 570 568 571 - static int xc5000_fwupload(struct dvb_frontend* fe) 569 + static int xc5000_fwupload(struct dvb_frontend *fe) 572 570 { 573 571 struct xc5000_priv *priv = fe->tuner_priv; 574 572 const struct firmware *fw; ··· 578 576 printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n", 579 577 XC5000_DEFAULT_FIRMWARE); 580 578 581 - ret = request_firmware(&fw, XC5000_DEFAULT_FIRMWARE, &priv->i2c_props.adap->dev); 579 + ret = request_firmware(&fw, XC5000_DEFAULT_FIRMWARE, 580 + &priv->i2c_props.adap->dev); 582 581 if (ret) { 583 582 printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); 584 583 ret = XC_RESULT_RESET_FAILURE; ··· 595 592 ret = XC_RESULT_RESET_FAILURE; 596 593 } else { 597 594 printk(KERN_INFO "xc5000: firmware upload\n"); 598 - ret = xc_load_i2c_sequence(fe, fw->data ); 595 + ret = xc_load_i2c_sequence(fe, fw->data); 599 596 } 600 597 601 598 out: ··· 654 651 655 652 dprintk(1, "%s() frequency=%d (Hz)\n", __func__, params->frequency); 656 653 657 - switch(params->u.vsb.modulation) { 654 + switch (params->u.vsb.modulation) { 658 655 case VSB_8: 659 656 case VSB_16: 660 657 dprintk(1, "%s() VSB modulation\n", __func__); ··· 751 748 /* FIX ME: Some video standards may have several possible audio 752 749 standards. We simply default to one of them here. 753 750 */ 754 - if(params->std & V4L2_STD_MN) { 751 + if (params->std & V4L2_STD_MN) { 755 752 /* default to BTSC audio standard */ 756 753 priv->video_standard = MN_NTSC_PAL_BTSC; 757 754 goto tune_channel; 758 755 } 759 756 760 - if(params->std & V4L2_STD_PAL_BG) { 757 + if (params->std & V4L2_STD_PAL_BG) { 761 758 /* default to NICAM audio standard */ 762 759 priv->video_standard = BG_PAL_NICAM; 763 760 goto tune_channel; 764 761 } 765 762 766 - if(params->std & V4L2_STD_PAL_I) { 763 + if (params->std & V4L2_STD_PAL_I) { 767 764 /* default to NICAM audio standard */ 768 765 priv->video_standard = I_PAL_NICAM; 769 766 goto tune_channel; 770 767 } 771 768 772 - if(params->std & V4L2_STD_PAL_DK) { 769 + if (params->std & V4L2_STD_PAL_DK) { 773 770 /* default to NICAM audio standard */ 774 771 priv->video_standard = DK_PAL_NICAM; 775 772 goto tune_channel; 776 773 } 777 774 778 - if(params->std & V4L2_STD_SECAM_DK) { 775 + if (params->std & V4L2_STD_SECAM_DK) { 779 776 /* default to A2 DK1 audio standard */ 780 777 priv->video_standard = DK_SECAM_A2DK1; 781 778 goto tune_channel; 782 779 } 783 780 784 - if(params->std & V4L2_STD_SECAM_L) { 781 + if (params->std & V4L2_STD_SECAM_L) { 785 782 priv->video_standard = L_SECAM_NICAM; 786 783 goto tune_channel; 787 784 } 788 785 789 - if(params->std & V4L2_STD_SECAM_LC) { 786 + if (params->std & V4L2_STD_SECAM_LC) { 790 787 priv->video_standard = LC_SECAM_NICAM; 791 788 goto tune_channel; 792 789 } ··· 794 791 tune_channel: 795 792 ret = xc_SetSignalSource(priv, priv->rf_mode); 796 793 if (ret != XC_RESULT_SUCCESS) { 797 - printk(KERN_ERR 794 + printk(KERN_ERR 798 795 "xc5000: xc_SetSignalSource(%d) failed\n", 799 796 priv->rf_mode); 800 797 return -EREMOTEIO; ··· 866 863 * I2C transactions until calibration is complete. This way we 867 864 * don't have to rely on clock stretching working. 868 865 */ 869 - xc_wait( 100 ); 866 + xc_wait(100); 870 867 871 868 /* Default to "CABLE" mode */ 872 869 ret |= xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE); ··· 888 885 */ 889 886 890 887 ret = xc_shutdown(priv); 891 - if(ret != XC_RESULT_SUCCESS) { 888 + if (ret != XC_RESULT_SUCCESS) { 892 889 printk(KERN_ERR 893 890 "xc5000: %s() unable to shutdown tuner\n", 894 891 __func__); 895 892 return -EREMOTEIO; 896 - } 897 - else { 893 + } else 898 894 return XC_RESULT_SUCCESS; 899 - } 900 895 } 901 896 902 897 static int xc5000_init(struct dvb_frontend *fe) ··· 990 989 if (xc5000_readreg(priv, XREG_PRODUCT_ID, &id) != 0) 991 990 goto fail; 992 991 993 - switch(id) { 992 + switch (id) { 994 993 case XC_PRODUCT_ID_FW_LOADED: 995 994 printk(KERN_INFO 996 995 "xc5000: Successfully identified at address 0x%02x\n",
+4 -4
drivers/media/common/tuners/xc5000.h
··· 45 45 46 46 #if defined(CONFIG_MEDIA_TUNER_XC5000) || \ 47 47 (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) 48 - extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, 48 + extern struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, 49 49 struct i2c_adapter *i2c, 50 50 struct xc5000_config *cfg); 51 51 #else 52 - static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, 52 + static inline struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, 53 53 struct i2c_adapter *i2c, 54 54 struct xc5000_config *cfg) 55 55 { 56 56 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 57 57 return NULL; 58 58 } 59 - #endif // CONFIG_MEDIA_TUNER_XC5000 59 + #endif 60 60 61 - #endif // __XC5000_H__ 61 + #endif
+12
drivers/media/dvb/dm1105/dm1105.c
··· 595 595 dm1105dvb_dma_unmap(dm1105dvb); 596 596 } 597 597 598 + static struct stv0299_config sharp_z0194a_config = { 599 + .demod_address = 0x68, 600 + .inittab = sharp_z0194a_inittab, 601 + .mclk = 88000000UL, 602 + .invert = 1, 603 + .skip_reinit = 0, 604 + .lock_output = STV0299_LOCKOUTPUT_1, 605 + .volt13_op0_op1 = STV0299_VOLT13_OP1, 606 + .min_delay_ms = 100, 607 + .set_symbol_rate = sharp_z0194a_set_symbol_rate, 608 + }; 609 + 598 610 static struct stv0288_config earda_config = { 599 611 .demod_address = 0x68, 600 612 .min_delay_ms = 100,
+85 -49
drivers/media/dvb/dvb-core/dvb_frontend.c
··· 47 47 static int dvb_force_auto_inversion; 48 48 static int dvb_override_tune_delay; 49 49 static int dvb_powerdown_on_sleep = 1; 50 + static int dvb_mfe_wait_time = 5; 50 51 51 52 module_param_named(frontend_debug, dvb_frontend_debug, int, 0644); 52 53 MODULE_PARM_DESC(frontend_debug, "Turn on/off frontend core debugging (default:off)."); ··· 59 58 MODULE_PARM_DESC(dvb_override_tune_delay, "0: normal (default), >0 => delay in milliseconds to wait for lock after a tune attempt"); 60 59 module_param(dvb_powerdown_on_sleep, int, 0644); 61 60 MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB voltage off on sleep (default)"); 61 + module_param(dvb_mfe_wait_time, int, 0644); 62 + MODULE_PARM_DESC(dvb_mfe_wait_time, "Wait up to <mfe_wait_time> seconds on open() for multi-frontend to become available (default:5 seconds)"); 62 63 63 64 #define dprintk if (dvb_frontend_debug) printk 64 65 ··· 215 212 216 213 static void dvb_frontend_init(struct dvb_frontend *fe) 217 214 { 218 - dprintk ("DVB: initialising frontend %i (%s)...\n", 215 + dprintk ("DVB: initialising adapter %i frontend %i (%s)...\n", 219 216 fe->dvb->num, 217 + fe->id, 220 218 fe->ops.info.name); 221 219 222 220 if (fe->ops.init) ··· 690 686 mb(); 691 687 692 688 fe_thread = kthread_run(dvb_frontend_thread, fe, 693 - "kdvb-fe-%i", fe->dvb->num); 689 + "kdvb-ad-%i-fe-%i", fe->dvb->num,fe->id); 694 690 if (IS_ERR(fe_thread)) { 695 691 ret = PTR_ERR(fe_thread); 696 692 printk("dvb_frontend_start: failed to start kthread (%d)\n", ret); ··· 714 710 *freq_max = min(fe->ops.info.frequency_max, fe->ops.tuner_ops.info.frequency_max); 715 711 716 712 if (*freq_min == 0 || *freq_max == 0) 717 - printk(KERN_WARNING "DVB: frontend %u frequency limits undefined - fix the driver\n", 718 - fe->dvb->num); 713 + printk(KERN_WARNING "DVB: adapter %i frontend %u frequency limits undefined - fix the driver\n", 714 + fe->dvb->num,fe->id); 719 715 } 720 716 721 717 static int dvb_frontend_check_parameters(struct dvb_frontend *fe, ··· 728 724 dvb_frontend_get_frequeny_limits(fe, &freq_min, &freq_max); 729 725 if ((freq_min && parms->frequency < freq_min) || 730 726 (freq_max && parms->frequency > freq_max)) { 731 - printk(KERN_WARNING "DVB: frontend %u frequency %u out of range (%u..%u)\n", 732 - fe->dvb->num, parms->frequency, freq_min, freq_max); 727 + printk(KERN_WARNING "DVB: adapter %i frontend %i frequency %u out of range (%u..%u)\n", 728 + fe->dvb->num, fe->id, parms->frequency, freq_min, freq_max); 733 729 return -EINVAL; 734 730 } 735 731 ··· 739 735 parms->u.qpsk.symbol_rate < fe->ops.info.symbol_rate_min) || 740 736 (fe->ops.info.symbol_rate_max && 741 737 parms->u.qpsk.symbol_rate > fe->ops.info.symbol_rate_max)) { 742 - printk(KERN_WARNING "DVB: frontend %u symbol rate %u out of range (%u..%u)\n", 743 - fe->dvb->num, parms->u.qpsk.symbol_rate, 738 + printk(KERN_WARNING "DVB: adapter %i frontend %i symbol rate %u out of range (%u..%u)\n", 739 + fe->dvb->num, fe->id, parms->u.qpsk.symbol_rate, 744 740 fe->ops.info.symbol_rate_min, fe->ops.info.symbol_rate_max); 745 741 return -EINVAL; 746 742 } ··· 750 746 parms->u.qam.symbol_rate < fe->ops.info.symbol_rate_min) || 751 747 (fe->ops.info.symbol_rate_max && 752 748 parms->u.qam.symbol_rate > fe->ops.info.symbol_rate_max)) { 753 - printk(KERN_WARNING "DVB: frontend %u symbol rate %u out of range (%u..%u)\n", 754 - fe->dvb->num, parms->u.qam.symbol_rate, 749 + printk(KERN_WARNING "DVB: adapter %i frontend %i symbol rate %u out of range (%u..%u)\n", 750 + fe->dvb->num, fe->id, parms->u.qam.symbol_rate, 755 751 fe->ops.info.symbol_rate_min, fe->ops.info.symbol_rate_max); 756 752 return -EINVAL; 757 753 } ··· 903 899 int i; 904 900 905 901 if (tvp->cmd <= 0 || tvp->cmd > DTV_MAX_COMMAND) { 906 - printk("%s: tvp.cmd = 0x%08x (undefined/unknown/invalid)\n", 902 + printk(KERN_WARNING "%s: tvp.cmd = 0x%08x undefined\n", 907 903 __func__, tvp->cmd); 908 904 return; 909 905 } 910 906 911 - printk("%s() tvp.cmd = 0x%08x (%s)\n" 912 - ,__FUNCTION__ 907 + dprintk("%s() tvp.cmd = 0x%08x (%s)\n" 908 + ,__func__ 913 909 ,tvp->cmd 914 910 ,dtv_cmds[ tvp->cmd ].name); 915 911 916 912 if(dtv_cmds[ tvp->cmd ].buffer) { 917 913 918 - printk("%s() tvp.u.buffer.len = 0x%02x\n" 919 - ,__FUNCTION__ 914 + dprintk("%s() tvp.u.buffer.len = 0x%02x\n" 915 + ,__func__ 920 916 ,tvp->u.buffer.len); 921 917 922 918 for(i = 0; i < tvp->u.buffer.len; i++) 923 - printk("%s() tvp.u.buffer.data[0x%02x] = 0x%02x\n" 924 - ,__FUNCTION__ 919 + dprintk("%s() tvp.u.buffer.data[0x%02x] = 0x%02x\n" 920 + ,__func__ 925 921 ,i 926 922 ,tvp->u.buffer.data[i]); 927 923 928 924 } else 929 - printk("%s() tvp.u.data = 0x%08x\n", __FUNCTION__, tvp->u.data); 925 + dprintk("%s() tvp.u.data = 0x%08x\n", __func__, tvp->u.data); 930 926 } 931 927 932 928 int is_legacy_delivery_system(fe_delivery_system_t s) ··· 945 941 void dtv_property_cache_sync(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) 946 942 { 947 943 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 948 - 949 - printk("%s()\n", __FUNCTION__); 950 944 951 945 c->frequency = p->frequency; 952 946 c->inversion = p->inversion; ··· 1000 998 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1001 999 struct dvb_frontend_parameters *p = &fepriv->parameters; 1002 1000 1003 - printk("%s()\n", __FUNCTION__); 1004 - 1005 1001 p->frequency = c->frequency; 1006 1002 p->inversion = c->inversion; 1007 1003 1008 1004 switch (fe->ops.info.type) { 1009 1005 case FE_QPSK: 1010 - printk("%s() Preparing QPSK req\n", __FUNCTION__); 1006 + dprintk("%s() Preparing QPSK req\n", __func__); 1011 1007 p->u.qpsk.symbol_rate = c->symbol_rate; 1012 1008 p->u.qpsk.fec_inner = c->fec_inner; 1013 1009 c->delivery_system = SYS_DVBS; 1014 1010 break; 1015 1011 case FE_QAM: 1016 - printk("%s() Preparing QAM req\n", __FUNCTION__); 1012 + dprintk("%s() Preparing QAM req\n", __func__); 1017 1013 p->u.qam.symbol_rate = c->symbol_rate; 1018 1014 p->u.qam.fec_inner = c->fec_inner; 1019 1015 p->u.qam.modulation = c->modulation; 1020 1016 c->delivery_system = SYS_DVBC_ANNEX_AC; 1021 1017 break; 1022 1018 case FE_OFDM: 1023 - printk("%s() Preparing OFDM req\n", __FUNCTION__); 1019 + dprintk("%s() Preparing OFDM req\n", __func__); 1024 1020 if (c->bandwidth_hz == 6000000) 1025 1021 p->u.ofdm.bandwidth = BANDWIDTH_6_MHZ; 1026 1022 else if (c->bandwidth_hz == 7000000) ··· 1036 1036 c->delivery_system = SYS_DVBT; 1037 1037 break; 1038 1038 case FE_ATSC: 1039 - printk("%s() Preparing VSB req\n", __FUNCTION__); 1039 + dprintk("%s() Preparing VSB req\n", __func__); 1040 1040 p->u.vsb.modulation = c->modulation; 1041 1041 if ((c->modulation == VSB_8) || (c->modulation == VSB_16)) 1042 1042 c->delivery_system = SYS_ATSC; ··· 1055 1055 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1056 1056 struct dvb_frontend_parameters *p = &fepriv->parameters; 1057 1057 1058 - printk("%s()\n", __FUNCTION__); 1059 - 1060 1058 p->frequency = c->frequency; 1061 1059 p->inversion = c->inversion; 1062 1060 1063 1061 switch(c->modulation) { 1064 1062 case PSK_8: 1065 1063 case APSK_16: 1064 + case APSK_32: 1066 1065 case QPSK: 1067 1066 p->u.qpsk.symbol_rate = c->symbol_rate; 1068 1067 p->u.qpsk.fec_inner = c->fec_inner; ··· 1088 1089 { 1089 1090 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 1090 1091 1091 - printk("%s()\n", __FUNCTION__); 1092 - 1093 1092 /* For legacy delivery systems we don't need the delivery_system to 1094 1093 * be specified, but we populate the older structures from the cache 1095 1094 * so we can call set_frontend on older drivers. 1096 1095 */ 1097 1096 if(is_legacy_delivery_system(c->delivery_system)) { 1098 1097 1099 - printk("%s() legacy, modulation = %d\n", __FUNCTION__, c->modulation); 1098 + dprintk("%s() legacy, modulation = %d\n", __func__, c->modulation); 1100 1099 dtv_property_legacy_params_sync(fe); 1101 1100 1102 1101 } else { 1103 - printk("%s() adv, modulation = %d\n", __FUNCTION__, c->modulation); 1102 + dprintk("%s() adv, modulation = %d\n", __func__, c->modulation); 1104 1103 1105 1104 /* For advanced delivery systems / modulation types ... 1106 1105 * we seed the lecacy dvb_frontend_parameters structure ··· 1119 1122 struct inode *inode, struct file *file) 1120 1123 { 1121 1124 int r = 0; 1122 - 1123 - printk("%s()\n", __FUNCTION__); 1124 1125 1125 1126 dtv_property_dump(tvp); 1126 1127 ··· 1193 1198 { 1194 1199 int r = 0; 1195 1200 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1196 - printk("%s()\n", __FUNCTION__); 1197 1201 dtv_property_dump(tvp); 1198 1202 1199 1203 /* Allow the frontend to validate incoming properties */ ··· 1207 1213 /* Reset a cache of data specific to the frontend here. This does 1208 1214 * not effect hardware. 1209 1215 */ 1210 - printk("%s() Flushing property cache\n", __FUNCTION__); 1216 + dprintk("%s() Flushing property cache\n", __func__); 1211 1217 memset(&fe->dtv_property_cache, 0, sizeof(struct dtv_frontend_properties)); 1212 1218 fe->dtv_property_cache.state = tvp->cmd; 1213 1219 fe->dtv_property_cache.delivery_system = SYS_UNDEFINED; ··· 1218 1224 * ioctl. 1219 1225 */ 1220 1226 fe->dtv_property_cache.state = tvp->cmd; 1221 - printk("%s() Finalised property cache\n", __FUNCTION__); 1227 + dprintk("%s() Finalised property cache\n", __func__); 1222 1228 dtv_property_cache_submit(fe); 1223 1229 1224 1230 r |= dvb_frontend_ioctl_legacy(inode, file, FE_SET_FRONTEND, ··· 1329 1335 dprintk("%s\n", __func__); 1330 1336 1331 1337 if(cmd == FE_SET_PROPERTY) { 1332 - printk("%s() FE_SET_PROPERTY\n", __FUNCTION__); 1333 - 1334 1338 tvps = (struct dtv_properties __user *)parg; 1335 1339 1336 - printk("%s() properties.num = %d\n", __FUNCTION__, tvps->num); 1337 - printk("%s() properties.props = %p\n", __FUNCTION__, tvps->props); 1340 + dprintk("%s() properties.num = %d\n", __func__, tvps->num); 1341 + dprintk("%s() properties.props = %p\n", __func__, tvps->props); 1338 1342 1339 1343 /* Put an arbitrary limit on the number of messages that can 1340 1344 * be sent at once */ ··· 1356 1364 err |= (tvp + i)->result; 1357 1365 } 1358 1366 1359 - if(fe->dtv_property_cache.state == DTV_TUNE) { 1360 - printk("%s() Property cache is full, tuning\n", __FUNCTION__); 1361 - } 1367 + if(fe->dtv_property_cache.state == DTV_TUNE) 1368 + dprintk("%s() Property cache is full, tuning\n", __func__); 1362 1369 1363 1370 } else 1364 1371 if(cmd == FE_GET_PROPERTY) { 1365 - printk("%s() FE_GET_PROPERTY\n", __FUNCTION__); 1366 1372 1367 1373 tvps = (struct dtv_properties __user *)parg; 1368 1374 1369 - printk("%s() properties.num = %d\n", __FUNCTION__, tvps->num); 1370 - printk("%s() properties.props = %p\n", __FUNCTION__, tvps->props); 1375 + dprintk("%s() properties.num = %d\n", __func__, tvps->num); 1376 + dprintk("%s() properties.props = %p\n", __func__, tvps->props); 1371 1377 1372 1378 /* Put an arbitrary limit on the number of messages that can 1373 1379 * be sent at once */ ··· 1694 1704 struct dvb_device *dvbdev = file->private_data; 1695 1705 struct dvb_frontend *fe = dvbdev->priv; 1696 1706 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1707 + struct dvb_adapter *adapter = fe->dvb; 1697 1708 int ret; 1698 1709 1699 1710 dprintk ("%s\n", __func__); 1700 1711 1712 + if (adapter->mfe_shared) { 1713 + mutex_lock (&adapter->mfe_lock); 1714 + 1715 + if (adapter->mfe_dvbdev == NULL) 1716 + adapter->mfe_dvbdev = dvbdev; 1717 + 1718 + else if (adapter->mfe_dvbdev != dvbdev) { 1719 + struct dvb_device 1720 + *mfedev = adapter->mfe_dvbdev; 1721 + struct dvb_frontend 1722 + *mfe = mfedev->priv; 1723 + struct dvb_frontend_private 1724 + *mfepriv = mfe->frontend_priv; 1725 + int mferetry = (dvb_mfe_wait_time << 1); 1726 + 1727 + mutex_unlock (&adapter->mfe_lock); 1728 + while (mferetry-- && (mfedev->users != -1 || 1729 + mfepriv->thread != NULL)) { 1730 + if(msleep_interruptible(500)) { 1731 + if(signal_pending(current)) 1732 + return -EINTR; 1733 + } 1734 + } 1735 + 1736 + mutex_lock (&adapter->mfe_lock); 1737 + if(adapter->mfe_dvbdev != dvbdev) { 1738 + mfedev = adapter->mfe_dvbdev; 1739 + mfe = mfedev->priv; 1740 + mfepriv = mfe->frontend_priv; 1741 + if (mfedev->users != -1 || 1742 + mfepriv->thread != NULL) { 1743 + mutex_unlock (&adapter->mfe_lock); 1744 + return -EBUSY; 1745 + } 1746 + adapter->mfe_dvbdev = dvbdev; 1747 + } 1748 + } 1749 + } 1750 + 1701 1751 if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) { 1702 1752 if ((ret = fe->ops.ts_bus_ctrl(fe, 1)) < 0) 1703 - return ret; 1753 + goto err0; 1704 1754 } 1705 1755 1706 1756 if ((ret = dvb_generic_open (inode, file)) < 0) ··· 1760 1730 fepriv->events.eventr = fepriv->events.eventw = 0; 1761 1731 } 1762 1732 1733 + if (adapter->mfe_shared) 1734 + mutex_unlock (&adapter->mfe_lock); 1763 1735 return ret; 1764 1736 1765 1737 err2: ··· 1769 1737 err1: 1770 1738 if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) 1771 1739 fe->ops.ts_bus_ctrl(fe, 0); 1740 + err0: 1741 + if (adapter->mfe_shared) 1742 + mutex_unlock (&adapter->mfe_lock); 1772 1743 return ret; 1773 1744 } 1774 1745 ··· 1841 1806 fe->dvb = dvb; 1842 1807 fepriv->inversion = INVERSION_OFF; 1843 1808 1844 - printk ("DVB: registering frontend %i (%s)...\n", 1809 + printk ("DVB: registering adapter %i frontend %i (%s)...\n", 1845 1810 fe->dvb->num, 1811 + fe->id, 1846 1812 fe->ops.info.name); 1847 1813 1848 1814 dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template,
+1
drivers/media/dvb/dvb-core/dvb_frontend.h
··· 222 222 struct dtv_frontend_properties dtv_property_cache; 223 223 #define DVB_FRONTEND_COMPONENT_TUNER 0 224 224 int (*callback)(void *adapter_priv, int component, int cmd, int arg); 225 + int id; 225 226 }; 226 227 227 228 extern int dvb_register_frontend(struct dvb_adapter *dvb,
+3
drivers/media/dvb/dvb-core/dvbdev.c
··· 326 326 adap->name = name; 327 327 adap->module = module; 328 328 adap->device = device; 329 + adap->mfe_shared = 0; 330 + adap->mfe_dvbdev = NULL; 331 + mutex_init (&adap->mfe_lock); 329 332 330 333 list_add_tail (&adap->list_head, &dvb_adapter_list); 331 334
+4
drivers/media/dvb/dvb-core/dvbdev.h
··· 62 62 struct device *device; 63 63 64 64 struct module *module; 65 + 66 + int mfe_shared; /* indicates mutually exclusive frontends */ 67 + struct dvb_device *mfe_dvbdev; /* frontend device in use */ 68 + struct mutex mfe_lock; /* access lock for thread creation */ 65 69 }; 66 70 67 71
+12
drivers/media/dvb/dvb-usb/dw2102.c
··· 422 422 return 0; 423 423 } 424 424 425 + static struct stv0299_config sharp_z0194a_config = { 426 + .demod_address = 0x68, 427 + .inittab = sharp_z0194a_inittab, 428 + .mclk = 88000000UL, 429 + .invert = 1, 430 + .skip_reinit = 0, 431 + .lock_output = STV0299_LOCKOUTPUT_1, 432 + .volt13_op0_op1 = STV0299_VOLT13_OP1, 433 + .min_delay_ms = 100, 434 + .set_symbol_rate = sharp_z0194a_set_symbol_rate, 435 + }; 436 + 425 437 static struct cx24116_config dw2104_config = { 426 438 .demod_address = 0x55, 427 439 .mpg_clk_pos_pol = 0x01,
+307 -201
drivers/media/dvb/frontends/cx22702.c
··· 34 34 #include "dvb_frontend.h" 35 35 #include "cx22702.h" 36 36 37 - 38 37 struct cx22702_state { 39 38 40 - struct i2c_adapter* i2c; 39 + struct i2c_adapter *i2c; 41 40 42 41 /* configuration settings */ 43 - const struct cx22702_config* config; 42 + const struct cx22702_config *config; 44 43 45 44 struct dvb_frontend frontend; 46 45 ··· 48 49 }; 49 50 50 51 static int debug; 52 + module_param(debug, int, 0644); 53 + MODULE_PARM_DESC(debug, "Enable verbose debug messages"); 54 + 51 55 #define dprintk if (debug) printk 52 56 53 57 /* Register values to initialise the demod */ 54 - static u8 init_tab [] = { 58 + static u8 init_tab[] = { 55 59 0x00, 0x00, /* Stop aquisition */ 56 60 0x0B, 0x06, 57 61 0x09, 0x01, ··· 82 80 0xfd, 0x00, 83 81 }; 84 82 85 - static int cx22702_writereg (struct cx22702_state* state, u8 reg, u8 data) 83 + static int cx22702_writereg(struct cx22702_state *state, u8 reg, u8 data) 86 84 { 87 85 int ret; 88 - u8 buf [] = { reg, data }; 89 - struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; 86 + u8 buf[] = { reg, data }; 87 + struct i2c_msg msg = { 88 + .addr = state->config->demod_address, .flags = 0, 89 + .buf = buf, .len = 2 }; 90 90 91 91 ret = i2c_transfer(state->i2c, &msg, 1); 92 92 93 93 if (ret != 1) 94 - printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", 94 + printk(KERN_ERR 95 + "%s: error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", 95 96 __func__, reg, data, ret); 96 97 97 98 return (ret != 1) ? -1 : 0; 98 99 } 99 100 100 - static u8 cx22702_readreg (struct cx22702_state* state, u8 reg) 101 + static u8 cx22702_readreg(struct cx22702_state *state, u8 reg) 101 102 { 102 103 int ret; 103 - u8 b0 [] = { reg }; 104 - u8 b1 [] = { 0 }; 104 + u8 b0[] = { reg }; 105 + u8 b1[] = { 0 }; 105 106 106 - struct i2c_msg msg [] = { 107 - { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, 108 - { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; 107 + struct i2c_msg msg[] = { 108 + { .addr = state->config->demod_address, .flags = 0, 109 + .buf = b0, .len = 1 }, 110 + { .addr = state->config->demod_address, .flags = I2C_M_RD, 111 + .buf = b1, .len = 1 } }; 109 112 110 113 ret = i2c_transfer(state->i2c, msg, 2); 111 114 112 115 if (ret != 2) 113 - printk("%s: readreg error (ret == %i)\n", __func__, ret); 116 + printk(KERN_ERR "%s: readreg error (ret == %i)\n", 117 + __func__, ret); 114 118 115 119 return b1[0]; 116 120 } 117 121 118 - static int cx22702_set_inversion (struct cx22702_state *state, int inversion) 122 + static int cx22702_set_inversion(struct cx22702_state *state, int inversion) 119 123 { 120 124 u8 val; 121 125 122 126 switch (inversion) { 123 - 124 - case INVERSION_AUTO: 125 - return -EOPNOTSUPP; 126 - 127 - case INVERSION_ON: 128 - val = cx22702_readreg (state, 0x0C); 129 - return cx22702_writereg (state, 0x0C, val | 0x01); 130 - 131 - case INVERSION_OFF: 132 - val = cx22702_readreg (state, 0x0C); 133 - return cx22702_writereg (state, 0x0C, val & 0xfe); 134 - 135 - default: 136 - return -EINVAL; 137 - 127 + case INVERSION_AUTO: 128 + return -EOPNOTSUPP; 129 + case INVERSION_ON: 130 + val = cx22702_readreg(state, 0x0C); 131 + return cx22702_writereg(state, 0x0C, val | 0x01); 132 + case INVERSION_OFF: 133 + val = cx22702_readreg(state, 0x0C); 134 + return cx22702_writereg(state, 0x0C, val & 0xfe); 135 + default: 136 + return -EINVAL; 138 137 } 139 138 140 139 } 141 140 142 141 /* Retrieve the demod settings */ 143 - static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_parameters *p) 142 + static int cx22702_get_tps(struct cx22702_state *state, 143 + struct dvb_ofdm_parameters *p) 144 144 { 145 145 u8 val; 146 146 ··· 150 146 if (!(cx22702_readreg(state, 0x0A) & 0x20)) 151 147 return -EAGAIN; 152 148 153 - val = cx22702_readreg (state, 0x01); 154 - switch( (val&0x18)>>3) { 155 - case 0: p->constellation = QPSK; break; 156 - case 1: p->constellation = QAM_16; break; 157 - case 2: p->constellation = QAM_64; break; 149 + val = cx22702_readreg(state, 0x01); 150 + switch ((val & 0x18) >> 3) { 151 + case 0: 152 + p->constellation = QPSK; 153 + break; 154 + case 1: 155 + p->constellation = QAM_16; 156 + break; 157 + case 2: 158 + p->constellation = QAM_64; 159 + break; 158 160 } 159 - switch( val&0x07 ) { 160 - case 0: p->hierarchy_information = HIERARCHY_NONE; break; 161 - case 1: p->hierarchy_information = HIERARCHY_1; break; 162 - case 2: p->hierarchy_information = HIERARCHY_2; break; 163 - case 3: p->hierarchy_information = HIERARCHY_4; break; 164 - } 165 - 166 - 167 - val = cx22702_readreg (state, 0x02); 168 - switch( (val&0x38)>>3 ) { 169 - case 0: p->code_rate_HP = FEC_1_2; break; 170 - case 1: p->code_rate_HP = FEC_2_3; break; 171 - case 2: p->code_rate_HP = FEC_3_4; break; 172 - case 3: p->code_rate_HP = FEC_5_6; break; 173 - case 4: p->code_rate_HP = FEC_7_8; break; 174 - } 175 - switch( val&0x07 ) { 176 - case 0: p->code_rate_LP = FEC_1_2; break; 177 - case 1: p->code_rate_LP = FEC_2_3; break; 178 - case 2: p->code_rate_LP = FEC_3_4; break; 179 - case 3: p->code_rate_LP = FEC_5_6; break; 180 - case 4: p->code_rate_LP = FEC_7_8; break; 161 + switch (val & 0x07) { 162 + case 0: 163 + p->hierarchy_information = HIERARCHY_NONE; 164 + break; 165 + case 1: 166 + p->hierarchy_information = HIERARCHY_1; 167 + break; 168 + case 2: 169 + p->hierarchy_information = HIERARCHY_2; 170 + break; 171 + case 3: 172 + p->hierarchy_information = HIERARCHY_4; 173 + break; 181 174 } 182 175 183 176 184 - val = cx22702_readreg (state, 0x03); 185 - switch( (val&0x0c)>>2 ) { 186 - case 0: p->guard_interval = GUARD_INTERVAL_1_32; break; 187 - case 1: p->guard_interval = GUARD_INTERVAL_1_16; break; 188 - case 2: p->guard_interval = GUARD_INTERVAL_1_8; break; 189 - case 3: p->guard_interval = GUARD_INTERVAL_1_4; break; 177 + val = cx22702_readreg(state, 0x02); 178 + switch ((val & 0x38) >> 3) { 179 + case 0: 180 + p->code_rate_HP = FEC_1_2; 181 + break; 182 + case 1: 183 + p->code_rate_HP = FEC_2_3; 184 + break; 185 + case 2: 186 + p->code_rate_HP = FEC_3_4; 187 + break; 188 + case 3: 189 + p->code_rate_HP = FEC_5_6; 190 + break; 191 + case 4: 192 + p->code_rate_HP = FEC_7_8; 193 + break; 190 194 } 191 - switch( val&0x03 ) { 192 - case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break; 193 - case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break; 195 + switch (val & 0x07) { 196 + case 0: 197 + p->code_rate_LP = FEC_1_2; 198 + break; 199 + case 1: 200 + p->code_rate_LP = FEC_2_3; 201 + break; 202 + case 2: 203 + p->code_rate_LP = FEC_3_4; 204 + break; 205 + case 3: 206 + p->code_rate_LP = FEC_5_6; 207 + break; 208 + case 4: 209 + p->code_rate_LP = FEC_7_8; 210 + break; 211 + } 212 + 213 + val = cx22702_readreg(state, 0x03); 214 + switch ((val & 0x0c) >> 2) { 215 + case 0: 216 + p->guard_interval = GUARD_INTERVAL_1_32; 217 + break; 218 + case 1: 219 + p->guard_interval = GUARD_INTERVAL_1_16; 220 + break; 221 + case 2: 222 + p->guard_interval = GUARD_INTERVAL_1_8; 223 + break; 224 + case 3: 225 + p->guard_interval = GUARD_INTERVAL_1_4; 226 + break; 227 + } 228 + switch (val & 0x03) { 229 + case 0: 230 + p->transmission_mode = TRANSMISSION_MODE_2K; 231 + break; 232 + case 1: 233 + p->transmission_mode = TRANSMISSION_MODE_8K; 234 + break; 194 235 } 195 236 196 237 return 0; 197 238 } 198 239 199 - static int cx22702_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) 240 + static int cx22702_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) 200 241 { 201 - struct cx22702_state* state = fe->demodulator_priv; 202 - dprintk ("%s(%d)\n", __func__, enable); 242 + struct cx22702_state *state = fe->demodulator_priv; 243 + dprintk("%s(%d)\n", __func__, enable); 203 244 if (enable) 204 - return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) & 0xfe); 245 + return cx22702_writereg(state, 0x0D, 246 + cx22702_readreg(state, 0x0D) & 0xfe); 205 247 else 206 - return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) | 1); 248 + return cx22702_writereg(state, 0x0D, 249 + cx22702_readreg(state, 0x0D) | 1); 207 250 } 208 251 209 252 /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ 210 - static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 253 + static int cx22702_set_tps(struct dvb_frontend *fe, 254 + struct dvb_frontend_parameters *p) 211 255 { 212 256 u8 val; 213 - struct cx22702_state* state = fe->demodulator_priv; 257 + struct cx22702_state *state = fe->demodulator_priv; 214 258 215 259 if (fe->ops.tuner_ops.set_params) { 216 260 fe->ops.tuner_ops.set_params(fe, p); 217 - if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); 261 + if (fe->ops.i2c_gate_ctrl) 262 + fe->ops.i2c_gate_ctrl(fe, 0); 218 263 } 219 264 220 265 /* set inversion */ 221 - cx22702_set_inversion (state, p->inversion); 266 + cx22702_set_inversion(state, p->inversion); 222 267 223 268 /* set bandwidth */ 224 - switch(p->u.ofdm.bandwidth) { 269 + switch (p->u.ofdm.bandwidth) { 225 270 case BANDWIDTH_6_MHZ: 226 - cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x20 ); 271 + cx22702_writereg(state, 0x0C, 272 + (cx22702_readreg(state, 0x0C) & 0xcf) | 0x20); 227 273 break; 228 274 case BANDWIDTH_7_MHZ: 229 - cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x10 ); 275 + cx22702_writereg(state, 0x0C, 276 + (cx22702_readreg(state, 0x0C) & 0xcf) | 0x10); 230 277 break; 231 278 case BANDWIDTH_8_MHZ: 232 - cx22702_writereg(state, 0x0C, cx22702_readreg(state, 0x0C) &0xcf ); 279 + cx22702_writereg(state, 0x0C, 280 + cx22702_readreg(state, 0x0C) & 0xcf); 233 281 break; 234 282 default: 235 - dprintk ("%s: invalid bandwidth\n",__func__); 283 + dprintk("%s: invalid bandwidth\n", __func__); 236 284 return -EINVAL; 237 285 } 238 286 239 - 240 - p->u.ofdm.code_rate_LP = FEC_AUTO; //temp hack as manual not working 287 + p->u.ofdm.code_rate_LP = FEC_AUTO; /* temp hack as manual not working */ 241 288 242 289 /* use auto configuration? */ 243 - if((p->u.ofdm.hierarchy_information==HIERARCHY_AUTO) || 244 - (p->u.ofdm.constellation==QAM_AUTO) || 245 - (p->u.ofdm.code_rate_HP==FEC_AUTO) || 246 - (p->u.ofdm.code_rate_LP==FEC_AUTO) || 247 - (p->u.ofdm.guard_interval==GUARD_INTERVAL_AUTO) || 248 - (p->u.ofdm.transmission_mode==TRANSMISSION_MODE_AUTO) ) { 290 + if ((p->u.ofdm.hierarchy_information == HIERARCHY_AUTO) || 291 + (p->u.ofdm.constellation == QAM_AUTO) || 292 + (p->u.ofdm.code_rate_HP == FEC_AUTO) || 293 + (p->u.ofdm.code_rate_LP == FEC_AUTO) || 294 + (p->u.ofdm.guard_interval == GUARD_INTERVAL_AUTO) || 295 + (p->u.ofdm.transmission_mode == TRANSMISSION_MODE_AUTO)) { 249 296 250 297 /* TPS Source - use hardware driven values */ 251 298 cx22702_writereg(state, 0x06, 0x10); 252 299 cx22702_writereg(state, 0x07, 0x9); 253 300 cx22702_writereg(state, 0x08, 0xC1); 254 - cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) & 0xfc ); 255 - cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 ); 301 + cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) 302 + & 0xfc); 303 + cx22702_writereg(state, 0x0C, 304 + (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40); 256 305 cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */ 257 - dprintk("%s: Autodetecting\n",__func__); 306 + dprintk("%s: Autodetecting\n", __func__); 258 307 return 0; 259 308 } 260 309 261 310 /* manually programmed values */ 262 - val=0; 263 - switch(p->u.ofdm.constellation) { 264 - case QPSK: val = (val&0xe7); break; 265 - case QAM_16: val = (val&0xe7)|0x08; break; 266 - case QAM_64: val = (val&0xe7)|0x10; break; 267 - default: 268 - dprintk ("%s: invalid constellation\n",__func__); 269 - return -EINVAL; 311 + val = 0; 312 + switch (p->u.ofdm.constellation) { 313 + case QPSK: 314 + val = (val & 0xe7); 315 + break; 316 + case QAM_16: 317 + val = (val & 0xe7) | 0x08; 318 + break; 319 + case QAM_64: 320 + val = (val & 0xe7) | 0x10; 321 + break; 322 + default: 323 + dprintk("%s: invalid constellation\n", __func__); 324 + return -EINVAL; 270 325 } 271 - switch(p->u.ofdm.hierarchy_information) { 272 - case HIERARCHY_NONE: val = (val&0xf8); break; 273 - case HIERARCHY_1: val = (val&0xf8)|1; break; 274 - case HIERARCHY_2: val = (val&0xf8)|2; break; 275 - case HIERARCHY_4: val = (val&0xf8)|3; break; 276 - default: 277 - dprintk ("%s: invalid hierarchy\n",__func__); 278 - return -EINVAL; 326 + switch (p->u.ofdm.hierarchy_information) { 327 + case HIERARCHY_NONE: 328 + val = (val & 0xf8); 329 + break; 330 + case HIERARCHY_1: 331 + val = (val & 0xf8) | 1; 332 + break; 333 + case HIERARCHY_2: 334 + val = (val & 0xf8) | 2; 335 + break; 336 + case HIERARCHY_4: 337 + val = (val & 0xf8) | 3; 338 + break; 339 + default: 340 + dprintk("%s: invalid hierarchy\n", __func__); 341 + return -EINVAL; 279 342 } 280 - cx22702_writereg (state, 0x06, val); 343 + cx22702_writereg(state, 0x06, val); 281 344 282 - val=0; 283 - switch(p->u.ofdm.code_rate_HP) { 284 - case FEC_NONE: 285 - case FEC_1_2: val = (val&0xc7); break; 286 - case FEC_2_3: val = (val&0xc7)|0x08; break; 287 - case FEC_3_4: val = (val&0xc7)|0x10; break; 288 - case FEC_5_6: val = (val&0xc7)|0x18; break; 289 - case FEC_7_8: val = (val&0xc7)|0x20; break; 290 - default: 291 - dprintk ("%s: invalid code_rate_HP\n",__func__); 292 - return -EINVAL; 345 + val = 0; 346 + switch (p->u.ofdm.code_rate_HP) { 347 + case FEC_NONE: 348 + case FEC_1_2: 349 + val = (val & 0xc7); 350 + break; 351 + case FEC_2_3: 352 + val = (val & 0xc7) | 0x08; 353 + break; 354 + case FEC_3_4: 355 + val = (val & 0xc7) | 0x10; 356 + break; 357 + case FEC_5_6: 358 + val = (val & 0xc7) | 0x18; 359 + break; 360 + case FEC_7_8: 361 + val = (val & 0xc7) | 0x20; 362 + break; 363 + default: 364 + dprintk("%s: invalid code_rate_HP\n", __func__); 365 + return -EINVAL; 293 366 } 294 - switch(p->u.ofdm.code_rate_LP) { 295 - case FEC_NONE: 296 - case FEC_1_2: val = (val&0xf8); break; 297 - case FEC_2_3: val = (val&0xf8)|1; break; 298 - case FEC_3_4: val = (val&0xf8)|2; break; 299 - case FEC_5_6: val = (val&0xf8)|3; break; 300 - case FEC_7_8: val = (val&0xf8)|4; break; 301 - default: 302 - dprintk ("%s: invalid code_rate_LP\n",__func__); 303 - return -EINVAL; 367 + switch (p->u.ofdm.code_rate_LP) { 368 + case FEC_NONE: 369 + case FEC_1_2: 370 + val = (val & 0xf8); 371 + break; 372 + case FEC_2_3: 373 + val = (val & 0xf8) | 1; 374 + break; 375 + case FEC_3_4: 376 + val = (val & 0xf8) | 2; 377 + break; 378 + case FEC_5_6: 379 + val = (val & 0xf8) | 3; 380 + break; 381 + case FEC_7_8: 382 + val = (val & 0xf8) | 4; 383 + break; 384 + default: 385 + dprintk("%s: invalid code_rate_LP\n", __func__); 386 + return -EINVAL; 304 387 } 305 - cx22702_writereg (state, 0x07, val); 388 + cx22702_writereg(state, 0x07, val); 306 389 307 - val=0; 308 - switch(p->u.ofdm.guard_interval) { 309 - case GUARD_INTERVAL_1_32: val = (val&0xf3); break; 310 - case GUARD_INTERVAL_1_16: val = (val&0xf3)|0x04; break; 311 - case GUARD_INTERVAL_1_8: val = (val&0xf3)|0x08; break; 312 - case GUARD_INTERVAL_1_4: val = (val&0xf3)|0x0c; break; 313 - default: 314 - dprintk ("%s: invalid guard_interval\n",__func__); 315 - return -EINVAL; 390 + val = 0; 391 + switch (p->u.ofdm.guard_interval) { 392 + case GUARD_INTERVAL_1_32: 393 + val = (val & 0xf3); 394 + break; 395 + case GUARD_INTERVAL_1_16: 396 + val = (val & 0xf3) | 0x04; 397 + break; 398 + case GUARD_INTERVAL_1_8: 399 + val = (val & 0xf3) | 0x08; 400 + break; 401 + case GUARD_INTERVAL_1_4: 402 + val = (val & 0xf3) | 0x0c; 403 + break; 404 + default: 405 + dprintk("%s: invalid guard_interval\n", __func__); 406 + return -EINVAL; 316 407 } 317 - switch(p->u.ofdm.transmission_mode) { 318 - case TRANSMISSION_MODE_2K: val = (val&0xfc); break; 319 - case TRANSMISSION_MODE_8K: val = (val&0xfc)|1; break; 320 - default: 321 - dprintk ("%s: invalid transmission_mode\n",__func__); 322 - return -EINVAL; 408 + switch (p->u.ofdm.transmission_mode) { 409 + case TRANSMISSION_MODE_2K: 410 + val = (val & 0xfc); 411 + break; 412 + case TRANSMISSION_MODE_8K: 413 + val = (val & 0xfc) | 1; 414 + break; 415 + default: 416 + dprintk("%s: invalid transmission_mode\n", __func__); 417 + return -EINVAL; 323 418 } 324 419 cx22702_writereg(state, 0x08, val); 325 - cx22702_writereg(state, 0x0B, (cx22702_readreg(state, 0x0B) & 0xfc) | 0x02 ); 326 - cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 ); 420 + cx22702_writereg(state, 0x0B, 421 + (cx22702_readreg(state, 0x0B) & 0xfc) | 0x02); 422 + cx22702_writereg(state, 0x0C, 423 + (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40); 327 424 328 425 /* Begin channel aquisition */ 329 426 cx22702_writereg(state, 0x00, 0x01); ··· 434 329 435 330 /* Reset the demod hardware and reset all of the configuration registers 436 331 to a default state. */ 437 - static int cx22702_init (struct dvb_frontend* fe) 332 + static int cx22702_init(struct dvb_frontend *fe) 438 333 { 439 334 int i; 440 - struct cx22702_state* state = fe->demodulator_priv; 335 + struct cx22702_state *state = fe->demodulator_priv; 441 336 442 - cx22702_writereg (state, 0x00, 0x02); 337 + cx22702_writereg(state, 0x00, 0x02); 443 338 444 339 msleep(10); 445 340 446 - for (i=0; i<sizeof(init_tab); i+=2) 447 - cx22702_writereg (state, init_tab[i], init_tab[i+1]); 341 + for (i = 0; i < ARRAY_SIZE(init_tab); i += 2) 342 + cx22702_writereg(state, init_tab[i], init_tab[i + 1]); 448 343 449 - cx22702_writereg (state, 0xf8, (state->config->output_mode << 1) & 0x02); 344 + cx22702_writereg(state, 0xf8, (state->config->output_mode << 1) 345 + & 0x02); 450 346 451 347 cx22702_i2c_gate_ctrl(fe, 0); 452 348 453 349 return 0; 454 350 } 455 351 456 - static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status) 352 + static int cx22702_read_status(struct dvb_frontend *fe, fe_status_t *status) 457 353 { 458 - struct cx22702_state* state = fe->demodulator_priv; 354 + struct cx22702_state *state = fe->demodulator_priv; 459 355 u8 reg0A; 460 356 u8 reg23; 461 357 462 358 *status = 0; 463 359 464 - reg0A = cx22702_readreg (state, 0x0A); 465 - reg23 = cx22702_readreg (state, 0x23); 360 + reg0A = cx22702_readreg(state, 0x0A); 361 + reg23 = cx22702_readreg(state, 0x23); 466 362 467 - dprintk ("%s: status demod=0x%02x agc=0x%02x\n" 468 - ,__func__,reg0A,reg23); 363 + dprintk("%s: status demod=0x%02x agc=0x%02x\n" 364 + , __func__, reg0A, reg23); 469 365 470 - if(reg0A & 0x10) { 366 + if (reg0A & 0x10) { 471 367 *status |= FE_HAS_LOCK; 472 368 *status |= FE_HAS_VITERBI; 473 369 *status |= FE_HAS_SYNC; 474 370 } 475 371 476 - if(reg0A & 0x20) 372 + if (reg0A & 0x20) 477 373 *status |= FE_HAS_CARRIER; 478 374 479 - if(reg23 < 0xf0) 375 + if (reg23 < 0xf0) 480 376 *status |= FE_HAS_SIGNAL; 481 377 482 378 return 0; 483 379 } 484 380 485 - static int cx22702_read_ber(struct dvb_frontend* fe, u32* ber) 381 + static int cx22702_read_ber(struct dvb_frontend *fe, u32 *ber) 486 382 { 487 - struct cx22702_state* state = fe->demodulator_priv; 383 + struct cx22702_state *state = fe->demodulator_priv; 488 384 489 - if(cx22702_readreg (state, 0xE4) & 0x02) { 385 + if (cx22702_readreg(state, 0xE4) & 0x02) { 490 386 /* Realtime statistics */ 491 - *ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 492 - | (cx22702_readreg (state, 0xDF)&0x7F); 387 + *ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7 388 + | (cx22702_readreg(state, 0xDF) & 0x7F); 493 389 } else { 494 390 /* Averagtine statistics */ 495 - *ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 496 - | cx22702_readreg (state, 0xDF); 391 + *ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7 392 + | cx22702_readreg(state, 0xDF); 497 393 } 498 394 499 395 return 0; 500 396 } 501 397 502 - static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) 398 + static int cx22702_read_signal_strength(struct dvb_frontend *fe, 399 + u16 *signal_strength) 503 400 { 504 - struct cx22702_state* state = fe->demodulator_priv; 401 + struct cx22702_state *state = fe->demodulator_priv; 505 402 506 403 u16 rs_ber = 0; 507 - rs_ber = cx22702_readreg (state, 0x23); 404 + rs_ber = cx22702_readreg(state, 0x23); 508 405 *signal_strength = (rs_ber << 8) | rs_ber; 509 406 510 407 return 0; 511 408 } 512 409 513 - static int cx22702_read_snr(struct dvb_frontend* fe, u16* snr) 410 + static int cx22702_read_snr(struct dvb_frontend *fe, u16 *snr) 514 411 { 515 - struct cx22702_state* state = fe->demodulator_priv; 412 + struct cx22702_state *state = fe->demodulator_priv; 516 413 517 - u16 rs_ber=0; 518 - if(cx22702_readreg (state, 0xE4) & 0x02) { 414 + u16 rs_ber = 0; 415 + if (cx22702_readreg(state, 0xE4) & 0x02) { 519 416 /* Realtime statistics */ 520 - rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 521 - | (cx22702_readreg (state, 0xDF)& 0x7F); 417 + rs_ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7 418 + | (cx22702_readreg(state, 0xDF) & 0x7F); 522 419 } else { 523 420 /* Averagine statistics */ 524 - rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 8 525 - | cx22702_readreg (state, 0xDF); 421 + rs_ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 8 422 + | cx22702_readreg(state, 0xDF); 526 423 } 527 424 *snr = ~rs_ber; 528 425 529 426 return 0; 530 427 } 531 428 532 - static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 429 + static int cx22702_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) 533 430 { 534 - struct cx22702_state* state = fe->demodulator_priv; 431 + struct cx22702_state *state = fe->demodulator_priv; 535 432 536 433 u8 _ucblocks; 537 434 538 435 /* RS Uncorrectable Packet Count then reset */ 539 - _ucblocks = cx22702_readreg (state, 0xE3); 436 + _ucblocks = cx22702_readreg(state, 0xE3); 540 437 if (state->prevUCBlocks < _ucblocks) 541 438 *ucblocks = (_ucblocks - state->prevUCBlocks); 542 439 else ··· 548 441 return 0; 549 442 } 550 443 551 - static int cx22702_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 444 + static int cx22702_get_frontend(struct dvb_frontend *fe, 445 + struct dvb_frontend_parameters *p) 552 446 { 553 - struct cx22702_state* state = fe->demodulator_priv; 447 + struct cx22702_state *state = fe->demodulator_priv; 554 448 555 - u8 reg0C = cx22702_readreg (state, 0x0C); 449 + u8 reg0C = cx22702_readreg(state, 0x0C); 556 450 557 451 p->inversion = reg0C & 0x1 ? INVERSION_ON : INVERSION_OFF; 558 - return cx22702_get_tps (state, &p->u.ofdm); 452 + return cx22702_get_tps(state, &p->u.ofdm); 559 453 } 560 454 561 - static int cx22702_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) 455 + static int cx22702_get_tune_settings(struct dvb_frontend *fe, 456 + struct dvb_frontend_tune_settings *tune) 562 457 { 563 458 tune->min_delay_ms = 1000; 564 459 return 0; 565 460 } 566 461 567 - static void cx22702_release(struct dvb_frontend* fe) 462 + static void cx22702_release(struct dvb_frontend *fe) 568 463 { 569 - struct cx22702_state* state = fe->demodulator_priv; 464 + struct cx22702_state *state = fe->demodulator_priv; 570 465 kfree(state); 571 466 } 572 467 573 468 static struct dvb_frontend_ops cx22702_ops; 574 469 575 - struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, 576 - struct i2c_adapter* i2c) 470 + struct dvb_frontend *cx22702_attach(const struct cx22702_config *config, 471 + struct i2c_adapter *i2c) 577 472 { 578 - struct cx22702_state* state = NULL; 473 + struct cx22702_state *state = NULL; 579 474 580 475 /* allocate memory for the internal state */ 581 476 state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL); ··· 594 485 goto error; 595 486 596 487 /* create dvb_frontend */ 597 - memcpy(&state->frontend.ops, &cx22702_ops, sizeof(struct dvb_frontend_ops)); 488 + memcpy(&state->frontend.ops, &cx22702_ops, 489 + sizeof(struct dvb_frontend_ops)); 598 490 state->frontend.demodulator_priv = state; 599 491 return &state->frontend; 600 492 ··· 603 493 kfree(state); 604 494 return NULL; 605 495 } 496 + EXPORT_SYMBOL(cx22702_attach); 606 497 607 498 static struct dvb_frontend_ops cx22702_ops = { 608 499 ··· 636 525 .read_ucblocks = cx22702_read_ucblocks, 637 526 }; 638 527 639 - module_param(debug, int, 0644); 640 - MODULE_PARM_DESC(debug, "Enable verbose debug messages"); 641 - 642 528 MODULE_DESCRIPTION("Conexant CX22702 DVB-T Demodulator driver"); 643 529 MODULE_AUTHOR("Steven Toth"); 644 530 MODULE_LICENSE("GPL"); 645 - 646 - EXPORT_SYMBOL(cx22702_attach);
+11 -9
drivers/media/dvb/frontends/cx22702.h
··· 30 30 31 31 #include <linux/dvb/frontend.h> 32 32 33 - struct cx22702_config 34 - { 33 + struct cx22702_config { 35 34 /* the demodulator's i2c address */ 36 35 u8 demod_address; 37 36 ··· 40 41 u8 output_mode; 41 42 }; 42 43 43 - #if defined(CONFIG_DVB_CX22702) || (defined(CONFIG_DVB_CX22702_MODULE) && defined(MODULE)) 44 - extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, 45 - struct i2c_adapter* i2c); 44 + #if defined(CONFIG_DVB_CX22702) || (defined(CONFIG_DVB_CX22702_MODULE) \ 45 + && defined(MODULE)) 46 + extern struct dvb_frontend *cx22702_attach( 47 + const struct cx22702_config *config, 48 + struct i2c_adapter *i2c); 46 49 #else 47 - static inline struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, 48 - struct i2c_adapter* i2c) 50 + static inline struct dvb_frontend *cx22702_attach( 51 + const struct cx22702_config *config, 52 + struct i2c_adapter *i2c) 49 53 { 50 54 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 51 55 return NULL; 52 56 } 53 - #endif // CONFIG_DVB_CX22702 57 + #endif 54 58 55 - #endif // CX22702_H 59 + #endif
+320 -273
drivers/media/dvb/frontends/cx24116.c
··· 41 41 #include "dvb_frontend.h" 42 42 #include "cx24116.h" 43 43 44 - static int debug = 0; 44 + static int debug; 45 + module_param(debug, int, 0644); 46 + MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); 47 + 45 48 #define dprintk(args...) \ 46 49 do { \ 47 - if (debug) printk ("cx24116: " args); \ 50 + if (debug) \ 51 + printk(KERN_INFO "cx24116: " args); \ 48 52 } while (0) 49 53 50 54 #define CX24116_DEFAULT_FIRMWARE "dvb-fe-cx24116.fw" ··· 72 68 #define CX24116_REG_UCB8 (0xca) 73 69 #define CX24116_REG_CLKDIV (0xf3) 74 70 #define CX24116_REG_RATEDIV (0xf9) 75 - #define CX24116_REG_FECSTATUS (0x9c) /* configured fec (not tuned) or actual FEC (tuned) 1=1/2 2=2/3 etc */ 71 + 72 + /* configured fec (not tuned) or actual FEC (tuned) 1=1/2 2=2/3 etc */ 73 + #define CX24116_REG_FECSTATUS (0x9c) 76 74 77 75 /* FECSTATUS bits */ 78 - #define CX24116_FEC_FECMASK (0x1f) /* mask to determine configured fec (not tuned) or actual fec (tuned) */ 79 - #define CX24116_FEC_DVBS (0x20) /* Select DVB-S demodulator, else DVB-S2 */ 76 + /* mask to determine configured fec (not tuned) or actual fec (tuned) */ 77 + #define CX24116_FEC_FECMASK (0x1f) 78 + 79 + /* Select DVB-S demodulator, else DVB-S2 */ 80 + #define CX24116_FEC_DVBS (0x20) 80 81 #define CX24116_FEC_UNKNOWN (0x40) /* Unknown/unused */ 81 - #define CX24116_FEC_PILOT (0x80) /* Pilot mode requested when tuning else always reset when tuned */ 82 + 83 + /* Pilot mode requested when tuning else always reset when tuned */ 84 + #define CX24116_FEC_PILOT (0x80) 82 85 83 86 /* arg buffer size */ 84 87 #define CX24116_ARGLEN (0x1e) ··· 127 116 128 117 /* DiSEqC tone burst */ 129 118 static int toneburst = 1; 119 + module_param(toneburst, int, 0644); 120 + MODULE_PARM_DESC(toneburst, "DiSEqC toneburst 0=OFF, 1=TONE CACHE, "\ 121 + "2=MESSAGE CACHE (default:1)"); 130 122 131 123 /* SNR measurements */ 132 - static int esno_snr = 0; 124 + static int esno_snr; 125 + module_param(esno_snr, int, 0644); 126 + MODULE_PARM_DESC(debug, "SNR return units, 0=PERCENTAGE 0-100, "\ 127 + "1=ESNO(db * 10) (default:0)"); 133 128 134 - enum cmds 135 - { 129 + enum cmds { 136 130 CMD_SET_VCO = 0x10, 137 131 CMD_TUNEREQUEST = 0x11, 138 132 CMD_MPEGCONFIG = 0x13, ··· 154 138 }; 155 139 156 140 /* The Demod/Tuner can't easily provide these, we cache them */ 157 - struct cx24116_tuning 158 - { 141 + struct cx24116_tuning { 159 142 u32 frequency; 160 143 u32 symbol_rate; 161 144 fe_spectral_inversion_t inversion; ··· 173 158 }; 174 159 175 160 /* Basic commands that are sent to the firmware */ 176 - struct cx24116_cmd 177 - { 161 + struct cx24116_cmd { 178 162 u8 len; 179 163 u8 args[CX24116_ARGLEN]; 180 164 }; 181 165 182 - struct cx24116_state 183 - { 184 - struct i2c_adapter* i2c; 185 - const struct cx24116_config* config; 166 + struct cx24116_state { 167 + struct i2c_adapter *i2c; 168 + const struct cx24116_config *config; 186 169 187 170 struct dvb_frontend frontend; 188 171 ··· 192 179 struct cx24116_cmd dsec_cmd; 193 180 }; 194 181 195 - static int cx24116_writereg(struct cx24116_state* state, int reg, int data) 182 + static int cx24116_writereg(struct cx24116_state *state, int reg, int data) 196 183 { 197 184 u8 buf[] = { reg, data }; 198 185 struct i2c_msg msg = { .addr = state->config->demod_address, 199 186 .flags = 0, .buf = buf, .len = 2 }; 200 187 int err; 201 188 202 - if (debug>1) 189 + if (debug > 1) 203 190 printk("cx24116: %s: write reg 0x%02x, value 0x%02x\n", 204 - __func__,reg, data); 191 + __func__, reg, data); 205 192 206 - if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 207 - printk("%s: writereg error(err == %i, reg == 0x%02x," 193 + err = i2c_transfer(state->i2c, &msg, 1); 194 + if (err != 1) { 195 + printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x," 208 196 " value == 0x%02x)\n", __func__, err, reg, data); 209 197 return -EREMOTEIO; 210 198 } ··· 214 200 } 215 201 216 202 /* Bulk byte writes to a single I2C address, for 32k firmware load */ 217 - static int cx24116_writeregN(struct cx24116_state* state, int reg, u8 *data, u16 len) 203 + static int cx24116_writeregN(struct cx24116_state *state, int reg, 204 + const u8 *data, u16 len) 218 205 { 219 206 int ret = -EREMOTEIO; 220 207 struct i2c_msg msg; ··· 236 221 msg.buf = buf; 237 222 msg.len = len + 1; 238 223 239 - if (debug>1) 240 - printk("cx24116: %s: write regN 0x%02x, len = %d\n", 241 - __func__,reg, len); 224 + if (debug > 1) 225 + printk(KERN_INFO "cx24116: %s: write regN 0x%02x, len = %d\n", 226 + __func__, reg, len); 242 227 243 - if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1) { 244 - printk("%s: writereg error(err == %i, reg == 0x%02x\n", 228 + ret = i2c_transfer(state->i2c, &msg, 1); 229 + if (ret != 1) { 230 + printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x\n", 245 231 __func__, ret, reg); 246 232 ret = -EREMOTEIO; 247 233 } ··· 253 237 return ret; 254 238 } 255 239 256 - static int cx24116_readreg(struct cx24116_state* state, u8 reg) 240 + static int cx24116_readreg(struct cx24116_state *state, u8 reg) 257 241 { 258 242 int ret; 259 243 u8 b0[] = { reg }; 260 244 u8 b1[] = { 0 }; 261 245 struct i2c_msg msg[] = { 262 - { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, 263 - { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } 246 + { .addr = state->config->demod_address, .flags = 0, 247 + .buf = b0, .len = 1 }, 248 + { .addr = state->config->demod_address, .flags = I2C_M_RD, 249 + .buf = b1, .len = 1 } 264 250 }; 265 251 266 252 ret = i2c_transfer(state->i2c, msg, 2); 267 253 268 254 if (ret != 2) { 269 - printk("%s: reg=0x%x (error=%d)\n", __func__, reg, ret); 255 + printk(KERN_ERR "%s: reg=0x%x (error=%d)\n", 256 + __func__, reg, ret); 270 257 return ret; 271 258 } 272 259 273 - if (debug>1) 274 - printk("cx24116: read reg 0x%02x, value 0x%02x\n",reg, b1[0]); 260 + if (debug > 1) 261 + printk(KERN_INFO "cx24116: read reg 0x%02x, value 0x%02x\n", 262 + reg, b1[0]); 275 263 276 264 return b1[0]; 277 265 } 278 266 279 - static int cx24116_set_inversion(struct cx24116_state* state, fe_spectral_inversion_t inversion) 267 + static int cx24116_set_inversion(struct cx24116_state *state, 268 + fe_spectral_inversion_t inversion) 280 269 { 281 270 dprintk("%s(%d)\n", __func__, inversion); 282 271 ··· 329 308 * Eg.(2/3) szap "Zone Horror" 330 309 * 331 310 * mask/val = 0x04, 0x20 332 - * status 1f | signal c3c0 | snr a333 | ber 00000098 | unc 00000000 | FE_HAS_LOCK 311 + * status 1f | signal c3c0 | snr a333 | ber 00000098 | unc 0 | FE_HAS_LOCK 333 312 * 334 313 * mask/val = 0x04, 0x30 335 - * status 1f | signal c3c0 | snr a333 | ber 00000000 | unc 00000000 | FE_HAS_LOCK 314 + * status 1f | signal c3c0 | snr a333 | ber 00000000 | unc 0 | FE_HAS_LOCK 336 315 * 337 316 * After tuning FECSTATUS contains actual FEC 338 317 * in use numbered 1 through to 8 for 1/2 .. 2/3 etc ··· 410 389 */ 411 390 }; 412 391 413 - static int cx24116_lookup_fecmod(struct cx24116_state* state, 392 + static int cx24116_lookup_fecmod(struct cx24116_state *state, 414 393 fe_modulation_t m, fe_code_rate_t f) 415 394 { 416 395 int i, ret = -EOPNOTSUPP; 417 396 418 397 dprintk("%s(0x%02x,0x%02x)\n", __func__, m, f); 419 398 420 - for(i=0 ; i < sizeof(CX24116_MODFEC_MODES) / sizeof(struct cx24116_modfec) ; i++) 421 - { 422 - if( (m == CX24116_MODFEC_MODES[i].modulation) && 423 - (f == CX24116_MODFEC_MODES[i].fec) ) 424 - { 399 + for (i = 0; i < ARRAY_SIZE(CX24116_MODFEC_MODES); i++) { 400 + if ((m == CX24116_MODFEC_MODES[i].modulation) && 401 + (f == CX24116_MODFEC_MODES[i].fec)) { 425 402 ret = i; 426 403 break; 427 404 } ··· 428 409 return ret; 429 410 } 430 411 431 - static int cx24116_set_fec(struct cx24116_state* state, fe_modulation_t mod, fe_code_rate_t fec) 412 + static int cx24116_set_fec(struct cx24116_state *state, 413 + fe_modulation_t mod, fe_code_rate_t fec) 432 414 { 433 415 int ret = 0; 434 416 ··· 437 417 438 418 ret = cx24116_lookup_fecmod(state, mod, fec); 439 419 440 - if(ret < 0) 420 + if (ret < 0) 441 421 return ret; 442 422 443 423 state->dnxt.fec = fec; ··· 449 429 return 0; 450 430 } 451 431 452 - static int cx24116_set_symbolrate(struct cx24116_state* state, u32 rate) 432 + static int cx24116_set_symbolrate(struct cx24116_state *state, u32 rate) 453 433 { 454 434 dprintk("%s(%d)\n", __func__, rate); 455 435 ··· 466 446 return 0; 467 447 } 468 448 469 - static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware *fw); 449 + static int cx24116_load_firmware(struct dvb_frontend *fe, 450 + const struct firmware *fw); 470 451 471 - static int cx24116_firmware_ondemand(struct dvb_frontend* fe) 452 + static int cx24116_firmware_ondemand(struct dvb_frontend *fe) 472 453 { 473 454 struct cx24116_state *state = fe->demodulator_priv; 474 455 const struct firmware *fw; 475 456 int ret = 0; 476 457 477 - dprintk("%s()\n",__func__); 458 + dprintk("%s()\n", __func__); 478 459 479 - if (cx24116_readreg(state, 0x20) > 0) 480 - { 460 + if (cx24116_readreg(state, 0x20) > 0) { 481 461 482 462 if (state->skip_fw_load) 483 463 return 0; 484 464 485 465 /* Load firmware */ 486 - /* request the firmware, this will block until someone uploads it */ 487 - printk("%s: Waiting for firmware upload (%s)...\n", __func__, CX24116_DEFAULT_FIRMWARE); 488 - ret = request_firmware(&fw, CX24116_DEFAULT_FIRMWARE, &state->i2c->dev); 489 - printk("%s: Waiting for firmware upload(2)...\n", __func__); 466 + /* request the firmware, this will block until loaded */ 467 + printk(KERN_INFO "%s: Waiting for firmware upload (%s)...\n", 468 + __func__, CX24116_DEFAULT_FIRMWARE); 469 + ret = request_firmware(&fw, CX24116_DEFAULT_FIRMWARE, 470 + &state->i2c->dev); 471 + printk(KERN_INFO "%s: Waiting for firmware upload(2)...\n", 472 + __func__); 490 473 if (ret) { 491 - printk("%s: No firmware uploaded (timeout or file not found?)\n", __func__); 474 + printk(KERN_ERR "%s: No firmware uploaded " 475 + "(timeout or file not found?)\n", __func__); 492 476 return ret; 493 477 } 494 478 495 - /* Make sure we don't recurse back through here during loading */ 479 + /* Make sure we don't recurse back through here 480 + * during loading */ 496 481 state->skip_fw_load = 1; 497 482 498 483 ret = cx24116_load_firmware(fe, fw); 499 484 if (ret) 500 - printk("%s: Writing firmware to device failed\n", __func__); 485 + printk(KERN_ERR "%s: Writing firmware to device failed\n", 486 + __func__); 501 487 502 488 release_firmware(fw); 503 489 504 - printk("%s: Firmware upload %s\n", __func__, ret == 0 ? "complete" : "failed"); 490 + printk(KERN_INFO "%s: Firmware upload %s\n", __func__, 491 + ret == 0 ? "complete" : "failed"); 505 492 506 493 /* Ensure firmware is always loaded if required */ 507 494 state->skip_fw_load = 0; ··· 517 490 return ret; 518 491 } 519 492 520 - /* Take a basic firmware command structure, format it and forward it for processing */ 521 - static int cx24116_cmd_execute(struct dvb_frontend* fe, struct cx24116_cmd *cmd) 493 + /* Take a basic firmware command structure, format it 494 + * and forward it for processing 495 + */ 496 + static int cx24116_cmd_execute(struct dvb_frontend *fe, struct cx24116_cmd *cmd) 522 497 { 523 498 struct cx24116_state *state = fe->demodulator_priv; 524 499 int i, ret; ··· 528 499 dprintk("%s()\n", __func__); 529 500 530 501 /* Load the firmware if required */ 531 - if ( (ret = cx24116_firmware_ondemand(fe)) != 0) 532 - { 533 - printk("%s(): Unable initialise the firmware\n", __func__); 502 + ret = cx24116_firmware_ondemand(fe); 503 + if (ret != 0) { 504 + printk(KERN_ERR "%s(): Unable initialise the firmware\n", 505 + __func__); 534 506 return ret; 535 507 } 536 508 537 509 /* Write the command */ 538 - for(i = 0; i < cmd->len ; i++) 539 - { 510 + for (i = 0; i < cmd->len ; i++) { 540 511 dprintk("%s: 0x%02x == 0x%02x\n", __func__, i, cmd->args[i]); 541 512 cx24116_writereg(state, i, cmd->args[i]); 542 513 } 543 514 544 515 /* Start execution and wait for cmd to terminate */ 545 516 cx24116_writereg(state, CX24116_REG_EXECUTE, 0x01); 546 - while( cx24116_readreg(state, CX24116_REG_EXECUTE) ) 547 - { 517 + while (cx24116_readreg(state, CX24116_REG_EXECUTE)) { 548 518 msleep(10); 549 - if(i++ > 64) 550 - { 551 - /* Avoid looping forever if the firmware does no respond */ 552 - printk("%s() Firmware not responding\n", __func__); 519 + if (i++ > 64) { 520 + /* Avoid looping forever if the firmware does 521 + not respond */ 522 + printk(KERN_WARNING "%s() Firmware not responding\n", 523 + __func__); 553 524 return -EREMOTEIO; 554 525 } 555 526 } 556 527 return 0; 557 528 } 558 529 559 - static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware *fw) 530 + static int cx24116_load_firmware(struct dvb_frontend *fe, 531 + const struct firmware *fw) 560 532 { 561 - struct cx24116_state* state = fe->demodulator_priv; 533 + struct cx24116_state *state = fe->demodulator_priv; 562 534 struct cx24116_cmd cmd; 563 535 int i, ret; 564 536 unsigned char vers[4]; 565 537 566 538 dprintk("%s\n", __func__); 567 - dprintk("Firmware is %zu bytes (%02x %02x .. %02x %02x)\n" 568 - ,fw->size 569 - ,fw->data[0] 570 - ,fw->data[1] 571 - ,fw->data[ fw->size-2 ] 572 - ,fw->data[ fw->size-1 ] 573 - ); 539 + dprintk("Firmware is %zu bytes (%02x %02x .. %02x %02x)\n", 540 + fw->size, 541 + fw->data[0], 542 + fw->data[1], 543 + fw->data[fw->size-2], 544 + fw->data[fw->size-1]); 574 545 575 546 /* Toggle 88x SRST pin to reset demod */ 576 547 if (state->config->reset_device) ··· 616 587 cmd.args[0x07] = 0x9d; 617 588 cmd.args[0x08] = 0xfc; 618 589 cmd.args[0x09] = 0x06; 619 - cmd.len= 0x0a; 590 + cmd.len = 0x0a; 620 591 ret = cx24116_cmd_execute(fe, &cmd); 621 592 if (ret != 0) 622 593 return ret; ··· 627 598 cmd.args[0x00] = CMD_TUNERINIT; 628 599 cmd.args[0x01] = 0x00; 629 600 cmd.args[0x02] = 0x00; 630 - cmd.len= 0x03; 601 + cmd.len = 0x03; 631 602 ret = cx24116_cmd_execute(fe, &cmd); 632 603 if (ret != 0) 633 604 return ret; ··· 644 615 else 645 616 cmd.args[0x04] = 0x02; 646 617 cmd.args[0x05] = 0x00; 647 - cmd.len= 0x06; 618 + cmd.len = 0x06; 648 619 ret = cx24116_cmd_execute(fe, &cmd); 649 620 if (ret != 0) 650 621 return ret; 651 622 652 623 /* Firmware CMD 35: Get firmware version */ 653 624 cmd.args[0x00] = CMD_UPDFWVERS; 654 - cmd.len= 0x02; 655 - for(i=0; i<4; i++) { 625 + cmd.len = 0x02; 626 + for (i = 0; i < 4; i++) { 656 627 cmd.args[0x01] = i; 657 628 ret = cx24116_cmd_execute(fe, &cmd); 658 629 if (ret != 0) 659 630 return ret; 660 - vers[i]= cx24116_readreg(state, CX24116_REG_MAILBOX); 631 + vers[i] = cx24116_readreg(state, CX24116_REG_MAILBOX); 661 632 } 662 - printk("%s: FW version %i.%i.%i.%i\n", __func__, 633 + printk(KERN_INFO "%s: FW version %i.%i.%i.%i\n", __func__, 663 634 vers[0], vers[1], vers[2], vers[3]); 664 635 665 636 return 0; 666 637 } 667 638 668 - static int cx24116_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 639 + static int cx24116_set_voltage(struct dvb_frontend *fe, 640 + fe_sec_voltage_t voltage) 669 641 { 670 642 /* The isl6421 module will override this function in the fops. */ 671 - dprintk("%s() This should never appear if the isl6421 module is loaded correctly\n",__func__); 643 + dprintk("%s() This should never appear if the isl6421 module " 644 + "is loaded correctly\n", __func__); 672 645 673 646 return -EOPNOTSUPP; 674 647 } 675 648 676 - static int cx24116_read_status(struct dvb_frontend* fe, fe_status_t* status) 649 + static int cx24116_read_status(struct dvb_frontend *fe, fe_status_t *status) 677 650 { 678 651 struct cx24116_state *state = fe->demodulator_priv; 679 652 ··· 697 666 return 0; 698 667 } 699 668 700 - static int cx24116_read_ber(struct dvb_frontend* fe, u32* ber) 669 + static int cx24116_read_ber(struct dvb_frontend *fe, u32 *ber) 701 670 { 702 671 struct cx24116_state *state = fe->demodulator_priv; 703 672 704 673 dprintk("%s()\n", __func__); 705 674 706 - *ber = ( cx24116_readreg(state, CX24116_REG_BER24) << 24 ) | 707 - ( cx24116_readreg(state, CX24116_REG_BER16) << 16 ) | 708 - ( cx24116_readreg(state, CX24116_REG_BER8 ) << 8 ) | 709 - cx24116_readreg(state, CX24116_REG_BER0 ); 675 + *ber = (cx24116_readreg(state, CX24116_REG_BER24) << 24) | 676 + (cx24116_readreg(state, CX24116_REG_BER16) << 16) | 677 + (cx24116_readreg(state, CX24116_REG_BER8) << 8) | 678 + cx24116_readreg(state, CX24116_REG_BER0); 710 679 711 680 return 0; 712 681 } 713 682 714 683 /* TODO Determine function and scale appropriately */ 715 - static int cx24116_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) 684 + static int cx24116_read_signal_strength(struct dvb_frontend *fe, 685 + u16 *signal_strength) 716 686 { 717 687 struct cx24116_state *state = fe->demodulator_priv; 718 688 struct cx24116_cmd cmd; ··· 724 692 725 693 /* Firmware CMD 19: Get AGC */ 726 694 cmd.args[0x00] = CMD_GETAGC; 727 - cmd.len= 0x01; 695 + cmd.len = 0x01; 728 696 ret = cx24116_cmd_execute(fe, &cmd); 729 697 if (ret != 0) 730 698 return ret; 731 699 732 - sig_reading = ( cx24116_readreg(state, CX24116_REG_SSTATUS) & CX24116_SIGNAL_MASK ) | 733 - ( cx24116_readreg(state, CX24116_REG_SIGNAL) << 6 ); 734 - *signal_strength= 0 - sig_reading; 700 + sig_reading = 701 + (cx24116_readreg(state, 702 + CX24116_REG_SSTATUS) & CX24116_SIGNAL_MASK) | 703 + (cx24116_readreg(state, CX24116_REG_SIGNAL) << 6); 704 + *signal_strength = 0 - sig_reading; 735 705 736 - dprintk("%s: raw / cooked = 0x%04x / 0x%04x\n", __func__, sig_reading, *signal_strength); 706 + dprintk("%s: raw / cooked = 0x%04x / 0x%04x\n", 707 + __func__, sig_reading, *signal_strength); 737 708 738 709 return 0; 739 710 } 740 711 741 712 /* SNR (0..100)% = (sig & 0xf0) * 10 + (sig & 0x0f) * 10 / 16 */ 742 - static int cx24116_read_snr_pct(struct dvb_frontend* fe, u16* snr) 713 + static int cx24116_read_snr_pct(struct dvb_frontend *fe, u16 *snr) 743 714 { 744 715 struct cx24116_state *state = fe->demodulator_priv; 745 716 u8 snr_reading; 746 717 static const u32 snr_tab[] = { /* 10 x Table (rounded up) */ 747 - 0x00000,0x0199A,0x03333,0x04ccD,0x06667, 748 - 0x08000,0x0999A,0x0b333,0x0cccD,0x0e667, 749 - 0x10000,0x1199A,0x13333,0x14ccD,0x16667,0x18000 }; 718 + 0x00000, 0x0199A, 0x03333, 0x04ccD, 0x06667, 719 + 0x08000, 0x0999A, 0x0b333, 0x0cccD, 0x0e667, 720 + 0x10000, 0x1199A, 0x13333, 0x14ccD, 0x16667, 721 + 0x18000 }; 750 722 751 723 dprintk("%s()\n", __func__); 752 724 753 725 snr_reading = cx24116_readreg(state, CX24116_REG_QUALITY0); 754 726 755 - if(snr_reading >= 0xa0 /* 100% */) 727 + if (snr_reading >= 0xa0 /* 100% */) 756 728 *snr = 0xffff; 757 729 else 758 - *snr = snr_tab [ ( snr_reading & 0xf0 ) >> 4 ] + 759 - ( snr_tab [ ( snr_reading & 0x0f ) ] >> 4 ); 730 + *snr = snr_tab[(snr_reading & 0xf0) >> 4] + 731 + (snr_tab[(snr_reading & 0x0f)] >> 4); 760 732 761 733 dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__, 762 734 snr_reading, *snr); ··· 772 736 * ESNO, from 0->30db (values 0->300). We provide this value by 773 737 * default. 774 738 */ 775 - static int cx24116_read_snr_esno(struct dvb_frontend* fe, u16* snr) 739 + static int cx24116_read_snr_esno(struct dvb_frontend *fe, u16 *snr) 776 740 { 777 741 struct cx24116_state *state = fe->demodulator_priv; 778 742 ··· 786 750 return 0; 787 751 } 788 752 789 - static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr) 753 + static int cx24116_read_snr(struct dvb_frontend *fe, u16 *snr) 790 754 { 791 755 if (esno_snr == 1) 792 756 return cx24116_read_snr_esno(fe, snr); ··· 794 758 return cx24116_read_snr_pct(fe, snr); 795 759 } 796 760 797 - static int cx24116_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 761 + static int cx24116_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) 798 762 { 799 763 struct cx24116_state *state = fe->demodulator_priv; 800 764 801 765 dprintk("%s()\n", __func__); 802 766 803 - *ucblocks = ( cx24116_readreg(state, CX24116_REG_UCB8) << 8 ) | 767 + *ucblocks = (cx24116_readreg(state, CX24116_REG_UCB8) << 8) | 804 768 cx24116_readreg(state, CX24116_REG_UCB0); 805 769 806 770 return 0; 807 771 } 808 772 809 773 /* Overwrite the current tuning params, we are about to tune */ 810 - static void cx24116_clone_params(struct dvb_frontend* fe) 774 + static void cx24116_clone_params(struct dvb_frontend *fe) 811 775 { 812 776 struct cx24116_state *state = fe->demodulator_priv; 813 777 memcpy(&state->dcur, &state->dnxt, sizeof(state->dcur)); 814 778 } 815 779 816 780 /* Wait for LNB */ 817 - static int cx24116_wait_for_lnb(struct dvb_frontend* fe) 781 + static int cx24116_wait_for_lnb(struct dvb_frontend *fe) 818 782 { 819 783 struct cx24116_state *state = fe->demodulator_priv; 820 784 int i; ··· 823 787 cx24116_readreg(state, CX24116_REG_QSTATUS)); 824 788 825 789 /* Wait for up to 300 ms */ 826 - for(i = 0; i < 30 ; i++) { 790 + for (i = 0; i < 30 ; i++) { 827 791 if (cx24116_readreg(state, CX24116_REG_QSTATUS) & 0x20) 828 792 return 0; 829 793 msleep(10); ··· 834 798 return -ETIMEDOUT; /* -EBUSY ? */ 835 799 } 836 800 837 - static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 801 + static int cx24116_set_tone(struct dvb_frontend *fe, 802 + fe_sec_tone_mode_t tone) 838 803 { 839 804 struct cx24116_cmd cmd; 840 805 int ret; 841 806 842 807 dprintk("%s(%d)\n", __func__, tone); 843 - if ( (tone != SEC_TONE_ON) && (tone != SEC_TONE_OFF) ) { 844 - printk("%s: Invalid, tone=%d\n", __func__, tone); 808 + if ((tone != SEC_TONE_ON) && (tone != SEC_TONE_OFF)) { 809 + printk(KERN_ERR "%s: Invalid, tone=%d\n", __func__, tone); 845 810 return -EINVAL; 846 811 } 847 812 848 813 /* Wait for LNB ready */ 849 814 ret = cx24116_wait_for_lnb(fe); 850 - if(ret != 0) 815 + if (ret != 0) 851 816 return ret; 852 817 853 818 /* Min delay time after DiSEqC send */ ··· 857 820 /* This is always done before the tone is set */ 858 821 cmd.args[0x00] = CMD_SET_TONEPRE; 859 822 cmd.args[0x01] = 0x00; 860 - cmd.len= 0x02; 823 + cmd.len = 0x02; 861 824 ret = cx24116_cmd_execute(fe, &cmd); 862 825 if (ret != 0) 863 826 return ret; ··· 873 836 cmd.args[0x03] = 0x01; 874 837 break; 875 838 case SEC_TONE_OFF: 876 - dprintk("%s: setting tone off\n",__func__); 839 + dprintk("%s: setting tone off\n", __func__); 877 840 cmd.args[0x03] = 0x00; 878 841 break; 879 842 } 880 - cmd.len= 0x04; 843 + cmd.len = 0x04; 881 844 882 845 /* Min delay time before DiSEqC send */ 883 846 msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ ··· 886 849 } 887 850 888 851 /* Initialise DiSEqC */ 889 - static int cx24116_diseqc_init(struct dvb_frontend* fe) 852 + static int cx24116_diseqc_init(struct dvb_frontend *fe) 890 853 { 891 854 struct cx24116_state *state = fe->demodulator_priv; 892 855 struct cx24116_cmd cmd; ··· 901 864 cmd.args[0x05] = 0x28; 902 865 cmd.args[0x06] = (toneburst == CX24116_DISEQC_TONEOFF) ? 0x00 : 0x01; 903 866 cmd.args[0x07] = 0x01; 904 - cmd.len= 0x08; 867 + cmd.len = 0x08; 905 868 ret = cx24116_cmd_execute(fe, &cmd); 906 869 if (ret != 0) 907 870 return ret; ··· 915 878 /* Unknown */ 916 879 state->dsec_cmd.args[CX24116_DISEQC_ARG2_2] = 0x02; 917 880 state->dsec_cmd.args[CX24116_DISEQC_ARG3_0] = 0x00; 918 - state->dsec_cmd.args[CX24116_DISEQC_ARG4_0] = 0x00; /* Continuation flag? */ 881 + /* Continuation flag? */ 882 + state->dsec_cmd.args[CX24116_DISEQC_ARG4_0] = 0x00; 919 883 920 884 /* DiSEqC message length */ 921 885 state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = 0x00; 922 886 923 887 /* Command length */ 924 - state->dsec_cmd.len= CX24116_DISEQC_MSGOFS; 888 + state->dsec_cmd.len = CX24116_DISEQC_MSGOFS; 925 889 926 890 return 0; 927 891 } 928 892 929 893 /* Send DiSEqC message with derived burst (hack) || previous burst */ 930 - static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *d) 894 + static int cx24116_send_diseqc_msg(struct dvb_frontend *fe, 895 + struct dvb_diseqc_master_cmd *d) 931 896 { 932 897 struct cx24116_state *state = fe->demodulator_priv; 933 898 int i, ret; 934 899 935 900 /* Dump DiSEqC message */ 936 901 if (debug) { 937 - printk("cx24116: %s(", __func__); 938 - for(i = 0 ; i < d->msg_len ;) { 939 - printk("0x%02x", d->msg[i]); 940 - if(++i < d->msg_len) 941 - printk(", "); 942 - } 902 + printk(KERN_INFO "cx24116: %s(", __func__); 903 + for (i = 0 ; i < d->msg_len ;) { 904 + printk(KERN_INFO "0x%02x", d->msg[i]); 905 + if (++i < d->msg_len) 906 + printk(KERN_INFO ", "); 907 + } 943 908 printk(") toneburst=%d\n", toneburst); 944 909 } 945 910 946 911 /* Validate length */ 947 - if(d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS)) 912 + if (d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS)) 948 913 return -EINVAL; 949 914 950 915 /* DiSEqC message */ ··· 957 918 state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = d->msg_len; 958 919 959 920 /* Command length */ 960 - state->dsec_cmd.len= CX24116_DISEQC_MSGOFS + state->dsec_cmd.args[CX24116_DISEQC_MSGLEN]; 921 + state->dsec_cmd.len = CX24116_DISEQC_MSGOFS + 922 + state->dsec_cmd.args[CX24116_DISEQC_MSGLEN]; 961 923 962 924 /* DiSEqC toneburst */ 963 - if(toneburst == CX24116_DISEQC_MESGCACHE) 925 + if (toneburst == CX24116_DISEQC_MESGCACHE) 964 926 /* Message is cached */ 965 927 return 0; 966 928 967 - else if(toneburst == CX24116_DISEQC_TONEOFF) 929 + else if (toneburst == CX24116_DISEQC_TONEOFF) 968 930 /* Message is sent without burst */ 969 931 state->dsec_cmd.args[CX24116_DISEQC_BURST] = 0; 970 932 971 - else if(toneburst == CX24116_DISEQC_TONECACHE) { 933 + else if (toneburst == CX24116_DISEQC_TONECACHE) { 972 934 /* 973 935 * Message is sent with derived else cached burst 974 936 * ··· 988 948 * Y = VOLTAGE (0=13V, 1=18V) 989 949 * Z = BAND (0=LOW, 1=HIGH(22K)) 990 950 */ 991 - if(d->msg_len >= 4 && d->msg[2] == 0x38) 992 - state->dsec_cmd.args[CX24116_DISEQC_BURST] = ((d->msg[3] & 4) >> 2); 993 - if(debug) 994 - dprintk("%s burst=%d\n", __func__, state->dsec_cmd.args[CX24116_DISEQC_BURST]); 951 + if (d->msg_len >= 4 && d->msg[2] == 0x38) 952 + state->dsec_cmd.args[CX24116_DISEQC_BURST] = 953 + ((d->msg[3] & 4) >> 2); 954 + if (debug) 955 + dprintk("%s burst=%d\n", __func__, 956 + state->dsec_cmd.args[CX24116_DISEQC_BURST]); 995 957 } 996 958 997 959 /* Wait for LNB ready */ 998 960 ret = cx24116_wait_for_lnb(fe); 999 - if(ret != 0) 961 + if (ret != 0) 1000 962 return ret; 1001 963 1002 964 /* Wait for voltage/min repeat delay */ ··· 1006 964 1007 965 /* Command */ 1008 966 ret = cx24116_cmd_execute(fe, &state->dsec_cmd); 1009 - if(ret != 0) 967 + if (ret != 0) 1010 968 return ret; 1011 969 /* 1012 970 * Wait for send ··· 1018 976 * 12.5ms burst + 1019 977 * >15ms delay (XXX determine if FW does this, see set_tone) 1020 978 */ 1021 - msleep( (state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + ((toneburst == CX24116_DISEQC_TONEOFF) ? 30 : 60) ); 979 + msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 980 + ((toneburst == CX24116_DISEQC_TONEOFF) ? 30 : 60)); 1022 981 1023 982 return 0; 1024 983 } 1025 984 1026 985 /* Send DiSEqC burst */ 1027 - static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) 986 + static int cx24116_diseqc_send_burst(struct dvb_frontend *fe, 987 + fe_sec_mini_cmd_t burst) 1028 988 { 1029 989 struct cx24116_state *state = fe->demodulator_priv; 1030 990 int ret; 1031 991 1032 - dprintk("%s(%d) toneburst=%d\n",__func__, burst, toneburst); 992 + dprintk("%s(%d) toneburst=%d\n", __func__, burst, toneburst); 1033 993 1034 994 /* DiSEqC burst */ 1035 995 if (burst == SEC_MINI_A) 1036 - state->dsec_cmd.args[CX24116_DISEQC_BURST] = CX24116_DISEQC_MINI_A; 1037 - else if(burst == SEC_MINI_B) 1038 - state->dsec_cmd.args[CX24116_DISEQC_BURST] = CX24116_DISEQC_MINI_B; 996 + state->dsec_cmd.args[CX24116_DISEQC_BURST] = 997 + CX24116_DISEQC_MINI_A; 998 + else if (burst == SEC_MINI_B) 999 + state->dsec_cmd.args[CX24116_DISEQC_BURST] = 1000 + CX24116_DISEQC_MINI_B; 1039 1001 else 1040 1002 return -EINVAL; 1041 1003 1042 1004 /* DiSEqC toneburst */ 1043 - if(toneburst != CX24116_DISEQC_MESGCACHE) 1005 + if (toneburst != CX24116_DISEQC_MESGCACHE) 1044 1006 /* Burst is cached */ 1045 1007 return 0; 1046 1008 ··· 1052 1006 1053 1007 /* Wait for LNB ready */ 1054 1008 ret = cx24116_wait_for_lnb(fe); 1055 - if(ret != 0) 1009 + if (ret != 0) 1056 1010 return ret; 1057 1011 1058 1012 /* Wait for voltage/min repeat delay */ ··· 1060 1014 1061 1015 /* Command */ 1062 1016 ret = cx24116_cmd_execute(fe, &state->dsec_cmd); 1063 - if(ret != 0) 1017 + if (ret != 0) 1064 1018 return ret; 1065 1019 1066 1020 /* ··· 1073 1027 * 12.5ms burst + 1074 1028 * >15ms delay (XXX determine if FW does this, see set_tone) 1075 1029 */ 1076 - msleep( (state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 60 ); 1030 + msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 60); 1077 1031 1078 1032 return 0; 1079 1033 } 1080 1034 1081 - static void cx24116_release(struct dvb_frontend* fe) 1035 + static void cx24116_release(struct dvb_frontend *fe) 1082 1036 { 1083 - struct cx24116_state* state = fe->demodulator_priv; 1084 - dprintk("%s\n",__func__); 1037 + struct cx24116_state *state = fe->demodulator_priv; 1038 + dprintk("%s\n", __func__); 1085 1039 kfree(state); 1086 1040 } 1087 1041 1088 1042 static struct dvb_frontend_ops cx24116_ops; 1089 1043 1090 - struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, 1091 - struct i2c_adapter* i2c) 1044 + struct dvb_frontend *cx24116_attach(const struct cx24116_config *config, 1045 + struct i2c_adapter *i2c) 1092 1046 { 1093 - struct cx24116_state* state = NULL; 1047 + struct cx24116_state *state = NULL; 1094 1048 int ret; 1095 1049 1096 - dprintk("%s\n",__func__); 1050 + dprintk("%s\n", __func__); 1097 1051 1098 1052 /* allocate memory for the internal state */ 1099 1053 state = kmalloc(sizeof(struct cx24116_state), GFP_KERNEL); 1100 - if (state == NULL) { 1101 - printk("Unable to kmalloc\n"); 1054 + if (state == NULL) 1102 1055 goto error1; 1103 - } 1104 1056 1105 1057 /* setup the state */ 1106 1058 memset(state, 0, sizeof(struct cx24116_state)); ··· 1107 1063 state->i2c = i2c; 1108 1064 1109 1065 /* check if the demod is present */ 1110 - ret = (cx24116_readreg(state, 0xFF) << 8) | cx24116_readreg(state, 0xFE); 1066 + ret = (cx24116_readreg(state, 0xFF) << 8) | 1067 + cx24116_readreg(state, 0xFE); 1111 1068 if (ret != 0x0501) { 1112 - printk("Invalid probe, probably not a CX24116 device\n"); 1069 + printk(KERN_INFO "Invalid probe, probably not a CX24116 device\n"); 1113 1070 goto error2; 1114 1071 } 1115 1072 1116 1073 /* create dvb_frontend */ 1117 - memcpy(&state->frontend.ops, &cx24116_ops, sizeof(struct dvb_frontend_ops)); 1074 + memcpy(&state->frontend.ops, &cx24116_ops, 1075 + sizeof(struct dvb_frontend_ops)); 1118 1076 state->frontend.demodulator_priv = state; 1119 1077 return &state->frontend; 1120 1078 1121 1079 error2: kfree(state); 1122 1080 error1: return NULL; 1123 1081 } 1082 + EXPORT_SYMBOL(cx24116_attach); 1083 + 1124 1084 /* 1125 1085 * Initialise or wake up device 1126 1086 * 1127 1087 * Power config will reset and load initial firmware if required 1128 1088 */ 1129 - static int cx24116_initfe(struct dvb_frontend* fe) 1089 + static int cx24116_initfe(struct dvb_frontend *fe) 1130 1090 { 1131 - struct cx24116_state* state = fe->demodulator_priv; 1091 + struct cx24116_state *state = fe->demodulator_priv; 1132 1092 struct cx24116_cmd cmd; 1133 1093 int ret; 1134 1094 1135 - dprintk("%s()\n",__func__); 1095 + dprintk("%s()\n", __func__); 1136 1096 1137 1097 /* Power on */ 1138 1098 cx24116_writereg(state, 0xe0, 0); ··· 1146 1098 /* Firmware CMD 36: Power config */ 1147 1099 cmd.args[0x00] = CMD_TUNERSLEEP; 1148 1100 cmd.args[0x01] = 0; 1149 - cmd.len= 0x02; 1101 + cmd.len = 0x02; 1150 1102 ret = cx24116_cmd_execute(fe, &cmd); 1151 - if(ret != 0) 1103 + if (ret != 0) 1152 1104 return ret; 1153 1105 1154 1106 return cx24116_diseqc_init(fe); ··· 1157 1109 /* 1158 1110 * Put device to sleep 1159 1111 */ 1160 - static int cx24116_sleep(struct dvb_frontend* fe) 1112 + static int cx24116_sleep(struct dvb_frontend *fe) 1161 1113 { 1162 - struct cx24116_state* state = fe->demodulator_priv; 1114 + struct cx24116_state *state = fe->demodulator_priv; 1163 1115 struct cx24116_cmd cmd; 1164 1116 int ret; 1165 1117 1166 - dprintk("%s()\n",__func__); 1118 + dprintk("%s()\n", __func__); 1167 1119 1168 1120 /* Firmware CMD 36: Power config */ 1169 1121 cmd.args[0x00] = CMD_TUNERSLEEP; 1170 1122 cmd.args[0x01] = 1; 1171 - cmd.len= 0x02; 1123 + cmd.len = 0x02; 1172 1124 ret = cx24116_cmd_execute(fe, &cmd); 1173 - if(ret != 0) 1125 + if (ret != 0) 1174 1126 return ret; 1175 1127 1176 1128 /* Power off (Shutdown clocks) */ ··· 1181 1133 return 0; 1182 1134 } 1183 1135 1184 - static int cx24116_set_property(struct dvb_frontend *fe, struct dtv_property* tvp) 1136 + static int cx24116_set_property(struct dvb_frontend *fe, 1137 + struct dtv_property *tvp) 1185 1138 { 1186 1139 dprintk("%s(..)\n", __func__); 1187 1140 return 0; 1188 1141 } 1189 1142 1190 - static int cx24116_get_property(struct dvb_frontend *fe, struct dtv_property* tvp) 1143 + static int cx24116_get_property(struct dvb_frontend *fe, 1144 + struct dtv_property *tvp) 1191 1145 { 1192 1146 dprintk("%s(..)\n", __func__); 1193 1147 return 0; ··· 1198 1148 /* dvb-core told us to tune, the tv property cache will be complete, 1199 1149 * it's safe for is to pull values and use them for tuning purposes. 1200 1150 */ 1201 - static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 1151 + static int cx24116_set_frontend(struct dvb_frontend *fe, 1152 + struct dvb_frontend_parameters *p) 1202 1153 { 1203 1154 struct cx24116_state *state = fe->demodulator_priv; 1204 1155 struct dtv_frontend_properties *c = &fe->dtv_property_cache; ··· 1207 1156 fe_status_t tunerstat; 1208 1157 int i, status, ret, retune; 1209 1158 1210 - dprintk("%s()\n",__func__); 1159 + dprintk("%s()\n", __func__); 1211 1160 1212 - switch(c->delivery_system) { 1213 - case SYS_DVBS: 1214 - dprintk("%s: DVB-S delivery system selected\n",__func__); 1161 + switch (c->delivery_system) { 1162 + case SYS_DVBS: 1163 + dprintk("%s: DVB-S delivery system selected\n", __func__); 1215 1164 1216 - /* Only QPSK is supported for DVB-S */ 1217 - if(c->modulation != QPSK) { 1218 - dprintk("%s: unsupported modulation selected (%d)\n", 1219 - __func__, c->modulation); 1220 - return -EOPNOTSUPP; 1221 - } 1165 + /* Only QPSK is supported for DVB-S */ 1166 + if (c->modulation != QPSK) { 1167 + dprintk("%s: unsupported modulation selected (%d)\n", 1168 + __func__, c->modulation); 1169 + return -EOPNOTSUPP; 1170 + } 1222 1171 1223 - /* Pilot doesn't exist in DVB-S, turn bit off */ 1172 + /* Pilot doesn't exist in DVB-S, turn bit off */ 1173 + state->dnxt.pilot_val = CX24116_PILOT_OFF; 1174 + retune = 1; 1175 + 1176 + /* DVB-S only supports 0.35 */ 1177 + if (c->rolloff != ROLLOFF_35) { 1178 + dprintk("%s: unsupported rolloff selected (%d)\n", 1179 + __func__, c->rolloff); 1180 + return -EOPNOTSUPP; 1181 + } 1182 + state->dnxt.rolloff_val = CX24116_ROLLOFF_035; 1183 + break; 1184 + 1185 + case SYS_DVBS2: 1186 + dprintk("%s: DVB-S2 delivery system selected\n", __func__); 1187 + 1188 + /* 1189 + * NBC 8PSK/QPSK with DVB-S is supported for DVB-S2, 1190 + * but not hardware auto detection 1191 + */ 1192 + if (c->modulation != PSK_8 && c->modulation != QPSK) { 1193 + dprintk("%s: unsupported modulation selected (%d)\n", 1194 + __func__, c->modulation); 1195 + return -EOPNOTSUPP; 1196 + } 1197 + 1198 + switch (c->pilot) { 1199 + case PILOT_AUTO: /* Not supported but emulated */ 1200 + state->dnxt.pilot_val = (c->modulation == QPSK) 1201 + ? CX24116_PILOT_OFF : CX24116_PILOT_ON; 1202 + retune = 2; 1203 + break; 1204 + case PILOT_OFF: 1224 1205 state->dnxt.pilot_val = CX24116_PILOT_OFF; 1225 - retune = 1; 1206 + break; 1207 + case PILOT_ON: 1208 + state->dnxt.pilot_val = CX24116_PILOT_ON; 1209 + break; 1210 + default: 1211 + dprintk("%s: unsupported pilot mode selected (%d)\n", 1212 + __func__, c->pilot); 1213 + return -EOPNOTSUPP; 1214 + } 1226 1215 1227 - /* DVB-S only supports 0.35 */ 1228 - if(c->rolloff != ROLLOFF_35) { 1229 - dprintk("%s: unsupported rolloff selected (%d)\n", 1230 - __func__, c->rolloff); 1231 - return -EOPNOTSUPP; 1232 - } 1216 + switch (c->rolloff) { 1217 + case ROLLOFF_20: 1218 + state->dnxt.rolloff_val = CX24116_ROLLOFF_020; 1219 + break; 1220 + case ROLLOFF_25: 1221 + state->dnxt.rolloff_val = CX24116_ROLLOFF_025; 1222 + break; 1223 + case ROLLOFF_35: 1233 1224 state->dnxt.rolloff_val = CX24116_ROLLOFF_035; 1234 1225 break; 1235 - 1236 - case SYS_DVBS2: 1237 - dprintk("%s: DVB-S2 delivery system selected\n",__func__); 1238 - 1239 - /* 1240 - * NBC 8PSK/QPSK with DVB-S is supported for DVB-S2, 1241 - * but not hardware auto detection 1242 - */ 1243 - if(c->modulation != PSK_8 && c->modulation != QPSK) { 1244 - dprintk("%s: unsupported modulation selected (%d)\n", 1245 - __func__, c->modulation); 1246 - return -EOPNOTSUPP; 1247 - } 1248 - 1249 - switch(c->pilot) { 1250 - case PILOT_AUTO: /* Not supported but emulated */ 1251 - retune = 2; /* Fall-through */ 1252 - case PILOT_OFF: 1253 - state->dnxt.pilot_val = CX24116_PILOT_OFF; 1254 - break; 1255 - case PILOT_ON: 1256 - state->dnxt.pilot_val = CX24116_PILOT_ON; 1257 - break; 1258 - default: 1259 - dprintk("%s: unsupported pilot mode selected (%d)\n", 1260 - __func__, c->pilot); 1261 - return -EOPNOTSUPP; 1262 - } 1263 - 1264 - switch(c->rolloff) { 1265 - case ROLLOFF_20: 1266 - state->dnxt.rolloff_val= CX24116_ROLLOFF_020; 1267 - break; 1268 - case ROLLOFF_25: 1269 - state->dnxt.rolloff_val= CX24116_ROLLOFF_025; 1270 - break; 1271 - case ROLLOFF_35: 1272 - state->dnxt.rolloff_val= CX24116_ROLLOFF_035; 1273 - break; 1274 - case ROLLOFF_AUTO: /* Rolloff must be explicit */ 1275 - default: 1276 - dprintk("%s: unsupported rolloff selected (%d)\n", 1277 - __func__, c->rolloff); 1278 - return -EOPNOTSUPP; 1279 - } 1280 - break; 1281 - 1226 + case ROLLOFF_AUTO: /* Rolloff must be explicit */ 1282 1227 default: 1283 - dprintk("%s: unsupported delivery system selected (%d)\n", 1284 - __func__, c->delivery_system); 1228 + dprintk("%s: unsupported rolloff selected (%d)\n", 1229 + __func__, c->rolloff); 1285 1230 return -EOPNOTSUPP; 1231 + } 1232 + break; 1233 + 1234 + default: 1235 + dprintk("%s: unsupported delivery system selected (%d)\n", 1236 + __func__, c->delivery_system); 1237 + return -EOPNOTSUPP; 1286 1238 } 1287 1239 state->dnxt.modulation = c->modulation; 1288 1240 state->dnxt.frequency = c->frequency; 1289 1241 state->dnxt.pilot = c->pilot; 1290 1242 state->dnxt.rolloff = c->rolloff; 1291 1243 1292 - if ((ret = cx24116_set_inversion(state, c->inversion)) != 0) 1244 + ret = cx24116_set_inversion(state, c->inversion); 1245 + if (ret != 0) 1293 1246 return ret; 1294 1247 1295 1248 /* FEC_NONE/AUTO for DVB-S2 is not supported and detected here */ 1296 - if ((ret = cx24116_set_fec(state, c->modulation, c->fec_inner)) != 0) 1249 + ret = cx24116_set_fec(state, c->modulation, c->fec_inner); 1250 + if (ret != 0) 1297 1251 return ret; 1298 1252 1299 - if ((ret = cx24116_set_symbolrate(state, c->symbol_rate)) != 0) 1253 + ret = cx24116_set_symbolrate(state, c->symbol_rate); 1254 + if (ret != 0) 1300 1255 return ret; 1301 1256 1302 1257 /* discard the 'current' tuning parameters and prepare to tune */ ··· 1328 1271 /* Set/Reset B/W */ 1329 1272 cmd.args[0x00] = CMD_BANDWIDTH; 1330 1273 cmd.args[0x01] = 0x01; 1331 - cmd.len= 0x02; 1274 + cmd.len = 0x02; 1332 1275 ret = cx24116_cmd_execute(fe, &cmd); 1333 1276 if (ret != 0) 1334 1277 return ret; ··· 1376 1319 cx24116_writereg(state, CX24116_REG_RATEDIV, 0x00); 1377 1320 } 1378 1321 1379 - cmd.len= 0x13; 1322 + cmd.len = 0x13; 1380 1323 1381 1324 /* We need to support pilot and non-pilot tuning in the 1382 1325 * driver automatically. This is a workaround for because ··· 1384 1327 */ 1385 1328 do { 1386 1329 /* Reset status register */ 1387 - status = cx24116_readreg(state, CX24116_REG_SSTATUS) & CX24116_SIGNAL_MASK; 1330 + status = cx24116_readreg(state, CX24116_REG_SSTATUS) 1331 + & CX24116_SIGNAL_MASK; 1388 1332 cx24116_writereg(state, CX24116_REG_SSTATUS, status); 1389 1333 1390 1334 /* Tune */ 1391 1335 ret = cx24116_cmd_execute(fe, &cmd); 1392 - if( ret != 0 ) 1336 + if (ret != 0) 1393 1337 break; 1394 1338 1395 1339 /* ··· 1399 1341 * If we are able to tune then generally it occurs within 100ms. 1400 1342 * If it takes longer, try a different toneburst setting. 1401 1343 */ 1402 - for(i = 0; i < 50 ; i++) { 1344 + for (i = 0; i < 50 ; i++) { 1403 1345 cx24116_read_status(fe, &tunerstat); 1404 1346 status = tunerstat & (FE_HAS_SIGNAL | FE_HAS_SYNC); 1405 - if(status == (FE_HAS_SIGNAL | FE_HAS_SYNC)) { 1406 - dprintk("%s: Tuned\n",__func__); 1347 + if (status == (FE_HAS_SIGNAL | FE_HAS_SYNC)) { 1348 + dprintk("%s: Tuned\n", __func__); 1407 1349 goto tuned; 1408 1350 } 1409 1351 msleep(10); 1410 1352 } 1411 1353 1412 - dprintk("%s: Not tuned\n",__func__); 1354 + dprintk("%s: Not tuned\n", __func__); 1413 1355 1414 1356 /* Toggle pilot bit when in auto-pilot */ 1415 - if(state->dcur.pilot == PILOT_AUTO) 1357 + if (state->dcur.pilot == PILOT_AUTO) 1416 1358 cmd.args[0x07] ^= CX24116_PILOT_ON; 1417 - } 1418 - while(--retune); 1359 + } while (--retune); 1419 1360 1420 1361 tuned: /* Set/Reset B/W */ 1421 1362 cmd.args[0x00] = CMD_BANDWIDTH; 1422 1363 cmd.args[0x01] = 0x00; 1423 - cmd.len= 0x02; 1364 + cmd.len = 0x02; 1424 1365 ret = cx24116_cmd_execute(fe, &cmd); 1425 1366 if (ret != 0) 1426 1367 return ret; ··· 1464 1407 .set_frontend = cx24116_set_frontend, 1465 1408 }; 1466 1409 1467 - module_param(debug, int, 0644); 1468 - MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); 1469 - 1470 - module_param(toneburst, int, 0644); 1471 - MODULE_PARM_DESC(toneburst, "DiSEqC toneburst 0=OFF, 1=TONE CACHE, 2=MESSAGE CACHE (default:1)"); 1472 - 1473 - module_param(esno_snr, int, 0644); 1474 - MODULE_PARM_DESC(debug, "SNR return units, 0=PERCENTAGE 0-100, 1=ESNO(db * 10) (default:0)"); 1475 - 1476 1410 MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware"); 1477 1411 MODULE_AUTHOR("Steven Toth"); 1478 1412 MODULE_LICENSE("GPL"); 1479 1413 1480 - EXPORT_SYMBOL(cx24116_attach);
+11 -10
drivers/media/dvb/frontends/cx24116.h
··· 23 23 24 24 #include <linux/dvb/frontend.h> 25 25 26 - struct cx24116_config 27 - { 26 + struct cx24116_config { 28 27 /* the demodulator's i2c address */ 29 28 u8 demod_address; 30 29 31 30 /* Need to set device param for start_dma */ 32 - int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 31 + int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured); 33 32 34 33 /* Need to reset device during firmware loading */ 35 - int (*reset_device)(struct dvb_frontend* fe); 34 + int (*reset_device)(struct dvb_frontend *fe); 36 35 37 36 /* Need to set MPEG parameters */ 38 37 u8 mpg_clk_pos_pol:0x02; 39 38 }; 40 39 41 40 #if defined(CONFIG_DVB_CX24116) || defined(CONFIG_DVB_CX24116_MODULE) 42 - extern struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, 43 - struct i2c_adapter* i2c); 41 + extern struct dvb_frontend *cx24116_attach( 42 + const struct cx24116_config *config, 43 + struct i2c_adapter *i2c); 44 44 #else 45 - static inline struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, 46 - struct i2c_adapter* i2c) 45 + static inline struct dvb_frontend *cx24116_attach( 46 + const struct cx24116_config *config, 47 + struct i2c_adapter *i2c) 47 48 { 48 - printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); 49 + printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 49 50 return NULL; 50 51 } 51 - #endif // CONFIG_DVB_CX24116 52 + #endif 52 53 53 54 #endif /* CX24116_H */
+128 -100
drivers/media/dvb/frontends/cx24123.c
··· 33 33 #define XTAL 10111000 34 34 35 35 static int force_band; 36 + module_param(force_band, int, 0644); 37 + MODULE_PARM_DESC(force_band, "Force a specific band select "\ 38 + "(1-9, default:off)."); 39 + 36 40 static int debug; 41 + module_param(debug, int, 0644); 42 + MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); 37 43 38 44 #define info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0) 39 45 #define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0) ··· 52 46 } \ 53 47 } while (0) 54 48 55 - struct cx24123_state 56 - { 57 - struct i2c_adapter* i2c; 58 - const struct cx24123_config* config; 49 + struct cx24123_state { 50 + struct i2c_adapter *i2c; 51 + const struct cx24123_config *config; 59 52 60 53 struct dvb_frontend frontend; 61 54 ··· 75 70 }; 76 71 77 72 /* Various tuner defaults need to be established for a given symbol rate Sps */ 78 - static struct 79 - { 73 + static struct cx24123_AGC_val { 80 74 u32 symbolrate_low; 81 75 u32 symbolrate_high; 82 76 u32 VCAprogdata; ··· 113 109 * fixme: The bounds on the bands do not match the doc in real life. 114 110 * fixme: Some of them have been moved, other might need adjustment. 115 111 */ 116 - static struct 117 - { 112 + static struct cx24123_bandselect_val { 118 113 u32 freq_low; 119 114 u32 freq_high; 120 115 u32 VCOdivider; ··· 252 249 253 250 /* printk(KERN_DEBUG "wr(%02x): %02x %02x\n", i2c_addr, reg, data); */ 254 251 255 - if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 252 + err = i2c_transfer(state->i2c, &msg, 1); 253 + if (err != 1) { 256 254 printk("%s: writereg error(err == %i, reg == 0x%02x," 257 255 " data == 0x%02x)\n", __func__, err, reg, data); 258 256 return err; ··· 288 284 #define cx24123_writereg(state, reg, val) \ 289 285 cx24123_i2c_writereg(state, state->config->demod_address, reg, val) 290 286 291 - static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) 287 + static int cx24123_set_inversion(struct cx24123_state *state, 288 + fe_spectral_inversion_t inversion) 292 289 { 293 290 u8 nom_reg = cx24123_readreg(state, 0x0e); 294 291 u8 auto_reg = cx24123_readreg(state, 0x10); ··· 316 311 return 0; 317 312 } 318 313 319 - static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_inversion_t *inversion) 314 + static int cx24123_get_inversion(struct cx24123_state *state, 315 + fe_spectral_inversion_t *inversion) 320 316 { 321 317 u8 val; 322 318 ··· 334 328 return 0; 335 329 } 336 330 337 - static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) 331 + static int cx24123_set_fec(struct cx24123_state *state, fe_code_rate_t fec) 338 332 { 339 333 u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07; 340 334 341 - if ( (fec < FEC_NONE) || (fec > FEC_AUTO) ) 335 + if ((fec < FEC_NONE) || (fec > FEC_AUTO)) 342 336 fec = FEC_AUTO; 343 337 344 338 /* Set the soft decision threshold */ 345 - if(fec == FEC_1_2) 346 - cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) | 0x01); 339 + if (fec == FEC_1_2) 340 + cx24123_writereg(state, 0x43, 341 + cx24123_readreg(state, 0x43) | 0x01); 347 342 else 348 - cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) & ~0x01); 343 + cx24123_writereg(state, 0x43, 344 + cx24123_readreg(state, 0x43) & ~0x01); 349 345 350 346 switch (fec) { 351 347 case FEC_1_2: ··· 396 388 return 0; 397 389 } 398 390 399 - static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec) 391 + static int cx24123_get_fec(struct cx24123_state *state, fe_code_rate_t *fec) 400 392 { 401 393 int ret; 402 394 403 - ret = cx24123_readreg (state, 0x1b); 395 + ret = cx24123_readreg(state, 0x1b); 404 396 if (ret < 0) 405 397 return ret; 406 398 ret = ret & 0x07; ··· 441 433 { 442 434 u32 exp, nearest = 0; 443 435 u32 div = a / b; 444 - if(a % b >= b / 2) ++div; 445 - if(div < (1 << 31)) 446 - { 447 - for(exp = 1; div > exp; nearest++) 436 + if (a % b >= b / 2) 437 + ++div; 438 + if (div < (1 << 31)) { 439 + for (exp = 1; div > exp; nearest++) 448 440 exp += exp; 449 441 } 450 442 return nearest; 451 443 } 452 444 453 - static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) 445 + static int cx24123_set_symbolrate(struct cx24123_state *state, u32 srate) 454 446 { 455 447 u32 tmp, sample_rate, ratio, sample_gain; 456 448 u8 pll_mult; ··· 506 498 507 499 cx24123_writereg(state, 0x01, pll_mult * 6); 508 500 509 - cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f ); 510 - cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff ); 511 - cx24123_writereg(state, 0x0a, (ratio ) & 0xff ); 501 + cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f); 502 + cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff); 503 + cx24123_writereg(state, 0x0a, ratio & 0xff); 512 504 513 505 /* also set the demodulator sample gain */ 514 506 sample_gain = cx24123_int_log2(sample_rate, srate); ··· 522 514 } 523 515 524 516 /* 525 - * Based on the required frequency and symbolrate, the tuner AGC has to be configured 526 - * and the correct band selected. Calculate those values 517 + * Based on the required frequency and symbolrate, the tuner AGC has 518 + * to be configured and the correct band selected. 519 + * Calculate those values. 527 520 */ 528 - static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 521 + static int cx24123_pll_calculate(struct dvb_frontend *fe, 522 + struct dvb_frontend_parameters *p) 529 523 { 530 524 struct cx24123_state *state = fe->demodulator_priv; 531 525 u32 ndiv = 0, adiv = 0, vco_div = 0; ··· 535 525 int pump = 2; 536 526 int band = 0; 537 527 int num_bands = ARRAY_SIZE(cx24123_bandselect_vals); 528 + struct cx24123_bandselect_val *bsv = NULL; 529 + struct cx24123_AGC_val *agcv = NULL; 538 530 539 531 /* Defaults for low freq, low rate */ 540 532 state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; ··· 544 532 state->bandselectarg = cx24123_bandselect_vals[0].progdata; 545 533 vco_div = cx24123_bandselect_vals[0].VCOdivider; 546 534 547 - /* For the given symbol rate, determine the VCA, VGA and FILTUNE programming bits */ 548 - for (i = 0; i < ARRAY_SIZE(cx24123_AGC_vals); i++) 549 - { 550 - if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) && 551 - (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) { 552 - state->VCAarg = cx24123_AGC_vals[i].VCAprogdata; 553 - state->VGAarg = cx24123_AGC_vals[i].VGAprogdata; 554 - state->FILTune = cx24123_AGC_vals[i].FILTune; 535 + /* For the given symbol rate, determine the VCA, VGA and 536 + * FILTUNE programming bits */ 537 + for (i = 0; i < ARRAY_SIZE(cx24123_AGC_vals); i++) { 538 + agcv = &cx24123_AGC_vals[i]; 539 + if ((agcv->symbolrate_low <= p->u.qpsk.symbol_rate) && 540 + (agcv->symbolrate_high >= p->u.qpsk.symbol_rate)) { 541 + state->VCAarg = agcv->VCAprogdata; 542 + state->VGAarg = agcv->VGAprogdata; 543 + state->FILTune = agcv->FILTune; 555 544 } 556 545 } 557 546 558 547 /* determine the band to use */ 559 - if(force_band < 1 || force_band > num_bands) 560 - { 561 - for (i = 0; i < num_bands; i++) 562 - { 563 - if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) && 564 - (cx24123_bandselect_vals[i].freq_high >= p->frequency) ) 548 + if (force_band < 1 || force_band > num_bands) { 549 + for (i = 0; i < num_bands; i++) { 550 + bsv = &cx24123_bandselect_vals[i]; 551 + if ((bsv->freq_low <= p->frequency) && 552 + (bsv->freq_high >= p->frequency)) 565 553 band = i; 566 554 } 567 - } 568 - else 555 + } else 569 556 band = force_band - 1; 570 557 571 558 state->bandselectarg = cx24123_bandselect_vals[band].progdata; 572 559 vco_div = cx24123_bandselect_vals[band].VCOdivider; 573 560 574 561 /* determine the charge pump current */ 575 - if ( p->frequency < (cx24123_bandselect_vals[band].freq_low + cx24123_bandselect_vals[band].freq_high)/2 ) 562 + if (p->frequency < (cx24123_bandselect_vals[band].freq_low + 563 + cx24123_bandselect_vals[band].freq_high) / 2) 576 564 pump = 0x01; 577 565 else 578 566 pump = 0x02; 579 567 580 568 /* Determine the N/A dividers for the requested lband freq (in kHz). */ 581 - /* Note: the reference divider R=10, frequency is in KHz, XTAL is in Hz */ 582 - ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff; 583 - adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f; 569 + /* Note: the reference divider R=10, frequency is in KHz, 570 + * XTAL is in Hz */ 571 + ndiv = (((p->frequency * vco_div * 10) / 572 + (2 * XTAL / 1000)) / 32) & 0x1ff; 573 + adiv = (((p->frequency * vco_div * 10) / 574 + (2 * XTAL / 1000)) % 32) & 0x1f; 584 575 585 576 if (adiv == 0 && ndiv > 0) 586 577 ndiv--; 587 578 588 - /* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */ 589 - state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv; 579 + /* control bits 11, refdiv 11, charge pump polarity 1, 580 + * charge pump current, ndiv, adiv */ 581 + state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | 582 + (pump << 14) | (ndiv << 5) | adiv; 590 583 591 584 return 0; 592 585 } 593 586 594 587 /* 595 588 * Tuner data is 21 bits long, must be left-aligned in data. 596 - * Tuner cx24109 is written through a dedicated 3wire interface on the demod chip. 589 + * Tuner cx24109 is written through a dedicated 3wire interface 590 + * on the demod chip. 597 591 */ 598 - static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_parameters *p, u32 data) 592 + static int cx24123_pll_writereg(struct dvb_frontend *fe, 593 + struct dvb_frontend_parameters *p, u32 data) 599 594 { 600 595 struct cx24123_state *state = fe->demodulator_priv; 601 596 unsigned long timeout; ··· 629 610 630 611 /* send another 8 bytes, wait for the send to be completed */ 631 612 timeout = jiffies + msecs_to_jiffies(40); 632 - cx24123_writereg(state, 0x22, (data>>8) & 0xff ); 613 + cx24123_writereg(state, 0x22, (data >> 8) & 0xff); 633 614 while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { 634 615 if (time_after(jiffies, timeout)) { 635 616 err("%s: demodulator is not responding, "\ ··· 639 620 msleep(10); 640 621 } 641 622 642 - /* send the lower 5 bits of this byte, padded with 3 LBB, wait for the send to be completed */ 623 + /* send the lower 5 bits of this byte, padded with 3 LBB, 624 + * wait for the send to be completed */ 643 625 timeout = jiffies + msecs_to_jiffies(40); 644 - cx24123_writereg(state, 0x22, (data) & 0xff ); 626 + cx24123_writereg(state, 0x22, (data) & 0xff); 645 627 while ((cx24123_readreg(state, 0x20) & 0x80)) { 646 628 if (time_after(jiffies, timeout)) { 647 629 err("%s: demodulator is not responding," \ ··· 659 639 return 0; 660 640 } 661 641 662 - static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 642 + static int cx24123_pll_tune(struct dvb_frontend *fe, 643 + struct dvb_frontend_parameters *p) 663 644 { 664 645 struct cx24123_state *state = fe->demodulator_priv; 665 646 u8 val; ··· 711 690 return cx24123_writereg(state, 0x23, r); 712 691 } 713 692 714 - static int cx24123_initfe(struct dvb_frontend* fe) 693 + static int cx24123_initfe(struct dvb_frontend *fe) 715 694 { 716 695 struct cx24123_state *state = fe->demodulator_priv; 717 696 int i; ··· 720 699 721 700 /* Configure the demod to a good set of defaults */ 722 701 for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++) 723 - cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); 702 + cx24123_writereg(state, cx24123_regdata[i].reg, 703 + cx24123_regdata[i].data); 724 704 725 705 /* Set the LNB polarity */ 726 - if(state->config->lnb_polarity) 727 - cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02); 706 + if (state->config->lnb_polarity) 707 + cx24123_writereg(state, 0x32, 708 + cx24123_readreg(state, 0x32) | 0x02); 728 709 729 710 if (state->config->dont_use_pll) 730 - cx24123_repeater_mode(state, 1, 0); 711 + cx24123_repeater_mode(state, 1, 0); 731 712 732 713 return 0; 733 714 } 734 715 735 - static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 716 + static int cx24123_set_voltage(struct dvb_frontend *fe, 717 + fe_sec_voltage_t voltage) 736 718 { 737 719 struct cx24123_state *state = fe->demodulator_priv; 738 720 u8 val; ··· 764 740 { 765 741 unsigned long timeout = jiffies + msecs_to_jiffies(200); 766 742 while (!(cx24123_readreg(state, 0x29) & 0x40)) { 767 - if(time_after(jiffies, timeout)) { 743 + if (time_after(jiffies, timeout)) { 768 744 err("%s: diseqc queue not ready, " \ 769 745 "command may be lost.\n", __func__); 770 746 break; ··· 773 749 } 774 750 } 775 751 776 - static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd) 752 + static int cx24123_send_diseqc_msg(struct dvb_frontend *fe, 753 + struct dvb_diseqc_master_cmd *cmd) 777 754 { 778 755 struct cx24123_state *state = fe->demodulator_priv; 779 756 int i, val, tone; ··· 796 771 cx24123_writereg(state, 0x2C + i, cmd->msg[i]); 797 772 798 773 val = cx24123_readreg(state, 0x29); 799 - cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); 774 + cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | 775 + ((cmd->msg_len-3) & 3)); 800 776 801 777 /* wait for diseqc message to finish sending */ 802 778 cx24123_wait_for_diseqc(state); 803 779 804 780 /* restart continuous tone if enabled */ 805 - if (tone & 0x10) { 781 + if (tone & 0x10) 806 782 cx24123_writereg(state, 0x29, tone & ~0x40); 807 - } 808 783 809 784 return 0; 810 785 } 811 786 812 - static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) 787 + static int cx24123_diseqc_send_burst(struct dvb_frontend *fe, 788 + fe_sec_mini_cmd_t burst) 813 789 { 814 790 struct cx24123_state *state = fe->demodulator_priv; 815 791 int val, tone; ··· 840 814 cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb); 841 815 842 816 /* restart continuous tone if enabled */ 843 - if (tone & 0x10) { 817 + if (tone & 0x10) 844 818 cx24123_writereg(state, 0x29, tone & ~0x40); 845 - } 819 + 846 820 return 0; 847 821 } 848 822 849 - static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) 823 + static int cx24123_read_status(struct dvb_frontend *fe, fe_status_t *status) 850 824 { 851 825 struct cx24123_state *state = fe->demodulator_priv; 852 826 int sync = cx24123_readreg(state, 0x14); ··· 879 853 } 880 854 881 855 /* 882 - * Configured to return the measurement of errors in blocks, because no UCBLOCKS value 883 - * is available, so this value doubles up to satisfy both measurements 856 + * Configured to return the measurement of errors in blocks, 857 + * because no UCBLOCKS value is available, so this value doubles up 858 + * to satisfy both measurements. 884 859 */ 885 860 static int cx24123_read_ber(struct dvb_frontend *fe, u32 *ber) 886 861 { ··· 903 876 { 904 877 struct cx24123_state *state = fe->demodulator_priv; 905 878 906 - *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ 879 + /* larger = better */ 880 + *signal_strength = cx24123_readreg(state, 0x3b) << 8; 907 881 908 882 dprintk("Signal strength = %d\n", *signal_strength); 909 883 ··· 935 907 if (state->config->set_ts_params) 936 908 state->config->set_ts_params(fe, 0); 937 909 938 - state->currentfreq=p->frequency; 910 + state->currentfreq = p->frequency; 939 911 state->currentsymbolrate = p->u.qpsk.symbol_rate; 940 912 941 913 cx24123_set_inversion(state, p->inversion); ··· 960 932 return 0; 961 933 } 962 934 963 - static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 935 + static int cx24123_get_frontend(struct dvb_frontend *fe, 936 + struct dvb_frontend_parameters *p) 964 937 { 965 938 struct cx24123_state *state = fe->demodulator_priv; 966 939 ··· 981 952 return 0; 982 953 } 983 954 984 - static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 955 + static int cx24123_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) 985 956 { 986 957 struct cx24123_state *state = fe->demodulator_priv; 987 958 u8 val; ··· 1006 977 return 0; 1007 978 } 1008 979 1009 - static int cx24123_tune(struct dvb_frontend* fe, 1010 - struct dvb_frontend_parameters* params, 980 + static int cx24123_tune(struct dvb_frontend *fe, 981 + struct dvb_frontend_parameters *params, 1011 982 unsigned int mode_flags, 1012 983 unsigned int *delay, 1013 984 fe_status_t *status) ··· 1026 997 1027 998 static int cx24123_get_algo(struct dvb_frontend *fe) 1028 999 { 1029 - return 1; //FE_ALGO_HW 1000 + return 1; /* FE_ALGO_HW */ 1030 1001 } 1031 1002 1032 - static void cx24123_release(struct dvb_frontend* fe) 1003 + static void cx24123_release(struct dvb_frontend *fe) 1033 1004 { 1034 - struct cx24123_state* state = fe->demodulator_priv; 1005 + struct cx24123_state *state = fe->demodulator_priv; 1035 1006 dprintk("\n"); 1036 1007 i2c_del_adapter(&state->tuner_i2c_adapter); 1037 1008 kfree(state); ··· 1042 1013 { 1043 1014 struct cx24123_state *state = i2c_get_adapdata(i2c_adap); 1044 1015 /* this repeater closes after the first stop */ 1045 - cx24123_repeater_mode(state, 1, 1); 1016 + cx24123_repeater_mode(state, 1, 1); 1046 1017 return i2c_transfer(state->i2c, msg, num); 1047 1018 } 1048 1019 ··· 1066 1037 1067 1038 static struct dvb_frontend_ops cx24123_ops; 1068 1039 1069 - struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, 1070 - struct i2c_adapter* i2c) 1040 + struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, 1041 + struct i2c_adapter *i2c) 1071 1042 { 1072 1043 struct cx24123_state *state = 1073 1044 kzalloc(sizeof(struct cx24123_state), GFP_KERNEL); ··· 1086 1057 /* check if the demod is there */ 1087 1058 state->demod_rev = cx24123_readreg(state, 0x00); 1088 1059 switch (state->demod_rev) { 1089 - case 0xe1: info("detected CX24123C\n"); break; 1090 - case 0xd1: info("detected CX24123\n"); break; 1060 + case 0xe1: 1061 + info("detected CX24123C\n"); 1062 + break; 1063 + case 0xd1: 1064 + info("detected CX24123\n"); 1065 + break; 1091 1066 default: 1092 1067 err("wrong demod revision: %x\n", state->demod_rev); 1093 1068 goto error; 1094 1069 } 1095 1070 1096 1071 /* create dvb_frontend */ 1097 - memcpy(&state->frontend.ops, &cx24123_ops, sizeof(struct dvb_frontend_ops)); 1072 + memcpy(&state->frontend.ops, &cx24123_ops, 1073 + sizeof(struct dvb_frontend_ops)); 1098 1074 state->frontend.demodulator_priv = state; 1099 1075 1100 - /* create tuner i2c adapter */ 1101 - if (config->dont_use_pll) 1102 - cx24123_repeater_mode(state, 1, 0); 1076 + /* create tuner i2c adapter */ 1077 + if (config->dont_use_pll) 1078 + cx24123_repeater_mode(state, 1, 0); 1103 1079 1104 1080 strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus", 1105 1081 sizeof(state->tuner_i2c_adapter.name)); ··· 1113 1079 state->tuner_i2c_adapter.algo_data = NULL; 1114 1080 i2c_set_adapdata(&state->tuner_i2c_adapter, state); 1115 1081 if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) { 1116 - err("tuner i2c bus could not be initialized\n"); 1082 + err("tuner i2c bus could not be initialized\n"); 1117 1083 goto error; 1118 1084 } 1119 1085 ··· 1124 1090 1125 1091 return NULL; 1126 1092 } 1093 + EXPORT_SYMBOL(cx24123_attach); 1127 1094 1128 1095 static struct dvb_frontend_ops cx24123_ops = { 1129 1096 ··· 1161 1126 .get_frontend_algo = cx24123_get_algo, 1162 1127 }; 1163 1128 1164 - module_param(debug, int, 0644); 1165 - MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); 1166 - 1167 - module_param(force_band, int, 0644); 1168 - MODULE_PARM_DESC(force_band, "Force a specific band select (1-9, default:off)."); 1169 - 1170 1129 MODULE_DESCRIPTION("DVB Frontend module for Conexant " \ 1171 1130 "CX24123/CX24109/CX24113 hardware"); 1172 1131 MODULE_AUTHOR("Steven Toth"); 1173 1132 MODULE_LICENSE("GPL"); 1174 1133 1175 - EXPORT_SYMBOL(cx24123_attach);
+5 -5
drivers/media/dvb/frontends/cx24123.h
··· 23 23 24 24 #include <linux/dvb/frontend.h> 25 25 26 - struct cx24123_config 27 - { 26 + struct cx24123_config { 28 27 /* the demodulator's i2c address */ 29 28 u8 demod_address; 30 29 31 30 /* Need to set device param for start_dma */ 32 - int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 31 + int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured); 33 32 34 33 /* 0 = LNB voltage normal, 1 = LNB voltage inverted */ 35 34 int lnb_polarity; ··· 38 39 void (*agc_callback) (struct dvb_frontend *); 39 40 }; 40 41 41 - #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) && defined(MODULE)) 42 + #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) \ 43 + && defined(MODULE)) 42 44 extern struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, 43 45 struct i2c_adapter *i2c); 44 46 extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *); ··· 56 56 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 57 57 return NULL; 58 58 } 59 - #endif // CONFIG_DVB_CX24123 59 + #endif 60 60 61 61 #endif /* CX24123_H */
+70 -68
drivers/media/dvb/frontends/s5h1409.c
··· 30 30 31 31 struct s5h1409_state { 32 32 33 - struct i2c_adapter* i2c; 33 + struct i2c_adapter *i2c; 34 34 35 35 /* configuration settings */ 36 - const struct s5h1409_config* config; 36 + const struct s5h1409_config *config; 37 37 38 38 struct dvb_frontend frontend; 39 39 ··· 48 48 }; 49 49 50 50 static int debug; 51 + module_param(debug, int, 0644); 52 + MODULE_PARM_DESC(debug, "Enable verbose debug messages"); 53 + 51 54 #define dprintk if (debug) printk 52 55 53 56 /* Register values to initialise the demod, this will set VSB by default */ ··· 302 299 }; 303 300 304 301 /* 8 bit registers, 16 bit values */ 305 - static int s5h1409_writereg(struct s5h1409_state* state, u8 reg, u16 data) 302 + static int s5h1409_writereg(struct s5h1409_state *state, u8 reg, u16 data) 306 303 { 307 304 int ret; 308 - u8 buf [] = { reg, data >> 8, data & 0xff }; 305 + u8 buf[] = { reg, data >> 8, data & 0xff }; 309 306 310 307 struct i2c_msg msg = { .addr = state->config->demod_address, 311 308 .flags = 0, .buf = buf, .len = 3 }; ··· 313 310 ret = i2c_transfer(state->i2c, &msg, 1); 314 311 315 312 if (ret != 1) 316 - printk("%s: writereg error (reg == 0x%02x, val == 0x%04x, " 313 + printk(KERN_ERR "%s: error (reg == 0x%02x, val == 0x%04x, " 317 314 "ret == %i)\n", __func__, reg, data, ret); 318 315 319 316 return (ret != 1) ? -1 : 0; 320 317 } 321 318 322 - static u16 s5h1409_readreg(struct s5h1409_state* state, u8 reg) 319 + static u16 s5h1409_readreg(struct s5h1409_state *state, u8 reg) 323 320 { 324 321 int ret; 325 - u8 b0 [] = { reg }; 326 - u8 b1 [] = { 0, 0 }; 322 + u8 b0[] = { reg }; 323 + u8 b1[] = { 0, 0 }; 327 324 328 - struct i2c_msg msg [] = { 325 + struct i2c_msg msg[] = { 329 326 { .addr = state->config->demod_address, .flags = 0, 330 327 .buf = b0, .len = 1 }, 331 328 { .addr = state->config->demod_address, .flags = I2C_M_RD, ··· 338 335 return (b1[0] << 8) | b1[1]; 339 336 } 340 337 341 - static int s5h1409_softreset(struct dvb_frontend* fe) 338 + static int s5h1409_softreset(struct dvb_frontend *fe) 342 339 { 343 - struct s5h1409_state* state = fe->demodulator_priv; 340 + struct s5h1409_state *state = fe->demodulator_priv; 344 341 345 342 dprintk("%s()\n", __func__); 346 343 ··· 352 349 } 353 350 354 351 #define S5H1409_VSB_IF_FREQ 5380 355 - #define S5H1409_QAM_IF_FREQ state->config->qam_if 352 + #define S5H1409_QAM_IF_FREQ (state->config->qam_if) 356 353 357 - static int s5h1409_set_if_freq(struct dvb_frontend* fe, int KHz) 354 + static int s5h1409_set_if_freq(struct dvb_frontend *fe, int KHz) 358 355 { 359 - struct s5h1409_state* state = fe->demodulator_priv; 356 + struct s5h1409_state *state = fe->demodulator_priv; 360 357 361 358 dprintk("%s(%d KHz)\n", __func__, KHz); 362 359 ··· 379 376 return 0; 380 377 } 381 378 382 - static int s5h1409_set_spectralinversion(struct dvb_frontend* fe, int inverted) 379 + static int s5h1409_set_spectralinversion(struct dvb_frontend *fe, int inverted) 383 380 { 384 - struct s5h1409_state* state = fe->demodulator_priv; 381 + struct s5h1409_state *state = fe->demodulator_priv; 385 382 386 383 dprintk("%s(%d)\n", __func__, inverted); 387 384 388 - if(inverted == 1) 385 + if (inverted == 1) 389 386 return s5h1409_writereg(state, 0x1b, 0x1101); /* Inverted */ 390 387 else 391 388 return s5h1409_writereg(state, 0x1b, 0x0110); /* Normal */ 392 389 } 393 390 394 - static int s5h1409_enable_modulation(struct dvb_frontend* fe, 391 + static int s5h1409_enable_modulation(struct dvb_frontend *fe, 395 392 fe_modulation_t m) 396 393 { 397 - struct s5h1409_state* state = fe->demodulator_priv; 394 + struct s5h1409_state *state = fe->demodulator_priv; 398 395 399 396 dprintk("%s(0x%08x)\n", __func__, m); 400 397 401 - switch(m) { 398 + switch (m) { 402 399 case VSB_8: 403 400 dprintk("%s() VSB_8\n", __func__); 404 401 if (state->if_freq != S5H1409_VSB_IF_FREQ) ··· 425 422 return 0; 426 423 } 427 424 428 - static int s5h1409_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) 425 + static int s5h1409_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) 429 426 { 430 - struct s5h1409_state* state = fe->demodulator_priv; 427 + struct s5h1409_state *state = fe->demodulator_priv; 431 428 432 429 dprintk("%s(%d)\n", __func__, enable); 433 430 ··· 437 434 return s5h1409_writereg(state, 0xf3, 0); 438 435 } 439 436 440 - static int s5h1409_set_gpio(struct dvb_frontend* fe, int enable) 437 + static int s5h1409_set_gpio(struct dvb_frontend *fe, int enable) 441 438 { 442 - struct s5h1409_state* state = fe->demodulator_priv; 439 + struct s5h1409_state *state = fe->demodulator_priv; 443 440 444 441 dprintk("%s(%d)\n", __func__, enable); 445 442 ··· 451 448 s5h1409_readreg(state, 0xe3) & 0xfeff); 452 449 } 453 450 454 - static int s5h1409_sleep(struct dvb_frontend* fe, int enable) 451 + static int s5h1409_sleep(struct dvb_frontend *fe, int enable) 455 452 { 456 - struct s5h1409_state* state = fe->demodulator_priv; 453 + struct s5h1409_state *state = fe->demodulator_priv; 457 454 458 455 dprintk("%s(%d)\n", __func__, enable); 459 456 460 457 return s5h1409_writereg(state, 0xf2, enable); 461 458 } 462 459 463 - static int s5h1409_register_reset(struct dvb_frontend* fe) 460 + static int s5h1409_register_reset(struct dvb_frontend *fe) 464 461 { 465 - struct s5h1409_state* state = fe->demodulator_priv; 462 + struct s5h1409_state *state = fe->demodulator_priv; 466 463 467 464 dprintk("%s()\n", __func__); 468 465 ··· 486 483 reg &= 0xff; 487 484 488 485 s5h1409_writereg(state, 0x96, 0x00c); 489 - if ((reg < 0x38) || (reg > 0x68) ) { 486 + if ((reg < 0x38) || (reg > 0x68)) { 490 487 s5h1409_writereg(state, 0x93, 0x3332); 491 488 s5h1409_writereg(state, 0x9e, 0x2c37); 492 489 } else { ··· 517 514 518 515 s5h1409_writereg(state, 0x96, 0x20); 519 516 s5h1409_writereg(state, 0xad, 520 - ( ((reg1 & 0xf000) >> 4) | (reg2 & 0xf0ff)) ); 517 + (((reg1 & 0xf000) >> 4) | (reg2 & 0xf0ff))); 521 518 s5h1409_writereg(state, 0xab, 522 519 s5h1409_readreg(state, 0xab) & 0xeffe); 523 520 } ··· 532 529 } 533 530 534 531 /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ 535 - static int s5h1409_set_frontend (struct dvb_frontend* fe, 532 + static int s5h1409_set_frontend(struct dvb_frontend *fe, 536 533 struct dvb_frontend_parameters *p) 537 534 { 538 - struct s5h1409_state* state = fe->demodulator_priv; 535 + struct s5h1409_state *state = fe->demodulator_priv; 539 536 540 537 dprintk("%s(frequency=%d)\n", __func__, p->frequency); 541 538 ··· 549 546 msleep(100); 550 547 551 548 if (fe->ops.tuner_ops.set_params) { 552 - if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); 549 + if (fe->ops.i2c_gate_ctrl) 550 + fe->ops.i2c_gate_ctrl(fe, 1); 553 551 fe->ops.tuner_ops.set_params(fe, p); 554 - if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); 552 + if (fe->ops.i2c_gate_ctrl) 553 + fe->ops.i2c_gate_ctrl(fe, 0); 555 554 } 556 555 557 556 /* Optimize the demod for QAM */ ··· 597 592 598 593 /* Reset the demod hardware and reset all of the configuration registers 599 594 to a default state. */ 600 - static int s5h1409_init (struct dvb_frontend* fe) 595 + static int s5h1409_init(struct dvb_frontend *fe) 601 596 { 602 597 int i; 603 598 604 - struct s5h1409_state* state = fe->demodulator_priv; 599 + struct s5h1409_state *state = fe->demodulator_priv; 605 600 dprintk("%s()\n", __func__); 606 601 607 602 s5h1409_sleep(fe, 0); 608 603 s5h1409_register_reset(fe); 609 604 610 - for (i=0; i < ARRAY_SIZE(init_tab); i++) 605 + for (i = 0; i < ARRAY_SIZE(init_tab); i++) 611 606 s5h1409_writereg(state, init_tab[i].reg, init_tab[i].data); 612 607 613 608 /* The datasheet says that after initialisation, VSB is default */ ··· 632 627 return 0; 633 628 } 634 629 635 - static int s5h1409_read_status(struct dvb_frontend* fe, fe_status_t* status) 630 + static int s5h1409_read_status(struct dvb_frontend *fe, fe_status_t *status) 636 631 { 637 - struct s5h1409_state* state = fe->demodulator_priv; 632 + struct s5h1409_state *state = fe->demodulator_priv; 638 633 u16 reg; 639 634 u32 tuner_status = 0; 640 635 ··· 642 637 643 638 /* Get the demodulator status */ 644 639 reg = s5h1409_readreg(state, 0xf1); 645 - if(reg & 0x1000) 640 + if (reg & 0x1000) 646 641 *status |= FE_HAS_VITERBI; 647 - if(reg & 0x8000) 642 + if (reg & 0x8000) 648 643 *status |= FE_HAS_LOCK | FE_HAS_SYNC; 649 644 650 - switch(state->config->status_mode) { 645 + switch (state->config->status_mode) { 651 646 case S5H1409_DEMODLOCKING: 652 647 if (*status & FE_HAS_VITERBI) 653 648 *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; ··· 673 668 return 0; 674 669 } 675 670 676 - static int s5h1409_qam256_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) 671 + static int s5h1409_qam256_lookup_snr(struct dvb_frontend *fe, u16 *snr, u16 v) 677 672 { 678 673 int i, ret = -EINVAL; 679 674 dprintk("%s()\n", __func__); 680 675 681 - for (i=0; i < ARRAY_SIZE(qam256_snr_tab); i++) { 676 + for (i = 0; i < ARRAY_SIZE(qam256_snr_tab); i++) { 682 677 if (v < qam256_snr_tab[i].val) { 683 678 *snr = qam256_snr_tab[i].data; 684 679 ret = 0; ··· 688 683 return ret; 689 684 } 690 685 691 - static int s5h1409_qam64_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) 686 + static int s5h1409_qam64_lookup_snr(struct dvb_frontend *fe, u16 *snr, u16 v) 692 687 { 693 688 int i, ret = -EINVAL; 694 689 dprintk("%s()\n", __func__); 695 690 696 - for (i=0; i < ARRAY_SIZE(qam64_snr_tab); i++) { 691 + for (i = 0; i < ARRAY_SIZE(qam64_snr_tab); i++) { 697 692 if (v < qam64_snr_tab[i].val) { 698 693 *snr = qam64_snr_tab[i].data; 699 694 ret = 0; ··· 703 698 return ret; 704 699 } 705 700 706 - static int s5h1409_vsb_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) 701 + static int s5h1409_vsb_lookup_snr(struct dvb_frontend *fe, u16 *snr, u16 v) 707 702 { 708 703 int i, ret = -EINVAL; 709 704 dprintk("%s()\n", __func__); 710 705 711 - for (i=0; i < ARRAY_SIZE(vsb_snr_tab); i++) { 706 + for (i = 0; i < ARRAY_SIZE(vsb_snr_tab); i++) { 712 707 if (v > vsb_snr_tab[i].val) { 713 708 *snr = vsb_snr_tab[i].data; 714 709 ret = 0; ··· 719 714 return ret; 720 715 } 721 716 722 - static int s5h1409_read_snr(struct dvb_frontend* fe, u16* snr) 717 + static int s5h1409_read_snr(struct dvb_frontend *fe, u16 *snr) 723 718 { 724 - struct s5h1409_state* state = fe->demodulator_priv; 719 + struct s5h1409_state *state = fe->demodulator_priv; 725 720 u16 reg; 726 721 dprintk("%s()\n", __func__); 727 722 728 - switch(state->current_modulation) { 723 + switch (state->current_modulation) { 729 724 case QAM_64: 730 725 reg = s5h1409_readreg(state, 0xf0) & 0xff; 731 726 return s5h1409_qam64_lookup_snr(fe, snr, reg); ··· 742 737 return -EINVAL; 743 738 } 744 739 745 - static int s5h1409_read_signal_strength(struct dvb_frontend* fe, 746 - u16* signal_strength) 740 + static int s5h1409_read_signal_strength(struct dvb_frontend *fe, 741 + u16 *signal_strength) 747 742 { 748 743 return s5h1409_read_snr(fe, signal_strength); 749 744 } 750 745 751 - static int s5h1409_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 746 + static int s5h1409_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) 752 747 { 753 - struct s5h1409_state* state = fe->demodulator_priv; 748 + struct s5h1409_state *state = fe->demodulator_priv; 754 749 755 750 *ucblocks = s5h1409_readreg(state, 0xb5); 756 751 757 752 return 0; 758 753 } 759 754 760 - static int s5h1409_read_ber(struct dvb_frontend* fe, u32* ber) 755 + static int s5h1409_read_ber(struct dvb_frontend *fe, u32 *ber) 761 756 { 762 757 return s5h1409_read_ucblocks(fe, ber); 763 758 } 764 759 765 - static int s5h1409_get_frontend(struct dvb_frontend* fe, 760 + static int s5h1409_get_frontend(struct dvb_frontend *fe, 766 761 struct dvb_frontend_parameters *p) 767 762 { 768 - struct s5h1409_state* state = fe->demodulator_priv; 763 + struct s5h1409_state *state = fe->demodulator_priv; 769 764 770 765 p->frequency = state->current_frequency; 771 766 p->u.vsb.modulation = state->current_modulation; ··· 773 768 return 0; 774 769 } 775 770 776 - static int s5h1409_get_tune_settings(struct dvb_frontend* fe, 771 + static int s5h1409_get_tune_settings(struct dvb_frontend *fe, 777 772 struct dvb_frontend_tune_settings *tune) 778 773 { 779 774 tune->min_delay_ms = 1000; 780 775 return 0; 781 776 } 782 777 783 - static void s5h1409_release(struct dvb_frontend* fe) 778 + static void s5h1409_release(struct dvb_frontend *fe) 784 779 { 785 - struct s5h1409_state* state = fe->demodulator_priv; 780 + struct s5h1409_state *state = fe->demodulator_priv; 786 781 kfree(state); 787 782 } 788 783 789 784 static struct dvb_frontend_ops s5h1409_ops; 790 785 791 - struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, 792 - struct i2c_adapter* i2c) 786 + struct dvb_frontend *s5h1409_attach(const struct s5h1409_config *config, 787 + struct i2c_adapter *i2c) 793 788 { 794 - struct s5h1409_state* state = NULL; 789 + struct s5h1409_state *state = NULL; 795 790 u16 reg; 796 791 797 792 /* allocate memory for the internal state */ ··· 830 825 kfree(state); 831 826 return NULL; 832 827 } 828 + EXPORT_SYMBOL(s5h1409_attach); 833 829 834 830 static struct dvb_frontend_ops s5h1409_ops = { 835 831 ··· 856 850 .release = s5h1409_release, 857 851 }; 858 852 859 - module_param(debug, int, 0644); 860 - MODULE_PARM_DESC(debug, "Enable verbose debug messages"); 861 - 862 853 MODULE_DESCRIPTION("Samsung S5H1409 QAM-B/ATSC Demodulator driver"); 863 854 MODULE_AUTHOR("Steven Toth"); 864 855 MODULE_LICENSE("GPL"); 865 856 866 - EXPORT_SYMBOL(s5h1409_attach); 867 857 868 858 /* 869 859 * Local variables:
+8 -7
drivers/media/dvb/frontends/s5h1409.h
··· 24 24 25 25 #include <linux/dvb/frontend.h> 26 26 27 - struct s5h1409_config 28 - { 27 + struct s5h1409_config { 29 28 /* the demodulator's i2c address */ 30 29 u8 demod_address; 31 30 ··· 59 60 u16 mpeg_timing; 60 61 }; 61 62 62 - #if defined(CONFIG_DVB_S5H1409) || (defined(CONFIG_DVB_S5H1409_MODULE) && defined(MODULE)) 63 - extern struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, 64 - struct i2c_adapter* i2c); 63 + #if defined(CONFIG_DVB_S5H1409) || (defined(CONFIG_DVB_S5H1409_MODULE) \ 64 + && defined(MODULE)) 65 + extern struct dvb_frontend *s5h1409_attach(const struct s5h1409_config *config, 66 + struct i2c_adapter *i2c); 65 67 #else 66 - static inline struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, 67 - struct i2c_adapter* i2c) 68 + static inline struct dvb_frontend *s5h1409_attach( 69 + const struct s5h1409_config *config, 70 + struct i2c_adapter *i2c) 68 71 { 69 72 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 70 73 return NULL;
+4 -4
drivers/media/dvb/frontends/s5h1411.c
··· 343 343 u8 addr, u8 reg, u16 data) 344 344 { 345 345 int ret; 346 - u8 buf [] = { reg, data >> 8, data & 0xff }; 346 + u8 buf[] = { reg, data >> 8, data & 0xff }; 347 347 348 348 struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 3 }; 349 349 ··· 359 359 static u16 s5h1411_readreg(struct s5h1411_state *state, u8 addr, u8 reg) 360 360 { 361 361 int ret; 362 - u8 b0 [] = { reg }; 363 - u8 b1 [] = { 0, 0 }; 362 + u8 b0[] = { reg }; 363 + u8 b1[] = { 0, 0 }; 364 364 365 - struct i2c_msg msg [] = { 365 + struct i2c_msg msg[] = { 366 366 { .addr = addr, .flags = 0, .buf = b0, .len = 1 }, 367 367 { .addr = addr, .flags = I2C_M_RD, .buf = b1, .len = 2 } }; 368 368
+73 -27
drivers/media/dvb/frontends/tda10048.c
··· 195 195 static int tda10048_writereg(struct tda10048_state *state, u8 reg, u8 data) 196 196 { 197 197 int ret; 198 - u8 buf [] = { reg, data }; 198 + u8 buf[] = { reg, data }; 199 199 struct i2c_msg msg = { 200 200 .addr = state->config->demod_address, 201 201 .flags = 0, .buf = buf, .len = 2 }; ··· 213 213 static u8 tda10048_readreg(struct tda10048_state *state, u8 reg) 214 214 { 215 215 int ret; 216 - u8 b0 [] = { reg }; 217 - u8 b1 [] = { 0 }; 218 - struct i2c_msg msg [] = { 216 + u8 b0[] = { reg }; 217 + u8 b1[] = { 0 }; 218 + struct i2c_msg msg[] = { 219 219 { .addr = state->config->demod_address, 220 220 .flags = 0, .buf = b0, .len = 1 }, 221 221 { .addr = state->config->demod_address, ··· 393 393 394 394 val = tda10048_readreg(state, TDA10048_OUT_CONF2); 395 395 switch ((val & 0x60) >> 5) { 396 - case 0: p->constellation = QPSK; break; 397 - case 1: p->constellation = QAM_16; break; 398 - case 2: p->constellation = QAM_64; break; 396 + case 0: 397 + p->constellation = QPSK; 398 + break; 399 + case 1: 400 + p->constellation = QAM_16; 401 + break; 402 + case 2: 403 + p->constellation = QAM_64; 404 + break; 399 405 } 400 406 switch ((val & 0x18) >> 3) { 401 - case 0: p->hierarchy_information = HIERARCHY_NONE; break; 402 - case 1: p->hierarchy_information = HIERARCHY_1; break; 403 - case 2: p->hierarchy_information = HIERARCHY_2; break; 404 - case 3: p->hierarchy_information = HIERARCHY_4; break; 407 + case 0: 408 + p->hierarchy_information = HIERARCHY_NONE; 409 + break; 410 + case 1: 411 + p->hierarchy_information = HIERARCHY_1; 412 + break; 413 + case 2: 414 + p->hierarchy_information = HIERARCHY_2; 415 + break; 416 + case 3: 417 + p->hierarchy_information = HIERARCHY_4; 418 + break; 405 419 } 406 420 switch (val & 0x07) { 407 - case 0: p->code_rate_HP = FEC_1_2; break; 408 - case 1: p->code_rate_HP = FEC_2_3; break; 409 - case 2: p->code_rate_HP = FEC_3_4; break; 410 - case 3: p->code_rate_HP = FEC_5_6; break; 411 - case 4: p->code_rate_HP = FEC_7_8; break; 421 + case 0: 422 + p->code_rate_HP = FEC_1_2; 423 + break; 424 + case 1: 425 + p->code_rate_HP = FEC_2_3; 426 + break; 427 + case 2: 428 + p->code_rate_HP = FEC_3_4; 429 + break; 430 + case 3: 431 + p->code_rate_HP = FEC_5_6; 432 + break; 433 + case 4: 434 + p->code_rate_HP = FEC_7_8; 435 + break; 412 436 } 413 437 414 438 val = tda10048_readreg(state, TDA10048_OUT_CONF3); 415 439 switch (val & 0x07) { 416 - case 0: p->code_rate_LP = FEC_1_2; break; 417 - case 1: p->code_rate_LP = FEC_2_3; break; 418 - case 2: p->code_rate_LP = FEC_3_4; break; 419 - case 3: p->code_rate_LP = FEC_5_6; break; 420 - case 4: p->code_rate_LP = FEC_7_8; break; 440 + case 0: 441 + p->code_rate_LP = FEC_1_2; 442 + break; 443 + case 1: 444 + p->code_rate_LP = FEC_2_3; 445 + break; 446 + case 2: 447 + p->code_rate_LP = FEC_3_4; 448 + break; 449 + case 3: 450 + p->code_rate_LP = FEC_5_6; 451 + break; 452 + case 4: 453 + p->code_rate_LP = FEC_7_8; 454 + break; 421 455 } 422 456 423 457 val = tda10048_readreg(state, TDA10048_OUT_CONF1); 424 458 switch ((val & 0x0c) >> 2) { 425 - case 0: p->guard_interval = GUARD_INTERVAL_1_32; break; 426 - case 1: p->guard_interval = GUARD_INTERVAL_1_16; break; 427 - case 2: p->guard_interval = GUARD_INTERVAL_1_8; break; 428 - case 3: p->guard_interval = GUARD_INTERVAL_1_4; break; 459 + case 0: 460 + p->guard_interval = GUARD_INTERVAL_1_32; 461 + break; 462 + case 1: 463 + p->guard_interval = GUARD_INTERVAL_1_16; 464 + break; 465 + case 2: 466 + p->guard_interval = GUARD_INTERVAL_1_8; 467 + break; 468 + case 3: 469 + p->guard_interval = GUARD_INTERVAL_1_4; 470 + break; 429 471 } 430 472 switch (val & 0x02) { 431 - case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break; 432 - case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break; 473 + case 0: 474 + p->transmission_mode = TRANSMISSION_MODE_2K; 475 + break; 476 + case 1: 477 + p->transmission_mode = TRANSMISSION_MODE_8K; 478 + break; 433 479 } 434 480 435 481 return 0;
+2 -14
drivers/media/dvb/frontends/z0194a.h
··· 12 12 #ifndef Z0194A 13 13 #define Z0194A 14 14 15 - static int sharp_z0194a__set_symbol_rate(struct dvb_frontend *fe, 15 + static int sharp_z0194a_set_symbol_rate(struct dvb_frontend *fe, 16 16 u32 srate, u32 ratio) 17 17 { 18 18 u8 aclk = 0; ··· 40 40 return 0; 41 41 } 42 42 43 - static u8 sharp_z0194a__inittab[] = { 43 + static u8 sharp_z0194a_inittab[] = { 44 44 0x01, 0x15, 45 45 0x02, 0x00, 46 46 0x03, 0x00, ··· 80 80 0x34, 0x93, /* error control */ 81 81 0x0f, 0x52, 82 82 0xff, 0xff 83 - }; 84 - 85 - static struct stv0299_config sharp_z0194a_config = { 86 - .demod_address = 0x68, 87 - .inittab = sharp_z0194a__inittab, 88 - .mclk = 88000000UL, 89 - .invert = 1, 90 - .skip_reinit = 0, 91 - .lock_output = STV0299_LOCKOUTPUT_1, 92 - .volt13_op0_op1 = STV0299_VOLT13_OP1, 93 - .min_delay_ms = 100, 94 - .set_symbol_rate = sharp_z0194a__set_symbol_rate, 95 83 }; 96 84 97 85 #endif
+4
drivers/media/dvb/siano/sms-cards.c
··· 42 42 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 43 43 { USB_DEVICE(0x2040, 0x5510), 44 44 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 45 + { USB_DEVICE(0x2040, 0x5520), 46 + .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 47 + { USB_DEVICE(0x2040, 0x5530), 48 + .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 45 49 { USB_DEVICE(0x2040, 0x5580), 46 50 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 47 51 { USB_DEVICE(0x2040, 0x5590),
+1 -1
drivers/media/radio/Kconfig
··· 359 359 computer's USB port. 360 360 361 361 To compile this driver as a module, choose M here: the 362 - module will be called radio-silabs. 362 + module will be called radio-si470x. 363 363 364 364 config USB_MR800 365 365 tristate "AverMedia MR 800 USB FM radio support"
+99 -139
drivers/media/radio/radio-si470x.c
··· 104 104 * - hardware frequency seek support 105 105 * - afc indication 106 106 * - more safety checks, let si470x_get_freq return errno 107 + * - vidioc behavior corrected according to v4l2 spec 107 108 * 108 109 * ToDo: 109 110 * - add firmware download/update support ··· 142 141 /* USB Device ID List */ 143 142 static struct usb_device_id si470x_usb_driver_id_table[] = { 144 143 /* Silicon Labs USB FM Radio Reference Design */ 145 - { USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) }, 144 + { USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) }, 146 145 /* ADS/Tech FM Radio Receiver (formerly Instant FM Music) */ 147 - { USB_DEVICE_AND_INTERFACE_INFO(0x06e1, 0xa155, USB_CLASS_HID, 0, 0) }, 146 + { USB_DEVICE_AND_INTERFACE_INFO(0x06e1, 0xa155, USB_CLASS_HID, 0, 0) }, 148 147 /* Terminating entry */ 149 148 { } 150 149 }; ··· 158 157 159 158 /* Radio Nr */ 160 159 static int radio_nr = -1; 161 - module_param(radio_nr, int, 0); 160 + module_param(radio_nr, int, 0444); 162 161 MODULE_PARM_DESC(radio_nr, "Radio Nr"); 163 162 164 163 /* Spacing (kHz) */ ··· 166 165 /* 1: 100 kHz (Europe, Japan) */ 167 166 /* 2: 50 kHz */ 168 167 static unsigned short space = 2; 169 - module_param(space, ushort, 0); 170 - MODULE_PARM_DESC(radio_nr, "Spacing: 0=200kHz 1=100kHz *2=50kHz*"); 168 + module_param(space, ushort, 0444); 169 + MODULE_PARM_DESC(space, "Spacing: 0=200kHz 1=100kHz *2=50kHz*"); 171 170 172 171 /* Bottom of Band (MHz) */ 173 172 /* 0: 87.5 - 108 MHz (USA, Europe)*/ 174 173 /* 1: 76 - 108 MHz (Japan wide band) */ 175 174 /* 2: 76 - 90 MHz (Japan) */ 176 175 static unsigned short band = 1; 177 - module_param(band, ushort, 0); 178 - MODULE_PARM_DESC(radio_nr, "Band: 0=87.5..108MHz *1=76..108MHz* 2=76..90MHz"); 176 + module_param(band, ushort, 0444); 177 + MODULE_PARM_DESC(band, "Band: 0=87.5..108MHz *1=76..108MHz* 2=76..90MHz"); 179 178 180 179 /* De-emphasis */ 181 180 /* 0: 75 us (USA) */ 182 181 /* 1: 50 us (Europe, Australia, Japan) */ 183 182 static unsigned short de = 1; 184 - module_param(de, ushort, 0); 185 - MODULE_PARM_DESC(radio_nr, "De-emphasis: 0=75us *1=50us*"); 183 + module_param(de, ushort, 0444); 184 + MODULE_PARM_DESC(de, "De-emphasis: 0=75us *1=50us*"); 186 185 187 186 /* USB timeout */ 188 187 static unsigned int usb_timeout = 500; 189 - module_param(usb_timeout, uint, 0); 188 + module_param(usb_timeout, uint, 0644); 190 189 MODULE_PARM_DESC(usb_timeout, "USB timeout (ms): *500*"); 191 190 192 191 /* Tune timeout */ 193 192 static unsigned int tune_timeout = 3000; 194 - module_param(tune_timeout, uint, 0); 193 + module_param(tune_timeout, uint, 0644); 195 194 MODULE_PARM_DESC(tune_timeout, "Tune timeout: *3000*"); 196 195 197 196 /* Seek timeout */ 198 197 static unsigned int seek_timeout = 5000; 199 - module_param(seek_timeout, uint, 0); 198 + module_param(seek_timeout, uint, 0644); 200 199 MODULE_PARM_DESC(seek_timeout, "Seek timeout: *5000*"); 201 200 202 201 /* RDS buffer blocks */ 203 202 static unsigned int rds_buf = 100; 204 - module_param(rds_buf, uint, 0); 203 + module_param(rds_buf, uint, 0444); 205 204 MODULE_PARM_DESC(rds_buf, "RDS buffer entries: *100*"); 206 205 207 206 /* RDS maximum block errors */ ··· 210 209 /* 1 means 1-2 errors requiring correction (used by original USBRadio.exe) */ 211 210 /* 2 means 3-5 errors requiring correction */ 212 211 /* 3 means 6+ errors or errors in checkword, correction not possible */ 213 - module_param(max_rds_errors, ushort, 0); 212 + module_param(max_rds_errors, ushort, 0644); 214 213 MODULE_PARM_DESC(max_rds_errors, "RDS maximum block errors: *1*"); 215 214 216 215 /* RDS poll frequency */ ··· 219 218 /* 50 is used by radio-cadet */ 220 219 /* 75 should be okay */ 221 220 /* 80 is the usual RDS receive interval */ 222 - module_param(rds_poll_time, uint, 0); 221 + module_param(rds_poll_time, uint, 0644); 223 222 MODULE_PARM_DESC(rds_poll_time, "RDS poll time (ms): *40*"); 224 223 225 224 ··· 668 667 int retval; 669 668 670 669 /* Spacing (kHz) */ 671 - switch (space) { 670 + switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_SPACE) >> 4) { 672 671 /* 0: 200 kHz (USA, Australia) */ 673 - case 0 : spacing = 0.200 * FREQ_MUL; break; 672 + case 0: 673 + spacing = 0.200 * FREQ_MUL; break; 674 674 /* 1: 100 kHz (Europe, Japan) */ 675 - case 1 : spacing = 0.100 * FREQ_MUL; break; 675 + case 1: 676 + spacing = 0.100 * FREQ_MUL; break; 676 677 /* 2: 50 kHz */ 677 - default: spacing = 0.050 * FREQ_MUL; break; 678 + default: 679 + spacing = 0.050 * FREQ_MUL; break; 678 680 }; 679 681 680 682 /* Bottom of Band (MHz) */ 681 - switch (band) { 683 + switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { 682 684 /* 0: 87.5 - 108 MHz (USA, Europe) */ 683 - case 0 : band_bottom = 87.5 * FREQ_MUL; break; 685 + case 0: 686 + band_bottom = 87.5 * FREQ_MUL; break; 684 687 /* 1: 76 - 108 MHz (Japan wide band) */ 685 - default: band_bottom = 76 * FREQ_MUL; break; 688 + default: 689 + band_bottom = 76 * FREQ_MUL; break; 686 690 /* 2: 76 - 90 MHz (Japan) */ 687 - case 2 : band_bottom = 76 * FREQ_MUL; break; 691 + case 2: 692 + band_bottom = 76 * FREQ_MUL; break; 688 693 }; 689 694 690 695 /* read channel */ ··· 713 706 unsigned short chan; 714 707 715 708 /* Spacing (kHz) */ 716 - switch (space) { 709 + switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_SPACE) >> 4) { 717 710 /* 0: 200 kHz (USA, Australia) */ 718 - case 0 : spacing = 0.200 * FREQ_MUL; break; 711 + case 0: 712 + spacing = 0.200 * FREQ_MUL; break; 719 713 /* 1: 100 kHz (Europe, Japan) */ 720 - case 1 : spacing = 0.100 * FREQ_MUL; break; 714 + case 1: 715 + spacing = 0.100 * FREQ_MUL; break; 721 716 /* 2: 50 kHz */ 722 - default: spacing = 0.050 * FREQ_MUL; break; 717 + default: 718 + spacing = 0.050 * FREQ_MUL; break; 723 719 }; 724 720 725 721 /* Bottom of Band (MHz) */ 726 - switch (band) { 722 + switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { 727 723 /* 0: 87.5 - 108 MHz (USA, Europe) */ 728 - case 0 : band_bottom = 87.5 * FREQ_MUL; break; 724 + case 0: 725 + band_bottom = 87.5 * FREQ_MUL; break; 729 726 /* 1: 76 - 108 MHz (Japan wide band) */ 730 - default: band_bottom = 76 * FREQ_MUL; break; 727 + default: 728 + band_bottom = 76 * FREQ_MUL; break; 731 729 /* 2: 76 - 90 MHz (Japan) */ 732 - case 2 : band_bottom = 76 * FREQ_MUL; break; 730 + case 2: 731 + band_bottom = 76 * FREQ_MUL; break; 733 732 }; 734 733 735 734 /* Chan = [ Freq (Mhz) - Bottom of Band (MHz) ] / Spacing (kHz) */ ··· 1177 1164 * si470x_v4l2_queryctrl - query control 1178 1165 */ 1179 1166 static struct v4l2_queryctrl si470x_v4l2_queryctrl[] = { 1180 - /* HINT: the disabled controls are only here to satify kradio and such apps */ 1181 1167 { 1182 1168 .id = V4L2_CID_AUDIO_VOLUME, 1183 1169 .type = V4L2_CTRL_TYPE_INTEGER, ··· 1187 1175 .default_value = 15, 1188 1176 }, 1189 1177 { 1190 - .id = V4L2_CID_AUDIO_BALANCE, 1191 - .flags = V4L2_CTRL_FLAG_DISABLED, 1192 - }, 1193 - { 1194 - .id = V4L2_CID_AUDIO_BASS, 1195 - .flags = V4L2_CTRL_FLAG_DISABLED, 1196 - }, 1197 - { 1198 - .id = V4L2_CID_AUDIO_TREBLE, 1199 - .flags = V4L2_CTRL_FLAG_DISABLED, 1200 - }, 1201 - { 1202 1178 .id = V4L2_CID_AUDIO_MUTE, 1203 1179 .type = V4L2_CTRL_TYPE_BOOLEAN, 1204 1180 .name = "Mute", ··· 1194 1194 .maximum = 1, 1195 1195 .step = 1, 1196 1196 .default_value = 1, 1197 - }, 1198 - { 1199 - .id = V4L2_CID_AUDIO_LOUDNESS, 1200 - .flags = V4L2_CTRL_FLAG_DISABLED, 1201 1197 }, 1202 1198 }; 1203 1199 ··· 1216 1220 1217 1221 1218 1222 /* 1219 - * si470x_vidioc_g_input - get input 1220 - */ 1221 - static int si470x_vidioc_g_input(struct file *file, void *priv, 1222 - unsigned int *i) 1223 - { 1224 - *i = 0; 1225 - 1226 - return 0; 1227 - } 1228 - 1229 - 1230 - /* 1231 - * si470x_vidioc_s_input - set input 1232 - */ 1233 - static int si470x_vidioc_s_input(struct file *file, void *priv, unsigned int i) 1234 - { 1235 - int retval = 0; 1236 - 1237 - /* safety checks */ 1238 - if (i != 0) 1239 - retval = -EINVAL; 1240 - 1241 - if (retval < 0) 1242 - printk(KERN_WARNING DRIVER_NAME 1243 - ": set input failed with %d\n", retval); 1244 - return retval; 1245 - } 1246 - 1247 - 1248 - /* 1249 1223 * si470x_vidioc_queryctrl - enumerate control items 1250 1224 */ 1251 1225 static int si470x_vidioc_queryctrl(struct file *file, void *priv, 1252 1226 struct v4l2_queryctrl *qc) 1253 1227 { 1254 - unsigned char i; 1228 + unsigned char i = 0; 1255 1229 int retval = -EINVAL; 1256 1230 1257 - /* safety checks */ 1258 - if (!qc->id) 1231 + /* abort if qc->id is below V4L2_CID_BASE */ 1232 + if (qc->id < V4L2_CID_BASE) 1259 1233 goto done; 1260 1234 1235 + /* search video control */ 1261 1236 for (i = 0; i < ARRAY_SIZE(si470x_v4l2_queryctrl); i++) { 1262 1237 if (qc->id == si470x_v4l2_queryctrl[i].id) { 1263 1238 memcpy(qc, &(si470x_v4l2_queryctrl[i]), sizeof(*qc)); 1264 - retval = 0; 1239 + retval = 0; /* found */ 1265 1240 break; 1266 1241 } 1242 + } 1243 + 1244 + /* disable unsupported base controls */ 1245 + /* to satisfy kradio and such apps */ 1246 + if ((retval == -EINVAL) && (qc->id < V4L2_CID_LASTP1)) { 1247 + qc->flags = V4L2_CTRL_FLAG_DISABLED; 1248 + retval = 0; 1267 1249 } 1268 1250 1269 1251 done: ··· 1334 1360 static int si470x_vidioc_g_audio(struct file *file, void *priv, 1335 1361 struct v4l2_audio *audio) 1336 1362 { 1337 - int retval = 0; 1338 - 1339 - /* safety checks */ 1340 - if (audio->index != 0) { 1341 - retval = -EINVAL; 1342 - goto done; 1343 - } 1344 - 1363 + /* driver constants */ 1364 + audio->index = 0; 1345 1365 strcpy(audio->name, "Radio"); 1346 1366 audio->capability = V4L2_AUDCAP_STEREO; 1367 + audio->mode = 0; 1347 1368 1348 - done: 1349 - if (retval < 0) 1350 - printk(KERN_WARNING DRIVER_NAME 1351 - ": get audio failed with %d\n", retval); 1352 - return retval; 1353 - } 1354 - 1355 - 1356 - /* 1357 - * si470x_vidioc_s_audio - set audio attributes 1358 - */ 1359 - static int si470x_vidioc_s_audio(struct file *file, void *priv, 1360 - struct v4l2_audio *audio) 1361 - { 1362 - int retval = 0; 1363 - 1364 - /* safety checks */ 1365 - if (audio->index != 0) { 1366 - retval = -EINVAL; 1367 - goto done; 1368 - } 1369 - 1370 - done: 1371 - if (retval < 0) 1372 - printk(KERN_WARNING DRIVER_NAME 1373 - ": set audio failed with %d\n", retval); 1374 - return retval; 1369 + return 0; 1375 1370 } 1376 1371 1377 1372 ··· 1358 1415 retval = -EIO; 1359 1416 goto done; 1360 1417 } 1361 - if ((tuner->index != 0) && (tuner->type != V4L2_TUNER_RADIO)) { 1418 + if (tuner->index != 0) { 1362 1419 retval = -EINVAL; 1363 1420 goto done; 1364 1421 } ··· 1367 1424 if (retval < 0) 1368 1425 goto done; 1369 1426 1427 + /* driver constants */ 1370 1428 strcpy(tuner->name, "FM"); 1371 - switch (band) { 1429 + tuner->type = V4L2_TUNER_RADIO; 1430 + tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; 1431 + 1432 + /* range limits */ 1433 + switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { 1372 1434 /* 0: 87.5 - 108 MHz (USA, Europe, default) */ 1373 1435 default: 1374 1436 tuner->rangelow = 87.5 * FREQ_MUL; ··· 1390 1442 tuner->rangehigh = 90 * FREQ_MUL; 1391 1443 break; 1392 1444 }; 1393 - tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; 1394 - tuner->capability = V4L2_TUNER_CAP_LOW; 1395 1445 1396 - /* Stereo indicator == Stereo (instead of Mono) */ 1446 + /* stereo indicator == stereo (instead of mono) */ 1397 1447 if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 1) 1398 - tuner->audmode = V4L2_TUNER_MODE_STEREO; 1448 + tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; 1399 1449 else 1450 + tuner->rxsubchans = V4L2_TUNER_SUB_MONO; 1451 + 1452 + /* mono/stereo selector */ 1453 + if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 1) 1400 1454 tuner->audmode = V4L2_TUNER_MODE_MONO; 1455 + else 1456 + tuner->audmode = V4L2_TUNER_MODE_STEREO; 1401 1457 1402 1458 /* min is worst, max is best; signal:0..0xffff; rssi: 0..0xff */ 1403 1459 tuner->signal = (radio->registers[STATUSRSSI] & STATUSRSSI_RSSI) ··· 1426 1474 struct v4l2_tuner *tuner) 1427 1475 { 1428 1476 struct si470x_device *radio = video_drvdata(file); 1429 - int retval = 0; 1477 + int retval = -EINVAL; 1430 1478 1431 1479 /* safety checks */ 1432 1480 if (radio->disconnected) { 1433 1481 retval = -EIO; 1434 1482 goto done; 1435 1483 } 1436 - if ((tuner->index != 0) && (tuner->type != V4L2_TUNER_RADIO)) { 1437 - retval = -EINVAL; 1484 + if (tuner->index != 0) 1485 + goto done; 1486 + 1487 + /* mono/stereo selector */ 1488 + switch (tuner->audmode) { 1489 + case V4L2_TUNER_MODE_MONO: 1490 + radio->registers[POWERCFG] |= POWERCFG_MONO; /* force mono */ 1491 + break; 1492 + case V4L2_TUNER_MODE_STEREO: 1493 + radio->registers[POWERCFG] &= ~POWERCFG_MONO; /* try stereo */ 1494 + break; 1495 + default: 1438 1496 goto done; 1439 1497 } 1440 - 1441 - if (tuner->audmode == V4L2_TUNER_MODE_MONO) 1442 - radio->registers[POWERCFG] |= POWERCFG_MONO; /* force mono */ 1443 - else 1444 - radio->registers[POWERCFG] &= ~POWERCFG_MONO; /* try stereo */ 1445 1498 1446 1499 retval = si470x_set_register(radio, POWERCFG); 1447 1500 ··· 1472 1515 retval = -EIO; 1473 1516 goto done; 1474 1517 } 1475 - if ((freq->tuner != 0) && (freq->type != V4L2_TUNER_RADIO)) { 1518 + if (freq->tuner != 0) { 1476 1519 retval = -EINVAL; 1477 1520 goto done; 1478 1521 } 1479 1522 1523 + freq->type = V4L2_TUNER_RADIO; 1480 1524 retval = si470x_get_freq(radio, &freq->frequency); 1481 1525 1482 1526 done: ··· 1502 1544 retval = -EIO; 1503 1545 goto done; 1504 1546 } 1505 - if ((freq->tuner != 0) && (freq->type != V4L2_TUNER_RADIO)) { 1547 + if (freq->tuner != 0) { 1506 1548 retval = -EINVAL; 1507 1549 goto done; 1508 1550 } ··· 1531 1573 retval = -EIO; 1532 1574 goto done; 1533 1575 } 1534 - if ((seek->tuner != 0) && (seek->type != V4L2_TUNER_RADIO)) { 1576 + if (seek->tuner != 0) { 1535 1577 retval = -EINVAL; 1536 1578 goto done; 1537 1579 } ··· 1546 1588 return retval; 1547 1589 } 1548 1590 1591 + 1592 + /* 1593 + * si470x_ioctl_ops - video device ioctl operations 1594 + */ 1549 1595 static const struct v4l2_ioctl_ops si470x_ioctl_ops = { 1550 1596 .vidioc_querycap = si470x_vidioc_querycap, 1551 - .vidioc_g_input = si470x_vidioc_g_input, 1552 - .vidioc_s_input = si470x_vidioc_s_input, 1553 1597 .vidioc_queryctrl = si470x_vidioc_queryctrl, 1554 1598 .vidioc_g_ctrl = si470x_vidioc_g_ctrl, 1555 1599 .vidioc_s_ctrl = si470x_vidioc_s_ctrl, 1556 1600 .vidioc_g_audio = si470x_vidioc_g_audio, 1557 - .vidioc_s_audio = si470x_vidioc_s_audio, 1558 1601 .vidioc_g_tuner = si470x_vidioc_g_tuner, 1559 1602 .vidioc_s_tuner = si470x_vidioc_s_tuner, 1560 1603 .vidioc_g_frequency = si470x_vidioc_g_frequency, ··· 1563 1604 .vidioc_s_hw_freq_seek = si470x_vidioc_s_hw_freq_seek, 1564 1605 }; 1565 1606 1607 + 1566 1608 /* 1567 - * si470x_viddev_tamples - video device interface 1609 + * si470x_viddev_template - video device interface 1568 1610 */ 1569 1611 static struct video_device si470x_viddev_template = { 1570 1612 .fops = &si470x_fops, 1571 - .ioctl_ops = &si470x_ioctl_ops, 1572 1613 .name = DRIVER_NAME, 1573 1614 .release = video_device_release, 1615 + .ioctl_ops = &si470x_ioctl_ops, 1574 1616 }; 1575 1617 1576 1618
+58 -195
drivers/media/video/adv7170.c
··· 29 29 */ 30 30 31 31 #include <linux/module.h> 32 - #include <linux/init.h> 33 - #include <linux/delay.h> 34 - #include <linux/errno.h> 35 - #include <linux/fs.h> 36 - #include <linux/kernel.h> 37 - #include <linux/major.h> 38 - #include <linux/slab.h> 39 - #include <linux/mm.h> 40 - #include <linux/signal.h> 41 32 #include <linux/types.h> 42 - #include <linux/i2c.h> 43 - #include <asm/io.h> 44 - #include <asm/pgtable.h> 45 - #include <asm/page.h> 33 + #include <linux/ioctl.h> 46 34 #include <asm/uaccess.h> 47 - 35 + #include <linux/i2c.h> 36 + #include <linux/i2c-id.h> 48 37 #include <linux/videodev.h> 49 38 #include <linux/video_encoder.h> 39 + #include <media/v4l2-common.h> 40 + #include <media/v4l2-i2c-drv-legacy.h> 50 41 51 42 MODULE_DESCRIPTION("Analog Devices ADV7170 video encoder driver"); 52 43 MODULE_AUTHOR("Maxim Yevtyushkin"); 53 44 MODULE_LICENSE("GPL"); 54 45 55 - 56 - #define I2C_NAME(x) (x)->name 57 - 58 - 59 46 static int debug; 60 47 module_param(debug, int, 0); 61 48 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 62 - 63 - #define dprintk(num, format, args...) \ 64 - do { \ 65 - if (debug >= num) \ 66 - printk(format, ##args); \ 67 - } while (0) 68 49 69 50 /* ----------------------------------------------------------------------- */ 70 51 ··· 61 80 int sat; 62 81 }; 63 82 64 - #define I2C_ADV7170 0xd4 65 - #define I2C_ADV7171 0x54 66 - 67 - static char adv7170_name[] = "adv7170"; 68 - static char adv7171_name[] = "adv7171"; 69 - 70 83 static char *inputs[] = { "pass_through", "play_back" }; 71 84 static char *norms[] = { "PAL", "NTSC" }; 72 85 73 86 /* ----------------------------------------------------------------------- */ 74 87 75 - static inline int 76 - adv7170_write (struct i2c_client *client, 77 - u8 reg, 78 - u8 value) 88 + static inline int adv7170_write(struct i2c_client *client, u8 reg, u8 value) 79 89 { 80 90 struct adv7170 *encoder = i2c_get_clientdata(client); 81 91 ··· 74 102 return i2c_smbus_write_byte_data(client, reg, value); 75 103 } 76 104 77 - static inline int 78 - adv7170_read (struct i2c_client *client, 79 - u8 reg) 105 + static inline int adv7170_read(struct i2c_client *client, u8 reg) 80 106 { 81 107 return i2c_smbus_read_byte_data(client, reg); 82 108 } 83 109 84 - static int 85 - adv7170_write_block (struct i2c_client *client, 86 - const u8 *data, 87 - unsigned int len) 110 + static int adv7170_write_block(struct i2c_client *client, 111 + const u8 *data, unsigned int len) 88 112 { 89 113 int ret = -1; 90 114 u8 reg; ··· 101 133 encoder->reg[reg++] = data[1]; 102 134 len -= 2; 103 135 data += 2; 104 - } while (len >= 2 && data[0] == reg && 105 - block_len < 32); 106 - if ((ret = i2c_master_send(client, block_data, 107 - block_len)) < 0) 136 + } while (len >= 2 && data[0] == reg && block_len < 32); 137 + ret = i2c_master_send(client, block_data, block_len); 138 + if (ret < 0) 108 139 break; 109 140 } 110 141 } else { 111 142 /* do some slow I2C emulation kind of thing */ 112 143 while (len >= 2) { 113 144 reg = *data++; 114 - if ((ret = adv7170_write(client, reg, 115 - *data++)) < 0) 145 + ret = adv7170_write(client, reg, *data++); 146 + if (ret < 0) 116 147 break; 117 148 len -= 2; 118 149 } 119 150 } 120 - 121 151 return ret; 122 152 } 123 153 124 154 /* ----------------------------------------------------------------------- */ 125 - // Output filter: S-Video Composite 126 - 127 - #define MR050 0x11 //0x09 128 - #define MR060 0x14 //0x0c 129 - 130 - //--------------------------------------------------------------------------- 131 155 132 156 #define TR0MODE 0x4c 133 157 #define TR0RST 0x80 134 158 135 159 #define TR1CAPT 0x00 136 160 #define TR1PLAY 0x00 137 - 138 161 139 162 static const unsigned char init_NTSC[] = { 140 163 0x00, 0x10, // MR0 ··· 186 227 }; 187 228 188 229 189 - static int 190 - adv7170_command (struct i2c_client *client, 191 - unsigned int cmd, 192 - void * arg) 230 + static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg) 193 231 { 194 232 struct adv7170 *encoder = i2c_get_clientdata(client); 195 233 196 234 switch (cmd) { 197 - 198 235 case 0: 199 236 #if 0 200 237 /* This is just for testing!!! */ ··· 209 254 VIDEO_ENCODER_NTSC; 210 255 cap->inputs = 2; 211 256 cap->outputs = 1; 212 - } 213 257 break; 258 + } 214 259 215 260 case ENCODER_SET_NORM: 216 261 { 217 262 int iarg = *(int *) arg; 218 263 219 - dprintk(1, KERN_DEBUG "%s_command: set norm %d", 220 - I2C_NAME(client), iarg); 264 + v4l_dbg(1, debug, client, "set norm %d\n", iarg); 221 265 222 266 switch (iarg) { 223 - 224 267 case VIDEO_MODE_NTSC: 225 268 adv7170_write_block(client, init_NTSC, 226 269 sizeof(init_NTSC)); ··· 238 285 break; 239 286 240 287 default: 241 - dprintk(1, KERN_ERR "%s: illegal norm: %d\n", 242 - I2C_NAME(client), iarg); 288 + v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg); 243 289 return -EINVAL; 244 - 245 290 } 246 - dprintk(1, KERN_DEBUG "%s: switched to %s\n", I2C_NAME(client), 247 - norms[iarg]); 291 + v4l_dbg(1, debug, client, "switched to %s\n", norms[iarg]); 248 292 encoder->norm = iarg; 249 - } 250 293 break; 294 + } 251 295 252 296 case ENCODER_SET_INPUT: 253 297 { ··· 254 304 *iarg = 1: input is from ZR36060 255 305 *iarg = 2: color bar */ 256 306 257 - dprintk(1, KERN_DEBUG "%s_command: set input from %s\n", 258 - I2C_NAME(client), 307 + v4l_dbg(1, debug, client, "set input from %s\n", 259 308 iarg == 0 ? "decoder" : "ZR36060"); 260 309 261 310 switch (iarg) { 262 - 263 311 case 0: 264 312 adv7170_write(client, 0x01, 0x20); 265 313 adv7170_write(client, 0x08, TR1CAPT); /* TR1 */ 266 314 adv7170_write(client, 0x02, 0x0e); // Enable genlock 267 315 adv7170_write(client, 0x07, TR0MODE | TR0RST); 268 316 adv7170_write(client, 0x07, TR0MODE); 269 - //udelay(10); 317 + /* udelay(10); */ 270 318 break; 271 319 272 320 case 1: ··· 273 325 adv7170_write(client, 0x02, 0x08); 274 326 adv7170_write(client, 0x07, TR0MODE | TR0RST); 275 327 adv7170_write(client, 0x07, TR0MODE); 276 - //udelay(10); 328 + /* udelay(10); */ 277 329 break; 278 330 279 331 default: 280 - dprintk(1, KERN_ERR "%s: illegal input: %d\n", 281 - I2C_NAME(client), iarg); 332 + v4l_dbg(1, debug, client, "illegal input: %d\n", iarg); 282 333 return -EINVAL; 283 - 284 334 } 285 - dprintk(1, KERN_DEBUG "%s: switched to %s\n", I2C_NAME(client), 286 - inputs[iarg]); 335 + v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]); 287 336 encoder->input = iarg; 288 - } 289 337 break; 338 + } 290 339 291 340 case ENCODER_SET_OUTPUT: 292 341 { ··· 293 348 if (*iarg != 0) { 294 349 return -EINVAL; 295 350 } 296 - } 297 351 break; 352 + } 298 353 299 354 case ENCODER_ENABLE_OUTPUT: 300 355 { 301 356 int *iarg = arg; 302 357 303 358 encoder->enable = !!*iarg; 304 - } 305 359 break; 360 + } 306 361 307 362 default: 308 363 return -EINVAL; ··· 313 368 314 369 /* ----------------------------------------------------------------------- */ 315 370 316 - /* 317 - * Generic i2c probe 318 - * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 319 - */ 320 - static unsigned short normal_i2c[] = 321 - { I2C_ADV7170 >> 1, (I2C_ADV7170 >> 1) + 1, 322 - I2C_ADV7171 >> 1, (I2C_ADV7171 >> 1) + 1, 371 + static unsigned short normal_i2c[] = { 372 + 0xd4 >> 1, 0xd6 >> 1, /* adv7170 IDs */ 373 + 0x54 >> 1, 0x56 >> 1, /* adv7171 IDs */ 323 374 I2C_CLIENT_END 324 375 }; 325 376 326 - static unsigned short ignore = I2C_CLIENT_END; 377 + I2C_CLIENT_INSMOD; 327 378 328 - static struct i2c_client_address_data addr_data = { 329 - .normal_i2c = normal_i2c, 330 - .probe = &ignore, 331 - .ignore = &ignore, 332 - }; 333 - 334 - static struct i2c_driver i2c_driver_adv7170; 335 - 336 - static int 337 - adv7170_detect_client (struct i2c_adapter *adapter, 338 - int address, 339 - int kind) 379 + static int adv7170_probe(struct i2c_client *client, 380 + const struct i2c_device_id *id) 340 381 { 341 - int i; 342 - struct i2c_client *client; 343 382 struct adv7170 *encoder; 344 - char *dname; 345 - 346 - dprintk(1, 347 - KERN_INFO 348 - "adv7170.c: detecting adv7170 client on address 0x%x\n", 349 - address << 1); 383 + int i; 350 384 351 385 /* Check if the adapter supports the needed features */ 352 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 353 - return 0; 386 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 387 + return -ENODEV; 354 388 355 - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 356 - if (!client) 357 - return -ENOMEM; 358 - client->addr = address; 359 - client->adapter = adapter; 360 - client->driver = &i2c_driver_adv7170; 361 - if ((client->addr == I2C_ADV7170 >> 1) || 362 - (client->addr == (I2C_ADV7170 >> 1) + 1)) { 363 - dname = adv7170_name; 364 - } else if ((client->addr == I2C_ADV7171 >> 1) || 365 - (client->addr == (I2C_ADV7171 >> 1) + 1)) { 366 - dname = adv7171_name; 367 - } else { 368 - /* We should never get here!!! */ 369 - kfree(client); 370 - return 0; 371 - } 372 - strlcpy(I2C_NAME(client), dname, sizeof(I2C_NAME(client))); 389 + v4l_info(client, "chip found @ 0x%x (%s)\n", 390 + client->addr << 1, client->adapter->name); 373 391 374 392 encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL); 375 - if (encoder == NULL) { 376 - kfree(client); 393 + if (encoder == NULL) 377 394 return -ENOMEM; 378 - } 379 395 encoder->norm = VIDEO_MODE_NTSC; 380 396 encoder->input = 0; 381 397 encoder->enable = 1; 382 398 i2c_set_clientdata(client, encoder); 383 - 384 - i = i2c_attach_client(client); 385 - if (i) { 386 - kfree(client); 387 - kfree(encoder); 388 - return i; 389 - } 390 399 391 400 i = adv7170_write_block(client, init_NTSC, sizeof(init_NTSC)); 392 401 if (i >= 0) { 393 402 i = adv7170_write(client, 0x07, TR0MODE | TR0RST); 394 403 i = adv7170_write(client, 0x07, TR0MODE); 395 404 i = adv7170_read(client, 0x12); 396 - dprintk(1, KERN_INFO "%s_attach: rev. %d at 0x%02x\n", 397 - I2C_NAME(client), i & 1, client->addr << 1); 405 + v4l_dbg(1, debug, client, "revision %d\n", i & 1); 398 406 } 399 - if (i < 0) { 400 - dprintk(1, KERN_ERR "%s_attach: init error 0x%x\n", 401 - I2C_NAME(client), i); 402 - } 403 - 407 + if (i < 0) 408 + v4l_dbg(1, debug, client, "init error 0x%x\n", i); 404 409 return 0; 405 410 } 406 411 407 - static int 408 - adv7170_attach_adapter (struct i2c_adapter *adapter) 412 + static int adv7170_remove(struct i2c_client *client) 409 413 { 410 - dprintk(1, 411 - KERN_INFO 412 - "adv7170.c: starting probe for adapter %s (0x%x)\n", 413 - I2C_NAME(adapter), adapter->id); 414 - return i2c_probe(adapter, &addr_data, &adv7170_detect_client); 415 - } 416 - 417 - static int 418 - adv7170_detach_client (struct i2c_client *client) 419 - { 420 - struct adv7170 *encoder = i2c_get_clientdata(client); 421 - int err; 422 - 423 - err = i2c_detach_client(client); 424 - if (err) { 425 - return err; 426 - } 427 - 428 - kfree(encoder); 429 - kfree(client); 430 - 414 + kfree(i2c_get_clientdata(client)); 431 415 return 0; 432 416 } 433 417 434 418 /* ----------------------------------------------------------------------- */ 435 419 436 - static struct i2c_driver i2c_driver_adv7170 = { 437 - .driver = { 438 - .name = "adv7170", /* name */ 439 - }, 440 - 441 - .id = I2C_DRIVERID_ADV7170, 442 - 443 - .attach_adapter = adv7170_attach_adapter, 444 - .detach_client = adv7170_detach_client, 445 - .command = adv7170_command, 420 + static const struct i2c_device_id adv7170_id[] = { 421 + { "adv7170", 0 }, 422 + { "adv7171", 0 }, 423 + { } 446 424 }; 425 + MODULE_DEVICE_TABLE(i2c, adv7170_id); 447 426 448 - static int __init 449 - adv7170_init (void) 450 - { 451 - return i2c_add_driver(&i2c_driver_adv7170); 452 - } 453 - 454 - static void __exit 455 - adv7170_exit (void) 456 - { 457 - i2c_del_driver(&i2c_driver_adv7170); 458 - } 459 - 460 - module_init(adv7170_init); 461 - module_exit(adv7170_exit); 427 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 428 + .name = "adv7170", 429 + .driverid = I2C_DRIVERID_ADV7170, 430 + .command = adv7170_command, 431 + .probe = adv7170_probe, 432 + .remove = adv7170_remove, 433 + .id_table = adv7170_id, 434 + };
+61 -184
drivers/media/video/adv7175.c
··· 25 25 */ 26 26 27 27 #include <linux/module.h> 28 - #include <linux/init.h> 29 - #include <linux/delay.h> 30 - #include <linux/errno.h> 31 - #include <linux/fs.h> 32 - #include <linux/kernel.h> 33 - #include <linux/major.h> 34 - #include <linux/slab.h> 35 - #include <linux/mm.h> 36 - #include <linux/signal.h> 37 28 #include <linux/types.h> 38 - #include <linux/i2c.h> 39 - #include <asm/io.h> 40 - #include <asm/pgtable.h> 41 - #include <asm/page.h> 29 + #include <linux/ioctl.h> 42 30 #include <asm/uaccess.h> 43 - 31 + #include <linux/i2c.h> 32 + #include <linux/i2c-id.h> 44 33 #include <linux/videodev.h> 45 34 #include <linux/video_encoder.h> 35 + #include <media/v4l2-common.h> 36 + #include <media/v4l2-i2c-drv-legacy.h> 46 37 47 38 MODULE_DESCRIPTION("Analog Devices ADV7175 video encoder driver"); 48 39 MODULE_AUTHOR("Dave Perks"); 49 40 MODULE_LICENSE("GPL"); 50 41 51 - 52 - #define I2C_NAME(s) (s)->name 53 - 54 - 55 42 static int debug; 56 43 module_param(debug, int, 0); 57 44 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 58 - 59 - #define dprintk(num, format, args...) \ 60 - do { \ 61 - if (debug >= num) \ 62 - printk(format, ##args); \ 63 - } while (0) 64 45 65 46 /* ----------------------------------------------------------------------- */ 66 47 ··· 58 77 #define I2C_ADV7175 0xd4 59 78 #define I2C_ADV7176 0x54 60 79 61 - static char adv7175_name[] = "adv7175"; 62 - static char adv7176_name[] = "adv7176"; 63 - 64 80 static char *inputs[] = { "pass_through", "play_back", "color_bar" }; 65 81 static char *norms[] = { "PAL", "NTSC", "SECAM->PAL (may not work!)" }; 66 82 67 83 /* ----------------------------------------------------------------------- */ 68 84 69 - static inline int 70 - adv7175_write (struct i2c_client *client, 71 - u8 reg, 72 - u8 value) 85 + static inline int adv7175_write(struct i2c_client *client, u8 reg, u8 value) 73 86 { 74 87 return i2c_smbus_write_byte_data(client, reg, value); 75 88 } 76 89 77 - static inline int 78 - adv7175_read (struct i2c_client *client, 79 - u8 reg) 90 + static inline int adv7175_read(struct i2c_client *client, u8 reg) 80 91 { 81 92 return i2c_smbus_read_byte_data(client, reg); 82 93 } 83 94 84 - static int 85 - adv7175_write_block (struct i2c_client *client, 86 - const u8 *data, 87 - unsigned int len) 95 + static int adv7175_write_block(struct i2c_client *client, 96 + const u8 *data, unsigned int len) 88 97 { 89 98 int ret = -1; 90 99 u8 reg; ··· 94 123 reg++; 95 124 len -= 2; 96 125 data += 2; 97 - } while (len >= 2 && data[0] == reg && 98 - block_len < 32); 99 - if ((ret = i2c_master_send(client, block_data, 100 - block_len)) < 0) 126 + } while (len >= 2 && data[0] == reg && block_len < 32); 127 + ret = i2c_master_send(client, block_data, block_len); 128 + if (ret < 0) 101 129 break; 102 130 } 103 131 } else { 104 132 /* do some slow I2C emulation kind of thing */ 105 133 while (len >= 2) { 106 134 reg = *data++; 107 - if ((ret = adv7175_write(client, reg, 108 - *data++)) < 0) 135 + ret = adv7175_write(client, reg, *data++); 136 + if (ret < 0) 109 137 break; 110 138 len -= 2; 111 139 } ··· 113 143 return ret; 114 144 } 115 145 116 - static void 117 - set_subcarrier_freq (struct i2c_client *client, 118 - int pass_through) 146 + static void set_subcarrier_freq(struct i2c_client *client, int pass_through) 119 147 { 120 148 /* for some reason pass_through NTSC needs 121 149 * a different sub-carrier freq to remain stable. */ 122 - if(pass_through) 150 + if (pass_through) 123 151 adv7175_write(client, 0x02, 0x00); 124 152 else 125 153 adv7175_write(client, 0x02, 0x55); ··· 128 160 } 129 161 130 162 /* ----------------------------------------------------------------------- */ 131 - // Output filter: S-Video Composite 163 + /* Output filter: S-Video Composite */ 132 164 133 - #define MR050 0x11 //0x09 134 - #define MR060 0x14 //0x0c 165 + #define MR050 0x11 /* 0x09 */ 166 + #define MR060 0x14 /* 0x0c */ 135 167 136 - //--------------------------------------------------------------------------- 168 + /* ----------------------------------------------------------------------- */ 137 169 138 170 #define TR0MODE 0x46 139 171 #define TR0RST 0x80 ··· 184 216 0x06, 0x1a, /* subc. phase */ 185 217 }; 186 218 187 - static int 188 - adv7175_command (struct i2c_client *client, 189 - unsigned int cmd, 190 - void *arg) 219 + static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) 191 220 { 192 221 struct adv7175 *encoder = i2c_get_clientdata(client); 193 222 194 223 switch (cmd) { 195 - 196 224 case 0: 197 225 /* This is just for testing!!! */ 198 226 adv7175_write_block(client, init_common, ··· 206 242 VIDEO_ENCODER_SECAM; /* well, hacky */ 207 243 cap->inputs = 2; 208 244 cap->outputs = 1; 209 - } 210 245 break; 246 + } 211 247 212 248 case ENCODER_SET_NORM: 213 249 { 214 250 int iarg = *(int *) arg; 215 251 216 252 switch (iarg) { 217 - 218 253 case VIDEO_MODE_NTSC: 219 254 adv7175_write_block(client, init_ntsc, 220 255 sizeof(init_ntsc)); ··· 247 284 adv7175_write(client, 0x07, TR0MODE); 248 285 break; 249 286 default: 250 - dprintk(1, KERN_ERR "%s: illegal norm: %d\n", 251 - I2C_NAME(client), iarg); 287 + v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg); 252 288 return -EINVAL; 253 - 254 289 } 255 - dprintk(1, KERN_INFO "%s: switched to %s\n", I2C_NAME(client), 256 - norms[iarg]); 290 + v4l_dbg(1, debug, client, "switched to %s\n", norms[iarg]); 257 291 encoder->norm = iarg; 258 - } 259 292 break; 293 + } 260 294 261 295 case ENCODER_SET_INPUT: 262 296 { ··· 264 304 *iarg = 2: color bar */ 265 305 266 306 switch (iarg) { 267 - 268 307 case 0: 269 308 adv7175_write(client, 0x01, 0x00); 270 309 ··· 290 331 adv7175_write(client, 0x0d, 0x49); 291 332 adv7175_write(client, 0x07, TR0MODE | TR0RST); 292 333 adv7175_write(client, 0x07, TR0MODE); 293 - //udelay(10); 334 + /* udelay(10); */ 294 335 break; 295 336 296 337 case 2: ··· 302 343 adv7175_write(client, 0x0d, 0x49); 303 344 adv7175_write(client, 0x07, TR0MODE | TR0RST); 304 345 adv7175_write(client, 0x07, TR0MODE); 305 - //udelay(10); 346 + /* udelay(10); */ 306 347 break; 307 348 308 349 default: 309 - dprintk(1, KERN_ERR "%s: illegal input: %d\n", 310 - I2C_NAME(client), iarg); 350 + v4l_dbg(1, debug, client, "illegal input: %d\n", iarg); 311 351 return -EINVAL; 312 - 313 352 } 314 - dprintk(1, KERN_INFO "%s: switched to %s\n", I2C_NAME(client), 315 - inputs[iarg]); 353 + v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]); 316 354 encoder->input = iarg; 317 - } 318 355 break; 356 + } 319 357 320 358 case ENCODER_SET_OUTPUT: 321 359 { 322 360 int *iarg = arg; 323 361 324 362 /* not much choice of outputs */ 325 - if (*iarg != 0) { 363 + if (*iarg != 0) 326 364 return -EINVAL; 327 - } 328 - } 329 365 break; 366 + } 330 367 331 368 case ENCODER_ENABLE_OUTPUT: 332 369 { 333 370 int *iarg = arg; 334 371 335 372 encoder->enable = !!*iarg; 336 - } 337 373 break; 374 + } 338 375 339 376 default: 340 377 return -EINVAL; ··· 345 390 * Generic i2c probe 346 391 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 347 392 */ 348 - static unsigned short normal_i2c[] = 349 - { I2C_ADV7175 >> 1, (I2C_ADV7175 >> 1) + 1, 393 + static unsigned short normal_i2c[] = { 394 + I2C_ADV7175 >> 1, (I2C_ADV7175 >> 1) + 1, 350 395 I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1, 351 396 I2C_CLIENT_END 352 397 }; 353 398 354 - static unsigned short ignore = I2C_CLIENT_END; 399 + I2C_CLIENT_INSMOD; 355 400 356 - static struct i2c_client_address_data addr_data = { 357 - .normal_i2c = normal_i2c, 358 - .probe = &ignore, 359 - .ignore = &ignore, 360 - }; 361 - 362 - static struct i2c_driver i2c_driver_adv7175; 363 - 364 - static int 365 - adv7175_detect_client (struct i2c_adapter *adapter, 366 - int address, 367 - int kind) 401 + static int adv7175_probe(struct i2c_client *client, 402 + const struct i2c_device_id *id) 368 403 { 369 404 int i; 370 - struct i2c_client *client; 371 405 struct adv7175 *encoder; 372 - char *dname; 373 - 374 - dprintk(1, 375 - KERN_INFO 376 - "adv7175.c: detecting adv7175 client on address 0x%x\n", 377 - address << 1); 378 406 379 407 /* Check if the adapter supports the needed features */ 380 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 381 - return 0; 408 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 409 + return -ENODEV; 382 410 383 - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 384 - if (!client) 385 - return -ENOMEM; 386 - client->addr = address; 387 - client->adapter = adapter; 388 - client->driver = &i2c_driver_adv7175; 389 - if ((client->addr == I2C_ADV7175 >> 1) || 390 - (client->addr == (I2C_ADV7175 >> 1) + 1)) { 391 - dname = adv7175_name; 392 - } else if ((client->addr == I2C_ADV7176 >> 1) || 393 - (client->addr == (I2C_ADV7176 >> 1) + 1)) { 394 - dname = adv7176_name; 395 - } else { 396 - /* We should never get here!!! */ 397 - kfree(client); 398 - return 0; 399 - } 400 - strlcpy(I2C_NAME(client), dname, sizeof(I2C_NAME(client))); 411 + v4l_info(client, "chip found @ 0x%x (%s)\n", 412 + client->addr << 1, client->adapter->name); 401 413 402 414 encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL); 403 - if (encoder == NULL) { 404 - kfree(client); 415 + if (encoder == NULL) 405 416 return -ENOMEM; 406 - } 407 417 encoder->norm = VIDEO_MODE_PAL; 408 418 encoder->input = 0; 409 419 encoder->enable = 1; 410 420 i2c_set_clientdata(client, encoder); 411 - 412 - i = i2c_attach_client(client); 413 - if (i) { 414 - kfree(client); 415 - kfree(encoder); 416 - return i; 417 - } 418 421 419 422 i = adv7175_write_block(client, init_common, sizeof(init_common)); 420 423 if (i >= 0) { 421 424 i = adv7175_write(client, 0x07, TR0MODE | TR0RST); 422 425 i = adv7175_write(client, 0x07, TR0MODE); 423 426 i = adv7175_read(client, 0x12); 424 - dprintk(1, KERN_INFO "%s_attach: rev. %d at 0x%x\n", 425 - I2C_NAME(client), i & 1, client->addr << 1); 427 + v4l_dbg(1, debug, client, "revision %d\n", i & 1); 426 428 } 427 - if (i < 0) { 428 - dprintk(1, KERN_ERR "%s_attach: init error 0x%x\n", 429 - I2C_NAME(client), i); 430 - } 431 - 429 + if (i < 0) 430 + v4l_dbg(1, debug, client, "init error 0x%x\n", i); 432 431 return 0; 433 432 } 434 433 435 - static int 436 - adv7175_attach_adapter (struct i2c_adapter *adapter) 434 + static int adv7175_remove(struct i2c_client *client) 437 435 { 438 - dprintk(1, 439 - KERN_INFO 440 - "adv7175.c: starting probe for adapter %s (0x%x)\n", 441 - I2C_NAME(adapter), adapter->id); 442 - return i2c_probe(adapter, &addr_data, &adv7175_detect_client); 443 - } 444 - 445 - static int 446 - adv7175_detach_client (struct i2c_client *client) 447 - { 448 - struct adv7175 *encoder = i2c_get_clientdata(client); 449 - int err; 450 - 451 - err = i2c_detach_client(client); 452 - if (err) { 453 - return err; 454 - } 455 - 456 - kfree(encoder); 457 - kfree(client); 458 - 436 + kfree(i2c_get_clientdata(client)); 459 437 return 0; 460 438 } 461 439 462 440 /* ----------------------------------------------------------------------- */ 463 441 464 - static struct i2c_driver i2c_driver_adv7175 = { 465 - .driver = { 466 - .name = "adv7175", /* name */ 467 - }, 468 - 469 - .id = I2C_DRIVERID_ADV7175, 470 - 471 - .attach_adapter = adv7175_attach_adapter, 472 - .detach_client = adv7175_detach_client, 473 - .command = adv7175_command, 442 + static const struct i2c_device_id adv7175_id[] = { 443 + { "adv7175", 0 }, 444 + { "adv7176", 0 }, 445 + { } 474 446 }; 447 + MODULE_DEVICE_TABLE(i2c, adv7175_id); 475 448 476 - static int __init 477 - adv7175_init (void) 478 - { 479 - return i2c_add_driver(&i2c_driver_adv7175); 480 - } 481 - 482 - static void __exit 483 - adv7175_exit (void) 484 - { 485 - i2c_del_driver(&i2c_driver_adv7175); 486 - } 487 - 488 - module_init(adv7175_init); 489 - module_exit(adv7175_exit); 449 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 450 + .name = "adv7175", 451 + .driverid = I2C_DRIVERID_ADV7175, 452 + .command = adv7175_command, 453 + .probe = adv7175_probe, 454 + .remove = adv7175_remove, 455 + .id_table = adv7175_id, 456 + };
+4 -1
drivers/media/video/au0828/au0828-cards.c
··· 90 90 case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ 91 91 case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ 92 92 case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and basic analog video */ 93 + case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */ 93 94 case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */ 94 95 case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ 95 96 break; ··· 186 185 } 187 186 188 187 /* table of devices that work with this driver */ 189 - struct usb_device_id au0828_usb_id_table [] = { 188 + struct usb_device_id au0828_usb_id_table[] = { 190 189 { USB_DEVICE(0x2040, 0x7200), 191 190 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 192 191 { USB_DEVICE(0x2040, 0x7240), ··· 198 197 { USB_DEVICE(0x2040, 0x7217), 199 198 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 200 199 { USB_DEVICE(0x2040, 0x721b), 200 + .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 201 + { USB_DEVICE(0x2040, 0x721e), 201 202 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 202 203 { USB_DEVICE(0x2040, 0x721f), 203 204 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
+2 -1
drivers/media/video/au0828/au0828-core.c
··· 91 91 status = usb_control_msg(dev->usbdev, 92 92 usb_sndctrlpipe(dev->usbdev, 0), 93 93 request, 94 - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 94 + USB_DIR_OUT | USB_TYPE_VENDOR | 95 + USB_RECIP_DEVICE, 95 96 value, index, 96 97 cp, size, 1000); 97 98
+2 -1
drivers/media/video/au0828/au0828-dvb.c
··· 173 173 purb->status = -EINPROGRESS; 174 174 usb_fill_bulk_urb(purb, 175 175 dev->usbdev, 176 - usb_rcvbulkpipe(dev->usbdev, _AU0828_BULKPIPE), 176 + usb_rcvbulkpipe(dev->usbdev, 177 + _AU0828_BULKPIPE), 177 178 purb->transfer_buffer, 178 179 URB_BUFSIZE, 179 180 urb_completion,
+93 -230
drivers/media/video/bt819.c
··· 29 29 */ 30 30 31 31 #include <linux/module.h> 32 - #include <linux/init.h> 33 32 #include <linux/delay.h> 34 - #include <linux/errno.h> 35 - #include <linux/fs.h> 36 - #include <linux/kernel.h> 37 - #include <linux/major.h> 38 - #include <linux/slab.h> 39 - #include <linux/mm.h> 40 - #include <linux/signal.h> 41 33 #include <linux/types.h> 42 - #include <linux/i2c.h> 43 - #include <asm/io.h> 44 - #include <asm/pgtable.h> 45 - #include <asm/page.h> 34 + #include <linux/ioctl.h> 46 35 #include <asm/uaccess.h> 47 - 36 + #include <linux/i2c.h> 37 + #include <linux/i2c-id.h> 48 38 #include <linux/videodev.h> 49 39 #include <linux/video_decoder.h> 50 - 40 + #include <media/v4l2-common.h> 41 + #include <media/v4l2-i2c-drv-legacy.h> 51 42 52 43 MODULE_DESCRIPTION("Brooktree-819 video decoder driver"); 53 44 MODULE_AUTHOR("Mike Bernson & Dave Perks"); 54 45 MODULE_LICENSE("GPL"); 55 46 56 - 57 - #define I2C_NAME(s) (s)->name 58 - 59 - 60 47 static int debug; 61 48 module_param(debug, int, 0); 62 49 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 63 - 64 - #define dprintk(num, format, args...) \ 65 - do { \ 66 - if (debug >= num) \ 67 - printk(format, ##args); \ 68 - } while (0) 69 50 70 51 /* ----------------------------------------------------------------------- */ 71 52 ··· 78 97 {858 - 24, 20, 525 - 2, 1, 0x00f8, 0x0000}, 79 98 }; 80 99 81 - #define I2C_BT819 0x8a 82 - 83 100 /* ----------------------------------------------------------------------- */ 84 101 85 - static inline int 86 - bt819_write (struct i2c_client *client, 87 - u8 reg, 88 - u8 value) 102 + static inline int bt819_write(struct i2c_client *client, u8 reg, u8 value) 89 103 { 90 104 struct bt819 *decoder = i2c_get_clientdata(client); 91 105 ··· 88 112 return i2c_smbus_write_byte_data(client, reg, value); 89 113 } 90 114 91 - static inline int 92 - bt819_setbit (struct i2c_client *client, 93 - u8 reg, 94 - u8 bit, 95 - u8 value) 115 + static inline int bt819_setbit(struct i2c_client *client, u8 reg, u8 bit, u8 value) 96 116 { 97 117 struct bt819 *decoder = i2c_get_clientdata(client); 98 118 99 119 return bt819_write(client, reg, 100 - (decoder-> 101 - reg[reg] & ~(1 << bit)) | 102 - (value ? (1 << bit) : 0)); 120 + (decoder->reg[reg] & ~(1 << bit)) | (value ? (1 << bit) : 0)); 103 121 } 104 122 105 - static int 106 - bt819_write_block (struct i2c_client *client, 107 - const u8 *data, 108 - unsigned int len) 123 + static int bt819_write_block(struct i2c_client *client, const u8 *data, unsigned int len) 109 124 { 110 125 int ret = -1; 111 126 u8 reg; ··· 117 150 decoder->reg[reg++] = data[1]; 118 151 len -= 2; 119 152 data += 2; 120 - } while (len >= 2 && data[0] == reg && 121 - block_len < 32); 122 - if ((ret = i2c_master_send(client, block_data, 123 - block_len)) < 0) 153 + } while (len >= 2 && data[0] == reg && block_len < 32); 154 + ret = i2c_master_send(client, block_data, block_len); 155 + if (ret < 0) 124 156 break; 125 157 } 126 158 } else { ··· 135 169 return ret; 136 170 } 137 171 138 - static inline int 139 - bt819_read (struct i2c_client *client, 140 - u8 reg) 172 + static inline int bt819_read(struct i2c_client *client, u8 reg) 141 173 { 142 174 return i2c_smbus_read_byte_data(client, reg); 143 175 } 144 176 145 - static int 146 - bt819_init (struct i2c_client *client) 177 + static int bt819_init(struct i2c_client *client) 147 178 { 148 179 struct bt819 *decoder = i2c_get_clientdata(client); 149 180 150 181 static unsigned char init[] = { 151 - //0x1f, 0x00, /* Reset */ 182 + /*0x1f, 0x00,*/ /* Reset */ 152 183 0x01, 0x59, /* 0x01 input format */ 153 184 0x02, 0x00, /* 0x02 temporal decimation */ 154 185 0x03, 0x12, /* 0x03 Cropping msb */ ··· 181 218 struct timing *timing = &timing_data[decoder->norm]; 182 219 183 220 init[0x03 * 2 - 1] = 184 - (((timing->vdelay >> 8) & 0x03) << 6) | (((timing-> 185 - vactive >> 8) & 186 - 0x03) << 4) | 187 - (((timing->hdelay >> 8) & 0x03) << 2) | ((timing-> 188 - hactive >> 8) & 189 - 0x03); 221 + (((timing->vdelay >> 8) & 0x03) << 6) | 222 + (((timing->vactive >> 8) & 0x03) << 4) | 223 + (((timing->hdelay >> 8) & 0x03) << 2) | 224 + ((timing->hactive >> 8) & 0x03); 190 225 init[0x04 * 2 - 1] = timing->vdelay & 0xff; 191 226 init[0x05 * 2 - 1] = timing->vactive & 0xff; 192 227 init[0x06 * 2 - 1] = timing->hdelay & 0xff; ··· 199 238 200 239 /* init */ 201 240 return bt819_write_block(client, init, sizeof(init)); 202 - 203 241 } 204 242 205 243 /* ----------------------------------------------------------------------- */ 206 244 207 - static int 208 - bt819_command (struct i2c_client *client, 209 - unsigned int cmd, 210 - void *arg) 245 + static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg) 211 246 { 212 247 int temp; 213 248 214 249 struct bt819 *decoder = i2c_get_clientdata(client); 215 250 216 - if (!decoder->initialized) { // First call to bt819_init could be 217 - bt819_init(client); // without #FRST = 0 251 + if (!decoder->initialized) { /* First call to bt819_init could be */ 252 + bt819_init(client); /* without #FRST = 0 */ 218 253 decoder->initialized = 1; 219 254 } 220 255 221 256 switch (cmd) { 222 - 223 257 case 0: 224 258 /* This is just for testing!!! */ 225 259 bt819_init(client); ··· 230 274 VIDEO_DECODER_CCIR; 231 275 cap->inputs = 8; 232 276 cap->outputs = 1; 233 - } 234 277 break; 278 + } 235 279 236 280 case DECODER_GET_STATUS: 237 281 { ··· 241 285 242 286 status = bt819_read(client, 0x00); 243 287 res = 0; 244 - if ((status & 0x80)) { 288 + if ((status & 0x80)) 245 289 res |= DECODER_STATUS_GOOD; 246 - } 290 + 247 291 switch (decoder->norm) { 248 292 case VIDEO_MODE_NTSC: 249 293 res |= DECODER_STATUS_NTSC; ··· 253 297 break; 254 298 default: 255 299 case VIDEO_MODE_AUTO: 256 - if ((status & 0x10)) { 300 + if ((status & 0x10)) 257 301 res |= DECODER_STATUS_PAL; 258 - } else { 302 + else 259 303 res |= DECODER_STATUS_NTSC; 260 - } 261 304 break; 262 305 } 263 306 res |= DECODER_STATUS_COLOR; 264 307 *iarg = res; 265 308 266 - dprintk(1, KERN_INFO "%s: get status %x\n", I2C_NAME(client), 267 - *iarg); 268 - } 309 + v4l_dbg(1, debug, client, "get status %x\n", *iarg); 269 310 break; 311 + } 270 312 271 313 case DECODER_SET_NORM: 272 314 { 273 315 int *iarg = arg; 274 316 struct timing *timing = NULL; 275 317 276 - dprintk(1, KERN_INFO "%s: set norm %x\n", I2C_NAME(client), 277 - *iarg); 318 + v4l_dbg(1, debug, client, "set norm %x\n", *iarg); 278 319 279 320 switch (*iarg) { 280 321 case VIDEO_MODE_NTSC: ··· 280 327 bt819_setbit(client, 0x01, 5, 0); 281 328 bt819_write(client, 0x18, 0x68); 282 329 bt819_write(client, 0x19, 0x5d); 283 - //bt819_setbit(client, 0x1a, 5, 1); 330 + /* bt819_setbit(client, 0x1a, 5, 1); */ 284 331 timing = &timing_data[VIDEO_MODE_NTSC]; 285 332 break; 286 333 case VIDEO_MODE_PAL: ··· 289 336 bt819_setbit(client, 0x01, 5, 1); 290 337 bt819_write(client, 0x18, 0x7f); 291 338 bt819_write(client, 0x19, 0x72); 292 - //bt819_setbit(client, 0x1a, 5, 0); 339 + /* bt819_setbit(client, 0x1a, 5, 0); */ 293 340 timing = &timing_data[VIDEO_MODE_PAL]; 294 341 break; 295 342 case VIDEO_MODE_AUTO: ··· 297 344 bt819_setbit(client, 0x01, 1, 0); 298 345 break; 299 346 default: 300 - dprintk(1, 301 - KERN_ERR 302 - "%s: unsupported norm %d\n", 303 - I2C_NAME(client), *iarg); 347 + v4l_dbg(1, debug, client, "unsupported norm %x\n", *iarg); 304 348 return -EINVAL; 305 349 } 306 350 ··· 316 366 } 317 367 318 368 decoder->norm = *iarg; 319 - } 320 369 break; 370 + } 321 371 322 372 case DECODER_SET_INPUT: 323 373 { 324 374 int *iarg = arg; 325 375 326 - dprintk(1, KERN_INFO "%s: set input %x\n", I2C_NAME(client), 327 - *iarg); 376 + v4l_dbg(1, debug, client, "set input %x\n", *iarg); 328 377 329 - if (*iarg < 0 || *iarg > 7) { 378 + if (*iarg < 0 || *iarg > 7) 330 379 return -EINVAL; 331 - } 332 380 333 381 if (decoder->input != *iarg) { 334 382 decoder->input = *iarg; ··· 339 391 bt819_setbit(client, 0x1a, 1, 0); 340 392 } 341 393 } 342 - } 343 394 break; 395 + } 344 396 345 397 case DECODER_SET_OUTPUT: 346 398 { 347 399 int *iarg = arg; 348 400 349 - dprintk(1, KERN_INFO "%s: set output %x\n", I2C_NAME(client), 350 - *iarg); 401 + v4l_dbg(1, debug, client, "set output %x\n", *iarg); 351 402 352 403 /* not much choice of outputs */ 353 - if (*iarg != 0) { 404 + if (*iarg != 0) 354 405 return -EINVAL; 355 - } 356 - } 357 406 break; 407 + } 358 408 359 409 case DECODER_ENABLE_OUTPUT: 360 410 { 361 411 int *iarg = arg; 362 412 int enable = (*iarg != 0); 363 413 364 - dprintk(1, KERN_INFO "%s: enable output %x\n", 365 - I2C_NAME(client), *iarg); 414 + v4l_dbg(1, debug, client, "enable output %x\n", *iarg); 366 415 367 416 if (decoder->enable != enable) { 368 417 decoder->enable = enable; 369 - 370 - if (decoder->enable) { 371 - bt819_setbit(client, 0x16, 7, 0); 372 - } else { 373 - bt819_setbit(client, 0x16, 7, 1); 374 - } 418 + bt819_setbit(client, 0x16, 7, !enable); 375 419 } 376 - } 377 420 break; 421 + } 378 422 379 423 case DECODER_SET_PICTURE: 380 424 { 381 425 struct video_picture *pic = arg; 382 426 383 - dprintk(1, 384 - KERN_INFO 385 - "%s: set picture brightness %d contrast %d colour %d\n", 386 - I2C_NAME(client), pic->brightness, pic->contrast, 387 - pic->colour); 427 + v4l_dbg(1, debug, client, 428 + "set picture brightness %d contrast %d colour %d\n", 429 + pic->brightness, pic->contrast, pic->colour); 388 430 389 431 390 432 if (decoder->bright != pic->brightness) { ··· 412 474 bt819_write(client, 0x0f, 413 475 128 - (decoder->hue >> 8)); 414 476 } 415 - } 416 477 break; 478 + } 417 479 418 480 default: 419 481 return -EINVAL; ··· 424 486 425 487 /* ----------------------------------------------------------------------- */ 426 488 427 - /* 428 - * Generic i2c probe 429 - * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 430 - */ 431 - static unsigned short normal_i2c[] = { 432 - I2C_BT819 >> 1, 433 - I2C_CLIENT_END, 434 - }; 489 + static unsigned short normal_i2c[] = { 0x8a >> 1, I2C_CLIENT_END }; 435 490 436 - static unsigned short ignore = I2C_CLIENT_END; 491 + I2C_CLIENT_INSMOD; 437 492 438 - static struct i2c_client_address_data addr_data = { 439 - .normal_i2c = normal_i2c, 440 - .probe = &ignore, 441 - .ignore = &ignore, 442 - }; 443 - 444 - static struct i2c_driver i2c_driver_bt819; 445 - 446 - static int 447 - bt819_detect_client (struct i2c_adapter *adapter, 448 - int address, 449 - int kind) 493 + static int bt819_probe(struct i2c_client *client, 494 + const struct i2c_device_id *id) 450 495 { 451 - int i, id; 496 + int i, ver; 452 497 struct bt819 *decoder; 453 - struct i2c_client *client; 454 - 455 - dprintk(1, 456 - KERN_INFO 457 - "bt819: detecting bt819 client on address 0x%x\n", 458 - address << 1); 498 + const char *name; 459 499 460 500 /* Check if the adapter supports the needed features */ 461 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 462 - return 0; 501 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 502 + return -ENODEV; 463 503 464 - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 465 - if (!client) 466 - return -ENOMEM; 467 - client->addr = address; 468 - client->adapter = adapter; 469 - client->driver = &i2c_driver_bt819; 504 + ver = bt819_read(client, 0x17); 505 + switch (ver & 0xf0) { 506 + case 0x70: 507 + name = "bt819a"; 508 + break; 509 + case 0x60: 510 + name = "bt817a"; 511 + break; 512 + case 0x20: 513 + name = "bt815a"; 514 + break; 515 + default: 516 + v4l_dbg(1, debug, client, 517 + "unknown chip version 0x%02x\n", ver); 518 + return -ENODEV; 519 + } 520 + 521 + v4l_info(client, "%s found @ 0x%x (%s)\n", name, 522 + client->addr << 1, client->adapter->name); 470 523 471 524 decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL); 472 - if (decoder == NULL) { 473 - kfree(client); 525 + if (decoder == NULL) 474 526 return -ENOMEM; 475 - } 476 527 decoder->norm = VIDEO_MODE_NTSC; 477 528 decoder->input = 0; 478 529 decoder->enable = 1; ··· 472 545 decoder->initialized = 0; 473 546 i2c_set_clientdata(client, decoder); 474 547 475 - id = bt819_read(client, 0x17); 476 - switch (id & 0xf0) { 477 - case 0x70: 478 - strlcpy(I2C_NAME(client), "bt819a", sizeof(I2C_NAME(client))); 479 - break; 480 - case 0x60: 481 - strlcpy(I2C_NAME(client), "bt817a", sizeof(I2C_NAME(client))); 482 - break; 483 - case 0x20: 484 - strlcpy(I2C_NAME(client), "bt815a", sizeof(I2C_NAME(client))); 485 - break; 486 - default: 487 - dprintk(1, 488 - KERN_ERR 489 - "bt819: unknown chip version 0x%x (ver 0x%x)\n", 490 - id & 0xf0, id & 0x0f); 491 - kfree(decoder); 492 - kfree(client); 493 - return 0; 494 - } 495 - 496 - i = i2c_attach_client(client); 497 - if (i) { 498 - kfree(client); 499 - kfree(decoder); 500 - return i; 501 - } 502 - 503 548 i = bt819_init(client); 504 - if (i < 0) { 505 - dprintk(1, KERN_ERR "%s_attach: init status %d\n", 506 - I2C_NAME(client), i); 507 - } else { 508 - dprintk(1, 509 - KERN_INFO 510 - "%s_attach: chip version 0x%x at address 0x%x\n", 511 - I2C_NAME(client), id & 0x0f, 512 - client->addr << 1); 513 - } 514 - 549 + if (i < 0) 550 + v4l_dbg(1, debug, client, "init status %d\n", i); 515 551 return 0; 516 552 } 517 553 518 - static int 519 - bt819_attach_adapter (struct i2c_adapter *adapter) 554 + static int bt819_remove(struct i2c_client *client) 520 555 { 521 - return i2c_probe(adapter, &addr_data, &bt819_detect_client); 522 - } 523 - 524 - static int 525 - bt819_detach_client (struct i2c_client *client) 526 - { 527 - struct bt819 *decoder = i2c_get_clientdata(client); 528 - int err; 529 - 530 - err = i2c_detach_client(client); 531 - if (err) { 532 - return err; 533 - } 534 - 535 - kfree(decoder); 536 - kfree(client); 537 - 556 + kfree(i2c_get_clientdata(client)); 538 557 return 0; 539 558 } 540 559 541 560 /* ----------------------------------------------------------------------- */ 542 561 543 - static struct i2c_driver i2c_driver_bt819 = { 544 - .driver = { 545 - .name = "bt819", 546 - }, 547 - 548 - .id = I2C_DRIVERID_BT819, 549 - 550 - .attach_adapter = bt819_attach_adapter, 551 - .detach_client = bt819_detach_client, 552 - .command = bt819_command, 562 + static const struct i2c_device_id bt819_id[] = { 563 + { "bt819a", 0 }, 564 + { "bt817a", 0 }, 565 + { "bt815a", 0 }, 566 + { } 553 567 }; 568 + MODULE_DEVICE_TABLE(i2c, bt819_id); 554 569 555 - static int __init 556 - bt819_init_module (void) 557 - { 558 - return i2c_add_driver(&i2c_driver_bt819); 559 - } 560 - 561 - static void __exit 562 - bt819_exit (void) 563 - { 564 - i2c_del_driver(&i2c_driver_bt819); 565 - } 566 - 567 - module_init(bt819_init_module); 568 - module_exit(bt819_exit); 570 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 571 + .name = "bt819", 572 + .driverid = I2C_DRIVERID_BT819, 573 + .command = bt819_command, 574 + .probe = bt819_probe, 575 + .remove = bt819_remove, 576 + .id_table = bt819_id, 577 + };
+50 -170
drivers/media/video/bt856.c
··· 29 29 */ 30 30 31 31 #include <linux/module.h> 32 - #include <linux/init.h> 33 - #include <linux/delay.h> 34 - #include <linux/errno.h> 35 - #include <linux/fs.h> 36 - #include <linux/kernel.h> 37 - #include <linux/major.h> 38 - #include <linux/slab.h> 39 - #include <linux/mm.h> 40 - #include <linux/signal.h> 41 32 #include <linux/types.h> 42 - #include <linux/i2c.h> 43 - #include <linux/video_encoder.h> 44 - #include <asm/io.h> 45 - #include <asm/pgtable.h> 46 - #include <asm/page.h> 33 + #include <linux/ioctl.h> 47 34 #include <asm/uaccess.h> 48 - 35 + #include <linux/i2c.h> 36 + #include <linux/i2c-id.h> 49 37 #include <linux/videodev.h> 38 + #include <linux/video_encoder.h> 39 + #include <media/v4l2-common.h> 40 + #include <media/v4l2-i2c-drv-legacy.h> 50 41 51 42 MODULE_DESCRIPTION("Brooktree-856A video encoder driver"); 52 43 MODULE_AUTHOR("Mike Bernson & Dave Perks"); 53 44 MODULE_LICENSE("GPL"); 54 45 55 - 56 - #define I2C_NAME(s) (s)->name 57 - 58 - 59 46 static int debug; 60 47 module_param(debug, int, 0); 61 48 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 62 - 63 - #define dprintk(num, format, args...) \ 64 - do { \ 65 - if (debug >= num) \ 66 - printk(format, ##args); \ 67 - } while (0) 68 49 69 50 /* ----------------------------------------------------------------------- */ 70 51 ··· 59 78 int enable; 60 79 }; 61 80 62 - #define I2C_BT856 0x88 63 - 64 81 /* ----------------------------------------------------------------------- */ 65 82 66 - static inline int 67 - bt856_write (struct i2c_client *client, 68 - u8 reg, 69 - u8 value) 83 + static inline int bt856_write(struct i2c_client *client, u8 reg, u8 value) 70 84 { 71 85 struct bt856 *encoder = i2c_get_clientdata(client); 72 86 ··· 69 93 return i2c_smbus_write_byte_data(client, reg, value); 70 94 } 71 95 72 - static inline int 73 - bt856_setbit (struct i2c_client *client, 74 - u8 reg, 75 - u8 bit, 76 - u8 value) 96 + static inline int bt856_setbit(struct i2c_client *client, u8 reg, u8 bit, u8 value) 77 97 { 78 98 struct bt856 *encoder = i2c_get_clientdata(client); 79 99 80 100 return bt856_write(client, reg, 81 - (encoder-> 82 - reg[reg - BT856_REG_OFFSET] & ~(1 << bit)) | 83 - (value ? (1 << bit) : 0)); 101 + (encoder->reg[reg - BT856_REG_OFFSET] & ~(1 << bit)) | 102 + (value ? (1 << bit) : 0)); 84 103 } 85 104 86 - static void 87 - bt856_dump (struct i2c_client *client) 105 + static void bt856_dump(struct i2c_client *client) 88 106 { 89 107 int i; 90 108 struct bt856 *encoder = i2c_get_clientdata(client); 91 109 92 - printk(KERN_INFO "%s: register dump:", I2C_NAME(client)); 110 + v4l_info(client, "register dump:\n"); 93 111 for (i = 0; i < BT856_NR_REG; i += 2) 94 - printk(" %02x", encoder->reg[i]); 95 - printk("\n"); 112 + printk(KERN_CONT " %02x", encoder->reg[i]); 113 + printk(KERN_CONT "\n"); 96 114 } 97 115 98 116 /* ----------------------------------------------------------------------- */ 99 117 100 - static int 101 - bt856_command (struct i2c_client *client, 102 - unsigned int cmd, 103 - void *arg) 118 + static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) 104 119 { 105 120 struct bt856 *encoder = i2c_get_clientdata(client); 106 121 107 122 switch (cmd) { 108 - 109 123 case 0: 110 124 /* This is just for testing!!! */ 111 - dprintk(1, KERN_INFO "bt856: init\n"); 125 + v4l_dbg(1, debug, client, "init\n"); 112 126 bt856_write(client, 0xdc, 0x18); 113 127 bt856_write(client, 0xda, 0); 114 128 bt856_write(client, 0xde, 0); ··· 108 142 bt856_setbit(client, 0xdc, 4, 1); 109 143 110 144 switch (encoder->norm) { 111 - 112 145 case VIDEO_MODE_NTSC: 113 146 bt856_setbit(client, 0xdc, 2, 0); 114 147 break; ··· 128 163 { 129 164 struct video_encoder_capability *cap = arg; 130 165 131 - dprintk(1, KERN_INFO "%s: get capabilities\n", 132 - I2C_NAME(client)); 166 + v4l_dbg(1, debug, client, "get capabilities\n"); 133 167 134 168 cap->flags = VIDEO_ENCODER_PAL | 135 169 VIDEO_ENCODER_NTSC | 136 170 VIDEO_ENCODER_CCIR; 137 171 cap->inputs = 2; 138 172 cap->outputs = 1; 139 - } 140 173 break; 174 + } 141 175 142 176 case ENCODER_SET_NORM: 143 177 { 144 178 int *iarg = arg; 145 179 146 - dprintk(1, KERN_INFO "%s: set norm %d\n", I2C_NAME(client), 147 - *iarg); 180 + v4l_dbg(1, debug, client, "set norm %d\n", *iarg); 148 181 149 182 switch (*iarg) { 150 - 151 183 case VIDEO_MODE_NTSC: 152 184 bt856_setbit(client, 0xdc, 2, 0); 153 185 break; ··· 157 195 158 196 default: 159 197 return -EINVAL; 160 - 161 198 } 162 199 encoder->norm = *iarg; 163 200 if (debug != 0) 164 201 bt856_dump(client); 165 - } 166 202 break; 203 + } 167 204 168 205 case ENCODER_SET_INPUT: 169 206 { 170 207 int *iarg = arg; 171 208 172 - dprintk(1, KERN_INFO "%s: set input %d\n", I2C_NAME(client), 173 - *iarg); 209 + v4l_dbg(1, debug, client, "set input %d\n", *iarg); 174 210 175 211 /* We only have video bus. 176 212 * iarg = 0: input is from bt819 177 213 * iarg = 1: input is from ZR36060 */ 178 - 179 214 switch (*iarg) { 180 - 181 215 case 0: 182 216 bt856_setbit(client, 0xde, 4, 0); 183 217 bt856_setbit(client, 0xde, 3, 1); ··· 192 234 break; 193 235 default: 194 236 return -EINVAL; 195 - 196 237 } 197 238 198 239 if (debug != 0) 199 240 bt856_dump(client); 200 - } 201 241 break; 242 + } 202 243 203 244 case ENCODER_SET_OUTPUT: 204 245 { 205 246 int *iarg = arg; 206 247 207 - dprintk(1, KERN_INFO "%s: set output %d\n", I2C_NAME(client), 208 - *iarg); 248 + v4l_dbg(1, debug, client, "set output %d\n", *iarg); 209 249 210 250 /* not much choice of outputs */ 211 - if (*iarg != 0) { 251 + if (*iarg != 0) 212 252 return -EINVAL; 213 - } 214 - } 215 253 break; 254 + } 216 255 217 256 case ENCODER_ENABLE_OUTPUT: 218 257 { ··· 217 262 218 263 encoder->enable = !!*iarg; 219 264 220 - dprintk(1, KERN_INFO "%s: enable output %d\n", 221 - I2C_NAME(client), encoder->enable); 222 - } 265 + v4l_dbg(1, debug, client, "enable output %d\n", encoder->enable); 223 266 break; 267 + } 224 268 225 269 default: 226 270 return -EINVAL; ··· 230 276 231 277 /* ----------------------------------------------------------------------- */ 232 278 233 - /* 234 - * Generic i2c probe 235 - * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 236 - */ 237 - static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END }; 279 + static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; 238 280 239 - static unsigned short ignore = I2C_CLIENT_END; 281 + I2C_CLIENT_INSMOD; 240 282 241 - static struct i2c_client_address_data addr_data = { 242 - .normal_i2c = normal_i2c, 243 - .probe = &ignore, 244 - .ignore = &ignore, 245 - }; 246 - 247 - static struct i2c_driver i2c_driver_bt856; 248 - 249 - static int 250 - bt856_detect_client (struct i2c_adapter *adapter, 251 - int address, 252 - int kind) 283 + static int bt856_probe(struct i2c_client *client, 284 + const struct i2c_device_id *id) 253 285 { 254 - int i; 255 - struct i2c_client *client; 256 286 struct bt856 *encoder; 257 287 258 - dprintk(1, 259 - KERN_INFO 260 - "bt856.c: detecting bt856 client on address 0x%x\n", 261 - address << 1); 262 - 263 288 /* Check if the adapter supports the needed features */ 264 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 265 - return 0; 289 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 290 + return -ENODEV; 266 291 267 - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 268 - if (!client) 269 - return -ENOMEM; 270 - client->addr = address; 271 - client->adapter = adapter; 272 - client->driver = &i2c_driver_bt856; 273 - strlcpy(I2C_NAME(client), "bt856", sizeof(I2C_NAME(client))); 292 + v4l_info(client, "chip found @ 0x%x (%s)\n", 293 + client->addr << 1, client->adapter->name); 274 294 275 295 encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL); 276 - if (encoder == NULL) { 277 - kfree(client); 296 + if (encoder == NULL) 278 297 return -ENOMEM; 279 - } 280 298 encoder->norm = VIDEO_MODE_NTSC; 281 299 encoder->enable = 1; 282 300 i2c_set_clientdata(client, encoder); 283 - 284 - i = i2c_attach_client(client); 285 - if (i) { 286 - kfree(client); 287 - kfree(encoder); 288 - return i; 289 - } 290 301 291 302 bt856_write(client, 0xdc, 0x18); 292 303 bt856_write(client, 0xda, 0); ··· 278 359 279 360 if (debug != 0) 280 361 bt856_dump(client); 281 - 282 - dprintk(1, KERN_INFO "%s_attach: at address 0x%x\n", I2C_NAME(client), 283 - client->addr << 1); 284 - 285 362 return 0; 286 363 } 287 364 288 - static int 289 - bt856_attach_adapter (struct i2c_adapter *adapter) 365 + static int bt856_remove(struct i2c_client *client) 290 366 { 291 - dprintk(1, 292 - KERN_INFO 293 - "bt856.c: starting probe for adapter %s (0x%x)\n", 294 - I2C_NAME(adapter), adapter->id); 295 - return i2c_probe(adapter, &addr_data, &bt856_detect_client); 296 - } 297 - 298 - static int 299 - bt856_detach_client (struct i2c_client *client) 300 - { 301 - struct bt856 *encoder = i2c_get_clientdata(client); 302 - int err; 303 - 304 - err = i2c_detach_client(client); 305 - if (err) { 306 - return err; 307 - } 308 - 309 - kfree(encoder); 310 - kfree(client); 311 - 367 + kfree(i2c_get_clientdata(client)); 312 368 return 0; 313 369 } 314 370 315 - /* ----------------------------------------------------------------------- */ 316 - 317 - static struct i2c_driver i2c_driver_bt856 = { 318 - .driver = { 319 - .name = "bt856", 320 - }, 321 - 322 - .id = I2C_DRIVERID_BT856, 323 - 324 - .attach_adapter = bt856_attach_adapter, 325 - .detach_client = bt856_detach_client, 326 - .command = bt856_command, 371 + static const struct i2c_device_id bt856_id[] = { 372 + { "bt856", 0 }, 373 + { } 327 374 }; 375 + MODULE_DEVICE_TABLE(i2c, bt856_id); 328 376 329 - static int __init 330 - bt856_init (void) 331 - { 332 - return i2c_add_driver(&i2c_driver_bt856); 333 - } 334 - 335 - static void __exit 336 - bt856_exit (void) 337 - { 338 - i2c_del_driver(&i2c_driver_bt856); 339 - } 340 - 341 - module_init(bt856_init); 342 - module_exit(bt856_exit); 377 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 378 + .name = "bt856", 379 + .driverid = I2C_DRIVERID_BT856, 380 + .command = bt856_command, 381 + .probe = bt856_probe, 382 + .remove = bt856_remove, 383 + .id_table = bt856_id, 384 + };
+84 -173
drivers/media/video/bt866.c
··· 29 29 */ 30 30 31 31 #include <linux/module.h> 32 - #include <linux/init.h> 33 - #include <linux/delay.h> 34 - #include <linux/errno.h> 35 - #include <linux/fs.h> 36 - #include <linux/kernel.h> 37 - #include <linux/major.h> 38 - #include <linux/slab.h> 39 - #include <linux/mm.h> 40 - #include <linux/signal.h> 41 - #include <asm/io.h> 42 - #include <asm/pgtable.h> 43 - #include <asm/page.h> 44 - #include <linux/sched.h> 45 32 #include <linux/types.h> 46 - #include <linux/i2c.h> 47 - 48 - #include <linux/videodev.h> 33 + #include <linux/ioctl.h> 49 34 #include <asm/uaccess.h> 50 - 35 + #include <linux/i2c.h> 36 + #include <linux/i2c-id.h> 37 + #include <linux/videodev.h> 51 38 #include <linux/video_encoder.h> 39 + #include <media/v4l2-common.h> 40 + #include <media/v4l2-i2c-drv-legacy.h> 52 41 42 + MODULE_DESCRIPTION("Brooktree-866 video encoder driver"); 43 + MODULE_AUTHOR("Mike Bernson & Dave Perks"); 53 44 MODULE_LICENSE("GPL"); 54 45 55 - #define BT866_DEVNAME "bt866" 56 - #define I2C_BT866 0x88 57 - 58 - MODULE_LICENSE("GPL"); 59 - 60 - #define DEBUG(x) /* Debug driver */ 46 + static int debug; 47 + module_param(debug, int, 0); 48 + MODULE_PARM_DESC(debug, "Debug level (0-1)"); 61 49 62 50 /* ----------------------------------------------------------------------- */ 63 51 64 52 struct bt866 { 65 - struct i2c_client *i2c; 66 - int addr; 67 - unsigned char reg[256]; 53 + u8 reg[256]; 68 54 69 55 int norm; 70 56 int enable; ··· 60 74 int sat; 61 75 }; 62 76 63 - static int bt866_write(struct bt866 *dev, 64 - unsigned char subaddr, unsigned char data); 65 - 66 - static int bt866_do_command(struct bt866 *encoder, 67 - unsigned int cmd, void *arg) 77 + static int bt866_write(struct i2c_client *client, u8 subaddr, u8 data) 68 78 { 79 + struct bt866 *encoder = i2c_get_clientdata(client); 80 + u8 buffer[2]; 81 + int err; 82 + 83 + buffer[0] = subaddr; 84 + buffer[1] = data; 85 + 86 + encoder->reg[subaddr] = data; 87 + 88 + v4l_dbg(1, debug, client, "write 0x%02x = 0x%02x\n", subaddr, data); 89 + 90 + for (err = 0; err < 3;) { 91 + if (i2c_master_send(client, buffer, 2) == 2) 92 + break; 93 + err++; 94 + v4l_warn(client, "error #%d writing to 0x%02x\n", 95 + err, subaddr); 96 + schedule_timeout_interruptible(msecs_to_jiffies(100)); 97 + } 98 + if (err == 3) { 99 + v4l_warn(client, "giving up\n"); 100 + return -1; 101 + } 102 + 103 + return 0; 104 + } 105 + 106 + static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg) 107 + { 108 + struct bt866 *encoder = i2c_get_clientdata(client); 109 + 69 110 switch (cmd) { 70 111 case ENCODER_GET_CAPABILITIES: 71 112 { 72 113 struct video_encoder_capability *cap = arg; 73 114 74 - DEBUG(printk 75 - (KERN_INFO "%s: get capabilities\n", 76 - encoder->i2c->name)); 115 + v4l_dbg(1, debug, client, "get capabilities\n"); 77 116 78 117 cap->flags 79 118 = VIDEO_ENCODER_PAL ··· 106 95 | VIDEO_ENCODER_CCIR; 107 96 cap->inputs = 2; 108 97 cap->outputs = 1; 98 + break; 109 99 } 110 - break; 111 100 112 101 case ENCODER_SET_NORM: 113 102 { 114 103 int *iarg = arg; 115 104 116 - DEBUG(printk(KERN_INFO "%s: set norm %d\n", 117 - encoder->i2c->name, *iarg)); 105 + v4l_dbg(1, debug, client, "set norm %d\n", *iarg); 118 106 119 107 switch (*iarg) { 120 - 121 108 case VIDEO_MODE_NTSC: 122 109 break; 123 110 ··· 124 115 125 116 default: 126 117 return -EINVAL; 127 - 128 118 } 129 119 encoder->norm = *iarg; 120 + break; 130 121 } 131 - break; 132 122 133 123 case ENCODER_SET_INPUT: 134 124 { ··· 163 155 u8 val; 164 156 165 157 for (i = 0; i < ARRAY_SIZE(init) / 2; i += 2) 166 - bt866_write(encoder, init[i], init[i+1]); 158 + bt866_write(client, init[i], init[i+1]); 167 159 168 160 val = encoder->reg[0xdc]; 169 161 ··· 172 164 else 173 165 val &= ~0x40; /* !CBSWAP */ 174 166 175 - bt866_write(encoder, 0xdc, val); 167 + bt866_write(client, 0xdc, val); 176 168 177 169 val = encoder->reg[0xcc]; 178 170 if (*iarg == 2) 179 171 val |= 0x01; /* OSDBAR */ 180 172 else 181 173 val &= ~0x01; /* !OSDBAR */ 182 - bt866_write(encoder, 0xcc, val); 174 + bt866_write(client, 0xcc, val); 183 175 184 - DEBUG(printk(KERN_INFO "%s: set input %d\n", 185 - encoder->i2c->name, *iarg)); 176 + v4l_dbg(1, debug, client, "set input %d\n", *iarg); 186 177 187 178 switch (*iarg) { 188 179 case 0: ··· 190 183 break; 191 184 default: 192 185 return -EINVAL; 193 - 194 186 } 187 + break; 195 188 } 196 - break; 197 189 198 190 case ENCODER_SET_OUTPUT: 199 191 { 200 192 int *iarg = arg; 201 193 202 - DEBUG(printk(KERN_INFO "%s: set output %d\n", 203 - encoder->i2c->name, *iarg)); 194 + v4l_dbg(1, debug, client, "set output %d\n", *iarg); 204 195 205 196 /* not much choice of outputs */ 206 197 if (*iarg != 0) 207 198 return -EINVAL; 199 + break; 208 200 } 209 - break; 210 201 211 202 case ENCODER_ENABLE_OUTPUT: 212 203 { 213 204 int *iarg = arg; 214 205 encoder->enable = !!*iarg; 215 206 216 - DEBUG(printk 217 - (KERN_INFO "%s: enable output %d\n", 218 - encoder->i2c->name, encoder->enable)); 207 + v4l_dbg(1, debug, client, "enable output %d\n", encoder->enable); 208 + break; 219 209 } 220 - break; 221 210 222 211 case 4711: 223 212 { 224 213 int *iarg = arg; 225 214 __u8 val; 226 215 227 - printk("bt866: square = %d\n", *iarg); 216 + v4l_dbg(1, debug, client, "square %d\n", *iarg); 228 217 229 218 val = encoder->reg[0xdc]; 230 219 if (*iarg) 231 220 val |= 1; /* SQUARE */ 232 221 else 233 222 val &= ~1; /* !SQUARE */ 234 - bt866_write(encoder, 0xdc, val); 223 + bt866_write(client, 0xdc, val); 235 224 break; 236 225 } 237 226 ··· 238 235 return 0; 239 236 } 240 237 241 - static int bt866_write(struct bt866 *encoder, 242 - unsigned char subaddr, unsigned char data) 243 - { 244 - unsigned char buffer[2]; 245 - int err; 238 + static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; 246 239 247 - buffer[0] = subaddr; 248 - buffer[1] = data; 240 + I2C_CLIENT_INSMOD; 249 241 250 - encoder->reg[subaddr] = data; 251 - 252 - DEBUG(printk 253 - ("%s: write 0x%02X = 0x%02X\n", 254 - encoder->i2c->name, subaddr, data)); 255 - 256 - for (err = 0; err < 3;) { 257 - if (i2c_master_send(encoder->i2c, buffer, 2) == 2) 258 - break; 259 - err++; 260 - printk(KERN_WARNING "%s: I/O error #%d " 261 - "(write 0x%02x/0x%02x)\n", 262 - encoder->i2c->name, err, encoder->addr, subaddr); 263 - schedule_timeout_interruptible(msecs_to_jiffies(100)); 264 - } 265 - if (err == 3) { 266 - printk(KERN_WARNING "%s: giving up\n", 267 - encoder->i2c->name); 268 - return -1; 269 - } 270 - 271 - return 0; 272 - } 273 - 274 - static int bt866_attach(struct i2c_adapter *adapter); 275 - static int bt866_detach(struct i2c_client *client); 276 - static int bt866_command(struct i2c_client *client, 277 - unsigned int cmd, void *arg); 278 - 279 - 280 - /* Addresses to scan */ 281 - static unsigned short normal_i2c[] = {I2C_BT866>>1, I2C_CLIENT_END}; 282 - static unsigned short probe[2] = {I2C_CLIENT_END, I2C_CLIENT_END}; 283 - static unsigned short ignore[2] = {I2C_CLIENT_END, I2C_CLIENT_END}; 284 - 285 - static struct i2c_client_address_data addr_data = { 286 - normal_i2c, 287 - probe, 288 - ignore, 289 - }; 290 - 291 - static struct i2c_driver i2c_driver_bt866 = { 292 - .driver.name = BT866_DEVNAME, 293 - .id = I2C_DRIVERID_BT866, 294 - .attach_adapter = bt866_attach, 295 - .detach_client = bt866_detach, 296 - .command = bt866_command 297 - }; 298 - 299 - 300 - static struct i2c_client bt866_client_tmpl = 301 - { 302 - .name = "(nil)", 303 - .addr = 0, 304 - .adapter = NULL, 305 - .driver = &i2c_driver_bt866, 306 - }; 307 - 308 - static int bt866_found_proc(struct i2c_adapter *adapter, 309 - int addr, int kind) 242 + static int bt866_probe(struct i2c_client *client, 243 + const struct i2c_device_id *id) 310 244 { 311 245 struct bt866 *encoder; 312 - struct i2c_client *client; 313 246 314 - client = kzalloc(sizeof(*client), GFP_KERNEL); 315 - if (client == NULL) 316 - return -ENOMEM; 317 - memcpy(client, &bt866_client_tmpl, sizeof(*client)); 247 + v4l_info(client, "chip found @ 0x%x (%s)\n", 248 + client->addr << 1, client->adapter->name); 318 249 319 250 encoder = kzalloc(sizeof(*encoder), GFP_KERNEL); 320 - if (encoder == NULL) { 321 - kfree(client); 251 + if (encoder == NULL) 322 252 return -ENOMEM; 323 - } 324 253 325 254 i2c_set_clientdata(client, encoder); 326 - client->adapter = adapter; 327 - client->addr = addr; 328 - sprintf(client->name, "%s-%02x", BT866_DEVNAME, adapter->id); 329 - 330 - encoder->i2c = client; 331 - encoder->addr = addr; 332 - //encoder->encoder_type = ENCODER_TYPE_UNKNOWN; 333 - 334 - /* initialize */ 335 - 336 - i2c_attach_client(client); 337 - 338 255 return 0; 339 256 } 340 257 341 - static int bt866_attach(struct i2c_adapter *adapter) 258 + static int bt866_remove(struct i2c_client *client) 342 259 { 343 - if (adapter->id == I2C_HW_B_ZR36067) 344 - return i2c_probe(adapter, &addr_data, bt866_found_proc); 260 + kfree(i2c_get_clientdata(client)); 345 261 return 0; 346 262 } 347 263 348 - static int bt866_detach(struct i2c_client *client) 264 + static int bt866_legacy_probe(struct i2c_adapter *adapter) 349 265 { 350 - struct bt866 *encoder = i2c_get_clientdata(client); 351 - 352 - i2c_detach_client(client); 353 - kfree(encoder); 354 - kfree(client); 355 - 356 - return 0; 266 + return adapter->id == I2C_HW_B_ZR36067; 357 267 } 358 268 359 - static int bt866_command(struct i2c_client *client, 360 - unsigned int cmd, void *arg) 361 - { 362 - struct bt866 *encoder = i2c_get_clientdata(client); 363 - return bt866_do_command(encoder, cmd, arg); 364 - } 269 + static const struct i2c_device_id bt866_id[] = { 270 + { "bt866", 0 }, 271 + { } 272 + }; 273 + MODULE_DEVICE_TABLE(i2c, bt866_id); 365 274 366 - static int __devinit bt866_init(void) 367 - { 368 - i2c_add_driver(&i2c_driver_bt866); 369 - return 0; 370 - } 371 - 372 - static void __devexit bt866_exit(void) 373 - { 374 - i2c_del_driver(&i2c_driver_bt866); 375 - } 376 - 377 - module_init(bt866_init); 378 - module_exit(bt866_exit); 275 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 276 + .name = "bt866", 277 + .driverid = I2C_DRIVERID_BT866, 278 + .command = bt866_command, 279 + .probe = bt866_probe, 280 + .remove = bt866_remove, 281 + .legacy_probe = bt866_legacy_probe, 282 + .id_table = bt866_id, 283 + };
+89 -63
drivers/media/video/cx23885/cx23885-cards.c
··· 39 39 .input = {{ 40 40 .type = CX23885_VMUX_COMPOSITE1, 41 41 .vmux = 0, 42 - },{ 42 + }, { 43 43 .type = CX23885_VMUX_COMPOSITE2, 44 44 .vmux = 1, 45 - },{ 45 + }, { 46 46 .type = CX23885_VMUX_COMPOSITE3, 47 47 .vmux = 2, 48 - },{ 48 + }, { 49 49 .type = CX23885_VMUX_COMPOSITE4, 50 50 .vmux = 3, 51 - }}, 51 + } }, 52 52 }, 53 53 [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = { 54 54 .name = "Hauppauge WinTV-HVR1800lp", ··· 57 57 .type = CX23885_VMUX_TELEVISION, 58 58 .vmux = 0, 59 59 .gpio0 = 0xff00, 60 - },{ 60 + }, { 61 61 .type = CX23885_VMUX_DEBUG, 62 62 .vmux = 0, 63 63 .gpio0 = 0xff01, 64 - },{ 64 + }, { 65 65 .type = CX23885_VMUX_COMPOSITE1, 66 66 .vmux = 1, 67 67 .gpio0 = 0xff02, 68 - },{ 68 + }, { 69 69 .type = CX23885_VMUX_SVIDEO, 70 70 .vmux = 2, 71 71 .gpio0 = 0xff02, 72 - }}, 72 + } }, 73 73 }, 74 74 [CX23885_BOARD_HAUPPAUGE_HVR1800] = { 75 75 .name = "Hauppauge WinTV-HVR1800", ··· 84 84 CX25840_VIN5_CH2 | 85 85 CX25840_VIN2_CH1, 86 86 .gpio0 = 0, 87 - },{ 87 + }, { 88 88 .type = CX23885_VMUX_COMPOSITE1, 89 89 .vmux = CX25840_VIN7_CH3 | 90 90 CX25840_VIN4_CH2 | 91 91 CX25840_VIN6_CH1, 92 92 .gpio0 = 0, 93 - },{ 93 + }, { 94 94 .type = CX23885_VMUX_SVIDEO, 95 95 .vmux = CX25840_VIN7_CH3 | 96 96 CX25840_VIN4_CH2 | 97 97 CX25840_VIN8_CH1 | 98 98 CX25840_SVIDEO_ON, 99 99 .gpio0 = 0, 100 - }}, 100 + } }, 101 101 }, 102 102 [CX23885_BOARD_HAUPPAUGE_HVR1250] = { 103 103 .name = "Hauppauge WinTV-HVR1250", ··· 106 106 .type = CX23885_VMUX_TELEVISION, 107 107 .vmux = 0, 108 108 .gpio0 = 0xff00, 109 - },{ 109 + }, { 110 110 .type = CX23885_VMUX_DEBUG, 111 111 .vmux = 0, 112 112 .gpio0 = 0xff01, 113 - },{ 113 + }, { 114 114 .type = CX23885_VMUX_COMPOSITE1, 115 115 .vmux = 1, 116 116 .gpio0 = 0xff02, 117 - },{ 117 + }, { 118 118 .type = CX23885_VMUX_SVIDEO, 119 119 .vmux = 2, 120 120 .gpio0 = 0xff02, 121 - }}, 121 + } }, 122 122 }, 123 123 [CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP] = { 124 124 .name = "DViCO FusionHDTV5 Express", ··· 169 169 .subvendor = 0x0070, 170 170 .subdevice = 0x3400, 171 171 .card = CX23885_BOARD_UNKNOWN, 172 - },{ 172 + }, { 173 173 .subvendor = 0x0070, 174 174 .subdevice = 0x7600, 175 175 .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp, 176 - },{ 176 + }, { 177 177 .subvendor = 0x0070, 178 178 .subdevice = 0x7800, 179 179 .card = CX23885_BOARD_HAUPPAUGE_HVR1800, 180 - },{ 180 + }, { 181 181 .subvendor = 0x0070, 182 182 .subdevice = 0x7801, 183 183 .card = CX23885_BOARD_HAUPPAUGE_HVR1800, 184 - },{ 184 + }, { 185 185 .subvendor = 0x0070, 186 186 .subdevice = 0x7809, 187 187 .card = CX23885_BOARD_HAUPPAUGE_HVR1800, 188 - },{ 188 + }, { 189 189 .subvendor = 0x0070, 190 190 .subdevice = 0x7911, 191 191 .card = CX23885_BOARD_HAUPPAUGE_HVR1250, 192 - },{ 192 + }, { 193 193 .subvendor = 0x18ac, 194 194 .subdevice = 0xd500, 195 195 .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP, 196 - },{ 196 + }, { 197 197 .subvendor = 0x0070, 198 198 .subdevice = 0x7790, 199 199 .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q, 200 - },{ 200 + }, { 201 201 .subvendor = 0x0070, 202 202 .subdevice = 0x7797, 203 203 .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q, 204 - },{ 204 + }, { 205 205 .subvendor = 0x0070, 206 206 .subdevice = 0x7710, 207 207 .card = CX23885_BOARD_HAUPPAUGE_HVR1500, 208 - },{ 208 + }, { 209 209 .subvendor = 0x0070, 210 210 .subdevice = 0x7717, 211 211 .card = CX23885_BOARD_HAUPPAUGE_HVR1500, ··· 225 225 .subvendor = 0x0070, 226 226 .subdevice = 0x8010, 227 227 .card = CX23885_BOARD_HAUPPAUGE_HVR1400, 228 - },{ 228 + }, { 229 229 .subvendor = 0x18ac, 230 230 .subdevice = 0xd618, 231 231 .card = CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP, 232 - },{ 232 + }, { 233 233 .subvendor = 0x18ac, 234 234 .subdevice = 0xdb78, 235 235 .card = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP, ··· 247 247 248 248 if (0 == dev->pci->subsystem_vendor && 249 249 0 == dev->pci->subsystem_device) { 250 - printk("%s: Your board has no valid PCIe Subsystem ID and thus can't\n" 251 - "%s: be autodetected. Please pass card=<n> insmod option to\n" 252 - "%s: workaround that. Redirect complaints to the vendor of\n" 253 - "%s: the TV card. Best regards,\n" 250 + printk(KERN_INFO 251 + "%s: Board has no valid PCIe Subsystem ID and can't\n" 252 + "%s: be autodetected. Pass card=<n> insmod option\n" 253 + "%s: to workaround that. Redirect complaints to the\n" 254 + "%s: vendor of the TV card. Best regards,\n" 254 255 "%s: -- tux\n", 255 256 dev->name, dev->name, dev->name, dev->name, dev->name); 256 257 } else { 257 - printk("%s: Your board isn't known (yet) to the driver. You can\n" 258 - "%s: try to pick one of the existing card configs via\n" 258 + printk(KERN_INFO 259 + "%s: Your board isn't known (yet) to the driver.\n" 260 + "%s: Try to pick one of the existing card configs via\n" 259 261 "%s: card=<n> insmod option. Updating to the latest\n" 260 262 "%s: version might help as well.\n", 261 263 dev->name, dev->name, dev->name, dev->name); 262 264 } 263 - printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n", 265 + printk(KERN_INFO "%s: Here is a list of valid choices for the card=<n> insmod option:\n", 264 266 dev->name); 265 267 for (i = 0; i < cx23885_bcount; i++) 266 - printk("%s: card=%d -> %s\n", 268 + printk(KERN_INFO "%s: card=%d -> %s\n", 267 269 dev->name, i, cx23885_boards[i].name); 268 270 } 269 271 ··· 273 271 { 274 272 struct tveeprom tv; 275 273 276 - tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv, eeprom_data); 274 + tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv, 275 + eeprom_data); 277 276 278 277 /* Make sure we support the board model */ 279 - switch (tv.model) 280 - { 278 + switch (tv.model) { 281 279 case 71009: 282 280 /* WinTV-HVR1200 (PCIe, Retail, full height) 283 281 * DVB-T and basic analog */ ··· 305 303 case 71999: 306 304 /* WinTV-HVR1200 (PCIe, OEM, full height) 307 305 * DVB-T and basic analog */ 308 - case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */ 309 - case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */ 310 - case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */ 311 - case 77041: /* WinTV-HVR1500Q (Express Card, OEM, No IR, ATSC/QAM and Basic analog */ 312 - case 77051: /* WinTV-HVR1500Q (Express Card, Retail, No IR, ATSC/QAM and Basic analog */ 313 - case 78011: /* WinTV-HVR1800 (PCIe, Retail, 3.5mm in, IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */ 314 - case 78501: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, Dual channel ATSC and MPEG2 HW Encoder */ 315 - case 78521: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, Dual channel ATSC and MPEG2 HW Encoder */ 316 - case 78531: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */ 317 - case 78631: /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */ 318 - case 79001: /* WinTV-HVR1250 (PCIe, Retail, IR, full height, ATSC and Basic analog */ 319 - case 79101: /* WinTV-HVR1250 (PCIe, Retail, IR, half height, ATSC and Basic analog */ 320 - case 79561: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */ 321 - case 79571: /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, ATSC and Basic analog */ 322 - case 79671: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */ 306 + case 76601: 307 + /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual 308 + channel ATSC and MPEG2 HW Encoder */ 309 + case 77001: 310 + /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC 311 + and Basic analog */ 312 + case 77011: 313 + /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC 314 + and Basic analog */ 315 + case 77041: 316 + /* WinTV-HVR1500Q (Express Card, OEM, No IR, ATSC/QAM 317 + and Basic analog */ 318 + case 77051: 319 + /* WinTV-HVR1500Q (Express Card, Retail, No IR, ATSC/QAM 320 + and Basic analog */ 321 + case 78011: 322 + /* WinTV-HVR1800 (PCIe, Retail, 3.5mm in, IR, No FM, 323 + Dual channel ATSC and MPEG2 HW Encoder */ 324 + case 78501: 325 + /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, 326 + Dual channel ATSC and MPEG2 HW Encoder */ 327 + case 78521: 328 + /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, 329 + Dual channel ATSC and MPEG2 HW Encoder */ 330 + case 78531: 331 + /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, No FM, 332 + Dual channel ATSC and MPEG2 HW Encoder */ 333 + case 78631: 334 + /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM, 335 + Dual channel ATSC and MPEG2 HW Encoder */ 336 + case 79001: 337 + /* WinTV-HVR1250 (PCIe, Retail, IR, full height, 338 + ATSC and Basic analog */ 339 + case 79101: 340 + /* WinTV-HVR1250 (PCIe, Retail, IR, half height, 341 + ATSC and Basic analog */ 342 + case 79561: 343 + /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, 344 + ATSC and Basic analog */ 345 + case 79571: 346 + /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, 347 + ATSC and Basic analog */ 348 + case 79671: 349 + /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, 350 + ATSC and Basic analog */ 323 351 case 80019: 324 352 /* WinTV-HVR1400 (Express Card, Retail, IR, 325 353 * DVB-T and Basic analog */ ··· 361 329 * DVB-T and MPEG2 HW Encoder */ 362 330 break; 363 331 default: 364 - printk("%s: warning: unknown hauppauge model #%d\n", dev->name, tv.model); 332 + printk(KERN_WARNING "%s: warning: unknown hauppauge model #%d\n", 333 + dev->name, tv.model); 365 334 break; 366 335 } 367 336 ··· 385 352 return -EINVAL; 386 353 } 387 354 388 - switch(dev->board) { 355 + switch (dev->board) { 389 356 case CX23885_BOARD_HAUPPAUGE_HVR1400: 390 357 case CX23885_BOARD_HAUPPAUGE_HVR1500: 391 358 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: ··· 416 383 417 384 void cx23885_gpio_setup(struct cx23885_dev *dev) 418 385 { 419 - switch(dev->board) { 386 + switch (dev->board) { 420 387 case CX23885_BOARD_HAUPPAUGE_HVR1250: 421 388 /* GPIO-0 cx24227 demodulator reset */ 422 389 cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */ ··· 650 617 } 651 618 652 619 /* ------------------------------------------------------------------ */ 653 - 654 - /* 655 - * Local variables: 656 - * c-basic-offset: 8 657 - * End: 658 - * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off 659 - */
+156 -120
drivers/media/video/cx23885/cx23885-core.c
··· 37 37 MODULE_LICENSE("GPL"); 38 38 39 39 static unsigned int debug; 40 - module_param(debug,int,0644); 41 - MODULE_PARM_DESC(debug,"enable debug messages"); 40 + module_param(debug, int, 0644); 41 + MODULE_PARM_DESC(debug, "enable debug messages"); 42 42 43 43 static unsigned int card[] = {[0 ... (CX23885_MAXBOARDS - 1)] = UNSET }; 44 44 module_param_array(card, int, NULL, 0444); 45 - MODULE_PARM_DESC(card,"card type"); 45 + MODULE_PARM_DESC(card, "card type"); 46 46 47 47 #define dprintk(level, fmt, arg...)\ 48 48 do { if (debug >= level)\ ··· 364 364 list_del(&buf->vb.queue); 365 365 wake_up(&buf->vb.done); 366 366 } 367 - if (list_empty(&q->active)) { 367 + if (list_empty(&q->active)) 368 368 del_timer(&q->timeout); 369 - } else { 369 + else 370 370 mod_timer(&q->timeout, jiffies + BUFFER_TIMEOUT); 371 - } 372 371 if (bc != 1) 373 - printk("%s: %d buffers handled (should be 1)\n", 372 + printk(KERN_WARNING "%s: %d buffers handled (should be 1)\n", 374 373 __func__, bc); 375 374 } 376 375 ··· 380 381 unsigned int i, lines; 381 382 u32 cdt; 382 383 383 - if (ch->cmds_start == 0) 384 - { 384 + if (ch->cmds_start == 0) { 385 385 dprintk(1, "%s() Erasing channel [%s]\n", __func__, 386 386 ch->name); 387 387 cx_write(ch->ptr1_reg, 0); ··· 416 418 417 419 /* write CMDS */ 418 420 if (ch->jumponly) 419 - cx_write(ch->cmds_start + 0, 8); 421 + cx_write(ch->cmds_start + 0, 8); 420 422 else 421 - cx_write(ch->cmds_start + 0, risc); 423 + cx_write(ch->cmds_start + 0, risc); 422 424 cx_write(ch->cmds_start + 4, 0); /* 64 bits 63-32 */ 423 425 cx_write(ch->cmds_start + 8, cdt); 424 426 cx_write(ch->cmds_start + 12, (lines*16) >> 3); 425 427 cx_write(ch->cmds_start + 16, ch->ctrl_start); 426 428 if (ch->jumponly) 427 - cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2) ); 429 + cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2)); 428 430 else 429 431 cx_write(ch->cmds_start + 20, 64 >> 2); 430 432 for (i = 24; i < 80; i += 4) ··· 434 436 cx_write(ch->ptr1_reg, ch->fifo_start); 435 437 cx_write(ch->ptr2_reg, cdt); 436 438 cx_write(ch->cnt2_reg, (lines*16) >> 3); 437 - cx_write(ch->cnt1_reg, (bpl >> 3) -1); 439 + cx_write(ch->cnt1_reg, (bpl >> 3) - 1); 438 440 439 - dprintk(2,"[bridge %d] sram setup %s: bpl=%d lines=%d\n", 441 + dprintk(2, "[bridge %d] sram setup %s: bpl=%d lines=%d\n", 440 442 dev->bridge, 441 443 ch->name, 442 444 bpl, ··· 467 469 u32 risc; 468 470 unsigned int i, j, n; 469 471 470 - printk("%s: %s - dma channel status dump\n", 472 + printk(KERN_WARNING "%s: %s - dma channel status dump\n", 471 473 dev->name, ch->name); 472 474 for (i = 0; i < ARRAY_SIZE(name); i++) 473 - printk("%s: cmds: %-15s: 0x%08x\n", 475 + printk(KERN_WARNING "%s: cmds: %-15s: 0x%08x\n", 474 476 dev->name, name[i], 475 477 cx_read(ch->cmds_start + 4*i)); 476 478 477 479 for (i = 0; i < 4; i++) { 478 480 risc = cx_read(ch->cmds_start + 4 * (i + 14)); 479 - printk("%s: risc%d: ", dev->name, i); 481 + printk(KERN_WARNING "%s: risc%d: ", dev->name, i); 480 482 cx23885_risc_decode(risc); 481 483 } 482 484 for (i = 0; i < (64 >> 2); i += n) { 483 485 risc = cx_read(ch->ctrl_start + 4 * i); 484 486 /* No consideration for bits 63-32 */ 485 487 486 - printk("%s: (0x%08x) iq %x: ", dev->name, 488 + printk(KERN_WARNING "%s: (0x%08x) iq %x: ", dev->name, 487 489 ch->ctrl_start + 4 * i, i); 488 490 n = cx23885_risc_decode(risc); 489 491 for (j = 1; j < n; j++) { 490 492 risc = cx_read(ch->ctrl_start + 4 * (i + j)); 491 - printk("%s: iq %x: 0x%08x [ arg #%d ]\n", 493 + printk(KERN_WARNING "%s: iq %x: 0x%08x [ arg #%d ]\n", 492 494 dev->name, i+j, risc, j); 493 495 } 494 496 } 495 497 496 - printk("%s: fifo: 0x%08x -> 0x%x\n", 498 + printk(KERN_WARNING "%s: fifo: 0x%08x -> 0x%x\n", 497 499 dev->name, ch->fifo_start, ch->fifo_start+ch->fifo_size); 498 - printk("%s: ctrl: 0x%08x -> 0x%x\n", 500 + printk(KERN_WARNING "%s: ctrl: 0x%08x -> 0x%x\n", 499 501 dev->name, ch->ctrl_start, ch->ctrl_start + 6*16); 500 - printk("%s: ptr1_reg: 0x%08x\n", 502 + printk(KERN_WARNING "%s: ptr1_reg: 0x%08x\n", 501 503 dev->name, cx_read(ch->ptr1_reg)); 502 - printk("%s: ptr2_reg: 0x%08x\n", 504 + printk(KERN_WARNING "%s: ptr2_reg: 0x%08x\n", 503 505 dev->name, cx_read(ch->ptr2_reg)); 504 - printk("%s: cnt1_reg: 0x%08x\n", 506 + printk(KERN_WARNING "%s: cnt1_reg: 0x%08x\n", 505 507 dev->name, cx_read(ch->cnt1_reg)); 506 - printk("%s: cnt2_reg: 0x%08x\n", 508 + printk(KERN_WARNING "%s: cnt2_reg: 0x%08x\n", 507 509 dev->name, cx_read(ch->cnt2_reg)); 508 510 } 509 511 ··· 513 515 struct cx23885_dev *dev = port->dev; 514 516 unsigned int i, j, n; 515 517 516 - printk("%s: risc disasm: %p [dma=0x%08lx]\n", 518 + printk(KERN_INFO "%s: risc disasm: %p [dma=0x%08lx]\n", 517 519 dev->name, risc->cpu, (unsigned long)risc->dma); 518 520 for (i = 0; i < (risc->size >> 2); i += n) { 519 - printk("%s: %04d: ", dev->name, i); 521 + printk(KERN_INFO "%s: %04d: ", dev->name, i); 520 522 n = cx23885_risc_decode(le32_to_cpu(risc->cpu[i])); 521 523 for (j = 1; j < n; j++) 522 - printk("%s: %04d: 0x%08x [ arg #%d ]\n", 524 + printk(KERN_INFO "%s: %04d: 0x%08x [ arg #%d ]\n", 523 525 dev->name, i + j, risc->cpu[i + j], j); 524 526 if (risc->cpu[i] == cpu_to_le32(RISC_JUMP)) 525 527 break; ··· 598 600 * when DMA begins if RDR_TLCTL0 bit4 is not cleared. It does not 599 601 * occur on the cx23887 bridge. 600 602 */ 601 - if(dev->bridge == CX23885_BRIDGE_885) 603 + if (dev->bridge == CX23885_BRIDGE_885) 602 604 cx_clear(RDR_TLCTL0, 1 << 4); 603 605 604 606 return 0; ··· 606 608 607 609 static int get_resources(struct cx23885_dev *dev) 608 610 { 609 - if (request_mem_region(pci_resource_start(dev->pci,0), 610 - pci_resource_len(dev->pci,0), 611 + if (request_mem_region(pci_resource_start(dev->pci, 0), 612 + pci_resource_len(dev->pci, 0), 611 613 dev->name)) 612 614 return 0; 613 615 614 616 printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n", 615 - dev->name, (unsigned long long)pci_resource_start(dev->pci,0)); 617 + dev->name, (unsigned long long)pci_resource_start(dev->pci, 0)); 616 618 617 619 return -EBUSY; 618 620 } ··· 621 623 int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, 622 624 u32 reg, u32 mask, u32 value); 623 625 624 - static int cx23885_init_tsport(struct cx23885_dev *dev, struct cx23885_tsport *port, int portno) 626 + static int cx23885_init_tsport(struct cx23885_dev *dev, 627 + struct cx23885_tsport *port, int portno) 625 628 { 626 629 dprintk(1, "%s(portno=%d)\n", __func__, portno); 627 630 ··· 642 643 port->mpegq.timeout.data = (unsigned long)port; 643 644 init_timer(&port->mpegq.timeout); 644 645 645 - switch(portno) { 646 + mutex_init(&port->frontends.lock); 647 + INIT_LIST_HEAD(&port->frontends.felist); 648 + port->frontends.active_fe_id = 0; 649 + 650 + /* This should be hardcoded allow a single frontend 651 + * attachment to this tsport, keeping the -dvb.c 652 + * code clean and safe. 653 + */ 654 + if (!port->num_frontends) 655 + port->num_frontends = 1; 656 + 657 + switch (portno) { 646 658 case 1: 647 659 port->reg_gpcnt = VID_B_GPCNT; 648 660 port->reg_gpcnt_ctl = VID_B_GPCNT_CTL; ··· 754 744 mutex_unlock(&devlist); 755 745 756 746 /* Configure the internal memory */ 757 - if(dev->pci->device == 0x8880) { 747 + if (dev->pci->device == 0x8880) { 758 748 dev->bridge = CX23885_BRIDGE_887; 759 749 /* Apply a sensible clock frequency for the PCIe bridge */ 760 750 dev->clk_freq = 25000000; 761 751 dev->sram_channels = cx23887_sram_channels; 762 752 } else 763 - if(dev->pci->device == 0x8852) { 753 + if (dev->pci->device == 0x8852) { 764 754 dev->bridge = CX23885_BRIDGE_885; 765 755 /* Apply a sensible clock frequency for the PCIe bridge */ 766 756 dev->clk_freq = 28000000; ··· 841 831 } 842 832 843 833 /* PCIe stuff */ 844 - dev->lmmio = ioremap(pci_resource_start(dev->pci,0), 845 - pci_resource_len(dev->pci,0)); 834 + dev->lmmio = ioremap(pci_resource_start(dev->pci, 0), 835 + pci_resource_len(dev->pci, 0)); 846 836 847 837 dev->bmmio = (u8 __iomem *)dev->lmmio; 848 838 ··· 872 862 cx23885_i2c_register(&dev->i2c_bus[1]); 873 863 cx23885_i2c_register(&dev->i2c_bus[2]); 874 864 cx23885_card_setup(dev); 875 - cx23885_call_i2c_clients (&dev->i2c_bus[0], TUNER_SET_STANDBY, NULL); 865 + cx23885_call_i2c_clients(&dev->i2c_bus[0], TUNER_SET_STANDBY, NULL); 876 866 cx23885_ir_init(dev); 877 867 878 868 if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { ··· 918 908 919 909 static void cx23885_dev_unregister(struct cx23885_dev *dev) 920 910 { 921 - release_mem_region(pci_resource_start(dev->pci,0), 922 - pci_resource_len(dev->pci,0)); 911 + release_mem_region(pci_resource_start(dev->pci, 0), 912 + pci_resource_len(dev->pci, 0)); 923 913 924 914 if (!atomic_dec_and_test(&dev->refcount)) 925 915 return; ··· 946 936 iounmap(dev->lmmio); 947 937 } 948 938 949 - static __le32* cx23885_risc_field(__le32 *rp, struct scatterlist *sglist, 939 + static __le32 *cx23885_risc_field(__le32 *rp, struct scatterlist *sglist, 950 940 unsigned int offset, u32 sync_line, 951 941 unsigned int bpl, unsigned int padding, 952 942 unsigned int lines) ··· 967 957 } 968 958 if (bpl <= sg_dma_len(sg)-offset) { 969 959 /* fits into current chunk */ 970 - *(rp++)=cpu_to_le32(RISC_WRITE|RISC_SOL|RISC_EOL|bpl); 971 - *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); 972 - *(rp++)=cpu_to_le32(0); /* bits 63-32 */ 973 - offset+=bpl; 960 + *(rp++) = cpu_to_le32(RISC_WRITE|RISC_SOL|RISC_EOL|bpl); 961 + *(rp++) = cpu_to_le32(sg_dma_address(sg)+offset); 962 + *(rp++) = cpu_to_le32(0); /* bits 63-32 */ 963 + offset += bpl; 974 964 } else { 975 965 /* scanline needs to be split */ 976 966 todo = bpl; 977 - *(rp++)=cpu_to_le32(RISC_WRITE|RISC_SOL| 967 + *(rp++) = cpu_to_le32(RISC_WRITE|RISC_SOL| 978 968 (sg_dma_len(sg)-offset)); 979 - *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); 980 - *(rp++)=cpu_to_le32(0); /* bits 63-32 */ 969 + *(rp++) = cpu_to_le32(sg_dma_address(sg)+offset); 970 + *(rp++) = cpu_to_le32(0); /* bits 63-32 */ 981 971 todo -= (sg_dma_len(sg)-offset); 982 972 offset = 0; 983 973 sg++; 984 974 while (todo > sg_dma_len(sg)) { 985 - *(rp++)=cpu_to_le32(RISC_WRITE| 975 + *(rp++) = cpu_to_le32(RISC_WRITE| 986 976 sg_dma_len(sg)); 987 - *(rp++)=cpu_to_le32(sg_dma_address(sg)); 988 - *(rp++)=cpu_to_le32(0); /* bits 63-32 */ 977 + *(rp++) = cpu_to_le32(sg_dma_address(sg)); 978 + *(rp++) = cpu_to_le32(0); /* bits 63-32 */ 989 979 todo -= sg_dma_len(sg); 990 980 sg++; 991 981 } 992 - *(rp++)=cpu_to_le32(RISC_WRITE|RISC_EOL|todo); 993 - *(rp++)=cpu_to_le32(sg_dma_address(sg)); 994 - *(rp++)=cpu_to_le32(0); /* bits 63-32 */ 982 + *(rp++) = cpu_to_le32(RISC_WRITE|RISC_EOL|todo); 983 + *(rp++) = cpu_to_le32(sg_dma_address(sg)); 984 + *(rp++) = cpu_to_le32(0); /* bits 63-32 */ 995 985 offset += todo; 996 986 } 997 987 offset += padding; ··· 1020 1010 can cause next bpl to start close to a page border. First DMA 1021 1011 region may be smaller than PAGE_SIZE */ 1022 1012 /* write and jump need and extra dword */ 1023 - instructions = fields * (1 + ((bpl + padding) * lines) / PAGE_SIZE + lines); 1013 + instructions = fields * (1 + ((bpl + padding) * lines) 1014 + / PAGE_SIZE + lines); 1024 1015 instructions += 2; 1025 - if ((rc = btcx_riscmem_alloc(pci,risc,instructions*12)) < 0) 1016 + rc = btcx_riscmem_alloc(pci, risc, instructions*12); 1017 + if (rc < 0) 1026 1018 return rc; 1027 1019 1028 1020 /* write risc instructions */ ··· 1038 1026 1039 1027 /* save pointer to jmp instruction address */ 1040 1028 risc->jmp = rp; 1041 - BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); 1029 + BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); 1042 1030 return 0; 1043 1031 } 1044 1032 ··· 1060 1048 instructions = 1 + (bpl * lines) / PAGE_SIZE + lines; 1061 1049 instructions += 1; 1062 1050 1063 - if ((rc = btcx_riscmem_alloc(pci,risc,instructions*12)) < 0) 1051 + rc = btcx_riscmem_alloc(pci, risc, instructions*12); 1052 + if (rc < 0) 1064 1053 return rc; 1065 1054 1066 1055 /* write risc instructions */ ··· 1070 1057 1071 1058 /* save pointer to jmp instruction address */ 1072 1059 risc->jmp = rp; 1073 - BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); 1060 + BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); 1074 1061 return 0; 1075 1062 } 1076 1063 ··· 1080 1067 __le32 *rp; 1081 1068 int rc; 1082 1069 1083 - if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0) 1070 + rc = btcx_riscmem_alloc(pci, risc, 4*16); 1071 + if (rc < 0) 1084 1072 return rc; 1085 1073 1086 1074 /* write risc instructions */ ··· 1175 1161 1176 1162 /* setup fifo + format */ 1177 1163 cx23885_sram_channel_setup(dev, 1178 - &dev->sram_channels[ port->sram_chno ], 1164 + &dev->sram_channels[port->sram_chno], 1179 1165 port->ts_packet_size, buf->risc.dma); 1180 - if(debug > 5) { 1181 - cx23885_sram_channel_dump(dev, &dev->sram_channels[ port->sram_chno ] ); 1166 + if (debug > 5) { 1167 + cx23885_sram_channel_dump(dev, 1168 + &dev->sram_channels[port->sram_chno]); 1182 1169 cx23885_risc_disasm(port, &buf->risc); 1183 1170 } 1184 1171 1185 1172 /* write TS length to chip */ 1186 1173 cx_write(port->reg_lngth, buf->vb.width); 1187 1174 1188 - if ( (!(cx23885_boards[dev->board].portb & CX23885_MPEG_DVB)) && 1189 - (!(cx23885_boards[dev->board].portc & CX23885_MPEG_DVB)) ) { 1190 - printk( "%s() Failed. Unsupported value in .portb/c (0x%08x)/(0x%08x)\n", 1175 + if ((!(cx23885_boards[dev->board].portb & CX23885_MPEG_DVB)) && 1176 + (!(cx23885_boards[dev->board].portc & CX23885_MPEG_DVB))) { 1177 + printk("%s() Unsupported .portb/c (0x%08x)/(0x%08x)\n", 1191 1178 __func__, 1192 1179 cx23885_boards[dev->board].portb, 1193 - cx23885_boards[dev->board].portc ); 1180 + cx23885_boards[dev->board].portc); 1194 1181 return -EINVAL; 1195 1182 } 1196 1183 ··· 1201 1186 udelay(100); 1202 1187 1203 1188 /* If the port supports SRC SELECT, configure it */ 1204 - if(port->reg_src_sel) 1189 + if (port->reg_src_sel) 1205 1190 cx_write(port->reg_src_sel, port->src_sel_val); 1206 1191 1207 1192 cx_write(port->reg_hw_sop_ctrl, port->hw_sop_ctrl_val); ··· 1210 1195 cx_write(port->reg_gen_ctrl, port->gen_ctrl_val); 1211 1196 udelay(100); 1212 1197 1213 - // NOTE: this is 2 (reserved) for portb, does it matter? 1198 + /* NOTE: this is 2 (reserved) for portb, does it matter? */ 1214 1199 /* reset counter to zero */ 1215 1200 cx_write(port->reg_gpcnt_ctl, 3); 1216 1201 q->count = 1; ··· 1244 1229 cx_write(ALT_PIN_OUT_SEL, 0x10100045); 1245 1230 } 1246 1231 1247 - switch(dev->bridge) { 1232 + switch (dev->bridge) { 1248 1233 case CX23885_BRIDGE_885: 1249 1234 case CX23885_BRIDGE_887: 1250 1235 /* enable irqs */ 1251 - dprintk(1, "%s() enabling TS int's and DMA\n", __func__ ); 1236 + dprintk(1, "%s() enabling TS int's and DMA\n", __func__); 1252 1237 cx_set(port->reg_ts_int_msk, port->ts_int_msk_val); 1253 1238 cx_set(port->reg_dma_ctl, port->dma_ctl_val); 1254 1239 cx_set(PCI_INT_MSK, dev->pci_irqmask | port->pci_irqmask); ··· 1307 1292 struct cx23885_buffer *buf; 1308 1293 1309 1294 dprintk(5, "%s()\n", __func__); 1310 - if (list_empty(&q->active)) 1311 - { 1295 + if (list_empty(&q->active)) { 1312 1296 struct cx23885_buffer *prev; 1313 1297 prev = NULL; 1314 1298 ··· 1325 1311 buf->vb.state = VIDEOBUF_ACTIVE; 1326 1312 buf->count = q->count++; 1327 1313 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 1328 - dprintk(5, "[%p/%d] restart_queue - first active\n", 1314 + dprintk(5, "[%p/%d] restart_queue - f/active\n", 1329 1315 buf, buf->vb.i); 1330 1316 1331 1317 } else if (prev->vb.width == buf->vb.width && ··· 1336 1322 buf->vb.state = VIDEOBUF_ACTIVE; 1337 1323 buf->count = q->count++; 1338 1324 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 1339 - prev->risc.jmp[2] = cpu_to_le32(0); /* 64 bit bits 63-32 */ 1340 - dprintk(5,"[%p/%d] restart_queue - move to active\n", 1325 + /* 64 bit bits 63-32 */ 1326 + prev->risc.jmp[2] = cpu_to_le32(0); 1327 + dprintk(5, "[%p/%d] restart_queue - m/active\n", 1341 1328 buf, buf->vb.i); 1342 1329 } else { 1343 1330 return 0; ··· 1377 1362 buf->vb.size = size; 1378 1363 buf->vb.field = field /*V4L2_FIELD_TOP*/; 1379 1364 1380 - if (0 != (rc = videobuf_iolock(q, &buf->vb, NULL))) 1365 + rc = videobuf_iolock(q, &buf->vb, NULL); 1366 + if (0 != rc) 1381 1367 goto fail; 1382 1368 cx23885_risc_databuffer(dev->pci, &buf->risc, 1383 1369 videobuf_to_dma(&buf->vb)->sglist, ··· 1404 1388 buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ 1405 1389 1406 1390 if (list_empty(&cx88q->active)) { 1407 - dprintk( 1, "queue is empty - first active\n" ); 1391 + dprintk(1, "queue is empty - first active\n"); 1408 1392 list_add_tail(&buf->vb.queue, &cx88q->active); 1409 1393 cx23885_start_dma(port, cx88q, buf); 1410 1394 buf->vb.state = VIDEOBUF_ACTIVE; ··· 1413 1397 dprintk(1, "[%p/%d] %s - first active\n", 1414 1398 buf, buf->vb.i, __func__); 1415 1399 } else { 1416 - dprintk( 1, "queue is not empty - append to active\n" ); 1400 + dprintk(1, "queue is not empty - append to active\n"); 1417 1401 prev = list_entry(cx88q->active.prev, struct cx23885_buffer, 1418 1402 vb.queue); 1419 1403 list_add_tail(&buf->vb.queue, &cx88q->active); ··· 1421 1405 buf->count = cx88q->count++; 1422 1406 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 1423 1407 prev->risc.jmp[2] = cpu_to_le32(0); /* 64 bit bits 63-32 */ 1424 - dprintk( 1, "[%p/%d] %s - append to active\n", 1408 + dprintk(1, "[%p/%d] %s - append to active\n", 1425 1409 buf, buf->vb.i, __func__); 1426 1410 } 1427 1411 } ··· 1447 1431 buf, buf->vb.i, reason, (unsigned long)buf->risc.dma); 1448 1432 } 1449 1433 if (restart) { 1450 - dprintk(1, "restarting queue\n" ); 1434 + dprintk(1, "restarting queue\n"); 1451 1435 cx23885_restart_queue(port, q); 1452 1436 } 1453 1437 spin_unlock_irqrestore(&port->slock, flags); ··· 1469 1453 struct cx23885_tsport *port = (struct cx23885_tsport *)data; 1470 1454 struct cx23885_dev *dev = port->dev; 1471 1455 1472 - dprintk(1, "%s()\n",__func__); 1456 + dprintk(1, "%s()\n", __func__); 1473 1457 1474 1458 if (debug > 5) 1475 - cx23885_sram_channel_dump(dev, &dev->sram_channels[ port->sram_chno ]); 1459 + cx23885_sram_channel_dump(dev, 1460 + &dev->sram_channels[port->sram_chno]); 1476 1461 1477 1462 cx23885_stop_dma(port); 1478 1463 do_cancel_buffers(port, "timeout", 1); ··· 1549 1532 if ((status & VID_BC_MSK_OPC_ERR) || 1550 1533 (status & VID_BC_MSK_BAD_PKT) || 1551 1534 (status & VID_BC_MSK_SYNC) || 1552 - (status & VID_BC_MSK_OF)) 1553 - { 1535 + (status & VID_BC_MSK_OF)) { 1536 + 1554 1537 if (status & VID_BC_MSK_OPC_ERR) 1555 - dprintk(7, " (VID_BC_MSK_OPC_ERR 0x%08x)\n", VID_BC_MSK_OPC_ERR); 1538 + dprintk(7, " (VID_BC_MSK_OPC_ERR 0x%08x)\n", 1539 + VID_BC_MSK_OPC_ERR); 1540 + 1556 1541 if (status & VID_BC_MSK_BAD_PKT) 1557 - dprintk(7, " (VID_BC_MSK_BAD_PKT 0x%08x)\n", VID_BC_MSK_BAD_PKT); 1542 + dprintk(7, " (VID_BC_MSK_BAD_PKT 0x%08x)\n", 1543 + VID_BC_MSK_BAD_PKT); 1544 + 1558 1545 if (status & VID_BC_MSK_SYNC) 1559 - dprintk(7, " (VID_BC_MSK_SYNC 0x%08x)\n", VID_BC_MSK_SYNC); 1546 + dprintk(7, " (VID_BC_MSK_SYNC 0x%08x)\n", 1547 + VID_BC_MSK_SYNC); 1548 + 1560 1549 if (status & VID_BC_MSK_OF) 1561 - dprintk(7, " (VID_BC_MSK_OF 0x%08x)\n", VID_BC_MSK_OF); 1550 + dprintk(7, " (VID_BC_MSK_OF 0x%08x)\n", 1551 + VID_BC_MSK_OF); 1562 1552 1563 1553 printk(KERN_ERR "%s: mpeg risc op code error\n", dev->name); 1564 1554 ··· 1619 1595 ts2_status = cx_read(VID_C_INT_STAT); 1620 1596 ts2_mask = cx_read(VID_C_INT_MSK); 1621 1597 1622 - if ( (pci_status == 0) && (ts2_status == 0) && (ts1_status == 0) ) 1598 + if ((pci_status == 0) && (ts2_status == 0) && (ts1_status == 0)) 1623 1599 goto out; 1624 1600 1625 1601 vida_count = cx_read(VID_A_GPCNT); ··· 1634 1610 dprintk(7, "ts2_status: 0x%08x ts2_mask: 0x%08x count: 0x%x\n", 1635 1611 ts2_status, ts2_mask, ts2_count); 1636 1612 1637 - if ( (pci_status & PCI_MSK_RISC_RD) || 1638 - (pci_status & PCI_MSK_RISC_WR) || 1639 - (pci_status & PCI_MSK_AL_RD) || 1640 - (pci_status & PCI_MSK_AL_WR) || 1641 - (pci_status & PCI_MSK_APB_DMA) || 1642 - (pci_status & PCI_MSK_VID_C) || 1643 - (pci_status & PCI_MSK_VID_B) || 1644 - (pci_status & PCI_MSK_VID_A) || 1645 - (pci_status & PCI_MSK_AUD_INT) || 1646 - (pci_status & PCI_MSK_AUD_EXT) ) 1647 - { 1613 + if ((pci_status & PCI_MSK_RISC_RD) || 1614 + (pci_status & PCI_MSK_RISC_WR) || 1615 + (pci_status & PCI_MSK_AL_RD) || 1616 + (pci_status & PCI_MSK_AL_WR) || 1617 + (pci_status & PCI_MSK_APB_DMA) || 1618 + (pci_status & PCI_MSK_VID_C) || 1619 + (pci_status & PCI_MSK_VID_B) || 1620 + (pci_status & PCI_MSK_VID_A) || 1621 + (pci_status & PCI_MSK_AUD_INT) || 1622 + (pci_status & PCI_MSK_AUD_EXT)) { 1648 1623 1649 1624 if (pci_status & PCI_MSK_RISC_RD) 1650 - dprintk(7, " (PCI_MSK_RISC_RD 0x%08x)\n", PCI_MSK_RISC_RD); 1625 + dprintk(7, " (PCI_MSK_RISC_RD 0x%08x)\n", 1626 + PCI_MSK_RISC_RD); 1627 + 1651 1628 if (pci_status & PCI_MSK_RISC_WR) 1652 - dprintk(7, " (PCI_MSK_RISC_WR 0x%08x)\n", PCI_MSK_RISC_WR); 1629 + dprintk(7, " (PCI_MSK_RISC_WR 0x%08x)\n", 1630 + PCI_MSK_RISC_WR); 1631 + 1653 1632 if (pci_status & PCI_MSK_AL_RD) 1654 - dprintk(7, " (PCI_MSK_AL_RD 0x%08x)\n", PCI_MSK_AL_RD); 1633 + dprintk(7, " (PCI_MSK_AL_RD 0x%08x)\n", 1634 + PCI_MSK_AL_RD); 1635 + 1655 1636 if (pci_status & PCI_MSK_AL_WR) 1656 - dprintk(7, " (PCI_MSK_AL_WR 0x%08x)\n", PCI_MSK_AL_WR); 1637 + dprintk(7, " (PCI_MSK_AL_WR 0x%08x)\n", 1638 + PCI_MSK_AL_WR); 1639 + 1657 1640 if (pci_status & PCI_MSK_APB_DMA) 1658 - dprintk(7, " (PCI_MSK_APB_DMA 0x%08x)\n", PCI_MSK_APB_DMA); 1641 + dprintk(7, " (PCI_MSK_APB_DMA 0x%08x)\n", 1642 + PCI_MSK_APB_DMA); 1643 + 1659 1644 if (pci_status & PCI_MSK_VID_C) 1660 - dprintk(7, " (PCI_MSK_VID_C 0x%08x)\n", PCI_MSK_VID_C); 1645 + dprintk(7, " (PCI_MSK_VID_C 0x%08x)\n", 1646 + PCI_MSK_VID_C); 1647 + 1661 1648 if (pci_status & PCI_MSK_VID_B) 1662 - dprintk(7, " (PCI_MSK_VID_B 0x%08x)\n", PCI_MSK_VID_B); 1649 + dprintk(7, " (PCI_MSK_VID_B 0x%08x)\n", 1650 + PCI_MSK_VID_B); 1651 + 1663 1652 if (pci_status & PCI_MSK_VID_A) 1664 - dprintk(7, " (PCI_MSK_VID_A 0x%08x)\n", PCI_MSK_VID_A); 1653 + dprintk(7, " (PCI_MSK_VID_A 0x%08x)\n", 1654 + PCI_MSK_VID_A); 1655 + 1665 1656 if (pci_status & PCI_MSK_AUD_INT) 1666 - dprintk(7, " (PCI_MSK_AUD_INT 0x%08x)\n", PCI_MSK_AUD_INT); 1657 + dprintk(7, " (PCI_MSK_AUD_INT 0x%08x)\n", 1658 + PCI_MSK_AUD_INT); 1659 + 1667 1660 if (pci_status & PCI_MSK_AUD_EXT) 1668 - dprintk(7, " (PCI_MSK_AUD_EXT 0x%08x)\n", PCI_MSK_AUD_EXT); 1661 + dprintk(7, " (PCI_MSK_AUD_EXT 0x%08x)\n", 1662 + PCI_MSK_AUD_EXT); 1669 1663 1670 1664 } 1671 1665 ··· 1795 1753 .device = 0x8852, 1796 1754 .subvendor = PCI_ANY_ID, 1797 1755 .subdevice = PCI_ANY_ID, 1798 - },{ 1756 + }, { 1799 1757 /* CX23887 Rev 2 */ 1800 1758 .vendor = 0x14f1, 1801 1759 .device = 0x8880, 1802 1760 .subvendor = PCI_ANY_ID, 1803 1761 .subdevice = PCI_ANY_ID, 1804 - },{ 1762 + }, { 1805 1763 /* --- end of list --- */ 1806 1764 } 1807 1765 }; ··· 1839 1797 module_exit(cx23885_fini); 1840 1798 1841 1799 /* ----------------------------------------------------------- */ 1842 - /* 1843 - * Local variables: 1844 - * c-basic-offset: 8 1845 - * End: 1846 - * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off 1847 - */
+116 -74
drivers/media/video/cx23885/cx23885-dvb.c
··· 78 78 struct videobuf_buffer *vb, enum v4l2_field field) 79 79 { 80 80 struct cx23885_tsport *port = q->priv_data; 81 - return cx23885_buf_prepare(q, port, (struct cx23885_buffer*)vb, field); 81 + return cx23885_buf_prepare(q, port, (struct cx23885_buffer *)vb, field); 82 82 } 83 83 84 84 static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) 85 85 { 86 86 struct cx23885_tsport *port = q->priv_data; 87 - cx23885_buf_queue(port, (struct cx23885_buffer*)vb); 87 + cx23885_buf_queue(port, (struct cx23885_buffer *)vb); 88 88 } 89 89 90 90 static void dvb_buf_release(struct videobuf_queue *q, 91 91 struct videobuf_buffer *vb) 92 92 { 93 - cx23885_free_buffer(q, (struct cx23885_buffer*)vb); 93 + cx23885_free_buffer(q, (struct cx23885_buffer *)vb); 94 94 } 95 95 96 96 static struct videobuf_queue_ops dvb_qops = { ··· 312 312 { 313 313 struct cx23885_dev *dev = port->dev; 314 314 struct cx23885_i2c *i2c_bus = NULL; 315 + struct videobuf_dvb_frontend *fe0; 316 + 317 + /* Get the first frontend */ 318 + fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); 319 + if (!fe0) 320 + return -EINVAL; 315 321 316 322 /* init struct videobuf_dvb */ 317 - port->dvb.name = dev->name; 323 + fe0->dvb.name = dev->name; 318 324 319 325 /* init frontend */ 320 326 switch (dev->board) { 321 327 case CX23885_BOARD_HAUPPAUGE_HVR1250: 322 328 i2c_bus = &dev->i2c_bus[0]; 323 - port->dvb.frontend = dvb_attach(s5h1409_attach, 329 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 324 330 &hauppauge_generic_config, 325 331 &i2c_bus->i2c_adap); 326 - if (port->dvb.frontend != NULL) { 327 - dvb_attach(mt2131_attach, port->dvb.frontend, 332 + if (fe0->dvb.frontend != NULL) { 333 + dvb_attach(mt2131_attach, fe0->dvb.frontend, 328 334 &i2c_bus->i2c_adap, 329 335 &hauppauge_generic_tunerconfig, 0); 330 336 } ··· 339 333 i2c_bus = &dev->i2c_bus[0]; 340 334 switch (alt_tuner) { 341 335 case 1: 342 - port->dvb.frontend = 336 + fe0->dvb.frontend = 343 337 dvb_attach(s5h1409_attach, 344 338 &hauppauge_ezqam_config, 345 339 &i2c_bus->i2c_adap); 346 - if (port->dvb.frontend != NULL) { 347 - dvb_attach(tda829x_attach, port->dvb.frontend, 340 + if (fe0->dvb.frontend != NULL) { 341 + dvb_attach(tda829x_attach, fe0->dvb.frontend, 348 342 &dev->i2c_bus[1].i2c_adap, 0x42, 349 343 &tda829x_no_probe); 350 - dvb_attach(tda18271_attach, port->dvb.frontend, 344 + dvb_attach(tda18271_attach, fe0->dvb.frontend, 351 345 0x60, &dev->i2c_bus[1].i2c_adap, 352 346 &hauppauge_tda18271_config); 353 347 } 354 348 break; 355 349 case 0: 356 350 default: 357 - port->dvb.frontend = 351 + fe0->dvb.frontend = 358 352 dvb_attach(s5h1409_attach, 359 353 &hauppauge_generic_config, 360 354 &i2c_bus->i2c_adap); 361 - if (port->dvb.frontend != NULL) 362 - dvb_attach(mt2131_attach, port->dvb.frontend, 355 + if (fe0->dvb.frontend != NULL) 356 + dvb_attach(mt2131_attach, fe0->dvb.frontend, 363 357 &i2c_bus->i2c_adap, 364 358 &hauppauge_generic_tunerconfig, 0); 365 359 break; ··· 367 361 break; 368 362 case CX23885_BOARD_HAUPPAUGE_HVR1800lp: 369 363 i2c_bus = &dev->i2c_bus[0]; 370 - port->dvb.frontend = dvb_attach(s5h1409_attach, 364 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 371 365 &hauppauge_hvr1800lp_config, 372 366 &i2c_bus->i2c_adap); 373 - if (port->dvb.frontend != NULL) { 374 - dvb_attach(mt2131_attach, port->dvb.frontend, 367 + if (fe0->dvb.frontend != NULL) { 368 + dvb_attach(mt2131_attach, fe0->dvb.frontend, 375 369 &i2c_bus->i2c_adap, 376 370 &hauppauge_generic_tunerconfig, 0); 377 371 } 378 372 break; 379 373 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: 380 374 i2c_bus = &dev->i2c_bus[0]; 381 - port->dvb.frontend = dvb_attach(lgdt330x_attach, 375 + fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 382 376 &fusionhdtv_5_express, 383 377 &i2c_bus->i2c_adap); 384 - if (port->dvb.frontend != NULL) { 385 - dvb_attach(simple_tuner_attach, port->dvb.frontend, 378 + if (fe0->dvb.frontend != NULL) { 379 + dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 386 380 &i2c_bus->i2c_adap, 0x61, 387 381 TUNER_LG_TDVS_H06XF); 388 382 } 389 383 break; 390 384 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: 391 385 i2c_bus = &dev->i2c_bus[1]; 392 - port->dvb.frontend = dvb_attach(s5h1409_attach, 386 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 393 387 &hauppauge_hvr1500q_config, 394 388 &dev->i2c_bus[0].i2c_adap); 395 - if (port->dvb.frontend != NULL) 396 - dvb_attach(xc5000_attach, port->dvb.frontend, 389 + if (fe0->dvb.frontend != NULL) 390 + dvb_attach(xc5000_attach, fe0->dvb.frontend, 397 391 &i2c_bus->i2c_adap, 398 392 &hauppauge_hvr1500q_tunerconfig); 399 393 break; 400 394 case CX23885_BOARD_HAUPPAUGE_HVR1500: 401 395 i2c_bus = &dev->i2c_bus[1]; 402 - port->dvb.frontend = dvb_attach(s5h1409_attach, 396 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 403 397 &hauppauge_hvr1500_config, 404 398 &dev->i2c_bus[0].i2c_adap); 405 - if (port->dvb.frontend != NULL) { 399 + if (fe0->dvb.frontend != NULL) { 406 400 struct dvb_frontend *fe; 407 401 struct xc2028_config cfg = { 408 402 .i2c_adap = &i2c_bus->i2c_adap, ··· 415 409 }; 416 410 417 411 fe = dvb_attach(xc2028_attach, 418 - port->dvb.frontend, &cfg); 412 + fe0->dvb.frontend, &cfg); 419 413 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 420 414 fe->ops.tuner_ops.set_config(fe, &ctl); 421 415 } ··· 423 417 case CX23885_BOARD_HAUPPAUGE_HVR1200: 424 418 case CX23885_BOARD_HAUPPAUGE_HVR1700: 425 419 i2c_bus = &dev->i2c_bus[0]; 426 - port->dvb.frontend = dvb_attach(tda10048_attach, 420 + fe0->dvb.frontend = dvb_attach(tda10048_attach, 427 421 &hauppauge_hvr1200_config, 428 422 &i2c_bus->i2c_adap); 429 - if (port->dvb.frontend != NULL) { 430 - dvb_attach(tda829x_attach, port->dvb.frontend, 423 + if (fe0->dvb.frontend != NULL) { 424 + dvb_attach(tda829x_attach, fe0->dvb.frontend, 431 425 &dev->i2c_bus[1].i2c_adap, 0x42, 432 426 &tda829x_no_probe); 433 - dvb_attach(tda18271_attach, port->dvb.frontend, 427 + dvb_attach(tda18271_attach, fe0->dvb.frontend, 434 428 0x60, &dev->i2c_bus[1].i2c_adap, 435 429 &hauppauge_hvr1200_tuner_config); 436 430 } 437 431 break; 438 432 case CX23885_BOARD_HAUPPAUGE_HVR1400: 439 433 i2c_bus = &dev->i2c_bus[0]; 440 - port->dvb.frontend = dvb_attach(dib7000p_attach, 434 + fe0->dvb.frontend = dvb_attach(dib7000p_attach, 441 435 &i2c_bus->i2c_adap, 442 436 0x12, &hauppauge_hvr1400_dib7000_config); 443 - if (port->dvb.frontend != NULL) { 437 + if (fe0->dvb.frontend != NULL) { 444 438 struct dvb_frontend *fe; 445 439 struct xc2028_config cfg = { 446 440 .i2c_adap = &dev->i2c_bus[1].i2c_adap, ··· 450 444 .fname = XC3028L_DEFAULT_FIRMWARE, 451 445 .max_len = 64, 452 446 .demod = 5000, 453 - /* This is true for all demods with v36 firmware? */ 447 + /* This is true for all demods with 448 + v36 firmware? */ 454 449 .type = XC2028_D2633, 455 450 }; 456 451 457 452 fe = dvb_attach(xc2028_attach, 458 - port->dvb.frontend, &cfg); 453 + fe0->dvb.frontend, &cfg); 459 454 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 460 455 fe->ops.tuner_ops.set_config(fe, &ctl); 461 456 } ··· 464 457 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP: 465 458 i2c_bus = &dev->i2c_bus[port->nr - 1]; 466 459 467 - port->dvb.frontend = dvb_attach(s5h1409_attach, 460 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 468 461 &dvico_s5h1409_config, 469 462 &i2c_bus->i2c_adap); 470 - if (port->dvb.frontend == NULL) 471 - port->dvb.frontend = dvb_attach(s5h1411_attach, 463 + if (fe0->dvb.frontend == NULL) 464 + fe0->dvb.frontend = dvb_attach(s5h1411_attach, 472 465 &dvico_s5h1411_config, 473 466 &i2c_bus->i2c_adap); 474 - if (port->dvb.frontend != NULL) 475 - dvb_attach(xc5000_attach, port->dvb.frontend, 467 + if (fe0->dvb.frontend != NULL) 468 + dvb_attach(xc5000_attach, fe0->dvb.frontend, 476 469 &i2c_bus->i2c_adap, 477 470 &dvico_xc5000_tunerconfig); 478 471 break; 479 472 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: { 480 473 i2c_bus = &dev->i2c_bus[port->nr - 1]; 481 474 482 - port->dvb.frontend = dvb_attach(zl10353_attach, 475 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 483 476 &dvico_fusionhdtv_xc3028, 484 477 &i2c_bus->i2c_adap); 485 - if (port->dvb.frontend != NULL) { 478 + if (fe0->dvb.frontend != NULL) { 486 479 struct dvb_frontend *fe; 487 480 struct xc2028_config cfg = { 488 481 .i2c_adap = &i2c_bus->i2c_adap, ··· 494 487 .demod = XC3028_FE_ZARLINK456, 495 488 }; 496 489 497 - fe = dvb_attach(xc2028_attach, port->dvb.frontend, 490 + fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, 498 491 &cfg); 499 492 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 500 493 fe->ops.tuner_ops.set_config(fe, &ctl); ··· 504 497 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: 505 498 i2c_bus = &dev->i2c_bus[0]; 506 499 507 - port->dvb.frontend = dvb_attach(zl10353_attach, 500 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 508 501 &dvico_fusionhdtv_xc3028, 509 502 &i2c_bus->i2c_adap); 510 - if (port->dvb.frontend != NULL) { 503 + if (fe0->dvb.frontend != NULL) { 511 504 struct dvb_frontend *fe; 512 505 struct xc2028_config cfg = { 513 506 .i2c_adap = &dev->i2c_bus[1].i2c_adap, ··· 519 512 .demod = XC3028_FE_ZARLINK456, 520 513 }; 521 514 522 - fe = dvb_attach(xc2028_attach, port->dvb.frontend, 515 + fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, 523 516 &cfg); 524 517 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 525 518 fe->ops.tuner_ops.set_config(fe, &ctl); 526 519 } 527 520 break; 528 521 default: 529 - printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", 522 + printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " 523 + " isn't supported yet\n", 530 524 dev->name); 531 525 break; 532 526 } 533 - if (NULL == port->dvb.frontend) { 534 - printk("%s: frontend initialization failed\n", dev->name); 527 + if (NULL == fe0->dvb.frontend) { 528 + printk(KERN_ERR "%s: frontend initialization failed\n", 529 + dev->name); 535 530 return -1; 536 531 } 537 532 /* define general-purpose callback pointer */ 538 - port->dvb.frontend->callback = cx23885_tuner_callback; 533 + fe0->dvb.frontend->callback = cx23885_tuner_callback; 539 534 540 535 /* Put the analog decoder in standby to keep it quiet */ 541 536 cx23885_call_i2c_clients(i2c_bus, TUNER_SET_STANDBY, NULL); 542 537 543 - if (port->dvb.frontend->ops.analog_ops.standby) 544 - port->dvb.frontend->ops.analog_ops.standby(port->dvb.frontend); 538 + if (fe0->dvb.frontend->ops.analog_ops.standby) 539 + fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend); 545 540 546 541 /* register everything */ 547 - return videobuf_dvb_register(&port->dvb, THIS_MODULE, port, 548 - &dev->pci->dev, adapter_nr); 542 + return videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port, 543 + &dev->pci->dev, adapter_nr, 0); 544 + 549 545 } 550 546 551 547 int cx23885_dvb_register(struct cx23885_tsport *port) 552 548 { 549 + 550 + struct videobuf_dvb_frontend *fe0; 553 551 struct cx23885_dev *dev = port->dev; 554 - int err; 552 + int err, i; 555 553 556 - dprintk(1, "%s\n", __func__); 557 - dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", 558 - dev->board, 559 - dev->name, 560 - dev->pci_bus, 561 - dev->pci_slot); 554 + /* Here we need to allocate the correct number of frontends, 555 + * as reflected in the cards struct. The reality is that currrently 556 + * no cx23885 boards support this - yet. But, if we don't modify this 557 + * code then the second frontend would never be allocated (later) 558 + * and fail with error before the attach in dvb_register(). 559 + * Without these changes we risk an OOPS later. The changes here 560 + * are for safety, and should provide a good foundation for the 561 + * future addition of any multi-frontend cx23885 based boards. 562 + */ 563 + printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, 564 + port->num_frontends); 562 565 563 - err = -ENODEV; 566 + for (i = 1; i <= port->num_frontends; i++) { 567 + if (videobuf_dvb_alloc_frontend( 568 + &port->frontends, i) == NULL) { 569 + printk(KERN_ERR "%s() failed to alloc\n", __func__); 570 + return -ENOMEM; 571 + } 564 572 565 - /* dvb stuff */ 566 - printk("%s: cx23885 based dvb card\n", dev->name); 567 - videobuf_queue_sg_init(&port->dvb.dvbq, &dvb_qops, &dev->pci->dev, &port->slock, 573 + fe0 = videobuf_dvb_get_frontend(&port->frontends, i); 574 + if (!fe0) 575 + err = -EINVAL; 576 + 577 + dprintk(1, "%s\n", __func__); 578 + dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n", 579 + dev->board, 580 + dev->name, 581 + dev->pci_bus, 582 + dev->pci_slot); 583 + 584 + err = -ENODEV; 585 + 586 + /* dvb stuff */ 587 + /* We have to init the queue for each frontend on a port. */ 588 + printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name); 589 + videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops, 590 + &dev->pci->dev, &port->slock, 568 591 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, 569 592 sizeof(struct cx23885_buffer), port); 593 + } 570 594 err = dvb_register(port); 571 595 if (err != 0) 572 - printk("%s() dvb_register failed err = %d\n", __func__, err); 596 + printk(KERN_ERR "%s() dvb_register failed err = %d\n", 597 + __func__, err); 573 598 574 599 return err; 575 600 } 576 601 577 602 int cx23885_dvb_unregister(struct cx23885_tsport *port) 578 603 { 579 - /* dvb */ 580 - if(port->dvb.frontend) 581 - videobuf_dvb_unregister(&port->dvb); 604 + struct videobuf_dvb_frontend *fe0; 605 + 606 + /* FIXME: in an error condition where the we have 607 + * an expected number of frontends (attach problem) 608 + * then this might not clean up correctly, if 1 609 + * is invalid. 610 + * This comment only applies to future boards IF they 611 + * implement MFE support. 612 + */ 613 + fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); 614 + if (fe0->dvb.frontend) 615 + videobuf_dvb_unregister_bus(&port->frontends); 582 616 583 617 return 0; 584 618 } 585 619 586 - /* 587 - * Local variables: 588 - * c-basic-offset: 8 589 - * End: 590 - * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off 591 - */
+24 -23
drivers/media/video/cx23885/cx23885-i2c.c
··· 131 131 printk(" >\n"); 132 132 } 133 133 134 - for (cnt = 1; cnt < msg->len; cnt++ ) { 134 + for (cnt = 1; cnt < msg->len; cnt++) { 135 135 /* following bytes */ 136 136 wdata = msg->buf[cnt]; 137 137 ctrl = bus->i2c_period | (1 << 12) | (1 << 2); ··· 151 151 if (retval == 0) 152 152 goto eio; 153 153 if (i2c_debug) { 154 - printk(" %02x", msg->buf[cnt]); 154 + dprintk(1, " %02x", msg->buf[cnt]); 155 155 if (!(ctrl & I2C_NOSTOP)) 156 - printk(" >\n"); 156 + dprintk(1, " >\n"); 157 157 } 158 158 } 159 159 return msg->len; ··· 162 162 retval = -EIO; 163 163 err: 164 164 if (i2c_debug) 165 - printk(" ERR: %d\n", retval); 165 + printk(KERN_ERR " ERR: %d\n", retval); 166 166 return retval; 167 167 } 168 168 ··· 194 194 195 195 if (i2c_debug) { 196 196 if (joined) 197 - printk(" R"); 197 + dprintk(1, " R"); 198 198 else 199 - printk(" <R %02x", (msg->addr << 1) + 1); 199 + dprintk(1, " <R %02x", (msg->addr << 1) + 1); 200 200 } 201 201 202 - for(cnt = 0; cnt < msg->len; cnt++) { 202 + for (cnt = 0; cnt < msg->len; cnt++) { 203 203 204 204 ctrl = bus->i2c_period | (1 << 12) | (1 << 2) | 1; 205 205 ··· 216 216 goto eio; 217 217 msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff; 218 218 if (i2c_debug) { 219 - printk(" %02x", msg->buf[cnt]); 219 + dprintk(1, " %02x", msg->buf[cnt]); 220 220 if (!(ctrl & I2C_NOSTOP)) 221 - printk(" >\n"); 221 + dprintk(1, " >\n"); 222 222 } 223 223 } 224 224 return msg->len; ··· 227 227 retval = -EIO; 228 228 err: 229 229 if (i2c_debug) 230 - printk(" ERR: %d\n", retval); 230 + printk(KERN_ERR " ERR: %d\n", retval); 231 231 return retval; 232 232 } 233 233 ··· 353 353 }; 354 354 355 355 static char *i2c_devs[128] = { 356 - [0x10 >> 1] = "tda10048", 357 - [0x12 >> 1] = "dib7000pc", 358 - [ 0x1c >> 1 ] = "lgdt3303", 359 - [ 0x86 >> 1 ] = "tda9887", 360 - [ 0x32 >> 1 ] = "cx24227", 361 - [ 0x88 >> 1 ] = "cx25837", 362 - [ 0x84 >> 1 ] = "tda8295", 363 - [ 0xa0 >> 1 ] = "eeprom", 364 - [ 0xc0 >> 1 ] = "tuner/mt2131/tda8275", 356 + [0x10 >> 1] = "tda10048", 357 + [0x12 >> 1] = "dib7000pc", 358 + [0x1c >> 1] = "lgdt3303", 359 + [0x86 >> 1] = "tda9887", 360 + [0x32 >> 1] = "cx24227", 361 + [0x88 >> 1] = "cx25837", 362 + [0x84 >> 1] = "tda8295", 363 + [0xa0 >> 1] = "eeprom", 364 + [0xc0 >> 1] = "tuner/mt2131/tda8275", 365 365 [0xc2 >> 1] = "tuner/mt2131/tda8275/xc5000/xc3028", 366 - [0xc8 >> 1] = "tuner/xc3028L", 366 + [0xc8 >> 1] = "tuner/xc3028L", 367 367 }; 368 368 369 369 static void do_i2c_scan(char *name, struct i2c_client *c) ··· 376 376 rc = i2c_master_recv(c, &buf, 0); 377 377 if (rc < 0) 378 378 continue; 379 - printk("%s: i2c scan: found device @ 0x%x [%s]\n", 379 + printk(KERN_INFO "%s: i2c scan: found device @ 0x%x [%s]\n", 380 380 name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???"); 381 381 } 382 382 } ··· 408 408 bus->i2c_client.adapter = &bus->i2c_adap; 409 409 410 410 if (0 == bus->i2c_rc) { 411 - printk("%s: i2c bus %d registered\n", dev->name, bus->nr); 411 + dprintk(1, "%s: i2c bus %d registered\n", dev->name, bus->nr); 412 412 if (i2c_scan) 413 413 do_i2c_scan(dev->name, &bus->i2c_client); 414 414 } else 415 - printk("%s: i2c bus %d register FAILED\n", dev->name, bus->nr); 415 + printk(KERN_WARNING "%s: i2c bus %d register FAILED\n", 416 + dev->name, bus->nr); 416 417 417 418 return bus->i2c_rc; 418 419 }
+13 -12
drivers/media/video/cx23885/cx23885-video.c
··· 285 285 list_del(&buf->vb.queue); 286 286 wake_up(&buf->vb.done); 287 287 } 288 - if (list_empty(&q->active)) { 288 + if (list_empty(&q->active)) 289 289 del_timer(&q->timeout); 290 - } else { 290 + else 291 291 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 292 - } 293 292 if (bc != 1) 294 293 printk(KERN_ERR "%s: %d buffers handled (should be 1)\n", 295 294 __func__, bc); ··· 378 379 379 380 static int res_check(struct cx23885_fh *fh, unsigned int bit) 380 381 { 381 - return (fh->resources & bit); 382 + return fh->resources & bit; 382 383 } 383 384 384 385 static int res_locked(struct cx23885_dev *dev, unsigned int bit) 385 386 { 386 - return (dev->resources & bit); 387 + return dev->resources & bit; 387 388 } 388 389 389 390 static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh, ··· 886 887 /* ------------------------------------------------------------------ */ 887 888 /* VIDEO CTRL IOCTLS */ 888 889 889 - static int cx23885_get_control(struct cx23885_dev *dev, struct v4l2_control *ctl) 890 + static int cx23885_get_control(struct cx23885_dev *dev, 891 + struct v4l2_control *ctl) 890 892 { 891 893 dprintk(1, "%s() calling cx25840(VIDIOC_G_CTRL)\n", __func__); 892 894 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_CTRL, ctl); 893 895 return 0; 894 896 } 895 897 896 - static int cx23885_set_control(struct cx23885_dev *dev, struct v4l2_control *ctl) 898 + static int cx23885_set_control(struct cx23885_dev *dev, 899 + struct v4l2_control *ctl) 897 900 { 898 901 dprintk(1, "%s() calling cx25840(VIDIOC_S_CTRL)" 899 902 " (disabled - no action)\n", __func__); ··· 1074 1073 struct v4l2_requestbuffers *p) 1075 1074 { 1076 1075 struct cx23885_fh *fh = priv; 1077 - return (videobuf_reqbufs(get_queue(fh), p)); 1076 + return videobuf_reqbufs(get_queue(fh), p); 1078 1077 } 1079 1078 1080 1079 static int vidioc_querybuf(struct file *file, void *priv, 1081 1080 struct v4l2_buffer *p) 1082 1081 { 1083 1082 struct cx23885_fh *fh = priv; 1084 - return (videobuf_querybuf(get_queue(fh), p)); 1083 + return videobuf_querybuf(get_queue(fh), p); 1085 1084 } 1086 1085 1087 1086 static int vidioc_qbuf(struct file *file, void *priv, 1088 1087 struct v4l2_buffer *p) 1089 1088 { 1090 1089 struct cx23885_fh *fh = priv; 1091 - return (videobuf_qbuf(get_queue(fh), p)); 1090 + return videobuf_qbuf(get_queue(fh), p); 1092 1091 } 1093 1092 1094 1093 static int vidioc_dqbuf(struct file *file, void *priv, 1095 1094 struct v4l2_buffer *p) 1096 1095 { 1097 1096 struct cx23885_fh *fh = priv; 1098 - return (videobuf_dqbuf(get_queue(fh), p, 1099 - file->f_flags & O_NONBLOCK)); 1097 + return videobuf_dqbuf(get_queue(fh), p, 1098 + file->f_flags & O_NONBLOCK); 1100 1099 } 1101 1100 1102 1101 static int vidioc_streamon(struct file *file, void *priv,
+11 -15
drivers/media/video/cx23885/cx23885.h
··· 37 37 #include <linux/version.h> 38 38 #include <linux/mutex.h> 39 39 40 - #define CX23885_VERSION_CODE KERNEL_VERSION(0,0,1) 40 + #define CX23885_VERSION_CODE KERNEL_VERSION(0, 0, 1) 41 41 42 42 #define UNSET (-1U) 43 43 ··· 225 225 int nr; 226 226 int sram_chno; 227 227 228 - struct videobuf_dvb dvb; 228 + struct videobuf_dvb_frontends frontends; 229 229 230 230 /* dma queues */ 231 231 struct cx23885_dmaqueue mpegq; ··· 262 262 u32 src_sel_val; 263 263 u32 vld_misc_val; 264 264 u32 hw_sop_ctrl_val; 265 + 266 + /* Allow a single tsport to have multiple frontends */ 267 + u32 num_frontends; 265 268 }; 266 269 267 270 struct cx23885_dev { ··· 370 367 /* ----------------------------------------------------------- */ 371 368 372 369 #define cx_read(reg) readl(dev->lmmio + ((reg)>>2)) 373 - #define cx_write(reg,value) writel((value), dev->lmmio + ((reg)>>2)) 370 + #define cx_write(reg, value) writel((value), dev->lmmio + ((reg)>>2)) 374 371 375 - #define cx_andor(reg,mask,value) \ 372 + #define cx_andor(reg, mask, value) \ 376 373 writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\ 377 374 ((value) & (mask)), dev->lmmio+((reg)>>2)) 378 375 379 - #define cx_set(reg,bit) cx_andor((reg),(bit),(bit)) 380 - #define cx_clear(reg,bit) cx_andor((reg),(bit),0) 376 + #define cx_set(reg, bit) cx_andor((reg), (bit), (bit)) 377 + #define cx_clear(reg, bit) cx_andor((reg), (bit), 0) 381 378 382 379 /* ----------------------------------------------------------- */ 383 380 /* cx23885-core.c */ ··· 414 411 extern struct cx23885_subid cx23885_subids[]; 415 412 extern const unsigned int cx23885_idcount; 416 413 417 - extern int cx23885_tuner_callback(void *priv, int component, int command, int arg); 414 + extern int cx23885_tuner_callback(void *priv, int component, 415 + int command, int arg); 418 416 extern void cx23885_card_list(struct cx23885_dev *dev); 419 417 extern int cx23885_ir_init(struct cx23885_dev *dev); 420 418 extern void cx23885_gpio_setup(struct cx23885_dev *dev); ··· 483 479 { 484 480 return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922; 485 481 } 486 - 487 - 488 - /* 489 - * Local variables: 490 - * c-basic-offset: 8 491 - * End: 492 - * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off 493 - */
+51 -7
drivers/media/video/cx88/cx88-cards.c
··· 1270 1270 .mpeg = CX88_MPEG_DVB, 1271 1271 }, 1272 1272 [CX88_BOARD_HAUPPAUGE_HVR3000] = { 1273 - /* FIXME: Add dvb & radio support */ 1274 1273 .name = "Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T", 1275 1274 .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3, 1276 1275 .radio_type = UNSET, 1277 1276 .tuner_addr = ADDR_UNSET, 1278 1277 .radio_addr = ADDR_UNSET, 1279 1278 .tda9887_conf = TDA9887_PRESENT, 1279 + .audio_chip = V4L2_IDENT_WM8775, 1280 1280 .input = {{ 1281 1281 .type = CX88_VMUX_TELEVISION, 1282 1282 .vmux = 0, 1283 1283 .gpio0 = 0x84bf, 1284 + /* 1: TV Audio / FM Mono */ 1285 + .audioroute = 1, 1284 1286 },{ 1285 1287 .type = CX88_VMUX_COMPOSITE1, 1286 1288 .vmux = 1, 1287 1289 .gpio0 = 0x84bf, 1290 + /* 2: Line-In */ 1291 + .audioroute = 2, 1288 1292 },{ 1289 1293 .type = CX88_VMUX_SVIDEO, 1290 1294 .vmux = 2, 1291 1295 .gpio0 = 0x84bf, 1296 + /* 2: Line-In */ 1297 + .audioroute = 2, 1292 1298 }}, 1299 + .radio = { 1300 + .type = CX88_RADIO, 1301 + .gpio0 = 0x84bf, 1302 + /* 4: FM Stereo (untested) */ 1303 + .audioroute = 8, 1304 + }, 1293 1305 .mpeg = CX88_MPEG_DVB, 1306 + .num_frontends = 2, 1294 1307 }, 1295 1308 [CX88_BOARD_NORWOOD_MICRO] = { 1296 1309 .name = "Norwood Micro TV Tuner", ··· 1369 1356 .type = CX88_VMUX_TELEVISION, 1370 1357 .vmux = 0, 1371 1358 .gpio0 = 0xef88, 1359 + /* 1: TV Audio / FM Mono */ 1372 1360 .audioroute = 1, 1373 1361 },{ 1374 1362 .type = CX88_VMUX_COMPOSITE1, 1375 1363 .vmux = 1, 1376 1364 .gpio0 = 0xef88, 1365 + /* 2: Line-In */ 1377 1366 .audioroute = 2, 1378 1367 },{ 1379 1368 .type = CX88_VMUX_SVIDEO, 1380 1369 .vmux = 2, 1381 1370 .gpio0 = 0xef88, 1371 + /* 2: Line-In */ 1382 1372 .audioroute = 2, 1383 1373 }}, 1384 - /* fixme: Add radio support */ 1385 1374 .mpeg = CX88_MPEG_DVB | CX88_MPEG_BLACKBIRD, 1386 1375 .radio = { 1387 1376 .type = CX88_RADIO, 1388 1377 .gpio0 = 0xef88, 1378 + /* 4: FM Stereo (untested) */ 1379 + .audioroute = 8, 1389 1380 }, 1390 1381 }, 1391 1382 [CX88_BOARD_ADSTECH_PTV_390] = { ··· 1733 1716 .tuner_addr = ADDR_UNSET, 1734 1717 .radio_addr = ADDR_UNSET, 1735 1718 .tda9887_conf = TDA9887_PRESENT, 1719 + .audio_chip = V4L2_IDENT_WM8775, 1736 1720 /* 1737 1721 * GPIO0 (WINTV2000) 1738 1722 * ··· 1747 1729 * BIT VALUE FUNCTION GP{x}_IO 1748 1730 * 0 1 I:? 1749 1731 * 1 1 I:? 1750 - * 2 1 O:DVB-T DEMOD ENABLE LOW/ANALOG DEMOD ENABLE HIGH 1732 + * 2 1 O:MPEG PORT 0=DVB-T 1=DVB-S 1751 1733 * 3 1 I:? 1752 1734 * 4 1 I:? 1753 1735 * 5 1 I:? ··· 1763 1745 * d 0 I 1764 1746 * e 1 O 1765 1747 * f 1 O 1748 + * 1749 + * WM8775 ADC 1750 + * 1751 + * 1: TV Audio / FM Mono 1752 + * 2: Line-In 1753 + * 3: Line-In Expansion 1754 + * 4: FM Stereo 1766 1755 */ 1767 1756 .input = {{ 1768 1757 .type = CX88_VMUX_TELEVISION, 1769 1758 .vmux = 0, 1770 1759 .gpio0 = 0xc4bf, 1760 + /* 1: TV Audio / FM Mono */ 1761 + .audioroute = 1, 1771 1762 }, { 1772 1763 .type = CX88_VMUX_COMPOSITE1, 1773 1764 .vmux = 1, 1774 1765 .gpio0 = 0xc4bf, 1766 + /* 2: Line-In */ 1767 + .audioroute = 2, 1775 1768 }, { 1776 1769 .type = CX88_VMUX_SVIDEO, 1777 1770 .vmux = 2, 1778 1771 .gpio0 = 0xc4bf, 1772 + /* 2: Line-In */ 1773 + .audioroute = 2, 1779 1774 } }, 1780 - /* fixme: Add radio support */ 1775 + .radio = { 1776 + .type = CX88_RADIO, 1777 + .gpio0 = 0xc4bf, 1778 + /* 4: FM Stereo */ 1779 + .audioroute = 8, 1780 + }, 1781 1781 .mpeg = CX88_MPEG_DVB, 1782 + .num_frontends = 2, 1782 1783 }, 1783 1784 [CX88_BOARD_HAUPPAUGE_HVR4000LITE] = { 1784 1785 .name = "Hauppauge WinTV-HVR4000(Lite) DVB-S/S2", ··· 2699 2662 2700 2663 case CX88_BOARD_HAUPPAUGE_HVR3000: 2701 2664 case CX88_BOARD_HAUPPAUGE_HVR4000: 2702 - case CX88_BOARD_HAUPPAUGE_HVR4000LITE: 2703 2665 /* Init GPIO */ 2704 2666 cx_write(MO_GP0_IO, core->board.input[0].gpio0); 2667 + udelay(1000); 2668 + cx_clear(MO_GP0_IO, 0x00000080); 2669 + udelay(50); 2670 + cx_set(MO_GP0_IO, 0x00000080); /* 702 out of reset */ 2705 2671 udelay(1000); 2706 2672 break; 2707 2673 } ··· 3044 3004 3045 3005 memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board)); 3046 3006 3047 - info_printk(core, "subsystem: %04x:%04x, board: %s [card=%d,%s]\n", 3007 + if (!core->board.num_frontends) 3008 + core->board.num_frontends=1; 3009 + 3010 + info_printk(core, "subsystem: %04x:%04x, board: %s [card=%d,%s], frontend(s): %d\n", 3048 3011 pci->subsystem_vendor, pci->subsystem_device, core->board.name, 3049 3012 core->boardnr, card[core->nr] == core->boardnr ? 3050 - "insmod option" : "autodetected"); 3013 + "insmod option" : "autodetected", 3014 + core->board.num_frontends); 3051 3015 3052 3016 if (tuner[core->nr] != UNSET) 3053 3017 core->board.tuner_type = tuner[core->nr];
+2 -1
drivers/media/video/cx88/cx88-core.c
··· 549 549 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 550 550 } 551 551 if (bc != 1) 552 - printk("%s: %d buffers handled (should be 1)\n",__func__,bc); 552 + dprintk(2, "%s: %d buffers handled (should be 1)\n", 553 + __func__, bc); 553 554 } 554 555 555 556 void cx88_shutdown(struct cx88_core *core)
+274 -133
drivers/media/video/cx88/cx88-dvb.c
··· 116 116 struct cx8802_dev *dev= fe->dvb->priv; 117 117 struct cx8802_driver *drv = NULL; 118 118 int ret = 0; 119 + int fe_id; 120 + 121 + fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe); 122 + if (!fe_id) { 123 + printk(KERN_ERR "%s() No frontend found\n", __func__); 124 + return -EINVAL; 125 + } 119 126 120 127 drv = cx8802_get_driver(dev, CX88_MPEG_DVB); 121 128 if (drv) { 122 - if (acquire) 129 + if (acquire){ 130 + dev->frontends.active_fe_id = fe_id; 123 131 ret = drv->request_acquire(drv); 124 - else 132 + } else { 125 133 ret = drv->request_release(drv); 134 + dev->frontends.active_fe_id = 0; 135 + } 126 136 } 127 137 128 138 return ret; ··· 406 396 cx_write(MO_GP0_IO, 0x00006060); 407 397 break; 408 398 case SEC_VOLTAGE_OFF: 409 - printk("LNB Voltage SEC_VOLTAGE_off\n"); 399 + printk("LNB Voltage SEC_VOLTAGE_off\n"); 410 400 break; 411 401 } 412 402 ··· 493 483 static int attach_xc3028(u8 addr, struct cx8802_dev *dev) 494 484 { 495 485 struct dvb_frontend *fe; 486 + struct videobuf_dvb_frontend *fe0 = NULL; 496 487 struct xc2028_ctrl ctl; 497 488 struct xc2028_config cfg = { 498 489 .i2c_adap = &dev->core->i2c_adap, ··· 501 490 .ctrl = &ctl, 502 491 }; 503 492 504 - if (!dev->dvb.frontend) { 493 + /* Get the first frontend */ 494 + fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); 495 + if (!fe0) 496 + return -EINVAL; 497 + 498 + if (!fe0->dvb.frontend) { 505 499 printk(KERN_ERR "%s/2: dvb frontend not attached. " 506 500 "Can't attach xc3028\n", 507 501 dev->core->name); ··· 520 504 */ 521 505 cx88_setup_xc3028(dev->core, &ctl); 522 506 523 - fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg); 507 + fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg); 524 508 if (!fe) { 525 509 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 526 510 dev->core->name); 511 + dvb_frontend_detach(fe0->dvb.frontend); 512 + dvb_unregister_frontend(fe0->dvb.frontend); 513 + fe0->dvb.frontend = NULL; 527 514 return -EINVAL; 528 515 } 529 516 ··· 551 532 struct cx88_core *core = dev->core; 552 533 553 534 /* Reset the part */ 535 + /* Put the cx24116 into reset */ 554 536 cx_write(MO_SRST_IO, 0); 555 537 msleep(10); 538 + /* Take the cx24116 out of reset */ 556 539 cx_write(MO_SRST_IO, 1); 557 540 msleep(10); 558 541 ··· 575 554 576 555 static struct stv0299_config tevii_tuner_sharp_config = { 577 556 .demod_address = 0x68, 578 - .inittab = sharp_z0194a__inittab, 557 + .inittab = sharp_z0194a_inittab, 579 558 .mclk = 88000000UL, 580 559 .invert = 1, 581 560 .skip_reinit = 0, 582 561 .lock_output = 1, 583 562 .volt13_op0_op1 = STV0299_VOLT13_OP1, 584 563 .min_delay_ms = 100, 585 - .set_symbol_rate = sharp_z0194a__set_symbol_rate, 564 + .set_symbol_rate = sharp_z0194a_set_symbol_rate, 586 565 .set_ts_params = cx24116_set_ts_param, 587 566 }; 588 567 ··· 595 574 static int dvb_register(struct cx8802_dev *dev) 596 575 { 597 576 struct cx88_core *core = dev->core; 577 + struct videobuf_dvb_frontend *fe0, *fe1 = NULL; 578 + int mfe_shared = 0; /* bus not shared by default */ 598 579 599 - /* init struct videobuf_dvb */ 600 - dev->dvb.name = core->name; 601 - dev->ts_gen_cntrl = 0x0c; 580 + /* Get the first frontend */ 581 + fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); 582 + if (!fe0) 583 + return -EINVAL; 602 584 603 - /* init frontend */ 585 + /* multi-frontend gate control is undefined or defaults to fe0 */ 586 + dev->frontends.gate = 0; 587 + 588 + /* init frontend(s) */ 604 589 switch (core->boardnr) { 605 590 case CX88_BOARD_HAUPPAUGE_DVB_T1: 606 - dev->dvb.frontend = dvb_attach(cx22702_attach, 591 + fe0->dvb.frontend = dvb_attach(cx22702_attach, 607 592 &connexant_refboard_config, 608 593 &core->i2c_adap); 609 - if (dev->dvb.frontend != NULL) { 610 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 594 + if (fe0->dvb.frontend != NULL) { 595 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 611 596 0x61, &core->i2c_adap, 612 597 DVB_PLL_THOMSON_DTT759X)) 613 598 goto frontend_detach; ··· 623 596 case CX88_BOARD_CONEXANT_DVB_T1: 624 597 case CX88_BOARD_KWORLD_DVB_T_CX22702: 625 598 case CX88_BOARD_WINFAST_DTV1000: 626 - dev->dvb.frontend = dvb_attach(cx22702_attach, 599 + fe0->dvb.frontend = dvb_attach(cx22702_attach, 627 600 &connexant_refboard_config, 628 601 &core->i2c_adap); 629 - if (dev->dvb.frontend != NULL) { 630 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 602 + if (fe0->dvb.frontend != NULL) { 603 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 631 604 0x60, &core->i2c_adap, 632 605 DVB_PLL_THOMSON_DTT7579)) 633 606 goto frontend_detach; ··· 637 610 case CX88_BOARD_HAUPPAUGE_HVR1100: 638 611 case CX88_BOARD_HAUPPAUGE_HVR1100LP: 639 612 case CX88_BOARD_HAUPPAUGE_HVR1300: 640 - case CX88_BOARD_HAUPPAUGE_HVR3000: 641 - dev->dvb.frontend = dvb_attach(cx22702_attach, 613 + fe0->dvb.frontend = dvb_attach(cx22702_attach, 642 614 &hauppauge_hvr_config, 643 615 &core->i2c_adap); 644 - if (dev->dvb.frontend != NULL) { 645 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 616 + if (fe0->dvb.frontend != NULL) { 617 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 646 618 &core->i2c_adap, 0x61, 647 619 TUNER_PHILIPS_FMD1216ME_MK3)) 648 620 goto frontend_detach; 649 621 } 650 622 break; 623 + case CX88_BOARD_HAUPPAUGE_HVR3000: 624 + /* DVB-S init */ 625 + fe0->dvb.frontend = dvb_attach(cx24123_attach, 626 + &hauppauge_novas_config, 627 + &dev->core->i2c_adap); 628 + if (fe0->dvb.frontend) { 629 + if (!dvb_attach(isl6421_attach, fe0->dvb.frontend, 630 + &dev->core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) { 631 + dprintk( 1, "%s(): HVR3000 - DVB-S LNB Init: failed\n", __func__); 632 + } 633 + } else { 634 + dprintk( 1, "%s(): HVR3000 - DVB-S Init: failed\n", __func__); 635 + } 636 + /* DVB-T init */ 637 + fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2); 638 + if (fe1) { 639 + dev->frontends.gate = 2; 640 + mfe_shared = 1; 641 + fe1->dvb.frontend = dvb_attach(cx22702_attach, 642 + &hauppauge_hvr_config, 643 + &dev->core->i2c_adap); 644 + if (fe1->dvb.frontend) { 645 + fe1->dvb.frontend->id = 1; 646 + if(!dvb_attach(simple_tuner_attach, fe1->dvb.frontend, 647 + &dev->core->i2c_adap, 0x61, 648 + TUNER_PHILIPS_FMD1216ME_MK3)) { 649 + dprintk( 1, "%s(): HVR3000 - DVB-T misc Init: failed\n", __func__); 650 + } 651 + } else { 652 + dprintk( 1, "%s(): HVR3000 - DVB-T Init: failed\n", __func__); 653 + } 654 + } else { 655 + dprintk( 1, "%s(): HVR3000 - DVB-T Init: can't find frontend 2.\n", __func__); 656 + } 657 + break; 651 658 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 652 - dev->dvb.frontend = dvb_attach(mt352_attach, 659 + fe0->dvb.frontend = dvb_attach(mt352_attach, 653 660 &dvico_fusionhdtv, 654 661 &core->i2c_adap); 655 - if (dev->dvb.frontend != NULL) { 656 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 662 + if (fe0->dvb.frontend != NULL) { 663 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 657 664 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 658 665 goto frontend_detach; 659 666 break; 660 667 } 661 668 /* ZL10353 replaces MT352 on later cards */ 662 - dev->dvb.frontend = dvb_attach(zl10353_attach, 669 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 663 670 &dvico_fusionhdtv_plus_v1_1, 664 671 &core->i2c_adap); 665 - if (dev->dvb.frontend != NULL) { 666 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 672 + if (fe0->dvb.frontend != NULL) { 673 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 667 674 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 668 675 goto frontend_detach; 669 676 } ··· 705 644 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 706 645 /* The tin box says DEE1601, but it seems to be DTT7579 707 646 * compatible, with a slightly different MT352 AGC gain. */ 708 - dev->dvb.frontend = dvb_attach(mt352_attach, 647 + fe0->dvb.frontend = dvb_attach(mt352_attach, 709 648 &dvico_fusionhdtv_dual, 710 649 &core->i2c_adap); 711 - if (dev->dvb.frontend != NULL) { 712 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 650 + if (fe0->dvb.frontend != NULL) { 651 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 713 652 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 714 653 goto frontend_detach; 715 654 break; 716 655 } 717 656 /* ZL10353 replaces MT352 on later cards */ 718 - dev->dvb.frontend = dvb_attach(zl10353_attach, 657 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 719 658 &dvico_fusionhdtv_plus_v1_1, 720 659 &core->i2c_adap); 721 - if (dev->dvb.frontend != NULL) { 722 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 660 + if (fe0->dvb.frontend != NULL) { 661 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 723 662 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 724 663 goto frontend_detach; 725 664 } 726 665 break; 727 666 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 728 - dev->dvb.frontend = dvb_attach(mt352_attach, 667 + fe0->dvb.frontend = dvb_attach(mt352_attach, 729 668 &dvico_fusionhdtv, 730 669 &core->i2c_adap); 731 - if (dev->dvb.frontend != NULL) { 732 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 670 + if (fe0->dvb.frontend != NULL) { 671 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 733 672 0x61, NULL, DVB_PLL_LG_Z201)) 734 673 goto frontend_detach; 735 674 } ··· 737 676 case CX88_BOARD_KWORLD_DVB_T: 738 677 case CX88_BOARD_DNTV_LIVE_DVB_T: 739 678 case CX88_BOARD_ADSTECH_DVB_T_PCI: 740 - dev->dvb.frontend = dvb_attach(mt352_attach, 679 + fe0->dvb.frontend = dvb_attach(mt352_attach, 741 680 &dntv_live_dvbt_config, 742 681 &core->i2c_adap); 743 - if (dev->dvb.frontend != NULL) { 744 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 682 + if (fe0->dvb.frontend != NULL) { 683 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 745 684 0x61, NULL, DVB_PLL_UNKNOWN_1)) 746 685 goto frontend_detach; 747 686 } ··· 749 688 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 750 689 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE)) 751 690 /* MT352 is on a secondary I2C bus made from some GPIO lines */ 752 - dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, 691 + fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, 753 692 &dev->vp3054->adap); 754 - if (dev->dvb.frontend != NULL) { 755 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 693 + if (fe0->dvb.frontend != NULL) { 694 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 756 695 &core->i2c_adap, 0x61, 757 696 TUNER_PHILIPS_FMD1216ME_MK3)) 758 697 goto frontend_detach; ··· 763 702 #endif 764 703 break; 765 704 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 766 - dev->dvb.frontend = dvb_attach(zl10353_attach, 705 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 767 706 &dvico_fusionhdtv_hybrid, 768 707 &core->i2c_adap); 769 - if (dev->dvb.frontend != NULL) { 770 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 708 + if (fe0->dvb.frontend != NULL) { 709 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 771 710 &core->i2c_adap, 0x61, 772 711 TUNER_THOMSON_FE6600)) 773 712 goto frontend_detach; 774 713 } 775 714 break; 776 715 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: 777 - dev->dvb.frontend = dvb_attach(zl10353_attach, 716 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 778 717 &dvico_fusionhdtv_xc3028, 779 718 &core->i2c_adap); 780 - if (dev->dvb.frontend == NULL) 781 - dev->dvb.frontend = dvb_attach(mt352_attach, 719 + if (fe0->dvb.frontend == NULL) 720 + fe0->dvb.frontend = dvb_attach(mt352_attach, 782 721 &dvico_fusionhdtv_mt352_xc3028, 783 722 &core->i2c_adap); 784 723 /* ··· 786 725 * We must not permit gate_ctrl to be performed, or 787 726 * the xc3028 cannot communicate on the bus. 788 727 */ 789 - if (dev->dvb.frontend) 790 - dev->dvb.frontend->ops.i2c_gate_ctrl = NULL; 728 + if (fe0->dvb.frontend) 729 + fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; 791 730 if (attach_xc3028(0x61, dev) < 0) 792 731 return -EINVAL; 793 732 break; 794 733 case CX88_BOARD_PCHDTV_HD3000: 795 - dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, 734 + fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, 796 735 &core->i2c_adap); 797 - if (dev->dvb.frontend != NULL) { 798 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 736 + if (fe0->dvb.frontend != NULL) { 737 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 799 738 &core->i2c_adap, 0x61, 800 739 TUNER_THOMSON_DTT761X)) 801 740 goto frontend_detach; ··· 812 751 813 752 /* Select RF connector callback */ 814 753 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; 815 - dev->dvb.frontend = dvb_attach(lgdt330x_attach, 754 + fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 816 755 &fusionhdtv_3_gold, 817 756 &core->i2c_adap); 818 - if (dev->dvb.frontend != NULL) { 819 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 757 + if (fe0->dvb.frontend != NULL) { 758 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 820 759 &core->i2c_adap, 0x61, 821 760 TUNER_MICROTUNE_4042FI5)) 822 761 goto frontend_detach; ··· 830 769 mdelay(100); 831 770 cx_set(MO_GP0_IO, 9); 832 771 mdelay(200); 833 - dev->dvb.frontend = dvb_attach(lgdt330x_attach, 772 + fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 834 773 &fusionhdtv_3_gold, 835 774 &core->i2c_adap); 836 - if (dev->dvb.frontend != NULL) { 837 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 775 + if (fe0->dvb.frontend != NULL) { 776 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 838 777 &core->i2c_adap, 0x61, 839 778 TUNER_THOMSON_DTT761X)) 840 779 goto frontend_detach; ··· 848 787 mdelay(100); 849 788 cx_set(MO_GP0_IO, 1); 850 789 mdelay(200); 851 - dev->dvb.frontend = dvb_attach(lgdt330x_attach, 790 + fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 852 791 &fusionhdtv_5_gold, 853 792 &core->i2c_adap); 854 - if (dev->dvb.frontend != NULL) { 855 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 793 + if (fe0->dvb.frontend != NULL) { 794 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 856 795 &core->i2c_adap, 0x61, 857 796 TUNER_LG_TDVS_H06XF)) 858 797 goto frontend_detach; 859 - if (!dvb_attach(tda9887_attach, dev->dvb.frontend, 798 + if (!dvb_attach(tda9887_attach, fe0->dvb.frontend, 860 799 &core->i2c_adap, 0x43)) 861 800 goto frontend_detach; 862 801 } ··· 869 808 mdelay(100); 870 809 cx_set(MO_GP0_IO, 1); 871 810 mdelay(200); 872 - dev->dvb.frontend = dvb_attach(lgdt330x_attach, 811 + fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 873 812 &pchdtv_hd5500, 874 813 &core->i2c_adap); 875 - if (dev->dvb.frontend != NULL) { 876 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 814 + if (fe0->dvb.frontend != NULL) { 815 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 877 816 &core->i2c_adap, 0x61, 878 817 TUNER_LG_TDVS_H06XF)) 879 818 goto frontend_detach; 880 - if (!dvb_attach(tda9887_attach, dev->dvb.frontend, 819 + if (!dvb_attach(tda9887_attach, fe0->dvb.frontend, 881 820 &core->i2c_adap, 0x43)) 882 821 goto frontend_detach; 883 822 } 884 823 break; 885 824 case CX88_BOARD_ATI_HDTVWONDER: 886 - dev->dvb.frontend = dvb_attach(nxt200x_attach, 825 + fe0->dvb.frontend = dvb_attach(nxt200x_attach, 887 826 &ati_hdtvwonder, 888 827 &core->i2c_adap); 889 - if (dev->dvb.frontend != NULL) { 890 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 828 + if (fe0->dvb.frontend != NULL) { 829 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 891 830 &core->i2c_adap, 0x61, 892 831 TUNER_PHILIPS_TUV1236D)) 893 832 goto frontend_detach; ··· 895 834 break; 896 835 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 897 836 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 898 - dev->dvb.frontend = dvb_attach(cx24123_attach, 837 + fe0->dvb.frontend = dvb_attach(cx24123_attach, 899 838 &hauppauge_novas_config, 900 839 &core->i2c_adap); 901 - if (dev->dvb.frontend) { 902 - if (!dvb_attach(isl6421_attach, dev->dvb.frontend, 840 + if (fe0->dvb.frontend) { 841 + if (!dvb_attach(isl6421_attach, fe0->dvb.frontend, 903 842 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) 904 843 goto frontend_detach; 905 844 } 906 845 break; 907 846 case CX88_BOARD_KWORLD_DVBS_100: 908 - dev->dvb.frontend = dvb_attach(cx24123_attach, 847 + fe0->dvb.frontend = dvb_attach(cx24123_attach, 909 848 &kworld_dvbs_100_config, 910 849 &core->i2c_adap); 911 - if (dev->dvb.frontend) { 912 - core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 913 - dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; 850 + if (fe0->dvb.frontend) { 851 + core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; 852 + fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; 914 853 } 915 854 break; 916 855 case CX88_BOARD_GENIATECH_DVBS: 917 - dev->dvb.frontend = dvb_attach(cx24123_attach, 856 + fe0->dvb.frontend = dvb_attach(cx24123_attach, 918 857 &geniatech_dvbs_config, 919 858 &core->i2c_adap); 920 - if (dev->dvb.frontend) { 921 - core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 922 - dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; 859 + if (fe0->dvb.frontend) { 860 + core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; 861 + fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; 923 862 } 924 863 break; 925 864 case CX88_BOARD_PINNACLE_PCTV_HD_800i: 926 - dev->dvb.frontend = dvb_attach(s5h1409_attach, 865 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 927 866 &pinnacle_pctv_hd_800i_config, 928 867 &core->i2c_adap); 929 - if (dev->dvb.frontend != NULL) { 930 - if (!dvb_attach(xc5000_attach, dev->dvb.frontend, 868 + if (fe0->dvb.frontend != NULL) { 869 + if (!dvb_attach(xc5000_attach, fe0->dvb.frontend, 931 870 &core->i2c_adap, 932 871 &pinnacle_pctv_hd_800i_tuner_config)) 933 872 goto frontend_detach; 934 873 } 935 874 break; 936 875 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: 937 - dev->dvb.frontend = dvb_attach(s5h1409_attach, 876 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 938 877 &dvico_hdtv5_pci_nano_config, 939 878 &core->i2c_adap); 940 - if (dev->dvb.frontend != NULL) { 879 + if (fe0->dvb.frontend != NULL) { 941 880 struct dvb_frontend *fe; 942 881 struct xc2028_config cfg = { 943 882 .i2c_adap = &core->i2c_adap, ··· 950 889 }; 951 890 952 891 fe = dvb_attach(xc2028_attach, 953 - dev->dvb.frontend, &cfg); 892 + fe0->dvb.frontend, &cfg); 954 893 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 955 894 fe->ops.tuner_ops.set_config(fe, &ctl); 956 895 } 957 896 break; 958 897 case CX88_BOARD_PINNACLE_HYBRID_PCTV: 959 - dev->dvb.frontend = dvb_attach(zl10353_attach, 898 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 960 899 &cx88_pinnacle_hybrid_pctv, 961 900 &core->i2c_adap); 962 - if (dev->dvb.frontend) { 963 - dev->dvb.frontend->ops.i2c_gate_ctrl = NULL; 901 + if (fe0->dvb.frontend) { 902 + fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; 964 903 if (attach_xc3028(0x61, dev) < 0) 965 904 goto frontend_detach; 966 905 } ··· 968 907 case CX88_BOARD_GENIATECH_X8000_MT: 969 908 dev->ts_gen_cntrl = 0x00; 970 909 971 - dev->dvb.frontend = dvb_attach(zl10353_attach, 910 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 972 911 &cx88_geniatech_x8000_mt, 973 912 &core->i2c_adap); 974 913 if (attach_xc3028(0x61, dev) < 0) 975 914 goto frontend_detach; 976 915 break; 977 916 case CX88_BOARD_KWORLD_ATSC_120: 978 - dev->dvb.frontend = dvb_attach(s5h1409_attach, 917 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 979 918 &kworld_atsc_120_config, 980 919 &core->i2c_adap); 981 920 if (attach_xc3028(0x61, dev) < 0) 982 921 goto frontend_detach; 983 922 break; 984 923 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: 985 - dev->dvb.frontend = dvb_attach(s5h1411_attach, 924 + fe0->dvb.frontend = dvb_attach(s5h1411_attach, 986 925 &dvico_fusionhdtv7_config, 987 926 &core->i2c_adap); 988 - if (dev->dvb.frontend != NULL) { 989 - if (!dvb_attach(xc5000_attach, dev->dvb.frontend, 927 + if (fe0->dvb.frontend != NULL) { 928 + if (!dvb_attach(xc5000_attach, fe0->dvb.frontend, 990 929 &core->i2c_adap, 991 930 &dvico_fusionhdtv7_tuner_config)) 992 931 goto frontend_detach; 993 932 } 994 933 break; 995 934 case CX88_BOARD_HAUPPAUGE_HVR4000: 996 - case CX88_BOARD_HAUPPAUGE_HVR4000LITE: 997 - /* Support for DVB-S only, not DVB-T support */ 998 - dev->dvb.frontend = dvb_attach(cx24116_attach, 935 + /* DVB-S/S2 Init */ 936 + fe0->dvb.frontend = dvb_attach(cx24116_attach, 999 937 &hauppauge_hvr4000_config, 1000 938 &dev->core->i2c_adap); 1001 - if (dev->dvb.frontend) { 1002 - dvb_attach(isl6421_attach, dev->dvb.frontend, 939 + if (fe0->dvb.frontend) { 940 + if(!dvb_attach(isl6421_attach, fe0->dvb.frontend, 941 + &dev->core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) { 942 + dprintk( 1, "%s(): HVR4000 - DVB-S LNB Init: failed\n", __func__); 943 + } 944 + } else { 945 + dprintk( 1, "%s(): HVR4000 - DVB-S Init: failed\n", __func__); 946 + } 947 + /* DVB-T Init */ 948 + fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2); 949 + if (fe1) { 950 + dev->frontends.gate = 2; 951 + mfe_shared = 1; 952 + fe1->dvb.frontend = dvb_attach(cx22702_attach, 953 + &hauppauge_hvr_config, 954 + &dev->core->i2c_adap); 955 + if (fe1->dvb.frontend) { 956 + fe1->dvb.frontend->id = 1; 957 + if(!dvb_attach(simple_tuner_attach, fe1->dvb.frontend, 958 + &dev->core->i2c_adap, 0x61, 959 + TUNER_PHILIPS_FMD1216ME_MK3)) { 960 + dprintk( 1, "%s(): HVR4000 - DVB-T misc Init: failed\n", __func__); 961 + } 962 + } else { 963 + dprintk( 1, "%s(): HVR4000 - DVB-T Init: failed\n", __func__); 964 + } 965 + } else { 966 + dprintk( 1, "%s(): HVR4000 - DVB-T Init: can't find frontend 2.\n", __func__); 967 + } 968 + break; 969 + case CX88_BOARD_HAUPPAUGE_HVR4000LITE: 970 + fe0->dvb.frontend = dvb_attach(cx24116_attach, 971 + &hauppauge_hvr4000_config, 972 + &dev->core->i2c_adap); 973 + if (fe0->dvb.frontend) { 974 + dvb_attach(isl6421_attach, fe0->dvb.frontend, 1003 975 &dev->core->i2c_adap, 1004 976 0x08, ISL6421_DCL, 0x00); 1005 977 } 1006 978 break; 1007 979 case CX88_BOARD_TEVII_S420: 1008 - dev->dvb.frontend = dvb_attach(stv0299_attach, 980 + fe0->dvb.frontend = dvb_attach(stv0299_attach, 1009 981 &tevii_tuner_sharp_config, 1010 982 &core->i2c_adap); 1011 - if (dev->dvb.frontend != NULL) { 1012 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 983 + if (fe0->dvb.frontend != NULL) { 984 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60, 1013 985 &core->i2c_adap, DVB_PLL_OPERA1)) 1014 986 goto frontend_detach; 1015 - core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 1016 - dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 987 + core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; 988 + fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1017 989 1018 990 } else { 1019 - dev->dvb.frontend = dvb_attach(stv0288_attach, 991 + fe0->dvb.frontend = dvb_attach(stv0288_attach, 1020 992 &tevii_tuner_earda_config, 1021 993 &core->i2c_adap); 1022 - if (dev->dvb.frontend != NULL) { 1023 - if (!dvb_attach(stb6000_attach, dev->dvb.frontend, 0x61, 994 + if (fe0->dvb.frontend != NULL) { 995 + if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61, 1024 996 &core->i2c_adap)) 1025 997 goto frontend_detach; 1026 - core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 1027 - dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 998 + core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; 999 + fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1028 1000 1029 1001 } 1030 1002 } 1031 1003 break; 1032 1004 case CX88_BOARD_TEVII_S460: 1033 - dev->dvb.frontend = dvb_attach(cx24116_attach, 1005 + fe0->dvb.frontend = dvb_attach(cx24116_attach, 1034 1006 &tevii_s460_config, 1035 1007 &core->i2c_adap); 1036 - if (dev->dvb.frontend != NULL) { 1037 - core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 1038 - dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1008 + if (fe0->dvb.frontend != NULL) { 1009 + core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; 1010 + fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1039 1011 } 1040 1012 break; 1041 1013 case CX88_BOARD_OMICOM_SS4_PCI: 1042 1014 case CX88_BOARD_TBS_8920: 1043 1015 case CX88_BOARD_PROF_7300: 1044 - dev->dvb.frontend = dvb_attach(cx24116_attach, 1016 + fe0->dvb.frontend = dvb_attach(cx24116_attach, 1045 1017 &hauppauge_hvr4000_config, 1046 1018 &core->i2c_adap); 1047 - if (dev->dvb.frontend != NULL) { 1048 - core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 1049 - dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1019 + if (fe0->dvb.frontend != NULL) { 1020 + core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; 1021 + fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1050 1022 } 1051 1023 break; 1052 1024 default: ··· 1087 993 core->name); 1088 994 break; 1089 995 } 1090 - if (NULL == dev->dvb.frontend) { 996 + 997 + if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) { 1091 998 printk(KERN_ERR 1092 999 "%s/2: frontend initialization failed\n", 1093 1000 core->name); 1094 1001 return -EINVAL; 1095 1002 } 1096 1003 /* define general-purpose callback pointer */ 1097 - dev->dvb.frontend->callback = cx88_tuner_callback; 1004 + fe0->dvb.frontend->callback = cx88_tuner_callback; 1098 1005 1099 1006 /* Ensure all frontends negotiate bus access */ 1100 - dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; 1007 + fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; 1008 + if (fe1) 1009 + fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; 1101 1010 1102 1011 /* Put the analog decoder in standby to keep it quiet */ 1103 1012 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL); 1104 1013 1105 1014 /* register everything */ 1106 - return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, 1107 - &dev->pci->dev, adapter_nr); 1015 + return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, 1016 + &dev->pci->dev, adapter_nr, mfe_shared); 1108 1017 1109 1018 frontend_detach: 1110 - if (dev->dvb.frontend) { 1111 - dvb_frontend_detach(dev->dvb.frontend); 1112 - dev->dvb.frontend = NULL; 1019 + if (fe0->dvb.frontend) { 1020 + dvb_frontend_detach(fe0->dvb.frontend); 1021 + fe0->dvb.frontend = NULL; 1113 1022 } 1114 1023 return -EINVAL; 1115 1024 } ··· 1136 1039 cx_clear(MO_GP0_IO, 0x00000004); 1137 1040 udelay(1000); 1138 1041 break; 1042 + 1043 + case CX88_BOARD_HAUPPAUGE_HVR3000: 1044 + case CX88_BOARD_HAUPPAUGE_HVR4000: 1045 + if(core->dvbdev->frontends.active_fe_id == 1) { 1046 + /* DVB-S/S2 Enabled */ 1047 + 1048 + /* Toggle reset on cx22702 leaving i2c active */ 1049 + cx_write(MO_GP0_IO, (core->board.input[0].gpio0 & 0x0000ff00) | 0x00000080); 1050 + udelay(1000); 1051 + cx_clear(MO_GP0_IO, 0x00000080); 1052 + udelay(50); 1053 + cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset */ 1054 + cx_set(MO_GP0_IO, 0x00000004); /* tri-state the cx22702 pins */ 1055 + udelay(1000); 1056 + 1057 + cx_write(MO_SRST_IO, 1); /* Take the cx24116/cx24123 out of reset */ 1058 + core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */ 1059 + } else 1060 + if (core->dvbdev->frontends.active_fe_id == 2) { 1061 + /* DVB-T Enabled */ 1062 + 1063 + /* Put the cx24116/cx24123 into reset */ 1064 + cx_write(MO_SRST_IO, 0); 1065 + 1066 + /* cx22702 out of reset and enable it */ 1067 + cx_set(MO_GP0_IO, 0x00000080); 1068 + cx_clear(MO_GP0_IO, 0x00000004); 1069 + core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */ 1070 + udelay(1000); 1071 + } 1072 + break; 1073 + 1139 1074 default: 1140 1075 err = -ENODEV; 1141 1076 } ··· 1185 1056 case CX88_BOARD_HAUPPAUGE_HVR1300: 1186 1057 /* Do Nothing, leave the cx22702 on the bus. */ 1187 1058 break; 1059 + case CX88_BOARD_HAUPPAUGE_HVR3000: 1060 + case CX88_BOARD_HAUPPAUGE_HVR4000: 1061 + break; 1188 1062 default: 1189 1063 err = -ENODEV; 1190 1064 } ··· 1198 1066 { 1199 1067 struct cx88_core *core = drv->core; 1200 1068 struct cx8802_dev *dev = drv->core->dvbdev; 1201 - int err; 1069 + int err, i; 1070 + struct videobuf_dvb_frontend *fe; 1202 1071 1203 1072 dprintk( 1, "%s\n", __func__); 1204 1073 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", ··· 1219 1086 1220 1087 /* dvb stuff */ 1221 1088 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); 1222 - videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops, 1089 + dev->ts_gen_cntrl = 0x0c; 1090 + 1091 + for (i = 1; i <= core->board.num_frontends; i++) { 1092 + fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i); 1093 + if (!fe) { 1094 + printk(KERN_ERR "%s() failed to get frontend(%d)\n", __func__, i); 1095 + continue; 1096 + } 1097 + videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops, 1223 1098 &dev->pci->dev, &dev->slock, 1224 1099 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1225 1100 V4L2_FIELD_TOP, 1226 1101 sizeof(struct cx88_buffer), 1227 1102 dev); 1103 + /* init struct videobuf_dvb */ 1104 + fe->dvb.name = dev->core->name; 1105 + } 1228 1106 err = dvb_register(dev); 1229 1107 if (err != 0) 1230 1108 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n", 1231 1109 core->name, err); 1232 - 1233 - fail_core: 1110 + fail_core: 1234 1111 return err; 1235 1112 } 1236 1113 ··· 1248 1105 { 1249 1106 struct cx8802_dev *dev = drv->core->dvbdev; 1250 1107 1251 - /* dvb */ 1252 - if (dev->dvb.frontend) 1253 - videobuf_dvb_unregister(&dev->dvb); 1108 + videobuf_dvb_unregister_bus(&dev->frontends); 1254 1109 1255 1110 vp3054_i2c_remove(dev); 1256 1111
+12 -5
drivers/media/video/cx88/cx88-i2c.c
··· 116 116 117 117 void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg) 118 118 { 119 + struct videobuf_dvb_frontends *f = &core->dvbdev->frontends; 120 + struct videobuf_dvb_frontend *fe = NULL; 119 121 if (0 != core->i2c_rc) 120 122 return; 121 123 122 124 #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) 123 - if ( (core->dvbdev) && (core->dvbdev->dvb.frontend) ) { 124 - if (core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl) 125 - core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl(core->dvbdev->dvb.frontend, 1); 125 + if (core->dvbdev && f) { 126 + if(f->gate <= 1) /* undefined or fe0 */ 127 + fe = videobuf_dvb_get_frontend(f, 1); 128 + else 129 + fe = videobuf_dvb_get_frontend(f, f->gate); 130 + 131 + if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl) 132 + fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, 1); 126 133 127 134 i2c_clients_command(&core->i2c_adap, cmd, arg); 128 135 129 - if (core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl) 130 - core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl(core->dvbdev->dvb.frontend, 0); 136 + if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl) 137 + fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, 0); 131 138 } else 132 139 #endif 133 140 i2c_clients_command(&core->i2c_adap, cmd, arg);
+21 -1
drivers/media/video/cx88/cx88-mpeg.c
··· 768 768 { 769 769 struct cx8802_dev *dev; 770 770 struct cx88_core *core; 771 - int err; 771 + struct videobuf_dvb_frontend *demod; 772 + int err,i; 772 773 773 774 /* general setup */ 774 775 core = cx88_core_get(pci_dev); ··· 781 780 err = -ENODEV; 782 781 if (!core->board.mpeg) 783 782 goto fail_core; 783 + 784 + if (!core->board.num_frontends) { 785 + printk(KERN_ERR "%s() .num_frontends should be non-zero, err = %d\n", __func__, err); 786 + goto fail_core; 787 + } 784 788 785 789 err = -ENOMEM; 786 790 dev = kzalloc(sizeof(*dev),GFP_KERNEL); ··· 800 794 801 795 INIT_LIST_HEAD(&dev->drvlist); 802 796 list_add_tail(&dev->devlist,&cx8802_devlist); 797 + 798 + mutex_init(&dev->frontends.lock); 799 + INIT_LIST_HEAD(&dev->frontends.felist); 800 + 801 + printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, core->board.num_frontends); 802 + 803 + for (i = 1; i <= core->board.num_frontends; i++) { 804 + demod = videobuf_dvb_alloc_frontend(&dev->frontends, i); 805 + if(demod == NULL) { 806 + printk(KERN_ERR "%s() failed to alloc\n", __func__); 807 + err = -ENOMEM; 808 + goto fail_free; 809 + } 810 + } 803 811 804 812 /* Maintain a reference so cx88-video can query the 8802 device. */ 805 813 core->dvbdev = dev;
+11
drivers/media/video/cx88/cx88-tvaudio.c
··· 767 767 case WW_FM: 768 768 set_audio_standard_FM(core, radio_deemphasis); 769 769 break; 770 + case WW_I2SADC: 771 + set_audio_start(core, 0x01); 772 + /* Slave/Philips/Autobaud */ 773 + cx_write(AUD_I2SINPUTCNTL, 0); 774 + /* Switch to "I2S ADC mode" */ 775 + cx_write(AUD_I2SCNTL, 0x1); 776 + set_audio_finish(core, EN_I2SIN_ENABLE); 777 + break; 770 778 case WW_NONE: 771 779 default: 772 780 printk("%s/0: unknown tv audio mode [%d]\n", ··· 902 894 mask = 0x3f; 903 895 break; 904 896 } 897 + break; 898 + case WW_I2SADC: 899 + /* DO NOTHING */ 905 900 break; 906 901 } 907 902
+30 -22
drivers/media/video/cx88/cx88-video.c
··· 426 426 427 427 /* if there are audioroutes defined, we have an external 428 428 ADC to deal with audio */ 429 - 430 429 if (INPUT(input).audioroute) { 431 - 432 - /* cx2388's C-ADC is connected to the tuner only. 433 - When used with S-Video, that ADC is busy dealing with 434 - chroma, so an external must be used for baseband audio */ 435 - 436 - if (INPUT(input).type != CX88_VMUX_TELEVISION && 437 - INPUT(input).type != CX88_RADIO) { 438 - /* "ADC mode" */ 439 - cx_write(AUD_I2SCNTL, 0x1); 440 - cx_set(AUD_CTL, EN_I2SIN_ENABLE); 441 - } else { 442 - /* Normal mode */ 443 - cx_write(AUD_I2SCNTL, 0x0); 444 - cx_clear(AUD_CTL, EN_I2SIN_ENABLE); 445 - } 446 - 447 430 /* The wm8775 module has the "2" route hardwired into 448 431 the initialization. Some boards may use different 449 432 routes for different inputs. HVR-1300 surely does */ ··· 437 454 route.input = INPUT(input).audioroute; 438 455 cx88_call_i2c_clients(core, 439 456 VIDIOC_INT_S_AUDIO_ROUTING, &route); 440 - 441 457 } 442 - 458 + /* cx2388's C-ADC is connected to the tuner only. 459 + When used with S-Video, that ADC is busy dealing with 460 + chroma, so an external must be used for baseband audio */ 461 + if (INPUT(input).type != CX88_VMUX_TELEVISION ) { 462 + /* "I2S ADC mode" */ 463 + core->tvaudio = WW_I2SADC; 464 + cx88_set_tvaudio(core); 465 + } else { 466 + /* Normal mode */ 467 + cx_write(AUD_I2SCNTL, 0x0); 468 + cx_clear(AUD_CTL, EN_I2SIN_ENABLE); 469 + } 443 470 } 444 471 445 472 return 0; ··· 825 832 cx_write(MO_GP0_IO, core->board.radio.gpio0); 826 833 cx_write(MO_GP1_IO, core->board.radio.gpio1); 827 834 cx_write(MO_GP2_IO, core->board.radio.gpio2); 828 - core->tvaudio = WW_FM; 829 - cx88_set_tvaudio(core); 830 - cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); 835 + if (core->board.radio.audioroute) { 836 + if(core->board.audio_chip && 837 + core->board.audio_chip == V4L2_IDENT_WM8775) { 838 + struct v4l2_routing route; 839 + 840 + route.input = core->board.radio.audioroute; 841 + cx88_call_i2c_clients(core, 842 + VIDIOC_INT_S_AUDIO_ROUTING, &route); 843 + } 844 + /* "I2S ADC mode" */ 845 + core->tvaudio = WW_I2SADC; 846 + cx88_set_tvaudio(core); 847 + } else { 848 + /* FM Mode */ 849 + core->tvaudio = WW_FM; 850 + cx88_set_tvaudio(core); 851 + cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); 852 + } 831 853 cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL); 832 854 } 833 855 unlock_kernel();
+5 -2
drivers/media/video/cx88/cx88.h
··· 247 247 enum cx88_itype type; 248 248 u32 gpio0, gpio1, gpio2, gpio3; 249 249 unsigned int vmux:2; 250 - unsigned int audioroute:2; 250 + unsigned int audioroute:4; 251 251 }; 252 252 253 253 struct cx88_board { ··· 261 261 struct cx88_input radio; 262 262 enum cx88_board_type mpeg; 263 263 unsigned int audio_chip; 264 + int num_frontends; 264 265 }; 265 266 266 267 struct cx88_subid { ··· 357 356 struct cx8802_dev *dvbdev; 358 357 enum cx88_board_type active_type_id; 359 358 int active_ref; 359 + int active_fe_id; 360 360 }; 361 361 362 362 struct cx8800_dev; ··· 492 490 493 491 #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) 494 492 /* for dvb only */ 495 - struct videobuf_dvb dvb; 493 + struct videobuf_dvb_frontends frontends; 496 494 #endif 497 495 498 496 #if defined(CONFIG_VIDEO_CX88_VP3054) || \ ··· 630 628 #define WW_EIAJ 7 631 629 #define WW_I2SPT 8 632 630 #define WW_FM 9 631 + #define WW_I2SADC 10 633 632 634 633 void cx88_set_tvaudio(struct cx88_core *core); 635 634 void cx88_newstation(struct cx88_core *core);
+2 -1
drivers/media/video/gspca/gspca.c
··· 21 21 #define MODULE_NAME "gspca" 22 22 23 23 #include <linux/init.h> 24 + #include <linux/version.h> 24 25 #include <linux/fs.h> 25 26 #include <linux/vmalloc.h> 26 27 #include <linux/sched.h> ··· 404 403 unsigned int i; 405 404 406 405 PDEBUG(D_STREAM, "kill transfer"); 407 - for (i = 0; i < MAX_NURBS; ++i) { 406 + for (i = 0; i < MAX_NURBS; i++) { 408 407 urb = gspca_dev->urb[i]; 409 408 if (urb == NULL) 410 409 break;
-1
drivers/media/video/gspca/gspca.h
··· 2 2 #define GSPCAV2_H 3 3 4 4 #include <linux/module.h> 5 - #include <linux/version.h> 6 5 #include <linux/kernel.h> 7 6 #include <linux/usb.h> 8 7 #include <linux/videodev2.h>
+1 -28
drivers/media/video/gspca/m5602/m5602_bridge.h
··· 1 1 /* 2 2 * USB Driver for ALi m5602 based webcams 3 3 * 4 - * Copyright (C) 2008 Erik Andren 4 + * Copyright (C) 2008 Erik Andrén 5 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 * ··· 22 22 #include "gspca.h" 23 23 24 24 #define MODULE_NAME "ALi m5602" 25 - 26 - /*****************************************************************************/ 27 - 28 - #undef PDEBUG 29 - #undef info 30 - #undef err 31 - 32 - #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ 33 - format "\n" , ## arg) 34 - #define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \ 35 - format "\n" , ## arg) 36 - 37 - /* Debug parameters */ 38 - #define DBG_INIT 0x1 39 - #define DBG_PROBE 0x2 40 - #define DBG_V4L2 0x4 41 - #define DBG_TRACE 0x8 42 - #define DBG_DATA 0x10 43 - #define DBG_V4L2_CID 0x20 44 - #define DBG_GSPCA 0x40 45 - 46 - #define PDEBUG(level, fmt, args...) \ 47 - do { \ 48 - if (m5602_debug & level) \ 49 - info("[%s:%d] " fmt, __func__, __LINE__ , \ 50 - ## args); \ 51 - } while (0) 52 25 53 26 /*****************************************************************************/ 54 27
+21 -25
drivers/media/video/gspca/m5602/m5602_core.c
··· 1 - /* 1 + /* 2 2 * USB Driver for ALi m5602 based webcams 3 3 * 4 - * Copyright (C) 2008 Erik Andren 4 + * Copyright (C) 2008 Erik Andrén 5 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 * ··· 26 26 int force_sensor; 27 27 int dump_bridge; 28 28 int dump_sensor; 29 - unsigned int m5602_debug; 30 29 31 30 static const __devinitdata struct usb_device_id m5602_table[] = { 32 31 {USB_DEVICE(0x0402, 0x5602)}, ··· 47 48 1, M5602_URB_MSG_TIMEOUT); 48 49 *i2c_data = buf[0]; 49 50 50 - PDEBUG(DBG_TRACE, "Reading bridge register 0x%x containing 0x%x", 51 + PDEBUG(D_CONF, "Reading bridge register 0x%x containing 0x%x", 51 52 address, *i2c_data); 52 53 53 54 /* usb_control_msg(...) returns the number of bytes sent upon success, ··· 62 63 struct usb_device *udev = sd->gspca_dev.dev; 63 64 __u8 *buf = sd->gspca_dev.usb_buf; 64 65 65 - PDEBUG(DBG_TRACE, "Writing bridge register 0x%x with 0x%x", 66 + PDEBUG(D_CONF, "Writing bridge register 0x%x with 0x%x", 66 67 address, i2c_data); 67 68 68 69 memcpy(buf, bridge_urb_skeleton, ··· 90 91 m5602_read_bridge(sd, i, &val); 91 92 info("ALi m5602 address 0x%x contains 0x%x", i, val); 92 93 } 93 - info("Warning: The camera probably won't work until it's power cycled"); 94 + info("Warning: The ALi m5602 webcam probably won't work " 95 + "until it's power cycled"); 94 96 } 95 97 96 98 static int m5602_probe_sensor(struct sd *sd) ··· 135 135 struct sd *sd = (struct sd *) gspca_dev; 136 136 int err; 137 137 138 - PDEBUG(DBG_TRACE, "Initializing ALi m5602 webcam"); 138 + PDEBUG(D_CONF, "Initializing ALi m5602 webcam"); 139 139 /* Run the init sequence */ 140 140 err = sd->sensor->init(sd); 141 141 ··· 146 146 { 147 147 struct sd *sd = (struct sd *) gspca_dev; 148 148 __u8 *buf = sd->gspca_dev.usb_buf; 149 + int err; 149 150 150 151 /* Send start command to the camera */ 151 152 const u8 buffer[4] = {0x13, 0xf9, 0x0f, 0x01}; 152 153 memcpy(buf, buffer, sizeof(buffer)); 153 - usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), 154 - 0x04, 0x40, 0x19, 0x0000, buf, 155 - 4, M5602_URB_MSG_TIMEOUT); 154 + err = usb_control_msg(gspca_dev->dev, 155 + usb_sndctrlpipe(gspca_dev->dev, 0), 156 + 0x04, 0x40, 0x19, 0x0000, buf, 157 + 4, M5602_URB_MSG_TIMEOUT); 156 158 157 - PDEBUG(DBG_V4L2, "Transfer started"); 158 - return 0; 159 + PDEBUG(D_STREAM, "Transfer started"); 160 + return (err < 0) ? err : 0; 159 161 } 160 162 161 163 static void m5602_urb_complete(struct gspca_dev *gspca_dev, ··· 167 165 struct sd *sd = (struct sd *) gspca_dev; 168 166 169 167 if (len < 6) { 170 - PDEBUG(DBG_DATA, "Packet is less than 6 bytes"); 168 + PDEBUG(D_PACK, "Packet is less than 6 bytes"); 171 169 return; 172 170 } 173 171 174 172 /* Frame delimiter: ff xx xx xx ff ff */ 175 173 if (data[0] == 0xff && data[4] == 0xff && data[5] == 0xff && 176 174 data[2] != sd->frame_id) { 177 - PDEBUG(DBG_DATA, "Frame delimiter detected"); 175 + PDEBUG(D_FRAM, "Frame delimiter detected"); 178 176 sd->frame_id = data[2]; 179 177 180 178 /* Remove the extra fluff appended on each header */ ··· 189 187 /* Create a new frame */ 190 188 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len); 191 189 192 - PDEBUG(DBG_V4L2, "Starting new frame %d", 190 + PDEBUG(D_FRAM, "Starting new frame %d", 193 191 sd->frame_count); 194 192 195 193 } else { ··· 200 198 len -= 4; 201 199 202 200 if (cur_frame_len + len <= frame->v4l2_buf.length) { 203 - PDEBUG(DBG_DATA, "Continuing frame %d copying %d bytes", 201 + PDEBUG(D_FRAM, "Continuing frame %d copying %d bytes", 204 202 sd->frame_count, len); 205 203 206 204 gspca_frame_add(gspca_dev, INTER_PACKET, frame, ··· 236 234 struct cam *cam; 237 235 int err; 238 236 239 - PDEBUG(DBG_GSPCA, "m5602_configure start"); 240 - 241 237 cam = &gspca_dev->cam; 242 238 cam->epaddr = M5602_ISOC_ENDPOINT_ADDR; 243 239 sd->desc = &sd_desc; ··· 248 248 if (err) 249 249 goto fail; 250 250 251 - PDEBUG(DBG_GSPCA, "m5602_configure end"); 252 251 return 0; 253 252 254 253 fail: 255 - PDEBUG(DBG_GSPCA, "m5602_configure failed"); 254 + PDEBUG(D_ERR, "ALi m5602 webcam failed"); 256 255 cam->cam_mode = NULL; 257 256 cam->nmodes = 0; 258 257 ··· 281 282 { 282 283 if (usb_register(&sd_driver) < 0) 283 284 return -1; 284 - PDEBUG(D_PROBE, "m5602 module registered"); 285 + PDEBUG(D_PROBE, "registered"); 285 286 return 0; 286 287 } 287 288 static void __exit mod_m5602_exit(void) 288 289 { 289 290 usb_deregister(&sd_driver); 290 - PDEBUG(D_PROBE, "m5602 module deregistered"); 291 + PDEBUG(D_PROBE, "deregistered"); 291 292 } 292 293 293 294 module_init(mod_m5602_init); ··· 296 297 MODULE_AUTHOR(DRIVER_AUTHOR); 297 298 MODULE_DESCRIPTION(DRIVER_DESC); 298 299 MODULE_LICENSE("GPL"); 299 - module_param_named(debug, m5602_debug, int, S_IRUGO | S_IWUSR); 300 - MODULE_PARM_DESC(debug, "toggles debug on/off"); 301 - 302 300 module_param(force_sensor, int, S_IRUGO | S_IWUSR); 303 301 MODULE_PARM_DESC(force_sensor, 304 302 "force detection of sensor, "
+9 -9
drivers/media/video/gspca/m5602/m5602_mt9m111.c
··· 1 1 /* 2 2 * Driver for the mt9m111 sensor 3 3 * 4 - * Copyright (C) 2008 Erik Andren 4 + * Copyright (C) 2008 Erik Andrén 5 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 * ··· 107 107 err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, 108 108 data, 2); 109 109 *val = data[0] & MT9M111_RMB_MIRROR_ROWS; 110 - PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); 110 + PDEBUG(D_V4L2, "Read vertical flip %d", *val); 111 111 112 112 return (err < 0) ? err : 0; 113 113 } ··· 118 118 u8 data[2] = {0x00, 0x00}; 119 119 struct sd *sd = (struct sd *) gspca_dev; 120 120 121 - PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); 121 + PDEBUG(D_V4L2, "Set vertical flip to %d", val); 122 122 123 123 /* Set the correct page map */ 124 124 err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); ··· 145 145 err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, 146 146 data, 2); 147 147 *val = data[0] & MT9M111_RMB_MIRROR_COLS; 148 - PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); 148 + PDEBUG(D_V4L2, "Read horizontal flip %d", *val); 149 149 150 150 return (err < 0) ? err : 0; 151 151 } ··· 156 156 u8 data[2] = {0x00, 0x00}; 157 157 struct sd *sd = (struct sd *) gspca_dev; 158 158 159 - PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", val); 159 + PDEBUG(D_V4L2, "Set horizontal flip to %d", val); 160 160 161 161 /* Set the correct page map */ 162 162 err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); ··· 188 188 ((tmp & (1 << 8)) * 2) | 189 189 (tmp & 0x7f); 190 190 191 - PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 191 + PDEBUG(D_V4L2, "Read gain %d", *val); 192 192 193 193 return (err < 0) ? err : 0; 194 194 } ··· 222 222 223 223 data[1] = (tmp & 0xff00) >> 8; 224 224 data[0] = (tmp & 0xff); 225 - PDEBUG(DBG_V4L2_CID, "tmp=%d, data[1]=%d, data[0]=%d", tmp, 225 + PDEBUG(D_V4L2, "tmp=%d, data[1]=%d, data[0]=%d", tmp, 226 226 data[1], data[0]); 227 227 228 228 err = mt9m111_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, ··· 257 257 for (i = 0; i < len && !err; i++) { 258 258 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 259 259 260 - PDEBUG(DBG_TRACE, "Reading sensor register " 260 + PDEBUG(D_CONF, "Reading sensor register " 261 261 "0x%x contains 0x%x ", address, *i2c_data); 262 262 } 263 263 out: ··· 290 290 memcpy(p, sensor_urb_skeleton + 16, 4); 291 291 p[3] = i2c_data[i]; 292 292 p += 4; 293 - PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 293 + PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", 294 294 address, i2c_data[i]); 295 295 } 296 296
+3 -4
drivers/media/video/gspca/m5602/m5602_mt9m111.h
··· 1 1 /* 2 2 * Driver for the mt9m111 sensor 3 3 * 4 - * Copyright (C) 2008 Erik Andren 4 + * Copyright (C) 2008 Erik Andrén 5 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 * ··· 82 82 /* Kernel module parameters */ 83 83 extern int force_sensor; 84 84 extern int dump_sensor; 85 - extern unsigned int m5602_debug; 86 85 87 86 int mt9m111_probe(struct sd *sd); 88 87 int mt9m111_init(struct sd *sd); ··· 151 152 .default_value = DEFAULT_GAIN, 152 153 .flags = V4L2_CTRL_FLAG_SLIDER 153 154 }, 154 - .set = mt9m111_set_hflip, 155 - .get = mt9m111_get_hflip 155 + .set = mt9m111_set_gain, 156 + .get = mt9m111_get_gain 156 157 } 157 158 }, 158 159
+20 -20
drivers/media/video/gspca/m5602/m5602_ov9650.c
··· 1 1 /* 2 2 * Driver for the ov9650 sensor 3 3 * 4 - * Copyright (C) 2008 Erik Andren 4 + * Copyright (C) 2008 Erik Andrén 5 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 * ··· 40 40 for (i = 0; i < len; i++) { 41 41 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 42 42 43 - PDEBUG(DBG_TRACE, "Reading sensor register " 43 + PDEBUG(D_CONF, "Reading sensor register " 44 44 "0x%x containing 0x%x ", address, *i2c_data); 45 45 } 46 46 return (err < 0) ? err : 0; ··· 72 72 memcpy(p, sensor_urb_skeleton + 16, 4); 73 73 p[3] = i2c_data[i]; 74 74 p += 4; 75 - PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 75 + PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", 76 76 address, i2c_data[i]); 77 77 } 78 78 ··· 199 199 goto out; 200 200 *val |= (i2c_data & 0x3f) << 10; 201 201 202 - PDEBUG(DBG_V4L2_CID, "Read exposure %d", *val); 202 + PDEBUG(D_V4L2, "Read exposure %d", *val); 203 203 out: 204 204 return (err < 0) ? err : 0; 205 205 } ··· 210 210 u8 i2c_data; 211 211 int err; 212 212 213 - PDEBUG(DBG_V4L2_CID, "Set exposure to %d", 213 + PDEBUG(D_V4L2, "Set exposure to %d", 214 214 val & 0xffff); 215 215 216 216 /* The 6 MSBs */ ··· 246 246 247 247 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); 248 248 *val |= i2c_data; 249 - PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 249 + PDEBUG(D_V4L2, "Read gain %d", *val); 250 250 return (err < 0) ? err : 0; 251 251 } 252 252 ··· 280 280 err = ov9650_read_sensor(sd, OV9650_RED, &i2c_data, 1); 281 281 *val = i2c_data; 282 282 283 - PDEBUG(DBG_V4L2_CID, "Read red gain %d", *val); 283 + PDEBUG(D_V4L2, "Read red gain %d", *val); 284 284 285 285 return (err < 0) ? err : 0; 286 286 } ··· 291 291 u8 i2c_data; 292 292 struct sd *sd = (struct sd *) gspca_dev; 293 293 294 - PDEBUG(DBG_V4L2_CID, "Set red gain to %d", 294 + PDEBUG(D_V4L2, "Set red gain to %d", 295 295 val & 0xff); 296 296 297 297 i2c_data = val & 0xff; ··· 309 309 err = ov9650_read_sensor(sd, OV9650_BLUE, &i2c_data, 1); 310 310 *val = i2c_data; 311 311 312 - PDEBUG(DBG_V4L2_CID, "Read blue gain %d", *val); 312 + PDEBUG(D_V4L2, "Read blue gain %d", *val); 313 313 314 314 return (err < 0) ? err : 0; 315 315 } ··· 320 320 u8 i2c_data; 321 321 struct sd *sd = (struct sd *) gspca_dev; 322 322 323 - PDEBUG(DBG_V4L2_CID, "Set blue gain to %d", 323 + PDEBUG(D_V4L2, "Set blue gain to %d", 324 324 val & 0xff); 325 325 326 326 i2c_data = val & 0xff; ··· 340 340 *val = ((i2c_data & OV9650_HFLIP) >> 5) ? 0 : 1; 341 341 else 342 342 *val = (i2c_data & OV9650_HFLIP) >> 5; 343 - PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); 343 + PDEBUG(D_V4L2, "Read horizontal flip %d", *val); 344 344 345 345 return (err < 0) ? err : 0; 346 346 } ··· 351 351 u8 i2c_data; 352 352 struct sd *sd = (struct sd *) gspca_dev; 353 353 354 - PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", val); 354 + PDEBUG(D_V4L2, "Set horizontal flip to %d", val); 355 355 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 356 356 if (err < 0) 357 357 goto out; ··· 379 379 *val = ((i2c_data & 0x10) >> 4) ? 0 : 1; 380 380 else 381 381 *val = (i2c_data & 0x10) >> 4; 382 - PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); 382 + PDEBUG(D_V4L2, "Read vertical flip %d", *val); 383 383 384 384 return (err < 0) ? err : 0; 385 385 } ··· 390 390 u8 i2c_data; 391 391 struct sd *sd = (struct sd *) gspca_dev; 392 392 393 - PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); 393 + PDEBUG(D_V4L2, "Set vertical flip to %d", val); 394 394 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 395 395 if (err < 0) 396 396 goto out; ··· 420 420 421 421 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); 422 422 *val |= i2c_data; 423 - PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 423 + PDEBUG(D_V4L2, "Read gain %d", *val); 424 424 out: 425 425 return (err < 0) ? err : 0; 426 426 } ··· 431 431 u8 i2c_data; 432 432 struct sd *sd = (struct sd *) gspca_dev; 433 433 434 - PDEBUG(DBG_V4L2_CID, "Set gain to %d", val & 0x3ff); 434 + PDEBUG(D_V4L2, "Set gain to %d", val & 0x3ff); 435 435 436 436 /* Read the OV9650_VREF register first to avoid 437 437 corrupting the VREF high and low bits */ ··· 461 461 462 462 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 463 463 *val = (i2c_data & OV9650_AWB_EN) >> 1; 464 - PDEBUG(DBG_V4L2_CID, "Read auto white balance %d", *val); 464 + PDEBUG(D_V4L2, "Read auto white balance %d", *val); 465 465 466 466 return (err < 0) ? err : 0; 467 467 } ··· 472 472 u8 i2c_data; 473 473 struct sd *sd = (struct sd *) gspca_dev; 474 474 475 - PDEBUG(DBG_V4L2_CID, "Set auto white balance to %d", val); 475 + PDEBUG(D_V4L2, "Set auto white balance to %d", val); 476 476 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 477 477 if (err < 0) 478 478 goto out; ··· 491 491 492 492 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 493 493 *val = (i2c_data & OV9650_AGC_EN) >> 2; 494 - PDEBUG(DBG_V4L2_CID, "Read auto gain control %d", *val); 494 + PDEBUG(D_V4L2, "Read auto gain control %d", *val); 495 495 496 496 return (err < 0) ? err : 0; 497 497 } ··· 502 502 u8 i2c_data; 503 503 struct sd *sd = (struct sd *) gspca_dev; 504 504 505 - PDEBUG(DBG_V4L2_CID, "Set auto gain control to %d", val); 505 + PDEBUG(D_V4L2, "Set auto gain control to %d", val); 506 506 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 507 507 if (err < 0) 508 508 goto out;
+1 -2
drivers/media/video/gspca/m5602/m5602_ov9650.h
··· 1 1 /* 2 2 * Driver for the ov9650 sensor 3 3 * 4 - * Copyright (C) 2008 Erik Andren 4 + * Copyright (C) 2008 Erik Andrén 5 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 * ··· 121 121 /* Kernel module parameters */ 122 122 extern int force_sensor; 123 123 extern int dump_sensor; 124 - extern unsigned int m5602_debug; 125 124 126 125 int ov9650_probe(struct sd *sd); 127 126 int ov9650_init(struct sd *sd);
+77 -13
drivers/media/video/gspca/m5602/m5602_po1030.c
··· 1 1 /* 2 2 * Driver for the po1030 sensor 3 3 * 4 - * Copyright (c) 2008 Erik Andren 4 + * Copyright (c) 2008 Erik Andrén 5 5 * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 * ··· 82 82 for (i = 0; i < len; i++) { 83 83 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 84 84 85 - PDEBUG(DBG_TRACE, "Reading sensor register " 85 + PDEBUG(D_CONF, "Reading sensor register " 86 86 "0x%x containing 0x%x ", address, *i2c_data); 87 87 } 88 88 return (err < 0) ? err : 0; ··· 112 112 memcpy(p, sensor_urb_skeleton + 16, 4); 113 113 p[3] = i2c_data[i]; 114 114 p += 4; 115 - PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 115 + PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", 116 116 address, i2c_data[i]); 117 117 } 118 118 ··· 185 185 &i2c_data, 1); 186 186 *val |= i2c_data; 187 187 188 - PDEBUG(DBG_V4L2_CID, "Exposure read as %d", *val); 188 + PDEBUG(D_V4L2, "Exposure read as %d", *val); 189 189 out: 190 190 return (err < 0) ? err : 0; 191 191 } ··· 196 196 u8 i2c_data; 197 197 int err; 198 198 199 - PDEBUG(DBG_V4L2, "Set exposure to %d", val & 0xffff); 199 + PDEBUG(D_V4L2, "Set exposure to %d", val & 0xffff); 200 200 201 201 i2c_data = ((val & 0xff00) >> 8); 202 - PDEBUG(DBG_V4L2, "Set exposure to high byte to 0x%x", 202 + PDEBUG(D_V4L2, "Set exposure to high byte to 0x%x", 203 203 i2c_data); 204 204 205 205 err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_H, ··· 208 208 goto out; 209 209 210 210 i2c_data = (val & 0xff); 211 - PDEBUG(DBG_V4L2, "Set exposure to low byte to 0x%x", 211 + PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x", 212 212 i2c_data); 213 213 err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_M, 214 214 &i2c_data, 1); ··· 226 226 err = po1030_read_sensor(sd, PO1030_REG_GLOBALGAIN, 227 227 &i2c_data, 1); 228 228 *val = i2c_data; 229 - PDEBUG(DBG_V4L2_CID, "Read global gain %d", *val); 229 + PDEBUG(D_V4L2, "Read global gain %d", *val); 230 + 231 + return (err < 0) ? err : 0; 232 + } 233 + 234 + int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) 235 + { 236 + struct sd *sd = (struct sd *) gspca_dev; 237 + u8 i2c_data; 238 + int err; 239 + 240 + err = po1030_read_sensor(sd, PO1030_REG_CONTROL2, 241 + &i2c_data, 1); 242 + 243 + *val = (i2c_data >> 7) & 0x01 ; 244 + 245 + PDEBUG(D_V4L2, "Read hflip %d", *val); 246 + 247 + return (err < 0) ? err : 0; 248 + } 249 + 250 + int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val) 251 + { 252 + struct sd *sd = (struct sd *) gspca_dev; 253 + u8 i2c_data; 254 + int err; 255 + 256 + PDEBUG(D_V4L2, "Set hflip %d", val); 257 + 258 + i2c_data = (val & 0x01) << 7; 259 + 260 + err = po1030_write_sensor(sd, PO1030_REG_CONTROL2, 261 + &i2c_data, 1); 262 + 263 + return (err < 0) ? err : 0; 264 + } 265 + 266 + int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) 267 + { 268 + struct sd *sd = (struct sd *) gspca_dev; 269 + u8 i2c_data; 270 + int err; 271 + 272 + err = po1030_read_sensor(sd, PO1030_REG_GLOBALGAIN, 273 + &i2c_data, 1); 274 + 275 + *val = (i2c_data >> 6) & 0x01; 276 + 277 + PDEBUG(D_V4L2, "Read vflip %d", *val); 278 + 279 + return (err < 0) ? err : 0; 280 + } 281 + 282 + int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val) 283 + { 284 + struct sd *sd = (struct sd *) gspca_dev; 285 + u8 i2c_data; 286 + int err; 287 + 288 + PDEBUG(D_V4L2, "Set vflip %d", val); 289 + 290 + i2c_data = (val & 0x01) << 6; 291 + 292 + err = po1030_write_sensor(sd, PO1030_REG_CONTROL2, 293 + &i2c_data, 1); 230 294 231 295 return (err < 0) ? err : 0; 232 296 } ··· 302 238 int err; 303 239 304 240 i2c_data = val & 0xff; 305 - PDEBUG(DBG_V4L2, "Set global gain to %d", i2c_data); 241 + PDEBUG(D_V4L2, "Set global gain to %d", i2c_data); 306 242 err = po1030_write_sensor(sd, PO1030_REG_GLOBALGAIN, 307 243 &i2c_data, 1); 308 244 return (err < 0) ? err : 0; ··· 317 253 err = po1030_read_sensor(sd, PO1030_REG_RED_GAIN, 318 254 &i2c_data, 1); 319 255 *val = i2c_data; 320 - PDEBUG(DBG_V4L2_CID, "Read red gain %d", *val); 256 + PDEBUG(D_V4L2, "Read red gain %d", *val); 321 257 return (err < 0) ? err : 0; 322 258 } 323 259 ··· 328 264 int err; 329 265 330 266 i2c_data = val & 0xff; 331 - PDEBUG(DBG_V4L2, "Set red gain to %d", i2c_data); 267 + PDEBUG(D_V4L2, "Set red gain to %d", i2c_data); 332 268 err = po1030_write_sensor(sd, PO1030_REG_RED_GAIN, 333 269 &i2c_data, 1); 334 270 return (err < 0) ? err : 0; ··· 343 279 err = po1030_read_sensor(sd, PO1030_REG_BLUE_GAIN, 344 280 &i2c_data, 1); 345 281 *val = i2c_data; 346 - PDEBUG(DBG_V4L2_CID, "Read blue gain %d", *val); 282 + PDEBUG(D_V4L2, "Read blue gain %d", *val); 347 283 348 284 return (err < 0) ? err : 0; 349 285 } ··· 354 290 u8 i2c_data; 355 291 int err; 356 292 i2c_data = val & 0xff; 357 - PDEBUG(DBG_V4L2, "Set blue gain to %d", i2c_data); 293 + PDEBUG(D_V4L2, "Set blue gain to %d", i2c_data); 358 294 err = po1030_write_sensor(sd, PO1030_REG_BLUE_GAIN, 359 295 &i2c_data, 1); 360 296
+38 -8
drivers/media/video/gspca/m5602/m5602_po1030.h
··· 1 1 /* 2 2 * Driver for the po1030 sensor. 3 - * This is probably a pixel plus sensor but we haven't identified it yet 4 3 * 5 - * Copyright (c) 2008 Erik Andren 4 + * Copyright (c) 2008 Erik Andrén 6 5 * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 7 6 * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 8 7 * ··· 108 109 #define PO1030_REG_YCONTRAST 0x74 109 110 #define PO1030_REG_YSATURATION 0x75 110 111 112 + #define PO1030_HFLIP (1 << 7) 113 + #define PO1030_VFLIP (1 << 6) 114 + 111 115 /*****************************************************************************/ 112 116 113 117 #define PO1030_GLOBAL_GAIN_DEFAULT 0x12 114 - #define PO1030_EXPOSURE_DEFAULT 0xf0ff 118 + #define PO1030_EXPOSURE_DEFAULT 0x0085 115 119 #define PO1030_BLUE_GAIN_DEFAULT 0x40 116 120 #define PO1030_RED_GAIN_DEFAULT 0x40 117 121 ··· 123 121 /* Kernel module parameters */ 124 122 extern int force_sensor; 125 123 extern int dump_sensor; 126 - extern unsigned int m5602_debug; 127 124 128 125 int po1030_probe(struct sd *sd); 129 126 int po1030_init(struct sd *sd); ··· 143 142 int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val); 144 143 int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val); 145 144 int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val); 145 + int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val); 146 + int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val); 147 + int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val); 148 + int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val); 146 149 147 150 static struct m5602_sensor po1030 = { 148 151 .name = "PO1030", ··· 157 152 .init = po1030_init, 158 153 .power_down = po1030_power_down, 159 154 160 - .nctrls = 4, 155 + .nctrls = 6, 161 156 .ctrls = { 162 157 { 163 158 { ··· 165 160 .type = V4L2_CTRL_TYPE_INTEGER, 166 161 .name = "gain", 167 162 .minimum = 0x00, 168 - .maximum = 0xff, 163 + .maximum = 0x4f, 169 164 .step = 0x1, 170 165 .default_value = PO1030_GLOBAL_GAIN_DEFAULT, 171 166 .flags = V4L2_CTRL_FLAG_SLIDER ··· 178 173 .type = V4L2_CTRL_TYPE_INTEGER, 179 174 .name = "exposure", 180 175 .minimum = 0x00, 181 - .maximum = 0xffff, 176 + .maximum = 0x02ff, 182 177 .step = 0x1, 183 178 .default_value = PO1030_EXPOSURE_DEFAULT, 184 179 .flags = V4L2_CTRL_FLAG_SLIDER ··· 211 206 }, 212 207 .set = po1030_set_blue_balance, 213 208 .get = po1030_get_blue_balance 209 + }, { 210 + { 211 + .id = V4L2_CID_HFLIP, 212 + .type = V4L2_CTRL_TYPE_BOOLEAN, 213 + .name = "horizontal flip", 214 + .minimum = 0, 215 + .maximum = 1, 216 + .step = 1, 217 + .default_value = 0, 218 + }, 219 + .set = po1030_set_hflip, 220 + .get = po1030_get_hflip 221 + }, { 222 + { 223 + .id = V4L2_CID_VFLIP, 224 + .type = V4L2_CTRL_TYPE_BOOLEAN, 225 + .name = "vertical flip", 226 + .minimum = 0, 227 + .maximum = 1, 228 + .step = 1, 229 + .default_value = 0, 230 + }, 231 + .set = po1030_set_vflip, 232 + .get = po1030_get_vflip 214 233 } 215 234 }, 235 + 216 236 .nmodes = 1, 217 237 .modes = { 218 238 { ··· 411 381 412 382 /* Set the y window to 1 */ 413 383 {SENSOR, PO1030_REG_WINDOWY_H, 0x00}, 414 - {SENSOR, PO1030_REG_WINDOWX_L, 0x01}, 384 + {SENSOR, PO1030_REG_WINDOWY_L, 0x01}, 415 385 416 386 {SENSOR, PO1030_REG_WINDOWWIDTH_H, 0x02}, 417 387 {SENSOR, PO1030_REG_WINDOWWIDTH_L, 0x87},
+11 -11
drivers/media/video/gspca/m5602/m5602_s5k4aa.c
··· 1 1 /* 2 2 * Driver for the s5k4aa sensor 3 3 * 4 - * Copyright (C) 2008 Erik Andren 4 + * Copyright (C) 2008 Erik Andrén 5 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 * ··· 117 117 for (i = 0; (i < len) & !err; i++) { 118 118 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 119 119 120 - PDEBUG(DBG_TRACE, "Reading sensor register " 120 + PDEBUG(D_CONF, "Reading sensor register " 121 121 "0x%x containing 0x%x ", address, *i2c_data); 122 122 } 123 123 out: ··· 150 150 memcpy(p, sensor_urb_skeleton + 16, 4); 151 151 p[3] = i2c_data[i]; 152 152 p += 4; 153 - PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 153 + PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", 154 154 address, i2c_data[i]); 155 155 } 156 156 ··· 248 248 *val = data << 8; 249 249 err = s5k4aa_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); 250 250 *val |= data; 251 - PDEBUG(DBG_V4L2_CID, "Read exposure %d", *val); 251 + PDEBUG(D_V4L2, "Read exposure %d", *val); 252 252 out: 253 253 return (err < 0) ? err : 0; 254 254 } ··· 259 259 u8 data = S5K4AA_PAGE_MAP_2; 260 260 int err; 261 261 262 - PDEBUG(DBG_V4L2_CID, "Set exposure to %d", val); 262 + PDEBUG(D_V4L2, "Set exposure to %d", val); 263 263 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 264 264 if (err < 0) 265 265 goto out; ··· 285 285 286 286 err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 287 287 *val = (data & S5K4AA_RM_V_FLIP) >> 7; 288 - PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); 288 + PDEBUG(D_V4L2, "Read vertical flip %d", *val); 289 289 290 290 out: 291 291 return (err < 0) ? err : 0; ··· 297 297 u8 data = S5K4AA_PAGE_MAP_2; 298 298 int err; 299 299 300 - PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); 300 + PDEBUG(D_V4L2, "Set vertical flip to %d", val); 301 301 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 302 302 if (err < 0) 303 303 goto out; ··· 341 341 342 342 err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 343 343 *val = (data & S5K4AA_RM_H_FLIP) >> 6; 344 - PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); 344 + PDEBUG(D_V4L2, "Read horizontal flip %d", *val); 345 345 out: 346 346 return (err < 0) ? err : 0; 347 347 } ··· 352 352 u8 data = S5K4AA_PAGE_MAP_2; 353 353 int err; 354 354 355 - PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", 355 + PDEBUG(D_V4L2, "Set horizontal flip to %d", 356 356 val); 357 357 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 358 358 if (err < 0) ··· 397 397 398 398 err = s5k4aa_read_sensor(sd, S5K4AA_GAIN_2, &data, 1); 399 399 *val = data; 400 - PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 400 + PDEBUG(D_V4L2, "Read gain %d", *val); 401 401 402 402 out: 403 403 return (err < 0) ? err : 0; ··· 409 409 u8 data = S5K4AA_PAGE_MAP_2; 410 410 int err; 411 411 412 - PDEBUG(DBG_V4L2_CID, "Set gain to %d", val); 412 + PDEBUG(D_V4L2, "Set gain to %d", val); 413 413 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 414 414 if (err < 0) 415 415 goto out;
+1 -2
drivers/media/video/gspca/m5602/m5602_s5k4aa.h
··· 1 1 /* 2 2 * Driver for the s5k4aa sensor 3 3 * 4 - * Copyright (C) 2008 Erik Andren 4 + * Copyright (C) 2008 Erik Andrén 5 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 * ··· 63 63 /* Kernel module parameters */ 64 64 extern int force_sensor; 65 65 extern int dump_sensor; 66 - extern unsigned int m5602_debug; 67 66 68 67 int s5k4aa_probe(struct sd *sd); 69 68 int s5k4aa_init(struct sd *sd);
+3 -3
drivers/media/video/gspca/m5602/m5602_s5k83a.c
··· 1 1 /* 2 2 * Driver for the s5k83a sensor 3 3 * 4 - * Copyright (C) 2008 Erik Andren 4 + * Copyright (C) 2008 Erik Andrén 5 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 * ··· 101 101 for (i = 0; i < len && !len; i++) { 102 102 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 103 103 104 - PDEBUG(DBG_TRACE, "Reading sensor register " 104 + PDEBUG(D_CONF, "Reading sensor register " 105 105 "0x%x containing 0x%x ", address, *i2c_data); 106 106 } 107 107 ··· 135 135 memcpy(p, sensor_urb_skeleton + 16, 4); 136 136 p[3] = i2c_data[i]; 137 137 p += 4; 138 - PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 138 + PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", 139 139 address, i2c_data[i]); 140 140 } 141 141
+1 -3
drivers/media/video/gspca/m5602/m5602_s5k83a.h
··· 1 1 /* 2 2 * Driver for the s5k83a sensor 3 3 * 4 - * Copyright (C) 2008 Erik Andren 4 + * Copyright (C) 2008 Erik Andrén 5 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 * ··· 41 41 /* Kernel module parameters */ 42 42 extern int force_sensor; 43 43 extern int dump_sensor; 44 - extern unsigned int m5602_debug; 45 - 46 44 47 45 int s5k83a_probe(struct sd *sd); 48 46 int s5k83a_init(struct sd *sd);
+1 -1
drivers/media/video/gspca/m5602/m5602_sensor.h
··· 1 1 /* 2 2 * USB Driver for ALi m5602 based webcams 3 3 * 4 - * Copyright (C) 2008 Erik Andren 4 + * Copyright (C) 2008 Erik Andrén 5 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 7 *
+238 -135
drivers/media/video/gspca/t613.c
··· 50 50 51 51 __u8 sensor; 52 52 #define SENSOR_TAS5130A 0 53 - #define SENSOR_OTHER 1 53 + #define SENSOR_OM6802 1 54 54 }; 55 55 56 56 /* V4L2 controls supported by the driver */ ··· 188 188 .minimum = 0, 189 189 .maximum = 1, 190 190 .step = 1, 191 - .default_value = 1, 191 + .default_value = 0, 192 192 }, 193 193 .set = sd_setwhitebalance, 194 194 .get = sd_getwhitebalance ··· 259 259 .sizeimage = 640 * 480 * 3 / 8 + 590, 260 260 .colorspace = V4L2_COLORSPACE_JPEG, 261 261 .priv = 0}, 262 + }; 263 + 264 + /* sensor specific data */ 265 + struct additional_sensor_data { 266 + const __u8 data1[20]; 267 + const __u8 data2[18]; 268 + const __u8 data3[18]; 269 + const __u8 data4[4]; 270 + const __u8 data5[6]; 271 + const __u8 stream[4]; 272 + }; 273 + 274 + const static struct additional_sensor_data sensor_data[] = { 275 + { /* TAS5130A */ 276 + .data1 = 277 + {0xd0, 0xbb, 0xd1, 0x28, 0xd2, 0x10, 0xd3, 0x10, 278 + 0xd4, 0xbb, 0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27, 279 + 0xd8, 0xc8, 0xd9, 0xfc}, 280 + .data2 = 281 + {0xe0, 0x60, 0xe1, 0xa8, 0xe2, 0xe0, 0xe3, 0x60, 282 + 0xe4, 0xa8, 0xe5, 0xe0, 0xe6, 0x60, 0xe7, 0xa8, 283 + 0xe8, 0xe0}, 284 + .data3 = 285 + {0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, 286 + 0xcb, 0xa8, 0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8, 287 + 0xcf, 0xe0}, 288 + .data4 = /* Freq (50/60Hz). Splitted for test purpose */ 289 + {0x66, 0x00, 0xa8, 0xe8}, 290 + .data5 = 291 + {0x0c, 0x03, 0xab, 0x10, 0x81, 0x20}, 292 + .stream = 293 + {0x0b, 0x04, 0x0a, 0x40}, 294 + }, 295 + { /* OM6802 */ 296 + .data1 = 297 + {0xd0, 0xc2, 0xd1, 0x28, 0xd2, 0x0f, 0xd3, 0x22, 298 + 0xd4, 0xcd, 0xd5, 0x27, 0xd6, 0x2c, 0xd7, 0x06, 299 + 0xd8, 0xb3, 0xd9, 0xfc}, 300 + .data2 = 301 + {0xe0, 0x80, 0xe1, 0xff, 0xe2, 0xff, 0xe3, 0x80, 302 + 0xe4, 0xff, 0xe5, 0xff, 0xe6, 0x80, 0xe7, 0xff, 303 + 0xe8, 0xff}, 304 + .data3 = 305 + {0xc7, 0x80, 0xc8, 0xff, 0xc9, 0xff, 0xca, 0x80, 306 + 0xcb, 0xff, 0xcc, 0xff, 0xcd, 0x80, 0xce, 0xff, 307 + 0xcf, 0xff}, 308 + .data4 = /*Freq (50/60Hz). Splitted for test purpose */ 309 + {0x66, 0xca, 0xa8, 0xf0 }, 310 + .data5 = /* this could be removed later */ 311 + {0x0c, 0x03, 0xab, 0x13, 0x81, 0x23}, 312 + .stream = 313 + {0x0b, 0x04, 0x0a, 0x78}, 314 + } 262 315 }; 263 316 264 317 #define MAX_EFFECTS 7 ··· 418 365 {}, 419 366 }; 420 367 368 + static __u8 sensor_reset[] = {0x61, 0x68, 0x62, 0xff, 0x60, 0x07}; 369 + 421 370 /* read 1 byte */ 422 371 static int reg_r(struct gspca_dev *gspca_dev, 423 372 __u16 index) ··· 440 385 usb_control_msg(gspca_dev->dev, 441 386 usb_sndctrlpipe(gspca_dev->dev, 0), 442 387 0, 443 - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 388 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 444 389 0, index, 445 390 NULL, 0, 500); 446 391 } 447 392 448 - static void i2c_w(struct gspca_dev *gspca_dev, 393 + static void reg_w_buf(struct gspca_dev *gspca_dev, 449 394 const __u8 *buffer, __u16 len) 450 395 { 451 396 if (len <= USB_BUF_SZ) { ··· 453 398 usb_control_msg(gspca_dev->dev, 454 399 usb_sndctrlpipe(gspca_dev->dev, 0), 455 400 0, 456 - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 401 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 457 402 0x01, 0, 458 403 gspca_dev->usb_buf, len, 500); 459 404 } else { ··· 464 409 usb_control_msg(gspca_dev->dev, 465 410 usb_sndctrlpipe(gspca_dev->dev, 0), 466 411 0, 467 - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 412 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 468 413 0x01, 0, 469 414 tmpbuf, len, 500); 470 415 kfree(tmpbuf); 471 416 } 472 417 } 473 418 474 - static void other_sensor_init(struct gspca_dev *gspca_dev) 419 + /* Reported as OM6802*/ 420 + static void om6802_sensor_init(struct gspca_dev *gspca_dev) 475 421 { 476 422 int i; 477 423 const __u8 *p; ··· 492 436 0x90, 0x24, 493 437 0x91, 0xb2, 494 438 0x82, 0x32, 495 - 0xfd, 0x00, 496 - 0xfd, 0x01, 497 439 0xfd, 0x41, 498 440 0x00 /* table end */ 499 441 }; 442 + 443 + reg_w_buf(gspca_dev, sensor_reset, sizeof sensor_reset); 444 + msleep(5); 445 + i = 4; 446 + while (--i < 0) { 447 + byte = reg_r(gspca_dev, 0x0060); 448 + if (!(byte & 0x01)) 449 + break; 450 + msleep(100); 451 + } 452 + byte = reg_r(gspca_dev, 0x0063); 453 + if (byte != 0x17) { 454 + err("Bad sensor reset %02x", byte); 455 + /* continue? */ 456 + } 500 457 501 458 p = sensor_init; 502 459 while (*p != 0) { ··· 517 448 val[3] = *p++; 518 449 if (*p == 0) 519 450 reg_w(gspca_dev, 0x3c80); 520 - i2c_w(gspca_dev, val, sizeof val); 451 + reg_w_buf(gspca_dev, val, sizeof val); 521 452 i = 4; 522 453 while (--i >= 0) { 523 454 msleep(15); ··· 526 457 break; 527 458 } 528 459 } 529 - reg_w(gspca_dev, 0x3c80); 460 + msleep(15); 461 + reg_w(gspca_dev, 0x3c80); 530 462 } 531 463 532 464 /* this function is called at probe time */ ··· 555 485 return 0; 556 486 } 557 487 488 + static void setbrightness(struct gspca_dev *gspca_dev) 489 + { 490 + struct sd *sd = (struct sd *) gspca_dev; 491 + unsigned int brightness; 492 + __u8 set6[4] = { 0x8f, 0x24, 0xc3, 0x00 }; 493 + 494 + brightness = sd->brightness; 495 + if (brightness < 7) { 496 + set6[1] = 0x26; 497 + set6[3] = 0x70 - brightness * 0x10; 498 + } else { 499 + set6[3] = 0x00 + ((brightness - 7) * 0x10); 500 + } 501 + 502 + reg_w_buf(gspca_dev, set6, sizeof set6); 503 + } 504 + 505 + static void setcontrast(struct gspca_dev *gspca_dev) 506 + { 507 + struct sd *sd = (struct sd *) gspca_dev; 508 + unsigned int contrast = sd->contrast; 509 + __u16 reg_to_write; 510 + 511 + if (contrast < 7) 512 + reg_to_write = 0x8ea9 - contrast * 0x200; 513 + else 514 + reg_to_write = 0x00a9 + (contrast - 7) * 0x200; 515 + 516 + reg_w(gspca_dev, reg_to_write); 517 + } 518 + 519 + static void setcolors(struct gspca_dev *gspca_dev) 520 + { 521 + struct sd *sd = (struct sd *) gspca_dev; 522 + __u16 reg_to_write; 523 + 524 + reg_to_write = 0x80bb + sd->colors * 0x100; /* was 0xc0 */ 525 + reg_w(gspca_dev, reg_to_write); 526 + } 527 + 558 528 static void setgamma(struct gspca_dev *gspca_dev) 559 529 { 560 530 struct sd *sd = (struct sd *) gspca_dev; 561 531 562 532 PDEBUG(D_CONF, "Gamma: %d", sd->gamma); 563 - i2c_w(gspca_dev, gamma_table[sd->gamma], sizeof gamma_table[0]); 533 + reg_w_buf(gspca_dev, gamma_table[sd->gamma], sizeof gamma_table[0]); 534 + } 535 + 536 + static void setwhitebalance(struct gspca_dev *gspca_dev) 537 + { 538 + struct sd *sd = (struct sd *) gspca_dev; 539 + 540 + __u8 white_balance[8] = 541 + {0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38}; 542 + 543 + if (sd->whitebalance) 544 + white_balance[7] = 0x3c; 545 + 546 + reg_w_buf(gspca_dev, white_balance, sizeof white_balance); 547 + } 548 + 549 + static void setsharpness(struct gspca_dev *gspca_dev) 550 + { 551 + struct sd *sd = (struct sd *) gspca_dev; 552 + __u16 reg_to_write; 553 + 554 + reg_to_write = 0x0aa6 + 0x1000 * sd->sharpness; 555 + 556 + reg_w(gspca_dev, reg_to_write); 564 557 } 565 558 566 559 /* this function is called at probe and resume time */ ··· 644 511 {0x08, 0x03, 0x09, 0x03, 0x12, 0x04}; 645 512 static const __u8 n2[] = 646 513 {0x08, 0x00}; 647 - static const __u8 nset[] = 648 - { 0x61, 0x68, 0x62, 0xff, 0x60, 0x07 }; 649 514 static const __u8 n3[] = 650 515 {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04}; 651 516 static const __u8 n4[] = ··· 656 525 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68, 657 526 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40, 658 527 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46}; 659 - static const __u8 nset4[] = { 660 - 0xe0, 0x60, 0xe1, 0xa8, 0xe2, 0xe0, 0xe3, 0x60, 0xe4, 0xa8, 661 - 0xe5, 0xe0, 0xe6, 0x60, 0xe7, 0xa8, 662 - 0xe8, 0xe0 663 - }; 664 - /* ojo puede ser 0xe6 en vez de 0xe9 */ 665 - static const __u8 nset2[] = { 666 - 0xd0, 0xbb, 0xd1, 0x28, 0xd2, 0x10, 0xd3, 0x10, 0xd4, 0xbb, 667 - 0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27, 668 - 0xd8, 0xc8, 0xd9, 0xfc 669 - }; 670 - static const __u8 missing[] = 671 - { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 }; 672 - static const __u8 nset3[] = { 673 - 0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, 0xcb, 0xa8, 674 - 0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8, 675 - 0xcf, 0xe0 676 - }; 677 - static const __u8 nset5[] = 678 - { 0x8f, 0x24, 0xc3, 0x00 }; /* bright */ 679 - static const __u8 nset7[4] = 680 - { 0x66, 0xca, 0xa8, 0xf8 }; /* 50/60 Hz */ 681 528 static const __u8 nset9[4] = 682 529 { 0x0b, 0x04, 0x0a, 0x78 }; 683 530 static const __u8 nset8[6] = 684 531 { 0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00 }; 685 - static const __u8 nset10[6] = 686 - { 0x0c, 0x03, 0xab, 0x10, 0x81, 0x20 }; 687 532 688 533 byte = reg_r(gspca_dev, 0x06); 689 534 test_byte = reg_r(gspca_dev, 0x07); 690 535 if (byte == 0x08 && test_byte == 0x07) { 691 - PDEBUG(D_CONF, "other sensor"); 692 - sd->sensor = SENSOR_OTHER; 536 + PDEBUG(D_CONF, "sensor om6802"); 537 + sd->sensor = SENSOR_OM6802; 538 + } else if (byte == 0x08 && test_byte == 0x01) { 539 + PDEBUG(D_CONF, "sensor tas5130a"); 540 + sd->sensor = SENSOR_TAS5130A; 693 541 } else { 694 - PDEBUG(D_CONF, "sensor %02x %02x", byte, test_byte); 542 + PDEBUG(D_CONF, "unknown sensor %02x %02x", byte, test_byte); 695 543 sd->sensor = SENSOR_TAS5130A; 696 544 } 697 545 698 - i2c_w(gspca_dev, n1, sizeof n1); 546 + reg_w_buf(gspca_dev, n1, sizeof n1); 699 547 test_byte = 0; 700 548 i = 5; 701 549 while (--i >= 0) { 702 - i2c_w(gspca_dev, nset, sizeof nset); 703 - msleep(5); 550 + reg_w_buf(gspca_dev, sensor_reset, sizeof sensor_reset); 704 551 test_byte = reg_r(gspca_dev, 0x0063); 705 552 msleep(100); 706 553 if (test_byte == 0x17) ··· 689 580 /* return -EIO; */ 690 581 /*fixme: test - continue */ 691 582 } 692 - i2c_w(gspca_dev, n2, sizeof n2); 583 + reg_w_buf(gspca_dev, n2, sizeof n2); 693 584 694 585 i = 0; 695 586 while (read_indexs[i] != 0x00) { ··· 699 590 i++; 700 591 } 701 592 702 - i2c_w(gspca_dev, n3, sizeof n3); 703 - i2c_w(gspca_dev, n4, sizeof n4); 593 + reg_w_buf(gspca_dev, n3, sizeof n3); 594 + reg_w_buf(gspca_dev, n4, sizeof n4); 704 595 reg_r(gspca_dev, 0x0080); 705 596 reg_w(gspca_dev, 0x2c80); 706 - i2c_w(gspca_dev, nset2, sizeof nset2); 707 - i2c_w(gspca_dev, nset3, sizeof nset3); 708 - i2c_w(gspca_dev, nset4, sizeof nset4); 597 + 598 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].data1, 599 + sizeof sensor_data[sd->sensor].data1); 600 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].data3, 601 + sizeof sensor_data[sd->sensor].data3); 602 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].data2, 603 + sizeof sensor_data[sd->sensor].data2); 604 + 709 605 reg_w(gspca_dev, 0x3880); 710 606 reg_w(gspca_dev, 0x3880); 711 607 reg_w(gspca_dev, 0x338e); 712 - i2c_w(gspca_dev, nset5, sizeof nset5); 713 - reg_w(gspca_dev, 0x00a9); 608 + 609 + setbrightness(gspca_dev); 610 + setcontrast(gspca_dev); 714 611 setgamma(gspca_dev); 715 - reg_w(gspca_dev, 0x86bb); 716 - reg_w(gspca_dev, 0x4aa6); 612 + setcolors(gspca_dev); 613 + setsharpness(gspca_dev); 614 + setwhitebalance(gspca_dev); 717 615 718 - i2c_w(gspca_dev, missing, sizeof missing); 719 - 720 - reg_w(gspca_dev, 0x2087); 616 + reg_w(gspca_dev, 0x2087); /* tied to white balance? */ 721 617 reg_w(gspca_dev, 0x2088); 722 618 reg_w(gspca_dev, 0x2089); 723 619 724 - i2c_w(gspca_dev, nset7, sizeof nset7); 725 - i2c_w(gspca_dev, nset10, sizeof nset10); 726 - i2c_w(gspca_dev, nset8, sizeof nset8); 727 - i2c_w(gspca_dev, nset9, sizeof nset9); 620 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].data4, 621 + sizeof sensor_data[sd->sensor].data4); 622 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].data5, 623 + sizeof sensor_data[sd->sensor].data5); 624 + reg_w_buf(gspca_dev, nset8, sizeof nset8); 625 + reg_w_buf(gspca_dev, nset9, sizeof nset9); 728 626 729 627 reg_w(gspca_dev, 0x2880); 730 - i2c_w(gspca_dev, nset2, sizeof nset2); 731 - i2c_w(gspca_dev, nset3, sizeof nset3); 732 - i2c_w(gspca_dev, nset4, sizeof nset4); 628 + 629 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].data1, 630 + sizeof sensor_data[sd->sensor].data1); 631 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].data3, 632 + sizeof sensor_data[sd->sensor].data3); 633 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].data2, 634 + sizeof sensor_data[sd->sensor].data2); 733 635 734 636 return 0; 735 - } 736 - 737 - static void setbrightness(struct gspca_dev *gspca_dev) 738 - { 739 - struct sd *sd = (struct sd *) gspca_dev; 740 - unsigned int brightness; 741 - __u8 set6[4] = { 0x8f, 0x26, 0xc3, 0x00 }; 742 - 743 - brightness = sd->brightness; 744 - if (brightness < 7) { 745 - set6[3] = 0x70 - brightness * 0x10; 746 - } else { 747 - set6[1] = 0x24; 748 - set6[3] = 0x00 + ((brightness - 7) * 0x10); 749 - } 750 - 751 - i2c_w(gspca_dev, set6, sizeof set6); 752 637 } 753 638 754 639 static void setflip(struct gspca_dev *gspca_dev) ··· 754 651 if (sd->mirror) 755 652 flipcmd[3] = 0x01; 756 653 757 - i2c_w(gspca_dev, flipcmd, sizeof flipcmd); 654 + reg_w_buf(gspca_dev, flipcmd, sizeof flipcmd); 758 655 } 759 656 760 657 static void seteffect(struct gspca_dev *gspca_dev) 761 658 { 762 659 struct sd *sd = (struct sd *) gspca_dev; 763 660 764 - i2c_w(gspca_dev, effects_table[sd->effect], sizeof effects_table[0]); 661 + reg_w_buf(gspca_dev, effects_table[sd->effect], 662 + sizeof effects_table[0]); 765 663 if (sd->effect == 1 || sd->effect == 5) { 766 664 PDEBUG(D_CONF, 767 665 "This effect have been disabled for webcam \"safety\""); ··· 775 671 reg_w(gspca_dev, 0xfaa6); 776 672 } 777 673 778 - static void setwhitebalance(struct gspca_dev *gspca_dev) 779 - { 780 - struct sd *sd = (struct sd *) gspca_dev; 781 - 782 - __u8 white_balance[8] = 783 - { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 }; 784 - 785 - if (sd->whitebalance == 1) 786 - white_balance[7] = 0x3c; 787 - 788 - i2c_w(gspca_dev, white_balance, sizeof white_balance); 789 - } 790 - 791 674 static void setlightfreq(struct gspca_dev *gspca_dev) 792 675 { 793 676 struct sd *sd = (struct sd *) gspca_dev; ··· 783 692 if (sd->freq == 2) /* 60hz */ 784 693 freq[1] = 0x00; 785 694 786 - i2c_w(gspca_dev, freq, sizeof freq); 695 + reg_w_buf(gspca_dev, freq, sizeof freq); 787 696 } 788 697 789 - static void setcontrast(struct gspca_dev *gspca_dev) 698 + /* Is this really needed? 699 + * i added some module parameters for test with some users */ 700 + static void poll_sensor(struct gspca_dev *gspca_dev) 790 701 { 791 702 struct sd *sd = (struct sd *) gspca_dev; 792 - unsigned int contrast = sd->contrast; 793 - __u16 reg_to_write; 703 + static const __u8 poll1[] = 704 + {0x67, 0x05, 0x68, 0x81, 0x69, 0x80, 0x6a, 0x82, 705 + 0x6b, 0x68, 0x6c, 0x69, 0x72, 0xd9, 0x73, 0x34, 706 + 0x74, 0x32, 0x75, 0x92, 0x76, 0x00, 0x09, 0x01, 707 + 0x60, 0x14}; 708 + static const __u8 poll2[] = 709 + {0x67, 0x02, 0x68, 0x71, 0x69, 0x72, 0x72, 0xa9, 710 + 0x73, 0x02, 0x73, 0x02, 0x60, 0x14}; 711 + static const __u8 poll3[] = 712 + {0x87, 0x3f, 0x88, 0x20, 0x89, 0x2d}; 713 + static const __u8 poll4[] = 714 + {0xa6, 0x0a, 0xea, 0xcf, 0xbe, 0x26, 0xb1, 0x5f, 715 + 0xa1, 0xb1, 0xda, 0x6b, 0xdb, 0x98, 0xdf, 0x0c, 716 + 0xc2, 0x80, 0xc3, 0x10}; 794 717 795 - if (contrast < 7) 796 - reg_to_write = 0x8ea9 - (0x200 * contrast); 797 - else 798 - reg_to_write = (0x00a9 + ((contrast - 7) * 0x200)); 799 - 800 - reg_w(gspca_dev, reg_to_write); 801 - } 802 - 803 - static void setcolors(struct gspca_dev *gspca_dev) 804 - { 805 - struct sd *sd = (struct sd *) gspca_dev; 806 - __u16 reg_to_write; 807 - 808 - reg_to_write = 0xc0bb + sd->colors * 0x100; 809 - reg_w(gspca_dev, reg_to_write); 810 - } 811 - 812 - static void setsharpness(struct gspca_dev *gspca_dev) 813 - { 814 - struct sd *sd = (struct sd *) gspca_dev; 815 - __u16 reg_to_write; 816 - 817 - reg_to_write = 0x0aa6 + 0x1000 * sd->sharpness; 818 - 819 - reg_w(gspca_dev, reg_to_write); 718 + if (sd->sensor != SENSOR_TAS5130A) { 719 + PDEBUG(D_STREAM, "[Sensor requires polling]"); 720 + reg_w_buf(gspca_dev, poll1, sizeof poll1); 721 + reg_w_buf(gspca_dev, poll2, sizeof poll2); 722 + reg_w_buf(gspca_dev, poll3, sizeof poll3); 723 + reg_w_buf(gspca_dev, poll4, sizeof poll4); 724 + } 820 725 } 821 726 822 727 static int sd_start(struct gspca_dev *gspca_dev) 823 728 { 824 729 struct sd *sd = (struct sd *) gspca_dev; 825 730 int i, mode; 826 - static const __u8 t1[] = { 0x66, 0x00, 0xa8, 0xe8 }; 827 731 __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 }; 828 732 static const __u8 t3[] = 829 733 { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06, 830 734 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 }; 831 - static const __u8 t4[] = { 0x0b, 0x04, 0x0a, 0x40 }; 832 735 833 736 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv; 834 737 switch (mode) { ··· 845 760 if (sd->sensor == SENSOR_TAS5130A) { 846 761 i = 0; 847 762 while (tas5130a_sensor_init[i][0] != 0) { 848 - i2c_w(gspca_dev, tas5130a_sensor_init[i], 763 + reg_w_buf(gspca_dev, tas5130a_sensor_init[i], 849 764 sizeof tas5130a_sensor_init[0]); 850 765 i++; 851 766 } 852 767 reg_w(gspca_dev, 0x3c80); 853 768 /* just in case and to keep sync with logs (for mine) */ 854 - i2c_w(gspca_dev, tas5130a_sensor_init[3], 769 + reg_w_buf(gspca_dev, tas5130a_sensor_init[3], 855 770 sizeof tas5130a_sensor_init[0]); 856 771 reg_w(gspca_dev, 0x3c80); 857 772 } else { 858 - other_sensor_init(gspca_dev); 773 + om6802_sensor_init(gspca_dev); 859 774 } 860 - /* just in case and to keep sync with logs (for mine) */ 861 - i2c_w(gspca_dev, t1, sizeof t1); 862 - i2c_w(gspca_dev, t2, sizeof t2); 775 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].data4, 776 + sizeof sensor_data[sd->sensor].data4); 863 777 reg_r(gspca_dev, 0x0012); 864 - i2c_w(gspca_dev, t3, sizeof t3); 778 + reg_w_buf(gspca_dev, t2, sizeof t2); 779 + reg_w_buf(gspca_dev, t3, sizeof t3); 865 780 reg_w(gspca_dev, 0x0013); 866 - i2c_w(gspca_dev, t4, sizeof t4); 781 + msleep(15); 782 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream, 783 + sizeof sensor_data[sd->sensor].stream); 784 + poll_sensor(gspca_dev); 785 + 867 786 /* restart on each start, just in case, sometimes regs goes wrong 868 787 * when using controls from app */ 869 788 setbrightness(gspca_dev); 870 789 setcontrast(gspca_dev); 871 790 setcolors(gspca_dev); 872 791 return 0; 792 + } 793 + 794 + static void sd_stopN(struct gspca_dev *gspca_dev) 795 + { 796 + struct sd *sd = (struct sd *) gspca_dev; 797 + 798 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream, 799 + sizeof sensor_data[sd->sensor].stream); 800 + msleep(20); 801 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream, 802 + sizeof sensor_data[sd->sensor].stream); 803 + msleep(20); 804 + reg_w(gspca_dev, 0x0309); 873 805 } 874 806 875 807 static void sd_pkt_scan(struct gspca_dev *gspca_dev, ··· 1138 1036 .config = sd_config, 1139 1037 .init = sd_init, 1140 1038 .start = sd_start, 1039 + .stopN = sd_stopN, 1141 1040 .pkt_scan = sd_pkt_scan, 1142 1041 .querymenu = sd_querymenu, 1143 1042 };
+8 -7
drivers/media/video/ivtv/ivtv-fileops.c
··· 600 600 since we may get here before the stream has been fully set-up */ 601 601 if (mode == OUT_YUV && s->q_full.length == 0 && itv->dma_data_req_size) { 602 602 while (count >= itv->dma_data_req_size) { 603 - if (!ivtv_yuv_udma_stream_frame (itv, (void __user *)user_buf)) { 604 - bytes_written += itv->dma_data_req_size; 605 - user_buf += itv->dma_data_req_size; 606 - count -= itv->dma_data_req_size; 607 - } else { 608 - break; 609 - } 603 + rc = ivtv_yuv_udma_stream_frame(itv, (void __user *)user_buf); 604 + 605 + if (rc < 0) 606 + return rc; 607 + 608 + bytes_written += itv->dma_data_req_size; 609 + user_buf += itv->dma_data_req_size; 610 + count -= itv->dma_data_req_size; 610 611 } 611 612 if (count == 0) { 612 613 IVTV_DEBUG_HI_FILE("Wrote %d bytes to %s (%d)\n", bytes_written, s->name, s->q_full.bytesused);
+16 -2
drivers/media/video/ivtv/ivtv-ioctl.c
··· 509 509 static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt) 510 510 { 511 511 struct ivtv_open_id *id = fh; 512 - struct ivtv *itv = id->itv; 513 512 s32 w = fmt->fmt.pix.width; 514 513 s32 h = fmt->fmt.pix.height; 515 514 int field = fmt->fmt.pix.field; ··· 516 517 517 518 w = min(w, 720); 518 519 w = max(w, 2); 519 - h = min(h, itv->is_out_50hz ? 576 : 480); 520 + /* Why can the height be 576 even when the output is NTSC? 521 + 522 + Internally the buffers of the PVR350 are always set to 720x576. The 523 + decoded video frame will always be placed in the top left corner of 524 + this buffer. For any video which is not 720x576, the buffer will 525 + then be cropped to remove the unused right and lower areas, with 526 + the remaining image being scaled by the hardware to fit the display 527 + area. The video can be scaled both up and down, so a 720x480 video 528 + can be displayed full-screen on PAL and a 720x576 video can be 529 + displayed without cropping on NTSC. 530 + 531 + Note that the scaling only occurs on the video stream, the osd 532 + resolution is locked to the broadcast standard and not scaled. 533 + 534 + Thanks to Ian Armstrong for this explanation. */ 535 + h = min(h, 576); 520 536 h = max(h, 2); 521 537 if (id->type == IVTV_DEC_STREAM_TYPE_YUV) 522 538 fmt->fmt.pix.field = field;
+212 -264
drivers/media/video/ks0127.c
··· 33 33 * V1.1 Gerard v.d. Horst Added some debugoutput, reset the video-standard 34 34 */ 35 35 36 - #ifndef __KERNEL__ 37 - #define __KERNEL__ 38 - #endif 39 - 40 36 #include <linux/init.h> 41 37 #include <linux/module.h> 42 38 #include <linux/delay.h> 43 39 #include <linux/errno.h> 44 40 #include <linux/kernel.h> 45 - #include <linux/slab.h> 46 - #include <linux/proc_fs.h> 47 - #include "ks0127.h" 48 - 49 41 #include <linux/i2c.h> 50 42 #include <linux/video_decoder.h> 43 + #include <media/v4l2-common.h> 44 + #include <media/v4l2-i2c-drv-legacy.h> 45 + #include "ks0127.h" 51 46 52 - #define dprintk if (debug) printk 53 - 54 - /* i2c identification */ 55 - #define I2C_KS0127_ADDON 0xD8 56 - #define I2C_KS0127_ONBOARD 0xDA 47 + MODULE_DESCRIPTION("KS0127 video decoder driver"); 48 + MODULE_AUTHOR("Ryan Drake"); 49 + MODULE_LICENSE("GPL"); 57 50 58 51 #define KS_TYPE_UNKNOWN 0 59 52 #define KS_TYPE_0122S 1 ··· 197 204 }; 198 205 199 206 struct ks0127 { 200 - struct i2c_client *client; 201 - unsigned char addr; 202 207 int format_width; 203 208 int format_height; 204 209 int cap_width; ··· 211 220 212 221 module_param(debug, int, 0); 213 222 MODULE_PARM_DESC(debug, "Debug output"); 214 - MODULE_LICENSE("GPL"); 215 223 216 224 static u8 reg_defaults[64]; 217 225 218 - 219 - 220 226 static void init_reg_defaults(void) 221 227 { 228 + static int initialized; 222 229 u8 *table = reg_defaults; 230 + 231 + if (initialized) 232 + return; 233 + initialized = 1; 223 234 224 235 table[KS_CMDA] = 0x2c; /* VSE=0, CCIR 601, autodetect standard */ 225 236 table[KS_CMDB] = 0x12; /* VALIGN=0, AGC control and input */ ··· 301 308 * An explanation from kayork@mail.utexas.edu: 302 309 * 303 310 * During I2C reads, the KS0127 only samples for a stop condition 304 - * during the place where the acknoledge bit should be. Any standard 311 + * during the place where the acknowledge bit should be. Any standard 305 312 * I2C implementation (correctly) throws in another clock transition 306 313 * at the 9th bit, and the KS0127 will not recognize the stop condition 307 314 * and will continue to clock out data. 308 315 * 309 316 * So we have to do the read ourself. Big deal. 310 - workaround in i2c-algo-bit 317 + * workaround in i2c-algo-bit 311 318 */ 312 319 313 320 314 - static u8 ks0127_read(struct ks0127 *ks, u8 reg) 321 + static u8 ks0127_read(struct i2c_client *c, u8 reg) 315 322 { 316 - struct i2c_client *c = ks->client; 317 323 char val = 0; 318 324 struct i2c_msg msgs[] = { 319 - {c->addr, 0, sizeof(reg), &reg}, 320 - {c->addr, I2C_M_RD | I2C_M_NO_RD_ACK, sizeof(val), &val}}; 325 + { c->addr, 0, sizeof(reg), &reg }, 326 + { c->addr, I2C_M_RD | I2C_M_NO_RD_ACK, sizeof(val), &val } 327 + }; 321 328 int ret; 322 329 323 330 ret = i2c_transfer(c->adapter, msgs, ARRAY_SIZE(msgs)); 324 331 if (ret != ARRAY_SIZE(msgs)) 325 - dprintk("ks0127_write error\n"); 332 + v4l_dbg(1, debug, c, "read error\n"); 326 333 327 334 return val; 328 335 } 329 336 330 337 331 - static void ks0127_write(struct ks0127 *ks, u8 reg, u8 val) 338 + static void ks0127_write(struct i2c_client *c, u8 reg, u8 val) 332 339 { 333 - char msg[] = {reg, val}; 340 + struct ks0127 *ks = i2c_get_clientdata(c); 341 + char msg[] = { reg, val }; 334 342 335 - if (i2c_master_send(ks->client, msg, sizeof(msg)) != sizeof(msg)) 336 - dprintk("ks0127_write error\n"); 343 + if (i2c_master_send(c, msg, sizeof(msg)) != sizeof(msg)) 344 + v4l_dbg(1, debug, c, "write error\n"); 337 345 338 346 ks->regs[reg] = val; 339 347 } 340 348 341 349 342 350 /* generic bit-twiddling */ 343 - static void ks0127_and_or(struct ks0127 *ks, u8 reg, u8 and_v, u8 or_v) 351 + static void ks0127_and_or(struct i2c_client *client, u8 reg, u8 and_v, u8 or_v) 344 352 { 353 + struct ks0127 *ks = i2c_get_clientdata(client); 354 + 345 355 u8 val = ks->regs[reg]; 346 356 val = (val & and_v) | or_v; 347 - ks0127_write(ks, reg, val); 357 + ks0127_write(client, reg, val); 348 358 } 349 359 350 360 ··· 355 359 /**************************************************************************** 356 360 * ks0127 private api 357 361 ****************************************************************************/ 358 - static void ks0127_reset(struct ks0127* ks) 362 + static void ks0127_reset(struct i2c_client *c) 359 363 { 360 - int i; 364 + struct ks0127 *ks = i2c_get_clientdata(c); 361 365 u8 *table = reg_defaults; 366 + int i; 362 367 363 368 ks->ks_type = KS_TYPE_UNKNOWN; 364 369 365 - dprintk("ks0127: reset\n"); 370 + v4l_dbg(1, debug, c, "reset\n"); 366 371 msleep(1); 367 372 368 373 /* initialize all registers to known values */ 369 374 /* (except STAT, 0x21, 0x22, TEST and 0x38,0x39) */ 370 375 371 - for(i = 1; i < 33; i++) 372 - ks0127_write(ks, i, table[i]); 376 + for (i = 1; i < 33; i++) 377 + ks0127_write(c, i, table[i]); 373 378 374 - for(i = 35; i < 40; i++) 375 - ks0127_write(ks, i, table[i]); 379 + for (i = 35; i < 40; i++) 380 + ks0127_write(c, i, table[i]); 376 381 377 - for(i = 41; i < 56; i++) 378 - ks0127_write(ks, i, table[i]); 382 + for (i = 41; i < 56; i++) 383 + ks0127_write(c, i, table[i]); 379 384 380 - for(i = 58; i < 64; i++) 381 - ks0127_write(ks, i, table[i]); 385 + for (i = 58; i < 64; i++) 386 + ks0127_write(c, i, table[i]); 382 387 383 388 384 - if ((ks0127_read(ks, KS_STAT) & 0x80) == 0) { 389 + if ((ks0127_read(c, KS_STAT) & 0x80) == 0) { 385 390 ks->ks_type = KS_TYPE_0122S; 386 - dprintk("ks0127: ks0122s Found\n"); 391 + v4l_dbg(1, debug, c, "ks0122s found\n"); 387 392 return; 388 393 } 389 394 390 - switch(ks0127_read(ks, KS_CMDE) & 0x0f) { 391 - 395 + switch (ks0127_read(c, KS_CMDE) & 0x0f) { 392 396 case 0: 393 397 ks->ks_type = KS_TYPE_0127; 394 - dprintk("ks0127: ks0127 found\n"); 398 + v4l_dbg(1, debug, c, "ks0127 found\n"); 395 399 break; 396 400 397 401 case 9: 398 402 ks->ks_type = KS_TYPE_0127B; 399 - dprintk("ks0127: ks0127B Revision A found\n"); 403 + v4l_dbg(1, debug, c, "ks0127B Revision A found\n"); 400 404 break; 401 405 402 406 default: 403 - dprintk("ks0127: unknown revision\n"); 407 + v4l_dbg(1, debug, c, "unknown revision\n"); 404 408 break; 405 409 } 406 410 } 407 411 408 - static int ks0127_command(struct i2c_client *client, 409 - unsigned int cmd, void *arg) 412 + static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) 410 413 { 411 - struct ks0127 *ks = i2c_get_clientdata(client); 412 - 413 - int *iarg = (int*)arg; 414 - 414 + struct ks0127 *ks = i2c_get_clientdata(c); 415 + int *iarg = (int *)arg; 415 416 int status; 416 417 417 418 if (!ks) 418 419 return -ENODEV; 419 420 420 421 switch (cmd) { 421 - 422 422 case DECODER_INIT: 423 - dprintk("ks0127: command DECODER_INIT\n"); 424 - ks0127_reset(ks); 423 + v4l_dbg(1, debug, c, "DECODER_INIT\n"); 424 + ks0127_reset(c); 425 425 break; 426 426 427 427 case DECODER_SET_INPUT: ··· 428 436 case KS_INPUT_COMPOSITE_4: 429 437 case KS_INPUT_COMPOSITE_5: 430 438 case KS_INPUT_COMPOSITE_6: 431 - dprintk("ks0127: command DECODER_SET_INPUT %d: " 432 - "Composite\n", *iarg); 439 + v4l_dbg(1, debug, c, 440 + "DECODER_SET_INPUT %d: Composite\n", *iarg); 433 441 /* autodetect 50/60 Hz */ 434 - ks0127_and_or(ks, KS_CMDA, 0xfc, 0x00); 442 + ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); 435 443 /* VSE=0 */ 436 - ks0127_and_or(ks, KS_CMDA, ~0x40, 0x00); 444 + ks0127_and_or(c, KS_CMDA, ~0x40, 0x00); 437 445 /* set input line */ 438 - ks0127_and_or(ks, KS_CMDB, 0xb0, *iarg); 446 + ks0127_and_or(c, KS_CMDB, 0xb0, *iarg); 439 447 /* non-freerunning mode */ 440 - ks0127_and_or(ks, KS_CMDC, 0x70, 0x0a); 448 + ks0127_and_or(c, KS_CMDC, 0x70, 0x0a); 441 449 /* analog input */ 442 - ks0127_and_or(ks, KS_CMDD, 0x03, 0x00); 450 + ks0127_and_or(c, KS_CMDD, 0x03, 0x00); 443 451 /* enable chroma demodulation */ 444 - ks0127_and_or(ks, KS_CTRACK, 0xcf, 0x00); 452 + ks0127_and_or(c, KS_CTRACK, 0xcf, 0x00); 445 453 /* chroma trap, HYBWR=1 */ 446 - ks0127_and_or(ks, KS_LUMA, 0x00, 454 + ks0127_and_or(c, KS_LUMA, 0x00, 447 455 (reg_defaults[KS_LUMA])|0x0c); 448 456 /* scaler fullbw, luma comb off */ 449 - ks0127_and_or(ks, KS_VERTIA, 0x08, 0x81); 457 + ks0127_and_or(c, KS_VERTIA, 0x08, 0x81); 450 458 /* manual chroma comb .25 .5 .25 */ 451 - ks0127_and_or(ks, KS_VERTIC, 0x0f, 0x90); 459 + ks0127_and_or(c, KS_VERTIC, 0x0f, 0x90); 452 460 453 461 /* chroma path delay */ 454 - ks0127_and_or(ks, KS_CHROMB, 0x0f, 0x90); 462 + ks0127_and_or(c, KS_CHROMB, 0x0f, 0x90); 455 463 456 - ks0127_write(ks, KS_UGAIN, reg_defaults[KS_UGAIN]); 457 - ks0127_write(ks, KS_VGAIN, reg_defaults[KS_VGAIN]); 458 - ks0127_write(ks, KS_UVOFFH, reg_defaults[KS_UVOFFH]); 459 - ks0127_write(ks, KS_UVOFFL, reg_defaults[KS_UVOFFL]); 464 + ks0127_write(c, KS_UGAIN, reg_defaults[KS_UGAIN]); 465 + ks0127_write(c, KS_VGAIN, reg_defaults[KS_VGAIN]); 466 + ks0127_write(c, KS_UVOFFH, reg_defaults[KS_UVOFFH]); 467 + ks0127_write(c, KS_UVOFFL, reg_defaults[KS_UVOFFL]); 460 468 break; 461 469 462 470 case KS_INPUT_SVIDEO_1: 463 471 case KS_INPUT_SVIDEO_2: 464 472 case KS_INPUT_SVIDEO_3: 465 - dprintk("ks0127: command DECODER_SET_INPUT %d: " 466 - "S-Video\n", *iarg); 473 + v4l_dbg(1, debug, c, 474 + "DECODER_SET_INPUT %d: S-Video\n", *iarg); 467 475 /* autodetect 50/60 Hz */ 468 - ks0127_and_or(ks, KS_CMDA, 0xfc, 0x00); 476 + ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); 469 477 /* VSE=0 */ 470 - ks0127_and_or(ks, KS_CMDA, ~0x40, 0x00); 478 + ks0127_and_or(c, KS_CMDA, ~0x40, 0x00); 471 479 /* set input line */ 472 - ks0127_and_or(ks, KS_CMDB, 0xb0, *iarg); 480 + ks0127_and_or(c, KS_CMDB, 0xb0, *iarg); 473 481 /* non-freerunning mode */ 474 - ks0127_and_or(ks, KS_CMDC, 0x70, 0x0a); 482 + ks0127_and_or(c, KS_CMDC, 0x70, 0x0a); 475 483 /* analog input */ 476 - ks0127_and_or(ks, KS_CMDD, 0x03, 0x00); 484 + ks0127_and_or(c, KS_CMDD, 0x03, 0x00); 477 485 /* enable chroma demodulation */ 478 - ks0127_and_or(ks, KS_CTRACK, 0xcf, 0x00); 479 - ks0127_and_or(ks, KS_LUMA, 0x00, 486 + ks0127_and_or(c, KS_CTRACK, 0xcf, 0x00); 487 + ks0127_and_or(c, KS_LUMA, 0x00, 480 488 reg_defaults[KS_LUMA]); 481 489 /* disable luma comb */ 482 - ks0127_and_or(ks, KS_VERTIA, 0x08, 490 + ks0127_and_or(c, KS_VERTIA, 0x08, 483 491 (reg_defaults[KS_VERTIA]&0xf0)|0x01); 484 - ks0127_and_or(ks, KS_VERTIC, 0x0f, 492 + ks0127_and_or(c, KS_VERTIC, 0x0f, 485 493 reg_defaults[KS_VERTIC]&0xf0); 486 494 487 - ks0127_and_or(ks, KS_CHROMB, 0x0f, 495 + ks0127_and_or(c, KS_CHROMB, 0x0f, 488 496 reg_defaults[KS_CHROMB]&0xf0); 489 497 490 - ks0127_write(ks, KS_UGAIN, reg_defaults[KS_UGAIN]); 491 - ks0127_write(ks, KS_VGAIN, reg_defaults[KS_VGAIN]); 492 - ks0127_write(ks, KS_UVOFFH, reg_defaults[KS_UVOFFH]); 493 - ks0127_write(ks, KS_UVOFFL, reg_defaults[KS_UVOFFL]); 498 + ks0127_write(c, KS_UGAIN, reg_defaults[KS_UGAIN]); 499 + ks0127_write(c, KS_VGAIN, reg_defaults[KS_VGAIN]); 500 + ks0127_write(c, KS_UVOFFH, reg_defaults[KS_UVOFFH]); 501 + ks0127_write(c, KS_UVOFFL, reg_defaults[KS_UVOFFL]); 494 502 break; 495 503 496 504 case KS_INPUT_YUV656: 497 - dprintk("ks0127: command DECODER_SET_INPUT 15: " 498 - "YUV656\n"); 505 + v4l_dbg(1, debug, c, 506 + "DECODER_SET_INPUT 15: YUV656\n"); 499 507 if (ks->norm == VIDEO_MODE_NTSC || 500 508 ks->norm == KS_STD_PAL_M) 501 509 /* force 60 Hz */ 502 - ks0127_and_or(ks, KS_CMDA, 0xfc, 0x03); 510 + ks0127_and_or(c, KS_CMDA, 0xfc, 0x03); 503 511 else 504 512 /* force 50 Hz */ 505 - ks0127_and_or(ks, KS_CMDA, 0xfc, 0x02); 513 + ks0127_and_or(c, KS_CMDA, 0xfc, 0x02); 506 514 507 - ks0127_and_or(ks, KS_CMDA, 0xff, 0x40); /* VSE=1 */ 515 + ks0127_and_or(c, KS_CMDA, 0xff, 0x40); /* VSE=1 */ 508 516 /* set input line and VALIGN */ 509 - ks0127_and_or(ks, KS_CMDB, 0xb0, (*iarg | 0x40)); 517 + ks0127_and_or(c, KS_CMDB, 0xb0, (*iarg | 0x40)); 510 518 /* freerunning mode, */ 511 519 /* TSTGEN = 1 TSTGFR=11 TSTGPH=0 TSTGPK=0 VMEM=1*/ 512 - ks0127_and_or(ks, KS_CMDC, 0x70, 0x87); 520 + ks0127_and_or(c, KS_CMDC, 0x70, 0x87); 513 521 /* digital input, SYNDIR = 0 INPSL=01 CLKDIR=0 EAV=0 */ 514 - ks0127_and_or(ks, KS_CMDD, 0x03, 0x08); 522 + ks0127_and_or(c, KS_CMDD, 0x03, 0x08); 515 523 /* disable chroma demodulation */ 516 - ks0127_and_or(ks, KS_CTRACK, 0xcf, 0x30); 524 + ks0127_and_or(c, KS_CTRACK, 0xcf, 0x30); 517 525 /* HYPK =01 CTRAP = 0 HYBWR=0 PED=1 RGBH=1 UNIT=1 */ 518 - ks0127_and_or(ks, KS_LUMA, 0x00, 0x71); 519 - ks0127_and_or(ks, KS_VERTIC, 0x0f, 526 + ks0127_and_or(c, KS_LUMA, 0x00, 0x71); 527 + ks0127_and_or(c, KS_VERTIC, 0x0f, 520 528 reg_defaults[KS_VERTIC]&0xf0); 521 529 522 530 /* scaler fullbw, luma comb off */ 523 - ks0127_and_or(ks, KS_VERTIA, 0x08, 0x81); 531 + ks0127_and_or(c, KS_VERTIA, 0x08, 0x81); 524 532 525 - ks0127_and_or(ks, KS_CHROMB, 0x0f, 533 + ks0127_and_or(c, KS_CHROMB, 0x0f, 526 534 reg_defaults[KS_CHROMB]&0xf0); 527 535 528 - ks0127_and_or(ks, KS_CON, 0x00, 0x00); 529 - ks0127_and_or(ks, KS_BRT, 0x00, 32); /* spec: 34 */ 536 + ks0127_and_or(c, KS_CON, 0x00, 0x00); 537 + ks0127_and_or(c, KS_BRT, 0x00, 32); /* spec: 34 */ 530 538 /* spec: 229 (e5) */ 531 - ks0127_and_or(ks, KS_SAT, 0x00, 0xe8); 532 - ks0127_and_or(ks, KS_HUE, 0x00, 0); 539 + ks0127_and_or(c, KS_SAT, 0x00, 0xe8); 540 + ks0127_and_or(c, KS_HUE, 0x00, 0); 533 541 534 - ks0127_and_or(ks, KS_UGAIN, 0x00, 238); 535 - ks0127_and_or(ks, KS_VGAIN, 0x00, 0x00); 542 + ks0127_and_or(c, KS_UGAIN, 0x00, 238); 543 + ks0127_and_or(c, KS_VGAIN, 0x00, 0x00); 536 544 537 545 /*UOFF:0x30, VOFF:0x30, TSTCGN=1 */ 538 - ks0127_and_or(ks, KS_UVOFFH, 0x00, 0x4f); 539 - ks0127_and_or(ks, KS_UVOFFL, 0x00, 0x00); 546 + ks0127_and_or(c, KS_UVOFFH, 0x00, 0x4f); 547 + ks0127_and_or(c, KS_UVOFFL, 0x00, 0x00); 540 548 break; 541 549 542 550 default: 543 - dprintk("ks0127: command DECODER_SET_INPUT: " 544 - "Unknown input %d\n", *iarg); 551 + v4l_dbg(1, debug, c, 552 + "DECODER_SET_INPUT: Unknown input %d\n", *iarg); 545 553 break; 546 554 } 547 555 548 556 /* hack: CDMLPF sometimes spontaneously switches on; */ 549 557 /* force back off */ 550 - ks0127_write(ks, KS_DEMOD, reg_defaults[KS_DEMOD]); 558 + ks0127_write(c, KS_DEMOD, reg_defaults[KS_DEMOD]); 551 559 break; 552 560 553 561 case DECODER_SET_OUTPUT: 554 562 switch(*iarg) { 555 563 case KS_OUTPUT_YUV656E: 556 - dprintk("ks0127: command DECODER_SET_OUTPUT: " 557 - "OUTPUT_YUV656E (Missing)\n"); 564 + v4l_dbg(1, debug, c, 565 + "DECODER_SET_OUTPUT: OUTPUT_YUV656E (Missing)\n"); 558 566 return -EINVAL; 559 - break; 560 567 561 568 case KS_OUTPUT_EXV: 562 - dprintk("ks0127: command DECODER_SET_OUTPUT: " 563 - "OUTPUT_EXV\n"); 564 - ks0127_and_or(ks, KS_OFMTA, 0xf0, 0x09); 569 + v4l_dbg(1, debug, c, 570 + "DECODER_SET_OUTPUT: OUTPUT_EXV\n"); 571 + ks0127_and_or(c, KS_OFMTA, 0xf0, 0x09); 565 572 break; 566 573 } 567 574 break; 568 575 569 - case DECODER_SET_NORM: //sam This block mixes old and new norm names... 576 + case DECODER_SET_NORM: /* sam This block mixes old and new norm names... */ 570 577 /* Set to automatic SECAM/Fsc mode */ 571 - ks0127_and_or(ks, KS_DEMOD, 0xf0, 0x00); 578 + ks0127_and_or(c, KS_DEMOD, 0xf0, 0x00); 572 579 573 580 ks->norm = *iarg; 574 - switch(*iarg) 575 - { 581 + switch (*iarg) { 576 582 /* this is untested !! */ 577 583 /* It just detects PAL_N/NTSC_M (no special frequencies) */ 578 584 /* And you have to set the standard a second time afterwards */ 579 585 case VIDEO_MODE_AUTO: 580 - dprintk("ks0127: command DECODER_SET_NORM: AUTO\n"); 586 + v4l_dbg(1, debug, c, 587 + "DECODER_SET_NORM: AUTO\n"); 581 588 582 589 /* The chip determines the format */ 583 590 /* based on the current field rate */ 584 - ks0127_and_or(ks, KS_CMDA, 0xfc, 0x00); 585 - ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x20); 591 + ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); 592 + ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); 586 593 /* This is wrong for PAL ! As I said, */ 587 594 /* you need to set the standard once again !! */ 588 595 ks->format_height = 240; ··· 589 598 break; 590 599 591 600 case VIDEO_MODE_NTSC: 592 - dprintk("ks0127: command DECODER_SET_NORM: NTSC_M\n"); 593 - ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x20); 601 + v4l_dbg(1, debug, c, 602 + "DECODER_SET_NORM: NTSC_M\n"); 603 + ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); 594 604 ks->format_height = 240; 595 605 ks->format_width = 704; 596 606 break; 597 607 598 608 case KS_STD_NTSC_N: 599 - dprintk("ks0127: command KS0127_SET_STANDARD: " 600 - "NTSC_N (fixme)\n"); 601 - ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x40); 609 + v4l_dbg(1, debug, c, 610 + "KS0127_SET_NORM: NTSC_N (fixme)\n"); 611 + ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); 602 612 ks->format_height = 240; 603 613 ks->format_width = 704; 604 614 break; 605 615 606 616 case VIDEO_MODE_PAL: 607 - dprintk("ks0127: command DECODER_SET_NORM: PAL_N\n"); 608 - ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x20); 617 + v4l_dbg(1, debug, c, 618 + "DECODER_SET_NORM: PAL_N\n"); 619 + ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); 609 620 ks->format_height = 290; 610 621 ks->format_width = 704; 611 622 break; 612 623 613 624 case KS_STD_PAL_M: 614 - dprintk("ks0127: command KS0127_SET_STANDARD: " 615 - "PAL_M (fixme)\n"); 616 - ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x40); 625 + v4l_dbg(1, debug, c, 626 + "KS0127_SET_NORM: PAL_M (fixme)\n"); 627 + ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); 617 628 ks->format_height = 290; 618 629 ks->format_width = 704; 619 630 break; 620 631 621 632 case VIDEO_MODE_SECAM: 622 - dprintk("ks0127: command KS0127_SET_STANDARD: " 623 - "SECAM\n"); 633 + v4l_dbg(1, debug, c, 634 + "KS0127_SET_NORM: SECAM\n"); 624 635 ks->format_height = 290; 625 636 ks->format_width = 704; 626 637 627 638 /* set to secam autodetection */ 628 - ks0127_and_or(ks, KS_CHROMA, 0xdf, 0x20); 629 - ks0127_and_or(ks, KS_DEMOD, 0xf0, 0x00); 639 + ks0127_and_or(c, KS_CHROMA, 0xdf, 0x20); 640 + ks0127_and_or(c, KS_DEMOD, 0xf0, 0x00); 630 641 schedule_timeout_interruptible(HZ/10+1); 631 642 632 643 /* did it autodetect? */ 633 - if (ks0127_read(ks, KS_DEMOD) & 0x40) 644 + if (ks0127_read(c, KS_DEMOD) & 0x40) 634 645 break; 635 646 636 647 /* force to secam mode */ 637 - ks0127_and_or(ks, KS_DEMOD, 0xf0, 0x0f); 648 + ks0127_and_or(c, KS_DEMOD, 0xf0, 0x0f); 638 649 break; 639 650 640 651 default: 641 - dprintk("ks0127: command DECODER_SET_NORM: " 642 - "Unknown norm %d\n", *iarg); 652 + v4l_dbg(1, debug, c, 653 + "DECODER_SET_NORM: Unknown norm %d\n", *iarg); 643 654 break; 644 655 } 645 656 break; 646 657 647 658 case DECODER_SET_PICTURE: 648 - dprintk("ks0127: command DECODER_SET_PICTURE " 649 - "not yet supported (fixme)\n"); 659 + v4l_dbg(1, debug, c, 660 + "DECODER_SET_PICTURE: not yet supported\n"); 650 661 return -EINVAL; 651 662 652 - //sam todo: KS0127_SET_BRIGHTNESS: Merge into DECODER_SET_PICTURE 653 - //sam todo: KS0127_SET_CONTRAST: Merge into DECODER_SET_PICTURE 654 - //sam todo: KS0127_SET_HUE: Merge into DECODER_SET_PICTURE? 655 - //sam todo: KS0127_SET_SATURATION: Merge into DECODER_SET_PICTURE 656 - //sam todo: KS0127_SET_AGC_MODE: 657 - //sam todo: KS0127_SET_AGC: 658 - //sam todo: KS0127_SET_CHROMA_MODE: 659 - //sam todo: KS0127_SET_PIXCLK_MODE: 660 - //sam todo: KS0127_SET_GAMMA_MODE: 661 - //sam todo: KS0127_SET_UGAIN: 662 - //sam todo: KS0127_SET_VGAIN: 663 - //sam todo: KS0127_SET_INVALY: 664 - //sam todo: KS0127_SET_INVALU: 665 - //sam todo: KS0127_SET_INVALV: 666 - //sam todo: KS0127_SET_UNUSEY: 667 - //sam todo: KS0127_SET_UNUSEU: 668 - //sam todo: KS0127_SET_UNUSEV: 669 - //sam todo: KS0127_SET_VSALIGN_MODE: 663 + /* sam todo: KS0127_SET_BRIGHTNESS: Merge into DECODER_SET_PICTURE */ 664 + /* sam todo: KS0127_SET_CONTRAST: Merge into DECODER_SET_PICTURE */ 665 + /* sam todo: KS0127_SET_HUE: Merge into DECODER_SET_PICTURE? */ 666 + /* sam todo: KS0127_SET_SATURATION: Merge into DECODER_SET_PICTURE */ 667 + /* sam todo: KS0127_SET_AGC_MODE: */ 668 + /* sam todo: KS0127_SET_AGC: */ 669 + /* sam todo: KS0127_SET_CHROMA_MODE: */ 670 + /* sam todo: KS0127_SET_PIXCLK_MODE: */ 671 + /* sam todo: KS0127_SET_GAMMA_MODE: */ 672 + /* sam todo: KS0127_SET_UGAIN: */ 673 + /* sam todo: KS0127_SET_VGAIN: */ 674 + /* sam todo: KS0127_SET_INVALY: */ 675 + /* sam todo: KS0127_SET_INVALU: */ 676 + /* sam todo: KS0127_SET_INVALV: */ 677 + /* sam todo: KS0127_SET_UNUSEY: */ 678 + /* sam todo: KS0127_SET_UNUSEU: */ 679 + /* sam todo: KS0127_SET_UNUSEV: */ 680 + /* sam todo: KS0127_SET_VSALIGN_MODE: */ 670 681 671 682 case DECODER_ENABLE_OUTPUT: 672 683 { ··· 677 684 iarg = arg; 678 685 enable = (*iarg != 0); 679 686 if (enable) { 680 - dprintk("ks0127: command " 681 - "DECODER_ENABLE_OUTPUT on " 682 - "(%d)\n", enable); 687 + v4l_dbg(1, debug, c, 688 + "DECODER_ENABLE_OUTPUT on\n"); 683 689 /* All output pins on */ 684 - ks0127_and_or(ks, KS_OFMTA, 0xcf, 0x30); 690 + ks0127_and_or(c, KS_OFMTA, 0xcf, 0x30); 685 691 /* Obey the OEN pin */ 686 - ks0127_and_or(ks, KS_CDEM, 0x7f, 0x00); 692 + ks0127_and_or(c, KS_CDEM, 0x7f, 0x00); 687 693 } else { 688 - dprintk("ks0127: command " 689 - "DECODER_ENABLE_OUTPUT off " 690 - "(%d)\n", enable); 694 + v4l_dbg(1, debug, c, 695 + "DECODER_ENABLE_OUTPUT off\n"); 691 696 /* Video output pins off */ 692 - ks0127_and_or(ks, KS_OFMTA, 0xcf, 0x00); 697 + ks0127_and_or(c, KS_OFMTA, 0xcf, 0x00); 693 698 /* Ignore the OEN pin */ 694 - ks0127_and_or(ks, KS_CDEM, 0x7f, 0x80); 699 + ks0127_and_or(c, KS_CDEM, 0x7f, 0x80); 695 700 } 696 - } 697 701 break; 702 + } 698 703 699 - //sam todo: KS0127_SET_OUTPUT_MODE: 700 - //sam todo: KS0127_SET_WIDTH: 701 - //sam todo: KS0127_SET_HEIGHT: 702 - //sam todo: KS0127_SET_HSCALE: 704 + /* sam todo: KS0127_SET_OUTPUT_MODE: */ 705 + /* sam todo: KS0127_SET_WIDTH: */ 706 + /* sam todo: KS0127_SET_HEIGHT: */ 707 + /* sam todo: KS0127_SET_HSCALE: */ 703 708 704 709 case DECODER_GET_STATUS: 705 - dprintk("ks0127: command DECODER_GET_STATUS\n"); 710 + v4l_dbg(1, debug, c, "DECODER_GET_STATUS\n"); 706 711 *iarg = 0; 707 - status = ks0127_read(ks, KS_STAT); 712 + status = ks0127_read(c, KS_STAT); 708 713 if (!(status & 0x20)) /* NOVID not set */ 709 714 *iarg = (*iarg | DECODER_STATUS_GOOD); 710 715 if ((status & 0x01)) /* CLOCK set */ ··· 713 722 *iarg = (*iarg | DECODER_STATUS_NTSC); 714 723 break; 715 724 716 - //Catch any unknown command 725 + /* Catch any unknown command */ 717 726 default: 718 - dprintk("ks0127: command unknown: %04X\n", cmd); 727 + v4l_dbg(1, debug, c, "unknown: 0x%08x\n", cmd); 719 728 return -EINVAL; 720 729 } 721 730 return 0; 722 731 } 723 732 724 733 725 - 726 - 727 - static int ks0127_probe(struct i2c_adapter *adapter); 728 - static int ks0127_detach(struct i2c_client *client); 729 - static int ks0127_command(struct i2c_client *client, 730 - unsigned int cmd, void *arg); 731 - 732 - 733 - 734 734 /* Addresses to scan */ 735 - static unsigned short normal_i2c[] = {I2C_KS0127_ADDON>>1, 736 - I2C_KS0127_ONBOARD>>1, I2C_CLIENT_END}; 737 - static unsigned short probe[2] = {I2C_CLIENT_END, I2C_CLIENT_END}; 738 - static unsigned short ignore[2] = {I2C_CLIENT_END, I2C_CLIENT_END}; 739 - static struct i2c_client_address_data addr_data = { 740 - normal_i2c, 741 - probe, 742 - ignore, 735 + #define I2C_KS0127_ADDON 0xD8 736 + #define I2C_KS0127_ONBOARD 0xDA 737 + 738 + static unsigned short normal_i2c[] = { 739 + I2C_KS0127_ADDON >> 1, 740 + I2C_KS0127_ONBOARD >> 1, 741 + I2C_CLIENT_END 743 742 }; 744 743 745 - static struct i2c_driver i2c_driver_ks0127 = { 746 - .driver.name = "ks0127", 747 - .id = I2C_DRIVERID_KS0127, 748 - .attach_adapter = ks0127_probe, 749 - .detach_client = ks0127_detach, 750 - .command = ks0127_command 751 - }; 744 + I2C_CLIENT_INSMOD; 752 745 753 - static struct i2c_client ks0127_client_tmpl = 754 - { 755 - .name = "(ks0127 unset)", 756 - .addr = 0, 757 - .adapter = NULL, 758 - .driver = &i2c_driver_ks0127, 759 - }; 760 - 761 - static int ks0127_found_proc(struct i2c_adapter *adapter, int addr, int kind) 746 + static int ks0127_probe(struct i2c_client *c, const struct i2c_device_id *id) 762 747 { 763 748 struct ks0127 *ks; 764 - struct i2c_client *client; 765 749 766 - client = kzalloc(sizeof(*client), GFP_KERNEL); 767 - if (client == NULL) 768 - return -ENOMEM; 769 - memcpy(client, &ks0127_client_tmpl, sizeof(*client)); 750 + v4l_info(c, "%s chip found @ 0x%x (%s)\n", 751 + c->addr == (I2C_KS0127_ADDON >> 1) ? "addon" : "on-board", 752 + c->addr << 1, c->adapter->name); 770 753 771 754 ks = kzalloc(sizeof(*ks), GFP_KERNEL); 772 - if (ks == NULL) { 773 - kfree(client); 755 + if (ks == NULL) 774 756 return -ENOMEM; 775 - } 776 757 777 - i2c_set_clientdata(client, ks); 778 - client->adapter = adapter; 779 - client->addr = addr; 780 - sprintf(client->name, "ks0127-%02x", adapter->id); 758 + i2c_set_clientdata(c, ks); 781 759 782 - ks->client = client; 783 - ks->addr = addr; 784 760 ks->ks_type = KS_TYPE_UNKNOWN; 785 761 786 762 /* power up */ 787 - ks0127_write(ks, KS_CMDA, 0x2c); 763 + init_reg_defaults(); 764 + ks0127_write(c, KS_CMDA, 0x2c); 788 765 mdelay(10); 789 766 790 767 /* reset the device */ 791 - ks0127_reset(ks); 792 - printk(KERN_INFO "ks0127: attach: %s video decoder\n", 793 - ks->addr==(I2C_KS0127_ADDON>>1) ? "addon" : "on-board"); 794 - 795 - i2c_attach_client(client); 768 + ks0127_reset(c); 796 769 return 0; 797 770 } 798 771 799 - 800 - static int ks0127_probe(struct i2c_adapter *adapter) 772 + static int ks0127_remove(struct i2c_client *c) 801 773 { 802 - if (adapter->id == I2C_HW_B_ZR36067) 803 - return i2c_probe(adapter, &addr_data, ks0127_found_proc); 804 - return 0; 805 - } 774 + struct ks0127 *ks = i2c_get_clientdata(c); 806 775 807 - static int ks0127_detach(struct i2c_client *client) 808 - { 809 - struct ks0127 *ks = i2c_get_clientdata(client); 776 + ks0127_write(c, KS_OFMTA, 0x20); /* tristate */ 777 + ks0127_write(c, KS_CMDA, 0x2c | 0x80); /* power down */ 810 778 811 - ks0127_write(ks, KS_OFMTA, 0x20); /*tristate*/ 812 - ks0127_write(ks, KS_CMDA, 0x2c | 0x80); /* power down */ 813 - 814 - i2c_detach_client(client); 815 779 kfree(ks); 816 - kfree(client); 817 - 818 - dprintk("ks0127: detach\n"); 819 780 return 0; 820 781 } 821 782 822 - 823 - static int __devinit ks0127_init_module(void) 783 + static int ks0127_legacy_probe(struct i2c_adapter *adapter) 824 784 { 825 - init_reg_defaults(); 826 - return i2c_add_driver(&i2c_driver_ks0127); 785 + return adapter->id == I2C_HW_B_ZR36067; 827 786 } 828 787 829 - static void __devexit ks0127_cleanup_module(void) 830 - { 831 - i2c_del_driver(&i2c_driver_ks0127); 832 - } 788 + static const struct i2c_device_id ks0127_id[] = { 789 + { "ks0127", 0 }, 790 + { } 791 + }; 792 + MODULE_DEVICE_TABLE(i2c, ks0127_id); 833 793 834 - 835 - module_init(ks0127_init_module); 836 - module_exit(ks0127_cleanup_module); 794 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 795 + .name = "ks0127", 796 + .driverid = I2C_DRIVERID_KS0127, 797 + .command = ks0127_command, 798 + .probe = ks0127_probe, 799 + .remove = ks0127_remove, 800 + .legacy_probe = ks0127_legacy_probe, 801 + .id_table = ks0127_id, 802 + };
+65 -179
drivers/media/video/saa7110.c
··· 31 31 #include <linux/delay.h> 32 32 #include <linux/slab.h> 33 33 #include <linux/wait.h> 34 - #include <asm/io.h> 35 34 #include <asm/uaccess.h> 35 + #include <linux/i2c.h> 36 + #include <linux/videodev.h> 37 + #include <linux/video_decoder.h> 38 + #include <media/v4l2-common.h> 39 + #include <media/v4l2-i2c-drv-legacy.h> 36 40 37 41 MODULE_DESCRIPTION("Philips SAA7110 video decoder driver"); 38 42 MODULE_AUTHOR("Pauline Middelink"); 39 43 MODULE_LICENSE("GPL"); 40 44 41 - #include <linux/i2c.h> 42 - 43 - #define I2C_NAME(s) (s)->name 44 - 45 - #include <linux/videodev.h> 46 - #include <media/v4l2-common.h> 47 - #include <linux/video_decoder.h> 48 - 49 45 static int debug; 50 46 module_param(debug, int, 0); 51 47 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 52 48 53 - #define dprintk(num, format, args...) \ 54 - do { \ 55 - if (debug >= num) \ 56 - printk(format, ##args); \ 57 - } while (0) 58 - 59 49 #define SAA7110_MAX_INPUT 9 /* 6 CVBS, 3 SVHS */ 60 50 #define SAA7110_MAX_OUTPUT 0 /* its a decoder only */ 61 - 62 - #define I2C_SAA7110 0x9C /* or 0x9E */ 63 51 64 52 #define SAA7110_NR_REG 0x35 65 53 ··· 69 81 /* I2C support functions */ 70 82 /* ----------------------------------------------------------------------- */ 71 83 72 - static int 73 - saa7110_write (struct i2c_client *client, 74 - u8 reg, 75 - u8 value) 84 + static int saa7110_write(struct i2c_client *client, u8 reg, u8 value) 76 85 { 77 86 struct saa7110 *decoder = i2c_get_clientdata(client); 78 87 ··· 77 92 return i2c_smbus_write_byte_data(client, reg, value); 78 93 } 79 94 80 - static int 81 - saa7110_write_block (struct i2c_client *client, 82 - const u8 *data, 83 - unsigned int len) 95 + static int saa7110_write_block(struct i2c_client *client, const u8 *data, unsigned int len) 84 96 { 85 97 int ret = -1; 86 98 u8 reg = *data; /* first register to write to */ ··· 97 115 memcpy(decoder->reg + reg, data + 1, len - 1); 98 116 } else { 99 117 for (++data, --len; len; len--) { 100 - if ((ret = saa7110_write(client, reg++, 101 - *data++)) < 0) 118 + ret = saa7110_write(client, reg++, *data++); 119 + if (ret < 0) 102 120 break; 103 121 } 104 122 } ··· 106 124 return ret; 107 125 } 108 126 109 - static inline int 110 - saa7110_read (struct i2c_client *client) 127 + static inline int saa7110_read(struct i2c_client *client) 111 128 { 112 129 return i2c_smbus_read_byte(client); 113 130 } ··· 119 138 #define FRESP_06H_SVIDEO 0x83 //0xC0 120 139 121 140 122 - static int 123 - saa7110_selmux (struct i2c_client *client, 124 - int chan) 141 + static int saa7110_selmux(struct i2c_client *client, int chan) 125 142 { 126 143 static const unsigned char modes[9][8] = { 127 144 /* mode 0 */ ··· 176 197 /* 0x30 */ 0x44, 0x71, 0x02, 0x8C, 0x02 177 198 }; 178 199 179 - static int 180 - determine_norm (struct i2c_client *client) 200 + static int determine_norm(struct i2c_client *client) 181 201 { 182 202 DEFINE_WAIT(wait); 183 203 struct saa7110 *decoder = i2c_get_clientdata(client); ··· 190 212 finish_wait(&decoder->wq, &wait); 191 213 status = saa7110_read(client); 192 214 if (status & 0x40) { 193 - dprintk(1, KERN_INFO "%s: status=0x%02x (no signal)\n", 194 - I2C_NAME(client), status); 215 + v4l_dbg(1, debug, client, "status=0x%02x (no signal)\n", status); 195 216 return decoder->norm; // no change 196 217 } 197 218 if ((status & 3) == 0) { 198 219 saa7110_write(client, 0x06, 0x83); 199 220 if (status & 0x20) { 200 - dprintk(1, 201 - KERN_INFO 202 - "%s: status=0x%02x (NTSC/no color)\n", 203 - I2C_NAME(client), status); 221 + v4l_dbg(1, debug, client, "status=0x%02x (NTSC/no color)\n", status); 204 222 //saa7110_write(client,0x2E,0x81); 205 223 return VIDEO_MODE_NTSC; 206 224 } 207 - dprintk(1, KERN_INFO "%s: status=0x%02x (PAL/no color)\n", 208 - I2C_NAME(client), status); 225 + v4l_dbg(1, debug, client, "status=0x%02x (PAL/no color)\n", status); 209 226 //saa7110_write(client,0x2E,0x9A); 210 227 return VIDEO_MODE_PAL; 211 228 } 212 229 //saa7110_write(client,0x06,0x03); 213 230 if (status & 0x20) { /* 60Hz */ 214 - dprintk(1, KERN_INFO "%s: status=0x%02x (NTSC)\n", 215 - I2C_NAME(client), status); 231 + v4l_dbg(1, debug, client, "status=0x%02x (NTSC)\n", status); 216 232 saa7110_write(client, 0x0D, 0x86); 217 233 saa7110_write(client, 0x0F, 0x50); 218 234 saa7110_write(client, 0x11, 0x2C); ··· 226 254 227 255 status = saa7110_read(client); 228 256 if ((status & 0x03) == 0x01) { 229 - dprintk(1, KERN_INFO "%s: status=0x%02x (SECAM)\n", 230 - I2C_NAME(client), status); 257 + v4l_dbg(1, debug, client, "status=0x%02x (SECAM)\n", status); 231 258 saa7110_write(client, 0x0D, 0x87); 232 259 return VIDEO_MODE_SECAM; 233 260 } 234 - dprintk(1, KERN_INFO "%s: status=0x%02x (PAL)\n", I2C_NAME(client), 235 - status); 261 + v4l_dbg(1, debug, client, "status=0x%02x (PAL)\n", status); 236 262 return VIDEO_MODE_PAL; 237 263 } 238 264 ··· 256 286 VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO; 257 287 dc->inputs = SAA7110_MAX_INPUT; 258 288 dc->outputs = SAA7110_MAX_OUTPUT; 259 - } 260 289 break; 290 + } 261 291 262 292 case DECODER_GET_STATUS: 263 293 { ··· 265 295 int res = 0; 266 296 267 297 status = saa7110_read(client); 268 - dprintk(1, KERN_INFO "%s: status=0x%02x norm=%d\n", 269 - I2C_NAME(client), status, decoder->norm); 298 + v4l_dbg(1, debug, client, "status=0x%02x norm=%d\n", 299 + status, decoder->norm); 270 300 if (!(status & 0x40)) 271 301 res |= DECODER_STATUS_GOOD; 272 302 if (status & 0x03) ··· 284 314 break; 285 315 } 286 316 *(int *) arg = res; 287 - } 288 317 break; 318 + } 289 319 290 320 case DECODER_SET_NORM: 291 321 v = *(int *) arg; ··· 298 328 saa7110_write(client, 0x0F, 0x50); 299 329 saa7110_write(client, 0x11, 0x2C); 300 330 //saa7110_write(client, 0x2E, 0x81); 301 - dprintk(1, 302 - KERN_INFO "%s: switched to NTSC\n", 303 - I2C_NAME(client)); 331 + v4l_dbg(1, debug, client, "switched to NTSC\n"); 304 332 break; 305 333 case VIDEO_MODE_PAL: 306 334 saa7110_write(client, 0x0D, 0x86); 307 335 saa7110_write(client, 0x0F, 0x10); 308 336 saa7110_write(client, 0x11, 0x59); 309 337 //saa7110_write(client, 0x2E, 0x9A); 310 - dprintk(1, 311 - KERN_INFO "%s: switched to PAL\n", 312 - I2C_NAME(client)); 338 + v4l_dbg(1, debug, client, "switched to PAL\n"); 313 339 break; 314 340 case VIDEO_MODE_SECAM: 315 341 saa7110_write(client, 0x0D, 0x87); 316 342 saa7110_write(client, 0x0F, 0x10); 317 343 saa7110_write(client, 0x11, 0x59); 318 344 //saa7110_write(client, 0x2E, 0x9A); 319 - dprintk(1, 320 - KERN_INFO 321 - "%s: switched to SECAM\n", 322 - I2C_NAME(client)); 345 + v4l_dbg(1, debug, client, "switched to SECAM\n"); 323 346 break; 324 347 case VIDEO_MODE_AUTO: 325 - dprintk(1, 326 - KERN_INFO 327 - "%s: TV standard detection...\n", 328 - I2C_NAME(client)); 348 + v4l_dbg(1, debug, client, "switched to AUTO\n"); 329 349 decoder->norm = determine_norm(client); 330 350 *(int *) arg = decoder->norm; 331 351 break; ··· 328 368 case DECODER_SET_INPUT: 329 369 v = *(int *) arg; 330 370 if (v < 0 || v > SAA7110_MAX_INPUT) { 331 - dprintk(1, 332 - KERN_INFO "%s: input=%d not available\n", 333 - I2C_NAME(client), v); 371 + v4l_dbg(1, debug, client, "input=%d not available\n", v); 334 372 return -EINVAL; 335 373 } 336 374 if (decoder->input != v) { 337 375 saa7110_selmux(client, v); 338 - dprintk(1, KERN_INFO "%s: switched to input=%d\n", 339 - I2C_NAME(client), v); 376 + v4l_dbg(1, debug, client, "switched to input=%d\n", v); 340 377 } 341 378 break; 342 379 ··· 349 392 if (decoder->enable != v) { 350 393 decoder->enable = v; 351 394 saa7110_write(client, 0x0E, v ? 0x18 : 0x80); 352 - dprintk(1, KERN_INFO "%s: YUV %s\n", I2C_NAME(client), 353 - v ? "on" : "off"); 395 + v4l_dbg(1, debug, client, "YUV %s\n", v ? "on" : "off"); 354 396 } 355 397 break; 356 398 ··· 379 423 saa7110_write(client, 0x07, 380 424 (decoder->hue >> 8) - 128); 381 425 } 382 - } 383 426 break; 427 + } 384 428 385 429 case DECODER_DUMP: 430 + if (!debug) 431 + break; 386 432 for (v = 0; v < SAA7110_NR_REG; v += 16) { 387 433 int j; 388 - dprintk(1, KERN_DEBUG "%s: %02x:", I2C_NAME(client), 389 - v); 434 + v4l_dbg(1, debug, client, "%02x:", v); 390 435 for (j = 0; j < 16 && v + j < SAA7110_NR_REG; j++) 391 - dprintk(1, " %02x", decoder->reg[v + j]); 392 - dprintk(1, "\n"); 436 + printk(KERN_CONT " %02x", decoder->reg[v + j]); 437 + printk(KERN_CONT "\n"); 393 438 } 394 439 break; 395 440 396 441 default: 397 - dprintk(1, KERN_INFO "unknown saa7110_command??(%d)\n", 398 - cmd); 442 + v4l_dbg(1, debug, client, "unknown command %08x\n", cmd); 399 443 return -EINVAL; 400 444 } 401 445 return 0; ··· 407 451 * Generic i2c probe 408 452 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 409 453 */ 410 - static unsigned short normal_i2c[] = { 411 - I2C_SAA7110 >> 1, 412 - (I2C_SAA7110 >> 1) + 1, 413 - I2C_CLIENT_END 414 - }; 415 454 416 - static unsigned short ignore = I2C_CLIENT_END; 455 + static unsigned short normal_i2c[] = { 0x9c >> 1, 0x9e >> 1, I2C_CLIENT_END }; 417 456 418 - static struct i2c_client_address_data addr_data = { 419 - .normal_i2c = normal_i2c, 420 - .probe = &ignore, 421 - .ignore = &ignore, 422 - }; 457 + I2C_CLIENT_INSMOD; 423 458 424 - static struct i2c_driver i2c_driver_saa7110; 425 - 426 - static int 427 - saa7110_detect_client (struct i2c_adapter *adapter, 428 - int address, 429 - int kind) 459 + static int saa7110_probe(struct i2c_client *client, 460 + const struct i2c_device_id *id) 430 461 { 431 - struct i2c_client *client; 432 462 struct saa7110 *decoder; 433 463 int rv; 434 464 435 - dprintk(1, 436 - KERN_INFO 437 - "saa7110.c: detecting saa7110 client on address 0x%x\n", 438 - address << 1); 439 - 440 465 /* Check if the adapter supports the needed features */ 441 - if (!i2c_check_functionality 442 - (adapter, 443 - I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) 444 - return 0; 466 + if (!i2c_check_functionality(client->adapter, 467 + I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) 468 + return -ENODEV; 445 469 446 - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 447 - if (!client) 448 - return -ENOMEM; 449 - client->addr = address; 450 - client->adapter = adapter; 451 - client->driver = &i2c_driver_saa7110; 452 - strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client))); 470 + v4l_info(client, "chip found @ 0x%x (%s)\n", 471 + client->addr << 1, client->adapter->name); 453 472 454 473 decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); 455 - if (!decoder) { 456 - kfree(client); 474 + if (!decoder) 457 475 return -ENOMEM; 458 - } 459 476 decoder->norm = VIDEO_MODE_PAL; 460 477 decoder->input = 0; 461 478 decoder->enable = 1; ··· 439 510 init_waitqueue_head(&decoder->wq); 440 511 i2c_set_clientdata(client, decoder); 441 512 442 - rv = i2c_attach_client(client); 443 - if (rv) { 444 - kfree(client); 445 - kfree(decoder); 446 - return rv; 447 - } 448 - 449 513 rv = saa7110_write_block(client, initseq, sizeof(initseq)); 450 - if (rv < 0) 451 - dprintk(1, KERN_ERR "%s_attach: init status %d\n", 452 - I2C_NAME(client), rv); 453 - else { 514 + if (rv < 0) { 515 + v4l_dbg(1, debug, client, "init status %d\n", rv); 516 + } else { 454 517 int ver, status; 455 518 saa7110_write(client, 0x21, 0x10); 456 519 saa7110_write(client, 0x0e, 0x18); ··· 451 530 saa7110_write(client, 0x0D, 0x06); 452 531 //mdelay(150); 453 532 status = saa7110_read(client); 454 - dprintk(1, 455 - KERN_INFO 456 - "%s_attach: SAA7110A version %x at 0x%02x, status=0x%02x\n", 457 - I2C_NAME(client), ver, client->addr << 1, status); 533 + v4l_dbg(1, debug, client, "version %x, status=0x%02x\n", 534 + ver, status); 458 535 saa7110_write(client, 0x0D, 0x86); 459 536 saa7110_write(client, 0x0F, 0x10); 460 537 saa7110_write(client, 0x11, 0x59); ··· 466 547 return 0; 467 548 } 468 549 469 - static int 470 - saa7110_attach_adapter (struct i2c_adapter *adapter) 550 + static int saa7110_remove(struct i2c_client *client) 471 551 { 472 - dprintk(1, 473 - KERN_INFO 474 - "saa7110.c: starting probe for adapter %s (0x%x)\n", 475 - I2C_NAME(adapter), adapter->id); 476 - return i2c_probe(adapter, &addr_data, &saa7110_detect_client); 477 - } 478 - 479 - static int 480 - saa7110_detach_client (struct i2c_client *client) 481 - { 482 - struct saa7110 *decoder = i2c_get_clientdata(client); 483 - int err; 484 - 485 - err = i2c_detach_client(client); 486 - if (err) { 487 - return err; 488 - } 489 - 490 - kfree(decoder); 491 - kfree(client); 492 - 552 + kfree(i2c_get_clientdata(client)); 493 553 return 0; 494 554 } 495 555 496 556 /* ----------------------------------------------------------------------- */ 497 557 498 - static struct i2c_driver i2c_driver_saa7110 = { 499 - .driver = { 500 - .name = "saa7110", 501 - }, 502 - 503 - .id = I2C_DRIVERID_SAA7110, 504 - 505 - .attach_adapter = saa7110_attach_adapter, 506 - .detach_client = saa7110_detach_client, 507 - .command = saa7110_command, 558 + static const struct i2c_device_id saa7110_id[] = { 559 + { "saa7110", 0 }, 560 + { } 508 561 }; 562 + MODULE_DEVICE_TABLE(i2c, saa7110_id); 509 563 510 - static int __init 511 - saa7110_init (void) 512 - { 513 - return i2c_add_driver(&i2c_driver_saa7110); 514 - } 515 - 516 - static void __exit 517 - saa7110_exit (void) 518 - { 519 - i2c_del_driver(&i2c_driver_saa7110); 520 - } 521 - 522 - module_init(saa7110_init); 523 - module_exit(saa7110_exit); 564 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 565 + .name = "saa7110", 566 + .driverid = I2C_DRIVERID_SAA7110, 567 + .command = saa7110_command, 568 + .probe = saa7110_probe, 569 + .remove = saa7110_remove, 570 + .id_table = saa7110_id, 571 + };
+59 -167
drivers/media/video/saa7111.c
··· 28 28 */ 29 29 30 30 #include <linux/module.h> 31 - #include <linux/init.h> 32 - #include <linux/delay.h> 33 - #include <linux/errno.h> 34 - #include <linux/fs.h> 35 - #include <linux/kernel.h> 36 - #include <linux/major.h> 37 - #include <linux/slab.h> 38 - #include <linux/mm.h> 39 - #include <linux/signal.h> 40 31 #include <linux/types.h> 41 - #include <linux/i2c.h> 42 - #include <asm/io.h> 43 - #include <asm/pgtable.h> 44 - #include <asm/page.h> 32 + #include <linux/ioctl.h> 45 33 #include <asm/uaccess.h> 46 - 34 + #include <linux/i2c.h> 35 + #include <linux/i2c-id.h> 47 36 #include <linux/videodev.h> 48 37 #include <linux/video_decoder.h> 38 + #include <media/v4l2-common.h> 39 + #include <media/v4l2-i2c-drv-legacy.h> 49 40 50 41 MODULE_DESCRIPTION("Philips SAA7111 video decoder driver"); 51 42 MODULE_AUTHOR("Dave Perks"); 52 43 MODULE_LICENSE("GPL"); 53 44 54 - 55 - #define I2C_NAME(s) (s)->name 56 - 57 - 58 45 static int debug; 59 46 module_param(debug, int, 0644); 60 47 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 61 - 62 - #define dprintk(num, format, args...) \ 63 - do { \ 64 - if (debug >= num) \ 65 - printk(format, ##args); \ 66 - } while (0) 67 48 68 49 /* ----------------------------------------------------------------------- */ 69 50 ··· 58 77 int enable; 59 78 }; 60 79 61 - #define I2C_SAA7111 0x48 62 - 63 80 /* ----------------------------------------------------------------------- */ 64 81 65 - static inline int 66 - saa7111_write (struct i2c_client *client, 67 - u8 reg, 68 - u8 value) 82 + static inline int saa7111_write(struct i2c_client *client, u8 reg, u8 value) 69 83 { 70 84 struct saa7111 *decoder = i2c_get_clientdata(client); 71 85 ··· 68 92 return i2c_smbus_write_byte_data(client, reg, value); 69 93 } 70 94 71 - static inline void 72 - saa7111_write_if_changed(struct i2c_client *client, u8 reg, u8 value) 95 + static inline void saa7111_write_if_changed(struct i2c_client *client, u8 reg, u8 value) 73 96 { 74 97 struct saa7111 *decoder = i2c_get_clientdata(client); 75 98 ··· 78 103 } 79 104 } 80 105 81 - static int 82 - saa7111_write_block (struct i2c_client *client, 83 - const u8 *data, 84 - unsigned int len) 106 + static int saa7111_write_block(struct i2c_client *client, const u8 *data, unsigned int len) 85 107 { 86 108 int ret = -1; 87 109 u8 reg; ··· 99 127 decoder->reg[reg++] = data[1]; 100 128 len -= 2; 101 129 data += 2; 102 - } while (len >= 2 && data[0] == reg && 103 - block_len < 32); 104 - if ((ret = i2c_master_send(client, block_data, 105 - block_len)) < 0) 130 + } while (len >= 2 && data[0] == reg && block_len < 32); 131 + ret = i2c_master_send(client, block_data, block_len); 132 + if (ret < 0) 106 133 break; 107 134 } 108 135 } else { 109 136 /* do some slow I2C emulation kind of thing */ 110 137 while (len >= 2) { 111 138 reg = *data++; 112 - if ((ret = saa7111_write(client, reg, 113 - *data++)) < 0) 139 + ret = saa7111_write(client, reg, *data++); 140 + if (ret < 0) 114 141 break; 115 142 len -= 2; 116 143 } ··· 118 147 return ret; 119 148 } 120 149 121 - static int 122 - saa7111_init_decoder (struct i2c_client *client, 123 - struct video_decoder_init *init) 150 + static int saa7111_init_decoder(struct i2c_client *client, 151 + struct video_decoder_init *init) 124 152 { 125 153 return saa7111_write_block(client, init->data, init->len); 126 154 } 127 155 128 - static inline int 129 - saa7111_read (struct i2c_client *client, 130 - u8 reg) 156 + static inline int saa7111_read(struct i2c_client *client, u8 reg) 131 157 { 132 158 return i2c_smbus_read_byte_data(client, reg); 133 159 } ··· 171 203 0x17, 0x00, /* 17 - VBI */ 172 204 }; 173 205 174 - static int 175 - saa7111_command (struct i2c_client *client, 176 - unsigned int cmd, 177 - void *arg) 206 + static int saa7111_command(struct i2c_client *client, unsigned cmd, void *arg) 178 207 { 179 208 struct saa7111 *decoder = i2c_get_clientdata(client); 180 209 181 210 switch (cmd) { 182 - 183 211 case 0: 184 212 break; 185 213 case DECODER_INIT: 186 214 { 187 215 struct video_decoder_init *init = arg; 216 + struct video_decoder_init vdi; 217 + 188 218 if (NULL != init) 189 219 return saa7111_init_decoder(client, init); 190 - else { 191 - struct video_decoder_init vdi; 192 - vdi.data = saa7111_i2c_init; 193 - vdi.len = sizeof(saa7111_i2c_init); 194 - return saa7111_init_decoder(client, &vdi); 195 - } 220 + vdi.data = saa7111_i2c_init; 221 + vdi.len = sizeof(saa7111_i2c_init); 222 + return saa7111_init_decoder(client, &vdi); 196 223 } 197 224 198 225 case DECODER_DUMP: ··· 197 234 for (i = 0; i < SAA7111_NR_REG; i += 16) { 198 235 int j; 199 236 200 - printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i); 237 + v4l_info(client, "%03x", i); 201 238 for (j = 0; j < 16 && i + j < SAA7111_NR_REG; ++j) { 202 - printk(" %02x", 239 + printk(KERN_CONT " %02x", 203 240 saa7111_read(client, i + j)); 204 241 } 205 - printk("\n"); 242 + printk(KERN_CONT "\n"); 206 243 } 207 - } 208 244 break; 245 + } 209 246 210 247 case DECODER_GET_CAPABILITIES: 211 248 { ··· 218 255 VIDEO_DECODER_CCIR; 219 256 cap->inputs = 8; 220 257 cap->outputs = 1; 221 - } 222 258 break; 259 + } 223 260 224 261 case DECODER_GET_STATUS: 225 262 { ··· 228 265 int res; 229 266 230 267 status = saa7111_read(client, 0x1f); 231 - dprintk(1, KERN_DEBUG "%s status: 0x%02x\n", I2C_NAME(client), 232 - status); 268 + v4l_dbg(1, debug, client, "status: 0x%02x\n", status); 233 269 res = 0; 234 270 if ((status & (1 << 6)) == 0) { 235 271 res |= DECODER_STATUS_GOOD; ··· 256 294 res |= DECODER_STATUS_COLOR; 257 295 } 258 296 *iarg = res; 259 - } 260 297 break; 298 + } 261 299 262 300 case DECODER_SET_GPIO: 263 301 { ··· 324 362 325 363 } 326 364 decoder->norm = *iarg; 327 - } 328 365 break; 366 + } 329 367 330 368 case DECODER_SET_INPUT: 331 369 { ··· 349 387 3) ? 0x80 : 350 388 0)); 351 389 } 352 - } 353 390 break; 391 + } 354 392 355 393 case DECODER_SET_OUTPUT: 356 394 { ··· 360 398 if (*iarg != 0) { 361 399 return -EINVAL; 362 400 } 363 - } 364 401 break; 402 + } 365 403 366 404 case DECODER_ENABLE_OUTPUT: 367 405 { ··· 401 439 (decoder->reg[0x11] & 0xf3)); 402 440 } 403 441 } 404 - } 405 442 break; 443 + } 406 444 407 445 case DECODER_SET_PICTURE: 408 446 { ··· 416 454 saa7111_write(client, 0x0c, pic->colour >> 9); 417 455 /* We want -128 to 127 we get 0-65535 */ 418 456 saa7111_write(client, 0x0d, (pic->hue - 32768) >> 8); 419 - } 420 457 break; 458 + } 421 459 422 460 default: 423 461 return -EINVAL; ··· 428 466 429 467 /* ----------------------------------------------------------------------- */ 430 468 431 - /* 432 - * Generic i2c probe 433 - * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 434 - */ 435 - static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END }; 469 + static unsigned short normal_i2c[] = { 0x48 >> 1, I2C_CLIENT_END }; 436 470 437 - static unsigned short ignore = I2C_CLIENT_END; 471 + I2C_CLIENT_INSMOD; 438 472 439 - static struct i2c_client_address_data addr_data = { 440 - .normal_i2c = normal_i2c, 441 - .probe = &ignore, 442 - .ignore = &ignore, 443 - }; 444 - 445 - static struct i2c_driver i2c_driver_saa7111; 446 - 447 - static int 448 - saa7111_detect_client (struct i2c_adapter *adapter, 449 - int address, 450 - int kind) 473 + static int saa7111_probe(struct i2c_client *client, 474 + const struct i2c_device_id *id) 451 475 { 452 476 int i; 453 - struct i2c_client *client; 454 477 struct saa7111 *decoder; 455 478 struct video_decoder_init vdi; 456 479 457 - dprintk(1, 458 - KERN_INFO 459 - "saa7111.c: detecting saa7111 client on address 0x%x\n", 460 - address << 1); 461 - 462 480 /* Check if the adapter supports the needed features */ 463 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 464 - return 0; 481 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 482 + return -ENODEV; 465 483 466 - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 467 - if (!client) 468 - return -ENOMEM; 469 - client->addr = address; 470 - client->adapter = adapter; 471 - client->driver = &i2c_driver_saa7111; 472 - strlcpy(I2C_NAME(client), "saa7111", sizeof(I2C_NAME(client))); 484 + v4l_info(client, "chip found @ 0x%x (%s)\n", 485 + client->addr << 1, client->adapter->name); 473 486 474 487 decoder = kzalloc(sizeof(struct saa7111), GFP_KERNEL); 475 488 if (decoder == NULL) { ··· 456 519 decoder->enable = 1; 457 520 i2c_set_clientdata(client, decoder); 458 521 459 - i = i2c_attach_client(client); 460 - if (i) { 461 - kfree(client); 462 - kfree(decoder); 463 - return i; 464 - } 465 - 466 522 vdi.data = saa7111_i2c_init; 467 523 vdi.len = sizeof(saa7111_i2c_init); 468 524 i = saa7111_init_decoder(client, &vdi); 469 525 if (i < 0) { 470 - dprintk(1, KERN_ERR "%s_attach error: init status %d\n", 471 - I2C_NAME(client), i); 526 + v4l_dbg(1, debug, client, "init status %d\n", i); 472 527 } else { 473 - dprintk(1, 474 - KERN_INFO 475 - "%s_attach: chip version %x at address 0x%x\n", 476 - I2C_NAME(client), saa7111_read(client, 0x00) >> 4, 477 - client->addr << 1); 528 + v4l_dbg(1, debug, client, "revision %x\n", 529 + saa7111_read(client, 0x00) >> 4); 478 530 } 479 - 480 531 return 0; 481 532 } 482 533 483 - static int 484 - saa7111_attach_adapter (struct i2c_adapter *adapter) 534 + static int saa7111_remove(struct i2c_client *client) 485 535 { 486 - dprintk(1, 487 - KERN_INFO 488 - "saa7111.c: starting probe for adapter %s (0x%x)\n", 489 - I2C_NAME(adapter), adapter->id); 490 - return i2c_probe(adapter, &addr_data, &saa7111_detect_client); 491 - } 492 - 493 - static int 494 - saa7111_detach_client (struct i2c_client *client) 495 - { 496 - struct saa7111 *decoder = i2c_get_clientdata(client); 497 - int err; 498 - 499 - err = i2c_detach_client(client); 500 - if (err) { 501 - return err; 502 - } 503 - 504 - kfree(decoder); 505 - kfree(client); 506 - 536 + kfree(i2c_get_clientdata(client)); 507 537 return 0; 508 538 } 509 539 510 540 /* ----------------------------------------------------------------------- */ 511 541 512 - static struct i2c_driver i2c_driver_saa7111 = { 513 - .driver = { 514 - .name = "saa7111", 515 - }, 516 - 517 - .id = I2C_DRIVERID_SAA7111A, 518 - 519 - .attach_adapter = saa7111_attach_adapter, 520 - .detach_client = saa7111_detach_client, 521 - .command = saa7111_command, 542 + static const struct i2c_device_id saa7111_id[] = { 543 + { "saa7111_old", 0 }, /* "saa7111" maps to the saa7115 driver */ 544 + { } 522 545 }; 546 + MODULE_DEVICE_TABLE(i2c, saa7111_id); 523 547 524 - static int __init 525 - saa7111_init (void) 526 - { 527 - return i2c_add_driver(&i2c_driver_saa7111); 528 - } 529 - 530 - static void __exit 531 - saa7111_exit (void) 532 - { 533 - i2c_del_driver(&i2c_driver_saa7111); 534 - } 535 - 536 - module_init(saa7111_init); 537 - module_exit(saa7111_exit); 548 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 549 + .name = "saa7111", 550 + .driverid = I2C_DRIVERID_SAA7111A, 551 + .command = saa7111_command, 552 + .probe = saa7111_probe, 553 + .remove = saa7111_remove, 554 + .id_table = saa7111_id, 555 + };
+109 -257
drivers/media/video/saa7114.c
··· 29 29 */ 30 30 31 31 #include <linux/module.h> 32 - #include <linux/init.h> 33 - #include <linux/delay.h> 34 - #include <linux/errno.h> 35 - #include <linux/fs.h> 36 - #include <linux/kernel.h> 37 - #include <linux/major.h> 38 - #include <linux/slab.h> 39 - #include <linux/mm.h> 40 - #include <linux/signal.h> 41 32 #include <linux/types.h> 42 - #include <linux/i2c.h> 43 - #include <asm/io.h> 44 - #include <asm/pgtable.h> 45 - #include <asm/page.h> 33 + #include <linux/ioctl.h> 46 34 #include <asm/uaccess.h> 47 - 35 + #include <linux/i2c.h> 36 + #include <linux/i2c-id.h> 48 37 #include <linux/videodev.h> 49 38 #include <linux/video_decoder.h> 39 + #include <media/v4l2-common.h> 40 + #include <media/v4l2-i2c-drv-legacy.h> 50 41 51 42 MODULE_DESCRIPTION("Philips SAA7114H video decoder driver"); 52 43 MODULE_AUTHOR("Maxim Yevtyushkin"); 53 44 MODULE_LICENSE("GPL"); 54 45 55 - 56 - #define I2C_NAME(x) (x)->name 57 - 58 - 59 46 static int debug; 60 47 module_param(debug, int, 0); 61 48 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 62 - 63 - #define dprintk(num, format, args...) \ 64 - do { \ 65 - if (debug >= num) \ 66 - printk(format, ##args); \ 67 - } while (0) 68 49 69 50 /* ----------------------------------------------------------------------- */ 70 51 ··· 61 80 int sat; 62 81 int playback; 63 82 }; 64 - 65 - #define I2C_SAA7114 0x42 66 - #define I2C_SAA7114A 0x40 67 83 68 84 #define I2C_DELAY 10 69 85 ··· 107 129 108 130 /* ----------------------------------------------------------------------- */ 109 131 110 - static inline int 111 - saa7114_write (struct i2c_client *client, 112 - u8 reg, 113 - u8 value) 132 + static inline int saa7114_write(struct i2c_client *client, u8 reg, u8 value) 114 133 { 115 134 return i2c_smbus_write_byte_data(client, reg, value); 116 135 } 117 136 118 - static int 119 - saa7114_write_block (struct i2c_client *client, 120 - const u8 *data, 121 - unsigned int len) 137 + static int saa7114_write_block(struct i2c_client *client, const u8 *data, unsigned int len) 122 138 { 123 139 int ret = -1; 124 140 u8 reg; ··· 132 160 reg++; 133 161 len -= 2; 134 162 data += 2; 135 - } while (len >= 2 && data[0] == reg && 136 - block_len < 32); 137 - if ((ret = i2c_master_send(client, block_data, 138 - block_len)) < 0) 163 + } while (len >= 2 && data[0] == reg && block_len < 32); 164 + ret = i2c_master_send(client, block_data, block_len); 165 + if (ret < 0) 139 166 break; 140 167 } 141 168 } else { 142 169 /* do some slow I2C emulation kind of thing */ 143 170 while (len >= 2) { 144 171 reg = *data++; 145 - if ((ret = saa7114_write(client, reg, 146 - *data++)) < 0) 172 + ret = saa7114_write(client, reg, *data++); 173 + if (ret < 0) 147 174 break; 148 175 len -= 2; 149 176 } ··· 151 180 return ret; 152 181 } 153 182 154 - static inline int 155 - saa7114_read (struct i2c_client *client, 156 - u8 reg) 183 + static inline int saa7114_read(struct i2c_client *client, u8 reg) 157 184 { 158 185 return i2c_smbus_read_byte_data(client, reg); 159 186 } ··· 421 452 0xef, 0x00 422 453 }; 423 454 424 - static int 425 - saa7114_command (struct i2c_client *client, 426 - unsigned int cmd, 427 - void *arg) 455 + static int saa7114_command(struct i2c_client *client, unsigned cmd, void *arg) 428 456 { 429 457 struct saa7114 *decoder = i2c_get_clientdata(client); 430 458 431 459 switch (cmd) { 432 - 433 460 case 0: 434 461 //dprintk(1, KERN_INFO "%s: writing init\n", I2C_NAME(client)); 435 462 //saa7114_write_block(client, init, sizeof(init)); ··· 435 470 { 436 471 int i; 437 472 438 - dprintk(1, KERN_INFO "%s: decoder dump\n", I2C_NAME(client)); 473 + if (!debug) 474 + break; 475 + v4l_info(client, "decoder dump\n"); 439 476 440 477 for (i = 0; i < 32; i += 16) { 441 478 int j; 442 479 443 - printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i); 480 + v4l_info(client, "%03x", i); 444 481 for (j = 0; j < 16; ++j) { 445 - printk(" %02x", 482 + printk(KERN_CONT " %02x", 446 483 saa7114_read(client, i + j)); 447 484 } 448 - printk("\n"); 485 + printk(KERN_CONT "\n"); 449 486 } 450 - } 451 487 break; 488 + } 452 489 453 490 case DECODER_GET_CAPABILITIES: 454 491 { 455 492 struct video_decoder_capability *cap = arg; 456 493 457 - dprintk(1, KERN_DEBUG "%s: decoder get capabilities\n", 458 - I2C_NAME(client)); 494 + v4l_dbg(1, debug, client, "get capabilities\n"); 459 495 460 496 cap->flags = VIDEO_DECODER_PAL | 461 497 VIDEO_DECODER_NTSC | ··· 464 498 VIDEO_DECODER_CCIR; 465 499 cap->inputs = 8; 466 500 cap->outputs = 1; 467 - } 468 501 break; 502 + } 469 503 470 504 case DECODER_GET_STATUS: 471 505 { ··· 475 509 476 510 status = saa7114_read(client, 0x1f); 477 511 478 - dprintk(1, KERN_DEBUG "%s status: 0x%02x\n", I2C_NAME(client), 479 - status); 512 + v4l_dbg(1, debug, client, "status: 0x%02x\n", status); 480 513 res = 0; 481 514 if ((status & (1 << 6)) == 0) { 482 515 res |= DECODER_STATUS_GOOD; ··· 503 538 res |= DECODER_STATUS_COLOR; 504 539 } 505 540 *iarg = res; 506 - } 507 541 break; 542 + } 508 543 509 544 case DECODER_SET_NORM: 510 545 { ··· 512 547 513 548 short int hoff = 0, voff = 0, w = 0, h = 0; 514 549 515 - dprintk(1, KERN_DEBUG "%s: decoder set norm ", 516 - I2C_NAME(client)); 517 - switch (*iarg) { 550 + v4l_dbg(1, debug, client, "set norm\n"); 518 551 552 + switch (*iarg) { 519 553 case VIDEO_MODE_NTSC: 520 - dprintk(1, "NTSC\n"); 554 + v4l_dbg(1, debug, client, "NTSC\n"); 521 555 decoder->reg[REG_ADDR(0x06)] = 522 556 SAA_7114_NTSC_HSYNC_START; 523 557 decoder->reg[REG_ADDR(0x07)] = ··· 535 571 break; 536 572 537 573 case VIDEO_MODE_PAL: 538 - dprintk(1, "PAL\n"); 574 + v4l_dbg(1, debug, client, "PAL\n"); 539 575 decoder->reg[REG_ADDR(0x06)] = 540 576 SAA_7114_PAL_HSYNC_START; 541 577 decoder->reg[REG_ADDR(0x07)] = ··· 554 590 break; 555 591 556 592 default: 557 - dprintk(1, " Unknown video mode!!!\n"); 593 + v4l_dbg(1, debug, client, "Unknown video mode\n"); 558 594 return -EINVAL; 559 - 560 595 } 561 596 562 597 ··· 607 644 saa7114_write(client, 0x80, 0x36); // i-port and scaler back end clock selection 608 645 609 646 decoder->norm = *iarg; 610 - } 611 647 break; 648 + } 612 649 613 650 case DECODER_SET_INPUT: 614 651 { 615 652 int *iarg = arg; 616 653 617 - dprintk(1, KERN_DEBUG "%s: decoder set input (%d)\n", 618 - I2C_NAME(client), *iarg); 654 + v4l_dbg(1, debug, client, "set input (%d)\n", *iarg); 619 655 if (*iarg < 0 || *iarg > 7) { 620 656 return -EINVAL; 621 657 } 622 658 623 659 if (decoder->input != *iarg) { 624 - dprintk(1, KERN_DEBUG "%s: now setting %s input\n", 625 - I2C_NAME(client), 660 + v4l_dbg(1, debug, client, "now setting %s input\n", 626 661 *iarg >= 6 ? "S-Video" : "Composite"); 627 662 decoder->input = *iarg; 628 663 ··· 651 690 saa7114_write(client, 0x0e, 652 691 decoder->reg[REG_ADDR(0x0e)]); 653 692 } 654 - } 655 693 break; 694 + } 656 695 657 696 case DECODER_SET_OUTPUT: 658 697 { 659 698 int *iarg = arg; 660 699 661 - dprintk(1, KERN_DEBUG "%s: decoder set output\n", 662 - I2C_NAME(client)); 700 + v4l_dbg(1, debug, client, "set output\n"); 663 701 664 702 /* not much choice of outputs */ 665 703 if (*iarg != 0) { 666 704 return -EINVAL; 667 705 } 668 - } 669 706 break; 707 + } 670 708 671 709 case DECODER_ENABLE_OUTPUT: 672 710 { 673 711 int *iarg = arg; 674 712 int enable = (*iarg != 0); 675 713 676 - dprintk(1, KERN_DEBUG "%s: decoder %s output\n", 677 - I2C_NAME(client), enable ? "enable" : "disable"); 714 + v4l_dbg(1, debug, client, "%s output\n", 715 + enable ? "enable" : "disable"); 678 716 679 717 decoder->playback = !enable; 680 718 ··· 714 754 saa7114_write(client, 0x80, 0x36); 715 755 716 756 } 717 - } 718 757 break; 758 + } 719 759 720 760 case DECODER_SET_PICTURE: 721 761 { 722 762 struct video_picture *pic = arg; 723 763 724 - dprintk(1, 725 - KERN_DEBUG 726 - "%s: decoder set picture bright=%d contrast=%d saturation=%d hue=%d\n", 727 - I2C_NAME(client), pic->brightness, pic->contrast, 728 - pic->colour, pic->hue); 764 + v4l_dbg(1, debug, client, 765 + "decoder set picture bright=%d contrast=%d saturation=%d hue=%d\n", 766 + pic->brightness, pic->contrast, pic->colour, pic->hue); 729 767 730 768 if (decoder->bright != pic->brightness) { 731 769 /* We want 0 to 255 we get 0-65535 */ ··· 747 789 saa7114_write(client, 0x0d, 748 790 (decoder->hue - 32768) >> 8); 749 791 } 750 - } 751 792 break; 793 + } 752 794 753 795 default: 754 796 return -EINVAL; ··· 759 801 760 802 /* ----------------------------------------------------------------------- */ 761 803 762 - /* 763 - * Generic i2c probe 764 - * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 765 - */ 766 - static unsigned short normal_i2c[] = 767 - { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END }; 804 + static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END }; 768 805 769 - static unsigned short ignore = I2C_CLIENT_END; 806 + I2C_CLIENT_INSMOD; 770 807 771 - static struct i2c_client_address_data addr_data = { 772 - .normal_i2c = normal_i2c, 773 - .probe = &ignore, 774 - .ignore = &ignore, 775 - }; 776 - 777 - static struct i2c_driver i2c_driver_saa7114; 778 - 779 - static int 780 - saa7114_detect_client (struct i2c_adapter *adapter, 781 - int address, 782 - int kind) 808 + static int saa7114_probe(struct i2c_client *client, 809 + const struct i2c_device_id *id) 783 810 { 784 811 int i, err[30]; 785 812 short int hoff = SAA_7114_NTSC_HOFFSET; 786 813 short int voff = SAA_7114_NTSC_VOFFSET; 787 814 short int w = SAA_7114_NTSC_WIDTH; 788 815 short int h = SAA_7114_NTSC_HEIGHT; 789 - struct i2c_client *client; 790 816 struct saa7114 *decoder; 791 817 792 - dprintk(1, 793 - KERN_INFO 794 - "saa7114.c: detecting saa7114 client on address 0x%x\n", 795 - address << 1); 796 - 797 818 /* Check if the adapter supports the needed features */ 798 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 799 - return 0; 819 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 820 + return -ENODEV; 800 821 801 - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 802 - if (!client) 803 - return -ENOMEM; 804 - client->addr = address; 805 - client->adapter = adapter; 806 - client->driver = &i2c_driver_saa7114; 807 - strlcpy(I2C_NAME(client), "saa7114", sizeof(I2C_NAME(client))); 822 + v4l_info(client, "chip found @ 0x%x (%s)\n", 823 + client->addr << 1, client->adapter->name); 808 824 809 825 decoder = kzalloc(sizeof(struct saa7114), GFP_KERNEL); 810 - if (decoder == NULL) { 811 - kfree(client); 826 + if (decoder == NULL) 812 827 return -ENOMEM; 813 - } 814 828 decoder->norm = VIDEO_MODE_NTSC; 815 829 decoder->input = -1; 816 830 decoder->enable = 1; ··· 867 937 decoder->reg[REG_ADDR(0x0e)] |= 1; // combfilter on 868 938 869 939 870 - dprintk(1, KERN_DEBUG "%s_attach: starting decoder init\n", 871 - I2C_NAME(client)); 940 + v4l_dbg(1, debug, client, "starting init\n"); 872 941 873 942 err[0] = 874 943 saa7114_write_block(client, decoder->reg + (0x20 << 1), ··· 891 962 892 963 for (i = 0; i <= 5; i++) { 893 964 if (err[i] < 0) { 894 - dprintk(1, 895 - KERN_ERR 896 - "%s_attach: init error %d at stage %d, leaving attach.\n", 897 - I2C_NAME(client), i, err[i]); 965 + v4l_dbg(1, debug, client, 966 + "init error %d at stage %d, leaving attach.\n", 967 + i, err[i]); 898 968 kfree(decoder); 899 - kfree(client); 900 - return 0; 969 + return -EIO; 901 970 } 902 971 } 903 972 904 973 for (i = 6; i < 8; i++) { 905 - dprintk(1, 906 - KERN_DEBUG 907 - "%s_attach: reg[0x%02x] = 0x%02x (0x%02x)\n", 908 - I2C_NAME(client), i, saa7114_read(client, i), 974 + v4l_dbg(1, debug, client, 975 + "reg[0x%02x] = 0x%02x (0x%02x)\n", 976 + i, saa7114_read(client, i), 909 977 decoder->reg[REG_ADDR(i)]); 910 978 } 911 979 912 - dprintk(1, 913 - KERN_DEBUG 914 - "%s_attach: performing decoder reset sequence\n", 915 - I2C_NAME(client)); 980 + v4l_dbg(1, debug, client, 981 + "performing decoder reset sequence\n"); 916 982 917 983 err[6] = saa7114_write(client, 0x80, 0x06); // i-port and scaler backend clock selection, task A&B off 918 984 err[7] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler ··· 915 991 916 992 for (i = 6; i <= 8; i++) { 917 993 if (err[i] < 0) { 918 - dprintk(1, 919 - KERN_ERR 920 - "%s_attach: init error %d at stage %d, leaving attach.\n", 921 - I2C_NAME(client), i, err[i]); 994 + v4l_dbg(1, debug, client, 995 + "init error %d at stage %d, leaving attach.\n", 996 + i, err[i]); 922 997 kfree(decoder); 923 - kfree(client); 924 - return 0; 998 + return -EIO; 925 999 } 926 1000 } 927 1001 928 - dprintk(1, KERN_INFO "%s_attach: performing the rest of init\n", 929 - I2C_NAME(client)); 930 - 1002 + v4l_dbg(1, debug, client, "performing the rest of init\n"); 931 1003 932 1004 err[9] = saa7114_write(client, 0x01, decoder->reg[REG_ADDR(0x01)]); 933 1005 err[10] = saa7114_write_block(client, decoder->reg + (0x03 << 1), (0x1e + 1 - 0x03) << 1); // big seq ··· 959 1039 960 1040 for (i = 9; i <= 18; i++) { 961 1041 if (err[i] < 0) { 962 - dprintk(1, 963 - KERN_ERR 964 - "%s_attach: init error %d at stage %d, leaving attach.\n", 965 - I2C_NAME(client), i, err[i]); 1042 + v4l_dbg(1, debug, client, 1043 + "init error %d at stage %d, leaving attach.\n", 1044 + i, err[i]); 966 1045 kfree(decoder); 967 - kfree(client); 968 - return 0; 1046 + return -EIO; 969 1047 } 970 1048 } 971 1049 972 1050 973 1051 for (i = 6; i < 8; i++) { 974 - dprintk(1, 975 - KERN_DEBUG 976 - "%s_attach: reg[0x%02x] = 0x%02x (0x%02x)\n", 977 - I2C_NAME(client), i, saa7114_read(client, i), 1052 + v4l_dbg(1, debug, client, 1053 + "reg[0x%02x] = 0x%02x (0x%02x)\n", 1054 + i, saa7114_read(client, i), 978 1055 decoder->reg[REG_ADDR(i)]); 979 1056 } 980 1057 981 1058 982 1059 for (i = 0x11; i <= 0x13; i++) { 983 - dprintk(1, 984 - KERN_DEBUG 985 - "%s_attach: reg[0x%02x] = 0x%02x (0x%02x)\n", 986 - I2C_NAME(client), i, saa7114_read(client, i), 1060 + v4l_dbg(1, debug, client, 1061 + "reg[0x%02x] = 0x%02x (0x%02x)\n", 1062 + i, saa7114_read(client, i), 987 1063 decoder->reg[REG_ADDR(i)]); 988 1064 } 989 1065 990 1066 991 - dprintk(1, KERN_DEBUG "%s_attach: setting video input\n", 992 - I2C_NAME(client)); 1067 + v4l_dbg(1, debug, client, "setting video input\n"); 993 1068 994 1069 err[19] = 995 1070 saa7114_write(client, 0x02, decoder->reg[REG_ADDR(0x02)]); ··· 995 1080 996 1081 for (i = 19; i <= 21; i++) { 997 1082 if (err[i] < 0) { 998 - dprintk(1, 999 - KERN_ERR 1000 - "%s_attach: init error %d at stage %d, leaving attach.\n", 1001 - I2C_NAME(client), i, err[i]); 1083 + v4l_dbg(1, debug, client, 1084 + "init error %d at stage %d, leaving attach.\n", 1085 + i, err[i]); 1002 1086 kfree(decoder); 1003 - kfree(client); 1004 - return 0; 1087 + return -EIO; 1005 1088 } 1006 1089 } 1007 1090 1008 - dprintk(1, 1009 - KERN_DEBUG 1010 - "%s_attach: performing decoder reset sequence\n", 1011 - I2C_NAME(client)); 1091 + v4l_dbg(1, debug, client, "performing decoder reset sequence\n"); 1012 1092 1013 1093 err[22] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler 1014 1094 err[23] = saa7114_write(client, 0x88, 0xf8); // sw reset scaler release ··· 1012 1102 1013 1103 for (i = 22; i <= 24; i++) { 1014 1104 if (err[i] < 0) { 1015 - dprintk(1, 1016 - KERN_ERR 1017 - "%s_attach: init error %d at stage %d, leaving attach.\n", 1018 - I2C_NAME(client), i, err[i]); 1105 + v4l_dbg(1, debug, client, 1106 + "init error %d at stage %d, leaving attach.\n", 1107 + i, err[i]); 1019 1108 kfree(decoder); 1020 - kfree(client); 1021 - return 0; 1109 + return -EIO; 1022 1110 } 1023 1111 } 1024 1112 ··· 1024 1116 err[26] = saa7114_write(client, 0x07, init[REG_ADDR(0x07)]); 1025 1117 err[27] = saa7114_write(client, 0x10, init[REG_ADDR(0x10)]); 1026 1118 1027 - dprintk(1, 1028 - KERN_INFO 1029 - "%s_attach: chip version %x, decoder status 0x%02x\n", 1030 - I2C_NAME(client), saa7114_read(client, 0x00) >> 4, 1119 + v4l_dbg(1, debug, client, "chip version %x, decoder status 0x%02x\n", 1120 + saa7114_read(client, 0x00) >> 4, 1031 1121 saa7114_read(client, 0x1f)); 1032 - dprintk(1, 1033 - KERN_DEBUG 1034 - "%s_attach: power save control: 0x%02x, scaler status: 0x%02x\n", 1035 - I2C_NAME(client), saa7114_read(client, 0x88), 1122 + v4l_dbg(1, debug, client, 1123 + "power save control: 0x%02x, scaler status: 0x%02x\n", 1124 + saa7114_read(client, 0x88), 1036 1125 saa7114_read(client, 0x8f)); 1037 1126 1038 1127 1039 1128 for (i = 0x94; i < 0x96; i++) { 1040 - dprintk(1, 1041 - KERN_DEBUG 1042 - "%s_attach: reg[0x%02x] = 0x%02x (0x%02x)\n", 1043 - I2C_NAME(client), i, saa7114_read(client, i), 1129 + v4l_dbg(1, debug, client, 1130 + "reg[0x%02x] = 0x%02x (0x%02x)\n", 1131 + i, saa7114_read(client, i), 1044 1132 decoder->reg[REG_ADDR(i)]); 1045 1133 } 1046 1134 1047 - i = i2c_attach_client(client); 1048 - if (i) { 1049 - kfree(client); 1050 - kfree(decoder); 1051 - return i; 1052 - } 1053 - 1054 1135 //i = saa7114_write_block(client, init, sizeof(init)); 1055 - i = 0; 1056 - if (i < 0) { 1057 - dprintk(1, KERN_ERR "%s_attach error: init status %d\n", 1058 - I2C_NAME(client), i); 1059 - } else { 1060 - dprintk(1, 1061 - KERN_INFO 1062 - "%s_attach: chip version %x at address 0x%x\n", 1063 - I2C_NAME(client), saa7114_read(client, 0x00) >> 4, 1064 - client->addr << 1); 1065 - } 1066 - 1067 1136 return 0; 1068 1137 } 1069 1138 1070 - static int 1071 - saa7114_attach_adapter (struct i2c_adapter *adapter) 1139 + static int saa7114_remove(struct i2c_client *client) 1072 1140 { 1073 - dprintk(1, 1074 - KERN_INFO 1075 - "saa7114.c: starting probe for adapter %s (0x%x)\n", 1076 - I2C_NAME(adapter), adapter->id); 1077 - return i2c_probe(adapter, &addr_data, &saa7114_detect_client); 1078 - } 1079 - 1080 - static int 1081 - saa7114_detach_client (struct i2c_client *client) 1082 - { 1083 - struct saa7114 *decoder = i2c_get_clientdata(client); 1084 - int err; 1085 - 1086 - err = i2c_detach_client(client); 1087 - if (err) { 1088 - return err; 1089 - } 1090 - 1091 - kfree(decoder); 1092 - kfree(client); 1093 - 1141 + kfree(i2c_get_clientdata(client)); 1094 1142 return 0; 1095 1143 } 1096 1144 1097 1145 /* ----------------------------------------------------------------------- */ 1098 1146 1099 - static struct i2c_driver i2c_driver_saa7114 = { 1100 - .driver = { 1101 - .name = "saa7114", 1102 - }, 1103 - 1104 - .id = I2C_DRIVERID_SAA7114, 1105 - 1106 - .attach_adapter = saa7114_attach_adapter, 1107 - .detach_client = saa7114_detach_client, 1108 - .command = saa7114_command, 1147 + static const struct i2c_device_id saa7114_id[] = { 1148 + { "saa7114_old", 0 }, /* "saa7114" maps to the saa7115 driver */ 1149 + { } 1109 1150 }; 1151 + MODULE_DEVICE_TABLE(i2c, saa7114_id); 1110 1152 1111 - static int __init 1112 - saa7114_init (void) 1113 - { 1114 - return i2c_add_driver(&i2c_driver_saa7114); 1115 - } 1116 - 1117 - static void __exit 1118 - saa7114_exit (void) 1119 - { 1120 - i2c_del_driver(&i2c_driver_saa7114); 1121 - } 1122 - 1123 - module_init(saa7114_init); 1124 - module_exit(saa7114_exit); 1153 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 1154 + .name = "saa7114", 1155 + .driverid = I2C_DRIVERID_SAA7114, 1156 + .command = saa7114_command, 1157 + .probe = saa7114_probe, 1158 + .remove = saa7114_remove, 1159 + .id_table = saa7114_id, 1160 + };
+1 -1
drivers/media/video/saa7127.c
··· 29 29 * Note: the saa7126 is identical to the saa7127, and the saa7128 is 30 30 * identical to the saa7129, except that the saa7126 and saa7128 have 31 31 * macrovision anti-taping support. This driver will almost certainly 32 - * work find for those chips, except of course for the missing anti-taping 32 + * work fine for those chips, except of course for the missing anti-taping 33 33 * support. 34 34 * 35 35 * This program is free software; you can redistribute it and/or modify
+123 -93
drivers/media/video/saa7134/saa7134-dvb.c
··· 535 535 struct tda1004x_config *cdec_conf, 536 536 struct tda827x_config *tuner_conf) 537 537 { 538 - dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap); 539 - if (dev->dvb.frontend) { 538 + struct videobuf_dvb_frontend *fe0; 539 + 540 + /* Get the first frontend */ 541 + fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); 542 + 543 + fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap); 544 + if (fe0->dvb.frontend) { 540 545 if (cdec_conf->i2c_gate) 541 - dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; 542 - if (dvb_attach(tda827x_attach, dev->dvb.frontend, 546 + fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; 547 + if (dvb_attach(tda827x_attach, fe0->dvb.frontend, 543 548 cdec_conf->tuner_address, 544 549 &dev->i2c_adap, tuner_conf)) 545 550 return 0; ··· 949 944 { 950 945 int ret; 951 946 int attach_xc3028 = 0; 947 + struct videobuf_dvb_frontend *fe0; 948 + 949 + /* FIXME: add support for multi-frontend */ 950 + mutex_init(&dev->frontends.lock); 951 + INIT_LIST_HEAD(&dev->frontends.felist); 952 + dev->frontends.active_fe_id = 0; 953 + 954 + printk(KERN_INFO "%s() allocating 1 frontend\n", __func__); 955 + 956 + if (videobuf_dvb_alloc_frontend(&dev->frontends, 1) == NULL) { 957 + printk(KERN_ERR "%s() failed to alloc\n", __func__); 958 + return -ENOMEM; 959 + } 960 + 961 + /* Get the first frontend */ 962 + fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); 963 + if (!fe0) 964 + return -EINVAL; 952 965 953 966 /* init struct videobuf_dvb */ 954 967 dev->ts.nr_bufs = 32; 955 968 dev->ts.nr_packets = 32*4; 956 - dev->dvb.name = dev->name; 957 - videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops, 969 + fe0->dvb.name = dev->name; 970 + videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops, 958 971 &dev->pci->dev, &dev->slock, 959 972 V4L2_BUF_TYPE_VIDEO_CAPTURE, 960 973 V4L2_FIELD_ALTERNATE, ··· 982 959 switch (dev->board) { 983 960 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: 984 961 dprintk("pinnacle 300i dvb setup\n"); 985 - dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i, 962 + fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i, 986 963 &dev->i2c_adap); 987 - if (dev->dvb.frontend) { 988 - dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params; 964 + if (fe0->dvb.frontend) { 965 + fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params; 989 966 } 990 967 break; 991 968 case SAA7134_BOARD_AVERMEDIA_777: 992 969 case SAA7134_BOARD_AVERMEDIA_A16AR: 993 970 dprintk("avertv 777 dvb setup\n"); 994 - dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, 971 + fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, 995 972 &dev->i2c_adap); 996 - if (dev->dvb.frontend) { 997 - dvb_attach(simple_tuner_attach, dev->dvb.frontend, 973 + if (fe0->dvb.frontend) { 974 + dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 998 975 &dev->i2c_adap, 0x61, 999 976 TUNER_PHILIPS_TD1316); 1000 977 } 1001 978 break; 1002 979 case SAA7134_BOARD_AVERMEDIA_A16D: 1003 980 dprintk("AverMedia A16D dvb setup\n"); 1004 - dev->dvb.frontend = dvb_attach(mt352_attach, 981 + fe0->dvb.frontend = dvb_attach(mt352_attach, 1005 982 &avermedia_xc3028_mt352_dev, 1006 983 &dev->i2c_adap); 1007 984 attach_xc3028 = 1; 1008 985 break; 1009 986 case SAA7134_BOARD_MD7134: 1010 - dev->dvb.frontend = dvb_attach(tda10046_attach, 987 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1011 988 &medion_cardbus, 1012 989 &dev->i2c_adap); 1013 - if (dev->dvb.frontend) { 1014 - dvb_attach(simple_tuner_attach, dev->dvb.frontend, 990 + if (fe0->dvb.frontend) { 991 + dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1015 992 &dev->i2c_adap, medion_cardbus.tuner_address, 1016 993 TUNER_PHILIPS_FMD1216ME_MK3); 1017 994 } 1018 995 break; 1019 996 case SAA7134_BOARD_PHILIPS_TOUGH: 1020 - dev->dvb.frontend = dvb_attach(tda10046_attach, 997 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1021 998 &philips_tu1216_60_config, 1022 999 &dev->i2c_adap); 1023 - if (dev->dvb.frontend) { 1024 - dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init; 1025 - dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; 1000 + if (fe0->dvb.frontend) { 1001 + fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init; 1002 + fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; 1026 1003 } 1027 1004 break; 1028 1005 case SAA7134_BOARD_FLYDVBTDUO: ··· 1033 1010 break; 1034 1011 case SAA7134_BOARD_PHILIPS_EUROPA: 1035 1012 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 1036 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1013 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1037 1014 &philips_europa_config, 1038 1015 &dev->i2c_adap); 1039 - if (dev->dvb.frontend) { 1040 - dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; 1041 - dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; 1042 - dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; 1043 - dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; 1044 - dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; 1016 + if (fe0->dvb.frontend) { 1017 + dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep; 1018 + fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep; 1019 + fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; 1020 + fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; 1021 + fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; 1045 1022 } 1046 1023 break; 1047 1024 case SAA7134_BOARD_VIDEOMATE_DVBT_200: 1048 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1025 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1049 1026 &philips_tu1216_61_config, 1050 1027 &dev->i2c_adap); 1051 - if (dev->dvb.frontend) { 1052 - dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init; 1053 - dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; 1028 + if (fe0->dvb.frontend) { 1029 + fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init; 1030 + fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; 1054 1031 } 1055 1032 break; 1056 1033 case SAA7134_BOARD_KWORLD_DVBT_210: ··· 1089 1066 &tda827x_cfg_0) < 0) 1090 1067 goto dettach_frontend; 1091 1068 } else { /* satellite */ 1092 - dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); 1093 - if (dev->dvb.frontend) { 1094 - if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, 1069 + fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); 1070 + if (fe0->dvb.frontend) { 1071 + if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63, 1095 1072 &dev->i2c_adap, 0) == NULL) { 1096 1073 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); 1097 1074 goto dettach_frontend; 1098 1075 } 1099 - if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, 1076 + if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap, 1100 1077 0x08, 0, 0) == NULL) { 1101 1078 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); 1102 1079 goto dettach_frontend; ··· 1106 1083 break; 1107 1084 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: 1108 1085 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: 1109 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1086 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1110 1087 &ads_tech_duo_config, 1111 1088 &dev->i2c_adap); 1112 - if (dev->dvb.frontend) { 1113 - if (dvb_attach(tda827x_attach,dev->dvb.frontend, 1089 + if (fe0->dvb.frontend) { 1090 + if (dvb_attach(tda827x_attach,fe0->dvb.frontend, 1114 1091 ads_tech_duo_config.tuner_address, &dev->i2c_adap, 1115 1092 &ads_duo_cfg) == NULL) { 1116 1093 wprintk("no tda827x tuner found at addr: %02x\n", ··· 1131 1108 &tda827x_cfg_0) < 0) 1132 1109 goto dettach_frontend; 1133 1110 } else { /* satellite */ 1134 - dev->dvb.frontend = dvb_attach(tda10086_attach, 1111 + fe0->dvb.frontend = dvb_attach(tda10086_attach, 1135 1112 &flydvbs, &dev->i2c_adap); 1136 - if (dev->dvb.frontend) { 1137 - struct dvb_frontend *fe = dev->dvb.frontend; 1113 + if (fe0->dvb.frontend) { 1114 + struct dvb_frontend *fe = fe0->dvb.frontend; 1138 1115 u8 dev_id = dev->eedata[2]; 1139 1116 u8 data = 0xc4; 1140 1117 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1}; 1141 1118 1142 - if (dvb_attach(tda826x_attach, dev->dvb.frontend, 1119 + if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 1143 1120 0x60, &dev->i2c_adap, 0) == NULL) { 1144 1121 wprintk("%s: Medion Quadro, no tda826x " 1145 1122 "found !\n", __func__); ··· 1173 1150 } 1174 1151 break; 1175 1152 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1176 - dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, 1153 + fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, 1177 1154 &dev->i2c_adap); 1178 - if (dev->dvb.frontend) 1179 - dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 1155 + if (fe0->dvb.frontend) 1156 + dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61, 1180 1157 NULL, DVB_PLL_TDHU2); 1181 1158 break; 1182 1159 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI: 1183 1160 case SAA7134_BOARD_KWORLD_ATSC110: 1184 - dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, 1161 + fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, 1185 1162 &dev->i2c_adap); 1186 - if (dev->dvb.frontend) 1187 - dvb_attach(simple_tuner_attach, dev->dvb.frontend, 1163 + if (fe0->dvb.frontend) 1164 + dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1188 1165 &dev->i2c_adap, 0x61, 1189 1166 TUNER_PHILIPS_TUV1236D); 1190 1167 break; 1191 1168 case SAA7134_BOARD_FLYDVBS_LR300: 1192 - dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1169 + fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1193 1170 &dev->i2c_adap); 1194 - if (dev->dvb.frontend) { 1195 - if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1171 + if (fe0->dvb.frontend) { 1172 + if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60, 1196 1173 &dev->i2c_adap, 0) == NULL) { 1197 1174 wprintk("%s: No tda826x found!\n", __func__); 1198 1175 goto dettach_frontend; 1199 1176 } 1200 - if (dvb_attach(isl6421_attach, dev->dvb.frontend, 1177 + if (dvb_attach(isl6421_attach, fe0->dvb.frontend, 1201 1178 &dev->i2c_adap, 0x08, 0, 0) == NULL) { 1202 1179 wprintk("%s: No ISL6421 found!\n", __func__); 1203 1180 goto dettach_frontend; ··· 1205 1182 } 1206 1183 break; 1207 1184 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: 1208 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1185 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1209 1186 &medion_cardbus, 1210 1187 &dev->i2c_adap); 1211 - if (dev->dvb.frontend) { 1212 - dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; 1213 - dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; 1188 + if (fe0->dvb.frontend) { 1189 + dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep; 1190 + fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep; 1214 1191 1215 - dvb_attach(simple_tuner_attach, dev->dvb.frontend, 1192 + dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1216 1193 &dev->i2c_adap, medion_cardbus.tuner_address, 1217 1194 TUNER_PHILIPS_FMD1216ME_MK3); 1218 1195 } 1219 1196 break; 1220 1197 case SAA7134_BOARD_VIDEOMATE_DVBT_200A: 1221 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1198 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1222 1199 &philips_europa_config, 1223 1200 &dev->i2c_adap); 1224 - if (dev->dvb.frontend) { 1225 - dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init; 1226 - dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; 1201 + if (fe0->dvb.frontend) { 1202 + fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init; 1203 + fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; 1227 1204 } 1228 1205 break; 1229 1206 case SAA7134_BOARD_CINERGY_HT_PCMCIA: ··· 1262 1239 goto dettach_frontend; 1263 1240 break; 1264 1241 case SAA7134_BOARD_PHILIPS_SNAKE: 1265 - dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1242 + fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1266 1243 &dev->i2c_adap); 1267 - if (dev->dvb.frontend) { 1268 - if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1244 + if (fe0->dvb.frontend) { 1245 + if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60, 1269 1246 &dev->i2c_adap, 0) == NULL) { 1270 1247 wprintk("%s: No tda826x found!\n", __func__); 1271 1248 goto dettach_frontend; 1272 1249 } 1273 - if (dvb_attach(lnbp21_attach, dev->dvb.frontend, 1250 + if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, 1274 1251 &dev->i2c_adap, 0, 0) == NULL) { 1275 1252 wprintk("%s: No lnbp21 found!\n", __func__); 1276 1253 goto dettach_frontend; ··· 1292 1269 saa7134_set_gpio(dev, 25, 0); 1293 1270 msleep(10); 1294 1271 saa7134_set_gpio(dev, 25, 1); 1295 - dev->dvb.frontend = dvb_attach(mt352_attach, 1272 + fe0->dvb.frontend = dvb_attach(mt352_attach, 1296 1273 &avermedia_xc3028_mt352_dev, 1297 1274 &dev->i2c_adap); 1298 1275 attach_xc3028 = 1; 1299 1276 break; 1300 1277 case SAA7134_BOARD_MD7134_BRIDGE_2: 1301 - dev->dvb.frontend = dvb_attach(tda10086_attach, 1278 + fe0->dvb.frontend = dvb_attach(tda10086_attach, 1302 1279 &sd1878_4m, &dev->i2c_adap); 1303 - if (dev->dvb.frontend) { 1280 + if (fe0->dvb.frontend) { 1304 1281 struct dvb_frontend *fe; 1305 - if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 1282 + if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60, 1306 1283 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) { 1307 1284 wprintk("%s: MD7134 DVB-S, no SD1878 " 1308 1285 "found !\n", __func__); 1309 1286 goto dettach_frontend; 1310 1287 } 1311 1288 /* we need to open the i2c gate (we know it exists) */ 1312 - fe = dev->dvb.frontend; 1289 + fe = fe0->dvb.frontend; 1313 1290 fe->ops.i2c_gate_ctrl(fe, 1); 1314 1291 if (dvb_attach(isl6405_attach, fe, 1315 1292 &dev->i2c_adap, 0x08, 0, 0) == NULL) { ··· 1328 1305 saa7134_set_gpio(dev, 25, 0); 1329 1306 msleep(10); 1330 1307 saa7134_set_gpio(dev, 25, 1); 1331 - dev->dvb.frontend = dvb_attach(mt352_attach, 1308 + fe0->dvb.frontend = dvb_attach(mt352_attach, 1332 1309 &avermedia_xc3028_mt352_dev, 1333 1310 &dev->i2c_adap); 1334 1311 attach_xc3028 = 1; ··· 1339 1316 &tda827x_cfg_2) < 0) 1340 1317 goto dettach_frontend; 1341 1318 } else { /* satellite */ 1342 - dev->dvb.frontend = dvb_attach(tda10086_attach, 1319 + fe0->dvb.frontend = dvb_attach(tda10086_attach, 1343 1320 &flydvbs, &dev->i2c_adap); 1344 - if (dev->dvb.frontend) { 1321 + if (fe0->dvb.frontend) { 1345 1322 if (dvb_attach(tda826x_attach, 1346 - dev->dvb.frontend, 0x60, 1323 + fe0->dvb.frontend, 0x60, 1347 1324 &dev->i2c_adap, 0) == NULL) { 1348 1325 wprintk("%s: Asus Tiger 3in1, no " 1349 1326 "tda826x found!\n", __func__); 1350 1327 goto dettach_frontend; 1351 1328 } 1352 - if (dvb_attach(lnbp21_attach, dev->dvb.frontend, 1329 + if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, 1353 1330 &dev->i2c_adap, 0, 0) == NULL) { 1354 1331 wprintk("%s: Asus Tiger 3in1, no lnbp21" 1355 1332 " found!\n", __func__); ··· 1375 1352 .i2c_addr = 0x61, 1376 1353 }; 1377 1354 1378 - if (!dev->dvb.frontend) 1355 + if (!fe0->dvb.frontend) 1379 1356 return -1; 1380 1357 1381 - fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg); 1358 + fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg); 1382 1359 if (!fe) { 1383 1360 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 1384 1361 dev->name); ··· 1386 1363 } 1387 1364 } 1388 1365 1389 - if (NULL == dev->dvb.frontend) { 1366 + if (NULL == fe0->dvb.frontend) { 1390 1367 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name); 1391 1368 return -1; 1392 1369 } 1393 1370 /* define general-purpose callback pointer */ 1394 - dev->dvb.frontend->callback = saa7134_tuner_callback; 1371 + fe0->dvb.frontend->callback = saa7134_tuner_callback; 1395 1372 1396 1373 /* register everything else */ 1397 - ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev, 1398 - adapter_nr); 1374 + ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, 1375 + &dev->pci->dev, adapter_nr, 0); 1399 1376 1400 1377 /* this sequence is necessary to make the tda1004x load its firmware 1401 1378 * and to enter analog mode of hybrid boards 1402 1379 */ 1403 1380 if (!ret) { 1404 - if (dev->dvb.frontend->ops.init) 1405 - dev->dvb.frontend->ops.init(dev->dvb.frontend); 1406 - if (dev->dvb.frontend->ops.sleep) 1407 - dev->dvb.frontend->ops.sleep(dev->dvb.frontend); 1408 - if (dev->dvb.frontend->ops.tuner_ops.sleep) 1409 - dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend); 1381 + if (fe0->dvb.frontend->ops.init) 1382 + fe0->dvb.frontend->ops.init(fe0->dvb.frontend); 1383 + if (fe0->dvb.frontend->ops.sleep) 1384 + fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend); 1385 + if (fe0->dvb.frontend->ops.tuner_ops.sleep) 1386 + fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend); 1410 1387 } 1411 1388 return ret; 1412 1389 1413 1390 dettach_frontend: 1414 - if (dev->dvb.frontend) 1415 - dvb_frontend_detach(dev->dvb.frontend); 1416 - dev->dvb.frontend = NULL; 1391 + if (fe0->dvb.frontend) 1392 + dvb_frontend_detach(fe0->dvb.frontend); 1393 + fe0->dvb.frontend = NULL; 1417 1394 1418 1395 return -1; 1419 1396 } 1420 1397 1421 1398 static int dvb_fini(struct saa7134_dev *dev) 1422 1399 { 1400 + struct videobuf_dvb_frontend *fe0; 1401 + 1402 + /* Get the first frontend */ 1403 + fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); 1404 + if (!fe0) 1405 + return -EINVAL; 1406 + 1423 1407 /* FIXME: I suspect that this code is bogus, since the entry for 1424 1408 Pinnacle 300I DVB-T PAL already defines the proper init to allow 1425 1409 the detection of mt2032 (TDA9887_PORT2_INACTIVE) ··· 1446 1416 u8 data = 0x80; 1447 1417 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1}; 1448 1418 struct dvb_frontend *fe; 1449 - fe = dev->dvb.frontend; 1419 + fe = fe0->dvb.frontend; 1450 1420 if (fe->ops.i2c_gate_ctrl) { 1451 1421 fe->ops.i2c_gate_ctrl(fe, 1); 1452 1422 i2c_transfer(&dev->i2c_adap, &msg, 1); ··· 1454 1424 } 1455 1425 } 1456 1426 } 1457 - if (dev->dvb.frontend) 1458 - videobuf_dvb_unregister(&dev->dvb); 1427 + if (fe0->dvb.frontend) 1428 + videobuf_dvb_unregister_bus(&dev->frontends); 1459 1429 return 0; 1460 1430 } 1461 1431
+1 -1
drivers/media/video/saa7134/saa7134.h
··· 581 581 582 582 #if defined(CONFIG_VIDEO_SAA7134_DVB) || defined(CONFIG_VIDEO_SAA7134_DVB_MODULE) 583 583 /* SAA7134_MPEG_DVB only */ 584 - struct videobuf_dvb dvb; 584 + struct videobuf_dvb_frontends frontends; 585 585 int (*original_demod_sleep)(struct dvb_frontend *fe); 586 586 int (*original_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage); 587 587 int (*original_set_high_voltage)(struct dvb_frontend *fe, long arg);
+51 -161
drivers/media/video/saa7185.c
··· 25 25 */ 26 26 27 27 #include <linux/module.h> 28 - #include <linux/init.h> 29 - #include <linux/delay.h> 30 - #include <linux/errno.h> 31 - #include <linux/fs.h> 32 - #include <linux/kernel.h> 33 - #include <linux/major.h> 34 - #include <linux/slab.h> 35 - #include <linux/mm.h> 36 - #include <linux/signal.h> 37 28 #include <linux/types.h> 38 - #include <linux/i2c.h> 39 - #include <asm/io.h> 40 - #include <asm/pgtable.h> 41 - #include <asm/page.h> 29 + #include <linux/ioctl.h> 42 30 #include <asm/uaccess.h> 43 - 31 + #include <linux/i2c.h> 32 + #include <linux/i2c-id.h> 44 33 #include <linux/videodev.h> 45 34 #include <linux/video_encoder.h> 35 + #include <media/v4l2-common.h> 36 + #include <media/v4l2-i2c-drv-legacy.h> 46 37 47 38 MODULE_DESCRIPTION("Philips SAA7185 video encoder driver"); 48 39 MODULE_AUTHOR("Dave Perks"); 49 40 MODULE_LICENSE("GPL"); 50 41 51 42 52 - #define I2C_NAME(s) (s)->name 53 - 54 - 55 43 static int debug; 56 44 module_param(debug, int, 0); 57 45 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 58 - 59 - #define dprintk(num, format, args...) \ 60 - do { \ 61 - if (debug >= num) \ 62 - printk(format, ##args); \ 63 - } while (0) 64 46 65 47 /* ----------------------------------------------------------------------- */ 66 48 ··· 57 75 int sat; 58 76 }; 59 77 60 - #define I2C_SAA7185 0x88 61 - 62 78 /* ----------------------------------------------------------------------- */ 63 79 64 - static inline int 65 - saa7185_read (struct i2c_client *client) 80 + static inline int saa7185_read(struct i2c_client *client) 66 81 { 67 82 return i2c_smbus_read_byte(client); 68 83 } 69 84 70 - static int 71 - saa7185_write (struct i2c_client *client, 72 - u8 reg, 73 - u8 value) 85 + static int saa7185_write(struct i2c_client *client, u8 reg, u8 value) 74 86 { 75 87 struct saa7185 *encoder = i2c_get_clientdata(client); 76 88 77 - dprintk(1, KERN_DEBUG "SAA7185: %02x set to %02x\n", reg, value); 89 + v4l_dbg(1, debug, client, "%02x set to %02x\n", reg, value); 78 90 encoder->reg[reg] = value; 79 91 return i2c_smbus_write_byte_data(client, reg, value); 80 92 } 81 93 82 - static int 83 - saa7185_write_block (struct i2c_client *client, 84 - const u8 *data, 85 - unsigned int len) 94 + static int saa7185_write_block(struct i2c_client *client, 95 + const u8 *data, unsigned int len) 86 96 { 87 97 int ret = -1; 88 98 u8 reg; ··· 95 121 encoder->reg[reg++] = data[1]; 96 122 len -= 2; 97 123 data += 2; 98 - } while (len >= 2 && data[0] == reg && 99 - block_len < 32); 100 - if ((ret = i2c_master_send(client, block_data, 101 - block_len)) < 0) 124 + } while (len >= 2 && data[0] == reg && block_len < 32); 125 + ret = i2c_master_send(client, block_data, block_len); 126 + if (ret < 0) 102 127 break; 103 128 } 104 129 } else { 105 130 /* do some slow I2C emulation kind of thing */ 106 131 while (len >= 2) { 107 132 reg = *data++; 108 - if ((ret = saa7185_write(client, reg, 109 - *data++)) < 0) 133 + ret = saa7185_write(client, reg, *data++); 134 + if (ret < 0) 110 135 break; 111 136 len -= 2; 112 137 } ··· 213 240 0x66, 0x21, /* FSC3 */ 214 241 }; 215 242 216 - static int 217 - saa7185_command (struct i2c_client *client, 218 - unsigned int cmd, 219 - void *arg) 243 + static int saa7185_command(struct i2c_client *client, unsigned cmd, void *arg) 220 244 { 221 245 struct saa7185 *encoder = i2c_get_clientdata(client); 222 246 223 247 switch (cmd) { 224 - 225 248 case 0: 226 249 saa7185_write_block(client, init_common, 227 250 sizeof(init_common)); ··· 233 264 sizeof(init_pal)); 234 265 break; 235 266 } 236 - 237 267 break; 238 268 239 269 case ENCODER_GET_CAPABILITIES: ··· 244 276 VIDEO_ENCODER_SECAM | VIDEO_ENCODER_CCIR; 245 277 cap->inputs = 1; 246 278 cap->outputs = 1; 247 - } 248 279 break; 280 + } 249 281 250 282 case ENCODER_SET_NORM: 251 283 { ··· 254 286 //saa7185_write_block(client, init_common, sizeof(init_common)); 255 287 256 288 switch (*iarg) { 257 - 258 289 case VIDEO_MODE_NTSC: 259 290 saa7185_write_block(client, init_ntsc, 260 291 sizeof(init_ntsc)); ··· 267 300 case VIDEO_MODE_SECAM: 268 301 default: 269 302 return -EINVAL; 270 - 271 303 } 272 304 encoder->norm = *iarg; 273 - } 274 305 break; 306 + } 275 307 276 308 case ENCODER_SET_INPUT: 277 309 { ··· 280 314 *iarg = 1: input is from ZR36060 */ 281 315 282 316 switch (*iarg) { 283 - 284 317 case 0: 285 318 /* Switch RTCE to 1 */ 286 319 saa7185_write(client, 0x61, ··· 297 332 298 333 default: 299 334 return -EINVAL; 300 - 301 335 } 302 - } 303 336 break; 337 + } 304 338 305 339 case ENCODER_SET_OUTPUT: 306 340 { 307 341 int *iarg = arg; 308 342 309 343 /* not much choice of outputs */ 310 - if (*iarg != 0) { 344 + if (*iarg != 0) 311 345 return -EINVAL; 312 - } 313 - } 314 346 break; 347 + } 315 348 316 349 case ENCODER_ENABLE_OUTPUT: 317 350 { ··· 319 356 saa7185_write(client, 0x61, 320 357 (encoder->reg[0x61] & 0xbf) | 321 358 (encoder->enable ? 0x00 : 0x40)); 322 - } 323 359 break; 360 + } 324 361 325 362 default: 326 363 return -EINVAL; ··· 331 368 332 369 /* ----------------------------------------------------------------------- */ 333 370 334 - /* 335 - * Generic i2c probe 336 - * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 337 - */ 338 - static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END }; 371 + static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; 339 372 340 - static unsigned short ignore = I2C_CLIENT_END; 373 + I2C_CLIENT_INSMOD; 341 374 342 - static struct i2c_client_address_data addr_data = { 343 - .normal_i2c = normal_i2c, 344 - .probe = &ignore, 345 - .ignore = &ignore, 346 - }; 347 - 348 - static struct i2c_driver i2c_driver_saa7185; 349 - 350 - static int 351 - saa7185_detect_client (struct i2c_adapter *adapter, 352 - int address, 353 - int kind) 375 + static int saa7185_probe(struct i2c_client *client, 376 + const struct i2c_device_id *id) 354 377 { 355 378 int i; 356 - struct i2c_client *client; 357 379 struct saa7185 *encoder; 358 380 359 - dprintk(1, 360 - KERN_INFO 361 - "saa7185.c: detecting saa7185 client on address 0x%x\n", 362 - address << 1); 363 - 364 381 /* Check if the adapter supports the needed features */ 365 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 366 - return 0; 382 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 383 + return -ENODEV; 367 384 368 - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 369 - if (!client) 370 - return -ENOMEM; 371 - client->addr = address; 372 - client->adapter = adapter; 373 - client->driver = &i2c_driver_saa7185; 374 - strlcpy(I2C_NAME(client), "saa7185", sizeof(I2C_NAME(client))); 385 + v4l_info(client, "chip found @ 0x%x (%s)\n", 386 + client->addr << 1, client->adapter->name); 375 387 376 388 encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL); 377 - if (encoder == NULL) { 378 - kfree(client); 389 + if (encoder == NULL) 379 390 return -ENOMEM; 380 - } 381 391 encoder->norm = VIDEO_MODE_NTSC; 382 392 encoder->enable = 1; 383 393 i2c_set_clientdata(client, encoder); 384 394 385 - i = i2c_attach_client(client); 386 - if (i) { 387 - kfree(client); 388 - kfree(encoder); 389 - return i; 390 - } 391 - 392 395 i = saa7185_write_block(client, init_common, sizeof(init_common)); 393 - if (i >= 0) { 394 - i = saa7185_write_block(client, init_ntsc, 395 - sizeof(init_ntsc)); 396 - } 397 - if (i < 0) { 398 - dprintk(1, KERN_ERR "%s_attach: init error %d\n", 399 - I2C_NAME(client), i); 400 - } else { 401 - dprintk(1, 402 - KERN_INFO 403 - "%s_attach: chip version %d at address 0x%x\n", 404 - I2C_NAME(client), saa7185_read(client) >> 5, 405 - client->addr << 1); 406 - } 407 - 396 + if (i >= 0) 397 + i = saa7185_write_block(client, init_ntsc, sizeof(init_ntsc)); 398 + if (i < 0) 399 + v4l_dbg(1, debug, client, "init error %d\n", i); 400 + else 401 + v4l_dbg(1, debug, client, "revision 0x%x\n", 402 + saa7185_read(client) >> 5); 408 403 return 0; 409 404 } 410 405 411 - static int 412 - saa7185_attach_adapter (struct i2c_adapter *adapter) 413 - { 414 - dprintk(1, 415 - KERN_INFO 416 - "saa7185.c: starting probe for adapter %s (0x%x)\n", 417 - I2C_NAME(adapter), adapter->id); 418 - return i2c_probe(adapter, &addr_data, &saa7185_detect_client); 419 - } 420 - 421 - static int 422 - saa7185_detach_client (struct i2c_client *client) 406 + static int saa7185_remove(struct i2c_client *client) 423 407 { 424 408 struct saa7185 *encoder = i2c_get_clientdata(client); 425 - int err; 426 - 427 - err = i2c_detach_client(client); 428 - if (err) { 429 - return err; 430 - } 431 409 432 410 saa7185_write(client, 0x61, (encoder->reg[0x61]) | 0x40); /* SW: output off is active */ 433 411 //saa7185_write(client, 0x3a, (encoder->reg[0x3a]) | 0x80); /* SW: color bar */ 434 412 435 413 kfree(encoder); 436 - kfree(client); 437 - 438 414 return 0; 439 415 } 440 416 441 417 /* ----------------------------------------------------------------------- */ 442 418 443 - static struct i2c_driver i2c_driver_saa7185 = { 444 - .driver = { 445 - .name = "saa7185", /* name */ 446 - }, 447 - 448 - .id = I2C_DRIVERID_SAA7185B, 449 - 450 - .attach_adapter = saa7185_attach_adapter, 451 - .detach_client = saa7185_detach_client, 452 - .command = saa7185_command, 419 + static const struct i2c_device_id saa7185_id[] = { 420 + { "saa7185", 0 }, 421 + { } 453 422 }; 423 + MODULE_DEVICE_TABLE(i2c, saa7185_id); 454 424 455 - static int __init 456 - saa7185_init (void) 457 - { 458 - return i2c_add_driver(&i2c_driver_saa7185); 459 - } 460 - 461 - static void __exit 462 - saa7185_exit (void) 463 - { 464 - i2c_del_driver(&i2c_driver_saa7185); 465 - } 466 - 467 - module_init(saa7185_init); 468 - module_exit(saa7185_exit); 425 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 426 + .name = "saa7185", 427 + .driverid = I2C_DRIVERID_SAA7185B, 428 + .command = saa7185_command, 429 + .probe = saa7185_probe, 430 + .remove = saa7185_remove, 431 + .id_table = saa7185_id, 432 + };
+61 -35
drivers/media/video/sh_mobile_ceu_camera.c
··· 40 40 41 41 /* register offsets for sh7722 / sh7723 */ 42 42 43 - #define CAPSR 0x00 44 - #define CAPCR 0x04 45 - #define CAMCR 0x08 46 - #define CMCYR 0x0c 47 - #define CAMOR 0x10 48 - #define CAPWR 0x14 49 - #define CAIFR 0x18 50 - #define CSTCR 0x20 /* not on sh7723 */ 51 - #define CSECR 0x24 /* not on sh7723 */ 52 - #define CRCNTR 0x28 53 - #define CRCMPR 0x2c 54 - #define CFLCR 0x30 55 - #define CFSZR 0x34 56 - #define CDWDR 0x38 57 - #define CDAYR 0x3c 58 - #define CDACR 0x40 59 - #define CDBYR 0x44 60 - #define CDBCR 0x48 61 - #define CBDSR 0x4c 62 - #define CFWCR 0x5c 63 - #define CLFCR 0x60 64 - #define CDOCR 0x64 65 - #define CDDCR 0x68 66 - #define CDDAR 0x6c 67 - #define CEIER 0x70 68 - #define CETCR 0x74 69 - #define CSTSR 0x7c 70 - #define CSRTR 0x80 71 - #define CDSSR 0x84 72 - #define CDAYR2 0x90 73 - #define CDACR2 0x94 74 - #define CDBYR2 0x98 75 - #define CDBCR2 0x9c 43 + #define CAPSR 0x00 /* Capture start register */ 44 + #define CAPCR 0x04 /* Capture control register */ 45 + #define CAMCR 0x08 /* Capture interface control register */ 46 + #define CMCYR 0x0c /* Capture interface cycle register */ 47 + #define CAMOR 0x10 /* Capture interface offset register */ 48 + #define CAPWR 0x14 /* Capture interface width register */ 49 + #define CAIFR 0x18 /* Capture interface input format register */ 50 + #define CSTCR 0x20 /* Camera strobe control register (<= sh7722) */ 51 + #define CSECR 0x24 /* Camera strobe emission count register (<= sh7722) */ 52 + #define CRCNTR 0x28 /* CEU register control register */ 53 + #define CRCMPR 0x2c /* CEU register forcible control register */ 54 + #define CFLCR 0x30 /* Capture filter control register */ 55 + #define CFSZR 0x34 /* Capture filter size clip register */ 56 + #define CDWDR 0x38 /* Capture destination width register */ 57 + #define CDAYR 0x3c /* Capture data address Y register */ 58 + #define CDACR 0x40 /* Capture data address C register */ 59 + #define CDBYR 0x44 /* Capture data bottom-field address Y register */ 60 + #define CDBCR 0x48 /* Capture data bottom-field address C register */ 61 + #define CBDSR 0x4c /* Capture bundle destination size register */ 62 + #define CFWCR 0x5c /* Firewall operation control register */ 63 + #define CLFCR 0x60 /* Capture low-pass filter control register */ 64 + #define CDOCR 0x64 /* Capture data output control register */ 65 + #define CDDCR 0x68 /* Capture data complexity level register */ 66 + #define CDDAR 0x6c /* Capture data complexity level address register */ 67 + #define CEIER 0x70 /* Capture event interrupt enable register */ 68 + #define CETCR 0x74 /* Capture event flag clear register */ 69 + #define CSTSR 0x7c /* Capture status register */ 70 + #define CSRTR 0x80 /* Capture software reset register */ 71 + #define CDSSR 0x84 /* Capture data size register */ 72 + #define CDAYR2 0x90 /* Capture data address Y register 2 */ 73 + #define CDACR2 0x94 /* Capture data address C register 2 */ 74 + #define CDBYR2 0x98 /* Capture data bottom-field address Y register 2 */ 75 + #define CDBCR2 0x9c /* Capture data bottom-field address C register 2 */ 76 76 77 77 static DEFINE_MUTEX(camera_lock); 78 78 ··· 165 165 ceu_write(pcdev, CETCR, 0x0317f313 ^ 0x10); 166 166 167 167 if (pcdev->active) { 168 + pcdev->active->state = VIDEOBUF_ACTIVE; 168 169 ceu_write(pcdev, CDAYR, videobuf_to_dma_contig(pcdev->active)); 169 170 ceu_write(pcdev, CAPSR, 0x1); /* start capture */ 170 171 } ··· 237 236 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %zd\n", __func__, 238 237 vb, vb->baddr, vb->bsize); 239 238 240 - vb->state = VIDEOBUF_ACTIVE; 239 + vb->state = VIDEOBUF_QUEUED; 241 240 spin_lock_irqsave(&pcdev->lock, flags); 242 241 list_add_tail(&vb->queue, &pcdev->capture); 243 242 ··· 324 323 { 325 324 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 326 325 struct sh_mobile_ceu_dev *pcdev = ici->priv; 326 + unsigned long flags; 327 327 328 328 BUG_ON(icd != pcdev->icd); 329 329 330 330 /* disable capture, disable interrupts */ 331 331 ceu_write(pcdev, CEIER, 0); 332 332 ceu_write(pcdev, CAPSR, 1 << 16); /* reset */ 333 + 334 + /* make sure active buffer is canceled */ 335 + spin_lock_irqsave(&pcdev->lock, flags); 336 + if (pcdev->active) { 337 + list_del(&pcdev->active->queue); 338 + pcdev->active->state = VIDEOBUF_ERROR; 339 + wake_up_all(&pcdev->active->done); 340 + pcdev->active = NULL; 341 + } 342 + spin_unlock_irqrestore(&pcdev->lock, flags); 343 + 333 344 icd->ops->release(icd); 334 345 335 346 dev_info(&icd->dev, ··· 404 391 ceu_write(pcdev, CFLCR, 0); /* data fetch mode - no scaling */ 405 392 ceu_write(pcdev, CFSZR, (icd->height << 16) | cfszr_width); 406 393 ceu_write(pcdev, CLFCR, 0); /* data fetch mode - no lowpass filter */ 407 - ceu_write(pcdev, CDOCR, 0x00000016); 394 + 395 + /* A few words about byte order (observed in Big Endian mode) 396 + * 397 + * In data fetch mode bytes are received in chunks of 8 bytes. 398 + * D0, D1, D2, D3, D4, D5, D6, D7 (D0 received first) 399 + * 400 + * The data is however by default written to memory in reverse order: 401 + * D7, D6, D5, D4, D3, D2, D1, D0 (D7 written to lowest byte) 402 + * 403 + * The lowest three bits of CDOCR allows us to do swapping, 404 + * using 7 we swap the data bytes to match the incoming order: 405 + * D0, D1, D2, D3, D4, D5, D6, D7 406 + */ 407 + ceu_write(pcdev, CDOCR, 0x00000017); 408 408 409 409 ceu_write(pcdev, CDWDR, cdwdr_width); 410 410 ceu_write(pcdev, CFWCR, 0); /* keep "datafetch firewall" disabled */
+11 -9
drivers/media/video/soc_camera_platform.c
··· 18 18 #include <linux/videodev2.h> 19 19 #include <media/v4l2-common.h> 20 20 #include <media/soc_camera.h> 21 - 22 - struct soc_camera_platform_info { 23 - int iface; 24 - char *format_name; 25 - unsigned long format_depth; 26 - struct v4l2_pix_format format; 27 - unsigned long bus_param; 28 - int (*set_capture)(struct soc_camera_platform_info *info, int enable); 29 - }; 21 + #include <media/soc_camera_platform.h> 30 22 31 23 struct soc_camera_platform_priv { 32 24 struct soc_camera_platform_info *info; ··· 36 44 37 45 static int soc_camera_platform_init(struct soc_camera_device *icd) 38 46 { 47 + struct soc_camera_platform_info *p = soc_camera_platform_get_info(icd); 48 + 49 + if (p->power) 50 + p->power(1); 51 + 39 52 return 0; 40 53 } 41 54 42 55 static int soc_camera_platform_release(struct soc_camera_device *icd) 43 56 { 57 + struct soc_camera_platform_info *p = soc_camera_platform_get_info(icd); 58 + 59 + if (p->power) 60 + p->power(0); 61 + 44 62 return 0; 45 63 } 46 64
+8 -19
drivers/media/video/stk-webcam.c
··· 27 27 #include <linux/kernel.h> 28 28 #include <linux/errno.h> 29 29 #include <linux/slab.h> 30 - #include <linux/kref.h> 31 30 32 31 #include <linux/usb.h> 33 32 #include <linux/mm.h> ··· 559 560 560 561 urb = dev->isobufs[i].urb; 561 562 if (urb) { 562 - if (atomic_read(&dev->urbs_used)) 563 + if (atomic_read(&dev->urbs_used) && is_present(dev)) 563 564 usb_kill_urb(urb); 564 565 usb_free_urb(urb); 565 566 } ··· 688 689 { 689 690 struct stk_camera *dev = fp->private_data; 690 691 691 - if (dev->owner != fp) { 692 - usb_autopm_put_interface(dev->interface); 693 - return 0; 692 + if (dev->owner == fp) { 693 + stk_stop_stream(dev); 694 + stk_free_buffers(dev); 695 + dev->owner = NULL; 694 696 } 695 697 696 - stk_stop_stream(dev); 697 - 698 - stk_free_buffers(dev); 699 - 700 - dev->owner = NULL; 701 - 702 - usb_autopm_put_interface(dev->interface); 698 + if(is_present(dev)) 699 + usb_autopm_put_interface(dev->interface); 703 700 704 701 return 0; 705 702 } ··· 708 713 unsigned long flags; 709 714 struct stk_sio_buffer *sbuf; 710 715 struct stk_camera *dev = fp->private_data; 711 - 712 - if (dev == NULL) 713 - return -EIO; 714 716 715 717 if (!is_present(dev)) 716 718 return -EIO; ··· 764 772 static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait) 765 773 { 766 774 struct stk_camera *dev = fp->private_data; 767 - 768 - if (dev == NULL) 769 - return -ENODEV; 770 775 771 776 poll_wait(fp, &dev->wait_frame, wait); 772 777 ··· 1425 1436 wake_up_interruptible(&dev->wait_frame); 1426 1437 stk_remove_sysfs_files(&dev->vdev); 1427 1438 1428 - STK_INFO("Syntek USB2.0 Camera release resources" 1439 + STK_INFO("Syntek USB2.0 Camera release resources " 1429 1440 "video device /dev/video%d\n", dev->vdev.minor); 1430 1441 1431 1442 video_unregister_device(&dev->vdev);
-1
drivers/media/video/stk-webcam.h
··· 122 122 123 123 #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev) 124 124 125 - void stk_camera_delete(struct kref *); 126 125 int stk_camera_write_reg(struct stk_camera *, u16, u8); 127 126 int stk_camera_read_reg(struct stk_camera *, u16, int *); 128 127
+1 -1
drivers/media/video/tveeprom.c
··· 242 242 { TUNER_ABSENT, "TCL M2523_3DBH_E"}, 243 243 { TUNER_ABSENT, "TCL M2523_3DIH_E"}, 244 244 { TUNER_ABSENT, "TCL MFPE05_2_U"}, 245 - { TUNER_PHILIPS_FMD1216ME_MK3, "Philips FMD1216MEX"}, 245 + { TUNER_PHILIPS_FMD1216MEX_MK3, "Philips FMD1216MEX"}, 246 246 { TUNER_ABSENT, "Philips FRH2036B"}, 247 247 { TUNER_ABSENT, "Panasonic ENGF75_01GF"}, 248 248 { TUNER_ABSENT, "MaxLinear MXL5005"},
+170 -37
drivers/media/video/videobuf-dvb.c
··· 126 126 mutex_lock(&dvb->lock); 127 127 dvb->nfeeds--; 128 128 if (0 == dvb->nfeeds && NULL != dvb->thread) { 129 - // FIXME: cx8802_cancel_buffers(dev); 130 129 err = kthread_stop(dvb->thread); 131 130 dvb->thread = NULL; 132 131 } ··· 133 134 return err; 134 135 } 135 136 136 - /* ------------------------------------------------------------------ */ 137 - 138 - int videobuf_dvb_register(struct videobuf_dvb *dvb, 137 + static int videobuf_dvb_register_adapter(struct videobuf_dvb_frontends *fe, 139 138 struct module *module, 140 139 void *adapter_priv, 141 140 struct device *device, 142 - short *adapter_nr) 141 + char *adapter_name, 142 + short *adapter_nr, 143 + int mfe_shared) 143 144 { 144 145 int result; 145 146 146 - mutex_init(&dvb->lock); 147 + mutex_init(&fe->lock); 147 148 148 149 /* register adapter */ 149 - result = dvb_register_adapter(&dvb->adapter, dvb->name, module, device, 150 - adapter_nr); 150 + result = dvb_register_adapter(&fe->adapter, adapter_name, module, 151 + device, adapter_nr); 151 152 if (result < 0) { 152 153 printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", 153 - dvb->name, result); 154 - goto fail_adapter; 154 + adapter_name, result); 155 155 } 156 - dvb->adapter.priv = adapter_priv; 156 + fe->adapter.priv = adapter_priv; 157 + fe->adapter.mfe_shared = mfe_shared; 158 + 159 + return result; 160 + } 161 + 162 + static int videobuf_dvb_register_frontend(struct dvb_adapter *adapter, 163 + struct videobuf_dvb *dvb) 164 + { 165 + int result; 157 166 158 167 /* register frontend */ 159 - result = dvb_register_frontend(&dvb->adapter, dvb->frontend); 168 + result = dvb_register_frontend(adapter, dvb->frontend); 160 169 if (result < 0) { 161 170 printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", 162 171 dvb->name, result); ··· 190 183 dvb->dmxdev.filternum = 256; 191 184 dvb->dmxdev.demux = &dvb->demux.dmx; 192 185 dvb->dmxdev.capabilities = 0; 193 - result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); 186 + result = dvb_dmxdev_init(&dvb->dmxdev, adapter); 187 + 194 188 if (result < 0) { 195 189 printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", 196 190 dvb->name, result); ··· 222 214 } 223 215 224 216 /* register network adapter */ 225 - dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); 217 + dvb_net_init(adapter, &dvb->net, &dvb->demux.dmx); 218 + if (dvb->net.dvbdev == NULL) { 219 + result = -ENOMEM; 220 + goto fail_fe_conn; 221 + } 226 222 return 0; 227 223 228 224 fail_fe_conn: ··· 241 229 dvb_unregister_frontend(dvb->frontend); 242 230 fail_frontend: 243 231 dvb_frontend_detach(dvb->frontend); 244 - dvb_unregister_adapter(&dvb->adapter); 245 - fail_adapter: 232 + dvb->frontend = NULL; 233 + 246 234 return result; 247 235 } 248 236 249 - void videobuf_dvb_unregister(struct videobuf_dvb *dvb) 250 - { 251 - dvb_net_release(&dvb->net); 252 - dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); 253 - dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); 254 - dvb_dmxdev_release(&dvb->dmxdev); 255 - dvb_dmx_release(&dvb->demux); 256 - dvb_unregister_frontend(dvb->frontend); 257 - dvb_frontend_detach(dvb->frontend); 258 - dvb_unregister_adapter(&dvb->adapter); 259 - } 260 - 261 - EXPORT_SYMBOL(videobuf_dvb_register); 262 - EXPORT_SYMBOL(videobuf_dvb_unregister); 263 - 264 237 /* ------------------------------------------------------------------ */ 265 - /* 266 - * Local variables: 267 - * c-basic-offset: 8 268 - * compile-command: "make DVB=1" 269 - * End: 270 - */ 238 + /* Register a single adapter and one or more frontends */ 239 + int videobuf_dvb_register_bus(struct videobuf_dvb_frontends *f, 240 + struct module *module, 241 + void *adapter_priv, 242 + struct device *device, 243 + short *adapter_nr, 244 + int mfe_shared) 245 + { 246 + struct list_head *list, *q; 247 + struct videobuf_dvb_frontend *fe; 248 + int res; 249 + 250 + fe = videobuf_dvb_get_frontend(f, 1); 251 + if (!fe) { 252 + printk(KERN_WARNING "Unable to register the adapter which has no frontends\n"); 253 + return -EINVAL; 254 + } 255 + 256 + /* Bring up the adapter */ 257 + res = videobuf_dvb_register_adapter(f, module, adapter_priv, device, 258 + fe->dvb.name, adapter_nr, mfe_shared); 259 + if (res < 0) { 260 + printk(KERN_WARNING "videobuf_dvb_register_adapter failed (errno = %d)\n", res); 261 + return res; 262 + } 263 + 264 + /* Attach all of the frontends to the adapter */ 265 + mutex_lock(&f->lock); 266 + list_for_each_safe(list, q, &f->felist) { 267 + fe = list_entry(list, struct videobuf_dvb_frontend, felist); 268 + res = videobuf_dvb_register_frontend(&f->adapter, &fe->dvb); 269 + if (res < 0) { 270 + printk(KERN_WARNING "%s: videobuf_dvb_register_frontend failed (errno = %d)\n", 271 + fe->dvb.name, res); 272 + goto err; 273 + } 274 + } 275 + mutex_unlock(&f->lock); 276 + return 0; 277 + 278 + err: 279 + mutex_unlock(&f->lock); 280 + videobuf_dvb_unregister_bus(f); 281 + return res; 282 + } 283 + EXPORT_SYMBOL(videobuf_dvb_register_bus); 284 + 285 + void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f) 286 + { 287 + struct list_head *list, *q; 288 + struct videobuf_dvb_frontend *fe; 289 + 290 + mutex_lock(&f->lock); 291 + list_for_each_safe(list, q, &f->felist) { 292 + fe = list_entry(list, struct videobuf_dvb_frontend, felist); 293 + if (fe->dvb.net.dvbdev) { 294 + dvb_net_release(&fe->dvb.net); 295 + fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx, 296 + &fe->dvb.fe_mem); 297 + fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx, 298 + &fe->dvb.fe_hw); 299 + dvb_dmxdev_release(&fe->dvb.dmxdev); 300 + dvb_dmx_release(&fe->dvb.demux); 301 + dvb_unregister_frontend(fe->dvb.frontend); 302 + } 303 + if (fe->dvb.frontend) 304 + /* always allocated, may have been reset */ 305 + dvb_frontend_detach(fe->dvb.frontend); 306 + list_del(list); 307 + kfree(fe); 308 + } 309 + mutex_unlock(&f->lock); 310 + 311 + dvb_unregister_adapter(&f->adapter); 312 + } 313 + EXPORT_SYMBOL(videobuf_dvb_unregister_bus); 314 + 315 + struct videobuf_dvb_frontend *videobuf_dvb_get_frontend( 316 + struct videobuf_dvb_frontends *f, int id) 317 + { 318 + struct list_head *list, *q; 319 + struct videobuf_dvb_frontend *fe, *ret = NULL; 320 + 321 + mutex_lock(&f->lock); 322 + 323 + list_for_each_safe(list, q, &f->felist) { 324 + fe = list_entry(list, struct videobuf_dvb_frontend, felist); 325 + if (fe->id == id) { 326 + ret = fe; 327 + break; 328 + } 329 + } 330 + 331 + mutex_unlock(&f->lock); 332 + 333 + return ret; 334 + } 335 + EXPORT_SYMBOL(videobuf_dvb_get_frontend); 336 + 337 + int videobuf_dvb_find_frontend(struct videobuf_dvb_frontends *f, 338 + struct dvb_frontend *p) 339 + { 340 + struct list_head *list, *q; 341 + struct videobuf_dvb_frontend *fe = NULL; 342 + int ret = 0; 343 + 344 + mutex_lock(&f->lock); 345 + 346 + list_for_each_safe(list, q, &f->felist) { 347 + fe = list_entry(list, struct videobuf_dvb_frontend, felist); 348 + if (fe->dvb.frontend == p) { 349 + ret = fe->id; 350 + break; 351 + } 352 + } 353 + 354 + mutex_unlock(&f->lock); 355 + 356 + return ret; 357 + } 358 + EXPORT_SYMBOL(videobuf_dvb_find_frontend); 359 + 360 + struct videobuf_dvb_frontend *videobuf_dvb_alloc_frontend( 361 + struct videobuf_dvb_frontends *f, int id) 362 + { 363 + struct videobuf_dvb_frontend *fe; 364 + 365 + fe = kzalloc(sizeof(struct videobuf_dvb_frontend), GFP_KERNEL); 366 + if (fe == NULL) 367 + goto fail_alloc; 368 + 369 + fe->id = id; 370 + mutex_init(&fe->dvb.lock); 371 + 372 + mutex_lock(&f->lock); 373 + list_add_tail(&fe->felist, &f->felist); 374 + mutex_unlock(&f->lock); 375 + 376 + fail_alloc: 377 + return fe; 378 + } 379 + EXPORT_SYMBOL(videobuf_dvb_alloc_frontend);
+210 -74
drivers/media/video/vivi.c
··· 128 128 int depth; 129 129 }; 130 130 131 - static struct vivi_fmt format = { 132 - .name = "4:2:2, packed, YUYV", 133 - .fourcc = V4L2_PIX_FMT_YUYV, 134 - .depth = 16, 131 + static struct vivi_fmt formats[] = { 132 + { 133 + .name = "4:2:2, packed, YUYV", 134 + .fourcc = V4L2_PIX_FMT_YUYV, 135 + .depth = 16, 136 + }, 137 + { 138 + .name = "4:2:2, packed, UYVY", 139 + .fourcc = V4L2_PIX_FMT_UYVY, 140 + .depth = 16, 141 + }, 142 + { 143 + .name = "RGB565 (LE)", 144 + .fourcc = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */ 145 + .depth = 16, 146 + }, 147 + { 148 + .name = "RGB565 (BE)", 149 + .fourcc = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */ 150 + .depth = 16, 151 + }, 152 + { 153 + .name = "RGB555 (LE)", 154 + .fourcc = V4L2_PIX_FMT_RGB555, /* gggbbbbb arrrrrgg */ 155 + .depth = 16, 156 + }, 157 + { 158 + .name = "RGB555 (BE)", 159 + .fourcc = V4L2_PIX_FMT_RGB555X, /* arrrrrgg gggbbbbb */ 160 + .depth = 16, 161 + }, 135 162 }; 163 + 164 + static struct vivi_fmt *get_format(struct v4l2_format *f) 165 + { 166 + struct vivi_fmt *fmt; 167 + unsigned int k; 168 + 169 + for (k = 0; k < ARRAY_SIZE(formats); k++) { 170 + fmt = &formats[k]; 171 + if (fmt->fourcc == f->fmt.pix.pixelformat) 172 + break; 173 + } 174 + 175 + if (k == ARRAY_SIZE(formats)) 176 + return NULL; 177 + 178 + return &formats[k]; 179 + } 136 180 137 181 struct sg_to_addr { 138 182 int pos; ··· 234 190 struct videobuf_queue vb_vidq; 235 191 236 192 enum v4l2_buf_type type; 193 + unsigned char bars[8][3]; 237 194 }; 238 195 239 196 /* ------------------------------------------------------------------ ··· 279 234 #define TSTAMP_MAX_Y TSTAMP_MIN_Y+15 280 235 #define TSTAMP_MIN_X 64 281 236 282 - static void gen_line(char *basep, int inipos, int wmax, 237 + static void gen_twopix(struct vivi_fh *fh, unsigned char *buf, int colorpos) 238 + { 239 + unsigned char r_y, g_u, b_v; 240 + unsigned char *p; 241 + int color; 242 + 243 + r_y = fh->bars[colorpos][0]; /* R or precalculated Y */ 244 + g_u = fh->bars[colorpos][1]; /* G or precalculated U */ 245 + b_v = fh->bars[colorpos][2]; /* B or precalculated V */ 246 + 247 + for (color = 0; color < 4; color++) { 248 + p = buf + color; 249 + 250 + switch (fh->fmt->fourcc) { 251 + case V4L2_PIX_FMT_YUYV: 252 + switch (color) { 253 + case 0: 254 + case 2: 255 + *p = r_y; 256 + break; 257 + case 1: 258 + *p = g_u; 259 + break; 260 + case 3: 261 + *p = b_v; 262 + break; 263 + } 264 + break; 265 + case V4L2_PIX_FMT_UYVY: 266 + switch (color) { 267 + case 1: 268 + case 3: 269 + *p = r_y; 270 + break; 271 + case 0: 272 + *p = g_u; 273 + break; 274 + case 2: 275 + *p = b_v; 276 + break; 277 + } 278 + break; 279 + case V4L2_PIX_FMT_RGB565: 280 + switch (color) { 281 + case 0: 282 + case 2: 283 + *p = (g_u << 5) | b_v; 284 + break; 285 + case 1: 286 + case 3: 287 + *p = (r_y << 3) | (g_u >> 3); 288 + break; 289 + } 290 + break; 291 + case V4L2_PIX_FMT_RGB565X: 292 + switch (color) { 293 + case 0: 294 + case 2: 295 + *p = (r_y << 3) | (g_u >> 3); 296 + break; 297 + case 1: 298 + case 3: 299 + *p = (g_u << 5) | b_v; 300 + break; 301 + } 302 + break; 303 + case V4L2_PIX_FMT_RGB555: 304 + switch (color) { 305 + case 0: 306 + case 2: 307 + *p = (g_u << 5) | b_v; 308 + break; 309 + case 1: 310 + case 3: 311 + *p = (r_y << 2) | (g_u >> 3); 312 + break; 313 + } 314 + break; 315 + case V4L2_PIX_FMT_RGB555X: 316 + switch (color) { 317 + case 0: 318 + case 2: 319 + *p = (r_y << 2) | (g_u >> 3); 320 + break; 321 + case 1: 322 + case 3: 323 + *p = (g_u << 5) | b_v; 324 + break; 325 + } 326 + break; 327 + } 328 + } 329 + } 330 + 331 + static void gen_line(struct vivi_fh *fh, char *basep, int inipos, int wmax, 283 332 int hmax, int line, int count, char *timestr) 284 333 { 285 - int w, i, j, y; 334 + int w, i, j; 286 335 int pos = inipos; 287 - char *p, *s; 288 - u8 chr, r, g, b, color; 336 + char *s; 337 + u8 chr; 289 338 290 339 /* We will just duplicate the second pixel at the packet */ 291 340 wmax /= 2; ··· 387 248 /* Generate a standard color bar pattern */ 388 249 for (w = 0; w < wmax; w++) { 389 250 int colorpos = ((w + count) * 8/(wmax + 1)) % 8; 390 - r = bars[colorpos][0]; 391 - g = bars[colorpos][1]; 392 - b = bars[colorpos][2]; 393 251 394 - for (color = 0; color < 4; color++) { 395 - p = basep + pos; 396 - 397 - switch (color) { 398 - case 0: 399 - case 2: 400 - *p = TO_Y(r, g, b); /* Luma */ 401 - break; 402 - case 1: 403 - *p = TO_U(r, g, b); /* Cb */ 404 - break; 405 - case 3: 406 - *p = TO_V(r, g, b); /* Cr */ 407 - break; 408 - } 409 - pos++; 410 - } 252 + gen_twopix(fh, basep + pos, colorpos); 253 + pos += 4; /* only 16 bpp supported for now */ 411 254 } 412 255 413 256 /* Checks if it is possible to show timestamp */ ··· 404 283 for (s = timestr; *s; s++) { 405 284 chr = rom8x16_bits[(*s-0x30)*16+line-TSTAMP_MIN_Y]; 406 285 for (i = 0; i < 7; i++) { 407 - if (chr & 1 << (7 - i)) { 408 - /* Font color*/ 409 - r = 0; 410 - g = 198; 411 - b = 0; 412 - } else { 413 - /* Background color */ 414 - r = bars[BLACK][0]; 415 - g = bars[BLACK][1]; 416 - b = bars[BLACK][2]; 417 - } 418 - 419 286 pos = inipos + j * 2; 420 - for (color = 0; color < 4; color++) { 421 - p = basep + pos; 422 - 423 - y = TO_Y(r, g, b); 424 - 425 - switch (color) { 426 - case 0: 427 - case 2: 428 - *p = TO_Y(r, g, b); /* Luma */ 429 - break; 430 - case 1: 431 - *p = TO_U(r, g, b); /* Cb */ 432 - break; 433 - case 3: 434 - *p = TO_V(r, g, b); /* Cr */ 435 - break; 436 - } 437 - pos++; 438 - } 287 + /* Draw white font on black background */ 288 + if (chr & 1 << (7 - i)) 289 + gen_twopix(fh, basep + pos, WHITE); 290 + else 291 + gen_twopix(fh, basep + pos, BLACK); 439 292 j++; 440 293 } 441 294 } ··· 419 324 return; 420 325 } 421 326 422 - static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) 327 + static void vivi_fillbuff(struct vivi_fh *fh, struct vivi_buffer *buf) 423 328 { 329 + struct vivi_dev *dev = fh->dev; 424 330 int h , pos = 0; 425 331 int hmax = buf->vb.height; 426 332 int wmax = buf->vb.width; ··· 437 341 return; 438 342 439 343 for (h = 0; h < hmax; h++) { 440 - gen_line(tmpbuf, 0, wmax, hmax, h, dev->mv_count, 344 + gen_line(fh, tmpbuf, 0, wmax, hmax, h, dev->mv_count, 441 345 dev->timestr); 442 346 memcpy(vbuf + pos, tmpbuf, wmax * 2); 443 347 pos += wmax*2; ··· 506 410 do_gettimeofday(&buf->vb.ts); 507 411 508 412 /* Fill buffer */ 509 - vivi_fillbuff(dev, buf); 413 + vivi_fillbuff(fh, buf); 510 414 dprintk(dev, 1, "filled buffer %p\n", buf); 511 415 512 416 wake_up(&buf->vb.done); ··· 732 636 static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, 733 637 struct v4l2_fmtdesc *f) 734 638 { 735 - if (f->index > 0) 639 + struct vivi_fmt *fmt; 640 + 641 + if (f->index >= ARRAY_SIZE(formats)) 736 642 return -EINVAL; 737 643 738 - strlcpy(f->description, format.name, sizeof(f->description)); 739 - f->pixelformat = format.fourcc; 644 + fmt = &formats[f->index]; 645 + 646 + strlcpy(f->description, fmt->name, sizeof(f->description)); 647 + f->pixelformat = fmt->fourcc; 740 648 return 0; 741 649 } 742 650 ··· 770 670 enum v4l2_field field; 771 671 unsigned int maxw, maxh; 772 672 773 - if (format.fourcc != f->fmt.pix.pixelformat) { 774 - dprintk(dev, 1, "Fourcc format (0x%08x) invalid. " 775 - "Driver accepts only 0x%08x\n", 776 - f->fmt.pix.pixelformat, format.fourcc); 673 + fmt = get_format(f); 674 + if (!fmt) { 675 + dprintk(dev, 1, "Fourcc format (0x%08x) invalid.\n", 676 + f->fmt.pix.pixelformat); 777 677 return -EINVAL; 778 678 } 779 - fmt = &format; 780 679 781 680 field = f->fmt.pix.field; 782 681 ··· 813 714 { 814 715 struct vivi_fh *fh = priv; 815 716 struct videobuf_queue *q = &fh->vb_vidq; 717 + unsigned char r, g, b; 718 + int k, is_yuv; 816 719 817 720 int ret = vidioc_try_fmt_vid_cap(file, fh, f); 818 721 if (ret < 0) ··· 828 727 goto out; 829 728 } 830 729 831 - fh->fmt = &format; 730 + fh->fmt = get_format(f); 832 731 fh->width = f->fmt.pix.width; 833 732 fh->height = f->fmt.pix.height; 834 733 fh->vb_vidq.field = f->fmt.pix.field; 835 734 fh->type = f->type; 735 + 736 + /* precalculate color bar values to speed up rendering */ 737 + for (k = 0; k < 8; k++) { 738 + r = bars[k][0]; 739 + g = bars[k][1]; 740 + b = bars[k][2]; 741 + is_yuv = 0; 742 + 743 + switch (fh->fmt->fourcc) { 744 + case V4L2_PIX_FMT_YUYV: 745 + case V4L2_PIX_FMT_UYVY: 746 + is_yuv = 1; 747 + break; 748 + case V4L2_PIX_FMT_RGB565: 749 + case V4L2_PIX_FMT_RGB565X: 750 + r >>= 3; 751 + g >>= 2; 752 + b >>= 3; 753 + break; 754 + case V4L2_PIX_FMT_RGB555: 755 + case V4L2_PIX_FMT_RGB555X: 756 + r >>= 3; 757 + g >>= 3; 758 + b >>= 3; 759 + break; 760 + } 761 + 762 + if (is_yuv) { 763 + fh->bars[k][0] = TO_Y(r, g, b); /* Luma */ 764 + fh->bars[k][1] = TO_U(r, g, b); /* Cb */ 765 + fh->bars[k][2] = TO_V(r, g, b); /* Cr */ 766 + } else { 767 + fh->bars[k][0] = r; 768 + fh->bars[k][1] = g; 769 + fh->bars[k][2] = b; 770 + } 771 + } 836 772 837 773 ret = 0; 838 774 out: ··· 1024 886 File operations for the device 1025 887 ------------------------------------------------------------------*/ 1026 888 1027 - #define line_buf_size(norm) (norm_maxw(norm)*(format.depth+7)/8) 1028 - 1029 889 static int vivi_open(struct inode *inode, struct file *file) 1030 890 { 1031 891 int minor = iminor(inode); ··· 1072 936 fh->dev = dev; 1073 937 1074 938 fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1075 - fh->fmt = &format; 939 + fh->fmt = &formats[0]; 1076 940 fh->width = 640; 1077 941 fh->height = 480; 1078 942
+92 -238
drivers/media/video/vpx3220.c
··· 22 22 #include <linux/init.h> 23 23 #include <linux/delay.h> 24 24 #include <linux/types.h> 25 - #include <linux/slab.h> 26 - 27 - #include <asm/io.h> 28 25 #include <asm/uaccess.h> 29 - 30 26 #include <linux/i2c.h> 31 - 32 - #define I2C_NAME(x) (x)->name 33 - 34 - #include <linux/videodev.h> 35 27 #include <media/v4l2-common.h> 28 + #include <media/v4l2-i2c-drv-legacy.h> 29 + #include <linux/videodev.h> 36 30 #include <linux/video_decoder.h> 37 31 38 - #define I2C_VPX3220 0x86 39 - #define VPX3220_DEBUG KERN_DEBUG "vpx3220: " 32 + MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video decoder driver"); 33 + MODULE_AUTHOR("Laurent Pinchart"); 34 + MODULE_LICENSE("GPL"); 40 35 41 36 static int debug; 42 37 module_param(debug, int, 0); 43 38 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 44 - 45 - #define dprintk(num, format, args...) \ 46 - do { \ 47 - if (debug >= num) \ 48 - printk(format, ##args); \ 49 - } while (0) 50 39 51 40 #define VPX_TIMEOUT_COUNT 10 52 41 ··· 56 67 static char *inputs[] = { "internal", "composite", "svideo" }; 57 68 58 69 /* ----------------------------------------------------------------------- */ 59 - static inline int 60 - vpx3220_write (struct i2c_client *client, 61 - u8 reg, 62 - u8 value) 70 + 71 + static inline int vpx3220_write(struct i2c_client *client, u8 reg, u8 value) 63 72 { 64 73 struct vpx3220 *decoder = i2c_get_clientdata(client); 65 74 ··· 65 78 return i2c_smbus_write_byte_data(client, reg, value); 66 79 } 67 80 68 - static inline int 69 - vpx3220_read (struct i2c_client *client, 70 - u8 reg) 81 + static inline int vpx3220_read(struct i2c_client *client, u8 reg) 71 82 { 72 83 return i2c_smbus_read_byte_data(client, reg); 73 84 } 74 85 75 - static int 76 - vpx3220_fp_status (struct i2c_client *client) 86 + static int vpx3220_fp_status(struct i2c_client *client) 77 87 { 78 88 unsigned char status; 79 89 unsigned int i; ··· 90 106 return -1; 91 107 } 92 108 93 - static int 94 - vpx3220_fp_write (struct i2c_client *client, 95 - u8 fpaddr, 96 - u16 data) 109 + static int vpx3220_fp_write(struct i2c_client *client, u8 fpaddr, u16 data) 97 110 { 98 111 /* Write the 16-bit address to the FPWR register */ 99 112 if (i2c_smbus_write_word_data(client, 0x27, swab16(fpaddr)) == -1) { 100 - dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); 113 + v4l_dbg(1, debug, client, "%s: failed\n", __func__); 101 114 return -1; 102 115 } 103 116 ··· 103 122 104 123 /* Write the 16-bit data to the FPDAT register */ 105 124 if (i2c_smbus_write_word_data(client, 0x28, swab16(data)) == -1) { 106 - dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); 125 + v4l_dbg(1, debug, client, "%s: failed\n", __func__); 107 126 return -1; 108 127 } 109 128 110 129 return 0; 111 130 } 112 131 113 - static u16 114 - vpx3220_fp_read (struct i2c_client *client, 115 - u16 fpaddr) 132 + static u16 vpx3220_fp_read(struct i2c_client *client, u16 fpaddr) 116 133 { 117 134 s16 data; 118 135 119 136 /* Write the 16-bit address to the FPRD register */ 120 137 if (i2c_smbus_write_word_data(client, 0x26, swab16(fpaddr)) == -1) { 121 - dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); 138 + v4l_dbg(1, debug, client, "%s: failed\n", __func__); 122 139 return -1; 123 140 } 124 141 ··· 126 147 /* Read the 16-bit data from the FPDAT register */ 127 148 data = i2c_smbus_read_word_data(client, 0x28); 128 149 if (data == -1) { 129 - dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); 150 + v4l_dbg(1, debug, client, "%s: failed\n", __func__); 130 151 return -1; 131 152 } 132 153 133 154 return swab16(data); 134 155 } 135 156 136 - static int 137 - vpx3220_write_block (struct i2c_client *client, 138 - const u8 *data, 139 - unsigned int len) 157 + static int vpx3220_write_block(struct i2c_client *client, const u8 *data, unsigned int len) 140 158 { 141 159 u8 reg; 142 160 int ret = -1; 143 161 144 162 while (len >= 2) { 145 163 reg = *data++; 146 - if ((ret = 147 - vpx3220_write(client, reg, *data++)) < 0) 164 + ret = vpx3220_write(client, reg, *data++); 165 + if (ret < 0) 148 166 break; 149 167 len -= 2; 150 168 } ··· 149 173 return ret; 150 174 } 151 175 152 - static int 153 - vpx3220_write_fp_block (struct i2c_client *client, 154 - const u16 *data, 155 - unsigned int len) 176 + static int vpx3220_write_fp_block(struct i2c_client *client, 177 + const u16 *data, unsigned int len) 156 178 { 157 179 u8 reg; 158 180 int ret = 0; ··· 259 285 0x4b, 0x298, /* PLL gain */ 260 286 }; 261 287 262 - static void 263 - vpx3220_dump_i2c (struct i2c_client *client) 288 + static void vpx3220_dump_i2c(struct i2c_client *client) 264 289 { 265 290 int len = sizeof(init_common); 266 291 const unsigned char *data = init_common; 267 292 268 293 while (len > 1) { 269 - dprintk(1, 270 - KERN_DEBUG "vpx3216b i2c reg 0x%02x data 0x%02x\n", 294 + v4l_dbg(1, debug, client, "i2c reg 0x%02x data 0x%02x\n", 271 295 *data, vpx3220_read(client, *data)); 272 296 data += 2; 273 297 len -= 2; 274 298 } 275 299 } 276 300 277 - static int 278 - vpx3220_command (struct i2c_client *client, 279 - unsigned int cmd, 280 - void *arg) 301 + static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) 281 302 { 282 303 struct vpx3220 *decoder = i2c_get_clientdata(client); 283 304 ··· 284 315 vpx3220_write_fp_block(client, init_fp, 285 316 sizeof(init_fp) >> 1); 286 317 switch (decoder->norm) { 287 - 288 318 case VIDEO_MODE_NTSC: 289 319 vpx3220_write_fp_block(client, init_ntsc, 290 320 sizeof(init_ntsc) >> 1); ··· 302 334 sizeof(init_pal) >> 1); 303 335 break; 304 336 } 305 - } 306 337 break; 338 + } 307 339 308 340 case DECODER_DUMP: 309 341 { 310 342 vpx3220_dump_i2c(client); 311 - } 312 343 break; 344 + } 313 345 314 346 case DECODER_GET_CAPABILITIES: 315 347 { 316 348 struct video_decoder_capability *cap = arg; 317 349 318 - dprintk(1, KERN_DEBUG "%s: DECODER_GET_CAPABILITIES\n", 319 - I2C_NAME(client)); 350 + v4l_dbg(1, debug, client, "DECODER_GET_CAPABILITIES\n"); 320 351 321 352 cap->flags = VIDEO_DECODER_PAL | 322 353 VIDEO_DECODER_NTSC | ··· 324 357 VIDEO_DECODER_CCIR; 325 358 cap->inputs = 3; 326 359 cap->outputs = 1; 327 - } 328 360 break; 361 + } 329 362 330 363 case DECODER_GET_STATUS: 331 364 { 332 365 int res = 0, status; 333 366 334 - dprintk(1, KERN_INFO "%s: DECODER_GET_STATUS\n", 335 - I2C_NAME(client)); 367 + v4l_dbg(1, debug, client, "DECODER_GET_STATUS\n"); 336 368 337 369 status = vpx3220_fp_read(client, 0x0f3); 338 370 339 - dprintk(1, KERN_INFO "%s: status: 0x%04x\n", I2C_NAME(client), 340 - status); 371 + v4l_dbg(1, debug, client, "status: 0x%04x\n", status); 341 372 342 373 if (status < 0) 343 374 return status; ··· 344 379 res |= DECODER_STATUS_GOOD | DECODER_STATUS_COLOR; 345 380 346 381 switch (status & 0x18) { 347 - 348 382 case 0x00: 349 383 case 0x10: 350 384 case 0x14: ··· 364 400 } 365 401 366 402 *(int *) arg = res; 367 - } 368 403 break; 404 + } 369 405 370 406 case DECODER_SET_NORM: 371 407 { ··· 377 413 choosen video norm */ 378 414 temp_input = vpx3220_fp_read(client, 0xf2); 379 415 380 - dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n", 381 - I2C_NAME(client), *iarg); 416 + v4l_dbg(1, debug, client, "DECODER_SET_NORM %d\n", *iarg); 382 417 switch (*iarg) { 383 - 384 418 case VIDEO_MODE_NTSC: 385 419 vpx3220_write_fp_block(client, init_ntsc, 386 420 sizeof(init_ntsc) >> 1); 387 - dprintk(1, KERN_INFO "%s: norm switched to NTSC\n", 388 - I2C_NAME(client)); 421 + v4l_dbg(1, debug, client, "norm switched to NTSC\n"); 389 422 break; 390 423 391 424 case VIDEO_MODE_PAL: 392 425 vpx3220_write_fp_block(client, init_pal, 393 426 sizeof(init_pal) >> 1); 394 - dprintk(1, KERN_INFO "%s: norm switched to PAL\n", 395 - I2C_NAME(client)); 427 + v4l_dbg(1, debug, client, "norm switched to PAL\n"); 396 428 break; 397 429 398 430 case VIDEO_MODE_SECAM: 399 431 vpx3220_write_fp_block(client, init_secam, 400 432 sizeof(init_secam) >> 1); 401 - dprintk(1, KERN_INFO "%s: norm switched to SECAM\n", 402 - I2C_NAME(client)); 433 + v4l_dbg(1, debug, client, "norm switched to SECAM\n"); 403 434 break; 404 435 405 436 case VIDEO_MODE_AUTO: 406 437 /* FIXME This is only preliminary support */ 407 438 data = vpx3220_fp_read(client, 0xf2) & 0x20; 408 439 vpx3220_fp_write(client, 0xf2, 0x00c0 | data); 409 - dprintk(1, KERN_INFO "%s: norm switched to Auto\n", 410 - I2C_NAME(client)); 440 + v4l_dbg(1, debug, client, "norm switched to AUTO\n"); 411 441 break; 412 442 413 443 default: 414 444 return -EINVAL; 415 - 416 445 } 417 446 decoder->norm = *iarg; 418 447 419 448 /* And here we set the backed up video input again */ 420 449 vpx3220_fp_write(client, 0xf2, temp_input | 0x0010); 421 450 udelay(10); 422 - } 423 451 break; 452 + } 424 453 425 454 case DECODER_SET_INPUT: 426 455 { ··· 432 475 if (*iarg < 0 || *iarg > 2) 433 476 return -EINVAL; 434 477 435 - dprintk(1, KERN_INFO "%s: input switched to %s\n", 436 - I2C_NAME(client), inputs[*iarg]); 478 + v4l_dbg(1, debug, client, "input switched to %s\n", inputs[*iarg]); 437 479 438 480 vpx3220_write(client, 0x33, input[*iarg][0]); 439 481 ··· 444 488 data | (input[*iarg][1] << 5) | 0x0010); 445 489 446 490 udelay(10); 447 - } 448 491 break; 492 + } 449 493 450 494 case DECODER_SET_OUTPUT: 451 495 { ··· 455 499 if (*iarg != 0) { 456 500 return -EINVAL; 457 501 } 458 - } 459 502 break; 503 + } 460 504 461 505 case DECODER_ENABLE_OUTPUT: 462 506 { 463 507 int *iarg = arg; 464 508 465 - dprintk(1, KERN_DEBUG "%s: DECODER_ENABLE_OUTPUT %d\n", 466 - I2C_NAME(client), *iarg); 509 + v4l_dbg(1, debug, client, "DECODER_ENABLE_OUTPUT %d\n", *iarg); 467 510 468 511 vpx3220_write(client, 0xf2, (*iarg ? 0x1b : 0x00)); 469 - } 470 512 break; 513 + } 471 514 472 515 case DECODER_SET_PICTURE: 473 516 { ··· 497 542 vpx3220_fp_write(client, 0x1c, 498 543 ((decoder->hue - 32768) >> 6) & 0xFFF); 499 544 } 500 - } 501 545 break; 546 + } 502 547 503 548 default: 504 549 return -EINVAL; ··· 507 552 return 0; 508 553 } 509 554 510 - static int 511 - vpx3220_init_client (struct i2c_client *client) 555 + static int vpx3220_init_client(struct i2c_client *client) 512 556 { 513 557 vpx3220_write_block(client, init_common, sizeof(init_common)); 514 558 vpx3220_write_fp_block(client, init_fp, sizeof(init_fp) >> 1); ··· 521 567 * Client management code 522 568 */ 523 569 524 - /* 525 - * Generic i2c probe 526 - * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 527 - */ 528 - static unsigned short normal_i2c[] = 529 - { I2C_VPX3220 >> 1, (I2C_VPX3220 >> 1) + 4, 530 - I2C_CLIENT_END 531 - }; 570 + static unsigned short normal_i2c[] = { 0x86 >> 1, 0x8e >> 1, I2C_CLIENT_END }; 532 571 533 - static unsigned short ignore = I2C_CLIENT_END; 572 + I2C_CLIENT_INSMOD; 534 573 535 - static struct i2c_client_address_data addr_data = { 536 - .normal_i2c = normal_i2c, 537 - .probe = &ignore, 538 - .ignore = &ignore, 539 - }; 540 - 541 - static struct i2c_driver vpx3220_i2c_driver; 542 - 543 - static int 544 - vpx3220_detach_client (struct i2c_client *client) 574 + static int vpx3220_probe(struct i2c_client *client, 575 + const struct i2c_device_id *id) 545 576 { 546 - struct vpx3220 *decoder = i2c_get_clientdata(client); 547 - int err; 548 - 549 - err = i2c_detach_client(client); 550 - if (err) { 551 - return err; 552 - } 553 - 554 - kfree(decoder); 555 - kfree(client); 556 - 557 - return 0; 558 - } 559 - 560 - static int 561 - vpx3220_detect_client (struct i2c_adapter *adapter, 562 - int address, 563 - int kind) 564 - { 565 - int err; 566 - struct i2c_client *client; 567 577 struct vpx3220 *decoder; 568 - 569 - dprintk(1, VPX3220_DEBUG "%s\n", __func__); 578 + const char *name = NULL; 579 + u8 ver; 580 + u16 pn; 570 581 571 582 /* Check if the adapter supports the needed features */ 572 - if (!i2c_check_functionality 573 - (adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) 574 - return 0; 575 - 576 - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 577 - if (client == NULL) { 578 - return -ENOMEM; 579 - } 580 - 581 - client->addr = address; 582 - client->adapter = adapter; 583 - client->driver = &vpx3220_i2c_driver; 584 - 585 - /* Check for manufacture ID and part number */ 586 - if (kind < 0) { 587 - u8 id; 588 - u16 pn; 589 - 590 - id = vpx3220_read(client, 0x00); 591 - if (id != 0xec) { 592 - dprintk(1, 593 - KERN_INFO 594 - "vpx3220_attach: Wrong manufacturer ID (0x%02x)\n", 595 - id); 596 - kfree(client); 597 - return 0; 598 - } 599 - 600 - pn = (vpx3220_read(client, 0x02) << 8) + 601 - vpx3220_read(client, 0x01); 602 - switch (pn) { 603 - case 0x4680: 604 - strlcpy(I2C_NAME(client), "vpx3220a", 605 - sizeof(I2C_NAME(client))); 606 - break; 607 - case 0x4260: 608 - strlcpy(I2C_NAME(client), "vpx3216b", 609 - sizeof(I2C_NAME(client))); 610 - break; 611 - case 0x4280: 612 - strlcpy(I2C_NAME(client), "vpx3214c", 613 - sizeof(I2C_NAME(client))); 614 - break; 615 - default: 616 - dprintk(1, 617 - KERN_INFO 618 - "%s: Wrong part number (0x%04x)\n", 619 - __func__, pn); 620 - kfree(client); 621 - return 0; 622 - } 623 - } else { 624 - strlcpy(I2C_NAME(client), "forced vpx32xx", 625 - sizeof(I2C_NAME(client))); 626 - } 583 + if (!i2c_check_functionality(client->adapter, 584 + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) 585 + return -ENODEV; 627 586 628 587 decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL); 629 - if (decoder == NULL) { 630 - kfree(client); 588 + if (decoder == NULL) 631 589 return -ENOMEM; 632 - } 633 590 decoder->norm = VIDEO_MODE_PAL; 634 591 decoder->input = 0; 635 592 decoder->enable = 1; ··· 550 685 decoder->sat = 32768; 551 686 i2c_set_clientdata(client, decoder); 552 687 553 - err = i2c_attach_client(client); 554 - if (err) { 555 - kfree(client); 556 - kfree(decoder); 557 - return err; 688 + ver = i2c_smbus_read_byte_data(client, 0x00); 689 + pn = (i2c_smbus_read_byte_data(client, 0x02) << 8) + 690 + i2c_smbus_read_byte_data(client, 0x01); 691 + if (ver == 0xec) { 692 + switch (pn) { 693 + case 0x4680: 694 + name = "vpx3220a"; 695 + break; 696 + case 0x4260: 697 + name = "vpx3216b"; 698 + break; 699 + case 0x4280: 700 + name = "vpx3214c"; 701 + break; 702 + } 558 703 } 559 - 560 - dprintk(1, KERN_INFO "%s: vpx32xx client found at address 0x%02x\n", 561 - I2C_NAME(client), client->addr << 1); 704 + if (name) 705 + v4l_info(client, "%s found @ 0x%x (%s)\n", name, 706 + client->addr << 1, client->adapter->name); 707 + else 708 + v4l_info(client, "chip (%02x:%04x) found @ 0x%x (%s)\n", 709 + ver, pn, client->addr << 1, client->adapter->name); 562 710 563 711 vpx3220_init_client(client); 564 - 565 712 return 0; 566 713 } 567 714 568 - static int 569 - vpx3220_attach_adapter (struct i2c_adapter *adapter) 715 + static int vpx3220_remove(struct i2c_client *client) 570 716 { 571 - int ret; 572 - 573 - ret = i2c_probe(adapter, &addr_data, &vpx3220_detect_client); 574 - dprintk(1, VPX3220_DEBUG "%s: i2c_probe returned %d\n", 575 - __func__, ret); 576 - return ret; 717 + kfree(i2c_get_clientdata(client)); 718 + return 0; 577 719 } 578 720 579 - /* ----------------------------------------------------------------------- 580 - * Driver initialization and cleanup code 581 - */ 582 - 583 - static struct i2c_driver vpx3220_i2c_driver = { 584 - .driver = { 585 - .name = "vpx3220", 586 - }, 587 - 588 - .id = I2C_DRIVERID_VPX3220, 589 - 590 - .attach_adapter = vpx3220_attach_adapter, 591 - .detach_client = vpx3220_detach_client, 592 - .command = vpx3220_command, 721 + static const struct i2c_device_id vpx3220_id[] = { 722 + { "vpx3220a", 0 }, 723 + { "vpx3216b", 0 }, 724 + { "vpx3214c", 0 }, 725 + { } 593 726 }; 727 + MODULE_DEVICE_TABLE(i2c, vpx3220_id); 594 728 595 - static int __init 596 - vpx3220_init (void) 597 - { 598 - return i2c_add_driver(&vpx3220_i2c_driver); 599 - } 600 - 601 - static void __exit 602 - vpx3220_cleanup (void) 603 - { 604 - i2c_del_driver(&vpx3220_i2c_driver); 605 - } 606 - 607 - module_init(vpx3220_init); 608 - module_exit(vpx3220_cleanup); 609 - 610 - MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video decoder driver"); 611 - MODULE_AUTHOR("Laurent Pinchart"); 612 - MODULE_LICENSE("GPL"); 729 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 730 + .name = "vpx3220", 731 + .driverid = I2C_DRIVERID_VPX3220, 732 + .command = vpx3220_command, 733 + .probe = vpx3220_probe, 734 + .remove = vpx3220_remove, 735 + .id_table = vpx3220_id, 736 + };
+1
drivers/media/video/zoran/zoran_card.c
··· 817 817 memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template, 818 818 sizeof(struct i2c_algo_bit_data)); 819 819 zr->i2c_algo.data = zr; 820 + zr->i2c_adapter.class = I2C_CLASS_TV_ANALOG; 820 821 zr->i2c_adapter.id = I2C_HW_B_ZR36067; 821 822 zr->i2c_adapter.client_register = zoran_i2c_client_register; 822 823 zr->i2c_adapter.client_unregister = zoran_i2c_client_unregister;
-1
drivers/media/video/zoran/zoran_driver.c
··· 2996 2996 break; 2997 2997 2998 2998 default: 2999 - dprintk(3, "unsupported\n"); 3000 2999 dprintk(1, 3001 3000 KERN_ERR 3002 3001 "%s: VIDIOC_S_FMT - unsupported type %d\n",
+2
include/linux/dvb/frontend.h
··· 166 166 VSB_16, 167 167 PSK_8, 168 168 APSK_16, 169 + APSK_32, 169 170 DQPSK, 170 171 } fe_modulation_t; 171 172 ··· 296 295 SYS_DVBC_ANNEX_AC, 297 296 SYS_DVBC_ANNEX_B, 298 297 SYS_DVBT, 298 + SYS_DSS, 299 299 SYS_DVBS, 300 300 SYS_DVBS2, 301 301 SYS_DVBH,
+1 -1
include/linux/i2c-id.h
··· 60 60 #define I2C_DRIVERID_WM8775 69 /* wm8775 audio processor */ 61 61 #define I2C_DRIVERID_CS53L32A 70 /* cs53l32a audio processor */ 62 62 #define I2C_DRIVERID_CX25840 71 /* cx2584x video encoder */ 63 - #define I2C_DRIVERID_SAA7127 72 /* saa7124 video encoder */ 63 + #define I2C_DRIVERID_SAA7127 72 /* saa7127 video encoder */ 64 64 #define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */ 65 65 #define I2C_DRIVERID_AKITAIOEXP 74 /* IO Expander on Sharp SL-C1000 */ 66 66 #define I2C_DRIVERID_INFRARED 75 /* I2C InfraRed on Video boards */
+11
include/media/soc_camera_platform.h
··· 1 + /* 2 + * Generic Platform Camera Driver Header 3 + * 4 + * Copyright (C) 2008 Magnus Damm 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 version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + 1 11 #ifndef __SOC_CAMERA_H__ 2 12 #define __SOC_CAMERA_H__ 3 13 ··· 19 9 unsigned long format_depth; 20 10 struct v4l2_pix_format format; 21 11 unsigned long bus_param; 12 + void (*power)(int); 22 13 int (*set_capture)(struct soc_camera_platform_info *info, int enable); 23 14 }; 24 15
+1
include/media/tuner.h
··· 123 123 #define TUNER_TEA5761 75 /* Only FM Radio Tuner */ 124 124 #define TUNER_XC5000 76 /* Xceive Silicon Tuner */ 125 125 #define TUNER_TCL_MF02GIP_5N 77 /* TCL MF02GIP_5N */ 126 + #define TUNER_PHILIPS_FMD1216MEX_MK3 78 126 127 127 128 /* tv card specific */ 128 129 #define TDA9887_PRESENT (1<<0)
+11
include/media/v4l2-i2c-drv-legacy.h
··· 21 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 22 */ 23 23 24 + /* NOTE: the full version of this header is in the v4l-dvb repository 25 + * and allows v4l i2c drivers to be compiled on older kernels as well. 26 + * The version of this header as it appears in the kernel is a stripped 27 + * version (without all the backwards compatibility stuff) and so it 28 + * looks a bit odd. 29 + * 30 + * If you look at the full version then you will understand the reason 31 + * for introducing this header since you really don't want to have all 32 + * the tricky backwards compatibility code in each and every i2c driver. 33 + */ 34 + 24 35 struct v4l2_i2c_driver_data { 25 36 const char * const name; 26 37 int driverid;
+11
include/media/v4l2-i2c-drv.h
··· 21 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 22 */ 23 23 24 + /* NOTE: the full version of this header is in the v4l-dvb repository 25 + * and allows v4l i2c drivers to be compiled on older kernels as well. 26 + * The version of this header as it appears in the kernel is a stripped 27 + * version (without all the backwards compatibility stuff) and so it 28 + * looks a bit odd. 29 + * 30 + * If you look at the full version then you will understand the reason 31 + * for introducing this header since you really don't want to have all 32 + * the tricky backwards compatibility code in each and every i2c driver. 33 + */ 34 + 24 35 #ifndef __V4L2_I2C_DRV_H__ 25 36 #define __V4L2_I2C_DRV_H__ 26 37
+25 -4
include/media/videobuf-dvb.h
··· 16 16 int nfeeds; 17 17 18 18 /* videobuf_dvb_(un)register manges this */ 19 - struct dvb_adapter adapter; 20 19 struct dvb_demux demux; 21 20 struct dmxdev dmxdev; 22 21 struct dmx_frontend fe_hw; ··· 23 24 struct dvb_net net; 24 25 }; 25 26 26 - int videobuf_dvb_register(struct videobuf_dvb *dvb, 27 + struct videobuf_dvb_frontend { 28 + struct list_head felist; 29 + int id; 30 + struct videobuf_dvb dvb; 31 + }; 32 + 33 + struct videobuf_dvb_frontends { 34 + struct list_head felist; 35 + struct mutex lock; 36 + struct dvb_adapter adapter; 37 + int active_fe_id; /* Indicates which frontend in the felist is in use */ 38 + int gate; /* Frontend with gate control 0=!MFE,1=fe0,2=fe1 etc */ 39 + }; 40 + 41 + int videobuf_dvb_register_bus(struct videobuf_dvb_frontends *f, 27 42 struct module *module, 28 43 void *adapter_priv, 29 44 struct device *device, 30 - short *adapter_nr); 31 - void videobuf_dvb_unregister(struct videobuf_dvb *dvb); 45 + short *adapter_nr, 46 + int mfe_shared); 47 + 48 + void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f); 49 + 50 + struct videobuf_dvb_frontend * videobuf_dvb_alloc_frontend(struct videobuf_dvb_frontends *f, int id); 51 + 52 + struct videobuf_dvb_frontend * videobuf_dvb_get_frontend(struct videobuf_dvb_frontends *f, int id); 53 + int videobuf_dvb_find_frontend(struct videobuf_dvb_frontends *f, struct dvb_frontend *p); 54 + 32 55 33 56 /* 34 57 * Local variables: