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
This diff is collapsed.
...@@ -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 @@ int msp3400c_thread(void *data) ...@@ -659,7 +659,7 @@ int msp3400c_thread(void *data)
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 @@ int msp3410d_thread(void *data) ...@@ -825,7 +825,7 @@ int msp3410d_thread(void *data)
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 @@ int msp34xxg_thread(void *data) ...@@ -1049,7 +1049,7 @@ int msp34xxg_thread(void *data)
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