aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/video/tuner-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/tuner-core.c')
-rw-r--r--drivers/media/video/tuner-core.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 7be73e3763d..505591a7abe 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -144,7 +144,8 @@ static void set_freq(struct i2c_client *c, unsigned long freq)
}
static void set_type(struct i2c_client *c, unsigned int type,
- unsigned int new_mode_mask)
+ unsigned int new_mode_mask, unsigned int new_config,
+ int (*tuner_callback) (void *dev, int command,int arg))
{
struct tuner *t = i2c_get_clientdata(c);
unsigned char buffer[4];
@@ -159,15 +160,20 @@ static void set_type(struct i2c_client *c, unsigned int type,
return;
}
+ t->type = type;
+ t->config = new_config;
+ if (tuner_callback != NULL) {
+ tuner_dbg("defining GPIO callback\n");
+ t->tuner_callback = tuner_callback;
+ }
+
/* This code detects calls by card attach_inform */
if (NULL == t->i2c.dev.driver) {
tuner_dbg ("tuner 0x%02x: called during i2c_client register by adapter's attach_inform\n", c->addr);
- t->type=type;
return;
}
- t->type = type;
switch (t->type) {
case TUNER_MT2032:
microtune_init(c);
@@ -234,10 +240,11 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup)
tuner_dbg("set addr for type %i\n", t->type);
- if ( t->type == UNSET && ((tun_setup->addr == ADDR_UNSET &&
- (t->mode_mask & tun_setup->mode_mask)) ||
- tun_setup->addr == c->addr)) {
- set_type(c, tun_setup->type, tun_setup->mode_mask);
+ if ( (t->type == UNSET && ((tun_setup->addr == ADDR_UNSET) &&
+ (t->mode_mask & tun_setup->mode_mask))) ||
+ (tun_setup->addr == c->addr)) {
+ set_type(c, tun_setup->type, tun_setup->mode_mask,
+ tun_setup->config, tun_setup->tuner_callback);
}
}
@@ -496,7 +503,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
register_client:
tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
i2c_attach_client (&t->i2c);
- set_type (&t->i2c,t->type, t->mode_mask);
+ set_type (&t->i2c,t->type, t->mode_mask, t->config, t->tuner_callback);
return 0;
}
@@ -576,10 +583,11 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
switch (cmd) {
/* --- configuration --- */
case TUNER_SET_TYPE_ADDR:
- tuner_dbg ("Calling set_type_addr for type=%d, addr=0x%02x, mode=0x%02x\n",
+ tuner_dbg ("Calling set_type_addr for type=%d, addr=0x%02x, mode=0x%02x, config=0x%02x\n",
((struct tuner_setup *)arg)->type,
((struct tuner_setup *)arg)->addr,
- ((struct tuner_setup *)arg)->mode_mask);
+ ((struct tuner_setup *)arg)->mode_mask,
+ ((struct tuner_setup *)arg)->config);
set_addr(client, (struct tuner_setup *)arg);
break;
@@ -804,9 +812,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
return 0;
}
-static int tuner_suspend(struct device *dev, pm_message_t state)
+static int tuner_suspend(struct i2c_client *c, pm_message_t state)
{
- struct i2c_client *c = container_of (dev, struct i2c_client, dev);
struct tuner *t = i2c_get_clientdata (c);
tuner_dbg ("suspend\n");
@@ -814,9 +821,8 @@ static int tuner_suspend(struct device *dev, pm_message_t state)
return 0;
}
-static int tuner_resume(struct device *dev)
+static int tuner_resume(struct i2c_client *c)
{
- struct i2c_client *c = container_of (dev, struct i2c_client, dev);
struct tuner *t = i2c_get_clientdata (c);
tuner_dbg ("resume\n");
@@ -837,10 +843,10 @@ static struct i2c_driver driver = {
.attach_adapter = tuner_probe,
.detach_client = tuner_detach,
.command = tuner_command,
+ .suspend = tuner_suspend,
+ .resume = tuner_resume,
.driver = {
.name = "tuner",
- .suspend = tuner_suspend,
- .resume = tuner_resume,
},
};
static struct i2c_client client_template = {