summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRahul Mittal <rmittal@nvidia.com>2013-09-03 14:50:35 +0530
committerMandar Padmawar <mpadmawar@nvidia.com>2013-11-14 23:45:37 -0800
commitda8bab0a5be5d77a5cc9618ba0a17a720b004950 (patch)
treec18f0cc04c54496d150846aca5f7313e51d7d4fc
parent0e7e1f85eb146ed2edad2a480e52bcf67fc6d7b5 (diff)
ALSA: usbaudio: Expose supported channel counts
Add alsa controls to expose playback and capture channels supported by the connected device Bug 1360445 Change-Id: I812c05a1b318a756f2d1f82e63c10e48cea01db3 Signed-off-by: Rahul Mittal <rmittal@nvidia.com> Reviewed-on: http://git-master/r/269923 (cherry picked from commit c3067e961f1e4320f006b3e9121df0c2e9142d39) Reviewed-on: http://git-master/r/330696 Tested-by: Scott Peterson <speterson@nvidia.com> Reviewed-by: Scott Peterson <speterson@nvidia.com>
-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;
}