[media] cx23885: fix audio input handling

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

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
Hans Verkuil 2014-04-23 05:24:58 -03:00 committed by Mauro Carvalho Chehab
parent a7d3eabd77
commit d43be757b9

View file

@ -1153,7 +1153,7 @@ static int vidioc_querycap(struct file *file, void *priv,
strlcpy(cap->card, cx23885_boards[dev->board].name, strlcpy(cap->card, cx23885_boards[dev->board].name,
sizeof(cap->card)); sizeof(cap->card));
sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci)); 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) if (dev->tuner_type != TUNER_ABSENT)
cap->device_caps |= V4L2_CAP_TUNER; cap->device_caps |= V4L2_CAP_TUNER;
if (vdev->vfl_type == VFL_TYPE_VBI) 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->index = n;
i->type = V4L2_INPUT_TYPE_CAMERA; i->type = V4L2_INPUT_TYPE_CAMERA;
strcpy(i->name, iname[INPUT(n)->type]); strcpy(i->name, iname[INPUT(n)->type]);
i->std = CX23885_NORMS;
if ((CX23885_VMUX_TELEVISION == INPUT(n)->type) || if ((CX23885_VMUX_TELEVISION == INPUT(n)->type) ||
(CX23885_VMUX_CABLE == INPUT(n)->type)) { (CX23885_VMUX_CABLE == INPUT(n)->type)) {
i->type = V4L2_INPUT_TYPE_TUNER; i->type = V4L2_INPUT_TYPE_TUNER;
i->std = CX23885_NORMS; i->audioset = 4;
} } else {
/* Two selectable audio inputs for non-tv inputs */ /* Two selectable audio inputs for non-tv inputs */
if (INPUT(n)->type != CX23885_VMUX_TELEVISION) i->audioset = 3;
i->audioset = 0x3; }
if (dev->input == n) { if (dev->input == n) {
/* enum'd input matches our configured input. /* 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[] = { static const char *iname[] = {
[0] = "Baseband L/R 1", [0] = "Baseband L/R 1",
[1] = "Baseband L/R 2", [1] = "Baseband L/R 2",
[2] = "TV",
}; };
unsigned int n; unsigned int n;
dprintk(1, "%s()\n", __func__); dprintk(1, "%s()\n", __func__);
n = i->index; n = i->index;
if (n >= 2) if (n >= 3)
return -EINVAL; return -EINVAL;
memset(i, 0, sizeof(*i)); memset(i, 0, sizeof(*i));
i->index = n; i->index = n;
strcpy(i->name, iname[n]); strcpy(i->name, iname[n]);
i->capability = V4L2_AUDCAP_STEREO; i->capability = V4L2_AUDCAP_STEREO;
i->mode = V4L2_AUDMODE_AVL;
return 0; 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; 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; i->index = dev->audinput;
dprintk(1, "%s(input=%d)\n", __func__, i->index); 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) const struct v4l2_audio *i)
{ {
struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; 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; return -EINVAL;
dprintk(1, "%s(%d)\n", __func__, i->index); dprintk(1, "%s(%d)\n", __func__, i->index);