]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.16.3/media-xc4000-fix-get_frequency.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.16.3 / media-xc4000-fix-get_frequency.patch
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()
5
6 From: Mauro Carvalho Chehab <m.chehab@samsung.com>
7
8 commit 4c07e32884ab69574cfd9eb4de3334233c938071 upstream.
9
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.
13
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
19 dib7000p driver.
20
21 This broke support for PCTV 340e, with uses dib7000p demod and
22 xc4000 tuner.
23
24 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26
27 ---
28 drivers/media/tuners/xc4000.c | 20 +++++++++++---------
29 1 file changed, 11 insertions(+), 9 deletions(-)
30
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;
35 int firm_size;
36 u32 if_khz;
37 - u32 freq_hz;
38 + u32 freq_hz, freq_offset;
39 u32 bandwidth;
40 u8 video_standard;
41 u8 rf_mode;
42 @@ -1157,14 +1157,14 @@ static int xc4000_set_params(struct dvb_
43 case SYS_ATSC:
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;
49 type = DTV6;
50 break;
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;
57 type = DTV6;
58 break;
59 @@ -1173,23 +1173,23 @@ static int xc4000_set_params(struct dvb_
60 dprintk(1, "%s() OFDM\n", __func__);
61 if (bw == 0) {
62 if (c->frequency < 400000000) {
63 - priv->freq_hz = c->frequency - 2250000;
64 + priv->freq_offset = 2250000;
65 } else {
66 - priv->freq_hz = c->frequency - 2750000;
67 + priv->freq_offset = 2750000;
68 }
69 priv->video_standard = XC4000_DTV7_8;
70 type = DTV78;
71 } else if (bw <= 6000000) {
72 priv->video_standard = XC4000_DTV6;
73 - priv->freq_hz = c->frequency - 1750000;
74 + priv->freq_offset = 1750000;
75 type = DTV6;
76 } else if (bw <= 7000000) {
77 priv->video_standard = XC4000_DTV7;
78 - priv->freq_hz = c->frequency - 2250000;
79 + priv->freq_offset = 2250000;
80 type = DTV7;
81 } else {
82 priv->video_standard = XC4000_DTV8;
83 - priv->freq_hz = c->frequency - 2750000;
84 + priv->freq_offset = 2750000;
85 type = DTV8;
86 }
87 priv->rf_mode = XC_RF_MODE_AIR;
88 @@ -1200,6 +1200,8 @@ static int xc4000_set_params(struct dvb_
89 goto fail;
90 }
91
92 + priv->freq_hz = c->frequency - priv->freq_offset;
93 +
94 dprintk(1, "%s() frequency=%d (compensated)\n",
95 __func__, priv->freq_hz);
96
97 @@ -1520,7 +1522,7 @@ static int xc4000_get_frequency(struct d
98 {
99 struct xc4000_priv *priv = fe->tuner_priv;
100
101 - *freq = priv->freq_hz;
102 + *freq = priv->freq_hz + priv->freq_offset;
103
104 if (debug) {
105 mutex_lock(&priv->lock);