summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/tea5767.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-08-21 00:24:42 -0400
committerMichael Krufky <mkrufky@linuxtv.org>2007-08-21 00:24:42 -0400
commit23de3b791533b6d38067b9328473dffcc7b8ba9a (patch)
treefb176e55ae33795971523aa485294817d3697d78 /linux/drivers/media/video/tea5767.c
parentc6db53bfd18521449f940b904dfb79e36ed81b59 (diff)
downloadmediapointer-dvb-s2-23de3b791533b6d38067b9328473dffcc7b8ba9a.tar.gz
mediapointer-dvb-s2-23de3b791533b6d38067b9328473dffcc7b8ba9a.tar.bz2
tuner: kill i2c_client interface to tuner sub-drivers
From: Michael Krufky <mkrufky@linuxtv.org> 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>
Diffstat (limited to 'linux/drivers/media/video/tea5767.c')
-rw-r--r--linux/drivers/media/video/tea5767.c65
1 files changed, 41 insertions, 24 deletions
diff --git a/linux/drivers/media/video/tea5767.c b/linux/drivers/media/video/tea5767.c
index 145b0716e..74f75b90f 100644
--- a/linux/drivers/media/video/tea5767.c
+++ b/linux/drivers/media/video/tea5767.c
@@ -24,6 +24,10 @@
/* from tuner-core.c */
extern int tuner_debug;
+struct tea5767_priv {
+ struct tuner_i2c_props i2c_props;
+};
+
/*****************************************************************************/
/******************************
@@ -133,10 +137,8 @@ enum tea5767_xtal_freq {
/*****************************************************************************/
-static void set_tv_freq(struct i2c_client *c, unsigned int freq)
+static void set_tv_freq(struct tuner *t, unsigned int freq)
{
- struct tuner *t = i2c_get_clientdata(c);
-
tuner_warn("This tuner doesn't support TV freq.\n");
}
@@ -194,9 +196,9 @@ static void tea5767_status_dump(unsigned char *buffer)
}
/* Freq should be specifyed at 62.5 Hz */
-static void set_radio_freq(struct i2c_client *c, unsigned int frq)
+static void set_radio_freq(struct tuner *t, unsigned int frq)
{
- struct tuner *t = i2c_get_clientdata(c);
+ struct tea5767_priv *priv = t->priv;
unsigned char buffer[5];
unsigned div;
int rc;
@@ -250,38 +252,38 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
buffer[0] = (div >> 8) & 0x3f;
buffer[1] = div & 0xff;
- if (5 != (rc = i2c_master_send(c, buffer, 5)))
+ if (5 != (rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 5)))
tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
if (tuner_debug) {
- if (5 != (rc = i2c_master_recv(c, buffer, 5)))
+ if (5 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buffer, 5)))
tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
else
tea5767_status_dump(buffer);
}
}
-static int tea5767_signal(struct i2c_client *c)
+static int tea5767_signal(struct tuner *t)
{
unsigned char buffer[5];
int rc;
- struct tuner *t = i2c_get_clientdata(c);
+ struct tea5767_priv *priv = t->priv;
memset(buffer, 0, sizeof(buffer));
- if (5 != (rc = i2c_master_recv(c, buffer, 5)))
+ if (5 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buffer, 5)))
tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
return ((buffer[3] & TEA5767_ADC_LEVEL_MASK) << 8);
}
-static int tea5767_stereo(struct i2c_client *c)
+static int tea5767_stereo(struct tuner *t)
{
unsigned char buffer[5];
int rc;
- struct tuner *t = i2c_get_clientdata(c);
+ struct tea5767_priv *priv = t->priv;
memset(buffer, 0, sizeof(buffer));
- if (5 != (rc = i2c_master_recv(c, buffer, 5)))
+ if (5 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buffer, 5)))
tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
rc = buffer[2] & TEA5767_STEREO_MASK;
@@ -291,10 +293,10 @@ static int tea5767_stereo(struct i2c_client *c)
return ((buffer[2] & TEA5767_STEREO_MASK) ? V4L2_TUNER_SUB_STEREO : 0);
}
-static void tea5767_standby(struct i2c_client *c)
+static void tea5767_standby(struct tuner *t)
{
unsigned char buffer[5];
- struct tuner *t = i2c_get_clientdata(c);
+ struct tea5767_priv *priv = t->priv;
unsigned div, rc;
div = (87500 * 4 + 700 + 225 + 25) / 50; /* Set frequency to 87.5 MHz */
@@ -305,20 +307,20 @@ static void tea5767_standby(struct i2c_client *c)
TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND | TEA5767_STDBY;
buffer[4] = 0;
- if (5 != (rc = i2c_master_send(c, buffer, 5)))
+ if (5 != (rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 5)))
tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
}
-int tea5767_autodetection(struct i2c_client *c)
+int tea5767_autodetection(struct tuner *t)
{
+ struct tuner_i2c_props i2c = { .adap = t->i2c.adapter, .addr = t->i2c.addr };
unsigned char buffer[7] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
int rc;
- struct tuner *t = i2c_get_clientdata(c);
#if 0 /* Needed if uncomment I2C send code below */
int div;
#endif
- if ((rc = i2c_master_recv(c, buffer, 7))< 5) {
+ if ((rc = tuner_i2c_xfer_send(&i2c, buffer, 7))< 5) {
tuner_warn("It is not a TEA5767. Received %i bytes.\n", rc);
return EINVAL;
}
@@ -356,12 +358,12 @@ int tea5767_autodetection(struct i2c_client *c)
TEA5767_ST_NOISE_CTL;
buffer[4] = 0;
- if (5 != (rc = i2c_master_send(c, buffer, 5)))
+ if (5 != (rc = tuner_i2c_xfer_send(&i2c, buffer, 5)))
tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
msleep(15);
- if (5 != (rc = i2c_master_recv(c, buffer, 5))) {
+ if (5 != (rc = tuner_i2c_xfer_recv(&i2c, buffer, 5))) {
tuner_warn("It is not a TEA5767. Received %i bytes.\n", rc);
return EINVAL;
}
@@ -378,24 +380,39 @@ int tea5767_autodetection(struct i2c_client *c)
return 0;
}
+static void tea5767_release(struct tuner *t)
+{
+ kfree(t->priv);
+ t->priv = NULL;
+}
+
static struct tuner_operations tea5767_tuner_ops = {
.set_tv_freq = set_tv_freq,
.set_radio_freq = set_radio_freq,
.has_signal = tea5767_signal,
.is_stereo = tea5767_stereo,
.standby = tea5767_standby,
+ .release = tea5767_release,
};
-int tea5767_tuner_init(struct i2c_client *c)
+int tea5767_tuner_init(struct tuner *t)
{
- struct tuner *t = i2c_get_clientdata(c);
+ struct tea5767_priv *priv = NULL;
#if 0 /* By removing autodetection allows forcing TEA chip */
if (tea5767_autodetection(c) == EINVAL)
return EINVAL;
#endif
+ priv = kzalloc(sizeof(struct tea5767_priv), GFP_KERNEL);
+ if (priv == NULL)
+ return -ENOMEM;
+ t->priv = priv;
+
+ priv->i2c_props.addr = t->i2c.addr;
+ priv->i2c_props.adap = t->i2c.adapter;
+
tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5767HN FM Radio");
- strlcpy(c->name, "tea5767", sizeof(c->name));
+ strlcpy(t->i2c.name, "tea5767", sizeof(t->i2c.name));
memcpy(&t->ops, &tea5767_tuner_ops, sizeof(struct tuner_operations));