diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-08-21 00:24:42 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-10-09 21:07:34 -0400 |
commit | db8a695658cda21eacfa2a5e3b15e8964bfb93ef (patch) | |
tree | ac69f32af5b52f78ad65ad1125d330aa19c7bdda /drivers/media/video/tuner-simple.c | |
parent | 293197cd0f34eb6bfb5492a63a878575b69e9df4 (diff) |
V4L/DVB (6127): tuner: kill i2c_client interface to tuner sub-drivers
To ease the conversion of the analog tuner sub-drivers into dvb_frontend
style tuner modules, we must remove the i2c_client interface.
dvb_frontend style tuner modules use i2c_transfer directly on the i2c_adapter.
This change only alters the interface between tuner.ko and the tuner
sub-drivers. The v4l2 / i2c_client interface to tuner.ko remains intact.
This patch adds inline functions tuner_i2c_xfer_send, and tuner_i2c_xfer_recv,
to replace i2c_master_send and i2c_master_recv inside the tuner sub-drivers.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Acked-by: Mike Isely <isely@pobox.com>
Acked-by: Steven Toth <stoth@hauppauge.com>
Acked-by: Patrick Boettcher <pb@linuxtv.org>
Acked-by: Jarod Wilson <jwilson@redhat.com>
Acked-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/tuner-simple.c')
-rw-r--r-- | drivers/media/video/tuner-simple.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 572f22423b98..eca2ff249a36 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c | |||
@@ -84,31 +84,32 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner"); | |||
84 | 84 | ||
85 | struct tuner_simple_priv { | 85 | struct tuner_simple_priv { |
86 | u16 last_div; | 86 | u16 last_div; |
87 | struct tuner_i2c_props i2c_props; | ||
87 | }; | 88 | }; |
88 | 89 | ||
89 | /* ---------------------------------------------------------------------- */ | 90 | /* ---------------------------------------------------------------------- */ |
90 | 91 | ||
91 | static int tuner_getstatus(struct i2c_client *c) | 92 | static int tuner_getstatus(struct tuner *t) |
92 | { | 93 | { |
94 | struct tuner_simple_priv *priv = t->priv; | ||
93 | unsigned char byte; | 95 | unsigned char byte; |
94 | 96 | ||
95 | if (1 != i2c_master_recv(c,&byte,1)) | 97 | if (1 != tuner_i2c_xfer_recv(&priv->i2c_props,&byte,1)) |
96 | return 0; | 98 | return 0; |
97 | 99 | ||
98 | return byte; | 100 | return byte; |
99 | } | 101 | } |
100 | 102 | ||
101 | static int tuner_signal(struct i2c_client *c) | 103 | static int tuner_signal(struct tuner *t) |
102 | { | 104 | { |
103 | return (tuner_getstatus(c) & TUNER_SIGNAL) << 13; | 105 | return (tuner_getstatus(t) & TUNER_SIGNAL) << 13; |
104 | } | 106 | } |
105 | 107 | ||
106 | static int tuner_stereo(struct i2c_client *c) | 108 | static int tuner_stereo(struct tuner *t) |
107 | { | 109 | { |
108 | int stereo, status; | 110 | int stereo, status; |
109 | struct tuner *t = i2c_get_clientdata(c); | ||
110 | 111 | ||
111 | status = tuner_getstatus (c); | 112 | status = tuner_getstatus(t); |
112 | 113 | ||
113 | switch (t->type) { | 114 | switch (t->type) { |
114 | case TUNER_PHILIPS_FM1216ME_MK3: | 115 | case TUNER_PHILIPS_FM1216ME_MK3: |
@@ -127,9 +128,8 @@ static int tuner_stereo(struct i2c_client *c) | |||
127 | 128 | ||
128 | /* ---------------------------------------------------------------------- */ | 129 | /* ---------------------------------------------------------------------- */ |
129 | 130 | ||
130 | static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | 131 | static void default_set_tv_freq(struct tuner *t, unsigned int freq) |
131 | { | 132 | { |
132 | struct tuner *t = i2c_get_clientdata(c); | ||
133 | struct tuner_simple_priv *priv = t->priv; | 133 | struct tuner_simple_priv *priv = t->priv; |
134 | u8 config, cb, tuneraddr; | 134 | u8 config, cb, tuneraddr; |
135 | u16 div; | 135 | u16 div; |
@@ -285,13 +285,13 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
285 | buffer[1] = 0x04; | 285 | buffer[1] = 0x04; |
286 | } | 286 | } |
287 | /* set to the correct mode (analog or digital) */ | 287 | /* set to the correct mode (analog or digital) */ |
288 | tuneraddr = c->addr; | 288 | tuneraddr = priv->i2c_props.addr; |
289 | c->addr = 0x0a; | 289 | priv->i2c_props.addr = 0x0a; |
290 | if (2 != (rc = i2c_master_send(c,&buffer[0],2))) | 290 | if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[0],2))) |
291 | tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); | 291 | tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); |
292 | if (2 != (rc = i2c_master_send(c,&buffer[2],2))) | 292 | if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[2],2))) |
293 | tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); | 293 | tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); |
294 | c->addr = tuneraddr; | 294 | priv->i2c_props.addr = tuneraddr; |
295 | /* FIXME: input */ | 295 | /* FIXME: input */ |
296 | break; | 296 | break; |
297 | } | 297 | } |
@@ -345,12 +345,12 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
345 | } | 345 | } |
346 | if (params->default_pll_gating_18) | 346 | if (params->default_pll_gating_18) |
347 | config |= TDA9887_GATING_18; | 347 | config |= TDA9887_GATING_18; |
348 | i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config); | 348 | i2c_clients_command(priv->i2c_props.adap, TDA9887_SET_CONFIG, &config); |
349 | } | 349 | } |
350 | tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", | 350 | tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", |
351 | buffer[0],buffer[1],buffer[2],buffer[3]); | 351 | buffer[0],buffer[1],buffer[2],buffer[3]); |
352 | 352 | ||
353 | if (4 != (rc = i2c_master_send(c,buffer,4))) | 353 | if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4))) |
354 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); | 354 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); |
355 | 355 | ||
356 | switch (t->type) { | 356 | switch (t->type) { |
@@ -362,7 +362,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
362 | buffer[1] = 0x20; | 362 | buffer[1] = 0x20; |
363 | tuner_dbg("tv 0x%02x 0x%02x\n",buffer[0],buffer[1]); | 363 | tuner_dbg("tv 0x%02x 0x%02x\n",buffer[0],buffer[1]); |
364 | 364 | ||
365 | if (2 != (rc = i2c_master_send(c,buffer,2))) | 365 | if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,2))) |
366 | tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); | 366 | tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); |
367 | break; | 367 | break; |
368 | case TUNER_MICROTUNE_4042FI5: | 368 | case TUNER_MICROTUNE_4042FI5: |
@@ -375,7 +375,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
375 | for (;;) { | 375 | for (;;) { |
376 | if (time_after(jiffies,timeout)) | 376 | if (time_after(jiffies,timeout)) |
377 | return; | 377 | return; |
378 | if (1 != (rc = i2c_master_recv(c,&status_byte,1))) { | 378 | if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,&status_byte,1))) { |
379 | tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc); | 379 | tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc); |
380 | break; | 380 | break; |
381 | } | 381 | } |
@@ -393,17 +393,16 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
393 | tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", | 393 | tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", |
394 | buffer[0],buffer[1],buffer[2],buffer[3]); | 394 | buffer[0],buffer[1],buffer[2],buffer[3]); |
395 | 395 | ||
396 | if (4 != (rc = i2c_master_send(c,buffer,4))) | 396 | if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4))) |
397 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); | 397 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); |
398 | break; | 398 | break; |
399 | } | 399 | } |
400 | } | 400 | } |
401 | } | 401 | } |
402 | 402 | ||
403 | static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) | 403 | static void default_set_radio_freq(struct tuner *t, unsigned int freq) |
404 | { | 404 | { |
405 | struct tunertype *tun; | 405 | struct tunertype *tun; |
406 | struct tuner *t = i2c_get_clientdata(c); | ||
407 | struct tuner_simple_priv *priv = t->priv; | 406 | struct tuner_simple_priv *priv = t->priv; |
408 | u8 buffer[4]; | 407 | u8 buffer[4]; |
409 | u16 div; | 408 | u16 div; |
@@ -498,16 +497,14 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) | |||
498 | config |= TDA9887_GAIN_NORMAL; | 497 | config |= TDA9887_GAIN_NORMAL; |
499 | if (params->radio_if == 2) | 498 | if (params->radio_if == 2) |
500 | config |= TDA9887_RIF_41_3; | 499 | config |= TDA9887_RIF_41_3; |
501 | i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config); | 500 | i2c_clients_command(priv->i2c_props.adap, TDA9887_SET_CONFIG, &config); |
502 | } | 501 | } |
503 | if (4 != (rc = i2c_master_send(c,buffer,4))) | 502 | if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4))) |
504 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); | 503 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); |
505 | } | 504 | } |
506 | 505 | ||
507 | static void tuner_release(struct i2c_client *c) | 506 | static void tuner_release(struct tuner *t) |
508 | { | 507 | { |
509 | struct tuner *t = i2c_get_clientdata(c); | ||
510 | |||
511 | kfree(t->priv); | 508 | kfree(t->priv); |
512 | t->priv = NULL; | 509 | t->priv = NULL; |
513 | } | 510 | } |
@@ -520,9 +517,8 @@ static struct tuner_operations simple_tuner_ops = { | |||
520 | .release = tuner_release, | 517 | .release = tuner_release, |
521 | }; | 518 | }; |
522 | 519 | ||
523 | int default_tuner_init(struct i2c_client *c) | 520 | int default_tuner_init(struct tuner *t) |
524 | { | 521 | { |
525 | struct tuner *t = i2c_get_clientdata(c); | ||
526 | struct tuner_simple_priv *priv = NULL; | 522 | struct tuner_simple_priv *priv = NULL; |
527 | 523 | ||
528 | priv = kzalloc(sizeof(struct tuner_simple_priv), GFP_KERNEL); | 524 | priv = kzalloc(sizeof(struct tuner_simple_priv), GFP_KERNEL); |
@@ -530,9 +526,12 @@ int default_tuner_init(struct i2c_client *c) | |||
530 | return -ENOMEM; | 526 | return -ENOMEM; |
531 | t->priv = priv; | 527 | t->priv = priv; |
532 | 528 | ||
529 | priv->i2c_props.addr = t->i2c.addr; | ||
530 | priv->i2c_props.adap = t->i2c.adapter; | ||
531 | |||
533 | tuner_info("type set to %d (%s)\n", | 532 | tuner_info("type set to %d (%s)\n", |
534 | t->type, tuners[t->type].name); | 533 | t->type, tuners[t->type].name); |
535 | strlcpy(c->name, tuners[t->type].name, sizeof(c->name)); | 534 | strlcpy(t->i2c.name, tuners[t->type].name, sizeof(t->i2c.name)); |
536 | 535 | ||
537 | memcpy(&t->ops, &simple_tuner_ops, sizeof(struct tuner_operations)); | 536 | memcpy(&t->ops, &simple_tuner_ops, sizeof(struct tuner_operations)); |
538 | 537 | ||