summaryrefslogtreecommitdiff
path: root/sound/usb/stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/stream.c')
-rw-r--r--sound/usb/stream.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/sound/usb/stream.c b/sound/usb/stream.c
index 8b4bb0ecf1b8..0164abc060c5 100644
--- a/sound/usb/stream.c
+++ b/sound/usb/stream.c
@@ -23,6 +23,7 @@
#include <sound/core.h>
#include <sound/pcm.h>
+#include <sound/control.h>
#include "usbaudio.h"
#include "card.h"
@@ -246,6 +247,44 @@ static int usb_device_sample_rate_get(struct snd_kcontrol *kcontrol,
return 0;
}
+static int usb_device_pb_channels_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ uinfo->count = 1;
+ uinfo->value.integer.min = 1;
+ uinfo->value.integer.max = 2;
+ return 0;
+}
+
+static int usb_device_pb_channels_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct audioformat *fp = snd_kcontrol_chip(kcontrol);
+
+ ucontrol->value.integer.value[0] = fp->channels;
+ return 0;
+}
+
+static int usb_device_cap_channels_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ uinfo->count = 1;
+ uinfo->value.integer.min = 1;
+ uinfo->value.integer.max = 2;
+ return 0;
+}
+
+static int usb_device_cap_channels_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct audioformat *fp = snd_kcontrol_chip(kcontrol);
+
+ ucontrol->value.integer.value[0] = fp->channels;
+ return 0;
+}
+
struct snd_kcontrol_new usb_device_sample_rate_control = {
.access = SNDRV_CTL_ELEM_ACCESS_READ,
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -254,6 +293,22 @@ struct snd_kcontrol_new usb_device_sample_rate_control = {
.get = usb_device_sample_rate_get,
};
+struct snd_kcontrol_new usb_device_pb_channels_control = {
+ .access = SNDRV_CTL_ELEM_ACCESS_READ,
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "USB Device Playback Channels",
+ .info = usb_device_pb_channels_info,
+ .get = usb_device_pb_channels_get,
+};
+
+struct snd_kcontrol_new usb_device_cap_channels_control = {
+ .access = SNDRV_CTL_ELEM_ACCESS_READ,
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "USB Device Capture Channels",
+ .info = usb_device_cap_channels_info,
+ .get = usb_device_cap_channels_get,
+};
+
int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
{
struct usb_device *dev;
@@ -481,6 +536,16 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
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)
+ 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)
+ snd_ctl_add(chip->card,
+ snd_ctl_new1(&usb_device_cap_channels_control, fp));
+
return 0;
}