Lines Matching +full:0 +full:xc4000

3  *  Driver for Xceive XC4000 "QAM/8VSB single chip tuner"
23 #include "xc4000.h"
29 MODULE_PARM_DESC(debug, "Debugging level (0 to 2, default: 0 (off)).");
33 MODULE_PARM_DESC(no_poweroff, "Power management (1: disabled, 2: enabled, 0 (default): use device-s…
37 MODULE_PARM_DESC(audio_std, "Audio standard. XC4000 audio decoder explicitly needs to know what aud…
46 module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0);
53 printk(KERN_INFO "%s: " fmt, "xc4000", ## arg)
101 #define XC4000_DEFAULT_FIRMWARE "dvb-fe-xc4000-1.4.fw"
102 #define XC4000_DEFAULT_FIRMWARE_NEW "dvb-fe-xc4000-1.4.1.fw"
107 #define XC_POWERED_DOWN 0x80000000U
110 #define XC_RF_MODE_AIR 0
114 #define XC_PRODUCT_ID_FW_NOT_LOADED 0x2000
115 #define XC_PRODUCT_ID_XC4000 0x0FA0
116 #define XC_PRODUCT_ID_XC4100 0x1004
119 #define XREG_INIT 0x00
120 #define XREG_VIDEO_MODE 0x01
121 #define XREG_AUDIO_MODE 0x02
122 #define XREG_RF_FREQ 0x03
123 #define XREG_D_CODE 0x04
124 #define XREG_DIRECTSITTING_MODE 0x05
125 #define XREG_SEEK_MODE 0x06
126 #define XREG_POWER_DOWN 0x08
127 #define XREG_SIGNALSOURCE 0x0A
128 #define XREG_SMOOTHEDCVBS 0x0E
129 #define XREG_AMPLITUDE 0x10
132 #define XREG_ADC_ENV 0x00
133 #define XREG_QUALITY 0x01
134 #define XREG_FRAME_LINES 0x02
135 #define XREG_HSYNC_FREQ 0x03
136 #define XREG_LOCK 0x04
137 #define XREG_FREQ_ERROR 0x05
138 #define XREG_SNR 0x06
139 #define XREG_VERSION 0x07
140 #define XREG_PRODUCT_ID 0x08
141 #define XREG_SIGNAL_LEVEL 0x0A
142 #define XREG_NOISE_LEVEL 0x0B
151 char[0 ]=len0_MSB -> len = len_MSB * 256 + len_LSB
170 len=0NNN_NNNN_NNNN_NNNN : Normal transaction: number of bytes = {1:32767)
185 #define XC4000_MN_NTSC_PAL_BTSC 0
211 {"M/N-NTSC/PAL-BTSC", 0x0000, 0x80A0, 4500},
212 {"M/N-NTSC/PAL-A2", 0x0000, 0x80A0, 4600},
213 {"M/N-NTSC/PAL-EIAJ", 0x0040, 0x80A0, 4500},
214 {"M/N-NTSC/PAL-Mono", 0x0078, 0x80A0, 4500},
215 {"B/G-PAL-A2", 0x0000, 0x8159, 5640},
216 {"B/G-PAL-NICAM", 0x0004, 0x8159, 5740},
217 {"B/G-PAL-MONO", 0x0078, 0x8159, 5500},
218 {"I-PAL-NICAM", 0x0080, 0x8049, 6240},
219 {"I-PAL-NICAM-MONO", 0x0078, 0x8049, 6000},
220 {"D/K-PAL-A2", 0x0000, 0x8049, 6380},
221 {"D/K-PAL-NICAM", 0x0080, 0x8049, 6200},
222 {"D/K-PAL-MONO", 0x0078, 0x8049, 6500},
223 {"D/K-SECAM-A2 DK1", 0x0000, 0x8049, 6340},
224 {"D/K-SECAM-A2 L/DK3", 0x0000, 0x8049, 6000},
225 {"D/K-SECAM-A2 MONO", 0x0078, 0x8049, 6500},
226 {"D/K-SECAM-NICAM", 0x0080, 0x8049, 6200},
227 {"L-SECAM-NICAM", 0x8080, 0x0009, 6200},
228 {"L'-SECAM-NICAM", 0x8080, 0x4009, 6200},
229 {"DTV6", 0x00C0, 0x8002, 0},
230 {"DTV8", 0x00C0, 0x800B, 0},
231 {"DTV7/8", 0x00C0, 0x801B, 0},
232 {"DTV7", 0x00C0, 0x8007, 0},
233 {"FM Radio-INPUT2", 0x0008, 0x9800, 10700},
234 {"FM Radio-INPUT1", 0x0008, 0x9000, 10700}
244 .flags = 0, .buf = buf, .len = len }; in xc_send_i2c_data()
246 if (priv->ignore_i2c_write_errors == 0) { in xc_send_i2c_data()
247 printk(KERN_ERR "xc4000: I2C write failed (len=%i)\n", in xc_send_i2c_data()
255 return 0; in xc_send_i2c_data()
270 XC4000_TUNER_RESET, 0); in xc4000_tuner_reset()
272 printk(KERN_ERR "xc4000: reset failed\n"); in xc4000_tuner_reset()
276 printk(KERN_ERR "xc4000: no tuner reset callback function, fatal\n"); in xc4000_tuner_reset()
279 return 0; in xc4000_tuner_reset()
286 buf[0] = (regAddr >> 8) & 0xFF; in xc_write_reg()
287 buf[1] = regAddr & 0xFF; in xc_write_reg()
288 buf[2] = (i2cData >> 8) & 0xFF; in xc_write_reg()
289 buf[3] = i2cData & 0xFF; in xc_write_reg()
302 index = 0; in xc_load_i2c_sequence()
303 while ((i2c_sequence[index] != 0xFF) || in xc_load_i2c_sequence()
304 (i2c_sequence[index + 1] != 0xFF)) { in xc_load_i2c_sequence()
306 if (len == 0x0000) { in xc_load_i2c_sequence()
311 } else if (len & 0x8000) { in xc_load_i2c_sequence()
313 msleep(len & 0x7FFF); in xc_load_i2c_sequence()
320 buf[0] = i2c_sequence[index]; in xc_load_i2c_sequence()
336 if (result != 0) in xc_load_i2c_sequence()
344 return 0; in xc_load_i2c_sequence()
351 dprintk(1, "%s(0x%04x,0x%04x)\n", __func__, video_mode, audio_mode); in xc_set_tv_standard()
360 if (ret == 0) in xc_set_tv_standard()
363 priv->ignore_i2c_write_errors = 0; in xc_set_tv_standard()
397 FINERFREQ for all normal tuning (the doc indicates reg 0x03 should in xc_set_rf_frequency()
415 if (result != 0) in xc_get_frequency_error()
418 tmp = (u32)regData & 0xFFFFU; in xc_get_frequency_error()
419 tmp = (tmp < 0x8000U ? tmp : 0x10000U - tmp); in xc_get_frequency_error()
437 if (result != 0) in xc_get_version()
440 (*hw_majorversion) = (data >> 12) & 0x0F; in xc_get_version()
441 (*hw_minorversion) = (data >> 8) & 0x0F; in xc_get_version()
442 (*fw_majorversion) = (data >> 4) & 0x0F; in xc_get_version()
443 (*fw_minorversion) = data & 0x0F; in xc_get_version()
445 return 0; in xc_get_version()
454 if (result != 0) in xc_get_hsync_freq()
457 (*hsync_freq_hz) = ((regData & 0x0fff) * 763)/100; in xc_get_hsync_freq()
483 u16 lock_state = 0; in xc_wait_for_lock()
486 while ((lock_state == 0) && (watchdog_count > 0)) { in xc_wait_for_lock()
506 priv->ignore_i2c_write_errors = 0; in xc_tune_channel()
508 if (result != 0) in xc_tune_channel()
509 return 0; in xc_tune_channel()
512 if ((priv->cur_fw.type & (FM | DTV6 | DTV7 | DTV78 | DTV8)) == 0) { in xc_tune_channel()
514 found = 0; in xc_tune_channel()
531 u8 buf[2] = { reg >> 8, reg & 0xff }; in xc4000_readreg()
532 u8 bval[2] = { 0, 0 }; in xc4000_readreg()
535 .flags = 0, .buf = &buf[0], .len = 2 }, in xc4000_readreg()
537 .flags = I2C_M_RD, .buf = &bval[0], .len = 2 }, in xc4000_readreg()
541 printk(KERN_ERR "xc4000: I2C read failed\n"); in xc4000_readreg()
545 *val = (bval[0] << 8) | bval[1]; in xc4000_readreg()
546 return 0; in xc4000_readreg()
549 #define dump_firm_type(t) dump_firm_type_and_int_freq(t, 0)
628 if (((type & ~SCODE) == 0) && (*id == 0)) in seek_firmware()
632 for (i = 0; i < priv->firm_size; i++) { in seek_firmware()
655 if (best_i < 0) { in seek_firmware()
660 if (best_nr_diffs > 0U) { in seek_firmware()
673 (i < 0) ? "Can't find" : "Found"); in seek_firmware()
688 if (pos < 0) in load_firmware()
698 priv->ignore_i2c_write_errors = 0; in load_firmware()
708 int rc = 0; in xc4000_fwupload()
713 if (firmware_name[0] != '\0') { in xc4000_fwupload()
732 if (rc < 0) { in xc4000_fwupload()
753 name[sizeof(name) - 1] = '\0'; in xc4000_fwupload()
764 priv->firm_version >> 8, priv->firm_version & 0xff); in xc4000_fwupload()
778 __u16 int_freq = 0; in xc4000_fwupload()
850 if (rc == 0) in xc4000_fwupload()
869 if (pos < 0) in load_scode()
872 for (pos = 0; pos < priv->firm_size; pos++) { in load_scode()
895 scode_buf[0] = 0x00; in load_scode()
899 rc = xc_write_reg(priv, XREG_DIRECTSITTING_MODE, 0); in load_scode()
900 if (rc < 0) { in load_scode()
906 if (rc != 0) { in load_scode()
913 memset(indirect_mode, 0, sizeof(indirect_mode)); in load_scode()
914 indirect_mode[4] = 0x88; in load_scode()
918 return 0; in load_scode()
926 int rc = 0, is_retry = 0; in check_firmware()
929 u8 hw_major = 0, hw_minor = 0, fw_major = 0, fw_minor = 0; in check_firmware()
935 if (rc < 0) in check_firmware()
944 new_fw.scode_nr = 0; in check_firmware()
966 memset(&priv->cur_fw, 0, sizeof(priv->cur_fw)); in check_firmware()
970 if (rc < 0) in check_firmware()
974 std0 = 0; in check_firmware()
976 if (rc < 0) { in check_firmware()
987 if (rc < 0 && rc != -ENOENT) { in check_firmware()
1005 priv->cur_fw.scode_table = 0; in check_firmware()
1010 if (rc < 0) in check_firmware()
1023 if (rc != 0) in check_firmware()
1027 if (xc4000_readreg(priv, XREG_PRODUCT_ID, &hwmodel) < 0) { in check_firmware()
1033 &fw_minor) != 0) { in check_firmware()
1050 if (priv->hwmodel == 0 && in check_firmware()
1055 } else if (priv->hwmodel == 0 || priv->hwmodel != hwmodel || in check_firmware()
1067 * 1. Identify that BASE firmware with type=0 has been loaded; in check_firmware()
1072 return 0; in check_firmware()
1075 memset(&priv->cur_fw, 0, sizeof(priv->cur_fw)); in check_firmware()
1091 u32 freq_error_hz = 0; in xc_debug_dump()
1093 u32 hsync_freq_hz = 0; in xc_debug_dump()
1096 u16 signal = 0; in xc_debug_dump()
1097 u16 noise = 0; in xc_debug_dump()
1098 u8 hw_majorversion = 0, hw_minorversion = 0; in xc_debug_dump()
1099 u8 fw_majorversion = 0, fw_minorversion = 0; in xc_debug_dump()
1102 dprintk(1, "*** ADC envelope (0-1023) = %d\n", adc_envelope); in xc_debug_dump()
1108 dprintk(1, "*** Lock status (0-Wait, 1-Locked, 2-No-signal) = %d\n", in xc_debug_dump()
1127 dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality); in xc_debug_dump()
1167 if (bw == 0) { in xc4000_set_params()
1191 printk(KERN_ERR "xc4000 delivery system not supported!\n"); in xc4000_set_params()
1202 if (check_firmware(fe, type, 0, priv->if_khz) != 0) in xc4000_set_params()
1208 if (ret != 0) { in xc4000_set_params()
1209 printk(KERN_ERR "xc4000: xc_set_signal_source(%d) failed\n", in xc4000_set_params()
1216 if (type == DTV6 && priv->firm_version != 0x0102) in xc4000_set_params()
1217 video_mode |= 0x0001; in xc4000_set_params()
1219 if (ret != 0) { in xc4000_set_params()
1220 printk(KERN_ERR "xc4000: xc_set_tv_standard failed\n"); in xc4000_set_params()
1226 if (xc_write_reg(priv, XREG_D_CODE, 0) == 0) in xc4000_set_params()
1227 ret = 0; in xc4000_set_params()
1228 if (priv->dvb_amplitude != 0) { in xc4000_set_params()
1230 (priv->firm_version != 0x0102 || in xc4000_set_params()
1232 priv->dvb_amplitude : 132)) != 0) in xc4000_set_params()
1235 if (priv->set_smoothedcvbs != 0) { in xc4000_set_params()
1236 if (xc_write_reg(priv, XREG_SMOOTHEDCVBS, 1) != 0) in xc4000_set_params()
1239 if (ret != 0) { in xc4000_set_params()
1240 printk(KERN_ERR "xc4000: setting registers failed\n"); in xc4000_set_params()
1246 ret = 0; in xc4000_set_params()
1258 unsigned int type = 0; in xc4000_set_analog_params()
1267 params->std = 0; in xc4000_set_analog_params()
1363 type = 0; in xc4000_set_analog_params()
1378 type = 0; in xc4000_set_analog_params()
1386 type = 0; in xc4000_set_analog_params()
1397 xc4000_standard[priv->video_standard].int_freq) != 0) in xc4000_set_analog_params()
1401 if (ret != 0) { in xc4000_set_analog_params()
1403 "xc4000: xc_set_signal_source(%d) failed\n", in xc4000_set_analog_params()
1412 video_mode &= 0xFF7F; in xc4000_set_analog_params()
1414 if (priv->firm_version == 0x0102) in xc4000_set_analog_params()
1415 video_mode &= 0xFEFF; in xc4000_set_analog_params()
1417 video_mode |= 0x0080; in xc4000_set_analog_params()
1420 if (ret != 0) { in xc4000_set_analog_params()
1421 printk(KERN_ERR "xc4000: xc_set_tv_standard failed\n"); in xc4000_set_analog_params()
1426 if (xc_write_reg(priv, XREG_D_CODE, 0) == 0) in xc4000_set_analog_params()
1427 ret = 0; in xc4000_set_analog_params()
1428 if (xc_write_reg(priv, XREG_AMPLITUDE, 1) != 0) in xc4000_set_analog_params()
1430 if (priv->set_smoothedcvbs != 0) { in xc4000_set_analog_params()
1431 if (xc_write_reg(priv, XREG_SMOOTHEDCVBS, 1) != 0) in xc4000_set_analog_params()
1434 if (ret != 0) { in xc4000_set_analog_params()
1435 printk(KERN_ERR "xc4000: setting registers failed\n"); in xc4000_set_analog_params()
1441 ret = 0; in xc4000_set_analog_params()
1452 u16 value = 0; in xc4000_get_signal()
1459 if (rc < 0) in xc4000_get_signal()
1463 coefficient for one dB is 0xff. in xc4000_get_signal()
1486 if (value >= 0x2000) { in xc4000_get_signal()
1487 value = 0; in xc4000_get_signal()
1489 value = (~value << 3) & 0xffff; in xc4000_get_signal()
1499 if (value <= 0x3200) { in xc4000_get_signal()
1500 value = 0xffff; in xc4000_get_signal()
1501 /* minimum: -114dB - should be 0x7200 but real zero is 0x713A */ in xc4000_get_signal()
1502 } else if (value >= 0x713A) { in xc4000_get_signal()
1503 value = 0; in xc4000_get_signal()
1505 value = ~(value - 0x3200) << 2; in xc4000_get_signal()
1524 u16 snr = 0; in xc4000_get_frequency()
1525 if (xc4000_readreg(priv, XREG_SNR, &snr) == 0) { in xc4000_get_frequency()
1529 return 0; in xc4000_get_frequency()
1537 return 0; in xc4000_get_frequency()
1546 return 0; in xc4000_get_bandwidth()
1552 u16 lock_status = 0; in xc4000_get_status()
1560 TUNER_STATUS_LOCKED | TUNER_STATUS_STEREO : 0); in xc4000_get_status()
1568 return 0; in xc4000_get_status()
1574 int ret = 0; in xc4000_sleep()
1582 (no_poweroff == 0 && priv->default_pm != 0)) && in xc4000_sleep()
1583 (priv->cur_fw.type & BASE) != 0) { in xc4000_sleep()
1587 if (xc_write_reg(priv, XREG_POWER_DOWN, 0) != 0) { in xc4000_sleep()
1589 "xc4000: %s() unable to shutdown tuner\n", in xc4000_sleep()
1605 return 0; in xc4000_init()
1626 .name = "Xceive XC4000",
1650 u16 id = 0; in xc4000_attach()
1660 i2c, cfg->i2c_address, "xc4000"); in xc4000_attach()
1662 case 0: in xc4000_attach()
1669 priv->default_pm = 0; in xc4000_attach()
1681 if (cfg->if_khz != 0) { in xc4000_attach()
1694 if (xc4000_readreg(priv, XREG_PRODUCT_ID, &id) != 0) in xc4000_attach()
1697 id = ((priv->cur_fw.type & BASE) != 0 ? in xc4000_attach()
1705 "xc4000: Successfully identified at address 0x%02x\n", in xc4000_attach()
1708 "xc4000: Firmware has been loaded previously\n"); in xc4000_attach()
1712 "xc4000: Successfully identified at address 0x%02x\n", in xc4000_attach()
1715 "xc4000: Firmware has not been loaded previously\n"); in xc4000_attach()
1719 "xc4000: Device not found at addr 0x%02x (0x%x)\n", in xc4000_attach()
1734 if (ret != 0) in xc4000_attach()
1748 MODULE_DESCRIPTION("Xceive xc4000 silicon tuner driver");