Skip to content

Commit

Permalink
V4L/DVB (11309): cx25840: cleanup: remove intermediate 'ioctl' step
Browse files Browse the repository at this point in the history
The audio and vbi functions where still called through an ioctl-like
interface, even though this is no longer needed with v4l2-subdev. Just
change each 'case' into a proper function and call that directly.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Mar 30, 2009
1 parent 2c26976 commit df1d5ed
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 248 deletions.
121 changes: 60 additions & 61 deletions drivers/media/video/cx25840/cx25840-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,75 +363,74 @@ static void set_mute(struct i2c_client *client, int mute)
}
}

int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg)
int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
{
struct cx25840_state *state = to_state(i2c_get_clientdata(client));
struct v4l2_control *ctrl = arg;
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct cx25840_state *state = to_state(sd);
int retval;

switch (cmd) {
case VIDIOC_INT_AUDIO_CLOCK_FREQ:
if (!state->is_cx25836)
cx25840_and_or(client, 0x810, ~0x1, 1);
if (state->aud_input != CX25840_AUDIO_SERIAL) {
cx25840_and_or(client, 0x803, ~0x10, 0);
cx25840_write(client, 0x8d3, 0x1f);
}
retval = set_audclk_freq(client, *(u32 *)arg);
if (state->aud_input != CX25840_AUDIO_SERIAL) {
cx25840_and_or(client, 0x803, ~0x10, 0x10);
}
if (!state->is_cx25836)
cx25840_and_or(client, 0x810, ~0x1, 0);
return retval;

case VIDIOC_G_CTRL:
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
ctrl->value = get_volume(client);
break;
case V4L2_CID_AUDIO_BASS:
ctrl->value = get_bass(client);
break;
case V4L2_CID_AUDIO_TREBLE:
ctrl->value = get_treble(client);
break;
case V4L2_CID_AUDIO_BALANCE:
ctrl->value = get_balance(client);
break;
case V4L2_CID_AUDIO_MUTE:
ctrl->value = get_mute(client);
break;
default:
return -EINVAL;
}
break;
if (!state->is_cx25836)
cx25840_and_or(client, 0x810, ~0x1, 1);
if (state->aud_input != CX25840_AUDIO_SERIAL) {
cx25840_and_or(client, 0x803, ~0x10, 0);
cx25840_write(client, 0x8d3, 0x1f);
}
retval = set_audclk_freq(client, freq);
if (state->aud_input != CX25840_AUDIO_SERIAL)
cx25840_and_or(client, 0x803, ~0x10, 0x10);
if (!state->is_cx25836)
cx25840_and_or(client, 0x810, ~0x1, 0);
return retval;
}

case VIDIOC_S_CTRL:
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
set_volume(client, ctrl->value);
break;
case V4L2_CID_AUDIO_BASS:
set_bass(client, ctrl->value);
break;
case V4L2_CID_AUDIO_TREBLE:
set_treble(client, ctrl->value);
break;
case V4L2_CID_AUDIO_BALANCE:
set_balance(client, ctrl->value);
break;
case V4L2_CID_AUDIO_MUTE:
set_mute(client, ctrl->value);
break;
default:
return -EINVAL;
}
break;
int cx25840_audio_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
ctrl->value = get_volume(client);
break;
case V4L2_CID_AUDIO_BASS:
ctrl->value = get_bass(client);
break;
case V4L2_CID_AUDIO_TREBLE:
ctrl->value = get_treble(client);
break;
case V4L2_CID_AUDIO_BALANCE:
ctrl->value = get_balance(client);
break;
case V4L2_CID_AUDIO_MUTE:
ctrl->value = get_mute(client);
break;
default:
return -EINVAL;
}
return 0;
}

int cx25840_audio_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
set_volume(client, ctrl->value);
break;
case V4L2_CID_AUDIO_BASS:
set_bass(client, ctrl->value);
break;
case V4L2_CID_AUDIO_TREBLE:
set_treble(client, ctrl->value);
break;
case V4L2_CID_AUDIO_BALANCE:
set_balance(client, ctrl->value);
break;
case V4L2_CID_AUDIO_MUTE:
set_mute(client, ctrl->value);
break;
default:
return -EINVAL;
}
return 0;
}
24 changes: 5 additions & 19 deletions drivers/media/video/cx25840/cx25840-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ static int cx25840_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
case V4L2_CID_AUDIO_MUTE:
if (state->is_cx25836)
return -EINVAL;
return cx25840_audio(client, VIDIOC_S_CTRL, ctrl);
return cx25840_audio_s_ctrl(sd, ctrl);

default:
return -EINVAL;
Expand Down Expand Up @@ -812,7 +812,7 @@ static int cx25840_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
case V4L2_CID_AUDIO_MUTE:
if (state->is_cx25836)
return -EINVAL;
return cx25840_audio(client, VIDIOC_G_CTRL, ctrl);
return cx25840_audio_g_ctrl(sd, ctrl);
default:
return -EINVAL;
}
Expand All @@ -828,7 +828,7 @@ static int cx25840_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)

switch (fmt->type) {
case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
return cx25840_vbi(client, VIDIOC_G_FMT, fmt);
return cx25840_vbi_g_fmt(sd, fmt);
default:
return -EINVAL;
}
Expand Down Expand Up @@ -890,10 +890,10 @@ static int cx25840_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
break;

case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
return cx25840_vbi(client, VIDIOC_S_FMT, fmt);
return cx25840_vbi_s_fmt(sd, fmt);

case V4L2_BUF_TYPE_VBI_CAPTURE:
return cx25840_vbi(client, VIDIOC_S_FMT, fmt);
return cx25840_vbi_s_fmt(sd, fmt);

default:
return -EINVAL;
Expand Down Expand Up @@ -1153,20 +1153,6 @@ static int cx25840_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *
}
#endif

static int cx25840_decode_vbi_line(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

return cx25840_vbi(client, VIDIOC_INT_DECODE_VBI_LINE, vbi);
}

static int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

return cx25840_audio(client, VIDIOC_INT_AUDIO_CLOCK_FREQ, &freq);
}

static int cx25840_s_stream(struct v4l2_subdev *sd, int enable)
{
struct cx25840_state *state = to_state(sd);
Expand Down
8 changes: 6 additions & 2 deletions drivers/media/video/cx25840/cx25840-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@ int cx25840_loadfw(struct i2c_client *client);

/* ----------------------------------------------------------------------- */
/* cx25850-audio.c */
int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg);
void cx25840_audio_set_path(struct i2c_client *client);
int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq);
int cx25840_audio_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
int cx25840_audio_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl);

/* ----------------------------------------------------------------------- */
/* cx25850-vbi.c */
int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg);
int cx25840_vbi_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt);
int cx25840_vbi_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt);
int cx25840_decode_vbi_line(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi);

#endif
Loading

0 comments on commit df1d5ed

Please sign in to comment.