Skip to content

Commit

Permalink
[media] go7007: add audio input ioctls
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Mar 24, 2013
1 parent 94c0c67 commit 5e41054
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions drivers/staging/media/go7007/go7007-v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 |
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5e41054

Please sign in to comment.