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,29 +363,30 @@ 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) {
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;
}
int cx25840_audio_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
case VIDIOC_G_CTRL:
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
ctrl->value = get_volume(client);
......@@ -405,9 +406,13 @@ int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg)
default:
return -EINVAL;
}
break;
return 0;
}
int cx25840_audio_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
case VIDIOC_S_CTRL:
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
set_volume(client, ctrl->value);
......@@ -427,11 +432,5 @@ int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg)
default:
return -EINVAL;
}
break;
default:
return -EINVAL;
}
return 0;
}
......@@ -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;
......@@ -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;
}
......@@ -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;
}
......@@ -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;
......@@ -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);
......
......@@ -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
......@@ -82,16 +82,12 @@ static int decode_vps(u8 * dst, u8 * p)
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 v4l2_format *fmt;
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct cx25840_state *state = to_state(sd);
struct v4l2_sliced_vbi_format *svbi;
switch (cmd) {
case VIDIOC_G_FMT:
{
static u16 lcr2vbi[] = {
static const u16 lcr2vbi[] = {
0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */
0, V4L2_SLICED_WSS_625, 0, /* 4 */
V4L2_SLICED_CAPTION_525, /* 6 */
......@@ -101,14 +97,13 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
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;
return 0;
if (is_pal) {
for (i = 7; i <= 23; i++) {
......@@ -116,31 +111,32 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
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];
svbi->service_set |= svbi->service_lines[0][i] |
svbi->service_lines[1][i];
}
}
else {
} else {
for (i = 10; i <= 21; i++) {
u8 v = cx25840_read(client, 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];
svbi->service_set |= svbi->service_lines[0][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)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct cx25840_state *state = to_state(sd);
struct v4l2_sliced_vbi_format *svbi;
int is_pal = !(state->std & V4L2_STD_525_60);
int vbi_offset = is_pal ? 1 : 0;
int i, x;
u8 lcr[24];
fmt = arg;
if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE &&
fmt->type != V4L2_BUF_TYPE_VBI_CAPTURE)
return -EINVAL;
......@@ -155,7 +151,7 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
/* VBI Offset */
cx25840_write(client, 0x47f, vbi_offset);
cx25840_write(client, 0x404, 0x2e);
break;
return 0;
}
for (x = 0; x <= 23; x++)
......@@ -203,39 +199,30 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
}
if (is_pal) {
for (x = 1, i = 0x424; i <= 0x434; i++, x++) {
for (x = 1, i = 0x424; i <= 0x434; i++, x++)
cx25840_write(client, i, lcr[6 + x]);
}
}
else {
for (x = 1, i = 0x424; i <= 0x430; i++, x++) {
} else {
for (x = 1, i = 0x424; i <= 0x430; i++, x++)
cx25840_write(client, i, lcr[9 + x]);
}
for (i = 0x431; i <= 0x434; i++) {
for (i = 0x431; i <= 0x434; i++)
cx25840_write(client, i, 0);
}
}
cx25840_write(client, 0x43c, 0x16);
cx25840_write(client, 0x474, is_pal ? 0x2a : 0x22);
return 0;
}
if (is_pal) {
cx25840_write(client, 0x474, 0x2a);
} else {
cx25840_write(client, 0x474, 0x22);
}
break;
}
case VIDIOC_INT_DECODE_VBI_LINE:
{
struct v4l2_decode_vbi_line *vbi = arg;
int cx25840_decode_vbi_line(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi)
{
struct cx25840_state *state = to_state(sd);
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;
break;
return 0;
}
p += 4;
......@@ -258,9 +245,8 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
break;
case 9:
id2 = V4L2_SLICED_VPS;
if (decode_vps(p, p) != 0) {
if (decode_vps(p, p) != 0)
err = 1;
}
break;
default:
id2 = 0;
......@@ -272,9 +258,5 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
vbi->line = err ? 0 : l;
vbi->is_second_field = err ? 0 : (id1 == 0x55);
vbi->p = p;
break;
}
}
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