The patch number 9825 was added via Hans Verkuil <hverk...@xs4all.nl>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        v4l-dvb-maintai...@linuxtv.org

------

From: Hans Verkuil  <hverk...@xs4all.nl>
msp3400: convert to v4l2_subdev.


Priority: normal

Signed-off-by: Hans Verkuil <hverk...@xs4all.nl>


---

 linux/drivers/media/video/msp3400-driver.c   |  454 ++++++++++---------
 linux/drivers/media/video/msp3400-driver.h   |    7 
 linux/drivers/media/video/msp3400-kthreads.c |   34 -
 3 files changed, 273 insertions(+), 222 deletions(-)

diff -r 72de2d8883a3 -r 2c15544d9736 linux/drivers/media/video/msp3400-driver.c
--- a/linux/drivers/media/video/msp3400-driver.c        Sat Nov 29 16:51:32 
2008 +0100
+++ b/linux/drivers/media/video/msp3400-driver.c        Mon Nov 24 22:16:46 
2008 +0100
@@ -51,18 +51,18 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/videodev2.h>
-#include <media/v4l2-common.h>
-#include <media/v4l2-ioctl.h>
-#include <media/v4l2-i2c-drv-legacy.h>
-#include <media/tvaudio.h>
-#include <media/msp3400.h>
 #include <linux/kthread.h>
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
 #include <linux/suspend.h>
 #else
 #include <linux/freezer.h>
 #endif
+#include <linux/videodev2.h>
+#include <media/v4l2-device.h>
+#include <media/v4l2-ioctl.h>
+#include <media/v4l2-i2c-drv-legacy.h>
+#include <media/msp3400.h>
+#include <media/tvaudio.h>
 #include "compat.h"
 #include "msp3400-driver.h"
 
