1 From 4c07e32884ab69574cfd9eb4de3334233c938071 Mon Sep 17 00:00:00 2001
2 From: Mauro Carvalho Chehab <m.chehab@samsung.com>
3 Date: Mon, 21 Jul 2014 13:28:15 -0300
4 Subject: media: xc4000: Fix get_frequency()
6 From: Mauro Carvalho Chehab <m.chehab@samsung.com>
8 commit 4c07e32884ab69574cfd9eb4de3334233c938071 upstream.
10 The programmed frequency on xc4000 is not the middle
11 frequency, but the initial frequency on the bandwidth range.
12 However, the DVB API works with the middle frequency.
14 This works fine on set_frontend, as the device calculates
15 the needed offset. However, at get_frequency(), the returned
16 value is the initial frequency. That's generally not a big
17 problem on most drivers, however, starting with changeset
18 6fe1099c7aec, the frequency drift is taken into account at
21 This broke support for PCTV 340e, with uses dib7000p demod and
24 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28 drivers/media/tuners/xc4000.c | 20 +++++++++++---------
29 1 file changed, 11 insertions(+), 9 deletions(-)
31 --- a/drivers/media/tuners/xc4000.c
32 +++ b/drivers/media/tuners/xc4000.c
33 @@ -93,7 +93,7 @@ struct xc4000_priv {
34 struct firmware_description *firm;
38 + u32 freq_hz, freq_offset;
42 @@ -1157,14 +1157,14 @@ static int xc4000_set_params(struct dvb_
44 dprintk(1, "%s() VSB modulation\n", __func__);
45 priv->rf_mode = XC_RF_MODE_AIR;
46 - priv->freq_hz = c->frequency - 1750000;
47 + priv->freq_offset = 1750000;
48 priv->video_standard = XC4000_DTV6;
51 case SYS_DVBC_ANNEX_B:
52 dprintk(1, "%s() QAM modulation\n", __func__);
53 priv->rf_mode = XC_RF_MODE_CABLE;
54 - priv->freq_hz = c->frequency - 1750000;
55 + priv->freq_offset = 1750000;
56 priv->video_standard = XC4000_DTV6;
59 @@ -1173,23 +1173,23 @@ static int xc4000_set_params(struct dvb_
60 dprintk(1, "%s() OFDM\n", __func__);
62 if (c->frequency < 400000000) {
63 - priv->freq_hz = c->frequency - 2250000;
64 + priv->freq_offset = 2250000;
66 - priv->freq_hz = c->frequency - 2750000;
67 + priv->freq_offset = 2750000;
69 priv->video_standard = XC4000_DTV7_8;
71 } else if (bw <= 6000000) {
72 priv->video_standard = XC4000_DTV6;
73 - priv->freq_hz = c->frequency - 1750000;
74 + priv->freq_offset = 1750000;
76 } else if (bw <= 7000000) {
77 priv->video_standard = XC4000_DTV7;
78 - priv->freq_hz = c->frequency - 2250000;
79 + priv->freq_offset = 2250000;
82 priv->video_standard = XC4000_DTV8;
83 - priv->freq_hz = c->frequency - 2750000;
84 + priv->freq_offset = 2750000;
87 priv->rf_mode = XC_RF_MODE_AIR;
88 @@ -1200,6 +1200,8 @@ static int xc4000_set_params(struct dvb_
92 + priv->freq_hz = c->frequency - priv->freq_offset;
94 dprintk(1, "%s() frequency=%d (compensated)\n",
95 __func__, priv->freq_hz);
97 @@ -1520,7 +1522,7 @@ static int xc4000_get_frequency(struct d
99 struct xc4000_priv *priv = fe->tuner_priv;
101 - *freq = priv->freq_hz;
102 + *freq = priv->freq_hz + priv->freq_offset;
105 mutex_lock(&priv->lock);