Skip to content

Commit

Permalink
V4L/DVB (6127): tuner: kill i2c_client interface to tuner sub-drivers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Krufky authored and Mauro Carvalho Chehab committed Oct 10, 2007
1 parent 293197c commit db8a695
Show file tree
Hide file tree
Showing 9 changed files with 430 additions and 329 deletions.
138 changes: 66 additions & 72 deletions drivers/media/video/mt20xx.c

Large diffs are not rendered by default.

247 changes: 124 additions & 123 deletions drivers/media/video/tda8290.c

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions drivers/media/video/tda9887.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)

struct tda9887_priv {
struct tuner_i2c_props i2c_props;

unsigned char data[4];
};

Expand Down Expand Up @@ -510,19 +512,19 @@ static int tda9887_set_config(struct tuner *t, char *buf)

static int tda9887_status(struct tuner *t)
{
struct tda9887_priv *priv = t->priv;
unsigned char buf[1];
int rc;

memset(buf,0,sizeof(buf));
if (1 != (rc = i2c_master_recv(&t->i2c,buf,1)))
if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,buf,1)))
tda9887_info("i2c i/o error: rc == %d (should be 1)\n",rc);
dump_read_message(t, buf);
return 0;
}

static void tda9887_configure(struct i2c_client *client)
static void tda9887_configure(struct tuner *t)
{
struct tuner *t = i2c_get_clientdata(client);
struct tda9887_priv *priv = t->priv;
int rc;

Expand Down Expand Up @@ -557,7 +559,7 @@ static void tda9887_configure(struct i2c_client *client)
if (tuner_debug > 1)
dump_write_message(t, priv->data);

if (4 != (rc = i2c_master_send(&t->i2c,priv->data,4)))
if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,priv->data,4)))
tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc);

if (tuner_debug > 2) {
Expand All @@ -568,16 +570,15 @@ static void tda9887_configure(struct i2c_client *client)

/* ---------------------------------------------------------------------- */

static void tda9887_tuner_status(struct i2c_client *client)
static void tda9887_tuner_status(struct tuner *t)
{
struct tuner *t = i2c_get_clientdata(client);
struct tda9887_priv *priv = t->priv;
tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]);
}

static int tda9887_get_afc(struct i2c_client *client)
static int tda9887_get_afc(struct tuner *t)
{
struct tuner *t = i2c_get_clientdata(client);
struct tda9887_priv *priv = t->priv;
static int AFC_BITS_2_kHz[] = {
-12500, -37500, -62500, -97500,
-112500, -137500, -162500, -187500,
Expand All @@ -587,26 +588,24 @@ static int tda9887_get_afc(struct i2c_client *client)
int afc=0;
__u8 reg = 0;

if (1 == i2c_master_recv(&t->i2c,&reg,1))
if (1 == tuner_i2c_xfer_recv(&priv->i2c_props,&reg,1))
afc = AFC_BITS_2_kHz[(reg>>1)&0x0f];

return afc;
}

static void tda9887_standby(struct i2c_client *client)
static void tda9887_standby(struct tuner *t)
{
tda9887_configure(client);
tda9887_configure(t);
}

static void tda9887_set_freq(struct i2c_client *client, unsigned int freq)
static void tda9887_set_freq(struct tuner *t, unsigned int freq)
{
tda9887_configure(client);
tda9887_configure(t);
}

static void tda9887_release(struct i2c_client *c)
static void tda9887_release(struct tuner *t)
{
struct tuner *t = i2c_get_clientdata(c);

kfree(t->priv);
t->priv = NULL;
}
Expand All @@ -620,17 +619,19 @@ static struct tuner_operations tda9887_tuner_ops = {
.release = tda9887_release,
};

int tda9887_tuner_init(struct i2c_client *c)
int tda9887_tuner_init(struct tuner *t)
{
struct tda9887_priv *priv = NULL;
struct tuner *t = i2c_get_clientdata(c);

priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL);
if (priv == NULL)
return -ENOMEM;
t->priv = priv;

strlcpy(c->name, "tda9887", sizeof(c->name));
priv->i2c_props.addr = t->i2c.addr;
priv->i2c_props.adap = t->i2c.adapter;

strlcpy(t->i2c.name, "tda9887", sizeof(t->i2c.name));

tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr,
t->i2c.driver->driver.name);
Expand Down
55 changes: 36 additions & 19 deletions drivers/media/video/tea5761.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
/* from tuner-core.c */
extern int tuner_debug;

struct tea5761_priv {
struct tuner_i2c_props i2c_props;
};

/*****************************************************************************/

/***************************
Expand Down Expand Up @@ -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");
}

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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));

Expand Down
Loading

0 comments on commit db8a695

Please sign in to comment.