From: Eldad Zack <eldad@fogrefinery.com>
To: Takashi Iwai <tiwai@suse.de>, Daniel Mack <zonque@gmail.com>,
Felix Homann <linuxaudio@showlabor.de>,
Clemens Ladisch <clemens@ladisch.de>,
alsa-devel@alsa-project.org
Cc: Grant Diffey <gdiffey@gmail.com>,
George Willian Condomitti <georgecondomitti@gmail.com>,
Chris Cavey <chris-alsa@rauros.net>,
Eldad Zack <eldad@fogrefinery.com>
Subject: [FT C400, PATCH RFC, v3 3/9] usb-audio: add control index offset
Date: Tue, 27 Nov 2012 17:00:52 +0100 [thread overview]
Message-ID: <1354032058-668-4-git-send-email-eldad@fogrefinery.com> (raw)
In-Reply-To: <1354032058-668-1-git-send-email-eldad@fogrefinery.com>
Currently, channel IDs exceeding 31 (0x1f) cannot be used.
The channel ID is derived from the cmask. Extending cmask
to a 64-bit type would only allow it to go up to 63 (0x2f).
Some devices have channel IDs exceeding that as well.
To address that, add an offset to the mixer element which
is then accounted for in the UAC set/get functions.
Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
---
sound/usb/mixer.c | 4 ++++
sound/usb/mixer.h | 1 +
sound/usb/mixer_quirks.c | 16 +++++++++++++++-
3 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 298070e..b0fc6ae 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -382,6 +382,8 @@ error:
static int get_ctl_value(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret)
{
+ validx += cval->idx_off;
+
return (cval->mixer->protocol == UAC_VERSION_1) ?
get_ctl_value_v1(cval, request, validx, value_ret) :
get_ctl_value_v2(cval, request, validx, value_ret);
@@ -432,6 +434,8 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
unsigned char buf[2];
int idx = 0, val_len, err, timeout = 10;
+ validx += cval->idx_off;
+
if (cval->mixer->protocol == UAC_VERSION_1) {
val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1;
} else { /* UAC_VERSION_2 */
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index a7f3d45..aab80df 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -43,6 +43,7 @@ struct usb_mixer_elem_info {
unsigned int id;
unsigned int control; /* CS or ICN (high byte) */
unsigned int cmask; /* channel mask bitmap: 0 = master */
+ unsigned int idx_off; /* Control index offset */
unsigned int ch_readonly;
unsigned int master_readonly;
int channels;
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index ae2b714..4199b97 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -63,11 +63,12 @@ static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
* Since there doesn't seem to be a devices that needs a multichannel
* version, we keep it mono for simplicity.
*/
-static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
+static int snd_create_std_mono_ctl_offset(struct usb_mixer_interface *mixer,
unsigned int unitid,
unsigned int control,
unsigned int cmask,
int val_type,
+ unsigned int idx_off,
const char *name,
snd_kcontrol_tlv_rw_t *tlv_callback)
{
@@ -85,6 +86,7 @@ static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
cval->channels = 1;
cval->control = control;
cval->cmask = cmask;
+ cval->idx_off = idx_off;
/* get_min_max() is called only for integer volumes later,
* so provide a short-cut for booleans */
@@ -120,6 +122,18 @@ static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
return 0;
}
+static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
+ unsigned int unitid,
+ unsigned int control,
+ unsigned int cmask,
+ int val_type,
+ const char *name,
+ snd_kcontrol_tlv_rw_t *tlv_callback)
+{
+ return snd_create_std_mono_ctl_offset(mixer, unitid, control, cmask,
+ val_type, 0 /* Offset */, name, tlv_callback);
+}
+
/*
* Create a set of standard UAC controls from a table
*/
--
1.7.8.6
next prev parent reply other threads:[~2012-11-27 16:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 16:00 [FT C400,PATCH RFC,v3 0/9] M-Audio Fast Track C400 Eldad Zack
2012-11-27 16:00 ` [FT C400, PATCH RFC, v3 1/9] usb-audio: replace hardcoded value with const Eldad Zack
2012-11-27 16:00 ` [FT C400, PATCH RFC, v3 2/9] usb-audio: use sender stride for implicit feedback Eldad Zack
2012-11-27 16:00 ` Eldad Zack [this message]
2012-11-27 16:00 ` [FT C400, PATCH RFC, v3 4/9] usb-audio: skip UAC2 EFFECT_UNIT Eldad Zack
2012-11-27 16:00 ` [FT C400, PATCH RFC, v3 5/9] usb-audio: parameterize FTU effect unit control Eldad Zack
2012-11-27 16:00 ` [FT C400, PATCH RFC, v3 6/9] usb-audio: M-Audio Fast Track C400 quirks table Eldad Zack
2012-11-27 16:11 ` Clemens Ladisch
2012-11-27 16:44 ` Eldad Zack
2012-11-28 10:20 ` Takashi Iwai
2012-11-27 16:00 ` [FT C400, PATCH RFC, v3 7/9] usb-audio: Fast Track C400 mixer ranges Eldad Zack
2012-11-27 16:12 ` Clemens Ladisch
2012-11-27 17:44 ` Eldad Zack
2012-11-27 16:00 ` [FT C400, PATCH RFC, v3 8/9] usb-audio: Fast Track C400 mixer controls Eldad Zack
2012-11-27 16:00 ` [FT C400, PATCH RFC, v3 9/9] usb-audio: FT C400 sync playback EP to capture EP Eldad Zack
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354032058-668-4-git-send-email-eldad@fogrefinery.com \
--to=eldad@fogrefinery.com \
--cc=alsa-devel@alsa-project.org \
--cc=chris-alsa@rauros.net \
--cc=clemens@ladisch.de \
--cc=gdiffey@gmail.com \
--cc=georgecondomitti@gmail.com \
--cc=linuxaudio@showlabor.de \
--cc=tiwai@suse.de \
--cc=zonque@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.