diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-11 22:09:32 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-11 22:09:32 -0400 |
commit | c634920abaf9c0a93266a57beff6fce9d3852cb2 (patch) | |
tree | 5ac85f54905a8cd3b12b262c66189084cbff54fc /drivers/media/video/tda9887.c | |
parent | 6abd2c860e34add677de50e8b134f5af6f4b0893 (diff) | |
parent | a991f44b79fa49b281eb078eed4a76a42101012a (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb: (310 commits)
V4L/DVB (6316): Change list_for_each+list_entry to list_for_each_entry
V4L/DVB (6315): pvrusb2: Change list_for_each+list_entry to list_for_each_entry
V4L/DVB (6314): saa7134: Replace list_for_each+list_entry with list_for_each_entry
V4L/DVB (6313): ivtv: Replace list_for_each+list_entry with list_for_each_entry
V4L/DVB (6312): cx88: Replace list_for_each+list_entry with list_for_each_entry
V4L/DVB (6311): dvb: Replace list_for_each+list_entry with list_for_each_entry
V4L/DVB (6308): V4L: zc0301, remove bad usage of ERESTARTSYS
V4L/DVB (6307): V4L: w9968cf, remove bad usage of ERESTARTSYS
V4L/DVB (6306): Few clenups for saa7134 resume code
V4L/DVB (6305): V4L: videobuf-core.c avoid NULL dereferences in videobuf-core
V4L/DVB (6301): pvrusb: Update DEBUGIFC sysfs to kernel 2.6.13+
V4L/DVB (6300): CodingStyle cleanup
V4L/DVB (6299): dvb: Add dependencies for VIDEOBUF_DVB
V4L/DVB (6297): cx23885: remove wrong Kconfig selection of VIDEOBUF
V4L/DVB (6296): dib0700: add support for AverMedia DVB-T Express card
V4L/DVB (6295): saa7134: add autodetection for KWorld ATSC-115
V4L/DVB (6293): V4L: convert struct class_device to struct device
V4L/DVB (6292): videobuf_core init always require callback implementation
V4L/DVB (6291): Fix: avoid oops on some SMP machines
V4L/DVB (6290): remove videobuf_set_pci_ops
...
Diffstat (limited to 'drivers/media/video/tda9887.c')
-rw-r--r-- | drivers/media/video/tda9887.c | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index a8f773274fe3..be5387f11afb 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c | |||
@@ -1,14 +1,12 @@ | |||
1 | #include <linux/module.h> | 1 | #include <linux/module.h> |
2 | #include <linux/moduleparam.h> | ||
3 | #include <linux/kernel.h> | 2 | #include <linux/kernel.h> |
4 | #include <linux/i2c.h> | 3 | #include <linux/i2c.h> |
5 | #include <linux/types.h> | 4 | #include <linux/types.h> |
6 | #include <linux/videodev.h> | ||
7 | #include <linux/init.h> | 5 | #include <linux/init.h> |
8 | #include <linux/errno.h> | 6 | #include <linux/errno.h> |
9 | #include <linux/slab.h> | 7 | #include <linux/slab.h> |
10 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
11 | 9 | #include <linux/videodev.h> | |
12 | #include <media/v4l2-common.h> | 10 | #include <media/v4l2-common.h> |
13 | #include <media/tuner.h> | 11 | #include <media/tuner.h> |
14 | #include "tuner-driver.h" | 12 | #include "tuner-driver.h" |
@@ -31,6 +29,8 @@ | |||
31 | 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) |
32 | 30 | ||
33 | struct tda9887_priv { | 31 | struct tda9887_priv { |
32 | struct tuner_i2c_props i2c_props; | ||
33 | |||
34 | unsigned char data[4]; | 34 | unsigned char data[4]; |
35 | }; | 35 | }; |
36 | 36 | ||
@@ -97,6 +97,8 @@ struct tvnorm { | |||
97 | #define cAudioIF_6_5 0x03 // bit e0:1 | 97 | #define cAudioIF_6_5 0x03 // bit e0:1 |
98 | 98 | ||
99 | 99 | ||
100 | #define cVideoIFMask 0x1c // bit e2:4 | ||
101 | /* Video IF selection in TV Mode (bit B3=0) */ | ||
100 | #define cVideoIF_58_75 0x00 // bit e2:4 | 102 | #define cVideoIF_58_75 0x00 // bit e2:4 |
101 | #define cVideoIF_45_75 0x04 // bit e2:4 | 103 | #define cVideoIF_45_75 0x04 // bit e2:4 |
102 | #define cVideoIF_38_90 0x08 // bit e2:4 | 104 | #define cVideoIF_38_90 0x08 // bit e2:4 |
@@ -106,6 +108,13 @@ struct tvnorm { | |||
106 | #define cRadioIF_45_75 0x18 // bit e2:4 | 108 | #define cRadioIF_45_75 0x18 // bit e2:4 |
107 | #define cRadioIF_38_90 0x1C // bit e2:4 | 109 | #define cRadioIF_38_90 0x1C // bit e2:4 |
108 | 110 | ||
111 | /* IF1 selection in Radio Mode (bit B3=1) */ | ||
112 | #define cRadioIF_33_30 0x00 // bit e2,4 (also 0x10,0x14) | ||
113 | #define cRadioIF_41_30 0x04 // bit e2,4 | ||
114 | |||
115 | /* Output of AFC pin in radio mode when bit E7=1 */ | ||
116 | #define cRadioAGC_SIF 0x00 // bit e3 | ||
117 | #define cRadioAGC_FM 0x08 // bit e3 | ||
109 | 118 | ||
110 | #define cTunerGainNormal 0x00 // bit e5 | 119 | #define cTunerGainNormal 0x00 // bit e5 |
111 | #define cTunerGainLow 0x20 // bit e5 | 120 | #define cTunerGainLow 0x20 // bit e5 |
@@ -487,9 +496,13 @@ static int tda9887_set_config(struct tuner *t, char *buf) | |||
487 | if (t->tda9887_config & TDA9887_GATING_18) | 496 | if (t->tda9887_config & TDA9887_GATING_18) |
488 | buf[3] &= ~cGating_36; | 497 | buf[3] &= ~cGating_36; |
489 | 498 | ||
490 | if (t->tda9887_config & TDA9887_GAIN_NORMAL) { | 499 | if (t->mode == V4L2_TUNER_RADIO) { |
491 | radio_stereo.e &= ~cTunerGainLow; | 500 | if (t->tda9887_config & TDA9887_RIF_41_3) { |
492 | radio_mono.e &= ~cTunerGainLow; | 501 | buf[3] &= ~cVideoIFMask; |
502 | buf[3] |= cRadioIF_41_30; | ||
503 | } | ||
504 | if (t->tda9887_config & TDA9887_GAIN_NORMAL) | ||
505 | buf[3] &= ~cTunerGainLow; | ||
493 | } | 506 | } |
494 | 507 | ||
495 | return 0; | 508 | return 0; |
@@ -499,19 +512,19 @@ static int tda9887_set_config(struct tuner *t, char *buf) | |||
499 | 512 | ||
500 | static int tda9887_status(struct tuner *t) | 513 | static int tda9887_status(struct tuner *t) |
501 | { | 514 | { |
515 | struct tda9887_priv *priv = t->priv; | ||
502 | unsigned char buf[1]; | 516 | unsigned char buf[1]; |
503 | int rc; | 517 | int rc; |
504 | 518 | ||
505 | memset(buf,0,sizeof(buf)); | 519 | memset(buf,0,sizeof(buf)); |
506 | if (1 != (rc = i2c_master_recv(&t->i2c,buf,1))) | 520 | if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,buf,1))) |
507 | 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); |
508 | dump_read_message(t, buf); | 522 | dump_read_message(t, buf); |
509 | return 0; | 523 | return 0; |
510 | } | 524 | } |
511 | 525 | ||
512 | static void tda9887_configure(struct i2c_client *client) | 526 | static void tda9887_configure(struct tuner *t) |
513 | { | 527 | { |
514 | struct tuner *t = i2c_get_clientdata(client); | ||
515 | struct tda9887_priv *priv = t->priv; | 528 | struct tda9887_priv *priv = t->priv; |
516 | int rc; | 529 | int rc; |
517 | 530 | ||
@@ -546,7 +559,7 @@ static void tda9887_configure(struct i2c_client *client) | |||
546 | if (tuner_debug > 1) | 559 | if (tuner_debug > 1) |
547 | dump_write_message(t, priv->data); | 560 | dump_write_message(t, priv->data); |
548 | 561 | ||
549 | 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))) |
550 | 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); |
551 | 564 | ||
552 | if (tuner_debug > 2) { | 565 | if (tuner_debug > 2) { |
@@ -557,16 +570,15 @@ static void tda9887_configure(struct i2c_client *client) | |||
557 | 570 | ||
558 | /* ---------------------------------------------------------------------- */ | 571 | /* ---------------------------------------------------------------------- */ |
559 | 572 | ||
560 | static void tda9887_tuner_status(struct i2c_client *client) | 573 | static void tda9887_tuner_status(struct tuner *t) |
561 | { | 574 | { |
562 | struct tuner *t = i2c_get_clientdata(client); | ||
563 | struct tda9887_priv *priv = t->priv; | 575 | 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]); | 576 | tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]); |
565 | } | 577 | } |
566 | 578 | ||
567 | static int tda9887_get_afc(struct i2c_client *client) | 579 | static int tda9887_get_afc(struct tuner *t) |
568 | { | 580 | { |
569 | struct tuner *t = i2c_get_clientdata(client); | 581 | struct tda9887_priv *priv = t->priv; |
570 | static int AFC_BITS_2_kHz[] = { | 582 | static int AFC_BITS_2_kHz[] = { |
571 | -12500, -37500, -62500, -97500, | 583 | -12500, -37500, -62500, -97500, |
572 | -112500, -137500, -162500, -187500, | 584 | -112500, -137500, -162500, -187500, |
@@ -576,26 +588,24 @@ static int tda9887_get_afc(struct i2c_client *client) | |||
576 | int afc=0; | 588 | int afc=0; |
577 | __u8 reg = 0; | 589 | __u8 reg = 0; |
578 | 590 | ||
579 | if (1 == i2c_master_recv(&t->i2c,®,1)) | 591 | if (1 == tuner_i2c_xfer_recv(&priv->i2c_props,®,1)) |
580 | afc = AFC_BITS_2_kHz[(reg>>1)&0x0f]; | 592 | afc = AFC_BITS_2_kHz[(reg>>1)&0x0f]; |
581 | 593 | ||
582 | return afc; | 594 | return afc; |
583 | } | 595 | } |
584 | 596 | ||
585 | static void tda9887_standby(struct i2c_client *client) | 597 | static void tda9887_standby(struct tuner *t) |
586 | { | 598 | { |
587 | tda9887_configure(client); | 599 | tda9887_configure(t); |
588 | } | 600 | } |
589 | 601 | ||
590 | static void tda9887_set_freq(struct i2c_client *client, unsigned int freq) | 602 | static void tda9887_set_freq(struct tuner *t, unsigned int freq) |
591 | { | 603 | { |
592 | tda9887_configure(client); | 604 | tda9887_configure(t); |
593 | } | 605 | } |
594 | 606 | ||
595 | static void tda9887_release(struct i2c_client *c) | 607 | static void tda9887_release(struct tuner *t) |
596 | { | 608 | { |
597 | struct tuner *t = i2c_get_clientdata(c); | ||
598 | |||
599 | kfree(t->priv); | 609 | kfree(t->priv); |
600 | t->priv = NULL; | 610 | t->priv = NULL; |
601 | } | 611 | } |
@@ -609,17 +619,19 @@ static struct tuner_operations tda9887_tuner_ops = { | |||
609 | .release = tda9887_release, | 619 | .release = tda9887_release, |
610 | }; | 620 | }; |
611 | 621 | ||
612 | int tda9887_tuner_init(struct i2c_client *c) | 622 | int tda9887_tuner_init(struct tuner *t) |
613 | { | 623 | { |
614 | struct tda9887_priv *priv = NULL; | 624 | struct tda9887_priv *priv = NULL; |
615 | struct tuner *t = i2c_get_clientdata(c); | ||
616 | 625 | ||
617 | priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL); | 626 | priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL); |
618 | if (priv == NULL) | 627 | if (priv == NULL) |
619 | return -ENOMEM; | 628 | return -ENOMEM; |
620 | t->priv = priv; | 629 | t->priv = priv; |
621 | 630 | ||
622 | 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)); | ||
623 | 635 | ||
624 | 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, |
625 | t->i2c.driver->driver.name); | 637 | t->i2c.driver->driver.name); |