From: Vinod Koul <vinod.koul@intel.com>
To: alsa-devel@alsa-project.org
Cc: liam.r.girdwood@linux.intel.com, tiwai@suse.de,
broonie@kernel.org, Vinod Koul <vinod.koul@intel.com>,
patches.audio@intel.com
Subject: [PATCH] amixer: add support for TLV byte control read
Date: Fri, 22 Jan 2016 11:16:52 +0530 [thread overview]
Message-ID: <1453441612-29902-1-git-send-email-vinod.koul@intel.com> (raw)
TLV byte control are new type of byte controls added in kernel where
controls can have large sizes.
For these controls querying with 4096 size fails, so use the queried size to
read the control
This fixes the crash with current cget/contents on these type of controls
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
amixer/amixer.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/amixer/amixer.c b/amixer/amixer.c
index db1849333da3..cfe13592347f 100644
--- a/amixer/amixer.c
+++ b/amixer/amixer.c
@@ -588,7 +588,7 @@ static int show_control(const char *space, snd_hctl_elem_t *elem,
int level)
{
int err;
- unsigned int item, idx, count, *tlv;
+ unsigned int item, idx, count, *tlv, tlv_sz;
snd_ctl_elem_type_t type;
snd_ctl_elem_id_t *id;
snd_ctl_elem_info_t *info;
@@ -682,13 +682,20 @@ static int show_control(const char *space, snd_hctl_elem_t *elem,
__skip_read:
if (!snd_ctl_elem_info_is_tlv_readable(info))
goto __skip_tlv;
- tlv = malloc(4096);
- if ((err = snd_hctl_elem_tlv_read(elem, tlv, 4096)) < 0) {
+
+ if (type == SND_CTL_ELEM_TYPE_BYTES)
+ tlv_sz = count + 2 * sizeof(unsigned int);
+ else
+ tlv_sz = 4096;
+
+ tlv = malloc(tlv_sz);
+
+ if ((err = snd_hctl_elem_tlv_read(elem, tlv, tlv_sz)) < 0) {
error("Control %s element TLV read error: %s\n", card, snd_strerror(err));
free(tlv);
return err;
}
- decode_tlv(strlen(space), tlv, 4096);
+ decode_tlv(strlen(space), tlv, tlv_sz);
free(tlv);
}
__skip_tlv:
--
1.9.1
next reply other threads:[~2016-01-22 5:43 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-22 5:46 Vinod Koul [this message]
2016-01-22 6:19 ` [PATCH] amixer: add support for TLV byte control read Takashi Iwai
2016-01-22 7:46 ` Vinod Koul
2016-01-22 8:09 ` Takashi Iwai
2016-01-22 8:26 ` Takashi Iwai
2016-01-22 9:57 ` Vinod Koul
2016-01-22 9:56 ` Vinod Koul
2016-01-22 10:50 ` Takashi Iwai
2016-01-27 17:47 ` Vinod Koul
2016-01-27 18:49 ` Takashi Iwai
2016-01-28 4:25 ` Vinod Koul
2016-01-28 5:49 ` Takashi Iwai
2016-01-28 9:26 ` Vinod Koul
2016-01-28 16:19 ` Takashi Iwai
2016-01-29 6:51 ` Vinod Koul
2016-01-29 11:13 ` Vinod Koul
2016-01-29 13:17 ` Takashi Iwai
2016-01-29 13:53 ` Vinod Koul
2016-01-29 13:53 ` Takashi Iwai
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=1453441612-29902-1-git-send-email-vinod.koul@intel.com \
--to=vinod.koul@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=liam.r.girdwood@linux.intel.com \
--cc=patches.audio@intel.com \
--cc=tiwai@suse.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).