Commit 41c129a8 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (11310): cx18: remove intermediate 'ioctl' step

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: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent df1d5ed8
...@@ -464,82 +464,76 @@ static void set_mute(struct cx18 *cx, int mute) ...@@ -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 cx18_av_state *state = &cx->av_state;
struct v4l2_control *ctrl = arg;
int retval; int retval;
u8 v;
switch (cmd) { if (state->aud_input > CX18_AV_AUDIO_SERIAL2) {
case VIDIOC_INT_AUDIO_CLOCK_FREQ: v = cx18_av_read(cx, 0x803) & ~0x10;
{ cx18_av_write_expect(cx, 0x803, v, v, 0x1f);
u8 v; cx18_av_write(cx, 0x8d3, 0x1f);
if (state->aud_input > CX18_AV_AUDIO_SERIAL2) { }
v = cx18_av_read(cx, 0x803) & ~0x10; v = cx18_av_read(cx, 0x810) | 0x1;
cx18_av_write_expect(cx, 0x803, v, v, 0x1f); cx18_av_write_expect(cx, 0x810, v, v, 0x0f);
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; v = cx18_av_read(cx, 0x810) & ~0x1;
cx18_av_write_expect(cx, 0x810, v, v, 0x0f); cx18_av_write_expect(cx, 0x810, v, v, 0x0f);
if (state->aud_input > CX18_AV_AUDIO_SERIAL2) { if (state->aud_input > CX18_AV_AUDIO_SERIAL2) {
v = cx18_av_read(cx, 0x803) | 0x10; v = cx18_av_read(cx, 0x803) | 0x10;
cx18_av_write_expect(cx, 0x803, v, v, 0x1f); cx18_av_write_expect(cx, 0x803, v, v, 0x1f);
}
return retval;
} }
return retval;
}
case VIDIOC_G_CTRL: int cx18_av_audio_g_ctrl(struct cx18 *cx, struct v4l2_control *ctrl)
switch (ctrl->id) { {
case V4L2_CID_AUDIO_VOLUME: switch (ctrl->id) {
ctrl->value = get_volume(cx); case V4L2_CID_AUDIO_VOLUME:
break; ctrl->value = get_volume(cx);
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;
}
break; break;
case V4L2_CID_AUDIO_BASS:
case VIDIOC_S_CTRL: ctrl->value = get_bass(cx);
switch (ctrl->id) { break;
case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_TREBLE:
set_volume(cx, ctrl->value); ctrl->value = get_treble(cx);
break; break;
case V4L2_CID_AUDIO_BASS: case V4L2_CID_AUDIO_BALANCE:
set_bass(cx, ctrl->value); ctrl->value = get_balance(cx);
break; break;
case V4L2_CID_AUDIO_TREBLE: case V4L2_CID_AUDIO_MUTE:
set_treble(cx, ctrl->value); ctrl->value = get_mute(cx);
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;
}
break; break;
default: default:
return -EINVAL; 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; return 0;
} }
...@@ -413,19 +413,6 @@ void cx18_av_std_setup(struct cx18 *cx) ...@@ -413,19 +413,6 @@ void cx18_av_std_setup(struct cx18 *cx)
cx18_av_write(cx, 0x47f, state->slicer_line_delay); 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) static void input_change(struct cx18 *cx)
{ {
struct cx18_av_state *state = &cx->av_state; struct cx18_av_state *state = &cx->av_state;
...@@ -772,7 +759,7 @@ static int cx18_av_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) ...@@ -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_TREBLE:
case V4L2_CID_AUDIO_BALANCE: case V4L2_CID_AUDIO_BALANCE:
case V4L2_CID_AUDIO_MUTE: case V4L2_CID_AUDIO_MUTE:
return cx18_av_audio(cx, VIDIOC_S_CTRL, ctrl); return cx18_av_audio_s_ctrl(cx, ctrl);
default: default:
return -EINVAL; return -EINVAL;
...@@ -802,7 +789,7 @@ static int cx18_av_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) ...@@ -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_TREBLE:
case V4L2_CID_AUDIO_BALANCE: case V4L2_CID_AUDIO_BALANCE:
case V4L2_CID_AUDIO_MUTE: case V4L2_CID_AUDIO_MUTE:
return cx18_av_audio(cx, VIDIOC_G_CTRL, ctrl); return cx18_av_audio_g_ctrl(cx, ctrl);
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -845,13 +832,7 @@ static int cx18_av_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt) ...@@ -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); struct cx18 *cx = v4l2_get_subdevdata(sd);
switch (fmt->type) { return cx18_av_vbi_g_fmt(cx, fmt);
case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
return cx18_av_vbi(cx, VIDIOC_G_FMT, fmt);
default:
return -EINVAL;
}
return 0;
} }
static int cx18_av_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt) static int cx18_av_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
...@@ -925,10 +906,10 @@ static int cx18_av_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt) ...@@ -925,10 +906,10 @@ static int cx18_av_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
break; break;
case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: 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: case V4L2_BUF_TYPE_VBI_CAPTURE:
return cx18_av_vbi(cx, VIDIOC_S_FMT, fmt); return cx18_av_vbi_s_fmt(cx, fmt);
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -355,11 +355,16 @@ int cx18_av_loadfw(struct cx18 *cx); ...@@ -355,11 +355,16 @@ int cx18_av_loadfw(struct cx18 *cx);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* cx18_av-audio.c */ /* 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); void cx18_av_audio_set_path(struct cx18 *cx);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* cx18_av-vbi.c */ /* 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 #endif
...@@ -129,196 +129,189 @@ static int decode_vps(u8 *dst, u8 *p) ...@@ -129,196 +129,189 @@ static int decode_vps(u8 *dst, u8 *p)
return err & 0xf0; return err & 0xf0;
} }
int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg) int cx18_av_vbi_g_fmt(struct cx18 *cx, struct v4l2_format *fmt)
{ {
struct cx18_av_state *state = &cx->av_state; struct cx18_av_state *state = &cx->av_state;
struct v4l2_format *fmt;
struct v4l2_sliced_vbi_format *svbi; struct v4l2_sliced_vbi_format *svbi;
static const u16 lcr2vbi[] = {
0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */
0, V4L2_SLICED_WSS_625, 0, /* 4 */
V4L2_SLICED_CAPTION_525, /* 6 */
0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */
0, 0, 0, 0
};
int is_pal = !(state->std & V4L2_STD_525_60);
int i;
switch (cmd) { if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
case VIDIOC_G_FMT: return -EINVAL;
{ svbi = &fmt->fmt.sliced;
static u16 lcr2vbi[] = { memset(svbi, 0, sizeof(*svbi));
0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */ /* we're done if raw VBI is active */
0, V4L2_SLICED_WSS_625, 0, /* 4 */ if ((cx18_av_read(cx, 0x404) & 0x10) == 0)
V4L2_SLICED_CAPTION_525, /* 6 */ return 0;
0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */
0, 0, 0, 0 if (is_pal) {
}; for (i = 7; i <= 23; i++) {
int is_pal = !(state->std & V4L2_STD_525_60); u8 v = cx18_av_read(cx, 0x424 + i - 7);
int i;
fmt = arg;
if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
return -EINVAL;
svbi = &fmt->fmt.sliced;
memset(svbi, 0, sizeof(*svbi));
/* we're done if raw VBI is active */
if ((cx18_av_read(cx, 0x404) & 0x10) == 0)
break;
if (is_pal) {
for (i = 7; i <= 23; i++) {
u8 v = cx18_av_read(cx, 0x424 + i - 7);
svbi->service_lines[0][i] = lcr2vbi[v >> 4];
svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
svbi->service_set |= svbi->service_lines[0][i] |
svbi->service_lines[1][i];
}
} else {
for (i = 10; i <= 21; i++) {
u8 v = cx18_av_read(cx, 0x424 + i - 10);
svbi->service_lines[0][i] = lcr2vbi[v >> 4];
svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
svbi->service_set |= svbi->service_lines[0][i] |
svbi->service_lines[1][i];
}
}
break;
}
case VIDIOC_S_FMT: svbi->service_lines[0][i] = lcr2vbi[v >> 4];
{ svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
int is_pal = !(state->std & V4L2_STD_525_60); svbi->service_set |= svbi->service_lines[0][i] |
int i, x; svbi->service_lines[1][i];
u8 lcr[24];
fmt = arg;
if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE &&
fmt->type != V4L2_BUF_TYPE_VBI_CAPTURE)
return -EINVAL;
svbi = &fmt->fmt.sliced;
if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
/* raw VBI */
memset(svbi, 0, sizeof(*svbi));
/* Setup standard */
cx18_av_std_setup(cx);
/* VBI Offset */
cx18_av_write(cx, 0x47f, state->slicer_line_delay);
cx18_av_write(cx, 0x404, 0x2e);
break;
} }
} else {
for (i = 10; i <= 21; i++) {
u8 v = cx18_av_read(cx, 0x424 + i - 10);
svbi->service_lines[0][i] = lcr2vbi[v >> 4];
svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
svbi->service_set |= svbi->service_lines[0][i] |
svbi->service_lines[1][i];
}
}
return 0;
}
for (x = 0; x <= 23; x++) int cx18_av_vbi_s_fmt(struct cx18 *cx, struct v4l2_format *fmt)
lcr[x] = 0x00; {
struct cx18_av_state *state = &cx->av_state;
struct v4l2_sliced_vbi_format *svbi;
int is_pal = !(state->std & V4L2_STD_525_60);
int i, x;
u8 lcr[24];
if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE &&
fmt->type != V4L2_BUF_TYPE_VBI_CAPTURE)
return -EINVAL;
svbi = &fmt->fmt.sliced;
if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
/* raw VBI */
memset(svbi, 0, sizeof(*svbi));
/* Setup standard */ /* Setup standard */
cx18_av_std_setup(cx); cx18_av_std_setup(cx);
/* Sliced VBI */ /* VBI Offset */
cx18_av_write(cx, 0x404, 0x32); /* Ancillary data */
cx18_av_write(cx, 0x406, 0x13);
cx18_av_write(cx, 0x47f, state->slicer_line_delay); cx18_av_write(cx, 0x47f, state->slicer_line_delay);
cx18_av_write(cx, 0x404, 0x2e);
return 0;
}
/* Force impossible lines to 0 */ for (x = 0; x <= 23; x++)
if (is_pal) { lcr[x] = 0x00;
for (i = 0; i <= 6; i++)
svbi->service_lines[0][i] = /* Setup standard */
svbi->service_lines[1][i] = 0; cx18_av_std_setup(cx);
} else {
for (i = 0; i <= 9; i++) /* Sliced VBI */
svbi->service_lines[0][i] = cx18_av_write(cx, 0x404, 0x32); /* Ancillary data */
svbi->service_lines[1][i] = 0; cx18_av_write(cx, 0x406, 0x13);
cx18_av_write(cx, 0x47f, state->slicer_line_delay);
for (i = 22; i <= 23; i++)
svbi->service_lines[0][i] = /* Force impossible lines to 0 */
svbi->service_lines[1][i] = 0; if (is_pal) {
} for (i = 0; i <= 6; i++)
svbi->service_lines[0][i] =
svbi->service_lines[1][i] = 0;
} else {
for (i = 0; i <= 9; i++)
svbi->service_lines[0][i] =
svbi->service_lines[1][i] = 0;
for (i = 22; i <= 23; i++)
svbi->service_lines[0][i] =
svbi->service_lines[1][i] = 0;
}
/* Build register values for requested service lines */ /* Build register values for requested service lines */
for (i = 7; i <= 23; i++) { for (i = 7; i <= 23; i++) {
for (x = 0; x <= 1; x++) { for (x = 0; x <= 1; x++) {
switch (svbi->service_lines[1-x][i]) { switch (svbi->service_lines[1-x][i]) {
case V4L2_SLICED_TELETEXT_B: case V4L2_SLICED_TELETEXT_B:
lcr[i] |= 1 << (4 * x); lcr[i] |= 1 << (4 * x);
break; break;
case V4L2_SLICED_WSS_625: case V4L2_SLICED_WSS_625:
lcr[i] |= 4 << (4 * x); lcr[i] |= 4 << (4 * x);
break; break;
case V4L2_SLICED_CAPTION_525: case V4L2_SLICED_CAPTION_525:
lcr[i] |= 6 << (4 * x); lcr[i] |= 6 << (4 * x);
break; break;
case V4L2_SLICED_VPS: case V4L2_SLICED_VPS:
lcr[i] |= 9 << (4 * x); lcr[i] |= 9 << (4 * x);
break; break;
}
} }
} }
}
if (is_pal) { if (is_pal) {
for (x = 1, i = 0x424; i <= 0x434; i++, x++) for (x = 1, i = 0x424; i <= 0x434; i++, x++)
cx18_av_write(cx, i, lcr[6 + x]); cx18_av_write(cx, i, lcr[6 + x]);
} else { } else {
for (x = 1, i = 0x424; i <= 0x430; i++, x++) for (x = 1, i = 0x424; i <= 0x430; i++, x++)
cx18_av_write(cx, i, lcr[9 + x]); cx18_av_write(cx, i, lcr[9 + x]);
for (i = 0x431; i <= 0x434; i++) for (i = 0x431; i <= 0x434; i++)
cx18_av_write(cx, i, 0); cx18_av_write(cx, i, 0);
} }
cx18_av_write(cx, 0x43c, 0x16); cx18_av_write(cx, 0x43c, 0x16);
/* FIXME - should match vblank set in cx18_av_std_setup() */ /* FIXME - should match vblank set in cx18_av_std_setup() */
cx18_av_write(cx, 0x474, is_pal ? 0x2a : 26); cx18_av_write(cx, 0x474, is_pal ? 0x2a : 26);
break; return 0;
}
int cx18_av_decode_vbi_line(struct v4l2_subdev *sd,
struct v4l2_decode_vbi_line *vbi)
{
struct cx18 *cx = v4l2_get_subdevdata(sd);
struct cx18_av_state *state = &cx->av_state;
struct vbi_anc_data *anc = (struct vbi_anc_data *)vbi->p;
u8 *p;
int did, sdid, l, err = 0;
/*
* Check for the ancillary data header for sliced VBI
*/
if (anc->preamble[0] ||
anc->preamble[1] != 0xff || anc->preamble[2] != 0xff ||
(anc->did != sliced_vbi_did[0] &&
anc->did != sliced_vbi_did[1])) {
vbi->line = vbi->type = 0;
return 0;
} }
case VIDIOC_INT_DECODE_VBI_LINE: did = anc->did;
{ sdid = anc->sdid & 0xf;
struct v4l2_decode_vbi_line *vbi = arg; l = anc->idid[0] & 0x3f;
u8 *p; l += state->slicer_line_offset;
struct vbi_anc_data *anc = (struct vbi_anc_data *) vbi->p; p = anc->payload;
int did, sdid, l, err = 0;
/*
* Check for the ancillary data header for sliced VBI
*/
if (anc->preamble[0] ||
anc->preamble[1] != 0xff || anc->preamble[2] != 0xff ||
(anc->did != sliced_vbi_did[0] &&
anc->did != sliced_vbi_did[1])) {
vbi->line = vbi->type = 0;
break;
}
did = anc->did; /* Decode the SDID set by the slicer */
sdid = anc->sdid & 0xf; switch (sdid) {
l = anc->idid[0] & 0x3f; case 1:
l += state->slicer_line_offset; sdid = V4L2_SLICED_TELETEXT_B;
p = anc->payload; break;
case 4:
/* Decode the SDID set by the slicer */ sdid = V4L2_SLICED_WSS_625;
switch (sdid) { break;
case 1: case 6:
sdid = V4L2_SLICED_TELETEXT_B; sdid = V4L2_SLICED_CAPTION_525;
break; err = !odd_parity(p[0]) || !odd_parity(p[1]);
case 4: break;
sdid = V4L2_SLICED_WSS_625; case 9:
break; sdid = V4L2_SLICED_VPS;
case 6: if (decode_vps(p, p) != 0)
sdid = V4L2_SLICED_CAPTION_525;
err = !odd_parity(p[0]) || !odd_parity(p[1]);
break;
case 9:
sdid = V4L2_SLICED_VPS;
if (decode_vps(p, p) != 0)
err = 1;
break;
default:
sdid = 0;
err = 1; err = 1;
break;
}
vbi->type = err ? 0 : sdid;
vbi->line = err ? 0 : l;
vbi->is_second_field = err ? 0 : (did == sliced_vbi_did[1]);
vbi->p = p;
break; break;
} default:
sdid = 0;
err = 1;
break;
} }
vbi->type = err ? 0 : sdid;
vbi->line = err ? 0 : l;
vbi->is_second_field = err ? 0 : (did == sliced_vbi_did[1]);
vbi->p = p;
return 0; return 0;
} }
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