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

V4L/DVB (11309): cx25840: cleanup: remove intermediate 'ioctl' step

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: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 2c26976d
...@@ -363,75 +363,74 @@ static void set_mute(struct i2c_client *client, int mute) ...@@ -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 i2c_client *client = v4l2_get_subdevdata(sd);
struct v4l2_control *ctrl = arg; struct cx25840_state *state = to_state(sd);
int retval; int retval;
switch (cmd) { if (!state->is_cx25836)
case VIDIOC_INT_AUDIO_CLOCK_FREQ: cx25840_and_or(client, 0x810, ~0x1, 1);
if (!state->is_cx25836) if (state->aud_input != CX25840_AUDIO_SERIAL) {
cx25840_and_or(client, 0x810, ~0x1, 1); cx25840_and_or(client, 0x803, ~0x10, 0);
if (state->aud_input != CX25840_AUDIO_SERIAL) { cx25840_write(client, 0x8d3, 0x1f);
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)
retval = set_audclk_freq(client, *(u32 *)arg); cx25840_and_or(client, 0x803, ~0x10, 0x10);
if (state->aud_input != CX25840_AUDIO_SERIAL) { if (!state->is_cx25836)
cx25840_and_or(client, 0x803, ~0x10, 0x10); cx25840_and_or(client, 0x810, ~0x1, 0);
} return retval;
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;
case VIDIOC_S_CTRL: int cx25840_audio_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
switch (ctrl->id) { {
case V4L2_CID_AUDIO_VOLUME: struct i2c_client *client = v4l2_get_subdevdata(sd);
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;
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: default:
return -EINVAL; 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; return 0;
} }
...@@ -775,7 +775,7 @@ static int cx25840_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) ...@@ -775,7 +775,7 @@ static int cx25840_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
case V4L2_CID_AUDIO_MUTE: case V4L2_CID_AUDIO_MUTE:
if (state->is_cx25836) if (state->is_cx25836)
return -EINVAL; return -EINVAL;
return cx25840_audio(client, VIDIOC_S_CTRL, ctrl); return cx25840_audio_s_ctrl(sd, ctrl);
default: default:
return -EINVAL; return -EINVAL;
...@@ -812,7 +812,7 @@ static int cx25840_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) ...@@ -812,7 +812,7 @@ static int cx25840_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
case V4L2_CID_AUDIO_MUTE: case V4L2_CID_AUDIO_MUTE:
if (state->is_cx25836) if (state->is_cx25836)
return -EINVAL; return -EINVAL;
return cx25840_audio(client, VIDIOC_G_CTRL, ctrl); return cx25840_audio_g_ctrl(sd, ctrl);
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -828,7 +828,7 @@ static int cx25840_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt) ...@@ -828,7 +828,7 @@ static int cx25840_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
switch (fmt->type) { switch (fmt->type) {
case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
return cx25840_vbi(client, VIDIOC_G_FMT, fmt); return cx25840_vbi_g_fmt(sd, fmt);
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -890,10 +890,10 @@ static int cx25840_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt) ...@@ -890,10 +890,10 @@ static int cx25840_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 cx25840_vbi(client, VIDIOC_S_FMT, fmt); return cx25840_vbi_s_fmt(sd, fmt);
case V4L2_BUF_TYPE_VBI_CAPTURE: case V4L2_BUF_TYPE_VBI_CAPTURE:
return cx25840_vbi(client, VIDIOC_S_FMT, fmt); return cx25840_vbi_s_fmt(sd, fmt);
default: default:
return -EINVAL; return -EINVAL;
...@@ -1153,20 +1153,6 @@ static int cx25840_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * ...@@ -1153,20 +1153,6 @@ static int cx25840_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *
} }
#endif #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) static int cx25840_s_stream(struct v4l2_subdev *sd, int enable)
{ {
struct cx25840_state *state = to_state(sd); struct cx25840_state *state = to_state(sd);
......
...@@ -75,11 +75,15 @@ int cx25840_loadfw(struct i2c_client *client); ...@@ -75,11 +75,15 @@ int cx25840_loadfw(struct i2c_client *client);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* cx25850-audio.c */ /* cx25850-audio.c */
int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg);
void cx25840_audio_set_path(struct i2c_client *client); 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 */ /* 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 #endif
...@@ -82,199 +82,181 @@ static int decode_vps(u8 * dst, u8 * p) ...@@ -82,199 +82,181 @@ static int decode_vps(u8 * dst, u8 * p)
return err & 0xf0; return err & 0xf0;
} }
int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg) int cx25840_vbi_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
{ {
struct cx25840_state *state = to_state(i2c_get_clientdata(client)); struct i2c_client *client = v4l2_get_subdevdata(sd);
struct v4l2_format *fmt; struct cx25840_state *state = to_state(sd);
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 ((cx25840_read(client, 0x404) & 0x10) == 0)
V4L2_SLICED_CAPTION_525, /* 6 */ return 0;
0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */
0, 0, 0, 0
};
int is_pal = !(state->std & V4L2_STD_525_60);
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 ((cx25840_read(client, 0x404) & 0x10) == 0)
break;
if (is_pal) { if (is_pal) {
for (i = 7; i <= 23; i++) { for (i = 7; i <= 23; i++) {
u8 v = cx25840_read(client, 0x424 + i - 7); u8 v = cx25840_read(client, 0x424 + i - 7);
svbi->service_lines[0][i] = lcr2vbi[v >> 4]; svbi->service_lines[0][i] = lcr2vbi[v >> 4];
svbi->service_lines[1][i] = lcr2vbi[v & 0xf]; svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
svbi->service_set |= svbi->service_set |= svbi->service_lines[0][i] |
svbi->service_lines[0][i] | svbi->service_lines[1][i]; svbi->service_lines[1][i];
}
} }
else { } else {
for (i = 10; i <= 21; i++) { for (i = 10; i <= 21; i++) {
u8 v = cx25840_read(client, 0x424 + i - 10); u8 v = cx25840_read(client, 0x424 + i - 10);
svbi->service_lines[0][i] = lcr2vbi[v >> 4]; svbi->service_lines[0][i] = lcr2vbi[v >> 4];
svbi->service_lines[1][i] = lcr2vbi[v & 0xf]; svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
svbi->service_set |= svbi->service_set |= svbi->service_lines[0][i] |
svbi->service_lines[0][i] | svbi->service_lines[1][i]; svbi->service_lines[1][i];
}
} }
break;
} }
return 0;
}
case VIDIOC_S_FMT: int cx25840_vbi_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
{ {
int is_pal = !(state->std & V4L2_STD_525_60); struct i2c_client *client = v4l2_get_subdevdata(sd);
int vbi_offset = is_pal ? 1 : 0; struct cx25840_state *state = to_state(sd);
int i, x; struct v4l2_sliced_vbi_format *svbi;
u8 lcr[24]; int is_pal = !(state->std & V4L2_STD_525_60);
int vbi_offset = is_pal ? 1 : 0;
fmt = arg; int i, x;
if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE && u8 lcr[24];
fmt->type != V4L2_BUF_TYPE_VBI_CAPTURE)
return -EINVAL; if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE &&
svbi = &fmt->fmt.sliced; fmt->type != V4L2_BUF_TYPE_VBI_CAPTURE)
if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) { return -EINVAL;
/* raw VBI */ svbi = &fmt->fmt.sliced;
memset(svbi, 0, sizeof(*svbi)); if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
/* raw VBI */
/* Setup standard */ memset(svbi, 0, sizeof(*svbi));
cx25840_std_setup(client);
/* VBI Offset */
cx25840_write(client, 0x47f, vbi_offset);
cx25840_write(client, 0x404, 0x2e);
break;
}
for (x = 0; x <= 23; x++)
lcr[x] = 0x00;
/* Setup standard */ /* Setup standard */
cx25840_std_setup(client); cx25840_std_setup(client);
/* Sliced VBI */ /* VBI Offset */
cx25840_write(client, 0x404, 0x32); /* Ancillary data */
cx25840_write(client, 0x406, 0x13);
cx25840_write(client, 0x47f, vbi_offset); cx25840_write(client, 0x47f, vbi_offset);
cx25840_write(client, 0x404, 0x2e);
return 0;
}
if (is_pal) { for (x = 0; x <= 23; x++)
for (i = 0; i <= 6; i++) lcr[x] = 0x00;
svbi->service_lines[0][i] =
svbi->service_lines[1][i] = 0; /* Setup standard */
} else { cx25840_std_setup(client);
for (i = 0; i <= 9; i++)
svbi->service_lines[0][i] = /* Sliced VBI */
svbi->service_lines[1][i] = 0; cx25840_write(client, 0x404, 0x32); /* Ancillary data */
cx25840_write(client, 0x406, 0x13);
for (i = 22; i <= 23; i++) cx25840_write(client, 0x47f, vbi_offset);
svbi->service_lines[0][i] =
svbi->service_lines[1][i] = 0; if (is_pal) {
} for (i = 0; i <= 6; i++)
svbi->service_lines[0][i] =
for (i = 7; i <= 23; i++) { svbi->service_lines[1][i] = 0;
for (x = 0; x <= 1; x++) { } else {
switch (svbi->service_lines[1-x][i]) { for (i = 0; i <= 9; i++)
case V4L2_SLICED_TELETEXT_B: svbi->service_lines[0][i] =
lcr[i] |= 1 << (4 * x); svbi->service_lines[1][i] = 0;
break;
case V4L2_SLICED_WSS_625: for (i = 22; i <= 23; i++)
lcr[i] |= 4 << (4 * x); svbi->service_lines[0][i] =
break; svbi->service_lines[1][i] = 0;
case V4L2_SLICED_CAPTION_525: }
lcr[i] |= 6 << (4 * x);
break;
case V4L2_SLICED_VPS:
lcr[i] |= 9 << (4 * x);
break;
}
}
}
if (is_pal) { for (i = 7; i <= 23; i++) {
for (x = 1, i = 0x424; i <= 0x434; i++, x++) { for (x = 0; x <= 1; x++) {
cx25840_write(client, i, lcr[6 + x]); switch (svbi->service_lines[1-x][i]) {
} case V4L2_SLICED_TELETEXT_B:
} lcr[i] |= 1 << (4 * x);
else { break;
for (x = 1, i = 0x424; i <= 0x430; i++, x++) { case V4L2_SLICED_WSS_625:
cx25840_write(client, i, lcr[9 + x]); lcr[i] |= 4 << (4 * x);
} break;
for (i = 0x431; i <= 0x434; i++) { case V4L2_SLICED_CAPTION_525:
cx25840_write(client, i, 0); lcr[i] |= 6 << (4 * x);
break;
case V4L2_SLICED_VPS:
lcr[i] |= 9 << (4 * x);
break;
} }
} }
}
cx25840_write(client, 0x43c, 0x16); if (is_pal) {
for (x = 1, i = 0x424; i <= 0x434; i++, x++)
if (is_pal) { cx25840_write(client, i, lcr[6 + x]);
cx25840_write(client, 0x474, 0x2a); } else {
} else { for (x = 1, i = 0x424; i <= 0x430; i++, x++)
cx25840_write(client, 0x474, 0x22); cx25840_write(client, i, lcr[9 + x]);
} for (i = 0x431; i <= 0x434; i++)
break; cx25840_write(client, i, 0);
} }
case VIDIOC_INT_DECODE_VBI_LINE: cx25840_write(client, 0x43c, 0x16);
{ cx25840_write(client, 0x474, is_pal ? 0x2a : 0x22);
struct v4l2_decode_vbi_line *vbi = arg; return 0;
u8 *p = vbi->p; }
int id1, id2, l, err = 0;
if (p[0] || p[1] != 0xff || p[2] != 0xff || int cx25840_decode_vbi_line(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi)
(p[3] != 0x55 && p[3] != 0x91)) { {
vbi->line = vbi->type = 0; struct cx25840_state *state = to_state(sd);
break; u8 *p = vbi->p;
} int id1, id2, l, err = 0;
if (p[0] || p[1] != 0xff || p[2] != 0xff ||
(p[3] != 0x55 && p[3] != 0x91)) {
vbi->line = vbi->type = 0;
return 0;
}
p += 4; p += 4;
id1 = p[-1]; id1 = p[-1];
id2 = p[0] & 0xf; id2 = p[0] & 0xf;
l = p[2] & 0x3f; l = p[2] & 0x3f;
l += state->vbi_line_offset; l += state->vbi_line_offset;
p += 4; p += 4;
switch (id2) { switch (id2) {
case 1: case 1:
id2 = V4L2_SLICED_TELETEXT_B; id2 = V4L2_SLICED_TELETEXT_B;
break; break;
case 4: case 4:
id2 = V4L2_SLICED_WSS_625; id2 = V4L2_SLICED_WSS_625;
break; break;
case 6: case 6:
id2 = V4L2_SLICED_CAPTION_525; id2 = V4L2_SLICED_CAPTION_525;
err = !odd_parity(p[0]) || !odd_parity(p[1]); err = !odd_parity(p[0]) || !odd_parity(p[1]);
break; break;
case 9: case 9:
id2 = V4L2_SLICED_VPS; id2 = V4L2_SLICED_VPS;
if (decode_vps(p, p) != 0) { if (decode_vps(p, p) != 0)
err = 1;
}
break;
default:
id2 = 0;
err = 1; err = 1;
break;
}
vbi->type = err ? 0 : id2;
vbi->line = err ? 0 : l;
vbi->is_second_field = err ? 0 : (id1 == 0x55);
vbi->p = p;
break; break;
} default:
id2 = 0;
err = 1;
break;
} }
vbi->type = err ? 0 : id2;
vbi->line = err ? 0 : l;
vbi->is_second_field = err ? 0 : (id1 == 0x55);
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