diff options
Diffstat (limited to 'drivers/media/video/tda9887.c')
-rw-r--r-- | drivers/media/video/tda9887.c | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index fde576f1101c..a8f773274fe3 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <media/v4l2-common.h> | 12 | #include <media/v4l2-common.h> |
13 | #include <media/tuner.h> | 13 | #include <media/tuner.h> |
14 | #include "tuner-driver.h" | ||
14 | 15 | ||
15 | 16 | ||
16 | /* Chips: | 17 | /* Chips: |
@@ -29,6 +30,9 @@ | |||
29 | printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \ | 30 | printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \ |
30 | i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) | 31 | i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) |
31 | 32 | ||
33 | struct tda9887_priv { | ||
34 | unsigned char data[4]; | ||
35 | }; | ||
32 | 36 | ||
33 | /* ---------------------------------------------------------------------- */ | 37 | /* ---------------------------------------------------------------------- */ |
34 | 38 | ||
@@ -508,10 +512,11 @@ static int tda9887_status(struct tuner *t) | |||
508 | static void tda9887_configure(struct i2c_client *client) | 512 | static void tda9887_configure(struct i2c_client *client) |
509 | { | 513 | { |
510 | struct tuner *t = i2c_get_clientdata(client); | 514 | struct tuner *t = i2c_get_clientdata(client); |
515 | struct tda9887_priv *priv = t->priv; | ||
511 | int rc; | 516 | int rc; |
512 | 517 | ||
513 | memset(t->tda9887_data,0,sizeof(t->tda9887_data)); | 518 | memset(priv->data,0,sizeof(priv->data)); |
514 | tda9887_set_tvnorm(t,t->tda9887_data); | 519 | tda9887_set_tvnorm(t,priv->data); |
515 | 520 | ||
516 | /* A note on the port settings: | 521 | /* A note on the port settings: |
517 | These settings tend to depend on the specifics of the board. | 522 | These settings tend to depend on the specifics of the board. |
@@ -526,22 +531,22 @@ static void tda9887_configure(struct i2c_client *client) | |||
526 | the ports should be set to active (0), but, again, that may | 531 | the ports should be set to active (0), but, again, that may |
527 | differ depending on the precise hardware configuration. | 532 | differ depending on the precise hardware configuration. |
528 | */ | 533 | */ |
529 | t->tda9887_data[1] |= cOutputPort1Inactive; | 534 | priv->data[1] |= cOutputPort1Inactive; |
530 | t->tda9887_data[1] |= cOutputPort2Inactive; | 535 | priv->data[1] |= cOutputPort2Inactive; |
531 | 536 | ||
532 | tda9887_set_config(t,t->tda9887_data); | 537 | tda9887_set_config(t,priv->data); |
533 | tda9887_set_insmod(t,t->tda9887_data); | 538 | tda9887_set_insmod(t,priv->data); |
534 | 539 | ||
535 | if (t->mode == T_STANDBY) { | 540 | if (t->mode == T_STANDBY) { |
536 | t->tda9887_data[1] |= cForcedMuteAudioON; | 541 | priv->data[1] |= cForcedMuteAudioON; |
537 | } | 542 | } |
538 | 543 | ||
539 | tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n", | 544 | tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n", |
540 | t->tda9887_data[1],t->tda9887_data[2],t->tda9887_data[3]); | 545 | priv->data[1],priv->data[2],priv->data[3]); |
541 | if (tuner_debug > 1) | 546 | if (tuner_debug > 1) |
542 | dump_write_message(t, t->tda9887_data); | 547 | dump_write_message(t, priv->data); |
543 | 548 | ||
544 | if (4 != (rc = i2c_master_send(&t->i2c,t->tda9887_data,4))) | 549 | if (4 != (rc = i2c_master_send(&t->i2c,priv->data,4))) |
545 | tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc); | 550 | tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc); |
546 | 551 | ||
547 | if (tuner_debug > 2) { | 552 | if (tuner_debug > 2) { |
@@ -555,7 +560,8 @@ static void tda9887_configure(struct i2c_client *client) | |||
555 | static void tda9887_tuner_status(struct i2c_client *client) | 560 | static void tda9887_tuner_status(struct i2c_client *client) |
556 | { | 561 | { |
557 | struct tuner *t = i2c_get_clientdata(client); | 562 | struct tuner *t = i2c_get_clientdata(client); |
558 | tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", t->tda9887_data[1], t->tda9887_data[2], t->tda9887_data[3]); | 563 | struct tda9887_priv *priv = t->priv; |
564 | tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]); | ||
559 | } | 565 | } |
560 | 566 | ||
561 | static int tda9887_get_afc(struct i2c_client *client) | 567 | static int tda9887_get_afc(struct i2c_client *client) |
@@ -586,20 +592,39 @@ static void tda9887_set_freq(struct i2c_client *client, unsigned int freq) | |||
586 | tda9887_configure(client); | 592 | tda9887_configure(client); |
587 | } | 593 | } |
588 | 594 | ||
595 | static void tda9887_release(struct i2c_client *c) | ||
596 | { | ||
597 | struct tuner *t = i2c_get_clientdata(c); | ||
598 | |||
599 | kfree(t->priv); | ||
600 | t->priv = NULL; | ||
601 | } | ||
602 | |||
603 | static struct tuner_operations tda9887_tuner_ops = { | ||
604 | .set_tv_freq = tda9887_set_freq, | ||
605 | .set_radio_freq = tda9887_set_freq, | ||
606 | .standby = tda9887_standby, | ||
607 | .tuner_status = tda9887_tuner_status, | ||
608 | .get_afc = tda9887_get_afc, | ||
609 | .release = tda9887_release, | ||
610 | }; | ||
611 | |||
589 | int tda9887_tuner_init(struct i2c_client *c) | 612 | int tda9887_tuner_init(struct i2c_client *c) |
590 | { | 613 | { |
614 | struct tda9887_priv *priv = NULL; | ||
591 | struct tuner *t = i2c_get_clientdata(c); | 615 | struct tuner *t = i2c_get_clientdata(c); |
592 | 616 | ||
617 | priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL); | ||
618 | if (priv == NULL) | ||
619 | return -ENOMEM; | ||
620 | t->priv = priv; | ||
621 | |||
593 | strlcpy(c->name, "tda9887", sizeof(c->name)); | 622 | strlcpy(c->name, "tda9887", sizeof(c->name)); |
594 | 623 | ||
595 | tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr, | 624 | tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr, |
596 | t->i2c.driver->driver.name); | 625 | t->i2c.driver->driver.name); |
597 | 626 | ||
598 | t->set_tv_freq = tda9887_set_freq; | 627 | memcpy(&t->ops, &tda9887_tuner_ops, sizeof(struct tuner_operations)); |
599 | t->set_radio_freq = tda9887_set_freq; | ||
600 | t->standby = tda9887_standby; | ||
601 | t->tuner_status = tda9887_tuner_status; | ||
602 | t->get_afc = tda9887_get_afc; | ||
603 | 628 | ||
604 | return 0; | 629 | return 0; |
605 | } | 630 | } |