diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-10-21 18:39:50 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:01:09 -0500 |
commit | 4e9154b8a77d0f0f8f06857162823905612a50d7 (patch) | |
tree | b4aaf7945fe52833168eabc8b581bedc2a774035 /drivers/media/video | |
parent | 482b498d7a1eb0e445657fb55d2bc6d4871c0ef5 (diff) |
V4L/DVB (6440): tuner: convert analog tuner demod sub-modules to dvb_frontend interface
Convert tda9887 and tda8290/5 to dvb_frontend interface
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/tda8290.c | 164 | ||||
-rw-r--r-- | drivers/media/video/tda9887.c | 78 | ||||
-rw-r--r-- | drivers/media/video/tuner-core.c | 79 | ||||
-rw-r--r-- | drivers/media/video/tuner-driver.h | 16 |
4 files changed, 186 insertions, 151 deletions
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c index e001c397ccfc..288865c3c714 100644 --- a/drivers/media/video/tda8290.c +++ b/drivers/media/video/tda8290.c | |||
@@ -44,13 +44,15 @@ struct tda8290_priv { | |||
44 | unsigned char tda827x_ver; | 44 | unsigned char tda827x_ver; |
45 | 45 | ||
46 | struct tda827x_config cfg; | 46 | struct tda827x_config cfg; |
47 | |||
48 | struct tuner *t; | ||
47 | }; | 49 | }; |
48 | 50 | ||
49 | /*---------------------------------------------------------------------*/ | 51 | /*---------------------------------------------------------------------*/ |
50 | 52 | ||
51 | static void tda8290_i2c_bridge(struct tuner *t, int close) | 53 | static void tda8290_i2c_bridge(struct dvb_frontend *fe, int close) |
52 | { | 54 | { |
53 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 55 | struct tda8290_priv *priv = fe->analog_demod_priv; |
54 | 56 | ||
55 | unsigned char enable[2] = { 0x21, 0xC0 }; | 57 | unsigned char enable[2] = { 0x21, 0xC0 }; |
56 | unsigned char disable[2] = { 0x21, 0x00 }; | 58 | unsigned char disable[2] = { 0x21, 0x00 }; |
@@ -66,9 +68,9 @@ static void tda8290_i2c_bridge(struct tuner *t, int close) | |||
66 | } | 68 | } |
67 | } | 69 | } |
68 | 70 | ||
69 | static void tda8295_i2c_bridge(struct tuner *t, int close) | 71 | static void tda8295_i2c_bridge(struct dvb_frontend *fe, int close) |
70 | { | 72 | { |
71 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 73 | struct tda8290_priv *priv = fe->analog_demod_priv; |
72 | 74 | ||
73 | unsigned char enable[2] = { 0x45, 0xc1 }; | 75 | unsigned char enable[2] = { 0x45, 0xc1 }; |
74 | unsigned char disable[2] = { 0x46, 0x00 }; | 76 | unsigned char disable[2] = { 0x46, 0x00 }; |
@@ -96,9 +98,10 @@ static void tda8295_i2c_bridge(struct tuner *t, int close) | |||
96 | 98 | ||
97 | /*---------------------------------------------------------------------*/ | 99 | /*---------------------------------------------------------------------*/ |
98 | 100 | ||
99 | static void set_audio(struct tuner *t) | 101 | static void set_audio(struct dvb_frontend *fe) |
100 | { | 102 | { |
101 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 103 | struct tda8290_priv *priv = fe->analog_demod_priv; |
104 | struct tuner *t = priv->t; | ||
102 | char* mode; | 105 | char* mode; |
103 | 106 | ||
104 | priv->cfg.tda827x_lpsel = 0; | 107 | priv->cfg.tda827x_lpsel = 0; |
@@ -143,9 +146,11 @@ static void set_audio(struct tuner *t) | |||
143 | tuner_dbg("setting tda8290 to system %s\n", mode); | 146 | tuner_dbg("setting tda8290 to system %s\n", mode); |
144 | } | 147 | } |
145 | 148 | ||
146 | static void tda8290_set_freq(struct tuner *t, unsigned int freq) | 149 | static void tda8290_set_freq(struct dvb_frontend *fe, unsigned int freq) |
147 | { | 150 | { |
148 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 151 | struct tda8290_priv *priv = fe->analog_demod_priv; |
152 | struct tuner *t = priv->t; | ||
153 | |||
149 | unsigned char soft_reset[] = { 0x00, 0x00 }; | 154 | unsigned char soft_reset[] = { 0x00, 0x00 }; |
150 | unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode }; | 155 | unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode }; |
151 | unsigned char expert_mode[] = { 0x01, 0x80 }; | 156 | unsigned char expert_mode[] = { 0x01, 0x80 }; |
@@ -175,7 +180,7 @@ static void tda8290_set_freq(struct tuner *t, unsigned int freq) | |||
175 | .std = t->std | 180 | .std = t->std |
176 | }; | 181 | }; |
177 | 182 | ||
178 | set_audio(t); | 183 | set_audio(fe); |
179 | 184 | ||
180 | tuner_dbg("tda827xa config is 0x%02x\n", t->config); | 185 | tuner_dbg("tda827xa config is 0x%02x\n", t->config); |
181 | tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); | 186 | tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); |
@@ -193,10 +198,10 @@ static void tda8290_set_freq(struct tuner *t, unsigned int freq) | |||
193 | tuner_i2c_xfer_send(&priv->i2c_props, adc_head_6, 2); | 198 | tuner_i2c_xfer_send(&priv->i2c_props, adc_head_6, 2); |
194 | tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2); | 199 | tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2); |
195 | 200 | ||
196 | tda8290_i2c_bridge(t, 1); | 201 | tda8290_i2c_bridge(fe, 1); |
197 | 202 | ||
198 | if (t->fe.ops.tuner_ops.set_analog_params) | 203 | if (fe->ops.tuner_ops.set_analog_params) |
199 | t->fe.ops.tuner_ops.set_analog_params(&t->fe, ¶ms); | 204 | fe->ops.tuner_ops.set_analog_params(fe, ¶ms); |
200 | 205 | ||
201 | for (i = 0; i < 3; i++) { | 206 | for (i = 0; i < 3; i++) { |
202 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); | 207 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); |
@@ -227,7 +232,7 @@ static void tda8290_set_freq(struct tuner *t, unsigned int freq) | |||
227 | tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n", | 232 | tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n", |
228 | agc_stat, pll_stat & 0x80); | 233 | agc_stat, pll_stat & 0x80); |
229 | if (priv->cfg.agcf) | 234 | if (priv->cfg.agcf) |
230 | priv->cfg.agcf(&t->fe); | 235 | priv->cfg.agcf(fe); |
231 | msleep(100); | 236 | msleep(100); |
232 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); | 237 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); |
233 | tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); | 238 | tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); |
@@ -256,15 +261,15 @@ static void tda8290_set_freq(struct tuner *t, unsigned int freq) | |||
256 | } | 261 | } |
257 | } | 262 | } |
258 | 263 | ||
259 | tda8290_i2c_bridge(t, 0); | 264 | tda8290_i2c_bridge(fe, 0); |
260 | tuner_i2c_xfer_send(&priv->i2c_props, if_agc_set, 2); | 265 | tuner_i2c_xfer_send(&priv->i2c_props, if_agc_set, 2); |
261 | } | 266 | } |
262 | 267 | ||
263 | /*---------------------------------------------------------------------*/ | 268 | /*---------------------------------------------------------------------*/ |
264 | 269 | ||
265 | static void tda8295_power(struct tuner *t, int enable) | 270 | static void tda8295_power(struct dvb_frontend *fe, int enable) |
266 | { | 271 | { |
267 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 272 | struct tda8290_priv *priv = fe->analog_demod_priv; |
268 | unsigned char buf[] = { 0x30, 0x00 }; /* clb_stdbt */ | 273 | unsigned char buf[] = { 0x30, 0x00 }; /* clb_stdbt */ |
269 | 274 | ||
270 | tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); | 275 | tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); |
@@ -278,9 +283,9 @@ static void tda8295_power(struct tuner *t, int enable) | |||
278 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); | 283 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); |
279 | } | 284 | } |
280 | 285 | ||
281 | static void tda8295_set_easy_mode(struct tuner *t, int enable) | 286 | static void tda8295_set_easy_mode(struct dvb_frontend *fe, int enable) |
282 | { | 287 | { |
283 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 288 | struct tda8290_priv *priv = fe->analog_demod_priv; |
284 | unsigned char buf[] = { 0x01, 0x00 }; | 289 | unsigned char buf[] = { 0x01, 0x00 }; |
285 | 290 | ||
286 | tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); | 291 | tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); |
@@ -294,23 +299,23 @@ static void tda8295_set_easy_mode(struct tuner *t, int enable) | |||
294 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); | 299 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); |
295 | } | 300 | } |
296 | 301 | ||
297 | static void tda8295_set_video_std(struct tuner *t) | 302 | static void tda8295_set_video_std(struct dvb_frontend *fe) |
298 | { | 303 | { |
299 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 304 | struct tda8290_priv *priv = fe->analog_demod_priv; |
300 | unsigned char buf[] = { 0x00, priv->tda8290_easy_mode }; | 305 | unsigned char buf[] = { 0x00, priv->tda8290_easy_mode }; |
301 | 306 | ||
302 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); | 307 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); |
303 | 308 | ||
304 | tda8295_set_easy_mode(t, 1); | 309 | tda8295_set_easy_mode(fe, 1); |
305 | msleep(20); | 310 | msleep(20); |
306 | tda8295_set_easy_mode(t, 0); | 311 | tda8295_set_easy_mode(fe, 0); |
307 | } | 312 | } |
308 | 313 | ||
309 | /*---------------------------------------------------------------------*/ | 314 | /*---------------------------------------------------------------------*/ |
310 | 315 | ||
311 | static void tda8295_agc1_out(struct tuner *t, int enable) | 316 | static void tda8295_agc1_out(struct dvb_frontend *fe, int enable) |
312 | { | 317 | { |
313 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 318 | struct tda8290_priv *priv = fe->analog_demod_priv; |
314 | unsigned char buf[] = { 0x02, 0x00 }; /* DIV_FUNC */ | 319 | unsigned char buf[] = { 0x02, 0x00 }; /* DIV_FUNC */ |
315 | 320 | ||
316 | tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); | 321 | tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); |
@@ -324,9 +329,9 @@ static void tda8295_agc1_out(struct tuner *t, int enable) | |||
324 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); | 329 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); |
325 | } | 330 | } |
326 | 331 | ||
327 | static void tda8295_agc2_out(struct tuner *t, int enable) | 332 | static void tda8295_agc2_out(struct dvb_frontend *fe, int enable) |
328 | { | 333 | { |
329 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 334 | struct tda8290_priv *priv = fe->analog_demod_priv; |
330 | unsigned char set_gpio_cf[] = { 0x44, 0x00 }; | 335 | unsigned char set_gpio_cf[] = { 0x44, 0x00 }; |
331 | unsigned char set_gpio_val[] = { 0x46, 0x00 }; | 336 | unsigned char set_gpio_val[] = { 0x46, 0x00 }; |
332 | 337 | ||
@@ -345,9 +350,9 @@ static void tda8295_agc2_out(struct tuner *t, int enable) | |||
345 | tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_val, 2); | 350 | tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_val, 2); |
346 | } | 351 | } |
347 | 352 | ||
348 | static int tda8295_has_signal(struct tuner *t) | 353 | static int tda8295_has_signal(struct dvb_frontend *fe) |
349 | { | 354 | { |
350 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 355 | struct tda8290_priv *priv = fe->analog_demod_priv; |
351 | 356 | ||
352 | unsigned char hvpll_stat = 0x26; | 357 | unsigned char hvpll_stat = 0x26; |
353 | unsigned char ret; | 358 | unsigned char ret; |
@@ -359,9 +364,10 @@ static int tda8295_has_signal(struct tuner *t) | |||
359 | 364 | ||
360 | /*---------------------------------------------------------------------*/ | 365 | /*---------------------------------------------------------------------*/ |
361 | 366 | ||
362 | static void tda8295_set_freq(struct tuner *t, unsigned int freq) | 367 | static void tda8295_set_freq(struct dvb_frontend *fe, unsigned int freq) |
363 | { | 368 | { |
364 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 369 | struct tda8290_priv *priv = fe->analog_demod_priv; |
370 | struct tuner *t = priv->t; | ||
365 | u16 ifc; | 371 | u16 ifc; |
366 | 372 | ||
367 | unsigned char blanking_mode[] = { 0x1d, 0x00 }; | 373 | unsigned char blanking_mode[] = { 0x1d, 0x00 }; |
@@ -373,45 +379,45 @@ static void tda8295_set_freq(struct tuner *t, unsigned int freq) | |||
373 | .std = t->std | 379 | .std = t->std |
374 | }; | 380 | }; |
375 | 381 | ||
376 | set_audio(t); | 382 | set_audio(fe); |
377 | 383 | ||
378 | ifc = priv->cfg.sgIF; /* FIXME */ | 384 | ifc = priv->cfg.sgIF; /* FIXME */ |
379 | 385 | ||
380 | tuner_dbg("%s: ifc = %u, freq = %d\n", __FUNCTION__, ifc, freq); | 386 | tuner_dbg("%s: ifc = %u, freq = %d\n", __FUNCTION__, ifc, freq); |
381 | 387 | ||
382 | tda8295_power(t, 1); | 388 | tda8295_power(fe, 1); |
383 | tda8295_agc1_out(t, 1); | 389 | tda8295_agc1_out(fe, 1); |
384 | 390 | ||
385 | tuner_i2c_xfer_send(&priv->i2c_props, &blanking_mode[0], 1); | 391 | tuner_i2c_xfer_send(&priv->i2c_props, &blanking_mode[0], 1); |
386 | tuner_i2c_xfer_recv(&priv->i2c_props, &blanking_mode[1], 1); | 392 | tuner_i2c_xfer_recv(&priv->i2c_props, &blanking_mode[1], 1); |
387 | 393 | ||
388 | tda8295_set_video_std(t); | 394 | tda8295_set_video_std(fe); |
389 | 395 | ||
390 | blanking_mode[1] = 0x03; | 396 | blanking_mode[1] = 0x03; |
391 | tuner_i2c_xfer_send(&priv->i2c_props, blanking_mode, 2); | 397 | tuner_i2c_xfer_send(&priv->i2c_props, blanking_mode, 2); |
392 | msleep(20); | 398 | msleep(20); |
393 | 399 | ||
394 | tda8295_i2c_bridge(t, 1); | 400 | tda8295_i2c_bridge(fe, 1); |
395 | 401 | ||
396 | if (t->fe.ops.tuner_ops.set_analog_params) | 402 | if (fe->ops.tuner_ops.set_analog_params) |
397 | t->fe.ops.tuner_ops.set_analog_params(&t->fe, ¶ms); | 403 | fe->ops.tuner_ops.set_analog_params(fe, ¶ms); |
398 | 404 | ||
399 | if (priv->cfg.agcf) | 405 | if (priv->cfg.agcf) |
400 | priv->cfg.agcf(&t->fe); | 406 | priv->cfg.agcf(fe); |
401 | 407 | ||
402 | if (tda8295_has_signal(t)) | 408 | if (tda8295_has_signal(fe)) |
403 | tuner_dbg("tda8295 is locked\n"); | 409 | tuner_dbg("tda8295 is locked\n"); |
404 | else | 410 | else |
405 | tuner_dbg("tda8295 not locked, no signal?\n"); | 411 | tuner_dbg("tda8295 not locked, no signal?\n"); |
406 | 412 | ||
407 | tda8295_i2c_bridge(t, 0); | 413 | tda8295_i2c_bridge(fe, 0); |
408 | } | 414 | } |
409 | 415 | ||
410 | /*---------------------------------------------------------------------*/ | 416 | /*---------------------------------------------------------------------*/ |
411 | 417 | ||
412 | static int tda8290_has_signal(struct tuner *t) | 418 | static int tda8290_has_signal(struct dvb_frontend *fe) |
413 | { | 419 | { |
414 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 420 | struct tda8290_priv *priv = fe->analog_demod_priv; |
415 | 421 | ||
416 | unsigned char i2c_get_afc[1] = { 0x1B }; | 422 | unsigned char i2c_get_afc[1] = { 0x1B }; |
417 | unsigned char afc = 0; | 423 | unsigned char afc = 0; |
@@ -423,33 +429,35 @@ static int tda8290_has_signal(struct tuner *t) | |||
423 | 429 | ||
424 | /*---------------------------------------------------------------------*/ | 430 | /*---------------------------------------------------------------------*/ |
425 | 431 | ||
426 | static void tda8290_standby(struct tuner *t) | 432 | static void tda8290_standby(struct dvb_frontend *fe) |
427 | { | 433 | { |
428 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 434 | struct tda8290_priv *priv = fe->analog_demod_priv; |
435 | |||
429 | unsigned char cb1[] = { 0x30, 0xD0 }; | 436 | unsigned char cb1[] = { 0x30, 0xD0 }; |
430 | unsigned char tda8290_standby[] = { 0x00, 0x02 }; | 437 | unsigned char tda8290_standby[] = { 0x00, 0x02 }; |
431 | unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; | 438 | unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; |
432 | struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2}; | 439 | struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2}; |
433 | 440 | ||
434 | tda8290_i2c_bridge(t, 1); | 441 | tda8290_i2c_bridge(fe, 1); |
435 | if (priv->tda827x_ver != 0) | 442 | if (priv->tda827x_ver != 0) |
436 | cb1[1] = 0x90; | 443 | cb1[1] = 0x90; |
437 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | 444 | i2c_transfer(priv->i2c_props.adap, &msg, 1); |
438 | tda8290_i2c_bridge(t, 0); | 445 | tda8290_i2c_bridge(fe, 0); |
439 | tuner_i2c_xfer_send(&priv->i2c_props, tda8290_agc_tri, 2); | 446 | tuner_i2c_xfer_send(&priv->i2c_props, tda8290_agc_tri, 2); |
440 | tuner_i2c_xfer_send(&priv->i2c_props, tda8290_standby, 2); | 447 | tuner_i2c_xfer_send(&priv->i2c_props, tda8290_standby, 2); |
441 | } | 448 | } |
442 | 449 | ||
443 | static void tda8295_standby(struct tuner *t) | 450 | static void tda8295_standby(struct dvb_frontend *fe) |
444 | { | 451 | { |
445 | tda8295_agc1_out(t, 0); /* Put AGC in tri-state */ | 452 | tda8295_agc1_out(fe, 0); /* Put AGC in tri-state */ |
446 | 453 | ||
447 | tda8295_power(t, 0); | 454 | tda8295_power(fe, 0); |
448 | } | 455 | } |
449 | 456 | ||
450 | static void tda8290_init_if(struct tuner *t) | 457 | static void tda8290_init_if(struct dvb_frontend *fe) |
451 | { | 458 | { |
452 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 459 | struct tda8290_priv *priv = fe->analog_demod_priv; |
460 | struct tuner *t = priv->t; | ||
453 | 461 | ||
454 | unsigned char set_VS[] = { 0x30, 0x6F }; | 462 | unsigned char set_VS[] = { 0x30, 0x6F }; |
455 | unsigned char set_GP00_CF[] = { 0x20, 0x01 }; | 463 | unsigned char set_GP00_CF[] = { 0x20, 0x01 }; |
@@ -462,9 +470,9 @@ static void tda8290_init_if(struct tuner *t) | |||
462 | tuner_i2c_xfer_send(&priv->i2c_props, set_VS, 2); | 470 | tuner_i2c_xfer_send(&priv->i2c_props, set_VS, 2); |
463 | } | 471 | } |
464 | 472 | ||
465 | static void tda8295_init_if(struct tuner *t) | 473 | static void tda8295_init_if(struct dvb_frontend *fe) |
466 | { | 474 | { |
467 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 475 | struct tda8290_priv *priv = fe->analog_demod_priv; |
468 | 476 | ||
469 | static unsigned char set_adc_ctl[] = { 0x33, 0x14 }; | 477 | static unsigned char set_adc_ctl[] = { 0x33, 0x14 }; |
470 | static unsigned char set_adc_ctl2[] = { 0x34, 0x00 }; | 478 | static unsigned char set_adc_ctl2[] = { 0x34, 0x00 }; |
@@ -474,10 +482,10 @@ static void tda8295_init_if(struct tuner *t) | |||
474 | static unsigned char set_pll_reg10[] = { 0x42, 0x61 }; | 482 | static unsigned char set_pll_reg10[] = { 0x42, 0x61 }; |
475 | static unsigned char set_gpio_reg0[] = { 0x44, 0x0b }; | 483 | static unsigned char set_gpio_reg0[] = { 0x44, 0x0b }; |
476 | 484 | ||
477 | tda8295_power(t, 1); | 485 | tda8295_power(fe, 1); |
478 | 486 | ||
479 | tda8295_set_easy_mode(t, 0); | 487 | tda8295_set_easy_mode(fe, 0); |
480 | tda8295_set_video_std(t); | 488 | tda8295_set_video_std(fe); |
481 | 489 | ||
482 | tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl, 2); | 490 | tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl, 2); |
483 | tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl2, 2); | 491 | tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl2, 2); |
@@ -487,13 +495,13 @@ static void tda8295_init_if(struct tuner *t) | |||
487 | tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg10, 2); | 495 | tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg10, 2); |
488 | tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_reg0, 2); | 496 | tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_reg0, 2); |
489 | 497 | ||
490 | tda8295_agc1_out(t, 0); | 498 | tda8295_agc1_out(fe, 0); |
491 | tda8295_agc2_out(t, 0); | 499 | tda8295_agc2_out(fe, 0); |
492 | } | 500 | } |
493 | 501 | ||
494 | static void tda8290_init_tuner(struct tuner *t) | 502 | static void tda8290_init_tuner(struct dvb_frontend *fe) |
495 | { | 503 | { |
496 | struct tda8290_priv *priv = t->fe.analog_demod_priv; | 504 | struct tda8290_priv *priv = fe->analog_demod_priv; |
497 | unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, | 505 | unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, |
498 | 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; | 506 | 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; |
499 | unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, | 507 | unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, |
@@ -503,20 +511,20 @@ static void tda8290_init_tuner(struct tuner *t) | |||
503 | if (priv->tda827x_ver != 0) | 511 | if (priv->tda827x_ver != 0) |
504 | msg.buf = tda8275a_init; | 512 | msg.buf = tda8275a_init; |
505 | 513 | ||
506 | tda8290_i2c_bridge(t, 1); | 514 | tda8290_i2c_bridge(fe, 1); |
507 | i2c_transfer(priv->i2c_props.adap, &msg, 1); | 515 | i2c_transfer(priv->i2c_props.adap, &msg, 1); |
508 | tda8290_i2c_bridge(t, 0); | 516 | tda8290_i2c_bridge(fe, 0); |
509 | } | 517 | } |
510 | 518 | ||
511 | /*---------------------------------------------------------------------*/ | 519 | /*---------------------------------------------------------------------*/ |
512 | 520 | ||
513 | static void tda829x_release(struct tuner *t) | 521 | static void tda829x_release(struct dvb_frontend *fe) |
514 | { | 522 | { |
515 | if (t->fe.ops.tuner_ops.release) | 523 | if (fe->ops.tuner_ops.release) |
516 | t->fe.ops.tuner_ops.release(&t->fe); | 524 | fe->ops.tuner_ops.release(fe); |
517 | 525 | ||
518 | kfree(t->fe.analog_demod_priv); | 526 | kfree(fe->analog_demod_priv); |
519 | t->fe.analog_demod_priv = NULL; | 527 | fe->analog_demod_priv = NULL; |
520 | } | 528 | } |
521 | 529 | ||
522 | static struct analog_tuner_ops tda8290_tuner_ops = { | 530 | static struct analog_tuner_ops tda8290_tuner_ops = { |
@@ -552,8 +560,9 @@ int tda8290_attach(struct tuner *t) | |||
552 | priv->i2c_props.adap = t->i2c.adapter; | 560 | priv->i2c_props.adap = t->i2c.adapter; |
553 | priv->cfg.config = &t->config; | 561 | priv->cfg.config = &t->config; |
554 | priv->cfg.tuner_callback = t->tuner_callback; | 562 | priv->cfg.tuner_callback = t->tuner_callback; |
563 | priv->t = t; | ||
555 | 564 | ||
556 | tda8290_i2c_bridge(t, 1); | 565 | tda8290_i2c_bridge(&t->fe, 1); |
557 | /* probe for tuner chip */ | 566 | /* probe for tuner chip */ |
558 | tuners_found = 0; | 567 | tuners_found = 0; |
559 | tuner_addrs = 0; | 568 | tuner_addrs = 0; |
@@ -569,7 +578,7 @@ int tda8290_attach(struct tuner *t) | |||
569 | behind the bridge and we choose the highest address that doesn't | 578 | behind the bridge and we choose the highest address that doesn't |
570 | give a response now | 579 | give a response now |
571 | */ | 580 | */ |
572 | tda8290_i2c_bridge(t, 0); | 581 | tda8290_i2c_bridge(&t->fe, 0); |
573 | if(tuners_found > 1) | 582 | if(tuners_found > 1) |
574 | for (i = 0; i < tuners_found; i++) { | 583 | for (i = 0; i < tuners_found; i++) { |
575 | msg.addr = tuner_addrs & 0xff; | 584 | msg.addr = tuner_addrs & 0xff; |
@@ -590,7 +599,7 @@ int tda8290_attach(struct tuner *t) | |||
590 | priv->tda827x_addr = tuner_addrs; | 599 | priv->tda827x_addr = tuner_addrs; |
591 | msg.addr = tuner_addrs; | 600 | msg.addr = tuner_addrs; |
592 | 601 | ||
593 | tda8290_i2c_bridge(t, 1); | 602 | tda8290_i2c_bridge(&t->fe, 1); |
594 | 603 | ||
595 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); | 604 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); |
596 | if( ret != 1) | 605 | if( ret != 1) |
@@ -619,8 +628,8 @@ int tda8290_attach(struct tuner *t) | |||
619 | priv->cfg.tda827x_lpsel = 0; | 628 | priv->cfg.tda827x_lpsel = 0; |
620 | t->mode = V4L2_TUNER_ANALOG_TV; | 629 | t->mode = V4L2_TUNER_ANALOG_TV; |
621 | 630 | ||
622 | tda8290_init_tuner(t); | 631 | tda8290_init_tuner(&t->fe); |
623 | tda8290_init_if(t); | 632 | tda8290_init_if(&t->fe); |
624 | return 0; | 633 | return 0; |
625 | } | 634 | } |
626 | EXPORT_SYMBOL_GPL(tda8290_attach); | 635 | EXPORT_SYMBOL_GPL(tda8290_attach); |
@@ -640,8 +649,9 @@ int tda8295_attach(struct tuner *t) | |||
640 | 649 | ||
641 | priv->i2c_props.addr = t->i2c.addr; | 650 | priv->i2c_props.addr = t->i2c.addr; |
642 | priv->i2c_props.adap = t->i2c.adapter; | 651 | priv->i2c_props.adap = t->i2c.adapter; |
652 | priv->t = t; | ||
643 | 653 | ||
644 | tda8295_i2c_bridge(t, 1); | 654 | tda8295_i2c_bridge(&t->fe, 1); |
645 | /* probe for tuner chip */ | 655 | /* probe for tuner chip */ |
646 | tuners_found = 0; | 656 | tuners_found = 0; |
647 | tuner_addrs = 0; | 657 | tuner_addrs = 0; |
@@ -657,7 +667,7 @@ int tda8295_attach(struct tuner *t) | |||
657 | behind the bridge and we choose the highest address that doesn't | 667 | behind the bridge and we choose the highest address that doesn't |
658 | give a response now | 668 | give a response now |
659 | */ | 669 | */ |
660 | tda8295_i2c_bridge(t, 0); | 670 | tda8295_i2c_bridge(&t->fe, 0); |
661 | if (tuners_found > 1) | 671 | if (tuners_found > 1) |
662 | for (i = 0; i < tuners_found; i++) { | 672 | for (i = 0; i < tuners_found; i++) { |
663 | msg.addr = tuner_addrs & 0xff; | 673 | msg.addr = tuner_addrs & 0xff; |
@@ -678,9 +688,9 @@ int tda8295_attach(struct tuner *t) | |||
678 | priv->tda827x_addr = tuner_addrs; | 688 | priv->tda827x_addr = tuner_addrs; |
679 | msg.addr = tuner_addrs; | 689 | msg.addr = tuner_addrs; |
680 | 690 | ||
681 | tda8295_i2c_bridge(t, 1); | 691 | tda8295_i2c_bridge(&t->fe, 1); |
682 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); | 692 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); |
683 | tda8295_i2c_bridge(t, 0); | 693 | tda8295_i2c_bridge(&t->fe, 0); |
684 | if (ret != 1) | 694 | if (ret != 1) |
685 | tuner_warn("TDA827x access failed!\n"); | 695 | tuner_warn("TDA827x access failed!\n"); |
686 | if ((data & 0x3c) == 0) { | 696 | if ((data & 0x3c) == 0) { |
@@ -708,7 +718,7 @@ int tda8295_attach(struct tuner *t) | |||
708 | priv->cfg.tda827x_lpsel = 0; | 718 | priv->cfg.tda827x_lpsel = 0; |
709 | t->mode = V4L2_TUNER_ANALOG_TV; | 719 | t->mode = V4L2_TUNER_ANALOG_TV; |
710 | 720 | ||
711 | tda8295_init_if(t); | 721 | tda8295_init_if(&t->fe); |
712 | return 0; | 722 | return 0; |
713 | } | 723 | } |
714 | EXPORT_SYMBOL_GPL(tda8295_attach); | 724 | EXPORT_SYMBOL_GPL(tda8295_attach); |
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index 68b22da7e25b..7663a5579757 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c | |||
@@ -21,17 +21,19 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #define tda9887_info(fmt, arg...) do {\ | 23 | #define tda9887_info(fmt, arg...) do {\ |
24 | printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \ | 24 | printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ |
25 | i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) | 25 | i2c_adapter_id(priv->t->i2c.adapter), priv->t->i2c.addr , ##arg); } while (0) |
26 | #define tda9887_dbg(fmt, arg...) do {\ | 26 | #define tda9887_dbg(fmt, arg...) do {\ |
27 | if (tuner_debug) \ | 27 | if (tuner_debug) \ |
28 | printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \ | 28 | printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ |
29 | i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) | 29 | i2c_adapter_id(priv->t->i2c.adapter), priv->t->i2c.addr , ##arg); } while (0) |
30 | 30 | ||
31 | struct tda9887_priv { | 31 | struct tda9887_priv { |
32 | struct tuner_i2c_props i2c_props; | 32 | struct tuner_i2c_props i2c_props; |
33 | 33 | ||
34 | unsigned char data[4]; | 34 | unsigned char data[4]; |
35 | |||
36 | struct tuner *t; | ||
35 | }; | 37 | }; |
36 | 38 | ||
37 | /* ---------------------------------------------------------------------- */ | 39 | /* ---------------------------------------------------------------------- */ |
@@ -262,8 +264,10 @@ static struct tvnorm radio_mono = { | |||
262 | 264 | ||
263 | /* ---------------------------------------------------------------------- */ | 265 | /* ---------------------------------------------------------------------- */ |
264 | 266 | ||
265 | static void dump_read_message(struct tuner *t, unsigned char *buf) | 267 | static void dump_read_message(struct dvb_frontend *fe, unsigned char *buf) |
266 | { | 268 | { |
269 | struct tda9887_priv *priv = fe->analog_demod_priv; | ||
270 | |||
267 | static char *afc[16] = { | 271 | static char *afc[16] = { |
268 | "- 12.5 kHz", | 272 | "- 12.5 kHz", |
269 | "- 37.5 kHz", | 273 | "- 37.5 kHz", |
@@ -290,8 +294,10 @@ static void dump_read_message(struct tuner *t, unsigned char *buf) | |||
290 | tda9887_info(" vfi level : %s\n", (buf[0] & 0x80) ? "high" : "low"); | 294 | tda9887_info(" vfi level : %s\n", (buf[0] & 0x80) ? "high" : "low"); |
291 | } | 295 | } |
292 | 296 | ||
293 | static void dump_write_message(struct tuner *t, unsigned char *buf) | 297 | static void dump_write_message(struct dvb_frontend *fe, unsigned char *buf) |
294 | { | 298 | { |
299 | struct tda9887_priv *priv = fe->analog_demod_priv; | ||
300 | |||
295 | static char *sound[4] = { | 301 | static char *sound[4] = { |
296 | "AM/TV", | 302 | "AM/TV", |
297 | "FM/radio", | 303 | "FM/radio", |
@@ -386,9 +392,12 @@ static void dump_write_message(struct tuner *t, unsigned char *buf) | |||
386 | 392 | ||
387 | /* ---------------------------------------------------------------------- */ | 393 | /* ---------------------------------------------------------------------- */ |
388 | 394 | ||
389 | static int tda9887_set_tvnorm(struct tuner *t, char *buf) | 395 | static int tda9887_set_tvnorm(struct dvb_frontend *fe) |
390 | { | 396 | { |
397 | struct tda9887_priv *priv = fe->analog_demod_priv; | ||
398 | struct tuner *t = priv->t; | ||
391 | struct tvnorm *norm = NULL; | 399 | struct tvnorm *norm = NULL; |
400 | char *buf = priv->data; | ||
392 | int i; | 401 | int i; |
393 | 402 | ||
394 | if (t->mode == V4L2_TUNER_RADIO) { | 403 | if (t->mode == V4L2_TUNER_RADIO) { |
@@ -426,8 +435,11 @@ module_param(port2, int, 0644); | |||
426 | module_param(qss, int, 0644); | 435 | module_param(qss, int, 0644); |
427 | module_param(adjust, int, 0644); | 436 | module_param(adjust, int, 0644); |
428 | 437 | ||
429 | static int tda9887_set_insmod(struct tuner *t, char *buf) | 438 | static int tda9887_set_insmod(struct dvb_frontend *fe) |
430 | { | 439 | { |
440 | struct tda9887_priv *priv = fe->analog_demod_priv; | ||
441 | char *buf = priv->data; | ||
442 | |||
431 | if (UNSET != port1) { | 443 | if (UNSET != port1) { |
432 | if (port1) | 444 | if (port1) |
433 | buf[1] |= cOutputPort1Inactive; | 445 | buf[1] |= cOutputPort1Inactive; |
@@ -455,8 +467,12 @@ static int tda9887_set_insmod(struct tuner *t, char *buf) | |||
455 | return 0; | 467 | return 0; |
456 | } | 468 | } |
457 | 469 | ||
458 | static int tda9887_set_config(struct tuner *t, char *buf) | 470 | static int tda9887_set_config(struct dvb_frontend *fe) |
459 | { | 471 | { |
472 | struct tda9887_priv *priv = fe->analog_demod_priv; | ||
473 | struct tuner *t = priv->t; | ||
474 | char *buf = priv->data; | ||
475 | |||
460 | if (t->tda9887_config & TDA9887_PORT1_ACTIVE) | 476 | if (t->tda9887_config & TDA9887_PORT1_ACTIVE) |
461 | buf[1] &= ~cOutputPort1Inactive; | 477 | buf[1] &= ~cOutputPort1Inactive; |
462 | if (t->tda9887_config & TDA9887_PORT1_INACTIVE) | 478 | if (t->tda9887_config & TDA9887_PORT1_INACTIVE) |
@@ -510,26 +526,27 @@ static int tda9887_set_config(struct tuner *t, char *buf) | |||
510 | 526 | ||
511 | /* ---------------------------------------------------------------------- */ | 527 | /* ---------------------------------------------------------------------- */ |
512 | 528 | ||
513 | static int tda9887_status(struct tuner *t) | 529 | static int tda9887_status(struct dvb_frontend *fe) |
514 | { | 530 | { |
515 | struct tda9887_priv *priv = t->fe.analog_demod_priv; | 531 | struct tda9887_priv *priv = fe->analog_demod_priv; |
516 | unsigned char buf[1]; | 532 | unsigned char buf[1]; |
517 | int rc; | 533 | int rc; |
518 | 534 | ||
519 | memset(buf,0,sizeof(buf)); | 535 | memset(buf,0,sizeof(buf)); |
520 | if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,buf,1))) | 536 | if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,buf,1))) |
521 | tda9887_info("i2c i/o error: rc == %d (should be 1)\n",rc); | 537 | tda9887_info("i2c i/o error: rc == %d (should be 1)\n",rc); |
522 | dump_read_message(t, buf); | 538 | dump_read_message(fe, buf); |
523 | return 0; | 539 | return 0; |
524 | } | 540 | } |
525 | 541 | ||
526 | static void tda9887_configure(struct tuner *t) | 542 | static void tda9887_configure(struct dvb_frontend *fe) |
527 | { | 543 | { |
528 | struct tda9887_priv *priv = t->fe.analog_demod_priv; | 544 | struct tda9887_priv *priv = fe->analog_demod_priv; |
545 | struct tuner *t = priv->t; | ||
529 | int rc; | 546 | int rc; |
530 | 547 | ||
531 | memset(priv->data,0,sizeof(priv->data)); | 548 | memset(priv->data,0,sizeof(priv->data)); |
532 | tda9887_set_tvnorm(t,priv->data); | 549 | tda9887_set_tvnorm(fe); |
533 | 550 | ||
534 | /* A note on the port settings: | 551 | /* A note on the port settings: |
535 | These settings tend to depend on the specifics of the board. | 552 | These settings tend to depend on the specifics of the board. |
@@ -547,8 +564,8 @@ static void tda9887_configure(struct tuner *t) | |||
547 | priv->data[1] |= cOutputPort1Inactive; | 564 | priv->data[1] |= cOutputPort1Inactive; |
548 | priv->data[1] |= cOutputPort2Inactive; | 565 | priv->data[1] |= cOutputPort2Inactive; |
549 | 566 | ||
550 | tda9887_set_config(t,priv->data); | 567 | tda9887_set_config(fe); |
551 | tda9887_set_insmod(t,priv->data); | 568 | tda9887_set_insmod(fe); |
552 | 569 | ||
553 | if (t->mode == T_STANDBY) { | 570 | if (t->mode == T_STANDBY) { |
554 | priv->data[1] |= cForcedMuteAudioON; | 571 | priv->data[1] |= cForcedMuteAudioON; |
@@ -557,28 +574,28 @@ static void tda9887_configure(struct tuner *t) | |||
557 | tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n", | 574 | tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n", |
558 | priv->data[1],priv->data[2],priv->data[3]); | 575 | priv->data[1],priv->data[2],priv->data[3]); |
559 | if (tuner_debug > 1) | 576 | if (tuner_debug > 1) |
560 | dump_write_message(t, priv->data); | 577 | dump_write_message(fe, priv->data); |
561 | 578 | ||
562 | if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,priv->data,4))) | 579 | if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,priv->data,4))) |
563 | tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc); | 580 | tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc); |
564 | 581 | ||
565 | if (tuner_debug > 2) { | 582 | if (tuner_debug > 2) { |
566 | msleep_interruptible(1000); | 583 | msleep_interruptible(1000); |
567 | tda9887_status(t); | 584 | tda9887_status(fe); |
568 | } | 585 | } |
569 | } | 586 | } |
570 | 587 | ||
571 | /* ---------------------------------------------------------------------- */ | 588 | /* ---------------------------------------------------------------------- */ |
572 | 589 | ||
573 | static void tda9887_tuner_status(struct tuner *t) | 590 | static void tda9887_tuner_status(struct dvb_frontend *fe) |
574 | { | 591 | { |
575 | struct tda9887_priv *priv = t->fe.analog_demod_priv; | 592 | struct tda9887_priv *priv = fe->analog_demod_priv; |
576 | tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]); | 593 | tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]); |
577 | } | 594 | } |
578 | 595 | ||
579 | static int tda9887_get_afc(struct tuner *t) | 596 | static int tda9887_get_afc(struct dvb_frontend *fe) |
580 | { | 597 | { |
581 | struct tda9887_priv *priv = t->fe.analog_demod_priv; | 598 | struct tda9887_priv *priv = fe->analog_demod_priv; |
582 | static int AFC_BITS_2_kHz[] = { | 599 | static int AFC_BITS_2_kHz[] = { |
583 | -12500, -37500, -62500, -97500, | 600 | -12500, -37500, -62500, -97500, |
584 | -112500, -137500, -162500, -187500, | 601 | -112500, -137500, -162500, -187500, |
@@ -594,20 +611,20 @@ static int tda9887_get_afc(struct tuner *t) | |||
594 | return afc; | 611 | return afc; |
595 | } | 612 | } |
596 | 613 | ||
597 | static void tda9887_standby(struct tuner *t) | 614 | static void tda9887_standby(struct dvb_frontend *fe) |
598 | { | 615 | { |
599 | tda9887_configure(t); | 616 | tda9887_configure(fe); |
600 | } | 617 | } |
601 | 618 | ||
602 | static void tda9887_set_freq(struct tuner *t, unsigned int freq) | 619 | static void tda9887_set_freq(struct dvb_frontend *fe, unsigned int freq) |
603 | { | 620 | { |
604 | tda9887_configure(t); | 621 | tda9887_configure(fe); |
605 | } | 622 | } |
606 | 623 | ||
607 | static void tda9887_release(struct tuner *t) | 624 | static void tda9887_release(struct dvb_frontend *fe) |
608 | { | 625 | { |
609 | kfree(t->fe.analog_demod_priv); | 626 | kfree(fe->analog_demod_priv); |
610 | t->fe.analog_demod_priv = NULL; | 627 | fe->analog_demod_priv = NULL; |
611 | } | 628 | } |
612 | 629 | ||
613 | static struct analog_tuner_ops tda9887_tuner_ops = { | 630 | static struct analog_tuner_ops tda9887_tuner_ops = { |
@@ -630,6 +647,7 @@ int tda9887_tuner_init(struct tuner *t) | |||
630 | 647 | ||
631 | priv->i2c_props.addr = t->i2c.addr; | 648 | priv->i2c_props.addr = t->i2c.addr; |
632 | priv->i2c_props.adap = t->i2c.adapter; | 649 | priv->i2c_props.adap = t->i2c.adapter; |
650 | priv->t = t; | ||
633 | 651 | ||
634 | strlcpy(t->i2c.name, "tda9887", sizeof(t->i2c.name)); | 652 | strlcpy(t->i2c.name, "tda9887", sizeof(t->i2c.name)); |
635 | 653 | ||
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 9903b3f25300..805a2bd29e7f 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -77,9 +77,10 @@ static struct i2c_client client_template; | |||
77 | 77 | ||
78 | /* ---------------------------------------------------------------------- */ | 78 | /* ---------------------------------------------------------------------- */ |
79 | 79 | ||
80 | static void fe_set_freq(struct tuner *t, unsigned int freq) | 80 | static void fe_set_freq(struct dvb_frontend *fe, unsigned int freq) |
81 | { | 81 | { |
82 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; | 82 | struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; |
83 | struct tuner *t = fe->analog_demod_priv; | ||
83 | 84 | ||
84 | struct analog_parameters params = { | 85 | struct analog_parameters params = { |
85 | .frequency = freq, | 86 | .frequency = freq, |
@@ -92,39 +93,38 @@ static void fe_set_freq(struct tuner *t, unsigned int freq) | |||
92 | tuner_warn("Tuner frontend module has no way to set freq\n"); | 93 | tuner_warn("Tuner frontend module has no way to set freq\n"); |
93 | return; | 94 | return; |
94 | } | 95 | } |
95 | fe_tuner_ops->set_analog_params(&t->fe, ¶ms); | 96 | fe_tuner_ops->set_analog_params(fe, ¶ms); |
96 | } | 97 | } |
97 | 98 | ||
98 | static void fe_release(struct tuner *t) | 99 | static void fe_release(struct dvb_frontend *fe) |
99 | { | 100 | { |
100 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; | 101 | if (fe->ops.tuner_ops.release) |
101 | 102 | fe->ops.tuner_ops.release(fe); | |
102 | if (fe_tuner_ops->release) | ||
103 | fe_tuner_ops->release(&t->fe); | ||
104 | 103 | ||
105 | t->fe.ops.analog_demod_ops = NULL; | 104 | fe->ops.analog_demod_ops = NULL; |
105 | /* DO NOT kfree(t->fe.analog_demod_priv) */ | ||
106 | fe->analog_demod_priv = NULL; | ||
106 | } | 107 | } |
107 | 108 | ||
108 | static void fe_standby(struct tuner *t) | 109 | static void fe_standby(struct dvb_frontend *fe) |
109 | { | 110 | { |
110 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; | 111 | struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; |
111 | 112 | ||
112 | if (fe_tuner_ops->sleep) | 113 | if (fe_tuner_ops->sleep) |
113 | fe_tuner_ops->sleep(&t->fe); | 114 | fe_tuner_ops->sleep(fe); |
114 | } | 115 | } |
115 | 116 | ||
116 | static int fe_has_signal(struct tuner *t) | 117 | static int fe_has_signal(struct dvb_frontend *fe) |
117 | { | 118 | { |
118 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; | ||
119 | u16 strength = 0; | 119 | u16 strength = 0; |
120 | 120 | ||
121 | if (fe_tuner_ops->get_rf_strength) | 121 | if (fe->ops.tuner_ops.get_rf_strength) |
122 | fe_tuner_ops->get_rf_strength(&t->fe, &strength); | 122 | fe->ops.tuner_ops.get_rf_strength(fe, &strength); |
123 | 123 | ||
124 | return strength; | 124 | return strength; |
125 | } | 125 | } |
126 | 126 | ||
127 | static void tuner_status(struct tuner *t); | 127 | static void tuner_status(struct dvb_frontend *fe); |
128 | 128 | ||
129 | static struct analog_tuner_ops tuner_core_ops = { | 129 | static struct analog_tuner_ops tuner_core_ops = { |
130 | .set_tv_freq = fe_set_freq, | 130 | .set_tv_freq = fe_set_freq, |
@@ -160,7 +160,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
160 | else | 160 | else |
161 | freq = tv_range[1] * 16; | 161 | freq = tv_range[1] * 16; |
162 | } | 162 | } |
163 | ops->set_tv_freq(t, freq); | 163 | ops->set_tv_freq(&t->fe, freq); |
164 | } | 164 | } |
165 | 165 | ||
166 | static void set_radio_freq(struct i2c_client *c, unsigned int freq) | 166 | static void set_radio_freq(struct i2c_client *c, unsigned int freq) |
@@ -188,7 +188,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) | |||
188 | freq = radio_range[1] * 16000; | 188 | freq = radio_range[1] * 16000; |
189 | } | 189 | } |
190 | 190 | ||
191 | ops->set_radio_freq(t, freq); | 191 | ops->set_radio_freq(&t->fe, freq); |
192 | } | 192 | } |
193 | 193 | ||
194 | static void set_freq(struct i2c_client *c, unsigned long freq) | 194 | static void set_freq(struct i2c_client *c, unsigned long freq) |
@@ -279,7 +279,7 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
279 | 279 | ||
280 | /* discard private data, in case set_type() was previously called */ | 280 | /* discard private data, in case set_type() was previously called */ |
281 | if ((ops) && (ops->release)) | 281 | if ((ops) && (ops->release)) |
282 | ops->release(t); | 282 | ops->release(&t->fe); |
283 | 283 | ||
284 | switch (t->type) { | 284 | switch (t->type) { |
285 | case TUNER_MT2032: | 285 | case TUNER_MT2032: |
@@ -359,6 +359,7 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
359 | strlcpy(t->i2c.name, fe_tuner_ops->info.name, sizeof(t->i2c.name)); | 359 | strlcpy(t->i2c.name, fe_tuner_ops->info.name, sizeof(t->i2c.name)); |
360 | 360 | ||
361 | t->fe.ops.analog_demod_ops = &tuner_core_ops; | 361 | t->fe.ops.analog_demod_ops = &tuner_core_ops; |
362 | t->fe.analog_demod_priv = t; | ||
362 | } | 363 | } |
363 | 364 | ||
364 | tuner_info("type set to %s\n", t->i2c.name); | 365 | tuner_info("type set to %s\n", t->i2c.name); |
@@ -531,8 +532,9 @@ static int tuner_fixup_std(struct tuner *t) | |||
531 | return 0; | 532 | return 0; |
532 | } | 533 | } |
533 | 534 | ||
534 | static void tuner_status(struct tuner *t) | 535 | static void tuner_status(struct dvb_frontend *fe) |
535 | { | 536 | { |
537 | struct tuner *t = fe->analog_demod_priv; | ||
536 | unsigned long freq, freq_fraction; | 538 | unsigned long freq, freq_fraction; |
537 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; | 539 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; |
538 | struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; | 540 | struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; |
@@ -566,10 +568,11 @@ static void tuner_status(struct tuner *t) | |||
566 | tuner_info("Stereo: yes\n"); | 568 | tuner_info("Stereo: yes\n"); |
567 | } | 569 | } |
568 | if ((ops) && (ops->has_signal)) { | 570 | if ((ops) && (ops->has_signal)) { |
569 | tuner_info("Signal strength: %d\n", ops->has_signal(t)); | 571 | tuner_info("Signal strength: %d\n", ops->has_signal(fe)); |
570 | } | 572 | } |
571 | if ((ops) && (ops->is_stereo)) { | 573 | if ((ops) && (ops->is_stereo)) { |
572 | tuner_info("Stereo: %s\n", ops->is_stereo(t) ? "yes" : "no"); | 574 | tuner_info("Stereo: %s\n", ops->is_stereo(fe) ? |
575 | "yes" : "no"); | ||
573 | } | 576 | } |
574 | } | 577 | } |
575 | 578 | ||
@@ -723,7 +726,7 @@ static int tuner_detach(struct i2c_client *client) | |||
723 | } | 726 | } |
724 | 727 | ||
725 | if ((ops) && (ops->release)) | 728 | if ((ops) && (ops->release)) |
726 | ops->release(t); | 729 | ops->release(&t->fe); |
727 | 730 | ||
728 | kfree(t); | 731 | kfree(t); |
729 | return 0; | 732 | return 0; |
@@ -748,7 +751,7 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, | |||
748 | if (check_mode(t, cmd) == EINVAL) { | 751 | if (check_mode(t, cmd) == EINVAL) { |
749 | t->mode = T_STANDBY; | 752 | t->mode = T_STANDBY; |
750 | if ((ops) && (ops->standby)) | 753 | if ((ops) && (ops->standby)) |
751 | ops->standby(t); | 754 | ops->standby(&t->fe); |
752 | return EINVAL; | 755 | return EINVAL; |
753 | } | 756 | } |
754 | return 0; | 757 | return 0; |
@@ -799,7 +802,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
799 | return 0; | 802 | return 0; |
800 | t->mode = T_STANDBY; | 803 | t->mode = T_STANDBY; |
801 | if ((ops) && (ops->standby)) | 804 | if ((ops) && (ops->standby)) |
802 | ops->standby(t); | 805 | ops->standby(&t->fe); |
803 | break; | 806 | break; |
804 | #ifdef CONFIG_VIDEO_V4L1 | 807 | #ifdef CONFIG_VIDEO_V4L1 |
805 | case VIDIOCSAUDIO: | 808 | case VIDIOCSAUDIO: |
@@ -868,7 +871,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
868 | vt->flags &= ~VIDEO_TUNER_STEREO_ON; | 871 | vt->flags &= ~VIDEO_TUNER_STEREO_ON; |
869 | } else { | 872 | } else { |
870 | if ((ops) && (ops->is_stereo)) { | 873 | if ((ops) && (ops->is_stereo)) { |
871 | if (ops->is_stereo(t)) | 874 | if (ops->is_stereo(&t->fe)) |
872 | vt->flags |= | 875 | vt->flags |= |
873 | VIDEO_TUNER_STEREO_ON; | 876 | VIDEO_TUNER_STEREO_ON; |
874 | else | 877 | else |
@@ -877,7 +880,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
877 | } | 880 | } |
878 | } | 881 | } |
879 | if ((ops) && (ops->has_signal)) | 882 | if ((ops) && (ops->has_signal)) |
880 | vt->signal = ops->has_signal(t); | 883 | vt->signal = ops->has_signal(&t->fe); |
881 | 884 | ||
882 | vt->flags |= VIDEO_TUNER_LOW; /* Allow freqs at 62.5 Hz */ | 885 | vt->flags |= VIDEO_TUNER_LOW; /* Allow freqs at 62.5 Hz */ |
883 | 886 | ||
@@ -908,7 +911,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
908 | va->mode = (tuner_status & TUNER_STATUS_STEREO) | 911 | va->mode = (tuner_status & TUNER_STATUS_STEREO) |
909 | ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; | 912 | ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; |
910 | } else if ((ops) && (ops->is_stereo)) | 913 | } else if ((ops) && (ops->is_stereo)) |
911 | va->mode = ops->is_stereo(t) | 914 | va->mode = ops->is_stereo(&t->fe) |
912 | ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; | 915 | ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; |
913 | } | 916 | } |
914 | return 0; | 917 | return 0; |
@@ -999,7 +1002,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
999 | 1002 | ||
1000 | tuner->type = t->mode; | 1003 | tuner->type = t->mode; |
1001 | if ((ops) && (ops->get_afc)) | 1004 | if ((ops) && (ops->get_afc)) |
1002 | tuner->afc = ops->get_afc(t); | 1005 | tuner->afc = ops->get_afc(&t->fe); |
1003 | if (t->mode == V4L2_TUNER_ANALOG_TV) | 1006 | if (t->mode == V4L2_TUNER_ANALOG_TV) |
1004 | tuner->capability |= V4L2_TUNER_CAP_NORM; | 1007 | tuner->capability |= V4L2_TUNER_CAP_NORM; |
1005 | if (t->mode != V4L2_TUNER_RADIO) { | 1008 | if (t->mode != V4L2_TUNER_RADIO) { |
@@ -1015,16 +1018,20 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1015 | u32 tuner_status; | 1018 | u32 tuner_status; |
1016 | 1019 | ||
1017 | fe_tuner_ops->get_status(&t->fe, &tuner_status); | 1020 | fe_tuner_ops->get_status(&t->fe, &tuner_status); |
1018 | tuner->rxsubchans = (tuner_status & TUNER_STATUS_STEREO) ? | 1021 | tuner->rxsubchans = |
1019 | V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; | 1022 | (tuner_status & TUNER_STATUS_STEREO) ? |
1023 | V4L2_TUNER_SUB_STEREO : | ||
1024 | V4L2_TUNER_SUB_MONO; | ||
1020 | } else { | 1025 | } else { |
1021 | if ((ops) && (ops->is_stereo)) { | 1026 | if ((ops) && (ops->is_stereo)) { |
1022 | tuner->rxsubchans = ops->is_stereo(t) ? | 1027 | tuner->rxsubchans = |
1023 | V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; | 1028 | ops->is_stereo(&t->fe) ? |
1029 | V4L2_TUNER_SUB_STEREO : | ||
1030 | V4L2_TUNER_SUB_MONO; | ||
1024 | } | 1031 | } |
1025 | } | 1032 | } |
1026 | if ((ops) && (ops->has_signal)) | 1033 | if ((ops) && (ops->has_signal)) |
1027 | tuner->signal = ops->has_signal(t); | 1034 | tuner->signal = ops->has_signal(&t->fe); |
1028 | tuner->capability |= | 1035 | tuner->capability |= |
1029 | V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; | 1036 | V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; |
1030 | tuner->audmode = t->audmode; | 1037 | tuner->audmode = t->audmode; |
@@ -1050,7 +1057,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1050 | } | 1057 | } |
1051 | case VIDIOC_LOG_STATUS: | 1058 | case VIDIOC_LOG_STATUS: |
1052 | if ((ops) && (ops->tuner_status)) | 1059 | if ((ops) && (ops->tuner_status)) |
1053 | ops->tuner_status(t); | 1060 | ops->tuner_status(&t->fe); |
1054 | break; | 1061 | break; |
1055 | } | 1062 | } |
1056 | 1063 | ||
diff --git a/drivers/media/video/tuner-driver.h b/drivers/media/video/tuner-driver.h index fffacb378fd0..cc9c1c74117b 100644 --- a/drivers/media/video/tuner-driver.h +++ b/drivers/media/video/tuner-driver.h | |||
@@ -32,14 +32,14 @@ extern unsigned const int tuner_count; | |||
32 | struct tuner; | 32 | struct tuner; |
33 | 33 | ||
34 | struct analog_tuner_ops { | 34 | struct analog_tuner_ops { |
35 | void (*set_tv_freq)(struct tuner *t, unsigned int freq); | 35 | void (*set_tv_freq)(struct dvb_frontend *fe, unsigned int freq); |
36 | void (*set_radio_freq)(struct tuner *t, unsigned int freq); | 36 | void (*set_radio_freq)(struct dvb_frontend *fe, unsigned int freq); |
37 | int (*has_signal)(struct tuner *t); | 37 | int (*has_signal)(struct dvb_frontend *fe); |
38 | int (*is_stereo)(struct tuner *t); | 38 | int (*is_stereo)(struct dvb_frontend *fe); |
39 | int (*get_afc)(struct tuner *t); | 39 | int (*get_afc)(struct dvb_frontend *fe); |
40 | void (*tuner_status)(struct tuner *t); | 40 | void (*tuner_status)(struct dvb_frontend *fe); |
41 | void (*standby)(struct tuner *t); | 41 | void (*standby)(struct dvb_frontend *fe); |
42 | void (*release)(struct tuner *t); | 42 | void (*release)(struct dvb_frontend *fe); |
43 | }; | 43 | }; |
44 | 44 | ||
45 | struct tuner { | 45 | struct tuner { |