Commit 76efd62f authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (9825): msp3400: convert to v4l2_subdev.

Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 5d302f2e
...@@ -51,14 +51,14 @@ ...@@ -51,14 +51,14 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/kthread.h>
#include <linux/freezer.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <media/v4l2-common.h> #include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h> #include <media/v4l2-ioctl.h>
#include <media/v4l2-i2c-drv-legacy.h> #include <media/v4l2-i2c-drv-legacy.h>
#include <media/tvaudio.h>
#include <media/msp3400.h> #include <media/msp3400.h>
#include <linux/kthread.h> #include <media/tvaudio.h>
#include <linux/freezer.h>
#include "msp3400-driver.h" #include "msp3400-driver.h"
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
...@@ -265,7 +265,7 @@ static char *scart_names[] = { ...@@ -265,7 +265,7 @@ static char *scart_names[] = {
void msp_set_scart(struct i2c_client *client, int in, int out) 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; state->in_scart = in;
...@@ -289,7 +289,7 @@ void msp_set_scart(struct i2c_client *client, int in, int out) ...@@ -289,7 +289,7 @@ void msp_set_scart(struct i2c_client *client, int in, int out)
void msp_set_audio(struct i2c_client *client) 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 bal = 0, bass, treble, loudness;
int val = 0; int val = 0;
int reallymuted = state->muted | state->scan_in_progress; int reallymuted = state->muted | state->scan_in_progress;
...@@ -336,7 +336,7 @@ void msp_set_audio(struct i2c_client *client) ...@@ -336,7 +336,7 @@ void msp_set_audio(struct i2c_client *client)
static void msp_wake_thread(struct i2c_client *client) 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) if (NULL == state->kthread)
return; return;
...@@ -390,9 +390,9 @@ static int msp_mode_v4l1_to_v4l2(int mode) ...@@ -390,9 +390,9 @@ static int msp_mode_v4l1_to_v4l2(int mode)
} }
#endif #endif
static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl) static int msp_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{ {
struct msp_state *state = i2c_get_clientdata(client); struct msp_state *state = to_state(sd);
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_VOLUME:
...@@ -433,9 +433,10 @@ static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl) ...@@ -433,9 +433,10 @@ static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
return 0; return 0;
} }
static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl) static int msp_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{ {
struct msp_state *state = i2c_get_clientdata(client); struct msp_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_VOLUME:
...@@ -481,40 +482,16 @@ static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl) ...@@ -481,40 +482,16 @@ static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
return 0; return 0;
} }
static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) #ifdef CONFIG_VIDEO_ALLOW_V4L1
static int msp_ioctl(struct v4l2_subdev *sd, int cmd, void *arg)
{ {
struct msp_state *state = i2c_get_clientdata(client); struct msp_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
if (msp_debug >= 2)
v4l_i2c_print_ioctl(client, cmd);
switch (cmd) { 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 --- */ /* --- v4l ioctls --- */
/* take care: bttv does userspace copying, we'll get a /* take care: bttv does userspace copying, we'll get a
kernel pointer here... */ kernel pointer here... */
#ifdef CONFIG_VIDEO_ALLOW_V4L1
case VIDIOCGAUDIO: case VIDIOCGAUDIO:
{ {
struct video_audio *va = arg; struct video_audio *va = arg;
...@@ -588,38 +565,67 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -588,38 +565,67 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
msp_wake_thread(client); msp_wake_thread(client);
break; break;
} }
default:
return -ENOIOCTLCMD;
}
return 0;
}
#endif #endif
case VIDIOC_S_FREQUENCY:
{ /* --- v4l2 ioctls --- */
/* new channel -- kick audio carrier scan */ 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); msp_wake_thread(client);
break; break;
} }
return 0;
}
/* --- v4l2 ioctls --- */ static int msp_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
case VIDIOC_S_STD: {
{ struct i2c_client *client = v4l2_get_subdevdata(sd);
v4l2_std_id *id = arg;
int update = state->radio || state->v4l2_std != *id;
state->v4l2_std = *id; /* new channel -- kick audio carrier scan */
state->radio = 0;
if (update)
msp_wake_thread(client); msp_wake_thread(client);
return 0; return 0;
} }
case VIDIOC_INT_G_AUDIO_ROUTING: static int msp_s_std(struct v4l2_subdev *sd, v4l2_std_id id)
{ {
struct v4l2_routing *rt = arg; struct msp_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
int update = state->radio || state->v4l2_std != id;
*rt = state->routing; state->v4l2_std = id;
break; state->radio = 0;
} if (update)
msp_wake_thread(client);
return 0;
}
case VIDIOC_INT_S_AUDIO_ROUTING: static int msp_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *rt)
{ {
struct v4l2_routing *rt = arg; struct msp_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
int tuner = (rt->input >> 3) & 1; int tuner = (rt->input >> 3) & 1;
int sc_in = rt->input & 0x7; int sc_in = rt->input & 0x7;
int sc1_out = rt->output & 0xf; int sc1_out = rt->output & 0xf;
...@@ -630,7 +636,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -630,7 +636,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
if (state->routing.input == rt->input && if (state->routing.input == rt->input &&
state->routing.output == rt->output) state->routing.output == rt->output)
break; return 0;
state->routing = *rt; state->routing = *rt;
/* check if the tuner input is used */ /* check if the tuner input is used */
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
...@@ -648,45 +654,48 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -648,45 +654,48 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
msp_write_dem(client, reg, (val & ~0x100) | (tuner << 8)); msp_write_dem(client, reg, (val & ~0x100) | (tuner << 8));
/* wake thread when a new input is chosen */ /* wake thread when a new input is chosen */
msp_wake_thread(client); msp_wake_thread(client);
break; return 0;
} }
case VIDIOC_G_TUNER: static int msp_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
{ {
struct v4l2_tuner *vt = arg; struct msp_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
if (state->radio) if (state->radio)
break; return 0;
if (state->opmode == OPMODE_AUTOSELECT) if (state->opmode == OPMODE_AUTOSELECT)
msp_detect_stereo(client); msp_detect_stereo(client);
vt->audmode = state->audmode; vt->audmode = state->audmode;
vt->rxsubchans = state->rxsubchans; vt->rxsubchans = state->rxsubchans;
vt->capability |= V4L2_TUNER_CAP_STEREO | vt->capability |= V4L2_TUNER_CAP_STEREO |
V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2;
break; return 0;
} }
case VIDIOC_S_TUNER: static int msp_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
{ {
struct v4l2_tuner *vt = (struct v4l2_tuner *)arg; 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 */ if (state->radio) /* TODO: add mono/stereo support for radio */
break; return 0;
if (state->audmode == vt->audmode) if (state->audmode == vt->audmode)
break; return 0;
state->audmode = vt->audmode; state->audmode = vt->audmode;
/* only set audmode */ /* only set audmode */
msp_set_audmode(client); msp_set_audmode(client);
break; return 0;
} }
case VIDIOC_INT_I2S_CLOCK_FREQ: static int msp_s_i2s_clock_freq(struct v4l2_subdev *sd, u32 freq)
{ {
u32 *a = (u32 *)arg; 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", *a); v4l_dbg(1, msp_debug, client, "Setting I2S speed to %d\n", freq);
switch (*a) { switch (freq) {
case 1024000: case 1024000:
state->i2s_mode = 0; state->i2s_mode = 0;
break; break;
...@@ -696,12 +705,12 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -696,12 +705,12 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
default: default:
return -EINVAL; return -EINVAL;
} }
break; return 0;
} }
case VIDIOC_QUERYCTRL: static int msp_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
{ {
struct v4l2_queryctrl *qc = arg; struct msp_state *state = to_state(sd);
switch (qc->id) { switch (qc->id) {
case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_VOLUME:
...@@ -721,16 +730,22 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -721,16 +730,22 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
default: default:
return -EINVAL; return -EINVAL;
} }
} return 0;
}
case VIDIOC_G_CTRL: static int msp_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip)
return msp_get_ctrl(client, arg); {
struct msp_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
case VIDIOC_S_CTRL: return v4l2_chip_ident_i2c_client(client, chip, state->ident,
return msp_set_ctrl(client, arg); (state->rev1 << 16) | state->rev2);
}
case VIDIOC_LOG_STATUS: 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; const char *p;
if (state->opmode == OPMODE_AUTOSELECT) if (state->opmode == OPMODE_AUTOSELECT)
...@@ -775,17 +790,6 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -775,17 +790,6 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
v4l_info(client, "Routing: 0x%08x (input) 0x%08x (output)\n", v4l_info(client, "Routing: 0x%08x (input) 0x%08x (output)\n",
state->routing.input, state->routing.output); state->routing.input, state->routing.output);
v4l_info(client, "ACB: 0x%04x\n", state->acb); 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;
}
return 0; return 0;
} }
...@@ -803,11 +807,49 @@ static int msp_resume(struct i2c_client *client) ...@@ -803,11 +807,49 @@ static int msp_resume(struct i2c_client *client)
return 0; 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) static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
{ {
struct msp_state *state; struct msp_state *state;
struct v4l2_subdev *sd;
int (*thread_func)(void *data) = NULL; int (*thread_func)(void *data) = NULL;
int msp_hard; int msp_hard;
int msp_family; int msp_family;
...@@ -827,7 +869,8 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -827,7 +869,8 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
if (!state) if (!state)
return -ENOMEM; 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->v4l2_std = V4L2_STD_NTSC;
state->audmode = V4L2_TUNER_MODE_STEREO; state->audmode = V4L2_TUNER_MODE_STEREO;
...@@ -972,8 +1015,9 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -972,8 +1015,9 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
static int msp_remove(struct i2c_client *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 */ /* shutdown control thread */
if (state->kthread) { if (state->kthread) {
state->restart = 1; state->restart = 1;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#define MSP3400_DRIVER_H #define MSP3400_DRIVER_H
#include <media/msp3400.h> #include <media/msp3400.h>
#include <media/v4l2-device.h>
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
...@@ -49,6 +50,7 @@ extern int msp_dolby; ...@@ -49,6 +50,7 @@ extern int msp_dolby;
extern int msp_stereo_thresh; extern int msp_stereo_thresh;
struct msp_state { struct msp_state {
struct v4l2_subdev sd;
int rev1, rev2; int rev1, rev2;
int ident; int ident;
u8 has_nicam; u8 has_nicam;
...@@ -96,6 +98,11 @@ struct msp_state { ...@@ -96,6 +98,11 @@ struct msp_state {
unsigned int watch_stereo:1; 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 */ /* msp3400-driver.c */
int msp_write_dem(struct i2c_client *client, int addr, int val); int msp_write_dem(struct i2c_client *client, int addr, int val);
int msp_write_dsp(struct i2c_client *client, int addr, int val); int msp_write_dsp(struct i2c_client *client, int addr, int val);
......
...@@ -159,7 +159,7 @@ const char *msp_standard_std_name(int std) ...@@ -159,7 +159,7 @@ const char *msp_standard_std_name(int std)
static void msp_set_source(struct i2c_client *client, u16 src) 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) { if (msp_dolby) {
msp_write_dsp(client, 0x0008, 0x0520); /* I2S1 */ msp_write_dsp(client, 0x0008, 0x0520); /* I2S1 */
...@@ -186,7 +186,7 @@ void msp3400c_set_carrier(struct i2c_client *client, int cdo1, int cdo2) ...@@ -186,7 +186,7 @@ void msp3400c_set_carrier(struct i2c_client *client, int cdo1, int cdo2)
void msp3400c_set_mode(struct i2c_client *client, int mode) 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]; struct msp3400c_init_data_dem *data = &msp3400c_init_data[mode];
int tuner = (state->routing.input >> 3) & 1; int tuner = (state->routing.input >> 3) & 1;
int i; int i;
...@@ -227,7 +227,7 @@ static void msp3400c_set_audmode(struct i2c_client *client) ...@@ -227,7 +227,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
static char *strmode[] = { static char *strmode[] = {
"mono", "stereo", "lang2", "lang1", "lang1+lang2" "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) ? char *modestr = (state->audmode >= 0 && state->audmode < 5) ?
strmode[state->audmode] : "unknown"; strmode[state->audmode] : "unknown";
int src = 0; /* channel source: FM/AM, nicam or SCART */ int src = 0; /* channel source: FM/AM, nicam or SCART */
...@@ -356,7 +356,7 @@ static void msp3400c_set_audmode(struct i2c_client *client) ...@@ -356,7 +356,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
static void msp3400c_print_mode(struct i2c_client *client) 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) if (state->main == state->second)
v4l_dbg(1, msp_debug, client, v4l_dbg(1, msp_debug, client,
...@@ -385,7 +385,7 @@ static void msp3400c_print_mode(struct i2c_client *client) ...@@ -385,7 +385,7 @@ static void msp3400c_print_mode(struct i2c_client *client)
static int msp3400c_detect_stereo(struct i2c_client *client) 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 val;
int rxsubchans = state->rxsubchans; int rxsubchans = state->rxsubchans;
int newnicam = state->nicam_on; int newnicam = state->nicam_on;
...@@ -463,7 +463,7 @@ static int msp3400c_detect_stereo(struct i2c_client *client) ...@@ -463,7 +463,7 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
/* stereo/multilang monitoring */ /* stereo/multilang monitoring */
static void watch_stereo(struct i2c_client *client) 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)) if (msp_detect_stereo(client))
msp_set_audmode(client); msp_set_audmode(client);
...@@ -475,7 +475,7 @@ static void watch_stereo(struct i2c_client *client) ...@@ -475,7 +475,7 @@ static void watch_stereo(struct i2c_client *client)
int msp3400c_thread(void *data) int msp3400c_thread(void *data)
{ {
struct i2c_client *client = 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; struct msp3400c_carrier_detect *cd;
int count, max1, max2, val1, val2, val, i; int count, max1, max2, val1, val2, val, i;
...@@ -659,7 +659,7 @@ no_second: ...@@ -659,7 +659,7 @@ no_second:
int msp3410d_thread(void *data) int msp3410d_thread(void *data)
{ {
struct i2c_client *client = 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; int val, i, std, count;
v4l_dbg(1, msp_debug, client, "msp3410 daemon started\n"); v4l_dbg(1, msp_debug, client, "msp3410 daemon started\n");
...@@ -825,7 +825,7 @@ restart: ...@@ -825,7 +825,7 @@ restart:
static int msp34xxg_modus(struct i2c_client *client) 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) { if (state->radio) {
v4l_dbg(1, msp_debug, client, "selected radio modus\n"); v4l_dbg(1, msp_debug, client, "selected radio modus\n");
...@@ -852,7 +852,7 @@ static int msp34xxg_modus(struct i2c_client *client) ...@@ -852,7 +852,7 @@ static int msp34xxg_modus(struct i2c_client *client)
static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in) 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; int source, matrix;
switch (state->audmode) { switch (state->audmode) {
...@@ -895,7 +895,7 @@ static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in) ...@@ -895,7 +895,7 @@ static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
static void msp34xxg_set_sources(struct i2c_client *client) 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; u32 in = state->routing.input;
msp34xxg_set_source(client, 0x0008, (in >> 4) & 0xf); msp34xxg_set_source(client, 0x0008, (in >> 4) & 0xf);
...@@ -911,7 +911,7 @@ static void msp34xxg_set_sources(struct i2c_client *client) ...@@ -911,7 +911,7 @@ static void msp34xxg_set_sources(struct i2c_client *client)
/* (re-)initialize the msp34xxg */ /* (re-)initialize the msp34xxg */
static void msp34xxg_reset(struct i2c_client *client) 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 tuner = (state->routing.input >> 3) & 1;
int modus; int modus;
...@@ -954,7 +954,7 @@ static void msp34xxg_reset(struct i2c_client *client) ...@@ -954,7 +954,7 @@ static void msp34xxg_reset(struct i2c_client *client)
int msp34xxg_thread(void *data) int msp34xxg_thread(void *data)
{ {
struct i2c_client *client = 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; int val, i;
v4l_dbg(1, msp_debug, client, "msp34xxg daemon started\n"); v4l_dbg(1, msp_debug, client, "msp34xxg daemon started\n");
...@@ -1049,7 +1049,7 @@ unmute: ...@@ -1049,7 +1049,7 @@ unmute:
static int msp34xxg_detect_stereo(struct i2c_client *client) 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 status = msp_read_dem(client, 0x0200);
int is_bilingual = status & 0x100; int is_bilingual = status & 0x100;
int is_stereo = status & 0x40; int is_stereo = status & 0x40;
...@@ -1078,7 +1078,7 @@ static int msp34xxg_detect_stereo(struct i2c_client *client) ...@@ -1078,7 +1078,7 @@ static int msp34xxg_detect_stereo(struct i2c_client *client)
static void msp34xxg_set_audmode(struct i2c_client *client) 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->std == 0x20) {
if ((state->rxsubchans & V4L2_TUNER_SUB_SAP) && if ((state->rxsubchans & V4L2_TUNER_SUB_SAP) &&
...@@ -1095,7 +1095,7 @@ static void msp34xxg_set_audmode(struct i2c_client *client) ...@@ -1095,7 +1095,7 @@ static void msp34xxg_set_audmode(struct i2c_client *client)
void msp_set_audmode(struct i2c_client *client) 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) { switch (state->opmode) {
case OPMODE_MANUAL: case OPMODE_MANUAL:
...@@ -1110,7 +1110,7 @@ void msp_set_audmode(struct i2c_client *client) ...@@ -1110,7 +1110,7 @@ void msp_set_audmode(struct i2c_client *client)
int msp_detect_stereo(struct i2c_client *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) { switch (state->opmode) {
case OPMODE_MANUAL: case OPMODE_MANUAL:
......
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