summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2016-06-29 22:43:00 +0900
committerTakashi Iwai <tiwai@suse.de>2016-06-30 08:42:17 +0200
commit16812b70daeb1c31f4681d22474b21f986ff6619 (patch)
treea5437547af64c90b7b4f58c6f4bf5876c8c9de38
parentf9e6011255b338c2aa04360c0e71923763871bc8 (diff)
downloadalsa-lib-16812b70daeb1c31f4681d22474b21f986ff6619.tar.gz
ctl: add an API to set dimension levels to element information
In a former commit, 'struct snd_ctl_elem_info' is used as a 'container' to transfer extra fields of element information for APIs to add an element set. The extra fields should be filled in advance of call of the APIs. Currently, dimension level is in the extra fields and no APIs to set it. This commit adds an API to set dimension level to the information structure. This API is expected to be used in advance of usage of APIs to add an element set, for nothing others. When the information structure is extended in future, then the similar APIs shall be added for the new feature. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--include/control.h2
-rw-r--r--src/control/control.c30
2 files changed, 32 insertions, 0 deletions
diff --git a/include/control.h b/include/control.h
index b14edee3..cd60d90f 100644
--- a/include/control.h
+++ b/include/control.h
@@ -408,6 +408,8 @@ void snd_ctl_elem_info_set_item(snd_ctl_elem_info_t *obj, unsigned int val);
const char *snd_ctl_elem_info_get_item_name(const snd_ctl_elem_info_t *obj);
int snd_ctl_elem_info_get_dimensions(const snd_ctl_elem_info_t *obj);
int snd_ctl_elem_info_get_dimension(const snd_ctl_elem_info_t *obj, unsigned int idx);
+int snd_ctl_elem_info_set_dimension(snd_ctl_elem_info_t *info,
+ const int dimension[4]);
void snd_ctl_elem_info_get_id(const snd_ctl_elem_info_t *obj, snd_ctl_elem_id_t *ptr);
unsigned int snd_ctl_elem_info_get_numid(const snd_ctl_elem_info_t *obj);
snd_ctl_elem_iface_t snd_ctl_elem_info_get_interface(const snd_ctl_elem_info_t *obj);
diff --git a/src/control/control.c b/src/control/control.c
index 70b166b8..2ad3e0d5 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -2458,6 +2458,36 @@ int snd_ctl_elem_info_get_dimension(const snd_ctl_elem_info_t *obj, unsigned int
use_default_symbol_version(__snd_ctl_elem_info_get_dimension, snd_ctl_elem_info_get_dimension, ALSA_0.9.3);
/**
+ * \brief Set width to a specified dimension level of given element information.
+ * \param info Information of an element.
+ * \param dimension Dimension width for each level by member unit.
+ * \return Zero on success, otherwise a negative error code.
+ *
+ * \par Errors:
+ * <dl>
+ * <dt>-EINVAL
+ * <dd>Invalid arguments are given as parameters.
+ * </dl>
+ */
+int snd_ctl_elem_info_set_dimension(snd_ctl_elem_info_t *info,
+ const int dimension[4])
+{
+ unsigned int i;
+
+ if (info == NULL)
+ return -EINVAL;
+
+ for (i = 0; i < ARRAY_SIZE(info->dimen.d); i++) {
+ if (dimension[i] < 0)
+ return -EINVAL;
+
+ info->dimen.d[i] = dimension[i];
+ }
+
+ return 0;
+}
+
+/**
* \brief Get CTL element identifier of a CTL element id/info
* \param obj CTL element id/info
* \param ptr Pointer to returned CTL element identifier