Lines Matching +full:fw +full:- +full:cfg
1 // SPDX-License-Identifier: GPL-2.0-or-later
21 #include "tuner-i2c.h"
88 /* Set the output amplitude - SIF for analog, DTVP/DTVN for digital */
118 char[0 ]=len0_MSB -> len = len_MSB * 256 + len_LSB
119 char[1 ]=len0_LSB -> length of first write transaction
120 char[2 ]=data0 -> first byte to be sent
124 char[M ]=dataN -> last byte to be sent
125 char[M+1]=len1_MSB -> len = len_MSB * 256 + len_LSB
126 char[M+2]=len1_LSB -> length of second write transaction
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},
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"
219 #define XC5000C_FIRMWARE "dvb-fe-xc5000c-4.1.30.7.fw"
246 struct i2c_msg msg = { .addr = priv->i2c_props.addr, in xc_send_i2c_data()
249 if (i2c_transfer(priv->i2c_props.adap, &msg, 1) != 1) { in xc_send_i2c_data()
251 return -EREMOTEIO; in xc_send_i2c_data()
259 transaction in case we are on a multi-master bus */
262 struct i2c_msg msg = { .addr = priv->i2c_props.addr,
265 if (i2c_transfer(priv->i2c_props.adap, &msg, 1) != 1) {
267 return -EREMOTEIO;
278 { .addr = priv->i2c_props.addr, in xc5000_readreg()
280 { .addr = priv->i2c_props.addr, in xc5000_readreg()
284 if (i2c_transfer(priv->i2c_props.adap, msg, 2) != 2) { in xc5000_readreg()
286 return -EREMOTEIO; in xc5000_readreg()
295 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_tuner_reset()
300 if (fe->callback) { in xc5000_tuner_reset()
301 ret = fe->callback(((fe->dvb) && (fe->dvb->priv)) ? in xc5000_tuner_reset()
302 fe->dvb->priv : in xc5000_tuner_reset()
303 priv->i2c_props.adap->algo_data, in xc5000_tuner_reset()
312 return -EINVAL; in xc5000_tuner_reset()
338 watch_dog_timer--; in xc_write_reg()
344 result = -EREMOTEIO; in xc_write_reg()
351 struct xc5000_priv *priv = fe->tuner_priv; in xc_load_i2c_sequence()
380 if ((len - pos) > XC_MAX_I2C_WRITE_LENGTH - 2) in xc_load_i2c_sequence()
384 nbytes_to_send = (len - pos + 2); in xc_load_i2c_sequence()
387 i - 2]; in xc_load_i2c_sequence()
395 pos += nbytes_to_send - 2; in xc_load_i2c_sequence()
421 xc5000_standard[priv->video_standard].name); in xc_set_tv_standard()
455 return -EINVAL; in xc_set_rf_frequency()
565 return -EREMOTEIO; in xc_tune_channel()
572 struct xc5000_priv *priv = fe->tuner_priv; in xc_set_xtal()
575 switch (priv->chip_id) { in xc_set_xtal()
581 switch (priv->xtal_khz) { in xc_set_xtal()
598 const struct firmware *fw) in xc5000_fwupload() argument
600 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_fwupload()
605 desired_fw->name); in xc5000_fwupload()
607 priv->pll_register_no = desired_fw->pll_reg; in xc5000_fwupload()
608 priv->init_status_supported = desired_fw->init_status_supported; in xc5000_fwupload()
609 priv->fw_checksum_supported = desired_fw->fw_checksum_supported; in xc5000_fwupload()
613 ret = xc_load_i2c_sequence(fe, fw->data); in xc5000_fwupload()
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()
657 dprintk(1, "*** HW: V%d.%d, FW: V %d.%d.%d\n", in xc_debug_dump()
677 if (priv->pll_register_no) { in xc_debug_dump()
678 if (!xc5000_readreg(priv, priv->pll_register_no, ®val)) in xc_debug_dump()
685 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_tune_digital()
687 u32 bw = fe->dtv_property_cache.bandwidth_hz; in xc5000_tune_digital()
689 ret = xc_set_signal_source(priv, priv->rf_mode); in xc5000_tune_digital()
693 priv->rf_mode); in xc5000_tune_digital()
694 return -EREMOTEIO; in xc5000_tune_digital()
698 xc5000_standard[priv->video_standard].video_mode, in xc5000_tune_digital()
699 xc5000_standard[priv->video_standard].audio_mode, 0); in xc5000_tune_digital()
702 return -EREMOTEIO; in xc5000_tune_digital()
705 ret = xc_set_IF_frequency(priv, priv->if_khz); in xc5000_tune_digital()
708 priv->if_khz); in xc5000_tune_digital()
709 return -EIO; in xc5000_tune_digital()
713 __func__, priv->output_amp); in xc5000_tune_digital()
714 xc_write_reg(priv, XREG_OUTPUT_AMP, priv->output_amp); in xc5000_tune_digital()
716 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_DIGITAL); in xc5000_tune_digital()
721 priv->bandwidth = bw; in xc5000_tune_digital()
729 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_set_digital_params()
730 u32 bw = fe->dtv_property_cache.bandwidth_hz; in xc5000_set_digital_params()
731 u32 freq = fe->dtv_property_cache.frequency; in xc5000_set_digital_params()
732 u32 delsys = fe->dtv_property_cache.delivery_system; in xc5000_set_digital_params()
736 return -EINVAL; in xc5000_set_digital_params()
744 priv->rf_mode = XC_RF_MODE_AIR; in xc5000_set_digital_params()
745 priv->freq_offset = 1750000; in xc5000_set_digital_params()
746 priv->video_standard = DTV6; in xc5000_set_digital_params()
750 priv->rf_mode = XC_RF_MODE_CABLE; in xc5000_set_digital_params()
751 priv->freq_offset = 1750000; in xc5000_set_digital_params()
752 priv->video_standard = DTV6; in xc5000_set_digital_params()
755 /* All ISDB-T are currently for 6 MHz bw */ in xc5000_set_digital_params()
766 priv->video_standard = DTV6; in xc5000_set_digital_params()
767 priv->freq_offset = 1750000; in xc5000_set_digital_params()
770 priv->video_standard = DTV7; in xc5000_set_digital_params()
771 priv->freq_offset = 2250000; in xc5000_set_digital_params()
774 priv->video_standard = DTV8; in xc5000_set_digital_params()
775 priv->freq_offset = 2750000; in xc5000_set_digital_params()
779 return -EINVAL; in xc5000_set_digital_params()
781 priv->rf_mode = XC_RF_MODE_AIR; in xc5000_set_digital_params()
786 priv->rf_mode = XC_RF_MODE_CABLE; in xc5000_set_digital_params()
788 priv->video_standard = DTV6; in xc5000_set_digital_params()
789 priv->freq_offset = 1750000; in xc5000_set_digital_params()
792 priv->video_standard = DTV7; in xc5000_set_digital_params()
793 priv->freq_offset = 2250000; in xc5000_set_digital_params()
796 priv->video_standard = DTV7_8; in xc5000_set_digital_params()
797 priv->freq_offset = 2750000; in xc5000_set_digital_params()
805 return -EINVAL; in xc5000_set_digital_params()
808 priv->freq_hz = freq - priv->freq_offset; in xc5000_set_digital_params()
809 priv->mode = V4L2_TUNER_DIGITAL_TV; in xc5000_set_digital_params()
812 __func__, freq, priv->freq_hz); in xc5000_set_digital_params()
819 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_is_firmware_loaded()
826 ret = -ENOENT; in xc5000_is_firmware_loaded()
840 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_config_tv()
843 __func__, params->frequency); in xc5000_config_tv()
846 priv->rf_mode = params->mode; in xc5000_config_tv()
847 if (params->mode > XC_RF_MODE_CABLE) in xc5000_config_tv()
848 priv->rf_mode = XC_RF_MODE_CABLE; in xc5000_config_tv()
850 /* params->frequency is in units of 62.5khz */ in xc5000_config_tv()
851 priv->freq_hz = params->frequency * 62500; in xc5000_config_tv()
856 if (params->std & V4L2_STD_MN) { in xc5000_config_tv()
858 priv->video_standard = MN_NTSC_PAL_BTSC; in xc5000_config_tv()
862 if (params->std & V4L2_STD_PAL_BG) { in xc5000_config_tv()
864 priv->video_standard = BG_PAL_NICAM; in xc5000_config_tv()
868 if (params->std & V4L2_STD_PAL_I) { in xc5000_config_tv()
870 priv->video_standard = I_PAL_NICAM; in xc5000_config_tv()
874 if (params->std & V4L2_STD_PAL_DK) { in xc5000_config_tv()
876 priv->video_standard = DK_PAL_NICAM; in xc5000_config_tv()
880 if (params->std & V4L2_STD_SECAM_DK) { in xc5000_config_tv()
882 priv->video_standard = DK_SECAM_A2DK1; in xc5000_config_tv()
886 if (params->std & V4L2_STD_SECAM_L) { in xc5000_config_tv()
887 priv->video_standard = L_SECAM_NICAM; in xc5000_config_tv()
891 if (params->std & V4L2_STD_SECAM_LC) { in xc5000_config_tv()
892 priv->video_standard = LC_SECAM_NICAM; in xc5000_config_tv()
899 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_set_tv_freq()
904 ret = xc_set_signal_source(priv, priv->rf_mode); in xc5000_set_tv_freq()
908 priv->rf_mode); in xc5000_set_tv_freq()
909 return -EREMOTEIO; in xc5000_set_tv_freq()
913 xc5000_standard[priv->video_standard].video_mode, in xc5000_set_tv_freq()
914 xc5000_standard[priv->video_standard].audio_mode, 0); in xc5000_set_tv_freq()
917 return -EREMOTEIO; in xc5000_set_tv_freq()
922 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_ANALOG); in xc5000_set_tv_freq()
927 if (priv->pll_register_no != 0) { in xc5000_set_tv_freq()
929 ret = xc5000_readreg(priv, priv->pll_register_no, in xc5000_set_tv_freq()
938 printk(KERN_ERR "xc5000: Unable to reload fw\n"); in xc5000_set_tv_freq()
939 return -EREMOTEIO; in xc5000_set_tv_freq()
952 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_config_radio()
955 __func__, params->frequency); in xc5000_config_radio()
957 if (priv->radio_input == XC5000_RADIO_NOT_CONFIGURED) { in xc5000_config_radio()
959 return -EINVAL; in xc5000_config_radio()
962 priv->freq_hz = params->frequency * 125 / 2; in xc5000_config_radio()
963 priv->rf_mode = XC_RF_MODE_AIR; in xc5000_config_radio()
970 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_set_radio_freq()
974 if (priv->radio_input == XC5000_RADIO_FM1) in xc5000_set_radio_freq()
976 else if (priv->radio_input == XC5000_RADIO_FM2) in xc5000_set_radio_freq()
978 else if (priv->radio_input == XC5000_RADIO_FM1_MONO) in xc5000_set_radio_freq()
982 priv->radio_input); in xc5000_set_radio_freq()
983 return -EINVAL; in xc5000_set_radio_freq()
991 return -EREMOTEIO; in xc5000_set_radio_freq()
994 ret = xc_set_signal_source(priv, priv->rf_mode); in xc5000_set_radio_freq()
998 priv->rf_mode); in xc5000_set_radio_freq()
999 return -EREMOTEIO; in xc5000_set_radio_freq()
1002 if ((priv->radio_input == XC5000_RADIO_FM1) || in xc5000_set_radio_freq()
1003 (priv->radio_input == XC5000_RADIO_FM2)) in xc5000_set_radio_freq()
1005 else if (priv->radio_input == XC5000_RADIO_FM1_MONO) in xc5000_set_radio_freq()
1008 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_ANALOG); in xc5000_set_radio_freq()
1015 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_set_params()
1019 return -EINVAL; in xc5000_set_params()
1022 switch (priv->mode) { in xc5000_set_params()
1037 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_set_analog_params()
1040 if (priv->i2c_props.adap == NULL) in xc5000_set_analog_params()
1041 return -EINVAL; in xc5000_set_analog_params()
1043 switch (params->mode) { in xc5000_set_analog_params()
1055 priv->mode = params->mode; in xc5000_set_analog_params()
1062 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_get_frequency()
1064 *freq = priv->freq_hz + priv->freq_offset; in xc5000_get_frequency()
1070 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_get_if_frequency()
1072 *freq = priv->if_khz * 1000; in xc5000_get_if_frequency()
1078 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_get_bandwidth()
1081 *bw = priv->bandwidth; in xc5000_get_bandwidth()
1087 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_get_status()
1101 struct xc5000_priv *priv = fe->tuner_priv; in xc_load_fw_and_init_tuner()
1102 const struct xc5000_fw_cfg *desired_fw = xc5000_assign_firmware(priv->chip_id); in xc_load_fw_and_init_tuner()
1103 const struct firmware *fw; in xc_load_fw_and_init_tuner() local
1108 cancel_delayed_work(&priv->timer_sleep); in xc_load_fw_and_init_tuner()
1113 ret = request_firmware(&fw, desired_fw->name, in xc_load_fw_and_init_tuner()
1114 priv->i2c_props.adap->dev.parent); in xc_load_fw_and_init_tuner()
1119 dprintk(1, "firmware read %zu bytes.\n", fw->size); in xc_load_fw_and_init_tuner()
1121 if (fw->size != desired_fw->size) { in xc_load_fw_and_init_tuner()
1123 release_firmware(fw); in xc_load_fw_and_init_tuner()
1124 return -EINVAL; in xc_load_fw_and_init_tuner()
1130 printk(KERN_CONT " - retrying to upload firmware.\n"); in xc_load_fw_and_init_tuner()
1132 ret = xc5000_fwupload(fe, desired_fw, fw); in xc_load_fw_and_init_tuner()
1138 if (priv->fw_checksum_supported) { 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()
1153 /* Start the tuner self-calibration process */ in xc_load_fw_and_init_tuner()
1156 printk(KERN_ERR "xc5000: Can't request self-calibration."); in xc_load_fw_and_init_tuner()
1167 if (priv->init_status_supported) { 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()
1182 if (priv->pll_register_no) { in xc_load_fw_and_init_tuner()
1183 ret = xc5000_readreg(priv, priv->pll_register_no, in xc_load_fw_and_init_tuner()
1203 release_firmware(fw); in xc_load_fw_and_init_tuner()
1206 desired_fw->name); in xc_load_fw_and_init_tuner()
1208 printk(KERN_CONT " - too many retries. Giving up\n"); in xc_load_fw_and_init_tuner()
1217 struct dvb_frontend *fe = priv->fe; in xc5000_do_timer_sleep()
1234 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_sleep()
1242 schedule_delayed_work(&priv->timer_sleep, in xc5000_sleep()
1250 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_suspend()
1255 cancel_delayed_work(&priv->timer_sleep); in xc5000_suspend()
1268 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_resume()
1274 if (!priv->inited) in xc5000_resume()
1282 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_init()
1287 return -EREMOTEIO; in xc5000_init()
1293 priv->inited = true; in xc5000_init()
1300 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_release()
1307 cancel_delayed_work(&priv->timer_sleep); in xc5000_release()
1313 fe->tuner_priv = NULL; in xc5000_release()
1318 struct xc5000_priv *priv = fe->tuner_priv; in xc5000_set_config()
1323 if (p->if_khz) in xc5000_set_config()
1324 priv->if_khz = p->if_khz; in xc5000_set_config()
1326 if (p->radio_input) in xc5000_set_config()
1327 priv->radio_input = p->radio_input; in xc5000_set_config()
1329 if (p->output_amp) in xc5000_set_config()
1330 priv->output_amp = p->output_amp; in xc5000_set_config()
1361 const struct xc5000_config *cfg) in xc5000_attach() argument
1367 dprintk(1, "%s(%d-%04x)\n", __func__, in xc5000_attach()
1368 i2c ? i2c_adapter_id(i2c) : -1, in xc5000_attach()
1369 cfg ? cfg->i2c_address : -1); in xc5000_attach()
1375 i2c, cfg->i2c_address, "xc5000"); in xc5000_attach()
1381 priv->bandwidth = 6000000; in xc5000_attach()
1382 fe->tuner_priv = priv; in xc5000_attach()
1383 priv->fe = fe; in xc5000_attach()
1384 INIT_DELAYED_WORK(&priv->timer_sleep, xc5000_do_timer_sleep); in xc5000_attach()
1388 fe->tuner_priv = priv; in xc5000_attach()
1392 if (priv->if_khz == 0) { in xc5000_attach()
1396 priv->if_khz = cfg->if_khz; in xc5000_attach()
1399 if (priv->xtal_khz == 0) in xc5000_attach()
1400 priv->xtal_khz = cfg->xtal_khz; in xc5000_attach()
1402 if (priv->radio_input == 0) in xc5000_attach()
1403 priv->radio_input = cfg->radio_input; in xc5000_attach()
1407 if ((priv->chip_id == 0) || (cfg->chip_id)) 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()
1428 cfg->i2c_address); in xc5000_attach()
1435 cfg->i2c_address); in xc5000_attach()
1442 cfg->i2c_address, id); in xc5000_attach()
1448 memcpy(&fe->ops.tuner_ops, &xc5000_tuner_ops, in xc5000_attach()