Lines Matching +full:0 +full:xc5000
3 * Driver for Xceive XC5000 "QAM/8VSB single chip tuner"
20 #include "xc5000.h"
29 MODULE_PARM_DESC(no_poweroff, "0 (default) powers device off when not used.\n"
37 printk(KERN_INFO "%s: " fmt, "xc5000", ## arg)
72 #define XC_RF_MODE_AIR 0
76 #define XC_PRODUCT_ID_FW_NOT_LOADED 0x2000
77 #define XC_PRODUCT_ID_FW_LOADED 0x1388
80 #define XREG_INIT 0x00
81 #define XREG_VIDEO_MODE 0x01
82 #define XREG_AUDIO_MODE 0x02
83 #define XREG_RF_FREQ 0x03
84 #define XREG_D_CODE 0x04
85 #define XREG_IF_OUT 0x05
86 #define XREG_SEEK_MODE 0x07
87 #define XREG_POWER_DOWN 0x0A /* Obsolete */
89 #define XREG_OUTPUT_AMP 0x0B
90 #define XREG_SIGNALSOURCE 0x0D /* 0=Air, 1=Cable */
91 #define XREG_SMOOTHEDCVBS 0x0E
92 #define XREG_XTALFREQ 0x0F
93 #define XREG_FINERFREQ 0x10
94 #define XREG_DDIMODE 0x11
96 #define XREG_ADC_ENV 0x00
97 #define XREG_QUALITY 0x01
98 #define XREG_FRAME_LINES 0x02
99 #define XREG_HSYNC_FREQ 0x03
100 #define XREG_LOCK 0x04
101 #define XREG_FREQ_ERROR 0x05
102 #define XREG_SNR 0x06
103 #define XREG_VERSION 0x07
104 #define XREG_PRODUCT_ID 0x08
105 #define XREG_BUSY 0x09
106 #define XREG_BUILD 0x0D
107 #define XREG_TOTALGAIN 0x0F
108 #define XREG_FW_CHECKSUM 0x12
109 #define XREG_INIT_STATUS 0x13
118 char[0 ]=len0_MSB -> len = len_MSB * 256 + len_LSB
137 len=0NNN_NNNN_NNNN_NNNN : Normal transaction: number of bytes = {1:32767)
151 #define MN_NTSC_PAL_BTSC 0
177 {"M/N-NTSC/PAL-BTSC", 0x0400, 0x8020},
178 {"M/N-NTSC/PAL-A2", 0x0600, 0x8020},
179 {"M/N-NTSC/PAL-EIAJ", 0x0440, 0x8020},
180 {"M/N-NTSC/PAL-Mono", 0x0478, 0x8020},
181 {"B/G-PAL-A2", 0x0A00, 0x8049},
182 {"B/G-PAL-NICAM", 0x0C04, 0x8049},
183 {"B/G-PAL-MONO", 0x0878, 0x8059},
184 {"I-PAL-NICAM", 0x1080, 0x8009},
185 {"I-PAL-NICAM-MONO", 0x0E78, 0x8009},
186 {"D/K-PAL-A2", 0x1600, 0x8009},
187 {"D/K-PAL-NICAM", 0x0E80, 0x8009},
188 {"D/K-PAL-MONO", 0x1478, 0x8009},
189 {"D/K-SECAM-A2 DK1", 0x1200, 0x8009},
190 {"D/K-SECAM-A2 L/DK3", 0x0E00, 0x8009},
191 {"D/K-SECAM-A2 MONO", 0x1478, 0x8009},
192 {"L-SECAM-NICAM", 0x8E82, 0x0009},
193 {"L'-SECAM-NICAM", 0x8E82, 0x4009},
194 {"DTV6", 0x00C0, 0x8002},
195 {"DTV8", 0x00C0, 0x800B},
196 {"DTV7/8", 0x00C0, 0x801B},
197 {"DTV7", 0x00C0, 0x8007},
198 {"FM Radio-INPUT2", 0x9802, 0x9002},
199 {"FM Radio-INPUT1", 0x0208, 0x9002},
200 {"FM Radio-INPUT1_MONO", 0x0278, 0x9002}
212 #define XC5000A_FIRMWARE "dvb-fe-xc5000-1.6.114.fw"
216 .pll_reg = 0x806c,
223 .pll_reg = 0x13,
247 .flags = 0, .buf = buf, .len = len }; in xc_send_i2c_data()
250 printk(KERN_ERR "xc5000: I2C write failed (len=%i)\n", len); in xc_send_i2c_data()
253 return 0; in xc_send_i2c_data()
256 #if 0
266 printk(KERN_ERR "xc5000 I2C read failed (len=%i)\n", len);
269 return 0;
275 u8 buf[2] = { reg >> 8, reg & 0xff }; in xc5000_readreg()
276 u8 bval[2] = { 0, 0 }; in xc5000_readreg()
279 .flags = 0, .buf = &buf[0], .len = 2 }, in xc5000_readreg()
281 .flags = I2C_M_RD, .buf = &bval[0], .len = 2 }, in xc5000_readreg()
285 printk(KERN_WARNING "xc5000: I2C read failed\n"); in xc5000_readreg()
289 *val = (bval[0] << 8) | bval[1]; in xc5000_readreg()
290 return 0; in xc5000_readreg()
305 XC5000_TUNER_RESET, 0); in xc5000_tuner_reset()
307 printk(KERN_ERR "xc5000: reset failed\n"); in xc5000_tuner_reset()
311 printk(KERN_ERR "xc5000: no tuner reset callback function, fatal\n"); in xc5000_tuner_reset()
314 return 0; in xc5000_tuner_reset()
323 buf[0] = (reg_addr >> 8) & 0xFF; in xc_write_reg()
324 buf[1] = reg_addr & 0xFF; in xc_write_reg()
325 buf[2] = (i2c_data >> 8) & 0xFF; in xc_write_reg()
326 buf[3] = i2c_data & 0xFF; in xc_write_reg()
328 if (result == 0) { in xc_write_reg()
330 while ((watch_dog_timer > 0) && (result == 0)) { in xc_write_reg()
332 if (result == 0) { in xc_write_reg()
333 if ((buf[0] == 0) && (buf[1] == 0)) { in xc_write_reg()
343 if (watch_dog_timer <= 0) in xc_write_reg()
357 index = 0; in xc_load_i2c_sequence()
358 while ((i2c_sequence[index] != 0xFF) || in xc_load_i2c_sequence()
359 (i2c_sequence[index + 1] != 0xFF)) { in xc_load_i2c_sequence()
361 if (len == 0x0000) { in xc_load_i2c_sequence()
365 if (result != 0) in xc_load_i2c_sequence()
367 } else if (len & 0x8000) { in xc_load_i2c_sequence()
369 msleep(len & 0x7FFF); in xc_load_i2c_sequence()
376 buf[0] = i2c_sequence[index]; in xc_load_i2c_sequence()
392 if (result != 0) in xc_load_i2c_sequence()
400 return 0; in xc_load_i2c_sequence()
406 return xc_write_reg(priv, XREG_INIT, 0); in xc_initialize()
413 dprintk(1, "%s(0x%04x,0x%04x)\n", __func__, video_mode, audio_mode); in xc_set_tv_standard()
425 if (ret == 0) in xc_set_tv_standard()
460 FINERFREQ for all normal tuning (the doc indicates reg 0x03 should in xc_set_rf_frequency()
469 dprintk(1, "%s(freq_khz = %d) freq_code = 0x%x\n", in xc_set_IF_frequency()
488 if (result != 0) in xc_get_frequency_error()
509 if (result != 0) in xc_get_version()
512 (*hw_majorversion) = (data >> 12) & 0x0F; in xc_get_version()
513 (*hw_minorversion) = (data >> 8) & 0x0F; in xc_get_version()
514 (*fw_majorversion) = (data >> 4) & 0x0F; in xc_get_version()
515 (*fw_minorversion) = data & 0x0F; in xc_get_version()
517 return 0; in xc_get_version()
531 if (result != 0) in xc_get_hsync_freq()
534 (*hsync_freq_hz) = ((reg_data & 0x0fff) * 763)/100; in xc_get_hsync_freq()
558 #define XC_TUNE_ANALOG 0
564 if (xc_set_rf_frequency(priv, freq_hz) != 0) in xc_tune_channel()
567 return 0; in xc_tune_channel()
573 int ret = 0; in xc_set_xtal()
588 ret = xc_write_reg(priv, 0x000f, 0x8081); in xc_set_xtal()
618 printk(KERN_ERR "xc5000: firmware upload failed...\n"); in xc5000_fwupload()
626 u32 freq_error_hz = 0; in xc_debug_dump()
628 u32 hsync_freq_hz = 0; in xc_debug_dump()
633 u8 hw_majorversion = 0, hw_minorversion = 0; in xc_debug_dump()
634 u8 fw_majorversion = 0, fw_minorversion = 0; in xc_debug_dump()
635 u16 fw_buildversion = 0; in xc_debug_dump()
645 dprintk(1, "*** ADC envelope (0-1023) = %d\n", adc_envelope); in xc_debug_dump()
651 dprintk(1, "*** Lock status (0-Wait, 1-Locked, 2-No-signal) = %d\n", in xc_debug_dump()
668 dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality & 0x07); in xc_debug_dump()
671 dprintk(1, "*** Unweighted analog SNR = %d dB\n", snr & 0x3f); in xc_debug_dump()
679 dprintk(1, "*** PLL lock status = 0x%04x\n", regval); in xc_debug_dump()
690 if (ret != 0) { in xc5000_tune_digital()
692 "xc5000: xc_set_signal_source(%d) failed\n", in xc5000_tune_digital()
699 xc5000_standard[priv->video_standard].audio_mode, 0); in xc5000_tune_digital()
700 if (ret != 0) { in xc5000_tune_digital()
701 printk(KERN_ERR "xc5000: xc_set_tv_standard failed\n"); in xc5000_tune_digital()
706 if (ret != 0) { in xc5000_tune_digital()
707 printk(KERN_ERR "xc5000: xc_Set_IF_frequency(%d) failed\n", in xc5000_tune_digital()
712 dprintk(1, "%s() setting OUTPUT_AMP to 0x%x\n", in xc5000_tune_digital()
723 return 0; in xc5000_tune_digital()
734 if (xc_load_fw_and_init_tuner(fe, 0) != 0) { in xc5000_set_digital_params()
778 printk(KERN_ERR "xc5000 bandwidth not set!\n"); in xc5000_set_digital_params()
804 printk(KERN_ERR "xc5000: delivery system is not supported!\n"); in xc5000_set_digital_params()
828 ret = 0; in xc5000_is_firmware_loaded()
829 dprintk(1, "%s() returns id = 0x%x\n", __func__, id); in xc5000_is_firmware_loaded()
905 if (ret != 0) { in xc5000_set_tv_freq()
907 "xc5000: xc_set_signal_source(%d) failed\n", in xc5000_set_tv_freq()
914 xc5000_standard[priv->video_standard].audio_mode, 0); in xc5000_set_tv_freq()
915 if (ret != 0) { in xc5000_set_tv_freq()
916 printk(KERN_ERR "xc5000: xc_set_tv_standard failed\n"); in xc5000_set_tv_freq()
920 xc_write_reg(priv, XREG_OUTPUT_AMP, 0x09); in xc5000_set_tv_freq()
927 if (priv->pll_register_no != 0) { in xc5000_set_tv_freq()
935 dprintk(1, "xc5000: PLL not locked (0x%x). Reloading...\n", in xc5000_set_tv_freq()
937 if (xc_load_fw_and_init_tuner(fe, 1) != 0) { in xc5000_set_tv_freq()
938 printk(KERN_ERR "xc5000: Unable to reload fw\n"); in xc5000_set_tv_freq()
945 return 0; in xc5000_set_tv_freq()
965 return 0; in xc5000_config_radio()
989 if (ret != 0) { in xc5000_set_radio_freq()
990 printk(KERN_ERR "xc5000: xc_set_tv_standard failed\n"); in xc5000_set_radio_freq()
995 if (ret != 0) { in xc5000_set_radio_freq()
997 "xc5000: xc_set_signal_source(%d) failed\n", in xc5000_set_radio_freq()
1004 xc_write_reg(priv, XREG_OUTPUT_AMP, 0x09); in xc5000_set_radio_freq()
1006 xc_write_reg(priv, XREG_OUTPUT_AMP, 0x06); in xc5000_set_radio_freq()
1010 return 0; in xc5000_set_radio_freq()
1017 if (xc_load_fw_and_init_tuner(fe, 0) != 0) { in xc5000_set_params()
1031 return 0; in xc5000_set_params()
1065 return 0; in xc5000_get_frequency()
1073 return 0; in xc5000_get_if_frequency()
1082 return 0; in xc5000_get_bandwidth()
1088 u16 lock_status = 0; in xc5000_get_status()
1092 dprintk(1, "%s() lock_status = 0x%08x\n", __func__, lock_status); in xc5000_get_status()
1096 return 0; in xc5000_get_status()
1110 if (!force && xc5000_is_firmware_loaded(fe) == 0) in xc_load_fw_and_init_tuner()
1111 return 0; in xc_load_fw_and_init_tuner()
1116 pr_err("xc5000: Upload failed. rc %d\n", ret); in xc_load_fw_and_init_tuner()
1122 pr_err("xc5000: Firmware file with incorrect size\n"); in xc_load_fw_and_init_tuner()
1128 for (i = 0; i < 5; i++) { in xc_load_fw_and_init_tuner()
1133 if (ret != 0) in xc_load_fw_and_init_tuner()
1141 "xc5000: FW checksum reading failed."); in xc_load_fw_and_init_tuner()
1147 "xc5000: FW checksum failed = 0x%04x.", in xc_load_fw_and_init_tuner()
1156 printk(KERN_ERR "xc5000: Can't request self-calibration."); in xc_load_fw_and_init_tuner()
1161 * We could continue but XC5000 will clock stretch subsequent in xc_load_fw_and_init_tuner()
1170 "xc5000: FW failed reading init status."); in xc_load_fw_and_init_tuner()
1176 "xc5000: FW init status failed = 0x%04x.", in xc_load_fw_and_init_tuner()
1190 "xc5000: PLL not running after fwload."); in xc_load_fw_and_init_tuner()
1199 printk(KERN_ERR "xc5000: can't set to cable mode."); in xc_load_fw_and_init_tuner()
1205 printk(KERN_INFO "xc5000: Firmware %s loaded and running.\n", in xc_load_fw_and_init_tuner()
1226 if (ret != 0) in xc5000_do_timer_sleep()
1228 "xc5000: %s() unable to shutdown tuner\n", in xc5000_do_timer_sleep()
1240 return 0; in xc5000_sleep()
1245 return 0; in xc5000_sleep()
1258 if (ret != 0) in xc5000_suspend()
1260 "xc5000: %s() unable to shutdown tuner\n", in xc5000_suspend()
1263 return 0; in xc5000_suspend()
1275 return 0; in xc5000_resume()
1285 if (xc_load_fw_and_init_tuner(fe, 0) != 0) { in xc5000_init()
1286 printk(KERN_ERR "xc5000: Unable to initialise tuner\n"); in xc5000_init()
1295 return 0; in xc5000_init()
1332 return 0; in xc5000_set_config()
1338 .name = "Xceive XC5000",
1365 u16 id = 0; in xc5000_attach()
1375 i2c, cfg->i2c_address, "xc5000"); in xc5000_attach()
1377 case 0: in xc5000_attach()
1392 if (priv->if_khz == 0) { in xc5000_attach()
1399 if (priv->xtal_khz == 0) in xc5000_attach()
1402 if (priv->radio_input == 0) in xc5000_attach()
1407 if ((priv->chip_id == 0) || (cfg->chip_id)) in xc5000_attach()
1408 /* use default chip id if none specified, set to 0 so in xc5000_attach()
1410 priv->chip_id = (cfg->chip_id) ? cfg->chip_id : 0; in xc5000_attach()
1414 if ((priv->output_amp == 0) || (cfg->output_amp)) in xc5000_attach()
1416 priv->output_amp = (cfg->output_amp) ? cfg->output_amp : 0x8a; in xc5000_attach()
1421 if (xc5000_readreg(priv, XREG_PRODUCT_ID, &id) != 0) in xc5000_attach()
1427 "xc5000: Successfully identified at address 0x%02x\n", in xc5000_attach()
1430 "xc5000: Firmware has been loaded previously\n"); in xc5000_attach()
1434 "xc5000: Successfully identified at address 0x%02x\n", in xc5000_attach()
1437 "xc5000: Firmware has not been loaded previously\n"); in xc5000_attach()
1441 "xc5000: Device not found at addr 0x%02x (0x%x)\n", in xc5000_attach()
1461 MODULE_DESCRIPTION("Xceive xc5000 silicon tuner driver");