Commit a3eec916 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] xc5000: Fix get_frequency()

The programmed frequency on xc5000 is not the middle
frequency, but the initial frequency on the bandwidth range.
However, the DVB API works with the middle frequency.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 612ae142
...@@ -56,7 +56,7 @@ struct xc5000_priv { ...@@ -56,7 +56,7 @@ struct xc5000_priv {
u32 if_khz; u32 if_khz;
u16 xtal_khz; u16 xtal_khz;
u32 freq_hz; u32 freq_hz, freq_offset;
u32 bandwidth; u32 bandwidth;
u8 video_standard; u8 video_standard;
u8 rf_mode; u8 rf_mode;
...@@ -749,13 +749,13 @@ static int xc5000_set_params(struct dvb_frontend *fe) ...@@ -749,13 +749,13 @@ static int xc5000_set_params(struct dvb_frontend *fe)
case SYS_ATSC: case SYS_ATSC:
dprintk(1, "%s() VSB modulation\n", __func__); dprintk(1, "%s() VSB modulation\n", __func__);
priv->rf_mode = XC_RF_MODE_AIR; priv->rf_mode = XC_RF_MODE_AIR;
priv->freq_hz = freq - 1750000; priv->freq_offset = 1750000;
priv->video_standard = DTV6; priv->video_standard = DTV6;
break; break;
case SYS_DVBC_ANNEX_B: case SYS_DVBC_ANNEX_B:
dprintk(1, "%s() QAM modulation\n", __func__); dprintk(1, "%s() QAM modulation\n", __func__);
priv->rf_mode = XC_RF_MODE_CABLE; priv->rf_mode = XC_RF_MODE_CABLE;
priv->freq_hz = freq - 1750000; priv->freq_offset = 1750000;
priv->video_standard = DTV6; priv->video_standard = DTV6;
break; break;
case SYS_ISDBT: case SYS_ISDBT:
...@@ -770,15 +770,15 @@ static int xc5000_set_params(struct dvb_frontend *fe) ...@@ -770,15 +770,15 @@ static int xc5000_set_params(struct dvb_frontend *fe)
switch (bw) { switch (bw) {
case 6000000: case 6000000:
priv->video_standard = DTV6; priv->video_standard = DTV6;
priv->freq_hz = freq - 1750000; priv->freq_offset = 1750000;
break; break;
case 7000000: case 7000000:
priv->video_standard = DTV7; priv->video_standard = DTV7;
priv->freq_hz = freq - 2250000; priv->freq_offset = 2250000;
break; break;
case 8000000: case 8000000:
priv->video_standard = DTV8; priv->video_standard = DTV8;
priv->freq_hz = freq - 2750000; priv->freq_offset = 2750000;
break; break;
default: default:
printk(KERN_ERR "xc5000 bandwidth not set!\n"); printk(KERN_ERR "xc5000 bandwidth not set!\n");
...@@ -792,15 +792,15 @@ static int xc5000_set_params(struct dvb_frontend *fe) ...@@ -792,15 +792,15 @@ static int xc5000_set_params(struct dvb_frontend *fe)
priv->rf_mode = XC_RF_MODE_CABLE; priv->rf_mode = XC_RF_MODE_CABLE;
if (bw <= 6000000) { if (bw <= 6000000) {
priv->video_standard = DTV6; priv->video_standard = DTV6;
priv->freq_hz = freq - 1750000; priv->freq_offset = 1750000;
b = 6; b = 6;
} else if (bw <= 7000000) { } else if (bw <= 7000000) {
priv->video_standard = DTV7; priv->video_standard = DTV7;
priv->freq_hz = freq - 2250000; priv->freq_offset = 2250000;
b = 7; b = 7;
} else { } else {
priv->video_standard = DTV7_8; priv->video_standard = DTV7_8;
priv->freq_hz = freq - 2750000; priv->freq_offset = 2750000;
b = 8; b = 8;
} }
dprintk(1, "%s() Bandwidth %dMHz (%d)\n", __func__, dprintk(1, "%s() Bandwidth %dMHz (%d)\n", __func__,
...@@ -811,6 +811,8 @@ static int xc5000_set_params(struct dvb_frontend *fe) ...@@ -811,6 +811,8 @@ static int xc5000_set_params(struct dvb_frontend *fe)
return -EINVAL; return -EINVAL;
} }
priv->freq_hz = freq - priv->freq_offset;
dprintk(1, "%s() frequency=%d (compensated to %d)\n", dprintk(1, "%s() frequency=%d (compensated to %d)\n",
__func__, freq, priv->freq_hz); __func__, freq, priv->freq_hz);
...@@ -1061,7 +1063,7 @@ static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq) ...@@ -1061,7 +1063,7 @@ static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq)
{ {
struct xc5000_priv *priv = fe->tuner_priv; struct xc5000_priv *priv = fe->tuner_priv;
dprintk(1, "%s()\n", __func__); dprintk(1, "%s()\n", __func__);
*freq = priv->freq_hz; *freq = priv->freq_hz + priv->freq_offset;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment