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 0 -> Unknown board (au0828) 2 - 1 -> Hauppauge HVR950Q (au0828) [2040:7200,2040:7210,2040:7217,2040:721b,2040:721f,2040:7280,0fd9:0008] 3 2 -> Hauppauge HVR850 (au0828) [2040:7240] 4 3 -> DViCO FusionHDTV USB (au0828) [0fe9:d620] 5 4 -> Hauppauge HVR950Q rev xxF8 (au0828) [2040:7201,2040:7211,2040:7281]
··· 1 0 -> Unknown board (au0828) 2 + 1 -> Hauppauge HVR950Q (au0828) [2040:7200,2040:7210,2040:7217,2040:721b,2040:721e,2040:721f,2040:7280,0fd9:0008] 3 2 -> Hauppauge HVR850 (au0828) [2040:7240] 4 3 -> DViCO FusionHDTV USB (au0828) [0fe9:d620] 5 4 -> Hauppauge HVR950Q rev xxF8 (au0828) [2040:7201,2040:7211,2040:7281]
+1
Documentation/video4linux/CARDLIST.tuner
··· 75 tuner=75 - Philips TEA5761 FM Radio 76 tuner=76 - Xceive 5000 tuner 77 tuner=77 - TCL tuner MF02GIP-5N-E
··· 75 tuner=75 - Philips TEA5761 FM Radio 76 tuner=76 - Xceive 5000 tuner 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 } 3482 ctrlVal = 0; 3483 for (k = 0; k < state->MXL_Ctrl[i].size; k++) 3484 - ctrlVal += state->MXL_Ctrl[i].val[k] * (1 << k); 3485 } else 3486 return -1; 3487 } ··· 3583 3584 static u32 MXL_Ceiling(u32 value, u32 resolution) 3585 { 3586 - return (value/resolution + (value % resolution > 0 ? 1 : 0)); 3587 } 3588 3589 /* Retrieve the Initialzation Registers */ ··· 3912 3913 static int mxl5005s_init(struct dvb_frontend *fe) 3914 { 3915 dprintk(1, "%s()\n", __func__); 3916 return mxl5005s_reconfigure(fe, MXL_QAM, MXL5005S_BANDWIDTH_6MHZ); 3917 } 3918 ··· 4097 state->frontend = fe; 4098 state->config = config; 4099 state->i2c = i2c; 4100 - state->current_mode = MXL_QAM; 4101 4102 printk(KERN_INFO "MXL5005S: Attached at address 0x%02x\n", 4103 config->i2c_address);
··· 3481 } 3482 ctrlVal = 0; 3483 for (k = 0; k < state->MXL_Ctrl[i].size; k++) 3484 + ctrlVal += state-> 3485 + MXL_Ctrl[i].val[k] * 3486 + (1 << k); 3487 } else 3488 return -1; 3489 } ··· 3581 3582 static u32 MXL_Ceiling(u32 value, u32 resolution) 3583 { 3584 + return value / resolution + (value % resolution > 0 ? 1 : 0); 3585 } 3586 3587 /* Retrieve the Initialzation Registers */ ··· 3910 3911 static int mxl5005s_init(struct dvb_frontend *fe) 3912 { 3913 + struct mxl5005s_state *state = fe->tuner_priv; 3914 + 3915 dprintk(1, "%s()\n", __func__); 3916 + state->current_mode = MXL_QAM; 3917 return mxl5005s_reconfigure(fe, MXL_QAM, MXL5005S_BANDWIDTH_6MHZ); 3918 } 3919 ··· 4092 state->frontend = fe; 4093 state->config = config; 4094 state->i2c = i2c; 4095 4096 printk(KERN_INFO "MXL5005S: Attached at address 0x%02x\n", 4097 config->i2c_address);
+2
drivers/media/common/tuners/tuner-simple.c
··· 493 case TUNER_PHILIPS_FM1216ME_MK3: 494 case TUNER_PHILIPS_FM1236_MK3: 495 case TUNER_PHILIPS_FMD1216ME_MK3: 496 case TUNER_LG_NTSC_TAPE: 497 case TUNER_PHILIPS_FM1256_IH3: 498 case TUNER_TCL_MF02GIP_5N: ··· 768 769 switch (priv->type) { 770 case TUNER_PHILIPS_FMD1216ME_MK3: 771 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ && 772 params->frequency >= 158870000) 773 buf[3] |= 0x08;
··· 493 case TUNER_PHILIPS_FM1216ME_MK3: 494 case TUNER_PHILIPS_FM1236_MK3: 495 case TUNER_PHILIPS_FMD1216ME_MK3: 496 + case TUNER_PHILIPS_FMD1216MEX_MK3: 497 case TUNER_LG_NTSC_TAPE: 498 case TUNER_PHILIPS_FM1256_IH3: 499 case TUNER_TCL_MF02GIP_5N: ··· 767 768 switch (priv->type) { 769 case TUNER_PHILIPS_FMD1216ME_MK3: 770 + case TUNER_PHILIPS_FMD1216MEX_MK3: 771 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ && 772 params->frequency >= 158870000) 773 buf[3] |= 0x08;
+32 -1
drivers/media/common/tuners/tuner-types.c
··· 946 }, 947 }; 948 949 - /* ------------ TUNER_PHILIPS_FMD1216ME_MK3 - Philips PAL ------------ */ 950 951 static struct tuner_range tuner_philips_fmd1216me_mk3_pal_ranges[] = { 952 { 16 * 160.00 /*MHz*/, 0x86, 0x51, }, ··· 984 }, 985 }; 986 987 988 /* ------ TUNER_LG_TDVS_H06XF - LG INNOTEK / INFINEON ATSC ----- */ 989 ··· 1683 .name = "TCL tuner MF02GIP-5N-E", 1684 .params = tuner_tcl_mf02gip_5n_params, 1685 .count = ARRAY_SIZE(tuner_tcl_mf02gip_5n_params), 1686 }, 1687 }; 1688 EXPORT_SYMBOL(tuners);
··· 946 }, 947 }; 948 949 + /* ------------ TUNER_PHILIPS_FMD1216ME(X)_MK3 - Philips PAL ------------ */ 950 951 static struct tuner_range tuner_philips_fmd1216me_mk3_pal_ranges[] = { 952 { 16 * 160.00 /*MHz*/, 0x86, 0x51, }, ··· 984 }, 985 }; 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 + }; 1008 1009 /* ------ TUNER_LG_TDVS_H06XF - LG INNOTEK / INFINEON ATSC ----- */ 1010 ··· 1662 .name = "TCL tuner MF02GIP-5N-E", 1663 .params = tuner_tcl_mf02gip_5n_params, 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 }, 1675 }, 1676 }; 1677 EXPORT_SYMBOL(tuners);
+37 -36
drivers/media/common/tuners/xc5000.c
··· 43 static DEFINE_MUTEX(xc5000_list_mutex); 44 static LIST_HEAD(hybrid_tuner_instance_list); 45 46 - #define dprintk(level,fmt, arg...) if (debug >= level) \ 47 printk(KERN_INFO "%s: " fmt, "xc5000", ## arg) 48 49 #define XC5000_DEFAULT_FIRMWARE "dvb-fe-xc5000-1.1.fw" ··· 138 immediately the length of the following transaction. 139 140 */ 141 - typedef struct { 142 char *Name; 143 u16 AudioMode; 144 u16 VideoMode; 145 - } XC_TV_STANDARD; 146 147 /* Tuner standards */ 148 #define MN_NTSC_PAL_BTSC 0 ··· 169 #define FM_Radio_INPUT2 21 170 #define FM_Radio_INPUT1 22 171 172 - static XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = { 173 {"M/N-NTSC/PAL-BTSC", 0x0400, 0x8020}, 174 {"M/N-NTSC/PAL-A2", 0x0600, 0x8020}, 175 {"M/N-NTSC/PAL-EIAJ", 0x0440, 0x8020}, ··· 183 {"D/K-PAL-NICAM", 0x0E80, 0x8009}, 184 {"D/K-PAL-MONO", 0x1478, 0x8009}, 185 {"D/K-SECAM-A2 DK1", 0x1200, 0x8009}, 186 - {"D/K-SECAM-A2 L/DK3",0x0E00, 0x8009}, 187 {"D/K-SECAM-A2 MONO", 0x1478, 0x8009}, 188 {"L-SECAM-NICAM", 0x8E82, 0x0009}, 189 {"L'-SECAM-NICAM", 0x8E82, 0x4009}, ··· 307 unsigned int len, pos, index; 308 u8 buf[XC_MAX_I2C_WRITE_LENGTH]; 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]; 313 if (len == 0x0000) { 314 /* RESET command */ 315 result = xc_reset(fe); ··· 330 buf[1] = i2c_sequence[index + 1]; 331 pos = 2; 332 while (pos < len) { 333 - if ((len - pos) > XC_MAX_I2C_WRITE_LENGTH - 2) { 334 - nbytes_to_send = XC_MAX_I2C_WRITE_LENGTH; 335 - } else { 336 nbytes_to_send = (len - pos + 2); 337 } 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); 342 343 if (result != XC_RESULT_SUCCESS) 344 return result; ··· 389 dprintk(1, "%s(%d) Source = %s\n", __func__, rf_mode, 390 rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE"); 391 392 - if ((rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE)) 393 - { 394 rf_mode = XC_RF_MODE_CABLE; 395 printk(KERN_ERR 396 "%s(), Invalid mode, defaulting to CABLE", ··· 562 .flags = I2C_M_RD, .buf = buf, .len = len }; 563 564 if (i2c_transfer(priv->i2c_props.adap, &msg, 1) != 1) { 565 - printk(KERN_ERR "xc5000 I2C read failed (len=%i)\n",(int)len); 566 return -EREMOTEIO; 567 } 568 return 0; 569 } 570 571 - static int xc5000_fwupload(struct dvb_frontend* fe) 572 { 573 struct xc5000_priv *priv = fe->tuner_priv; 574 const struct firmware *fw; ··· 578 printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n", 579 XC5000_DEFAULT_FIRMWARE); 580 581 - ret = request_firmware(&fw, XC5000_DEFAULT_FIRMWARE, &priv->i2c_props.adap->dev); 582 if (ret) { 583 printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); 584 ret = XC_RESULT_RESET_FAILURE; ··· 595 ret = XC_RESULT_RESET_FAILURE; 596 } else { 597 printk(KERN_INFO "xc5000: firmware upload\n"); 598 - ret = xc_load_i2c_sequence(fe, fw->data ); 599 } 600 601 out: ··· 654 655 dprintk(1, "%s() frequency=%d (Hz)\n", __func__, params->frequency); 656 657 - switch(params->u.vsb.modulation) { 658 case VSB_8: 659 case VSB_16: 660 dprintk(1, "%s() VSB modulation\n", __func__); ··· 751 /* FIX ME: Some video standards may have several possible audio 752 standards. We simply default to one of them here. 753 */ 754 - if(params->std & V4L2_STD_MN) { 755 /* default to BTSC audio standard */ 756 priv->video_standard = MN_NTSC_PAL_BTSC; 757 goto tune_channel; 758 } 759 760 - if(params->std & V4L2_STD_PAL_BG) { 761 /* default to NICAM audio standard */ 762 priv->video_standard = BG_PAL_NICAM; 763 goto tune_channel; 764 } 765 766 - if(params->std & V4L2_STD_PAL_I) { 767 /* default to NICAM audio standard */ 768 priv->video_standard = I_PAL_NICAM; 769 goto tune_channel; 770 } 771 772 - if(params->std & V4L2_STD_PAL_DK) { 773 /* default to NICAM audio standard */ 774 priv->video_standard = DK_PAL_NICAM; 775 goto tune_channel; 776 } 777 778 - if(params->std & V4L2_STD_SECAM_DK) { 779 /* default to A2 DK1 audio standard */ 780 priv->video_standard = DK_SECAM_A2DK1; 781 goto tune_channel; 782 } 783 784 - if(params->std & V4L2_STD_SECAM_L) { 785 priv->video_standard = L_SECAM_NICAM; 786 goto tune_channel; 787 } 788 789 - if(params->std & V4L2_STD_SECAM_LC) { 790 priv->video_standard = LC_SECAM_NICAM; 791 goto tune_channel; 792 } ··· 794 tune_channel: 795 ret = xc_SetSignalSource(priv, priv->rf_mode); 796 if (ret != XC_RESULT_SUCCESS) { 797 - printk(KERN_ERR 798 "xc5000: xc_SetSignalSource(%d) failed\n", 799 priv->rf_mode); 800 return -EREMOTEIO; ··· 866 * I2C transactions until calibration is complete. This way we 867 * don't have to rely on clock stretching working. 868 */ 869 - xc_wait( 100 ); 870 871 /* Default to "CABLE" mode */ 872 ret |= xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE); ··· 888 */ 889 890 ret = xc_shutdown(priv); 891 - if(ret != XC_RESULT_SUCCESS) { 892 printk(KERN_ERR 893 "xc5000: %s() unable to shutdown tuner\n", 894 __func__); 895 return -EREMOTEIO; 896 - } 897 - else { 898 return XC_RESULT_SUCCESS; 899 - } 900 } 901 902 static int xc5000_init(struct dvb_frontend *fe) ··· 990 if (xc5000_readreg(priv, XREG_PRODUCT_ID, &id) != 0) 991 goto fail; 992 993 - switch(id) { 994 case XC_PRODUCT_ID_FW_LOADED: 995 printk(KERN_INFO 996 "xc5000: Successfully identified at address 0x%02x\n",
··· 43 static DEFINE_MUTEX(xc5000_list_mutex); 44 static LIST_HEAD(hybrid_tuner_instance_list); 45 46 + #define dprintk(level, fmt, arg...) if (debug >= level) \ 47 printk(KERN_INFO "%s: " fmt, "xc5000", ## arg) 48 49 #define XC5000_DEFAULT_FIRMWARE "dvb-fe-xc5000-1.1.fw" ··· 138 immediately the length of the following transaction. 139 140 */ 141 + struct XC_TV_STANDARD { 142 char *Name; 143 u16 AudioMode; 144 u16 VideoMode; 145 + }; 146 147 /* Tuner standards */ 148 #define MN_NTSC_PAL_BTSC 0 ··· 169 #define FM_Radio_INPUT2 21 170 #define FM_Radio_INPUT1 22 171 172 + static struct XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = { 173 {"M/N-NTSC/PAL-BTSC", 0x0400, 0x8020}, 174 {"M/N-NTSC/PAL-A2", 0x0600, 0x8020}, 175 {"M/N-NTSC/PAL-EIAJ", 0x0440, 0x8020}, ··· 183 {"D/K-PAL-NICAM", 0x0E80, 0x8009}, 184 {"D/K-PAL-MONO", 0x1478, 0x8009}, 185 {"D/K-SECAM-A2 DK1", 0x1200, 0x8009}, 186 + {"D/K-SECAM-A2 L/DK3", 0x0E00, 0x8009}, 187 {"D/K-SECAM-A2 MONO", 0x1478, 0x8009}, 188 {"L-SECAM-NICAM", 0x8E82, 0x0009}, 189 {"L'-SECAM-NICAM", 0x8E82, 0x4009}, ··· 307 unsigned int len, pos, index; 308 u8 buf[XC_MAX_I2C_WRITE_LENGTH]; 309 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]; 314 if (len == 0x0000) { 315 /* RESET command */ 316 result = xc_reset(fe); ··· 329 buf[1] = i2c_sequence[index + 1]; 330 pos = 2; 331 while (pos < len) { 332 + if ((len - pos) > XC_MAX_I2C_WRITE_LENGTH - 2) 333 + nbytes_to_send = 334 + XC_MAX_I2C_WRITE_LENGTH; 335 + else 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]; 340 } 341 + result = xc_send_i2c_data(priv, buf, 342 + nbytes_to_send); 343 344 if (result != XC_RESULT_SUCCESS) 345 return result; ··· 386 dprintk(1, "%s(%d) Source = %s\n", __func__, rf_mode, 387 rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE"); 388 389 + if ((rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE)) { 390 rf_mode = XC_RF_MODE_CABLE; 391 printk(KERN_ERR 392 "%s(), Invalid mode, defaulting to CABLE", ··· 560 .flags = I2C_M_RD, .buf = buf, .len = len }; 561 562 if (i2c_transfer(priv->i2c_props.adap, &msg, 1) != 1) { 563 + printk(KERN_ERR "xc5000 I2C read failed (len=%i)\n", (int)len); 564 return -EREMOTEIO; 565 } 566 return 0; 567 } 568 569 + static int xc5000_fwupload(struct dvb_frontend *fe) 570 { 571 struct xc5000_priv *priv = fe->tuner_priv; 572 const struct firmware *fw; ··· 576 printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n", 577 XC5000_DEFAULT_FIRMWARE); 578 579 + ret = request_firmware(&fw, XC5000_DEFAULT_FIRMWARE, 580 + &priv->i2c_props.adap->dev); 581 if (ret) { 582 printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); 583 ret = XC_RESULT_RESET_FAILURE; ··· 592 ret = XC_RESULT_RESET_FAILURE; 593 } else { 594 printk(KERN_INFO "xc5000: firmware upload\n"); 595 + ret = xc_load_i2c_sequence(fe, fw->data); 596 } 597 598 out: ··· 651 652 dprintk(1, "%s() frequency=%d (Hz)\n", __func__, params->frequency); 653 654 + switch (params->u.vsb.modulation) { 655 case VSB_8: 656 case VSB_16: 657 dprintk(1, "%s() VSB modulation\n", __func__); ··· 748 /* FIX ME: Some video standards may have several possible audio 749 standards. We simply default to one of them here. 750 */ 751 + if (params->std & V4L2_STD_MN) { 752 /* default to BTSC audio standard */ 753 priv->video_standard = MN_NTSC_PAL_BTSC; 754 goto tune_channel; 755 } 756 757 + if (params->std & V4L2_STD_PAL_BG) { 758 /* default to NICAM audio standard */ 759 priv->video_standard = BG_PAL_NICAM; 760 goto tune_channel; 761 } 762 763 + if (params->std & V4L2_STD_PAL_I) { 764 /* default to NICAM audio standard */ 765 priv->video_standard = I_PAL_NICAM; 766 goto tune_channel; 767 } 768 769 + if (params->std & V4L2_STD_PAL_DK) { 770 /* default to NICAM audio standard */ 771 priv->video_standard = DK_PAL_NICAM; 772 goto tune_channel; 773 } 774 775 + if (params->std & V4L2_STD_SECAM_DK) { 776 /* default to A2 DK1 audio standard */ 777 priv->video_standard = DK_SECAM_A2DK1; 778 goto tune_channel; 779 } 780 781 + if (params->std & V4L2_STD_SECAM_L) { 782 priv->video_standard = L_SECAM_NICAM; 783 goto tune_channel; 784 } 785 786 + if (params->std & V4L2_STD_SECAM_LC) { 787 priv->video_standard = LC_SECAM_NICAM; 788 goto tune_channel; 789 } ··· 791 tune_channel: 792 ret = xc_SetSignalSource(priv, priv->rf_mode); 793 if (ret != XC_RESULT_SUCCESS) { 794 + printk(KERN_ERR 795 "xc5000: xc_SetSignalSource(%d) failed\n", 796 priv->rf_mode); 797 return -EREMOTEIO; ··· 863 * I2C transactions until calibration is complete. This way we 864 * don't have to rely on clock stretching working. 865 */ 866 + xc_wait(100); 867 868 /* Default to "CABLE" mode */ 869 ret |= xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE); ··· 885 */ 886 887 ret = xc_shutdown(priv); 888 + if (ret != XC_RESULT_SUCCESS) { 889 printk(KERN_ERR 890 "xc5000: %s() unable to shutdown tuner\n", 891 __func__); 892 return -EREMOTEIO; 893 + } else 894 return XC_RESULT_SUCCESS; 895 } 896 897 static int xc5000_init(struct dvb_frontend *fe) ··· 989 if (xc5000_readreg(priv, XREG_PRODUCT_ID, &id) != 0) 990 goto fail; 991 992 + switch (id) { 993 case XC_PRODUCT_ID_FW_LOADED: 994 printk(KERN_INFO 995 "xc5000: Successfully identified at address 0x%02x\n",
+4 -4
drivers/media/common/tuners/xc5000.h
··· 45 46 #if defined(CONFIG_MEDIA_TUNER_XC5000) || \ 47 (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) 48 - extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, 49 struct i2c_adapter *i2c, 50 struct xc5000_config *cfg); 51 #else 52 - static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, 53 struct i2c_adapter *i2c, 54 struct xc5000_config *cfg) 55 { 56 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 57 return NULL; 58 } 59 - #endif // CONFIG_MEDIA_TUNER_XC5000 60 61 - #endif // __XC5000_H__
··· 45 46 #if defined(CONFIG_MEDIA_TUNER_XC5000) || \ 47 (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) 48 + extern struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, 49 struct i2c_adapter *i2c, 50 struct xc5000_config *cfg); 51 #else 52 + static inline struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, 53 struct i2c_adapter *i2c, 54 struct xc5000_config *cfg) 55 { 56 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 57 return NULL; 58 } 59 + #endif 60 61 + #endif
+12
drivers/media/dvb/dm1105/dm1105.c
··· 595 dm1105dvb_dma_unmap(dm1105dvb); 596 } 597 598 static struct stv0288_config earda_config = { 599 .demod_address = 0x68, 600 .min_delay_ms = 100,
··· 595 dm1105dvb_dma_unmap(dm1105dvb); 596 } 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 + 610 static struct stv0288_config earda_config = { 611 .demod_address = 0x68, 612 .min_delay_ms = 100,
+85 -49
drivers/media/dvb/dvb-core/dvb_frontend.c
··· 47 static int dvb_force_auto_inversion; 48 static int dvb_override_tune_delay; 49 static int dvb_powerdown_on_sleep = 1; 50 51 module_param_named(frontend_debug, dvb_frontend_debug, int, 0644); 52 MODULE_PARM_DESC(frontend_debug, "Turn on/off frontend core debugging (default:off)."); ··· 59 MODULE_PARM_DESC(dvb_override_tune_delay, "0: normal (default), >0 => delay in milliseconds to wait for lock after a tune attempt"); 60 module_param(dvb_powerdown_on_sleep, int, 0644); 61 MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB voltage off on sleep (default)"); 62 63 #define dprintk if (dvb_frontend_debug) printk 64 ··· 215 216 static void dvb_frontend_init(struct dvb_frontend *fe) 217 { 218 - dprintk ("DVB: initialising frontend %i (%s)...\n", 219 fe->dvb->num, 220 fe->ops.info.name); 221 222 if (fe->ops.init) ··· 690 mb(); 691 692 fe_thread = kthread_run(dvb_frontend_thread, fe, 693 - "kdvb-fe-%i", fe->dvb->num); 694 if (IS_ERR(fe_thread)) { 695 ret = PTR_ERR(fe_thread); 696 printk("dvb_frontend_start: failed to start kthread (%d)\n", ret); ··· 714 *freq_max = min(fe->ops.info.frequency_max, fe->ops.tuner_ops.info.frequency_max); 715 716 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); 719 } 720 721 static int dvb_frontend_check_parameters(struct dvb_frontend *fe, ··· 728 dvb_frontend_get_frequeny_limits(fe, &freq_min, &freq_max); 729 if ((freq_min && parms->frequency < freq_min) || 730 (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); 733 return -EINVAL; 734 } 735 ··· 739 parms->u.qpsk.symbol_rate < fe->ops.info.symbol_rate_min) || 740 (fe->ops.info.symbol_rate_max && 741 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, 744 fe->ops.info.symbol_rate_min, fe->ops.info.symbol_rate_max); 745 return -EINVAL; 746 } ··· 750 parms->u.qam.symbol_rate < fe->ops.info.symbol_rate_min) || 751 (fe->ops.info.symbol_rate_max && 752 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, 755 fe->ops.info.symbol_rate_min, fe->ops.info.symbol_rate_max); 756 return -EINVAL; 757 } ··· 903 int i; 904 905 if (tvp->cmd <= 0 || tvp->cmd > DTV_MAX_COMMAND) { 906 - printk("%s: tvp.cmd = 0x%08x (undefined/unknown/invalid)\n", 907 __func__, tvp->cmd); 908 return; 909 } 910 911 - printk("%s() tvp.cmd = 0x%08x (%s)\n" 912 - ,__FUNCTION__ 913 ,tvp->cmd 914 ,dtv_cmds[ tvp->cmd ].name); 915 916 if(dtv_cmds[ tvp->cmd ].buffer) { 917 918 - printk("%s() tvp.u.buffer.len = 0x%02x\n" 919 - ,__FUNCTION__ 920 ,tvp->u.buffer.len); 921 922 for(i = 0; i < tvp->u.buffer.len; i++) 923 - printk("%s() tvp.u.buffer.data[0x%02x] = 0x%02x\n" 924 - ,__FUNCTION__ 925 ,i 926 ,tvp->u.buffer.data[i]); 927 928 } else 929 - printk("%s() tvp.u.data = 0x%08x\n", __FUNCTION__, tvp->u.data); 930 } 931 932 int is_legacy_delivery_system(fe_delivery_system_t s) ··· 945 void dtv_property_cache_sync(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) 946 { 947 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 948 - 949 - printk("%s()\n", __FUNCTION__); 950 951 c->frequency = p->frequency; 952 c->inversion = p->inversion; ··· 1000 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1001 struct dvb_frontend_parameters *p = &fepriv->parameters; 1002 1003 - printk("%s()\n", __FUNCTION__); 1004 - 1005 p->frequency = c->frequency; 1006 p->inversion = c->inversion; 1007 1008 switch (fe->ops.info.type) { 1009 case FE_QPSK: 1010 - printk("%s() Preparing QPSK req\n", __FUNCTION__); 1011 p->u.qpsk.symbol_rate = c->symbol_rate; 1012 p->u.qpsk.fec_inner = c->fec_inner; 1013 c->delivery_system = SYS_DVBS; 1014 break; 1015 case FE_QAM: 1016 - printk("%s() Preparing QAM req\n", __FUNCTION__); 1017 p->u.qam.symbol_rate = c->symbol_rate; 1018 p->u.qam.fec_inner = c->fec_inner; 1019 p->u.qam.modulation = c->modulation; 1020 c->delivery_system = SYS_DVBC_ANNEX_AC; 1021 break; 1022 case FE_OFDM: 1023 - printk("%s() Preparing OFDM req\n", __FUNCTION__); 1024 if (c->bandwidth_hz == 6000000) 1025 p->u.ofdm.bandwidth = BANDWIDTH_6_MHZ; 1026 else if (c->bandwidth_hz == 7000000) ··· 1036 c->delivery_system = SYS_DVBT; 1037 break; 1038 case FE_ATSC: 1039 - printk("%s() Preparing VSB req\n", __FUNCTION__); 1040 p->u.vsb.modulation = c->modulation; 1041 if ((c->modulation == VSB_8) || (c->modulation == VSB_16)) 1042 c->delivery_system = SYS_ATSC; ··· 1055 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1056 struct dvb_frontend_parameters *p = &fepriv->parameters; 1057 1058 - printk("%s()\n", __FUNCTION__); 1059 - 1060 p->frequency = c->frequency; 1061 p->inversion = c->inversion; 1062 1063 switch(c->modulation) { 1064 case PSK_8: 1065 case APSK_16: 1066 case QPSK: 1067 p->u.qpsk.symbol_rate = c->symbol_rate; 1068 p->u.qpsk.fec_inner = c->fec_inner; ··· 1088 { 1089 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 1090 1091 - printk("%s()\n", __FUNCTION__); 1092 - 1093 /* For legacy delivery systems we don't need the delivery_system to 1094 * be specified, but we populate the older structures from the cache 1095 * so we can call set_frontend on older drivers. 1096 */ 1097 if(is_legacy_delivery_system(c->delivery_system)) { 1098 1099 - printk("%s() legacy, modulation = %d\n", __FUNCTION__, c->modulation); 1100 dtv_property_legacy_params_sync(fe); 1101 1102 } else { 1103 - printk("%s() adv, modulation = %d\n", __FUNCTION__, c->modulation); 1104 1105 /* For advanced delivery systems / modulation types ... 1106 * we seed the lecacy dvb_frontend_parameters structure ··· 1119 struct inode *inode, struct file *file) 1120 { 1121 int r = 0; 1122 - 1123 - printk("%s()\n", __FUNCTION__); 1124 1125 dtv_property_dump(tvp); 1126 ··· 1193 { 1194 int r = 0; 1195 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1196 - printk("%s()\n", __FUNCTION__); 1197 dtv_property_dump(tvp); 1198 1199 /* Allow the frontend to validate incoming properties */ ··· 1207 /* Reset a cache of data specific to the frontend here. This does 1208 * not effect hardware. 1209 */ 1210 - printk("%s() Flushing property cache\n", __FUNCTION__); 1211 memset(&fe->dtv_property_cache, 0, sizeof(struct dtv_frontend_properties)); 1212 fe->dtv_property_cache.state = tvp->cmd; 1213 fe->dtv_property_cache.delivery_system = SYS_UNDEFINED; ··· 1218 * ioctl. 1219 */ 1220 fe->dtv_property_cache.state = tvp->cmd; 1221 - printk("%s() Finalised property cache\n", __FUNCTION__); 1222 dtv_property_cache_submit(fe); 1223 1224 r |= dvb_frontend_ioctl_legacy(inode, file, FE_SET_FRONTEND, ··· 1329 dprintk("%s\n", __func__); 1330 1331 if(cmd == FE_SET_PROPERTY) { 1332 - printk("%s() FE_SET_PROPERTY\n", __FUNCTION__); 1333 - 1334 tvps = (struct dtv_properties __user *)parg; 1335 1336 - printk("%s() properties.num = %d\n", __FUNCTION__, tvps->num); 1337 - printk("%s() properties.props = %p\n", __FUNCTION__, tvps->props); 1338 1339 /* Put an arbitrary limit on the number of messages that can 1340 * be sent at once */ ··· 1356 err |= (tvp + i)->result; 1357 } 1358 1359 - if(fe->dtv_property_cache.state == DTV_TUNE) { 1360 - printk("%s() Property cache is full, tuning\n", __FUNCTION__); 1361 - } 1362 1363 } else 1364 if(cmd == FE_GET_PROPERTY) { 1365 - printk("%s() FE_GET_PROPERTY\n", __FUNCTION__); 1366 1367 tvps = (struct dtv_properties __user *)parg; 1368 1369 - printk("%s() properties.num = %d\n", __FUNCTION__, tvps->num); 1370 - printk("%s() properties.props = %p\n", __FUNCTION__, tvps->props); 1371 1372 /* Put an arbitrary limit on the number of messages that can 1373 * be sent at once */ ··· 1694 struct dvb_device *dvbdev = file->private_data; 1695 struct dvb_frontend *fe = dvbdev->priv; 1696 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1697 int ret; 1698 1699 dprintk ("%s\n", __func__); 1700 1701 if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) { 1702 if ((ret = fe->ops.ts_bus_ctrl(fe, 1)) < 0) 1703 - return ret; 1704 } 1705 1706 if ((ret = dvb_generic_open (inode, file)) < 0) ··· 1760 fepriv->events.eventr = fepriv->events.eventw = 0; 1761 } 1762 1763 return ret; 1764 1765 err2: ··· 1769 err1: 1770 if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) 1771 fe->ops.ts_bus_ctrl(fe, 0); 1772 return ret; 1773 } 1774 ··· 1841 fe->dvb = dvb; 1842 fepriv->inversion = INVERSION_OFF; 1843 1844 - printk ("DVB: registering frontend %i (%s)...\n", 1845 fe->dvb->num, 1846 fe->ops.info.name); 1847 1848 dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template,
··· 47 static int dvb_force_auto_inversion; 48 static int dvb_override_tune_delay; 49 static int dvb_powerdown_on_sleep = 1; 50 + static int dvb_mfe_wait_time = 5; 51 52 module_param_named(frontend_debug, dvb_frontend_debug, int, 0644); 53 MODULE_PARM_DESC(frontend_debug, "Turn on/off frontend core debugging (default:off)."); ··· 58 MODULE_PARM_DESC(dvb_override_tune_delay, "0: normal (default), >0 => delay in milliseconds to wait for lock after a tune attempt"); 59 module_param(dvb_powerdown_on_sleep, int, 0644); 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)"); 63 64 #define dprintk if (dvb_frontend_debug) printk 65 ··· 212 213 static void dvb_frontend_init(struct dvb_frontend *fe) 214 { 215 + dprintk ("DVB: initialising adapter %i frontend %i (%s)...\n", 216 fe->dvb->num, 217 + fe->id, 218 fe->ops.info.name); 219 220 if (fe->ops.init) ··· 686 mb(); 687 688 fe_thread = kthread_run(dvb_frontend_thread, fe, 689 + "kdvb-ad-%i-fe-%i", fe->dvb->num,fe->id); 690 if (IS_ERR(fe_thread)) { 691 ret = PTR_ERR(fe_thread); 692 printk("dvb_frontend_start: failed to start kthread (%d)\n", ret); ··· 710 *freq_max = min(fe->ops.info.frequency_max, fe->ops.tuner_ops.info.frequency_max); 711 712 if (*freq_min == 0 || *freq_max == 0) 713 + printk(KERN_WARNING "DVB: adapter %i frontend %u frequency limits undefined - fix the driver\n", 714 + fe->dvb->num,fe->id); 715 } 716 717 static int dvb_frontend_check_parameters(struct dvb_frontend *fe, ··· 724 dvb_frontend_get_frequeny_limits(fe, &freq_min, &freq_max); 725 if ((freq_min && parms->frequency < freq_min) || 726 (freq_max && parms->frequency > 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); 729 return -EINVAL; 730 } 731 ··· 735 parms->u.qpsk.symbol_rate < fe->ops.info.symbol_rate_min) || 736 (fe->ops.info.symbol_rate_max && 737 parms->u.qpsk.symbol_rate > fe->ops.info.symbol_rate_max)) { 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, 740 fe->ops.info.symbol_rate_min, fe->ops.info.symbol_rate_max); 741 return -EINVAL; 742 } ··· 746 parms->u.qam.symbol_rate < fe->ops.info.symbol_rate_min) || 747 (fe->ops.info.symbol_rate_max && 748 parms->u.qam.symbol_rate > fe->ops.info.symbol_rate_max)) { 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, 751 fe->ops.info.symbol_rate_min, fe->ops.info.symbol_rate_max); 752 return -EINVAL; 753 } ··· 899 int i; 900 901 if (tvp->cmd <= 0 || tvp->cmd > DTV_MAX_COMMAND) { 902 + printk(KERN_WARNING "%s: tvp.cmd = 0x%08x undefined\n", 903 __func__, tvp->cmd); 904 return; 905 } 906 907 + dprintk("%s() tvp.cmd = 0x%08x (%s)\n" 908 + ,__func__ 909 ,tvp->cmd 910 ,dtv_cmds[ tvp->cmd ].name); 911 912 if(dtv_cmds[ tvp->cmd ].buffer) { 913 914 + dprintk("%s() tvp.u.buffer.len = 0x%02x\n" 915 + ,__func__ 916 ,tvp->u.buffer.len); 917 918 for(i = 0; i < tvp->u.buffer.len; i++) 919 + dprintk("%s() tvp.u.buffer.data[0x%02x] = 0x%02x\n" 920 + ,__func__ 921 ,i 922 ,tvp->u.buffer.data[i]); 923 924 } else 925 + dprintk("%s() tvp.u.data = 0x%08x\n", __func__, tvp->u.data); 926 } 927 928 int is_legacy_delivery_system(fe_delivery_system_t s) ··· 941 void dtv_property_cache_sync(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) 942 { 943 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 944 945 c->frequency = p->frequency; 946 c->inversion = p->inversion; ··· 998 struct dvb_frontend_private *fepriv = fe->frontend_priv; 999 struct dvb_frontend_parameters *p = &fepriv->parameters; 1000 1001 p->frequency = c->frequency; 1002 p->inversion = c->inversion; 1003 1004 switch (fe->ops.info.type) { 1005 case FE_QPSK: 1006 + dprintk("%s() Preparing QPSK req\n", __func__); 1007 p->u.qpsk.symbol_rate = c->symbol_rate; 1008 p->u.qpsk.fec_inner = c->fec_inner; 1009 c->delivery_system = SYS_DVBS; 1010 break; 1011 case FE_QAM: 1012 + dprintk("%s() Preparing QAM req\n", __func__); 1013 p->u.qam.symbol_rate = c->symbol_rate; 1014 p->u.qam.fec_inner = c->fec_inner; 1015 p->u.qam.modulation = c->modulation; 1016 c->delivery_system = SYS_DVBC_ANNEX_AC; 1017 break; 1018 case FE_OFDM: 1019 + dprintk("%s() Preparing OFDM req\n", __func__); 1020 if (c->bandwidth_hz == 6000000) 1021 p->u.ofdm.bandwidth = BANDWIDTH_6_MHZ; 1022 else if (c->bandwidth_hz == 7000000) ··· 1036 c->delivery_system = SYS_DVBT; 1037 break; 1038 case FE_ATSC: 1039 + dprintk("%s() Preparing VSB req\n", __func__); 1040 p->u.vsb.modulation = c->modulation; 1041 if ((c->modulation == VSB_8) || (c->modulation == VSB_16)) 1042 c->delivery_system = SYS_ATSC; ··· 1055 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1056 struct dvb_frontend_parameters *p = &fepriv->parameters; 1057 1058 p->frequency = c->frequency; 1059 p->inversion = c->inversion; 1060 1061 switch(c->modulation) { 1062 case PSK_8: 1063 case APSK_16: 1064 + case APSK_32: 1065 case QPSK: 1066 p->u.qpsk.symbol_rate = c->symbol_rate; 1067 p->u.qpsk.fec_inner = c->fec_inner; ··· 1089 { 1090 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 1091 1092 /* For legacy delivery systems we don't need the delivery_system to 1093 * be specified, but we populate the older structures from the cache 1094 * so we can call set_frontend on older drivers. 1095 */ 1096 if(is_legacy_delivery_system(c->delivery_system)) { 1097 1098 + dprintk("%s() legacy, modulation = %d\n", __func__, c->modulation); 1099 dtv_property_legacy_params_sync(fe); 1100 1101 } else { 1102 + dprintk("%s() adv, modulation = %d\n", __func__, c->modulation); 1103 1104 /* For advanced delivery systems / modulation types ... 1105 * we seed the lecacy dvb_frontend_parameters structure ··· 1122 struct inode *inode, struct file *file) 1123 { 1124 int r = 0; 1125 1126 dtv_property_dump(tvp); 1127 ··· 1198 { 1199 int r = 0; 1200 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1201 dtv_property_dump(tvp); 1202 1203 /* Allow the frontend to validate incoming properties */ ··· 1213 /* Reset a cache of data specific to the frontend here. This does 1214 * not effect hardware. 1215 */ 1216 + dprintk("%s() Flushing property cache\n", __func__); 1217 memset(&fe->dtv_property_cache, 0, sizeof(struct dtv_frontend_properties)); 1218 fe->dtv_property_cache.state = tvp->cmd; 1219 fe->dtv_property_cache.delivery_system = SYS_UNDEFINED; ··· 1224 * ioctl. 1225 */ 1226 fe->dtv_property_cache.state = tvp->cmd; 1227 + dprintk("%s() Finalised property cache\n", __func__); 1228 dtv_property_cache_submit(fe); 1229 1230 r |= dvb_frontend_ioctl_legacy(inode, file, FE_SET_FRONTEND, ··· 1335 dprintk("%s\n", __func__); 1336 1337 if(cmd == FE_SET_PROPERTY) { 1338 tvps = (struct dtv_properties __user *)parg; 1339 1340 + dprintk("%s() properties.num = %d\n", __func__, tvps->num); 1341 + dprintk("%s() properties.props = %p\n", __func__, tvps->props); 1342 1343 /* Put an arbitrary limit on the number of messages that can 1344 * be sent at once */ ··· 1364 err |= (tvp + i)->result; 1365 } 1366 1367 + if(fe->dtv_property_cache.state == DTV_TUNE) 1368 + dprintk("%s() Property cache is full, tuning\n", __func__); 1369 1370 } else 1371 if(cmd == FE_GET_PROPERTY) { 1372 1373 tvps = (struct dtv_properties __user *)parg; 1374 1375 + dprintk("%s() properties.num = %d\n", __func__, tvps->num); 1376 + dprintk("%s() properties.props = %p\n", __func__, tvps->props); 1377 1378 /* Put an arbitrary limit on the number of messages that can 1379 * be sent at once */ ··· 1704 struct dvb_device *dvbdev = file->private_data; 1705 struct dvb_frontend *fe = dvbdev->priv; 1706 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1707 + struct dvb_adapter *adapter = fe->dvb; 1708 int ret; 1709 1710 dprintk ("%s\n", __func__); 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 + 1751 if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) { 1752 if ((ret = fe->ops.ts_bus_ctrl(fe, 1)) < 0) 1753 + goto err0; 1754 } 1755 1756 if ((ret = dvb_generic_open (inode, file)) < 0) ··· 1730 fepriv->events.eventr = fepriv->events.eventw = 0; 1731 } 1732 1733 + if (adapter->mfe_shared) 1734 + mutex_unlock (&adapter->mfe_lock); 1735 return ret; 1736 1737 err2: ··· 1737 err1: 1738 if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) 1739 fe->ops.ts_bus_ctrl(fe, 0); 1740 + err0: 1741 + if (adapter->mfe_shared) 1742 + mutex_unlock (&adapter->mfe_lock); 1743 return ret; 1744 } 1745 ··· 1806 fe->dvb = dvb; 1807 fepriv->inversion = INVERSION_OFF; 1808 1809 + printk ("DVB: registering adapter %i frontend %i (%s)...\n", 1810 fe->dvb->num, 1811 + fe->id, 1812 fe->ops.info.name); 1813 1814 dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template,
+1
drivers/media/dvb/dvb-core/dvb_frontend.h
··· 222 struct dtv_frontend_properties dtv_property_cache; 223 #define DVB_FRONTEND_COMPONENT_TUNER 0 224 int (*callback)(void *adapter_priv, int component, int cmd, int arg); 225 }; 226 227 extern int dvb_register_frontend(struct dvb_adapter *dvb,
··· 222 struct dtv_frontend_properties dtv_property_cache; 223 #define DVB_FRONTEND_COMPONENT_TUNER 0 224 int (*callback)(void *adapter_priv, int component, int cmd, int arg); 225 + int id; 226 }; 227 228 extern int dvb_register_frontend(struct dvb_adapter *dvb,
+3
drivers/media/dvb/dvb-core/dvbdev.c
··· 326 adap->name = name; 327 adap->module = module; 328 adap->device = device; 329 330 list_add_tail (&adap->list_head, &dvb_adapter_list); 331
··· 326 adap->name = name; 327 adap->module = module; 328 adap->device = device; 329 + adap->mfe_shared = 0; 330 + adap->mfe_dvbdev = NULL; 331 + mutex_init (&adap->mfe_lock); 332 333 list_add_tail (&adap->list_head, &dvb_adapter_list); 334
+4
drivers/media/dvb/dvb-core/dvbdev.h
··· 62 struct device *device; 63 64 struct module *module; 65 }; 66 67
··· 62 struct device *device; 63 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 */ 69 }; 70 71
+12
drivers/media/dvb/dvb-usb/dw2102.c
··· 422 return 0; 423 } 424 425 static struct cx24116_config dw2104_config = { 426 .demod_address = 0x55, 427 .mpg_clk_pos_pol = 0x01,
··· 422 return 0; 423 } 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 + 437 static struct cx24116_config dw2104_config = { 438 .demod_address = 0x55, 439 .mpg_clk_pos_pol = 0x01,
+307 -201
drivers/media/dvb/frontends/cx22702.c
··· 34 #include "dvb_frontend.h" 35 #include "cx22702.h" 36 37 - 38 struct cx22702_state { 39 40 - struct i2c_adapter* i2c; 41 42 /* configuration settings */ 43 - const struct cx22702_config* config; 44 45 struct dvb_frontend frontend; 46 ··· 48 }; 49 50 static int debug; 51 #define dprintk if (debug) printk 52 53 /* Register values to initialise the demod */ 54 - static u8 init_tab [] = { 55 0x00, 0x00, /* Stop aquisition */ 56 0x0B, 0x06, 57 0x09, 0x01, ··· 82 0xfd, 0x00, 83 }; 84 85 - static int cx22702_writereg (struct cx22702_state* state, u8 reg, u8 data) 86 { 87 int ret; 88 - u8 buf [] = { reg, data }; 89 - struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; 90 91 ret = i2c_transfer(state->i2c, &msg, 1); 92 93 if (ret != 1) 94 - printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", 95 __func__, reg, data, ret); 96 97 return (ret != 1) ? -1 : 0; 98 } 99 100 - static u8 cx22702_readreg (struct cx22702_state* state, u8 reg) 101 { 102 int ret; 103 - u8 b0 [] = { reg }; 104 - u8 b1 [] = { 0 }; 105 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 } }; 109 110 ret = i2c_transfer(state->i2c, msg, 2); 111 112 if (ret != 2) 113 - printk("%s: readreg error (ret == %i)\n", __func__, ret); 114 115 return b1[0]; 116 } 117 118 - static int cx22702_set_inversion (struct cx22702_state *state, int inversion) 119 { 120 u8 val; 121 122 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 - 138 } 139 140 } 141 142 /* Retrieve the demod settings */ 143 - static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_parameters *p) 144 { 145 u8 val; 146 ··· 150 if (!(cx22702_readreg(state, 0x0A) & 0x20)) 151 return -EAGAIN; 152 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; 158 } 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; 181 } 182 183 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; 190 } 191 - switch( val&0x03 ) { 192 - case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break; 193 - case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break; 194 } 195 196 return 0; 197 } 198 199 - static int cx22702_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) 200 { 201 - struct cx22702_state* state = fe->demodulator_priv; 202 - dprintk ("%s(%d)\n", __func__, enable); 203 if (enable) 204 - return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) & 0xfe); 205 else 206 - return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) | 1); 207 } 208 209 /* 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) 211 { 212 u8 val; 213 - struct cx22702_state* state = fe->demodulator_priv; 214 215 if (fe->ops.tuner_ops.set_params) { 216 fe->ops.tuner_ops.set_params(fe, p); 217 - if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); 218 } 219 220 /* set inversion */ 221 - cx22702_set_inversion (state, p->inversion); 222 223 /* set bandwidth */ 224 - switch(p->u.ofdm.bandwidth) { 225 case BANDWIDTH_6_MHZ: 226 - cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x20 ); 227 break; 228 case BANDWIDTH_7_MHZ: 229 - cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x10 ); 230 break; 231 case BANDWIDTH_8_MHZ: 232 - cx22702_writereg(state, 0x0C, cx22702_readreg(state, 0x0C) &0xcf ); 233 break; 234 default: 235 - dprintk ("%s: invalid bandwidth\n",__func__); 236 return -EINVAL; 237 } 238 239 - 240 - p->u.ofdm.code_rate_LP = FEC_AUTO; //temp hack as manual not working 241 242 /* 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) ) { 249 250 /* TPS Source - use hardware driven values */ 251 cx22702_writereg(state, 0x06, 0x10); 252 cx22702_writereg(state, 0x07, 0x9); 253 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 ); 256 cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */ 257 - dprintk("%s: Autodetecting\n",__func__); 258 return 0; 259 } 260 261 /* 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; 270 } 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; 279 } 280 - cx22702_writereg (state, 0x06, val); 281 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; 293 } 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; 304 } 305 - cx22702_writereg (state, 0x07, val); 306 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; 316 } 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; 323 } 324 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 ); 327 328 /* Begin channel aquisition */ 329 cx22702_writereg(state, 0x00, 0x01); ··· 434 435 /* Reset the demod hardware and reset all of the configuration registers 436 to a default state. */ 437 - static int cx22702_init (struct dvb_frontend* fe) 438 { 439 int i; 440 - struct cx22702_state* state = fe->demodulator_priv; 441 442 - cx22702_writereg (state, 0x00, 0x02); 443 444 msleep(10); 445 446 - for (i=0; i<sizeof(init_tab); i+=2) 447 - cx22702_writereg (state, init_tab[i], init_tab[i+1]); 448 449 - cx22702_writereg (state, 0xf8, (state->config->output_mode << 1) & 0x02); 450 451 cx22702_i2c_gate_ctrl(fe, 0); 452 453 return 0; 454 } 455 456 - static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status) 457 { 458 - struct cx22702_state* state = fe->demodulator_priv; 459 u8 reg0A; 460 u8 reg23; 461 462 *status = 0; 463 464 - reg0A = cx22702_readreg (state, 0x0A); 465 - reg23 = cx22702_readreg (state, 0x23); 466 467 - dprintk ("%s: status demod=0x%02x agc=0x%02x\n" 468 - ,__func__,reg0A,reg23); 469 470 - if(reg0A & 0x10) { 471 *status |= FE_HAS_LOCK; 472 *status |= FE_HAS_VITERBI; 473 *status |= FE_HAS_SYNC; 474 } 475 476 - if(reg0A & 0x20) 477 *status |= FE_HAS_CARRIER; 478 479 - if(reg23 < 0xf0) 480 *status |= FE_HAS_SIGNAL; 481 482 return 0; 483 } 484 485 - static int cx22702_read_ber(struct dvb_frontend* fe, u32* ber) 486 { 487 - struct cx22702_state* state = fe->demodulator_priv; 488 489 - if(cx22702_readreg (state, 0xE4) & 0x02) { 490 /* Realtime statistics */ 491 - *ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 492 - | (cx22702_readreg (state, 0xDF)&0x7F); 493 } else { 494 /* Averagtine statistics */ 495 - *ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 496 - | cx22702_readreg (state, 0xDF); 497 } 498 499 return 0; 500 } 501 502 - static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) 503 { 504 - struct cx22702_state* state = fe->demodulator_priv; 505 506 u16 rs_ber = 0; 507 - rs_ber = cx22702_readreg (state, 0x23); 508 *signal_strength = (rs_ber << 8) | rs_ber; 509 510 return 0; 511 } 512 513 - static int cx22702_read_snr(struct dvb_frontend* fe, u16* snr) 514 { 515 - struct cx22702_state* state = fe->demodulator_priv; 516 517 - u16 rs_ber=0; 518 - if(cx22702_readreg (state, 0xE4) & 0x02) { 519 /* Realtime statistics */ 520 - rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 521 - | (cx22702_readreg (state, 0xDF)& 0x7F); 522 } else { 523 /* Averagine statistics */ 524 - rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 8 525 - | cx22702_readreg (state, 0xDF); 526 } 527 *snr = ~rs_ber; 528 529 return 0; 530 } 531 532 - static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 533 { 534 - struct cx22702_state* state = fe->demodulator_priv; 535 536 u8 _ucblocks; 537 538 /* RS Uncorrectable Packet Count then reset */ 539 - _ucblocks = cx22702_readreg (state, 0xE3); 540 if (state->prevUCBlocks < _ucblocks) 541 *ucblocks = (_ucblocks - state->prevUCBlocks); 542 else ··· 548 return 0; 549 } 550 551 - static int cx22702_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 552 { 553 - struct cx22702_state* state = fe->demodulator_priv; 554 555 - u8 reg0C = cx22702_readreg (state, 0x0C); 556 557 p->inversion = reg0C & 0x1 ? INVERSION_ON : INVERSION_OFF; 558 - return cx22702_get_tps (state, &p->u.ofdm); 559 } 560 561 - static int cx22702_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) 562 { 563 tune->min_delay_ms = 1000; 564 return 0; 565 } 566 567 - static void cx22702_release(struct dvb_frontend* fe) 568 { 569 - struct cx22702_state* state = fe->demodulator_priv; 570 kfree(state); 571 } 572 573 static struct dvb_frontend_ops cx22702_ops; 574 575 - struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, 576 - struct i2c_adapter* i2c) 577 { 578 - struct cx22702_state* state = NULL; 579 580 /* allocate memory for the internal state */ 581 state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL); ··· 594 goto error; 595 596 /* create dvb_frontend */ 597 - memcpy(&state->frontend.ops, &cx22702_ops, sizeof(struct dvb_frontend_ops)); 598 state->frontend.demodulator_priv = state; 599 return &state->frontend; 600 ··· 603 kfree(state); 604 return NULL; 605 } 606 607 static struct dvb_frontend_ops cx22702_ops = { 608 ··· 636 .read_ucblocks = cx22702_read_ucblocks, 637 }; 638 639 - module_param(debug, int, 0644); 640 - MODULE_PARM_DESC(debug, "Enable verbose debug messages"); 641 - 642 MODULE_DESCRIPTION("Conexant CX22702 DVB-T Demodulator driver"); 643 MODULE_AUTHOR("Steven Toth"); 644 MODULE_LICENSE("GPL"); 645 - 646 - EXPORT_SYMBOL(cx22702_attach);
··· 34 #include "dvb_frontend.h" 35 #include "cx22702.h" 36 37 struct cx22702_state { 38 39 + struct i2c_adapter *i2c; 40 41 /* configuration settings */ 42 + const struct cx22702_config *config; 43 44 struct dvb_frontend frontend; 45 ··· 49 }; 50 51 static int debug; 52 + module_param(debug, int, 0644); 53 + MODULE_PARM_DESC(debug, "Enable verbose debug messages"); 54 + 55 #define dprintk if (debug) printk 56 57 /* Register values to initialise the demod */ 58 + static u8 init_tab[] = { 59 0x00, 0x00, /* Stop aquisition */ 60 0x0B, 0x06, 61 0x09, 0x01, ··· 80 0xfd, 0x00, 81 }; 82 83 + static int cx22702_writereg(struct cx22702_state *state, u8 reg, u8 data) 84 { 85 int ret; 86 + u8 buf[] = { reg, data }; 87 + struct i2c_msg msg = { 88 + .addr = state->config->demod_address, .flags = 0, 89 + .buf = buf, .len = 2 }; 90 91 ret = i2c_transfer(state->i2c, &msg, 1); 92 93 if (ret != 1) 94 + printk(KERN_ERR 95 + "%s: error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", 96 __func__, reg, data, ret); 97 98 return (ret != 1) ? -1 : 0; 99 } 100 101 + static u8 cx22702_readreg(struct cx22702_state *state, u8 reg) 102 { 103 int ret; 104 + u8 b0[] = { reg }; 105 + u8 b1[] = { 0 }; 106 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 } }; 112 113 ret = i2c_transfer(state->i2c, msg, 2); 114 115 if (ret != 2) 116 + printk(KERN_ERR "%s: readreg error (ret == %i)\n", 117 + __func__, ret); 118 119 return b1[0]; 120 } 121 122 + static int cx22702_set_inversion(struct cx22702_state *state, int inversion) 123 { 124 u8 val; 125 126 switch (inversion) { 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; 137 } 138 139 } 140 141 /* Retrieve the demod settings */ 142 + static int cx22702_get_tps(struct cx22702_state *state, 143 + struct dvb_ofdm_parameters *p) 144 { 145 u8 val; 146 ··· 146 if (!(cx22702_readreg(state, 0x0A) & 0x20)) 147 return -EAGAIN; 148 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; 160 } 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; 174 } 175 176 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; 194 } 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; 235 } 236 237 return 0; 238 } 239 240 + static int cx22702_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) 241 { 242 + struct cx22702_state *state = fe->demodulator_priv; 243 + dprintk("%s(%d)\n", __func__, enable); 244 if (enable) 245 + return cx22702_writereg(state, 0x0D, 246 + cx22702_readreg(state, 0x0D) & 0xfe); 247 else 248 + return cx22702_writereg(state, 0x0D, 249 + cx22702_readreg(state, 0x0D) | 1); 250 } 251 252 /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ 253 + static int cx22702_set_tps(struct dvb_frontend *fe, 254 + struct dvb_frontend_parameters *p) 255 { 256 u8 val; 257 + struct cx22702_state *state = fe->demodulator_priv; 258 259 if (fe->ops.tuner_ops.set_params) { 260 fe->ops.tuner_ops.set_params(fe, p); 261 + if (fe->ops.i2c_gate_ctrl) 262 + fe->ops.i2c_gate_ctrl(fe, 0); 263 } 264 265 /* set inversion */ 266 + cx22702_set_inversion(state, p->inversion); 267 268 /* set bandwidth */ 269 + switch (p->u.ofdm.bandwidth) { 270 case BANDWIDTH_6_MHZ: 271 + cx22702_writereg(state, 0x0C, 272 + (cx22702_readreg(state, 0x0C) & 0xcf) | 0x20); 273 break; 274 case BANDWIDTH_7_MHZ: 275 + cx22702_writereg(state, 0x0C, 276 + (cx22702_readreg(state, 0x0C) & 0xcf) | 0x10); 277 break; 278 case BANDWIDTH_8_MHZ: 279 + cx22702_writereg(state, 0x0C, 280 + cx22702_readreg(state, 0x0C) & 0xcf); 281 break; 282 default: 283 + dprintk("%s: invalid bandwidth\n", __func__); 284 return -EINVAL; 285 } 286 287 + p->u.ofdm.code_rate_LP = FEC_AUTO; /* temp hack as manual not working */ 288 289 /* use auto configuration? */ 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)) { 296 297 /* TPS Source - use hardware driven values */ 298 cx22702_writereg(state, 0x06, 0x10); 299 cx22702_writereg(state, 0x07, 0x9); 300 cx22702_writereg(state, 0x08, 0xC1); 301 + cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) 302 + & 0xfc); 303 + cx22702_writereg(state, 0x0C, 304 + (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40); 305 cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */ 306 + dprintk("%s: Autodetecting\n", __func__); 307 return 0; 308 } 309 310 /* manually programmed values */ 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; 325 } 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; 342 } 343 + cx22702_writereg(state, 0x06, val); 344 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; 366 } 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; 387 } 388 + cx22702_writereg(state, 0x07, val); 389 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; 407 } 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; 418 } 419 cx22702_writereg(state, 0x08, val); 420 + cx22702_writereg(state, 0x0B, 421 + (cx22702_readreg(state, 0x0B) & 0xfc) | 0x02); 422 + cx22702_writereg(state, 0x0C, 423 + (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40); 424 425 /* Begin channel aquisition */ 426 cx22702_writereg(state, 0x00, 0x01); ··· 329 330 /* Reset the demod hardware and reset all of the configuration registers 331 to a default state. */ 332 + static int cx22702_init(struct dvb_frontend *fe) 333 { 334 int i; 335 + struct cx22702_state *state = fe->demodulator_priv; 336 337 + cx22702_writereg(state, 0x00, 0x02); 338 339 msleep(10); 340 341 + for (i = 0; i < ARRAY_SIZE(init_tab); i += 2) 342 + cx22702_writereg(state, init_tab[i], init_tab[i + 1]); 343 344 + cx22702_writereg(state, 0xf8, (state->config->output_mode << 1) 345 + & 0x02); 346 347 cx22702_i2c_gate_ctrl(fe, 0); 348 349 return 0; 350 } 351 352 + static int cx22702_read_status(struct dvb_frontend *fe, fe_status_t *status) 353 { 354 + struct cx22702_state *state = fe->demodulator_priv; 355 u8 reg0A; 356 u8 reg23; 357 358 *status = 0; 359 360 + reg0A = cx22702_readreg(state, 0x0A); 361 + reg23 = cx22702_readreg(state, 0x23); 362 363 + dprintk("%s: status demod=0x%02x agc=0x%02x\n" 364 + , __func__, reg0A, reg23); 365 366 + if (reg0A & 0x10) { 367 *status |= FE_HAS_LOCK; 368 *status |= FE_HAS_VITERBI; 369 *status |= FE_HAS_SYNC; 370 } 371 372 + if (reg0A & 0x20) 373 *status |= FE_HAS_CARRIER; 374 375 + if (reg23 < 0xf0) 376 *status |= FE_HAS_SIGNAL; 377 378 return 0; 379 } 380 381 + static int cx22702_read_ber(struct dvb_frontend *fe, u32 *ber) 382 { 383 + struct cx22702_state *state = fe->demodulator_priv; 384 385 + if (cx22702_readreg(state, 0xE4) & 0x02) { 386 /* Realtime statistics */ 387 + *ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7 388 + | (cx22702_readreg(state, 0xDF) & 0x7F); 389 } else { 390 /* Averagtine statistics */ 391 + *ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7 392 + | cx22702_readreg(state, 0xDF); 393 } 394 395 return 0; 396 } 397 398 + static int cx22702_read_signal_strength(struct dvb_frontend *fe, 399 + u16 *signal_strength) 400 { 401 + struct cx22702_state *state = fe->demodulator_priv; 402 403 u16 rs_ber = 0; 404 + rs_ber = cx22702_readreg(state, 0x23); 405 *signal_strength = (rs_ber << 8) | rs_ber; 406 407 return 0; 408 } 409 410 + static int cx22702_read_snr(struct dvb_frontend *fe, u16 *snr) 411 { 412 + struct cx22702_state *state = fe->demodulator_priv; 413 414 + u16 rs_ber = 0; 415 + if (cx22702_readreg(state, 0xE4) & 0x02) { 416 /* Realtime statistics */ 417 + rs_ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7 418 + | (cx22702_readreg(state, 0xDF) & 0x7F); 419 } else { 420 /* Averagine statistics */ 421 + rs_ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 8 422 + | cx22702_readreg(state, 0xDF); 423 } 424 *snr = ~rs_ber; 425 426 return 0; 427 } 428 429 + static int cx22702_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) 430 { 431 + struct cx22702_state *state = fe->demodulator_priv; 432 433 u8 _ucblocks; 434 435 /* RS Uncorrectable Packet Count then reset */ 436 + _ucblocks = cx22702_readreg(state, 0xE3); 437 if (state->prevUCBlocks < _ucblocks) 438 *ucblocks = (_ucblocks - state->prevUCBlocks); 439 else ··· 441 return 0; 442 } 443 444 + static int cx22702_get_frontend(struct dvb_frontend *fe, 445 + struct dvb_frontend_parameters *p) 446 { 447 + struct cx22702_state *state = fe->demodulator_priv; 448 449 + u8 reg0C = cx22702_readreg(state, 0x0C); 450 451 p->inversion = reg0C & 0x1 ? INVERSION_ON : INVERSION_OFF; 452 + return cx22702_get_tps(state, &p->u.ofdm); 453 } 454 455 + static int cx22702_get_tune_settings(struct dvb_frontend *fe, 456 + struct dvb_frontend_tune_settings *tune) 457 { 458 tune->min_delay_ms = 1000; 459 return 0; 460 } 461 462 + static void cx22702_release(struct dvb_frontend *fe) 463 { 464 + struct cx22702_state *state = fe->demodulator_priv; 465 kfree(state); 466 } 467 468 static struct dvb_frontend_ops cx22702_ops; 469 470 + struct dvb_frontend *cx22702_attach(const struct cx22702_config *config, 471 + struct i2c_adapter *i2c) 472 { 473 + struct cx22702_state *state = NULL; 474 475 /* allocate memory for the internal state */ 476 state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL); ··· 485 goto error; 486 487 /* create dvb_frontend */ 488 + memcpy(&state->frontend.ops, &cx22702_ops, 489 + sizeof(struct dvb_frontend_ops)); 490 state->frontend.demodulator_priv = state; 491 return &state->frontend; 492 ··· 493 kfree(state); 494 return NULL; 495 } 496 + EXPORT_SYMBOL(cx22702_attach); 497 498 static struct dvb_frontend_ops cx22702_ops = { 499 ··· 525 .read_ucblocks = cx22702_read_ucblocks, 526 }; 527 528 MODULE_DESCRIPTION("Conexant CX22702 DVB-T Demodulator driver"); 529 MODULE_AUTHOR("Steven Toth"); 530 MODULE_LICENSE("GPL");
+11 -9
drivers/media/dvb/frontends/cx22702.h
··· 30 31 #include <linux/dvb/frontend.h> 32 33 - struct cx22702_config 34 - { 35 /* the demodulator's i2c address */ 36 u8 demod_address; 37 ··· 40 u8 output_mode; 41 }; 42 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); 46 #else 47 - static inline struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, 48 - struct i2c_adapter* i2c) 49 { 50 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 51 return NULL; 52 } 53 - #endif // CONFIG_DVB_CX22702 54 55 - #endif // CX22702_H
··· 30 31 #include <linux/dvb/frontend.h> 32 33 + struct cx22702_config { 34 /* the demodulator's i2c address */ 35 u8 demod_address; 36 ··· 41 u8 output_mode; 42 }; 43 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); 49 #else 50 + static inline struct dvb_frontend *cx22702_attach( 51 + const struct cx22702_config *config, 52 + struct i2c_adapter *i2c) 53 { 54 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 55 return NULL; 56 } 57 + #endif 58 59 + #endif
+320 -273
drivers/media/dvb/frontends/cx24116.c
··· 41 #include "dvb_frontend.h" 42 #include "cx24116.h" 43 44 - static int debug = 0; 45 #define dprintk(args...) \ 46 do { \ 47 - if (debug) printk ("cx24116: " args); \ 48 } while (0) 49 50 #define CX24116_DEFAULT_FIRMWARE "dvb-fe-cx24116.fw" ··· 72 #define CX24116_REG_UCB8 (0xca) 73 #define CX24116_REG_CLKDIV (0xf3) 74 #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 */ 76 77 /* 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 */ 80 #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 /* arg buffer size */ 84 #define CX24116_ARGLEN (0x1e) ··· 127 128 /* DiSEqC tone burst */ 129 static int toneburst = 1; 130 131 /* SNR measurements */ 132 - static int esno_snr = 0; 133 134 - enum cmds 135 - { 136 CMD_SET_VCO = 0x10, 137 CMD_TUNEREQUEST = 0x11, 138 CMD_MPEGCONFIG = 0x13, ··· 154 }; 155 156 /* The Demod/Tuner can't easily provide these, we cache them */ 157 - struct cx24116_tuning 158 - { 159 u32 frequency; 160 u32 symbol_rate; 161 fe_spectral_inversion_t inversion; ··· 173 }; 174 175 /* Basic commands that are sent to the firmware */ 176 - struct cx24116_cmd 177 - { 178 u8 len; 179 u8 args[CX24116_ARGLEN]; 180 }; 181 182 - struct cx24116_state 183 - { 184 - struct i2c_adapter* i2c; 185 - const struct cx24116_config* config; 186 187 struct dvb_frontend frontend; 188 ··· 192 struct cx24116_cmd dsec_cmd; 193 }; 194 195 - static int cx24116_writereg(struct cx24116_state* state, int reg, int data) 196 { 197 u8 buf[] = { reg, data }; 198 struct i2c_msg msg = { .addr = state->config->demod_address, 199 .flags = 0, .buf = buf, .len = 2 }; 200 int err; 201 202 - if (debug>1) 203 printk("cx24116: %s: write reg 0x%02x, value 0x%02x\n", 204 - __func__,reg, data); 205 206 - if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 207 - printk("%s: writereg error(err == %i, reg == 0x%02x," 208 " value == 0x%02x)\n", __func__, err, reg, data); 209 return -EREMOTEIO; 210 } ··· 214 } 215 216 /* 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) 218 { 219 int ret = -EREMOTEIO; 220 struct i2c_msg msg; ··· 236 msg.buf = buf; 237 msg.len = len + 1; 238 239 - if (debug>1) 240 - printk("cx24116: %s: write regN 0x%02x, len = %d\n", 241 - __func__,reg, len); 242 243 - if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1) { 244 - printk("%s: writereg error(err == %i, reg == 0x%02x\n", 245 __func__, ret, reg); 246 ret = -EREMOTEIO; 247 } ··· 253 return ret; 254 } 255 256 - static int cx24116_readreg(struct cx24116_state* state, u8 reg) 257 { 258 int ret; 259 u8 b0[] = { reg }; 260 u8 b1[] = { 0 }; 261 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 } 264 }; 265 266 ret = i2c_transfer(state->i2c, msg, 2); 267 268 if (ret != 2) { 269 - printk("%s: reg=0x%x (error=%d)\n", __func__, reg, ret); 270 return ret; 271 } 272 273 - if (debug>1) 274 - printk("cx24116: read reg 0x%02x, value 0x%02x\n",reg, b1[0]); 275 276 return b1[0]; 277 } 278 279 - static int cx24116_set_inversion(struct cx24116_state* state, fe_spectral_inversion_t inversion) 280 { 281 dprintk("%s(%d)\n", __func__, inversion); 282 ··· 329 * Eg.(2/3) szap "Zone Horror" 330 * 331 * mask/val = 0x04, 0x20 332 - * status 1f | signal c3c0 | snr a333 | ber 00000098 | unc 00000000 | FE_HAS_LOCK 333 * 334 * mask/val = 0x04, 0x30 335 - * status 1f | signal c3c0 | snr a333 | ber 00000000 | unc 00000000 | FE_HAS_LOCK 336 * 337 * After tuning FECSTATUS contains actual FEC 338 * in use numbered 1 through to 8 for 1/2 .. 2/3 etc ··· 410 */ 411 }; 412 413 - static int cx24116_lookup_fecmod(struct cx24116_state* state, 414 fe_modulation_t m, fe_code_rate_t f) 415 { 416 int i, ret = -EOPNOTSUPP; 417 418 dprintk("%s(0x%02x,0x%02x)\n", __func__, m, f); 419 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 - { 425 ret = i; 426 break; 427 } ··· 428 return ret; 429 } 430 431 - static int cx24116_set_fec(struct cx24116_state* state, fe_modulation_t mod, fe_code_rate_t fec) 432 { 433 int ret = 0; 434 ··· 437 438 ret = cx24116_lookup_fecmod(state, mod, fec); 439 440 - if(ret < 0) 441 return ret; 442 443 state->dnxt.fec = fec; ··· 449 return 0; 450 } 451 452 - static int cx24116_set_symbolrate(struct cx24116_state* state, u32 rate) 453 { 454 dprintk("%s(%d)\n", __func__, rate); 455 ··· 466 return 0; 467 } 468 469 - static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware *fw); 470 471 - static int cx24116_firmware_ondemand(struct dvb_frontend* fe) 472 { 473 struct cx24116_state *state = fe->demodulator_priv; 474 const struct firmware *fw; 475 int ret = 0; 476 477 - dprintk("%s()\n",__func__); 478 479 - if (cx24116_readreg(state, 0x20) > 0) 480 - { 481 482 if (state->skip_fw_load) 483 return 0; 484 485 /* 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__); 490 if (ret) { 491 - printk("%s: No firmware uploaded (timeout or file not found?)\n", __func__); 492 return ret; 493 } 494 495 - /* Make sure we don't recurse back through here during loading */ 496 state->skip_fw_load = 1; 497 498 ret = cx24116_load_firmware(fe, fw); 499 if (ret) 500 - printk("%s: Writing firmware to device failed\n", __func__); 501 502 release_firmware(fw); 503 504 - printk("%s: Firmware upload %s\n", __func__, ret == 0 ? "complete" : "failed"); 505 506 /* Ensure firmware is always loaded if required */ 507 state->skip_fw_load = 0; ··· 517 return ret; 518 } 519 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) 522 { 523 struct cx24116_state *state = fe->demodulator_priv; 524 int i, ret; ··· 528 dprintk("%s()\n", __func__); 529 530 /* Load the firmware if required */ 531 - if ( (ret = cx24116_firmware_ondemand(fe)) != 0) 532 - { 533 - printk("%s(): Unable initialise the firmware\n", __func__); 534 return ret; 535 } 536 537 /* Write the command */ 538 - for(i = 0; i < cmd->len ; i++) 539 - { 540 dprintk("%s: 0x%02x == 0x%02x\n", __func__, i, cmd->args[i]); 541 cx24116_writereg(state, i, cmd->args[i]); 542 } 543 544 /* Start execution and wait for cmd to terminate */ 545 cx24116_writereg(state, CX24116_REG_EXECUTE, 0x01); 546 - while( cx24116_readreg(state, CX24116_REG_EXECUTE) ) 547 - { 548 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__); 553 return -EREMOTEIO; 554 } 555 } 556 return 0; 557 } 558 559 - static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware *fw) 560 { 561 - struct cx24116_state* state = fe->demodulator_priv; 562 struct cx24116_cmd cmd; 563 int i, ret; 564 unsigned char vers[4]; 565 566 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 - ); 574 575 /* Toggle 88x SRST pin to reset demod */ 576 if (state->config->reset_device) ··· 616 cmd.args[0x07] = 0x9d; 617 cmd.args[0x08] = 0xfc; 618 cmd.args[0x09] = 0x06; 619 - cmd.len= 0x0a; 620 ret = cx24116_cmd_execute(fe, &cmd); 621 if (ret != 0) 622 return ret; ··· 627 cmd.args[0x00] = CMD_TUNERINIT; 628 cmd.args[0x01] = 0x00; 629 cmd.args[0x02] = 0x00; 630 - cmd.len= 0x03; 631 ret = cx24116_cmd_execute(fe, &cmd); 632 if (ret != 0) 633 return ret; ··· 644 else 645 cmd.args[0x04] = 0x02; 646 cmd.args[0x05] = 0x00; 647 - cmd.len= 0x06; 648 ret = cx24116_cmd_execute(fe, &cmd); 649 if (ret != 0) 650 return ret; 651 652 /* Firmware CMD 35: Get firmware version */ 653 cmd.args[0x00] = CMD_UPDFWVERS; 654 - cmd.len= 0x02; 655 - for(i=0; i<4; i++) { 656 cmd.args[0x01] = i; 657 ret = cx24116_cmd_execute(fe, &cmd); 658 if (ret != 0) 659 return ret; 660 - vers[i]= cx24116_readreg(state, CX24116_REG_MAILBOX); 661 } 662 - printk("%s: FW version %i.%i.%i.%i\n", __func__, 663 vers[0], vers[1], vers[2], vers[3]); 664 665 return 0; 666 } 667 668 - static int cx24116_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 669 { 670 /* 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__); 672 673 return -EOPNOTSUPP; 674 } 675 676 - static int cx24116_read_status(struct dvb_frontend* fe, fe_status_t* status) 677 { 678 struct cx24116_state *state = fe->demodulator_priv; 679 ··· 697 return 0; 698 } 699 700 - static int cx24116_read_ber(struct dvb_frontend* fe, u32* ber) 701 { 702 struct cx24116_state *state = fe->demodulator_priv; 703 704 dprintk("%s()\n", __func__); 705 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 ); 710 711 return 0; 712 } 713 714 /* TODO Determine function and scale appropriately */ 715 - static int cx24116_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) 716 { 717 struct cx24116_state *state = fe->demodulator_priv; 718 struct cx24116_cmd cmd; ··· 724 725 /* Firmware CMD 19: Get AGC */ 726 cmd.args[0x00] = CMD_GETAGC; 727 - cmd.len= 0x01; 728 ret = cx24116_cmd_execute(fe, &cmd); 729 if (ret != 0) 730 return ret; 731 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; 735 736 - dprintk("%s: raw / cooked = 0x%04x / 0x%04x\n", __func__, sig_reading, *signal_strength); 737 738 return 0; 739 } 740 741 /* SNR (0..100)% = (sig & 0xf0) * 10 + (sig & 0x0f) * 10 / 16 */ 742 - static int cx24116_read_snr_pct(struct dvb_frontend* fe, u16* snr) 743 { 744 struct cx24116_state *state = fe->demodulator_priv; 745 u8 snr_reading; 746 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 }; 750 751 dprintk("%s()\n", __func__); 752 753 snr_reading = cx24116_readreg(state, CX24116_REG_QUALITY0); 754 755 - if(snr_reading >= 0xa0 /* 100% */) 756 *snr = 0xffff; 757 else 758 - *snr = snr_tab [ ( snr_reading & 0xf0 ) >> 4 ] + 759 - ( snr_tab [ ( snr_reading & 0x0f ) ] >> 4 ); 760 761 dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__, 762 snr_reading, *snr); ··· 772 * ESNO, from 0->30db (values 0->300). We provide this value by 773 * default. 774 */ 775 - static int cx24116_read_snr_esno(struct dvb_frontend* fe, u16* snr) 776 { 777 struct cx24116_state *state = fe->demodulator_priv; 778 ··· 786 return 0; 787 } 788 789 - static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr) 790 { 791 if (esno_snr == 1) 792 return cx24116_read_snr_esno(fe, snr); ··· 794 return cx24116_read_snr_pct(fe, snr); 795 } 796 797 - static int cx24116_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 798 { 799 struct cx24116_state *state = fe->demodulator_priv; 800 801 dprintk("%s()\n", __func__); 802 803 - *ucblocks = ( cx24116_readreg(state, CX24116_REG_UCB8) << 8 ) | 804 cx24116_readreg(state, CX24116_REG_UCB0); 805 806 return 0; 807 } 808 809 /* Overwrite the current tuning params, we are about to tune */ 810 - static void cx24116_clone_params(struct dvb_frontend* fe) 811 { 812 struct cx24116_state *state = fe->demodulator_priv; 813 memcpy(&state->dcur, &state->dnxt, sizeof(state->dcur)); 814 } 815 816 /* Wait for LNB */ 817 - static int cx24116_wait_for_lnb(struct dvb_frontend* fe) 818 { 819 struct cx24116_state *state = fe->demodulator_priv; 820 int i; ··· 823 cx24116_readreg(state, CX24116_REG_QSTATUS)); 824 825 /* Wait for up to 300 ms */ 826 - for(i = 0; i < 30 ; i++) { 827 if (cx24116_readreg(state, CX24116_REG_QSTATUS) & 0x20) 828 return 0; 829 msleep(10); ··· 834 return -ETIMEDOUT; /* -EBUSY ? */ 835 } 836 837 - static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 838 { 839 struct cx24116_cmd cmd; 840 int ret; 841 842 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); 845 return -EINVAL; 846 } 847 848 /* Wait for LNB ready */ 849 ret = cx24116_wait_for_lnb(fe); 850 - if(ret != 0) 851 return ret; 852 853 /* Min delay time after DiSEqC send */ ··· 857 /* This is always done before the tone is set */ 858 cmd.args[0x00] = CMD_SET_TONEPRE; 859 cmd.args[0x01] = 0x00; 860 - cmd.len= 0x02; 861 ret = cx24116_cmd_execute(fe, &cmd); 862 if (ret != 0) 863 return ret; ··· 873 cmd.args[0x03] = 0x01; 874 break; 875 case SEC_TONE_OFF: 876 - dprintk("%s: setting tone off\n",__func__); 877 cmd.args[0x03] = 0x00; 878 break; 879 } 880 - cmd.len= 0x04; 881 882 /* Min delay time before DiSEqC send */ 883 msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ ··· 886 } 887 888 /* Initialise DiSEqC */ 889 - static int cx24116_diseqc_init(struct dvb_frontend* fe) 890 { 891 struct cx24116_state *state = fe->demodulator_priv; 892 struct cx24116_cmd cmd; ··· 901 cmd.args[0x05] = 0x28; 902 cmd.args[0x06] = (toneburst == CX24116_DISEQC_TONEOFF) ? 0x00 : 0x01; 903 cmd.args[0x07] = 0x01; 904 - cmd.len= 0x08; 905 ret = cx24116_cmd_execute(fe, &cmd); 906 if (ret != 0) 907 return ret; ··· 915 /* Unknown */ 916 state->dsec_cmd.args[CX24116_DISEQC_ARG2_2] = 0x02; 917 state->dsec_cmd.args[CX24116_DISEQC_ARG3_0] = 0x00; 918 - state->dsec_cmd.args[CX24116_DISEQC_ARG4_0] = 0x00; /* Continuation flag? */ 919 920 /* DiSEqC message length */ 921 state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = 0x00; 922 923 /* Command length */ 924 - state->dsec_cmd.len= CX24116_DISEQC_MSGOFS; 925 926 return 0; 927 } 928 929 /* 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) 931 { 932 struct cx24116_state *state = fe->demodulator_priv; 933 int i, ret; 934 935 /* Dump DiSEqC message */ 936 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 - } 943 printk(") toneburst=%d\n", toneburst); 944 } 945 946 /* Validate length */ 947 - if(d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS)) 948 return -EINVAL; 949 950 /* DiSEqC message */ ··· 957 state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = d->msg_len; 958 959 /* Command length */ 960 - state->dsec_cmd.len= CX24116_DISEQC_MSGOFS + state->dsec_cmd.args[CX24116_DISEQC_MSGLEN]; 961 962 /* DiSEqC toneburst */ 963 - if(toneburst == CX24116_DISEQC_MESGCACHE) 964 /* Message is cached */ 965 return 0; 966 967 - else if(toneburst == CX24116_DISEQC_TONEOFF) 968 /* Message is sent without burst */ 969 state->dsec_cmd.args[CX24116_DISEQC_BURST] = 0; 970 971 - else if(toneburst == CX24116_DISEQC_TONECACHE) { 972 /* 973 * Message is sent with derived else cached burst 974 * ··· 988 * Y = VOLTAGE (0=13V, 1=18V) 989 * Z = BAND (0=LOW, 1=HIGH(22K)) 990 */ 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]); 995 } 996 997 /* Wait for LNB ready */ 998 ret = cx24116_wait_for_lnb(fe); 999 - if(ret != 0) 1000 return ret; 1001 1002 /* Wait for voltage/min repeat delay */ ··· 1006 1007 /* Command */ 1008 ret = cx24116_cmd_execute(fe, &state->dsec_cmd); 1009 - if(ret != 0) 1010 return ret; 1011 /* 1012 * Wait for send ··· 1018 * 12.5ms burst + 1019 * >15ms delay (XXX determine if FW does this, see set_tone) 1020 */ 1021 - msleep( (state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + ((toneburst == CX24116_DISEQC_TONEOFF) ? 30 : 60) ); 1022 1023 return 0; 1024 } 1025 1026 /* Send DiSEqC burst */ 1027 - static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) 1028 { 1029 struct cx24116_state *state = fe->demodulator_priv; 1030 int ret; 1031 1032 - dprintk("%s(%d) toneburst=%d\n",__func__, burst, toneburst); 1033 1034 /* DiSEqC burst */ 1035 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; 1039 else 1040 return -EINVAL; 1041 1042 /* DiSEqC toneburst */ 1043 - if(toneburst != CX24116_DISEQC_MESGCACHE) 1044 /* Burst is cached */ 1045 return 0; 1046 ··· 1052 1053 /* Wait for LNB ready */ 1054 ret = cx24116_wait_for_lnb(fe); 1055 - if(ret != 0) 1056 return ret; 1057 1058 /* Wait for voltage/min repeat delay */ ··· 1060 1061 /* Command */ 1062 ret = cx24116_cmd_execute(fe, &state->dsec_cmd); 1063 - if(ret != 0) 1064 return ret; 1065 1066 /* ··· 1073 * 12.5ms burst + 1074 * >15ms delay (XXX determine if FW does this, see set_tone) 1075 */ 1076 - msleep( (state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 60 ); 1077 1078 return 0; 1079 } 1080 1081 - static void cx24116_release(struct dvb_frontend* fe) 1082 { 1083 - struct cx24116_state* state = fe->demodulator_priv; 1084 - dprintk("%s\n",__func__); 1085 kfree(state); 1086 } 1087 1088 static struct dvb_frontend_ops cx24116_ops; 1089 1090 - struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, 1091 - struct i2c_adapter* i2c) 1092 { 1093 - struct cx24116_state* state = NULL; 1094 int ret; 1095 1096 - dprintk("%s\n",__func__); 1097 1098 /* allocate memory for the internal state */ 1099 state = kmalloc(sizeof(struct cx24116_state), GFP_KERNEL); 1100 - if (state == NULL) { 1101 - printk("Unable to kmalloc\n"); 1102 goto error1; 1103 - } 1104 1105 /* setup the state */ 1106 memset(state, 0, sizeof(struct cx24116_state)); ··· 1107 state->i2c = i2c; 1108 1109 /* check if the demod is present */ 1110 - ret = (cx24116_readreg(state, 0xFF) << 8) | cx24116_readreg(state, 0xFE); 1111 if (ret != 0x0501) { 1112 - printk("Invalid probe, probably not a CX24116 device\n"); 1113 goto error2; 1114 } 1115 1116 /* create dvb_frontend */ 1117 - memcpy(&state->frontend.ops, &cx24116_ops, sizeof(struct dvb_frontend_ops)); 1118 state->frontend.demodulator_priv = state; 1119 return &state->frontend; 1120 1121 error2: kfree(state); 1122 error1: return NULL; 1123 } 1124 /* 1125 * Initialise or wake up device 1126 * 1127 * Power config will reset and load initial firmware if required 1128 */ 1129 - static int cx24116_initfe(struct dvb_frontend* fe) 1130 { 1131 - struct cx24116_state* state = fe->demodulator_priv; 1132 struct cx24116_cmd cmd; 1133 int ret; 1134 1135 - dprintk("%s()\n",__func__); 1136 1137 /* Power on */ 1138 cx24116_writereg(state, 0xe0, 0); ··· 1146 /* Firmware CMD 36: Power config */ 1147 cmd.args[0x00] = CMD_TUNERSLEEP; 1148 cmd.args[0x01] = 0; 1149 - cmd.len= 0x02; 1150 ret = cx24116_cmd_execute(fe, &cmd); 1151 - if(ret != 0) 1152 return ret; 1153 1154 return cx24116_diseqc_init(fe); ··· 1157 /* 1158 * Put device to sleep 1159 */ 1160 - static int cx24116_sleep(struct dvb_frontend* fe) 1161 { 1162 - struct cx24116_state* state = fe->demodulator_priv; 1163 struct cx24116_cmd cmd; 1164 int ret; 1165 1166 - dprintk("%s()\n",__func__); 1167 1168 /* Firmware CMD 36: Power config */ 1169 cmd.args[0x00] = CMD_TUNERSLEEP; 1170 cmd.args[0x01] = 1; 1171 - cmd.len= 0x02; 1172 ret = cx24116_cmd_execute(fe, &cmd); 1173 - if(ret != 0) 1174 return ret; 1175 1176 /* Power off (Shutdown clocks) */ ··· 1181 return 0; 1182 } 1183 1184 - static int cx24116_set_property(struct dvb_frontend *fe, struct dtv_property* tvp) 1185 { 1186 dprintk("%s(..)\n", __func__); 1187 return 0; 1188 } 1189 1190 - static int cx24116_get_property(struct dvb_frontend *fe, struct dtv_property* tvp) 1191 { 1192 dprintk("%s(..)\n", __func__); 1193 return 0; ··· 1198 /* dvb-core told us to tune, the tv property cache will be complete, 1199 * it's safe for is to pull values and use them for tuning purposes. 1200 */ 1201 - static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 1202 { 1203 struct cx24116_state *state = fe->demodulator_priv; 1204 struct dtv_frontend_properties *c = &fe->dtv_property_cache; ··· 1207 fe_status_t tunerstat; 1208 int i, status, ret, retune; 1209 1210 - dprintk("%s()\n",__func__); 1211 1212 - switch(c->delivery_system) { 1213 - case SYS_DVBS: 1214 - dprintk("%s: DVB-S delivery system selected\n",__func__); 1215 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 - } 1222 1223 - /* Pilot doesn't exist in DVB-S, turn bit off */ 1224 state->dnxt.pilot_val = CX24116_PILOT_OFF; 1225 - retune = 1; 1226 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 - } 1233 state->dnxt.rolloff_val = CX24116_ROLLOFF_035; 1234 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 - 1282 default: 1283 - dprintk("%s: unsupported delivery system selected (%d)\n", 1284 - __func__, c->delivery_system); 1285 return -EOPNOTSUPP; 1286 } 1287 state->dnxt.modulation = c->modulation; 1288 state->dnxt.frequency = c->frequency; 1289 state->dnxt.pilot = c->pilot; 1290 state->dnxt.rolloff = c->rolloff; 1291 1292 - if ((ret = cx24116_set_inversion(state, c->inversion)) != 0) 1293 return ret; 1294 1295 /* 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) 1297 return ret; 1298 1299 - if ((ret = cx24116_set_symbolrate(state, c->symbol_rate)) != 0) 1300 return ret; 1301 1302 /* discard the 'current' tuning parameters and prepare to tune */ ··· 1328 /* Set/Reset B/W */ 1329 cmd.args[0x00] = CMD_BANDWIDTH; 1330 cmd.args[0x01] = 0x01; 1331 - cmd.len= 0x02; 1332 ret = cx24116_cmd_execute(fe, &cmd); 1333 if (ret != 0) 1334 return ret; ··· 1376 cx24116_writereg(state, CX24116_REG_RATEDIV, 0x00); 1377 } 1378 1379 - cmd.len= 0x13; 1380 1381 /* We need to support pilot and non-pilot tuning in the 1382 * driver automatically. This is a workaround for because ··· 1384 */ 1385 do { 1386 /* Reset status register */ 1387 - status = cx24116_readreg(state, CX24116_REG_SSTATUS) & CX24116_SIGNAL_MASK; 1388 cx24116_writereg(state, CX24116_REG_SSTATUS, status); 1389 1390 /* Tune */ 1391 ret = cx24116_cmd_execute(fe, &cmd); 1392 - if( ret != 0 ) 1393 break; 1394 1395 /* ··· 1399 * If we are able to tune then generally it occurs within 100ms. 1400 * If it takes longer, try a different toneburst setting. 1401 */ 1402 - for(i = 0; i < 50 ; i++) { 1403 cx24116_read_status(fe, &tunerstat); 1404 status = tunerstat & (FE_HAS_SIGNAL | FE_HAS_SYNC); 1405 - if(status == (FE_HAS_SIGNAL | FE_HAS_SYNC)) { 1406 - dprintk("%s: Tuned\n",__func__); 1407 goto tuned; 1408 } 1409 msleep(10); 1410 } 1411 1412 - dprintk("%s: Not tuned\n",__func__); 1413 1414 /* Toggle pilot bit when in auto-pilot */ 1415 - if(state->dcur.pilot == PILOT_AUTO) 1416 cmd.args[0x07] ^= CX24116_PILOT_ON; 1417 - } 1418 - while(--retune); 1419 1420 tuned: /* Set/Reset B/W */ 1421 cmd.args[0x00] = CMD_BANDWIDTH; 1422 cmd.args[0x01] = 0x00; 1423 - cmd.len= 0x02; 1424 ret = cx24116_cmd_execute(fe, &cmd); 1425 if (ret != 0) 1426 return ret; ··· 1464 .set_frontend = cx24116_set_frontend, 1465 }; 1466 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 MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware"); 1477 MODULE_AUTHOR("Steven Toth"); 1478 MODULE_LICENSE("GPL"); 1479 1480 - EXPORT_SYMBOL(cx24116_attach);
··· 41 #include "dvb_frontend.h" 42 #include "cx24116.h" 43 44 + static int debug; 45 + module_param(debug, int, 0644); 46 + MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); 47 + 48 #define dprintk(args...) \ 49 do { \ 50 + if (debug) \ 51 + printk(KERN_INFO "cx24116: " args); \ 52 } while (0) 53 54 #define CX24116_DEFAULT_FIRMWARE "dvb-fe-cx24116.fw" ··· 68 #define CX24116_REG_UCB8 (0xca) 69 #define CX24116_REG_CLKDIV (0xf3) 70 #define CX24116_REG_RATEDIV (0xf9) 71 + 72 + /* configured fec (not tuned) or actual FEC (tuned) 1=1/2 2=2/3 etc */ 73 + #define CX24116_REG_FECSTATUS (0x9c) 74 75 /* FECSTATUS bits */ 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) 81 #define CX24116_FEC_UNKNOWN (0x40) /* Unknown/unused */ 82 + 83 + /* Pilot mode requested when tuning else always reset when tuned */ 84 + #define CX24116_FEC_PILOT (0x80) 85 86 /* arg buffer size */ 87 #define CX24116_ARGLEN (0x1e) ··· 116 117 /* DiSEqC tone burst */ 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)"); 122 123 /* SNR measurements */ 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)"); 128 129 + enum cmds { 130 CMD_SET_VCO = 0x10, 131 CMD_TUNEREQUEST = 0x11, 132 CMD_MPEGCONFIG = 0x13, ··· 138 }; 139 140 /* The Demod/Tuner can't easily provide these, we cache them */ 141 + struct cx24116_tuning { 142 u32 frequency; 143 u32 symbol_rate; 144 fe_spectral_inversion_t inversion; ··· 158 }; 159 160 /* Basic commands that are sent to the firmware */ 161 + struct cx24116_cmd { 162 u8 len; 163 u8 args[CX24116_ARGLEN]; 164 }; 165 166 + struct cx24116_state { 167 + struct i2c_adapter *i2c; 168 + const struct cx24116_config *config; 169 170 struct dvb_frontend frontend; 171 ··· 179 struct cx24116_cmd dsec_cmd; 180 }; 181 182 + static int cx24116_writereg(struct cx24116_state *state, int reg, int data) 183 { 184 u8 buf[] = { reg, data }; 185 struct i2c_msg msg = { .addr = state->config->demod_address, 186 .flags = 0, .buf = buf, .len = 2 }; 187 int err; 188 189 + if (debug > 1) 190 printk("cx24116: %s: write reg 0x%02x, value 0x%02x\n", 191 + __func__, reg, data); 192 193 + err = i2c_transfer(state->i2c, &msg, 1); 194 + if (err != 1) { 195 + printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x," 196 " value == 0x%02x)\n", __func__, err, reg, data); 197 return -EREMOTEIO; 198 } ··· 200 } 201 202 /* Bulk byte writes to a single I2C address, for 32k firmware load */ 203 + static int cx24116_writeregN(struct cx24116_state *state, int reg, 204 + const u8 *data, u16 len) 205 { 206 int ret = -EREMOTEIO; 207 struct i2c_msg msg; ··· 221 msg.buf = buf; 222 msg.len = len + 1; 223 224 + if (debug > 1) 225 + printk(KERN_INFO "cx24116: %s: write regN 0x%02x, len = %d\n", 226 + __func__, reg, len); 227 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", 231 __func__, ret, reg); 232 ret = -EREMOTEIO; 233 } ··· 237 return ret; 238 } 239 240 + static int cx24116_readreg(struct cx24116_state *state, u8 reg) 241 { 242 int ret; 243 u8 b0[] = { reg }; 244 u8 b1[] = { 0 }; 245 struct i2c_msg msg[] = { 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 } 250 }; 251 252 ret = i2c_transfer(state->i2c, msg, 2); 253 254 if (ret != 2) { 255 + printk(KERN_ERR "%s: reg=0x%x (error=%d)\n", 256 + __func__, reg, ret); 257 return ret; 258 } 259 260 + if (debug > 1) 261 + printk(KERN_INFO "cx24116: read reg 0x%02x, value 0x%02x\n", 262 + reg, b1[0]); 263 264 return b1[0]; 265 } 266 267 + static int cx24116_set_inversion(struct cx24116_state *state, 268 + fe_spectral_inversion_t inversion) 269 { 270 dprintk("%s(%d)\n", __func__, inversion); 271 ··· 308 * Eg.(2/3) szap "Zone Horror" 309 * 310 * mask/val = 0x04, 0x20 311 + * status 1f | signal c3c0 | snr a333 | ber 00000098 | unc 0 | FE_HAS_LOCK 312 * 313 * mask/val = 0x04, 0x30 314 + * status 1f | signal c3c0 | snr a333 | ber 00000000 | unc 0 | FE_HAS_LOCK 315 * 316 * After tuning FECSTATUS contains actual FEC 317 * in use numbered 1 through to 8 for 1/2 .. 2/3 etc ··· 389 */ 390 }; 391 392 + static int cx24116_lookup_fecmod(struct cx24116_state *state, 393 fe_modulation_t m, fe_code_rate_t f) 394 { 395 int i, ret = -EOPNOTSUPP; 396 397 dprintk("%s(0x%02x,0x%02x)\n", __func__, m, f); 398 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)) { 402 ret = i; 403 break; 404 } ··· 409 return ret; 410 } 411 412 + static int cx24116_set_fec(struct cx24116_state *state, 413 + fe_modulation_t mod, fe_code_rate_t fec) 414 { 415 int ret = 0; 416 ··· 417 418 ret = cx24116_lookup_fecmod(state, mod, fec); 419 420 + if (ret < 0) 421 return ret; 422 423 state->dnxt.fec = fec; ··· 429 return 0; 430 } 431 432 + static int cx24116_set_symbolrate(struct cx24116_state *state, u32 rate) 433 { 434 dprintk("%s(%d)\n", __func__, rate); 435 ··· 446 return 0; 447 } 448 449 + static int cx24116_load_firmware(struct dvb_frontend *fe, 450 + const struct firmware *fw); 451 452 + static int cx24116_firmware_ondemand(struct dvb_frontend *fe) 453 { 454 struct cx24116_state *state = fe->demodulator_priv; 455 const struct firmware *fw; 456 int ret = 0; 457 458 + dprintk("%s()\n", __func__); 459 460 + if (cx24116_readreg(state, 0x20) > 0) { 461 462 if (state->skip_fw_load) 463 return 0; 464 465 /* Load firmware */ 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__); 473 if (ret) { 474 + printk(KERN_ERR "%s: No firmware uploaded " 475 + "(timeout or file not found?)\n", __func__); 476 return ret; 477 } 478 479 + /* Make sure we don't recurse back through here 480 + * during loading */ 481 state->skip_fw_load = 1; 482 483 ret = cx24116_load_firmware(fe, fw); 484 if (ret) 485 + printk(KERN_ERR "%s: Writing firmware to device failed\n", 486 + __func__); 487 488 release_firmware(fw); 489 490 + printk(KERN_INFO "%s: Firmware upload %s\n", __func__, 491 + ret == 0 ? "complete" : "failed"); 492 493 /* Ensure firmware is always loaded if required */ 494 state->skip_fw_load = 0; ··· 490 return ret; 491 } 492 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) 497 { 498 struct cx24116_state *state = fe->demodulator_priv; 499 int i, ret; ··· 499 dprintk("%s()\n", __func__); 500 501 /* Load the firmware if required */ 502 + ret = cx24116_firmware_ondemand(fe); 503 + if (ret != 0) { 504 + printk(KERN_ERR "%s(): Unable initialise the firmware\n", 505 + __func__); 506 return ret; 507 } 508 509 /* Write the command */ 510 + for (i = 0; i < cmd->len ; i++) { 511 dprintk("%s: 0x%02x == 0x%02x\n", __func__, i, cmd->args[i]); 512 cx24116_writereg(state, i, cmd->args[i]); 513 } 514 515 /* Start execution and wait for cmd to terminate */ 516 cx24116_writereg(state, CX24116_REG_EXECUTE, 0x01); 517 + while (cx24116_readreg(state, CX24116_REG_EXECUTE)) { 518 msleep(10); 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__); 524 return -EREMOTEIO; 525 } 526 } 527 return 0; 528 } 529 530 + static int cx24116_load_firmware(struct dvb_frontend *fe, 531 + const struct firmware *fw) 532 { 533 + struct cx24116_state *state = fe->demodulator_priv; 534 struct cx24116_cmd cmd; 535 int i, ret; 536 unsigned char vers[4]; 537 538 dprintk("%s\n", __func__); 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]); 545 546 /* Toggle 88x SRST pin to reset demod */ 547 if (state->config->reset_device) ··· 587 cmd.args[0x07] = 0x9d; 588 cmd.args[0x08] = 0xfc; 589 cmd.args[0x09] = 0x06; 590 + cmd.len = 0x0a; 591 ret = cx24116_cmd_execute(fe, &cmd); 592 if (ret != 0) 593 return ret; ··· 598 cmd.args[0x00] = CMD_TUNERINIT; 599 cmd.args[0x01] = 0x00; 600 cmd.args[0x02] = 0x00; 601 + cmd.len = 0x03; 602 ret = cx24116_cmd_execute(fe, &cmd); 603 if (ret != 0) 604 return ret; ··· 615 else 616 cmd.args[0x04] = 0x02; 617 cmd.args[0x05] = 0x00; 618 + cmd.len = 0x06; 619 ret = cx24116_cmd_execute(fe, &cmd); 620 if (ret != 0) 621 return ret; 622 623 /* Firmware CMD 35: Get firmware version */ 624 cmd.args[0x00] = CMD_UPDFWVERS; 625 + cmd.len = 0x02; 626 + for (i = 0; i < 4; i++) { 627 cmd.args[0x01] = i; 628 ret = cx24116_cmd_execute(fe, &cmd); 629 if (ret != 0) 630 return ret; 631 + vers[i] = cx24116_readreg(state, CX24116_REG_MAILBOX); 632 } 633 + printk(KERN_INFO "%s: FW version %i.%i.%i.%i\n", __func__, 634 vers[0], vers[1], vers[2], vers[3]); 635 636 return 0; 637 } 638 639 + static int cx24116_set_voltage(struct dvb_frontend *fe, 640 + fe_sec_voltage_t voltage) 641 { 642 /* The isl6421 module will override this function in the fops. */ 643 + dprintk("%s() This should never appear if the isl6421 module " 644 + "is loaded correctly\n", __func__); 645 646 return -EOPNOTSUPP; 647 } 648 649 + static int cx24116_read_status(struct dvb_frontend *fe, fe_status_t *status) 650 { 651 struct cx24116_state *state = fe->demodulator_priv; 652 ··· 666 return 0; 667 } 668 669 + static int cx24116_read_ber(struct dvb_frontend *fe, u32 *ber) 670 { 671 struct cx24116_state *state = fe->demodulator_priv; 672 673 dprintk("%s()\n", __func__); 674 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); 679 680 return 0; 681 } 682 683 /* TODO Determine function and scale appropriately */ 684 + static int cx24116_read_signal_strength(struct dvb_frontend *fe, 685 + u16 *signal_strength) 686 { 687 struct cx24116_state *state = fe->demodulator_priv; 688 struct cx24116_cmd cmd; ··· 692 693 /* Firmware CMD 19: Get AGC */ 694 cmd.args[0x00] = CMD_GETAGC; 695 + cmd.len = 0x01; 696 ret = cx24116_cmd_execute(fe, &cmd); 697 if (ret != 0) 698 return ret; 699 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; 705 706 + dprintk("%s: raw / cooked = 0x%04x / 0x%04x\n", 707 + __func__, sig_reading, *signal_strength); 708 709 return 0; 710 } 711 712 /* SNR (0..100)% = (sig & 0xf0) * 10 + (sig & 0x0f) * 10 / 16 */ 713 + static int cx24116_read_snr_pct(struct dvb_frontend *fe, u16 *snr) 714 { 715 struct cx24116_state *state = fe->demodulator_priv; 716 u8 snr_reading; 717 static const u32 snr_tab[] = { /* 10 x Table (rounded up) */ 718 + 0x00000, 0x0199A, 0x03333, 0x04ccD, 0x06667, 719 + 0x08000, 0x0999A, 0x0b333, 0x0cccD, 0x0e667, 720 + 0x10000, 0x1199A, 0x13333, 0x14ccD, 0x16667, 721 + 0x18000 }; 722 723 dprintk("%s()\n", __func__); 724 725 snr_reading = cx24116_readreg(state, CX24116_REG_QUALITY0); 726 727 + if (snr_reading >= 0xa0 /* 100% */) 728 *snr = 0xffff; 729 else 730 + *snr = snr_tab[(snr_reading & 0xf0) >> 4] + 731 + (snr_tab[(snr_reading & 0x0f)] >> 4); 732 733 dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__, 734 snr_reading, *snr); ··· 736 * ESNO, from 0->30db (values 0->300). We provide this value by 737 * default. 738 */ 739 + static int cx24116_read_snr_esno(struct dvb_frontend *fe, u16 *snr) 740 { 741 struct cx24116_state *state = fe->demodulator_priv; 742 ··· 750 return 0; 751 } 752 753 + static int cx24116_read_snr(struct dvb_frontend *fe, u16 *snr) 754 { 755 if (esno_snr == 1) 756 return cx24116_read_snr_esno(fe, snr); ··· 758 return cx24116_read_snr_pct(fe, snr); 759 } 760 761 + static int cx24116_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) 762 { 763 struct cx24116_state *state = fe->demodulator_priv; 764 765 dprintk("%s()\n", __func__); 766 767 + *ucblocks = (cx24116_readreg(state, CX24116_REG_UCB8) << 8) | 768 cx24116_readreg(state, CX24116_REG_UCB0); 769 770 return 0; 771 } 772 773 /* Overwrite the current tuning params, we are about to tune */ 774 + static void cx24116_clone_params(struct dvb_frontend *fe) 775 { 776 struct cx24116_state *state = fe->demodulator_priv; 777 memcpy(&state->dcur, &state->dnxt, sizeof(state->dcur)); 778 } 779 780 /* Wait for LNB */ 781 + static int cx24116_wait_for_lnb(struct dvb_frontend *fe) 782 { 783 struct cx24116_state *state = fe->demodulator_priv; 784 int i; ··· 787 cx24116_readreg(state, CX24116_REG_QSTATUS)); 788 789 /* Wait for up to 300 ms */ 790 + for (i = 0; i < 30 ; i++) { 791 if (cx24116_readreg(state, CX24116_REG_QSTATUS) & 0x20) 792 return 0; 793 msleep(10); ··· 798 return -ETIMEDOUT; /* -EBUSY ? */ 799 } 800 801 + static int cx24116_set_tone(struct dvb_frontend *fe, 802 + fe_sec_tone_mode_t tone) 803 { 804 struct cx24116_cmd cmd; 805 int ret; 806 807 dprintk("%s(%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); 810 return -EINVAL; 811 } 812 813 /* Wait for LNB ready */ 814 ret = cx24116_wait_for_lnb(fe); 815 + if (ret != 0) 816 return ret; 817 818 /* Min delay time after DiSEqC send */ ··· 820 /* This is always done before the tone is set */ 821 cmd.args[0x00] = CMD_SET_TONEPRE; 822 cmd.args[0x01] = 0x00; 823 + cmd.len = 0x02; 824 ret = cx24116_cmd_execute(fe, &cmd); 825 if (ret != 0) 826 return ret; ··· 836 cmd.args[0x03] = 0x01; 837 break; 838 case SEC_TONE_OFF: 839 + dprintk("%s: setting tone off\n", __func__); 840 cmd.args[0x03] = 0x00; 841 break; 842 } 843 + cmd.len = 0x04; 844 845 /* Min delay time before DiSEqC send */ 846 msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ ··· 849 } 850 851 /* Initialise DiSEqC */ 852 + static int cx24116_diseqc_init(struct dvb_frontend *fe) 853 { 854 struct cx24116_state *state = fe->demodulator_priv; 855 struct cx24116_cmd cmd; ··· 864 cmd.args[0x05] = 0x28; 865 cmd.args[0x06] = (toneburst == CX24116_DISEQC_TONEOFF) ? 0x00 : 0x01; 866 cmd.args[0x07] = 0x01; 867 + cmd.len = 0x08; 868 ret = cx24116_cmd_execute(fe, &cmd); 869 if (ret != 0) 870 return ret; ··· 878 /* Unknown */ 879 state->dsec_cmd.args[CX24116_DISEQC_ARG2_2] = 0x02; 880 state->dsec_cmd.args[CX24116_DISEQC_ARG3_0] = 0x00; 881 + /* Continuation flag? */ 882 + state->dsec_cmd.args[CX24116_DISEQC_ARG4_0] = 0x00; 883 884 /* DiSEqC message length */ 885 state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = 0x00; 886 887 /* Command length */ 888 + state->dsec_cmd.len = CX24116_DISEQC_MSGOFS; 889 890 return 0; 891 } 892 893 /* Send DiSEqC message with derived burst (hack) || previous burst */ 894 + static int cx24116_send_diseqc_msg(struct dvb_frontend *fe, 895 + struct dvb_diseqc_master_cmd *d) 896 { 897 struct cx24116_state *state = fe->demodulator_priv; 898 int i, ret; 899 900 /* Dump DiSEqC message */ 901 if (debug) { 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 + } 908 printk(") toneburst=%d\n", toneburst); 909 } 910 911 /* Validate length */ 912 + if (d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS)) 913 return -EINVAL; 914 915 /* DiSEqC message */ ··· 918 state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = d->msg_len; 919 920 /* Command length */ 921 + state->dsec_cmd.len = CX24116_DISEQC_MSGOFS + 922 + state->dsec_cmd.args[CX24116_DISEQC_MSGLEN]; 923 924 /* DiSEqC toneburst */ 925 + if (toneburst == CX24116_DISEQC_MESGCACHE) 926 /* Message is cached */ 927 return 0; 928 929 + else if (toneburst == CX24116_DISEQC_TONEOFF) 930 /* Message is sent without burst */ 931 state->dsec_cmd.args[CX24116_DISEQC_BURST] = 0; 932 933 + else if (toneburst == CX24116_DISEQC_TONECACHE) { 934 /* 935 * Message is sent with derived else cached burst 936 * ··· 948 * Y = VOLTAGE (0=13V, 1=18V) 949 * Z = BAND (0=LOW, 1=HIGH(22K)) 950 */ 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]); 957 } 958 959 /* Wait for LNB ready */ 960 ret = cx24116_wait_for_lnb(fe); 961 + if (ret != 0) 962 return ret; 963 964 /* Wait for voltage/min repeat delay */ ··· 964 965 /* Command */ 966 ret = cx24116_cmd_execute(fe, &state->dsec_cmd); 967 + if (ret != 0) 968 return ret; 969 /* 970 * Wait for send ··· 976 * 12.5ms burst + 977 * >15ms delay (XXX determine if FW does this, see set_tone) 978 */ 979 + msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 980 + ((toneburst == CX24116_DISEQC_TONEOFF) ? 30 : 60)); 981 982 return 0; 983 } 984 985 /* Send DiSEqC burst */ 986 + static int cx24116_diseqc_send_burst(struct dvb_frontend *fe, 987 + fe_sec_mini_cmd_t burst) 988 { 989 struct cx24116_state *state = fe->demodulator_priv; 990 int ret; 991 992 + dprintk("%s(%d) toneburst=%d\n", __func__, burst, toneburst); 993 994 /* DiSEqC burst */ 995 if (burst == SEC_MINI_A) 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; 1001 else 1002 return -EINVAL; 1003 1004 /* DiSEqC toneburst */ 1005 + if (toneburst != CX24116_DISEQC_MESGCACHE) 1006 /* Burst is cached */ 1007 return 0; 1008 ··· 1006 1007 /* Wait for LNB ready */ 1008 ret = cx24116_wait_for_lnb(fe); 1009 + if (ret != 0) 1010 return ret; 1011 1012 /* Wait for voltage/min repeat delay */ ··· 1014 1015 /* Command */ 1016 ret = cx24116_cmd_execute(fe, &state->dsec_cmd); 1017 + if (ret != 0) 1018 return ret; 1019 1020 /* ··· 1027 * 12.5ms burst + 1028 * >15ms delay (XXX determine if FW does this, see set_tone) 1029 */ 1030 + msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 60); 1031 1032 return 0; 1033 } 1034 1035 + static void cx24116_release(struct dvb_frontend *fe) 1036 { 1037 + struct cx24116_state *state = fe->demodulator_priv; 1038 + dprintk("%s\n", __func__); 1039 kfree(state); 1040 } 1041 1042 static struct dvb_frontend_ops cx24116_ops; 1043 1044 + struct dvb_frontend *cx24116_attach(const struct cx24116_config *config, 1045 + struct i2c_adapter *i2c) 1046 { 1047 + struct cx24116_state *state = NULL; 1048 int ret; 1049 1050 + dprintk("%s\n", __func__); 1051 1052 /* allocate memory for the internal state */ 1053 state = kmalloc(sizeof(struct cx24116_state), GFP_KERNEL); 1054 + if (state == NULL) 1055 goto error1; 1056 1057 /* setup the state */ 1058 memset(state, 0, sizeof(struct cx24116_state)); ··· 1063 state->i2c = i2c; 1064 1065 /* check if the demod is present */ 1066 + ret = (cx24116_readreg(state, 0xFF) << 8) | 1067 + cx24116_readreg(state, 0xFE); 1068 if (ret != 0x0501) { 1069 + printk(KERN_INFO "Invalid probe, probably not a CX24116 device\n"); 1070 goto error2; 1071 } 1072 1073 /* create dvb_frontend */ 1074 + memcpy(&state->frontend.ops, &cx24116_ops, 1075 + sizeof(struct dvb_frontend_ops)); 1076 state->frontend.demodulator_priv = state; 1077 return &state->frontend; 1078 1079 error2: kfree(state); 1080 error1: return NULL; 1081 } 1082 + EXPORT_SYMBOL(cx24116_attach); 1083 + 1084 /* 1085 * Initialise or wake up device 1086 * 1087 * Power config will reset and load initial firmware if required 1088 */ 1089 + static int cx24116_initfe(struct dvb_frontend *fe) 1090 { 1091 + struct cx24116_state *state = fe->demodulator_priv; 1092 struct cx24116_cmd cmd; 1093 int ret; 1094 1095 + dprintk("%s()\n", __func__); 1096 1097 /* Power on */ 1098 cx24116_writereg(state, 0xe0, 0); ··· 1098 /* Firmware CMD 36: Power config */ 1099 cmd.args[0x00] = CMD_TUNERSLEEP; 1100 cmd.args[0x01] = 0; 1101 + cmd.len = 0x02; 1102 ret = cx24116_cmd_execute(fe, &cmd); 1103 + if (ret != 0) 1104 return ret; 1105 1106 return cx24116_diseqc_init(fe); ··· 1109 /* 1110 * Put device to sleep 1111 */ 1112 + static int cx24116_sleep(struct dvb_frontend *fe) 1113 { 1114 + struct cx24116_state *state = fe->demodulator_priv; 1115 struct cx24116_cmd cmd; 1116 int ret; 1117 1118 + dprintk("%s()\n", __func__); 1119 1120 /* Firmware CMD 36: Power config */ 1121 cmd.args[0x00] = CMD_TUNERSLEEP; 1122 cmd.args[0x01] = 1; 1123 + cmd.len = 0x02; 1124 ret = cx24116_cmd_execute(fe, &cmd); 1125 + if (ret != 0) 1126 return ret; 1127 1128 /* Power off (Shutdown clocks) */ ··· 1133 return 0; 1134 } 1135 1136 + static int cx24116_set_property(struct dvb_frontend *fe, 1137 + struct dtv_property *tvp) 1138 { 1139 dprintk("%s(..)\n", __func__); 1140 return 0; 1141 } 1142 1143 + static int cx24116_get_property(struct dvb_frontend *fe, 1144 + struct dtv_property *tvp) 1145 { 1146 dprintk("%s(..)\n", __func__); 1147 return 0; ··· 1148 /* dvb-core told us to tune, the tv property cache will be complete, 1149 * it's safe for is to pull values and use them for tuning purposes. 1150 */ 1151 + static int cx24116_set_frontend(struct dvb_frontend *fe, 1152 + struct dvb_frontend_parameters *p) 1153 { 1154 struct cx24116_state *state = fe->demodulator_priv; 1155 struct dtv_frontend_properties *c = &fe->dtv_property_cache; ··· 1156 fe_status_t tunerstat; 1157 int i, status, ret, retune; 1158 1159 + dprintk("%s()\n", __func__); 1160 1161 + switch (c->delivery_system) { 1162 + case SYS_DVBS: 1163 + dprintk("%s: DVB-S delivery system selected\n", __func__); 1164 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 + } 1171 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: 1205 state->dnxt.pilot_val = CX24116_PILOT_OFF; 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 + } 1215 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: 1224 state->dnxt.rolloff_val = CX24116_ROLLOFF_035; 1225 break; 1226 + case ROLLOFF_AUTO: /* Rolloff must be explicit */ 1227 default: 1228 + dprintk("%s: unsupported rolloff selected (%d)\n", 1229 + __func__, c->rolloff); 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; 1238 } 1239 state->dnxt.modulation = c->modulation; 1240 state->dnxt.frequency = c->frequency; 1241 state->dnxt.pilot = c->pilot; 1242 state->dnxt.rolloff = c->rolloff; 1243 1244 + ret = cx24116_set_inversion(state, c->inversion); 1245 + if (ret != 0) 1246 return ret; 1247 1248 /* FEC_NONE/AUTO for DVB-S2 is not supported and detected here */ 1249 + ret = cx24116_set_fec(state, c->modulation, c->fec_inner); 1250 + if (ret != 0) 1251 return ret; 1252 1253 + ret = cx24116_set_symbolrate(state, c->symbol_rate); 1254 + if (ret != 0) 1255 return ret; 1256 1257 /* discard the 'current' tuning parameters and prepare to tune */ ··· 1271 /* Set/Reset B/W */ 1272 cmd.args[0x00] = CMD_BANDWIDTH; 1273 cmd.args[0x01] = 0x01; 1274 + cmd.len = 0x02; 1275 ret = cx24116_cmd_execute(fe, &cmd); 1276 if (ret != 0) 1277 return ret; ··· 1319 cx24116_writereg(state, CX24116_REG_RATEDIV, 0x00); 1320 } 1321 1322 + cmd.len = 0x13; 1323 1324 /* We need to support pilot and non-pilot tuning in the 1325 * driver automatically. This is a workaround for because ··· 1327 */ 1328 do { 1329 /* Reset status register */ 1330 + status = cx24116_readreg(state, CX24116_REG_SSTATUS) 1331 + & CX24116_SIGNAL_MASK; 1332 cx24116_writereg(state, CX24116_REG_SSTATUS, status); 1333 1334 /* Tune */ 1335 ret = cx24116_cmd_execute(fe, &cmd); 1336 + if (ret != 0) 1337 break; 1338 1339 /* ··· 1341 * If we are able to tune then generally it occurs within 100ms. 1342 * If it takes longer, try a different toneburst setting. 1343 */ 1344 + for (i = 0; i < 50 ; i++) { 1345 cx24116_read_status(fe, &tunerstat); 1346 status = tunerstat & (FE_HAS_SIGNAL | FE_HAS_SYNC); 1347 + if (status == (FE_HAS_SIGNAL | FE_HAS_SYNC)) { 1348 + dprintk("%s: Tuned\n", __func__); 1349 goto tuned; 1350 } 1351 msleep(10); 1352 } 1353 1354 + dprintk("%s: Not tuned\n", __func__); 1355 1356 /* Toggle pilot bit when in auto-pilot */ 1357 + if (state->dcur.pilot == PILOT_AUTO) 1358 cmd.args[0x07] ^= CX24116_PILOT_ON; 1359 + } while (--retune); 1360 1361 tuned: /* Set/Reset B/W */ 1362 cmd.args[0x00] = CMD_BANDWIDTH; 1363 cmd.args[0x01] = 0x00; 1364 + cmd.len = 0x02; 1365 ret = cx24116_cmd_execute(fe, &cmd); 1366 if (ret != 0) 1367 return ret; ··· 1407 .set_frontend = cx24116_set_frontend, 1408 }; 1409 1410 MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware"); 1411 MODULE_AUTHOR("Steven Toth"); 1412 MODULE_LICENSE("GPL"); 1413
+11 -10
drivers/media/dvb/frontends/cx24116.h
··· 23 24 #include <linux/dvb/frontend.h> 25 26 - struct cx24116_config 27 - { 28 /* the demodulator's i2c address */ 29 u8 demod_address; 30 31 /* Need to set device param for start_dma */ 32 - int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 33 34 /* Need to reset device during firmware loading */ 35 - int (*reset_device)(struct dvb_frontend* fe); 36 37 /* Need to set MPEG parameters */ 38 u8 mpg_clk_pos_pol:0x02; 39 }; 40 41 #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); 44 #else 45 - static inline struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, 46 - struct i2c_adapter* i2c) 47 { 48 - printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); 49 return NULL; 50 } 51 - #endif // CONFIG_DVB_CX24116 52 53 #endif /* CX24116_H */
··· 23 24 #include <linux/dvb/frontend.h> 25 26 + struct cx24116_config { 27 /* the demodulator's i2c address */ 28 u8 demod_address; 29 30 /* Need to set device param for start_dma */ 31 + int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured); 32 33 /* Need to reset device during firmware loading */ 34 + int (*reset_device)(struct dvb_frontend *fe); 35 36 /* Need to set MPEG parameters */ 37 u8 mpg_clk_pos_pol:0x02; 38 }; 39 40 #if defined(CONFIG_DVB_CX24116) || defined(CONFIG_DVB_CX24116_MODULE) 41 + extern struct dvb_frontend *cx24116_attach( 42 + const struct cx24116_config *config, 43 + struct i2c_adapter *i2c); 44 #else 45 + static inline struct dvb_frontend *cx24116_attach( 46 + const struct cx24116_config *config, 47 + struct i2c_adapter *i2c) 48 { 49 + printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 50 return NULL; 51 } 52 + #endif 53 54 #endif /* CX24116_H */
+128 -100
drivers/media/dvb/frontends/cx24123.c
··· 33 #define XTAL 10111000 34 35 static int force_band; 36 static int debug; 37 38 #define info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0) 39 #define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0) ··· 52 } \ 53 } while (0) 54 55 - struct cx24123_state 56 - { 57 - struct i2c_adapter* i2c; 58 - const struct cx24123_config* config; 59 60 struct dvb_frontend frontend; 61 ··· 75 }; 76 77 /* Various tuner defaults need to be established for a given symbol rate Sps */ 78 - static struct 79 - { 80 u32 symbolrate_low; 81 u32 symbolrate_high; 82 u32 VCAprogdata; ··· 113 * fixme: The bounds on the bands do not match the doc in real life. 114 * fixme: Some of them have been moved, other might need adjustment. 115 */ 116 - static struct 117 - { 118 u32 freq_low; 119 u32 freq_high; 120 u32 VCOdivider; ··· 252 253 /* printk(KERN_DEBUG "wr(%02x): %02x %02x\n", i2c_addr, reg, data); */ 254 255 - if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 256 printk("%s: writereg error(err == %i, reg == 0x%02x," 257 " data == 0x%02x)\n", __func__, err, reg, data); 258 return err; ··· 288 #define cx24123_writereg(state, reg, val) \ 289 cx24123_i2c_writereg(state, state->config->demod_address, reg, val) 290 291 - static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) 292 { 293 u8 nom_reg = cx24123_readreg(state, 0x0e); 294 u8 auto_reg = cx24123_readreg(state, 0x10); ··· 316 return 0; 317 } 318 319 - static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_inversion_t *inversion) 320 { 321 u8 val; 322 ··· 334 return 0; 335 } 336 337 - static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) 338 { 339 u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07; 340 341 - if ( (fec < FEC_NONE) || (fec > FEC_AUTO) ) 342 fec = FEC_AUTO; 343 344 /* Set the soft decision threshold */ 345 - if(fec == FEC_1_2) 346 - cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) | 0x01); 347 else 348 - cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) & ~0x01); 349 350 switch (fec) { 351 case FEC_1_2: ··· 396 return 0; 397 } 398 399 - static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec) 400 { 401 int ret; 402 403 - ret = cx24123_readreg (state, 0x1b); 404 if (ret < 0) 405 return ret; 406 ret = ret & 0x07; ··· 441 { 442 u32 exp, nearest = 0; 443 u32 div = a / b; 444 - if(a % b >= b / 2) ++div; 445 - if(div < (1 << 31)) 446 - { 447 - for(exp = 1; div > exp; nearest++) 448 exp += exp; 449 } 450 return nearest; 451 } 452 453 - static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) 454 { 455 u32 tmp, sample_rate, ratio, sample_gain; 456 u8 pll_mult; ··· 506 507 cx24123_writereg(state, 0x01, pll_mult * 6); 508 509 - cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f ); 510 - cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff ); 511 - cx24123_writereg(state, 0x0a, (ratio ) & 0xff ); 512 513 /* also set the demodulator sample gain */ 514 sample_gain = cx24123_int_log2(sample_rate, srate); ··· 522 } 523 524 /* 525 - * Based on the required frequency and symbolrate, the tuner AGC has to be configured 526 - * and the correct band selected. Calculate those values 527 */ 528 - static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 529 { 530 struct cx24123_state *state = fe->demodulator_priv; 531 u32 ndiv = 0, adiv = 0, vco_div = 0; ··· 535 int pump = 2; 536 int band = 0; 537 int num_bands = ARRAY_SIZE(cx24123_bandselect_vals); 538 539 /* Defaults for low freq, low rate */ 540 state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; ··· 544 state->bandselectarg = cx24123_bandselect_vals[0].progdata; 545 vco_div = cx24123_bandselect_vals[0].VCOdivider; 546 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; 555 } 556 } 557 558 /* 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) ) 565 band = i; 566 } 567 - } 568 - else 569 band = force_band - 1; 570 571 state->bandselectarg = cx24123_bandselect_vals[band].progdata; 572 vco_div = cx24123_bandselect_vals[band].VCOdivider; 573 574 /* determine the charge pump current */ 575 - if ( p->frequency < (cx24123_bandselect_vals[band].freq_low + cx24123_bandselect_vals[band].freq_high)/2 ) 576 pump = 0x01; 577 else 578 pump = 0x02; 579 580 /* 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; 584 585 if (adiv == 0 && ndiv > 0) 586 ndiv--; 587 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; 590 591 return 0; 592 } 593 594 /* 595 * 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. 597 */ 598 - static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_parameters *p, u32 data) 599 { 600 struct cx24123_state *state = fe->demodulator_priv; 601 unsigned long timeout; ··· 629 630 /* send another 8 bytes, wait for the send to be completed */ 631 timeout = jiffies + msecs_to_jiffies(40); 632 - cx24123_writereg(state, 0x22, (data>>8) & 0xff ); 633 while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { 634 if (time_after(jiffies, timeout)) { 635 err("%s: demodulator is not responding, "\ ··· 639 msleep(10); 640 } 641 642 - /* send the lower 5 bits of this byte, padded with 3 LBB, wait for the send to be completed */ 643 timeout = jiffies + msecs_to_jiffies(40); 644 - cx24123_writereg(state, 0x22, (data) & 0xff ); 645 while ((cx24123_readreg(state, 0x20) & 0x80)) { 646 if (time_after(jiffies, timeout)) { 647 err("%s: demodulator is not responding," \ ··· 659 return 0; 660 } 661 662 - static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 663 { 664 struct cx24123_state *state = fe->demodulator_priv; 665 u8 val; ··· 711 return cx24123_writereg(state, 0x23, r); 712 } 713 714 - static int cx24123_initfe(struct dvb_frontend* fe) 715 { 716 struct cx24123_state *state = fe->demodulator_priv; 717 int i; ··· 720 721 /* Configure the demod to a good set of defaults */ 722 for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++) 723 - cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); 724 725 /* Set the LNB polarity */ 726 - if(state->config->lnb_polarity) 727 - cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02); 728 729 if (state->config->dont_use_pll) 730 - cx24123_repeater_mode(state, 1, 0); 731 732 return 0; 733 } 734 735 - static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 736 { 737 struct cx24123_state *state = fe->demodulator_priv; 738 u8 val; ··· 764 { 765 unsigned long timeout = jiffies + msecs_to_jiffies(200); 766 while (!(cx24123_readreg(state, 0x29) & 0x40)) { 767 - if(time_after(jiffies, timeout)) { 768 err("%s: diseqc queue not ready, " \ 769 "command may be lost.\n", __func__); 770 break; ··· 773 } 774 } 775 776 - static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd) 777 { 778 struct cx24123_state *state = fe->demodulator_priv; 779 int i, val, tone; ··· 796 cx24123_writereg(state, 0x2C + i, cmd->msg[i]); 797 798 val = cx24123_readreg(state, 0x29); 799 - cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); 800 801 /* wait for diseqc message to finish sending */ 802 cx24123_wait_for_diseqc(state); 803 804 /* restart continuous tone if enabled */ 805 - if (tone & 0x10) { 806 cx24123_writereg(state, 0x29, tone & ~0x40); 807 - } 808 809 return 0; 810 } 811 812 - static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) 813 { 814 struct cx24123_state *state = fe->demodulator_priv; 815 int val, tone; ··· 840 cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb); 841 842 /* restart continuous tone if enabled */ 843 - if (tone & 0x10) { 844 cx24123_writereg(state, 0x29, tone & ~0x40); 845 - } 846 return 0; 847 } 848 849 - static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) 850 { 851 struct cx24123_state *state = fe->demodulator_priv; 852 int sync = cx24123_readreg(state, 0x14); ··· 879 } 880 881 /* 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 884 */ 885 static int cx24123_read_ber(struct dvb_frontend *fe, u32 *ber) 886 { ··· 903 { 904 struct cx24123_state *state = fe->demodulator_priv; 905 906 - *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ 907 908 dprintk("Signal strength = %d\n", *signal_strength); 909 ··· 935 if (state->config->set_ts_params) 936 state->config->set_ts_params(fe, 0); 937 938 - state->currentfreq=p->frequency; 939 state->currentsymbolrate = p->u.qpsk.symbol_rate; 940 941 cx24123_set_inversion(state, p->inversion); ··· 960 return 0; 961 } 962 963 - static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 964 { 965 struct cx24123_state *state = fe->demodulator_priv; 966 ··· 981 return 0; 982 } 983 984 - static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 985 { 986 struct cx24123_state *state = fe->demodulator_priv; 987 u8 val; ··· 1006 return 0; 1007 } 1008 1009 - static int cx24123_tune(struct dvb_frontend* fe, 1010 - struct dvb_frontend_parameters* params, 1011 unsigned int mode_flags, 1012 unsigned int *delay, 1013 fe_status_t *status) ··· 1026 1027 static int cx24123_get_algo(struct dvb_frontend *fe) 1028 { 1029 - return 1; //FE_ALGO_HW 1030 } 1031 1032 - static void cx24123_release(struct dvb_frontend* fe) 1033 { 1034 - struct cx24123_state* state = fe->demodulator_priv; 1035 dprintk("\n"); 1036 i2c_del_adapter(&state->tuner_i2c_adapter); 1037 kfree(state); ··· 1042 { 1043 struct cx24123_state *state = i2c_get_adapdata(i2c_adap); 1044 /* this repeater closes after the first stop */ 1045 - cx24123_repeater_mode(state, 1, 1); 1046 return i2c_transfer(state->i2c, msg, num); 1047 } 1048 ··· 1066 1067 static struct dvb_frontend_ops cx24123_ops; 1068 1069 - struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, 1070 - struct i2c_adapter* i2c) 1071 { 1072 struct cx24123_state *state = 1073 kzalloc(sizeof(struct cx24123_state), GFP_KERNEL); ··· 1086 /* check if the demod is there */ 1087 state->demod_rev = cx24123_readreg(state, 0x00); 1088 switch (state->demod_rev) { 1089 - case 0xe1: info("detected CX24123C\n"); break; 1090 - case 0xd1: info("detected CX24123\n"); break; 1091 default: 1092 err("wrong demod revision: %x\n", state->demod_rev); 1093 goto error; 1094 } 1095 1096 /* create dvb_frontend */ 1097 - memcpy(&state->frontend.ops, &cx24123_ops, sizeof(struct dvb_frontend_ops)); 1098 state->frontend.demodulator_priv = state; 1099 1100 - /* create tuner i2c adapter */ 1101 - if (config->dont_use_pll) 1102 - cx24123_repeater_mode(state, 1, 0); 1103 1104 strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus", 1105 sizeof(state->tuner_i2c_adapter.name)); ··· 1113 state->tuner_i2c_adapter.algo_data = NULL; 1114 i2c_set_adapdata(&state->tuner_i2c_adapter, state); 1115 if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) { 1116 - err("tuner i2c bus could not be initialized\n"); 1117 goto error; 1118 } 1119 ··· 1124 1125 return NULL; 1126 } 1127 1128 static struct dvb_frontend_ops cx24123_ops = { 1129 ··· 1161 .get_frontend_algo = cx24123_get_algo, 1162 }; 1163 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 MODULE_DESCRIPTION("DVB Frontend module for Conexant " \ 1171 "CX24123/CX24109/CX24113 hardware"); 1172 MODULE_AUTHOR("Steven Toth"); 1173 MODULE_LICENSE("GPL"); 1174 1175 - EXPORT_SYMBOL(cx24123_attach);
··· 33 #define XTAL 10111000 34 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 + 40 static int debug; 41 + module_param(debug, int, 0644); 42 + MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); 43 44 #define info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0) 45 #define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0) ··· 46 } \ 47 } while (0) 48 49 + struct cx24123_state { 50 + struct i2c_adapter *i2c; 51 + const struct cx24123_config *config; 52 53 struct dvb_frontend frontend; 54 ··· 70 }; 71 72 /* Various tuner defaults need to be established for a given symbol rate Sps */ 73 + static struct cx24123_AGC_val { 74 u32 symbolrate_low; 75 u32 symbolrate_high; 76 u32 VCAprogdata; ··· 109 * fixme: The bounds on the bands do not match the doc in real life. 110 * fixme: Some of them have been moved, other might need adjustment. 111 */ 112 + static struct cx24123_bandselect_val { 113 u32 freq_low; 114 u32 freq_high; 115 u32 VCOdivider; ··· 249 250 /* printk(KERN_DEBUG "wr(%02x): %02x %02x\n", i2c_addr, reg, data); */ 251 252 + err = i2c_transfer(state->i2c, &msg, 1); 253 + if (err != 1) { 254 printk("%s: writereg error(err == %i, reg == 0x%02x," 255 " data == 0x%02x)\n", __func__, err, reg, data); 256 return err; ··· 284 #define cx24123_writereg(state, reg, val) \ 285 cx24123_i2c_writereg(state, state->config->demod_address, reg, val) 286 287 + static int cx24123_set_inversion(struct cx24123_state *state, 288 + fe_spectral_inversion_t inversion) 289 { 290 u8 nom_reg = cx24123_readreg(state, 0x0e); 291 u8 auto_reg = cx24123_readreg(state, 0x10); ··· 311 return 0; 312 } 313 314 + static int cx24123_get_inversion(struct cx24123_state *state, 315 + fe_spectral_inversion_t *inversion) 316 { 317 u8 val; 318 ··· 328 return 0; 329 } 330 331 + static int cx24123_set_fec(struct cx24123_state *state, fe_code_rate_t fec) 332 { 333 u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07; 334 335 + if ((fec < FEC_NONE) || (fec > FEC_AUTO)) 336 fec = FEC_AUTO; 337 338 /* Set the soft decision threshold */ 339 + if (fec == FEC_1_2) 340 + cx24123_writereg(state, 0x43, 341 + cx24123_readreg(state, 0x43) | 0x01); 342 else 343 + cx24123_writereg(state, 0x43, 344 + cx24123_readreg(state, 0x43) & ~0x01); 345 346 switch (fec) { 347 case FEC_1_2: ··· 388 return 0; 389 } 390 391 + static int cx24123_get_fec(struct cx24123_state *state, fe_code_rate_t *fec) 392 { 393 int ret; 394 395 + ret = cx24123_readreg(state, 0x1b); 396 if (ret < 0) 397 return ret; 398 ret = ret & 0x07; ··· 433 { 434 u32 exp, nearest = 0; 435 u32 div = a / b; 436 + if (a % b >= b / 2) 437 + ++div; 438 + if (div < (1 << 31)) { 439 + for (exp = 1; div > exp; nearest++) 440 exp += exp; 441 } 442 return nearest; 443 } 444 445 + static int cx24123_set_symbolrate(struct cx24123_state *state, u32 srate) 446 { 447 u32 tmp, sample_rate, ratio, sample_gain; 448 u8 pll_mult; ··· 498 499 cx24123_writereg(state, 0x01, pll_mult * 6); 500 501 + cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f); 502 + cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff); 503 + cx24123_writereg(state, 0x0a, ratio & 0xff); 504 505 /* also set the demodulator sample gain */ 506 sample_gain = cx24123_int_log2(sample_rate, srate); ··· 514 } 515 516 /* 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. 520 */ 521 + static int cx24123_pll_calculate(struct dvb_frontend *fe, 522 + struct dvb_frontend_parameters *p) 523 { 524 struct cx24123_state *state = fe->demodulator_priv; 525 u32 ndiv = 0, adiv = 0, vco_div = 0; ··· 525 int pump = 2; 526 int band = 0; 527 int num_bands = ARRAY_SIZE(cx24123_bandselect_vals); 528 + struct cx24123_bandselect_val *bsv = NULL; 529 + struct cx24123_AGC_val *agcv = NULL; 530 531 /* Defaults for low freq, low rate */ 532 state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; ··· 532 state->bandselectarg = cx24123_bandselect_vals[0].progdata; 533 vco_div = cx24123_bandselect_vals[0].VCOdivider; 534 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; 544 } 545 } 546 547 /* determine the band to use */ 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)) 553 band = i; 554 } 555 + } else 556 band = force_band - 1; 557 558 state->bandselectarg = cx24123_bandselect_vals[band].progdata; 559 vco_div = cx24123_bandselect_vals[band].VCOdivider; 560 561 /* determine the charge pump current */ 562 + if (p->frequency < (cx24123_bandselect_vals[band].freq_low + 563 + cx24123_bandselect_vals[band].freq_high) / 2) 564 pump = 0x01; 565 else 566 pump = 0x02; 567 568 /* Determine the N/A dividers for the requested lband freq (in kHz). */ 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; 575 576 if (adiv == 0 && ndiv > 0) 577 ndiv--; 578 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; 583 584 return 0; 585 } 586 587 /* 588 * Tuner data is 21 bits long, must be left-aligned in data. 589 + * Tuner cx24109 is written through a dedicated 3wire interface 590 + * on the demod chip. 591 */ 592 + static int cx24123_pll_writereg(struct dvb_frontend *fe, 593 + struct dvb_frontend_parameters *p, u32 data) 594 { 595 struct cx24123_state *state = fe->demodulator_priv; 596 unsigned long timeout; ··· 610 611 /* send another 8 bytes, wait for the send to be completed */ 612 timeout = jiffies + msecs_to_jiffies(40); 613 + cx24123_writereg(state, 0x22, (data >> 8) & 0xff); 614 while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { 615 if (time_after(jiffies, timeout)) { 616 err("%s: demodulator is not responding, "\ ··· 620 msleep(10); 621 } 622 623 + /* send the lower 5 bits of this byte, padded with 3 LBB, 624 + * wait for the send to be completed */ 625 timeout = jiffies + msecs_to_jiffies(40); 626 + cx24123_writereg(state, 0x22, (data) & 0xff); 627 while ((cx24123_readreg(state, 0x20) & 0x80)) { 628 if (time_after(jiffies, timeout)) { 629 err("%s: demodulator is not responding," \ ··· 639 return 0; 640 } 641 642 + static int cx24123_pll_tune(struct dvb_frontend *fe, 643 + struct dvb_frontend_parameters *p) 644 { 645 struct cx24123_state *state = fe->demodulator_priv; 646 u8 val; ··· 690 return cx24123_writereg(state, 0x23, r); 691 } 692 693 + static int cx24123_initfe(struct dvb_frontend *fe) 694 { 695 struct cx24123_state *state = fe->demodulator_priv; 696 int i; ··· 699 700 /* Configure the demod to a good set of defaults */ 701 for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++) 702 + cx24123_writereg(state, cx24123_regdata[i].reg, 703 + cx24123_regdata[i].data); 704 705 /* Set the LNB polarity */ 706 + if (state->config->lnb_polarity) 707 + cx24123_writereg(state, 0x32, 708 + cx24123_readreg(state, 0x32) | 0x02); 709 710 if (state->config->dont_use_pll) 711 + cx24123_repeater_mode(state, 1, 0); 712 713 return 0; 714 } 715 716 + static int cx24123_set_voltage(struct dvb_frontend *fe, 717 + fe_sec_voltage_t voltage) 718 { 719 struct cx24123_state *state = fe->demodulator_priv; 720 u8 val; ··· 740 { 741 unsigned long timeout = jiffies + msecs_to_jiffies(200); 742 while (!(cx24123_readreg(state, 0x29) & 0x40)) { 743 + if (time_after(jiffies, timeout)) { 744 err("%s: diseqc queue not ready, " \ 745 "command may be lost.\n", __func__); 746 break; ··· 749 } 750 } 751 752 + static int cx24123_send_diseqc_msg(struct dvb_frontend *fe, 753 + struct dvb_diseqc_master_cmd *cmd) 754 { 755 struct cx24123_state *state = fe->demodulator_priv; 756 int i, val, tone; ··· 771 cx24123_writereg(state, 0x2C + i, cmd->msg[i]); 772 773 val = cx24123_readreg(state, 0x29); 774 + cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | 775 + ((cmd->msg_len-3) & 3)); 776 777 /* wait for diseqc message to finish sending */ 778 cx24123_wait_for_diseqc(state); 779 780 /* restart continuous tone if enabled */ 781 + if (tone & 0x10) 782 cx24123_writereg(state, 0x29, tone & ~0x40); 783 784 return 0; 785 } 786 787 + static int cx24123_diseqc_send_burst(struct dvb_frontend *fe, 788 + fe_sec_mini_cmd_t burst) 789 { 790 struct cx24123_state *state = fe->demodulator_priv; 791 int val, tone; ··· 814 cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb); 815 816 /* restart continuous tone if enabled */ 817 + if (tone & 0x10) 818 cx24123_writereg(state, 0x29, tone & ~0x40); 819 + 820 return 0; 821 } 822 823 + static int cx24123_read_status(struct dvb_frontend *fe, fe_status_t *status) 824 { 825 struct cx24123_state *state = fe->demodulator_priv; 826 int sync = cx24123_readreg(state, 0x14); ··· 853 } 854 855 /* 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. 859 */ 860 static int cx24123_read_ber(struct dvb_frontend *fe, u32 *ber) 861 { ··· 876 { 877 struct cx24123_state *state = fe->demodulator_priv; 878 879 + /* larger = better */ 880 + *signal_strength = cx24123_readreg(state, 0x3b) << 8; 881 882 dprintk("Signal strength = %d\n", *signal_strength); 883 ··· 907 if (state->config->set_ts_params) 908 state->config->set_ts_params(fe, 0); 909 910 + state->currentfreq = p->frequency; 911 state->currentsymbolrate = p->u.qpsk.symbol_rate; 912 913 cx24123_set_inversion(state, p->inversion); ··· 932 return 0; 933 } 934 935 + static int cx24123_get_frontend(struct dvb_frontend *fe, 936 + struct dvb_frontend_parameters *p) 937 { 938 struct cx24123_state *state = fe->demodulator_priv; 939 ··· 952 return 0; 953 } 954 955 + static int cx24123_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) 956 { 957 struct cx24123_state *state = fe->demodulator_priv; 958 u8 val; ··· 977 return 0; 978 } 979 980 + static int cx24123_tune(struct dvb_frontend *fe, 981 + struct dvb_frontend_parameters *params, 982 unsigned int mode_flags, 983 unsigned int *delay, 984 fe_status_t *status) ··· 997 998 static int cx24123_get_algo(struct dvb_frontend *fe) 999 { 1000 + return 1; /* FE_ALGO_HW */ 1001 } 1002 1003 + static void cx24123_release(struct dvb_frontend *fe) 1004 { 1005 + struct cx24123_state *state = fe->demodulator_priv; 1006 dprintk("\n"); 1007 i2c_del_adapter(&state->tuner_i2c_adapter); 1008 kfree(state); ··· 1013 { 1014 struct cx24123_state *state = i2c_get_adapdata(i2c_adap); 1015 /* this repeater closes after the first stop */ 1016 + cx24123_repeater_mode(state, 1, 1); 1017 return i2c_transfer(state->i2c, msg, num); 1018 } 1019 ··· 1037 1038 static struct dvb_frontend_ops cx24123_ops; 1039 1040 + struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, 1041 + struct i2c_adapter *i2c) 1042 { 1043 struct cx24123_state *state = 1044 kzalloc(sizeof(struct cx24123_state), GFP_KERNEL); ··· 1057 /* check if the demod is there */ 1058 state->demod_rev = cx24123_readreg(state, 0x00); 1059 switch (state->demod_rev) { 1060 + case 0xe1: 1061 + info("detected CX24123C\n"); 1062 + break; 1063 + case 0xd1: 1064 + info("detected CX24123\n"); 1065 + break; 1066 default: 1067 err("wrong demod revision: %x\n", state->demod_rev); 1068 goto error; 1069 } 1070 1071 /* create dvb_frontend */ 1072 + memcpy(&state->frontend.ops, &cx24123_ops, 1073 + sizeof(struct dvb_frontend_ops)); 1074 state->frontend.demodulator_priv = state; 1075 1076 + /* create tuner i2c adapter */ 1077 + if (config->dont_use_pll) 1078 + cx24123_repeater_mode(state, 1, 0); 1079 1080 strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus", 1081 sizeof(state->tuner_i2c_adapter.name)); ··· 1079 state->tuner_i2c_adapter.algo_data = NULL; 1080 i2c_set_adapdata(&state->tuner_i2c_adapter, state); 1081 if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) { 1082 + err("tuner i2c bus could not be initialized\n"); 1083 goto error; 1084 } 1085 ··· 1090 1091 return NULL; 1092 } 1093 + EXPORT_SYMBOL(cx24123_attach); 1094 1095 static struct dvb_frontend_ops cx24123_ops = { 1096 ··· 1126 .get_frontend_algo = cx24123_get_algo, 1127 }; 1128 1129 MODULE_DESCRIPTION("DVB Frontend module for Conexant " \ 1130 "CX24123/CX24109/CX24113 hardware"); 1131 MODULE_AUTHOR("Steven Toth"); 1132 MODULE_LICENSE("GPL"); 1133
+5 -5
drivers/media/dvb/frontends/cx24123.h
··· 23 24 #include <linux/dvb/frontend.h> 25 26 - struct cx24123_config 27 - { 28 /* the demodulator's i2c address */ 29 u8 demod_address; 30 31 /* Need to set device param for start_dma */ 32 - int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 33 34 /* 0 = LNB voltage normal, 1 = LNB voltage inverted */ 35 int lnb_polarity; ··· 38 void (*agc_callback) (struct dvb_frontend *); 39 }; 40 41 - #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) && defined(MODULE)) 42 extern struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, 43 struct i2c_adapter *i2c); 44 extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *); ··· 56 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 57 return NULL; 58 } 59 - #endif // CONFIG_DVB_CX24123 60 61 #endif /* CX24123_H */
··· 23 24 #include <linux/dvb/frontend.h> 25 26 + struct cx24123_config { 27 /* the demodulator's i2c address */ 28 u8 demod_address; 29 30 /* Need to set device param for start_dma */ 31 + int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured); 32 33 /* 0 = LNB voltage normal, 1 = LNB voltage inverted */ 34 int lnb_polarity; ··· 39 void (*agc_callback) (struct dvb_frontend *); 40 }; 41 42 + #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) \ 43 + && defined(MODULE)) 44 extern struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, 45 struct i2c_adapter *i2c); 46 extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *); ··· 56 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 57 return NULL; 58 } 59 + #endif 60 61 #endif /* CX24123_H */
+70 -68
drivers/media/dvb/frontends/s5h1409.c
··· 30 31 struct s5h1409_state { 32 33 - struct i2c_adapter* i2c; 34 35 /* configuration settings */ 36 - const struct s5h1409_config* config; 37 38 struct dvb_frontend frontend; 39 ··· 48 }; 49 50 static int debug; 51 #define dprintk if (debug) printk 52 53 /* Register values to initialise the demod, this will set VSB by default */ ··· 302 }; 303 304 /* 8 bit registers, 16 bit values */ 305 - static int s5h1409_writereg(struct s5h1409_state* state, u8 reg, u16 data) 306 { 307 int ret; 308 - u8 buf [] = { reg, data >> 8, data & 0xff }; 309 310 struct i2c_msg msg = { .addr = state->config->demod_address, 311 .flags = 0, .buf = buf, .len = 3 }; ··· 313 ret = i2c_transfer(state->i2c, &msg, 1); 314 315 if (ret != 1) 316 - printk("%s: writereg error (reg == 0x%02x, val == 0x%04x, " 317 "ret == %i)\n", __func__, reg, data, ret); 318 319 return (ret != 1) ? -1 : 0; 320 } 321 322 - static u16 s5h1409_readreg(struct s5h1409_state* state, u8 reg) 323 { 324 int ret; 325 - u8 b0 [] = { reg }; 326 - u8 b1 [] = { 0, 0 }; 327 328 - struct i2c_msg msg [] = { 329 { .addr = state->config->demod_address, .flags = 0, 330 .buf = b0, .len = 1 }, 331 { .addr = state->config->demod_address, .flags = I2C_M_RD, ··· 338 return (b1[0] << 8) | b1[1]; 339 } 340 341 - static int s5h1409_softreset(struct dvb_frontend* fe) 342 { 343 - struct s5h1409_state* state = fe->demodulator_priv; 344 345 dprintk("%s()\n", __func__); 346 ··· 352 } 353 354 #define S5H1409_VSB_IF_FREQ 5380 355 - #define S5H1409_QAM_IF_FREQ state->config->qam_if 356 357 - static int s5h1409_set_if_freq(struct dvb_frontend* fe, int KHz) 358 { 359 - struct s5h1409_state* state = fe->demodulator_priv; 360 361 dprintk("%s(%d KHz)\n", __func__, KHz); 362 ··· 379 return 0; 380 } 381 382 - static int s5h1409_set_spectralinversion(struct dvb_frontend* fe, int inverted) 383 { 384 - struct s5h1409_state* state = fe->demodulator_priv; 385 386 dprintk("%s(%d)\n", __func__, inverted); 387 388 - if(inverted == 1) 389 return s5h1409_writereg(state, 0x1b, 0x1101); /* Inverted */ 390 else 391 return s5h1409_writereg(state, 0x1b, 0x0110); /* Normal */ 392 } 393 394 - static int s5h1409_enable_modulation(struct dvb_frontend* fe, 395 fe_modulation_t m) 396 { 397 - struct s5h1409_state* state = fe->demodulator_priv; 398 399 dprintk("%s(0x%08x)\n", __func__, m); 400 401 - switch(m) { 402 case VSB_8: 403 dprintk("%s() VSB_8\n", __func__); 404 if (state->if_freq != S5H1409_VSB_IF_FREQ) ··· 425 return 0; 426 } 427 428 - static int s5h1409_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) 429 { 430 - struct s5h1409_state* state = fe->demodulator_priv; 431 432 dprintk("%s(%d)\n", __func__, enable); 433 ··· 437 return s5h1409_writereg(state, 0xf3, 0); 438 } 439 440 - static int s5h1409_set_gpio(struct dvb_frontend* fe, int enable) 441 { 442 - struct s5h1409_state* state = fe->demodulator_priv; 443 444 dprintk("%s(%d)\n", __func__, enable); 445 ··· 451 s5h1409_readreg(state, 0xe3) & 0xfeff); 452 } 453 454 - static int s5h1409_sleep(struct dvb_frontend* fe, int enable) 455 { 456 - struct s5h1409_state* state = fe->demodulator_priv; 457 458 dprintk("%s(%d)\n", __func__, enable); 459 460 return s5h1409_writereg(state, 0xf2, enable); 461 } 462 463 - static int s5h1409_register_reset(struct dvb_frontend* fe) 464 { 465 - struct s5h1409_state* state = fe->demodulator_priv; 466 467 dprintk("%s()\n", __func__); 468 ··· 486 reg &= 0xff; 487 488 s5h1409_writereg(state, 0x96, 0x00c); 489 - if ((reg < 0x38) || (reg > 0x68) ) { 490 s5h1409_writereg(state, 0x93, 0x3332); 491 s5h1409_writereg(state, 0x9e, 0x2c37); 492 } else { ··· 517 518 s5h1409_writereg(state, 0x96, 0x20); 519 s5h1409_writereg(state, 0xad, 520 - ( ((reg1 & 0xf000) >> 4) | (reg2 & 0xf0ff)) ); 521 s5h1409_writereg(state, 0xab, 522 s5h1409_readreg(state, 0xab) & 0xeffe); 523 } ··· 532 } 533 534 /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ 535 - static int s5h1409_set_frontend (struct dvb_frontend* fe, 536 struct dvb_frontend_parameters *p) 537 { 538 - struct s5h1409_state* state = fe->demodulator_priv; 539 540 dprintk("%s(frequency=%d)\n", __func__, p->frequency); 541 ··· 549 msleep(100); 550 551 if (fe->ops.tuner_ops.set_params) { 552 - if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); 553 fe->ops.tuner_ops.set_params(fe, p); 554 - if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); 555 } 556 557 /* Optimize the demod for QAM */ ··· 597 598 /* Reset the demod hardware and reset all of the configuration registers 599 to a default state. */ 600 - static int s5h1409_init (struct dvb_frontend* fe) 601 { 602 int i; 603 604 - struct s5h1409_state* state = fe->demodulator_priv; 605 dprintk("%s()\n", __func__); 606 607 s5h1409_sleep(fe, 0); 608 s5h1409_register_reset(fe); 609 610 - for (i=0; i < ARRAY_SIZE(init_tab); i++) 611 s5h1409_writereg(state, init_tab[i].reg, init_tab[i].data); 612 613 /* The datasheet says that after initialisation, VSB is default */ ··· 632 return 0; 633 } 634 635 - static int s5h1409_read_status(struct dvb_frontend* fe, fe_status_t* status) 636 { 637 - struct s5h1409_state* state = fe->demodulator_priv; 638 u16 reg; 639 u32 tuner_status = 0; 640 ··· 642 643 /* Get the demodulator status */ 644 reg = s5h1409_readreg(state, 0xf1); 645 - if(reg & 0x1000) 646 *status |= FE_HAS_VITERBI; 647 - if(reg & 0x8000) 648 *status |= FE_HAS_LOCK | FE_HAS_SYNC; 649 650 - switch(state->config->status_mode) { 651 case S5H1409_DEMODLOCKING: 652 if (*status & FE_HAS_VITERBI) 653 *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; ··· 673 return 0; 674 } 675 676 - static int s5h1409_qam256_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) 677 { 678 int i, ret = -EINVAL; 679 dprintk("%s()\n", __func__); 680 681 - for (i=0; i < ARRAY_SIZE(qam256_snr_tab); i++) { 682 if (v < qam256_snr_tab[i].val) { 683 *snr = qam256_snr_tab[i].data; 684 ret = 0; ··· 688 return ret; 689 } 690 691 - static int s5h1409_qam64_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) 692 { 693 int i, ret = -EINVAL; 694 dprintk("%s()\n", __func__); 695 696 - for (i=0; i < ARRAY_SIZE(qam64_snr_tab); i++) { 697 if (v < qam64_snr_tab[i].val) { 698 *snr = qam64_snr_tab[i].data; 699 ret = 0; ··· 703 return ret; 704 } 705 706 - static int s5h1409_vsb_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) 707 { 708 int i, ret = -EINVAL; 709 dprintk("%s()\n", __func__); 710 711 - for (i=0; i < ARRAY_SIZE(vsb_snr_tab); i++) { 712 if (v > vsb_snr_tab[i].val) { 713 *snr = vsb_snr_tab[i].data; 714 ret = 0; ··· 719 return ret; 720 } 721 722 - static int s5h1409_read_snr(struct dvb_frontend* fe, u16* snr) 723 { 724 - struct s5h1409_state* state = fe->demodulator_priv; 725 u16 reg; 726 dprintk("%s()\n", __func__); 727 728 - switch(state->current_modulation) { 729 case QAM_64: 730 reg = s5h1409_readreg(state, 0xf0) & 0xff; 731 return s5h1409_qam64_lookup_snr(fe, snr, reg); ··· 742 return -EINVAL; 743 } 744 745 - static int s5h1409_read_signal_strength(struct dvb_frontend* fe, 746 - u16* signal_strength) 747 { 748 return s5h1409_read_snr(fe, signal_strength); 749 } 750 751 - static int s5h1409_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 752 { 753 - struct s5h1409_state* state = fe->demodulator_priv; 754 755 *ucblocks = s5h1409_readreg(state, 0xb5); 756 757 return 0; 758 } 759 760 - static int s5h1409_read_ber(struct dvb_frontend* fe, u32* ber) 761 { 762 return s5h1409_read_ucblocks(fe, ber); 763 } 764 765 - static int s5h1409_get_frontend(struct dvb_frontend* fe, 766 struct dvb_frontend_parameters *p) 767 { 768 - struct s5h1409_state* state = fe->demodulator_priv; 769 770 p->frequency = state->current_frequency; 771 p->u.vsb.modulation = state->current_modulation; ··· 773 return 0; 774 } 775 776 - static int s5h1409_get_tune_settings(struct dvb_frontend* fe, 777 struct dvb_frontend_tune_settings *tune) 778 { 779 tune->min_delay_ms = 1000; 780 return 0; 781 } 782 783 - static void s5h1409_release(struct dvb_frontend* fe) 784 { 785 - struct s5h1409_state* state = fe->demodulator_priv; 786 kfree(state); 787 } 788 789 static struct dvb_frontend_ops s5h1409_ops; 790 791 - struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, 792 - struct i2c_adapter* i2c) 793 { 794 - struct s5h1409_state* state = NULL; 795 u16 reg; 796 797 /* allocate memory for the internal state */ ··· 830 kfree(state); 831 return NULL; 832 } 833 834 static struct dvb_frontend_ops s5h1409_ops = { 835 ··· 856 .release = s5h1409_release, 857 }; 858 859 - module_param(debug, int, 0644); 860 - MODULE_PARM_DESC(debug, "Enable verbose debug messages"); 861 - 862 MODULE_DESCRIPTION("Samsung S5H1409 QAM-B/ATSC Demodulator driver"); 863 MODULE_AUTHOR("Steven Toth"); 864 MODULE_LICENSE("GPL"); 865 866 - EXPORT_SYMBOL(s5h1409_attach); 867 868 /* 869 * Local variables:
··· 30 31 struct s5h1409_state { 32 33 + struct i2c_adapter *i2c; 34 35 /* configuration settings */ 36 + const struct s5h1409_config *config; 37 38 struct dvb_frontend frontend; 39 ··· 48 }; 49 50 static int debug; 51 + module_param(debug, int, 0644); 52 + MODULE_PARM_DESC(debug, "Enable verbose debug messages"); 53 + 54 #define dprintk if (debug) printk 55 56 /* Register values to initialise the demod, this will set VSB by default */ ··· 299 }; 300 301 /* 8 bit registers, 16 bit values */ 302 + static int s5h1409_writereg(struct s5h1409_state *state, u8 reg, u16 data) 303 { 304 int ret; 305 + u8 buf[] = { reg, data >> 8, data & 0xff }; 306 307 struct i2c_msg msg = { .addr = state->config->demod_address, 308 .flags = 0, .buf = buf, .len = 3 }; ··· 310 ret = i2c_transfer(state->i2c, &msg, 1); 311 312 if (ret != 1) 313 + printk(KERN_ERR "%s: error (reg == 0x%02x, val == 0x%04x, " 314 "ret == %i)\n", __func__, reg, data, ret); 315 316 return (ret != 1) ? -1 : 0; 317 } 318 319 + static u16 s5h1409_readreg(struct s5h1409_state *state, u8 reg) 320 { 321 int ret; 322 + u8 b0[] = { reg }; 323 + u8 b1[] = { 0, 0 }; 324 325 + struct i2c_msg msg[] = { 326 { .addr = state->config->demod_address, .flags = 0, 327 .buf = b0, .len = 1 }, 328 { .addr = state->config->demod_address, .flags = I2C_M_RD, ··· 335 return (b1[0] << 8) | b1[1]; 336 } 337 338 + static int s5h1409_softreset(struct dvb_frontend *fe) 339 { 340 + struct s5h1409_state *state = fe->demodulator_priv; 341 342 dprintk("%s()\n", __func__); 343 ··· 349 } 350 351 #define S5H1409_VSB_IF_FREQ 5380 352 + #define S5H1409_QAM_IF_FREQ (state->config->qam_if) 353 354 + static int s5h1409_set_if_freq(struct dvb_frontend *fe, int KHz) 355 { 356 + struct s5h1409_state *state = fe->demodulator_priv; 357 358 dprintk("%s(%d KHz)\n", __func__, KHz); 359 ··· 376 return 0; 377 } 378 379 + static int s5h1409_set_spectralinversion(struct dvb_frontend *fe, int inverted) 380 { 381 + struct s5h1409_state *state = fe->demodulator_priv; 382 383 dprintk("%s(%d)\n", __func__, inverted); 384 385 + if (inverted == 1) 386 return s5h1409_writereg(state, 0x1b, 0x1101); /* Inverted */ 387 else 388 return s5h1409_writereg(state, 0x1b, 0x0110); /* Normal */ 389 } 390 391 + static int s5h1409_enable_modulation(struct dvb_frontend *fe, 392 fe_modulation_t m) 393 { 394 + struct s5h1409_state *state = fe->demodulator_priv; 395 396 dprintk("%s(0x%08x)\n", __func__, m); 397 398 + switch (m) { 399 case VSB_8: 400 dprintk("%s() VSB_8\n", __func__); 401 if (state->if_freq != S5H1409_VSB_IF_FREQ) ··· 422 return 0; 423 } 424 425 + static int s5h1409_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) 426 { 427 + struct s5h1409_state *state = fe->demodulator_priv; 428 429 dprintk("%s(%d)\n", __func__, enable); 430 ··· 434 return s5h1409_writereg(state, 0xf3, 0); 435 } 436 437 + static int s5h1409_set_gpio(struct dvb_frontend *fe, int enable) 438 { 439 + struct s5h1409_state *state = fe->demodulator_priv; 440 441 dprintk("%s(%d)\n", __func__, enable); 442 ··· 448 s5h1409_readreg(state, 0xe3) & 0xfeff); 449 } 450 451 + static int s5h1409_sleep(struct dvb_frontend *fe, int enable) 452 { 453 + struct s5h1409_state *state = fe->demodulator_priv; 454 455 dprintk("%s(%d)\n", __func__, enable); 456 457 return s5h1409_writereg(state, 0xf2, enable); 458 } 459 460 + static int s5h1409_register_reset(struct dvb_frontend *fe) 461 { 462 + struct s5h1409_state *state = fe->demodulator_priv; 463 464 dprintk("%s()\n", __func__); 465 ··· 483 reg &= 0xff; 484 485 s5h1409_writereg(state, 0x96, 0x00c); 486 + if ((reg < 0x38) || (reg > 0x68)) { 487 s5h1409_writereg(state, 0x93, 0x3332); 488 s5h1409_writereg(state, 0x9e, 0x2c37); 489 } else { ··· 514 515 s5h1409_writereg(state, 0x96, 0x20); 516 s5h1409_writereg(state, 0xad, 517 + (((reg1 & 0xf000) >> 4) | (reg2 & 0xf0ff))); 518 s5h1409_writereg(state, 0xab, 519 s5h1409_readreg(state, 0xab) & 0xeffe); 520 } ··· 529 } 530 531 /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ 532 + static int s5h1409_set_frontend(struct dvb_frontend *fe, 533 struct dvb_frontend_parameters *p) 534 { 535 + struct s5h1409_state *state = fe->demodulator_priv; 536 537 dprintk("%s(frequency=%d)\n", __func__, p->frequency); 538 ··· 546 msleep(100); 547 548 if (fe->ops.tuner_ops.set_params) { 549 + if (fe->ops.i2c_gate_ctrl) 550 + fe->ops.i2c_gate_ctrl(fe, 1); 551 fe->ops.tuner_ops.set_params(fe, p); 552 + if (fe->ops.i2c_gate_ctrl) 553 + fe->ops.i2c_gate_ctrl(fe, 0); 554 } 555 556 /* Optimize the demod for QAM */ ··· 592 593 /* Reset the demod hardware and reset all of the configuration registers 594 to a default state. */ 595 + static int s5h1409_init(struct dvb_frontend *fe) 596 { 597 int i; 598 599 + struct s5h1409_state *state = fe->demodulator_priv; 600 dprintk("%s()\n", __func__); 601 602 s5h1409_sleep(fe, 0); 603 s5h1409_register_reset(fe); 604 605 + for (i = 0; i < ARRAY_SIZE(init_tab); i++) 606 s5h1409_writereg(state, init_tab[i].reg, init_tab[i].data); 607 608 /* The datasheet says that after initialisation, VSB is default */ ··· 627 return 0; 628 } 629 630 + static int s5h1409_read_status(struct dvb_frontend *fe, fe_status_t *status) 631 { 632 + struct s5h1409_state *state = fe->demodulator_priv; 633 u16 reg; 634 u32 tuner_status = 0; 635 ··· 637 638 /* Get the demodulator status */ 639 reg = s5h1409_readreg(state, 0xf1); 640 + if (reg & 0x1000) 641 *status |= FE_HAS_VITERBI; 642 + if (reg & 0x8000) 643 *status |= FE_HAS_LOCK | FE_HAS_SYNC; 644 645 + switch (state->config->status_mode) { 646 case S5H1409_DEMODLOCKING: 647 if (*status & FE_HAS_VITERBI) 648 *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; ··· 668 return 0; 669 } 670 671 + static int s5h1409_qam256_lookup_snr(struct dvb_frontend *fe, u16 *snr, u16 v) 672 { 673 int i, ret = -EINVAL; 674 dprintk("%s()\n", __func__); 675 676 + for (i = 0; i < ARRAY_SIZE(qam256_snr_tab); i++) { 677 if (v < qam256_snr_tab[i].val) { 678 *snr = qam256_snr_tab[i].data; 679 ret = 0; ··· 683 return ret; 684 } 685 686 + static int s5h1409_qam64_lookup_snr(struct dvb_frontend *fe, u16 *snr, u16 v) 687 { 688 int i, ret = -EINVAL; 689 dprintk("%s()\n", __func__); 690 691 + for (i = 0; i < ARRAY_SIZE(qam64_snr_tab); i++) { 692 if (v < qam64_snr_tab[i].val) { 693 *snr = qam64_snr_tab[i].data; 694 ret = 0; ··· 698 return ret; 699 } 700 701 + static int s5h1409_vsb_lookup_snr(struct dvb_frontend *fe, u16 *snr, u16 v) 702 { 703 int i, ret = -EINVAL; 704 dprintk("%s()\n", __func__); 705 706 + for (i = 0; i < ARRAY_SIZE(vsb_snr_tab); i++) { 707 if (v > vsb_snr_tab[i].val) { 708 *snr = vsb_snr_tab[i].data; 709 ret = 0; ··· 714 return ret; 715 } 716 717 + static int s5h1409_read_snr(struct dvb_frontend *fe, u16 *snr) 718 { 719 + struct s5h1409_state *state = fe->demodulator_priv; 720 u16 reg; 721 dprintk("%s()\n", __func__); 722 723 + switch (state->current_modulation) { 724 case QAM_64: 725 reg = s5h1409_readreg(state, 0xf0) & 0xff; 726 return s5h1409_qam64_lookup_snr(fe, snr, reg); ··· 737 return -EINVAL; 738 } 739 740 + static int s5h1409_read_signal_strength(struct dvb_frontend *fe, 741 + u16 *signal_strength) 742 { 743 return s5h1409_read_snr(fe, signal_strength); 744 } 745 746 + static int s5h1409_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) 747 { 748 + struct s5h1409_state *state = fe->demodulator_priv; 749 750 *ucblocks = s5h1409_readreg(state, 0xb5); 751 752 return 0; 753 } 754 755 + static int s5h1409_read_ber(struct dvb_frontend *fe, u32 *ber) 756 { 757 return s5h1409_read_ucblocks(fe, ber); 758 } 759 760 + static int s5h1409_get_frontend(struct dvb_frontend *fe, 761 struct dvb_frontend_parameters *p) 762 { 763 + struct s5h1409_state *state = fe->demodulator_priv; 764 765 p->frequency = state->current_frequency; 766 p->u.vsb.modulation = state->current_modulation; ··· 768 return 0; 769 } 770 771 + static int s5h1409_get_tune_settings(struct dvb_frontend *fe, 772 struct dvb_frontend_tune_settings *tune) 773 { 774 tune->min_delay_ms = 1000; 775 return 0; 776 } 777 778 + static void s5h1409_release(struct dvb_frontend *fe) 779 { 780 + struct s5h1409_state *state = fe->demodulator_priv; 781 kfree(state); 782 } 783 784 static struct dvb_frontend_ops s5h1409_ops; 785 786 + struct dvb_frontend *s5h1409_attach(const struct s5h1409_config *config, 787 + struct i2c_adapter *i2c) 788 { 789 + struct s5h1409_state *state = NULL; 790 u16 reg; 791 792 /* allocate memory for the internal state */ ··· 825 kfree(state); 826 return NULL; 827 } 828 + EXPORT_SYMBOL(s5h1409_attach); 829 830 static struct dvb_frontend_ops s5h1409_ops = { 831 ··· 850 .release = s5h1409_release, 851 }; 852 853 MODULE_DESCRIPTION("Samsung S5H1409 QAM-B/ATSC Demodulator driver"); 854 MODULE_AUTHOR("Steven Toth"); 855 MODULE_LICENSE("GPL"); 856 857 858 /* 859 * Local variables:
+8 -7
drivers/media/dvb/frontends/s5h1409.h
··· 24 25 #include <linux/dvb/frontend.h> 26 27 - struct s5h1409_config 28 - { 29 /* the demodulator's i2c address */ 30 u8 demod_address; 31 ··· 59 u16 mpeg_timing; 60 }; 61 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); 65 #else 66 - static inline struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, 67 - struct i2c_adapter* i2c) 68 { 69 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 70 return NULL;
··· 24 25 #include <linux/dvb/frontend.h> 26 27 + struct s5h1409_config { 28 /* the demodulator's i2c address */ 29 u8 demod_address; 30 ··· 60 u16 mpeg_timing; 61 }; 62 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); 67 #else 68 + static inline struct dvb_frontend *s5h1409_attach( 69 + const struct s5h1409_config *config, 70 + struct i2c_adapter *i2c) 71 { 72 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 73 return NULL;
+4 -4
drivers/media/dvb/frontends/s5h1411.c
··· 343 u8 addr, u8 reg, u16 data) 344 { 345 int ret; 346 - u8 buf [] = { reg, data >> 8, data & 0xff }; 347 348 struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 3 }; 349 ··· 359 static u16 s5h1411_readreg(struct s5h1411_state *state, u8 addr, u8 reg) 360 { 361 int ret; 362 - u8 b0 [] = { reg }; 363 - u8 b1 [] = { 0, 0 }; 364 365 - struct i2c_msg msg [] = { 366 { .addr = addr, .flags = 0, .buf = b0, .len = 1 }, 367 { .addr = addr, .flags = I2C_M_RD, .buf = b1, .len = 2 } }; 368
··· 343 u8 addr, u8 reg, u16 data) 344 { 345 int ret; 346 + u8 buf[] = { reg, data >> 8, data & 0xff }; 347 348 struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 3 }; 349 ··· 359 static u16 s5h1411_readreg(struct s5h1411_state *state, u8 addr, u8 reg) 360 { 361 int ret; 362 + u8 b0[] = { reg }; 363 + u8 b1[] = { 0, 0 }; 364 365 + struct i2c_msg msg[] = { 366 { .addr = addr, .flags = 0, .buf = b0, .len = 1 }, 367 { .addr = addr, .flags = I2C_M_RD, .buf = b1, .len = 2 } }; 368
+73 -27
drivers/media/dvb/frontends/tda10048.c
··· 195 static int tda10048_writereg(struct tda10048_state *state, u8 reg, u8 data) 196 { 197 int ret; 198 - u8 buf [] = { reg, data }; 199 struct i2c_msg msg = { 200 .addr = state->config->demod_address, 201 .flags = 0, .buf = buf, .len = 2 }; ··· 213 static u8 tda10048_readreg(struct tda10048_state *state, u8 reg) 214 { 215 int ret; 216 - u8 b0 [] = { reg }; 217 - u8 b1 [] = { 0 }; 218 - struct i2c_msg msg [] = { 219 { .addr = state->config->demod_address, 220 .flags = 0, .buf = b0, .len = 1 }, 221 { .addr = state->config->demod_address, ··· 393 394 val = tda10048_readreg(state, TDA10048_OUT_CONF2); 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; 399 } 400 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; 405 } 406 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; 412 } 413 414 val = tda10048_readreg(state, TDA10048_OUT_CONF3); 415 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; 421 } 422 423 val = tda10048_readreg(state, TDA10048_OUT_CONF1); 424 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; 429 } 430 switch (val & 0x02) { 431 - case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break; 432 - case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break; 433 } 434 435 return 0;
··· 195 static int tda10048_writereg(struct tda10048_state *state, u8 reg, u8 data) 196 { 197 int ret; 198 + u8 buf[] = { reg, data }; 199 struct i2c_msg msg = { 200 .addr = state->config->demod_address, 201 .flags = 0, .buf = buf, .len = 2 }; ··· 213 static u8 tda10048_readreg(struct tda10048_state *state, u8 reg) 214 { 215 int ret; 216 + u8 b0[] = { reg }; 217 + u8 b1[] = { 0 }; 218 + struct i2c_msg msg[] = { 219 { .addr = state->config->demod_address, 220 .flags = 0, .buf = b0, .len = 1 }, 221 { .addr = state->config->demod_address, ··· 393 394 val = tda10048_readreg(state, TDA10048_OUT_CONF2); 395 switch ((val & 0x60) >> 5) { 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; 405 } 406 switch ((val & 0x18) >> 3) { 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; 419 } 420 switch (val & 0x07) { 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; 436 } 437 438 val = tda10048_readreg(state, TDA10048_OUT_CONF3); 439 switch (val & 0x07) { 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; 455 } 456 457 val = tda10048_readreg(state, TDA10048_OUT_CONF1); 458 switch ((val & 0x0c) >> 2) { 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; 471 } 472 switch (val & 0x02) { 473 + case 0: 474 + p->transmission_mode = TRANSMISSION_MODE_2K; 475 + break; 476 + case 1: 477 + p->transmission_mode = TRANSMISSION_MODE_8K; 478 + break; 479 } 480 481 return 0;
+2 -14
drivers/media/dvb/frontends/z0194a.h
··· 12 #ifndef Z0194A 13 #define Z0194A 14 15 - static int sharp_z0194a__set_symbol_rate(struct dvb_frontend *fe, 16 u32 srate, u32 ratio) 17 { 18 u8 aclk = 0; ··· 40 return 0; 41 } 42 43 - static u8 sharp_z0194a__inittab[] = { 44 0x01, 0x15, 45 0x02, 0x00, 46 0x03, 0x00, ··· 80 0x34, 0x93, /* error control */ 81 0x0f, 0x52, 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 }; 96 97 #endif
··· 12 #ifndef Z0194A 13 #define Z0194A 14 15 + static int sharp_z0194a_set_symbol_rate(struct dvb_frontend *fe, 16 u32 srate, u32 ratio) 17 { 18 u8 aclk = 0; ··· 40 return 0; 41 } 42 43 + static u8 sharp_z0194a_inittab[] = { 44 0x01, 0x15, 45 0x02, 0x00, 46 0x03, 0x00, ··· 80 0x34, 0x93, /* error control */ 81 0x0f, 0x52, 82 0xff, 0xff 83 }; 84 85 #endif
+4
drivers/media/dvb/siano/sms-cards.c
··· 42 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 43 { USB_DEVICE(0x2040, 0x5510), 44 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 45 { USB_DEVICE(0x2040, 0x5580), 46 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 47 { USB_DEVICE(0x2040, 0x5590),
··· 42 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 43 { USB_DEVICE(0x2040, 0x5510), 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 }, 49 { USB_DEVICE(0x2040, 0x5580), 50 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 51 { USB_DEVICE(0x2040, 0x5590),
+1 -1
drivers/media/radio/Kconfig
··· 359 computer's USB port. 360 361 To compile this driver as a module, choose M here: the 362 - module will be called radio-silabs. 363 364 config USB_MR800 365 tristate "AverMedia MR 800 USB FM radio support"
··· 359 computer's USB port. 360 361 To compile this driver as a module, choose M here: the 362 + module will be called radio-si470x. 363 364 config USB_MR800 365 tristate "AverMedia MR 800 USB FM radio support"
+99 -139
drivers/media/radio/radio-si470x.c
··· 104 * - hardware frequency seek support 105 * - afc indication 106 * - more safety checks, let si470x_get_freq return errno 107 * 108 * ToDo: 109 * - add firmware download/update support ··· 142 /* USB Device ID List */ 143 static struct usb_device_id si470x_usb_driver_id_table[] = { 144 /* Silicon Labs USB FM Radio Reference Design */ 145 - { USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) }, 146 /* ADS/Tech FM Radio Receiver (formerly Instant FM Music) */ 147 - { USB_DEVICE_AND_INTERFACE_INFO(0x06e1, 0xa155, USB_CLASS_HID, 0, 0) }, 148 /* Terminating entry */ 149 { } 150 }; ··· 158 159 /* Radio Nr */ 160 static int radio_nr = -1; 161 - module_param(radio_nr, int, 0); 162 MODULE_PARM_DESC(radio_nr, "Radio Nr"); 163 164 /* Spacing (kHz) */ ··· 166 /* 1: 100 kHz (Europe, Japan) */ 167 /* 2: 50 kHz */ 168 static unsigned short space = 2; 169 - module_param(space, ushort, 0); 170 - MODULE_PARM_DESC(radio_nr, "Spacing: 0=200kHz 1=100kHz *2=50kHz*"); 171 172 /* Bottom of Band (MHz) */ 173 /* 0: 87.5 - 108 MHz (USA, Europe)*/ 174 /* 1: 76 - 108 MHz (Japan wide band) */ 175 /* 2: 76 - 90 MHz (Japan) */ 176 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"); 179 180 /* De-emphasis */ 181 /* 0: 75 us (USA) */ 182 /* 1: 50 us (Europe, Australia, Japan) */ 183 static unsigned short de = 1; 184 - module_param(de, ushort, 0); 185 - MODULE_PARM_DESC(radio_nr, "De-emphasis: 0=75us *1=50us*"); 186 187 /* USB timeout */ 188 static unsigned int usb_timeout = 500; 189 - module_param(usb_timeout, uint, 0); 190 MODULE_PARM_DESC(usb_timeout, "USB timeout (ms): *500*"); 191 192 /* Tune timeout */ 193 static unsigned int tune_timeout = 3000; 194 - module_param(tune_timeout, uint, 0); 195 MODULE_PARM_DESC(tune_timeout, "Tune timeout: *3000*"); 196 197 /* Seek timeout */ 198 static unsigned int seek_timeout = 5000; 199 - module_param(seek_timeout, uint, 0); 200 MODULE_PARM_DESC(seek_timeout, "Seek timeout: *5000*"); 201 202 /* RDS buffer blocks */ 203 static unsigned int rds_buf = 100; 204 - module_param(rds_buf, uint, 0); 205 MODULE_PARM_DESC(rds_buf, "RDS buffer entries: *100*"); 206 207 /* RDS maximum block errors */ ··· 210 /* 1 means 1-2 errors requiring correction (used by original USBRadio.exe) */ 211 /* 2 means 3-5 errors requiring correction */ 212 /* 3 means 6+ errors or errors in checkword, correction not possible */ 213 - module_param(max_rds_errors, ushort, 0); 214 MODULE_PARM_DESC(max_rds_errors, "RDS maximum block errors: *1*"); 215 216 /* RDS poll frequency */ ··· 219 /* 50 is used by radio-cadet */ 220 /* 75 should be okay */ 221 /* 80 is the usual RDS receive interval */ 222 - module_param(rds_poll_time, uint, 0); 223 MODULE_PARM_DESC(rds_poll_time, "RDS poll time (ms): *40*"); 224 225 ··· 668 int retval; 669 670 /* Spacing (kHz) */ 671 - switch (space) { 672 /* 0: 200 kHz (USA, Australia) */ 673 - case 0 : spacing = 0.200 * FREQ_MUL; break; 674 /* 1: 100 kHz (Europe, Japan) */ 675 - case 1 : spacing = 0.100 * FREQ_MUL; break; 676 /* 2: 50 kHz */ 677 - default: spacing = 0.050 * FREQ_MUL; break; 678 }; 679 680 /* Bottom of Band (MHz) */ 681 - switch (band) { 682 /* 0: 87.5 - 108 MHz (USA, Europe) */ 683 - case 0 : band_bottom = 87.5 * FREQ_MUL; break; 684 /* 1: 76 - 108 MHz (Japan wide band) */ 685 - default: band_bottom = 76 * FREQ_MUL; break; 686 /* 2: 76 - 90 MHz (Japan) */ 687 - case 2 : band_bottom = 76 * FREQ_MUL; break; 688 }; 689 690 /* read channel */ ··· 713 unsigned short chan; 714 715 /* Spacing (kHz) */ 716 - switch (space) { 717 /* 0: 200 kHz (USA, Australia) */ 718 - case 0 : spacing = 0.200 * FREQ_MUL; break; 719 /* 1: 100 kHz (Europe, Japan) */ 720 - case 1 : spacing = 0.100 * FREQ_MUL; break; 721 /* 2: 50 kHz */ 722 - default: spacing = 0.050 * FREQ_MUL; break; 723 }; 724 725 /* Bottom of Band (MHz) */ 726 - switch (band) { 727 /* 0: 87.5 - 108 MHz (USA, Europe) */ 728 - case 0 : band_bottom = 87.5 * FREQ_MUL; break; 729 /* 1: 76 - 108 MHz (Japan wide band) */ 730 - default: band_bottom = 76 * FREQ_MUL; break; 731 /* 2: 76 - 90 MHz (Japan) */ 732 - case 2 : band_bottom = 76 * FREQ_MUL; break; 733 }; 734 735 /* Chan = [ Freq (Mhz) - Bottom of Band (MHz) ] / Spacing (kHz) */ ··· 1177 * si470x_v4l2_queryctrl - query control 1178 */ 1179 static struct v4l2_queryctrl si470x_v4l2_queryctrl[] = { 1180 - /* HINT: the disabled controls are only here to satify kradio and such apps */ 1181 { 1182 .id = V4L2_CID_AUDIO_VOLUME, 1183 .type = V4L2_CTRL_TYPE_INTEGER, ··· 1187 .default_value = 15, 1188 }, 1189 { 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 .id = V4L2_CID_AUDIO_MUTE, 1203 .type = V4L2_CTRL_TYPE_BOOLEAN, 1204 .name = "Mute", ··· 1194 .maximum = 1, 1195 .step = 1, 1196 .default_value = 1, 1197 - }, 1198 - { 1199 - .id = V4L2_CID_AUDIO_LOUDNESS, 1200 - .flags = V4L2_CTRL_FLAG_DISABLED, 1201 }, 1202 }; 1203 ··· 1216 1217 1218 /* 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 * si470x_vidioc_queryctrl - enumerate control items 1250 */ 1251 static int si470x_vidioc_queryctrl(struct file *file, void *priv, 1252 struct v4l2_queryctrl *qc) 1253 { 1254 - unsigned char i; 1255 int retval = -EINVAL; 1256 1257 - /* safety checks */ 1258 - if (!qc->id) 1259 goto done; 1260 1261 for (i = 0; i < ARRAY_SIZE(si470x_v4l2_queryctrl); i++) { 1262 if (qc->id == si470x_v4l2_queryctrl[i].id) { 1263 memcpy(qc, &(si470x_v4l2_queryctrl[i]), sizeof(*qc)); 1264 - retval = 0; 1265 break; 1266 } 1267 } 1268 1269 done: ··· 1334 static int si470x_vidioc_g_audio(struct file *file, void *priv, 1335 struct v4l2_audio *audio) 1336 { 1337 - int retval = 0; 1338 - 1339 - /* safety checks */ 1340 - if (audio->index != 0) { 1341 - retval = -EINVAL; 1342 - goto done; 1343 - } 1344 - 1345 strcpy(audio->name, "Radio"); 1346 audio->capability = V4L2_AUDCAP_STEREO; 1347 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; 1375 } 1376 1377 ··· 1358 retval = -EIO; 1359 goto done; 1360 } 1361 - if ((tuner->index != 0) && (tuner->type != V4L2_TUNER_RADIO)) { 1362 retval = -EINVAL; 1363 goto done; 1364 } ··· 1367 if (retval < 0) 1368 goto done; 1369 1370 strcpy(tuner->name, "FM"); 1371 - switch (band) { 1372 /* 0: 87.5 - 108 MHz (USA, Europe, default) */ 1373 default: 1374 tuner->rangelow = 87.5 * FREQ_MUL; ··· 1390 tuner->rangehigh = 90 * FREQ_MUL; 1391 break; 1392 }; 1393 - tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; 1394 - tuner->capability = V4L2_TUNER_CAP_LOW; 1395 1396 - /* Stereo indicator == Stereo (instead of Mono) */ 1397 if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 1) 1398 - tuner->audmode = V4L2_TUNER_MODE_STEREO; 1399 else 1400 tuner->audmode = V4L2_TUNER_MODE_MONO; 1401 1402 /* min is worst, max is best; signal:0..0xffff; rssi: 0..0xff */ 1403 tuner->signal = (radio->registers[STATUSRSSI] & STATUSRSSI_RSSI) ··· 1426 struct v4l2_tuner *tuner) 1427 { 1428 struct si470x_device *radio = video_drvdata(file); 1429 - int retval = 0; 1430 1431 /* safety checks */ 1432 if (radio->disconnected) { 1433 retval = -EIO; 1434 goto done; 1435 } 1436 - if ((tuner->index != 0) && (tuner->type != V4L2_TUNER_RADIO)) { 1437 - retval = -EINVAL; 1438 goto done; 1439 } 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 1446 retval = si470x_set_register(radio, POWERCFG); 1447 ··· 1472 retval = -EIO; 1473 goto done; 1474 } 1475 - if ((freq->tuner != 0) && (freq->type != V4L2_TUNER_RADIO)) { 1476 retval = -EINVAL; 1477 goto done; 1478 } 1479 1480 retval = si470x_get_freq(radio, &freq->frequency); 1481 1482 done: ··· 1502 retval = -EIO; 1503 goto done; 1504 } 1505 - if ((freq->tuner != 0) && (freq->type != V4L2_TUNER_RADIO)) { 1506 retval = -EINVAL; 1507 goto done; 1508 } ··· 1531 retval = -EIO; 1532 goto done; 1533 } 1534 - if ((seek->tuner != 0) && (seek->type != V4L2_TUNER_RADIO)) { 1535 retval = -EINVAL; 1536 goto done; 1537 } ··· 1546 return retval; 1547 } 1548 1549 static const struct v4l2_ioctl_ops si470x_ioctl_ops = { 1550 .vidioc_querycap = si470x_vidioc_querycap, 1551 - .vidioc_g_input = si470x_vidioc_g_input, 1552 - .vidioc_s_input = si470x_vidioc_s_input, 1553 .vidioc_queryctrl = si470x_vidioc_queryctrl, 1554 .vidioc_g_ctrl = si470x_vidioc_g_ctrl, 1555 .vidioc_s_ctrl = si470x_vidioc_s_ctrl, 1556 .vidioc_g_audio = si470x_vidioc_g_audio, 1557 - .vidioc_s_audio = si470x_vidioc_s_audio, 1558 .vidioc_g_tuner = si470x_vidioc_g_tuner, 1559 .vidioc_s_tuner = si470x_vidioc_s_tuner, 1560 .vidioc_g_frequency = si470x_vidioc_g_frequency, ··· 1563 .vidioc_s_hw_freq_seek = si470x_vidioc_s_hw_freq_seek, 1564 }; 1565 1566 /* 1567 - * si470x_viddev_tamples - video device interface 1568 */ 1569 static struct video_device si470x_viddev_template = { 1570 .fops = &si470x_fops, 1571 - .ioctl_ops = &si470x_ioctl_ops, 1572 .name = DRIVER_NAME, 1573 .release = video_device_release, 1574 }; 1575 1576
··· 104 * - hardware frequency seek support 105 * - afc indication 106 * - more safety checks, let si470x_get_freq return errno 107 + * - vidioc behavior corrected according to v4l2 spec 108 * 109 * ToDo: 110 * - add firmware download/update support ··· 141 /* USB Device ID List */ 142 static struct usb_device_id si470x_usb_driver_id_table[] = { 143 /* Silicon Labs USB FM Radio Reference Design */ 144 + { USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) }, 145 /* ADS/Tech FM Radio Receiver (formerly Instant FM Music) */ 146 + { USB_DEVICE_AND_INTERFACE_INFO(0x06e1, 0xa155, USB_CLASS_HID, 0, 0) }, 147 /* Terminating entry */ 148 { } 149 }; ··· 157 158 /* Radio Nr */ 159 static int radio_nr = -1; 160 + module_param(radio_nr, int, 0444); 161 MODULE_PARM_DESC(radio_nr, "Radio Nr"); 162 163 /* Spacing (kHz) */ ··· 165 /* 1: 100 kHz (Europe, Japan) */ 166 /* 2: 50 kHz */ 167 static unsigned short space = 2; 168 + module_param(space, ushort, 0444); 169 + MODULE_PARM_DESC(space, "Spacing: 0=200kHz 1=100kHz *2=50kHz*"); 170 171 /* Bottom of Band (MHz) */ 172 /* 0: 87.5 - 108 MHz (USA, Europe)*/ 173 /* 1: 76 - 108 MHz (Japan wide band) */ 174 /* 2: 76 - 90 MHz (Japan) */ 175 static unsigned short band = 1; 176 + module_param(band, ushort, 0444); 177 + MODULE_PARM_DESC(band, "Band: 0=87.5..108MHz *1=76..108MHz* 2=76..90MHz"); 178 179 /* De-emphasis */ 180 /* 0: 75 us (USA) */ 181 /* 1: 50 us (Europe, Australia, Japan) */ 182 static unsigned short de = 1; 183 + module_param(de, ushort, 0444); 184 + MODULE_PARM_DESC(de, "De-emphasis: 0=75us *1=50us*"); 185 186 /* USB timeout */ 187 static unsigned int usb_timeout = 500; 188 + module_param(usb_timeout, uint, 0644); 189 MODULE_PARM_DESC(usb_timeout, "USB timeout (ms): *500*"); 190 191 /* Tune timeout */ 192 static unsigned int tune_timeout = 3000; 193 + module_param(tune_timeout, uint, 0644); 194 MODULE_PARM_DESC(tune_timeout, "Tune timeout: *3000*"); 195 196 /* Seek timeout */ 197 static unsigned int seek_timeout = 5000; 198 + module_param(seek_timeout, uint, 0644); 199 MODULE_PARM_DESC(seek_timeout, "Seek timeout: *5000*"); 200 201 /* RDS buffer blocks */ 202 static unsigned int rds_buf = 100; 203 + module_param(rds_buf, uint, 0444); 204 MODULE_PARM_DESC(rds_buf, "RDS buffer entries: *100*"); 205 206 /* RDS maximum block errors */ ··· 209 /* 1 means 1-2 errors requiring correction (used by original USBRadio.exe) */ 210 /* 2 means 3-5 errors requiring correction */ 211 /* 3 means 6+ errors or errors in checkword, correction not possible */ 212 + module_param(max_rds_errors, ushort, 0644); 213 MODULE_PARM_DESC(max_rds_errors, "RDS maximum block errors: *1*"); 214 215 /* RDS poll frequency */ ··· 218 /* 50 is used by radio-cadet */ 219 /* 75 should be okay */ 220 /* 80 is the usual RDS receive interval */ 221 + module_param(rds_poll_time, uint, 0644); 222 MODULE_PARM_DESC(rds_poll_time, "RDS poll time (ms): *40*"); 223 224 ··· 667 int retval; 668 669 /* Spacing (kHz) */ 670 + switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_SPACE) >> 4) { 671 /* 0: 200 kHz (USA, Australia) */ 672 + case 0: 673 + spacing = 0.200 * FREQ_MUL; break; 674 /* 1: 100 kHz (Europe, Japan) */ 675 + case 1: 676 + spacing = 0.100 * FREQ_MUL; break; 677 /* 2: 50 kHz */ 678 + default: 679 + spacing = 0.050 * FREQ_MUL; break; 680 }; 681 682 /* Bottom of Band (MHz) */ 683 + switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { 684 /* 0: 87.5 - 108 MHz (USA, Europe) */ 685 + case 0: 686 + band_bottom = 87.5 * FREQ_MUL; break; 687 /* 1: 76 - 108 MHz (Japan wide band) */ 688 + default: 689 + band_bottom = 76 * FREQ_MUL; break; 690 /* 2: 76 - 90 MHz (Japan) */ 691 + case 2: 692 + band_bottom = 76 * FREQ_MUL; break; 693 }; 694 695 /* read channel */ ··· 706 unsigned short chan; 707 708 /* Spacing (kHz) */ 709 + switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_SPACE) >> 4) { 710 /* 0: 200 kHz (USA, Australia) */ 711 + case 0: 712 + spacing = 0.200 * FREQ_MUL; break; 713 /* 1: 100 kHz (Europe, Japan) */ 714 + case 1: 715 + spacing = 0.100 * FREQ_MUL; break; 716 /* 2: 50 kHz */ 717 + default: 718 + spacing = 0.050 * FREQ_MUL; break; 719 }; 720 721 /* Bottom of Band (MHz) */ 722 + switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { 723 /* 0: 87.5 - 108 MHz (USA, Europe) */ 724 + case 0: 725 + band_bottom = 87.5 * FREQ_MUL; break; 726 /* 1: 76 - 108 MHz (Japan wide band) */ 727 + default: 728 + band_bottom = 76 * FREQ_MUL; break; 729 /* 2: 76 - 90 MHz (Japan) */ 730 + case 2: 731 + band_bottom = 76 * FREQ_MUL; break; 732 }; 733 734 /* Chan = [ Freq (Mhz) - Bottom of Band (MHz) ] / Spacing (kHz) */ ··· 1164 * si470x_v4l2_queryctrl - query control 1165 */ 1166 static struct v4l2_queryctrl si470x_v4l2_queryctrl[] = { 1167 { 1168 .id = V4L2_CID_AUDIO_VOLUME, 1169 .type = V4L2_CTRL_TYPE_INTEGER, ··· 1175 .default_value = 15, 1176 }, 1177 { 1178 .id = V4L2_CID_AUDIO_MUTE, 1179 .type = V4L2_CTRL_TYPE_BOOLEAN, 1180 .name = "Mute", ··· 1194 .maximum = 1, 1195 .step = 1, 1196 .default_value = 1, 1197 }, 1198 }; 1199 ··· 1220 1221 1222 /* 1223 * si470x_vidioc_queryctrl - enumerate control items 1224 */ 1225 static int si470x_vidioc_queryctrl(struct file *file, void *priv, 1226 struct v4l2_queryctrl *qc) 1227 { 1228 + unsigned char i = 0; 1229 int retval = -EINVAL; 1230 1231 + /* abort if qc->id is below V4L2_CID_BASE */ 1232 + if (qc->id < V4L2_CID_BASE) 1233 goto done; 1234 1235 + /* search video control */ 1236 for (i = 0; i < ARRAY_SIZE(si470x_v4l2_queryctrl); i++) { 1237 if (qc->id == si470x_v4l2_queryctrl[i].id) { 1238 memcpy(qc, &(si470x_v4l2_queryctrl[i]), sizeof(*qc)); 1239 + retval = 0; /* found */ 1240 break; 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; 1249 } 1250 1251 done: ··· 1360 static int si470x_vidioc_g_audio(struct file *file, void *priv, 1361 struct v4l2_audio *audio) 1362 { 1363 + /* driver constants */ 1364 + audio->index = 0; 1365 strcpy(audio->name, "Radio"); 1366 audio->capability = V4L2_AUDCAP_STEREO; 1367 + audio->mode = 0; 1368 1369 + return 0; 1370 } 1371 1372 ··· 1415 retval = -EIO; 1416 goto done; 1417 } 1418 + if (tuner->index != 0) { 1419 retval = -EINVAL; 1420 goto done; 1421 } ··· 1424 if (retval < 0) 1425 goto done; 1426 1427 + /* driver constants */ 1428 strcpy(tuner->name, "FM"); 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) { 1434 /* 0: 87.5 - 108 MHz (USA, Europe, default) */ 1435 default: 1436 tuner->rangelow = 87.5 * FREQ_MUL; ··· 1442 tuner->rangehigh = 90 * FREQ_MUL; 1443 break; 1444 }; 1445 1446 + /* stereo indicator == stereo (instead of mono) */ 1447 if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 1) 1448 + tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; 1449 else 1450 + tuner->rxsubchans = V4L2_TUNER_SUB_MONO; 1451 + 1452 + /* mono/stereo selector */ 1453 + if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 1) 1454 tuner->audmode = V4L2_TUNER_MODE_MONO; 1455 + else 1456 + tuner->audmode = V4L2_TUNER_MODE_STEREO; 1457 1458 /* min is worst, max is best; signal:0..0xffff; rssi: 0..0xff */ 1459 tuner->signal = (radio->registers[STATUSRSSI] & STATUSRSSI_RSSI) ··· 1474 struct v4l2_tuner *tuner) 1475 { 1476 struct si470x_device *radio = video_drvdata(file); 1477 + int retval = -EINVAL; 1478 1479 /* safety checks */ 1480 if (radio->disconnected) { 1481 retval = -EIO; 1482 goto done; 1483 } 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: 1496 goto done; 1497 } 1498 1499 retval = si470x_set_register(radio, POWERCFG); 1500 ··· 1515 retval = -EIO; 1516 goto done; 1517 } 1518 + if (freq->tuner != 0) { 1519 retval = -EINVAL; 1520 goto done; 1521 } 1522 1523 + freq->type = V4L2_TUNER_RADIO; 1524 retval = si470x_get_freq(radio, &freq->frequency); 1525 1526 done: ··· 1544 retval = -EIO; 1545 goto done; 1546 } 1547 + if (freq->tuner != 0) { 1548 retval = -EINVAL; 1549 goto done; 1550 } ··· 1573 retval = -EIO; 1574 goto done; 1575 } 1576 + if (seek->tuner != 0) { 1577 retval = -EINVAL; 1578 goto done; 1579 } ··· 1588 return retval; 1589 } 1590 1591 + 1592 + /* 1593 + * si470x_ioctl_ops - video device ioctl operations 1594 + */ 1595 static const struct v4l2_ioctl_ops si470x_ioctl_ops = { 1596 .vidioc_querycap = si470x_vidioc_querycap, 1597 .vidioc_queryctrl = si470x_vidioc_queryctrl, 1598 .vidioc_g_ctrl = si470x_vidioc_g_ctrl, 1599 .vidioc_s_ctrl = si470x_vidioc_s_ctrl, 1600 .vidioc_g_audio = si470x_vidioc_g_audio, 1601 .vidioc_g_tuner = si470x_vidioc_g_tuner, 1602 .vidioc_s_tuner = si470x_vidioc_s_tuner, 1603 .vidioc_g_frequency = si470x_vidioc_g_frequency, ··· 1604 .vidioc_s_hw_freq_seek = si470x_vidioc_s_hw_freq_seek, 1605 }; 1606 1607 + 1608 /* 1609 + * si470x_viddev_template - video device interface 1610 */ 1611 static struct video_device si470x_viddev_template = { 1612 .fops = &si470x_fops, 1613 .name = DRIVER_NAME, 1614 .release = video_device_release, 1615 + .ioctl_ops = &si470x_ioctl_ops, 1616 }; 1617 1618
+58 -195
drivers/media/video/adv7170.c
··· 29 */ 30 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 <linux/types.h> 42 - #include <linux/i2c.h> 43 - #include <asm/io.h> 44 - #include <asm/pgtable.h> 45 - #include <asm/page.h> 46 #include <asm/uaccess.h> 47 - 48 #include <linux/videodev.h> 49 #include <linux/video_encoder.h> 50 51 MODULE_DESCRIPTION("Analog Devices ADV7170 video encoder driver"); 52 MODULE_AUTHOR("Maxim Yevtyushkin"); 53 MODULE_LICENSE("GPL"); 54 55 - 56 - #define I2C_NAME(x) (x)->name 57 - 58 - 59 static int debug; 60 module_param(debug, int, 0); 61 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 69 /* ----------------------------------------------------------------------- */ 70 ··· 61 int sat; 62 }; 63 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 static char *inputs[] = { "pass_through", "play_back" }; 71 static char *norms[] = { "PAL", "NTSC" }; 72 73 /* ----------------------------------------------------------------------- */ 74 75 - static inline int 76 - adv7170_write (struct i2c_client *client, 77 - u8 reg, 78 - u8 value) 79 { 80 struct adv7170 *encoder = i2c_get_clientdata(client); 81 ··· 74 return i2c_smbus_write_byte_data(client, reg, value); 75 } 76 77 - static inline int 78 - adv7170_read (struct i2c_client *client, 79 - u8 reg) 80 { 81 return i2c_smbus_read_byte_data(client, reg); 82 } 83 84 - static int 85 - adv7170_write_block (struct i2c_client *client, 86 - const u8 *data, 87 - unsigned int len) 88 { 89 int ret = -1; 90 u8 reg; ··· 101 encoder->reg[reg++] = data[1]; 102 len -= 2; 103 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) 108 break; 109 } 110 } else { 111 /* do some slow I2C emulation kind of thing */ 112 while (len >= 2) { 113 reg = *data++; 114 - if ((ret = adv7170_write(client, reg, 115 - *data++)) < 0) 116 break; 117 len -= 2; 118 } 119 } 120 - 121 return ret; 122 } 123 124 /* ----------------------------------------------------------------------- */ 125 - // Output filter: S-Video Composite 126 - 127 - #define MR050 0x11 //0x09 128 - #define MR060 0x14 //0x0c 129 - 130 - //--------------------------------------------------------------------------- 131 132 #define TR0MODE 0x4c 133 #define TR0RST 0x80 134 135 #define TR1CAPT 0x00 136 #define TR1PLAY 0x00 137 - 138 139 static const unsigned char init_NTSC[] = { 140 0x00, 0x10, // MR0 ··· 186 }; 187 188 189 - static int 190 - adv7170_command (struct i2c_client *client, 191 - unsigned int cmd, 192 - void * arg) 193 { 194 struct adv7170 *encoder = i2c_get_clientdata(client); 195 196 switch (cmd) { 197 - 198 case 0: 199 #if 0 200 /* This is just for testing!!! */ ··· 209 VIDEO_ENCODER_NTSC; 210 cap->inputs = 2; 211 cap->outputs = 1; 212 - } 213 break; 214 215 case ENCODER_SET_NORM: 216 { 217 int iarg = *(int *) arg; 218 219 - dprintk(1, KERN_DEBUG "%s_command: set norm %d", 220 - I2C_NAME(client), iarg); 221 222 switch (iarg) { 223 - 224 case VIDEO_MODE_NTSC: 225 adv7170_write_block(client, init_NTSC, 226 sizeof(init_NTSC)); ··· 238 break; 239 240 default: 241 - dprintk(1, KERN_ERR "%s: illegal norm: %d\n", 242 - I2C_NAME(client), iarg); 243 return -EINVAL; 244 - 245 } 246 - dprintk(1, KERN_DEBUG "%s: switched to %s\n", I2C_NAME(client), 247 - norms[iarg]); 248 encoder->norm = iarg; 249 - } 250 break; 251 252 case ENCODER_SET_INPUT: 253 { ··· 254 *iarg = 1: input is from ZR36060 255 *iarg = 2: color bar */ 256 257 - dprintk(1, KERN_DEBUG "%s_command: set input from %s\n", 258 - I2C_NAME(client), 259 iarg == 0 ? "decoder" : "ZR36060"); 260 261 switch (iarg) { 262 - 263 case 0: 264 adv7170_write(client, 0x01, 0x20); 265 adv7170_write(client, 0x08, TR1CAPT); /* TR1 */ 266 adv7170_write(client, 0x02, 0x0e); // Enable genlock 267 adv7170_write(client, 0x07, TR0MODE | TR0RST); 268 adv7170_write(client, 0x07, TR0MODE); 269 - //udelay(10); 270 break; 271 272 case 1: ··· 273 adv7170_write(client, 0x02, 0x08); 274 adv7170_write(client, 0x07, TR0MODE | TR0RST); 275 adv7170_write(client, 0x07, TR0MODE); 276 - //udelay(10); 277 break; 278 279 default: 280 - dprintk(1, KERN_ERR "%s: illegal input: %d\n", 281 - I2C_NAME(client), iarg); 282 return -EINVAL; 283 - 284 } 285 - dprintk(1, KERN_DEBUG "%s: switched to %s\n", I2C_NAME(client), 286 - inputs[iarg]); 287 encoder->input = iarg; 288 - } 289 break; 290 291 case ENCODER_SET_OUTPUT: 292 { ··· 293 if (*iarg != 0) { 294 return -EINVAL; 295 } 296 - } 297 break; 298 299 case ENCODER_ENABLE_OUTPUT: 300 { 301 int *iarg = arg; 302 303 encoder->enable = !!*iarg; 304 - } 305 break; 306 307 default: 308 return -EINVAL; ··· 313 314 /* ----------------------------------------------------------------------- */ 315 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, 323 I2C_CLIENT_END 324 }; 325 326 - static unsigned short ignore = I2C_CLIENT_END; 327 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) 340 { 341 - int i; 342 - struct i2c_client *client; 343 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); 350 351 /* Check if the adapter supports the needed features */ 352 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 353 - return 0; 354 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))); 373 374 encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL); 375 - if (encoder == NULL) { 376 - kfree(client); 377 return -ENOMEM; 378 - } 379 encoder->norm = VIDEO_MODE_NTSC; 380 encoder->input = 0; 381 encoder->enable = 1; 382 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 391 i = adv7170_write_block(client, init_NTSC, sizeof(init_NTSC)); 392 if (i >= 0) { 393 i = adv7170_write(client, 0x07, TR0MODE | TR0RST); 394 i = adv7170_write(client, 0x07, TR0MODE); 395 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); 398 } 399 - if (i < 0) { 400 - dprintk(1, KERN_ERR "%s_attach: init error 0x%x\n", 401 - I2C_NAME(client), i); 402 - } 403 - 404 return 0; 405 } 406 407 - static int 408 - adv7170_attach_adapter (struct i2c_adapter *adapter) 409 { 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 - 431 return 0; 432 } 433 434 /* ----------------------------------------------------------------------- */ 435 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, 446 }; 447 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);
··· 29 */ 30 31 #include <linux/module.h> 32 #include <linux/types.h> 33 + #include <linux/ioctl.h> 34 #include <asm/uaccess.h> 35 + #include <linux/i2c.h> 36 + #include <linux/i2c-id.h> 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> 41 42 MODULE_DESCRIPTION("Analog Devices ADV7170 video encoder driver"); 43 MODULE_AUTHOR("Maxim Yevtyushkin"); 44 MODULE_LICENSE("GPL"); 45 46 static int debug; 47 module_param(debug, int, 0); 48 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 49 50 /* ----------------------------------------------------------------------- */ 51 ··· 80 int sat; 81 }; 82 83 static char *inputs[] = { "pass_through", "play_back" }; 84 static char *norms[] = { "PAL", "NTSC" }; 85 86 /* ----------------------------------------------------------------------- */ 87 88 + static inline int adv7170_write(struct i2c_client *client, u8 reg, u8 value) 89 { 90 struct adv7170 *encoder = i2c_get_clientdata(client); 91 ··· 102 return i2c_smbus_write_byte_data(client, reg, value); 103 } 104 105 + static inline int adv7170_read(struct i2c_client *client, u8 reg) 106 { 107 return i2c_smbus_read_byte_data(client, reg); 108 } 109 110 + static int adv7170_write_block(struct i2c_client *client, 111 + const u8 *data, unsigned int len) 112 { 113 int ret = -1; 114 u8 reg; ··· 133 encoder->reg[reg++] = data[1]; 134 len -= 2; 135 data += 2; 136 + } while (len >= 2 && data[0] == reg && block_len < 32); 137 + ret = i2c_master_send(client, block_data, block_len); 138 + if (ret < 0) 139 break; 140 } 141 } else { 142 /* do some slow I2C emulation kind of thing */ 143 while (len >= 2) { 144 reg = *data++; 145 + ret = adv7170_write(client, reg, *data++); 146 + if (ret < 0) 147 break; 148 len -= 2; 149 } 150 } 151 return ret; 152 } 153 154 /* ----------------------------------------------------------------------- */ 155 156 #define TR0MODE 0x4c 157 #define TR0RST 0x80 158 159 #define TR1CAPT 0x00 160 #define TR1PLAY 0x00 161 162 static const unsigned char init_NTSC[] = { 163 0x00, 0x10, // MR0 ··· 227 }; 228 229 230 + static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg) 231 { 232 struct adv7170 *encoder = i2c_get_clientdata(client); 233 234 switch (cmd) { 235 case 0: 236 #if 0 237 /* This is just for testing!!! */ ··· 254 VIDEO_ENCODER_NTSC; 255 cap->inputs = 2; 256 cap->outputs = 1; 257 break; 258 + } 259 260 case ENCODER_SET_NORM: 261 { 262 int iarg = *(int *) arg; 263 264 + v4l_dbg(1, debug, client, "set norm %d\n", iarg); 265 266 switch (iarg) { 267 case VIDEO_MODE_NTSC: 268 adv7170_write_block(client, init_NTSC, 269 sizeof(init_NTSC)); ··· 285 break; 286 287 default: 288 + v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg); 289 return -EINVAL; 290 } 291 + v4l_dbg(1, debug, client, "switched to %s\n", norms[iarg]); 292 encoder->norm = iarg; 293 break; 294 + } 295 296 case ENCODER_SET_INPUT: 297 { ··· 304 *iarg = 1: input is from ZR36060 305 *iarg = 2: color bar */ 306 307 + v4l_dbg(1, debug, client, "set input from %s\n", 308 iarg == 0 ? "decoder" : "ZR36060"); 309 310 switch (iarg) { 311 case 0: 312 adv7170_write(client, 0x01, 0x20); 313 adv7170_write(client, 0x08, TR1CAPT); /* TR1 */ 314 adv7170_write(client, 0x02, 0x0e); // Enable genlock 315 adv7170_write(client, 0x07, TR0MODE | TR0RST); 316 adv7170_write(client, 0x07, TR0MODE); 317 + /* udelay(10); */ 318 break; 319 320 case 1: ··· 325 adv7170_write(client, 0x02, 0x08); 326 adv7170_write(client, 0x07, TR0MODE | TR0RST); 327 adv7170_write(client, 0x07, TR0MODE); 328 + /* udelay(10); */ 329 break; 330 331 default: 332 + v4l_dbg(1, debug, client, "illegal input: %d\n", iarg); 333 return -EINVAL; 334 } 335 + v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]); 336 encoder->input = iarg; 337 break; 338 + } 339 340 case ENCODER_SET_OUTPUT: 341 { ··· 348 if (*iarg != 0) { 349 return -EINVAL; 350 } 351 break; 352 + } 353 354 case ENCODER_ENABLE_OUTPUT: 355 { 356 int *iarg = arg; 357 358 encoder->enable = !!*iarg; 359 break; 360 + } 361 362 default: 363 return -EINVAL; ··· 368 369 /* ----------------------------------------------------------------------- */ 370 371 + static unsigned short normal_i2c[] = { 372 + 0xd4 >> 1, 0xd6 >> 1, /* adv7170 IDs */ 373 + 0x54 >> 1, 0x56 >> 1, /* adv7171 IDs */ 374 I2C_CLIENT_END 375 }; 376 377 + I2C_CLIENT_INSMOD; 378 379 + static int adv7170_probe(struct i2c_client *client, 380 + const struct i2c_device_id *id) 381 { 382 struct adv7170 *encoder; 383 + int i; 384 385 /* Check if the adapter supports the needed features */ 386 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 387 + return -ENODEV; 388 389 + v4l_info(client, "chip found @ 0x%x (%s)\n", 390 + client->addr << 1, client->adapter->name); 391 392 encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL); 393 + if (encoder == NULL) 394 return -ENOMEM; 395 encoder->norm = VIDEO_MODE_NTSC; 396 encoder->input = 0; 397 encoder->enable = 1; 398 i2c_set_clientdata(client, encoder); 399 400 i = adv7170_write_block(client, init_NTSC, sizeof(init_NTSC)); 401 if (i >= 0) { 402 i = adv7170_write(client, 0x07, TR0MODE | TR0RST); 403 i = adv7170_write(client, 0x07, TR0MODE); 404 i = adv7170_read(client, 0x12); 405 + v4l_dbg(1, debug, client, "revision %d\n", i & 1); 406 } 407 + if (i < 0) 408 + v4l_dbg(1, debug, client, "init error 0x%x\n", i); 409 return 0; 410 } 411 412 + static int adv7170_remove(struct i2c_client *client) 413 { 414 + kfree(i2c_get_clientdata(client)); 415 return 0; 416 } 417 418 /* ----------------------------------------------------------------------- */ 419 420 + static const struct i2c_device_id adv7170_id[] = { 421 + { "adv7170", 0 }, 422 + { "adv7171", 0 }, 423 + { } 424 }; 425 + MODULE_DEVICE_TABLE(i2c, adv7170_id); 426 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 */ 26 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 #include <linux/types.h> 38 - #include <linux/i2c.h> 39 - #include <asm/io.h> 40 - #include <asm/pgtable.h> 41 - #include <asm/page.h> 42 #include <asm/uaccess.h> 43 - 44 #include <linux/videodev.h> 45 #include <linux/video_encoder.h> 46 47 MODULE_DESCRIPTION("Analog Devices ADV7175 video encoder driver"); 48 MODULE_AUTHOR("Dave Perks"); 49 MODULE_LICENSE("GPL"); 50 51 - 52 - #define I2C_NAME(s) (s)->name 53 - 54 - 55 static int debug; 56 module_param(debug, int, 0); 57 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 65 /* ----------------------------------------------------------------------- */ 66 ··· 58 #define I2C_ADV7175 0xd4 59 #define I2C_ADV7176 0x54 60 61 - static char adv7175_name[] = "adv7175"; 62 - static char adv7176_name[] = "adv7176"; 63 - 64 static char *inputs[] = { "pass_through", "play_back", "color_bar" }; 65 static char *norms[] = { "PAL", "NTSC", "SECAM->PAL (may not work!)" }; 66 67 /* ----------------------------------------------------------------------- */ 68 69 - static inline int 70 - adv7175_write (struct i2c_client *client, 71 - u8 reg, 72 - u8 value) 73 { 74 return i2c_smbus_write_byte_data(client, reg, value); 75 } 76 77 - static inline int 78 - adv7175_read (struct i2c_client *client, 79 - u8 reg) 80 { 81 return i2c_smbus_read_byte_data(client, reg); 82 } 83 84 - static int 85 - adv7175_write_block (struct i2c_client *client, 86 - const u8 *data, 87 - unsigned int len) 88 { 89 int ret = -1; 90 u8 reg; ··· 94 reg++; 95 len -= 2; 96 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) 101 break; 102 } 103 } else { 104 /* do some slow I2C emulation kind of thing */ 105 while (len >= 2) { 106 reg = *data++; 107 - if ((ret = adv7175_write(client, reg, 108 - *data++)) < 0) 109 break; 110 len -= 2; 111 } ··· 113 return ret; 114 } 115 116 - static void 117 - set_subcarrier_freq (struct i2c_client *client, 118 - int pass_through) 119 { 120 /* for some reason pass_through NTSC needs 121 * a different sub-carrier freq to remain stable. */ 122 - if(pass_through) 123 adv7175_write(client, 0x02, 0x00); 124 else 125 adv7175_write(client, 0x02, 0x55); ··· 128 } 129 130 /* ----------------------------------------------------------------------- */ 131 - // Output filter: S-Video Composite 132 133 - #define MR050 0x11 //0x09 134 - #define MR060 0x14 //0x0c 135 136 - //--------------------------------------------------------------------------- 137 138 #define TR0MODE 0x46 139 #define TR0RST 0x80 ··· 184 0x06, 0x1a, /* subc. phase */ 185 }; 186 187 - static int 188 - adv7175_command (struct i2c_client *client, 189 - unsigned int cmd, 190 - void *arg) 191 { 192 struct adv7175 *encoder = i2c_get_clientdata(client); 193 194 switch (cmd) { 195 - 196 case 0: 197 /* This is just for testing!!! */ 198 adv7175_write_block(client, init_common, ··· 206 VIDEO_ENCODER_SECAM; /* well, hacky */ 207 cap->inputs = 2; 208 cap->outputs = 1; 209 - } 210 break; 211 212 case ENCODER_SET_NORM: 213 { 214 int iarg = *(int *) arg; 215 216 switch (iarg) { 217 - 218 case VIDEO_MODE_NTSC: 219 adv7175_write_block(client, init_ntsc, 220 sizeof(init_ntsc)); ··· 247 adv7175_write(client, 0x07, TR0MODE); 248 break; 249 default: 250 - dprintk(1, KERN_ERR "%s: illegal norm: %d\n", 251 - I2C_NAME(client), iarg); 252 return -EINVAL; 253 - 254 } 255 - dprintk(1, KERN_INFO "%s: switched to %s\n", I2C_NAME(client), 256 - norms[iarg]); 257 encoder->norm = iarg; 258 - } 259 break; 260 261 case ENCODER_SET_INPUT: 262 { ··· 264 *iarg = 2: color bar */ 265 266 switch (iarg) { 267 - 268 case 0: 269 adv7175_write(client, 0x01, 0x00); 270 ··· 290 adv7175_write(client, 0x0d, 0x49); 291 adv7175_write(client, 0x07, TR0MODE | TR0RST); 292 adv7175_write(client, 0x07, TR0MODE); 293 - //udelay(10); 294 break; 295 296 case 2: ··· 302 adv7175_write(client, 0x0d, 0x49); 303 adv7175_write(client, 0x07, TR0MODE | TR0RST); 304 adv7175_write(client, 0x07, TR0MODE); 305 - //udelay(10); 306 break; 307 308 default: 309 - dprintk(1, KERN_ERR "%s: illegal input: %d\n", 310 - I2C_NAME(client), iarg); 311 return -EINVAL; 312 - 313 } 314 - dprintk(1, KERN_INFO "%s: switched to %s\n", I2C_NAME(client), 315 - inputs[iarg]); 316 encoder->input = iarg; 317 - } 318 break; 319 320 case ENCODER_SET_OUTPUT: 321 { 322 int *iarg = arg; 323 324 /* not much choice of outputs */ 325 - if (*iarg != 0) { 326 return -EINVAL; 327 - } 328 - } 329 break; 330 331 case ENCODER_ENABLE_OUTPUT: 332 { 333 int *iarg = arg; 334 335 encoder->enable = !!*iarg; 336 - } 337 break; 338 339 default: 340 return -EINVAL; ··· 345 * Generic i2c probe 346 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 347 */ 348 - static unsigned short normal_i2c[] = 349 - { I2C_ADV7175 >> 1, (I2C_ADV7175 >> 1) + 1, 350 I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1, 351 I2C_CLIENT_END 352 }; 353 354 - static unsigned short ignore = I2C_CLIENT_END; 355 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) 368 { 369 int i; 370 - struct i2c_client *client; 371 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 379 /* Check if the adapter supports the needed features */ 380 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 381 - return 0; 382 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))); 401 402 encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL); 403 - if (encoder == NULL) { 404 - kfree(client); 405 return -ENOMEM; 406 - } 407 encoder->norm = VIDEO_MODE_PAL; 408 encoder->input = 0; 409 encoder->enable = 1; 410 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 419 i = adv7175_write_block(client, init_common, sizeof(init_common)); 420 if (i >= 0) { 421 i = adv7175_write(client, 0x07, TR0MODE | TR0RST); 422 i = adv7175_write(client, 0x07, TR0MODE); 423 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); 426 } 427 - if (i < 0) { 428 - dprintk(1, KERN_ERR "%s_attach: init error 0x%x\n", 429 - I2C_NAME(client), i); 430 - } 431 - 432 return 0; 433 } 434 435 - static int 436 - adv7175_attach_adapter (struct i2c_adapter *adapter) 437 { 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 - 459 return 0; 460 } 461 462 /* ----------------------------------------------------------------------- */ 463 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, 474 }; 475 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);
··· 25 */ 26 27 #include <linux/module.h> 28 #include <linux/types.h> 29 + #include <linux/ioctl.h> 30 #include <asm/uaccess.h> 31 + #include <linux/i2c.h> 32 + #include <linux/i2c-id.h> 33 #include <linux/videodev.h> 34 #include <linux/video_encoder.h> 35 + #include <media/v4l2-common.h> 36 + #include <media/v4l2-i2c-drv-legacy.h> 37 38 MODULE_DESCRIPTION("Analog Devices ADV7175 video encoder driver"); 39 MODULE_AUTHOR("Dave Perks"); 40 MODULE_LICENSE("GPL"); 41 42 static int debug; 43 module_param(debug, int, 0); 44 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 45 46 /* ----------------------------------------------------------------------- */ 47 ··· 77 #define I2C_ADV7175 0xd4 78 #define I2C_ADV7176 0x54 79 80 static char *inputs[] = { "pass_through", "play_back", "color_bar" }; 81 static char *norms[] = { "PAL", "NTSC", "SECAM->PAL (may not work!)" }; 82 83 /* ----------------------------------------------------------------------- */ 84 85 + static inline int adv7175_write(struct i2c_client *client, u8 reg, u8 value) 86 { 87 return i2c_smbus_write_byte_data(client, reg, value); 88 } 89 90 + static inline int adv7175_read(struct i2c_client *client, u8 reg) 91 { 92 return i2c_smbus_read_byte_data(client, reg); 93 } 94 95 + static int adv7175_write_block(struct i2c_client *client, 96 + const u8 *data, unsigned int len) 97 { 98 int ret = -1; 99 u8 reg; ··· 123 reg++; 124 len -= 2; 125 data += 2; 126 + } while (len >= 2 && data[0] == reg && block_len < 32); 127 + ret = i2c_master_send(client, block_data, block_len); 128 + if (ret < 0) 129 break; 130 } 131 } else { 132 /* do some slow I2C emulation kind of thing */ 133 while (len >= 2) { 134 reg = *data++; 135 + ret = adv7175_write(client, reg, *data++); 136 + if (ret < 0) 137 break; 138 len -= 2; 139 } ··· 143 return ret; 144 } 145 146 + static void set_subcarrier_freq(struct i2c_client *client, int pass_through) 147 { 148 /* for some reason pass_through NTSC needs 149 * a different sub-carrier freq to remain stable. */ 150 + if (pass_through) 151 adv7175_write(client, 0x02, 0x00); 152 else 153 adv7175_write(client, 0x02, 0x55); ··· 160 } 161 162 /* ----------------------------------------------------------------------- */ 163 + /* Output filter: S-Video Composite */ 164 165 + #define MR050 0x11 /* 0x09 */ 166 + #define MR060 0x14 /* 0x0c */ 167 168 + /* ----------------------------------------------------------------------- */ 169 170 #define TR0MODE 0x46 171 #define TR0RST 0x80 ··· 216 0x06, 0x1a, /* subc. phase */ 217 }; 218 219 + static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) 220 { 221 struct adv7175 *encoder = i2c_get_clientdata(client); 222 223 switch (cmd) { 224 case 0: 225 /* This is just for testing!!! */ 226 adv7175_write_block(client, init_common, ··· 242 VIDEO_ENCODER_SECAM; /* well, hacky */ 243 cap->inputs = 2; 244 cap->outputs = 1; 245 break; 246 + } 247 248 case ENCODER_SET_NORM: 249 { 250 int iarg = *(int *) arg; 251 252 switch (iarg) { 253 case VIDEO_MODE_NTSC: 254 adv7175_write_block(client, init_ntsc, 255 sizeof(init_ntsc)); ··· 284 adv7175_write(client, 0x07, TR0MODE); 285 break; 286 default: 287 + v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg); 288 return -EINVAL; 289 } 290 + v4l_dbg(1, debug, client, "switched to %s\n", norms[iarg]); 291 encoder->norm = iarg; 292 break; 293 + } 294 295 case ENCODER_SET_INPUT: 296 { ··· 304 *iarg = 2: color bar */ 305 306 switch (iarg) { 307 case 0: 308 adv7175_write(client, 0x01, 0x00); 309 ··· 331 adv7175_write(client, 0x0d, 0x49); 332 adv7175_write(client, 0x07, TR0MODE | TR0RST); 333 adv7175_write(client, 0x07, TR0MODE); 334 + /* udelay(10); */ 335 break; 336 337 case 2: ··· 343 adv7175_write(client, 0x0d, 0x49); 344 adv7175_write(client, 0x07, TR0MODE | TR0RST); 345 adv7175_write(client, 0x07, TR0MODE); 346 + /* udelay(10); */ 347 break; 348 349 default: 350 + v4l_dbg(1, debug, client, "illegal input: %d\n", iarg); 351 return -EINVAL; 352 } 353 + v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]); 354 encoder->input = iarg; 355 break; 356 + } 357 358 case ENCODER_SET_OUTPUT: 359 { 360 int *iarg = arg; 361 362 /* not much choice of outputs */ 363 + if (*iarg != 0) 364 return -EINVAL; 365 break; 366 + } 367 368 case ENCODER_ENABLE_OUTPUT: 369 { 370 int *iarg = arg; 371 372 encoder->enable = !!*iarg; 373 break; 374 + } 375 376 default: 377 return -EINVAL; ··· 390 * Generic i2c probe 391 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 392 */ 393 + static unsigned short normal_i2c[] = { 394 + I2C_ADV7175 >> 1, (I2C_ADV7175 >> 1) + 1, 395 I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1, 396 I2C_CLIENT_END 397 }; 398 399 + I2C_CLIENT_INSMOD; 400 401 + static int adv7175_probe(struct i2c_client *client, 402 + const struct i2c_device_id *id) 403 { 404 int i; 405 struct adv7175 *encoder; 406 407 /* Check if the adapter supports the needed features */ 408 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 409 + return -ENODEV; 410 411 + v4l_info(client, "chip found @ 0x%x (%s)\n", 412 + client->addr << 1, client->adapter->name); 413 414 encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL); 415 + if (encoder == NULL) 416 return -ENOMEM; 417 encoder->norm = VIDEO_MODE_PAL; 418 encoder->input = 0; 419 encoder->enable = 1; 420 i2c_set_clientdata(client, encoder); 421 422 i = adv7175_write_block(client, init_common, sizeof(init_common)); 423 if (i >= 0) { 424 i = adv7175_write(client, 0x07, TR0MODE | TR0RST); 425 i = adv7175_write(client, 0x07, TR0MODE); 426 i = adv7175_read(client, 0x12); 427 + v4l_dbg(1, debug, client, "revision %d\n", i & 1); 428 } 429 + if (i < 0) 430 + v4l_dbg(1, debug, client, "init error 0x%x\n", i); 431 return 0; 432 } 433 434 + static int adv7175_remove(struct i2c_client *client) 435 { 436 + kfree(i2c_get_clientdata(client)); 437 return 0; 438 } 439 440 /* ----------------------------------------------------------------------- */ 441 442 + static const struct i2c_device_id adv7175_id[] = { 443 + { "adv7175", 0 }, 444 + { "adv7176", 0 }, 445 + { } 446 }; 447 + MODULE_DEVICE_TABLE(i2c, adv7175_id); 448 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 case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ 91 case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ 92 case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and basic analog video */ 93 case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */ 94 case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ 95 break; ··· 186 } 187 188 /* table of devices that work with this driver */ 189 - struct usb_device_id au0828_usb_id_table [] = { 190 { USB_DEVICE(0x2040, 0x7200), 191 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 192 { USB_DEVICE(0x2040, 0x7240), ··· 198 { USB_DEVICE(0x2040, 0x7217), 199 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 200 { USB_DEVICE(0x2040, 0x721b), 201 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 202 { USB_DEVICE(0x2040, 0x721f), 203 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
··· 90 case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ 91 case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ 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 */ 94 case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */ 95 case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ 96 break; ··· 185 } 186 187 /* table of devices that work with this driver */ 188 + struct usb_device_id au0828_usb_id_table[] = { 189 { USB_DEVICE(0x2040, 0x7200), 190 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 191 { USB_DEVICE(0x2040, 0x7240), ··· 197 { USB_DEVICE(0x2040, 0x7217), 198 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 199 { USB_DEVICE(0x2040, 0x721b), 200 + .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 201 + { USB_DEVICE(0x2040, 0x721e), 202 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 203 { USB_DEVICE(0x2040, 0x721f), 204 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
+2 -1
drivers/media/video/au0828/au0828-core.c
··· 91 status = usb_control_msg(dev->usbdev, 92 usb_sndctrlpipe(dev->usbdev, 0), 93 request, 94 - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 95 value, index, 96 cp, size, 1000); 97
··· 91 status = usb_control_msg(dev->usbdev, 92 usb_sndctrlpipe(dev->usbdev, 0), 93 request, 94 + USB_DIR_OUT | USB_TYPE_VENDOR | 95 + USB_RECIP_DEVICE, 96 value, index, 97 cp, size, 1000); 98
+2 -1
drivers/media/video/au0828/au0828-dvb.c
··· 173 purb->status = -EINPROGRESS; 174 usb_fill_bulk_urb(purb, 175 dev->usbdev, 176 - usb_rcvbulkpipe(dev->usbdev, _AU0828_BULKPIPE), 177 purb->transfer_buffer, 178 URB_BUFSIZE, 179 urb_completion,
··· 173 purb->status = -EINPROGRESS; 174 usb_fill_bulk_urb(purb, 175 dev->usbdev, 176 + usb_rcvbulkpipe(dev->usbdev, 177 + _AU0828_BULKPIPE), 178 purb->transfer_buffer, 179 URB_BUFSIZE, 180 urb_completion,
+93 -230
drivers/media/video/bt819.c
··· 29 */ 30 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 <linux/types.h> 42 - #include <linux/i2c.h> 43 - #include <asm/io.h> 44 - #include <asm/pgtable.h> 45 - #include <asm/page.h> 46 #include <asm/uaccess.h> 47 - 48 #include <linux/videodev.h> 49 #include <linux/video_decoder.h> 50 - 51 52 MODULE_DESCRIPTION("Brooktree-819 video decoder driver"); 53 MODULE_AUTHOR("Mike Bernson & Dave Perks"); 54 MODULE_LICENSE("GPL"); 55 56 - 57 - #define I2C_NAME(s) (s)->name 58 - 59 - 60 static int debug; 61 module_param(debug, int, 0); 62 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 70 /* ----------------------------------------------------------------------- */ 71 ··· 78 {858 - 24, 20, 525 - 2, 1, 0x00f8, 0x0000}, 79 }; 80 81 - #define I2C_BT819 0x8a 82 - 83 /* ----------------------------------------------------------------------- */ 84 85 - static inline int 86 - bt819_write (struct i2c_client *client, 87 - u8 reg, 88 - u8 value) 89 { 90 struct bt819 *decoder = i2c_get_clientdata(client); 91 ··· 88 return i2c_smbus_write_byte_data(client, reg, value); 89 } 90 91 - static inline int 92 - bt819_setbit (struct i2c_client *client, 93 - u8 reg, 94 - u8 bit, 95 - u8 value) 96 { 97 struct bt819 *decoder = i2c_get_clientdata(client); 98 99 return bt819_write(client, reg, 100 - (decoder-> 101 - reg[reg] & ~(1 << bit)) | 102 - (value ? (1 << bit) : 0)); 103 } 104 105 - static int 106 - bt819_write_block (struct i2c_client *client, 107 - const u8 *data, 108 - unsigned int len) 109 { 110 int ret = -1; 111 u8 reg; ··· 117 decoder->reg[reg++] = data[1]; 118 len -= 2; 119 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) 124 break; 125 } 126 } else { ··· 135 return ret; 136 } 137 138 - static inline int 139 - bt819_read (struct i2c_client *client, 140 - u8 reg) 141 { 142 return i2c_smbus_read_byte_data(client, reg); 143 } 144 145 - static int 146 - bt819_init (struct i2c_client *client) 147 { 148 struct bt819 *decoder = i2c_get_clientdata(client); 149 150 static unsigned char init[] = { 151 - //0x1f, 0x00, /* Reset */ 152 0x01, 0x59, /* 0x01 input format */ 153 0x02, 0x00, /* 0x02 temporal decimation */ 154 0x03, 0x12, /* 0x03 Cropping msb */ ··· 181 struct timing *timing = &timing_data[decoder->norm]; 182 183 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); 190 init[0x04 * 2 - 1] = timing->vdelay & 0xff; 191 init[0x05 * 2 - 1] = timing->vactive & 0xff; 192 init[0x06 * 2 - 1] = timing->hdelay & 0xff; ··· 199 200 /* init */ 201 return bt819_write_block(client, init, sizeof(init)); 202 - 203 } 204 205 /* ----------------------------------------------------------------------- */ 206 207 - static int 208 - bt819_command (struct i2c_client *client, 209 - unsigned int cmd, 210 - void *arg) 211 { 212 int temp; 213 214 struct bt819 *decoder = i2c_get_clientdata(client); 215 216 - if (!decoder->initialized) { // First call to bt819_init could be 217 - bt819_init(client); // without #FRST = 0 218 decoder->initialized = 1; 219 } 220 221 switch (cmd) { 222 - 223 case 0: 224 /* This is just for testing!!! */ 225 bt819_init(client); ··· 230 VIDEO_DECODER_CCIR; 231 cap->inputs = 8; 232 cap->outputs = 1; 233 - } 234 break; 235 236 case DECODER_GET_STATUS: 237 { ··· 241 242 status = bt819_read(client, 0x00); 243 res = 0; 244 - if ((status & 0x80)) { 245 res |= DECODER_STATUS_GOOD; 246 - } 247 switch (decoder->norm) { 248 case VIDEO_MODE_NTSC: 249 res |= DECODER_STATUS_NTSC; ··· 253 break; 254 default: 255 case VIDEO_MODE_AUTO: 256 - if ((status & 0x10)) { 257 res |= DECODER_STATUS_PAL; 258 - } else { 259 res |= DECODER_STATUS_NTSC; 260 - } 261 break; 262 } 263 res |= DECODER_STATUS_COLOR; 264 *iarg = res; 265 266 - dprintk(1, KERN_INFO "%s: get status %x\n", I2C_NAME(client), 267 - *iarg); 268 - } 269 break; 270 271 case DECODER_SET_NORM: 272 { 273 int *iarg = arg; 274 struct timing *timing = NULL; 275 276 - dprintk(1, KERN_INFO "%s: set norm %x\n", I2C_NAME(client), 277 - *iarg); 278 279 switch (*iarg) { 280 case VIDEO_MODE_NTSC: ··· 280 bt819_setbit(client, 0x01, 5, 0); 281 bt819_write(client, 0x18, 0x68); 282 bt819_write(client, 0x19, 0x5d); 283 - //bt819_setbit(client, 0x1a, 5, 1); 284 timing = &timing_data[VIDEO_MODE_NTSC]; 285 break; 286 case VIDEO_MODE_PAL: ··· 289 bt819_setbit(client, 0x01, 5, 1); 290 bt819_write(client, 0x18, 0x7f); 291 bt819_write(client, 0x19, 0x72); 292 - //bt819_setbit(client, 0x1a, 5, 0); 293 timing = &timing_data[VIDEO_MODE_PAL]; 294 break; 295 case VIDEO_MODE_AUTO: ··· 297 bt819_setbit(client, 0x01, 1, 0); 298 break; 299 default: 300 - dprintk(1, 301 - KERN_ERR 302 - "%s: unsupported norm %d\n", 303 - I2C_NAME(client), *iarg); 304 return -EINVAL; 305 } 306 ··· 316 } 317 318 decoder->norm = *iarg; 319 - } 320 break; 321 322 case DECODER_SET_INPUT: 323 { 324 int *iarg = arg; 325 326 - dprintk(1, KERN_INFO "%s: set input %x\n", I2C_NAME(client), 327 - *iarg); 328 329 - if (*iarg < 0 || *iarg > 7) { 330 return -EINVAL; 331 - } 332 333 if (decoder->input != *iarg) { 334 decoder->input = *iarg; ··· 339 bt819_setbit(client, 0x1a, 1, 0); 340 } 341 } 342 - } 343 break; 344 345 case DECODER_SET_OUTPUT: 346 { 347 int *iarg = arg; 348 349 - dprintk(1, KERN_INFO "%s: set output %x\n", I2C_NAME(client), 350 - *iarg); 351 352 /* not much choice of outputs */ 353 - if (*iarg != 0) { 354 return -EINVAL; 355 - } 356 - } 357 break; 358 359 case DECODER_ENABLE_OUTPUT: 360 { 361 int *iarg = arg; 362 int enable = (*iarg != 0); 363 364 - dprintk(1, KERN_INFO "%s: enable output %x\n", 365 - I2C_NAME(client), *iarg); 366 367 if (decoder->enable != enable) { 368 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 - } 375 } 376 - } 377 break; 378 379 case DECODER_SET_PICTURE: 380 { 381 struct video_picture *pic = arg; 382 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); 388 389 390 if (decoder->bright != pic->brightness) { ··· 412 bt819_write(client, 0x0f, 413 128 - (decoder->hue >> 8)); 414 } 415 - } 416 break; 417 418 default: 419 return -EINVAL; ··· 424 425 /* ----------------------------------------------------------------------- */ 426 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 - }; 435 436 - static unsigned short ignore = I2C_CLIENT_END; 437 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) 450 { 451 - int i, id; 452 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); 459 460 /* Check if the adapter supports the needed features */ 461 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 462 - return 0; 463 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; 470 471 decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL); 472 - if (decoder == NULL) { 473 - kfree(client); 474 return -ENOMEM; 475 - } 476 decoder->norm = VIDEO_MODE_NTSC; 477 decoder->input = 0; 478 decoder->enable = 1; ··· 472 decoder->initialized = 0; 473 i2c_set_clientdata(client, decoder); 474 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 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 - 515 return 0; 516 } 517 518 - static int 519 - bt819_attach_adapter (struct i2c_adapter *adapter) 520 { 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 - 538 return 0; 539 } 540 541 /* ----------------------------------------------------------------------- */ 542 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, 553 }; 554 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);
··· 29 */ 30 31 #include <linux/module.h> 32 #include <linux/delay.h> 33 #include <linux/types.h> 34 + #include <linux/ioctl.h> 35 #include <asm/uaccess.h> 36 + #include <linux/i2c.h> 37 + #include <linux/i2c-id.h> 38 #include <linux/videodev.h> 39 #include <linux/video_decoder.h> 40 + #include <media/v4l2-common.h> 41 + #include <media/v4l2-i2c-drv-legacy.h> 42 43 MODULE_DESCRIPTION("Brooktree-819 video decoder driver"); 44 MODULE_AUTHOR("Mike Bernson & Dave Perks"); 45 MODULE_LICENSE("GPL"); 46 47 static int debug; 48 module_param(debug, int, 0); 49 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 50 51 /* ----------------------------------------------------------------------- */ 52 ··· 97 {858 - 24, 20, 525 - 2, 1, 0x00f8, 0x0000}, 98 }; 99 100 /* ----------------------------------------------------------------------- */ 101 102 + static inline int bt819_write(struct i2c_client *client, u8 reg, u8 value) 103 { 104 struct bt819 *decoder = i2c_get_clientdata(client); 105 ··· 112 return i2c_smbus_write_byte_data(client, reg, value); 113 } 114 115 + static inline int bt819_setbit(struct i2c_client *client, u8 reg, u8 bit, u8 value) 116 { 117 struct bt819 *decoder = i2c_get_clientdata(client); 118 119 return bt819_write(client, reg, 120 + (decoder->reg[reg] & ~(1 << bit)) | (value ? (1 << bit) : 0)); 121 } 122 123 + static int bt819_write_block(struct i2c_client *client, const u8 *data, unsigned int len) 124 { 125 int ret = -1; 126 u8 reg; ··· 150 decoder->reg[reg++] = data[1]; 151 len -= 2; 152 data += 2; 153 + } while (len >= 2 && data[0] == reg && block_len < 32); 154 + ret = i2c_master_send(client, block_data, block_len); 155 + if (ret < 0) 156 break; 157 } 158 } else { ··· 169 return ret; 170 } 171 172 + static inline int bt819_read(struct i2c_client *client, u8 reg) 173 { 174 return i2c_smbus_read_byte_data(client, reg); 175 } 176 177 + static int bt819_init(struct i2c_client *client) 178 { 179 struct bt819 *decoder = i2c_get_clientdata(client); 180 181 static unsigned char init[] = { 182 + /*0x1f, 0x00,*/ /* Reset */ 183 0x01, 0x59, /* 0x01 input format */ 184 0x02, 0x00, /* 0x02 temporal decimation */ 185 0x03, 0x12, /* 0x03 Cropping msb */ ··· 218 struct timing *timing = &timing_data[decoder->norm]; 219 220 init[0x03 * 2 - 1] = 221 + (((timing->vdelay >> 8) & 0x03) << 6) | 222 + (((timing->vactive >> 8) & 0x03) << 4) | 223 + (((timing->hdelay >> 8) & 0x03) << 2) | 224 + ((timing->hactive >> 8) & 0x03); 225 init[0x04 * 2 - 1] = timing->vdelay & 0xff; 226 init[0x05 * 2 - 1] = timing->vactive & 0xff; 227 init[0x06 * 2 - 1] = timing->hdelay & 0xff; ··· 238 239 /* init */ 240 return bt819_write_block(client, init, sizeof(init)); 241 } 242 243 /* ----------------------------------------------------------------------- */ 244 245 + static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg) 246 { 247 int temp; 248 249 struct bt819 *decoder = i2c_get_clientdata(client); 250 251 + if (!decoder->initialized) { /* First call to bt819_init could be */ 252 + bt819_init(client); /* without #FRST = 0 */ 253 decoder->initialized = 1; 254 } 255 256 switch (cmd) { 257 case 0: 258 /* This is just for testing!!! */ 259 bt819_init(client); ··· 274 VIDEO_DECODER_CCIR; 275 cap->inputs = 8; 276 cap->outputs = 1; 277 break; 278 + } 279 280 case DECODER_GET_STATUS: 281 { ··· 285 286 status = bt819_read(client, 0x00); 287 res = 0; 288 + if ((status & 0x80)) 289 res |= DECODER_STATUS_GOOD; 290 + 291 switch (decoder->norm) { 292 case VIDEO_MODE_NTSC: 293 res |= DECODER_STATUS_NTSC; ··· 297 break; 298 default: 299 case VIDEO_MODE_AUTO: 300 + if ((status & 0x10)) 301 res |= DECODER_STATUS_PAL; 302 + else 303 res |= DECODER_STATUS_NTSC; 304 break; 305 } 306 res |= DECODER_STATUS_COLOR; 307 *iarg = res; 308 309 + v4l_dbg(1, debug, client, "get status %x\n", *iarg); 310 break; 311 + } 312 313 case DECODER_SET_NORM: 314 { 315 int *iarg = arg; 316 struct timing *timing = NULL; 317 318 + v4l_dbg(1, debug, client, "set norm %x\n", *iarg); 319 320 switch (*iarg) { 321 case VIDEO_MODE_NTSC: ··· 327 bt819_setbit(client, 0x01, 5, 0); 328 bt819_write(client, 0x18, 0x68); 329 bt819_write(client, 0x19, 0x5d); 330 + /* bt819_setbit(client, 0x1a, 5, 1); */ 331 timing = &timing_data[VIDEO_MODE_NTSC]; 332 break; 333 case VIDEO_MODE_PAL: ··· 336 bt819_setbit(client, 0x01, 5, 1); 337 bt819_write(client, 0x18, 0x7f); 338 bt819_write(client, 0x19, 0x72); 339 + /* bt819_setbit(client, 0x1a, 5, 0); */ 340 timing = &timing_data[VIDEO_MODE_PAL]; 341 break; 342 case VIDEO_MODE_AUTO: ··· 344 bt819_setbit(client, 0x01, 1, 0); 345 break; 346 default: 347 + v4l_dbg(1, debug, client, "unsupported norm %x\n", *iarg); 348 return -EINVAL; 349 } 350 ··· 366 } 367 368 decoder->norm = *iarg; 369 break; 370 + } 371 372 case DECODER_SET_INPUT: 373 { 374 int *iarg = arg; 375 376 + v4l_dbg(1, debug, client, "set input %x\n", *iarg); 377 378 + if (*iarg < 0 || *iarg > 7) 379 return -EINVAL; 380 381 if (decoder->input != *iarg) { 382 decoder->input = *iarg; ··· 391 bt819_setbit(client, 0x1a, 1, 0); 392 } 393 } 394 break; 395 + } 396 397 case DECODER_SET_OUTPUT: 398 { 399 int *iarg = arg; 400 401 + v4l_dbg(1, debug, client, "set output %x\n", *iarg); 402 403 /* not much choice of outputs */ 404 + if (*iarg != 0) 405 return -EINVAL; 406 break; 407 + } 408 409 case DECODER_ENABLE_OUTPUT: 410 { 411 int *iarg = arg; 412 int enable = (*iarg != 0); 413 414 + v4l_dbg(1, debug, client, "enable output %x\n", *iarg); 415 416 if (decoder->enable != enable) { 417 decoder->enable = enable; 418 + bt819_setbit(client, 0x16, 7, !enable); 419 } 420 break; 421 + } 422 423 case DECODER_SET_PICTURE: 424 { 425 struct video_picture *pic = arg; 426 427 + v4l_dbg(1, debug, client, 428 + "set picture brightness %d contrast %d colour %d\n", 429 + pic->brightness, pic->contrast, pic->colour); 430 431 432 if (decoder->bright != pic->brightness) { ··· 474 bt819_write(client, 0x0f, 475 128 - (decoder->hue >> 8)); 476 } 477 break; 478 + } 479 480 default: 481 return -EINVAL; ··· 486 487 /* ----------------------------------------------------------------------- */ 488 489 + static unsigned short normal_i2c[] = { 0x8a >> 1, I2C_CLIENT_END }; 490 491 + I2C_CLIENT_INSMOD; 492 493 + static int bt819_probe(struct i2c_client *client, 494 + const struct i2c_device_id *id) 495 { 496 + int i, ver; 497 struct bt819 *decoder; 498 + const char *name; 499 500 /* Check if the adapter supports the needed features */ 501 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 502 + return -ENODEV; 503 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); 523 524 decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL); 525 + if (decoder == NULL) 526 return -ENOMEM; 527 decoder->norm = VIDEO_MODE_NTSC; 528 decoder->input = 0; 529 decoder->enable = 1; ··· 545 decoder->initialized = 0; 546 i2c_set_clientdata(client, decoder); 547 548 i = bt819_init(client); 549 + if (i < 0) 550 + v4l_dbg(1, debug, client, "init status %d\n", i); 551 return 0; 552 } 553 554 + static int bt819_remove(struct i2c_client *client) 555 { 556 + kfree(i2c_get_clientdata(client)); 557 return 0; 558 } 559 560 /* ----------------------------------------------------------------------- */ 561 562 + static const struct i2c_device_id bt819_id[] = { 563 + { "bt819a", 0 }, 564 + { "bt817a", 0 }, 565 + { "bt815a", 0 }, 566 + { } 567 }; 568 + MODULE_DEVICE_TABLE(i2c, bt819_id); 569 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 */ 30 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 <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> 47 #include <asm/uaccess.h> 48 - 49 #include <linux/videodev.h> 50 51 MODULE_DESCRIPTION("Brooktree-856A video encoder driver"); 52 MODULE_AUTHOR("Mike Bernson & Dave Perks"); 53 MODULE_LICENSE("GPL"); 54 55 - 56 - #define I2C_NAME(s) (s)->name 57 - 58 - 59 static int debug; 60 module_param(debug, int, 0); 61 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 69 /* ----------------------------------------------------------------------- */ 70 ··· 59 int enable; 60 }; 61 62 - #define I2C_BT856 0x88 63 - 64 /* ----------------------------------------------------------------------- */ 65 66 - static inline int 67 - bt856_write (struct i2c_client *client, 68 - u8 reg, 69 - u8 value) 70 { 71 struct bt856 *encoder = i2c_get_clientdata(client); 72 ··· 69 return i2c_smbus_write_byte_data(client, reg, value); 70 } 71 72 - static inline int 73 - bt856_setbit (struct i2c_client *client, 74 - u8 reg, 75 - u8 bit, 76 - u8 value) 77 { 78 struct bt856 *encoder = i2c_get_clientdata(client); 79 80 return bt856_write(client, reg, 81 - (encoder-> 82 - reg[reg - BT856_REG_OFFSET] & ~(1 << bit)) | 83 - (value ? (1 << bit) : 0)); 84 } 85 86 - static void 87 - bt856_dump (struct i2c_client *client) 88 { 89 int i; 90 struct bt856 *encoder = i2c_get_clientdata(client); 91 92 - printk(KERN_INFO "%s: register dump:", I2C_NAME(client)); 93 for (i = 0; i < BT856_NR_REG; i += 2) 94 - printk(" %02x", encoder->reg[i]); 95 - printk("\n"); 96 } 97 98 /* ----------------------------------------------------------------------- */ 99 100 - static int 101 - bt856_command (struct i2c_client *client, 102 - unsigned int cmd, 103 - void *arg) 104 { 105 struct bt856 *encoder = i2c_get_clientdata(client); 106 107 switch (cmd) { 108 - 109 case 0: 110 /* This is just for testing!!! */ 111 - dprintk(1, KERN_INFO "bt856: init\n"); 112 bt856_write(client, 0xdc, 0x18); 113 bt856_write(client, 0xda, 0); 114 bt856_write(client, 0xde, 0); ··· 108 bt856_setbit(client, 0xdc, 4, 1); 109 110 switch (encoder->norm) { 111 - 112 case VIDEO_MODE_NTSC: 113 bt856_setbit(client, 0xdc, 2, 0); 114 break; ··· 128 { 129 struct video_encoder_capability *cap = arg; 130 131 - dprintk(1, KERN_INFO "%s: get capabilities\n", 132 - I2C_NAME(client)); 133 134 cap->flags = VIDEO_ENCODER_PAL | 135 VIDEO_ENCODER_NTSC | 136 VIDEO_ENCODER_CCIR; 137 cap->inputs = 2; 138 cap->outputs = 1; 139 - } 140 break; 141 142 case ENCODER_SET_NORM: 143 { 144 int *iarg = arg; 145 146 - dprintk(1, KERN_INFO "%s: set norm %d\n", I2C_NAME(client), 147 - *iarg); 148 149 switch (*iarg) { 150 - 151 case VIDEO_MODE_NTSC: 152 bt856_setbit(client, 0xdc, 2, 0); 153 break; ··· 157 158 default: 159 return -EINVAL; 160 - 161 } 162 encoder->norm = *iarg; 163 if (debug != 0) 164 bt856_dump(client); 165 - } 166 break; 167 168 case ENCODER_SET_INPUT: 169 { 170 int *iarg = arg; 171 172 - dprintk(1, KERN_INFO "%s: set input %d\n", I2C_NAME(client), 173 - *iarg); 174 175 /* We only have video bus. 176 * iarg = 0: input is from bt819 177 * iarg = 1: input is from ZR36060 */ 178 - 179 switch (*iarg) { 180 - 181 case 0: 182 bt856_setbit(client, 0xde, 4, 0); 183 bt856_setbit(client, 0xde, 3, 1); ··· 192 break; 193 default: 194 return -EINVAL; 195 - 196 } 197 198 if (debug != 0) 199 bt856_dump(client); 200 - } 201 break; 202 203 case ENCODER_SET_OUTPUT: 204 { 205 int *iarg = arg; 206 207 - dprintk(1, KERN_INFO "%s: set output %d\n", I2C_NAME(client), 208 - *iarg); 209 210 /* not much choice of outputs */ 211 - if (*iarg != 0) { 212 return -EINVAL; 213 - } 214 - } 215 break; 216 217 case ENCODER_ENABLE_OUTPUT: 218 { ··· 217 218 encoder->enable = !!*iarg; 219 220 - dprintk(1, KERN_INFO "%s: enable output %d\n", 221 - I2C_NAME(client), encoder->enable); 222 - } 223 break; 224 225 default: 226 return -EINVAL; ··· 230 231 /* ----------------------------------------------------------------------- */ 232 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 }; 238 239 - static unsigned short ignore = I2C_CLIENT_END; 240 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) 253 { 254 - int i; 255 - struct i2c_client *client; 256 struct bt856 *encoder; 257 258 - dprintk(1, 259 - KERN_INFO 260 - "bt856.c: detecting bt856 client on address 0x%x\n", 261 - address << 1); 262 - 263 /* Check if the adapter supports the needed features */ 264 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 265 - return 0; 266 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))); 274 275 encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL); 276 - if (encoder == NULL) { 277 - kfree(client); 278 return -ENOMEM; 279 - } 280 encoder->norm = VIDEO_MODE_NTSC; 281 encoder->enable = 1; 282 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 291 bt856_write(client, 0xdc, 0x18); 292 bt856_write(client, 0xda, 0); ··· 278 279 if (debug != 0) 280 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 return 0; 286 } 287 288 - static int 289 - bt856_attach_adapter (struct i2c_adapter *adapter) 290 { 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 - 312 return 0; 313 } 314 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, 327 }; 328 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);
··· 29 */ 30 31 #include <linux/module.h> 32 #include <linux/types.h> 33 + #include <linux/ioctl.h> 34 #include <asm/uaccess.h> 35 + #include <linux/i2c.h> 36 + #include <linux/i2c-id.h> 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> 41 42 MODULE_DESCRIPTION("Brooktree-856A video encoder driver"); 43 MODULE_AUTHOR("Mike Bernson & Dave Perks"); 44 MODULE_LICENSE("GPL"); 45 46 static int debug; 47 module_param(debug, int, 0); 48 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 49 50 /* ----------------------------------------------------------------------- */ 51 ··· 78 int enable; 79 }; 80 81 /* ----------------------------------------------------------------------- */ 82 83 + static inline int bt856_write(struct i2c_client *client, u8 reg, u8 value) 84 { 85 struct bt856 *encoder = i2c_get_clientdata(client); 86 ··· 93 return i2c_smbus_write_byte_data(client, reg, value); 94 } 95 96 + static inline int bt856_setbit(struct i2c_client *client, u8 reg, u8 bit, u8 value) 97 { 98 struct bt856 *encoder = i2c_get_clientdata(client); 99 100 return bt856_write(client, reg, 101 + (encoder->reg[reg - BT856_REG_OFFSET] & ~(1 << bit)) | 102 + (value ? (1 << bit) : 0)); 103 } 104 105 + static void bt856_dump(struct i2c_client *client) 106 { 107 int i; 108 struct bt856 *encoder = i2c_get_clientdata(client); 109 110 + v4l_info(client, "register dump:\n"); 111 for (i = 0; i < BT856_NR_REG; i += 2) 112 + printk(KERN_CONT " %02x", encoder->reg[i]); 113 + printk(KERN_CONT "\n"); 114 } 115 116 /* ----------------------------------------------------------------------- */ 117 118 + static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) 119 { 120 struct bt856 *encoder = i2c_get_clientdata(client); 121 122 switch (cmd) { 123 case 0: 124 /* This is just for testing!!! */ 125 + v4l_dbg(1, debug, client, "init\n"); 126 bt856_write(client, 0xdc, 0x18); 127 bt856_write(client, 0xda, 0); 128 bt856_write(client, 0xde, 0); ··· 142 bt856_setbit(client, 0xdc, 4, 1); 143 144 switch (encoder->norm) { 145 case VIDEO_MODE_NTSC: 146 bt856_setbit(client, 0xdc, 2, 0); 147 break; ··· 163 { 164 struct video_encoder_capability *cap = arg; 165 166 + v4l_dbg(1, debug, client, "get capabilities\n"); 167 168 cap->flags = VIDEO_ENCODER_PAL | 169 VIDEO_ENCODER_NTSC | 170 VIDEO_ENCODER_CCIR; 171 cap->inputs = 2; 172 cap->outputs = 1; 173 break; 174 + } 175 176 case ENCODER_SET_NORM: 177 { 178 int *iarg = arg; 179 180 + v4l_dbg(1, debug, client, "set norm %d\n", *iarg); 181 182 switch (*iarg) { 183 case VIDEO_MODE_NTSC: 184 bt856_setbit(client, 0xdc, 2, 0); 185 break; ··· 195 196 default: 197 return -EINVAL; 198 } 199 encoder->norm = *iarg; 200 if (debug != 0) 201 bt856_dump(client); 202 break; 203 + } 204 205 case ENCODER_SET_INPUT: 206 { 207 int *iarg = arg; 208 209 + v4l_dbg(1, debug, client, "set input %d\n", *iarg); 210 211 /* We only have video bus. 212 * iarg = 0: input is from bt819 213 * iarg = 1: input is from ZR36060 */ 214 switch (*iarg) { 215 case 0: 216 bt856_setbit(client, 0xde, 4, 0); 217 bt856_setbit(client, 0xde, 3, 1); ··· 234 break; 235 default: 236 return -EINVAL; 237 } 238 239 if (debug != 0) 240 bt856_dump(client); 241 break; 242 + } 243 244 case ENCODER_SET_OUTPUT: 245 { 246 int *iarg = arg; 247 248 + v4l_dbg(1, debug, client, "set output %d\n", *iarg); 249 250 /* not much choice of outputs */ 251 + if (*iarg != 0) 252 return -EINVAL; 253 break; 254 + } 255 256 case ENCODER_ENABLE_OUTPUT: 257 { ··· 262 263 encoder->enable = !!*iarg; 264 265 + v4l_dbg(1, debug, client, "enable output %d\n", encoder->enable); 266 break; 267 + } 268 269 default: 270 return -EINVAL; ··· 276 277 /* ----------------------------------------------------------------------- */ 278 279 + static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; 280 281 + I2C_CLIENT_INSMOD; 282 283 + static int bt856_probe(struct i2c_client *client, 284 + const struct i2c_device_id *id) 285 { 286 struct bt856 *encoder; 287 288 /* Check if the adapter supports the needed features */ 289 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 290 + return -ENODEV; 291 292 + v4l_info(client, "chip found @ 0x%x (%s)\n", 293 + client->addr << 1, client->adapter->name); 294 295 encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL); 296 + if (encoder == NULL) 297 return -ENOMEM; 298 encoder->norm = VIDEO_MODE_NTSC; 299 encoder->enable = 1; 300 i2c_set_clientdata(client, encoder); 301 302 bt856_write(client, 0xdc, 0x18); 303 bt856_write(client, 0xda, 0); ··· 359 360 if (debug != 0) 361 bt856_dump(client); 362 return 0; 363 } 364 365 + static int bt856_remove(struct i2c_client *client) 366 { 367 + kfree(i2c_get_clientdata(client)); 368 return 0; 369 } 370 371 + static const struct i2c_device_id bt856_id[] = { 372 + { "bt856", 0 }, 373 + { } 374 }; 375 + MODULE_DEVICE_TABLE(i2c, bt856_id); 376 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 */ 30 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 #include <linux/types.h> 46 - #include <linux/i2c.h> 47 - 48 - #include <linux/videodev.h> 49 #include <asm/uaccess.h> 50 - 51 #include <linux/video_encoder.h> 52 53 MODULE_LICENSE("GPL"); 54 55 - #define BT866_DEVNAME "bt866" 56 - #define I2C_BT866 0x88 57 - 58 - MODULE_LICENSE("GPL"); 59 - 60 - #define DEBUG(x) /* Debug driver */ 61 62 /* ----------------------------------------------------------------------- */ 63 64 struct bt866 { 65 - struct i2c_client *i2c; 66 - int addr; 67 - unsigned char reg[256]; 68 69 int norm; 70 int enable; ··· 60 int sat; 61 }; 62 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) 68 { 69 switch (cmd) { 70 case ENCODER_GET_CAPABILITIES: 71 { 72 struct video_encoder_capability *cap = arg; 73 74 - DEBUG(printk 75 - (KERN_INFO "%s: get capabilities\n", 76 - encoder->i2c->name)); 77 78 cap->flags 79 = VIDEO_ENCODER_PAL ··· 106 | VIDEO_ENCODER_CCIR; 107 cap->inputs = 2; 108 cap->outputs = 1; 109 } 110 - break; 111 112 case ENCODER_SET_NORM: 113 { 114 int *iarg = arg; 115 116 - DEBUG(printk(KERN_INFO "%s: set norm %d\n", 117 - encoder->i2c->name, *iarg)); 118 119 switch (*iarg) { 120 - 121 case VIDEO_MODE_NTSC: 122 break; 123 ··· 124 125 default: 126 return -EINVAL; 127 - 128 } 129 encoder->norm = *iarg; 130 } 131 - break; 132 133 case ENCODER_SET_INPUT: 134 { ··· 163 u8 val; 164 165 for (i = 0; i < ARRAY_SIZE(init) / 2; i += 2) 166 - bt866_write(encoder, init[i], init[i+1]); 167 168 val = encoder->reg[0xdc]; 169 ··· 172 else 173 val &= ~0x40; /* !CBSWAP */ 174 175 - bt866_write(encoder, 0xdc, val); 176 177 val = encoder->reg[0xcc]; 178 if (*iarg == 2) 179 val |= 0x01; /* OSDBAR */ 180 else 181 val &= ~0x01; /* !OSDBAR */ 182 - bt866_write(encoder, 0xcc, val); 183 184 - DEBUG(printk(KERN_INFO "%s: set input %d\n", 185 - encoder->i2c->name, *iarg)); 186 187 switch (*iarg) { 188 case 0: ··· 190 break; 191 default: 192 return -EINVAL; 193 - 194 } 195 } 196 - break; 197 198 case ENCODER_SET_OUTPUT: 199 { 200 int *iarg = arg; 201 202 - DEBUG(printk(KERN_INFO "%s: set output %d\n", 203 - encoder->i2c->name, *iarg)); 204 205 /* not much choice of outputs */ 206 if (*iarg != 0) 207 return -EINVAL; 208 } 209 - break; 210 211 case ENCODER_ENABLE_OUTPUT: 212 { 213 int *iarg = arg; 214 encoder->enable = !!*iarg; 215 216 - DEBUG(printk 217 - (KERN_INFO "%s: enable output %d\n", 218 - encoder->i2c->name, encoder->enable)); 219 } 220 - break; 221 222 case 4711: 223 { 224 int *iarg = arg; 225 __u8 val; 226 227 - printk("bt866: square = %d\n", *iarg); 228 229 val = encoder->reg[0xdc]; 230 if (*iarg) 231 val |= 1; /* SQUARE */ 232 else 233 val &= ~1; /* !SQUARE */ 234 - bt866_write(encoder, 0xdc, val); 235 break; 236 } 237 ··· 238 return 0; 239 } 240 241 - static int bt866_write(struct bt866 *encoder, 242 - unsigned char subaddr, unsigned char data) 243 - { 244 - unsigned char buffer[2]; 245 - int err; 246 247 - buffer[0] = subaddr; 248 - buffer[1] = data; 249 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) 310 { 311 struct bt866 *encoder; 312 - struct i2c_client *client; 313 314 - client = kzalloc(sizeof(*client), GFP_KERNEL); 315 - if (client == NULL) 316 - return -ENOMEM; 317 - memcpy(client, &bt866_client_tmpl, sizeof(*client)); 318 319 encoder = kzalloc(sizeof(*encoder), GFP_KERNEL); 320 - if (encoder == NULL) { 321 - kfree(client); 322 return -ENOMEM; 323 - } 324 325 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 return 0; 339 } 340 341 - static int bt866_attach(struct i2c_adapter *adapter) 342 { 343 - if (adapter->id == I2C_HW_B_ZR36067) 344 - return i2c_probe(adapter, &addr_data, bt866_found_proc); 345 return 0; 346 } 347 348 - static int bt866_detach(struct i2c_client *client) 349 { 350 - struct bt866 *encoder = i2c_get_clientdata(client); 351 - 352 - i2c_detach_client(client); 353 - kfree(encoder); 354 - kfree(client); 355 - 356 - return 0; 357 } 358 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 - } 365 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);
··· 29 */ 30 31 #include <linux/module.h> 32 #include <linux/types.h> 33 + #include <linux/ioctl.h> 34 #include <asm/uaccess.h> 35 + #include <linux/i2c.h> 36 + #include <linux/i2c-id.h> 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> 41 42 + MODULE_DESCRIPTION("Brooktree-866 video encoder driver"); 43 + MODULE_AUTHOR("Mike Bernson & Dave Perks"); 44 MODULE_LICENSE("GPL"); 45 46 + static int debug; 47 + module_param(debug, int, 0); 48 + MODULE_PARM_DESC(debug, "Debug level (0-1)"); 49 50 /* ----------------------------------------------------------------------- */ 51 52 struct bt866 { 53 + u8 reg[256]; 54 55 int norm; 56 int enable; ··· 74 int sat; 75 }; 76 77 + static int bt866_write(struct i2c_client *client, u8 subaddr, u8 data) 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 + 110 switch (cmd) { 111 case ENCODER_GET_CAPABILITIES: 112 { 113 struct video_encoder_capability *cap = arg; 114 115 + v4l_dbg(1, debug, client, "get capabilities\n"); 116 117 cap->flags 118 = VIDEO_ENCODER_PAL ··· 95 | VIDEO_ENCODER_CCIR; 96 cap->inputs = 2; 97 cap->outputs = 1; 98 + break; 99 } 100 101 case ENCODER_SET_NORM: 102 { 103 int *iarg = arg; 104 105 + v4l_dbg(1, debug, client, "set norm %d\n", *iarg); 106 107 switch (*iarg) { 108 case VIDEO_MODE_NTSC: 109 break; 110 ··· 115 116 default: 117 return -EINVAL; 118 } 119 encoder->norm = *iarg; 120 + break; 121 } 122 123 case ENCODER_SET_INPUT: 124 { ··· 155 u8 val; 156 157 for (i = 0; i < ARRAY_SIZE(init) / 2; i += 2) 158 + bt866_write(client, init[i], init[i+1]); 159 160 val = encoder->reg[0xdc]; 161 ··· 164 else 165 val &= ~0x40; /* !CBSWAP */ 166 167 + bt866_write(client, 0xdc, val); 168 169 val = encoder->reg[0xcc]; 170 if (*iarg == 2) 171 val |= 0x01; /* OSDBAR */ 172 else 173 val &= ~0x01; /* !OSDBAR */ 174 + bt866_write(client, 0xcc, val); 175 176 + v4l_dbg(1, debug, client, "set input %d\n", *iarg); 177 178 switch (*iarg) { 179 case 0: ··· 183 break; 184 default: 185 return -EINVAL; 186 } 187 + break; 188 } 189 190 case ENCODER_SET_OUTPUT: 191 { 192 int *iarg = arg; 193 194 + v4l_dbg(1, debug, client, "set output %d\n", *iarg); 195 196 /* not much choice of outputs */ 197 if (*iarg != 0) 198 return -EINVAL; 199 + break; 200 } 201 202 case ENCODER_ENABLE_OUTPUT: 203 { 204 int *iarg = arg; 205 encoder->enable = !!*iarg; 206 207 + v4l_dbg(1, debug, client, "enable output %d\n", encoder->enable); 208 + break; 209 } 210 211 case 4711: 212 { 213 int *iarg = arg; 214 __u8 val; 215 216 + v4l_dbg(1, debug, client, "square %d\n", *iarg); 217 218 val = encoder->reg[0xdc]; 219 if (*iarg) 220 val |= 1; /* SQUARE */ 221 else 222 val &= ~1; /* !SQUARE */ 223 + bt866_write(client, 0xdc, val); 224 break; 225 } 226 ··· 235 return 0; 236 } 237 238 + static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; 239 240 + I2C_CLIENT_INSMOD; 241 242 + static int bt866_probe(struct i2c_client *client, 243 + const struct i2c_device_id *id) 244 { 245 struct bt866 *encoder; 246 247 + v4l_info(client, "chip found @ 0x%x (%s)\n", 248 + client->addr << 1, client->adapter->name); 249 250 encoder = kzalloc(sizeof(*encoder), GFP_KERNEL); 251 + if (encoder == NULL) 252 return -ENOMEM; 253 254 i2c_set_clientdata(client, encoder); 255 return 0; 256 } 257 258 + static int bt866_remove(struct i2c_client *client) 259 { 260 + kfree(i2c_get_clientdata(client)); 261 return 0; 262 } 263 264 + static int bt866_legacy_probe(struct i2c_adapter *adapter) 265 { 266 + return adapter->id == I2C_HW_B_ZR36067; 267 } 268 269 + static const struct i2c_device_id bt866_id[] = { 270 + { "bt866", 0 }, 271 + { } 272 + }; 273 + MODULE_DEVICE_TABLE(i2c, bt866_id); 274 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 .input = {{ 40 .type = CX23885_VMUX_COMPOSITE1, 41 .vmux = 0, 42 - },{ 43 .type = CX23885_VMUX_COMPOSITE2, 44 .vmux = 1, 45 - },{ 46 .type = CX23885_VMUX_COMPOSITE3, 47 .vmux = 2, 48 - },{ 49 .type = CX23885_VMUX_COMPOSITE4, 50 .vmux = 3, 51 - }}, 52 }, 53 [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = { 54 .name = "Hauppauge WinTV-HVR1800lp", ··· 57 .type = CX23885_VMUX_TELEVISION, 58 .vmux = 0, 59 .gpio0 = 0xff00, 60 - },{ 61 .type = CX23885_VMUX_DEBUG, 62 .vmux = 0, 63 .gpio0 = 0xff01, 64 - },{ 65 .type = CX23885_VMUX_COMPOSITE1, 66 .vmux = 1, 67 .gpio0 = 0xff02, 68 - },{ 69 .type = CX23885_VMUX_SVIDEO, 70 .vmux = 2, 71 .gpio0 = 0xff02, 72 - }}, 73 }, 74 [CX23885_BOARD_HAUPPAUGE_HVR1800] = { 75 .name = "Hauppauge WinTV-HVR1800", ··· 84 CX25840_VIN5_CH2 | 85 CX25840_VIN2_CH1, 86 .gpio0 = 0, 87 - },{ 88 .type = CX23885_VMUX_COMPOSITE1, 89 .vmux = CX25840_VIN7_CH3 | 90 CX25840_VIN4_CH2 | 91 CX25840_VIN6_CH1, 92 .gpio0 = 0, 93 - },{ 94 .type = CX23885_VMUX_SVIDEO, 95 .vmux = CX25840_VIN7_CH3 | 96 CX25840_VIN4_CH2 | 97 CX25840_VIN8_CH1 | 98 CX25840_SVIDEO_ON, 99 .gpio0 = 0, 100 - }}, 101 }, 102 [CX23885_BOARD_HAUPPAUGE_HVR1250] = { 103 .name = "Hauppauge WinTV-HVR1250", ··· 106 .type = CX23885_VMUX_TELEVISION, 107 .vmux = 0, 108 .gpio0 = 0xff00, 109 - },{ 110 .type = CX23885_VMUX_DEBUG, 111 .vmux = 0, 112 .gpio0 = 0xff01, 113 - },{ 114 .type = CX23885_VMUX_COMPOSITE1, 115 .vmux = 1, 116 .gpio0 = 0xff02, 117 - },{ 118 .type = CX23885_VMUX_SVIDEO, 119 .vmux = 2, 120 .gpio0 = 0xff02, 121 - }}, 122 }, 123 [CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP] = { 124 .name = "DViCO FusionHDTV5 Express", ··· 169 .subvendor = 0x0070, 170 .subdevice = 0x3400, 171 .card = CX23885_BOARD_UNKNOWN, 172 - },{ 173 .subvendor = 0x0070, 174 .subdevice = 0x7600, 175 .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp, 176 - },{ 177 .subvendor = 0x0070, 178 .subdevice = 0x7800, 179 .card = CX23885_BOARD_HAUPPAUGE_HVR1800, 180 - },{ 181 .subvendor = 0x0070, 182 .subdevice = 0x7801, 183 .card = CX23885_BOARD_HAUPPAUGE_HVR1800, 184 - },{ 185 .subvendor = 0x0070, 186 .subdevice = 0x7809, 187 .card = CX23885_BOARD_HAUPPAUGE_HVR1800, 188 - },{ 189 .subvendor = 0x0070, 190 .subdevice = 0x7911, 191 .card = CX23885_BOARD_HAUPPAUGE_HVR1250, 192 - },{ 193 .subvendor = 0x18ac, 194 .subdevice = 0xd500, 195 .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP, 196 - },{ 197 .subvendor = 0x0070, 198 .subdevice = 0x7790, 199 .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q, 200 - },{ 201 .subvendor = 0x0070, 202 .subdevice = 0x7797, 203 .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q, 204 - },{ 205 .subvendor = 0x0070, 206 .subdevice = 0x7710, 207 .card = CX23885_BOARD_HAUPPAUGE_HVR1500, 208 - },{ 209 .subvendor = 0x0070, 210 .subdevice = 0x7717, 211 .card = CX23885_BOARD_HAUPPAUGE_HVR1500, ··· 225 .subvendor = 0x0070, 226 .subdevice = 0x8010, 227 .card = CX23885_BOARD_HAUPPAUGE_HVR1400, 228 - },{ 229 .subvendor = 0x18ac, 230 .subdevice = 0xd618, 231 .card = CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP, 232 - },{ 233 .subvendor = 0x18ac, 234 .subdevice = 0xdb78, 235 .card = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP, ··· 247 248 if (0 == dev->pci->subsystem_vendor && 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" 254 "%s: -- tux\n", 255 dev->name, dev->name, dev->name, dev->name, dev->name); 256 } 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" 259 "%s: card=<n> insmod option. Updating to the latest\n" 260 "%s: version might help as well.\n", 261 dev->name, dev->name, dev->name, dev->name); 262 } 263 - printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n", 264 dev->name); 265 for (i = 0; i < cx23885_bcount; i++) 266 - printk("%s: card=%d -> %s\n", 267 dev->name, i, cx23885_boards[i].name); 268 } 269 ··· 273 { 274 struct tveeprom tv; 275 276 - tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv, eeprom_data); 277 278 /* Make sure we support the board model */ 279 - switch (tv.model) 280 - { 281 case 71009: 282 /* WinTV-HVR1200 (PCIe, Retail, full height) 283 * DVB-T and basic analog */ ··· 305 case 71999: 306 /* WinTV-HVR1200 (PCIe, OEM, full height) 307 * 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 */ 323 case 80019: 324 /* WinTV-HVR1400 (Express Card, Retail, IR, 325 * DVB-T and Basic analog */ ··· 361 * DVB-T and MPEG2 HW Encoder */ 362 break; 363 default: 364 - printk("%s: warning: unknown hauppauge model #%d\n", dev->name, tv.model); 365 break; 366 } 367 ··· 385 return -EINVAL; 386 } 387 388 - switch(dev->board) { 389 case CX23885_BOARD_HAUPPAUGE_HVR1400: 390 case CX23885_BOARD_HAUPPAUGE_HVR1500: 391 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: ··· 416 417 void cx23885_gpio_setup(struct cx23885_dev *dev) 418 { 419 - switch(dev->board) { 420 case CX23885_BOARD_HAUPPAUGE_HVR1250: 421 /* GPIO-0 cx24227 demodulator reset */ 422 cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */ ··· 650 } 651 652 /* ------------------------------------------------------------------ */ 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 - */
··· 39 .input = {{ 40 .type = CX23885_VMUX_COMPOSITE1, 41 .vmux = 0, 42 + }, { 43 .type = CX23885_VMUX_COMPOSITE2, 44 .vmux = 1, 45 + }, { 46 .type = CX23885_VMUX_COMPOSITE3, 47 .vmux = 2, 48 + }, { 49 .type = CX23885_VMUX_COMPOSITE4, 50 .vmux = 3, 51 + } }, 52 }, 53 [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = { 54 .name = "Hauppauge WinTV-HVR1800lp", ··· 57 .type = CX23885_VMUX_TELEVISION, 58 .vmux = 0, 59 .gpio0 = 0xff00, 60 + }, { 61 .type = CX23885_VMUX_DEBUG, 62 .vmux = 0, 63 .gpio0 = 0xff01, 64 + }, { 65 .type = CX23885_VMUX_COMPOSITE1, 66 .vmux = 1, 67 .gpio0 = 0xff02, 68 + }, { 69 .type = CX23885_VMUX_SVIDEO, 70 .vmux = 2, 71 .gpio0 = 0xff02, 72 + } }, 73 }, 74 [CX23885_BOARD_HAUPPAUGE_HVR1800] = { 75 .name = "Hauppauge WinTV-HVR1800", ··· 84 CX25840_VIN5_CH2 | 85 CX25840_VIN2_CH1, 86 .gpio0 = 0, 87 + }, { 88 .type = CX23885_VMUX_COMPOSITE1, 89 .vmux = CX25840_VIN7_CH3 | 90 CX25840_VIN4_CH2 | 91 CX25840_VIN6_CH1, 92 .gpio0 = 0, 93 + }, { 94 .type = CX23885_VMUX_SVIDEO, 95 .vmux = CX25840_VIN7_CH3 | 96 CX25840_VIN4_CH2 | 97 CX25840_VIN8_CH1 | 98 CX25840_SVIDEO_ON, 99 .gpio0 = 0, 100 + } }, 101 }, 102 [CX23885_BOARD_HAUPPAUGE_HVR1250] = { 103 .name = "Hauppauge WinTV-HVR1250", ··· 106 .type = CX23885_VMUX_TELEVISION, 107 .vmux = 0, 108 .gpio0 = 0xff00, 109 + }, { 110 .type = CX23885_VMUX_DEBUG, 111 .vmux = 0, 112 .gpio0 = 0xff01, 113 + }, { 114 .type = CX23885_VMUX_COMPOSITE1, 115 .vmux = 1, 116 .gpio0 = 0xff02, 117 + }, { 118 .type = CX23885_VMUX_SVIDEO, 119 .vmux = 2, 120 .gpio0 = 0xff02, 121 + } }, 122 }, 123 [CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP] = { 124 .name = "DViCO FusionHDTV5 Express", ··· 169 .subvendor = 0x0070, 170 .subdevice = 0x3400, 171 .card = CX23885_BOARD_UNKNOWN, 172 + }, { 173 .subvendor = 0x0070, 174 .subdevice = 0x7600, 175 .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp, 176 + }, { 177 .subvendor = 0x0070, 178 .subdevice = 0x7800, 179 .card = CX23885_BOARD_HAUPPAUGE_HVR1800, 180 + }, { 181 .subvendor = 0x0070, 182 .subdevice = 0x7801, 183 .card = CX23885_BOARD_HAUPPAUGE_HVR1800, 184 + }, { 185 .subvendor = 0x0070, 186 .subdevice = 0x7809, 187 .card = CX23885_BOARD_HAUPPAUGE_HVR1800, 188 + }, { 189 .subvendor = 0x0070, 190 .subdevice = 0x7911, 191 .card = CX23885_BOARD_HAUPPAUGE_HVR1250, 192 + }, { 193 .subvendor = 0x18ac, 194 .subdevice = 0xd500, 195 .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP, 196 + }, { 197 .subvendor = 0x0070, 198 .subdevice = 0x7790, 199 .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q, 200 + }, { 201 .subvendor = 0x0070, 202 .subdevice = 0x7797, 203 .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q, 204 + }, { 205 .subvendor = 0x0070, 206 .subdevice = 0x7710, 207 .card = CX23885_BOARD_HAUPPAUGE_HVR1500, 208 + }, { 209 .subvendor = 0x0070, 210 .subdevice = 0x7717, 211 .card = CX23885_BOARD_HAUPPAUGE_HVR1500, ··· 225 .subvendor = 0x0070, 226 .subdevice = 0x8010, 227 .card = CX23885_BOARD_HAUPPAUGE_HVR1400, 228 + }, { 229 .subvendor = 0x18ac, 230 .subdevice = 0xd618, 231 .card = CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP, 232 + }, { 233 .subvendor = 0x18ac, 234 .subdevice = 0xdb78, 235 .card = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP, ··· 247 248 if (0 == dev->pci->subsystem_vendor && 249 0 == dev->pci->subsystem_device) { 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" 255 "%s: -- tux\n", 256 dev->name, dev->name, dev->name, dev->name, dev->name); 257 } else { 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" 261 "%s: card=<n> insmod option. Updating to the latest\n" 262 "%s: version might help as well.\n", 263 dev->name, dev->name, dev->name, dev->name); 264 } 265 + printk(KERN_INFO "%s: Here is a list of valid choices for the card=<n> insmod option:\n", 266 dev->name); 267 for (i = 0; i < cx23885_bcount; i++) 268 + printk(KERN_INFO "%s: card=%d -> %s\n", 269 dev->name, i, cx23885_boards[i].name); 270 } 271 ··· 271 { 272 struct tveeprom tv; 273 274 + tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv, 275 + eeprom_data); 276 277 /* Make sure we support the board model */ 278 + switch (tv.model) { 279 case 71009: 280 /* WinTV-HVR1200 (PCIe, Retail, full height) 281 * DVB-T and basic analog */ ··· 303 case 71999: 304 /* WinTV-HVR1200 (PCIe, OEM, full height) 305 * DVB-T 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 */ 351 case 80019: 352 /* WinTV-HVR1400 (Express Card, Retail, IR, 353 * DVB-T and Basic analog */ ··· 329 * DVB-T and MPEG2 HW Encoder */ 330 break; 331 default: 332 + printk(KERN_WARNING "%s: warning: unknown hauppauge model #%d\n", 333 + dev->name, tv.model); 334 break; 335 } 336 ··· 352 return -EINVAL; 353 } 354 355 + switch (dev->board) { 356 case CX23885_BOARD_HAUPPAUGE_HVR1400: 357 case CX23885_BOARD_HAUPPAUGE_HVR1500: 358 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: ··· 383 384 void cx23885_gpio_setup(struct cx23885_dev *dev) 385 { 386 + switch (dev->board) { 387 case CX23885_BOARD_HAUPPAUGE_HVR1250: 388 /* GPIO-0 cx24227 demodulator reset */ 389 cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */ ··· 617 } 618 619 /* ------------------------------------------------------------------ */
+156 -120
drivers/media/video/cx23885/cx23885-core.c
··· 37 MODULE_LICENSE("GPL"); 38 39 static unsigned int debug; 40 - module_param(debug,int,0644); 41 - MODULE_PARM_DESC(debug,"enable debug messages"); 42 43 static unsigned int card[] = {[0 ... (CX23885_MAXBOARDS - 1)] = UNSET }; 44 module_param_array(card, int, NULL, 0444); 45 - MODULE_PARM_DESC(card,"card type"); 46 47 #define dprintk(level, fmt, arg...)\ 48 do { if (debug >= level)\ ··· 364 list_del(&buf->vb.queue); 365 wake_up(&buf->vb.done); 366 } 367 - if (list_empty(&q->active)) { 368 del_timer(&q->timeout); 369 - } else { 370 mod_timer(&q->timeout, jiffies + BUFFER_TIMEOUT); 371 - } 372 if (bc != 1) 373 - printk("%s: %d buffers handled (should be 1)\n", 374 __func__, bc); 375 } 376 ··· 380 unsigned int i, lines; 381 u32 cdt; 382 383 - if (ch->cmds_start == 0) 384 - { 385 dprintk(1, "%s() Erasing channel [%s]\n", __func__, 386 ch->name); 387 cx_write(ch->ptr1_reg, 0); ··· 416 417 /* write CMDS */ 418 if (ch->jumponly) 419 - cx_write(ch->cmds_start + 0, 8); 420 else 421 - cx_write(ch->cmds_start + 0, risc); 422 cx_write(ch->cmds_start + 4, 0); /* 64 bits 63-32 */ 423 cx_write(ch->cmds_start + 8, cdt); 424 cx_write(ch->cmds_start + 12, (lines*16) >> 3); 425 cx_write(ch->cmds_start + 16, ch->ctrl_start); 426 if (ch->jumponly) 427 - cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2) ); 428 else 429 cx_write(ch->cmds_start + 20, 64 >> 2); 430 for (i = 24; i < 80; i += 4) ··· 434 cx_write(ch->ptr1_reg, ch->fifo_start); 435 cx_write(ch->ptr2_reg, cdt); 436 cx_write(ch->cnt2_reg, (lines*16) >> 3); 437 - cx_write(ch->cnt1_reg, (bpl >> 3) -1); 438 439 - dprintk(2,"[bridge %d] sram setup %s: bpl=%d lines=%d\n", 440 dev->bridge, 441 ch->name, 442 bpl, ··· 467 u32 risc; 468 unsigned int i, j, n; 469 470 - printk("%s: %s - dma channel status dump\n", 471 dev->name, ch->name); 472 for (i = 0; i < ARRAY_SIZE(name); i++) 473 - printk("%s: cmds: %-15s: 0x%08x\n", 474 dev->name, name[i], 475 cx_read(ch->cmds_start + 4*i)); 476 477 for (i = 0; i < 4; i++) { 478 risc = cx_read(ch->cmds_start + 4 * (i + 14)); 479 - printk("%s: risc%d: ", dev->name, i); 480 cx23885_risc_decode(risc); 481 } 482 for (i = 0; i < (64 >> 2); i += n) { 483 risc = cx_read(ch->ctrl_start + 4 * i); 484 /* No consideration for bits 63-32 */ 485 486 - printk("%s: (0x%08x) iq %x: ", dev->name, 487 ch->ctrl_start + 4 * i, i); 488 n = cx23885_risc_decode(risc); 489 for (j = 1; j < n; j++) { 490 risc = cx_read(ch->ctrl_start + 4 * (i + j)); 491 - printk("%s: iq %x: 0x%08x [ arg #%d ]\n", 492 dev->name, i+j, risc, j); 493 } 494 } 495 496 - printk("%s: fifo: 0x%08x -> 0x%x\n", 497 dev->name, ch->fifo_start, ch->fifo_start+ch->fifo_size); 498 - printk("%s: ctrl: 0x%08x -> 0x%x\n", 499 dev->name, ch->ctrl_start, ch->ctrl_start + 6*16); 500 - printk("%s: ptr1_reg: 0x%08x\n", 501 dev->name, cx_read(ch->ptr1_reg)); 502 - printk("%s: ptr2_reg: 0x%08x\n", 503 dev->name, cx_read(ch->ptr2_reg)); 504 - printk("%s: cnt1_reg: 0x%08x\n", 505 dev->name, cx_read(ch->cnt1_reg)); 506 - printk("%s: cnt2_reg: 0x%08x\n", 507 dev->name, cx_read(ch->cnt2_reg)); 508 } 509 ··· 513 struct cx23885_dev *dev = port->dev; 514 unsigned int i, j, n; 515 516 - printk("%s: risc disasm: %p [dma=0x%08lx]\n", 517 dev->name, risc->cpu, (unsigned long)risc->dma); 518 for (i = 0; i < (risc->size >> 2); i += n) { 519 - printk("%s: %04d: ", dev->name, i); 520 n = cx23885_risc_decode(le32_to_cpu(risc->cpu[i])); 521 for (j = 1; j < n; j++) 522 - printk("%s: %04d: 0x%08x [ arg #%d ]\n", 523 dev->name, i + j, risc->cpu[i + j], j); 524 if (risc->cpu[i] == cpu_to_le32(RISC_JUMP)) 525 break; ··· 598 * when DMA begins if RDR_TLCTL0 bit4 is not cleared. It does not 599 * occur on the cx23887 bridge. 600 */ 601 - if(dev->bridge == CX23885_BRIDGE_885) 602 cx_clear(RDR_TLCTL0, 1 << 4); 603 604 return 0; ··· 606 607 static int get_resources(struct cx23885_dev *dev) 608 { 609 - if (request_mem_region(pci_resource_start(dev->pci,0), 610 - pci_resource_len(dev->pci,0), 611 dev->name)) 612 return 0; 613 614 printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n", 615 - dev->name, (unsigned long long)pci_resource_start(dev->pci,0)); 616 617 return -EBUSY; 618 } ··· 621 int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, 622 u32 reg, u32 mask, u32 value); 623 624 - static int cx23885_init_tsport(struct cx23885_dev *dev, struct cx23885_tsport *port, int portno) 625 { 626 dprintk(1, "%s(portno=%d)\n", __func__, portno); 627 ··· 642 port->mpegq.timeout.data = (unsigned long)port; 643 init_timer(&port->mpegq.timeout); 644 645 - switch(portno) { 646 case 1: 647 port->reg_gpcnt = VID_B_GPCNT; 648 port->reg_gpcnt_ctl = VID_B_GPCNT_CTL; ··· 754 mutex_unlock(&devlist); 755 756 /* Configure the internal memory */ 757 - if(dev->pci->device == 0x8880) { 758 dev->bridge = CX23885_BRIDGE_887; 759 /* Apply a sensible clock frequency for the PCIe bridge */ 760 dev->clk_freq = 25000000; 761 dev->sram_channels = cx23887_sram_channels; 762 } else 763 - if(dev->pci->device == 0x8852) { 764 dev->bridge = CX23885_BRIDGE_885; 765 /* Apply a sensible clock frequency for the PCIe bridge */ 766 dev->clk_freq = 28000000; ··· 841 } 842 843 /* PCIe stuff */ 844 - dev->lmmio = ioremap(pci_resource_start(dev->pci,0), 845 - pci_resource_len(dev->pci,0)); 846 847 dev->bmmio = (u8 __iomem *)dev->lmmio; 848 ··· 872 cx23885_i2c_register(&dev->i2c_bus[1]); 873 cx23885_i2c_register(&dev->i2c_bus[2]); 874 cx23885_card_setup(dev); 875 - cx23885_call_i2c_clients (&dev->i2c_bus[0], TUNER_SET_STANDBY, NULL); 876 cx23885_ir_init(dev); 877 878 if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { ··· 918 919 static void cx23885_dev_unregister(struct cx23885_dev *dev) 920 { 921 - release_mem_region(pci_resource_start(dev->pci,0), 922 - pci_resource_len(dev->pci,0)); 923 924 if (!atomic_dec_and_test(&dev->refcount)) 925 return; ··· 946 iounmap(dev->lmmio); 947 } 948 949 - static __le32* cx23885_risc_field(__le32 *rp, struct scatterlist *sglist, 950 unsigned int offset, u32 sync_line, 951 unsigned int bpl, unsigned int padding, 952 unsigned int lines) ··· 967 } 968 if (bpl <= sg_dma_len(sg)-offset) { 969 /* 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; 974 } else { 975 /* scanline needs to be split */ 976 todo = bpl; 977 - *(rp++)=cpu_to_le32(RISC_WRITE|RISC_SOL| 978 (sg_dma_len(sg)-offset)); 979 - *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); 980 - *(rp++)=cpu_to_le32(0); /* bits 63-32 */ 981 todo -= (sg_dma_len(sg)-offset); 982 offset = 0; 983 sg++; 984 while (todo > sg_dma_len(sg)) { 985 - *(rp++)=cpu_to_le32(RISC_WRITE| 986 sg_dma_len(sg)); 987 - *(rp++)=cpu_to_le32(sg_dma_address(sg)); 988 - *(rp++)=cpu_to_le32(0); /* bits 63-32 */ 989 todo -= sg_dma_len(sg); 990 sg++; 991 } 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 */ 995 offset += todo; 996 } 997 offset += padding; ··· 1020 can cause next bpl to start close to a page border. First DMA 1021 region may be smaller than PAGE_SIZE */ 1022 /* write and jump need and extra dword */ 1023 - instructions = fields * (1 + ((bpl + padding) * lines) / PAGE_SIZE + lines); 1024 instructions += 2; 1025 - if ((rc = btcx_riscmem_alloc(pci,risc,instructions*12)) < 0) 1026 return rc; 1027 1028 /* write risc instructions */ ··· 1038 1039 /* save pointer to jmp instruction address */ 1040 risc->jmp = rp; 1041 - BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); 1042 return 0; 1043 } 1044 ··· 1060 instructions = 1 + (bpl * lines) / PAGE_SIZE + lines; 1061 instructions += 1; 1062 1063 - if ((rc = btcx_riscmem_alloc(pci,risc,instructions*12)) < 0) 1064 return rc; 1065 1066 /* write risc instructions */ ··· 1070 1071 /* save pointer to jmp instruction address */ 1072 risc->jmp = rp; 1073 - BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); 1074 return 0; 1075 } 1076 ··· 1080 __le32 *rp; 1081 int rc; 1082 1083 - if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0) 1084 return rc; 1085 1086 /* write risc instructions */ ··· 1175 1176 /* setup fifo + format */ 1177 cx23885_sram_channel_setup(dev, 1178 - &dev->sram_channels[ port->sram_chno ], 1179 port->ts_packet_size, buf->risc.dma); 1180 - if(debug > 5) { 1181 - cx23885_sram_channel_dump(dev, &dev->sram_channels[ port->sram_chno ] ); 1182 cx23885_risc_disasm(port, &buf->risc); 1183 } 1184 1185 /* write TS length to chip */ 1186 cx_write(port->reg_lngth, buf->vb.width); 1187 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", 1191 __func__, 1192 cx23885_boards[dev->board].portb, 1193 - cx23885_boards[dev->board].portc ); 1194 return -EINVAL; 1195 } 1196 ··· 1201 udelay(100); 1202 1203 /* If the port supports SRC SELECT, configure it */ 1204 - if(port->reg_src_sel) 1205 cx_write(port->reg_src_sel, port->src_sel_val); 1206 1207 cx_write(port->reg_hw_sop_ctrl, port->hw_sop_ctrl_val); ··· 1210 cx_write(port->reg_gen_ctrl, port->gen_ctrl_val); 1211 udelay(100); 1212 1213 - // NOTE: this is 2 (reserved) for portb, does it matter? 1214 /* reset counter to zero */ 1215 cx_write(port->reg_gpcnt_ctl, 3); 1216 q->count = 1; ··· 1244 cx_write(ALT_PIN_OUT_SEL, 0x10100045); 1245 } 1246 1247 - switch(dev->bridge) { 1248 case CX23885_BRIDGE_885: 1249 case CX23885_BRIDGE_887: 1250 /* enable irqs */ 1251 - dprintk(1, "%s() enabling TS int's and DMA\n", __func__ ); 1252 cx_set(port->reg_ts_int_msk, port->ts_int_msk_val); 1253 cx_set(port->reg_dma_ctl, port->dma_ctl_val); 1254 cx_set(PCI_INT_MSK, dev->pci_irqmask | port->pci_irqmask); ··· 1307 struct cx23885_buffer *buf; 1308 1309 dprintk(5, "%s()\n", __func__); 1310 - if (list_empty(&q->active)) 1311 - { 1312 struct cx23885_buffer *prev; 1313 prev = NULL; 1314 ··· 1325 buf->vb.state = VIDEOBUF_ACTIVE; 1326 buf->count = q->count++; 1327 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 1328 - dprintk(5, "[%p/%d] restart_queue - first active\n", 1329 buf, buf->vb.i); 1330 1331 } else if (prev->vb.width == buf->vb.width && ··· 1336 buf->vb.state = VIDEOBUF_ACTIVE; 1337 buf->count = q->count++; 1338 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", 1341 buf, buf->vb.i); 1342 } else { 1343 return 0; ··· 1377 buf->vb.size = size; 1378 buf->vb.field = field /*V4L2_FIELD_TOP*/; 1379 1380 - if (0 != (rc = videobuf_iolock(q, &buf->vb, NULL))) 1381 goto fail; 1382 cx23885_risc_databuffer(dev->pci, &buf->risc, 1383 videobuf_to_dma(&buf->vb)->sglist, ··· 1404 buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ 1405 1406 if (list_empty(&cx88q->active)) { 1407 - dprintk( 1, "queue is empty - first active\n" ); 1408 list_add_tail(&buf->vb.queue, &cx88q->active); 1409 cx23885_start_dma(port, cx88q, buf); 1410 buf->vb.state = VIDEOBUF_ACTIVE; ··· 1413 dprintk(1, "[%p/%d] %s - first active\n", 1414 buf, buf->vb.i, __func__); 1415 } else { 1416 - dprintk( 1, "queue is not empty - append to active\n" ); 1417 prev = list_entry(cx88q->active.prev, struct cx23885_buffer, 1418 vb.queue); 1419 list_add_tail(&buf->vb.queue, &cx88q->active); ··· 1421 buf->count = cx88q->count++; 1422 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 1423 prev->risc.jmp[2] = cpu_to_le32(0); /* 64 bit bits 63-32 */ 1424 - dprintk( 1, "[%p/%d] %s - append to active\n", 1425 buf, buf->vb.i, __func__); 1426 } 1427 } ··· 1447 buf, buf->vb.i, reason, (unsigned long)buf->risc.dma); 1448 } 1449 if (restart) { 1450 - dprintk(1, "restarting queue\n" ); 1451 cx23885_restart_queue(port, q); 1452 } 1453 spin_unlock_irqrestore(&port->slock, flags); ··· 1469 struct cx23885_tsport *port = (struct cx23885_tsport *)data; 1470 struct cx23885_dev *dev = port->dev; 1471 1472 - dprintk(1, "%s()\n",__func__); 1473 1474 if (debug > 5) 1475 - cx23885_sram_channel_dump(dev, &dev->sram_channels[ port->sram_chno ]); 1476 1477 cx23885_stop_dma(port); 1478 do_cancel_buffers(port, "timeout", 1); ··· 1549 if ((status & VID_BC_MSK_OPC_ERR) || 1550 (status & VID_BC_MSK_BAD_PKT) || 1551 (status & VID_BC_MSK_SYNC) || 1552 - (status & VID_BC_MSK_OF)) 1553 - { 1554 if (status & VID_BC_MSK_OPC_ERR) 1555 - dprintk(7, " (VID_BC_MSK_OPC_ERR 0x%08x)\n", VID_BC_MSK_OPC_ERR); 1556 if (status & VID_BC_MSK_BAD_PKT) 1557 - dprintk(7, " (VID_BC_MSK_BAD_PKT 0x%08x)\n", VID_BC_MSK_BAD_PKT); 1558 if (status & VID_BC_MSK_SYNC) 1559 - dprintk(7, " (VID_BC_MSK_SYNC 0x%08x)\n", VID_BC_MSK_SYNC); 1560 if (status & VID_BC_MSK_OF) 1561 - dprintk(7, " (VID_BC_MSK_OF 0x%08x)\n", VID_BC_MSK_OF); 1562 1563 printk(KERN_ERR "%s: mpeg risc op code error\n", dev->name); 1564 ··· 1619 ts2_status = cx_read(VID_C_INT_STAT); 1620 ts2_mask = cx_read(VID_C_INT_MSK); 1621 1622 - if ( (pci_status == 0) && (ts2_status == 0) && (ts1_status == 0) ) 1623 goto out; 1624 1625 vida_count = cx_read(VID_A_GPCNT); ··· 1634 dprintk(7, "ts2_status: 0x%08x ts2_mask: 0x%08x count: 0x%x\n", 1635 ts2_status, ts2_mask, ts2_count); 1636 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 - { 1648 1649 if (pci_status & PCI_MSK_RISC_RD) 1650 - dprintk(7, " (PCI_MSK_RISC_RD 0x%08x)\n", PCI_MSK_RISC_RD); 1651 if (pci_status & PCI_MSK_RISC_WR) 1652 - dprintk(7, " (PCI_MSK_RISC_WR 0x%08x)\n", PCI_MSK_RISC_WR); 1653 if (pci_status & PCI_MSK_AL_RD) 1654 - dprintk(7, " (PCI_MSK_AL_RD 0x%08x)\n", PCI_MSK_AL_RD); 1655 if (pci_status & PCI_MSK_AL_WR) 1656 - dprintk(7, " (PCI_MSK_AL_WR 0x%08x)\n", PCI_MSK_AL_WR); 1657 if (pci_status & PCI_MSK_APB_DMA) 1658 - dprintk(7, " (PCI_MSK_APB_DMA 0x%08x)\n", PCI_MSK_APB_DMA); 1659 if (pci_status & PCI_MSK_VID_C) 1660 - dprintk(7, " (PCI_MSK_VID_C 0x%08x)\n", PCI_MSK_VID_C); 1661 if (pci_status & PCI_MSK_VID_B) 1662 - dprintk(7, " (PCI_MSK_VID_B 0x%08x)\n", PCI_MSK_VID_B); 1663 if (pci_status & PCI_MSK_VID_A) 1664 - dprintk(7, " (PCI_MSK_VID_A 0x%08x)\n", PCI_MSK_VID_A); 1665 if (pci_status & PCI_MSK_AUD_INT) 1666 - dprintk(7, " (PCI_MSK_AUD_INT 0x%08x)\n", PCI_MSK_AUD_INT); 1667 if (pci_status & PCI_MSK_AUD_EXT) 1668 - dprintk(7, " (PCI_MSK_AUD_EXT 0x%08x)\n", PCI_MSK_AUD_EXT); 1669 1670 } 1671 ··· 1795 .device = 0x8852, 1796 .subvendor = PCI_ANY_ID, 1797 .subdevice = PCI_ANY_ID, 1798 - },{ 1799 /* CX23887 Rev 2 */ 1800 .vendor = 0x14f1, 1801 .device = 0x8880, 1802 .subvendor = PCI_ANY_ID, 1803 .subdevice = PCI_ANY_ID, 1804 - },{ 1805 /* --- end of list --- */ 1806 } 1807 }; ··· 1839 module_exit(cx23885_fini); 1840 1841 /* ----------------------------------------------------------- */ 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 - */
··· 37 MODULE_LICENSE("GPL"); 38 39 static unsigned int debug; 40 + module_param(debug, int, 0644); 41 + MODULE_PARM_DESC(debug, "enable debug messages"); 42 43 static unsigned int card[] = {[0 ... (CX23885_MAXBOARDS - 1)] = UNSET }; 44 module_param_array(card, int, NULL, 0444); 45 + MODULE_PARM_DESC(card, "card type"); 46 47 #define dprintk(level, fmt, arg...)\ 48 do { if (debug >= level)\ ··· 364 list_del(&buf->vb.queue); 365 wake_up(&buf->vb.done); 366 } 367 + if (list_empty(&q->active)) 368 del_timer(&q->timeout); 369 + else 370 mod_timer(&q->timeout, jiffies + BUFFER_TIMEOUT); 371 if (bc != 1) 372 + printk(KERN_WARNING "%s: %d buffers handled (should be 1)\n", 373 __func__, bc); 374 } 375 ··· 381 unsigned int i, lines; 382 u32 cdt; 383 384 + if (ch->cmds_start == 0) { 385 dprintk(1, "%s() Erasing channel [%s]\n", __func__, 386 ch->name); 387 cx_write(ch->ptr1_reg, 0); ··· 418 419 /* write CMDS */ 420 if (ch->jumponly) 421 + cx_write(ch->cmds_start + 0, 8); 422 else 423 + cx_write(ch->cmds_start + 0, risc); 424 cx_write(ch->cmds_start + 4, 0); /* 64 bits 63-32 */ 425 cx_write(ch->cmds_start + 8, cdt); 426 cx_write(ch->cmds_start + 12, (lines*16) >> 3); 427 cx_write(ch->cmds_start + 16, ch->ctrl_start); 428 if (ch->jumponly) 429 + cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2)); 430 else 431 cx_write(ch->cmds_start + 20, 64 >> 2); 432 for (i = 24; i < 80; i += 4) ··· 436 cx_write(ch->ptr1_reg, ch->fifo_start); 437 cx_write(ch->ptr2_reg, cdt); 438 cx_write(ch->cnt2_reg, (lines*16) >> 3); 439 + cx_write(ch->cnt1_reg, (bpl >> 3) - 1); 440 441 + dprintk(2, "[bridge %d] sram setup %s: bpl=%d lines=%d\n", 442 dev->bridge, 443 ch->name, 444 bpl, ··· 469 u32 risc; 470 unsigned int i, j, n; 471 472 + printk(KERN_WARNING "%s: %s - dma channel status dump\n", 473 dev->name, ch->name); 474 for (i = 0; i < ARRAY_SIZE(name); i++) 475 + printk(KERN_WARNING "%s: cmds: %-15s: 0x%08x\n", 476 dev->name, name[i], 477 cx_read(ch->cmds_start + 4*i)); 478 479 for (i = 0; i < 4; i++) { 480 risc = cx_read(ch->cmds_start + 4 * (i + 14)); 481 + printk(KERN_WARNING "%s: risc%d: ", dev->name, i); 482 cx23885_risc_decode(risc); 483 } 484 for (i = 0; i < (64 >> 2); i += n) { 485 risc = cx_read(ch->ctrl_start + 4 * i); 486 /* No consideration for bits 63-32 */ 487 488 + printk(KERN_WARNING "%s: (0x%08x) iq %x: ", dev->name, 489 ch->ctrl_start + 4 * i, i); 490 n = cx23885_risc_decode(risc); 491 for (j = 1; j < n; j++) { 492 risc = cx_read(ch->ctrl_start + 4 * (i + j)); 493 + printk(KERN_WARNING "%s: iq %x: 0x%08x [ arg #%d ]\n", 494 dev->name, i+j, risc, j); 495 } 496 } 497 498 + printk(KERN_WARNING "%s: fifo: 0x%08x -> 0x%x\n", 499 dev->name, ch->fifo_start, ch->fifo_start+ch->fifo_size); 500 + printk(KERN_WARNING "%s: ctrl: 0x%08x -> 0x%x\n", 501 dev->name, ch->ctrl_start, ch->ctrl_start + 6*16); 502 + printk(KERN_WARNING "%s: ptr1_reg: 0x%08x\n", 503 dev->name, cx_read(ch->ptr1_reg)); 504 + printk(KERN_WARNING "%s: ptr2_reg: 0x%08x\n", 505 dev->name, cx_read(ch->ptr2_reg)); 506 + printk(KERN_WARNING "%s: cnt1_reg: 0x%08x\n", 507 dev->name, cx_read(ch->cnt1_reg)); 508 + printk(KERN_WARNING "%s: cnt2_reg: 0x%08x\n", 509 dev->name, cx_read(ch->cnt2_reg)); 510 } 511 ··· 515 struct cx23885_dev *dev = port->dev; 516 unsigned int i, j, n; 517 518 + printk(KERN_INFO "%s: risc disasm: %p [dma=0x%08lx]\n", 519 dev->name, risc->cpu, (unsigned long)risc->dma); 520 for (i = 0; i < (risc->size >> 2); i += n) { 521 + printk(KERN_INFO "%s: %04d: ", dev->name, i); 522 n = cx23885_risc_decode(le32_to_cpu(risc->cpu[i])); 523 for (j = 1; j < n; j++) 524 + printk(KERN_INFO "%s: %04d: 0x%08x [ arg #%d ]\n", 525 dev->name, i + j, risc->cpu[i + j], j); 526 if (risc->cpu[i] == cpu_to_le32(RISC_JUMP)) 527 break; ··· 600 * when DMA begins if RDR_TLCTL0 bit4 is not cleared. It does not 601 * occur on the cx23887 bridge. 602 */ 603 + if (dev->bridge == CX23885_BRIDGE_885) 604 cx_clear(RDR_TLCTL0, 1 << 4); 605 606 return 0; ··· 608 609 static int get_resources(struct cx23885_dev *dev) 610 { 611 + if (request_mem_region(pci_resource_start(dev->pci, 0), 612 + pci_resource_len(dev->pci, 0), 613 dev->name)) 614 return 0; 615 616 printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n", 617 + dev->name, (unsigned long long)pci_resource_start(dev->pci, 0)); 618 619 return -EBUSY; 620 } ··· 623 int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, 624 u32 reg, u32 mask, u32 value); 625 626 + static int cx23885_init_tsport(struct cx23885_dev *dev, 627 + struct cx23885_tsport *port, int portno) 628 { 629 dprintk(1, "%s(portno=%d)\n", __func__, portno); 630 ··· 643 port->mpegq.timeout.data = (unsigned long)port; 644 init_timer(&port->mpegq.timeout); 645 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) { 658 case 1: 659 port->reg_gpcnt = VID_B_GPCNT; 660 port->reg_gpcnt_ctl = VID_B_GPCNT_CTL; ··· 744 mutex_unlock(&devlist); 745 746 /* Configure the internal memory */ 747 + if (dev->pci->device == 0x8880) { 748 dev->bridge = CX23885_BRIDGE_887; 749 /* Apply a sensible clock frequency for the PCIe bridge */ 750 dev->clk_freq = 25000000; 751 dev->sram_channels = cx23887_sram_channels; 752 } else 753 + if (dev->pci->device == 0x8852) { 754 dev->bridge = CX23885_BRIDGE_885; 755 /* Apply a sensible clock frequency for the PCIe bridge */ 756 dev->clk_freq = 28000000; ··· 831 } 832 833 /* PCIe stuff */ 834 + dev->lmmio = ioremap(pci_resource_start(dev->pci, 0), 835 + pci_resource_len(dev->pci, 0)); 836 837 dev->bmmio = (u8 __iomem *)dev->lmmio; 838 ··· 862 cx23885_i2c_register(&dev->i2c_bus[1]); 863 cx23885_i2c_register(&dev->i2c_bus[2]); 864 cx23885_card_setup(dev); 865 + cx23885_call_i2c_clients(&dev->i2c_bus[0], TUNER_SET_STANDBY, NULL); 866 cx23885_ir_init(dev); 867 868 if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { ··· 908 909 static void cx23885_dev_unregister(struct cx23885_dev *dev) 910 { 911 + release_mem_region(pci_resource_start(dev->pci, 0), 912 + pci_resource_len(dev->pci, 0)); 913 914 if (!atomic_dec_and_test(&dev->refcount)) 915 return; ··· 936 iounmap(dev->lmmio); 937 } 938 939 + static __le32 *cx23885_risc_field(__le32 *rp, struct scatterlist *sglist, 940 unsigned int offset, u32 sync_line, 941 unsigned int bpl, unsigned int padding, 942 unsigned int lines) ··· 957 } 958 if (bpl <= sg_dma_len(sg)-offset) { 959 /* fits into current chunk */ 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; 964 } else { 965 /* scanline needs to be split */ 966 todo = bpl; 967 + *(rp++) = cpu_to_le32(RISC_WRITE|RISC_SOL| 968 (sg_dma_len(sg)-offset)); 969 + *(rp++) = cpu_to_le32(sg_dma_address(sg)+offset); 970 + *(rp++) = cpu_to_le32(0); /* bits 63-32 */ 971 todo -= (sg_dma_len(sg)-offset); 972 offset = 0; 973 sg++; 974 while (todo > sg_dma_len(sg)) { 975 + *(rp++) = cpu_to_le32(RISC_WRITE| 976 sg_dma_len(sg)); 977 + *(rp++) = cpu_to_le32(sg_dma_address(sg)); 978 + *(rp++) = cpu_to_le32(0); /* bits 63-32 */ 979 todo -= sg_dma_len(sg); 980 sg++; 981 } 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 */ 985 offset += todo; 986 } 987 offset += padding; ··· 1010 can cause next bpl to start close to a page border. First DMA 1011 region may be smaller than PAGE_SIZE */ 1012 /* write and jump need and extra dword */ 1013 + instructions = fields * (1 + ((bpl + padding) * lines) 1014 + / PAGE_SIZE + lines); 1015 instructions += 2; 1016 + rc = btcx_riscmem_alloc(pci, risc, instructions*12); 1017 + if (rc < 0) 1018 return rc; 1019 1020 /* write risc instructions */ ··· 1026 1027 /* save pointer to jmp instruction address */ 1028 risc->jmp = rp; 1029 + BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); 1030 return 0; 1031 } 1032 ··· 1048 instructions = 1 + (bpl * lines) / PAGE_SIZE + lines; 1049 instructions += 1; 1050 1051 + rc = btcx_riscmem_alloc(pci, risc, instructions*12); 1052 + if (rc < 0) 1053 return rc; 1054 1055 /* write risc instructions */ ··· 1057 1058 /* save pointer to jmp instruction address */ 1059 risc->jmp = rp; 1060 + BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); 1061 return 0; 1062 } 1063 ··· 1067 __le32 *rp; 1068 int rc; 1069 1070 + rc = btcx_riscmem_alloc(pci, risc, 4*16); 1071 + if (rc < 0) 1072 return rc; 1073 1074 /* write risc instructions */ ··· 1161 1162 /* setup fifo + format */ 1163 cx23885_sram_channel_setup(dev, 1164 + &dev->sram_channels[port->sram_chno], 1165 port->ts_packet_size, buf->risc.dma); 1166 + if (debug > 5) { 1167 + cx23885_sram_channel_dump(dev, 1168 + &dev->sram_channels[port->sram_chno]); 1169 cx23885_risc_disasm(port, &buf->risc); 1170 } 1171 1172 /* write TS length to chip */ 1173 cx_write(port->reg_lngth, buf->vb.width); 1174 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", 1178 __func__, 1179 cx23885_boards[dev->board].portb, 1180 + cx23885_boards[dev->board].portc); 1181 return -EINVAL; 1182 } 1183 ··· 1186 udelay(100); 1187 1188 /* If the port supports SRC SELECT, configure it */ 1189 + if (port->reg_src_sel) 1190 cx_write(port->reg_src_sel, port->src_sel_val); 1191 1192 cx_write(port->reg_hw_sop_ctrl, port->hw_sop_ctrl_val); ··· 1195 cx_write(port->reg_gen_ctrl, port->gen_ctrl_val); 1196 udelay(100); 1197 1198 + /* NOTE: this is 2 (reserved) for portb, does it matter? */ 1199 /* reset counter to zero */ 1200 cx_write(port->reg_gpcnt_ctl, 3); 1201 q->count = 1; ··· 1229 cx_write(ALT_PIN_OUT_SEL, 0x10100045); 1230 } 1231 1232 + switch (dev->bridge) { 1233 case CX23885_BRIDGE_885: 1234 case CX23885_BRIDGE_887: 1235 /* enable irqs */ 1236 + dprintk(1, "%s() enabling TS int's and DMA\n", __func__); 1237 cx_set(port->reg_ts_int_msk, port->ts_int_msk_val); 1238 cx_set(port->reg_dma_ctl, port->dma_ctl_val); 1239 cx_set(PCI_INT_MSK, dev->pci_irqmask | port->pci_irqmask); ··· 1292 struct cx23885_buffer *buf; 1293 1294 dprintk(5, "%s()\n", __func__); 1295 + if (list_empty(&q->active)) { 1296 struct cx23885_buffer *prev; 1297 prev = NULL; 1298 ··· 1311 buf->vb.state = VIDEOBUF_ACTIVE; 1312 buf->count = q->count++; 1313 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 1314 + dprintk(5, "[%p/%d] restart_queue - f/active\n", 1315 buf, buf->vb.i); 1316 1317 } else if (prev->vb.width == buf->vb.width && ··· 1322 buf->vb.state = VIDEOBUF_ACTIVE; 1323 buf->count = q->count++; 1324 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 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", 1328 buf, buf->vb.i); 1329 } else { 1330 return 0; ··· 1362 buf->vb.size = size; 1363 buf->vb.field = field /*V4L2_FIELD_TOP*/; 1364 1365 + rc = videobuf_iolock(q, &buf->vb, NULL); 1366 + if (0 != rc) 1367 goto fail; 1368 cx23885_risc_databuffer(dev->pci, &buf->risc, 1369 videobuf_to_dma(&buf->vb)->sglist, ··· 1388 buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ 1389 1390 if (list_empty(&cx88q->active)) { 1391 + dprintk(1, "queue is empty - first active\n"); 1392 list_add_tail(&buf->vb.queue, &cx88q->active); 1393 cx23885_start_dma(port, cx88q, buf); 1394 buf->vb.state = VIDEOBUF_ACTIVE; ··· 1397 dprintk(1, "[%p/%d] %s - first active\n", 1398 buf, buf->vb.i, __func__); 1399 } else { 1400 + dprintk(1, "queue is not empty - append to active\n"); 1401 prev = list_entry(cx88q->active.prev, struct cx23885_buffer, 1402 vb.queue); 1403 list_add_tail(&buf->vb.queue, &cx88q->active); ··· 1405 buf->count = cx88q->count++; 1406 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 1407 prev->risc.jmp[2] = cpu_to_le32(0); /* 64 bit bits 63-32 */ 1408 + dprintk(1, "[%p/%d] %s - append to active\n", 1409 buf, buf->vb.i, __func__); 1410 } 1411 } ··· 1431 buf, buf->vb.i, reason, (unsigned long)buf->risc.dma); 1432 } 1433 if (restart) { 1434 + dprintk(1, "restarting queue\n"); 1435 cx23885_restart_queue(port, q); 1436 } 1437 spin_unlock_irqrestore(&port->slock, flags); ··· 1453 struct cx23885_tsport *port = (struct cx23885_tsport *)data; 1454 struct cx23885_dev *dev = port->dev; 1455 1456 + dprintk(1, "%s()\n", __func__); 1457 1458 if (debug > 5) 1459 + cx23885_sram_channel_dump(dev, 1460 + &dev->sram_channels[port->sram_chno]); 1461 1462 cx23885_stop_dma(port); 1463 do_cancel_buffers(port, "timeout", 1); ··· 1532 if ((status & VID_BC_MSK_OPC_ERR) || 1533 (status & VID_BC_MSK_BAD_PKT) || 1534 (status & VID_BC_MSK_SYNC) || 1535 + (status & VID_BC_MSK_OF)) { 1536 + 1537 if (status & VID_BC_MSK_OPC_ERR) 1538 + dprintk(7, " (VID_BC_MSK_OPC_ERR 0x%08x)\n", 1539 + VID_BC_MSK_OPC_ERR); 1540 + 1541 if (status & VID_BC_MSK_BAD_PKT) 1542 + dprintk(7, " (VID_BC_MSK_BAD_PKT 0x%08x)\n", 1543 + VID_BC_MSK_BAD_PKT); 1544 + 1545 if (status & VID_BC_MSK_SYNC) 1546 + dprintk(7, " (VID_BC_MSK_SYNC 0x%08x)\n", 1547 + VID_BC_MSK_SYNC); 1548 + 1549 if (status & VID_BC_MSK_OF) 1550 + dprintk(7, " (VID_BC_MSK_OF 0x%08x)\n", 1551 + VID_BC_MSK_OF); 1552 1553 printk(KERN_ERR "%s: mpeg risc op code error\n", dev->name); 1554 ··· 1595 ts2_status = cx_read(VID_C_INT_STAT); 1596 ts2_mask = cx_read(VID_C_INT_MSK); 1597 1598 + if ((pci_status == 0) && (ts2_status == 0) && (ts1_status == 0)) 1599 goto out; 1600 1601 vida_count = cx_read(VID_A_GPCNT); ··· 1610 dprintk(7, "ts2_status: 0x%08x ts2_mask: 0x%08x count: 0x%x\n", 1611 ts2_status, ts2_mask, ts2_count); 1612 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)) { 1623 1624 if (pci_status & PCI_MSK_RISC_RD) 1625 + dprintk(7, " (PCI_MSK_RISC_RD 0x%08x)\n", 1626 + PCI_MSK_RISC_RD); 1627 + 1628 if (pci_status & PCI_MSK_RISC_WR) 1629 + dprintk(7, " (PCI_MSK_RISC_WR 0x%08x)\n", 1630 + PCI_MSK_RISC_WR); 1631 + 1632 if (pci_status & PCI_MSK_AL_RD) 1633 + dprintk(7, " (PCI_MSK_AL_RD 0x%08x)\n", 1634 + PCI_MSK_AL_RD); 1635 + 1636 if (pci_status & PCI_MSK_AL_WR) 1637 + dprintk(7, " (PCI_MSK_AL_WR 0x%08x)\n", 1638 + PCI_MSK_AL_WR); 1639 + 1640 if (pci_status & PCI_MSK_APB_DMA) 1641 + dprintk(7, " (PCI_MSK_APB_DMA 0x%08x)\n", 1642 + PCI_MSK_APB_DMA); 1643 + 1644 if (pci_status & PCI_MSK_VID_C) 1645 + dprintk(7, " (PCI_MSK_VID_C 0x%08x)\n", 1646 + PCI_MSK_VID_C); 1647 + 1648 if (pci_status & PCI_MSK_VID_B) 1649 + dprintk(7, " (PCI_MSK_VID_B 0x%08x)\n", 1650 + PCI_MSK_VID_B); 1651 + 1652 if (pci_status & PCI_MSK_VID_A) 1653 + dprintk(7, " (PCI_MSK_VID_A 0x%08x)\n", 1654 + PCI_MSK_VID_A); 1655 + 1656 if (pci_status & PCI_MSK_AUD_INT) 1657 + dprintk(7, " (PCI_MSK_AUD_INT 0x%08x)\n", 1658 + PCI_MSK_AUD_INT); 1659 + 1660 if (pci_status & PCI_MSK_AUD_EXT) 1661 + dprintk(7, " (PCI_MSK_AUD_EXT 0x%08x)\n", 1662 + PCI_MSK_AUD_EXT); 1663 1664 } 1665 ··· 1753 .device = 0x8852, 1754 .subvendor = PCI_ANY_ID, 1755 .subdevice = PCI_ANY_ID, 1756 + }, { 1757 /* CX23887 Rev 2 */ 1758 .vendor = 0x14f1, 1759 .device = 0x8880, 1760 .subvendor = PCI_ANY_ID, 1761 .subdevice = PCI_ANY_ID, 1762 + }, { 1763 /* --- end of list --- */ 1764 } 1765 }; ··· 1797 module_exit(cx23885_fini); 1798 1799 /* ----------------------------------------------------------- */
+116 -74
drivers/media/video/cx23885/cx23885-dvb.c
··· 78 struct videobuf_buffer *vb, enum v4l2_field field) 79 { 80 struct cx23885_tsport *port = q->priv_data; 81 - return cx23885_buf_prepare(q, port, (struct cx23885_buffer*)vb, field); 82 } 83 84 static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) 85 { 86 struct cx23885_tsport *port = q->priv_data; 87 - cx23885_buf_queue(port, (struct cx23885_buffer*)vb); 88 } 89 90 static void dvb_buf_release(struct videobuf_queue *q, 91 struct videobuf_buffer *vb) 92 { 93 - cx23885_free_buffer(q, (struct cx23885_buffer*)vb); 94 } 95 96 static struct videobuf_queue_ops dvb_qops = { ··· 312 { 313 struct cx23885_dev *dev = port->dev; 314 struct cx23885_i2c *i2c_bus = NULL; 315 316 /* init struct videobuf_dvb */ 317 - port->dvb.name = dev->name; 318 319 /* init frontend */ 320 switch (dev->board) { 321 case CX23885_BOARD_HAUPPAUGE_HVR1250: 322 i2c_bus = &dev->i2c_bus[0]; 323 - port->dvb.frontend = dvb_attach(s5h1409_attach, 324 &hauppauge_generic_config, 325 &i2c_bus->i2c_adap); 326 - if (port->dvb.frontend != NULL) { 327 - dvb_attach(mt2131_attach, port->dvb.frontend, 328 &i2c_bus->i2c_adap, 329 &hauppauge_generic_tunerconfig, 0); 330 } ··· 339 i2c_bus = &dev->i2c_bus[0]; 340 switch (alt_tuner) { 341 case 1: 342 - port->dvb.frontend = 343 dvb_attach(s5h1409_attach, 344 &hauppauge_ezqam_config, 345 &i2c_bus->i2c_adap); 346 - if (port->dvb.frontend != NULL) { 347 - dvb_attach(tda829x_attach, port->dvb.frontend, 348 &dev->i2c_bus[1].i2c_adap, 0x42, 349 &tda829x_no_probe); 350 - dvb_attach(tda18271_attach, port->dvb.frontend, 351 0x60, &dev->i2c_bus[1].i2c_adap, 352 &hauppauge_tda18271_config); 353 } 354 break; 355 case 0: 356 default: 357 - port->dvb.frontend = 358 dvb_attach(s5h1409_attach, 359 &hauppauge_generic_config, 360 &i2c_bus->i2c_adap); 361 - if (port->dvb.frontend != NULL) 362 - dvb_attach(mt2131_attach, port->dvb.frontend, 363 &i2c_bus->i2c_adap, 364 &hauppauge_generic_tunerconfig, 0); 365 break; ··· 367 break; 368 case CX23885_BOARD_HAUPPAUGE_HVR1800lp: 369 i2c_bus = &dev->i2c_bus[0]; 370 - port->dvb.frontend = dvb_attach(s5h1409_attach, 371 &hauppauge_hvr1800lp_config, 372 &i2c_bus->i2c_adap); 373 - if (port->dvb.frontend != NULL) { 374 - dvb_attach(mt2131_attach, port->dvb.frontend, 375 &i2c_bus->i2c_adap, 376 &hauppauge_generic_tunerconfig, 0); 377 } 378 break; 379 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: 380 i2c_bus = &dev->i2c_bus[0]; 381 - port->dvb.frontend = dvb_attach(lgdt330x_attach, 382 &fusionhdtv_5_express, 383 &i2c_bus->i2c_adap); 384 - if (port->dvb.frontend != NULL) { 385 - dvb_attach(simple_tuner_attach, port->dvb.frontend, 386 &i2c_bus->i2c_adap, 0x61, 387 TUNER_LG_TDVS_H06XF); 388 } 389 break; 390 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: 391 i2c_bus = &dev->i2c_bus[1]; 392 - port->dvb.frontend = dvb_attach(s5h1409_attach, 393 &hauppauge_hvr1500q_config, 394 &dev->i2c_bus[0].i2c_adap); 395 - if (port->dvb.frontend != NULL) 396 - dvb_attach(xc5000_attach, port->dvb.frontend, 397 &i2c_bus->i2c_adap, 398 &hauppauge_hvr1500q_tunerconfig); 399 break; 400 case CX23885_BOARD_HAUPPAUGE_HVR1500: 401 i2c_bus = &dev->i2c_bus[1]; 402 - port->dvb.frontend = dvb_attach(s5h1409_attach, 403 &hauppauge_hvr1500_config, 404 &dev->i2c_bus[0].i2c_adap); 405 - if (port->dvb.frontend != NULL) { 406 struct dvb_frontend *fe; 407 struct xc2028_config cfg = { 408 .i2c_adap = &i2c_bus->i2c_adap, ··· 415 }; 416 417 fe = dvb_attach(xc2028_attach, 418 - port->dvb.frontend, &cfg); 419 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 420 fe->ops.tuner_ops.set_config(fe, &ctl); 421 } ··· 423 case CX23885_BOARD_HAUPPAUGE_HVR1200: 424 case CX23885_BOARD_HAUPPAUGE_HVR1700: 425 i2c_bus = &dev->i2c_bus[0]; 426 - port->dvb.frontend = dvb_attach(tda10048_attach, 427 &hauppauge_hvr1200_config, 428 &i2c_bus->i2c_adap); 429 - if (port->dvb.frontend != NULL) { 430 - dvb_attach(tda829x_attach, port->dvb.frontend, 431 &dev->i2c_bus[1].i2c_adap, 0x42, 432 &tda829x_no_probe); 433 - dvb_attach(tda18271_attach, port->dvb.frontend, 434 0x60, &dev->i2c_bus[1].i2c_adap, 435 &hauppauge_hvr1200_tuner_config); 436 } 437 break; 438 case CX23885_BOARD_HAUPPAUGE_HVR1400: 439 i2c_bus = &dev->i2c_bus[0]; 440 - port->dvb.frontend = dvb_attach(dib7000p_attach, 441 &i2c_bus->i2c_adap, 442 0x12, &hauppauge_hvr1400_dib7000_config); 443 - if (port->dvb.frontend != NULL) { 444 struct dvb_frontend *fe; 445 struct xc2028_config cfg = { 446 .i2c_adap = &dev->i2c_bus[1].i2c_adap, ··· 450 .fname = XC3028L_DEFAULT_FIRMWARE, 451 .max_len = 64, 452 .demod = 5000, 453 - /* This is true for all demods with v36 firmware? */ 454 .type = XC2028_D2633, 455 }; 456 457 fe = dvb_attach(xc2028_attach, 458 - port->dvb.frontend, &cfg); 459 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 460 fe->ops.tuner_ops.set_config(fe, &ctl); 461 } ··· 464 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP: 465 i2c_bus = &dev->i2c_bus[port->nr - 1]; 466 467 - port->dvb.frontend = dvb_attach(s5h1409_attach, 468 &dvico_s5h1409_config, 469 &i2c_bus->i2c_adap); 470 - if (port->dvb.frontend == NULL) 471 - port->dvb.frontend = dvb_attach(s5h1411_attach, 472 &dvico_s5h1411_config, 473 &i2c_bus->i2c_adap); 474 - if (port->dvb.frontend != NULL) 475 - dvb_attach(xc5000_attach, port->dvb.frontend, 476 &i2c_bus->i2c_adap, 477 &dvico_xc5000_tunerconfig); 478 break; 479 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: { 480 i2c_bus = &dev->i2c_bus[port->nr - 1]; 481 482 - port->dvb.frontend = dvb_attach(zl10353_attach, 483 &dvico_fusionhdtv_xc3028, 484 &i2c_bus->i2c_adap); 485 - if (port->dvb.frontend != NULL) { 486 struct dvb_frontend *fe; 487 struct xc2028_config cfg = { 488 .i2c_adap = &i2c_bus->i2c_adap, ··· 494 .demod = XC3028_FE_ZARLINK456, 495 }; 496 497 - fe = dvb_attach(xc2028_attach, port->dvb.frontend, 498 &cfg); 499 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 500 fe->ops.tuner_ops.set_config(fe, &ctl); ··· 504 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: 505 i2c_bus = &dev->i2c_bus[0]; 506 507 - port->dvb.frontend = dvb_attach(zl10353_attach, 508 &dvico_fusionhdtv_xc3028, 509 &i2c_bus->i2c_adap); 510 - if (port->dvb.frontend != NULL) { 511 struct dvb_frontend *fe; 512 struct xc2028_config cfg = { 513 .i2c_adap = &dev->i2c_bus[1].i2c_adap, ··· 519 .demod = XC3028_FE_ZARLINK456, 520 }; 521 522 - fe = dvb_attach(xc2028_attach, port->dvb.frontend, 523 &cfg); 524 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 525 fe->ops.tuner_ops.set_config(fe, &ctl); 526 } 527 break; 528 default: 529 - printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", 530 dev->name); 531 break; 532 } 533 - if (NULL == port->dvb.frontend) { 534 - printk("%s: frontend initialization failed\n", dev->name); 535 return -1; 536 } 537 /* define general-purpose callback pointer */ 538 - port->dvb.frontend->callback = cx23885_tuner_callback; 539 540 /* Put the analog decoder in standby to keep it quiet */ 541 cx23885_call_i2c_clients(i2c_bus, TUNER_SET_STANDBY, NULL); 542 543 - if (port->dvb.frontend->ops.analog_ops.standby) 544 - port->dvb.frontend->ops.analog_ops.standby(port->dvb.frontend); 545 546 /* register everything */ 547 - return videobuf_dvb_register(&port->dvb, THIS_MODULE, port, 548 - &dev->pci->dev, adapter_nr); 549 } 550 551 int cx23885_dvb_register(struct cx23885_tsport *port) 552 { 553 struct cx23885_dev *dev = port->dev; 554 - int err; 555 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); 562 563 - err = -ENODEV; 564 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, 568 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, 569 sizeof(struct cx23885_buffer), port); 570 err = dvb_register(port); 571 if (err != 0) 572 - printk("%s() dvb_register failed err = %d\n", __func__, err); 573 574 return err; 575 } 576 577 int cx23885_dvb_unregister(struct cx23885_tsport *port) 578 { 579 - /* dvb */ 580 - if(port->dvb.frontend) 581 - videobuf_dvb_unregister(&port->dvb); 582 583 return 0; 584 } 585 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 - */
··· 78 struct videobuf_buffer *vb, enum v4l2_field field) 79 { 80 struct cx23885_tsport *port = q->priv_data; 81 + return cx23885_buf_prepare(q, port, (struct cx23885_buffer *)vb, field); 82 } 83 84 static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) 85 { 86 struct cx23885_tsport *port = q->priv_data; 87 + cx23885_buf_queue(port, (struct cx23885_buffer *)vb); 88 } 89 90 static void dvb_buf_release(struct videobuf_queue *q, 91 struct videobuf_buffer *vb) 92 { 93 + cx23885_free_buffer(q, (struct cx23885_buffer *)vb); 94 } 95 96 static struct videobuf_queue_ops dvb_qops = { ··· 312 { 313 struct cx23885_dev *dev = port->dev; 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; 321 322 /* init struct videobuf_dvb */ 323 + fe0->dvb.name = dev->name; 324 325 /* init frontend */ 326 switch (dev->board) { 327 case CX23885_BOARD_HAUPPAUGE_HVR1250: 328 i2c_bus = &dev->i2c_bus[0]; 329 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 330 &hauppauge_generic_config, 331 &i2c_bus->i2c_adap); 332 + if (fe0->dvb.frontend != NULL) { 333 + dvb_attach(mt2131_attach, fe0->dvb.frontend, 334 &i2c_bus->i2c_adap, 335 &hauppauge_generic_tunerconfig, 0); 336 } ··· 333 i2c_bus = &dev->i2c_bus[0]; 334 switch (alt_tuner) { 335 case 1: 336 + fe0->dvb.frontend = 337 dvb_attach(s5h1409_attach, 338 &hauppauge_ezqam_config, 339 &i2c_bus->i2c_adap); 340 + if (fe0->dvb.frontend != NULL) { 341 + dvb_attach(tda829x_attach, fe0->dvb.frontend, 342 &dev->i2c_bus[1].i2c_adap, 0x42, 343 &tda829x_no_probe); 344 + dvb_attach(tda18271_attach, fe0->dvb.frontend, 345 0x60, &dev->i2c_bus[1].i2c_adap, 346 &hauppauge_tda18271_config); 347 } 348 break; 349 case 0: 350 default: 351 + fe0->dvb.frontend = 352 dvb_attach(s5h1409_attach, 353 &hauppauge_generic_config, 354 &i2c_bus->i2c_adap); 355 + if (fe0->dvb.frontend != NULL) 356 + dvb_attach(mt2131_attach, fe0->dvb.frontend, 357 &i2c_bus->i2c_adap, 358 &hauppauge_generic_tunerconfig, 0); 359 break; ··· 361 break; 362 case CX23885_BOARD_HAUPPAUGE_HVR1800lp: 363 i2c_bus = &dev->i2c_bus[0]; 364 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 365 &hauppauge_hvr1800lp_config, 366 &i2c_bus->i2c_adap); 367 + if (fe0->dvb.frontend != NULL) { 368 + dvb_attach(mt2131_attach, fe0->dvb.frontend, 369 &i2c_bus->i2c_adap, 370 &hauppauge_generic_tunerconfig, 0); 371 } 372 break; 373 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: 374 i2c_bus = &dev->i2c_bus[0]; 375 + fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 376 &fusionhdtv_5_express, 377 &i2c_bus->i2c_adap); 378 + if (fe0->dvb.frontend != NULL) { 379 + dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 380 &i2c_bus->i2c_adap, 0x61, 381 TUNER_LG_TDVS_H06XF); 382 } 383 break; 384 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: 385 i2c_bus = &dev->i2c_bus[1]; 386 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 387 &hauppauge_hvr1500q_config, 388 &dev->i2c_bus[0].i2c_adap); 389 + if (fe0->dvb.frontend != NULL) 390 + dvb_attach(xc5000_attach, fe0->dvb.frontend, 391 &i2c_bus->i2c_adap, 392 &hauppauge_hvr1500q_tunerconfig); 393 break; 394 case CX23885_BOARD_HAUPPAUGE_HVR1500: 395 i2c_bus = &dev->i2c_bus[1]; 396 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 397 &hauppauge_hvr1500_config, 398 &dev->i2c_bus[0].i2c_adap); 399 + if (fe0->dvb.frontend != NULL) { 400 struct dvb_frontend *fe; 401 struct xc2028_config cfg = { 402 .i2c_adap = &i2c_bus->i2c_adap, ··· 409 }; 410 411 fe = dvb_attach(xc2028_attach, 412 + fe0->dvb.frontend, &cfg); 413 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 414 fe->ops.tuner_ops.set_config(fe, &ctl); 415 } ··· 417 case CX23885_BOARD_HAUPPAUGE_HVR1200: 418 case CX23885_BOARD_HAUPPAUGE_HVR1700: 419 i2c_bus = &dev->i2c_bus[0]; 420 + fe0->dvb.frontend = dvb_attach(tda10048_attach, 421 &hauppauge_hvr1200_config, 422 &i2c_bus->i2c_adap); 423 + if (fe0->dvb.frontend != NULL) { 424 + dvb_attach(tda829x_attach, fe0->dvb.frontend, 425 &dev->i2c_bus[1].i2c_adap, 0x42, 426 &tda829x_no_probe); 427 + dvb_attach(tda18271_attach, fe0->dvb.frontend, 428 0x60, &dev->i2c_bus[1].i2c_adap, 429 &hauppauge_hvr1200_tuner_config); 430 } 431 break; 432 case CX23885_BOARD_HAUPPAUGE_HVR1400: 433 i2c_bus = &dev->i2c_bus[0]; 434 + fe0->dvb.frontend = dvb_attach(dib7000p_attach, 435 &i2c_bus->i2c_adap, 436 0x12, &hauppauge_hvr1400_dib7000_config); 437 + if (fe0->dvb.frontend != NULL) { 438 struct dvb_frontend *fe; 439 struct xc2028_config cfg = { 440 .i2c_adap = &dev->i2c_bus[1].i2c_adap, ··· 444 .fname = XC3028L_DEFAULT_FIRMWARE, 445 .max_len = 64, 446 .demod = 5000, 447 + /* This is true for all demods with 448 + v36 firmware? */ 449 .type = XC2028_D2633, 450 }; 451 452 fe = dvb_attach(xc2028_attach, 453 + fe0->dvb.frontend, &cfg); 454 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 455 fe->ops.tuner_ops.set_config(fe, &ctl); 456 } ··· 457 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP: 458 i2c_bus = &dev->i2c_bus[port->nr - 1]; 459 460 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 461 &dvico_s5h1409_config, 462 &i2c_bus->i2c_adap); 463 + if (fe0->dvb.frontend == NULL) 464 + fe0->dvb.frontend = dvb_attach(s5h1411_attach, 465 &dvico_s5h1411_config, 466 &i2c_bus->i2c_adap); 467 + if (fe0->dvb.frontend != NULL) 468 + dvb_attach(xc5000_attach, fe0->dvb.frontend, 469 &i2c_bus->i2c_adap, 470 &dvico_xc5000_tunerconfig); 471 break; 472 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: { 473 i2c_bus = &dev->i2c_bus[port->nr - 1]; 474 475 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 476 &dvico_fusionhdtv_xc3028, 477 &i2c_bus->i2c_adap); 478 + if (fe0->dvb.frontend != NULL) { 479 struct dvb_frontend *fe; 480 struct xc2028_config cfg = { 481 .i2c_adap = &i2c_bus->i2c_adap, ··· 487 .demod = XC3028_FE_ZARLINK456, 488 }; 489 490 + fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, 491 &cfg); 492 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 493 fe->ops.tuner_ops.set_config(fe, &ctl); ··· 497 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: 498 i2c_bus = &dev->i2c_bus[0]; 499 500 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 501 &dvico_fusionhdtv_xc3028, 502 &i2c_bus->i2c_adap); 503 + if (fe0->dvb.frontend != NULL) { 504 struct dvb_frontend *fe; 505 struct xc2028_config cfg = { 506 .i2c_adap = &dev->i2c_bus[1].i2c_adap, ··· 512 .demod = XC3028_FE_ZARLINK456, 513 }; 514 515 + fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, 516 &cfg); 517 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 518 fe->ops.tuner_ops.set_config(fe, &ctl); 519 } 520 break; 521 default: 522 + printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " 523 + " isn't supported yet\n", 524 dev->name); 525 break; 526 } 527 + if (NULL == fe0->dvb.frontend) { 528 + printk(KERN_ERR "%s: frontend initialization failed\n", 529 + dev->name); 530 return -1; 531 } 532 /* define general-purpose callback pointer */ 533 + fe0->dvb.frontend->callback = cx23885_tuner_callback; 534 535 /* Put the analog decoder in standby to keep it quiet */ 536 cx23885_call_i2c_clients(i2c_bus, TUNER_SET_STANDBY, NULL); 537 538 + if (fe0->dvb.frontend->ops.analog_ops.standby) 539 + fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend); 540 541 /* register everything */ 542 + return videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port, 543 + &dev->pci->dev, adapter_nr, 0); 544 + 545 } 546 547 int cx23885_dvb_register(struct cx23885_tsport *port) 548 { 549 + 550 + struct videobuf_dvb_frontend *fe0; 551 struct cx23885_dev *dev = port->dev; 552 + int err, i; 553 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); 565 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 + } 572 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, 591 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, 592 sizeof(struct cx23885_buffer), port); 593 + } 594 err = dvb_register(port); 595 if (err != 0) 596 + printk(KERN_ERR "%s() dvb_register failed err = %d\n", 597 + __func__, err); 598 599 return err; 600 } 601 602 int cx23885_dvb_unregister(struct cx23885_tsport *port) 603 { 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); 616 617 return 0; 618 } 619
+24 -23
drivers/media/video/cx23885/cx23885-i2c.c
··· 131 printk(" >\n"); 132 } 133 134 - for (cnt = 1; cnt < msg->len; cnt++ ) { 135 /* following bytes */ 136 wdata = msg->buf[cnt]; 137 ctrl = bus->i2c_period | (1 << 12) | (1 << 2); ··· 151 if (retval == 0) 152 goto eio; 153 if (i2c_debug) { 154 - printk(" %02x", msg->buf[cnt]); 155 if (!(ctrl & I2C_NOSTOP)) 156 - printk(" >\n"); 157 } 158 } 159 return msg->len; ··· 162 retval = -EIO; 163 err: 164 if (i2c_debug) 165 - printk(" ERR: %d\n", retval); 166 return retval; 167 } 168 ··· 194 195 if (i2c_debug) { 196 if (joined) 197 - printk(" R"); 198 else 199 - printk(" <R %02x", (msg->addr << 1) + 1); 200 } 201 202 - for(cnt = 0; cnt < msg->len; cnt++) { 203 204 ctrl = bus->i2c_period | (1 << 12) | (1 << 2) | 1; 205 ··· 216 goto eio; 217 msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff; 218 if (i2c_debug) { 219 - printk(" %02x", msg->buf[cnt]); 220 if (!(ctrl & I2C_NOSTOP)) 221 - printk(" >\n"); 222 } 223 } 224 return msg->len; ··· 227 retval = -EIO; 228 err: 229 if (i2c_debug) 230 - printk(" ERR: %d\n", retval); 231 return retval; 232 } 233 ··· 353 }; 354 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", 365 [0xc2 >> 1] = "tuner/mt2131/tda8275/xc5000/xc3028", 366 - [0xc8 >> 1] = "tuner/xc3028L", 367 }; 368 369 static void do_i2c_scan(char *name, struct i2c_client *c) ··· 376 rc = i2c_master_recv(c, &buf, 0); 377 if (rc < 0) 378 continue; 379 - printk("%s: i2c scan: found device @ 0x%x [%s]\n", 380 name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???"); 381 } 382 } ··· 408 bus->i2c_client.adapter = &bus->i2c_adap; 409 410 if (0 == bus->i2c_rc) { 411 - printk("%s: i2c bus %d registered\n", dev->name, bus->nr); 412 if (i2c_scan) 413 do_i2c_scan(dev->name, &bus->i2c_client); 414 } else 415 - printk("%s: i2c bus %d register FAILED\n", dev->name, bus->nr); 416 417 return bus->i2c_rc; 418 }
··· 131 printk(" >\n"); 132 } 133 134 + for (cnt = 1; cnt < msg->len; cnt++) { 135 /* following bytes */ 136 wdata = msg->buf[cnt]; 137 ctrl = bus->i2c_period | (1 << 12) | (1 << 2); ··· 151 if (retval == 0) 152 goto eio; 153 if (i2c_debug) { 154 + dprintk(1, " %02x", msg->buf[cnt]); 155 if (!(ctrl & I2C_NOSTOP)) 156 + dprintk(1, " >\n"); 157 } 158 } 159 return msg->len; ··· 162 retval = -EIO; 163 err: 164 if (i2c_debug) 165 + printk(KERN_ERR " ERR: %d\n", retval); 166 return retval; 167 } 168 ··· 194 195 if (i2c_debug) { 196 if (joined) 197 + dprintk(1, " R"); 198 else 199 + dprintk(1, " <R %02x", (msg->addr << 1) + 1); 200 } 201 202 + for (cnt = 0; cnt < msg->len; cnt++) { 203 204 ctrl = bus->i2c_period | (1 << 12) | (1 << 2) | 1; 205 ··· 216 goto eio; 217 msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff; 218 if (i2c_debug) { 219 + dprintk(1, " %02x", msg->buf[cnt]); 220 if (!(ctrl & I2C_NOSTOP)) 221 + dprintk(1, " >\n"); 222 } 223 } 224 return msg->len; ··· 227 retval = -EIO; 228 err: 229 if (i2c_debug) 230 + printk(KERN_ERR " ERR: %d\n", retval); 231 return retval; 232 } 233 ··· 353 }; 354 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", 365 [0xc2 >> 1] = "tuner/mt2131/tda8275/xc5000/xc3028", 366 + [0xc8 >> 1] = "tuner/xc3028L", 367 }; 368 369 static void do_i2c_scan(char *name, struct i2c_client *c) ··· 376 rc = i2c_master_recv(c, &buf, 0); 377 if (rc < 0) 378 continue; 379 + printk(KERN_INFO "%s: i2c scan: found device @ 0x%x [%s]\n", 380 name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???"); 381 } 382 } ··· 408 bus->i2c_client.adapter = &bus->i2c_adap; 409 410 if (0 == bus->i2c_rc) { 411 + dprintk(1, "%s: i2c bus %d registered\n", dev->name, bus->nr); 412 if (i2c_scan) 413 do_i2c_scan(dev->name, &bus->i2c_client); 414 } else 415 + printk(KERN_WARNING "%s: i2c bus %d register FAILED\n", 416 + dev->name, bus->nr); 417 418 return bus->i2c_rc; 419 }
+13 -12
drivers/media/video/cx23885/cx23885-video.c
··· 285 list_del(&buf->vb.queue); 286 wake_up(&buf->vb.done); 287 } 288 - if (list_empty(&q->active)) { 289 del_timer(&q->timeout); 290 - } else { 291 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 292 - } 293 if (bc != 1) 294 printk(KERN_ERR "%s: %d buffers handled (should be 1)\n", 295 __func__, bc); ··· 378 379 static int res_check(struct cx23885_fh *fh, unsigned int bit) 380 { 381 - return (fh->resources & bit); 382 } 383 384 static int res_locked(struct cx23885_dev *dev, unsigned int bit) 385 { 386 - return (dev->resources & bit); 387 } 388 389 static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh, ··· 886 /* ------------------------------------------------------------------ */ 887 /* VIDEO CTRL IOCTLS */ 888 889 - static int cx23885_get_control(struct cx23885_dev *dev, struct v4l2_control *ctl) 890 { 891 dprintk(1, "%s() calling cx25840(VIDIOC_G_CTRL)\n", __func__); 892 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_CTRL, ctl); 893 return 0; 894 } 895 896 - static int cx23885_set_control(struct cx23885_dev *dev, struct v4l2_control *ctl) 897 { 898 dprintk(1, "%s() calling cx25840(VIDIOC_S_CTRL)" 899 " (disabled - no action)\n", __func__); ··· 1074 struct v4l2_requestbuffers *p) 1075 { 1076 struct cx23885_fh *fh = priv; 1077 - return (videobuf_reqbufs(get_queue(fh), p)); 1078 } 1079 1080 static int vidioc_querybuf(struct file *file, void *priv, 1081 struct v4l2_buffer *p) 1082 { 1083 struct cx23885_fh *fh = priv; 1084 - return (videobuf_querybuf(get_queue(fh), p)); 1085 } 1086 1087 static int vidioc_qbuf(struct file *file, void *priv, 1088 struct v4l2_buffer *p) 1089 { 1090 struct cx23885_fh *fh = priv; 1091 - return (videobuf_qbuf(get_queue(fh), p)); 1092 } 1093 1094 static int vidioc_dqbuf(struct file *file, void *priv, 1095 struct v4l2_buffer *p) 1096 { 1097 struct cx23885_fh *fh = priv; 1098 - return (videobuf_dqbuf(get_queue(fh), p, 1099 - file->f_flags & O_NONBLOCK)); 1100 } 1101 1102 static int vidioc_streamon(struct file *file, void *priv,
··· 285 list_del(&buf->vb.queue); 286 wake_up(&buf->vb.done); 287 } 288 + if (list_empty(&q->active)) 289 del_timer(&q->timeout); 290 + else 291 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 292 if (bc != 1) 293 printk(KERN_ERR "%s: %d buffers handled (should be 1)\n", 294 __func__, bc); ··· 379 380 static int res_check(struct cx23885_fh *fh, unsigned int bit) 381 { 382 + return fh->resources & bit; 383 } 384 385 static int res_locked(struct cx23885_dev *dev, unsigned int bit) 386 { 387 + return dev->resources & bit; 388 } 389 390 static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh, ··· 887 /* ------------------------------------------------------------------ */ 888 /* VIDEO CTRL IOCTLS */ 889 890 + static int cx23885_get_control(struct cx23885_dev *dev, 891 + struct v4l2_control *ctl) 892 { 893 dprintk(1, "%s() calling cx25840(VIDIOC_G_CTRL)\n", __func__); 894 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_CTRL, ctl); 895 return 0; 896 } 897 898 + static int cx23885_set_control(struct cx23885_dev *dev, 899 + struct v4l2_control *ctl) 900 { 901 dprintk(1, "%s() calling cx25840(VIDIOC_S_CTRL)" 902 " (disabled - no action)\n", __func__); ··· 1073 struct v4l2_requestbuffers *p) 1074 { 1075 struct cx23885_fh *fh = priv; 1076 + return videobuf_reqbufs(get_queue(fh), p); 1077 } 1078 1079 static int vidioc_querybuf(struct file *file, void *priv, 1080 struct v4l2_buffer *p) 1081 { 1082 struct cx23885_fh *fh = priv; 1083 + return videobuf_querybuf(get_queue(fh), p); 1084 } 1085 1086 static int vidioc_qbuf(struct file *file, void *priv, 1087 struct v4l2_buffer *p) 1088 { 1089 struct cx23885_fh *fh = priv; 1090 + return videobuf_qbuf(get_queue(fh), p); 1091 } 1092 1093 static int vidioc_dqbuf(struct file *file, void *priv, 1094 struct v4l2_buffer *p) 1095 { 1096 struct cx23885_fh *fh = priv; 1097 + return videobuf_dqbuf(get_queue(fh), p, 1098 + file->f_flags & O_NONBLOCK); 1099 } 1100 1101 static int vidioc_streamon(struct file *file, void *priv,
+11 -15
drivers/media/video/cx23885/cx23885.h
··· 37 #include <linux/version.h> 38 #include <linux/mutex.h> 39 40 - #define CX23885_VERSION_CODE KERNEL_VERSION(0,0,1) 41 42 #define UNSET (-1U) 43 ··· 225 int nr; 226 int sram_chno; 227 228 - struct videobuf_dvb dvb; 229 230 /* dma queues */ 231 struct cx23885_dmaqueue mpegq; ··· 262 u32 src_sel_val; 263 u32 vld_misc_val; 264 u32 hw_sop_ctrl_val; 265 }; 266 267 struct cx23885_dev { ··· 370 /* ----------------------------------------------------------- */ 371 372 #define cx_read(reg) readl(dev->lmmio + ((reg)>>2)) 373 - #define cx_write(reg,value) writel((value), dev->lmmio + ((reg)>>2)) 374 375 - #define cx_andor(reg,mask,value) \ 376 writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\ 377 ((value) & (mask)), dev->lmmio+((reg)>>2)) 378 379 - #define cx_set(reg,bit) cx_andor((reg),(bit),(bit)) 380 - #define cx_clear(reg,bit) cx_andor((reg),(bit),0) 381 382 /* ----------------------------------------------------------- */ 383 /* cx23885-core.c */ ··· 414 extern struct cx23885_subid cx23885_subids[]; 415 extern const unsigned int cx23885_idcount; 416 417 - extern int cx23885_tuner_callback(void *priv, int component, int command, int arg); 418 extern void cx23885_card_list(struct cx23885_dev *dev); 419 extern int cx23885_ir_init(struct cx23885_dev *dev); 420 extern void cx23885_gpio_setup(struct cx23885_dev *dev); ··· 483 { 484 return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922; 485 } 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 - */
··· 37 #include <linux/version.h> 38 #include <linux/mutex.h> 39 40 + #define CX23885_VERSION_CODE KERNEL_VERSION(0, 0, 1) 41 42 #define UNSET (-1U) 43 ··· 225 int nr; 226 int sram_chno; 227 228 + struct videobuf_dvb_frontends frontends; 229 230 /* dma queues */ 231 struct cx23885_dmaqueue mpegq; ··· 262 u32 src_sel_val; 263 u32 vld_misc_val; 264 u32 hw_sop_ctrl_val; 265 + 266 + /* Allow a single tsport to have multiple frontends */ 267 + u32 num_frontends; 268 }; 269 270 struct cx23885_dev { ··· 367 /* ----------------------------------------------------------- */ 368 369 #define cx_read(reg) readl(dev->lmmio + ((reg)>>2)) 370 + #define cx_write(reg, value) writel((value), dev->lmmio + ((reg)>>2)) 371 372 + #define cx_andor(reg, mask, value) \ 373 writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\ 374 ((value) & (mask)), dev->lmmio+((reg)>>2)) 375 376 + #define cx_set(reg, bit) cx_andor((reg), (bit), (bit)) 377 + #define cx_clear(reg, bit) cx_andor((reg), (bit), 0) 378 379 /* ----------------------------------------------------------- */ 380 /* cx23885-core.c */ ··· 411 extern struct cx23885_subid cx23885_subids[]; 412 extern const unsigned int cx23885_idcount; 413 414 + extern int cx23885_tuner_callback(void *priv, int component, 415 + int command, int arg); 416 extern void cx23885_card_list(struct cx23885_dev *dev); 417 extern int cx23885_ir_init(struct cx23885_dev *dev); 418 extern void cx23885_gpio_setup(struct cx23885_dev *dev); ··· 479 { 480 return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922; 481 }
+51 -7
drivers/media/video/cx88/cx88-cards.c
··· 1270 .mpeg = CX88_MPEG_DVB, 1271 }, 1272 [CX88_BOARD_HAUPPAUGE_HVR3000] = { 1273 - /* FIXME: Add dvb & radio support */ 1274 .name = "Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T", 1275 .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3, 1276 .radio_type = UNSET, 1277 .tuner_addr = ADDR_UNSET, 1278 .radio_addr = ADDR_UNSET, 1279 .tda9887_conf = TDA9887_PRESENT, 1280 .input = {{ 1281 .type = CX88_VMUX_TELEVISION, 1282 .vmux = 0, 1283 .gpio0 = 0x84bf, 1284 },{ 1285 .type = CX88_VMUX_COMPOSITE1, 1286 .vmux = 1, 1287 .gpio0 = 0x84bf, 1288 },{ 1289 .type = CX88_VMUX_SVIDEO, 1290 .vmux = 2, 1291 .gpio0 = 0x84bf, 1292 }}, 1293 .mpeg = CX88_MPEG_DVB, 1294 }, 1295 [CX88_BOARD_NORWOOD_MICRO] = { 1296 .name = "Norwood Micro TV Tuner", ··· 1369 .type = CX88_VMUX_TELEVISION, 1370 .vmux = 0, 1371 .gpio0 = 0xef88, 1372 .audioroute = 1, 1373 },{ 1374 .type = CX88_VMUX_COMPOSITE1, 1375 .vmux = 1, 1376 .gpio0 = 0xef88, 1377 .audioroute = 2, 1378 },{ 1379 .type = CX88_VMUX_SVIDEO, 1380 .vmux = 2, 1381 .gpio0 = 0xef88, 1382 .audioroute = 2, 1383 }}, 1384 - /* fixme: Add radio support */ 1385 .mpeg = CX88_MPEG_DVB | CX88_MPEG_BLACKBIRD, 1386 .radio = { 1387 .type = CX88_RADIO, 1388 .gpio0 = 0xef88, 1389 }, 1390 }, 1391 [CX88_BOARD_ADSTECH_PTV_390] = { ··· 1733 .tuner_addr = ADDR_UNSET, 1734 .radio_addr = ADDR_UNSET, 1735 .tda9887_conf = TDA9887_PRESENT, 1736 /* 1737 * GPIO0 (WINTV2000) 1738 * ··· 1747 * BIT VALUE FUNCTION GP{x}_IO 1748 * 0 1 I:? 1749 * 1 1 I:? 1750 - * 2 1 O:DVB-T DEMOD ENABLE LOW/ANALOG DEMOD ENABLE HIGH 1751 * 3 1 I:? 1752 * 4 1 I:? 1753 * 5 1 I:? ··· 1763 * d 0 I 1764 * e 1 O 1765 * f 1 O 1766 */ 1767 .input = {{ 1768 .type = CX88_VMUX_TELEVISION, 1769 .vmux = 0, 1770 .gpio0 = 0xc4bf, 1771 }, { 1772 .type = CX88_VMUX_COMPOSITE1, 1773 .vmux = 1, 1774 .gpio0 = 0xc4bf, 1775 }, { 1776 .type = CX88_VMUX_SVIDEO, 1777 .vmux = 2, 1778 .gpio0 = 0xc4bf, 1779 } }, 1780 - /* fixme: Add radio support */ 1781 .mpeg = CX88_MPEG_DVB, 1782 }, 1783 [CX88_BOARD_HAUPPAUGE_HVR4000LITE] = { 1784 .name = "Hauppauge WinTV-HVR4000(Lite) DVB-S/S2", ··· 2699 2700 case CX88_BOARD_HAUPPAUGE_HVR3000: 2701 case CX88_BOARD_HAUPPAUGE_HVR4000: 2702 - case CX88_BOARD_HAUPPAUGE_HVR4000LITE: 2703 /* Init GPIO */ 2704 cx_write(MO_GP0_IO, core->board.input[0].gpio0); 2705 udelay(1000); 2706 break; 2707 } ··· 3044 3045 memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board)); 3046 3047 - info_printk(core, "subsystem: %04x:%04x, board: %s [card=%d,%s]\n", 3048 pci->subsystem_vendor, pci->subsystem_device, core->board.name, 3049 core->boardnr, card[core->nr] == core->boardnr ? 3050 - "insmod option" : "autodetected"); 3051 3052 if (tuner[core->nr] != UNSET) 3053 core->board.tuner_type = tuner[core->nr];
··· 1270 .mpeg = CX88_MPEG_DVB, 1271 }, 1272 [CX88_BOARD_HAUPPAUGE_HVR3000] = { 1273 .name = "Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T", 1274 .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3, 1275 .radio_type = UNSET, 1276 .tuner_addr = ADDR_UNSET, 1277 .radio_addr = ADDR_UNSET, 1278 .tda9887_conf = TDA9887_PRESENT, 1279 + .audio_chip = V4L2_IDENT_WM8775, 1280 .input = {{ 1281 .type = CX88_VMUX_TELEVISION, 1282 .vmux = 0, 1283 .gpio0 = 0x84bf, 1284 + /* 1: TV Audio / FM Mono */ 1285 + .audioroute = 1, 1286 },{ 1287 .type = CX88_VMUX_COMPOSITE1, 1288 .vmux = 1, 1289 .gpio0 = 0x84bf, 1290 + /* 2: Line-In */ 1291 + .audioroute = 2, 1292 },{ 1293 .type = CX88_VMUX_SVIDEO, 1294 .vmux = 2, 1295 .gpio0 = 0x84bf, 1296 + /* 2: Line-In */ 1297 + .audioroute = 2, 1298 }}, 1299 + .radio = { 1300 + .type = CX88_RADIO, 1301 + .gpio0 = 0x84bf, 1302 + /* 4: FM Stereo (untested) */ 1303 + .audioroute = 8, 1304 + }, 1305 .mpeg = CX88_MPEG_DVB, 1306 + .num_frontends = 2, 1307 }, 1308 [CX88_BOARD_NORWOOD_MICRO] = { 1309 .name = "Norwood Micro TV Tuner", ··· 1356 .type = CX88_VMUX_TELEVISION, 1357 .vmux = 0, 1358 .gpio0 = 0xef88, 1359 + /* 1: TV Audio / FM Mono */ 1360 .audioroute = 1, 1361 },{ 1362 .type = CX88_VMUX_COMPOSITE1, 1363 .vmux = 1, 1364 .gpio0 = 0xef88, 1365 + /* 2: Line-In */ 1366 .audioroute = 2, 1367 },{ 1368 .type = CX88_VMUX_SVIDEO, 1369 .vmux = 2, 1370 .gpio0 = 0xef88, 1371 + /* 2: Line-In */ 1372 .audioroute = 2, 1373 }}, 1374 .mpeg = CX88_MPEG_DVB | CX88_MPEG_BLACKBIRD, 1375 .radio = { 1376 .type = CX88_RADIO, 1377 .gpio0 = 0xef88, 1378 + /* 4: FM Stereo (untested) */ 1379 + .audioroute = 8, 1380 }, 1381 }, 1382 [CX88_BOARD_ADSTECH_PTV_390] = { ··· 1716 .tuner_addr = ADDR_UNSET, 1717 .radio_addr = ADDR_UNSET, 1718 .tda9887_conf = TDA9887_PRESENT, 1719 + .audio_chip = V4L2_IDENT_WM8775, 1720 /* 1721 * GPIO0 (WINTV2000) 1722 * ··· 1729 * BIT VALUE FUNCTION GP{x}_IO 1730 * 0 1 I:? 1731 * 1 1 I:? 1732 + * 2 1 O:MPEG PORT 0=DVB-T 1=DVB-S 1733 * 3 1 I:? 1734 * 4 1 I:? 1735 * 5 1 I:? ··· 1745 * d 0 I 1746 * e 1 O 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 1755 */ 1756 .input = {{ 1757 .type = CX88_VMUX_TELEVISION, 1758 .vmux = 0, 1759 .gpio0 = 0xc4bf, 1760 + /* 1: TV Audio / FM Mono */ 1761 + .audioroute = 1, 1762 }, { 1763 .type = CX88_VMUX_COMPOSITE1, 1764 .vmux = 1, 1765 .gpio0 = 0xc4bf, 1766 + /* 2: Line-In */ 1767 + .audioroute = 2, 1768 }, { 1769 .type = CX88_VMUX_SVIDEO, 1770 .vmux = 2, 1771 .gpio0 = 0xc4bf, 1772 + /* 2: Line-In */ 1773 + .audioroute = 2, 1774 } }, 1775 + .radio = { 1776 + .type = CX88_RADIO, 1777 + .gpio0 = 0xc4bf, 1778 + /* 4: FM Stereo */ 1779 + .audioroute = 8, 1780 + }, 1781 .mpeg = CX88_MPEG_DVB, 1782 + .num_frontends = 2, 1783 }, 1784 [CX88_BOARD_HAUPPAUGE_HVR4000LITE] = { 1785 .name = "Hauppauge WinTV-HVR4000(Lite) DVB-S/S2", ··· 2662 2663 case CX88_BOARD_HAUPPAUGE_HVR3000: 2664 case CX88_BOARD_HAUPPAUGE_HVR4000: 2665 /* Init GPIO */ 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 */ 2671 udelay(1000); 2672 break; 2673 } ··· 3004 3005 memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board)); 3006 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", 3011 pci->subsystem_vendor, pci->subsystem_device, core->board.name, 3012 core->boardnr, card[core->nr] == core->boardnr ? 3013 + "insmod option" : "autodetected", 3014 + core->board.num_frontends); 3015 3016 if (tuner[core->nr] != UNSET) 3017 core->board.tuner_type = tuner[core->nr];
+2 -1
drivers/media/video/cx88/cx88-core.c
··· 549 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 550 } 551 if (bc != 1) 552 - printk("%s: %d buffers handled (should be 1)\n",__func__,bc); 553 } 554 555 void cx88_shutdown(struct cx88_core *core)
··· 549 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 550 } 551 if (bc != 1) 552 + dprintk(2, "%s: %d buffers handled (should be 1)\n", 553 + __func__, bc); 554 } 555 556 void cx88_shutdown(struct cx88_core *core)
+274 -133
drivers/media/video/cx88/cx88-dvb.c
··· 116 struct cx8802_dev *dev= fe->dvb->priv; 117 struct cx8802_driver *drv = NULL; 118 int ret = 0; 119 120 drv = cx8802_get_driver(dev, CX88_MPEG_DVB); 121 if (drv) { 122 - if (acquire) 123 ret = drv->request_acquire(drv); 124 - else 125 ret = drv->request_release(drv); 126 } 127 128 return ret; ··· 406 cx_write(MO_GP0_IO, 0x00006060); 407 break; 408 case SEC_VOLTAGE_OFF: 409 - printk("LNB Voltage SEC_VOLTAGE_off\n"); 410 break; 411 } 412 ··· 493 static int attach_xc3028(u8 addr, struct cx8802_dev *dev) 494 { 495 struct dvb_frontend *fe; 496 struct xc2028_ctrl ctl; 497 struct xc2028_config cfg = { 498 .i2c_adap = &dev->core->i2c_adap, ··· 501 .ctrl = &ctl, 502 }; 503 504 - if (!dev->dvb.frontend) { 505 printk(KERN_ERR "%s/2: dvb frontend not attached. " 506 "Can't attach xc3028\n", 507 dev->core->name); ··· 520 */ 521 cx88_setup_xc3028(dev->core, &ctl); 522 523 - fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg); 524 if (!fe) { 525 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 526 dev->core->name); 527 return -EINVAL; 528 } 529 ··· 551 struct cx88_core *core = dev->core; 552 553 /* Reset the part */ 554 cx_write(MO_SRST_IO, 0); 555 msleep(10); 556 cx_write(MO_SRST_IO, 1); 557 msleep(10); 558 ··· 575 576 static struct stv0299_config tevii_tuner_sharp_config = { 577 .demod_address = 0x68, 578 - .inittab = sharp_z0194a__inittab, 579 .mclk = 88000000UL, 580 .invert = 1, 581 .skip_reinit = 0, 582 .lock_output = 1, 583 .volt13_op0_op1 = STV0299_VOLT13_OP1, 584 .min_delay_ms = 100, 585 - .set_symbol_rate = sharp_z0194a__set_symbol_rate, 586 .set_ts_params = cx24116_set_ts_param, 587 }; 588 ··· 595 static int dvb_register(struct cx8802_dev *dev) 596 { 597 struct cx88_core *core = dev->core; 598 599 - /* init struct videobuf_dvb */ 600 - dev->dvb.name = core->name; 601 - dev->ts_gen_cntrl = 0x0c; 602 603 - /* init frontend */ 604 switch (core->boardnr) { 605 case CX88_BOARD_HAUPPAUGE_DVB_T1: 606 - dev->dvb.frontend = dvb_attach(cx22702_attach, 607 &connexant_refboard_config, 608 &core->i2c_adap); 609 - if (dev->dvb.frontend != NULL) { 610 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 611 0x61, &core->i2c_adap, 612 DVB_PLL_THOMSON_DTT759X)) 613 goto frontend_detach; ··· 623 case CX88_BOARD_CONEXANT_DVB_T1: 624 case CX88_BOARD_KWORLD_DVB_T_CX22702: 625 case CX88_BOARD_WINFAST_DTV1000: 626 - dev->dvb.frontend = dvb_attach(cx22702_attach, 627 &connexant_refboard_config, 628 &core->i2c_adap); 629 - if (dev->dvb.frontend != NULL) { 630 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 631 0x60, &core->i2c_adap, 632 DVB_PLL_THOMSON_DTT7579)) 633 goto frontend_detach; ··· 637 case CX88_BOARD_HAUPPAUGE_HVR1100: 638 case CX88_BOARD_HAUPPAUGE_HVR1100LP: 639 case CX88_BOARD_HAUPPAUGE_HVR1300: 640 - case CX88_BOARD_HAUPPAUGE_HVR3000: 641 - dev->dvb.frontend = dvb_attach(cx22702_attach, 642 &hauppauge_hvr_config, 643 &core->i2c_adap); 644 - if (dev->dvb.frontend != NULL) { 645 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 646 &core->i2c_adap, 0x61, 647 TUNER_PHILIPS_FMD1216ME_MK3)) 648 goto frontend_detach; 649 } 650 break; 651 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 652 - dev->dvb.frontend = dvb_attach(mt352_attach, 653 &dvico_fusionhdtv, 654 &core->i2c_adap); 655 - if (dev->dvb.frontend != NULL) { 656 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 657 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 658 goto frontend_detach; 659 break; 660 } 661 /* ZL10353 replaces MT352 on later cards */ 662 - dev->dvb.frontend = dvb_attach(zl10353_attach, 663 &dvico_fusionhdtv_plus_v1_1, 664 &core->i2c_adap); 665 - if (dev->dvb.frontend != NULL) { 666 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 667 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 668 goto frontend_detach; 669 } ··· 705 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 706 /* The tin box says DEE1601, but it seems to be DTT7579 707 * compatible, with a slightly different MT352 AGC gain. */ 708 - dev->dvb.frontend = dvb_attach(mt352_attach, 709 &dvico_fusionhdtv_dual, 710 &core->i2c_adap); 711 - if (dev->dvb.frontend != NULL) { 712 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 713 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 714 goto frontend_detach; 715 break; 716 } 717 /* ZL10353 replaces MT352 on later cards */ 718 - dev->dvb.frontend = dvb_attach(zl10353_attach, 719 &dvico_fusionhdtv_plus_v1_1, 720 &core->i2c_adap); 721 - if (dev->dvb.frontend != NULL) { 722 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 723 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 724 goto frontend_detach; 725 } 726 break; 727 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 728 - dev->dvb.frontend = dvb_attach(mt352_attach, 729 &dvico_fusionhdtv, 730 &core->i2c_adap); 731 - if (dev->dvb.frontend != NULL) { 732 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 733 0x61, NULL, DVB_PLL_LG_Z201)) 734 goto frontend_detach; 735 } ··· 737 case CX88_BOARD_KWORLD_DVB_T: 738 case CX88_BOARD_DNTV_LIVE_DVB_T: 739 case CX88_BOARD_ADSTECH_DVB_T_PCI: 740 - dev->dvb.frontend = dvb_attach(mt352_attach, 741 &dntv_live_dvbt_config, 742 &core->i2c_adap); 743 - if (dev->dvb.frontend != NULL) { 744 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 745 0x61, NULL, DVB_PLL_UNKNOWN_1)) 746 goto frontend_detach; 747 } ··· 749 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 750 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE)) 751 /* 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, 753 &dev->vp3054->adap); 754 - if (dev->dvb.frontend != NULL) { 755 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 756 &core->i2c_adap, 0x61, 757 TUNER_PHILIPS_FMD1216ME_MK3)) 758 goto frontend_detach; ··· 763 #endif 764 break; 765 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 766 - dev->dvb.frontend = dvb_attach(zl10353_attach, 767 &dvico_fusionhdtv_hybrid, 768 &core->i2c_adap); 769 - if (dev->dvb.frontend != NULL) { 770 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 771 &core->i2c_adap, 0x61, 772 TUNER_THOMSON_FE6600)) 773 goto frontend_detach; 774 } 775 break; 776 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: 777 - dev->dvb.frontend = dvb_attach(zl10353_attach, 778 &dvico_fusionhdtv_xc3028, 779 &core->i2c_adap); 780 - if (dev->dvb.frontend == NULL) 781 - dev->dvb.frontend = dvb_attach(mt352_attach, 782 &dvico_fusionhdtv_mt352_xc3028, 783 &core->i2c_adap); 784 /* ··· 786 * We must not permit gate_ctrl to be performed, or 787 * the xc3028 cannot communicate on the bus. 788 */ 789 - if (dev->dvb.frontend) 790 - dev->dvb.frontend->ops.i2c_gate_ctrl = NULL; 791 if (attach_xc3028(0x61, dev) < 0) 792 return -EINVAL; 793 break; 794 case CX88_BOARD_PCHDTV_HD3000: 795 - dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, 796 &core->i2c_adap); 797 - if (dev->dvb.frontend != NULL) { 798 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 799 &core->i2c_adap, 0x61, 800 TUNER_THOMSON_DTT761X)) 801 goto frontend_detach; ··· 812 813 /* Select RF connector callback */ 814 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; 815 - dev->dvb.frontend = dvb_attach(lgdt330x_attach, 816 &fusionhdtv_3_gold, 817 &core->i2c_adap); 818 - if (dev->dvb.frontend != NULL) { 819 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 820 &core->i2c_adap, 0x61, 821 TUNER_MICROTUNE_4042FI5)) 822 goto frontend_detach; ··· 830 mdelay(100); 831 cx_set(MO_GP0_IO, 9); 832 mdelay(200); 833 - dev->dvb.frontend = dvb_attach(lgdt330x_attach, 834 &fusionhdtv_3_gold, 835 &core->i2c_adap); 836 - if (dev->dvb.frontend != NULL) { 837 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 838 &core->i2c_adap, 0x61, 839 TUNER_THOMSON_DTT761X)) 840 goto frontend_detach; ··· 848 mdelay(100); 849 cx_set(MO_GP0_IO, 1); 850 mdelay(200); 851 - dev->dvb.frontend = dvb_attach(lgdt330x_attach, 852 &fusionhdtv_5_gold, 853 &core->i2c_adap); 854 - if (dev->dvb.frontend != NULL) { 855 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 856 &core->i2c_adap, 0x61, 857 TUNER_LG_TDVS_H06XF)) 858 goto frontend_detach; 859 - if (!dvb_attach(tda9887_attach, dev->dvb.frontend, 860 &core->i2c_adap, 0x43)) 861 goto frontend_detach; 862 } ··· 869 mdelay(100); 870 cx_set(MO_GP0_IO, 1); 871 mdelay(200); 872 - dev->dvb.frontend = dvb_attach(lgdt330x_attach, 873 &pchdtv_hd5500, 874 &core->i2c_adap); 875 - if (dev->dvb.frontend != NULL) { 876 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 877 &core->i2c_adap, 0x61, 878 TUNER_LG_TDVS_H06XF)) 879 goto frontend_detach; 880 - if (!dvb_attach(tda9887_attach, dev->dvb.frontend, 881 &core->i2c_adap, 0x43)) 882 goto frontend_detach; 883 } 884 break; 885 case CX88_BOARD_ATI_HDTVWONDER: 886 - dev->dvb.frontend = dvb_attach(nxt200x_attach, 887 &ati_hdtvwonder, 888 &core->i2c_adap); 889 - if (dev->dvb.frontend != NULL) { 890 - if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 891 &core->i2c_adap, 0x61, 892 TUNER_PHILIPS_TUV1236D)) 893 goto frontend_detach; ··· 895 break; 896 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 897 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 898 - dev->dvb.frontend = dvb_attach(cx24123_attach, 899 &hauppauge_novas_config, 900 &core->i2c_adap); 901 - if (dev->dvb.frontend) { 902 - if (!dvb_attach(isl6421_attach, dev->dvb.frontend, 903 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) 904 goto frontend_detach; 905 } 906 break; 907 case CX88_BOARD_KWORLD_DVBS_100: 908 - dev->dvb.frontend = dvb_attach(cx24123_attach, 909 &kworld_dvbs_100_config, 910 &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; 914 } 915 break; 916 case CX88_BOARD_GENIATECH_DVBS: 917 - dev->dvb.frontend = dvb_attach(cx24123_attach, 918 &geniatech_dvbs_config, 919 &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; 923 } 924 break; 925 case CX88_BOARD_PINNACLE_PCTV_HD_800i: 926 - dev->dvb.frontend = dvb_attach(s5h1409_attach, 927 &pinnacle_pctv_hd_800i_config, 928 &core->i2c_adap); 929 - if (dev->dvb.frontend != NULL) { 930 - if (!dvb_attach(xc5000_attach, dev->dvb.frontend, 931 &core->i2c_adap, 932 &pinnacle_pctv_hd_800i_tuner_config)) 933 goto frontend_detach; 934 } 935 break; 936 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: 937 - dev->dvb.frontend = dvb_attach(s5h1409_attach, 938 &dvico_hdtv5_pci_nano_config, 939 &core->i2c_adap); 940 - if (dev->dvb.frontend != NULL) { 941 struct dvb_frontend *fe; 942 struct xc2028_config cfg = { 943 .i2c_adap = &core->i2c_adap, ··· 950 }; 951 952 fe = dvb_attach(xc2028_attach, 953 - dev->dvb.frontend, &cfg); 954 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 955 fe->ops.tuner_ops.set_config(fe, &ctl); 956 } 957 break; 958 case CX88_BOARD_PINNACLE_HYBRID_PCTV: 959 - dev->dvb.frontend = dvb_attach(zl10353_attach, 960 &cx88_pinnacle_hybrid_pctv, 961 &core->i2c_adap); 962 - if (dev->dvb.frontend) { 963 - dev->dvb.frontend->ops.i2c_gate_ctrl = NULL; 964 if (attach_xc3028(0x61, dev) < 0) 965 goto frontend_detach; 966 } ··· 968 case CX88_BOARD_GENIATECH_X8000_MT: 969 dev->ts_gen_cntrl = 0x00; 970 971 - dev->dvb.frontend = dvb_attach(zl10353_attach, 972 &cx88_geniatech_x8000_mt, 973 &core->i2c_adap); 974 if (attach_xc3028(0x61, dev) < 0) 975 goto frontend_detach; 976 break; 977 case CX88_BOARD_KWORLD_ATSC_120: 978 - dev->dvb.frontend = dvb_attach(s5h1409_attach, 979 &kworld_atsc_120_config, 980 &core->i2c_adap); 981 if (attach_xc3028(0x61, dev) < 0) 982 goto frontend_detach; 983 break; 984 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: 985 - dev->dvb.frontend = dvb_attach(s5h1411_attach, 986 &dvico_fusionhdtv7_config, 987 &core->i2c_adap); 988 - if (dev->dvb.frontend != NULL) { 989 - if (!dvb_attach(xc5000_attach, dev->dvb.frontend, 990 &core->i2c_adap, 991 &dvico_fusionhdtv7_tuner_config)) 992 goto frontend_detach; 993 } 994 break; 995 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, 999 &hauppauge_hvr4000_config, 1000 &dev->core->i2c_adap); 1001 - if (dev->dvb.frontend) { 1002 - dvb_attach(isl6421_attach, dev->dvb.frontend, 1003 &dev->core->i2c_adap, 1004 0x08, ISL6421_DCL, 0x00); 1005 } 1006 break; 1007 case CX88_BOARD_TEVII_S420: 1008 - dev->dvb.frontend = dvb_attach(stv0299_attach, 1009 &tevii_tuner_sharp_config, 1010 &core->i2c_adap); 1011 - if (dev->dvb.frontend != NULL) { 1012 - if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 1013 &core->i2c_adap, DVB_PLL_OPERA1)) 1014 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; 1017 1018 } else { 1019 - dev->dvb.frontend = dvb_attach(stv0288_attach, 1020 &tevii_tuner_earda_config, 1021 &core->i2c_adap); 1022 - if (dev->dvb.frontend != NULL) { 1023 - if (!dvb_attach(stb6000_attach, dev->dvb.frontend, 0x61, 1024 &core->i2c_adap)) 1025 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; 1028 1029 } 1030 } 1031 break; 1032 case CX88_BOARD_TEVII_S460: 1033 - dev->dvb.frontend = dvb_attach(cx24116_attach, 1034 &tevii_s460_config, 1035 &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; 1039 } 1040 break; 1041 case CX88_BOARD_OMICOM_SS4_PCI: 1042 case CX88_BOARD_TBS_8920: 1043 case CX88_BOARD_PROF_7300: 1044 - dev->dvb.frontend = dvb_attach(cx24116_attach, 1045 &hauppauge_hvr4000_config, 1046 &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; 1050 } 1051 break; 1052 default: ··· 1087 core->name); 1088 break; 1089 } 1090 - if (NULL == dev->dvb.frontend) { 1091 printk(KERN_ERR 1092 "%s/2: frontend initialization failed\n", 1093 core->name); 1094 return -EINVAL; 1095 } 1096 /* define general-purpose callback pointer */ 1097 - dev->dvb.frontend->callback = cx88_tuner_callback; 1098 1099 /* Ensure all frontends negotiate bus access */ 1100 - dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; 1101 1102 /* Put the analog decoder in standby to keep it quiet */ 1103 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL); 1104 1105 /* register everything */ 1106 - return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, 1107 - &dev->pci->dev, adapter_nr); 1108 1109 frontend_detach: 1110 - if (dev->dvb.frontend) { 1111 - dvb_frontend_detach(dev->dvb.frontend); 1112 - dev->dvb.frontend = NULL; 1113 } 1114 return -EINVAL; 1115 } ··· 1136 cx_clear(MO_GP0_IO, 0x00000004); 1137 udelay(1000); 1138 break; 1139 default: 1140 err = -ENODEV; 1141 } ··· 1185 case CX88_BOARD_HAUPPAUGE_HVR1300: 1186 /* Do Nothing, leave the cx22702 on the bus. */ 1187 break; 1188 default: 1189 err = -ENODEV; 1190 } ··· 1198 { 1199 struct cx88_core *core = drv->core; 1200 struct cx8802_dev *dev = drv->core->dvbdev; 1201 - int err; 1202 1203 dprintk( 1, "%s\n", __func__); 1204 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", ··· 1219 1220 /* dvb stuff */ 1221 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); 1222 - videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops, 1223 &dev->pci->dev, &dev->slock, 1224 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1225 V4L2_FIELD_TOP, 1226 sizeof(struct cx88_buffer), 1227 dev); 1228 err = dvb_register(dev); 1229 if (err != 0) 1230 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n", 1231 core->name, err); 1232 - 1233 - fail_core: 1234 return err; 1235 } 1236 ··· 1248 { 1249 struct cx8802_dev *dev = drv->core->dvbdev; 1250 1251 - /* dvb */ 1252 - if (dev->dvb.frontend) 1253 - videobuf_dvb_unregister(&dev->dvb); 1254 1255 vp3054_i2c_remove(dev); 1256
··· 116 struct cx8802_dev *dev= fe->dvb->priv; 117 struct cx8802_driver *drv = NULL; 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 + } 126 127 drv = cx8802_get_driver(dev, CX88_MPEG_DVB); 128 if (drv) { 129 + if (acquire){ 130 + dev->frontends.active_fe_id = fe_id; 131 ret = drv->request_acquire(drv); 132 + } else { 133 ret = drv->request_release(drv); 134 + dev->frontends.active_fe_id = 0; 135 + } 136 } 137 138 return ret; ··· 396 cx_write(MO_GP0_IO, 0x00006060); 397 break; 398 case SEC_VOLTAGE_OFF: 399 + printk("LNB Voltage SEC_VOLTAGE_off\n"); 400 break; 401 } 402 ··· 483 static int attach_xc3028(u8 addr, struct cx8802_dev *dev) 484 { 485 struct dvb_frontend *fe; 486 + struct videobuf_dvb_frontend *fe0 = NULL; 487 struct xc2028_ctrl ctl; 488 struct xc2028_config cfg = { 489 .i2c_adap = &dev->core->i2c_adap, ··· 490 .ctrl = &ctl, 491 }; 492 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) { 499 printk(KERN_ERR "%s/2: dvb frontend not attached. " 500 "Can't attach xc3028\n", 501 dev->core->name); ··· 504 */ 505 cx88_setup_xc3028(dev->core, &ctl); 506 507 + fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg); 508 if (!fe) { 509 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 510 dev->core->name); 511 + dvb_frontend_detach(fe0->dvb.frontend); 512 + dvb_unregister_frontend(fe0->dvb.frontend); 513 + fe0->dvb.frontend = NULL; 514 return -EINVAL; 515 } 516 ··· 532 struct cx88_core *core = dev->core; 533 534 /* Reset the part */ 535 + /* Put the cx24116 into reset */ 536 cx_write(MO_SRST_IO, 0); 537 msleep(10); 538 + /* Take the cx24116 out of reset */ 539 cx_write(MO_SRST_IO, 1); 540 msleep(10); 541 ··· 554 555 static struct stv0299_config tevii_tuner_sharp_config = { 556 .demod_address = 0x68, 557 + .inittab = sharp_z0194a_inittab, 558 .mclk = 88000000UL, 559 .invert = 1, 560 .skip_reinit = 0, 561 .lock_output = 1, 562 .volt13_op0_op1 = STV0299_VOLT13_OP1, 563 .min_delay_ms = 100, 564 + .set_symbol_rate = sharp_z0194a_set_symbol_rate, 565 .set_ts_params = cx24116_set_ts_param, 566 }; 567 ··· 574 static int dvb_register(struct cx8802_dev *dev) 575 { 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 */ 579 580 + /* Get the first frontend */ 581 + fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); 582 + if (!fe0) 583 + return -EINVAL; 584 585 + /* multi-frontend gate control is undefined or defaults to fe0 */ 586 + dev->frontends.gate = 0; 587 + 588 + /* init frontend(s) */ 589 switch (core->boardnr) { 590 case CX88_BOARD_HAUPPAUGE_DVB_T1: 591 + fe0->dvb.frontend = dvb_attach(cx22702_attach, 592 &connexant_refboard_config, 593 &core->i2c_adap); 594 + if (fe0->dvb.frontend != NULL) { 595 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 596 0x61, &core->i2c_adap, 597 DVB_PLL_THOMSON_DTT759X)) 598 goto frontend_detach; ··· 596 case CX88_BOARD_CONEXANT_DVB_T1: 597 case CX88_BOARD_KWORLD_DVB_T_CX22702: 598 case CX88_BOARD_WINFAST_DTV1000: 599 + fe0->dvb.frontend = dvb_attach(cx22702_attach, 600 &connexant_refboard_config, 601 &core->i2c_adap); 602 + if (fe0->dvb.frontend != NULL) { 603 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 604 0x60, &core->i2c_adap, 605 DVB_PLL_THOMSON_DTT7579)) 606 goto frontend_detach; ··· 610 case CX88_BOARD_HAUPPAUGE_HVR1100: 611 case CX88_BOARD_HAUPPAUGE_HVR1100LP: 612 case CX88_BOARD_HAUPPAUGE_HVR1300: 613 + fe0->dvb.frontend = dvb_attach(cx22702_attach, 614 &hauppauge_hvr_config, 615 &core->i2c_adap); 616 + if (fe0->dvb.frontend != NULL) { 617 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 618 &core->i2c_adap, 0x61, 619 TUNER_PHILIPS_FMD1216ME_MK3)) 620 goto frontend_detach; 621 } 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; 658 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 659 + fe0->dvb.frontend = dvb_attach(mt352_attach, 660 &dvico_fusionhdtv, 661 &core->i2c_adap); 662 + if (fe0->dvb.frontend != NULL) { 663 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 664 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 665 goto frontend_detach; 666 break; 667 } 668 /* ZL10353 replaces MT352 on later cards */ 669 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 670 &dvico_fusionhdtv_plus_v1_1, 671 &core->i2c_adap); 672 + if (fe0->dvb.frontend != NULL) { 673 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 674 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 675 goto frontend_detach; 676 } ··· 644 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 645 /* The tin box says DEE1601, but it seems to be DTT7579 646 * compatible, with a slightly different MT352 AGC gain. */ 647 + fe0->dvb.frontend = dvb_attach(mt352_attach, 648 &dvico_fusionhdtv_dual, 649 &core->i2c_adap); 650 + if (fe0->dvb.frontend != NULL) { 651 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 652 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 653 goto frontend_detach; 654 break; 655 } 656 /* ZL10353 replaces MT352 on later cards */ 657 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 658 &dvico_fusionhdtv_plus_v1_1, 659 &core->i2c_adap); 660 + if (fe0->dvb.frontend != NULL) { 661 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 662 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 663 goto frontend_detach; 664 } 665 break; 666 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 667 + fe0->dvb.frontend = dvb_attach(mt352_attach, 668 &dvico_fusionhdtv, 669 &core->i2c_adap); 670 + if (fe0->dvb.frontend != NULL) { 671 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 672 0x61, NULL, DVB_PLL_LG_Z201)) 673 goto frontend_detach; 674 } ··· 676 case CX88_BOARD_KWORLD_DVB_T: 677 case CX88_BOARD_DNTV_LIVE_DVB_T: 678 case CX88_BOARD_ADSTECH_DVB_T_PCI: 679 + fe0->dvb.frontend = dvb_attach(mt352_attach, 680 &dntv_live_dvbt_config, 681 &core->i2c_adap); 682 + if (fe0->dvb.frontend != NULL) { 683 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 684 0x61, NULL, DVB_PLL_UNKNOWN_1)) 685 goto frontend_detach; 686 } ··· 688 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 689 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE)) 690 /* MT352 is on a secondary I2C bus made from some GPIO lines */ 691 + fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, 692 &dev->vp3054->adap); 693 + if (fe0->dvb.frontend != NULL) { 694 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 695 &core->i2c_adap, 0x61, 696 TUNER_PHILIPS_FMD1216ME_MK3)) 697 goto frontend_detach; ··· 702 #endif 703 break; 704 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 705 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 706 &dvico_fusionhdtv_hybrid, 707 &core->i2c_adap); 708 + if (fe0->dvb.frontend != NULL) { 709 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 710 &core->i2c_adap, 0x61, 711 TUNER_THOMSON_FE6600)) 712 goto frontend_detach; 713 } 714 break; 715 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: 716 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 717 &dvico_fusionhdtv_xc3028, 718 &core->i2c_adap); 719 + if (fe0->dvb.frontend == NULL) 720 + fe0->dvb.frontend = dvb_attach(mt352_attach, 721 &dvico_fusionhdtv_mt352_xc3028, 722 &core->i2c_adap); 723 /* ··· 725 * We must not permit gate_ctrl to be performed, or 726 * the xc3028 cannot communicate on the bus. 727 */ 728 + if (fe0->dvb.frontend) 729 + fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; 730 if (attach_xc3028(0x61, dev) < 0) 731 return -EINVAL; 732 break; 733 case CX88_BOARD_PCHDTV_HD3000: 734 + fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, 735 &core->i2c_adap); 736 + if (fe0->dvb.frontend != NULL) { 737 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 738 &core->i2c_adap, 0x61, 739 TUNER_THOMSON_DTT761X)) 740 goto frontend_detach; ··· 751 752 /* Select RF connector callback */ 753 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; 754 + fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 755 &fusionhdtv_3_gold, 756 &core->i2c_adap); 757 + if (fe0->dvb.frontend != NULL) { 758 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 759 &core->i2c_adap, 0x61, 760 TUNER_MICROTUNE_4042FI5)) 761 goto frontend_detach; ··· 769 mdelay(100); 770 cx_set(MO_GP0_IO, 9); 771 mdelay(200); 772 + fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 773 &fusionhdtv_3_gold, 774 &core->i2c_adap); 775 + if (fe0->dvb.frontend != NULL) { 776 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 777 &core->i2c_adap, 0x61, 778 TUNER_THOMSON_DTT761X)) 779 goto frontend_detach; ··· 787 mdelay(100); 788 cx_set(MO_GP0_IO, 1); 789 mdelay(200); 790 + fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 791 &fusionhdtv_5_gold, 792 &core->i2c_adap); 793 + if (fe0->dvb.frontend != NULL) { 794 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 795 &core->i2c_adap, 0x61, 796 TUNER_LG_TDVS_H06XF)) 797 goto frontend_detach; 798 + if (!dvb_attach(tda9887_attach, fe0->dvb.frontend, 799 &core->i2c_adap, 0x43)) 800 goto frontend_detach; 801 } ··· 808 mdelay(100); 809 cx_set(MO_GP0_IO, 1); 810 mdelay(200); 811 + fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 812 &pchdtv_hd5500, 813 &core->i2c_adap); 814 + if (fe0->dvb.frontend != NULL) { 815 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 816 &core->i2c_adap, 0x61, 817 TUNER_LG_TDVS_H06XF)) 818 goto frontend_detach; 819 + if (!dvb_attach(tda9887_attach, fe0->dvb.frontend, 820 &core->i2c_adap, 0x43)) 821 goto frontend_detach; 822 } 823 break; 824 case CX88_BOARD_ATI_HDTVWONDER: 825 + fe0->dvb.frontend = dvb_attach(nxt200x_attach, 826 &ati_hdtvwonder, 827 &core->i2c_adap); 828 + if (fe0->dvb.frontend != NULL) { 829 + if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 830 &core->i2c_adap, 0x61, 831 TUNER_PHILIPS_TUV1236D)) 832 goto frontend_detach; ··· 834 break; 835 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 836 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 837 + fe0->dvb.frontend = dvb_attach(cx24123_attach, 838 &hauppauge_novas_config, 839 &core->i2c_adap); 840 + if (fe0->dvb.frontend) { 841 + if (!dvb_attach(isl6421_attach, fe0->dvb.frontend, 842 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) 843 goto frontend_detach; 844 } 845 break; 846 case CX88_BOARD_KWORLD_DVBS_100: 847 + fe0->dvb.frontend = dvb_attach(cx24123_attach, 848 &kworld_dvbs_100_config, 849 &core->i2c_adap); 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; 853 } 854 break; 855 case CX88_BOARD_GENIATECH_DVBS: 856 + fe0->dvb.frontend = dvb_attach(cx24123_attach, 857 &geniatech_dvbs_config, 858 &core->i2c_adap); 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; 862 } 863 break; 864 case CX88_BOARD_PINNACLE_PCTV_HD_800i: 865 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 866 &pinnacle_pctv_hd_800i_config, 867 &core->i2c_adap); 868 + if (fe0->dvb.frontend != NULL) { 869 + if (!dvb_attach(xc5000_attach, fe0->dvb.frontend, 870 &core->i2c_adap, 871 &pinnacle_pctv_hd_800i_tuner_config)) 872 goto frontend_detach; 873 } 874 break; 875 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: 876 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 877 &dvico_hdtv5_pci_nano_config, 878 &core->i2c_adap); 879 + if (fe0->dvb.frontend != NULL) { 880 struct dvb_frontend *fe; 881 struct xc2028_config cfg = { 882 .i2c_adap = &core->i2c_adap, ··· 889 }; 890 891 fe = dvb_attach(xc2028_attach, 892 + fe0->dvb.frontend, &cfg); 893 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 894 fe->ops.tuner_ops.set_config(fe, &ctl); 895 } 896 break; 897 case CX88_BOARD_PINNACLE_HYBRID_PCTV: 898 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 899 &cx88_pinnacle_hybrid_pctv, 900 &core->i2c_adap); 901 + if (fe0->dvb.frontend) { 902 + fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; 903 if (attach_xc3028(0x61, dev) < 0) 904 goto frontend_detach; 905 } ··· 907 case CX88_BOARD_GENIATECH_X8000_MT: 908 dev->ts_gen_cntrl = 0x00; 909 910 + fe0->dvb.frontend = dvb_attach(zl10353_attach, 911 &cx88_geniatech_x8000_mt, 912 &core->i2c_adap); 913 if (attach_xc3028(0x61, dev) < 0) 914 goto frontend_detach; 915 break; 916 case CX88_BOARD_KWORLD_ATSC_120: 917 + fe0->dvb.frontend = dvb_attach(s5h1409_attach, 918 &kworld_atsc_120_config, 919 &core->i2c_adap); 920 if (attach_xc3028(0x61, dev) < 0) 921 goto frontend_detach; 922 break; 923 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: 924 + fe0->dvb.frontend = dvb_attach(s5h1411_attach, 925 &dvico_fusionhdtv7_config, 926 &core->i2c_adap); 927 + if (fe0->dvb.frontend != NULL) { 928 + if (!dvb_attach(xc5000_attach, fe0->dvb.frontend, 929 &core->i2c_adap, 930 &dvico_fusionhdtv7_tuner_config)) 931 goto frontend_detach; 932 } 933 break; 934 case CX88_BOARD_HAUPPAUGE_HVR4000: 935 + /* DVB-S/S2 Init */ 936 + fe0->dvb.frontend = dvb_attach(cx24116_attach, 937 &hauppauge_hvr4000_config, 938 &dev->core->i2c_adap); 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, 975 &dev->core->i2c_adap, 976 0x08, ISL6421_DCL, 0x00); 977 } 978 break; 979 case CX88_BOARD_TEVII_S420: 980 + fe0->dvb.frontend = dvb_attach(stv0299_attach, 981 &tevii_tuner_sharp_config, 982 &core->i2c_adap); 983 + if (fe0->dvb.frontend != NULL) { 984 + if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60, 985 &core->i2c_adap, DVB_PLL_OPERA1)) 986 goto frontend_detach; 987 + core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; 988 + fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 989 990 } else { 991 + fe0->dvb.frontend = dvb_attach(stv0288_attach, 992 &tevii_tuner_earda_config, 993 &core->i2c_adap); 994 + if (fe0->dvb.frontend != NULL) { 995 + if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61, 996 &core->i2c_adap)) 997 goto frontend_detach; 998 + core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; 999 + fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1000 1001 } 1002 } 1003 break; 1004 case CX88_BOARD_TEVII_S460: 1005 + fe0->dvb.frontend = dvb_attach(cx24116_attach, 1006 &tevii_s460_config, 1007 &core->i2c_adap); 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; 1011 } 1012 break; 1013 case CX88_BOARD_OMICOM_SS4_PCI: 1014 case CX88_BOARD_TBS_8920: 1015 case CX88_BOARD_PROF_7300: 1016 + fe0->dvb.frontend = dvb_attach(cx24116_attach, 1017 &hauppauge_hvr4000_config, 1018 &core->i2c_adap); 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; 1022 } 1023 break; 1024 default: ··· 993 core->name); 994 break; 995 } 996 + 997 + if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) { 998 printk(KERN_ERR 999 "%s/2: frontend initialization failed\n", 1000 core->name); 1001 return -EINVAL; 1002 } 1003 /* define general-purpose callback pointer */ 1004 + fe0->dvb.frontend->callback = cx88_tuner_callback; 1005 1006 /* Ensure all frontends negotiate bus access */ 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; 1010 1011 /* Put the analog decoder in standby to keep it quiet */ 1012 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL); 1013 1014 /* register everything */ 1015 + return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, 1016 + &dev->pci->dev, adapter_nr, mfe_shared); 1017 1018 frontend_detach: 1019 + if (fe0->dvb.frontend) { 1020 + dvb_frontend_detach(fe0->dvb.frontend); 1021 + fe0->dvb.frontend = NULL; 1022 } 1023 return -EINVAL; 1024 } ··· 1039 cx_clear(MO_GP0_IO, 0x00000004); 1040 udelay(1000); 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 + 1074 default: 1075 err = -ENODEV; 1076 } ··· 1056 case CX88_BOARD_HAUPPAUGE_HVR1300: 1057 /* Do Nothing, leave the cx22702 on the bus. */ 1058 break; 1059 + case CX88_BOARD_HAUPPAUGE_HVR3000: 1060 + case CX88_BOARD_HAUPPAUGE_HVR4000: 1061 + break; 1062 default: 1063 err = -ENODEV; 1064 } ··· 1066 { 1067 struct cx88_core *core = drv->core; 1068 struct cx8802_dev *dev = drv->core->dvbdev; 1069 + int err, i; 1070 + struct videobuf_dvb_frontend *fe; 1071 1072 dprintk( 1, "%s\n", __func__); 1073 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", ··· 1086 1087 /* dvb stuff */ 1088 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); 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, 1098 &dev->pci->dev, &dev->slock, 1099 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1100 V4L2_FIELD_TOP, 1101 sizeof(struct cx88_buffer), 1102 dev); 1103 + /* init struct videobuf_dvb */ 1104 + fe->dvb.name = dev->core->name; 1105 + } 1106 err = dvb_register(dev); 1107 if (err != 0) 1108 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n", 1109 core->name, err); 1110 + fail_core: 1111 return err; 1112 } 1113 ··· 1105 { 1106 struct cx8802_dev *dev = drv->core->dvbdev; 1107 1108 + videobuf_dvb_unregister_bus(&dev->frontends); 1109 1110 vp3054_i2c_remove(dev); 1111
+12 -5
drivers/media/video/cx88/cx88-i2c.c
··· 116 117 void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg) 118 { 119 if (0 != core->i2c_rc) 120 return; 121 122 #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); 126 127 i2c_clients_command(&core->i2c_adap, cmd, arg); 128 129 - if (core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl) 130 - core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl(core->dvbdev->dvb.frontend, 0); 131 } else 132 #endif 133 i2c_clients_command(&core->i2c_adap, cmd, arg);
··· 116 117 void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg) 118 { 119 + struct videobuf_dvb_frontends *f = &core->dvbdev->frontends; 120 + struct videobuf_dvb_frontend *fe = NULL; 121 if (0 != core->i2c_rc) 122 return; 123 124 #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) 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); 133 134 i2c_clients_command(&core->i2c_adap, cmd, arg); 135 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); 138 } else 139 #endif 140 i2c_clients_command(&core->i2c_adap, cmd, arg);
+21 -1
drivers/media/video/cx88/cx88-mpeg.c
··· 768 { 769 struct cx8802_dev *dev; 770 struct cx88_core *core; 771 - int err; 772 773 /* general setup */ 774 core = cx88_core_get(pci_dev); ··· 781 err = -ENODEV; 782 if (!core->board.mpeg) 783 goto fail_core; 784 785 err = -ENOMEM; 786 dev = kzalloc(sizeof(*dev),GFP_KERNEL); ··· 800 801 INIT_LIST_HEAD(&dev->drvlist); 802 list_add_tail(&dev->devlist,&cx8802_devlist); 803 804 /* Maintain a reference so cx88-video can query the 8802 device. */ 805 core->dvbdev = dev;
··· 768 { 769 struct cx8802_dev *dev; 770 struct cx88_core *core; 771 + struct videobuf_dvb_frontend *demod; 772 + int err,i; 773 774 /* general setup */ 775 core = cx88_core_get(pci_dev); ··· 780 err = -ENODEV; 781 if (!core->board.mpeg) 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 + } 788 789 err = -ENOMEM; 790 dev = kzalloc(sizeof(*dev),GFP_KERNEL); ··· 794 795 INIT_LIST_HEAD(&dev->drvlist); 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 + } 811 812 /* Maintain a reference so cx88-video can query the 8802 device. */ 813 core->dvbdev = dev;
+11
drivers/media/video/cx88/cx88-tvaudio.c
··· 767 case WW_FM: 768 set_audio_standard_FM(core, radio_deemphasis); 769 break; 770 case WW_NONE: 771 default: 772 printk("%s/0: unknown tv audio mode [%d]\n", ··· 902 mask = 0x3f; 903 break; 904 } 905 break; 906 } 907
··· 767 case WW_FM: 768 set_audio_standard_FM(core, radio_deemphasis); 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; 778 case WW_NONE: 779 default: 780 printk("%s/0: unknown tv audio mode [%d]\n", ··· 894 mask = 0x3f; 895 break; 896 } 897 + break; 898 + case WW_I2SADC: 899 + /* DO NOTHING */ 900 break; 901 } 902
+30 -22
drivers/media/video/cx88/cx88-video.c
··· 426 427 /* if there are audioroutes defined, we have an external 428 ADC to deal with audio */ 429 - 430 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 /* The wm8775 module has the "2" route hardwired into 448 the initialization. Some boards may use different 449 routes for different inputs. HVR-1300 surely does */ ··· 437 route.input = INPUT(input).audioroute; 438 cx88_call_i2c_clients(core, 439 VIDIOC_INT_S_AUDIO_ROUTING, &route); 440 - 441 } 442 - 443 } 444 445 return 0; ··· 825 cx_write(MO_GP0_IO, core->board.radio.gpio0); 826 cx_write(MO_GP1_IO, core->board.radio.gpio1); 827 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); 831 cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL); 832 } 833 unlock_kernel();
··· 426 427 /* if there are audioroutes defined, we have an external 428 ADC to deal with audio */ 429 if (INPUT(input).audioroute) { 430 /* The wm8775 module has the "2" route hardwired into 431 the initialization. Some boards may use different 432 routes for different inputs. HVR-1300 surely does */ ··· 454 route.input = INPUT(input).audioroute; 455 cx88_call_i2c_clients(core, 456 VIDIOC_INT_S_AUDIO_ROUTING, &route); 457 } 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 + } 470 } 471 472 return 0; ··· 832 cx_write(MO_GP0_IO, core->board.radio.gpio0); 833 cx_write(MO_GP1_IO, core->board.radio.gpio1); 834 cx_write(MO_GP2_IO, core->board.radio.gpio2); 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 + } 853 cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL); 854 } 855 unlock_kernel();
+5 -2
drivers/media/video/cx88/cx88.h
··· 247 enum cx88_itype type; 248 u32 gpio0, gpio1, gpio2, gpio3; 249 unsigned int vmux:2; 250 - unsigned int audioroute:2; 251 }; 252 253 struct cx88_board { ··· 261 struct cx88_input radio; 262 enum cx88_board_type mpeg; 263 unsigned int audio_chip; 264 }; 265 266 struct cx88_subid { ··· 357 struct cx8802_dev *dvbdev; 358 enum cx88_board_type active_type_id; 359 int active_ref; 360 }; 361 362 struct cx8800_dev; ··· 492 493 #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) 494 /* for dvb only */ 495 - struct videobuf_dvb dvb; 496 #endif 497 498 #if defined(CONFIG_VIDEO_CX88_VP3054) || \ ··· 630 #define WW_EIAJ 7 631 #define WW_I2SPT 8 632 #define WW_FM 9 633 634 void cx88_set_tvaudio(struct cx88_core *core); 635 void cx88_newstation(struct cx88_core *core);
··· 247 enum cx88_itype type; 248 u32 gpio0, gpio1, gpio2, gpio3; 249 unsigned int vmux:2; 250 + unsigned int audioroute:4; 251 }; 252 253 struct cx88_board { ··· 261 struct cx88_input radio; 262 enum cx88_board_type mpeg; 263 unsigned int audio_chip; 264 + int num_frontends; 265 }; 266 267 struct cx88_subid { ··· 356 struct cx8802_dev *dvbdev; 357 enum cx88_board_type active_type_id; 358 int active_ref; 359 + int active_fe_id; 360 }; 361 362 struct cx8800_dev; ··· 490 491 #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) 492 /* for dvb only */ 493 + struct videobuf_dvb_frontends frontends; 494 #endif 495 496 #if defined(CONFIG_VIDEO_CX88_VP3054) || \ ··· 628 #define WW_EIAJ 7 629 #define WW_I2SPT 8 630 #define WW_FM 9 631 + #define WW_I2SADC 10 632 633 void cx88_set_tvaudio(struct cx88_core *core); 634 void cx88_newstation(struct cx88_core *core);
+2 -1
drivers/media/video/gspca/gspca.c
··· 21 #define MODULE_NAME "gspca" 22 23 #include <linux/init.h> 24 #include <linux/fs.h> 25 #include <linux/vmalloc.h> 26 #include <linux/sched.h> ··· 404 unsigned int i; 405 406 PDEBUG(D_STREAM, "kill transfer"); 407 - for (i = 0; i < MAX_NURBS; ++i) { 408 urb = gspca_dev->urb[i]; 409 if (urb == NULL) 410 break;
··· 21 #define MODULE_NAME "gspca" 22 23 #include <linux/init.h> 24 + #include <linux/version.h> 25 #include <linux/fs.h> 26 #include <linux/vmalloc.h> 27 #include <linux/sched.h> ··· 403 unsigned int i; 404 405 PDEBUG(D_STREAM, "kill transfer"); 406 + for (i = 0; i < MAX_NURBS; i++) { 407 urb = gspca_dev->urb[i]; 408 if (urb == NULL) 409 break;
-1
drivers/media/video/gspca/gspca.h
··· 2 #define GSPCAV2_H 3 4 #include <linux/module.h> 5 - #include <linux/version.h> 6 #include <linux/kernel.h> 7 #include <linux/usb.h> 8 #include <linux/videodev2.h>
··· 2 #define GSPCAV2_H 3 4 #include <linux/module.h> 5 #include <linux/kernel.h> 6 #include <linux/usb.h> 7 #include <linux/videodev2.h>
+1 -28
drivers/media/video/gspca/m5602/m5602_bridge.h
··· 1 /* 2 * USB Driver for ALi m5602 based webcams 3 * 4 - * Copyright (C) 2008 Erik Andren 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 22 #include "gspca.h" 23 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 53 /*****************************************************************************/ 54
··· 1 /* 2 * USB Driver for ALi m5602 based webcams 3 * 4 + * Copyright (C) 2008 Erik Andrén 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 22 #include "gspca.h" 23 24 #define MODULE_NAME "ALi m5602" 25 26 /*****************************************************************************/ 27
+21 -25
drivers/media/video/gspca/m5602/m5602_core.c
··· 1 - /* 2 * USB Driver for ALi m5602 based webcams 3 * 4 - * Copyright (C) 2008 Erik Andren 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 26 int force_sensor; 27 int dump_bridge; 28 int dump_sensor; 29 - unsigned int m5602_debug; 30 31 static const __devinitdata struct usb_device_id m5602_table[] = { 32 {USB_DEVICE(0x0402, 0x5602)}, ··· 47 1, M5602_URB_MSG_TIMEOUT); 48 *i2c_data = buf[0]; 49 50 - PDEBUG(DBG_TRACE, "Reading bridge register 0x%x containing 0x%x", 51 address, *i2c_data); 52 53 /* usb_control_msg(...) returns the number of bytes sent upon success, ··· 62 struct usb_device *udev = sd->gspca_dev.dev; 63 __u8 *buf = sd->gspca_dev.usb_buf; 64 65 - PDEBUG(DBG_TRACE, "Writing bridge register 0x%x with 0x%x", 66 address, i2c_data); 67 68 memcpy(buf, bridge_urb_skeleton, ··· 90 m5602_read_bridge(sd, i, &val); 91 info("ALi m5602 address 0x%x contains 0x%x", i, val); 92 } 93 - info("Warning: The camera probably won't work until it's power cycled"); 94 } 95 96 static int m5602_probe_sensor(struct sd *sd) ··· 135 struct sd *sd = (struct sd *) gspca_dev; 136 int err; 137 138 - PDEBUG(DBG_TRACE, "Initializing ALi m5602 webcam"); 139 /* Run the init sequence */ 140 err = sd->sensor->init(sd); 141 ··· 146 { 147 struct sd *sd = (struct sd *) gspca_dev; 148 __u8 *buf = sd->gspca_dev.usb_buf; 149 150 /* Send start command to the camera */ 151 const u8 buffer[4] = {0x13, 0xf9, 0x0f, 0x01}; 152 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); 156 157 - PDEBUG(DBG_V4L2, "Transfer started"); 158 - return 0; 159 } 160 161 static void m5602_urb_complete(struct gspca_dev *gspca_dev, ··· 167 struct sd *sd = (struct sd *) gspca_dev; 168 169 if (len < 6) { 170 - PDEBUG(DBG_DATA, "Packet is less than 6 bytes"); 171 return; 172 } 173 174 /* Frame delimiter: ff xx xx xx ff ff */ 175 if (data[0] == 0xff && data[4] == 0xff && data[5] == 0xff && 176 data[2] != sd->frame_id) { 177 - PDEBUG(DBG_DATA, "Frame delimiter detected"); 178 sd->frame_id = data[2]; 179 180 /* Remove the extra fluff appended on each header */ ··· 189 /* Create a new frame */ 190 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len); 191 192 - PDEBUG(DBG_V4L2, "Starting new frame %d", 193 sd->frame_count); 194 195 } else { ··· 200 len -= 4; 201 202 if (cur_frame_len + len <= frame->v4l2_buf.length) { 203 - PDEBUG(DBG_DATA, "Continuing frame %d copying %d bytes", 204 sd->frame_count, len); 205 206 gspca_frame_add(gspca_dev, INTER_PACKET, frame, ··· 236 struct cam *cam; 237 int err; 238 239 - PDEBUG(DBG_GSPCA, "m5602_configure start"); 240 - 241 cam = &gspca_dev->cam; 242 cam->epaddr = M5602_ISOC_ENDPOINT_ADDR; 243 sd->desc = &sd_desc; ··· 248 if (err) 249 goto fail; 250 251 - PDEBUG(DBG_GSPCA, "m5602_configure end"); 252 return 0; 253 254 fail: 255 - PDEBUG(DBG_GSPCA, "m5602_configure failed"); 256 cam->cam_mode = NULL; 257 cam->nmodes = 0; 258 ··· 281 { 282 if (usb_register(&sd_driver) < 0) 283 return -1; 284 - PDEBUG(D_PROBE, "m5602 module registered"); 285 return 0; 286 } 287 static void __exit mod_m5602_exit(void) 288 { 289 usb_deregister(&sd_driver); 290 - PDEBUG(D_PROBE, "m5602 module deregistered"); 291 } 292 293 module_init(mod_m5602_init); ··· 296 MODULE_AUTHOR(DRIVER_AUTHOR); 297 MODULE_DESCRIPTION(DRIVER_DESC); 298 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 module_param(force_sensor, int, S_IRUGO | S_IWUSR); 303 MODULE_PARM_DESC(force_sensor, 304 "force detection of sensor, "
··· 1 + /* 2 * USB Driver for ALi m5602 based webcams 3 * 4 + * Copyright (C) 2008 Erik Andrén 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 26 int force_sensor; 27 int dump_bridge; 28 int dump_sensor; 29 30 static const __devinitdata struct usb_device_id m5602_table[] = { 31 {USB_DEVICE(0x0402, 0x5602)}, ··· 48 1, M5602_URB_MSG_TIMEOUT); 49 *i2c_data = buf[0]; 50 51 + PDEBUG(D_CONF, "Reading bridge register 0x%x containing 0x%x", 52 address, *i2c_data); 53 54 /* usb_control_msg(...) returns the number of bytes sent upon success, ··· 63 struct usb_device *udev = sd->gspca_dev.dev; 64 __u8 *buf = sd->gspca_dev.usb_buf; 65 66 + PDEBUG(D_CONF, "Writing bridge register 0x%x with 0x%x", 67 address, i2c_data); 68 69 memcpy(buf, bridge_urb_skeleton, ··· 91 m5602_read_bridge(sd, i, &val); 92 info("ALi m5602 address 0x%x contains 0x%x", i, val); 93 } 94 + info("Warning: The ALi m5602 webcam probably won't work " 95 + "until it's power cycled"); 96 } 97 98 static int m5602_probe_sensor(struct sd *sd) ··· 135 struct sd *sd = (struct sd *) gspca_dev; 136 int err; 137 138 + PDEBUG(D_CONF, "Initializing ALi m5602 webcam"); 139 /* Run the init sequence */ 140 err = sd->sensor->init(sd); 141 ··· 146 { 147 struct sd *sd = (struct sd *) gspca_dev; 148 __u8 *buf = sd->gspca_dev.usb_buf; 149 + int err; 150 151 /* Send start command to the camera */ 152 const u8 buffer[4] = {0x13, 0xf9, 0x0f, 0x01}; 153 memcpy(buf, buffer, sizeof(buffer)); 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); 158 159 + PDEBUG(D_STREAM, "Transfer started"); 160 + return (err < 0) ? err : 0; 161 } 162 163 static void m5602_urb_complete(struct gspca_dev *gspca_dev, ··· 165 struct sd *sd = (struct sd *) gspca_dev; 166 167 if (len < 6) { 168 + PDEBUG(D_PACK, "Packet is less than 6 bytes"); 169 return; 170 } 171 172 /* Frame delimiter: ff xx xx xx ff ff */ 173 if (data[0] == 0xff && data[4] == 0xff && data[5] == 0xff && 174 data[2] != sd->frame_id) { 175 + PDEBUG(D_FRAM, "Frame delimiter detected"); 176 sd->frame_id = data[2]; 177 178 /* Remove the extra fluff appended on each header */ ··· 187 /* Create a new frame */ 188 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len); 189 190 + PDEBUG(D_FRAM, "Starting new frame %d", 191 sd->frame_count); 192 193 } else { ··· 198 len -= 4; 199 200 if (cur_frame_len + len <= frame->v4l2_buf.length) { 201 + PDEBUG(D_FRAM, "Continuing frame %d copying %d bytes", 202 sd->frame_count, len); 203 204 gspca_frame_add(gspca_dev, INTER_PACKET, frame, ··· 234 struct cam *cam; 235 int err; 236 237 cam = &gspca_dev->cam; 238 cam->epaddr = M5602_ISOC_ENDPOINT_ADDR; 239 sd->desc = &sd_desc; ··· 248 if (err) 249 goto fail; 250 251 return 0; 252 253 fail: 254 + PDEBUG(D_ERR, "ALi m5602 webcam failed"); 255 cam->cam_mode = NULL; 256 cam->nmodes = 0; 257 ··· 282 { 283 if (usb_register(&sd_driver) < 0) 284 return -1; 285 + PDEBUG(D_PROBE, "registered"); 286 return 0; 287 } 288 static void __exit mod_m5602_exit(void) 289 { 290 usb_deregister(&sd_driver); 291 + PDEBUG(D_PROBE, "deregistered"); 292 } 293 294 module_init(mod_m5602_init); ··· 297 MODULE_AUTHOR(DRIVER_AUTHOR); 298 MODULE_DESCRIPTION(DRIVER_DESC); 299 MODULE_LICENSE("GPL"); 300 module_param(force_sensor, int, S_IRUGO | S_IWUSR); 301 MODULE_PARM_DESC(force_sensor, 302 "force detection of sensor, "
+9 -9
drivers/media/video/gspca/m5602/m5602_mt9m111.c
··· 1 /* 2 * Driver for the mt9m111 sensor 3 * 4 - * Copyright (C) 2008 Erik Andren 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 107 err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, 108 data, 2); 109 *val = data[0] & MT9M111_RMB_MIRROR_ROWS; 110 - PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); 111 112 return (err < 0) ? err : 0; 113 } ··· 118 u8 data[2] = {0x00, 0x00}; 119 struct sd *sd = (struct sd *) gspca_dev; 120 121 - PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); 122 123 /* Set the correct page map */ 124 err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); ··· 145 err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, 146 data, 2); 147 *val = data[0] & MT9M111_RMB_MIRROR_COLS; 148 - PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); 149 150 return (err < 0) ? err : 0; 151 } ··· 156 u8 data[2] = {0x00, 0x00}; 157 struct sd *sd = (struct sd *) gspca_dev; 158 159 - PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", val); 160 161 /* Set the correct page map */ 162 err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); ··· 188 ((tmp & (1 << 8)) * 2) | 189 (tmp & 0x7f); 190 191 - PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 192 193 return (err < 0) ? err : 0; 194 } ··· 222 223 data[1] = (tmp & 0xff00) >> 8; 224 data[0] = (tmp & 0xff); 225 - PDEBUG(DBG_V4L2_CID, "tmp=%d, data[1]=%d, data[0]=%d", tmp, 226 data[1], data[0]); 227 228 err = mt9m111_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, ··· 257 for (i = 0; i < len && !err; i++) { 258 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 259 260 - PDEBUG(DBG_TRACE, "Reading sensor register " 261 "0x%x contains 0x%x ", address, *i2c_data); 262 } 263 out: ··· 290 memcpy(p, sensor_urb_skeleton + 16, 4); 291 p[3] = i2c_data[i]; 292 p += 4; 293 - PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 294 address, i2c_data[i]); 295 } 296
··· 1 /* 2 * Driver for the mt9m111 sensor 3 * 4 + * Copyright (C) 2008 Erik Andrén 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 107 err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, 108 data, 2); 109 *val = data[0] & MT9M111_RMB_MIRROR_ROWS; 110 + PDEBUG(D_V4L2, "Read vertical flip %d", *val); 111 112 return (err < 0) ? err : 0; 113 } ··· 118 u8 data[2] = {0x00, 0x00}; 119 struct sd *sd = (struct sd *) gspca_dev; 120 121 + PDEBUG(D_V4L2, "Set vertical flip to %d", val); 122 123 /* Set the correct page map */ 124 err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); ··· 145 err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, 146 data, 2); 147 *val = data[0] & MT9M111_RMB_MIRROR_COLS; 148 + PDEBUG(D_V4L2, "Read horizontal flip %d", *val); 149 150 return (err < 0) ? err : 0; 151 } ··· 156 u8 data[2] = {0x00, 0x00}; 157 struct sd *sd = (struct sd *) gspca_dev; 158 159 + PDEBUG(D_V4L2, "Set horizontal flip to %d", val); 160 161 /* Set the correct page map */ 162 err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); ··· 188 ((tmp & (1 << 8)) * 2) | 189 (tmp & 0x7f); 190 191 + PDEBUG(D_V4L2, "Read gain %d", *val); 192 193 return (err < 0) ? err : 0; 194 } ··· 222 223 data[1] = (tmp & 0xff00) >> 8; 224 data[0] = (tmp & 0xff); 225 + PDEBUG(D_V4L2, "tmp=%d, data[1]=%d, data[0]=%d", tmp, 226 data[1], data[0]); 227 228 err = mt9m111_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, ··· 257 for (i = 0; i < len && !err; i++) { 258 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 259 260 + PDEBUG(D_CONF, "Reading sensor register " 261 "0x%x contains 0x%x ", address, *i2c_data); 262 } 263 out: ··· 290 memcpy(p, sensor_urb_skeleton + 16, 4); 291 p[3] = i2c_data[i]; 292 p += 4; 293 + PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", 294 address, i2c_data[i]); 295 } 296
+3 -4
drivers/media/video/gspca/m5602/m5602_mt9m111.h
··· 1 /* 2 * Driver for the mt9m111 sensor 3 * 4 - * Copyright (C) 2008 Erik Andren 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 82 /* Kernel module parameters */ 83 extern int force_sensor; 84 extern int dump_sensor; 85 - extern unsigned int m5602_debug; 86 87 int mt9m111_probe(struct sd *sd); 88 int mt9m111_init(struct sd *sd); ··· 151 .default_value = DEFAULT_GAIN, 152 .flags = V4L2_CTRL_FLAG_SLIDER 153 }, 154 - .set = mt9m111_set_hflip, 155 - .get = mt9m111_get_hflip 156 } 157 }, 158
··· 1 /* 2 * Driver for the mt9m111 sensor 3 * 4 + * Copyright (C) 2008 Erik Andrén 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 82 /* Kernel module parameters */ 83 extern int force_sensor; 84 extern int dump_sensor; 85 86 int mt9m111_probe(struct sd *sd); 87 int mt9m111_init(struct sd *sd); ··· 152 .default_value = DEFAULT_GAIN, 153 .flags = V4L2_CTRL_FLAG_SLIDER 154 }, 155 + .set = mt9m111_set_gain, 156 + .get = mt9m111_get_gain 157 } 158 }, 159
+20 -20
drivers/media/video/gspca/m5602/m5602_ov9650.c
··· 1 /* 2 * Driver for the ov9650 sensor 3 * 4 - * Copyright (C) 2008 Erik Andren 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 40 for (i = 0; i < len; i++) { 41 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 42 43 - PDEBUG(DBG_TRACE, "Reading sensor register " 44 "0x%x containing 0x%x ", address, *i2c_data); 45 } 46 return (err < 0) ? err : 0; ··· 72 memcpy(p, sensor_urb_skeleton + 16, 4); 73 p[3] = i2c_data[i]; 74 p += 4; 75 - PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 76 address, i2c_data[i]); 77 } 78 ··· 199 goto out; 200 *val |= (i2c_data & 0x3f) << 10; 201 202 - PDEBUG(DBG_V4L2_CID, "Read exposure %d", *val); 203 out: 204 return (err < 0) ? err : 0; 205 } ··· 210 u8 i2c_data; 211 int err; 212 213 - PDEBUG(DBG_V4L2_CID, "Set exposure to %d", 214 val & 0xffff); 215 216 /* The 6 MSBs */ ··· 246 247 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); 248 *val |= i2c_data; 249 - PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 250 return (err < 0) ? err : 0; 251 } 252 ··· 280 err = ov9650_read_sensor(sd, OV9650_RED, &i2c_data, 1); 281 *val = i2c_data; 282 283 - PDEBUG(DBG_V4L2_CID, "Read red gain %d", *val); 284 285 return (err < 0) ? err : 0; 286 } ··· 291 u8 i2c_data; 292 struct sd *sd = (struct sd *) gspca_dev; 293 294 - PDEBUG(DBG_V4L2_CID, "Set red gain to %d", 295 val & 0xff); 296 297 i2c_data = val & 0xff; ··· 309 err = ov9650_read_sensor(sd, OV9650_BLUE, &i2c_data, 1); 310 *val = i2c_data; 311 312 - PDEBUG(DBG_V4L2_CID, "Read blue gain %d", *val); 313 314 return (err < 0) ? err : 0; 315 } ··· 320 u8 i2c_data; 321 struct sd *sd = (struct sd *) gspca_dev; 322 323 - PDEBUG(DBG_V4L2_CID, "Set blue gain to %d", 324 val & 0xff); 325 326 i2c_data = val & 0xff; ··· 340 *val = ((i2c_data & OV9650_HFLIP) >> 5) ? 0 : 1; 341 else 342 *val = (i2c_data & OV9650_HFLIP) >> 5; 343 - PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); 344 345 return (err < 0) ? err : 0; 346 } ··· 351 u8 i2c_data; 352 struct sd *sd = (struct sd *) gspca_dev; 353 354 - PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", val); 355 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 356 if (err < 0) 357 goto out; ··· 379 *val = ((i2c_data & 0x10) >> 4) ? 0 : 1; 380 else 381 *val = (i2c_data & 0x10) >> 4; 382 - PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); 383 384 return (err < 0) ? err : 0; 385 } ··· 390 u8 i2c_data; 391 struct sd *sd = (struct sd *) gspca_dev; 392 393 - PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); 394 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 395 if (err < 0) 396 goto out; ··· 420 421 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); 422 *val |= i2c_data; 423 - PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 424 out: 425 return (err < 0) ? err : 0; 426 } ··· 431 u8 i2c_data; 432 struct sd *sd = (struct sd *) gspca_dev; 433 434 - PDEBUG(DBG_V4L2_CID, "Set gain to %d", val & 0x3ff); 435 436 /* Read the OV9650_VREF register first to avoid 437 corrupting the VREF high and low bits */ ··· 461 462 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 463 *val = (i2c_data & OV9650_AWB_EN) >> 1; 464 - PDEBUG(DBG_V4L2_CID, "Read auto white balance %d", *val); 465 466 return (err < 0) ? err : 0; 467 } ··· 472 u8 i2c_data; 473 struct sd *sd = (struct sd *) gspca_dev; 474 475 - PDEBUG(DBG_V4L2_CID, "Set auto white balance to %d", val); 476 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 477 if (err < 0) 478 goto out; ··· 491 492 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 493 *val = (i2c_data & OV9650_AGC_EN) >> 2; 494 - PDEBUG(DBG_V4L2_CID, "Read auto gain control %d", *val); 495 496 return (err < 0) ? err : 0; 497 } ··· 502 u8 i2c_data; 503 struct sd *sd = (struct sd *) gspca_dev; 504 505 - PDEBUG(DBG_V4L2_CID, "Set auto gain control to %d", val); 506 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 507 if (err < 0) 508 goto out;
··· 1 /* 2 * Driver for the ov9650 sensor 3 * 4 + * Copyright (C) 2008 Erik Andrén 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 40 for (i = 0; i < len; i++) { 41 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 42 43 + PDEBUG(D_CONF, "Reading sensor register " 44 "0x%x containing 0x%x ", address, *i2c_data); 45 } 46 return (err < 0) ? err : 0; ··· 72 memcpy(p, sensor_urb_skeleton + 16, 4); 73 p[3] = i2c_data[i]; 74 p += 4; 75 + PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", 76 address, i2c_data[i]); 77 } 78 ··· 199 goto out; 200 *val |= (i2c_data & 0x3f) << 10; 201 202 + PDEBUG(D_V4L2, "Read exposure %d", *val); 203 out: 204 return (err < 0) ? err : 0; 205 } ··· 210 u8 i2c_data; 211 int err; 212 213 + PDEBUG(D_V4L2, "Set exposure to %d", 214 val & 0xffff); 215 216 /* The 6 MSBs */ ··· 246 247 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); 248 *val |= i2c_data; 249 + PDEBUG(D_V4L2, "Read gain %d", *val); 250 return (err < 0) ? err : 0; 251 } 252 ··· 280 err = ov9650_read_sensor(sd, OV9650_RED, &i2c_data, 1); 281 *val = i2c_data; 282 283 + PDEBUG(D_V4L2, "Read red gain %d", *val); 284 285 return (err < 0) ? err : 0; 286 } ··· 291 u8 i2c_data; 292 struct sd *sd = (struct sd *) gspca_dev; 293 294 + PDEBUG(D_V4L2, "Set red gain to %d", 295 val & 0xff); 296 297 i2c_data = val & 0xff; ··· 309 err = ov9650_read_sensor(sd, OV9650_BLUE, &i2c_data, 1); 310 *val = i2c_data; 311 312 + PDEBUG(D_V4L2, "Read blue gain %d", *val); 313 314 return (err < 0) ? err : 0; 315 } ··· 320 u8 i2c_data; 321 struct sd *sd = (struct sd *) gspca_dev; 322 323 + PDEBUG(D_V4L2, "Set blue gain to %d", 324 val & 0xff); 325 326 i2c_data = val & 0xff; ··· 340 *val = ((i2c_data & OV9650_HFLIP) >> 5) ? 0 : 1; 341 else 342 *val = (i2c_data & OV9650_HFLIP) >> 5; 343 + PDEBUG(D_V4L2, "Read horizontal flip %d", *val); 344 345 return (err < 0) ? err : 0; 346 } ··· 351 u8 i2c_data; 352 struct sd *sd = (struct sd *) gspca_dev; 353 354 + PDEBUG(D_V4L2, "Set horizontal flip to %d", val); 355 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 356 if (err < 0) 357 goto out; ··· 379 *val = ((i2c_data & 0x10) >> 4) ? 0 : 1; 380 else 381 *val = (i2c_data & 0x10) >> 4; 382 + PDEBUG(D_V4L2, "Read vertical flip %d", *val); 383 384 return (err < 0) ? err : 0; 385 } ··· 390 u8 i2c_data; 391 struct sd *sd = (struct sd *) gspca_dev; 392 393 + PDEBUG(D_V4L2, "Set vertical flip to %d", val); 394 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 395 if (err < 0) 396 goto out; ··· 420 421 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); 422 *val |= i2c_data; 423 + PDEBUG(D_V4L2, "Read gain %d", *val); 424 out: 425 return (err < 0) ? err : 0; 426 } ··· 431 u8 i2c_data; 432 struct sd *sd = (struct sd *) gspca_dev; 433 434 + PDEBUG(D_V4L2, "Set gain to %d", val & 0x3ff); 435 436 /* Read the OV9650_VREF register first to avoid 437 corrupting the VREF high and low bits */ ··· 461 462 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 463 *val = (i2c_data & OV9650_AWB_EN) >> 1; 464 + PDEBUG(D_V4L2, "Read auto white balance %d", *val); 465 466 return (err < 0) ? err : 0; 467 } ··· 472 u8 i2c_data; 473 struct sd *sd = (struct sd *) gspca_dev; 474 475 + PDEBUG(D_V4L2, "Set auto white balance to %d", val); 476 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 477 if (err < 0) 478 goto out; ··· 491 492 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 493 *val = (i2c_data & OV9650_AGC_EN) >> 2; 494 + PDEBUG(D_V4L2, "Read auto gain control %d", *val); 495 496 return (err < 0) ? err : 0; 497 } ··· 502 u8 i2c_data; 503 struct sd *sd = (struct sd *) gspca_dev; 504 505 + PDEBUG(D_V4L2, "Set auto gain control to %d", val); 506 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 507 if (err < 0) 508 goto out;
+1 -2
drivers/media/video/gspca/m5602/m5602_ov9650.h
··· 1 /* 2 * Driver for the ov9650 sensor 3 * 4 - * Copyright (C) 2008 Erik Andren 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 121 /* Kernel module parameters */ 122 extern int force_sensor; 123 extern int dump_sensor; 124 - extern unsigned int m5602_debug; 125 126 int ov9650_probe(struct sd *sd); 127 int ov9650_init(struct sd *sd);
··· 1 /* 2 * Driver for the ov9650 sensor 3 * 4 + * Copyright (C) 2008 Erik Andrén 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 121 /* Kernel module parameters */ 122 extern int force_sensor; 123 extern int dump_sensor; 124 125 int ov9650_probe(struct sd *sd); 126 int ov9650_init(struct sd *sd);
+77 -13
drivers/media/video/gspca/m5602/m5602_po1030.c
··· 1 /* 2 * Driver for the po1030 sensor 3 * 4 - * Copyright (c) 2008 Erik Andren 5 * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 82 for (i = 0; i < len; i++) { 83 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 84 85 - PDEBUG(DBG_TRACE, "Reading sensor register " 86 "0x%x containing 0x%x ", address, *i2c_data); 87 } 88 return (err < 0) ? err : 0; ··· 112 memcpy(p, sensor_urb_skeleton + 16, 4); 113 p[3] = i2c_data[i]; 114 p += 4; 115 - PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 116 address, i2c_data[i]); 117 } 118 ··· 185 &i2c_data, 1); 186 *val |= i2c_data; 187 188 - PDEBUG(DBG_V4L2_CID, "Exposure read as %d", *val); 189 out: 190 return (err < 0) ? err : 0; 191 } ··· 196 u8 i2c_data; 197 int err; 198 199 - PDEBUG(DBG_V4L2, "Set exposure to %d", val & 0xffff); 200 201 i2c_data = ((val & 0xff00) >> 8); 202 - PDEBUG(DBG_V4L2, "Set exposure to high byte to 0x%x", 203 i2c_data); 204 205 err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_H, ··· 208 goto out; 209 210 i2c_data = (val & 0xff); 211 - PDEBUG(DBG_V4L2, "Set exposure to low byte to 0x%x", 212 i2c_data); 213 err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_M, 214 &i2c_data, 1); ··· 226 err = po1030_read_sensor(sd, PO1030_REG_GLOBALGAIN, 227 &i2c_data, 1); 228 *val = i2c_data; 229 - PDEBUG(DBG_V4L2_CID, "Read global gain %d", *val); 230 231 return (err < 0) ? err : 0; 232 } ··· 302 int err; 303 304 i2c_data = val & 0xff; 305 - PDEBUG(DBG_V4L2, "Set global gain to %d", i2c_data); 306 err = po1030_write_sensor(sd, PO1030_REG_GLOBALGAIN, 307 &i2c_data, 1); 308 return (err < 0) ? err : 0; ··· 317 err = po1030_read_sensor(sd, PO1030_REG_RED_GAIN, 318 &i2c_data, 1); 319 *val = i2c_data; 320 - PDEBUG(DBG_V4L2_CID, "Read red gain %d", *val); 321 return (err < 0) ? err : 0; 322 } 323 ··· 328 int err; 329 330 i2c_data = val & 0xff; 331 - PDEBUG(DBG_V4L2, "Set red gain to %d", i2c_data); 332 err = po1030_write_sensor(sd, PO1030_REG_RED_GAIN, 333 &i2c_data, 1); 334 return (err < 0) ? err : 0; ··· 343 err = po1030_read_sensor(sd, PO1030_REG_BLUE_GAIN, 344 &i2c_data, 1); 345 *val = i2c_data; 346 - PDEBUG(DBG_V4L2_CID, "Read blue gain %d", *val); 347 348 return (err < 0) ? err : 0; 349 } ··· 354 u8 i2c_data; 355 int err; 356 i2c_data = val & 0xff; 357 - PDEBUG(DBG_V4L2, "Set blue gain to %d", i2c_data); 358 err = po1030_write_sensor(sd, PO1030_REG_BLUE_GAIN, 359 &i2c_data, 1); 360
··· 1 /* 2 * Driver for the po1030 sensor 3 * 4 + * Copyright (c) 2008 Erik Andrén 5 * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 82 for (i = 0; i < len; i++) { 83 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 84 85 + PDEBUG(D_CONF, "Reading sensor register " 86 "0x%x containing 0x%x ", address, *i2c_data); 87 } 88 return (err < 0) ? err : 0; ··· 112 memcpy(p, sensor_urb_skeleton + 16, 4); 113 p[3] = i2c_data[i]; 114 p += 4; 115 + PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", 116 address, i2c_data[i]); 117 } 118 ··· 185 &i2c_data, 1); 186 *val |= i2c_data; 187 188 + PDEBUG(D_V4L2, "Exposure read as %d", *val); 189 out: 190 return (err < 0) ? err : 0; 191 } ··· 196 u8 i2c_data; 197 int err; 198 199 + PDEBUG(D_V4L2, "Set exposure to %d", val & 0xffff); 200 201 i2c_data = ((val & 0xff00) >> 8); 202 + PDEBUG(D_V4L2, "Set exposure to high byte to 0x%x", 203 i2c_data); 204 205 err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_H, ··· 208 goto out; 209 210 i2c_data = (val & 0xff); 211 + PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x", 212 i2c_data); 213 err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_M, 214 &i2c_data, 1); ··· 226 err = po1030_read_sensor(sd, PO1030_REG_GLOBALGAIN, 227 &i2c_data, 1); 228 *val = i2c_data; 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); 294 295 return (err < 0) ? err : 0; 296 } ··· 238 int err; 239 240 i2c_data = val & 0xff; 241 + PDEBUG(D_V4L2, "Set global gain to %d", i2c_data); 242 err = po1030_write_sensor(sd, PO1030_REG_GLOBALGAIN, 243 &i2c_data, 1); 244 return (err < 0) ? err : 0; ··· 253 err = po1030_read_sensor(sd, PO1030_REG_RED_GAIN, 254 &i2c_data, 1); 255 *val = i2c_data; 256 + PDEBUG(D_V4L2, "Read red gain %d", *val); 257 return (err < 0) ? err : 0; 258 } 259 ··· 264 int err; 265 266 i2c_data = val & 0xff; 267 + PDEBUG(D_V4L2, "Set red gain to %d", i2c_data); 268 err = po1030_write_sensor(sd, PO1030_REG_RED_GAIN, 269 &i2c_data, 1); 270 return (err < 0) ? err : 0; ··· 279 err = po1030_read_sensor(sd, PO1030_REG_BLUE_GAIN, 280 &i2c_data, 1); 281 *val = i2c_data; 282 + PDEBUG(D_V4L2, "Read blue gain %d", *val); 283 284 return (err < 0) ? err : 0; 285 } ··· 290 u8 i2c_data; 291 int err; 292 i2c_data = val & 0xff; 293 + PDEBUG(D_V4L2, "Set blue gain to %d", i2c_data); 294 err = po1030_write_sensor(sd, PO1030_REG_BLUE_GAIN, 295 &i2c_data, 1); 296
+38 -8
drivers/media/video/gspca/m5602/m5602_po1030.h
··· 1 /* 2 * Driver for the po1030 sensor. 3 - * This is probably a pixel plus sensor but we haven't identified it yet 4 * 5 - * Copyright (c) 2008 Erik Andren 6 * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 7 * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 8 * ··· 108 #define PO1030_REG_YCONTRAST 0x74 109 #define PO1030_REG_YSATURATION 0x75 110 111 /*****************************************************************************/ 112 113 #define PO1030_GLOBAL_GAIN_DEFAULT 0x12 114 - #define PO1030_EXPOSURE_DEFAULT 0xf0ff 115 #define PO1030_BLUE_GAIN_DEFAULT 0x40 116 #define PO1030_RED_GAIN_DEFAULT 0x40 117 ··· 123 /* Kernel module parameters */ 124 extern int force_sensor; 125 extern int dump_sensor; 126 - extern unsigned int m5602_debug; 127 128 int po1030_probe(struct sd *sd); 129 int po1030_init(struct sd *sd); ··· 143 int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val); 144 int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val); 145 int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val); 146 147 static struct m5602_sensor po1030 = { 148 .name = "PO1030", ··· 157 .init = po1030_init, 158 .power_down = po1030_power_down, 159 160 - .nctrls = 4, 161 .ctrls = { 162 { 163 { ··· 165 .type = V4L2_CTRL_TYPE_INTEGER, 166 .name = "gain", 167 .minimum = 0x00, 168 - .maximum = 0xff, 169 .step = 0x1, 170 .default_value = PO1030_GLOBAL_GAIN_DEFAULT, 171 .flags = V4L2_CTRL_FLAG_SLIDER ··· 178 .type = V4L2_CTRL_TYPE_INTEGER, 179 .name = "exposure", 180 .minimum = 0x00, 181 - .maximum = 0xffff, 182 .step = 0x1, 183 .default_value = PO1030_EXPOSURE_DEFAULT, 184 .flags = V4L2_CTRL_FLAG_SLIDER ··· 211 }, 212 .set = po1030_set_blue_balance, 213 .get = po1030_get_blue_balance 214 } 215 }, 216 .nmodes = 1, 217 .modes = { 218 { ··· 411 412 /* Set the y window to 1 */ 413 {SENSOR, PO1030_REG_WINDOWY_H, 0x00}, 414 - {SENSOR, PO1030_REG_WINDOWX_L, 0x01}, 415 416 {SENSOR, PO1030_REG_WINDOWWIDTH_H, 0x02}, 417 {SENSOR, PO1030_REG_WINDOWWIDTH_L, 0x87},
··· 1 /* 2 * Driver for the po1030 sensor. 3 * 4 + * Copyright (c) 2008 Erik Andrén 5 * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 109 #define PO1030_REG_YCONTRAST 0x74 110 #define PO1030_REG_YSATURATION 0x75 111 112 + #define PO1030_HFLIP (1 << 7) 113 + #define PO1030_VFLIP (1 << 6) 114 + 115 /*****************************************************************************/ 116 117 #define PO1030_GLOBAL_GAIN_DEFAULT 0x12 118 + #define PO1030_EXPOSURE_DEFAULT 0x0085 119 #define PO1030_BLUE_GAIN_DEFAULT 0x40 120 #define PO1030_RED_GAIN_DEFAULT 0x40 121 ··· 121 /* Kernel module parameters */ 122 extern int force_sensor; 123 extern int dump_sensor; 124 125 int po1030_probe(struct sd *sd); 126 int po1030_init(struct sd *sd); ··· 142 int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val); 143 int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val); 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); 149 150 static struct m5602_sensor po1030 = { 151 .name = "PO1030", ··· 152 .init = po1030_init, 153 .power_down = po1030_power_down, 154 155 + .nctrls = 6, 156 .ctrls = { 157 { 158 { ··· 160 .type = V4L2_CTRL_TYPE_INTEGER, 161 .name = "gain", 162 .minimum = 0x00, 163 + .maximum = 0x4f, 164 .step = 0x1, 165 .default_value = PO1030_GLOBAL_GAIN_DEFAULT, 166 .flags = V4L2_CTRL_FLAG_SLIDER ··· 173 .type = V4L2_CTRL_TYPE_INTEGER, 174 .name = "exposure", 175 .minimum = 0x00, 176 + .maximum = 0x02ff, 177 .step = 0x1, 178 .default_value = PO1030_EXPOSURE_DEFAULT, 179 .flags = V4L2_CTRL_FLAG_SLIDER ··· 206 }, 207 .set = po1030_set_blue_balance, 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 233 } 234 }, 235 + 236 .nmodes = 1, 237 .modes = { 238 { ··· 381 382 /* Set the y window to 1 */ 383 {SENSOR, PO1030_REG_WINDOWY_H, 0x00}, 384 + {SENSOR, PO1030_REG_WINDOWY_L, 0x01}, 385 386 {SENSOR, PO1030_REG_WINDOWWIDTH_H, 0x02}, 387 {SENSOR, PO1030_REG_WINDOWWIDTH_L, 0x87},
+11 -11
drivers/media/video/gspca/m5602/m5602_s5k4aa.c
··· 1 /* 2 * Driver for the s5k4aa sensor 3 * 4 - * Copyright (C) 2008 Erik Andren 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 117 for (i = 0; (i < len) & !err; i++) { 118 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 119 120 - PDEBUG(DBG_TRACE, "Reading sensor register " 121 "0x%x containing 0x%x ", address, *i2c_data); 122 } 123 out: ··· 150 memcpy(p, sensor_urb_skeleton + 16, 4); 151 p[3] = i2c_data[i]; 152 p += 4; 153 - PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 154 address, i2c_data[i]); 155 } 156 ··· 248 *val = data << 8; 249 err = s5k4aa_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); 250 *val |= data; 251 - PDEBUG(DBG_V4L2_CID, "Read exposure %d", *val); 252 out: 253 return (err < 0) ? err : 0; 254 } ··· 259 u8 data = S5K4AA_PAGE_MAP_2; 260 int err; 261 262 - PDEBUG(DBG_V4L2_CID, "Set exposure to %d", val); 263 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 264 if (err < 0) 265 goto out; ··· 285 286 err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 287 *val = (data & S5K4AA_RM_V_FLIP) >> 7; 288 - PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); 289 290 out: 291 return (err < 0) ? err : 0; ··· 297 u8 data = S5K4AA_PAGE_MAP_2; 298 int err; 299 300 - PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); 301 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 302 if (err < 0) 303 goto out; ··· 341 342 err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 343 *val = (data & S5K4AA_RM_H_FLIP) >> 6; 344 - PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); 345 out: 346 return (err < 0) ? err : 0; 347 } ··· 352 u8 data = S5K4AA_PAGE_MAP_2; 353 int err; 354 355 - PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", 356 val); 357 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 358 if (err < 0) ··· 397 398 err = s5k4aa_read_sensor(sd, S5K4AA_GAIN_2, &data, 1); 399 *val = data; 400 - PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 401 402 out: 403 return (err < 0) ? err : 0; ··· 409 u8 data = S5K4AA_PAGE_MAP_2; 410 int err; 411 412 - PDEBUG(DBG_V4L2_CID, "Set gain to %d", val); 413 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 414 if (err < 0) 415 goto out;
··· 1 /* 2 * Driver for the s5k4aa sensor 3 * 4 + * Copyright (C) 2008 Erik Andrén 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 117 for (i = 0; (i < len) & !err; i++) { 118 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 119 120 + PDEBUG(D_CONF, "Reading sensor register " 121 "0x%x containing 0x%x ", address, *i2c_data); 122 } 123 out: ··· 150 memcpy(p, sensor_urb_skeleton + 16, 4); 151 p[3] = i2c_data[i]; 152 p += 4; 153 + PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", 154 address, i2c_data[i]); 155 } 156 ··· 248 *val = data << 8; 249 err = s5k4aa_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); 250 *val |= data; 251 + PDEBUG(D_V4L2, "Read exposure %d", *val); 252 out: 253 return (err < 0) ? err : 0; 254 } ··· 259 u8 data = S5K4AA_PAGE_MAP_2; 260 int err; 261 262 + PDEBUG(D_V4L2, "Set exposure to %d", val); 263 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 264 if (err < 0) 265 goto out; ··· 285 286 err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 287 *val = (data & S5K4AA_RM_V_FLIP) >> 7; 288 + PDEBUG(D_V4L2, "Read vertical flip %d", *val); 289 290 out: 291 return (err < 0) ? err : 0; ··· 297 u8 data = S5K4AA_PAGE_MAP_2; 298 int err; 299 300 + PDEBUG(D_V4L2, "Set vertical flip to %d", val); 301 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 302 if (err < 0) 303 goto out; ··· 341 342 err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 343 *val = (data & S5K4AA_RM_H_FLIP) >> 6; 344 + PDEBUG(D_V4L2, "Read horizontal flip %d", *val); 345 out: 346 return (err < 0) ? err : 0; 347 } ··· 352 u8 data = S5K4AA_PAGE_MAP_2; 353 int err; 354 355 + PDEBUG(D_V4L2, "Set horizontal flip to %d", 356 val); 357 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 358 if (err < 0) ··· 397 398 err = s5k4aa_read_sensor(sd, S5K4AA_GAIN_2, &data, 1); 399 *val = data; 400 + PDEBUG(D_V4L2, "Read gain %d", *val); 401 402 out: 403 return (err < 0) ? err : 0; ··· 409 u8 data = S5K4AA_PAGE_MAP_2; 410 int err; 411 412 + PDEBUG(D_V4L2, "Set gain to %d", val); 413 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 414 if (err < 0) 415 goto out;
+1 -2
drivers/media/video/gspca/m5602/m5602_s5k4aa.h
··· 1 /* 2 * Driver for the s5k4aa sensor 3 * 4 - * Copyright (C) 2008 Erik Andren 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 63 /* Kernel module parameters */ 64 extern int force_sensor; 65 extern int dump_sensor; 66 - extern unsigned int m5602_debug; 67 68 int s5k4aa_probe(struct sd *sd); 69 int s5k4aa_init(struct sd *sd);
··· 1 /* 2 * Driver for the s5k4aa sensor 3 * 4 + * Copyright (C) 2008 Erik Andrén 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 63 /* Kernel module parameters */ 64 extern int force_sensor; 65 extern int dump_sensor; 66 67 int s5k4aa_probe(struct sd *sd); 68 int s5k4aa_init(struct sd *sd);
+3 -3
drivers/media/video/gspca/m5602/m5602_s5k83a.c
··· 1 /* 2 * Driver for the s5k83a sensor 3 * 4 - * Copyright (C) 2008 Erik Andren 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 101 for (i = 0; i < len && !len; i++) { 102 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 103 104 - PDEBUG(DBG_TRACE, "Reading sensor register " 105 "0x%x containing 0x%x ", address, *i2c_data); 106 } 107 ··· 135 memcpy(p, sensor_urb_skeleton + 16, 4); 136 p[3] = i2c_data[i]; 137 p += 4; 138 - PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 139 address, i2c_data[i]); 140 } 141
··· 1 /* 2 * Driver for the s5k83a sensor 3 * 4 + * Copyright (C) 2008 Erik Andrén 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 101 for (i = 0; i < len && !len; i++) { 102 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 103 104 + PDEBUG(D_CONF, "Reading sensor register " 105 "0x%x containing 0x%x ", address, *i2c_data); 106 } 107 ··· 135 memcpy(p, sensor_urb_skeleton + 16, 4); 136 p[3] = i2c_data[i]; 137 p += 4; 138 + PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", 139 address, i2c_data[i]); 140 } 141
+1 -3
drivers/media/video/gspca/m5602/m5602_s5k83a.h
··· 1 /* 2 * Driver for the s5k83a sensor 3 * 4 - * Copyright (C) 2008 Erik Andren 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 41 /* Kernel module parameters */ 42 extern int force_sensor; 43 extern int dump_sensor; 44 - extern unsigned int m5602_debug; 45 - 46 47 int s5k83a_probe(struct sd *sd); 48 int s5k83a_init(struct sd *sd);
··· 1 /* 2 * Driver for the s5k83a sensor 3 * 4 + * Copyright (C) 2008 Erik Andrén 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 * ··· 41 /* Kernel module parameters */ 42 extern int force_sensor; 43 extern int dump_sensor; 44 45 int s5k83a_probe(struct sd *sd); 46 int s5k83a_init(struct sd *sd);
+1 -1
drivers/media/video/gspca/m5602/m5602_sensor.h
··· 1 /* 2 * USB Driver for ALi m5602 based webcams 3 * 4 - * Copyright (C) 2008 Erik Andren 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 *
··· 1 /* 2 * USB Driver for ALi m5602 based webcams 3 * 4 + * Copyright (C) 2008 Erik Andrén 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 7 *
+238 -135
drivers/media/video/gspca/t613.c
··· 50 51 __u8 sensor; 52 #define SENSOR_TAS5130A 0 53 - #define SENSOR_OTHER 1 54 }; 55 56 /* V4L2 controls supported by the driver */ ··· 188 .minimum = 0, 189 .maximum = 1, 190 .step = 1, 191 - .default_value = 1, 192 }, 193 .set = sd_setwhitebalance, 194 .get = sd_getwhitebalance ··· 259 .sizeimage = 640 * 480 * 3 / 8 + 590, 260 .colorspace = V4L2_COLORSPACE_JPEG, 261 .priv = 0}, 262 }; 263 264 #define MAX_EFFECTS 7 ··· 418 {}, 419 }; 420 421 /* read 1 byte */ 422 static int reg_r(struct gspca_dev *gspca_dev, 423 __u16 index) ··· 440 usb_control_msg(gspca_dev->dev, 441 usb_sndctrlpipe(gspca_dev->dev, 0), 442 0, 443 - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 444 0, index, 445 NULL, 0, 500); 446 } 447 448 - static void i2c_w(struct gspca_dev *gspca_dev, 449 const __u8 *buffer, __u16 len) 450 { 451 if (len <= USB_BUF_SZ) { ··· 453 usb_control_msg(gspca_dev->dev, 454 usb_sndctrlpipe(gspca_dev->dev, 0), 455 0, 456 - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 457 0x01, 0, 458 gspca_dev->usb_buf, len, 500); 459 } else { ··· 464 usb_control_msg(gspca_dev->dev, 465 usb_sndctrlpipe(gspca_dev->dev, 0), 466 0, 467 - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 468 0x01, 0, 469 tmpbuf, len, 500); 470 kfree(tmpbuf); 471 } 472 } 473 474 - static void other_sensor_init(struct gspca_dev *gspca_dev) 475 { 476 int i; 477 const __u8 *p; ··· 492 0x90, 0x24, 493 0x91, 0xb2, 494 0x82, 0x32, 495 - 0xfd, 0x00, 496 - 0xfd, 0x01, 497 0xfd, 0x41, 498 0x00 /* table end */ 499 }; 500 501 p = sensor_init; 502 while (*p != 0) { ··· 517 val[3] = *p++; 518 if (*p == 0) 519 reg_w(gspca_dev, 0x3c80); 520 - i2c_w(gspca_dev, val, sizeof val); 521 i = 4; 522 while (--i >= 0) { 523 msleep(15); ··· 526 break; 527 } 528 } 529 - reg_w(gspca_dev, 0x3c80); 530 } 531 532 /* this function is called at probe time */ ··· 555 return 0; 556 } 557 558 static void setgamma(struct gspca_dev *gspca_dev) 559 { 560 struct sd *sd = (struct sd *) gspca_dev; 561 562 PDEBUG(D_CONF, "Gamma: %d", sd->gamma); 563 - i2c_w(gspca_dev, gamma_table[sd->gamma], sizeof gamma_table[0]); 564 } 565 566 /* this function is called at probe and resume time */ ··· 644 {0x08, 0x03, 0x09, 0x03, 0x12, 0x04}; 645 static const __u8 n2[] = 646 {0x08, 0x00}; 647 - static const __u8 nset[] = 648 - { 0x61, 0x68, 0x62, 0xff, 0x60, 0x07 }; 649 static const __u8 n3[] = 650 {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04}; 651 static const __u8 n4[] = ··· 656 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68, 657 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40, 658 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 static const __u8 nset9[4] = 682 { 0x0b, 0x04, 0x0a, 0x78 }; 683 static const __u8 nset8[6] = 684 { 0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00 }; 685 - static const __u8 nset10[6] = 686 - { 0x0c, 0x03, 0xab, 0x10, 0x81, 0x20 }; 687 688 byte = reg_r(gspca_dev, 0x06); 689 test_byte = reg_r(gspca_dev, 0x07); 690 if (byte == 0x08 && test_byte == 0x07) { 691 - PDEBUG(D_CONF, "other sensor"); 692 - sd->sensor = SENSOR_OTHER; 693 } else { 694 - PDEBUG(D_CONF, "sensor %02x %02x", byte, test_byte); 695 sd->sensor = SENSOR_TAS5130A; 696 } 697 698 - i2c_w(gspca_dev, n1, sizeof n1); 699 test_byte = 0; 700 i = 5; 701 while (--i >= 0) { 702 - i2c_w(gspca_dev, nset, sizeof nset); 703 - msleep(5); 704 test_byte = reg_r(gspca_dev, 0x0063); 705 msleep(100); 706 if (test_byte == 0x17) ··· 689 /* return -EIO; */ 690 /*fixme: test - continue */ 691 } 692 - i2c_w(gspca_dev, n2, sizeof n2); 693 694 i = 0; 695 while (read_indexs[i] != 0x00) { ··· 699 i++; 700 } 701 702 - i2c_w(gspca_dev, n3, sizeof n3); 703 - i2c_w(gspca_dev, n4, sizeof n4); 704 reg_r(gspca_dev, 0x0080); 705 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); 709 reg_w(gspca_dev, 0x3880); 710 reg_w(gspca_dev, 0x3880); 711 reg_w(gspca_dev, 0x338e); 712 - i2c_w(gspca_dev, nset5, sizeof nset5); 713 - reg_w(gspca_dev, 0x00a9); 714 setgamma(gspca_dev); 715 - reg_w(gspca_dev, 0x86bb); 716 - reg_w(gspca_dev, 0x4aa6); 717 718 - i2c_w(gspca_dev, missing, sizeof missing); 719 - 720 - reg_w(gspca_dev, 0x2087); 721 reg_w(gspca_dev, 0x2088); 722 reg_w(gspca_dev, 0x2089); 723 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); 728 729 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); 733 734 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 } 753 754 static void setflip(struct gspca_dev *gspca_dev) ··· 754 if (sd->mirror) 755 flipcmd[3] = 0x01; 756 757 - i2c_w(gspca_dev, flipcmd, sizeof flipcmd); 758 } 759 760 static void seteffect(struct gspca_dev *gspca_dev) 761 { 762 struct sd *sd = (struct sd *) gspca_dev; 763 764 - i2c_w(gspca_dev, effects_table[sd->effect], sizeof effects_table[0]); 765 if (sd->effect == 1 || sd->effect == 5) { 766 PDEBUG(D_CONF, 767 "This effect have been disabled for webcam \"safety\""); ··· 775 reg_w(gspca_dev, 0xfaa6); 776 } 777 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 static void setlightfreq(struct gspca_dev *gspca_dev) 792 { 793 struct sd *sd = (struct sd *) gspca_dev; ··· 783 if (sd->freq == 2) /* 60hz */ 784 freq[1] = 0x00; 785 786 - i2c_w(gspca_dev, freq, sizeof freq); 787 } 788 789 - static void setcontrast(struct gspca_dev *gspca_dev) 790 { 791 struct sd *sd = (struct sd *) gspca_dev; 792 - unsigned int contrast = sd->contrast; 793 - __u16 reg_to_write; 794 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); 820 } 821 822 static int sd_start(struct gspca_dev *gspca_dev) 823 { 824 struct sd *sd = (struct sd *) gspca_dev; 825 int i, mode; 826 - static const __u8 t1[] = { 0x66, 0x00, 0xa8, 0xe8 }; 827 __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 }; 828 static const __u8 t3[] = 829 { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06, 830 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 }; 831 - static const __u8 t4[] = { 0x0b, 0x04, 0x0a, 0x40 }; 832 833 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv; 834 switch (mode) { ··· 845 if (sd->sensor == SENSOR_TAS5130A) { 846 i = 0; 847 while (tas5130a_sensor_init[i][0] != 0) { 848 - i2c_w(gspca_dev, tas5130a_sensor_init[i], 849 sizeof tas5130a_sensor_init[0]); 850 i++; 851 } 852 reg_w(gspca_dev, 0x3c80); 853 /* just in case and to keep sync with logs (for mine) */ 854 - i2c_w(gspca_dev, tas5130a_sensor_init[3], 855 sizeof tas5130a_sensor_init[0]); 856 reg_w(gspca_dev, 0x3c80); 857 } else { 858 - other_sensor_init(gspca_dev); 859 } 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); 863 reg_r(gspca_dev, 0x0012); 864 - i2c_w(gspca_dev, t3, sizeof t3); 865 reg_w(gspca_dev, 0x0013); 866 - i2c_w(gspca_dev, t4, sizeof t4); 867 /* restart on each start, just in case, sometimes regs goes wrong 868 * when using controls from app */ 869 setbrightness(gspca_dev); 870 setcontrast(gspca_dev); 871 setcolors(gspca_dev); 872 return 0; 873 } 874 875 static void sd_pkt_scan(struct gspca_dev *gspca_dev, ··· 1138 .config = sd_config, 1139 .init = sd_init, 1140 .start = sd_start, 1141 .pkt_scan = sd_pkt_scan, 1142 .querymenu = sd_querymenu, 1143 };
··· 50 51 __u8 sensor; 52 #define SENSOR_TAS5130A 0 53 + #define SENSOR_OM6802 1 54 }; 55 56 /* V4L2 controls supported by the driver */ ··· 188 .minimum = 0, 189 .maximum = 1, 190 .step = 1, 191 + .default_value = 0, 192 }, 193 .set = sd_setwhitebalance, 194 .get = sd_getwhitebalance ··· 259 .sizeimage = 640 * 480 * 3 / 8 + 590, 260 .colorspace = V4L2_COLORSPACE_JPEG, 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 + } 315 }; 316 317 #define MAX_EFFECTS 7 ··· 365 {}, 366 }; 367 368 + static __u8 sensor_reset[] = {0x61, 0x68, 0x62, 0xff, 0x60, 0x07}; 369 + 370 /* read 1 byte */ 371 static int reg_r(struct gspca_dev *gspca_dev, 372 __u16 index) ··· 385 usb_control_msg(gspca_dev->dev, 386 usb_sndctrlpipe(gspca_dev->dev, 0), 387 0, 388 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 389 0, index, 390 NULL, 0, 500); 391 } 392 393 + static void reg_w_buf(struct gspca_dev *gspca_dev, 394 const __u8 *buffer, __u16 len) 395 { 396 if (len <= USB_BUF_SZ) { ··· 398 usb_control_msg(gspca_dev->dev, 399 usb_sndctrlpipe(gspca_dev->dev, 0), 400 0, 401 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 402 0x01, 0, 403 gspca_dev->usb_buf, len, 500); 404 } else { ··· 409 usb_control_msg(gspca_dev->dev, 410 usb_sndctrlpipe(gspca_dev->dev, 0), 411 0, 412 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 413 0x01, 0, 414 tmpbuf, len, 500); 415 kfree(tmpbuf); 416 } 417 } 418 419 + /* Reported as OM6802*/ 420 + static void om6802_sensor_init(struct gspca_dev *gspca_dev) 421 { 422 int i; 423 const __u8 *p; ··· 436 0x90, 0x24, 437 0x91, 0xb2, 438 0x82, 0x32, 439 0xfd, 0x41, 440 0x00 /* table end */ 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 + } 457 458 p = sensor_init; 459 while (*p != 0) { ··· 448 val[3] = *p++; 449 if (*p == 0) 450 reg_w(gspca_dev, 0x3c80); 451 + reg_w_buf(gspca_dev, val, sizeof val); 452 i = 4; 453 while (--i >= 0) { 454 msleep(15); ··· 457 break; 458 } 459 } 460 + msleep(15); 461 + reg_w(gspca_dev, 0x3c80); 462 } 463 464 /* this function is called at probe time */ ··· 485 return 0; 486 } 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 + 528 static void setgamma(struct gspca_dev *gspca_dev) 529 { 530 struct sd *sd = (struct sd *) gspca_dev; 531 532 PDEBUG(D_CONF, "Gamma: %d", sd->gamma); 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); 557 } 558 559 /* this function is called at probe and resume time */ ··· 511 {0x08, 0x03, 0x09, 0x03, 0x12, 0x04}; 512 static const __u8 n2[] = 513 {0x08, 0x00}; 514 static const __u8 n3[] = 515 {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04}; 516 static const __u8 n4[] = ··· 525 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68, 526 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40, 527 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46}; 528 static const __u8 nset9[4] = 529 { 0x0b, 0x04, 0x0a, 0x78 }; 530 static const __u8 nset8[6] = 531 { 0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00 }; 532 533 byte = reg_r(gspca_dev, 0x06); 534 test_byte = reg_r(gspca_dev, 0x07); 535 if (byte == 0x08 && test_byte == 0x07) { 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; 541 } else { 542 + PDEBUG(D_CONF, "unknown sensor %02x %02x", byte, test_byte); 543 sd->sensor = SENSOR_TAS5130A; 544 } 545 546 + reg_w_buf(gspca_dev, n1, sizeof n1); 547 test_byte = 0; 548 i = 5; 549 while (--i >= 0) { 550 + reg_w_buf(gspca_dev, sensor_reset, sizeof sensor_reset); 551 test_byte = reg_r(gspca_dev, 0x0063); 552 msleep(100); 553 if (test_byte == 0x17) ··· 580 /* return -EIO; */ 581 /*fixme: test - continue */ 582 } 583 + reg_w_buf(gspca_dev, n2, sizeof n2); 584 585 i = 0; 586 while (read_indexs[i] != 0x00) { ··· 590 i++; 591 } 592 593 + reg_w_buf(gspca_dev, n3, sizeof n3); 594 + reg_w_buf(gspca_dev, n4, sizeof n4); 595 reg_r(gspca_dev, 0x0080); 596 reg_w(gspca_dev, 0x2c80); 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 + 605 reg_w(gspca_dev, 0x3880); 606 reg_w(gspca_dev, 0x3880); 607 reg_w(gspca_dev, 0x338e); 608 + 609 + setbrightness(gspca_dev); 610 + setcontrast(gspca_dev); 611 setgamma(gspca_dev); 612 + setcolors(gspca_dev); 613 + setsharpness(gspca_dev); 614 + setwhitebalance(gspca_dev); 615 616 + reg_w(gspca_dev, 0x2087); /* tied to white balance? */ 617 reg_w(gspca_dev, 0x2088); 618 reg_w(gspca_dev, 0x2089); 619 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); 626 627 reg_w(gspca_dev, 0x2880); 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); 635 636 return 0; 637 } 638 639 static void setflip(struct gspca_dev *gspca_dev) ··· 651 if (sd->mirror) 652 flipcmd[3] = 0x01; 653 654 + reg_w_buf(gspca_dev, flipcmd, sizeof flipcmd); 655 } 656 657 static void seteffect(struct gspca_dev *gspca_dev) 658 { 659 struct sd *sd = (struct sd *) gspca_dev; 660 661 + reg_w_buf(gspca_dev, effects_table[sd->effect], 662 + sizeof effects_table[0]); 663 if (sd->effect == 1 || sd->effect == 5) { 664 PDEBUG(D_CONF, 665 "This effect have been disabled for webcam \"safety\""); ··· 671 reg_w(gspca_dev, 0xfaa6); 672 } 673 674 static void setlightfreq(struct gspca_dev *gspca_dev) 675 { 676 struct sd *sd = (struct sd *) gspca_dev; ··· 692 if (sd->freq == 2) /* 60hz */ 693 freq[1] = 0x00; 694 695 + reg_w_buf(gspca_dev, freq, sizeof freq); 696 } 697 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) 701 { 702 struct sd *sd = (struct sd *) gspca_dev; 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}; 717 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 + } 725 } 726 727 static int sd_start(struct gspca_dev *gspca_dev) 728 { 729 struct sd *sd = (struct sd *) gspca_dev; 730 int i, mode; 731 __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 }; 732 static const __u8 t3[] = 733 { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06, 734 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 }; 735 736 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv; 737 switch (mode) { ··· 760 if (sd->sensor == SENSOR_TAS5130A) { 761 i = 0; 762 while (tas5130a_sensor_init[i][0] != 0) { 763 + reg_w_buf(gspca_dev, tas5130a_sensor_init[i], 764 sizeof tas5130a_sensor_init[0]); 765 i++; 766 } 767 reg_w(gspca_dev, 0x3c80); 768 /* just in case and to keep sync with logs (for mine) */ 769 + reg_w_buf(gspca_dev, tas5130a_sensor_init[3], 770 sizeof tas5130a_sensor_init[0]); 771 reg_w(gspca_dev, 0x3c80); 772 } else { 773 + om6802_sensor_init(gspca_dev); 774 } 775 + reg_w_buf(gspca_dev, sensor_data[sd->sensor].data4, 776 + sizeof sensor_data[sd->sensor].data4); 777 reg_r(gspca_dev, 0x0012); 778 + reg_w_buf(gspca_dev, t2, sizeof t2); 779 + reg_w_buf(gspca_dev, t3, sizeof t3); 780 reg_w(gspca_dev, 0x0013); 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 + 786 /* restart on each start, just in case, sometimes regs goes wrong 787 * when using controls from app */ 788 setbrightness(gspca_dev); 789 setcontrast(gspca_dev); 790 setcolors(gspca_dev); 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); 805 } 806 807 static void sd_pkt_scan(struct gspca_dev *gspca_dev, ··· 1036 .config = sd_config, 1037 .init = sd_init, 1038 .start = sd_start, 1039 + .stopN = sd_stopN, 1040 .pkt_scan = sd_pkt_scan, 1041 .querymenu = sd_querymenu, 1042 };
+8 -7
drivers/media/video/ivtv/ivtv-fileops.c
··· 600 since we may get here before the stream has been fully set-up */ 601 if (mode == OUT_YUV && s->q_full.length == 0 && itv->dma_data_req_size) { 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 - } 610 } 611 if (count == 0) { 612 IVTV_DEBUG_HI_FILE("Wrote %d bytes to %s (%d)\n", bytes_written, s->name, s->q_full.bytesused);
··· 600 since we may get here before the stream has been fully set-up */ 601 if (mode == OUT_YUV && s->q_full.length == 0 && itv->dma_data_req_size) { 602 while (count >= itv->dma_data_req_size) { 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; 611 } 612 if (count == 0) { 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 static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt) 510 { 511 struct ivtv_open_id *id = fh; 512 - struct ivtv *itv = id->itv; 513 s32 w = fmt->fmt.pix.width; 514 s32 h = fmt->fmt.pix.height; 515 int field = fmt->fmt.pix.field; ··· 516 517 w = min(w, 720); 518 w = max(w, 2); 519 - h = min(h, itv->is_out_50hz ? 576 : 480); 520 h = max(h, 2); 521 if (id->type == IVTV_DEC_STREAM_TYPE_YUV) 522 fmt->fmt.pix.field = field;
··· 509 static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt) 510 { 511 struct ivtv_open_id *id = fh; 512 s32 w = fmt->fmt.pix.width; 513 s32 h = fmt->fmt.pix.height; 514 int field = fmt->fmt.pix.field; ··· 517 518 w = min(w, 720); 519 w = max(w, 2); 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); 536 h = max(h, 2); 537 if (id->type == IVTV_DEC_STREAM_TYPE_YUV) 538 fmt->fmt.pix.field = field;
+212 -264
drivers/media/video/ks0127.c
··· 33 * V1.1 Gerard v.d. Horst Added some debugoutput, reset the video-standard 34 */ 35 36 - #ifndef __KERNEL__ 37 - #define __KERNEL__ 38 - #endif 39 - 40 #include <linux/init.h> 41 #include <linux/module.h> 42 #include <linux/delay.h> 43 #include <linux/errno.h> 44 #include <linux/kernel.h> 45 - #include <linux/slab.h> 46 - #include <linux/proc_fs.h> 47 - #include "ks0127.h" 48 - 49 #include <linux/i2c.h> 50 #include <linux/video_decoder.h> 51 52 - #define dprintk if (debug) printk 53 - 54 - /* i2c identification */ 55 - #define I2C_KS0127_ADDON 0xD8 56 - #define I2C_KS0127_ONBOARD 0xDA 57 58 #define KS_TYPE_UNKNOWN 0 59 #define KS_TYPE_0122S 1 ··· 197 }; 198 199 struct ks0127 { 200 - struct i2c_client *client; 201 - unsigned char addr; 202 int format_width; 203 int format_height; 204 int cap_width; ··· 211 212 module_param(debug, int, 0); 213 MODULE_PARM_DESC(debug, "Debug output"); 214 - MODULE_LICENSE("GPL"); 215 216 static u8 reg_defaults[64]; 217 218 - 219 - 220 static void init_reg_defaults(void) 221 { 222 u8 *table = reg_defaults; 223 224 table[KS_CMDA] = 0x2c; /* VSE=0, CCIR 601, autodetect standard */ 225 table[KS_CMDB] = 0x12; /* VALIGN=0, AGC control and input */ ··· 301 * An explanation from kayork@mail.utexas.edu: 302 * 303 * During I2C reads, the KS0127 only samples for a stop condition 304 - * during the place where the acknoledge bit should be. Any standard 305 * I2C implementation (correctly) throws in another clock transition 306 * at the 9th bit, and the KS0127 will not recognize the stop condition 307 * and will continue to clock out data. 308 * 309 * So we have to do the read ourself. Big deal. 310 - workaround in i2c-algo-bit 311 */ 312 313 314 - static u8 ks0127_read(struct ks0127 *ks, u8 reg) 315 { 316 - struct i2c_client *c = ks->client; 317 char val = 0; 318 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}}; 321 int ret; 322 323 ret = i2c_transfer(c->adapter, msgs, ARRAY_SIZE(msgs)); 324 if (ret != ARRAY_SIZE(msgs)) 325 - dprintk("ks0127_write error\n"); 326 327 return val; 328 } 329 330 331 - static void ks0127_write(struct ks0127 *ks, u8 reg, u8 val) 332 { 333 - char msg[] = {reg, val}; 334 335 - if (i2c_master_send(ks->client, msg, sizeof(msg)) != sizeof(msg)) 336 - dprintk("ks0127_write error\n"); 337 338 ks->regs[reg] = val; 339 } 340 341 342 /* generic bit-twiddling */ 343 - static void ks0127_and_or(struct ks0127 *ks, u8 reg, u8 and_v, u8 or_v) 344 { 345 u8 val = ks->regs[reg]; 346 val = (val & and_v) | or_v; 347 - ks0127_write(ks, reg, val); 348 } 349 350 ··· 355 /**************************************************************************** 356 * ks0127 private api 357 ****************************************************************************/ 358 - static void ks0127_reset(struct ks0127* ks) 359 { 360 - int i; 361 u8 *table = reg_defaults; 362 363 ks->ks_type = KS_TYPE_UNKNOWN; 364 365 - dprintk("ks0127: reset\n"); 366 msleep(1); 367 368 /* initialize all registers to known values */ 369 /* (except STAT, 0x21, 0x22, TEST and 0x38,0x39) */ 370 371 - for(i = 1; i < 33; i++) 372 - ks0127_write(ks, i, table[i]); 373 374 - for(i = 35; i < 40; i++) 375 - ks0127_write(ks, i, table[i]); 376 377 - for(i = 41; i < 56; i++) 378 - ks0127_write(ks, i, table[i]); 379 380 - for(i = 58; i < 64; i++) 381 - ks0127_write(ks, i, table[i]); 382 383 384 - if ((ks0127_read(ks, KS_STAT) & 0x80) == 0) { 385 ks->ks_type = KS_TYPE_0122S; 386 - dprintk("ks0127: ks0122s Found\n"); 387 return; 388 } 389 390 - switch(ks0127_read(ks, KS_CMDE) & 0x0f) { 391 - 392 case 0: 393 ks->ks_type = KS_TYPE_0127; 394 - dprintk("ks0127: ks0127 found\n"); 395 break; 396 397 case 9: 398 ks->ks_type = KS_TYPE_0127B; 399 - dprintk("ks0127: ks0127B Revision A found\n"); 400 break; 401 402 default: 403 - dprintk("ks0127: unknown revision\n"); 404 break; 405 } 406 } 407 408 - static int ks0127_command(struct i2c_client *client, 409 - unsigned int cmd, void *arg) 410 { 411 - struct ks0127 *ks = i2c_get_clientdata(client); 412 - 413 - int *iarg = (int*)arg; 414 - 415 int status; 416 417 if (!ks) 418 return -ENODEV; 419 420 switch (cmd) { 421 - 422 case DECODER_INIT: 423 - dprintk("ks0127: command DECODER_INIT\n"); 424 - ks0127_reset(ks); 425 break; 426 427 case DECODER_SET_INPUT: ··· 428 case KS_INPUT_COMPOSITE_4: 429 case KS_INPUT_COMPOSITE_5: 430 case KS_INPUT_COMPOSITE_6: 431 - dprintk("ks0127: command DECODER_SET_INPUT %d: " 432 - "Composite\n", *iarg); 433 /* autodetect 50/60 Hz */ 434 - ks0127_and_or(ks, KS_CMDA, 0xfc, 0x00); 435 /* VSE=0 */ 436 - ks0127_and_or(ks, KS_CMDA, ~0x40, 0x00); 437 /* set input line */ 438 - ks0127_and_or(ks, KS_CMDB, 0xb0, *iarg); 439 /* non-freerunning mode */ 440 - ks0127_and_or(ks, KS_CMDC, 0x70, 0x0a); 441 /* analog input */ 442 - ks0127_and_or(ks, KS_CMDD, 0x03, 0x00); 443 /* enable chroma demodulation */ 444 - ks0127_and_or(ks, KS_CTRACK, 0xcf, 0x00); 445 /* chroma trap, HYBWR=1 */ 446 - ks0127_and_or(ks, KS_LUMA, 0x00, 447 (reg_defaults[KS_LUMA])|0x0c); 448 /* scaler fullbw, luma comb off */ 449 - ks0127_and_or(ks, KS_VERTIA, 0x08, 0x81); 450 /* manual chroma comb .25 .5 .25 */ 451 - ks0127_and_or(ks, KS_VERTIC, 0x0f, 0x90); 452 453 /* chroma path delay */ 454 - ks0127_and_or(ks, KS_CHROMB, 0x0f, 0x90); 455 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]); 460 break; 461 462 case KS_INPUT_SVIDEO_1: 463 case KS_INPUT_SVIDEO_2: 464 case KS_INPUT_SVIDEO_3: 465 - dprintk("ks0127: command DECODER_SET_INPUT %d: " 466 - "S-Video\n", *iarg); 467 /* autodetect 50/60 Hz */ 468 - ks0127_and_or(ks, KS_CMDA, 0xfc, 0x00); 469 /* VSE=0 */ 470 - ks0127_and_or(ks, KS_CMDA, ~0x40, 0x00); 471 /* set input line */ 472 - ks0127_and_or(ks, KS_CMDB, 0xb0, *iarg); 473 /* non-freerunning mode */ 474 - ks0127_and_or(ks, KS_CMDC, 0x70, 0x0a); 475 /* analog input */ 476 - ks0127_and_or(ks, KS_CMDD, 0x03, 0x00); 477 /* enable chroma demodulation */ 478 - ks0127_and_or(ks, KS_CTRACK, 0xcf, 0x00); 479 - ks0127_and_or(ks, KS_LUMA, 0x00, 480 reg_defaults[KS_LUMA]); 481 /* disable luma comb */ 482 - ks0127_and_or(ks, KS_VERTIA, 0x08, 483 (reg_defaults[KS_VERTIA]&0xf0)|0x01); 484 - ks0127_and_or(ks, KS_VERTIC, 0x0f, 485 reg_defaults[KS_VERTIC]&0xf0); 486 487 - ks0127_and_or(ks, KS_CHROMB, 0x0f, 488 reg_defaults[KS_CHROMB]&0xf0); 489 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]); 494 break; 495 496 case KS_INPUT_YUV656: 497 - dprintk("ks0127: command DECODER_SET_INPUT 15: " 498 - "YUV656\n"); 499 if (ks->norm == VIDEO_MODE_NTSC || 500 ks->norm == KS_STD_PAL_M) 501 /* force 60 Hz */ 502 - ks0127_and_or(ks, KS_CMDA, 0xfc, 0x03); 503 else 504 /* force 50 Hz */ 505 - ks0127_and_or(ks, KS_CMDA, 0xfc, 0x02); 506 507 - ks0127_and_or(ks, KS_CMDA, 0xff, 0x40); /* VSE=1 */ 508 /* set input line and VALIGN */ 509 - ks0127_and_or(ks, KS_CMDB, 0xb0, (*iarg | 0x40)); 510 /* freerunning mode, */ 511 /* TSTGEN = 1 TSTGFR=11 TSTGPH=0 TSTGPK=0 VMEM=1*/ 512 - ks0127_and_or(ks, KS_CMDC, 0x70, 0x87); 513 /* digital input, SYNDIR = 0 INPSL=01 CLKDIR=0 EAV=0 */ 514 - ks0127_and_or(ks, KS_CMDD, 0x03, 0x08); 515 /* disable chroma demodulation */ 516 - ks0127_and_or(ks, KS_CTRACK, 0xcf, 0x30); 517 /* 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, 520 reg_defaults[KS_VERTIC]&0xf0); 521 522 /* scaler fullbw, luma comb off */ 523 - ks0127_and_or(ks, KS_VERTIA, 0x08, 0x81); 524 525 - ks0127_and_or(ks, KS_CHROMB, 0x0f, 526 reg_defaults[KS_CHROMB]&0xf0); 527 528 - ks0127_and_or(ks, KS_CON, 0x00, 0x00); 529 - ks0127_and_or(ks, KS_BRT, 0x00, 32); /* spec: 34 */ 530 /* spec: 229 (e5) */ 531 - ks0127_and_or(ks, KS_SAT, 0x00, 0xe8); 532 - ks0127_and_or(ks, KS_HUE, 0x00, 0); 533 534 - ks0127_and_or(ks, KS_UGAIN, 0x00, 238); 535 - ks0127_and_or(ks, KS_VGAIN, 0x00, 0x00); 536 537 /*UOFF:0x30, VOFF:0x30, TSTCGN=1 */ 538 - ks0127_and_or(ks, KS_UVOFFH, 0x00, 0x4f); 539 - ks0127_and_or(ks, KS_UVOFFL, 0x00, 0x00); 540 break; 541 542 default: 543 - dprintk("ks0127: command DECODER_SET_INPUT: " 544 - "Unknown input %d\n", *iarg); 545 break; 546 } 547 548 /* hack: CDMLPF sometimes spontaneously switches on; */ 549 /* force back off */ 550 - ks0127_write(ks, KS_DEMOD, reg_defaults[KS_DEMOD]); 551 break; 552 553 case DECODER_SET_OUTPUT: 554 switch(*iarg) { 555 case KS_OUTPUT_YUV656E: 556 - dprintk("ks0127: command DECODER_SET_OUTPUT: " 557 - "OUTPUT_YUV656E (Missing)\n"); 558 return -EINVAL; 559 - break; 560 561 case KS_OUTPUT_EXV: 562 - dprintk("ks0127: command DECODER_SET_OUTPUT: " 563 - "OUTPUT_EXV\n"); 564 - ks0127_and_or(ks, KS_OFMTA, 0xf0, 0x09); 565 break; 566 } 567 break; 568 569 - case DECODER_SET_NORM: //sam This block mixes old and new norm names... 570 /* Set to automatic SECAM/Fsc mode */ 571 - ks0127_and_or(ks, KS_DEMOD, 0xf0, 0x00); 572 573 ks->norm = *iarg; 574 - switch(*iarg) 575 - { 576 /* this is untested !! */ 577 /* It just detects PAL_N/NTSC_M (no special frequencies) */ 578 /* And you have to set the standard a second time afterwards */ 579 case VIDEO_MODE_AUTO: 580 - dprintk("ks0127: command DECODER_SET_NORM: AUTO\n"); 581 582 /* The chip determines the format */ 583 /* based on the current field rate */ 584 - ks0127_and_or(ks, KS_CMDA, 0xfc, 0x00); 585 - ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x20); 586 /* This is wrong for PAL ! As I said, */ 587 /* you need to set the standard once again !! */ 588 ks->format_height = 240; ··· 589 break; 590 591 case VIDEO_MODE_NTSC: 592 - dprintk("ks0127: command DECODER_SET_NORM: NTSC_M\n"); 593 - ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x20); 594 ks->format_height = 240; 595 ks->format_width = 704; 596 break; 597 598 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); 602 ks->format_height = 240; 603 ks->format_width = 704; 604 break; 605 606 case VIDEO_MODE_PAL: 607 - dprintk("ks0127: command DECODER_SET_NORM: PAL_N\n"); 608 - ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x20); 609 ks->format_height = 290; 610 ks->format_width = 704; 611 break; 612 613 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); 617 ks->format_height = 290; 618 ks->format_width = 704; 619 break; 620 621 case VIDEO_MODE_SECAM: 622 - dprintk("ks0127: command KS0127_SET_STANDARD: " 623 - "SECAM\n"); 624 ks->format_height = 290; 625 ks->format_width = 704; 626 627 /* set to secam autodetection */ 628 - ks0127_and_or(ks, KS_CHROMA, 0xdf, 0x20); 629 - ks0127_and_or(ks, KS_DEMOD, 0xf0, 0x00); 630 schedule_timeout_interruptible(HZ/10+1); 631 632 /* did it autodetect? */ 633 - if (ks0127_read(ks, KS_DEMOD) & 0x40) 634 break; 635 636 /* force to secam mode */ 637 - ks0127_and_or(ks, KS_DEMOD, 0xf0, 0x0f); 638 break; 639 640 default: 641 - dprintk("ks0127: command DECODER_SET_NORM: " 642 - "Unknown norm %d\n", *iarg); 643 break; 644 } 645 break; 646 647 case DECODER_SET_PICTURE: 648 - dprintk("ks0127: command DECODER_SET_PICTURE " 649 - "not yet supported (fixme)\n"); 650 return -EINVAL; 651 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: 670 671 case DECODER_ENABLE_OUTPUT: 672 { ··· 677 iarg = arg; 678 enable = (*iarg != 0); 679 if (enable) { 680 - dprintk("ks0127: command " 681 - "DECODER_ENABLE_OUTPUT on " 682 - "(%d)\n", enable); 683 /* All output pins on */ 684 - ks0127_and_or(ks, KS_OFMTA, 0xcf, 0x30); 685 /* Obey the OEN pin */ 686 - ks0127_and_or(ks, KS_CDEM, 0x7f, 0x00); 687 } else { 688 - dprintk("ks0127: command " 689 - "DECODER_ENABLE_OUTPUT off " 690 - "(%d)\n", enable); 691 /* Video output pins off */ 692 - ks0127_and_or(ks, KS_OFMTA, 0xcf, 0x00); 693 /* Ignore the OEN pin */ 694 - ks0127_and_or(ks, KS_CDEM, 0x7f, 0x80); 695 } 696 - } 697 break; 698 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: 703 704 case DECODER_GET_STATUS: 705 - dprintk("ks0127: command DECODER_GET_STATUS\n"); 706 *iarg = 0; 707 - status = ks0127_read(ks, KS_STAT); 708 if (!(status & 0x20)) /* NOVID not set */ 709 *iarg = (*iarg | DECODER_STATUS_GOOD); 710 if ((status & 0x01)) /* CLOCK set */ ··· 713 *iarg = (*iarg | DECODER_STATUS_NTSC); 714 break; 715 716 - //Catch any unknown command 717 default: 718 - dprintk("ks0127: command unknown: %04X\n", cmd); 719 return -EINVAL; 720 } 721 return 0; 722 } 723 724 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 /* 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, 743 }; 744 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 - }; 752 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) 762 { 763 struct ks0127 *ks; 764 - struct i2c_client *client; 765 766 - client = kzalloc(sizeof(*client), GFP_KERNEL); 767 - if (client == NULL) 768 - return -ENOMEM; 769 - memcpy(client, &ks0127_client_tmpl, sizeof(*client)); 770 771 ks = kzalloc(sizeof(*ks), GFP_KERNEL); 772 - if (ks == NULL) { 773 - kfree(client); 774 return -ENOMEM; 775 - } 776 777 - i2c_set_clientdata(client, ks); 778 - client->adapter = adapter; 779 - client->addr = addr; 780 - sprintf(client->name, "ks0127-%02x", adapter->id); 781 782 - ks->client = client; 783 - ks->addr = addr; 784 ks->ks_type = KS_TYPE_UNKNOWN; 785 786 /* power up */ 787 - ks0127_write(ks, KS_CMDA, 0x2c); 788 mdelay(10); 789 790 /* 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); 796 return 0; 797 } 798 799 - 800 - static int ks0127_probe(struct i2c_adapter *adapter) 801 { 802 - if (adapter->id == I2C_HW_B_ZR36067) 803 - return i2c_probe(adapter, &addr_data, ks0127_found_proc); 804 - return 0; 805 - } 806 807 - static int ks0127_detach(struct i2c_client *client) 808 - { 809 - struct ks0127 *ks = i2c_get_clientdata(client); 810 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 kfree(ks); 816 - kfree(client); 817 - 818 - dprintk("ks0127: detach\n"); 819 return 0; 820 } 821 822 - 823 - static int __devinit ks0127_init_module(void) 824 { 825 - init_reg_defaults(); 826 - return i2c_add_driver(&i2c_driver_ks0127); 827 } 828 829 - static void __devexit ks0127_cleanup_module(void) 830 - { 831 - i2c_del_driver(&i2c_driver_ks0127); 832 - } 833 834 - 835 - module_init(ks0127_init_module); 836 - module_exit(ks0127_cleanup_module);
··· 33 * V1.1 Gerard v.d. Horst Added some debugoutput, reset the video-standard 34 */ 35 36 #include <linux/init.h> 37 #include <linux/module.h> 38 #include <linux/delay.h> 39 #include <linux/errno.h> 40 #include <linux/kernel.h> 41 #include <linux/i2c.h> 42 #include <linux/video_decoder.h> 43 + #include <media/v4l2-common.h> 44 + #include <media/v4l2-i2c-drv-legacy.h> 45 + #include "ks0127.h" 46 47 + MODULE_DESCRIPTION("KS0127 video decoder driver"); 48 + MODULE_AUTHOR("Ryan Drake"); 49 + MODULE_LICENSE("GPL"); 50 51 #define KS_TYPE_UNKNOWN 0 52 #define KS_TYPE_0122S 1 ··· 204 }; 205 206 struct ks0127 { 207 int format_width; 208 int format_height; 209 int cap_width; ··· 220 221 module_param(debug, int, 0); 222 MODULE_PARM_DESC(debug, "Debug output"); 223 224 static u8 reg_defaults[64]; 225 226 static void init_reg_defaults(void) 227 { 228 + static int initialized; 229 u8 *table = reg_defaults; 230 + 231 + if (initialized) 232 + return; 233 + initialized = 1; 234 235 table[KS_CMDA] = 0x2c; /* VSE=0, CCIR 601, autodetect standard */ 236 table[KS_CMDB] = 0x12; /* VALIGN=0, AGC control and input */ ··· 308 * An explanation from kayork@mail.utexas.edu: 309 * 310 * During I2C reads, the KS0127 only samples for a stop condition 311 + * during the place where the acknowledge bit should be. Any standard 312 * I2C implementation (correctly) throws in another clock transition 313 * at the 9th bit, and the KS0127 will not recognize the stop condition 314 * and will continue to clock out data. 315 * 316 * So we have to do the read ourself. Big deal. 317 + * workaround in i2c-algo-bit 318 */ 319 320 321 + static u8 ks0127_read(struct i2c_client *c, u8 reg) 322 { 323 char val = 0; 324 struct i2c_msg msgs[] = { 325 + { c->addr, 0, sizeof(reg), &reg }, 326 + { c->addr, I2C_M_RD | I2C_M_NO_RD_ACK, sizeof(val), &val } 327 + }; 328 int ret; 329 330 ret = i2c_transfer(c->adapter, msgs, ARRAY_SIZE(msgs)); 331 if (ret != ARRAY_SIZE(msgs)) 332 + v4l_dbg(1, debug, c, "read error\n"); 333 334 return val; 335 } 336 337 338 + static void ks0127_write(struct i2c_client *c, u8 reg, u8 val) 339 { 340 + struct ks0127 *ks = i2c_get_clientdata(c); 341 + char msg[] = { reg, val }; 342 343 + if (i2c_master_send(c, msg, sizeof(msg)) != sizeof(msg)) 344 + v4l_dbg(1, debug, c, "write error\n"); 345 346 ks->regs[reg] = val; 347 } 348 349 350 /* generic bit-twiddling */ 351 + static void ks0127_and_or(struct i2c_client *client, u8 reg, u8 and_v, u8 or_v) 352 { 353 + struct ks0127 *ks = i2c_get_clientdata(client); 354 + 355 u8 val = ks->regs[reg]; 356 val = (val & and_v) | or_v; 357 + ks0127_write(client, reg, val); 358 } 359 360 ··· 359 /**************************************************************************** 360 * ks0127 private api 361 ****************************************************************************/ 362 + static void ks0127_reset(struct i2c_client *c) 363 { 364 + struct ks0127 *ks = i2c_get_clientdata(c); 365 u8 *table = reg_defaults; 366 + int i; 367 368 ks->ks_type = KS_TYPE_UNKNOWN; 369 370 + v4l_dbg(1, debug, c, "reset\n"); 371 msleep(1); 372 373 /* initialize all registers to known values */ 374 /* (except STAT, 0x21, 0x22, TEST and 0x38,0x39) */ 375 376 + for (i = 1; i < 33; i++) 377 + ks0127_write(c, i, table[i]); 378 379 + for (i = 35; i < 40; i++) 380 + ks0127_write(c, i, table[i]); 381 382 + for (i = 41; i < 56; i++) 383 + ks0127_write(c, i, table[i]); 384 385 + for (i = 58; i < 64; i++) 386 + ks0127_write(c, i, table[i]); 387 388 389 + if ((ks0127_read(c, KS_STAT) & 0x80) == 0) { 390 ks->ks_type = KS_TYPE_0122S; 391 + v4l_dbg(1, debug, c, "ks0122s found\n"); 392 return; 393 } 394 395 + switch (ks0127_read(c, KS_CMDE) & 0x0f) { 396 case 0: 397 ks->ks_type = KS_TYPE_0127; 398 + v4l_dbg(1, debug, c, "ks0127 found\n"); 399 break; 400 401 case 9: 402 ks->ks_type = KS_TYPE_0127B; 403 + v4l_dbg(1, debug, c, "ks0127B Revision A found\n"); 404 break; 405 406 default: 407 + v4l_dbg(1, debug, c, "unknown revision\n"); 408 break; 409 } 410 } 411 412 + static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) 413 { 414 + struct ks0127 *ks = i2c_get_clientdata(c); 415 + int *iarg = (int *)arg; 416 int status; 417 418 if (!ks) 419 return -ENODEV; 420 421 switch (cmd) { 422 case DECODER_INIT: 423 + v4l_dbg(1, debug, c, "DECODER_INIT\n"); 424 + ks0127_reset(c); 425 break; 426 427 case DECODER_SET_INPUT: ··· 436 case KS_INPUT_COMPOSITE_4: 437 case KS_INPUT_COMPOSITE_5: 438 case KS_INPUT_COMPOSITE_6: 439 + v4l_dbg(1, debug, c, 440 + "DECODER_SET_INPUT %d: Composite\n", *iarg); 441 /* autodetect 50/60 Hz */ 442 + ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); 443 /* VSE=0 */ 444 + ks0127_and_or(c, KS_CMDA, ~0x40, 0x00); 445 /* set input line */ 446 + ks0127_and_or(c, KS_CMDB, 0xb0, *iarg); 447 /* non-freerunning mode */ 448 + ks0127_and_or(c, KS_CMDC, 0x70, 0x0a); 449 /* analog input */ 450 + ks0127_and_or(c, KS_CMDD, 0x03, 0x00); 451 /* enable chroma demodulation */ 452 + ks0127_and_or(c, KS_CTRACK, 0xcf, 0x00); 453 /* chroma trap, HYBWR=1 */ 454 + ks0127_and_or(c, KS_LUMA, 0x00, 455 (reg_defaults[KS_LUMA])|0x0c); 456 /* scaler fullbw, luma comb off */ 457 + ks0127_and_or(c, KS_VERTIA, 0x08, 0x81); 458 /* manual chroma comb .25 .5 .25 */ 459 + ks0127_and_or(c, KS_VERTIC, 0x0f, 0x90); 460 461 /* chroma path delay */ 462 + ks0127_and_or(c, KS_CHROMB, 0x0f, 0x90); 463 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]); 468 break; 469 470 case KS_INPUT_SVIDEO_1: 471 case KS_INPUT_SVIDEO_2: 472 case KS_INPUT_SVIDEO_3: 473 + v4l_dbg(1, debug, c, 474 + "DECODER_SET_INPUT %d: S-Video\n", *iarg); 475 /* autodetect 50/60 Hz */ 476 + ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); 477 /* VSE=0 */ 478 + ks0127_and_or(c, KS_CMDA, ~0x40, 0x00); 479 /* set input line */ 480 + ks0127_and_or(c, KS_CMDB, 0xb0, *iarg); 481 /* non-freerunning mode */ 482 + ks0127_and_or(c, KS_CMDC, 0x70, 0x0a); 483 /* analog input */ 484 + ks0127_and_or(c, KS_CMDD, 0x03, 0x00); 485 /* enable chroma demodulation */ 486 + ks0127_and_or(c, KS_CTRACK, 0xcf, 0x00); 487 + ks0127_and_or(c, KS_LUMA, 0x00, 488 reg_defaults[KS_LUMA]); 489 /* disable luma comb */ 490 + ks0127_and_or(c, KS_VERTIA, 0x08, 491 (reg_defaults[KS_VERTIA]&0xf0)|0x01); 492 + ks0127_and_or(c, KS_VERTIC, 0x0f, 493 reg_defaults[KS_VERTIC]&0xf0); 494 495 + ks0127_and_or(c, KS_CHROMB, 0x0f, 496 reg_defaults[KS_CHROMB]&0xf0); 497 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]); 502 break; 503 504 case KS_INPUT_YUV656: 505 + v4l_dbg(1, debug, c, 506 + "DECODER_SET_INPUT 15: YUV656\n"); 507 if (ks->norm == VIDEO_MODE_NTSC || 508 ks->norm == KS_STD_PAL_M) 509 /* force 60 Hz */ 510 + ks0127_and_or(c, KS_CMDA, 0xfc, 0x03); 511 else 512 /* force 50 Hz */ 513 + ks0127_and_or(c, KS_CMDA, 0xfc, 0x02); 514 515 + ks0127_and_or(c, KS_CMDA, 0xff, 0x40); /* VSE=1 */ 516 /* set input line and VALIGN */ 517 + ks0127_and_or(c, KS_CMDB, 0xb0, (*iarg | 0x40)); 518 /* freerunning mode, */ 519 /* TSTGEN = 1 TSTGFR=11 TSTGPH=0 TSTGPK=0 VMEM=1*/ 520 + ks0127_and_or(c, KS_CMDC, 0x70, 0x87); 521 /* digital input, SYNDIR = 0 INPSL=01 CLKDIR=0 EAV=0 */ 522 + ks0127_and_or(c, KS_CMDD, 0x03, 0x08); 523 /* disable chroma demodulation */ 524 + ks0127_and_or(c, KS_CTRACK, 0xcf, 0x30); 525 /* HYPK =01 CTRAP = 0 HYBWR=0 PED=1 RGBH=1 UNIT=1 */ 526 + ks0127_and_or(c, KS_LUMA, 0x00, 0x71); 527 + ks0127_and_or(c, KS_VERTIC, 0x0f, 528 reg_defaults[KS_VERTIC]&0xf0); 529 530 /* scaler fullbw, luma comb off */ 531 + ks0127_and_or(c, KS_VERTIA, 0x08, 0x81); 532 533 + ks0127_and_or(c, KS_CHROMB, 0x0f, 534 reg_defaults[KS_CHROMB]&0xf0); 535 536 + ks0127_and_or(c, KS_CON, 0x00, 0x00); 537 + ks0127_and_or(c, KS_BRT, 0x00, 32); /* spec: 34 */ 538 /* spec: 229 (e5) */ 539 + ks0127_and_or(c, KS_SAT, 0x00, 0xe8); 540 + ks0127_and_or(c, KS_HUE, 0x00, 0); 541 542 + ks0127_and_or(c, KS_UGAIN, 0x00, 238); 543 + ks0127_and_or(c, KS_VGAIN, 0x00, 0x00); 544 545 /*UOFF:0x30, VOFF:0x30, TSTCGN=1 */ 546 + ks0127_and_or(c, KS_UVOFFH, 0x00, 0x4f); 547 + ks0127_and_or(c, KS_UVOFFL, 0x00, 0x00); 548 break; 549 550 default: 551 + v4l_dbg(1, debug, c, 552 + "DECODER_SET_INPUT: Unknown input %d\n", *iarg); 553 break; 554 } 555 556 /* hack: CDMLPF sometimes spontaneously switches on; */ 557 /* force back off */ 558 + ks0127_write(c, KS_DEMOD, reg_defaults[KS_DEMOD]); 559 break; 560 561 case DECODER_SET_OUTPUT: 562 switch(*iarg) { 563 case KS_OUTPUT_YUV656E: 564 + v4l_dbg(1, debug, c, 565 + "DECODER_SET_OUTPUT: OUTPUT_YUV656E (Missing)\n"); 566 return -EINVAL; 567 568 case KS_OUTPUT_EXV: 569 + v4l_dbg(1, debug, c, 570 + "DECODER_SET_OUTPUT: OUTPUT_EXV\n"); 571 + ks0127_and_or(c, KS_OFMTA, 0xf0, 0x09); 572 break; 573 } 574 break; 575 576 + case DECODER_SET_NORM: /* sam This block mixes old and new norm names... */ 577 /* Set to automatic SECAM/Fsc mode */ 578 + ks0127_and_or(c, KS_DEMOD, 0xf0, 0x00); 579 580 ks->norm = *iarg; 581 + switch (*iarg) { 582 /* this is untested !! */ 583 /* It just detects PAL_N/NTSC_M (no special frequencies) */ 584 /* And you have to set the standard a second time afterwards */ 585 case VIDEO_MODE_AUTO: 586 + v4l_dbg(1, debug, c, 587 + "DECODER_SET_NORM: AUTO\n"); 588 589 /* The chip determines the format */ 590 /* based on the current field rate */ 591 + ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); 592 + ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); 593 /* This is wrong for PAL ! As I said, */ 594 /* you need to set the standard once again !! */ 595 ks->format_height = 240; ··· 598 break; 599 600 case VIDEO_MODE_NTSC: 601 + v4l_dbg(1, debug, c, 602 + "DECODER_SET_NORM: NTSC_M\n"); 603 + ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); 604 ks->format_height = 240; 605 ks->format_width = 704; 606 break; 607 608 case KS_STD_NTSC_N: 609 + v4l_dbg(1, debug, c, 610 + "KS0127_SET_NORM: NTSC_N (fixme)\n"); 611 + ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); 612 ks->format_height = 240; 613 ks->format_width = 704; 614 break; 615 616 case VIDEO_MODE_PAL: 617 + v4l_dbg(1, debug, c, 618 + "DECODER_SET_NORM: PAL_N\n"); 619 + ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); 620 ks->format_height = 290; 621 ks->format_width = 704; 622 break; 623 624 case KS_STD_PAL_M: 625 + v4l_dbg(1, debug, c, 626 + "KS0127_SET_NORM: PAL_M (fixme)\n"); 627 + ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); 628 ks->format_height = 290; 629 ks->format_width = 704; 630 break; 631 632 case VIDEO_MODE_SECAM: 633 + v4l_dbg(1, debug, c, 634 + "KS0127_SET_NORM: SECAM\n"); 635 ks->format_height = 290; 636 ks->format_width = 704; 637 638 /* set to secam autodetection */ 639 + ks0127_and_or(c, KS_CHROMA, 0xdf, 0x20); 640 + ks0127_and_or(c, KS_DEMOD, 0xf0, 0x00); 641 schedule_timeout_interruptible(HZ/10+1); 642 643 /* did it autodetect? */ 644 + if (ks0127_read(c, KS_DEMOD) & 0x40) 645 break; 646 647 /* force to secam mode */ 648 + ks0127_and_or(c, KS_DEMOD, 0xf0, 0x0f); 649 break; 650 651 default: 652 + v4l_dbg(1, debug, c, 653 + "DECODER_SET_NORM: Unknown norm %d\n", *iarg); 654 break; 655 } 656 break; 657 658 case DECODER_SET_PICTURE: 659 + v4l_dbg(1, debug, c, 660 + "DECODER_SET_PICTURE: not yet supported\n"); 661 return -EINVAL; 662 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: */ 681 682 case DECODER_ENABLE_OUTPUT: 683 { ··· 684 iarg = arg; 685 enable = (*iarg != 0); 686 if (enable) { 687 + v4l_dbg(1, debug, c, 688 + "DECODER_ENABLE_OUTPUT on\n"); 689 /* All output pins on */ 690 + ks0127_and_or(c, KS_OFMTA, 0xcf, 0x30); 691 /* Obey the OEN pin */ 692 + ks0127_and_or(c, KS_CDEM, 0x7f, 0x00); 693 } else { 694 + v4l_dbg(1, debug, c, 695 + "DECODER_ENABLE_OUTPUT off\n"); 696 /* Video output pins off */ 697 + ks0127_and_or(c, KS_OFMTA, 0xcf, 0x00); 698 /* Ignore the OEN pin */ 699 + ks0127_and_or(c, KS_CDEM, 0x7f, 0x80); 700 } 701 break; 702 + } 703 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: */ 708 709 case DECODER_GET_STATUS: 710 + v4l_dbg(1, debug, c, "DECODER_GET_STATUS\n"); 711 *iarg = 0; 712 + status = ks0127_read(c, KS_STAT); 713 if (!(status & 0x20)) /* NOVID not set */ 714 *iarg = (*iarg | DECODER_STATUS_GOOD); 715 if ((status & 0x01)) /* CLOCK set */ ··· 722 *iarg = (*iarg | DECODER_STATUS_NTSC); 723 break; 724 725 + /* Catch any unknown command */ 726 default: 727 + v4l_dbg(1, debug, c, "unknown: 0x%08x\n", cmd); 728 return -EINVAL; 729 } 730 return 0; 731 } 732 733 734 /* Addresses to scan */ 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 742 }; 743 744 + I2C_CLIENT_INSMOD; 745 746 + static int ks0127_probe(struct i2c_client *c, const struct i2c_device_id *id) 747 { 748 struct ks0127 *ks; 749 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); 753 754 ks = kzalloc(sizeof(*ks), GFP_KERNEL); 755 + if (ks == NULL) 756 return -ENOMEM; 757 758 + i2c_set_clientdata(c, ks); 759 760 ks->ks_type = KS_TYPE_UNKNOWN; 761 762 /* power up */ 763 + init_reg_defaults(); 764 + ks0127_write(c, KS_CMDA, 0x2c); 765 mdelay(10); 766 767 /* reset the device */ 768 + ks0127_reset(c); 769 return 0; 770 } 771 772 + static int ks0127_remove(struct i2c_client *c) 773 { 774 + struct ks0127 *ks = i2c_get_clientdata(c); 775 776 + ks0127_write(c, KS_OFMTA, 0x20); /* tristate */ 777 + ks0127_write(c, KS_CMDA, 0x2c | 0x80); /* power down */ 778 779 kfree(ks); 780 return 0; 781 } 782 783 + static int ks0127_legacy_probe(struct i2c_adapter *adapter) 784 { 785 + return adapter->id == I2C_HW_B_ZR36067; 786 } 787 788 + static const struct i2c_device_id ks0127_id[] = { 789 + { "ks0127", 0 }, 790 + { } 791 + }; 792 + MODULE_DEVICE_TABLE(i2c, ks0127_id); 793 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 #include <linux/delay.h> 32 #include <linux/slab.h> 33 #include <linux/wait.h> 34 - #include <asm/io.h> 35 #include <asm/uaccess.h> 36 37 MODULE_DESCRIPTION("Philips SAA7110 video decoder driver"); 38 MODULE_AUTHOR("Pauline Middelink"); 39 MODULE_LICENSE("GPL"); 40 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 static int debug; 50 module_param(debug, int, 0); 51 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 52 53 - #define dprintk(num, format, args...) \ 54 - do { \ 55 - if (debug >= num) \ 56 - printk(format, ##args); \ 57 - } while (0) 58 - 59 #define SAA7110_MAX_INPUT 9 /* 6 CVBS, 3 SVHS */ 60 #define SAA7110_MAX_OUTPUT 0 /* its a decoder only */ 61 - 62 - #define I2C_SAA7110 0x9C /* or 0x9E */ 63 64 #define SAA7110_NR_REG 0x35 65 ··· 69 /* I2C support functions */ 70 /* ----------------------------------------------------------------------- */ 71 72 - static int 73 - saa7110_write (struct i2c_client *client, 74 - u8 reg, 75 - u8 value) 76 { 77 struct saa7110 *decoder = i2c_get_clientdata(client); 78 ··· 77 return i2c_smbus_write_byte_data(client, reg, value); 78 } 79 80 - static int 81 - saa7110_write_block (struct i2c_client *client, 82 - const u8 *data, 83 - unsigned int len) 84 { 85 int ret = -1; 86 u8 reg = *data; /* first register to write to */ ··· 97 memcpy(decoder->reg + reg, data + 1, len - 1); 98 } else { 99 for (++data, --len; len; len--) { 100 - if ((ret = saa7110_write(client, reg++, 101 - *data++)) < 0) 102 break; 103 } 104 } ··· 106 return ret; 107 } 108 109 - static inline int 110 - saa7110_read (struct i2c_client *client) 111 { 112 return i2c_smbus_read_byte(client); 113 } ··· 119 #define FRESP_06H_SVIDEO 0x83 //0xC0 120 121 122 - static int 123 - saa7110_selmux (struct i2c_client *client, 124 - int chan) 125 { 126 static const unsigned char modes[9][8] = { 127 /* mode 0 */ ··· 176 /* 0x30 */ 0x44, 0x71, 0x02, 0x8C, 0x02 177 }; 178 179 - static int 180 - determine_norm (struct i2c_client *client) 181 { 182 DEFINE_WAIT(wait); 183 struct saa7110 *decoder = i2c_get_clientdata(client); ··· 190 finish_wait(&decoder->wq, &wait); 191 status = saa7110_read(client); 192 if (status & 0x40) { 193 - dprintk(1, KERN_INFO "%s: status=0x%02x (no signal)\n", 194 - I2C_NAME(client), status); 195 return decoder->norm; // no change 196 } 197 if ((status & 3) == 0) { 198 saa7110_write(client, 0x06, 0x83); 199 if (status & 0x20) { 200 - dprintk(1, 201 - KERN_INFO 202 - "%s: status=0x%02x (NTSC/no color)\n", 203 - I2C_NAME(client), status); 204 //saa7110_write(client,0x2E,0x81); 205 return VIDEO_MODE_NTSC; 206 } 207 - dprintk(1, KERN_INFO "%s: status=0x%02x (PAL/no color)\n", 208 - I2C_NAME(client), status); 209 //saa7110_write(client,0x2E,0x9A); 210 return VIDEO_MODE_PAL; 211 } 212 //saa7110_write(client,0x06,0x03); 213 if (status & 0x20) { /* 60Hz */ 214 - dprintk(1, KERN_INFO "%s: status=0x%02x (NTSC)\n", 215 - I2C_NAME(client), status); 216 saa7110_write(client, 0x0D, 0x86); 217 saa7110_write(client, 0x0F, 0x50); 218 saa7110_write(client, 0x11, 0x2C); ··· 226 227 status = saa7110_read(client); 228 if ((status & 0x03) == 0x01) { 229 - dprintk(1, KERN_INFO "%s: status=0x%02x (SECAM)\n", 230 - I2C_NAME(client), status); 231 saa7110_write(client, 0x0D, 0x87); 232 return VIDEO_MODE_SECAM; 233 } 234 - dprintk(1, KERN_INFO "%s: status=0x%02x (PAL)\n", I2C_NAME(client), 235 - status); 236 return VIDEO_MODE_PAL; 237 } 238 ··· 256 VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO; 257 dc->inputs = SAA7110_MAX_INPUT; 258 dc->outputs = SAA7110_MAX_OUTPUT; 259 - } 260 break; 261 262 case DECODER_GET_STATUS: 263 { ··· 265 int res = 0; 266 267 status = saa7110_read(client); 268 - dprintk(1, KERN_INFO "%s: status=0x%02x norm=%d\n", 269 - I2C_NAME(client), status, decoder->norm); 270 if (!(status & 0x40)) 271 res |= DECODER_STATUS_GOOD; 272 if (status & 0x03) ··· 284 break; 285 } 286 *(int *) arg = res; 287 - } 288 break; 289 290 case DECODER_SET_NORM: 291 v = *(int *) arg; ··· 298 saa7110_write(client, 0x0F, 0x50); 299 saa7110_write(client, 0x11, 0x2C); 300 //saa7110_write(client, 0x2E, 0x81); 301 - dprintk(1, 302 - KERN_INFO "%s: switched to NTSC\n", 303 - I2C_NAME(client)); 304 break; 305 case VIDEO_MODE_PAL: 306 saa7110_write(client, 0x0D, 0x86); 307 saa7110_write(client, 0x0F, 0x10); 308 saa7110_write(client, 0x11, 0x59); 309 //saa7110_write(client, 0x2E, 0x9A); 310 - dprintk(1, 311 - KERN_INFO "%s: switched to PAL\n", 312 - I2C_NAME(client)); 313 break; 314 case VIDEO_MODE_SECAM: 315 saa7110_write(client, 0x0D, 0x87); 316 saa7110_write(client, 0x0F, 0x10); 317 saa7110_write(client, 0x11, 0x59); 318 //saa7110_write(client, 0x2E, 0x9A); 319 - dprintk(1, 320 - KERN_INFO 321 - "%s: switched to SECAM\n", 322 - I2C_NAME(client)); 323 break; 324 case VIDEO_MODE_AUTO: 325 - dprintk(1, 326 - KERN_INFO 327 - "%s: TV standard detection...\n", 328 - I2C_NAME(client)); 329 decoder->norm = determine_norm(client); 330 *(int *) arg = decoder->norm; 331 break; ··· 328 case DECODER_SET_INPUT: 329 v = *(int *) arg; 330 if (v < 0 || v > SAA7110_MAX_INPUT) { 331 - dprintk(1, 332 - KERN_INFO "%s: input=%d not available\n", 333 - I2C_NAME(client), v); 334 return -EINVAL; 335 } 336 if (decoder->input != v) { 337 saa7110_selmux(client, v); 338 - dprintk(1, KERN_INFO "%s: switched to input=%d\n", 339 - I2C_NAME(client), v); 340 } 341 break; 342 ··· 349 if (decoder->enable != v) { 350 decoder->enable = v; 351 saa7110_write(client, 0x0E, v ? 0x18 : 0x80); 352 - dprintk(1, KERN_INFO "%s: YUV %s\n", I2C_NAME(client), 353 - v ? "on" : "off"); 354 } 355 break; 356 ··· 379 saa7110_write(client, 0x07, 380 (decoder->hue >> 8) - 128); 381 } 382 - } 383 break; 384 385 case DECODER_DUMP: 386 for (v = 0; v < SAA7110_NR_REG; v += 16) { 387 int j; 388 - dprintk(1, KERN_DEBUG "%s: %02x:", I2C_NAME(client), 389 - v); 390 for (j = 0; j < 16 && v + j < SAA7110_NR_REG; j++) 391 - dprintk(1, " %02x", decoder->reg[v + j]); 392 - dprintk(1, "\n"); 393 } 394 break; 395 396 default: 397 - dprintk(1, KERN_INFO "unknown saa7110_command??(%d)\n", 398 - cmd); 399 return -EINVAL; 400 } 401 return 0; ··· 407 * Generic i2c probe 408 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 409 */ 410 - static unsigned short normal_i2c[] = { 411 - I2C_SAA7110 >> 1, 412 - (I2C_SAA7110 >> 1) + 1, 413 - I2C_CLIENT_END 414 - }; 415 416 - static unsigned short ignore = I2C_CLIENT_END; 417 418 - static struct i2c_client_address_data addr_data = { 419 - .normal_i2c = normal_i2c, 420 - .probe = &ignore, 421 - .ignore = &ignore, 422 - }; 423 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) 430 { 431 - struct i2c_client *client; 432 struct saa7110 *decoder; 433 int rv; 434 435 - dprintk(1, 436 - KERN_INFO 437 - "saa7110.c: detecting saa7110 client on address 0x%x\n", 438 - address << 1); 439 - 440 /* 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; 445 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))); 453 454 decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); 455 - if (!decoder) { 456 - kfree(client); 457 return -ENOMEM; 458 - } 459 decoder->norm = VIDEO_MODE_PAL; 460 decoder->input = 0; 461 decoder->enable = 1; ··· 439 init_waitqueue_head(&decoder->wq); 440 i2c_set_clientdata(client, decoder); 441 442 - rv = i2c_attach_client(client); 443 - if (rv) { 444 - kfree(client); 445 - kfree(decoder); 446 - return rv; 447 - } 448 - 449 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 { 454 int ver, status; 455 saa7110_write(client, 0x21, 0x10); 456 saa7110_write(client, 0x0e, 0x18); ··· 451 saa7110_write(client, 0x0D, 0x06); 452 //mdelay(150); 453 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); 458 saa7110_write(client, 0x0D, 0x86); 459 saa7110_write(client, 0x0F, 0x10); 460 saa7110_write(client, 0x11, 0x59); ··· 466 return 0; 467 } 468 469 - static int 470 - saa7110_attach_adapter (struct i2c_adapter *adapter) 471 { 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 - 493 return 0; 494 } 495 496 /* ----------------------------------------------------------------------- */ 497 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, 508 }; 509 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);
··· 31 #include <linux/delay.h> 32 #include <linux/slab.h> 33 #include <linux/wait.h> 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> 40 41 MODULE_DESCRIPTION("Philips SAA7110 video decoder driver"); 42 MODULE_AUTHOR("Pauline Middelink"); 43 MODULE_LICENSE("GPL"); 44 45 static int debug; 46 module_param(debug, int, 0); 47 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 48 49 #define SAA7110_MAX_INPUT 9 /* 6 CVBS, 3 SVHS */ 50 #define SAA7110_MAX_OUTPUT 0 /* its a decoder only */ 51 52 #define SAA7110_NR_REG 0x35 53 ··· 81 /* I2C support functions */ 82 /* ----------------------------------------------------------------------- */ 83 84 + static int saa7110_write(struct i2c_client *client, u8 reg, u8 value) 85 { 86 struct saa7110 *decoder = i2c_get_clientdata(client); 87 ··· 92 return i2c_smbus_write_byte_data(client, reg, value); 93 } 94 95 + static int saa7110_write_block(struct i2c_client *client, const u8 *data, unsigned int len) 96 { 97 int ret = -1; 98 u8 reg = *data; /* first register to write to */ ··· 115 memcpy(decoder->reg + reg, data + 1, len - 1); 116 } else { 117 for (++data, --len; len; len--) { 118 + ret = saa7110_write(client, reg++, *data++); 119 + if (ret < 0) 120 break; 121 } 122 } ··· 124 return ret; 125 } 126 127 + static inline int saa7110_read(struct i2c_client *client) 128 { 129 return i2c_smbus_read_byte(client); 130 } ··· 138 #define FRESP_06H_SVIDEO 0x83 //0xC0 139 140 141 + static int saa7110_selmux(struct i2c_client *client, int chan) 142 { 143 static const unsigned char modes[9][8] = { 144 /* mode 0 */ ··· 197 /* 0x30 */ 0x44, 0x71, 0x02, 0x8C, 0x02 198 }; 199 200 + static int determine_norm(struct i2c_client *client) 201 { 202 DEFINE_WAIT(wait); 203 struct saa7110 *decoder = i2c_get_clientdata(client); ··· 212 finish_wait(&decoder->wq, &wait); 213 status = saa7110_read(client); 214 if (status & 0x40) { 215 + v4l_dbg(1, debug, client, "status=0x%02x (no signal)\n", status); 216 return decoder->norm; // no change 217 } 218 if ((status & 3) == 0) { 219 saa7110_write(client, 0x06, 0x83); 220 if (status & 0x20) { 221 + v4l_dbg(1, debug, client, "status=0x%02x (NTSC/no color)\n", status); 222 //saa7110_write(client,0x2E,0x81); 223 return VIDEO_MODE_NTSC; 224 } 225 + v4l_dbg(1, debug, client, "status=0x%02x (PAL/no color)\n", status); 226 //saa7110_write(client,0x2E,0x9A); 227 return VIDEO_MODE_PAL; 228 } 229 //saa7110_write(client,0x06,0x03); 230 if (status & 0x20) { /* 60Hz */ 231 + v4l_dbg(1, debug, client, "status=0x%02x (NTSC)\n", status); 232 saa7110_write(client, 0x0D, 0x86); 233 saa7110_write(client, 0x0F, 0x50); 234 saa7110_write(client, 0x11, 0x2C); ··· 254 255 status = saa7110_read(client); 256 if ((status & 0x03) == 0x01) { 257 + v4l_dbg(1, debug, client, "status=0x%02x (SECAM)\n", status); 258 saa7110_write(client, 0x0D, 0x87); 259 return VIDEO_MODE_SECAM; 260 } 261 + v4l_dbg(1, debug, client, "status=0x%02x (PAL)\n", status); 262 return VIDEO_MODE_PAL; 263 } 264 ··· 286 VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO; 287 dc->inputs = SAA7110_MAX_INPUT; 288 dc->outputs = SAA7110_MAX_OUTPUT; 289 break; 290 + } 291 292 case DECODER_GET_STATUS: 293 { ··· 295 int res = 0; 296 297 status = saa7110_read(client); 298 + v4l_dbg(1, debug, client, "status=0x%02x norm=%d\n", 299 + status, decoder->norm); 300 if (!(status & 0x40)) 301 res |= DECODER_STATUS_GOOD; 302 if (status & 0x03) ··· 314 break; 315 } 316 *(int *) arg = res; 317 break; 318 + } 319 320 case DECODER_SET_NORM: 321 v = *(int *) arg; ··· 328 saa7110_write(client, 0x0F, 0x50); 329 saa7110_write(client, 0x11, 0x2C); 330 //saa7110_write(client, 0x2E, 0x81); 331 + v4l_dbg(1, debug, client, "switched to NTSC\n"); 332 break; 333 case VIDEO_MODE_PAL: 334 saa7110_write(client, 0x0D, 0x86); 335 saa7110_write(client, 0x0F, 0x10); 336 saa7110_write(client, 0x11, 0x59); 337 //saa7110_write(client, 0x2E, 0x9A); 338 + v4l_dbg(1, debug, client, "switched to PAL\n"); 339 break; 340 case VIDEO_MODE_SECAM: 341 saa7110_write(client, 0x0D, 0x87); 342 saa7110_write(client, 0x0F, 0x10); 343 saa7110_write(client, 0x11, 0x59); 344 //saa7110_write(client, 0x2E, 0x9A); 345 + v4l_dbg(1, debug, client, "switched to SECAM\n"); 346 break; 347 case VIDEO_MODE_AUTO: 348 + v4l_dbg(1, debug, client, "switched to AUTO\n"); 349 decoder->norm = determine_norm(client); 350 *(int *) arg = decoder->norm; 351 break; ··· 368 case DECODER_SET_INPUT: 369 v = *(int *) arg; 370 if (v < 0 || v > SAA7110_MAX_INPUT) { 371 + v4l_dbg(1, debug, client, "input=%d not available\n", v); 372 return -EINVAL; 373 } 374 if (decoder->input != v) { 375 saa7110_selmux(client, v); 376 + v4l_dbg(1, debug, client, "switched to input=%d\n", v); 377 } 378 break; 379 ··· 392 if (decoder->enable != v) { 393 decoder->enable = v; 394 saa7110_write(client, 0x0E, v ? 0x18 : 0x80); 395 + v4l_dbg(1, debug, client, "YUV %s\n", v ? "on" : "off"); 396 } 397 break; 398 ··· 423 saa7110_write(client, 0x07, 424 (decoder->hue >> 8) - 128); 425 } 426 break; 427 + } 428 429 case DECODER_DUMP: 430 + if (!debug) 431 + break; 432 for (v = 0; v < SAA7110_NR_REG; v += 16) { 433 int j; 434 + v4l_dbg(1, debug, client, "%02x:", v); 435 for (j = 0; j < 16 && v + j < SAA7110_NR_REG; j++) 436 + printk(KERN_CONT " %02x", decoder->reg[v + j]); 437 + printk(KERN_CONT "\n"); 438 } 439 break; 440 441 default: 442 + v4l_dbg(1, debug, client, "unknown command %08x\n", cmd); 443 return -EINVAL; 444 } 445 return 0; ··· 451 * Generic i2c probe 452 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 453 */ 454 455 + static unsigned short normal_i2c[] = { 0x9c >> 1, 0x9e >> 1, I2C_CLIENT_END }; 456 457 + I2C_CLIENT_INSMOD; 458 459 + static int saa7110_probe(struct i2c_client *client, 460 + const struct i2c_device_id *id) 461 { 462 struct saa7110 *decoder; 463 int rv; 464 465 /* Check if the adapter supports the needed features */ 466 + if (!i2c_check_functionality(client->adapter, 467 + I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) 468 + return -ENODEV; 469 470 + v4l_info(client, "chip found @ 0x%x (%s)\n", 471 + client->addr << 1, client->adapter->name); 472 473 decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); 474 + if (!decoder) 475 return -ENOMEM; 476 decoder->norm = VIDEO_MODE_PAL; 477 decoder->input = 0; 478 decoder->enable = 1; ··· 510 init_waitqueue_head(&decoder->wq); 511 i2c_set_clientdata(client, decoder); 512 513 rv = saa7110_write_block(client, initseq, sizeof(initseq)); 514 + if (rv < 0) { 515 + v4l_dbg(1, debug, client, "init status %d\n", rv); 516 + } else { 517 int ver, status; 518 saa7110_write(client, 0x21, 0x10); 519 saa7110_write(client, 0x0e, 0x18); ··· 530 saa7110_write(client, 0x0D, 0x06); 531 //mdelay(150); 532 status = saa7110_read(client); 533 + v4l_dbg(1, debug, client, "version %x, status=0x%02x\n", 534 + ver, status); 535 saa7110_write(client, 0x0D, 0x86); 536 saa7110_write(client, 0x0F, 0x10); 537 saa7110_write(client, 0x11, 0x59); ··· 547 return 0; 548 } 549 550 + static int saa7110_remove(struct i2c_client *client) 551 { 552 + kfree(i2c_get_clientdata(client)); 553 return 0; 554 } 555 556 /* ----------------------------------------------------------------------- */ 557 558 + static const struct i2c_device_id saa7110_id[] = { 559 + { "saa7110", 0 }, 560 + { } 561 }; 562 + MODULE_DEVICE_TABLE(i2c, saa7110_id); 563 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 */ 29 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 #include <linux/types.h> 41 - #include <linux/i2c.h> 42 - #include <asm/io.h> 43 - #include <asm/pgtable.h> 44 - #include <asm/page.h> 45 #include <asm/uaccess.h> 46 - 47 #include <linux/videodev.h> 48 #include <linux/video_decoder.h> 49 50 MODULE_DESCRIPTION("Philips SAA7111 video decoder driver"); 51 MODULE_AUTHOR("Dave Perks"); 52 MODULE_LICENSE("GPL"); 53 54 - 55 - #define I2C_NAME(s) (s)->name 56 - 57 - 58 static int debug; 59 module_param(debug, int, 0644); 60 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 68 /* ----------------------------------------------------------------------- */ 69 ··· 58 int enable; 59 }; 60 61 - #define I2C_SAA7111 0x48 62 - 63 /* ----------------------------------------------------------------------- */ 64 65 - static inline int 66 - saa7111_write (struct i2c_client *client, 67 - u8 reg, 68 - u8 value) 69 { 70 struct saa7111 *decoder = i2c_get_clientdata(client); 71 ··· 68 return i2c_smbus_write_byte_data(client, reg, value); 69 } 70 71 - static inline void 72 - saa7111_write_if_changed(struct i2c_client *client, u8 reg, u8 value) 73 { 74 struct saa7111 *decoder = i2c_get_clientdata(client); 75 ··· 78 } 79 } 80 81 - static int 82 - saa7111_write_block (struct i2c_client *client, 83 - const u8 *data, 84 - unsigned int len) 85 { 86 int ret = -1; 87 u8 reg; ··· 99 decoder->reg[reg++] = data[1]; 100 len -= 2; 101 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) 106 break; 107 } 108 } else { 109 /* do some slow I2C emulation kind of thing */ 110 while (len >= 2) { 111 reg = *data++; 112 - if ((ret = saa7111_write(client, reg, 113 - *data++)) < 0) 114 break; 115 len -= 2; 116 } ··· 118 return ret; 119 } 120 121 - static int 122 - saa7111_init_decoder (struct i2c_client *client, 123 - struct video_decoder_init *init) 124 { 125 return saa7111_write_block(client, init->data, init->len); 126 } 127 128 - static inline int 129 - saa7111_read (struct i2c_client *client, 130 - u8 reg) 131 { 132 return i2c_smbus_read_byte_data(client, reg); 133 } ··· 171 0x17, 0x00, /* 17 - VBI */ 172 }; 173 174 - static int 175 - saa7111_command (struct i2c_client *client, 176 - unsigned int cmd, 177 - void *arg) 178 { 179 struct saa7111 *decoder = i2c_get_clientdata(client); 180 181 switch (cmd) { 182 - 183 case 0: 184 break; 185 case DECODER_INIT: 186 { 187 struct video_decoder_init *init = arg; 188 if (NULL != init) 189 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 - } 196 } 197 198 case DECODER_DUMP: ··· 197 for (i = 0; i < SAA7111_NR_REG; i += 16) { 198 int j; 199 200 - printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i); 201 for (j = 0; j < 16 && i + j < SAA7111_NR_REG; ++j) { 202 - printk(" %02x", 203 saa7111_read(client, i + j)); 204 } 205 - printk("\n"); 206 } 207 - } 208 break; 209 210 case DECODER_GET_CAPABILITIES: 211 { ··· 218 VIDEO_DECODER_CCIR; 219 cap->inputs = 8; 220 cap->outputs = 1; 221 - } 222 break; 223 224 case DECODER_GET_STATUS: 225 { ··· 228 int res; 229 230 status = saa7111_read(client, 0x1f); 231 - dprintk(1, KERN_DEBUG "%s status: 0x%02x\n", I2C_NAME(client), 232 - status); 233 res = 0; 234 if ((status & (1 << 6)) == 0) { 235 res |= DECODER_STATUS_GOOD; ··· 256 res |= DECODER_STATUS_COLOR; 257 } 258 *iarg = res; 259 - } 260 break; 261 262 case DECODER_SET_GPIO: 263 { ··· 324 325 } 326 decoder->norm = *iarg; 327 - } 328 break; 329 330 case DECODER_SET_INPUT: 331 { ··· 349 3) ? 0x80 : 350 0)); 351 } 352 - } 353 break; 354 355 case DECODER_SET_OUTPUT: 356 { ··· 360 if (*iarg != 0) { 361 return -EINVAL; 362 } 363 - } 364 break; 365 366 case DECODER_ENABLE_OUTPUT: 367 { ··· 401 (decoder->reg[0x11] & 0xf3)); 402 } 403 } 404 - } 405 break; 406 407 case DECODER_SET_PICTURE: 408 { ··· 416 saa7111_write(client, 0x0c, pic->colour >> 9); 417 /* We want -128 to 127 we get 0-65535 */ 418 saa7111_write(client, 0x0d, (pic->hue - 32768) >> 8); 419 - } 420 break; 421 422 default: 423 return -EINVAL; ··· 428 429 /* ----------------------------------------------------------------------- */ 430 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 }; 436 437 - static unsigned short ignore = I2C_CLIENT_END; 438 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) 451 { 452 int i; 453 - struct i2c_client *client; 454 struct saa7111 *decoder; 455 struct video_decoder_init vdi; 456 457 - dprintk(1, 458 - KERN_INFO 459 - "saa7111.c: detecting saa7111 client on address 0x%x\n", 460 - address << 1); 461 - 462 /* Check if the adapter supports the needed features */ 463 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 464 - return 0; 465 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))); 473 474 decoder = kzalloc(sizeof(struct saa7111), GFP_KERNEL); 475 if (decoder == NULL) { ··· 456 decoder->enable = 1; 457 i2c_set_clientdata(client, decoder); 458 459 - i = i2c_attach_client(client); 460 - if (i) { 461 - kfree(client); 462 - kfree(decoder); 463 - return i; 464 - } 465 - 466 vdi.data = saa7111_i2c_init; 467 vdi.len = sizeof(saa7111_i2c_init); 468 i = saa7111_init_decoder(client, &vdi); 469 if (i < 0) { 470 - dprintk(1, KERN_ERR "%s_attach error: init status %d\n", 471 - I2C_NAME(client), i); 472 } 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); 478 } 479 - 480 return 0; 481 } 482 483 - static int 484 - saa7111_attach_adapter (struct i2c_adapter *adapter) 485 { 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 - 507 return 0; 508 } 509 510 /* ----------------------------------------------------------------------- */ 511 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, 522 }; 523 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);
··· 28 */ 29 30 #include <linux/module.h> 31 #include <linux/types.h> 32 + #include <linux/ioctl.h> 33 #include <asm/uaccess.h> 34 + #include <linux/i2c.h> 35 + #include <linux/i2c-id.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> 40 41 MODULE_DESCRIPTION("Philips SAA7111 video decoder driver"); 42 MODULE_AUTHOR("Dave Perks"); 43 MODULE_LICENSE("GPL"); 44 45 static int debug; 46 module_param(debug, int, 0644); 47 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 48 49 /* ----------------------------------------------------------------------- */ 50 ··· 77 int enable; 78 }; 79 80 /* ----------------------------------------------------------------------- */ 81 82 + static inline int saa7111_write(struct i2c_client *client, u8 reg, u8 value) 83 { 84 struct saa7111 *decoder = i2c_get_clientdata(client); 85 ··· 92 return i2c_smbus_write_byte_data(client, reg, value); 93 } 94 95 + static inline void saa7111_write_if_changed(struct i2c_client *client, u8 reg, u8 value) 96 { 97 struct saa7111 *decoder = i2c_get_clientdata(client); 98 ··· 103 } 104 } 105 106 + static int saa7111_write_block(struct i2c_client *client, const u8 *data, unsigned int len) 107 { 108 int ret = -1; 109 u8 reg; ··· 127 decoder->reg[reg++] = data[1]; 128 len -= 2; 129 data += 2; 130 + } while (len >= 2 && data[0] == reg && block_len < 32); 131 + ret = i2c_master_send(client, block_data, block_len); 132 + if (ret < 0) 133 break; 134 } 135 } else { 136 /* do some slow I2C emulation kind of thing */ 137 while (len >= 2) { 138 reg = *data++; 139 + ret = saa7111_write(client, reg, *data++); 140 + if (ret < 0) 141 break; 142 len -= 2; 143 } ··· 147 return ret; 148 } 149 150 + static int saa7111_init_decoder(struct i2c_client *client, 151 + struct video_decoder_init *init) 152 { 153 return saa7111_write_block(client, init->data, init->len); 154 } 155 156 + static inline int saa7111_read(struct i2c_client *client, u8 reg) 157 { 158 return i2c_smbus_read_byte_data(client, reg); 159 } ··· 203 0x17, 0x00, /* 17 - VBI */ 204 }; 205 206 + static int saa7111_command(struct i2c_client *client, unsigned cmd, void *arg) 207 { 208 struct saa7111 *decoder = i2c_get_clientdata(client); 209 210 switch (cmd) { 211 case 0: 212 break; 213 case DECODER_INIT: 214 { 215 struct video_decoder_init *init = arg; 216 + struct video_decoder_init vdi; 217 + 218 if (NULL != init) 219 return saa7111_init_decoder(client, init); 220 + vdi.data = saa7111_i2c_init; 221 + vdi.len = sizeof(saa7111_i2c_init); 222 + return saa7111_init_decoder(client, &vdi); 223 } 224 225 case DECODER_DUMP: ··· 234 for (i = 0; i < SAA7111_NR_REG; i += 16) { 235 int j; 236 237 + v4l_info(client, "%03x", i); 238 for (j = 0; j < 16 && i + j < SAA7111_NR_REG; ++j) { 239 + printk(KERN_CONT " %02x", 240 saa7111_read(client, i + j)); 241 } 242 + printk(KERN_CONT "\n"); 243 } 244 break; 245 + } 246 247 case DECODER_GET_CAPABILITIES: 248 { ··· 255 VIDEO_DECODER_CCIR; 256 cap->inputs = 8; 257 cap->outputs = 1; 258 break; 259 + } 260 261 case DECODER_GET_STATUS: 262 { ··· 265 int res; 266 267 status = saa7111_read(client, 0x1f); 268 + v4l_dbg(1, debug, client, "status: 0x%02x\n", status); 269 res = 0; 270 if ((status & (1 << 6)) == 0) { 271 res |= DECODER_STATUS_GOOD; ··· 294 res |= DECODER_STATUS_COLOR; 295 } 296 *iarg = res; 297 break; 298 + } 299 300 case DECODER_SET_GPIO: 301 { ··· 362 363 } 364 decoder->norm = *iarg; 365 break; 366 + } 367 368 case DECODER_SET_INPUT: 369 { ··· 387 3) ? 0x80 : 388 0)); 389 } 390 break; 391 + } 392 393 case DECODER_SET_OUTPUT: 394 { ··· 398 if (*iarg != 0) { 399 return -EINVAL; 400 } 401 break; 402 + } 403 404 case DECODER_ENABLE_OUTPUT: 405 { ··· 439 (decoder->reg[0x11] & 0xf3)); 440 } 441 } 442 break; 443 + } 444 445 case DECODER_SET_PICTURE: 446 { ··· 454 saa7111_write(client, 0x0c, pic->colour >> 9); 455 /* We want -128 to 127 we get 0-65535 */ 456 saa7111_write(client, 0x0d, (pic->hue - 32768) >> 8); 457 break; 458 + } 459 460 default: 461 return -EINVAL; ··· 466 467 /* ----------------------------------------------------------------------- */ 468 469 + static unsigned short normal_i2c[] = { 0x48 >> 1, I2C_CLIENT_END }; 470 471 + I2C_CLIENT_INSMOD; 472 473 + static int saa7111_probe(struct i2c_client *client, 474 + const struct i2c_device_id *id) 475 { 476 int i; 477 struct saa7111 *decoder; 478 struct video_decoder_init vdi; 479 480 /* Check if the adapter supports the needed features */ 481 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 482 + return -ENODEV; 483 484 + v4l_info(client, "chip found @ 0x%x (%s)\n", 485 + client->addr << 1, client->adapter->name); 486 487 decoder = kzalloc(sizeof(struct saa7111), GFP_KERNEL); 488 if (decoder == NULL) { ··· 519 decoder->enable = 1; 520 i2c_set_clientdata(client, decoder); 521 522 vdi.data = saa7111_i2c_init; 523 vdi.len = sizeof(saa7111_i2c_init); 524 i = saa7111_init_decoder(client, &vdi); 525 if (i < 0) { 526 + v4l_dbg(1, debug, client, "init status %d\n", i); 527 } else { 528 + v4l_dbg(1, debug, client, "revision %x\n", 529 + saa7111_read(client, 0x00) >> 4); 530 } 531 return 0; 532 } 533 534 + static int saa7111_remove(struct i2c_client *client) 535 { 536 + kfree(i2c_get_clientdata(client)); 537 return 0; 538 } 539 540 /* ----------------------------------------------------------------------- */ 541 542 + static const struct i2c_device_id saa7111_id[] = { 543 + { "saa7111_old", 0 }, /* "saa7111" maps to the saa7115 driver */ 544 + { } 545 }; 546 + MODULE_DEVICE_TABLE(i2c, saa7111_id); 547 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 */ 30 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 <linux/types.h> 42 - #include <linux/i2c.h> 43 - #include <asm/io.h> 44 - #include <asm/pgtable.h> 45 - #include <asm/page.h> 46 #include <asm/uaccess.h> 47 - 48 #include <linux/videodev.h> 49 #include <linux/video_decoder.h> 50 51 MODULE_DESCRIPTION("Philips SAA7114H video decoder driver"); 52 MODULE_AUTHOR("Maxim Yevtyushkin"); 53 MODULE_LICENSE("GPL"); 54 55 - 56 - #define I2C_NAME(x) (x)->name 57 - 58 - 59 static int debug; 60 module_param(debug, int, 0); 61 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 69 /* ----------------------------------------------------------------------- */ 70 ··· 61 int sat; 62 int playback; 63 }; 64 - 65 - #define I2C_SAA7114 0x42 66 - #define I2C_SAA7114A 0x40 67 68 #define I2C_DELAY 10 69 ··· 107 108 /* ----------------------------------------------------------------------- */ 109 110 - static inline int 111 - saa7114_write (struct i2c_client *client, 112 - u8 reg, 113 - u8 value) 114 { 115 return i2c_smbus_write_byte_data(client, reg, value); 116 } 117 118 - static int 119 - saa7114_write_block (struct i2c_client *client, 120 - const u8 *data, 121 - unsigned int len) 122 { 123 int ret = -1; 124 u8 reg; ··· 132 reg++; 133 len -= 2; 134 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) 139 break; 140 } 141 } else { 142 /* do some slow I2C emulation kind of thing */ 143 while (len >= 2) { 144 reg = *data++; 145 - if ((ret = saa7114_write(client, reg, 146 - *data++)) < 0) 147 break; 148 len -= 2; 149 } ··· 151 return ret; 152 } 153 154 - static inline int 155 - saa7114_read (struct i2c_client *client, 156 - u8 reg) 157 { 158 return i2c_smbus_read_byte_data(client, reg); 159 } ··· 421 0xef, 0x00 422 }; 423 424 - static int 425 - saa7114_command (struct i2c_client *client, 426 - unsigned int cmd, 427 - void *arg) 428 { 429 struct saa7114 *decoder = i2c_get_clientdata(client); 430 431 switch (cmd) { 432 - 433 case 0: 434 //dprintk(1, KERN_INFO "%s: writing init\n", I2C_NAME(client)); 435 //saa7114_write_block(client, init, sizeof(init)); ··· 435 { 436 int i; 437 438 - dprintk(1, KERN_INFO "%s: decoder dump\n", I2C_NAME(client)); 439 440 for (i = 0; i < 32; i += 16) { 441 int j; 442 443 - printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i); 444 for (j = 0; j < 16; ++j) { 445 - printk(" %02x", 446 saa7114_read(client, i + j)); 447 } 448 - printk("\n"); 449 } 450 - } 451 break; 452 453 case DECODER_GET_CAPABILITIES: 454 { 455 struct video_decoder_capability *cap = arg; 456 457 - dprintk(1, KERN_DEBUG "%s: decoder get capabilities\n", 458 - I2C_NAME(client)); 459 460 cap->flags = VIDEO_DECODER_PAL | 461 VIDEO_DECODER_NTSC | ··· 464 VIDEO_DECODER_CCIR; 465 cap->inputs = 8; 466 cap->outputs = 1; 467 - } 468 break; 469 470 case DECODER_GET_STATUS: 471 { ··· 475 476 status = saa7114_read(client, 0x1f); 477 478 - dprintk(1, KERN_DEBUG "%s status: 0x%02x\n", I2C_NAME(client), 479 - status); 480 res = 0; 481 if ((status & (1 << 6)) == 0) { 482 res |= DECODER_STATUS_GOOD; ··· 503 res |= DECODER_STATUS_COLOR; 504 } 505 *iarg = res; 506 - } 507 break; 508 509 case DECODER_SET_NORM: 510 { ··· 512 513 short int hoff = 0, voff = 0, w = 0, h = 0; 514 515 - dprintk(1, KERN_DEBUG "%s: decoder set norm ", 516 - I2C_NAME(client)); 517 - switch (*iarg) { 518 519 case VIDEO_MODE_NTSC: 520 - dprintk(1, "NTSC\n"); 521 decoder->reg[REG_ADDR(0x06)] = 522 SAA_7114_NTSC_HSYNC_START; 523 decoder->reg[REG_ADDR(0x07)] = ··· 535 break; 536 537 case VIDEO_MODE_PAL: 538 - dprintk(1, "PAL\n"); 539 decoder->reg[REG_ADDR(0x06)] = 540 SAA_7114_PAL_HSYNC_START; 541 decoder->reg[REG_ADDR(0x07)] = ··· 554 break; 555 556 default: 557 - dprintk(1, " Unknown video mode!!!\n"); 558 return -EINVAL; 559 - 560 } 561 562 ··· 607 saa7114_write(client, 0x80, 0x36); // i-port and scaler back end clock selection 608 609 decoder->norm = *iarg; 610 - } 611 break; 612 613 case DECODER_SET_INPUT: 614 { 615 int *iarg = arg; 616 617 - dprintk(1, KERN_DEBUG "%s: decoder set input (%d)\n", 618 - I2C_NAME(client), *iarg); 619 if (*iarg < 0 || *iarg > 7) { 620 return -EINVAL; 621 } 622 623 if (decoder->input != *iarg) { 624 - dprintk(1, KERN_DEBUG "%s: now setting %s input\n", 625 - I2C_NAME(client), 626 *iarg >= 6 ? "S-Video" : "Composite"); 627 decoder->input = *iarg; 628 ··· 651 saa7114_write(client, 0x0e, 652 decoder->reg[REG_ADDR(0x0e)]); 653 } 654 - } 655 break; 656 657 case DECODER_SET_OUTPUT: 658 { 659 int *iarg = arg; 660 661 - dprintk(1, KERN_DEBUG "%s: decoder set output\n", 662 - I2C_NAME(client)); 663 664 /* not much choice of outputs */ 665 if (*iarg != 0) { 666 return -EINVAL; 667 } 668 - } 669 break; 670 671 case DECODER_ENABLE_OUTPUT: 672 { 673 int *iarg = arg; 674 int enable = (*iarg != 0); 675 676 - dprintk(1, KERN_DEBUG "%s: decoder %s output\n", 677 - I2C_NAME(client), enable ? "enable" : "disable"); 678 679 decoder->playback = !enable; 680 ··· 714 saa7114_write(client, 0x80, 0x36); 715 716 } 717 - } 718 break; 719 720 case DECODER_SET_PICTURE: 721 { 722 struct video_picture *pic = arg; 723 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); 729 730 if (decoder->bright != pic->brightness) { 731 /* We want 0 to 255 we get 0-65535 */ ··· 747 saa7114_write(client, 0x0d, 748 (decoder->hue - 32768) >> 8); 749 } 750 - } 751 break; 752 753 default: 754 return -EINVAL; ··· 759 760 /* ----------------------------------------------------------------------- */ 761 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 }; 768 769 - static unsigned short ignore = I2C_CLIENT_END; 770 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) 783 { 784 int i, err[30]; 785 short int hoff = SAA_7114_NTSC_HOFFSET; 786 short int voff = SAA_7114_NTSC_VOFFSET; 787 short int w = SAA_7114_NTSC_WIDTH; 788 short int h = SAA_7114_NTSC_HEIGHT; 789 - struct i2c_client *client; 790 struct saa7114 *decoder; 791 792 - dprintk(1, 793 - KERN_INFO 794 - "saa7114.c: detecting saa7114 client on address 0x%x\n", 795 - address << 1); 796 - 797 /* Check if the adapter supports the needed features */ 798 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 799 - return 0; 800 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))); 808 809 decoder = kzalloc(sizeof(struct saa7114), GFP_KERNEL); 810 - if (decoder == NULL) { 811 - kfree(client); 812 return -ENOMEM; 813 - } 814 decoder->norm = VIDEO_MODE_NTSC; 815 decoder->input = -1; 816 decoder->enable = 1; ··· 867 decoder->reg[REG_ADDR(0x0e)] |= 1; // combfilter on 868 869 870 - dprintk(1, KERN_DEBUG "%s_attach: starting decoder init\n", 871 - I2C_NAME(client)); 872 873 err[0] = 874 saa7114_write_block(client, decoder->reg + (0x20 << 1), ··· 891 892 for (i = 0; i <= 5; i++) { 893 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]); 898 kfree(decoder); 899 - kfree(client); 900 - return 0; 901 } 902 } 903 904 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), 909 decoder->reg[REG_ADDR(i)]); 910 } 911 912 - dprintk(1, 913 - KERN_DEBUG 914 - "%s_attach: performing decoder reset sequence\n", 915 - I2C_NAME(client)); 916 917 err[6] = saa7114_write(client, 0x80, 0x06); // i-port and scaler backend clock selection, task A&B off 918 err[7] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler ··· 915 916 for (i = 6; i <= 8; i++) { 917 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]); 922 kfree(decoder); 923 - kfree(client); 924 - return 0; 925 } 926 } 927 928 - dprintk(1, KERN_INFO "%s_attach: performing the rest of init\n", 929 - I2C_NAME(client)); 930 - 931 932 err[9] = saa7114_write(client, 0x01, decoder->reg[REG_ADDR(0x01)]); 933 err[10] = saa7114_write_block(client, decoder->reg + (0x03 << 1), (0x1e + 1 - 0x03) << 1); // big seq ··· 959 960 for (i = 9; i <= 18; i++) { 961 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]); 966 kfree(decoder); 967 - kfree(client); 968 - return 0; 969 } 970 } 971 972 973 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), 978 decoder->reg[REG_ADDR(i)]); 979 } 980 981 982 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), 987 decoder->reg[REG_ADDR(i)]); 988 } 989 990 991 - dprintk(1, KERN_DEBUG "%s_attach: setting video input\n", 992 - I2C_NAME(client)); 993 994 err[19] = 995 saa7114_write(client, 0x02, decoder->reg[REG_ADDR(0x02)]); ··· 995 996 for (i = 19; i <= 21; i++) { 997 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]); 1002 kfree(decoder); 1003 - kfree(client); 1004 - return 0; 1005 } 1006 } 1007 1008 - dprintk(1, 1009 - KERN_DEBUG 1010 - "%s_attach: performing decoder reset sequence\n", 1011 - I2C_NAME(client)); 1012 1013 err[22] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler 1014 err[23] = saa7114_write(client, 0x88, 0xf8); // sw reset scaler release ··· 1012 1013 for (i = 22; i <= 24; i++) { 1014 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]); 1019 kfree(decoder); 1020 - kfree(client); 1021 - return 0; 1022 } 1023 } 1024 ··· 1024 err[26] = saa7114_write(client, 0x07, init[REG_ADDR(0x07)]); 1025 err[27] = saa7114_write(client, 0x10, init[REG_ADDR(0x10)]); 1026 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, 1031 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), 1036 saa7114_read(client, 0x8f)); 1037 1038 1039 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), 1044 decoder->reg[REG_ADDR(i)]); 1045 } 1046 1047 - i = i2c_attach_client(client); 1048 - if (i) { 1049 - kfree(client); 1050 - kfree(decoder); 1051 - return i; 1052 - } 1053 - 1054 //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 return 0; 1068 } 1069 1070 - static int 1071 - saa7114_attach_adapter (struct i2c_adapter *adapter) 1072 { 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 - 1094 return 0; 1095 } 1096 1097 /* ----------------------------------------------------------------------- */ 1098 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, 1109 }; 1110 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);
··· 29 */ 30 31 #include <linux/module.h> 32 #include <linux/types.h> 33 + #include <linux/ioctl.h> 34 #include <asm/uaccess.h> 35 + #include <linux/i2c.h> 36 + #include <linux/i2c-id.h> 37 #include <linux/videodev.h> 38 #include <linux/video_decoder.h> 39 + #include <media/v4l2-common.h> 40 + #include <media/v4l2-i2c-drv-legacy.h> 41 42 MODULE_DESCRIPTION("Philips SAA7114H video decoder driver"); 43 MODULE_AUTHOR("Maxim Yevtyushkin"); 44 MODULE_LICENSE("GPL"); 45 46 static int debug; 47 module_param(debug, int, 0); 48 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 49 50 /* ----------------------------------------------------------------------- */ 51 ··· 80 int sat; 81 int playback; 82 }; 83 84 #define I2C_DELAY 10 85 ··· 129 130 /* ----------------------------------------------------------------------- */ 131 132 + static inline int saa7114_write(struct i2c_client *client, u8 reg, u8 value) 133 { 134 return i2c_smbus_write_byte_data(client, reg, value); 135 } 136 137 + static int saa7114_write_block(struct i2c_client *client, const u8 *data, unsigned int len) 138 { 139 int ret = -1; 140 u8 reg; ··· 160 reg++; 161 len -= 2; 162 data += 2; 163 + } while (len >= 2 && data[0] == reg && block_len < 32); 164 + ret = i2c_master_send(client, block_data, block_len); 165 + if (ret < 0) 166 break; 167 } 168 } else { 169 /* do some slow I2C emulation kind of thing */ 170 while (len >= 2) { 171 reg = *data++; 172 + ret = saa7114_write(client, reg, *data++); 173 + if (ret < 0) 174 break; 175 len -= 2; 176 } ··· 180 return ret; 181 } 182 183 + static inline int saa7114_read(struct i2c_client *client, u8 reg) 184 { 185 return i2c_smbus_read_byte_data(client, reg); 186 } ··· 452 0xef, 0x00 453 }; 454 455 + static int saa7114_command(struct i2c_client *client, unsigned cmd, void *arg) 456 { 457 struct saa7114 *decoder = i2c_get_clientdata(client); 458 459 switch (cmd) { 460 case 0: 461 //dprintk(1, KERN_INFO "%s: writing init\n", I2C_NAME(client)); 462 //saa7114_write_block(client, init, sizeof(init)); ··· 470 { 471 int i; 472 473 + if (!debug) 474 + break; 475 + v4l_info(client, "decoder dump\n"); 476 477 for (i = 0; i < 32; i += 16) { 478 int j; 479 480 + v4l_info(client, "%03x", i); 481 for (j = 0; j < 16; ++j) { 482 + printk(KERN_CONT " %02x", 483 saa7114_read(client, i + j)); 484 } 485 + printk(KERN_CONT "\n"); 486 } 487 break; 488 + } 489 490 case DECODER_GET_CAPABILITIES: 491 { 492 struct video_decoder_capability *cap = arg; 493 494 + v4l_dbg(1, debug, client, "get capabilities\n"); 495 496 cap->flags = VIDEO_DECODER_PAL | 497 VIDEO_DECODER_NTSC | ··· 498 VIDEO_DECODER_CCIR; 499 cap->inputs = 8; 500 cap->outputs = 1; 501 break; 502 + } 503 504 case DECODER_GET_STATUS: 505 { ··· 509 510 status = saa7114_read(client, 0x1f); 511 512 + v4l_dbg(1, debug, client, "status: 0x%02x\n", status); 513 res = 0; 514 if ((status & (1 << 6)) == 0) { 515 res |= DECODER_STATUS_GOOD; ··· 538 res |= DECODER_STATUS_COLOR; 539 } 540 *iarg = res; 541 break; 542 + } 543 544 case DECODER_SET_NORM: 545 { ··· 547 548 short int hoff = 0, voff = 0, w = 0, h = 0; 549 550 + v4l_dbg(1, debug, client, "set norm\n"); 551 552 + switch (*iarg) { 553 case VIDEO_MODE_NTSC: 554 + v4l_dbg(1, debug, client, "NTSC\n"); 555 decoder->reg[REG_ADDR(0x06)] = 556 SAA_7114_NTSC_HSYNC_START; 557 decoder->reg[REG_ADDR(0x07)] = ··· 571 break; 572 573 case VIDEO_MODE_PAL: 574 + v4l_dbg(1, debug, client, "PAL\n"); 575 decoder->reg[REG_ADDR(0x06)] = 576 SAA_7114_PAL_HSYNC_START; 577 decoder->reg[REG_ADDR(0x07)] = ··· 590 break; 591 592 default: 593 + v4l_dbg(1, debug, client, "Unknown video mode\n"); 594 return -EINVAL; 595 } 596 597 ··· 644 saa7114_write(client, 0x80, 0x36); // i-port and scaler back end clock selection 645 646 decoder->norm = *iarg; 647 break; 648 + } 649 650 case DECODER_SET_INPUT: 651 { 652 int *iarg = arg; 653 654 + v4l_dbg(1, debug, client, "set input (%d)\n", *iarg); 655 if (*iarg < 0 || *iarg > 7) { 656 return -EINVAL; 657 } 658 659 if (decoder->input != *iarg) { 660 + v4l_dbg(1, debug, client, "now setting %s input\n", 661 *iarg >= 6 ? "S-Video" : "Composite"); 662 decoder->input = *iarg; 663 ··· 690 saa7114_write(client, 0x0e, 691 decoder->reg[REG_ADDR(0x0e)]); 692 } 693 break; 694 + } 695 696 case DECODER_SET_OUTPUT: 697 { 698 int *iarg = arg; 699 700 + v4l_dbg(1, debug, client, "set output\n"); 701 702 /* not much choice of outputs */ 703 if (*iarg != 0) { 704 return -EINVAL; 705 } 706 break; 707 + } 708 709 case DECODER_ENABLE_OUTPUT: 710 { 711 int *iarg = arg; 712 int enable = (*iarg != 0); 713 714 + v4l_dbg(1, debug, client, "%s output\n", 715 + enable ? "enable" : "disable"); 716 717 decoder->playback = !enable; 718 ··· 754 saa7114_write(client, 0x80, 0x36); 755 756 } 757 break; 758 + } 759 760 case DECODER_SET_PICTURE: 761 { 762 struct video_picture *pic = arg; 763 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); 767 768 if (decoder->bright != pic->brightness) { 769 /* We want 0 to 255 we get 0-65535 */ ··· 789 saa7114_write(client, 0x0d, 790 (decoder->hue - 32768) >> 8); 791 } 792 break; 793 + } 794 795 default: 796 return -EINVAL; ··· 801 802 /* ----------------------------------------------------------------------- */ 803 804 + static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END }; 805 806 + I2C_CLIENT_INSMOD; 807 808 + static int saa7114_probe(struct i2c_client *client, 809 + const struct i2c_device_id *id) 810 { 811 int i, err[30]; 812 short int hoff = SAA_7114_NTSC_HOFFSET; 813 short int voff = SAA_7114_NTSC_VOFFSET; 814 short int w = SAA_7114_NTSC_WIDTH; 815 short int h = SAA_7114_NTSC_HEIGHT; 816 struct saa7114 *decoder; 817 818 /* Check if the adapter supports the needed features */ 819 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 820 + return -ENODEV; 821 822 + v4l_info(client, "chip found @ 0x%x (%s)\n", 823 + client->addr << 1, client->adapter->name); 824 825 decoder = kzalloc(sizeof(struct saa7114), GFP_KERNEL); 826 + if (decoder == NULL) 827 return -ENOMEM; 828 decoder->norm = VIDEO_MODE_NTSC; 829 decoder->input = -1; 830 decoder->enable = 1; ··· 937 decoder->reg[REG_ADDR(0x0e)] |= 1; // combfilter on 938 939 940 + v4l_dbg(1, debug, client, "starting init\n"); 941 942 err[0] = 943 saa7114_write_block(client, decoder->reg + (0x20 << 1), ··· 962 963 for (i = 0; i <= 5; i++) { 964 if (err[i] < 0) { 965 + v4l_dbg(1, debug, client, 966 + "init error %d at stage %d, leaving attach.\n", 967 + i, err[i]); 968 kfree(decoder); 969 + return -EIO; 970 } 971 } 972 973 for (i = 6; i < 8; i++) { 974 + v4l_dbg(1, debug, client, 975 + "reg[0x%02x] = 0x%02x (0x%02x)\n", 976 + i, saa7114_read(client, i), 977 decoder->reg[REG_ADDR(i)]); 978 } 979 980 + v4l_dbg(1, debug, client, 981 + "performing decoder reset sequence\n"); 982 983 err[6] = saa7114_write(client, 0x80, 0x06); // i-port and scaler backend clock selection, task A&B off 984 err[7] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler ··· 991 992 for (i = 6; i <= 8; i++) { 993 if (err[i] < 0) { 994 + v4l_dbg(1, debug, client, 995 + "init error %d at stage %d, leaving attach.\n", 996 + i, err[i]); 997 kfree(decoder); 998 + return -EIO; 999 } 1000 } 1001 1002 + v4l_dbg(1, debug, client, "performing the rest of init\n"); 1003 1004 err[9] = saa7114_write(client, 0x01, decoder->reg[REG_ADDR(0x01)]); 1005 err[10] = saa7114_write_block(client, decoder->reg + (0x03 << 1), (0x1e + 1 - 0x03) << 1); // big seq ··· 1039 1040 for (i = 9; i <= 18; i++) { 1041 if (err[i] < 0) { 1042 + v4l_dbg(1, debug, client, 1043 + "init error %d at stage %d, leaving attach.\n", 1044 + i, err[i]); 1045 kfree(decoder); 1046 + return -EIO; 1047 } 1048 } 1049 1050 1051 for (i = 6; i < 8; i++) { 1052 + v4l_dbg(1, debug, client, 1053 + "reg[0x%02x] = 0x%02x (0x%02x)\n", 1054 + i, saa7114_read(client, i), 1055 decoder->reg[REG_ADDR(i)]); 1056 } 1057 1058 1059 for (i = 0x11; i <= 0x13; i++) { 1060 + v4l_dbg(1, debug, client, 1061 + "reg[0x%02x] = 0x%02x (0x%02x)\n", 1062 + i, saa7114_read(client, i), 1063 decoder->reg[REG_ADDR(i)]); 1064 } 1065 1066 1067 + v4l_dbg(1, debug, client, "setting video input\n"); 1068 1069 err[19] = 1070 saa7114_write(client, 0x02, decoder->reg[REG_ADDR(0x02)]); ··· 1080 1081 for (i = 19; i <= 21; i++) { 1082 if (err[i] < 0) { 1083 + v4l_dbg(1, debug, client, 1084 + "init error %d at stage %d, leaving attach.\n", 1085 + i, err[i]); 1086 kfree(decoder); 1087 + return -EIO; 1088 } 1089 } 1090 1091 + v4l_dbg(1, debug, client, "performing decoder reset sequence\n"); 1092 1093 err[22] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler 1094 err[23] = saa7114_write(client, 0x88, 0xf8); // sw reset scaler release ··· 1102 1103 for (i = 22; i <= 24; i++) { 1104 if (err[i] < 0) { 1105 + v4l_dbg(1, debug, client, 1106 + "init error %d at stage %d, leaving attach.\n", 1107 + i, err[i]); 1108 kfree(decoder); 1109 + return -EIO; 1110 } 1111 } 1112 ··· 1116 err[26] = saa7114_write(client, 0x07, init[REG_ADDR(0x07)]); 1117 err[27] = saa7114_write(client, 0x10, init[REG_ADDR(0x10)]); 1118 1119 + v4l_dbg(1, debug, client, "chip version %x, decoder status 0x%02x\n", 1120 + saa7114_read(client, 0x00) >> 4, 1121 saa7114_read(client, 0x1f)); 1122 + v4l_dbg(1, debug, client, 1123 + "power save control: 0x%02x, scaler status: 0x%02x\n", 1124 + saa7114_read(client, 0x88), 1125 saa7114_read(client, 0x8f)); 1126 1127 1128 for (i = 0x94; i < 0x96; i++) { 1129 + v4l_dbg(1, debug, client, 1130 + "reg[0x%02x] = 0x%02x (0x%02x)\n", 1131 + i, saa7114_read(client, i), 1132 decoder->reg[REG_ADDR(i)]); 1133 } 1134 1135 //i = saa7114_write_block(client, init, sizeof(init)); 1136 return 0; 1137 } 1138 1139 + static int saa7114_remove(struct i2c_client *client) 1140 { 1141 + kfree(i2c_get_clientdata(client)); 1142 return 0; 1143 } 1144 1145 /* ----------------------------------------------------------------------- */ 1146 1147 + static const struct i2c_device_id saa7114_id[] = { 1148 + { "saa7114_old", 0 }, /* "saa7114" maps to the saa7115 driver */ 1149 + { } 1150 }; 1151 + MODULE_DEVICE_TABLE(i2c, saa7114_id); 1152 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 * Note: the saa7126 is identical to the saa7127, and the saa7128 is 30 * identical to the saa7129, except that the saa7126 and saa7128 have 31 * macrovision anti-taping support. This driver will almost certainly 32 - * work find for those chips, except of course for the missing anti-taping 33 * support. 34 * 35 * This program is free software; you can redistribute it and/or modify
··· 29 * Note: the saa7126 is identical to the saa7127, and the saa7128 is 30 * identical to the saa7129, except that the saa7126 and saa7128 have 31 * macrovision anti-taping support. This driver will almost certainly 32 + * work fine for those chips, except of course for the missing anti-taping 33 * support. 34 * 35 * This program is free software; you can redistribute it and/or modify
+123 -93
drivers/media/video/saa7134/saa7134-dvb.c
··· 535 struct tda1004x_config *cdec_conf, 536 struct tda827x_config *tuner_conf) 537 { 538 - dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap); 539 - if (dev->dvb.frontend) { 540 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, 543 cdec_conf->tuner_address, 544 &dev->i2c_adap, tuner_conf)) 545 return 0; ··· 949 { 950 int ret; 951 int attach_xc3028 = 0; 952 953 /* init struct videobuf_dvb */ 954 dev->ts.nr_bufs = 32; 955 dev->ts.nr_packets = 32*4; 956 - dev->dvb.name = dev->name; 957 - videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops, 958 &dev->pci->dev, &dev->slock, 959 V4L2_BUF_TYPE_VIDEO_CAPTURE, 960 V4L2_FIELD_ALTERNATE, ··· 982 switch (dev->board) { 983 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: 984 dprintk("pinnacle 300i dvb setup\n"); 985 - dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i, 986 &dev->i2c_adap); 987 - if (dev->dvb.frontend) { 988 - dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params; 989 } 990 break; 991 case SAA7134_BOARD_AVERMEDIA_777: 992 case SAA7134_BOARD_AVERMEDIA_A16AR: 993 dprintk("avertv 777 dvb setup\n"); 994 - dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, 995 &dev->i2c_adap); 996 - if (dev->dvb.frontend) { 997 - dvb_attach(simple_tuner_attach, dev->dvb.frontend, 998 &dev->i2c_adap, 0x61, 999 TUNER_PHILIPS_TD1316); 1000 } 1001 break; 1002 case SAA7134_BOARD_AVERMEDIA_A16D: 1003 dprintk("AverMedia A16D dvb setup\n"); 1004 - dev->dvb.frontend = dvb_attach(mt352_attach, 1005 &avermedia_xc3028_mt352_dev, 1006 &dev->i2c_adap); 1007 attach_xc3028 = 1; 1008 break; 1009 case SAA7134_BOARD_MD7134: 1010 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1011 &medion_cardbus, 1012 &dev->i2c_adap); 1013 - if (dev->dvb.frontend) { 1014 - dvb_attach(simple_tuner_attach, dev->dvb.frontend, 1015 &dev->i2c_adap, medion_cardbus.tuner_address, 1016 TUNER_PHILIPS_FMD1216ME_MK3); 1017 } 1018 break; 1019 case SAA7134_BOARD_PHILIPS_TOUGH: 1020 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1021 &philips_tu1216_60_config, 1022 &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; 1026 } 1027 break; 1028 case SAA7134_BOARD_FLYDVBTDUO: ··· 1033 break; 1034 case SAA7134_BOARD_PHILIPS_EUROPA: 1035 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 1036 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1037 &philips_europa_config, 1038 &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; 1045 } 1046 break; 1047 case SAA7134_BOARD_VIDEOMATE_DVBT_200: 1048 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1049 &philips_tu1216_61_config, 1050 &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; 1054 } 1055 break; 1056 case SAA7134_BOARD_KWORLD_DVBT_210: ··· 1089 &tda827x_cfg_0) < 0) 1090 goto dettach_frontend; 1091 } 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, 1095 &dev->i2c_adap, 0) == NULL) { 1096 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); 1097 goto dettach_frontend; 1098 } 1099 - if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, 1100 0x08, 0, 0) == NULL) { 1101 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); 1102 goto dettach_frontend; ··· 1106 break; 1107 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: 1108 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: 1109 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1110 &ads_tech_duo_config, 1111 &dev->i2c_adap); 1112 - if (dev->dvb.frontend) { 1113 - if (dvb_attach(tda827x_attach,dev->dvb.frontend, 1114 ads_tech_duo_config.tuner_address, &dev->i2c_adap, 1115 &ads_duo_cfg) == NULL) { 1116 wprintk("no tda827x tuner found at addr: %02x\n", ··· 1131 &tda827x_cfg_0) < 0) 1132 goto dettach_frontend; 1133 } else { /* satellite */ 1134 - dev->dvb.frontend = dvb_attach(tda10086_attach, 1135 &flydvbs, &dev->i2c_adap); 1136 - if (dev->dvb.frontend) { 1137 - struct dvb_frontend *fe = dev->dvb.frontend; 1138 u8 dev_id = dev->eedata[2]; 1139 u8 data = 0xc4; 1140 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1}; 1141 1142 - if (dvb_attach(tda826x_attach, dev->dvb.frontend, 1143 0x60, &dev->i2c_adap, 0) == NULL) { 1144 wprintk("%s: Medion Quadro, no tda826x " 1145 "found !\n", __func__); ··· 1173 } 1174 break; 1175 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1176 - dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, 1177 &dev->i2c_adap); 1178 - if (dev->dvb.frontend) 1179 - dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 1180 NULL, DVB_PLL_TDHU2); 1181 break; 1182 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI: 1183 case SAA7134_BOARD_KWORLD_ATSC110: 1184 - dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, 1185 &dev->i2c_adap); 1186 - if (dev->dvb.frontend) 1187 - dvb_attach(simple_tuner_attach, dev->dvb.frontend, 1188 &dev->i2c_adap, 0x61, 1189 TUNER_PHILIPS_TUV1236D); 1190 break; 1191 case SAA7134_BOARD_FLYDVBS_LR300: 1192 - dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1193 &dev->i2c_adap); 1194 - if (dev->dvb.frontend) { 1195 - if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1196 &dev->i2c_adap, 0) == NULL) { 1197 wprintk("%s: No tda826x found!\n", __func__); 1198 goto dettach_frontend; 1199 } 1200 - if (dvb_attach(isl6421_attach, dev->dvb.frontend, 1201 &dev->i2c_adap, 0x08, 0, 0) == NULL) { 1202 wprintk("%s: No ISL6421 found!\n", __func__); 1203 goto dettach_frontend; ··· 1205 } 1206 break; 1207 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: 1208 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1209 &medion_cardbus, 1210 &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; 1214 1215 - dvb_attach(simple_tuner_attach, dev->dvb.frontend, 1216 &dev->i2c_adap, medion_cardbus.tuner_address, 1217 TUNER_PHILIPS_FMD1216ME_MK3); 1218 } 1219 break; 1220 case SAA7134_BOARD_VIDEOMATE_DVBT_200A: 1221 - dev->dvb.frontend = dvb_attach(tda10046_attach, 1222 &philips_europa_config, 1223 &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; 1227 } 1228 break; 1229 case SAA7134_BOARD_CINERGY_HT_PCMCIA: ··· 1262 goto dettach_frontend; 1263 break; 1264 case SAA7134_BOARD_PHILIPS_SNAKE: 1265 - dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1266 &dev->i2c_adap); 1267 - if (dev->dvb.frontend) { 1268 - if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1269 &dev->i2c_adap, 0) == NULL) { 1270 wprintk("%s: No tda826x found!\n", __func__); 1271 goto dettach_frontend; 1272 } 1273 - if (dvb_attach(lnbp21_attach, dev->dvb.frontend, 1274 &dev->i2c_adap, 0, 0) == NULL) { 1275 wprintk("%s: No lnbp21 found!\n", __func__); 1276 goto dettach_frontend; ··· 1292 saa7134_set_gpio(dev, 25, 0); 1293 msleep(10); 1294 saa7134_set_gpio(dev, 25, 1); 1295 - dev->dvb.frontend = dvb_attach(mt352_attach, 1296 &avermedia_xc3028_mt352_dev, 1297 &dev->i2c_adap); 1298 attach_xc3028 = 1; 1299 break; 1300 case SAA7134_BOARD_MD7134_BRIDGE_2: 1301 - dev->dvb.frontend = dvb_attach(tda10086_attach, 1302 &sd1878_4m, &dev->i2c_adap); 1303 - if (dev->dvb.frontend) { 1304 struct dvb_frontend *fe; 1305 - if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 1306 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) { 1307 wprintk("%s: MD7134 DVB-S, no SD1878 " 1308 "found !\n", __func__); 1309 goto dettach_frontend; 1310 } 1311 /* we need to open the i2c gate (we know it exists) */ 1312 - fe = dev->dvb.frontend; 1313 fe->ops.i2c_gate_ctrl(fe, 1); 1314 if (dvb_attach(isl6405_attach, fe, 1315 &dev->i2c_adap, 0x08, 0, 0) == NULL) { ··· 1328 saa7134_set_gpio(dev, 25, 0); 1329 msleep(10); 1330 saa7134_set_gpio(dev, 25, 1); 1331 - dev->dvb.frontend = dvb_attach(mt352_attach, 1332 &avermedia_xc3028_mt352_dev, 1333 &dev->i2c_adap); 1334 attach_xc3028 = 1; ··· 1339 &tda827x_cfg_2) < 0) 1340 goto dettach_frontend; 1341 } else { /* satellite */ 1342 - dev->dvb.frontend = dvb_attach(tda10086_attach, 1343 &flydvbs, &dev->i2c_adap); 1344 - if (dev->dvb.frontend) { 1345 if (dvb_attach(tda826x_attach, 1346 - dev->dvb.frontend, 0x60, 1347 &dev->i2c_adap, 0) == NULL) { 1348 wprintk("%s: Asus Tiger 3in1, no " 1349 "tda826x found!\n", __func__); 1350 goto dettach_frontend; 1351 } 1352 - if (dvb_attach(lnbp21_attach, dev->dvb.frontend, 1353 &dev->i2c_adap, 0, 0) == NULL) { 1354 wprintk("%s: Asus Tiger 3in1, no lnbp21" 1355 " found!\n", __func__); ··· 1375 .i2c_addr = 0x61, 1376 }; 1377 1378 - if (!dev->dvb.frontend) 1379 return -1; 1380 1381 - fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg); 1382 if (!fe) { 1383 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 1384 dev->name); ··· 1386 } 1387 } 1388 1389 - if (NULL == dev->dvb.frontend) { 1390 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name); 1391 return -1; 1392 } 1393 /* define general-purpose callback pointer */ 1394 - dev->dvb.frontend->callback = saa7134_tuner_callback; 1395 1396 /* register everything else */ 1397 - ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev, 1398 - adapter_nr); 1399 1400 /* this sequence is necessary to make the tda1004x load its firmware 1401 * and to enter analog mode of hybrid boards 1402 */ 1403 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); 1410 } 1411 return ret; 1412 1413 dettach_frontend: 1414 - if (dev->dvb.frontend) 1415 - dvb_frontend_detach(dev->dvb.frontend); 1416 - dev->dvb.frontend = NULL; 1417 1418 return -1; 1419 } 1420 1421 static int dvb_fini(struct saa7134_dev *dev) 1422 { 1423 /* FIXME: I suspect that this code is bogus, since the entry for 1424 Pinnacle 300I DVB-T PAL already defines the proper init to allow 1425 the detection of mt2032 (TDA9887_PORT2_INACTIVE) ··· 1446 u8 data = 0x80; 1447 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1}; 1448 struct dvb_frontend *fe; 1449 - fe = dev->dvb.frontend; 1450 if (fe->ops.i2c_gate_ctrl) { 1451 fe->ops.i2c_gate_ctrl(fe, 1); 1452 i2c_transfer(&dev->i2c_adap, &msg, 1); ··· 1454 } 1455 } 1456 } 1457 - if (dev->dvb.frontend) 1458 - videobuf_dvb_unregister(&dev->dvb); 1459 return 0; 1460 } 1461
··· 535 struct tda1004x_config *cdec_conf, 536 struct tda827x_config *tuner_conf) 537 { 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) { 545 if (cdec_conf->i2c_gate) 546 + fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; 547 + if (dvb_attach(tda827x_attach, fe0->dvb.frontend, 548 cdec_conf->tuner_address, 549 &dev->i2c_adap, tuner_conf)) 550 return 0; ··· 944 { 945 int ret; 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; 965 966 /* init struct videobuf_dvb */ 967 dev->ts.nr_bufs = 32; 968 dev->ts.nr_packets = 32*4; 969 + fe0->dvb.name = dev->name; 970 + videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops, 971 &dev->pci->dev, &dev->slock, 972 V4L2_BUF_TYPE_VIDEO_CAPTURE, 973 V4L2_FIELD_ALTERNATE, ··· 959 switch (dev->board) { 960 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: 961 dprintk("pinnacle 300i dvb setup\n"); 962 + fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i, 963 &dev->i2c_adap); 964 + if (fe0->dvb.frontend) { 965 + fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params; 966 } 967 break; 968 case SAA7134_BOARD_AVERMEDIA_777: 969 case SAA7134_BOARD_AVERMEDIA_A16AR: 970 dprintk("avertv 777 dvb setup\n"); 971 + fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, 972 &dev->i2c_adap); 973 + if (fe0->dvb.frontend) { 974 + dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 975 &dev->i2c_adap, 0x61, 976 TUNER_PHILIPS_TD1316); 977 } 978 break; 979 case SAA7134_BOARD_AVERMEDIA_A16D: 980 dprintk("AverMedia A16D dvb setup\n"); 981 + fe0->dvb.frontend = dvb_attach(mt352_attach, 982 &avermedia_xc3028_mt352_dev, 983 &dev->i2c_adap); 984 attach_xc3028 = 1; 985 break; 986 case SAA7134_BOARD_MD7134: 987 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 988 &medion_cardbus, 989 &dev->i2c_adap); 990 + if (fe0->dvb.frontend) { 991 + dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 992 &dev->i2c_adap, medion_cardbus.tuner_address, 993 TUNER_PHILIPS_FMD1216ME_MK3); 994 } 995 break; 996 case SAA7134_BOARD_PHILIPS_TOUGH: 997 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 998 &philips_tu1216_60_config, 999 &dev->i2c_adap); 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; 1003 } 1004 break; 1005 case SAA7134_BOARD_FLYDVBTDUO: ··· 1010 break; 1011 case SAA7134_BOARD_PHILIPS_EUROPA: 1012 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 1013 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1014 &philips_europa_config, 1015 &dev->i2c_adap); 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; 1022 } 1023 break; 1024 case SAA7134_BOARD_VIDEOMATE_DVBT_200: 1025 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1026 &philips_tu1216_61_config, 1027 &dev->i2c_adap); 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; 1031 } 1032 break; 1033 case SAA7134_BOARD_KWORLD_DVBT_210: ··· 1066 &tda827x_cfg_0) < 0) 1067 goto dettach_frontend; 1068 } else { /* satellite */ 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, 1072 &dev->i2c_adap, 0) == NULL) { 1073 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); 1074 goto dettach_frontend; 1075 } 1076 + if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap, 1077 0x08, 0, 0) == NULL) { 1078 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); 1079 goto dettach_frontend; ··· 1083 break; 1084 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: 1085 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: 1086 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1087 &ads_tech_duo_config, 1088 &dev->i2c_adap); 1089 + if (fe0->dvb.frontend) { 1090 + if (dvb_attach(tda827x_attach,fe0->dvb.frontend, 1091 ads_tech_duo_config.tuner_address, &dev->i2c_adap, 1092 &ads_duo_cfg) == NULL) { 1093 wprintk("no tda827x tuner found at addr: %02x\n", ··· 1108 &tda827x_cfg_0) < 0) 1109 goto dettach_frontend; 1110 } else { /* satellite */ 1111 + fe0->dvb.frontend = dvb_attach(tda10086_attach, 1112 &flydvbs, &dev->i2c_adap); 1113 + if (fe0->dvb.frontend) { 1114 + struct dvb_frontend *fe = fe0->dvb.frontend; 1115 u8 dev_id = dev->eedata[2]; 1116 u8 data = 0xc4; 1117 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1}; 1118 1119 + if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 1120 0x60, &dev->i2c_adap, 0) == NULL) { 1121 wprintk("%s: Medion Quadro, no tda826x " 1122 "found !\n", __func__); ··· 1150 } 1151 break; 1152 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1153 + fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, 1154 &dev->i2c_adap); 1155 + if (fe0->dvb.frontend) 1156 + dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61, 1157 NULL, DVB_PLL_TDHU2); 1158 break; 1159 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI: 1160 case SAA7134_BOARD_KWORLD_ATSC110: 1161 + fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, 1162 &dev->i2c_adap); 1163 + if (fe0->dvb.frontend) 1164 + dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1165 &dev->i2c_adap, 0x61, 1166 TUNER_PHILIPS_TUV1236D); 1167 break; 1168 case SAA7134_BOARD_FLYDVBS_LR300: 1169 + fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1170 &dev->i2c_adap); 1171 + if (fe0->dvb.frontend) { 1172 + if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60, 1173 &dev->i2c_adap, 0) == NULL) { 1174 wprintk("%s: No tda826x found!\n", __func__); 1175 goto dettach_frontend; 1176 } 1177 + if (dvb_attach(isl6421_attach, fe0->dvb.frontend, 1178 &dev->i2c_adap, 0x08, 0, 0) == NULL) { 1179 wprintk("%s: No ISL6421 found!\n", __func__); 1180 goto dettach_frontend; ··· 1182 } 1183 break; 1184 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: 1185 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1186 &medion_cardbus, 1187 &dev->i2c_adap); 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; 1191 1192 + dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1193 &dev->i2c_adap, medion_cardbus.tuner_address, 1194 TUNER_PHILIPS_FMD1216ME_MK3); 1195 } 1196 break; 1197 case SAA7134_BOARD_VIDEOMATE_DVBT_200A: 1198 + fe0->dvb.frontend = dvb_attach(tda10046_attach, 1199 &philips_europa_config, 1200 &dev->i2c_adap); 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; 1204 } 1205 break; 1206 case SAA7134_BOARD_CINERGY_HT_PCMCIA: ··· 1239 goto dettach_frontend; 1240 break; 1241 case SAA7134_BOARD_PHILIPS_SNAKE: 1242 + fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1243 &dev->i2c_adap); 1244 + if (fe0->dvb.frontend) { 1245 + if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60, 1246 &dev->i2c_adap, 0) == NULL) { 1247 wprintk("%s: No tda826x found!\n", __func__); 1248 goto dettach_frontend; 1249 } 1250 + if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, 1251 &dev->i2c_adap, 0, 0) == NULL) { 1252 wprintk("%s: No lnbp21 found!\n", __func__); 1253 goto dettach_frontend; ··· 1269 saa7134_set_gpio(dev, 25, 0); 1270 msleep(10); 1271 saa7134_set_gpio(dev, 25, 1); 1272 + fe0->dvb.frontend = dvb_attach(mt352_attach, 1273 &avermedia_xc3028_mt352_dev, 1274 &dev->i2c_adap); 1275 attach_xc3028 = 1; 1276 break; 1277 case SAA7134_BOARD_MD7134_BRIDGE_2: 1278 + fe0->dvb.frontend = dvb_attach(tda10086_attach, 1279 &sd1878_4m, &dev->i2c_adap); 1280 + if (fe0->dvb.frontend) { 1281 struct dvb_frontend *fe; 1282 + if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60, 1283 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) { 1284 wprintk("%s: MD7134 DVB-S, no SD1878 " 1285 "found !\n", __func__); 1286 goto dettach_frontend; 1287 } 1288 /* we need to open the i2c gate (we know it exists) */ 1289 + fe = fe0->dvb.frontend; 1290 fe->ops.i2c_gate_ctrl(fe, 1); 1291 if (dvb_attach(isl6405_attach, fe, 1292 &dev->i2c_adap, 0x08, 0, 0) == NULL) { ··· 1305 saa7134_set_gpio(dev, 25, 0); 1306 msleep(10); 1307 saa7134_set_gpio(dev, 25, 1); 1308 + fe0->dvb.frontend = dvb_attach(mt352_attach, 1309 &avermedia_xc3028_mt352_dev, 1310 &dev->i2c_adap); 1311 attach_xc3028 = 1; ··· 1316 &tda827x_cfg_2) < 0) 1317 goto dettach_frontend; 1318 } else { /* satellite */ 1319 + fe0->dvb.frontend = dvb_attach(tda10086_attach, 1320 &flydvbs, &dev->i2c_adap); 1321 + if (fe0->dvb.frontend) { 1322 if (dvb_attach(tda826x_attach, 1323 + fe0->dvb.frontend, 0x60, 1324 &dev->i2c_adap, 0) == NULL) { 1325 wprintk("%s: Asus Tiger 3in1, no " 1326 "tda826x found!\n", __func__); 1327 goto dettach_frontend; 1328 } 1329 + if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, 1330 &dev->i2c_adap, 0, 0) == NULL) { 1331 wprintk("%s: Asus Tiger 3in1, no lnbp21" 1332 " found!\n", __func__); ··· 1352 .i2c_addr = 0x61, 1353 }; 1354 1355 + if (!fe0->dvb.frontend) 1356 return -1; 1357 1358 + fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg); 1359 if (!fe) { 1360 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 1361 dev->name); ··· 1363 } 1364 } 1365 1366 + if (NULL == fe0->dvb.frontend) { 1367 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name); 1368 return -1; 1369 } 1370 /* define general-purpose callback pointer */ 1371 + fe0->dvb.frontend->callback = saa7134_tuner_callback; 1372 1373 /* register everything else */ 1374 + ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, 1375 + &dev->pci->dev, adapter_nr, 0); 1376 1377 /* this sequence is necessary to make the tda1004x load its firmware 1378 * and to enter analog mode of hybrid boards 1379 */ 1380 if (!ret) { 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); 1387 } 1388 return ret; 1389 1390 dettach_frontend: 1391 + if (fe0->dvb.frontend) 1392 + dvb_frontend_detach(fe0->dvb.frontend); 1393 + fe0->dvb.frontend = NULL; 1394 1395 return -1; 1396 } 1397 1398 static int dvb_fini(struct saa7134_dev *dev) 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 + 1407 /* FIXME: I suspect that this code is bogus, since the entry for 1408 Pinnacle 300I DVB-T PAL already defines the proper init to allow 1409 the detection of mt2032 (TDA9887_PORT2_INACTIVE) ··· 1416 u8 data = 0x80; 1417 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1}; 1418 struct dvb_frontend *fe; 1419 + fe = fe0->dvb.frontend; 1420 if (fe->ops.i2c_gate_ctrl) { 1421 fe->ops.i2c_gate_ctrl(fe, 1); 1422 i2c_transfer(&dev->i2c_adap, &msg, 1); ··· 1424 } 1425 } 1426 } 1427 + if (fe0->dvb.frontend) 1428 + videobuf_dvb_unregister_bus(&dev->frontends); 1429 return 0; 1430 } 1431
+1 -1
drivers/media/video/saa7134/saa7134.h
··· 581 582 #if defined(CONFIG_VIDEO_SAA7134_DVB) || defined(CONFIG_VIDEO_SAA7134_DVB_MODULE) 583 /* SAA7134_MPEG_DVB only */ 584 - struct videobuf_dvb dvb; 585 int (*original_demod_sleep)(struct dvb_frontend *fe); 586 int (*original_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage); 587 int (*original_set_high_voltage)(struct dvb_frontend *fe, long arg);
··· 581 582 #if defined(CONFIG_VIDEO_SAA7134_DVB) || defined(CONFIG_VIDEO_SAA7134_DVB_MODULE) 583 /* SAA7134_MPEG_DVB only */ 584 + struct videobuf_dvb_frontends frontends; 585 int (*original_demod_sleep)(struct dvb_frontend *fe); 586 int (*original_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage); 587 int (*original_set_high_voltage)(struct dvb_frontend *fe, long arg);
+51 -161
drivers/media/video/saa7185.c
··· 25 */ 26 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 #include <linux/types.h> 38 - #include <linux/i2c.h> 39 - #include <asm/io.h> 40 - #include <asm/pgtable.h> 41 - #include <asm/page.h> 42 #include <asm/uaccess.h> 43 - 44 #include <linux/videodev.h> 45 #include <linux/video_encoder.h> 46 47 MODULE_DESCRIPTION("Philips SAA7185 video encoder driver"); 48 MODULE_AUTHOR("Dave Perks"); 49 MODULE_LICENSE("GPL"); 50 51 52 - #define I2C_NAME(s) (s)->name 53 - 54 - 55 static int debug; 56 module_param(debug, int, 0); 57 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 65 /* ----------------------------------------------------------------------- */ 66 ··· 57 int sat; 58 }; 59 60 - #define I2C_SAA7185 0x88 61 - 62 /* ----------------------------------------------------------------------- */ 63 64 - static inline int 65 - saa7185_read (struct i2c_client *client) 66 { 67 return i2c_smbus_read_byte(client); 68 } 69 70 - static int 71 - saa7185_write (struct i2c_client *client, 72 - u8 reg, 73 - u8 value) 74 { 75 struct saa7185 *encoder = i2c_get_clientdata(client); 76 77 - dprintk(1, KERN_DEBUG "SAA7185: %02x set to %02x\n", reg, value); 78 encoder->reg[reg] = value; 79 return i2c_smbus_write_byte_data(client, reg, value); 80 } 81 82 - static int 83 - saa7185_write_block (struct i2c_client *client, 84 - const u8 *data, 85 - unsigned int len) 86 { 87 int ret = -1; 88 u8 reg; ··· 95 encoder->reg[reg++] = data[1]; 96 len -= 2; 97 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) 102 break; 103 } 104 } else { 105 /* do some slow I2C emulation kind of thing */ 106 while (len >= 2) { 107 reg = *data++; 108 - if ((ret = saa7185_write(client, reg, 109 - *data++)) < 0) 110 break; 111 len -= 2; 112 } ··· 213 0x66, 0x21, /* FSC3 */ 214 }; 215 216 - static int 217 - saa7185_command (struct i2c_client *client, 218 - unsigned int cmd, 219 - void *arg) 220 { 221 struct saa7185 *encoder = i2c_get_clientdata(client); 222 223 switch (cmd) { 224 - 225 case 0: 226 saa7185_write_block(client, init_common, 227 sizeof(init_common)); ··· 233 sizeof(init_pal)); 234 break; 235 } 236 - 237 break; 238 239 case ENCODER_GET_CAPABILITIES: ··· 244 VIDEO_ENCODER_SECAM | VIDEO_ENCODER_CCIR; 245 cap->inputs = 1; 246 cap->outputs = 1; 247 - } 248 break; 249 250 case ENCODER_SET_NORM: 251 { ··· 254 //saa7185_write_block(client, init_common, sizeof(init_common)); 255 256 switch (*iarg) { 257 - 258 case VIDEO_MODE_NTSC: 259 saa7185_write_block(client, init_ntsc, 260 sizeof(init_ntsc)); ··· 267 case VIDEO_MODE_SECAM: 268 default: 269 return -EINVAL; 270 - 271 } 272 encoder->norm = *iarg; 273 - } 274 break; 275 276 case ENCODER_SET_INPUT: 277 { ··· 280 *iarg = 1: input is from ZR36060 */ 281 282 switch (*iarg) { 283 - 284 case 0: 285 /* Switch RTCE to 1 */ 286 saa7185_write(client, 0x61, ··· 297 298 default: 299 return -EINVAL; 300 - 301 } 302 - } 303 break; 304 305 case ENCODER_SET_OUTPUT: 306 { 307 int *iarg = arg; 308 309 /* not much choice of outputs */ 310 - if (*iarg != 0) { 311 return -EINVAL; 312 - } 313 - } 314 break; 315 316 case ENCODER_ENABLE_OUTPUT: 317 { ··· 319 saa7185_write(client, 0x61, 320 (encoder->reg[0x61] & 0xbf) | 321 (encoder->enable ? 0x00 : 0x40)); 322 - } 323 break; 324 325 default: 326 return -EINVAL; ··· 331 332 /* ----------------------------------------------------------------------- */ 333 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 }; 339 340 - static unsigned short ignore = I2C_CLIENT_END; 341 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) 354 { 355 int i; 356 - struct i2c_client *client; 357 struct saa7185 *encoder; 358 359 - dprintk(1, 360 - KERN_INFO 361 - "saa7185.c: detecting saa7185 client on address 0x%x\n", 362 - address << 1); 363 - 364 /* Check if the adapter supports the needed features */ 365 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 366 - return 0; 367 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))); 375 376 encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL); 377 - if (encoder == NULL) { 378 - kfree(client); 379 return -ENOMEM; 380 - } 381 encoder->norm = VIDEO_MODE_NTSC; 382 encoder->enable = 1; 383 i2c_set_clientdata(client, encoder); 384 385 - i = i2c_attach_client(client); 386 - if (i) { 387 - kfree(client); 388 - kfree(encoder); 389 - return i; 390 - } 391 - 392 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 - 408 return 0; 409 } 410 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) 423 { 424 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 432 saa7185_write(client, 0x61, (encoder->reg[0x61]) | 0x40); /* SW: output off is active */ 433 //saa7185_write(client, 0x3a, (encoder->reg[0x3a]) | 0x80); /* SW: color bar */ 434 435 kfree(encoder); 436 - kfree(client); 437 - 438 return 0; 439 } 440 441 /* ----------------------------------------------------------------------- */ 442 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, 453 }; 454 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);
··· 25 */ 26 27 #include <linux/module.h> 28 #include <linux/types.h> 29 + #include <linux/ioctl.h> 30 #include <asm/uaccess.h> 31 + #include <linux/i2c.h> 32 + #include <linux/i2c-id.h> 33 #include <linux/videodev.h> 34 #include <linux/video_encoder.h> 35 + #include <media/v4l2-common.h> 36 + #include <media/v4l2-i2c-drv-legacy.h> 37 38 MODULE_DESCRIPTION("Philips SAA7185 video encoder driver"); 39 MODULE_AUTHOR("Dave Perks"); 40 MODULE_LICENSE("GPL"); 41 42 43 static int debug; 44 module_param(debug, int, 0); 45 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 46 47 /* ----------------------------------------------------------------------- */ 48 ··· 75 int sat; 76 }; 77 78 /* ----------------------------------------------------------------------- */ 79 80 + static inline int saa7185_read(struct i2c_client *client) 81 { 82 return i2c_smbus_read_byte(client); 83 } 84 85 + static int saa7185_write(struct i2c_client *client, u8 reg, u8 value) 86 { 87 struct saa7185 *encoder = i2c_get_clientdata(client); 88 89 + v4l_dbg(1, debug, client, "%02x set to %02x\n", reg, value); 90 encoder->reg[reg] = value; 91 return i2c_smbus_write_byte_data(client, reg, value); 92 } 93 94 + static int saa7185_write_block(struct i2c_client *client, 95 + const u8 *data, unsigned int len) 96 { 97 int ret = -1; 98 u8 reg; ··· 121 encoder->reg[reg++] = data[1]; 122 len -= 2; 123 data += 2; 124 + } while (len >= 2 && data[0] == reg && block_len < 32); 125 + ret = i2c_master_send(client, block_data, block_len); 126 + if (ret < 0) 127 break; 128 } 129 } else { 130 /* do some slow I2C emulation kind of thing */ 131 while (len >= 2) { 132 reg = *data++; 133 + ret = saa7185_write(client, reg, *data++); 134 + if (ret < 0) 135 break; 136 len -= 2; 137 } ··· 240 0x66, 0x21, /* FSC3 */ 241 }; 242 243 + static int saa7185_command(struct i2c_client *client, unsigned cmd, void *arg) 244 { 245 struct saa7185 *encoder = i2c_get_clientdata(client); 246 247 switch (cmd) { 248 case 0: 249 saa7185_write_block(client, init_common, 250 sizeof(init_common)); ··· 264 sizeof(init_pal)); 265 break; 266 } 267 break; 268 269 case ENCODER_GET_CAPABILITIES: ··· 276 VIDEO_ENCODER_SECAM | VIDEO_ENCODER_CCIR; 277 cap->inputs = 1; 278 cap->outputs = 1; 279 break; 280 + } 281 282 case ENCODER_SET_NORM: 283 { ··· 286 //saa7185_write_block(client, init_common, sizeof(init_common)); 287 288 switch (*iarg) { 289 case VIDEO_MODE_NTSC: 290 saa7185_write_block(client, init_ntsc, 291 sizeof(init_ntsc)); ··· 300 case VIDEO_MODE_SECAM: 301 default: 302 return -EINVAL; 303 } 304 encoder->norm = *iarg; 305 break; 306 + } 307 308 case ENCODER_SET_INPUT: 309 { ··· 314 *iarg = 1: input is from ZR36060 */ 315 316 switch (*iarg) { 317 case 0: 318 /* Switch RTCE to 1 */ 319 saa7185_write(client, 0x61, ··· 332 333 default: 334 return -EINVAL; 335 } 336 break; 337 + } 338 339 case ENCODER_SET_OUTPUT: 340 { 341 int *iarg = arg; 342 343 /* not much choice of outputs */ 344 + if (*iarg != 0) 345 return -EINVAL; 346 break; 347 + } 348 349 case ENCODER_ENABLE_OUTPUT: 350 { ··· 356 saa7185_write(client, 0x61, 357 (encoder->reg[0x61] & 0xbf) | 358 (encoder->enable ? 0x00 : 0x40)); 359 break; 360 + } 361 362 default: 363 return -EINVAL; ··· 368 369 /* ----------------------------------------------------------------------- */ 370 371 + static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; 372 373 + I2C_CLIENT_INSMOD; 374 375 + static int saa7185_probe(struct i2c_client *client, 376 + const struct i2c_device_id *id) 377 { 378 int i; 379 struct saa7185 *encoder; 380 381 /* Check if the adapter supports the needed features */ 382 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 383 + return -ENODEV; 384 385 + v4l_info(client, "chip found @ 0x%x (%s)\n", 386 + client->addr << 1, client->adapter->name); 387 388 encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL); 389 + if (encoder == NULL) 390 return -ENOMEM; 391 encoder->norm = VIDEO_MODE_NTSC; 392 encoder->enable = 1; 393 i2c_set_clientdata(client, encoder); 394 395 i = saa7185_write_block(client, init_common, sizeof(init_common)); 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); 403 return 0; 404 } 405 406 + static int saa7185_remove(struct i2c_client *client) 407 { 408 struct saa7185 *encoder = i2c_get_clientdata(client); 409 410 saa7185_write(client, 0x61, (encoder->reg[0x61]) | 0x40); /* SW: output off is active */ 411 //saa7185_write(client, 0x3a, (encoder->reg[0x3a]) | 0x80); /* SW: color bar */ 412 413 kfree(encoder); 414 return 0; 415 } 416 417 /* ----------------------------------------------------------------------- */ 418 419 + static const struct i2c_device_id saa7185_id[] = { 420 + { "saa7185", 0 }, 421 + { } 422 }; 423 + MODULE_DEVICE_TABLE(i2c, saa7185_id); 424 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 41 /* register offsets for sh7722 / sh7723 */ 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 76 77 static DEFINE_MUTEX(camera_lock); 78 ··· 165 ceu_write(pcdev, CETCR, 0x0317f313 ^ 0x10); 166 167 if (pcdev->active) { 168 ceu_write(pcdev, CDAYR, videobuf_to_dma_contig(pcdev->active)); 169 ceu_write(pcdev, CAPSR, 0x1); /* start capture */ 170 } ··· 237 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %zd\n", __func__, 238 vb, vb->baddr, vb->bsize); 239 240 - vb->state = VIDEOBUF_ACTIVE; 241 spin_lock_irqsave(&pcdev->lock, flags); 242 list_add_tail(&vb->queue, &pcdev->capture); 243 ··· 324 { 325 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 326 struct sh_mobile_ceu_dev *pcdev = ici->priv; 327 328 BUG_ON(icd != pcdev->icd); 329 330 /* disable capture, disable interrupts */ 331 ceu_write(pcdev, CEIER, 0); 332 ceu_write(pcdev, CAPSR, 1 << 16); /* reset */ 333 icd->ops->release(icd); 334 335 dev_info(&icd->dev, ··· 404 ceu_write(pcdev, CFLCR, 0); /* data fetch mode - no scaling */ 405 ceu_write(pcdev, CFSZR, (icd->height << 16) | cfszr_width); 406 ceu_write(pcdev, CLFCR, 0); /* data fetch mode - no lowpass filter */ 407 - ceu_write(pcdev, CDOCR, 0x00000016); 408 409 ceu_write(pcdev, CDWDR, cdwdr_width); 410 ceu_write(pcdev, CFWCR, 0); /* keep "datafetch firewall" disabled */
··· 40 41 /* register offsets for sh7722 / sh7723 */ 42 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 77 static DEFINE_MUTEX(camera_lock); 78 ··· 165 ceu_write(pcdev, CETCR, 0x0317f313 ^ 0x10); 166 167 if (pcdev->active) { 168 + pcdev->active->state = VIDEOBUF_ACTIVE; 169 ceu_write(pcdev, CDAYR, videobuf_to_dma_contig(pcdev->active)); 170 ceu_write(pcdev, CAPSR, 0x1); /* start capture */ 171 } ··· 236 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %zd\n", __func__, 237 vb, vb->baddr, vb->bsize); 238 239 + vb->state = VIDEOBUF_QUEUED; 240 spin_lock_irqsave(&pcdev->lock, flags); 241 list_add_tail(&vb->queue, &pcdev->capture); 242 ··· 323 { 324 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 325 struct sh_mobile_ceu_dev *pcdev = ici->priv; 326 + unsigned long flags; 327 328 BUG_ON(icd != pcdev->icd); 329 330 /* disable capture, disable interrupts */ 331 ceu_write(pcdev, CEIER, 0); 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 + 344 icd->ops->release(icd); 345 346 dev_info(&icd->dev, ··· 391 ceu_write(pcdev, CFLCR, 0); /* data fetch mode - no scaling */ 392 ceu_write(pcdev, CFSZR, (icd->height << 16) | cfszr_width); 393 ceu_write(pcdev, CLFCR, 0); /* data fetch mode - no lowpass filter */ 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 409 ceu_write(pcdev, CDWDR, cdwdr_width); 410 ceu_write(pcdev, CFWCR, 0); /* keep "datafetch firewall" disabled */
+11 -9
drivers/media/video/soc_camera_platform.c
··· 18 #include <linux/videodev2.h> 19 #include <media/v4l2-common.h> 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 - }; 30 31 struct soc_camera_platform_priv { 32 struct soc_camera_platform_info *info; ··· 36 37 static int soc_camera_platform_init(struct soc_camera_device *icd) 38 { 39 return 0; 40 } 41 42 static int soc_camera_platform_release(struct soc_camera_device *icd) 43 { 44 return 0; 45 } 46
··· 18 #include <linux/videodev2.h> 19 #include <media/v4l2-common.h> 20 #include <media/soc_camera.h> 21 + #include <media/soc_camera_platform.h> 22 23 struct soc_camera_platform_priv { 24 struct soc_camera_platform_info *info; ··· 44 45 static int soc_camera_platform_init(struct soc_camera_device *icd) 46 { 47 + struct soc_camera_platform_info *p = soc_camera_platform_get_info(icd); 48 + 49 + if (p->power) 50 + p->power(1); 51 + 52 return 0; 53 } 54 55 static int soc_camera_platform_release(struct soc_camera_device *icd) 56 { 57 + struct soc_camera_platform_info *p = soc_camera_platform_get_info(icd); 58 + 59 + if (p->power) 60 + p->power(0); 61 + 62 return 0; 63 } 64
+8 -19
drivers/media/video/stk-webcam.c
··· 27 #include <linux/kernel.h> 28 #include <linux/errno.h> 29 #include <linux/slab.h> 30 - #include <linux/kref.h> 31 32 #include <linux/usb.h> 33 #include <linux/mm.h> ··· 559 560 urb = dev->isobufs[i].urb; 561 if (urb) { 562 - if (atomic_read(&dev->urbs_used)) 563 usb_kill_urb(urb); 564 usb_free_urb(urb); 565 } ··· 688 { 689 struct stk_camera *dev = fp->private_data; 690 691 - if (dev->owner != fp) { 692 - usb_autopm_put_interface(dev->interface); 693 - return 0; 694 } 695 696 - stk_stop_stream(dev); 697 - 698 - stk_free_buffers(dev); 699 - 700 - dev->owner = NULL; 701 - 702 - usb_autopm_put_interface(dev->interface); 703 704 return 0; 705 } ··· 708 unsigned long flags; 709 struct stk_sio_buffer *sbuf; 710 struct stk_camera *dev = fp->private_data; 711 - 712 - if (dev == NULL) 713 - return -EIO; 714 715 if (!is_present(dev)) 716 return -EIO; ··· 764 static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait) 765 { 766 struct stk_camera *dev = fp->private_data; 767 - 768 - if (dev == NULL) 769 - return -ENODEV; 770 771 poll_wait(fp, &dev->wait_frame, wait); 772 ··· 1425 wake_up_interruptible(&dev->wait_frame); 1426 stk_remove_sysfs_files(&dev->vdev); 1427 1428 - STK_INFO("Syntek USB2.0 Camera release resources" 1429 "video device /dev/video%d\n", dev->vdev.minor); 1430 1431 video_unregister_device(&dev->vdev);
··· 27 #include <linux/kernel.h> 28 #include <linux/errno.h> 29 #include <linux/slab.h> 30 31 #include <linux/usb.h> 32 #include <linux/mm.h> ··· 560 561 urb = dev->isobufs[i].urb; 562 if (urb) { 563 + if (atomic_read(&dev->urbs_used) && is_present(dev)) 564 usb_kill_urb(urb); 565 usb_free_urb(urb); 566 } ··· 689 { 690 struct stk_camera *dev = fp->private_data; 691 692 + if (dev->owner == fp) { 693 + stk_stop_stream(dev); 694 + stk_free_buffers(dev); 695 + dev->owner = NULL; 696 } 697 698 + if(is_present(dev)) 699 + usb_autopm_put_interface(dev->interface); 700 701 return 0; 702 } ··· 713 unsigned long flags; 714 struct stk_sio_buffer *sbuf; 715 struct stk_camera *dev = fp->private_data; 716 717 if (!is_present(dev)) 718 return -EIO; ··· 772 static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait) 773 { 774 struct stk_camera *dev = fp->private_data; 775 776 poll_wait(fp, &dev->wait_frame, wait); 777 ··· 1436 wake_up_interruptible(&dev->wait_frame); 1437 stk_remove_sysfs_files(&dev->vdev); 1438 1439 + STK_INFO("Syntek USB2.0 Camera release resources " 1440 "video device /dev/video%d\n", dev->vdev.minor); 1441 1442 video_unregister_device(&dev->vdev);
-1
drivers/media/video/stk-webcam.h
··· 122 123 #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev) 124 125 - void stk_camera_delete(struct kref *); 126 int stk_camera_write_reg(struct stk_camera *, u16, u8); 127 int stk_camera_read_reg(struct stk_camera *, u16, int *); 128
··· 122 123 #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev) 124 125 int stk_camera_write_reg(struct stk_camera *, u16, u8); 126 int stk_camera_read_reg(struct stk_camera *, u16, int *); 127
+1 -1
drivers/media/video/tveeprom.c
··· 242 { TUNER_ABSENT, "TCL M2523_3DBH_E"}, 243 { TUNER_ABSENT, "TCL M2523_3DIH_E"}, 244 { TUNER_ABSENT, "TCL MFPE05_2_U"}, 245 - { TUNER_PHILIPS_FMD1216ME_MK3, "Philips FMD1216MEX"}, 246 { TUNER_ABSENT, "Philips FRH2036B"}, 247 { TUNER_ABSENT, "Panasonic ENGF75_01GF"}, 248 { TUNER_ABSENT, "MaxLinear MXL5005"},
··· 242 { TUNER_ABSENT, "TCL M2523_3DBH_E"}, 243 { TUNER_ABSENT, "TCL M2523_3DIH_E"}, 244 { TUNER_ABSENT, "TCL MFPE05_2_U"}, 245 + { TUNER_PHILIPS_FMD1216MEX_MK3, "Philips FMD1216MEX"}, 246 { TUNER_ABSENT, "Philips FRH2036B"}, 247 { TUNER_ABSENT, "Panasonic ENGF75_01GF"}, 248 { TUNER_ABSENT, "MaxLinear MXL5005"},
+170 -37
drivers/media/video/videobuf-dvb.c
··· 126 mutex_lock(&dvb->lock); 127 dvb->nfeeds--; 128 if (0 == dvb->nfeeds && NULL != dvb->thread) { 129 - // FIXME: cx8802_cancel_buffers(dev); 130 err = kthread_stop(dvb->thread); 131 dvb->thread = NULL; 132 } ··· 133 return err; 134 } 135 136 - /* ------------------------------------------------------------------ */ 137 - 138 - int videobuf_dvb_register(struct videobuf_dvb *dvb, 139 struct module *module, 140 void *adapter_priv, 141 struct device *device, 142 - short *adapter_nr) 143 { 144 int result; 145 146 - mutex_init(&dvb->lock); 147 148 /* register adapter */ 149 - result = dvb_register_adapter(&dvb->adapter, dvb->name, module, device, 150 - adapter_nr); 151 if (result < 0) { 152 printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", 153 - dvb->name, result); 154 - goto fail_adapter; 155 } 156 - dvb->adapter.priv = adapter_priv; 157 158 /* register frontend */ 159 - result = dvb_register_frontend(&dvb->adapter, dvb->frontend); 160 if (result < 0) { 161 printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", 162 dvb->name, result); ··· 190 dvb->dmxdev.filternum = 256; 191 dvb->dmxdev.demux = &dvb->demux.dmx; 192 dvb->dmxdev.capabilities = 0; 193 - result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); 194 if (result < 0) { 195 printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", 196 dvb->name, result); ··· 222 } 223 224 /* register network adapter */ 225 - dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); 226 return 0; 227 228 fail_fe_conn: ··· 241 dvb_unregister_frontend(dvb->frontend); 242 fail_frontend: 243 dvb_frontend_detach(dvb->frontend); 244 - dvb_unregister_adapter(&dvb->adapter); 245 - fail_adapter: 246 return result; 247 } 248 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 /* ------------------------------------------------------------------ */ 265 - /* 266 - * Local variables: 267 - * c-basic-offset: 8 268 - * compile-command: "make DVB=1" 269 - * End: 270 - */
··· 126 mutex_lock(&dvb->lock); 127 dvb->nfeeds--; 128 if (0 == dvb->nfeeds && NULL != dvb->thread) { 129 err = kthread_stop(dvb->thread); 130 dvb->thread = NULL; 131 } ··· 134 return err; 135 } 136 137 + static int videobuf_dvb_register_adapter(struct videobuf_dvb_frontends *fe, 138 struct module *module, 139 void *adapter_priv, 140 struct device *device, 141 + char *adapter_name, 142 + short *adapter_nr, 143 + int mfe_shared) 144 { 145 int result; 146 147 + mutex_init(&fe->lock); 148 149 /* register adapter */ 150 + result = dvb_register_adapter(&fe->adapter, adapter_name, module, 151 + device, adapter_nr); 152 if (result < 0) { 153 printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", 154 + adapter_name, result); 155 } 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; 166 167 /* register frontend */ 168 + result = dvb_register_frontend(adapter, dvb->frontend); 169 if (result < 0) { 170 printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", 171 dvb->name, result); ··· 183 dvb->dmxdev.filternum = 256; 184 dvb->dmxdev.demux = &dvb->demux.dmx; 185 dvb->dmxdev.capabilities = 0; 186 + result = dvb_dmxdev_init(&dvb->dmxdev, adapter); 187 + 188 if (result < 0) { 189 printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", 190 dvb->name, result); ··· 214 } 215 216 /* register network adapter */ 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 + } 222 return 0; 223 224 fail_fe_conn: ··· 229 dvb_unregister_frontend(dvb->frontend); 230 fail_frontend: 231 dvb_frontend_detach(dvb->frontend); 232 + dvb->frontend = NULL; 233 + 234 return result; 235 } 236 237 /* ------------------------------------------------------------------ */ 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 int depth; 129 }; 130 131 - static struct vivi_fmt format = { 132 - .name = "4:2:2, packed, YUYV", 133 - .fourcc = V4L2_PIX_FMT_YUYV, 134 - .depth = 16, 135 }; 136 137 struct sg_to_addr { 138 int pos; ··· 234 struct videobuf_queue vb_vidq; 235 236 enum v4l2_buf_type type; 237 }; 238 239 /* ------------------------------------------------------------------ ··· 279 #define TSTAMP_MAX_Y TSTAMP_MIN_Y+15 280 #define TSTAMP_MIN_X 64 281 282 - static void gen_line(char *basep, int inipos, int wmax, 283 int hmax, int line, int count, char *timestr) 284 { 285 - int w, i, j, y; 286 int pos = inipos; 287 - char *p, *s; 288 - u8 chr, r, g, b, color; 289 290 /* We will just duplicate the second pixel at the packet */ 291 wmax /= 2; ··· 387 /* Generate a standard color bar pattern */ 388 for (w = 0; w < wmax; w++) { 389 int colorpos = ((w + count) * 8/(wmax + 1)) % 8; 390 - r = bars[colorpos][0]; 391 - g = bars[colorpos][1]; 392 - b = bars[colorpos][2]; 393 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 - } 411 } 412 413 /* Checks if it is possible to show timestamp */ ··· 404 for (s = timestr; *s; s++) { 405 chr = rom8x16_bits[(*s-0x30)*16+line-TSTAMP_MIN_Y]; 406 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 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 - } 439 j++; 440 } 441 } ··· 419 return; 420 } 421 422 - static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) 423 { 424 int h , pos = 0; 425 int hmax = buf->vb.height; 426 int wmax = buf->vb.width; ··· 437 return; 438 439 for (h = 0; h < hmax; h++) { 440 - gen_line(tmpbuf, 0, wmax, hmax, h, dev->mv_count, 441 dev->timestr); 442 memcpy(vbuf + pos, tmpbuf, wmax * 2); 443 pos += wmax*2; ··· 506 do_gettimeofday(&buf->vb.ts); 507 508 /* Fill buffer */ 509 - vivi_fillbuff(dev, buf); 510 dprintk(dev, 1, "filled buffer %p\n", buf); 511 512 wake_up(&buf->vb.done); ··· 732 static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, 733 struct v4l2_fmtdesc *f) 734 { 735 - if (f->index > 0) 736 return -EINVAL; 737 738 - strlcpy(f->description, format.name, sizeof(f->description)); 739 - f->pixelformat = format.fourcc; 740 return 0; 741 } 742 ··· 770 enum v4l2_field field; 771 unsigned int maxw, maxh; 772 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); 777 return -EINVAL; 778 } 779 - fmt = &format; 780 781 field = f->fmt.pix.field; 782 ··· 813 { 814 struct vivi_fh *fh = priv; 815 struct videobuf_queue *q = &fh->vb_vidq; 816 817 int ret = vidioc_try_fmt_vid_cap(file, fh, f); 818 if (ret < 0) ··· 828 goto out; 829 } 830 831 - fh->fmt = &format; 832 fh->width = f->fmt.pix.width; 833 fh->height = f->fmt.pix.height; 834 fh->vb_vidq.field = f->fmt.pix.field; 835 fh->type = f->type; 836 837 ret = 0; 838 out: ··· 1024 File operations for the device 1025 ------------------------------------------------------------------*/ 1026 1027 - #define line_buf_size(norm) (norm_maxw(norm)*(format.depth+7)/8) 1028 - 1029 static int vivi_open(struct inode *inode, struct file *file) 1030 { 1031 int minor = iminor(inode); ··· 1072 fh->dev = dev; 1073 1074 fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1075 - fh->fmt = &format; 1076 fh->width = 640; 1077 fh->height = 480; 1078
··· 128 int depth; 129 }; 130 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 + }, 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 + } 180 181 struct sg_to_addr { 182 int pos; ··· 190 struct videobuf_queue vb_vidq; 191 192 enum v4l2_buf_type type; 193 + unsigned char bars[8][3]; 194 }; 195 196 /* ------------------------------------------------------------------ ··· 234 #define TSTAMP_MAX_Y TSTAMP_MIN_Y+15 235 #define TSTAMP_MIN_X 64 236 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, 332 int hmax, int line, int count, char *timestr) 333 { 334 + int w, i, j; 335 int pos = inipos; 336 + char *s; 337 + u8 chr; 338 339 /* We will just duplicate the second pixel at the packet */ 340 wmax /= 2; ··· 248 /* Generate a standard color bar pattern */ 249 for (w = 0; w < wmax; w++) { 250 int colorpos = ((w + count) * 8/(wmax + 1)) % 8; 251 252 + gen_twopix(fh, basep + pos, colorpos); 253 + pos += 4; /* only 16 bpp supported for now */ 254 } 255 256 /* Checks if it is possible to show timestamp */ ··· 283 for (s = timestr; *s; s++) { 284 chr = rom8x16_bits[(*s-0x30)*16+line-TSTAMP_MIN_Y]; 285 for (i = 0; i < 7; i++) { 286 pos = inipos + j * 2; 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); 292 j++; 293 } 294 } ··· 324 return; 325 } 326 327 + static void vivi_fillbuff(struct vivi_fh *fh, struct vivi_buffer *buf) 328 { 329 + struct vivi_dev *dev = fh->dev; 330 int h , pos = 0; 331 int hmax = buf->vb.height; 332 int wmax = buf->vb.width; ··· 341 return; 342 343 for (h = 0; h < hmax; h++) { 344 + gen_line(fh, tmpbuf, 0, wmax, hmax, h, dev->mv_count, 345 dev->timestr); 346 memcpy(vbuf + pos, tmpbuf, wmax * 2); 347 pos += wmax*2; ··· 410 do_gettimeofday(&buf->vb.ts); 411 412 /* Fill buffer */ 413 + vivi_fillbuff(fh, buf); 414 dprintk(dev, 1, "filled buffer %p\n", buf); 415 416 wake_up(&buf->vb.done); ··· 636 static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, 637 struct v4l2_fmtdesc *f) 638 { 639 + struct vivi_fmt *fmt; 640 + 641 + if (f->index >= ARRAY_SIZE(formats)) 642 return -EINVAL; 643 644 + fmt = &formats[f->index]; 645 + 646 + strlcpy(f->description, fmt->name, sizeof(f->description)); 647 + f->pixelformat = fmt->fourcc; 648 return 0; 649 } 650 ··· 670 enum v4l2_field field; 671 unsigned int maxw, maxh; 672 673 + fmt = get_format(f); 674 + if (!fmt) { 675 + dprintk(dev, 1, "Fourcc format (0x%08x) invalid.\n", 676 + f->fmt.pix.pixelformat); 677 return -EINVAL; 678 } 679 680 field = f->fmt.pix.field; 681 ··· 714 { 715 struct vivi_fh *fh = priv; 716 struct videobuf_queue *q = &fh->vb_vidq; 717 + unsigned char r, g, b; 718 + int k, is_yuv; 719 720 int ret = vidioc_try_fmt_vid_cap(file, fh, f); 721 if (ret < 0) ··· 727 goto out; 728 } 729 730 + fh->fmt = get_format(f); 731 fh->width = f->fmt.pix.width; 732 fh->height = f->fmt.pix.height; 733 fh->vb_vidq.field = f->fmt.pix.field; 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 + } 772 773 ret = 0; 774 out: ··· 886 File operations for the device 887 ------------------------------------------------------------------*/ 888 889 static int vivi_open(struct inode *inode, struct file *file) 890 { 891 int minor = iminor(inode); ··· 936 fh->dev = dev; 937 938 fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 939 + fh->fmt = &formats[0]; 940 fh->width = 640; 941 fh->height = 480; 942
+92 -238
drivers/media/video/vpx3220.c
··· 22 #include <linux/init.h> 23 #include <linux/delay.h> 24 #include <linux/types.h> 25 - #include <linux/slab.h> 26 - 27 - #include <asm/io.h> 28 #include <asm/uaccess.h> 29 - 30 #include <linux/i2c.h> 31 - 32 - #define I2C_NAME(x) (x)->name 33 - 34 - #include <linux/videodev.h> 35 #include <media/v4l2-common.h> 36 #include <linux/video_decoder.h> 37 38 - #define I2C_VPX3220 0x86 39 - #define VPX3220_DEBUG KERN_DEBUG "vpx3220: " 40 41 static int debug; 42 module_param(debug, int, 0); 43 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 51 #define VPX_TIMEOUT_COUNT 10 52 ··· 56 static char *inputs[] = { "internal", "composite", "svideo" }; 57 58 /* ----------------------------------------------------------------------- */ 59 - static inline int 60 - vpx3220_write (struct i2c_client *client, 61 - u8 reg, 62 - u8 value) 63 { 64 struct vpx3220 *decoder = i2c_get_clientdata(client); 65 ··· 65 return i2c_smbus_write_byte_data(client, reg, value); 66 } 67 68 - static inline int 69 - vpx3220_read (struct i2c_client *client, 70 - u8 reg) 71 { 72 return i2c_smbus_read_byte_data(client, reg); 73 } 74 75 - static int 76 - vpx3220_fp_status (struct i2c_client *client) 77 { 78 unsigned char status; 79 unsigned int i; ··· 90 return -1; 91 } 92 93 - static int 94 - vpx3220_fp_write (struct i2c_client *client, 95 - u8 fpaddr, 96 - u16 data) 97 { 98 /* Write the 16-bit address to the FPWR register */ 99 if (i2c_smbus_write_word_data(client, 0x27, swab16(fpaddr)) == -1) { 100 - dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); 101 return -1; 102 } 103 ··· 103 104 /* Write the 16-bit data to the FPDAT register */ 105 if (i2c_smbus_write_word_data(client, 0x28, swab16(data)) == -1) { 106 - dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); 107 return -1; 108 } 109 110 return 0; 111 } 112 113 - static u16 114 - vpx3220_fp_read (struct i2c_client *client, 115 - u16 fpaddr) 116 { 117 s16 data; 118 119 /* Write the 16-bit address to the FPRD register */ 120 if (i2c_smbus_write_word_data(client, 0x26, swab16(fpaddr)) == -1) { 121 - dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); 122 return -1; 123 } 124 ··· 126 /* Read the 16-bit data from the FPDAT register */ 127 data = i2c_smbus_read_word_data(client, 0x28); 128 if (data == -1) { 129 - dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); 130 return -1; 131 } 132 133 return swab16(data); 134 } 135 136 - static int 137 - vpx3220_write_block (struct i2c_client *client, 138 - const u8 *data, 139 - unsigned int len) 140 { 141 u8 reg; 142 int ret = -1; 143 144 while (len >= 2) { 145 reg = *data++; 146 - if ((ret = 147 - vpx3220_write(client, reg, *data++)) < 0) 148 break; 149 len -= 2; 150 } ··· 149 return ret; 150 } 151 152 - static int 153 - vpx3220_write_fp_block (struct i2c_client *client, 154 - const u16 *data, 155 - unsigned int len) 156 { 157 u8 reg; 158 int ret = 0; ··· 259 0x4b, 0x298, /* PLL gain */ 260 }; 261 262 - static void 263 - vpx3220_dump_i2c (struct i2c_client *client) 264 { 265 int len = sizeof(init_common); 266 const unsigned char *data = init_common; 267 268 while (len > 1) { 269 - dprintk(1, 270 - KERN_DEBUG "vpx3216b i2c reg 0x%02x data 0x%02x\n", 271 *data, vpx3220_read(client, *data)); 272 data += 2; 273 len -= 2; 274 } 275 } 276 277 - static int 278 - vpx3220_command (struct i2c_client *client, 279 - unsigned int cmd, 280 - void *arg) 281 { 282 struct vpx3220 *decoder = i2c_get_clientdata(client); 283 ··· 284 vpx3220_write_fp_block(client, init_fp, 285 sizeof(init_fp) >> 1); 286 switch (decoder->norm) { 287 - 288 case VIDEO_MODE_NTSC: 289 vpx3220_write_fp_block(client, init_ntsc, 290 sizeof(init_ntsc) >> 1); ··· 302 sizeof(init_pal) >> 1); 303 break; 304 } 305 - } 306 break; 307 308 case DECODER_DUMP: 309 { 310 vpx3220_dump_i2c(client); 311 - } 312 break; 313 314 case DECODER_GET_CAPABILITIES: 315 { 316 struct video_decoder_capability *cap = arg; 317 318 - dprintk(1, KERN_DEBUG "%s: DECODER_GET_CAPABILITIES\n", 319 - I2C_NAME(client)); 320 321 cap->flags = VIDEO_DECODER_PAL | 322 VIDEO_DECODER_NTSC | ··· 324 VIDEO_DECODER_CCIR; 325 cap->inputs = 3; 326 cap->outputs = 1; 327 - } 328 break; 329 330 case DECODER_GET_STATUS: 331 { 332 int res = 0, status; 333 334 - dprintk(1, KERN_INFO "%s: DECODER_GET_STATUS\n", 335 - I2C_NAME(client)); 336 337 status = vpx3220_fp_read(client, 0x0f3); 338 339 - dprintk(1, KERN_INFO "%s: status: 0x%04x\n", I2C_NAME(client), 340 - status); 341 342 if (status < 0) 343 return status; ··· 344 res |= DECODER_STATUS_GOOD | DECODER_STATUS_COLOR; 345 346 switch (status & 0x18) { 347 - 348 case 0x00: 349 case 0x10: 350 case 0x14: ··· 364 } 365 366 *(int *) arg = res; 367 - } 368 break; 369 370 case DECODER_SET_NORM: 371 { ··· 377 choosen video norm */ 378 temp_input = vpx3220_fp_read(client, 0xf2); 379 380 - dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n", 381 - I2C_NAME(client), *iarg); 382 switch (*iarg) { 383 - 384 case VIDEO_MODE_NTSC: 385 vpx3220_write_fp_block(client, init_ntsc, 386 sizeof(init_ntsc) >> 1); 387 - dprintk(1, KERN_INFO "%s: norm switched to NTSC\n", 388 - I2C_NAME(client)); 389 break; 390 391 case VIDEO_MODE_PAL: 392 vpx3220_write_fp_block(client, init_pal, 393 sizeof(init_pal) >> 1); 394 - dprintk(1, KERN_INFO "%s: norm switched to PAL\n", 395 - I2C_NAME(client)); 396 break; 397 398 case VIDEO_MODE_SECAM: 399 vpx3220_write_fp_block(client, init_secam, 400 sizeof(init_secam) >> 1); 401 - dprintk(1, KERN_INFO "%s: norm switched to SECAM\n", 402 - I2C_NAME(client)); 403 break; 404 405 case VIDEO_MODE_AUTO: 406 /* FIXME This is only preliminary support */ 407 data = vpx3220_fp_read(client, 0xf2) & 0x20; 408 vpx3220_fp_write(client, 0xf2, 0x00c0 | data); 409 - dprintk(1, KERN_INFO "%s: norm switched to Auto\n", 410 - I2C_NAME(client)); 411 break; 412 413 default: 414 return -EINVAL; 415 - 416 } 417 decoder->norm = *iarg; 418 419 /* And here we set the backed up video input again */ 420 vpx3220_fp_write(client, 0xf2, temp_input | 0x0010); 421 udelay(10); 422 - } 423 break; 424 425 case DECODER_SET_INPUT: 426 { ··· 432 if (*iarg < 0 || *iarg > 2) 433 return -EINVAL; 434 435 - dprintk(1, KERN_INFO "%s: input switched to %s\n", 436 - I2C_NAME(client), inputs[*iarg]); 437 438 vpx3220_write(client, 0x33, input[*iarg][0]); 439 ··· 444 data | (input[*iarg][1] << 5) | 0x0010); 445 446 udelay(10); 447 - } 448 break; 449 450 case DECODER_SET_OUTPUT: 451 { ··· 455 if (*iarg != 0) { 456 return -EINVAL; 457 } 458 - } 459 break; 460 461 case DECODER_ENABLE_OUTPUT: 462 { 463 int *iarg = arg; 464 465 - dprintk(1, KERN_DEBUG "%s: DECODER_ENABLE_OUTPUT %d\n", 466 - I2C_NAME(client), *iarg); 467 468 vpx3220_write(client, 0xf2, (*iarg ? 0x1b : 0x00)); 469 - } 470 break; 471 472 case DECODER_SET_PICTURE: 473 { ··· 497 vpx3220_fp_write(client, 0x1c, 498 ((decoder->hue - 32768) >> 6) & 0xFFF); 499 } 500 - } 501 break; 502 503 default: 504 return -EINVAL; ··· 507 return 0; 508 } 509 510 - static int 511 - vpx3220_init_client (struct i2c_client *client) 512 { 513 vpx3220_write_block(client, init_common, sizeof(init_common)); 514 vpx3220_write_fp_block(client, init_fp, sizeof(init_fp) >> 1); ··· 521 * Client management code 522 */ 523 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 - }; 532 533 - static unsigned short ignore = I2C_CLIENT_END; 534 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) 545 { 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 struct vpx3220 *decoder; 568 - 569 - dprintk(1, VPX3220_DEBUG "%s\n", __func__); 570 571 /* 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 - } 627 628 decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL); 629 - if (decoder == NULL) { 630 - kfree(client); 631 return -ENOMEM; 632 - } 633 decoder->norm = VIDEO_MODE_PAL; 634 decoder->input = 0; 635 decoder->enable = 1; ··· 550 decoder->sat = 32768; 551 i2c_set_clientdata(client, decoder); 552 553 - err = i2c_attach_client(client); 554 - if (err) { 555 - kfree(client); 556 - kfree(decoder); 557 - return err; 558 } 559 - 560 - dprintk(1, KERN_INFO "%s: vpx32xx client found at address 0x%02x\n", 561 - I2C_NAME(client), client->addr << 1); 562 563 vpx3220_init_client(client); 564 - 565 return 0; 566 } 567 568 - static int 569 - vpx3220_attach_adapter (struct i2c_adapter *adapter) 570 { 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; 577 } 578 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, 593 }; 594 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");
··· 22 #include <linux/init.h> 23 #include <linux/delay.h> 24 #include <linux/types.h> 25 #include <asm/uaccess.h> 26 #include <linux/i2c.h> 27 #include <media/v4l2-common.h> 28 + #include <media/v4l2-i2c-drv-legacy.h> 29 + #include <linux/videodev.h> 30 #include <linux/video_decoder.h> 31 32 + MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video decoder driver"); 33 + MODULE_AUTHOR("Laurent Pinchart"); 34 + MODULE_LICENSE("GPL"); 35 36 static int debug; 37 module_param(debug, int, 0); 38 MODULE_PARM_DESC(debug, "Debug level (0-1)"); 39 40 #define VPX_TIMEOUT_COUNT 10 41 ··· 67 static char *inputs[] = { "internal", "composite", "svideo" }; 68 69 /* ----------------------------------------------------------------------- */ 70 + 71 + static inline int vpx3220_write(struct i2c_client *client, u8 reg, u8 value) 72 { 73 struct vpx3220 *decoder = i2c_get_clientdata(client); 74 ··· 78 return i2c_smbus_write_byte_data(client, reg, value); 79 } 80 81 + static inline int vpx3220_read(struct i2c_client *client, u8 reg) 82 { 83 return i2c_smbus_read_byte_data(client, reg); 84 } 85 86 + static int vpx3220_fp_status(struct i2c_client *client) 87 { 88 unsigned char status; 89 unsigned int i; ··· 106 return -1; 107 } 108 109 + static int vpx3220_fp_write(struct i2c_client *client, u8 fpaddr, u16 data) 110 { 111 /* Write the 16-bit address to the FPWR register */ 112 if (i2c_smbus_write_word_data(client, 0x27, swab16(fpaddr)) == -1) { 113 + v4l_dbg(1, debug, client, "%s: failed\n", __func__); 114 return -1; 115 } 116 ··· 122 123 /* Write the 16-bit data to the FPDAT register */ 124 if (i2c_smbus_write_word_data(client, 0x28, swab16(data)) == -1) { 125 + v4l_dbg(1, debug, client, "%s: failed\n", __func__); 126 return -1; 127 } 128 129 return 0; 130 } 131 132 + static u16 vpx3220_fp_read(struct i2c_client *client, u16 fpaddr) 133 { 134 s16 data; 135 136 /* Write the 16-bit address to the FPRD register */ 137 if (i2c_smbus_write_word_data(client, 0x26, swab16(fpaddr)) == -1) { 138 + v4l_dbg(1, debug, client, "%s: failed\n", __func__); 139 return -1; 140 } 141 ··· 147 /* Read the 16-bit data from the FPDAT register */ 148 data = i2c_smbus_read_word_data(client, 0x28); 149 if (data == -1) { 150 + v4l_dbg(1, debug, client, "%s: failed\n", __func__); 151 return -1; 152 } 153 154 return swab16(data); 155 } 156 157 + static int vpx3220_write_block(struct i2c_client *client, const u8 *data, unsigned int len) 158 { 159 u8 reg; 160 int ret = -1; 161 162 while (len >= 2) { 163 reg = *data++; 164 + ret = vpx3220_write(client, reg, *data++); 165 + if (ret < 0) 166 break; 167 len -= 2; 168 } ··· 173 return ret; 174 } 175 176 + static int vpx3220_write_fp_block(struct i2c_client *client, 177 + const u16 *data, unsigned int len) 178 { 179 u8 reg; 180 int ret = 0; ··· 285 0x4b, 0x298, /* PLL gain */ 286 }; 287 288 + static void vpx3220_dump_i2c(struct i2c_client *client) 289 { 290 int len = sizeof(init_common); 291 const unsigned char *data = init_common; 292 293 while (len > 1) { 294 + v4l_dbg(1, debug, client, "i2c reg 0x%02x data 0x%02x\n", 295 *data, vpx3220_read(client, *data)); 296 data += 2; 297 len -= 2; 298 } 299 } 300 301 + static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) 302 { 303 struct vpx3220 *decoder = i2c_get_clientdata(client); 304 ··· 315 vpx3220_write_fp_block(client, init_fp, 316 sizeof(init_fp) >> 1); 317 switch (decoder->norm) { 318 case VIDEO_MODE_NTSC: 319 vpx3220_write_fp_block(client, init_ntsc, 320 sizeof(init_ntsc) >> 1); ··· 334 sizeof(init_pal) >> 1); 335 break; 336 } 337 break; 338 + } 339 340 case DECODER_DUMP: 341 { 342 vpx3220_dump_i2c(client); 343 break; 344 + } 345 346 case DECODER_GET_CAPABILITIES: 347 { 348 struct video_decoder_capability *cap = arg; 349 350 + v4l_dbg(1, debug, client, "DECODER_GET_CAPABILITIES\n"); 351 352 cap->flags = VIDEO_DECODER_PAL | 353 VIDEO_DECODER_NTSC | ··· 357 VIDEO_DECODER_CCIR; 358 cap->inputs = 3; 359 cap->outputs = 1; 360 break; 361 + } 362 363 case DECODER_GET_STATUS: 364 { 365 int res = 0, status; 366 367 + v4l_dbg(1, debug, client, "DECODER_GET_STATUS\n"); 368 369 status = vpx3220_fp_read(client, 0x0f3); 370 371 + v4l_dbg(1, debug, client, "status: 0x%04x\n", status); 372 373 if (status < 0) 374 return status; ··· 379 res |= DECODER_STATUS_GOOD | DECODER_STATUS_COLOR; 380 381 switch (status & 0x18) { 382 case 0x00: 383 case 0x10: 384 case 0x14: ··· 400 } 401 402 *(int *) arg = res; 403 break; 404 + } 405 406 case DECODER_SET_NORM: 407 { ··· 413 choosen video norm */ 414 temp_input = vpx3220_fp_read(client, 0xf2); 415 416 + v4l_dbg(1, debug, client, "DECODER_SET_NORM %d\n", *iarg); 417 switch (*iarg) { 418 case VIDEO_MODE_NTSC: 419 vpx3220_write_fp_block(client, init_ntsc, 420 sizeof(init_ntsc) >> 1); 421 + v4l_dbg(1, debug, client, "norm switched to NTSC\n"); 422 break; 423 424 case VIDEO_MODE_PAL: 425 vpx3220_write_fp_block(client, init_pal, 426 sizeof(init_pal) >> 1); 427 + v4l_dbg(1, debug, client, "norm switched to PAL\n"); 428 break; 429 430 case VIDEO_MODE_SECAM: 431 vpx3220_write_fp_block(client, init_secam, 432 sizeof(init_secam) >> 1); 433 + v4l_dbg(1, debug, client, "norm switched to SECAM\n"); 434 break; 435 436 case VIDEO_MODE_AUTO: 437 /* FIXME This is only preliminary support */ 438 data = vpx3220_fp_read(client, 0xf2) & 0x20; 439 vpx3220_fp_write(client, 0xf2, 0x00c0 | data); 440 + v4l_dbg(1, debug, client, "norm switched to AUTO\n"); 441 break; 442 443 default: 444 return -EINVAL; 445 } 446 decoder->norm = *iarg; 447 448 /* And here we set the backed up video input again */ 449 vpx3220_fp_write(client, 0xf2, temp_input | 0x0010); 450 udelay(10); 451 break; 452 + } 453 454 case DECODER_SET_INPUT: 455 { ··· 475 if (*iarg < 0 || *iarg > 2) 476 return -EINVAL; 477 478 + v4l_dbg(1, debug, client, "input switched to %s\n", inputs[*iarg]); 479 480 vpx3220_write(client, 0x33, input[*iarg][0]); 481 ··· 488 data | (input[*iarg][1] << 5) | 0x0010); 489 490 udelay(10); 491 break; 492 + } 493 494 case DECODER_SET_OUTPUT: 495 { ··· 499 if (*iarg != 0) { 500 return -EINVAL; 501 } 502 break; 503 + } 504 505 case DECODER_ENABLE_OUTPUT: 506 { 507 int *iarg = arg; 508 509 + v4l_dbg(1, debug, client, "DECODER_ENABLE_OUTPUT %d\n", *iarg); 510 511 vpx3220_write(client, 0xf2, (*iarg ? 0x1b : 0x00)); 512 break; 513 + } 514 515 case DECODER_SET_PICTURE: 516 { ··· 542 vpx3220_fp_write(client, 0x1c, 543 ((decoder->hue - 32768) >> 6) & 0xFFF); 544 } 545 break; 546 + } 547 548 default: 549 return -EINVAL; ··· 552 return 0; 553 } 554 555 + static int vpx3220_init_client(struct i2c_client *client) 556 { 557 vpx3220_write_block(client, init_common, sizeof(init_common)); 558 vpx3220_write_fp_block(client, init_fp, sizeof(init_fp) >> 1); ··· 567 * Client management code 568 */ 569 570 + static unsigned short normal_i2c[] = { 0x86 >> 1, 0x8e >> 1, I2C_CLIENT_END }; 571 572 + I2C_CLIENT_INSMOD; 573 574 + static int vpx3220_probe(struct i2c_client *client, 575 + const struct i2c_device_id *id) 576 { 577 struct vpx3220 *decoder; 578 + const char *name = NULL; 579 + u8 ver; 580 + u16 pn; 581 582 /* Check if the adapter supports the needed features */ 583 + if (!i2c_check_functionality(client->adapter, 584 + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) 585 + return -ENODEV; 586 587 decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL); 588 + if (decoder == NULL) 589 return -ENOMEM; 590 decoder->norm = VIDEO_MODE_PAL; 591 decoder->input = 0; 592 decoder->enable = 1; ··· 685 decoder->sat = 32768; 686 i2c_set_clientdata(client, decoder); 687 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 + } 703 } 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); 710 711 vpx3220_init_client(client); 712 return 0; 713 } 714 715 + static int vpx3220_remove(struct i2c_client *client) 716 { 717 + kfree(i2c_get_clientdata(client)); 718 + return 0; 719 } 720 721 + static const struct i2c_device_id vpx3220_id[] = { 722 + { "vpx3220a", 0 }, 723 + { "vpx3216b", 0 }, 724 + { "vpx3214c", 0 }, 725 + { } 726 }; 727 + MODULE_DEVICE_TABLE(i2c, vpx3220_id); 728 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 memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template, 818 sizeof(struct i2c_algo_bit_data)); 819 zr->i2c_algo.data = zr; 820 zr->i2c_adapter.id = I2C_HW_B_ZR36067; 821 zr->i2c_adapter.client_register = zoran_i2c_client_register; 822 zr->i2c_adapter.client_unregister = zoran_i2c_client_unregister;
··· 817 memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template, 818 sizeof(struct i2c_algo_bit_data)); 819 zr->i2c_algo.data = zr; 820 + zr->i2c_adapter.class = I2C_CLASS_TV_ANALOG; 821 zr->i2c_adapter.id = I2C_HW_B_ZR36067; 822 zr->i2c_adapter.client_register = zoran_i2c_client_register; 823 zr->i2c_adapter.client_unregister = zoran_i2c_client_unregister;
-1
drivers/media/video/zoran/zoran_driver.c
··· 2996 break; 2997 2998 default: 2999 - dprintk(3, "unsupported\n"); 3000 dprintk(1, 3001 KERN_ERR 3002 "%s: VIDIOC_S_FMT - unsupported type %d\n",
··· 2996 break; 2997 2998 default: 2999 dprintk(1, 3000 KERN_ERR 3001 "%s: VIDIOC_S_FMT - unsupported type %d\n",
+2
include/linux/dvb/frontend.h
··· 166 VSB_16, 167 PSK_8, 168 APSK_16, 169 DQPSK, 170 } fe_modulation_t; 171 ··· 296 SYS_DVBC_ANNEX_AC, 297 SYS_DVBC_ANNEX_B, 298 SYS_DVBT, 299 SYS_DVBS, 300 SYS_DVBS2, 301 SYS_DVBH,
··· 166 VSB_16, 167 PSK_8, 168 APSK_16, 169 + APSK_32, 170 DQPSK, 171 } fe_modulation_t; 172 ··· 295 SYS_DVBC_ANNEX_AC, 296 SYS_DVBC_ANNEX_B, 297 SYS_DVBT, 298 + SYS_DSS, 299 SYS_DVBS, 300 SYS_DVBS2, 301 SYS_DVBH,
+1 -1
include/linux/i2c-id.h
··· 60 #define I2C_DRIVERID_WM8775 69 /* wm8775 audio processor */ 61 #define I2C_DRIVERID_CS53L32A 70 /* cs53l32a audio processor */ 62 #define I2C_DRIVERID_CX25840 71 /* cx2584x video encoder */ 63 - #define I2C_DRIVERID_SAA7127 72 /* saa7124 video encoder */ 64 #define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */ 65 #define I2C_DRIVERID_AKITAIOEXP 74 /* IO Expander on Sharp SL-C1000 */ 66 #define I2C_DRIVERID_INFRARED 75 /* I2C InfraRed on Video boards */
··· 60 #define I2C_DRIVERID_WM8775 69 /* wm8775 audio processor */ 61 #define I2C_DRIVERID_CS53L32A 70 /* cs53l32a audio processor */ 62 #define I2C_DRIVERID_CX25840 71 /* cx2584x video encoder */ 63 + #define I2C_DRIVERID_SAA7127 72 /* saa7127 video encoder */ 64 #define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */ 65 #define I2C_DRIVERID_AKITAIOEXP 74 /* IO Expander on Sharp SL-C1000 */ 66 #define I2C_DRIVERID_INFRARED 75 /* I2C InfraRed on Video boards */
+11
include/media/soc_camera_platform.h
··· 1 #ifndef __SOC_CAMERA_H__ 2 #define __SOC_CAMERA_H__ 3 ··· 19 unsigned long format_depth; 20 struct v4l2_pix_format format; 21 unsigned long bus_param; 22 int (*set_capture)(struct soc_camera_platform_info *info, int enable); 23 }; 24
··· 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 + 11 #ifndef __SOC_CAMERA_H__ 12 #define __SOC_CAMERA_H__ 13 ··· 9 unsigned long format_depth; 10 struct v4l2_pix_format format; 11 unsigned long bus_param; 12 + void (*power)(int); 13 int (*set_capture)(struct soc_camera_platform_info *info, int enable); 14 }; 15
+1
include/media/tuner.h
··· 123 #define TUNER_TEA5761 75 /* Only FM Radio Tuner */ 124 #define TUNER_XC5000 76 /* Xceive Silicon Tuner */ 125 #define TUNER_TCL_MF02GIP_5N 77 /* TCL MF02GIP_5N */ 126 127 /* tv card specific */ 128 #define TDA9887_PRESENT (1<<0)
··· 123 #define TUNER_TEA5761 75 /* Only FM Radio Tuner */ 124 #define TUNER_XC5000 76 /* Xceive Silicon Tuner */ 125 #define TUNER_TCL_MF02GIP_5N 77 /* TCL MF02GIP_5N */ 126 + #define TUNER_PHILIPS_FMD1216MEX_MK3 78 127 128 /* tv card specific */ 129 #define TDA9887_PRESENT (1<<0)
+11
include/media/v4l2-i2c-drv-legacy.h
··· 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 */ 23 24 struct v4l2_i2c_driver_data { 25 const char * const name; 26 int driverid;
··· 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 */ 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 + 35 struct v4l2_i2c_driver_data { 36 const char * const name; 37 int driverid;
+11
include/media/v4l2-i2c-drv.h
··· 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 */ 23 24 #ifndef __V4L2_I2C_DRV_H__ 25 #define __V4L2_I2C_DRV_H__ 26
··· 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 */ 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 + 35 #ifndef __V4L2_I2C_DRV_H__ 36 #define __V4L2_I2C_DRV_H__ 37
+25 -4
include/media/videobuf-dvb.h
··· 16 int nfeeds; 17 18 /* videobuf_dvb_(un)register manges this */ 19 - struct dvb_adapter adapter; 20 struct dvb_demux demux; 21 struct dmxdev dmxdev; 22 struct dmx_frontend fe_hw; ··· 23 struct dvb_net net; 24 }; 25 26 - int videobuf_dvb_register(struct videobuf_dvb *dvb, 27 struct module *module, 28 void *adapter_priv, 29 struct device *device, 30 - short *adapter_nr); 31 - void videobuf_dvb_unregister(struct videobuf_dvb *dvb); 32 33 /* 34 * Local variables:
··· 16 int nfeeds; 17 18 /* videobuf_dvb_(un)register manges this */ 19 struct dvb_demux demux; 20 struct dmxdev dmxdev; 21 struct dmx_frontend fe_hw; ··· 24 struct dvb_net net; 25 }; 26 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, 42 struct module *module, 43 void *adapter_priv, 44 struct device *device, 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 + 55 56 /* 57 * Local variables: