diff options
author | Antti Palosaari <crope@iki.fi> | 2012-09-12 19:23:48 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-09-23 19:18:10 -0400 |
commit | 66b3c4deb9735e18d5b71dbcbf9532bdf080d001 (patch) | |
tree | 6e859b836a9e775579e0c7a6d7844dbbe42314b4 /drivers/media/dvb-frontends | |
parent | 86ad0f1dd72b39159065fdf089afe0913b9bef41 (diff) |
[media] rtl2830: use .get_if_frequency()
Use .get_if_frequency() as all used tuner drivers
(mt2060/qt1010/mxl5005s) supports it.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb-frontends')
-rw-r--r-- | drivers/media/dvb-frontends/rtl2830.c | 57 | ||||
-rw-r--r-- | drivers/media/dvb-frontends/rtl2830.h | 7 |
2 files changed, 33 insertions, 31 deletions
diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c index eca1d72f0684..3954760f2bde 100644 --- a/drivers/media/dvb-frontends/rtl2830.c +++ b/drivers/media/dvb-frontends/rtl2830.c | |||
@@ -182,9 +182,6 @@ static int rtl2830_init(struct dvb_frontend *fe) | |||
182 | { | 182 | { |
183 | struct rtl2830_priv *priv = fe->demodulator_priv; | 183 | struct rtl2830_priv *priv = fe->demodulator_priv; |
184 | int ret, i; | 184 | int ret, i; |
185 | u64 num; | ||
186 | u8 buf[3], tmp; | ||
187 | u32 if_ctl; | ||
188 | struct rtl2830_reg_val_mask tab[] = { | 185 | struct rtl2830_reg_val_mask tab[] = { |
189 | { 0x00d, 0x01, 0x03 }, | 186 | { 0x00d, 0x01, 0x03 }, |
190 | { 0x00d, 0x10, 0x10 }, | 187 | { 0x00d, 0x10, 0x10 }, |
@@ -240,26 +237,6 @@ static int rtl2830_init(struct dvb_frontend *fe) | |||
240 | if (ret) | 237 | if (ret) |
241 | goto err; | 238 | goto err; |
242 | 239 | ||
243 | num = priv->cfg.if_dvbt % priv->cfg.xtal; | ||
244 | num *= 0x400000; | ||
245 | num = div_u64(num, priv->cfg.xtal); | ||
246 | num = -num; | ||
247 | if_ctl = num & 0x3fffff; | ||
248 | dev_dbg(&priv->i2c->dev, "%s: if_ctl=%08x\n", __func__, if_ctl); | ||
249 | |||
250 | ret = rtl2830_rd_reg_mask(priv, 0x119, &tmp, 0xc0); /* b[7:6] */ | ||
251 | if (ret) | ||
252 | goto err; | ||
253 | |||
254 | buf[0] = tmp << 6; | ||
255 | buf[0] = (if_ctl >> 16) & 0x3f; | ||
256 | buf[1] = (if_ctl >> 8) & 0xff; | ||
257 | buf[2] = (if_ctl >> 0) & 0xff; | ||
258 | |||
259 | ret = rtl2830_wr_regs(priv, 0x119, buf, 3); | ||
260 | if (ret) | ||
261 | goto err; | ||
262 | |||
263 | /* TODO: spec init */ | 240 | /* TODO: spec init */ |
264 | 241 | ||
265 | /* soft reset */ | 242 | /* soft reset */ |
@@ -301,6 +278,9 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe) | |||
301 | struct rtl2830_priv *priv = fe->demodulator_priv; | 278 | struct rtl2830_priv *priv = fe->demodulator_priv; |
302 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 279 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
303 | int ret, i; | 280 | int ret, i; |
281 | u64 num; | ||
282 | u8 buf[3], tmp; | ||
283 | u32 if_ctl, if_frequency; | ||
304 | static u8 bw_params1[3][34] = { | 284 | static u8 bw_params1[3][34] = { |
305 | { | 285 | { |
306 | 0x1f, 0xf0, 0x1f, 0xf0, 0x1f, 0xfa, 0x00, 0x17, 0x00, 0x41, | 286 | 0x1f, 0xf0, 0x1f, 0xf0, 0x1f, 0xfa, 0x00, 0x17, 0x00, 0x41, |
@@ -325,7 +305,6 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe) | |||
325 | {0xae, 0xba, 0xf3, 0x26, 0x66, 0x64,}, /* 8 MHz */ | 305 | {0xae, 0xba, 0xf3, 0x26, 0x66, 0x64,}, /* 8 MHz */ |
326 | }; | 306 | }; |
327 | 307 | ||
328 | |||
329 | dev_dbg(&priv->i2c->dev, | 308 | dev_dbg(&priv->i2c->dev, |
330 | "%s: frequency=%d bandwidth_hz=%d inversion=%d\n", | 309 | "%s: frequency=%d bandwidth_hz=%d inversion=%d\n", |
331 | __func__, c->frequency, c->bandwidth_hz, c->inversion); | 310 | __func__, c->frequency, c->bandwidth_hz, c->inversion); |
@@ -353,6 +332,36 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe) | |||
353 | if (ret) | 332 | if (ret) |
354 | goto err; | 333 | goto err; |
355 | 334 | ||
335 | /* program if frequency */ | ||
336 | if (fe->ops.tuner_ops.get_if_frequency) | ||
337 | ret = fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency); | ||
338 | else | ||
339 | ret = -EINVAL; | ||
340 | |||
341 | if (ret < 0) | ||
342 | goto err; | ||
343 | |||
344 | num = if_frequency % priv->cfg.xtal; | ||
345 | num *= 0x400000; | ||
346 | num = div_u64(num, priv->cfg.xtal); | ||
347 | num = -num; | ||
348 | if_ctl = num & 0x3fffff; | ||
349 | dev_dbg(&priv->i2c->dev, "%s: if_frequency=%d if_ctl=%08x\n", | ||
350 | __func__, if_frequency, if_ctl); | ||
351 | |||
352 | ret = rtl2830_rd_reg_mask(priv, 0x119, &tmp, 0xc0); /* b[7:6] */ | ||
353 | if (ret) | ||
354 | goto err; | ||
355 | |||
356 | buf[0] = tmp << 6; | ||
357 | buf[0] |= (if_ctl >> 16) & 0x3f; | ||
358 | buf[1] = (if_ctl >> 8) & 0xff; | ||
359 | buf[2] = (if_ctl >> 0) & 0xff; | ||
360 | |||
361 | ret = rtl2830_wr_regs(priv, 0x119, buf, 3); | ||
362 | if (ret) | ||
363 | goto err; | ||
364 | |||
356 | /* 1/2 split I2C write */ | 365 | /* 1/2 split I2C write */ |
357 | ret = rtl2830_wr_regs(priv, 0x11c, &bw_params1[i][0], 17); | 366 | ret = rtl2830_wr_regs(priv, 0x11c, &bw_params1[i][0], 17); |
358 | if (ret) | 367 | if (ret) |
diff --git a/drivers/media/dvb-frontends/rtl2830.h b/drivers/media/dvb-frontends/rtl2830.h index e125166eed95..f4349a1fc03e 100644 --- a/drivers/media/dvb-frontends/rtl2830.h +++ b/drivers/media/dvb-frontends/rtl2830.h | |||
@@ -47,13 +47,6 @@ struct rtl2830_config { | |||
47 | bool spec_inv; | 47 | bool spec_inv; |
48 | 48 | ||
49 | /* | 49 | /* |
50 | * IFs for all used modes. | ||
51 | * Hz | ||
52 | * 4570000, 4571429, 36000000, 36125000, 36166667, 44000000 | ||
53 | */ | ||
54 | u32 if_dvbt; | ||
55 | |||
56 | /* | ||
57 | */ | 50 | */ |
58 | u8 vtop; | 51 | u8 vtop; |
59 | 52 | ||