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

[media] cx23885: fix audio input handling



Fix a bunch of v4l2-compliance errors relating to audio input handling.

Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent a7d3eabd
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -1153,7 +1153,7 @@ static int vidioc_querycap(struct file *file, void *priv,
	strlcpy(cap->card, cx23885_boards[dev->board].name,
		sizeof(cap->card));
	sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci));
	cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
	cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_AUDIO;
	if (dev->tuner_type != TUNER_ABSENT)
		cap->device_caps |= V4L2_CAP_TUNER;
	if (vdev->vfl_type == VFL_TYPE_VBI)
@@ -1302,15 +1302,15 @@ int cx23885_enum_input(struct cx23885_dev *dev, struct v4l2_input *i)
	i->index = n;
	i->type  = V4L2_INPUT_TYPE_CAMERA;
	strcpy(i->name, iname[INPUT(n)->type]);
	i->std = CX23885_NORMS;
	if ((CX23885_VMUX_TELEVISION == INPUT(n)->type) ||
		(CX23885_VMUX_CABLE == INPUT(n)->type)) {
		i->type = V4L2_INPUT_TYPE_TUNER;
		i->std = CX23885_NORMS;
	}

		i->audioset = 4;
	} else {
		/* Two selectable audio inputs for non-tv inputs */
	if (INPUT(n)->type != CX23885_VMUX_TELEVISION)
		i->audioset = 0x3;
		i->audioset = 3;
	}

	if (dev->input == n) {
		/* enum'd input matches our configured input.
@@ -1397,19 +1397,19 @@ static int cx23885_query_audinput(struct file *file, void *priv,
	static const char *iname[] = {
		[0] = "Baseband L/R 1",
		[1] = "Baseband L/R 2",
		[2] = "TV",
	};
	unsigned int n;
	dprintk(1, "%s()\n", __func__);

	n = i->index;
	if (n >= 2)
	if (n >= 3)
		return -EINVAL;

	memset(i, 0, sizeof(*i));
	i->index = n;
	strcpy(i->name, iname[n]);
	i->capability = V4L2_AUDCAP_STEREO;
	i->mode  = V4L2_AUDMODE_AVL;
	return 0;

}
@@ -1425,6 +1425,10 @@ static int vidioc_g_audinput(struct file *file, void *priv,
{
	struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev;

	if ((CX23885_VMUX_TELEVISION == INPUT(dev->input)->type) ||
		(CX23885_VMUX_CABLE == INPUT(dev->input)->type))
		i->index = 2;
	else
		i->index = dev->audinput;
	dprintk(1, "%s(input=%d)\n", __func__, i->index);

@@ -1435,7 +1439,12 @@ static int vidioc_s_audinput(struct file *file, void *priv,
	const struct v4l2_audio *i)
{
	struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev;
	if (i->index >= 2)

	if ((CX23885_VMUX_TELEVISION == INPUT(dev->input)->type) ||
		(CX23885_VMUX_CABLE == INPUT(dev->input)->type)) {
		return i->index != 2 ? -EINVAL : 0;
	}
	if (i->index > 1)
		return -EINVAL;

	dprintk(1, "%s(%d)\n", __func__, i->index);