]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
[media] go7007: add audio input ioctls
authorHans Verkuil <hans.verkuil@cisco.com>
Sat, 9 Mar 2013 16:19:08 +0000 (13:19 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 24 Mar 2013 15:36:28 +0000 (12:36 -0300)
Since we now know what audio inputs there are, we can also get/set and
enumerate them.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/staging/media/go7007/go7007-v4l2.c

index fcd3e2d3f9ae56fb4327fecfa56bfa0016ca0a8d..a7307812b0de91fce360c8ef07a0db7a0cb0d6c6 100644 (file)
@@ -608,9 +608,10 @@ static int vidioc_querycap(struct file *file, void  *priv,
 
        cap->version = KERNEL_VERSION(0, 9, 8);
 
-       cap->capabilities = V4L2_CAP_VIDEO_CAPTURE |
-                           V4L2_CAP_STREAMING; /* | V4L2_CAP_AUDIO; */
+       cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
 
+       if (go->board_info->num_aud_inputs)
+               cap->device_caps |= V4L2_CAP_AUDIO;
        if (go->board_info->flags & GO7007_BOARD_HAS_TUNER)
                cap->capabilities |= V4L2_CAP_TUNER;
 
@@ -1191,7 +1192,10 @@ static int vidioc_enum_input(struct file *file, void *priv,
        else
                inp->type = V4L2_INPUT_TYPE_CAMERA;
 
-       inp->audioset = 0;
+       if (go->board_info->num_aud_inputs)
+               inp->audioset = (1 << go->board_info->num_aud_inputs) - 1;
+       else
+               inp->audioset = 0;
        inp->tuner = 0;
        if (go->board_info->sensor_flags & GO7007_SENSOR_TV)
                inp->std = V4L2_STD_NTSC | V4L2_STD_PAL |
@@ -1212,6 +1216,39 @@ static int vidioc_g_input(struct file *file, void *priv, unsigned int *input)
        return 0;
 }
 
+static int vidioc_enumaudio(struct file *file, void *fh, struct v4l2_audio *a)
+{
+       struct go7007 *go = video_drvdata(file);
+
+       if (a->index >= go->board_info->num_aud_inputs)
+               return -EINVAL;
+       strlcpy(a->name, go->board_info->aud_inputs[a->index].name, sizeof(a->name));
+       a->capability = V4L2_AUDCAP_STEREO;
+       return 0;
+}
+
+static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a)
+{
+       struct go7007 *go = video_drvdata(file);
+
+       a->index = go->aud_input;
+       strlcpy(a->name, go->board_info->aud_inputs[go->aud_input].name, sizeof(a->name));
+       a->capability = V4L2_AUDCAP_STEREO;
+       return 0;
+}
+
+static int vidioc_s_audio(struct file *file, void *fh, const struct v4l2_audio *a)
+{
+       struct go7007 *go = video_drvdata(file);
+
+       if (a->index >= go->board_info->num_aud_inputs)
+               return -EINVAL;
+       go->aud_input = a->index;
+       v4l2_subdev_call(go->sd_audio, audio, s_routing,
+                       go->board_info->aud_inputs[go->aud_input].audio_input, 0, 0);
+       return 0;
+}
+
 static int vidioc_s_input(struct file *file, void *priv, unsigned int input)
 {
        struct go7007 *go = ((struct go7007_file *) priv)->go;
@@ -1772,6 +1809,9 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
        .vidioc_enum_input        = vidioc_enum_input,
        .vidioc_g_input           = vidioc_g_input,
        .vidioc_s_input           = vidioc_s_input,
+       .vidioc_enumaudio         = vidioc_enumaudio,
+       .vidioc_g_audio           = vidioc_g_audio,
+       .vidioc_s_audio           = vidioc_s_audio,
        .vidioc_queryctrl         = vidioc_queryctrl,
        .vidioc_g_ctrl            = vidioc_g_ctrl,
        .vidioc_s_ctrl            = vidioc_s_ctrl,
@@ -1816,6 +1856,11 @@ int go7007_v4l2_init(struct go7007 *go)
                go->video_dev = NULL;
                return rv;
        }
+       if (go->board_info->num_aud_inputs == 0) {
+               v4l2_disable_ioctl(go->video_dev, VIDIOC_G_AUDIO);
+               v4l2_disable_ioctl(go->video_dev, VIDIOC_S_AUDIO);
+               v4l2_disable_ioctl(go->video_dev, VIDIOC_ENUMAUDIO);
+       }
        rv = v4l2_device_register(go->dev, &go->v4l2_dev);
        if (rv < 0) {
                video_device_release(go->video_dev);