Commit db8a6956 authored by Michael Krufky's avatar Michael Krufky Committed by Mauro Carvalho Chehab

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: default avatarMichael Krufky <mkrufky@linuxtv.org>
Acked-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Acked-by: default avatarMike Isely <isely@pobox.com>
Acked-by: default avatarSteven Toth <stoth@hauppauge.com>
Acked-by: default avatarPatrick Boettcher <pb@linuxtv.org>
Acked-by: default avatarJarod Wilson <jwilson@redhat.com>
Acked-by: default avatarTrent Piepho <xyzzy@speakeasy.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 293197cd
This diff is collapsed.
This diff is collapsed.
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)
struct tda9887_priv { struct tda9887_priv {
struct tuner_i2c_props i2c_props;
unsigned char data[4]; unsigned char data[4];
}; };
...@@ -510,19 +512,19 @@ static int tda9887_set_config(struct tuner *t, char *buf) ...@@ -510,19 +512,19 @@ static int tda9887_set_config(struct tuner *t, char *buf)
static int tda9887_status(struct tuner *t) static int tda9887_status(struct tuner *t)
{ {
struct tda9887_priv *priv = t->priv;
unsigned char buf[1]; unsigned char buf[1];
int rc; int rc;
memset(buf,0,sizeof(buf)); 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); tda9887_info("i2c i/o error: rc == %d (should be 1)\n",rc);
dump_read_message(t, buf); dump_read_message(t, buf);
return 0; 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; struct tda9887_priv *priv = t->priv;
int rc; int rc;
...@@ -557,7 +559,7 @@ static void tda9887_configure(struct i2c_client *client) ...@@ -557,7 +559,7 @@ static void tda9887_configure(struct i2c_client *client)
if (tuner_debug > 1) if (tuner_debug > 1)
dump_write_message(t, priv->data); 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); tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc);
if (tuner_debug > 2) { if (tuner_debug > 2) {
...@@ -568,16 +570,15 @@ static void tda9887_configure(struct i2c_client *client) ...@@ -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; 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]); 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[] = { static int AFC_BITS_2_kHz[] = {
-12500, -37500, -62500, -97500, -12500, -37500, -62500, -97500,
-112500, -137500, -162500, -187500, -112500, -137500, -162500, -187500,
...@@ -587,26 +588,24 @@ static int tda9887_get_afc(struct i2c_client *client) ...@@ -587,26 +588,24 @@ static int tda9887_get_afc(struct i2c_client *client)
int afc=0; int afc=0;
__u8 reg = 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]; afc = AFC_BITS_2_kHz[(reg>>1)&0x0f];
return afc; 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); kfree(t->priv);
t->priv = NULL; t->priv = NULL;
} }
...@@ -620,17 +619,19 @@ static struct tuner_operations tda9887_tuner_ops = { ...@@ -620,17 +619,19 @@ static struct tuner_operations tda9887_tuner_ops = {
.release = tda9887_release, .release = tda9887_release,
}; };
int tda9887_tuner_init(struct i2c_client *c) int tda9887_tuner_init(struct tuner *t)
{ {
struct tda9887_priv *priv = NULL; struct tda9887_priv *priv = NULL;
struct tuner *t = i2c_get_clientdata(c);
priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL); priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL);
if (priv == NULL) if (priv == NULL)
return -ENOMEM; return -ENOMEM;
t->priv = priv; 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, tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr,
t->i2c.driver->driver.name); t->i2c.driver->driver.name);
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
/* from tuner-core.c */ /* from tuner-core.c */
extern int tuner_debug; extern int tuner_debug;
struct tea5761_priv {
struct tuner_i2c_props i2c_props;
};
/*****************************************************************************/ /*****************************************************************************/
/*************************** /***************************
...@@ -114,10 +118,8 @@ extern int tuner_debug; ...@@ -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"); tuner_warn("This tuner doesn't support TV freq.\n");
} }
...@@ -135,9 +137,9 @@ static void tea5761_status_dump(unsigned char *buffer) ...@@ -135,9 +137,9 @@ static void tea5761_status_dump(unsigned char *buffer)
} }
/* Freq should be specifyed at 62.5 Hz */ /* 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 char buffer[7] = {0, 0, 0, 0, 0, 0, 0 };
unsigned div; unsigned div;
int rc; int rc;
...@@ -167,31 +169,31 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) ...@@ -167,31 +169,31 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
if (tuner_debug) if (tuner_debug)
tea5761_status_dump(buffer); 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); 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]; unsigned char buffer[16];
int rc; int rc;
struct tuner *t = i2c_get_clientdata(c); struct tea5761_priv *priv = t->priv;
memset(buffer, 0, sizeof(buffer)); 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); tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
return ((buffer[9] & TEA5761_TUNCHECK_LEV_MASK) << (13 - 4)); 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]; unsigned char buffer[16];
int rc; int rc;
struct tuner *t = i2c_get_clientdata(c); struct tea5761_priv *priv = t->priv;
memset(buffer, 0, sizeof(buffer)); 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); tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
rc = buffer[9] & TEA5761_TUNCHECK_STEREO; rc = buffer[9] & TEA5761_TUNCHECK_STEREO;
...@@ -201,13 +203,13 @@ static int tea5761_stereo(struct i2c_client *c) ...@@ -201,13 +203,13 @@ static int tea5761_stereo(struct i2c_client *c)
return (rc ? V4L2_TUNER_SUB_STEREO : 0); return (rc ? V4L2_TUNER_SUB_STEREO : 0);
} }
int tea5761_autodetection(struct i2c_client *c) int tea5761_autodetection(struct tuner *t)
{ {
unsigned char buffer[16]; unsigned char buffer[16];
int rc; 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); tuner_warn("it is not a TEA5761. Received %i chars.\n", rc);
return EINVAL; return EINVAL;
} }
...@@ -220,22 +222,37 @@ int tea5761_autodetection(struct i2c_client *c) ...@@ -220,22 +222,37 @@ int tea5761_autodetection(struct i2c_client *c)
return 0; return 0;
} }
static void tea5761_release(struct tuner *t)
{
kfree(t->priv);
t->priv = NULL;
}
static struct tuner_operations tea5761_tuner_ops = { static struct tuner_operations tea5761_tuner_ops = {
.set_tv_freq = set_tv_freq, .set_tv_freq = set_tv_freq,
.set_radio_freq = set_radio_freq, .set_radio_freq = set_radio_freq,
.has_signal = tea5761_signal, .has_signal = tea5761_signal,
.is_stereo = tea5761_stereo, .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; 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"); 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)); memcpy(&t->ops, &tea5761_tuner_ops, sizeof(struct tuner_operations));
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
/* from tuner-core.c */ /* from tuner-core.c */
extern int tuner_debug; extern int tuner_debug;
struct tea5767_priv {
struct tuner_i2c_props i2c_props;
};
/*****************************************************************************/ /*****************************************************************************/
/****************************** /******************************
...@@ -129,10 +133,8 @@ enum tea5767_xtal_freq { ...@@ -129,10 +133,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"); tuner_warn("This tuner doesn't support TV freq.\n");
} }
...@@ -190,9 +192,9 @@ static void tea5767_status_dump(unsigned char *buffer) ...@@ -190,9 +192,9 @@ static void tea5767_status_dump(unsigned char *buffer)
} }
/* Freq should be specifyed at 62.5 Hz */ /* 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 char buffer[5];
unsigned div; unsigned div;
int rc; int rc;
...@@ -246,38 +248,38 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) ...@@ -246,38 +248,38 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
buffer[0] = (div >> 8) & 0x3f; buffer[0] = (div >> 8) & 0x3f;
buffer[1] = div & 0xff; 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); tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
if (tuner_debug) { 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); tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
else else
tea5767_status_dump(buffer); tea5767_status_dump(buffer);
} }
} }
static int tea5767_signal(struct i2c_client *c) static int tea5767_signal(struct tuner *t)
{ {
unsigned char buffer[5]; unsigned char buffer[5];
int rc; int rc;
struct tuner *t = i2c_get_clientdata(c); struct tea5767_priv *priv = t->priv;
memset(buffer, 0, sizeof(buffer)); 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); tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
return ((buffer[3] & TEA5767_ADC_LEVEL_MASK) << 8); 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]; unsigned char buffer[5];
int rc; int rc;
struct tuner *t = i2c_get_clientdata(c); struct tea5767_priv *priv = t->priv;
memset(buffer, 0, sizeof(buffer)); 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); tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
rc = buffer[2] & TEA5767_STEREO_MASK; rc = buffer[2] & TEA5767_STEREO_MASK;
...@@ -287,10 +289,10 @@ static int tea5767_stereo(struct i2c_client *c) ...@@ -287,10 +289,10 @@ static int tea5767_stereo(struct i2c_client *c)
return ((buffer[2] & TEA5767_STEREO_MASK) ? V4L2_TUNER_SUB_STEREO : 0); 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]; unsigned char buffer[5];
struct tuner *t = i2c_get_clientdata(c); struct tea5767_priv *priv = t->priv;
unsigned div, rc; unsigned div, rc;
div = (87500 * 4 + 700 + 225 + 25) / 50; /* Set frequency to 87.5 MHz */ div = (87500 * 4 + 700 + 225 + 25) / 50; /* Set frequency to 87.5 MHz */
...@@ -301,17 +303,17 @@ static void tea5767_standby(struct i2c_client *c) ...@@ -301,17 +303,17 @@ static void tea5767_standby(struct i2c_client *c)
TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND | TEA5767_STDBY; TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND | TEA5767_STDBY;
buffer[4] = 0; 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); 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 }; unsigned char buffer[7] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
int rc; int rc;
struct tuner *t = i2c_get_clientdata(c);
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); tuner_warn("It is not a TEA5767. Received %i bytes.\n", rc);
return EINVAL; return EINVAL;
} }
...@@ -343,20 +345,35 @@ int tea5767_autodetection(struct i2c_client *c) ...@@ -343,20 +345,35 @@ int tea5767_autodetection(struct i2c_client *c)
return 0; return 0;
} }
static void tea5767_release(struct tuner *t)
{
kfree(t->priv);
t->priv = NULL;
}
static struct tuner_operations tea5767_tuner_ops = { static struct tuner_operations tea5767_tuner_ops = {
.set_tv_freq = set_tv_freq, .set_tv_freq = set_tv_freq,
.set_radio_freq = set_radio_freq, .set_radio_freq = set_radio_freq,
.has_signal = tea5767_signal, .has_signal = tea5767_signal,
.is_stereo = tea5767_stereo, .is_stereo = tea5767_stereo,
.standby = tea5767_standby, .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;
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"); 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)); memcpy(&t->ops, &tea5767_tuner_ops, sizeof(struct tuner_operations));
......
...@@ -94,7 +94,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) ...@@ -94,7 +94,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
else else
freq = tv_range[1] * 16; freq = tv_range[1] * 16;
} }
t->ops.set_tv_freq(c, freq); t->ops.set_tv_freq(t, freq);
} }
static void set_radio_freq(struct i2c_client *c, unsigned int freq) static void set_radio_freq(struct i2c_client *c, unsigned int freq)
...@@ -121,7 +121,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) ...@@ -121,7 +121,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
freq = radio_range[1] * 16000; freq = radio_range[1] * 16000;
} }
t->ops.set_radio_freq(c, freq); t->ops.set_radio_freq(t, freq);
} }
static void set_freq(struct i2c_client *c, unsigned long freq) static void set_freq(struct i2c_client *c, unsigned long freq)
...@@ -199,7 +199,7 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -199,7 +199,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
/* discard private data, in case set_type() was previously called */ /* discard private data, in case set_type() was previously called */
if (t->ops.release) if (t->ops.release)
t->ops.release(c); t->ops.release(t);
else { else {
kfree(t->priv); kfree(t->priv);
t->priv = NULL; t->priv = NULL;
...@@ -207,13 +207,13 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -207,13 +207,13 @@ static void set_type(struct i2c_client *c, unsigned int type,
switch (t->type) { switch (t->type) {
case TUNER_MT2032: case TUNER_MT2032:
microtune_init(c); microtune_init(t);
break; break;
case TUNER_PHILIPS_TDA8290: case TUNER_PHILIPS_TDA8290:
tda8290_init(c); tda8290_init(t);
break; break;
case TUNER_TEA5767: case TUNER_TEA5767:
if (tea5767_tuner_init(c) == EINVAL) { if (tea5767_tuner_init(t) == EINVAL) {
t->type = TUNER_ABSENT; t->type = TUNER_ABSENT;
t->mode_mask = T_UNINITIALIZED; t->mode_mask = T_UNINITIALIZED;
return; return;
...@@ -222,7 +222,7 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -222,7 +222,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
break; break;
#ifdef CONFIG_TUNER_TEA5761 #ifdef CONFIG_TUNER_TEA5761
case TUNER_TEA5761: case TUNER_TEA5761:
if (tea5761_tuner_init(c) == EINVAL) { if (tea5761_tuner_init(t) == EINVAL) {
t->type = TUNER_ABSENT; t->type = TUNER_ABSENT;
t->mode_mask = T_UNINITIALIZED; t->mode_mask = T_UNINITIALIZED;
return; return;
...@@ -240,7 +240,7 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -240,7 +240,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
buffer[2] = 0x86; buffer[2] = 0x86;
buffer[3] = 0x54; buffer[3] = 0x54;
i2c_master_send(c, buffer, 4); i2c_master_send(c, buffer, 4);
default_tuner_init(c); default_tuner_init(t);
break; break;
case TUNER_PHILIPS_TD1316: case TUNER_PHILIPS_TD1316:
buffer[0] = 0x0b; buffer[0] = 0x0b;
...@@ -248,13 +248,13 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -248,13 +248,13 @@ static void set_type(struct i2c_client *c, unsigned int type,
buffer[2] = 0x86; buffer[2] = 0x86;
buffer[3] = 0xa4; buffer[3] = 0xa4;
i2c_master_send(c,buffer,4); i2c_master_send(c,buffer,4);
default_tuner_init(c); default_tuner_init(t);
break; break;
case TUNER_TDA9887: case TUNER_TDA9887:
tda9887_tuner_init(c); tda9887_tuner_init(t);
break; break;
default: default:
default_tuner_init(c); default_tuner_init(t);
break; break;
} }
...@@ -426,9 +426,8 @@ static int tuner_fixup_std(struct tuner *t) ...@@ -426,9 +426,8 @@ static int tuner_fixup_std(struct tuner *t)
return 0; return 0;
} }
static void tuner_status(struct i2c_client *client) static void tuner_status(struct tuner *t)
{ {
struct tuner *t = i2c_get_clientdata(client);
unsigned long freq, freq_fraction; unsigned long freq, freq_fraction;
const char *p; const char *p;
...@@ -451,10 +450,10 @@ static void tuner_status(struct i2c_client *client) ...@@ -451,10 +450,10 @@ static void tuner_status(struct i2c_client *client)
if (t->mode != V4L2_TUNER_RADIO) if (t->mode != V4L2_TUNER_RADIO)
return; return;
if (t->ops.has_signal) { if (t->ops.has_signal) {
tuner_info("Signal strength: %d\n", t->ops.has_signal(client)); tuner_info("Signal strength: %d\n", t->ops.has_signal(t));
} }
if (t->ops.is_stereo) { if (t->ops.is_stereo) {
tuner_info("Stereo: %s\n", t->ops.is_stereo(client) ? "yes" : "no"); tuner_info("Stereo: %s\n", t->ops.is_stereo(t) ? "yes" : "no");
} }
} }
...@@ -503,7 +502,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -503,7 +502,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
switch (addr) { switch (addr) {
#ifdef CONFIG_TUNER_TEA5761 #ifdef CONFIG_TUNER_TEA5761
case 0x10: case 0x10:
if (tea5761_autodetection(&t->i2c) != EINVAL) { if (tea5761_autodetection(t) != EINVAL) {
t->type = TUNER_TEA5761; t->type = TUNER_TEA5761;
t->mode_mask = T_RADIO; t->mode_mask = T_RADIO;
t->mode = T_STANDBY; t->mode = T_STANDBY;
...@@ -520,7 +519,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -520,7 +519,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
case 0x4b: case 0x4b:
/* If chip is not tda8290, don't register. /* If chip is not tda8290, don't register.
since it can be tda9887*/ since it can be tda9887*/
if (tda8290_probe(&t->i2c) == 0) { if (tda8290_probe(t) == 0) {
tuner_dbg("chip at addr %x is a tda8290\n", addr); tuner_dbg("chip at addr %x is a tda8290\n", addr);
} else { } else {
/* Default is being tda9887 */ /* Default is being tda9887 */
...@@ -531,7 +530,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -531,7 +530,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
} }
break; break;
case 0x60: case 0x60:
if (tea5767_autodetection(&t->i2c) != EINVAL) { if (tea5767_autodetection(t) != EINVAL) {
t->type = TUNER_TEA5767; t->type = TUNER_TEA5767;
t->mode_mask = T_RADIO; t->mode_mask = T_RADIO;
t->mode = T_STANDBY; t->mode = T_STANDBY;
...@@ -588,7 +587,7 @@ static int tuner_detach(struct i2c_client *client) ...@@ -588,7 +587,7 @@ static int tuner_detach(struct i2c_client *client)
} }
if (t->ops.release) if (t->ops.release)
t->ops.release(client); t->ops.release(t);
else { else {
kfree(t->priv); kfree(t->priv);
} }
...@@ -613,7 +612,7 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, ...@@ -613,7 +612,7 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode,
if (check_mode(t, cmd) == EINVAL) { if (check_mode(t, cmd) == EINVAL) {
t->mode = T_STANDBY; t->mode = T_STANDBY;
if (t->ops.standby) if (t->ops.standby)
t->ops.standby (client); t->ops.standby(t);
return EINVAL; return EINVAL;
} }
return 0; return 0;
...@@ -662,7 +661,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -662,7 +661,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
return 0; return 0;
t->mode = T_STANDBY; t->mode = T_STANDBY;
if (t->ops.standby) if (t->ops.standby)
t->ops.standby (client); t->ops.standby(t);
break; break;
#ifdef CONFIG_VIDEO_V4L1 #ifdef CONFIG_VIDEO_V4L1
case VIDIOCSAUDIO: case VIDIOCSAUDIO:
...@@ -722,9 +721,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -722,9 +721,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
if (V4L2_TUNER_RADIO == t->mode) { if (V4L2_TUNER_RADIO == t->mode) {
if (t->ops.has_signal) if (t->ops.has_signal)
vt->signal = t->ops.has_signal(client); vt->signal = t->ops.has_signal(t);
if (t->ops.is_stereo) { if (t->ops.is_stereo) {
if (t->ops.is_stereo(client)) if (t->ops.is_stereo(t))
vt->flags |= vt->flags |=
VIDEO_TUNER_STEREO_ON; VIDEO_TUNER_STEREO_ON;
else else
...@@ -753,7 +752,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -753,7 +752,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
return 0; return 0;
if (V4L2_TUNER_RADIO == t->mode && t->ops.is_stereo) if (V4L2_TUNER_RADIO == t->mode && t->ops.is_stereo)
va->mode = t->ops.is_stereo(client) va->mode = t->ops.is_stereo(t)
? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO;
return 0; return 0;
} }
...@@ -819,7 +818,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -819,7 +818,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
tuner->type = t->mode; tuner->type = t->mode;
if (t->ops.get_afc) if (t->ops.get_afc)
tuner->afc=t->ops.get_afc(client); tuner->afc=t->ops.get_afc(t);
if (t->mode == V4L2_TUNER_ANALOG_TV) if (t->mode == V4L2_TUNER_ANALOG_TV)
tuner->capability |= V4L2_TUNER_CAP_NORM; tuner->capability |= V4L2_TUNER_CAP_NORM;
if (t->mode != V4L2_TUNER_RADIO) { if (t->mode != V4L2_TUNER_RADIO) {
...@@ -830,12 +829,12 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -830,12 +829,12 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
/* radio mode */ /* radio mode */
if (t->ops.has_signal) if (t->ops.has_signal)
tuner->signal = t->ops.has_signal(client); tuner->signal = t->ops.has_signal(t);
tuner->rxsubchans = tuner->rxsubchans =
V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
if (t->ops.is_stereo) { if (t->ops.is_stereo) {
tuner->rxsubchans = t->ops.is_stereo(client) ? tuner->rxsubchans = t->ops.is_stereo(t) ?
V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO;
} }
...@@ -864,7 +863,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -864,7 +863,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
} }
case VIDIOC_LOG_STATUS: case VIDIOC_LOG_STATUS:
if (t->ops.tuner_status) if (t->ops.tuner_status)
t->ops.tuner_status(client); t->ops.tuner_status(t);
break; break;
} }
......
...@@ -24,18 +24,21 @@ ...@@ -24,18 +24,21 @@
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include "tuner-i2c.h"
extern unsigned const int tuner_count; extern unsigned const int tuner_count;
struct tuner;
struct tuner_operations { struct tuner_operations {
void (*set_tv_freq)(struct i2c_client *c, unsigned int freq); void (*set_tv_freq)(struct tuner *t, unsigned int freq);
void (*set_radio_freq)(struct i2c_client *c, unsigned int freq); void (*set_radio_freq)(struct tuner *t, unsigned int freq);
int (*has_signal)(struct i2c_client *c); int (*has_signal)(struct tuner *t);
int (*is_stereo)(struct i2c_client *c); int (*is_stereo)(struct tuner *t);
int (*get_afc)(struct i2c_client *c); int (*get_afc)(struct tuner *t);
void (*tuner_status)(struct i2c_client *c); void (*tuner_status)(struct tuner *t);
void (*standby)(struct i2c_client *c); void (*standby)(struct tuner *t);
void (*release)(struct i2c_client *c); void (*release)(struct tuner *t);
}; };
struct tuner { struct tuner {
...@@ -66,20 +69,20 @@ struct tuner { ...@@ -66,20 +69,20 @@ struct tuner {
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
extern int default_tuner_init(struct i2c_client *c); extern int default_tuner_init(struct tuner *t);
extern int tda9887_tuner_init(struct i2c_client *c); extern int tda9887_tuner_init(struct tuner *t);
extern int microtune_init(struct i2c_client *c); extern int microtune_init(struct tuner *t);
extern int tda8290_init(struct i2c_client *c); extern int tda8290_init(struct tuner *t);
extern int tda8290_probe(struct i2c_client *c); extern int tda8290_probe(struct tuner *t);
extern int tea5761_tuner_init(struct i2c_client *c); extern int tea5761_tuner_init(struct tuner *t);
extern int tea5761_autodetection(struct i2c_client *c); extern int tea5761_autodetection(struct tuner *t);
extern int tea5767_autodetection(struct i2c_client *c); extern int tea5767_autodetection(struct tuner *t);
extern int tea5767_tuner_init(struct i2c_client *c); extern int tea5767_tuner_init(struct tuner *t);
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
......
/*
tuner-i2c.h - i2c interface for different tuners
Copyright (C) 2007 Michael Krufky (mkrufky@linuxtv.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TUNER_I2C_H__
#define __TUNER_I2C_H__
#include <linux/i2c.h>
struct tuner_i2c_props {
u8 addr;
struct i2c_adapter *adap;
};
static inline int tuner_i2c_xfer_send(struct tuner_i2c_props *props, char *buf, int len)
{
struct i2c_msg msg = { .addr = props->addr, .flags = 0,
.buf = buf, .len = len };
int ret = i2c_transfer(props->adap, &msg, 1);
return (ret == 1) ? len : ret;
}
static inline int tuner_i2c_xfer_recv(struct tuner_i2c_props *props, char *buf, int len)
{
struct i2c_msg msg = { .addr = props->addr, .flags = I2C_M_RD,
.buf = buf, .len = len };
int ret = i2c_transfer(props->adap, &msg, 1);
return (ret == 1) ? len : ret;
}
#ifndef __TUNER_DRIVER_H__
#define tuner_warn(fmt, arg...) do {\
printk(KERN_WARNING PREFIX "%d-%04x: " fmt, \
i2c_adapter_id(priv->i2c_props.adap), priv->i2c_props.addr , ##arg); } while (0)
#define tuner_info(fmt, arg...) do {\
printk(KERN_INFO PREFIX "%d-%04x: " fmt, \
i2c_adapter_id(priv->i2c_props.adap), priv->i2c_props.addr , ##arg); } while (0)
#define tuner_dbg(fmt, arg...) do {\
if ((debug)) \
printk(KERN_DEBUG PREFIX "%d-%04x: " fmt, \
i2c_adapter_id(priv->i2c_props.adap), priv->i2c_props.addr , ##arg); } while (0)
#endif /* __TUNER_DRIVER_H__ */
#endif /* __TUNER_I2C_H__ */
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* ---------------------------------------------------------------------------
* Local variables:
* c-basic-offset: 8
* End:
*/
...@@ -84,31 +84,32 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner"); ...@@ -84,31 +84,32 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner");
struct tuner_simple_priv { struct tuner_simple_priv {
u16 last_div; u16 last_div;
struct tuner_i2c_props i2c_props;
}; };
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
static int tuner_getstatus(struct i2c_client *c) static int tuner_getstatus(struct tuner *t)
{ {
struct tuner_simple_priv *priv = t->priv;
unsigned char byte; unsigned char byte;
if (1 != i2c_master_recv(c,&byte,1)) if (1 != tuner_i2c_xfer_recv(&priv->i2c_props,&byte,1))
return 0; return 0;
return byte; return byte;
} }
static int tuner_signal(struct i2c_client *c) static int tuner_signal(struct tuner *t)
{ {
return (tuner_getstatus(c) & TUNER_SIGNAL) << 13; return (tuner_getstatus(t) & TUNER_SIGNAL) << 13;
} }
static int tuner_stereo(struct i2c_client *c) static int tuner_stereo(struct tuner *t)
{ {
int stereo, status; int stereo, status;
struct tuner *t = i2c_get_clientdata(c);
status = tuner_getstatus (c); status = tuner_getstatus(t);
switch (t->type) { switch (t->type) {
case TUNER_PHILIPS_FM1216ME_MK3: case TUNER_PHILIPS_FM1216ME_MK3:
...@@ -127,9 +128,8 @@ static int tuner_stereo(struct i2c_client *c) ...@@ -127,9 +128,8 @@ static int tuner_stereo(struct i2c_client *c)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) static void default_set_tv_freq(struct tuner *t, unsigned int freq)
{ {
struct tuner *t = i2c_get_clientdata(c);
struct tuner_simple_priv *priv = t->priv; struct tuner_simple_priv *priv = t->priv;
u8 config, cb, tuneraddr; u8 config, cb, tuneraddr;
u16 div; u16 div;
...@@ -285,13 +285,13 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) ...@@ -285,13 +285,13 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
buffer[1] = 0x04; buffer[1] = 0x04;
} }
/* set to the correct mode (analog or digital) */ /* set to the correct mode (analog or digital) */
tuneraddr = c->addr; tuneraddr = priv->i2c_props.addr;
c->addr = 0x0a; priv->i2c_props.addr = 0x0a;
if (2 != (rc = i2c_master_send(c,&buffer[0],2))) if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[0],2)))
tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc);
if (2 != (rc = i2c_master_send(c,&buffer[2],2))) if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[2],2)))
tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc);
c->addr = tuneraddr; priv->i2c_props.addr = tuneraddr;
/* FIXME: input */ /* FIXME: input */
break; break;
} }
...@@ -345,12 +345,12 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) ...@@ -345,12 +345,12 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
} }
if (params->default_pll_gating_18) if (params->default_pll_gating_18)
config |= TDA9887_GATING_18; config |= TDA9887_GATING_18;
i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config); i2c_clients_command(priv->i2c_props.adap, TDA9887_SET_CONFIG, &config);
} }
tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
buffer[0],buffer[1],buffer[2],buffer[3]); buffer[0],buffer[1],buffer[2],buffer[3]);
if (4 != (rc = i2c_master_send(c,buffer,4))) if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4)))
tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
switch (t->type) { switch (t->type) {
...@@ -362,7 +362,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) ...@@ -362,7 +362,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
buffer[1] = 0x20; buffer[1] = 0x20;
tuner_dbg("tv 0x%02x 0x%02x\n",buffer[0],buffer[1]); tuner_dbg("tv 0x%02x 0x%02x\n",buffer[0],buffer[1]);
if (2 != (rc = i2c_master_send(c,buffer,2))) if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,2)))
tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc);
break; break;
case TUNER_MICROTUNE_4042FI5: case TUNER_MICROTUNE_4042FI5:
...@@ -375,7 +375,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) ...@@ -375,7 +375,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
for (;;) { for (;;) {
if (time_after(jiffies,timeout)) if (time_after(jiffies,timeout))
return; return;
if (1 != (rc = i2c_master_recv(c,&status_byte,1))) { if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,&status_byte,1))) {
tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc); tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc);
break; break;
} }
...@@ -393,17 +393,16 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) ...@@ -393,17 +393,16 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
buffer[0],buffer[1],buffer[2],buffer[3]); buffer[0],buffer[1],buffer[2],buffer[3]);
if (4 != (rc = i2c_master_send(c,buffer,4))) if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4)))
tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
break; break;
} }
} }
} }
static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) static void default_set_radio_freq(struct tuner *t, unsigned int freq)
{ {
struct tunertype *tun; struct tunertype *tun;
struct tuner *t = i2c_get_clientdata(c);
struct tuner_simple_priv *priv = t->priv; struct tuner_simple_priv *priv = t->priv;
u8 buffer[4]; u8 buffer[4];
u16 div; u16 div;
...@@ -498,16 +497,14 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) ...@@ -498,16 +497,14 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
config |= TDA9887_GAIN_NORMAL; config |= TDA9887_GAIN_NORMAL;
if (params->radio_if == 2) if (params->radio_if == 2)
config |= TDA9887_RIF_41_3; config |= TDA9887_RIF_41_3;
i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config); i2c_clients_command(priv->i2c_props.adap, TDA9887_SET_CONFIG, &config);
} }
if (4 != (rc = i2c_master_send(c,buffer,4))) if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4)))
tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
} }
static void tuner_release(struct i2c_client *c) static void tuner_release(struct tuner *t)
{ {
struct tuner *t = i2c_get_clientdata(c);
kfree(t->priv); kfree(t->priv);
t->priv = NULL; t->priv = NULL;
} }
...@@ -520,9 +517,8 @@ static struct tuner_operations simple_tuner_ops = { ...@@ -520,9 +517,8 @@ static struct tuner_operations simple_tuner_ops = {
.release = tuner_release, .release = tuner_release,
}; };
int default_tuner_init(struct i2c_client *c) int default_tuner_init(struct tuner *t)
{ {
struct tuner *t = i2c_get_clientdata(c);
struct tuner_simple_priv *priv = NULL; struct tuner_simple_priv *priv = NULL;
priv = kzalloc(sizeof(struct tuner_simple_priv), GFP_KERNEL); priv = kzalloc(sizeof(struct tuner_simple_priv), GFP_KERNEL);
...@@ -530,9 +526,12 @@ int default_tuner_init(struct i2c_client *c) ...@@ -530,9 +526,12 @@ int default_tuner_init(struct i2c_client *c)
return -ENOMEM; return -ENOMEM;
t->priv = priv; 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", tuner_info("type set to %d (%s)\n",
t->type, tuners[t->type].name); t->type, tuners[t->type].name);
strlcpy(c->name, tuners[t->type].name, sizeof(c->name)); strlcpy(t->i2c.name, tuners[t->type].name, sizeof(t->i2c.name));
memcpy(&t->ops, &simple_tuner_ops, sizeof(struct tuner_operations)); memcpy(&t->ops, &simple_tuner_ops, sizeof(struct tuner_operations));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment