]> err.no Git - linux-2.6/commitdiff
V4L/DVB (5753): Tuner: create struct tuner_operations
authorMichael Krufky <mkrufky@linuxtv.org>
Wed, 6 Jun 2007 19:10:39 +0000 (16:10 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 18 Jul 2007 17:24:02 +0000 (14:24 -0300)
Move tuner callback function pointers out of struct tuner, into
struct tuner_operations.

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/mt20xx.c
drivers/media/video/tda8290.c
drivers/media/video/tda9887.c
drivers/media/video/tea5761.c
drivers/media/video/tea5767.c
drivers/media/video/tuner-core.c
drivers/media/video/tuner-simple.c
include/media/tuner.h

index 5b33be8a49cda30c88a1919e754b4679ca94a4ba..846c6233fa3d5f796234d5f0232f48c6d142a243 100644 (file)
@@ -361,8 +361,8 @@ static int mt2032_init(struct i2c_client *c)
        } while (xok != 1 );
        priv->xogc=xogc;
 
-       t->set_tv_freq    = mt2032_set_tv_freq;
-       t->set_radio_freq = mt2032_set_radio_freq;
+       t->ops.set_tv_freq    = mt2032_set_tv_freq;
+       t->ops.set_radio_freq = mt2032_set_radio_freq;
        return(1);
 }
 
@@ -490,8 +490,8 @@ static int mt2050_init(struct i2c_client *c)
        i2c_master_recv(c,buf,1);
 
        tuner_dbg("mt2050: sro is %x\n",buf[0]);
-       t->set_tv_freq    = mt2050_set_tv_freq;
-       t->set_radio_freq = mt2050_set_radio_freq;
+       t->ops.set_tv_freq    = mt2050_set_tv_freq;
+       t->ops.set_radio_freq = mt2050_set_radio_freq;
        return 0;
 }
 
@@ -519,10 +519,10 @@ int microtune_init(struct i2c_client *c)
        priv->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */
 
        memset(buf,0,sizeof(buf));
-       t->set_tv_freq    = NULL;
-       t->set_radio_freq = NULL;
-       t->standby    = NULL;
-       t->release        = microtune_release;
+       t->ops.set_tv_freq    = NULL;
+       t->ops.set_radio_freq = NULL;
+       t->ops.standby    = NULL;
+       t->ops.release        = microtune_release;
        if (t->std & V4L2_STD_525_60) {
                tuner_dbg("pinnacle ntsc\n");
                priv->radio_if2 = 41300 * 1000;
index 2614ea99a9c3054d109b9bcdd8608bbee159106b..99122ff4e81cb294d34370812f91abf4f936770c 100644 (file)
@@ -667,11 +667,11 @@ int tda8290_init(struct i2c_client *c)
        }
        tuner_info("type set to %s\n", c->name);
 
-       t->set_tv_freq    = set_tv_freq;
-       t->set_radio_freq = set_radio_freq;
-       t->has_signal = has_signal;
-       t->standby = standby;
-       t->release = tda8290_release;
+       t->ops.set_tv_freq    = set_tv_freq;
+       t->ops.set_radio_freq = set_radio_freq;
+       t->ops.has_signal = has_signal;
+       t->ops.standby = standby;
+       t->ops.release = tda8290_release;
        priv->tda827x_lpsel = 0;
        t->mode = V4L2_TUNER_ANALOG_TV;
 
index f0443cc02e5c48ebc21a15cef67b91e262a62c10..5bb7d19edfbcdeab0b6d21a292947a9f171d0a31 100644 (file)
@@ -614,12 +614,12 @@ int tda9887_tuner_init(struct i2c_client *c)
        tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr,
                                                t->i2c.driver->driver.name);
 
-       t->set_tv_freq = tda9887_set_freq;
-       t->set_radio_freq = tda9887_set_freq;
-       t->standby = tda9887_standby;
-       t->tuner_status = tda9887_tuner_status;
-       t->get_afc = tda9887_get_afc;
-       t->release = tda9887_release;
+       t->ops.set_tv_freq = tda9887_set_freq;
+       t->ops.set_radio_freq = tda9887_set_freq;
+       t->ops.standby = tda9887_standby;
+       t->ops.tuner_status = tda9887_tuner_status;
+       t->ops.get_afc = tda9887_get_afc;
+       t->ops.release = tda9887_release;
 
        return 0;
 }
index 1479f16f9ab3028948bb579b21afd948af15fa21..858f2d11496c8e48d156ce85a0d5902cf2fcdc16 100644 (file)
@@ -229,10 +229,10 @@ int tea5761_tuner_init(struct i2c_client *c)
        tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5761HN FM Radio");
        strlcpy(c->name, "tea5761", sizeof(c->name));
 
-       t->set_tv_freq = set_tv_freq;
-       t->set_radio_freq = set_radio_freq;
-       t->has_signal = tea5761_signal;
-       t->is_stereo = tea5761_stereo;
+       t->ops.set_tv_freq = set_tv_freq;
+       t->ops.set_radio_freq = set_radio_freq;
+       t->ops.has_signal = tea5761_signal;
+       t->ops.is_stereo = tea5761_stereo;
 
        return (0);
 }
index d1c41781ccc47dd3dd00ea8d7d5d15f3a6dd5cda..c5510422aa3e549035a63c4bbae2628ce328b449 100644 (file)
@@ -350,11 +350,11 @@ int tea5767_tuner_init(struct i2c_client *c)
        tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5767HN FM Radio");
        strlcpy(c->name, "tea5767", sizeof(c->name));
 
-       t->set_tv_freq = set_tv_freq;
-       t->set_radio_freq = set_radio_freq;
-       t->has_signal = tea5767_signal;
-       t->is_stereo = tea5767_stereo;
-       t->standby = tea5767_standby;
+       t->ops.set_tv_freq = set_tv_freq;
+       t->ops.set_radio_freq = set_radio_freq;
+       t->ops.has_signal = tea5767_signal;
+       t->ops.is_stereo = tea5767_stereo;
+       t->ops.standby = tea5767_standby;
 
        return (0);
 }
index acbffbfdb5084ddd8a7ca463be8c9de6ef00a22e..603476532f5c5e5f1ca119fd5925f96d1be360e3 100644 (file)
@@ -80,7 +80,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
                tuner_warn ("tuner type not set\n");
                return;
        }
-       if (NULL == t->set_tv_freq) {
+       if (NULL == t->ops.set_tv_freq) {
                tuner_warn ("Tuner has no way to set tv freq\n");
                return;
        }
@@ -95,7 +95,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
                else
                        freq = tv_range[1] * 16;
        }
-       t->set_tv_freq(c, freq);
+       t->ops.set_tv_freq(c, freq);
 }
 
 static void set_radio_freq(struct i2c_client *c, unsigned int freq)
@@ -106,7 +106,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
                tuner_warn ("tuner type not set\n");
                return;
        }
-       if (NULL == t->set_radio_freq) {
+       if (NULL == t->ops.set_radio_freq) {
                tuner_warn ("tuner has no way to set radio frequency\n");
                return;
        }
@@ -122,7 +122,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
                        freq = radio_range[1] * 16000;
        }
 
-       t->set_radio_freq(c, freq);
+       t->ops.set_radio_freq(c, freq);
 }
 
 static void set_freq(struct i2c_client *c, unsigned long freq)
@@ -178,8 +178,8 @@ static void set_type(struct i2c_client *c, unsigned int type,
        }
 
        /* discard private data, in case set_type() was previously called */
-       if (t->release)
-               t->release(c);
+       if (t->ops.release)
+               t->ops.release(c);
        else {
                kfree(t->priv);
                t->priv = NULL;
@@ -429,11 +429,11 @@ static void tuner_status(struct i2c_client *client)
        tuner_info("Standard:        0x%08lx\n", (unsigned long)t->std);
        if (t->mode != V4L2_TUNER_RADIO)
               return;
-       if (t->has_signal) {
-               tuner_info("Signal strength: %d\n", t->has_signal(client));
+       if (t->ops.has_signal) {
+               tuner_info("Signal strength: %d\n", t->ops.has_signal(client));
        }
-       if (t->is_stereo) {
-               tuner_info("Stereo:          %s\n", t->is_stereo(client) ? "yes" : "no");
+       if (t->ops.is_stereo) {
+               tuner_info("Stereo:          %s\n", t->ops.is_stereo(client) ? "yes" : "no");
        }
 }
 
@@ -460,7 +460,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
        t->type = UNSET;
        t->audmode = V4L2_TUNER_MODE_STEREO;
        t->mode_mask = T_UNINITIALIZED;
-       t->tuner_status = tuner_status;
+       t->ops.tuner_status = tuner_status;
 
        if (show_i2c) {
                unsigned char buffer[16];
@@ -566,8 +566,8 @@ static int tuner_detach(struct i2c_client *client)
                return err;
        }
 
-       if (t->release)
-               t->release(client);
+       if (t->ops.release)
+               t->ops.release(client);
        else {
                kfree(t->priv);
        }
@@ -591,8 +591,8 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode,
 
        if (check_mode(t, cmd) == EINVAL) {
                t->mode = T_STANDBY;
-               if (t->standby)
-                       t->standby (client);
+               if (t->ops.standby)
+                       t->ops.standby (client);
                return EINVAL;
        }
        return 0;
@@ -640,8 +640,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
                if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL)
                        return 0;
                t->mode = T_STANDBY;
-               if (t->standby)
-                       t->standby (client);
+               if (t->ops.standby)
+                       t->ops.standby (client);
                break;
 #ifdef CONFIG_VIDEO_V4L1
        case VIDIOCSAUDIO:
@@ -700,10 +700,10 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
                                return 0;
 
                        if (V4L2_TUNER_RADIO == t->mode) {
-                               if (t->has_signal)
-                                       vt->signal = t->has_signal(client);
-                               if (t->is_stereo) {
-                                       if (t->is_stereo(client))
+                               if (t->ops.has_signal)
+                                       vt->signal = t->ops.has_signal(client);
+                               if (t->ops.is_stereo) {
+                                       if (t->ops.is_stereo(client))
                                                vt->flags |=
                                                    VIDEO_TUNER_STEREO_ON;
                                        else
@@ -731,8 +731,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
                        if (check_v4l2(t) == EINVAL)
                                return 0;
 
-                       if (V4L2_TUNER_RADIO == t->mode && t->is_stereo)
-                               va->mode = t->is_stereo(client)
+                       if (V4L2_TUNER_RADIO == t->mode && t->ops.is_stereo)
+                               va->mode = t->ops.is_stereo(client)
                                    ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO;
                        return 0;
                }
@@ -797,8 +797,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
                        switch_v4l2();
 
                        tuner->type = t->mode;
-                       if (t->get_afc)
-                               tuner->afc=t->get_afc(client);
+                       if (t->ops.get_afc)
+                               tuner->afc=t->ops.get_afc(client);
                        if (t->mode == V4L2_TUNER_ANALOG_TV)
                                tuner->capability |= V4L2_TUNER_CAP_NORM;
                        if (t->mode != V4L2_TUNER_RADIO) {
@@ -808,13 +808,13 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
                        }
 
                        /* radio mode */
-                       if (t->has_signal)
-                               tuner->signal = t->has_signal(client);
+                       if (t->ops.has_signal)
+                               tuner->signal = t->ops.has_signal(client);
 
                        tuner->rxsubchans =
                                V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
-                       if (t->is_stereo) {
-                               tuner->rxsubchans = t->is_stereo(client) ?
+                       if (t->ops.is_stereo) {
+                               tuner->rxsubchans = t->ops.is_stereo(client) ?
                                        V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO;
                        }
 
@@ -842,8 +842,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
                        break;
                }
        case VIDIOC_LOG_STATUS:
-               if (t->tuner_status)
-                       t->tuner_status(client);
+               if (t->ops.tuner_status)
+                       t->ops.tuner_status(client);
                break;
        }
 
index b5792d6a73f39e8e04436e9ebbe30ddd2cf0d725..fb4addbd5eb605c64c8c1f2e419e55f68b8ede1f 100644 (file)
@@ -487,11 +487,11 @@ int default_tuner_init(struct i2c_client *c)
                   t->type, tuners[t->type].name);
        strlcpy(c->name, tuners[t->type].name, sizeof(c->name));
 
-       t->set_tv_freq = default_set_tv_freq;
-       t->set_radio_freq = default_set_radio_freq;
-       t->has_signal = tuner_signal;
-       t->is_stereo = tuner_stereo;
-       t->standby = NULL;
+       t->ops.set_tv_freq = default_set_tv_freq;
+       t->ops.set_radio_freq = default_set_radio_freq;
+       t->ops.has_signal = tuner_signal;
+       t->ops.is_stereo = tuner_stereo;
+       t->ops.standby = NULL;
 
        return 0;
 }
index da821a027e76001e34020eb4ec0af40c87ee354b..88eaf8930203a1446c04ffcb55807a4334901696 100644 (file)
@@ -183,6 +183,17 @@ struct tuner_setup {
        int (*tuner_callback) (void *dev, int command,int arg);
 };
 
+struct tuner_operations {
+       void (*set_tv_freq)(struct i2c_client *c, unsigned int freq);
+       void (*set_radio_freq)(struct i2c_client *c, unsigned int freq);
+       int  (*has_signal)(struct i2c_client *c);
+       int  (*is_stereo)(struct i2c_client *c);
+       int  (*get_afc)(struct i2c_client *c);
+       void (*tuner_status)(struct i2c_client *c);
+       void (*standby)(struct i2c_client *c);
+       void (*release)(struct i2c_client *c);
+};
+
 struct tuner {
        /* device */
        struct i2c_client i2c;
@@ -207,15 +218,7 @@ struct tuner {
        unsigned int config;
        int (*tuner_callback) (void *dev, int command,int arg);
 
-       /* function ptrs */
-       void (*set_tv_freq)(struct i2c_client *c, unsigned int freq);
-       void (*set_radio_freq)(struct i2c_client *c, unsigned int freq);
-       int  (*has_signal)(struct i2c_client *c);
-       int  (*is_stereo)(struct i2c_client *c);
-       int  (*get_afc)(struct i2c_client *c);
-       void (*tuner_status)(struct i2c_client *c);
-       void (*standby)(struct i2c_client *c);
-       void (*release)(struct i2c_client *c);
+       struct tuner_operations ops;
 };
 
 extern unsigned const int tuner_count;