aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tda9887.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-08-21 00:24:42 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:07:34 -0400
commitdb8a695658cda21eacfa2a5e3b15e8964bfb93ef (patch)
treeac69f32af5b52f78ad65ad1125d330aa19c7bdda /drivers/media/video/tda9887.c
parent293197cd0f34eb6bfb5492a63a878575b69e9df4 (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/tda9887.c')
-rw-r--r--drivers/media/video/tda9887.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index d162bc67d445..be5387f11afb 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -29,6 +29,8 @@
29 i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) 29 i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)
30 30
31struct tda9887_priv { 31struct tda9887_priv {
32 struct tuner_i2c_props i2c_props;
33
32 unsigned char data[4]; 34 unsigned char data[4];
33}; 35};
34 36
@@ -510,19 +512,19 @@ static int tda9887_set_config(struct tuner *t, char *buf)
510 512
511static int tda9887_status(struct tuner *t) 513static int tda9887_status(struct tuner *t)
512{ 514{
515 struct tda9887_priv *priv = t->priv;
513 unsigned char buf[1]; 516 unsigned char buf[1];
514 int rc; 517 int rc;
515 518
516 memset(buf,0,sizeof(buf)); 519 memset(buf,0,sizeof(buf));
517 if (1 != (rc = i2c_master_recv(&t->i2c,buf,1))) 520 if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,buf,1)))
518 tda9887_info("i2c i/o error: rc == %d (should be 1)\n",rc); 521 tda9887_info("i2c i/o error: rc == %d (should be 1)\n",rc);
519 dump_read_message(t, buf); 522 dump_read_message(t, buf);
520 return 0; 523 return 0;
521} 524}
522 525
523static void tda9887_configure(struct i2c_client *client) 526static void tda9887_configure(struct tuner *t)
524{ 527{
525 struct tuner *t = i2c_get_clientdata(client);
526 struct tda9887_priv *priv = t->priv; 528 struct tda9887_priv *priv = t->priv;
527 int rc; 529 int rc;
528 530
@@ -557,7 +559,7 @@ static void tda9887_configure(struct i2c_client *client)
557 if (tuner_debug > 1) 559 if (tuner_debug > 1)
558 dump_write_message(t, priv->data); 560 dump_write_message(t, priv->data);
559 561
560 if (4 != (rc = i2c_master_send(&t->i2c,priv->data,4))) 562 if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,priv->data,4)))
561 tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc); 563 tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc);
562 564
563 if (tuner_debug > 2) { 565 if (tuner_debug > 2) {
@@ -568,16 +570,15 @@ static void tda9887_configure(struct i2c_client *client)
568 570
569/* ---------------------------------------------------------------------- */ 571/* ---------------------------------------------------------------------- */
570 572
571static void tda9887_tuner_status(struct i2c_client *client) 573static void tda9887_tuner_status(struct tuner *t)
572{ 574{
573 struct tuner *t = i2c_get_clientdata(client);
574 struct tda9887_priv *priv = t->priv; 575 struct tda9887_priv *priv = t->priv;
575 tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]); 576 tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]);
576} 577}
577 578
578static int tda9887_get_afc(struct i2c_client *client) 579static int tda9887_get_afc(struct tuner *t)
579{ 580{
580 struct tuner *t = i2c_get_clientdata(client); 581 struct tda9887_priv *priv = t->priv;
581 static int AFC_BITS_2_kHz[] = { 582 static int AFC_BITS_2_kHz[] = {
582 -12500, -37500, -62500, -97500, 583 -12500, -37500, -62500, -97500,
583 -112500, -137500, -162500, -187500, 584 -112500, -137500, -162500, -187500,
@@ -587,26 +588,24 @@ static int tda9887_get_afc(struct i2c_client *client)
587 int afc=0; 588 int afc=0;
588 __u8 reg = 0; 589 __u8 reg = 0;
589 590
590 if (1 == i2c_master_recv(&t->i2c,&reg,1)) 591 if (1 == tuner_i2c_xfer_recv(&priv->i2c_props,&reg,1))
591 afc = AFC_BITS_2_kHz[(reg>>1)&0x0f]; 592 afc = AFC_BITS_2_kHz[(reg>>1)&0x0f];
592 593
593 return afc; 594 return afc;
594} 595}
595 596
596static void tda9887_standby(struct i2c_client *client) 597static void tda9887_standby(struct tuner *t)
597{ 598{
598 tda9887_configure(client); 599 tda9887_configure(t);
599} 600}
600 601
601static void tda9887_set_freq(struct i2c_client *client, unsigned int freq) 602static void tda9887_set_freq(struct tuner *t, unsigned int freq)
602{ 603{
603 tda9887_configure(client); 604 tda9887_configure(t);
604} 605}
605 606
606static void tda9887_release(struct i2c_client *c) 607static void tda9887_release(struct tuner *t)
607{ 608{
608 struct tuner *t = i2c_get_clientdata(c);
609
610 kfree(t->priv); 609 kfree(t->priv);
611 t->priv = NULL; 610 t->priv = NULL;
612} 611}
@@ -620,17 +619,19 @@ static struct tuner_operations tda9887_tuner_ops = {
620 .release = tda9887_release, 619 .release = tda9887_release,
621}; 620};
622 621
623int tda9887_tuner_init(struct i2c_client *c) 622int tda9887_tuner_init(struct tuner *t)
624{ 623{
625 struct tda9887_priv *priv = NULL; 624 struct tda9887_priv *priv = NULL;
626 struct tuner *t = i2c_get_clientdata(c);
627 625
628 priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL); 626 priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL);
629 if (priv == NULL) 627 if (priv == NULL)
630 return -ENOMEM; 628 return -ENOMEM;
631 t->priv = priv; 629 t->priv = priv;
632 630
633 strlcpy(c->name, "tda9887", sizeof(c->name)); 631 priv->i2c_props.addr = t->i2c.addr;
632 priv->i2c_props.adap = t->i2c.adapter;
633
634 strlcpy(t->i2c.name, "tda9887", sizeof(t->i2c.name));
634 635
635 tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr, 636 tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr,
636 t->i2c.driver->driver.name); 637 t->i2c.driver->driver.name);