diff options
Diffstat (limited to 'drivers/media/common/tuners')
-rw-r--r-- | drivers/media/common/tuners/xc5000.c | 73 | ||||
-rw-r--r-- | drivers/media/common/tuners/xc5000.h | 8 |
2 files changed, 41 insertions, 40 deletions
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c index f9c2bb917f54..e12d13e0cbe9 100644 --- a/drivers/media/common/tuners/xc5000.c +++ b/drivers/media/common/tuners/xc5000.c | |||
@@ -43,7 +43,7 @@ MODULE_PARM_DESC(init_fw, "Load firmware during driver initialization."); | |||
43 | static DEFINE_MUTEX(xc5000_list_mutex); | 43 | static DEFINE_MUTEX(xc5000_list_mutex); |
44 | static LIST_HEAD(hybrid_tuner_instance_list); | 44 | static LIST_HEAD(hybrid_tuner_instance_list); |
45 | 45 | ||
46 | #define dprintk(level,fmt, arg...) if (debug >= level) \ | 46 | #define dprintk(level, fmt, arg...) if (debug >= level) \ |
47 | printk(KERN_INFO "%s: " fmt, "xc5000", ## arg) | 47 | printk(KERN_INFO "%s: " fmt, "xc5000", ## arg) |
48 | 48 | ||
49 | #define XC5000_DEFAULT_FIRMWARE "dvb-fe-xc5000-1.1.fw" | 49 | #define XC5000_DEFAULT_FIRMWARE "dvb-fe-xc5000-1.1.fw" |
@@ -138,11 +138,11 @@ struct xc5000_priv { | |||
138 | immediately the length of the following transaction. | 138 | immediately the length of the following transaction. |
139 | 139 | ||
140 | */ | 140 | */ |
141 | typedef struct { | 141 | struct XC_TV_STANDARD { |
142 | char *Name; | 142 | char *Name; |
143 | u16 AudioMode; | 143 | u16 AudioMode; |
144 | u16 VideoMode; | 144 | u16 VideoMode; |
145 | } XC_TV_STANDARD; | 145 | }; |
146 | 146 | ||
147 | /* Tuner standards */ | 147 | /* Tuner standards */ |
148 | #define MN_NTSC_PAL_BTSC 0 | 148 | #define MN_NTSC_PAL_BTSC 0 |
@@ -169,7 +169,7 @@ typedef struct { | |||
169 | #define FM_Radio_INPUT2 21 | 169 | #define FM_Radio_INPUT2 21 |
170 | #define FM_Radio_INPUT1 22 | 170 | #define FM_Radio_INPUT1 22 |
171 | 171 | ||
172 | static XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = { | 172 | static struct XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = { |
173 | {"M/N-NTSC/PAL-BTSC", 0x0400, 0x8020}, | 173 | {"M/N-NTSC/PAL-BTSC", 0x0400, 0x8020}, |
174 | {"M/N-NTSC/PAL-A2", 0x0600, 0x8020}, | 174 | {"M/N-NTSC/PAL-A2", 0x0600, 0x8020}, |
175 | {"M/N-NTSC/PAL-EIAJ", 0x0440, 0x8020}, | 175 | {"M/N-NTSC/PAL-EIAJ", 0x0440, 0x8020}, |
@@ -183,7 +183,7 @@ static XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = { | |||
183 | {"D/K-PAL-NICAM", 0x0E80, 0x8009}, | 183 | {"D/K-PAL-NICAM", 0x0E80, 0x8009}, |
184 | {"D/K-PAL-MONO", 0x1478, 0x8009}, | 184 | {"D/K-PAL-MONO", 0x1478, 0x8009}, |
185 | {"D/K-SECAM-A2 DK1", 0x1200, 0x8009}, | 185 | {"D/K-SECAM-A2 DK1", 0x1200, 0x8009}, |
186 | {"D/K-SECAM-A2 L/DK3",0x0E00, 0x8009}, | 186 | {"D/K-SECAM-A2 L/DK3", 0x0E00, 0x8009}, |
187 | {"D/K-SECAM-A2 MONO", 0x1478, 0x8009}, | 187 | {"D/K-SECAM-A2 MONO", 0x1478, 0x8009}, |
188 | {"L-SECAM-NICAM", 0x8E82, 0x0009}, | 188 | {"L-SECAM-NICAM", 0x8E82, 0x0009}, |
189 | {"L'-SECAM-NICAM", 0x8E82, 0x4009}, | 189 | {"L'-SECAM-NICAM", 0x8E82, 0x4009}, |
@@ -307,9 +307,10 @@ static int xc_load_i2c_sequence(struct dvb_frontend *fe, const u8 *i2c_sequence) | |||
307 | unsigned int len, pos, index; | 307 | unsigned int len, pos, index; |
308 | u8 buf[XC_MAX_I2C_WRITE_LENGTH]; | 308 | u8 buf[XC_MAX_I2C_WRITE_LENGTH]; |
309 | 309 | ||
310 | index=0; | 310 | index = 0; |
311 | while ((i2c_sequence[index]!=0xFF) || (i2c_sequence[index+1]!=0xFF)) { | 311 | while ((i2c_sequence[index] != 0xFF) || |
312 | len = i2c_sequence[index]* 256 + i2c_sequence[index+1]; | 312 | (i2c_sequence[index + 1] != 0xFF)) { |
313 | len = i2c_sequence[index] * 256 + i2c_sequence[index+1]; | ||
313 | if (len == 0x0000) { | 314 | if (len == 0x0000) { |
314 | /* RESET command */ | 315 | /* RESET command */ |
315 | result = xc_reset(fe); | 316 | result = xc_reset(fe); |
@@ -329,15 +330,17 @@ static int xc_load_i2c_sequence(struct dvb_frontend *fe, const u8 *i2c_sequence) | |||
329 | buf[1] = i2c_sequence[index + 1]; | 330 | buf[1] = i2c_sequence[index + 1]; |
330 | pos = 2; | 331 | pos = 2; |
331 | while (pos < len) { | 332 | while (pos < len) { |
332 | if ((len - pos) > XC_MAX_I2C_WRITE_LENGTH - 2) { | 333 | if ((len - pos) > XC_MAX_I2C_WRITE_LENGTH - 2) |
333 | nbytes_to_send = XC_MAX_I2C_WRITE_LENGTH; | 334 | nbytes_to_send = |
334 | } else { | 335 | XC_MAX_I2C_WRITE_LENGTH; |
336 | else | ||
335 | nbytes_to_send = (len - pos + 2); | 337 | nbytes_to_send = (len - pos + 2); |
338 | for (i = 2; i < nbytes_to_send; i++) { | ||
339 | buf[i] = i2c_sequence[index + pos + | ||
340 | i - 2]; | ||
336 | } | 341 | } |
337 | for (i=2; i<nbytes_to_send; i++) { | 342 | result = xc_send_i2c_data(priv, buf, |
338 | buf[i] = i2c_sequence[index + pos + i - 2]; | 343 | nbytes_to_send); |
339 | } | ||
340 | result = xc_send_i2c_data(priv, buf, nbytes_to_send); | ||
341 | 344 | ||
342 | if (result != XC_RESULT_SUCCESS) | 345 | if (result != XC_RESULT_SUCCESS) |
343 | return result; | 346 | return result; |
@@ -386,8 +389,7 @@ static int xc_SetSignalSource(struct xc5000_priv *priv, u16 rf_mode) | |||
386 | dprintk(1, "%s(%d) Source = %s\n", __func__, rf_mode, | 389 | dprintk(1, "%s(%d) Source = %s\n", __func__, rf_mode, |
387 | rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE"); | 390 | rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE"); |
388 | 391 | ||
389 | if ((rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE)) | 392 | if ((rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE)) { |
390 | { | ||
391 | rf_mode = XC_RF_MODE_CABLE; | 393 | rf_mode = XC_RF_MODE_CABLE; |
392 | printk(KERN_ERR | 394 | printk(KERN_ERR |
393 | "%s(), Invalid mode, defaulting to CABLE", | 395 | "%s(), Invalid mode, defaulting to CABLE", |
@@ -560,13 +562,13 @@ static int xc5000_readregs(struct xc5000_priv *priv, u8 *buf, u8 len) | |||
560 | .flags = I2C_M_RD, .buf = buf, .len = len }; | 562 | .flags = I2C_M_RD, .buf = buf, .len = len }; |
561 | 563 | ||
562 | if (i2c_transfer(priv->i2c_props.adap, &msg, 1) != 1) { | 564 | if (i2c_transfer(priv->i2c_props.adap, &msg, 1) != 1) { |
563 | printk(KERN_ERR "xc5000 I2C read failed (len=%i)\n",(int)len); | 565 | printk(KERN_ERR "xc5000 I2C read failed (len=%i)\n", (int)len); |
564 | return -EREMOTEIO; | 566 | return -EREMOTEIO; |
565 | } | 567 | } |
566 | return 0; | 568 | return 0; |
567 | } | 569 | } |
568 | 570 | ||
569 | static int xc5000_fwupload(struct dvb_frontend* fe) | 571 | static int xc5000_fwupload(struct dvb_frontend *fe) |
570 | { | 572 | { |
571 | struct xc5000_priv *priv = fe->tuner_priv; | 573 | struct xc5000_priv *priv = fe->tuner_priv; |
572 | const struct firmware *fw; | 574 | const struct firmware *fw; |
@@ -576,7 +578,8 @@ static int xc5000_fwupload(struct dvb_frontend* fe) | |||
576 | printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n", | 578 | printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n", |
577 | XC5000_DEFAULT_FIRMWARE); | 579 | XC5000_DEFAULT_FIRMWARE); |
578 | 580 | ||
579 | ret = request_firmware(&fw, XC5000_DEFAULT_FIRMWARE, &priv->i2c_props.adap->dev); | 581 | ret = request_firmware(&fw, XC5000_DEFAULT_FIRMWARE, |
582 | &priv->i2c_props.adap->dev); | ||
580 | if (ret) { | 583 | if (ret) { |
581 | printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); | 584 | printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); |
582 | ret = XC_RESULT_RESET_FAILURE; | 585 | ret = XC_RESULT_RESET_FAILURE; |
@@ -592,7 +595,7 @@ static int xc5000_fwupload(struct dvb_frontend* fe) | |||
592 | ret = XC_RESULT_RESET_FAILURE; | 595 | ret = XC_RESULT_RESET_FAILURE; |
593 | } else { | 596 | } else { |
594 | printk(KERN_INFO "xc5000: firmware upload\n"); | 597 | printk(KERN_INFO "xc5000: firmware upload\n"); |
595 | ret = xc_load_i2c_sequence(fe, fw->data ); | 598 | ret = xc_load_i2c_sequence(fe, fw->data); |
596 | } | 599 | } |
597 | 600 | ||
598 | out: | 601 | out: |
@@ -651,7 +654,7 @@ static int xc5000_set_params(struct dvb_frontend *fe, | |||
651 | 654 | ||
652 | dprintk(1, "%s() frequency=%d (Hz)\n", __func__, params->frequency); | 655 | dprintk(1, "%s() frequency=%d (Hz)\n", __func__, params->frequency); |
653 | 656 | ||
654 | switch(params->u.vsb.modulation) { | 657 | switch (params->u.vsb.modulation) { |
655 | case VSB_8: | 658 | case VSB_8: |
656 | case VSB_16: | 659 | case VSB_16: |
657 | dprintk(1, "%s() VSB modulation\n", __func__); | 660 | dprintk(1, "%s() VSB modulation\n", __func__); |
@@ -748,42 +751,42 @@ static int xc5000_set_analog_params(struct dvb_frontend *fe, | |||
748 | /* FIX ME: Some video standards may have several possible audio | 751 | /* FIX ME: Some video standards may have several possible audio |
749 | standards. We simply default to one of them here. | 752 | standards. We simply default to one of them here. |
750 | */ | 753 | */ |
751 | if(params->std & V4L2_STD_MN) { | 754 | if (params->std & V4L2_STD_MN) { |
752 | /* default to BTSC audio standard */ | 755 | /* default to BTSC audio standard */ |
753 | priv->video_standard = MN_NTSC_PAL_BTSC; | 756 | priv->video_standard = MN_NTSC_PAL_BTSC; |
754 | goto tune_channel; | 757 | goto tune_channel; |
755 | } | 758 | } |
756 | 759 | ||
757 | if(params->std & V4L2_STD_PAL_BG) { | 760 | if (params->std & V4L2_STD_PAL_BG) { |
758 | /* default to NICAM audio standard */ | 761 | /* default to NICAM audio standard */ |
759 | priv->video_standard = BG_PAL_NICAM; | 762 | priv->video_standard = BG_PAL_NICAM; |
760 | goto tune_channel; | 763 | goto tune_channel; |
761 | } | 764 | } |
762 | 765 | ||
763 | if(params->std & V4L2_STD_PAL_I) { | 766 | if (params->std & V4L2_STD_PAL_I) { |
764 | /* default to NICAM audio standard */ | 767 | /* default to NICAM audio standard */ |
765 | priv->video_standard = I_PAL_NICAM; | 768 | priv->video_standard = I_PAL_NICAM; |
766 | goto tune_channel; | 769 | goto tune_channel; |
767 | } | 770 | } |
768 | 771 | ||
769 | if(params->std & V4L2_STD_PAL_DK) { | 772 | if (params->std & V4L2_STD_PAL_DK) { |
770 | /* default to NICAM audio standard */ | 773 | /* default to NICAM audio standard */ |
771 | priv->video_standard = DK_PAL_NICAM; | 774 | priv->video_standard = DK_PAL_NICAM; |
772 | goto tune_channel; | 775 | goto tune_channel; |
773 | } | 776 | } |
774 | 777 | ||
775 | if(params->std & V4L2_STD_SECAM_DK) { | 778 | if (params->std & V4L2_STD_SECAM_DK) { |
776 | /* default to A2 DK1 audio standard */ | 779 | /* default to A2 DK1 audio standard */ |
777 | priv->video_standard = DK_SECAM_A2DK1; | 780 | priv->video_standard = DK_SECAM_A2DK1; |
778 | goto tune_channel; | 781 | goto tune_channel; |
779 | } | 782 | } |
780 | 783 | ||
781 | if(params->std & V4L2_STD_SECAM_L) { | 784 | if (params->std & V4L2_STD_SECAM_L) { |
782 | priv->video_standard = L_SECAM_NICAM; | 785 | priv->video_standard = L_SECAM_NICAM; |
783 | goto tune_channel; | 786 | goto tune_channel; |
784 | } | 787 | } |
785 | 788 | ||
786 | if(params->std & V4L2_STD_SECAM_LC) { | 789 | if (params->std & V4L2_STD_SECAM_LC) { |
787 | priv->video_standard = LC_SECAM_NICAM; | 790 | priv->video_standard = LC_SECAM_NICAM; |
788 | goto tune_channel; | 791 | goto tune_channel; |
789 | } | 792 | } |
@@ -791,7 +794,7 @@ static int xc5000_set_analog_params(struct dvb_frontend *fe, | |||
791 | tune_channel: | 794 | tune_channel: |
792 | ret = xc_SetSignalSource(priv, priv->rf_mode); | 795 | ret = xc_SetSignalSource(priv, priv->rf_mode); |
793 | if (ret != XC_RESULT_SUCCESS) { | 796 | if (ret != XC_RESULT_SUCCESS) { |
794 | printk(KERN_ERR | 797 | printk(KERN_ERR |
795 | "xc5000: xc_SetSignalSource(%d) failed\n", | 798 | "xc5000: xc_SetSignalSource(%d) failed\n", |
796 | priv->rf_mode); | 799 | priv->rf_mode); |
797 | return -EREMOTEIO; | 800 | return -EREMOTEIO; |
@@ -863,7 +866,7 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe) | |||
863 | * I2C transactions until calibration is complete. This way we | 866 | * I2C transactions until calibration is complete. This way we |
864 | * don't have to rely on clock stretching working. | 867 | * don't have to rely on clock stretching working. |
865 | */ | 868 | */ |
866 | xc_wait( 100 ); | 869 | xc_wait(100); |
867 | 870 | ||
868 | /* Default to "CABLE" mode */ | 871 | /* Default to "CABLE" mode */ |
869 | ret |= xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE); | 872 | ret |= xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE); |
@@ -885,15 +888,13 @@ static int xc5000_sleep(struct dvb_frontend *fe) | |||
885 | */ | 888 | */ |
886 | 889 | ||
887 | ret = xc_shutdown(priv); | 890 | ret = xc_shutdown(priv); |
888 | if(ret != XC_RESULT_SUCCESS) { | 891 | if (ret != XC_RESULT_SUCCESS) { |
889 | printk(KERN_ERR | 892 | printk(KERN_ERR |
890 | "xc5000: %s() unable to shutdown tuner\n", | 893 | "xc5000: %s() unable to shutdown tuner\n", |
891 | __func__); | 894 | __func__); |
892 | return -EREMOTEIO; | 895 | return -EREMOTEIO; |
893 | } | 896 | } else |
894 | else { | ||
895 | return XC_RESULT_SUCCESS; | 897 | return XC_RESULT_SUCCESS; |
896 | } | ||
897 | } | 898 | } |
898 | 899 | ||
899 | static int xc5000_init(struct dvb_frontend *fe) | 900 | static int xc5000_init(struct dvb_frontend *fe) |
@@ -989,7 +990,7 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, | |||
989 | if (xc5000_readreg(priv, XREG_PRODUCT_ID, &id) != 0) | 990 | if (xc5000_readreg(priv, XREG_PRODUCT_ID, &id) != 0) |
990 | goto fail; | 991 | goto fail; |
991 | 992 | ||
992 | switch(id) { | 993 | switch (id) { |
993 | case XC_PRODUCT_ID_FW_LOADED: | 994 | case XC_PRODUCT_ID_FW_LOADED: |
994 | printk(KERN_INFO | 995 | printk(KERN_INFO |
995 | "xc5000: Successfully identified at address 0x%02x\n", | 996 | "xc5000: Successfully identified at address 0x%02x\n", |
diff --git a/drivers/media/common/tuners/xc5000.h b/drivers/media/common/tuners/xc5000.h index cf1a558e0e7f..f4c146698a00 100644 --- a/drivers/media/common/tuners/xc5000.h +++ b/drivers/media/common/tuners/xc5000.h | |||
@@ -45,17 +45,17 @@ struct xc5000_config { | |||
45 | 45 | ||
46 | #if defined(CONFIG_MEDIA_TUNER_XC5000) || \ | 46 | #if defined(CONFIG_MEDIA_TUNER_XC5000) || \ |
47 | (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) | 47 | (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) |
48 | extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, | 48 | extern struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, |
49 | struct i2c_adapter *i2c, | 49 | struct i2c_adapter *i2c, |
50 | struct xc5000_config *cfg); | 50 | struct xc5000_config *cfg); |
51 | #else | 51 | #else |
52 | static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, | 52 | static inline struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, |
53 | struct i2c_adapter *i2c, | 53 | struct i2c_adapter *i2c, |
54 | struct xc5000_config *cfg) | 54 | struct xc5000_config *cfg) |
55 | { | 55 | { |
56 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | 56 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
57 | return NULL; | 57 | return NULL; |
58 | } | 58 | } |
59 | #endif // CONFIG_MEDIA_TUNER_XC5000 | 59 | #endif |
60 | 60 | ||
61 | #endif // __XC5000_H__ | 61 | #endif |