Skip to content

Commit

Permalink
V4L/DVB (11310): cx18: remove intermediate 'ioctl' step
Browse files Browse the repository at this point in the history
The audio and vbi parts still used an 'ioctl'-like interface. Replace this
with normal functions.

Cc: Andy Walls <awalls@radix.net>
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 df1d5ed commit 41c129a
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 255 deletions.
120 changes: 57 additions & 63 deletions drivers/media/video/cx18/cx18-av-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,82 +464,76 @@ static void set_mute(struct cx18 *cx, int mute)
}
}

int cx18_av_audio(struct cx18 *cx, unsigned int cmd, void *arg)
int cx18_av_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
{
struct cx18 *cx = v4l2_get_subdevdata(sd);
struct cx18_av_state *state = &cx->av_state;
struct v4l2_control *ctrl = arg;
int retval;
u8 v;

switch (cmd) {
case VIDIOC_INT_AUDIO_CLOCK_FREQ:
{
u8 v;
if (state->aud_input > CX18_AV_AUDIO_SERIAL2) {
v = cx18_av_read(cx, 0x803) & ~0x10;
cx18_av_write_expect(cx, 0x803, v, v, 0x1f);
cx18_av_write(cx, 0x8d3, 0x1f);
}
v = cx18_av_read(cx, 0x810) | 0x1;
cx18_av_write_expect(cx, 0x810, v, v, 0x0f);
if (state->aud_input > CX18_AV_AUDIO_SERIAL2) {
v = cx18_av_read(cx, 0x803) & ~0x10;
cx18_av_write_expect(cx, 0x803, v, v, 0x1f);
cx18_av_write(cx, 0x8d3, 0x1f);
}
v = cx18_av_read(cx, 0x810) | 0x1;
cx18_av_write_expect(cx, 0x810, v, v, 0x0f);

retval = set_audclk_freq(cx, *(u32 *)arg);
retval = set_audclk_freq(cx, freq);

v = cx18_av_read(cx, 0x810) & ~0x1;
cx18_av_write_expect(cx, 0x810, v, v, 0x0f);
if (state->aud_input > CX18_AV_AUDIO_SERIAL2) {
v = cx18_av_read(cx, 0x803) | 0x10;
cx18_av_write_expect(cx, 0x803, v, v, 0x1f);
}
return retval;
v = cx18_av_read(cx, 0x810) & ~0x1;
cx18_av_write_expect(cx, 0x810, v, v, 0x0f);
if (state->aud_input > CX18_AV_AUDIO_SERIAL2) {
v = cx18_av_read(cx, 0x803) | 0x10;
cx18_av_write_expect(cx, 0x803, v, v, 0x1f);
}
return retval;
}

case VIDIOC_G_CTRL:
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
ctrl->value = get_volume(cx);
break;
case V4L2_CID_AUDIO_BASS:
ctrl->value = get_bass(cx);
break;
case V4L2_CID_AUDIO_TREBLE:
ctrl->value = get_treble(cx);
break;
case V4L2_CID_AUDIO_BALANCE:
ctrl->value = get_balance(cx);
break;
case V4L2_CID_AUDIO_MUTE:
ctrl->value = get_mute(cx);
break;
default:
return -EINVAL;
}
int cx18_av_audio_g_ctrl(struct cx18 *cx, struct v4l2_control *ctrl)
{
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
ctrl->value = get_volume(cx);
break;

case VIDIOC_S_CTRL:
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
set_volume(cx, ctrl->value);
break;
case V4L2_CID_AUDIO_BASS:
set_bass(cx, ctrl->value);
break;
case V4L2_CID_AUDIO_TREBLE:
set_treble(cx, ctrl->value);
break;
case V4L2_CID_AUDIO_BALANCE:
set_balance(cx, ctrl->value);
break;
case V4L2_CID_AUDIO_MUTE:
set_mute(cx, ctrl->value);
break;
default:
return -EINVAL;
}
case V4L2_CID_AUDIO_BASS:
ctrl->value = get_bass(cx);
break;
case V4L2_CID_AUDIO_TREBLE:
ctrl->value = get_treble(cx);
break;
case V4L2_CID_AUDIO_BALANCE:
ctrl->value = get_balance(cx);
break;
case V4L2_CID_AUDIO_MUTE:
ctrl->value = get_mute(cx);
break;

default:
return -EINVAL;
}
return 0;
}

