summaryrefslogtreecommitdiff
path: root/drivers/media/video/tea5761.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-08-21 01:24:42 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 22:07:34 -0300
commitdb8a695658cda21eacfa2a5e3b15e8964bfb93ef (patch)
treeac69f32af5b52f78ad65ad1125d330aa19c7bdda /drivers/media/video/tea5761.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/tea5761.c')
-rw-r--r--drivers/media/video/tea5761.c55
1 files changed, 36 insertions, 19 deletions
diff --git a/drivers/media/video/tea5761.c b/drivers/media/video/tea5761.c
index 43bdc374927e..9965ba48cffa 100644
--- a/drivers/media/video/tea5761.c
+++ b/drivers/media/video/tea5761.c
@@ -18,6 +18,10 @@
/* from tuner-core.c */
extern int tuner_debug;
+struct tea5761_priv {
+ struct tuner_i2c_props i2c_props;
+};
+
/*****************************************************************************/
/***************************
@@ -114,10 +118,8 @@ extern int tuner_debug;
/*****************************************************************************/
-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");
}
@@ -135,9 +137,9 @@ static void tea5761_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 tea5761_priv *priv = t->priv;
unsigned char buffer[7] = {0, 0, 0, 0, 0, 0, 0 };
unsigned div;
int rc;
@@ -167,31 +169,31 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
if (tuner_debug)
tea5761_status_dump(buffer);
- if (7 != (rc = i2c_master_send(c, buffer, 7)))
+ if (7 != (rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 7)))
tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
}
-static int tea5761_signal(struct i2c_client *c)
+static int tea5761_signal(struct tuner *t)
{
unsigned char buffer[16];
int rc;
- struct tuner *t = i2c_get_clientdata(c);
+ struct tea5761_priv *priv = t->priv;
memset(buffer, 0, sizeof(buffer));
- if (16 != (rc = i2c_master_recv(c, buffer, 16)))
+ if (16 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buffer, 16)))
tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
return ((buffer[9] & TEA5761_TUNCHECK_LEV_MASK) << (13 - 4));
}
-static int tea5761_stereo(struct i2c_client *c)
+static int tea5761_stereo(struct tuner *t)
{
unsigned char buffer[16];
int rc;
- struct tuner *t = i2c_get_clientdata(c);
+ struct tea5761_priv *priv = t->priv;
memset(buffer, 0, sizeof(buffer));
- if (16 != (rc = i2c_master_recv(c, buffer, 16)))
+ if (16 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buffer, 16)))
tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
rc = buffer[9] & TEA5761_TUNCHECK_STEREO;
@@ -201,13 +203,13 @@ static int tea5761_stereo(struct i2c_client *c)
return (rc ? V4L2_TUNER_SUB_STEREO : 0);
}
-int tea5761_autodetection(struct i2c_client *c)
+int tea5761_autodetection(struct tuner *t)
{
unsigned char buffer[16];
int rc;
- struct tuner *t = i2c_get_clientdata(c);
+ struct tuner_i2c_props i2c = { .adap = t->i2c.adapter, .addr = t->i2c.addr };
- if (16 != (rc = i2c_master_recv(c, buffer, 16))) {
+ if (16 != (rc = tuner_i2c_xfer_recv(&i2c, buffer, 16))) {
tuner_warn("it is not a TEA5761. Received %i chars.\n", rc);
return EINVAL;
}
@@ -220,22 +222,37 @@ int tea5761_autodetection(struct i2c_client *c)
return 0;
}
+static void tea5761_release(struct tuner *t)
+{
+ kfree(t->priv);
+ t->priv = NULL;
+}
+
static struct tuner_operations tea5761_tuner_ops = {
.set_tv_freq = set_tv_freq,
.set_radio_freq = set_radio_freq,
.has_signal = tea5761_signal,
.is_stereo = tea5761_stereo,
+ .release = tea5761_release,
};
-int tea5761_tuner_init(struct i2c_client *c)
+int tea5761_tuner_init(struct tuner *t)
{
- struct tuner *t = i2c_get_clientdata(c);
+ struct tea5761_priv *priv = NULL;
- if (tea5761_autodetection(c) == EINVAL)
+ if (tea5761_autodetection(t) == EINVAL)
return EINVAL;
+ priv = kzalloc(sizeof(struct tea5761_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 TEA5761HN FM Radio");
- strlcpy(c->name, "tea5761", sizeof(c->name));
+ strlcpy(t->i2c.name, "tea5761", sizeof(t->i2c.name));
memcpy(&t->ops, &tea5761_tuner_ops, sizeof(struct tuner_operations));