/*check tuner*/
if (!timer_tuner_not_enough()) {
strenth = tuner_get_ch_power2();
+
+ /*agc control,fine tune strength*/
+ if (is_ic_ver(IC_VER_TL1) && (dtvdd_devp->pin_name != NULL) &&
+ (strncmp(fe->ops.tuner_ops.info.name, "r842", 4)
+ == 0)) {
+ strenth += 22;
+
+ if (strenth <= -80)
+ strenth = dvbc_get_power_strength(
+ qam_read_reg(0x27) & 0x7ff, strenth);
+ }
+
if (strenth < -87) {
*status = FE_TIMEDOUT;
return 0;
static int gxtv_demod_dvbc_read_signal_strength
(struct dvb_frontend *fe, u16 *strength)
{
+ int tuner_sr;
#if 0
tn_strength = fe->ops.tuner_ops.get_strength(fe);
*strength = 256 - tn_strength;
#else
- *strength = tuner_get_ch_power3();
+ if (is_ic_ver(IC_VER_TL1) &&
+ (dtvdd_devp->pin_name != NULL) &&
+ (strncmp(fe->ops.tuner_ops.info.name, "r842", 4) == 0)) {
+ tuner_sr = tuner_get_ch_power2();
+ tuner_sr += 22;
+
+ if (tuner_sr <= -80)
+ tuner_sr = dvbc_get_power_strength(
+ qam_read_reg(0x27) & 0x7ff, tuner_sr);
+
+ if (tuner_sr < -100)
+ *strength = 0;
+ else
+ *strength = tuner_sr + 100;
+ } else
+ *strength = tuner_get_ch_power3();
#endif
return 0;
static int gxtv_demod_atsc_read_signal_strength
(struct dvb_frontend *fe, u16 *strength)
{
+ int strenth;
+
+ strenth = tuner_get_ch_power(fe);
/* struct aml_fe *afe = fe->demodulator_priv;*/
/*struct aml_fe_dev *dev = afe->dtv_demod; */
+ if (is_ic_ver(IC_VER_TL1) && (dtvdd_devp->pin_name != NULL) &&
+ (strncmp(fe->ops.tuner_ops.info.name, "r842", 4) == 0)) {
+ if ((fe->dtv_property_cache.modulation <= QAM_AUTO) &&
+ (fe->dtv_property_cache.modulation != QPSK))
+ strenth += 18;
+ else {
+ strenth += 15;
+ if (strenth <= -80)
+ strenth = atsc_get_power_strength(
+ atsc_read_reg_v4(0x44) & 0xfff,
+ strenth);
+ }
+ if (strenth < -100)
+ *strength = 0;
+ else
+ *strength = strenth + 100;
+ } else
+ *strength = tuner_get_ch_power3();
- *strength = tuner_get_ch_power3();
- #if 0
- if (*strength < 0)
- *strength = 0;
- else if (*strength > 100)
- *strength = 100;
- #endif
if (*strength > 100)
*strength = 100;
union ATSC_DEMOD_REG_0X6A_BITS Val_0x6a;
union ATSC_CNTR_REG_0X20_BITS Val_0x20;
int nco_rate;
+ /*[0]: specturm inverse(1),normal(0); [1]:if_frequency*/
+ unsigned int tuner_freq[2] = {0};
memset(¶m_atsc, 0, sizeof(param_atsc));
memset(¶m_j83b, 0, sizeof(param_j83b));
atsc_write_reg_v4(ATSC_DEMOD_REG_0X6A, Val_0x6a.bits);
atsc_write_reg_v4(ATSC_EQ_REG_0XA5, 0x8c);
+ if (fe->ops.tuner_ops.get_if_frequency)
+ fe->ops.tuner_ops.
+ get_if_frequency(fe, tuner_freq);
+
+ /*bit 2: invert specturm, for r842 tuner AGC control*/
+ if (tuner_freq[0] == 1)
+ atsc_write_reg_v4(ATSC_DEMOD_REG_0X56, 0x4);
+ else
+ atsc_write_reg_v4(ATSC_DEMOD_REG_0X56, 0x0);
+
if (demod_status.adc_freq == Adc_Clk_24M) {
atsc_write_reg_v4(ATSC_DEMOD_REG_0X54,
0x1aaaaa);
msleep(dvb_tuner_delay);
strenth = tuner_get_ch_power(fe);
+
+ /*agc control,fine tune strength*/
+ if (is_ic_ver(IC_VER_TL1) && (dtvdd_devp->pin_name != NULL) &&
+ (strncmp(fe->ops.tuner_ops.info.name, "r842", 4) == 0)) {
+ strenth += 15;
+ if (strenth <= -80)
+ strenth = atsc_get_power_strength(
+ atsc_read_reg_v4(0x44) & 0xfff, strenth);
+ }
+
if (strenth < THRD_TUNER_STRENTH_ATSC) {
*status = FE_TIMEDOUT;
PR_ATSC("tuner:no signal!\n");
msleep(dvb_tuner_delay);
strenth = tuner_get_ch_power(fe);
+
+ /*agc control,fine tune strength*/
+ if (is_ic_ver(IC_VER_TL1) && (dtvdd_devp->pin_name != NULL) &&
+ (strncmp(fe->ops.tuner_ops.info.name, "r842", 4) == 0))
+ strenth += 18;
+
if (strenth < THRD_TUNER_STRENTH_J83) {
*s = FE_TIMEDOUT;
PR_ATSC("tuner:no signal!j83\n");
PR_ERR("%s:not support %d!\n", __func__, get_dtmb_ver());
return -1;
}
+
s = amdemod_dtmb_stat_islock();
-/* s=1;*/
+
if (s == 1) {
ilock = 1;
*status =
static int gxtv_demod_dtmb_read_signal_strength
(struct dvb_frontend *fe, u16 *strength)
{
+ int tuner_sr;
- *strength = tuner_get_ch_power3();
+ if (is_ic_ver(IC_VER_TL1) &&
+ (dtvdd_devp->pin_name != NULL) &&
+ (strncmp(fe->ops.tuner_ops.info.name, "r842", 4) == 0)) {
+ tuner_sr = tuner_get_ch_power2();
+ tuner_sr += 16;
+
+ if (tuner_sr < -100)
+ *strength = 0;
+ else
+ *strength = tuner_sr + 100;
+ } else
+ *strength = tuner_get_ch_power3();
return 0;
}
qam_write_reg(0x7, qam_read_reg(0x7) & ~(1 << 0));
/* Sw disable demod */
qam_write_reg(0x7, qam_read_reg(0x7) | (1 << 0));
+
+ if (is_ic_ver(IC_VER_TL1))
+ if (agc_mode == 1) {
+ qam_write_reg(0x25,
+ qam_read_reg(0x25) & ~(0x1 << 10));
+ qam_write_reg(0x24,
+ qam_read_reg(0x24) | (0x1 << 17));
+ #if 0
+ qam_write_reg(0x3d,
+ qam_read_reg(0x3d) | 0xf);
+ #endif
+ }
+
/* Sw enable demod */
qam_write_reg(0x0, 0x0);
/* QAM_STATUS */
/* agc control */
/* dvbc_write_reg(QAM_BASE+0x094, 0x7f800d2c);// AGC_CTRL ALPS tuner */
/* dvbc_write_reg(QAM_BASE+0x094, 0x7f80292c); // Pilips Tuner */
- if ((agc_mode & 1) == 0)
- /* freeze if agc */
- qam_write_reg(0x25,
- qam_read_reg(0x25) | (0x1 << 10));
- if ((agc_mode & 2) == 0) {
- /* IF control */
- /*freeze rf agc */
- qam_write_reg(0x25,
- qam_read_reg(0x25) | (0x1 << 13));
+ if (!is_ic_ver(IC_VER_TL1)) {
+ if ((agc_mode & 1) == 0)
+ /* freeze if agc */
+ qam_write_reg(0x25,
+ qam_read_reg(0x25) | (0x1 << 10));
+ if ((agc_mode & 2) == 0) {
+ /* IF control */
+ /*freeze rf agc */
+ qam_write_reg(0x25,
+ qam_read_reg(0x25) | (0x1 << 13));
+ }
}
+
/*Maxlinear Tuner */
/*dvbc_write_reg(QAM_BASE+0x094, 0x7f80292d); */
/*dvbc_write_reg(QAM_BASE + 0x098, 0x9fcc8190);*/
return strength;
}
+/*tuner has 3 stage gain control, only last is controlled by demod agc*/
+static int dvbc_R842[20] = {
+ /*-90,-89,-88, -87, -86 , -85 , -84 , -83 , -82 , -81dbm*/
+ 1200, 1180, 1150, 1130, 1100, 1065, 1040, 1030, 1000, 970
+};
+
+int dvbc_get_power_strength(int agc_gain, int tuner_strength)
+{
+ int strength;
+ int i;
+
+ for (i = 0; i < sizeof(dvbc_R842)/sizeof(int); i++)
+ if (agc_gain >= dvbc_R842[i])
+ break;
+
+ if (agc_gain >= 970)
+ strength = -90+i*1;
+ else
+ strength = tuner_strength + 22;
+
+ return strength;
+}
+
+static int j83b_R842[10] = {
+ /*-90,-89,-88, -87, -86 , -85 , -84 , -83 , -82 , -81dbm*/
+ 1140, 1110, 1080, 1060, 1030, 1000, 980, 1000, 970, 1000,
+ /*-80,-79,-78, -77, -76 , -75 , -74 , -73 , -72 , -71dbm*/
+ /*970 , 980, 960, 970, 950, 960, 970, 980, 960, 970*/
+};
+
+int j83b_get_power_strength(int agc_gain, int tuner_strength)
+{
+ int strength;
+ int i;
+
+ for (i = 0; i < sizeof(j83b_R842)/sizeof(int); i++)
+ if (agc_gain >= j83b_R842[i])
+ break;
+
+ if (agc_gain >= 970)
+ strength = -90+i*1;
+ else
+ strength = tuner_strength + 18;
+
+ return strength;
+}
+
+static int atsc_R842[6] = {
+ /*-90,-89,-88, -87, -86 , -85 , -84 , -83 , -82 , -81dbm*/
+ 2160, 2110, 2060, 2010, 1960, 1910/*, 1870, 1910, 1860, 1900*/
+};
+
+int atsc_get_power_strength(int agc_gain, int tuner_strength)
+{
+ int strength;
+ int i;
+
+ for (i = 0; i < sizeof(atsc_R842)/sizeof(int); i++)
+ if (agc_gain >= atsc_R842[i])
+ break;
+
+ if (agc_gain >= 1910)
+ strength = -90+i*1;
+ else
+ strength = tuner_strength;
+
+ return strength;
+}