int cx18_av_audio_s_ctrl(struct cx18 *cx, struct v4l2_control *ctrl)
{
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
set_volume(cx, ctrl->value);
break;
case V4L2_CID_AUDIO_BASS:
set_bass(cx, ctrl->value);
break;
case V4L2_CID_AUDIO_TREBLE:
set_treble(cx, ctrl->value);
break;
case V4L2_CID_AUDIO_BALANCE:
set_balance(cx, ctrl->value);
break;
case V4L2_CID_AUDIO_MUTE:
set_mute(cx, ctrl->value);
break;
default:
return -EINVAL;
}
return 0;
}
29 changes: 5 additions & 24 deletions drivers/media/video/cx18/cx18-av-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,19 +413,6 @@ void cx18_av_std_setup(struct cx18 *cx)
cx18_av_write(cx, 0x47f, state->slicer_line_delay);
}

static int cx18_av_decode_vbi_line(struct v4l2_subdev *sd,
struct v4l2_decode_vbi_line *vbi_line)
{
struct cx18 *cx = v4l2_get_subdevdata(sd);
return cx18_av_vbi(cx, VIDIOC_INT_DECODE_VBI_LINE, vbi_line);
}

static int cx18_av_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
{
struct cx18 *cx = v4l2_get_subdevdata(sd);
return cx18_av_audio(cx, VIDIOC_INT_AUDIO_CLOCK_FREQ, &freq);
}

static void input_change(struct cx18 *cx)
{
struct cx18_av_state *state = &cx->av_state;
Expand Down Expand Up @@ -772,7 +759,7 @@ static int cx18_av_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:
return cx18_av_audio(cx, VIDIOC_S_CTRL, ctrl);
return cx18_av_audio_s_ctrl(cx, ctrl);

default:
return -EINVAL;
Expand Down Expand Up @@ -802,7 +789,7 @@ static int cx18_av_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:
return cx18_av_audio(cx, VIDIOC_G_CTRL, ctrl);
return cx18_av_audio_g_ctrl(cx, ctrl);
default:
return -EINVAL;
}
Expand Down Expand Up @@ -845,13 +832,7 @@ static int cx18_av_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
{
struct cx18 *cx = v4l2_get_subdevdata(sd);

switch (fmt->type) {
case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
return cx18_av_vbi(cx, VIDIOC_G_FMT, fmt);
default:
return -EINVAL;
}
return 0;
return cx18_av_vbi_g_fmt(cx, fmt);
}

static int cx18_av_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
Expand Down Expand Up @@ -925,10 +906,10 @@ static int cx18_av_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
break;

case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
return cx18_av_vbi(cx, VIDIOC_S_FMT, fmt);
return cx18_av_vbi_s_fmt(cx, fmt);

case V4L2_BUF_TYPE_VBI_CAPTURE:
return cx18_av_vbi(cx, VIDIOC_S_FMT, fmt);
return cx18_av_vbi_s_fmt(cx, fmt);

default:
return -EINVAL;
Expand Down
9 changes: 7 additions & 2 deletions drivers/media/video/cx18/cx18-av-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,16 @@ int cx18_av_loadfw(struct cx18 *cx);

/* ----------------------------------------------------------------------- */
/* cx18_av-audio.c */
int cx18_av_audio(struct cx18 *cx, unsigned int cmd, void *arg);
int cx18_av_audio_g_ctrl(struct cx18 *cx, struct v4l2_control *ctrl);
int cx18_av_audio_s_ctrl(struct cx18 *cx, struct v4l2_control *ctrl);
int cx18_av_s_clock_freq(struct v4l2_subdev *sd, u32 freq);
void cx18_av_audio_set_path(struct cx18 *cx);

/* ----------------------------------------------------------------------- */
/* cx18_av-vbi.c */
int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg);
int cx18_av_decode_vbi_line(struct v4l2_subdev *sd,
struct v4l2_decode_vbi_line *vbi);
int cx18_av_vbi_g_fmt(struct cx18 *cx, struct v4l2_format *fmt);
int cx18_av_vbi_s_fmt(struct cx18 *cx, struct v4l2_format *fmt);

#endif
Loading

0 comments on commit 41c129a

Please sign in to comment.