summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 0164abc060c5..452899d136ea 100644
--- a/sound/usb/stream.c
+++ b/sound/usb/stream.c
@@ -226,7 +226,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;
@@ -236,7 +236,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);
@@ -266,6 +266,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)
{
@@ -285,12 +306,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 = {
@@ -301,6 +322,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,
@@ -532,19 +561,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;
}