@@ -270,7 +270,7 @@ static char *scart_names[] = {
 
 void msp_set_scart(struct i2c_client *client, int in, int out)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
 
        state->in_scart = in;
 
@@ -294,7 +294,7 @@ void msp_set_scart(struct i2c_client *cl
 
 void msp_set_audio(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
        int bal = 0, bass, treble, loudness;
        int val = 0;
        int reallymuted = state->muted | state->scan_in_progress;
@@ -341,7 +341,7 @@ void msp_set_audio(struct i2c_client *cl
 
 static void msp_wake_thread(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
 
        if (NULL == state->kthread)
                return;
@@ -395,9 +395,9 @@ static int msp_mode_v4l1_to_v4l2(int mod
 }
 #endif
 
-static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
-{
-       struct msp_state *state = i2c_get_clientdata(client);
+static int msp_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+       struct msp_state *state = to_state(sd);
 
        switch (ctrl->id) {
        case V4L2_CID_AUDIO_VOLUME:
@@ -438,9 +438,10 @@ static int msp_get_ctrl(struct i2c_clien
        return 0;
 }
 
-static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
-{
-       struct msp_state *state = i2c_get_clientdata(client);
+static int msp_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+       struct msp_state *state = to_state(sd);
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
 
        switch (ctrl->id) {
        case V4L2_CID_AUDIO_VOLUME:
@@ -486,40 +487,16 @@ static int msp_set_ctrl(struct i2c_clien
        return 0;
 }
 
-static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
-{
-       struct msp_state *state = i2c_get_clientdata(client);
-
-       if (msp_debug >= 2)
-               v4l_i2c_print_ioctl(client, cmd);
+#ifdef CONFIG_VIDEO_ALLOW_V4L1
+static int msp_ioctl(struct v4l2_subdev *sd, int cmd, void *arg)
+{
+       struct msp_state *state = to_state(sd);
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
 
        switch (cmd) {
-       case AUDC_SET_RADIO:
-               if (state->radio)
-                       return 0;
-               state->radio = 1;
-               v4l_dbg(1, msp_debug, client, "switching to radio mode\n");
-               state->watch_stereo = 0;
-               switch (state->opmode) {
-               case OPMODE_MANUAL:
-                       /* set msp3400 to FM radio mode */
-                       msp3400c_set_mode(client, MSP_MODE_FM_RADIO);
-                       msp3400c_set_carrier(client, MSP_CARRIER(10.7),
-                                           MSP_CARRIER(10.7));
-                       msp_set_audio(client);
-                       break;
-               case OPMODE_AUTODETECT:
-               case OPMODE_AUTOSELECT:
-                       /* the thread will do for us */
-                       msp_wake_thread(client);
-                       break;
-               }
-               break;
-
        /* --- v4l ioctls --- */
        /* take care: bttv does userspace copying, we'll get a
           kernel pointer here... */
-#ifdef CONFIG_VIDEO_ALLOW_V4L1
        case VIDIOCGAUDIO:
        {
                struct video_audio *va = arg;
@@ -593,105 +570,137 @@ static int msp_command(struct i2c_client
                msp_wake_thread(client);
                break;
        }
+       default:
+               return -ENOIOCTLCMD;
+       }
+       return 0;
+}
 #endif
-       case VIDIOC_S_FREQUENCY:
-       {
-               /* new channel -- kick audio carrier scan */
+
+/* --- v4l2 ioctls --- */
+static int msp_s_radio(struct v4l2_subdev *sd)
+{
+       struct msp_state *state = to_state(sd);
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+       if (state->radio)
+               return 0;
+       state->radio = 1;
+       v4l_dbg(1, msp_debug, client, "switching to radio mode\n");
+       state->watch_stereo = 0;
+       switch (state->opmode) {
+       case OPMODE_MANUAL:
+               /* set msp3400 to FM radio mode */
+               msp3400c_set_mode(client, MSP_MODE_FM_RADIO);
+               msp3400c_set_carrier(client, MSP_CARRIER(10.7),
+                               MSP_CARRIER(10.7));
+               msp_set_audio(client);
+               break;
+       case OPMODE_AUTODETECT:
+       case OPMODE_AUTOSELECT:
+               /* the thread will do for us */
                msp_wake_thread(client);
                break;
        }
-
-       /* --- v4l2 ioctls --- */
-       case VIDIOC_S_STD:
-       {
-               v4l2_std_id *id = arg;
-               int update = state->radio || state->v4l2_std != *id;
-
-               state->v4l2_std = *id;
-               state->radio = 0;
-               if (update)
-                       msp_wake_thread(client);
+       return 0;
+}
+
+static int msp_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
+{
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+       /* new channel -- kick audio carrier scan */
+       msp_wake_thread(client);
+       return 0;
+}
+
+static int msp_s_std(struct v4l2_subdev *sd, v4l2_std_id id)
+{
+       struct msp_state *state = to_state(sd);
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
+       int update = state->radio || state->v4l2_std != id;
+
+       state->v4l2_std = id;
+       state->radio = 0;
+       if (update)
+               msp_wake_thread(client);
+       return 0;
+}
+
+static int msp_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *rt)
+{
+       struct msp_state *state = to_state(sd);
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
+       int tuner = (rt->input >> 3) & 1;
+       int sc_in = rt->input & 0x7;
+       int sc1_out = rt->output & 0xf;
+       int sc2_out = (rt->output >> 4) & 0xf;
+       u16 val, reg;
+       int i;
+       int extern_input = 1;
+
+       if (state->routing.input == rt->input &&
+                       state->routing.output == rt->output)
                return 0;
-       }
-
-       case VIDIOC_INT_G_AUDIO_ROUTING:
-       {
-               struct v4l2_routing *rt = arg;
-
-               *rt = state->routing;
-               break;
-       }
-
-       case VIDIOC_INT_S_AUDIO_ROUTING:
-       {
-               struct v4l2_routing *rt = arg;
-               int tuner = (rt->input >> 3) & 1;
-               int sc_in = rt->input & 0x7;
-               int sc1_out = rt->output & 0xf;
-               int sc2_out = (rt->output >> 4) & 0xf;
-               u16 val, reg;
-               int i;
-               int extern_input = 1;
-
-               if (state->routing.input == rt->input &&
-                   state->routing.output == rt->output)
-                       break;
-               state->routing = *rt;
-               /* check if the tuner input is used */
-               for (i = 0; i < 5; i++) {
-                       if (((rt->input >> (4 + i * 4)) & 0xf) == 0)
-                               extern_input = 0;
-               }
-               state->mode = extern_input ? MSP_MODE_EXTERN : 
MSP_MODE_AM_DETECT;
-               state->rxsubchans = V4L2_TUNER_SUB_STEREO;
-               msp_set_scart(client, sc_in, 0);
-               msp_set_scart(client, sc1_out, 1);
-               msp_set_scart(client, sc2_out, 2);
-               msp_set_audmode(client);
-               reg = (state->opmode == OPMODE_AUTOSELECT) ? 0x30 : 0xbb;
-               val = msp_read_dem(client, reg);
-               msp_write_dem(client, reg, (val & ~0x100) | (tuner << 8));
-               /* wake thread when a new input is chosen */
-               msp_wake_thread(client);
-               break;
-       }
-
-       case VIDIOC_G_TUNER:
-       {
-               struct v4l2_tuner *vt = arg;
-
-               if (state->radio)
-                       break;
-               if (state->opmode == OPMODE_AUTOSELECT)
-                       msp_detect_stereo(client);
-               vt->audmode    = state->audmode;
-               vt->rxsubchans = state->rxsubchans;
-               vt->capability |= V4L2_TUNER_CAP_STEREO |
-                       V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2;
-               break;
-       }
-
-       case VIDIOC_S_TUNER:
-       {
-               struct v4l2_tuner *vt = (struct v4l2_tuner *)arg;
-
-               if (state->radio)  /* TODO: add mono/stereo support for radio */
-                       break;
-               if (state->audmode == vt->audmode)
-                       break;
-               state->audmode = vt->audmode;
-               /* only set audmode */
-               msp_set_audmode(client);
-               break;
-       }
-
-       case VIDIOC_INT_I2S_CLOCK_FREQ:
-       {
-               u32 *a = (u32 *)arg;
-
-               v4l_dbg(1, msp_debug, client, "Setting I2S speed to %d\n", *a);
-
-               switch (*a) {
+       state->routing = *rt;
+       /* check if the tuner input is used */
+       for (i = 0; i < 5; i++) {
+               if (((rt->input >> (4 + i * 4)) & 0xf) == 0)
+                       extern_input = 0;
+       }
+       state->mode = extern_input ? MSP_MODE_EXTERN : MSP_MODE_AM_DETECT;
+       state->rxsubchans = V4L2_TUNER_SUB_STEREO;
+       msp_set_scart(client, sc_in, 0);
+       msp_set_scart(client, sc1_out, 1);
+       msp_set_scart(client, sc2_out, 2);
+       msp_set_audmode(client);
+       reg = (state->opmode == OPMODE_AUTOSELECT) ? 0x30 : 0xbb;
+       val = msp_read_dem(client, reg);
+       msp_write_dem(client, reg, (val & ~0x100) | (tuner << 8));
+       /* wake thread when a new input is chosen */
+       msp_wake_thread(client);
+       return 0;
+}
+
+static int msp_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
+{
+       struct msp_state *state = to_state(sd);
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+       if (state->radio)
+               return 0;
+       if (state->opmode == OPMODE_AUTOSELECT)
+               msp_detect_stereo(client);
+       vt->audmode    = state->audmode;
+       vt->rxsubchans = state->rxsubchans;
+       vt->capability |= V4L2_TUNER_CAP_STEREO |
+               V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2;
+       return 0;
+}
+
+static int msp_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
+{
+       struct msp_state *state = to_state(sd);
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+       if (state->radio)  /* TODO: add mono/stereo support for radio */
+               return 0;
+       if (state->audmode == vt->audmode)
+               return 0;
+       state->audmode = vt->audmode;
+       /* only set audmode */
+       msp_set_audmode(client);
+       return 0;
+}
+
+static int msp_s_i2s_clock_freq(struct v4l2_subdev *sd, u32 freq)
+{
+       struct msp_state *state = to_state(sd);
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+       v4l_dbg(1, msp_debug, client, "Setting I2S speed to %d\n", freq);
+
+       switch (freq) {
                case 1024000:
                        state->i2s_mode = 0;
                        break;
@@ -700,24 +709,24 @@ static int msp_command(struct i2c_client
                        break;
                default:
                        return -EINVAL;
-               }
-               break;
-       }
-
-       case VIDIOC_QUERYCTRL:
-       {
-               struct v4l2_queryctrl *qc = arg;
-
-               switch (qc->id) {
+       }
+       return 0;
+}
+
+static int msp_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
+{
+       struct msp_state *state = to_state(sd);
+
+       switch (qc->id) {
                case V4L2_CID_AUDIO_VOLUME:
                case V4L2_CID_AUDIO_MUTE:
                        return v4l2_ctrl_query_fill_std(qc);
                default:
                        break;
-               }
-               if (!state->has_sound_processing)
-                       return -EINVAL;
-               switch (qc->id) {
+       }
+       if (!state->has_sound_processing)
+               return -EINVAL;
+       switch (qc->id) {
                case V4L2_CID_AUDIO_LOUDNESS:
                case V4L2_CID_AUDIO_BALANCE:
                case V4L2_CID_AUDIO_BASS:
@@ -725,32 +734,38 @@ static int msp_command(struct i2c_client
                        return v4l2_ctrl_query_fill_std(qc);
                default:
                        return -EINVAL;
-               }
-       }
-
-       case VIDIOC_G_CTRL:
-               return msp_get_ctrl(client, arg);
-
-       case VIDIOC_S_CTRL:
-               return msp_set_ctrl(client, arg);
-
-       case VIDIOC_LOG_STATUS:
-       {
-               const char *p;
-
-               if (state->opmode == OPMODE_AUTOSELECT)
-                       msp_detect_stereo(client);
-               v4l_info(client, "%s rev1 = 0x%04x rev2 = 0x%04x\n",
-                               client->name, state->rev1, state->rev2);
-               v4l_info(client, "Audio:    volume %d%s\n",
-                               state->volume, state->muted ? " (muted)" : "");
-               if (state->has_sound_processing) {
-                       v4l_info(client, "Audio:    balance %d bass %d treble 
%d loudness %s\n",
-                                       state->balance, state->bass,
-                                       state->treble,
-                                       state->loudness ? "on" : "off");
-               }
-               switch (state->mode) {
+       }
+       return 0;
+}
+
+static int msp_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident 
*chip)
+{
+       struct msp_state *state = to_state(sd);
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+       return v4l2_chip_ident_i2c_client(client, chip, state->ident,
+                       (state->rev1 << 16) | state->rev2);
+}
+
+static int msp_log_status(struct v4l2_subdev *sd)
+{
+       struct msp_state *state = to_state(sd);
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
+       const char *p;
+
+       if (state->opmode == OPMODE_AUTOSELECT)
+               msp_detect_stereo(client);
+       v4l_info(client, "%s rev1 = 0x%04x rev2 = 0x%04x\n",
+                       client->name, state->rev1, state->rev2);
+       v4l_info(client, "Audio:    volume %d%s\n",
+                       state->volume, state->muted ? " (muted)" : "");
+       if (state->has_sound_processing) {
+               v4l_info(client, "Audio:    balance %d bass %d treble %d 
loudness %s\n",
+                               state->balance, state->bass,
+                               state->treble,
+                               state->loudness ? "on" : "off");
+       }
+       switch (state->mode) {
                case MSP_MODE_AM_DETECT: p = "AM (for carrier detect)"; break;
                case MSP_MODE_FM_RADIO: p = "FM Radio"; break;
                case MSP_MODE_FM_TERRA: p = "Terrestial FM-mono/stereo"; break;
@@ -761,36 +776,25 @@ static int msp_command(struct i2c_client
                case MSP_MODE_BTSC: p = "BTSC"; break;
                case MSP_MODE_EXTERN: p = "External input"; break;
                default: p = "unknown"; break;
-               }
-               if (state->mode == MSP_MODE_EXTERN) {
-                       v4l_info(client, "Mode:     %s\n", p);
-               } else if (state->opmode == OPMODE_MANUAL) {
-                       v4l_info(client, "Mode:     %s (%s%s)\n", p,
+       }
+       if (state->mode == MSP_MODE_EXTERN) {
+               v4l_info(client, "Mode:     %s\n", p);
+       } else if (state->opmode == OPMODE_MANUAL) {
+               v4l_info(client, "Mode:     %s (%s%s)\n", p,
                                (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? 
"stereo" : "mono",
                                (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", 
dual" : "");
-               } else {
-                       if (state->opmode == OPMODE_AUTODETECT)
-                               v4l_info(client, "Mode:     %s\n", p);
-                       v4l_info(client, "Standard: %s (%s%s)\n",
+       } else {
+               if (state->opmode == OPMODE_AUTODETECT)
+                       v4l_info(client, "Mode:     %s\n", p);
+               v4l_info(client, "Standard: %s (%s%s)\n",
                                msp_standard_std_name(state->std),
                                (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? 
"stereo" : "mono",
                                (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", 
dual" : "");
-               }
-               v4l_info(client, "Audmode:  0x%04x\n", state->audmode);
-               v4l_info(client, "Routing:  0x%08x (input) 0x%08x (output)\n",
-                               state->routing.input, state->routing.output);
-               v4l_info(client, "ACB:      0x%04x\n", state->acb);
-               break;
-       }
-
-       case VIDIOC_G_CHIP_IDENT:
-               return v4l2_chip_ident_i2c_client(client, arg, state->ident,
-                               (state->rev1 << 16) | state->rev2);
-
-       default:
-               /* unknown */
-               return -EINVAL;
-       }
+       }
+       v4l_info(client, "Audmode:  0x%04x\n", state->audmode);
+       v4l_info(client, "Routing:  0x%08x (input) 0x%08x (output)\n",
+                       state->routing.input, state->routing.output);
+       v4l_info(client, "ACB:      0x%04x\n", state->acb);
        return 0;
 }
 
@@ -808,11 +812,49 @@ static int msp_resume(struct i2c_client 
        return 0;
 }
 
+static int msp_command(struct i2c_client *client, unsigned cmd, void *arg)
+{
+       return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg);
+}
+
 /* ----------------------------------------------------------------------- */
 
+static const struct v4l2_subdev_core_ops msp_core_ops = {
+       .log_status = msp_log_status,
+       .g_chip_ident = msp_g_chip_ident,
+       .g_ctrl = msp_g_ctrl,
+       .s_ctrl = msp_s_ctrl,
+       .queryctrl = msp_queryctrl,
+#ifdef CONFIG_VIDEO_ALLOW_V4L1
+       .ioctl = msp_ioctl,
+#endif
+};
+
+static const struct v4l2_subdev_tuner_ops msp_tuner_ops = {
+       .s_frequency = msp_s_frequency,
+       .g_tuner = msp_g_tuner,
+       .s_tuner = msp_s_tuner,
+       .s_radio = msp_s_radio,
+       .s_std = msp_s_std,
+};
+
+static const struct v4l2_subdev_audio_ops msp_audio_ops = {
+       .s_routing = msp_s_routing,
+       .s_i2s_clock_freq = msp_s_i2s_clock_freq,
+};
+
+static const struct v4l2_subdev_ops msp_ops = {
+       .core = &msp_core_ops,
+       .tuner = &msp_tuner_ops,
+       .audio = &msp_audio_ops,
+};
+
+/* ----------------------------------------------------------------------- */
+
 static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
        struct msp_state *state;
+       struct v4l2_subdev *sd;
        int (*thread_func)(void *data) = NULL;
        int msp_hard;
        int msp_family;
@@ -836,7 +878,8 @@ static int msp_probe(struct i2c_client *
        if (!state)
                return -ENOMEM;
 
-       i2c_set_clientdata(client, state);
+       sd = &state->sd;
+       v4l2_i2c_subdev_init(sd, client, &msp_ops);
 
        state->v4l2_std = V4L2_STD_NTSC;
        state->audmode = V4L2_TUNER_MODE_STEREO;
@@ -990,8 +1033,9 @@ static int msp_probe(struct i2c_client *
 
 static int msp_remove(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
-
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
+
+       v4l2_device_unregister_subdev(&state->sd);
        /* shutdown control thread */
        if (state->kthread) {
                state->restart = 1;
diff -r 72de2d8883a3 -r 2c15544d9736 linux/drivers/media/video/msp3400-driver.h
--- a/linux/drivers/media/video/msp3400-driver.h        Sat Nov 29 16:51:32 
2008 +0100
+++ b/linux/drivers/media/video/msp3400-driver.h        Mon Nov 24 22:16:46 
2008 +0100
@@ -5,6 +5,7 @@
 #define MSP3400_DRIVER_H
 
 #include <media/msp3400.h>
+#include <media/v4l2-device.h>
 
 /* ---------------------------------------------------------------------- */
 
@@ -49,6 +50,7 @@ extern int msp_stereo_thresh;
 extern int msp_stereo_thresh;
 
 struct msp_state {
+       struct v4l2_subdev sd;
        int rev1, rev2;
        int ident;
        u8 has_nicam;
@@ -96,6 +98,11 @@ struct msp_state {
        unsigned int         watch_stereo:1;
 };
 
+static inline struct msp_state *to_state(struct v4l2_subdev *sd)
+{
+       return container_of(sd, struct msp_state, sd);
+}
+
 /* msp3400-driver.c */
 int msp_write_dem(struct i2c_client *client, int addr, int val);
 int msp_write_dsp(struct i2c_client *client, int addr, int val);
diff -r 72de2d8883a3 -r 2c15544d9736 
linux/drivers/media/video/msp3400-kthreads.c
--- a/linux/drivers/media/video/msp3400-kthreads.c      Sat Nov 29 16:51:32 
2008 +0100
+++ b/linux/drivers/media/video/msp3400-kthreads.c      Mon Nov 24 22:16:46 
2008 +0100
@@ -162,7 +162,7 @@ const char *msp_standard_std_name(int st
 
 static void msp_set_source(struct i2c_client *client, u16 src)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
 
        if (msp_dolby) {
                msp_write_dsp(client, 0x0008, 0x0520); /* I2S1 */
@@ -189,7 +189,7 @@ void msp3400c_set_carrier(struct i2c_cli
 
 void msp3400c_set_mode(struct i2c_client *client, int mode)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
        struct msp3400c_init_data_dem *data = &msp3400c_init_data[mode];
        int tuner = (state->routing.input >> 3) & 1;
        int i;
@@ -230,7 +230,7 @@ static void msp3400c_set_audmode(struct 
        static char *strmode[] = {
                "mono", "stereo", "lang2", "lang1", "lang1+lang2"
        };
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
        char *modestr = (state->audmode >= 0 && state->audmode < 5) ?
                strmode[state->audmode] : "unknown";
        int src = 0;    /* channel source: FM/AM, nicam or SCART */
@@ -359,7 +359,7 @@ static void msp3400c_set_audmode(struct 
 
 static void msp3400c_print_mode(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
 
        if (state->main == state->second)
                v4l_dbg(1, msp_debug, client,
@@ -388,7 +388,7 @@ static void msp3400c_print_mode(struct i
 
 static int msp3400c_detect_stereo(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
        int val;
        int rxsubchans = state->rxsubchans;
        int newnicam = state->nicam_on;
@@ -466,7 +466,7 @@ static int msp3400c_detect_stereo(struct
 /* stereo/multilang monitoring */
 static void watch_stereo(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
 
        if (msp_detect_stereo(client))
                msp_set_audmode(client);
@@ -478,7 +478,7 @@ int msp3400c_thread(void *data)
 int msp3400c_thread(void *data)
 {
        struct i2c_client *client = data;
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
        struct msp3400c_carrier_detect *cd;
        int count, max1, max2, val1, val2, val, i;
 
@@ -662,7 +662,7 @@ int msp3410d_thread(void *data)
 int msp3410d_thread(void *data)
 {
        struct i2c_client *client = data;
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
        int val, i, std, count;
 
        v4l_dbg(1, msp_debug, client, "msp3410 daemon started\n");
@@ -828,7 +828,7 @@ restart:
 
 static int msp34xxg_modus(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
 
        if (state->radio) {
                v4l_dbg(1, msp_debug, client, "selected radio modus\n");
@@ -855,7 +855,7 @@ static int msp34xxg_modus(struct i2c_cli
 
 static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
  {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
        int source, matrix;
 
        switch (state->audmode) {
@@ -898,7 +898,7 @@ static void msp34xxg_set_source(struct i
 
 static void msp34xxg_set_sources(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
        u32 in = state->routing.input;
 
        msp34xxg_set_source(client, 0x0008, (in >> 4) & 0xf);
@@ -914,7 +914,7 @@ static void msp34xxg_set_sources(struct 
 /* (re-)initialize the msp34xxg */
 static void msp34xxg_reset(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
        int tuner = (state->routing.input >> 3) & 1;
        int modus;
 
@@ -957,7 +957,7 @@ int msp34xxg_thread(void *data)
 int msp34xxg_thread(void *data)
 {
        struct i2c_client *client = data;
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
        int val, i;
 
        v4l_dbg(1, msp_debug, client, "msp34xxg daemon started\n");
@@ -1052,7 +1052,7 @@ unmute:
 
 static int msp34xxg_detect_stereo(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
        int status = msp_read_dem(client, 0x0200);
        int is_bilingual = status & 0x100;
        int is_stereo = status & 0x40;
@@ -1081,7 +1081,7 @@ static int msp34xxg_detect_stereo(struct
 
 static void msp34xxg_set_audmode(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
 
        if (state->std == 0x20) {
               if ((state->rxsubchans & V4L2_TUNER_SUB_SAP) &&
@@ -1098,7 +1098,7 @@ static void msp34xxg_set_audmode(struct 
 
 void msp_set_audmode(struct i2c_client *client)
 {
-       struct msp_state *state = i2c_get_clientdata(client);
+       struct msp_state *state = to_state(i2c_get_clientdata(client));
 
        switch (state->opmode) {
        case OPMODE_MANUAL:
@@ -1113,7 +1113,7 @@ void msp_set_audmode(struct i2c_client *
 
 int msp_detect_stereo(struct i2c_client *client)
 {
-       struct msp_state *state  = i2c_get_clientdata(client);
+       struct msp_state *state  = to_state(i2c_get_clientdata(client));
 
        switch (state->opmode) {
        case OPMODE_MANUAL:


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/2c15544d97367933549181da7e37fae5e0243e22

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to