Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+57 −63
Original line number Original line Diff line number Diff line
@@ -464,16 +464,13 @@ 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;

	switch (cmd) {
	case VIDIOC_INT_AUDIO_CLOCK_FREQ:
	{
	u8 v;
	u8 v;

	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);
@@ -482,7 +479,7 @@ int cx18_av_audio(struct cx18 *cx, unsigned int cmd, void *arg)
	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);


		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);
@@ -493,7 +490,8 @@ int cx18_av_audio(struct cx18 *cx, unsigned int cmd, void *arg)
	return retval;
	return retval;
}
}


	case VIDIOC_G_CTRL:
int cx18_av_audio_g_ctrl(struct cx18 *cx, struct v4l2_control *ctrl)
{
	switch (ctrl->id) {
	switch (ctrl->id) {
	case V4L2_CID_AUDIO_VOLUME:
	case V4L2_CID_AUDIO_VOLUME:
		ctrl->value = get_volume(cx);
		ctrl->value = get_volume(cx);
@@ -513,9 +511,11 @@ int cx18_av_audio(struct cx18 *cx, unsigned int cmd, void *arg)
	default:
	default:
		return -EINVAL;
		return -EINVAL;
	}
	}
		break;
	return 0;
}


	case VIDIOC_S_CTRL:
int cx18_av_audio_s_ctrl(struct cx18 *cx, struct v4l2_control *ctrl)
{
	switch (ctrl->id) {
	switch (ctrl->id) {
	case V4L2_CID_AUDIO_VOLUME:
	case V4L2_CID_AUDIO_VOLUME:
		set_volume(cx, ctrl->value);
		set_volume(cx, ctrl->value);
@@ -535,11 +535,5 @@ int cx18_av_audio(struct cx18 *cx, unsigned int cmd, void *arg)
	default:
	default:
		return -EINVAL;
		return -EINVAL;
	}
	}
		break;

	default:
		return -EINVAL;
	}

	return 0;
	return 0;
}
}
+5 −24
Original line number Original line Diff line number Diff line
@@ -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)
	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)
	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)
{
{
	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)
		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;
+7 −2
Original line number Original line Diff line number Diff line
@@ -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
+159 −166
Original line number Original line Diff line number Diff line
@@ -129,16 +129,11 @@ 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[] = {
	switch (cmd) {
	case VIDIOC_G_FMT:
	{
		static u16 lcr2vbi[] = {
		0, V4L2_SLICED_TELETEXT_B, 0,	/* 1 */
		0, V4L2_SLICED_TELETEXT_B, 0,	/* 1 */
		0, V4L2_SLICED_WSS_625, 0,	/* 4 */
		0, V4L2_SLICED_WSS_625, 0,	/* 4 */
		V4L2_SLICED_CAPTION_525,	/* 6 */
		V4L2_SLICED_CAPTION_525,	/* 6 */
@@ -148,14 +143,13 @@ int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg)
	int is_pal = !(state->std & V4L2_STD_525_60);
	int is_pal = !(state->std & V4L2_STD_525_60);
	int i;
	int i;


		fmt = arg;
	if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
	if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
		return -EINVAL;
		return -EINVAL;
	svbi = &fmt->fmt.sliced;
	svbi = &fmt->fmt.sliced;
	memset(svbi, 0, sizeof(*svbi));
	memset(svbi, 0, sizeof(*svbi));
	/* we're done if raw VBI is active */
	/* we're done if raw VBI is active */
	if ((cx18_av_read(cx, 0x404) & 0x10) == 0)
	if ((cx18_av_read(cx, 0x404) & 0x10) == 0)
			break;
		return 0;


	if (is_pal) {
	if (is_pal) {
		for (i = 7; i <= 23; i++) {
		for (i = 7; i <= 23; i++) {
@@ -176,16 +170,17 @@ int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg)
				svbi->service_lines[1][i];
				svbi->service_lines[1][i];
		}
		}
	}
	}
		break;
	return 0;
}
}


	case VIDIOC_S_FMT:
int cx18_av_vbi_s_fmt(struct cx18 *cx, struct v4l2_format *fmt)
{
{
	struct cx18_av_state *state = &cx->av_state;
	struct v4l2_sliced_vbi_format *svbi;
	int is_pal = !(state->std & V4L2_STD_525_60);
	int is_pal = !(state->std & V4L2_STD_525_60);
	int i, x;
	int i, x;
	u8 lcr[24];
	u8 lcr[24];


		fmt = arg;
	if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE &&
	if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE &&
			fmt->type != V4L2_BUF_TYPE_VBI_CAPTURE)
			fmt->type != V4L2_BUF_TYPE_VBI_CAPTURE)
		return -EINVAL;
		return -EINVAL;
@@ -200,7 +195,7 @@ int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg)
		/* VBI Offset */
		/* VBI Offset */
		cx18_av_write(cx, 0x47f, state->slicer_line_delay);
		cx18_av_write(cx, 0x47f, state->slicer_line_delay);
		cx18_av_write(cx, 0x404, 0x2e);
		cx18_av_write(cx, 0x404, 0x2e);
			break;
		return 0;
	}
	}


	for (x = 0; x <= 23; x++)
	for (x = 0; x <= 23; x++)
@@ -262,14 +257,16 @@ int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg)
	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;
}
}


	case VIDIOC_INT_DECODE_VBI_LINE:
int cx18_av_decode_vbi_line(struct v4l2_subdev *sd,
				   struct v4l2_decode_vbi_line *vbi)
{
{
		struct v4l2_decode_vbi_line *vbi = arg;
	struct cx18 *cx = v4l2_get_subdevdata(sd);
		u8 *p;
	struct cx18_av_state *state = &cx->av_state;
	struct vbi_anc_data *anc = (struct vbi_anc_data *)vbi->p;
	struct vbi_anc_data *anc = (struct vbi_anc_data *)vbi->p;
	u8 *p;
	int did, sdid, l, err = 0;
	int did, sdid, l, err = 0;


	/*
	/*
@@ -280,7 +277,7 @@ int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg)
			(anc->did != sliced_vbi_did[0] &&
			(anc->did != sliced_vbi_did[0] &&
			 anc->did != sliced_vbi_did[1])) {
			 anc->did != sliced_vbi_did[1])) {
		vbi->line = vbi->type = 0;
		vbi->line = vbi->type = 0;
			break;
		return 0;
	}
	}


	did = anc->did;
	did = anc->did;
@@ -316,9 +313,5 @@ int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg)
	vbi->line = err ? 0 : l;
	vbi->line = err ? 0 : l;
	vbi->is_second_field = err ? 0 : (did == sliced_vbi_did[1]);
	vbi->is_second_field = err ? 0 : (did == sliced_vbi_did[1]);
	vbi->p = p;
	vbi->p = p;
		break;
	}
	}

	return 0;
	return 0;
}
}