aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>2017-01-09 12:23:14 +0530
committerPankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>2017-01-10 13:50:39 +0530
commit9698d03a63b89fd5a2a2d775bcfc542812da54d9 (patch)
tree1ed0f01a9fb9506a3497675c7f3dcb6f472b0552
parentc848ea519f5c63b5a59bf2643e02a99ac7a7eef7 (diff)
mixer: Add support for TLV RW access check api
Tinyalsa doesn't expose an api to check TLV RW access Add mixer_ctl_is_access_tlv_rw(). This api will get used by tinymix and audio HALs for checking TLV RW access before managing the byte related mixer controls. Change-Id: Ib5707fabf479de638e1c7abd4cd149e7637ff9c2 Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
-rw-r--r--include/tinyalsa/mixer.h2
-rw-r--r--src/mixer.c15
2 files changed, 15 insertions, 2 deletions
diff --git a/include/tinyalsa/mixer.h b/include/tinyalsa/mixer.h
index d82d4b1..b9d6cf3 100644
--- a/include/tinyalsa/mixer.h
+++ b/include/tinyalsa/mixer.h
@@ -107,6 +107,8 @@ const char *mixer_ctl_get_enum_string(struct mixer_ctl *ctl, unsigned int enum_i
*/
void mixer_ctl_update(struct mixer_ctl *ctl);
+int mixer_ctl_is_access_tlv_rw(const struct mixer_ctl *ctl);
+
/* Set and get mixer controls */
int mixer_ctl_get_percent(const struct mixer_ctl *ctl, unsigned int id);
diff --git a/src/mixer.c b/src/mixer.c
index 66881e9..daa04f7 100644
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -381,6 +381,17 @@ void mixer_ctl_update(struct mixer_ctl *ctl)
ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_INFO, ctl->info);
}
+/** Checks the control for TLV Read/Write access.
+ * @param ctl An initialized control handle.
+ * @returns On success, non-zero.
+ * On failure, zero.
+ * @ingroup libtinyalsa-mixer
+ */
+int mixer_ctl_is_access_tlv_rw(const struct mixer_ctl *ctl)
+{
+ return (ctl->info.access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE);
+}
+
/** Gets the control's ID.
* @param ctl An initialized control handle.
* @returns On success, the control's ID is returned.
@@ -598,7 +609,7 @@ int mixer_ctl_get_array(const struct mixer_ctl *ctl, void *array, size_t count)
case SNDRV_CTL_ELEM_TYPE_BYTES:
/* check if this is new bytes TLV */
- if (ctl->info.access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) {
+ if (mixer_ctl_is_access_tlv_rw(ctl)) {
struct snd_ctl_tlv *tlv;
int ret;
@@ -719,7 +730,7 @@ int mixer_ctl_set_array(struct mixer_ctl *ctl, const void *array, size_t count)
case SNDRV_CTL_ELEM_TYPE_BYTES:
/* check if this is new bytes TLV */
- if (ctl->info.access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) {
+ if (mixer_ctl_is_access_tlv_rw(ctl)) {
struct snd_ctl_tlv *tlv;
int ret = 0;
if (count > SIZE_MAX - sizeof(*tlv))