summaryrefslogtreecommitdiff
path: root/sound/usb
diff options
context:
space:
mode:
authorRahul Mittal <rmittal@nvidia.com>2014-02-12 15:15:39 +0530
committerSachin Nikam <snikam@nvidia.com>2014-02-22 06:28:28 -0800
commite65884a629fc6aa2e73c3a618cb839b78dca05de (patch)
tree6a95d965124d368435ede1ea916be8df2969c21c /sound/usb
parent92137707ba342ac39fdc8701f3c7f8836e93695c (diff)
ALSA: usb: Add capture sample rate control
Add capture sample rate control Bug 1455195 Change-Id: I031ef70954d01fb5799727c470c3af48477d7459 Signed-off-by: Rahul Mittal <rmittal@nvidia.com> Reviewed-on: http://git-master/r/366461 (cherry picked from commit a60b34d57cc255d7e0940907469e1c7ce48246f3) Reviewed-on: http://git-master/r/372737 GVS: Gerrit_Virtual_Submit Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com> Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/stream.c59
1 files changed, 45 insertions, 14 deletions
diff --git a/sound/usb/stream.c b/sound/usb/stream.c
index 70a07761f270..5b6f7a027c6a 100644
--- a/sound/usb/stream.c
+++ b/sound/usb/stream.c
@@ -461,7 +461,7 @@ static struct uac2_output_terminal_descriptor *
return NULL;
}
-static int usb_device_sample_rate_info(struct snd_kcontrol *kcontrol,
+static int usb_device_pb_sample_rate_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -471,7 +471,7 @@ static int usb_device_sample_rate_info(struct snd_kcontrol *kcontrol,
return 0;
}
-static int usb_device_sample_rate_get(struct snd_kcontrol *kcontrol,
+static int usb_device_pb_sample_rate_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct audioformat *fp = snd_kcontrol_chip(kcontrol);
@@ -501,6 +501,27 @@ static int usb_device_pb_channels_get(struct snd_kcontrol *kcontrol,
return 0;
}
+static int usb_device_cap_sample_rate_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ uinfo->count = 2;
+ uinfo->value.integer.min = 0;
+ uinfo->value.integer.max = 192000;
+ return 0;
+}
+
+static int usb_device_cap_sample_rate_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct audioformat *fp = snd_kcontrol_chip(kcontrol);
+
+ ucontrol->value.integer.value[0] = fp->rate_min;
+ ucontrol->value.integer.value[1] = fp->rate_max;
+
+ return 0;
+}
+
static int usb_device_cap_channels_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
@@ -520,12 +541,12 @@ static int usb_device_cap_channels_get(struct snd_kcontrol *kcontrol,
return 0;
}
-struct snd_kcontrol_new usb_device_sample_rate_control = {
+struct snd_kcontrol_new usb_device_pb_sample_rate_control = {
.access = SNDRV_CTL_ELEM_ACCESS_READ,
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "USB Device Sample Rate",
- .info = usb_device_sample_rate_info,
- .get = usb_device_sample_rate_get,
+ .name = "USB Device Playback Sample Rate",
+ .info = usb_device_pb_sample_rate_info,
+ .get = usb_device_pb_sample_rate_get,
};
struct snd_kcontrol_new usb_device_pb_channels_control = {
@@ -536,6 +557,14 @@ struct snd_kcontrol_new usb_device_pb_channels_control = {
.get = usb_device_pb_channels_get,
};
+struct snd_kcontrol_new usb_device_cap_sample_rate_control = {
+ .access = SNDRV_CTL_ELEM_ACCESS_READ,
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "USB Device Capture Sample Rate",
+ .info = usb_device_cap_sample_rate_info,
+ .get = usb_device_cap_sample_rate_get,
+};
+
struct snd_kcontrol_new usb_device_cap_channels_control = {
.access = SNDRV_CTL_ELEM_ACCESS_READ,
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -781,19 +810,21 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
snd_usb_init_sample_rate(chip, iface_no, alts, fp, fp->rate_max);
}
- /* Add usb device sample rate control */
- snd_ctl_add(chip->card,
- snd_ctl_new1(&usb_device_sample_rate_control, fp));
-
- /* Add usb device playback channels control */
- if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+ /* Add usb device playback controls */
+ if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ snd_ctl_add(chip->card,
+ snd_ctl_new1(&usb_device_pb_sample_rate_control, fp));
snd_ctl_add(chip->card,
snd_ctl_new1(&usb_device_pb_channels_control, fp));
+ }
- /* Add usb device capture channels control */
- if (stream == SNDRV_PCM_STREAM_CAPTURE)
+ /* Add usb device capture controls */
+ if (stream == SNDRV_PCM_STREAM_CAPTURE) {
+ snd_ctl_add(chip->card,
+ snd_ctl_new1(&usb_device_cap_sample_rate_control, fp));
snd_ctl_add(chip->card,
snd_ctl_new1(&usb_device_cap_channels_control, fp));
+ }
return 0;
}