aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSteven Toth <stoth@kernellabs.com>2011-10-10 10:09:56 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-10-14 16:20:12 -0400
commitfc1a889df78dea08e522310c9eb6110448dc61f0 (patch)
tree20884d0587cd3fe17da3c8e0456a6c89c7b43a3f /drivers
parente92bcf8d8abb654cb916f3e615697320bc6bf1e1 (diff)
[media] cx23885: add generic functions for dealing with audio input selection
Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c81
-rw-r--r--drivers/media/video/cx23885/cx23885.h1
2 files changed, 82 insertions, 0 deletions
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index 596b46e7bc51..9726f2a0ef6c 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -517,6 +517,22 @@ static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input)
517 return 0; 517 return 0;
518} 518}
519 519
520static int cx23885_audio_mux(struct cx23885_dev *dev, unsigned int input)
521{
522 dprintk(1, "%s(input=%d)\n", __func__, input);
523
524 if ((dev->board == CX23885_BOARD_HAUPPAUGE_HVR1800) ||
525 (dev->board == CX23885_BOARD_MPX885)) {
526
527 if (INPUT(input)->amux == CX25840_AUDIO7)
528 cx23885_flatiron_mux(dev, 1);
529 else if (INPUT(input)->amux == CX25840_AUDIO6)
530 cx23885_flatiron_mux(dev, 2);
531 }
532
533 return 0;
534}
535
520/* ------------------------------------------------------------------ */ 536/* ------------------------------------------------------------------ */
521static int cx23885_set_scale(struct cx23885_dev *dev, unsigned int width, 537static int cx23885_set_scale(struct cx23885_dev *dev, unsigned int width,
522 unsigned int height, enum v4l2_field field) 538 unsigned int height, enum v4l2_field field)
@@ -1308,6 +1324,68 @@ static int vidioc_log_status(struct file *file, void *priv)
1308 return 0; 1324 return 0;
1309} 1325}
1310 1326
1327static int cx23885_query_audinput(struct file *file, void *priv,
1328 struct v4l2_audio *i)
1329{
1330 struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev;
1331 static const char *iname[] = {
1332 [0] = "Baseband L/R 1",
1333 [1] = "Baseband L/R 2",
1334 };
1335 unsigned int n;
1336 dprintk(1, "%s()\n", __func__);
1337
1338 n = i->index;
1339 if (n >= 2)
1340 return -EINVAL;
1341
1342 memset(i, 0, sizeof(*i));
1343 i->index = n;
1344 strcpy(i->name, iname[n]);
1345 i->capability = V4L2_AUDCAP_STEREO;
1346 i->mode = V4L2_AUDMODE_AVL;
1347 return 0;
1348
1349}
1350
1351static int vidioc_enum_audinput(struct file *file, void *priv,
1352 struct v4l2_audio *i)
1353{
1354 return cx23885_query_audinput(file, priv, i);
1355}
1356
1357static int vidioc_g_audinput(struct file *file, void *priv,
1358 struct v4l2_audio *i)
1359{
1360 struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev;
1361
1362 i->index = dev->audinput;
1363 dprintk(1, "%s(input=%d)\n", __func__, i->index);
1364
1365 return cx23885_query_audinput(file, priv, i);
1366}
1367
1368static int vidioc_s_audinput(struct file *file, void *priv,
1369 struct v4l2_audio *i)
1370{
1371 struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev;
1372
1373 /* cx23885 offers 2 different audio inputs on the A/V core, LR1 and LR2.
1374 * By default the driver has always used LR1 and we need support for
1375 * switching. This isn't board specific, is part of the base silicon.
1376 */
1377 if (i->index >= 2)
1378 return -EINVAL;
1379
1380 dprintk(1, "%s(%d)\n", __func__, i->index);
1381
1382 mutex_lock(&dev->lock);
1383 dev->audinput = i->index;
1384 cx23885_audio_mux(dev, dev->audinput);
1385 mutex_unlock(&dev->lock);
1386 return 0;
1387}
1388
1311static int vidioc_queryctrl(struct file *file, void *priv, 1389static int vidioc_queryctrl(struct file *file, void *priv,
1312 struct v4l2_queryctrl *qctrl) 1390 struct v4l2_queryctrl *qctrl)
1313{ 1391{
@@ -1548,6 +1626,9 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
1548 .vidioc_g_register = cx23885_g_register, 1626 .vidioc_g_register = cx23885_g_register,
1549 .vidioc_s_register = cx23885_s_register, 1627 .vidioc_s_register = cx23885_s_register,
1550#endif 1628#endif
1629 .vidioc_enumaudio = vidioc_enum_audinput,
1630 .vidioc_g_audio = vidioc_g_audinput,
1631 .vidioc_s_audio = vidioc_s_audinput,
1551}; 1632};
1552 1633
1553static struct video_device cx23885_vbi_template; 1634static struct video_device cx23885_vbi_template;
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h
index b205e3263b46..b49036fe3ffd 100644
--- a/drivers/media/video/cx23885/cx23885.h
+++ b/drivers/media/video/cx23885/cx23885.h
@@ -392,6 +392,7 @@ struct cx23885_dev {
392 /* Analog video */ 392 /* Analog video */
393 u32 resources; 393 u32 resources;
394 unsigned int input; 394 unsigned int input;
395 unsigned int audinput; /* Selectable audio input */
395 u32 tvaudio; 396 u32 tvaudio;
396 v4l2_std_id tvnorm; 397 v4l2_std_id tvnorm;
397 unsigned int tuner_type; 398 unsigned int tuner_type;