Skip to content

Commit

Permalink
V4L/DVB (13088): cx25840: Convert chip/core family checks to static i…
Browse files Browse the repository at this point in the history
…nline functions

Change logic to check for various chip or core families to inline functions.
Checks for specific chips should be made against the state->id field now.  This
is in preparation for chip/core specific code for setting up PLLs for the
CX2388[578] family of cores, that all run with different crystal frequencies.

Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Andy Walls authored and Mauro Carvalho Chehab committed Dec 5, 2009
1 parent c7dd1ec commit 2a03f03
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 60 deletions.
44 changes: 22 additions & 22 deletions drivers/media/video/cx25840/cx25840-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)

/* common for all inputs and rates */
/* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */
if (!state->is_cx23885 && !state->is_cx231xx)
if (!is_cx2388x(state) && !is_cx231xx(state))
cx25840_write(client, 0x127, 0x50);

if (state->aud_input != CX25840_AUDIO_SERIAL) {
switch (freq) {
case 32000:
if (state->is_cx23885) {
if (is_cx2388x(state)) {
/* We don't have register values
* so avoid destroying registers. */
break;
}

if (!state->is_cx231xx) {
if (!is_cx231xx(state)) {
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x1006040f);

/* AUX_PLL_FRAC */
cx25840_write4(client, 0x110, 0x01bb39ee);
}

if (state->is_cx25836)
if (is_cx2583x(state))
break;

/* src3/4/6_ctl = 0x0801f77f */
Expand All @@ -62,21 +62,21 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
break;

case 44100:
if (state->is_cx23885) {
if (is_cx2388x(state)) {
/* We don't have register values
* so avoid destroying registers. */
break;
}

if (!state->is_cx231xx) {
if (!is_cx231xx(state)) {
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x1009040f);

/* AUX_PLL_FRAC */
cx25840_write4(client, 0x110, 0x00ec6bd6);
}

if (state->is_cx25836)
if (is_cx2583x(state))
break;

/* src3/4/6_ctl = 0x08016d59 */
Expand All @@ -86,21 +86,21 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
break;

case 48000:
if (state->is_cx23885) {
if (is_cx2388x(state)) {
/* We don't have register values
* so avoid destroying registers. */
break;
}

if (!state->is_cx231xx) {
if (!is_cx231xx(state)) {
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x100a040f);

/* AUX_PLL_FRAC */
cx25840_write4(client, 0x110, 0x0098d6e5);
}

if (state->is_cx25836)
if (is_cx2583x(state))
break;

/* src3/4/6_ctl = 0x08014faa */
Expand All @@ -112,21 +112,21 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
} else {
switch (freq) {
case 32000:
if (state->is_cx23885) {
if (is_cx2388x(state)) {
/* We don't have register values
* so avoid destroying registers. */
break;
}

if (!state->is_cx231xx) {
if (!is_cx231xx(state)) {
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x1e08040f);

/* AUX_PLL_FRAC */
cx25840_write4(client, 0x110, 0x012a0869);
}

if (state->is_cx25836)
if (is_cx2583x(state))
break;

/* src1_ctl = 0x08010000 */
Expand All @@ -142,22 +142,22 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
break;

case 44100:
if (state->is_cx23885) {
if (is_cx2388x(state)) {
/* We don't have register values
* so avoid destroying registers. */
break;
}


if (!state->is_cx231xx) {
if (!is_cx231xx(state)) {
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x1809040f);

/* AUX_PLL_FRAC */
cx25840_write4(client, 0x110, 0x00ec6bd6);
}

if (state->is_cx25836)
if (is_cx2583x(state))
break;

/* src1_ctl = 0x08010000 */
Expand All @@ -170,18 +170,18 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
break;

case 48000:
if (!state->is_cx23885 && !state->is_cx231xx) {
if (!is_cx2388x(state) && !is_cx231xx(state)) {
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x180a040f);

/* AUX_PLL_FRAC */
cx25840_write4(client, 0x110, 0x0098d6e5);
}

if (state->is_cx25836)
if (is_cx2583x(state))
break;

if (!state->is_cx23885 && !state->is_cx231xx) {
if (!is_cx2388x(state) && !is_cx231xx(state)) {
/* src1_ctl */
cx25840_write4(client, 0x8f8, 0x08018000);

Expand Down Expand Up @@ -243,7 +243,7 @@ void cx25840_audio_set_path(struct i2c_client *client)
cx25840_and_or(client, 0x810, ~0x1, 0x00);

/* Ensure the controller is running when we exit */
if (state->is_cx23885 || state->is_cx231xx)
if (is_cx2388x(state) || is_cx231xx(state))
cx25840_and_or(client, 0x803, ~0x10, 0x10);
}

Expand Down Expand Up @@ -383,7 +383,7 @@ int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
struct cx25840_state *state = to_state(sd);
int retval;

if (!state->is_cx25836)
if (!is_cx2583x(state))
cx25840_and_or(client, 0x810, ~0x1, 1);
if (state->aud_input != CX25840_AUDIO_SERIAL) {
cx25840_and_or(client, 0x803, ~0x10, 0);
Expand All @@ -392,7 +392,7 @@ int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
retval = set_audclk_freq(client, freq);
if (state->aud_input != CX25840_AUDIO_SERIAL)
cx25840_and_or(client, 0x803, ~0x10, 0x10);
if (!state->is_cx25836)
if (!is_cx2583x(state))
cx25840_and_or(client, 0x810, ~0x1, 0);
return retval;
}
Expand Down
55 changes: 25 additions & 30 deletions drivers/media/video/cx25840/cx25840-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void cx25840_std_setup(struct i2c_client *client)
}

/* DEBUG: Displays configured PLL frequency */
if (!state->is_cx231xx) {
if (!is_cx231xx(state)) {
pll_int = cx25840_read(client, 0x108);
pll_frac = cx25840_read4(client, 0x10c) & 0x1ffffff;
pll_post = cx25840_read(client, 0x109);
Expand Down Expand Up @@ -678,7 +678,7 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
* configuration in reg (for the cx23885) so we have no
* need to attempt to flip bits for earlier av decoders.
*/
if (!state->is_cx23885 && !state->is_cx231xx) {
if (!is_cx2388x(state) && !is_cx231xx(state)) {
switch (aud_input) {
case CX25840_AUDIO_SERIAL:
/* do nothing, use serial audio input */
Expand All @@ -701,7 +701,7 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
/* Set INPUT_MODE to Composite (0) or S-Video (1) */
cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02);

if (!state->is_cx23885 && !state->is_cx231xx) {
if (!is_cx2388x(state) && !is_cx231xx(state)) {
/* Set CH_SEL_ADC2 to 1 if input comes from CH3 */
cx25840_and_or(client, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0);
/* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2&CH3 */
Expand All @@ -720,12 +720,12 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp

state->vid_input = vid_input;
state->aud_input = aud_input;
if (!state->is_cx25836) {
if (!is_cx2583x(state)) {
cx25840_audio_set_path(client);
input_change(client);
}

if (state->is_cx23885) {
if (is_cx2388x(state)) {
/* Audio channel 1 src : Parallel 1 */
cx25840_write(client, 0x124, 0x03);

Expand All @@ -741,7 +741,7 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
*/
cx25840_write(client, 0x918, 0xa0);
cx25840_write(client, 0x919, 0x01);
} else if (state->is_cx231xx) {
} else if (is_cx231xx(state)) {
/* Audio channel 1 src : Parallel 1 */
cx25840_write(client, 0x124, 0x03);

Expand Down Expand Up @@ -805,7 +805,7 @@ static int set_v4lstd(struct i2c_client *client)
cx25840_and_or(client, 0x400, ~0xf, fmt);
cx25840_and_or(client, 0x403, ~0x3, pal_m);
cx25840_std_setup(client);
if (!state->is_cx25836)
if (!is_cx2583x(state))
input_change(client);
return 0;
}
Expand Down Expand Up @@ -868,7 +868,7 @@ static int cx25840_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
case V4L2_CID_AUDIO_TREBLE:
case V4L2_CID_AUDIO_BALANCE:
case V4L2_CID_AUDIO_MUTE:
if (state->is_cx25836)
if (is_cx2583x(state))
return -EINVAL;
return cx25840_audio_s_ctrl(sd, ctrl);

Expand Down Expand Up @@ -905,7 +905,7 @@ static int cx25840_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
case V4L2_CID_AUDIO_TREBLE:
case V4L2_CID_AUDIO_BALANCE:
case V4L2_CID_AUDIO_MUTE:
if (state->is_cx25836)
if (is_cx2583x(state))
return -EINVAL;
return cx25840_audio_g_ctrl(sd, ctrl);
default:
Expand Down Expand Up @@ -1209,11 +1209,11 @@ static int cx25840_load_fw(struct v4l2_subdev *sd)
if (!state->is_initialized) {
/* initialize and load firmware */
state->is_initialized = 1;
if (state->is_cx25836)
if (is_cx2583x(state))
cx25836_initialize(client);
else if (state->is_cx23885)
else if (is_cx2388x(state))
cx23885_initialize(client);
else if (state->is_cx231xx)
else if (is_cx231xx(state))
cx231xx_initialize(client);
else
cx25840_initialize(client);
Expand Down Expand Up @@ -1256,17 +1256,17 @@ static int cx25840_s_stream(struct v4l2_subdev *sd, int enable)
v4l_dbg(1, cx25840_debug, client, "%s output\n",
enable ? "enable" : "disable");
if (enable) {
if (state->is_cx23885 || state->is_cx231xx) {
if (is_cx2388x(state) || is_cx231xx(state)) {
u8 v = (cx25840_read(client, 0x421) | 0x0b);
cx25840_write(client, 0x421, v);
} else {
cx25840_write(client, 0x115,
state->is_cx25836 ? 0x0c : 0x8c);
is_cx2583x(state) ? 0x0c : 0x8c);
cx25840_write(client, 0x116,
state->is_cx25836 ? 0x04 : 0x07);
is_cx2583x(state) ? 0x04 : 0x07);
}
} else {
if (state->is_cx23885 || state->is_cx231xx) {
if (is_cx2388x(state) || is_cx231xx(state)) {
u8 v = cx25840_read(client, 0x421) & ~(0x0b);
cx25840_write(client, 0x421, v);
} else {
Expand All @@ -1292,7 +1292,7 @@ static int cx25840_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
default:
break;
}
if (state->is_cx25836)
if (is_cx2583x(state))
return -EINVAL;

switch (qc->id) {
Expand Down Expand Up @@ -1346,7 +1346,7 @@ static int cx25840_s_audio_routing(struct v4l2_subdev *sd,
struct cx25840_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);

if (state->is_cx25836)
if (is_cx2583x(state))
return -EINVAL;
return set_input(client, state->vid_input, input);
}
Expand All @@ -1356,7 +1356,7 @@ static int cx25840_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *fr
struct cx25840_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);

if (!state->is_cx25836)
if (!is_cx2583x(state))
input_change(client);
return 0;
}
Expand All @@ -1373,7 +1373,7 @@ static int cx25840_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
return 0;

vt->signal = vpres ? 0xffff : 0x0;
if (state->is_cx25836)
if (is_cx2583x(state))
return 0;

vt->capability |=
Expand Down Expand Up @@ -1404,7 +1404,7 @@ static int cx25840_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
struct cx25840_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);

if (state->radio || state->is_cx25836)
if (state->radio || is_cx2583x(state))
return 0;

switch (vt->audmode) {
Expand Down Expand Up @@ -1445,11 +1445,11 @@ static int cx25840_reset(struct v4l2_subdev *sd, u32 val)
struct cx25840_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);

if (state->is_cx25836)
if (is_cx2583x(state))
cx25836_initialize(client);
else if (state->is_cx23885)
else if (is_cx2388x(state))
cx23885_initialize(client);
else if (state->is_cx231xx)
else if (is_cx231xx(state))
cx231xx_initialize(client);
else
cx25840_initialize(client);
Expand All @@ -1470,7 +1470,7 @@ static int cx25840_log_status(struct v4l2_subdev *sd)
struct i2c_client *client = v4l2_get_subdevdata(sd);

log_video_status(client);
if (!state->is_cx25836)
if (!is_cx2583x(state))
log_audio_status(client);
return 0;
}
Expand Down Expand Up @@ -1594,22 +1594,18 @@ static int cx25840_probe(struct i2c_client *client,
v4l2_i2c_subdev_init(sd, client, &cx25840_ops);
switch (id) {
case V4L2_IDENT_CX23885_AV:
state->is_cx23885 = 1;
v4l_info(client, "cx23885 A/V decoder found @ 0x%x (%s)\n",
client->addr << 1, client->adapter->name);
break;
case V4L2_IDENT_CX23887_AV:
state->is_cx23885 = 1;
v4l_info(client, "cx23887 A/V decoder found @ 0x%x (%s)\n",
client->addr << 1, client->adapter->name);
break;
case V4L2_IDENT_CX23888_AV:
state->is_cx23885 = 1;
v4l_info(client, "cx23888 A/V decoder found @ 0x%x (%s)\n",
client->addr << 1, client->adapter->name);
break;
case V4L2_IDENT_CX2310X_AV:
state->is_cx231xx = 1;
v4l_info(client, "cx%d A/V decoder found @ 0x%x (%s)\n",
device_id, client->addr << 1, client->adapter->name);
break;
Expand All @@ -1627,7 +1623,6 @@ static int cx25840_probe(struct i2c_client *client,
break;
case V4L2_IDENT_CX25836:
case V4L2_IDENT_CX25837:
state->is_cx25836 = 1;
default:
v4l_info(client, "cx25%3x-%x found @ 0x%x (%s)\n",
(device_id & 0xfff0) >> 4, device_id & 0x0f,
Expand Down
Loading

0 comments on commit 2a03f03

Please sign in to comment.