aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorIstvan Varga <istvan_v@mailbox.hu>2011-06-03 09:11:48 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-27 16:52:33 -0400
commitfbe4a29f2f6523b8b839debb19baa49461a302be (patch)
tree8b3ac548af1900c93dd551bd983706623490bfb7 /drivers/media
parente3bb7c607f5ca87030692ad4dab653b4a8d1571a (diff)
[media] xc4000: code cleanup
This is the first of a set of patches that update the original xc4000 sources to my modified version. It removes some unused code, and makes a few minor formatting changes. [mchehab@redhat.com: re-add XC_TUNE_ANALOG/XC_TUNE_DIGITAL constants, to avoid compilation breakage] Signed-off-by: Istvan Varga <istvan_v@mailbox.hu> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/common/tuners/xc4000.c156
-rw-r--r--drivers/media/common/tuners/xc4000.h4
2 files changed, 45 insertions, 115 deletions
diff --git a/drivers/media/common/tuners/xc4000.c b/drivers/media/common/tuners/xc4000.c
index 19be5aa21107..15e4e99ad9cb 100644
--- a/drivers/media/common/tuners/xc4000.c
+++ b/drivers/media/common/tuners/xc4000.c
@@ -55,8 +55,6 @@ static LIST_HEAD(hybrid_tuner_instance_list);
55/* Note that the last version digit is my internal build number (so I can 55/* Note that the last version digit is my internal build number (so I can
56 rev the firmware even if the core Xceive firmware was unchanged) */ 56 rev the firmware even if the core Xceive firmware was unchanged) */
57#define XC4000_DEFAULT_FIRMWARE "dvb-fe-xc4000-1.4.1.fw" 57#define XC4000_DEFAULT_FIRMWARE "dvb-fe-xc4000-1.4.1.fw"
58#define XC4000_DEFAULT_FIRMWARE_SIZE 18643
59
60 58
61/* struct for storing firmware table */ 59/* struct for storing firmware table */
62struct firmware_description { 60struct firmware_description {
@@ -80,18 +78,18 @@ struct xc4000_priv {
80 struct tuner_i2c_props i2c_props; 78 struct tuner_i2c_props i2c_props;
81 struct list_head hybrid_tuner_instance_list; 79 struct list_head hybrid_tuner_instance_list;
82 struct firmware_description *firm; 80 struct firmware_description *firm;
83 int firm_size; 81 int firm_size;
84 __u16 firm_version; 82 __u16 firm_version;
85 u32 if_khz; 83 u32 if_khz;
86 u32 freq_hz; 84 u32 freq_hz;
87 u32 bandwidth; 85 u32 bandwidth;
88 u8 video_standard; 86 u8 video_standard;
89 u8 rf_mode; 87 u8 rf_mode;
90// struct xc2028_ctrl ctrl; 88 u8 ignore_i2c_write_errors;
89 /* struct xc2028_ctrl ctrl; */
91 struct firmware_properties cur_fw; 90 struct firmware_properties cur_fw;
92 __u16 hwmodel; 91 __u16 hwmodel;
93 __u16 hwvers; 92 __u16 hwvers;
94 u8 ignore_i2c_write_errors;
95}; 93};
96 94
97/* Misc Defines */ 95/* Misc Defines */
@@ -167,12 +165,12 @@ struct xc4000_priv {
167 165
168 For the RESET and WAIT commands, the two following bytes will contain 166 For the RESET and WAIT commands, the two following bytes will contain
169 immediately the length of the following transaction. 167 immediately the length of the following transaction.
170
171*/ 168*/
169
172struct XC_TV_STANDARD { 170struct XC_TV_STANDARD {
173 char *Name; 171 const char *Name;
174 u16 AudioMode; 172 u16 AudioMode;
175 u16 VideoMode; 173 u16 VideoMode;
176}; 174};
177 175
178/* Tuner standards */ 176/* Tuner standards */
@@ -200,33 +198,6 @@ struct XC_TV_STANDARD {
200#define XC4000_FM_Radio_INPUT2 21 198#define XC4000_FM_Radio_INPUT2 21
201#define XC4000_FM_Radio_INPUT1 22 199#define XC4000_FM_Radio_INPUT1 22
202 200
203/* WAS :
204static struct XC_TV_STANDARD XC4000_Standard[MAX_TV_STANDARD] = {
205 {"M/N-NTSC/PAL-BTSC", 0x0400, 0x8020},
206 {"M/N-NTSC/PAL-A2", 0x0600, 0x8020},
207 {"M/N-NTSC/PAL-EIAJ", 0x0440, 0x8020},
208 {"M/N-NTSC/PAL-Mono", 0x0478, 0x8020},
209 {"B/G-PAL-A2", 0x0A00, 0x8049},
210 {"B/G-PAL-NICAM", 0x0C04, 0x8049},
211 {"B/G-PAL-MONO", 0x0878, 0x8059},
212 {"I-PAL-NICAM", 0x1080, 0x8009},
213 {"I-PAL-NICAM-MONO", 0x0E78, 0x8009},
214 {"D/K-PAL-A2", 0x1600, 0x8009},
215 {"D/K-PAL-NICAM", 0x0E80, 0x8009},
216 {"D/K-PAL-MONO", 0x1478, 0x8009},
217 {"D/K-SECAM-A2 DK1", 0x1200, 0x8009},
218 {"D/K-SECAM-A2 L/DK3", 0x0E00, 0x8009},
219 {"D/K-SECAM-A2 MONO", 0x1478, 0x8009},
220 {"L-SECAM-NICAM", 0x8E82, 0x0009},
221 {"L'-SECAM-NICAM", 0x8E82, 0x4009},
222 {"DTV6", 0x00C0, 0x8002},
223 {"DTV8", 0x00C0, 0x800B},
224 {"DTV7/8", 0x00C0, 0x801B},
225 {"DTV7", 0x00C0, 0x8007},
226 {"FM Radio-INPUT2", 0x9802, 0x9002},
227 {"FM Radio-INPUT1", 0x0208, 0x9002}
228};*/
229
230static struct XC_TV_STANDARD XC4000_Standard[MAX_TV_STANDARD] = { 201static struct XC_TV_STANDARD XC4000_Standard[MAX_TV_STANDARD] = {
231 {"M/N-NTSC/PAL-BTSC", 0x0000, 0x8020}, 202 {"M/N-NTSC/PAL-BTSC", 0x0000, 0x8020},
232 {"M/N-NTSC/PAL-A2", 0x0000, 0x8020}, 203 {"M/N-NTSC/PAL-A2", 0x0000, 0x8020},
@@ -253,7 +224,6 @@ static struct XC_TV_STANDARD XC4000_Standard[MAX_TV_STANDARD] = {
253 {"FM Radio-INPUT1", 0x0008, 0x9000} 224 {"FM Radio-INPUT1", 0x0008, 0x9000}
254}; 225};
255 226
256static int xc4000_is_firmware_loaded(struct dvb_frontend *fe);
257static int xc4000_readreg(struct xc4000_priv *priv, u16 reg, u16 *val); 227static int xc4000_readreg(struct xc4000_priv *priv, u16 reg, u16 *val);
258static int xc4000_TunerReset(struct dvb_frontend *fe); 228static int xc4000_TunerReset(struct dvb_frontend *fe);
259 229
@@ -275,10 +245,6 @@ static int xc_send_i2c_data(struct xc4000_priv *priv, u8 *buf, int len)
275 return XC_RESULT_SUCCESS; 245 return XC_RESULT_SUCCESS;
276} 246}
277 247
278/* This routine is never used because the only time we read data from the
279 i2c bus is when we read registers, and we want that to be an atomic i2c
280 transaction in case we are on a multi-master bus */
281
282static void xc_wait(int wait_ms) 248static void xc_wait(int wait_ms)
283{ 249{
284 msleep(wait_ms); 250 msleep(wait_ms);
@@ -431,7 +397,6 @@ static int xc_set_RF_frequency(struct xc4000_priv *priv, u32 freq_hz)
431 return xc_write_reg(priv, XREG_RF_FREQ, freq_code); /* WAS: XREG_FINERFREQ */ 397 return xc_write_reg(priv, XREG_RF_FREQ, freq_code); /* WAS: XREG_FINERFREQ */
432} 398}
433 399
434
435static int xc_get_ADC_Envelope(struct xc4000_priv *priv, u16 *adc_envelope) 400static int xc_get_ADC_Envelope(struct xc4000_priv *priv, u16 *adc_envelope)
436{ 401{
437 return xc4000_readreg(priv, XREG_ADC_ENV, adc_envelope); 402 return xc4000_readreg(priv, XREG_ADC_ENV, adc_envelope);
@@ -476,12 +441,6 @@ static int xc_get_version(struct xc4000_priv *priv,
476 return 0; 441 return 0;
477} 442}
478 443
479/* WAS THERE
480static int xc_get_buildversion(struct xc4000_priv *priv, u16 *buildrev)
481{
482 return xc4000_readreg(priv, XREG_BUILD, buildrev);
483}*/
484
485static int xc_get_hsync_freq(struct xc4000_priv *priv, u32 *hsync_freq_hz) 444static int xc_get_hsync_freq(struct xc4000_priv *priv, u32 *hsync_freq_hz)
486{ 445{
487 u16 regData; 446 u16 regData;
@@ -524,8 +483,8 @@ static u16 WaitForLock(struct xc4000_priv *priv)
524#define XC_TUNE_DIGITAL 1 483#define XC_TUNE_DIGITAL 1
525static int xc_tune_channel(struct xc4000_priv *priv, u32 freq_hz, int mode) 484static int xc_tune_channel(struct xc4000_priv *priv, u32 freq_hz, int mode)
526{ 485{
527 int found = 0; 486 int found = 0;
528 int result = 0; 487 int result = 0;
529 488
530 dprintk(1, "%s(%u)\n", __func__, freq_hz); 489 dprintk(1, "%s(%u)\n", __func__, freq_hz);
531 490
@@ -694,7 +653,6 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type,
694 if (best_nr_matches > 0) { 653 if (best_nr_matches > 0) {
695 printk("Selecting best matching firmware (%d bits) for " 654 printk("Selecting best matching firmware (%d bits) for "
696 "type=", best_nr_matches); 655 "type=", best_nr_matches);
697// dump_firm_type(type);
698 printk("(%x), id %016llx:\n", type, (unsigned long long)*id); 656 printk("(%x), id %016llx:\n", type, (unsigned long long)*id);
699 i = best_i; 657 i = best_i;
700 goto found; 658 goto found;
@@ -749,7 +707,7 @@ static int xc4000_fwupload(struct dvb_frontend *fe)
749 int rc = 0; 707 int rc = 0;
750 int n, n_array; 708 int n, n_array;
751 char name[33]; 709 char name[33];
752 char *fname; 710 const char *fname;
753 711
754 fname = XC4000_DEFAULT_FIRMWARE; 712 fname = XC4000_DEFAULT_FIRMWARE;
755 713
@@ -770,7 +728,7 @@ static int xc4000_fwupload(struct dvb_frontend *fe)
770 728
771 if (fw->size < sizeof(name) - 1 + 2 + 2) { 729 if (fw->size < sizeof(name) - 1 + 2 + 2) {
772 printk("Error: firmware file %s has invalid size!\n", 730 printk("Error: firmware file %s has invalid size!\n",
773 fname); 731 fname);
774 goto corrupt; 732 goto corrupt;
775 } 733 }
776 734
@@ -805,7 +763,7 @@ static int xc4000_fwupload(struct dvb_frontend *fe)
805 n++; 763 n++;
806 if (n >= n_array) { 764 if (n >= n_array) {
807 printk("More firmware images in file than " 765 printk("More firmware images in file than "
808 "were expected!\n"); 766 "were expected!\n");
809 goto corrupt; 767 goto corrupt;
810 } 768 }
811 769
@@ -831,7 +789,6 @@ static int xc4000_fwupload(struct dvb_frontend *fe)
831 789
832 if (!size || size > endp - p) { 790 if (!size || size > endp - p) {
833 printk("Firmware type "); 791 printk("Firmware type ");
834// dump_firm_type(type);
835 printk("(%x), id %llx is corrupted " 792 printk("(%x), id %llx is corrupted "
836 "(size=%d, expected %d)\n", 793 "(size=%d, expected %d)\n",
837 type, (unsigned long long)id, 794 type, (unsigned long long)id,
@@ -877,7 +834,6 @@ corrupt:
877 834
878err: 835err:
879 printk("Releasing partially loaded firmware file.\n"); 836 printk("Releasing partially loaded firmware file.\n");
880// free_firmware(priv);
881 837
882done: 838done:
883 release_firmware(fw); 839 release_firmware(fw);
@@ -986,8 +942,7 @@ retry:
986 new_fw.type = type; 942 new_fw.type = type;
987 new_fw.id = std; 943 new_fw.id = std;
988 new_fw.std_req = std; 944 new_fw.std_req = std;
989// new_fw.scode_table = SCODE | priv->ctrl.scode_table; 945 new_fw.scode_table = SCODE /* | priv->ctrl.scode_table */;
990 new_fw.scode_table = SCODE;
991 new_fw.scode_nr = 0; 946 new_fw.scode_nr = 0;
992 new_fw.int_freq = int_freq; 947 new_fw.int_freq = int_freq;
993 948
@@ -1108,7 +1063,7 @@ check_device:
1108 } else if (priv->hwmodel == 0 || priv->hwmodel != hwmodel || 1063 } else if (priv->hwmodel == 0 || priv->hwmodel != hwmodel ||
1109 priv->hwvers != (version & 0xff00)) { 1064 priv->hwvers != (version & 0xff00)) {
1110 printk("Read invalid device hardware information - tuner " 1065 printk("Read invalid device hardware information - tuner "
1111 "hung?\n"); 1066 "hung?\n");
1112 goto fail; 1067 goto fail;
1113 } 1068 }
1114 1069
@@ -1140,15 +1095,14 @@ fail:
1140 1095
1141static void xc_debug_dump(struct xc4000_priv *priv) 1096static void xc_debug_dump(struct xc4000_priv *priv)
1142{ 1097{
1143 u16 adc_envelope; 1098 u16 adc_envelope;
1144 u32 freq_error_hz = 0; 1099 u32 freq_error_hz = 0;
1145 u16 lock_status; 1100 u16 lock_status;
1146 u32 hsync_freq_hz = 0; 1101 u32 hsync_freq_hz = 0;
1147 u16 frame_lines; 1102 u16 frame_lines;
1148 u16 quality; 1103 u16 quality;
1149 u8 hw_majorversion = 0, hw_minorversion = 0; 1104 u8 hw_majorversion = 0, hw_minorversion = 0;
1150 u8 fw_majorversion = 0, fw_minorversion = 0; 1105 u8 fw_majorversion = 0, fw_minorversion = 0;
1151// u16 fw_buildversion = 0;
1152 1106
1153 /* Wait for stats to stabilize. 1107 /* Wait for stats to stabilize.
1154 * Frame Lines needs two frame times after initial lock 1108 * Frame Lines needs two frame times after initial lock
@@ -1156,35 +1110,30 @@ static void xc_debug_dump(struct xc4000_priv *priv)
1156 */ 1110 */
1157 xc_wait(100); 1111 xc_wait(100);
1158 1112
1159 xc_get_ADC_Envelope(priv, &adc_envelope); 1113 xc_get_ADC_Envelope(priv, &adc_envelope);
1160 dprintk(1, "*** ADC envelope (0-1023) = %d\n", adc_envelope); 1114 dprintk(1, "*** ADC envelope (0-1023) = %d\n", adc_envelope);
1161 1115
1162 xc_get_frequency_error(priv, &freq_error_hz); 1116 xc_get_frequency_error(priv, &freq_error_hz);
1163 dprintk(1, "*** Frequency error = %d Hz\n", freq_error_hz); 1117 dprintk(1, "*** Frequency error = %d Hz\n", freq_error_hz);
1164 1118
1165 xc_get_lock_status(priv, &lock_status); 1119 xc_get_lock_status(priv, &lock_status);
1166 dprintk(1, "*** Lock status (0-Wait, 1-Locked, 2-No-signal) = %d\n", 1120 dprintk(1, "*** Lock status (0-Wait, 1-Locked, 2-No-signal) = %d\n",
1167 lock_status); 1121 lock_status);
1168 1122
1169 xc_get_version(priv, &hw_majorversion, &hw_minorversion, 1123 xc_get_version(priv, &hw_majorversion, &hw_minorversion,
1170 &fw_majorversion, &fw_minorversion); 1124 &fw_majorversion, &fw_minorversion);
1171// WAS: 1125
1172// xc_get_buildversion(priv, &fw_buildversion);
1173// dprintk(1, "*** HW: V%02x.%02x, FW: V%02x.%02x.%04x\n",
1174// hw_majorversion, hw_minorversion,
1175// fw_majorversion, fw_minorversion, fw_buildversion);
1176// NOW:
1177 dprintk(1, "*** HW: V%02x.%02x, FW: V%02x.%02x\n", 1126 dprintk(1, "*** HW: V%02x.%02x, FW: V%02x.%02x\n",
1178 hw_majorversion, hw_minorversion, 1127 hw_majorversion, hw_minorversion,
1179 fw_majorversion, fw_minorversion); 1128 fw_majorversion, fw_minorversion);
1180 1129
1181 xc_get_hsync_freq(priv, &hsync_freq_hz); 1130 xc_get_hsync_freq(priv, &hsync_freq_hz);
1182 dprintk(1, "*** Horizontal sync frequency = %d Hz\n", hsync_freq_hz); 1131 dprintk(1, "*** Horizontal sync frequency = %d Hz\n", hsync_freq_hz);
1183 1132
1184 xc_get_frame_lines(priv, &frame_lines); 1133 xc_get_frame_lines(priv, &frame_lines);
1185 dprintk(1, "*** Frame lines = %d\n", frame_lines); 1134 dprintk(1, "*** Frame lines = %d\n", frame_lines);
1186 1135
1187 xc_get_quality(priv, &quality); 1136 xc_get_quality(priv, &quality);
1188 dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality); 1137 dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality);
1189} 1138}
1190 1139
@@ -1193,7 +1142,7 @@ static int xc4000_set_params(struct dvb_frontend *fe,
1193{ 1142{
1194 struct xc4000_priv *priv = fe->tuner_priv; 1143 struct xc4000_priv *priv = fe->tuner_priv;
1195 unsigned int type; 1144 unsigned int type;
1196 int ret; 1145 int ret;
1197 1146
1198 dprintk(1, "%s() frequency=%d (Hz)\n", __func__, params->frequency); 1147 dprintk(1, "%s() frequency=%d (Hz)\n", __func__, params->frequency);
1199 1148
@@ -1290,30 +1239,11 @@ static int xc4000_set_params(struct dvb_frontend *fe,
1290 return 0; 1239 return 0;
1291} 1240}
1292 1241
1293static int xc4000_is_firmware_loaded(struct dvb_frontend *fe)
1294{
1295 struct xc4000_priv *priv = fe->tuner_priv;
1296 int ret;
1297 u16 id;
1298
1299 ret = xc4000_readreg(priv, XREG_PRODUCT_ID, &id);
1300 if (ret == XC_RESULT_SUCCESS) {
1301 if (id == XC_PRODUCT_ID_FW_NOT_LOADED)
1302 ret = XC_RESULT_RESET_FAILURE;
1303 else
1304 ret = XC_RESULT_SUCCESS;
1305 }
1306
1307 dprintk(1, "%s() returns %s id = 0x%x\n", __func__,
1308 ret == XC_RESULT_SUCCESS ? "True" : "False", id);
1309 return ret;
1310}
1311
1312static int xc4000_set_analog_params(struct dvb_frontend *fe, 1242static int xc4000_set_analog_params(struct dvb_frontend *fe,
1313 struct analog_parameters *params) 1243 struct analog_parameters *params)
1314{ 1244{
1315 struct xc4000_priv *priv = fe->tuner_priv; 1245 struct xc4000_priv *priv = fe->tuner_priv;
1316 int ret; 1246 int ret;
1317 1247
1318 dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n", 1248 dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n",
1319 __func__, params->frequency); 1249 __func__, params->frequency);
@@ -1420,7 +1350,7 @@ static int xc4000_get_bandwidth(struct dvb_frontend *fe, u32 *bw)
1420static int xc4000_get_status(struct dvb_frontend *fe, u32 *status) 1350static int xc4000_get_status(struct dvb_frontend *fe, u32 *status)
1421{ 1351{
1422 struct xc4000_priv *priv = fe->tuner_priv; 1352 struct xc4000_priv *priv = fe->tuner_priv;
1423 u16 lock_status = 0; 1353 u16 lock_status = 0;
1424 1354
1425 xc_get_lock_status(priv, &lock_status); 1355 xc_get_lock_status(priv, &lock_status);
1426 1356
@@ -1495,8 +1425,8 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe,
1495 struct xc4000_config *cfg) 1425 struct xc4000_config *cfg)
1496{ 1426{
1497 struct xc4000_priv *priv = NULL; 1427 struct xc4000_priv *priv = NULL;
1498 int instance; 1428 int instance;
1499 u16 id = 0; 1429 u16 id = 0;
1500 1430
1501 dprintk(1, "%s(%d-%04x)\n", __func__, 1431 dprintk(1, "%s(%d-%04x)\n", __func__,
1502 i2c ? i2c_adapter_id(i2c) : -1, 1432 i2c ? i2c_adapter_id(i2c) : -1,
diff --git a/drivers/media/common/tuners/xc4000.h b/drivers/media/common/tuners/xc4000.h
index 2bbbe9d6480b..3881ba26b794 100644
--- a/drivers/media/common/tuners/xc4000.h
+++ b/drivers/media/common/tuners/xc4000.h
@@ -28,8 +28,8 @@ struct dvb_frontend;
28struct i2c_adapter; 28struct i2c_adapter;
29 29
30struct xc4000_config { 30struct xc4000_config {
31 u8 i2c_address; 31 u8 i2c_address;
32 u32 if_khz; 32 u32 if_khz;
33}; 33};
34 34
35/* xc4000 callback command */ 35/* xc4000 callback command */