From patchwork Mon Feb 15 13:33:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 8315101 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6C6DF9F372 for ; Mon, 15 Feb 2016 13:35:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F49B201FA for ; Mon, 15 Feb 2016 13:35:15 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 349782017D for ; Mon, 15 Feb 2016 13:35:14 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5D19326531A; Mon, 15 Feb 2016 14:35:13 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 9E604265091; Mon, 15 Feb 2016 14:33:37 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id B92782650C3; Mon, 15 Feb 2016 14:33:35 +0100 (CET) Received: from smtp303.phy.lolipop.jp (smtp303.phy.lolipop.jp [210.157.22.87]) by alsa0.perex.cz (Postfix) with ESMTP id 35DF52619F5 for ; Mon, 15 Feb 2016 14:33:19 +0100 (CET) Received: from smtp303.phy.lolipop.lan (HELO smtp303.phy.lolipop.jp) (172.17.1.87) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp303.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Mon, 15 Feb 2016 22:33:16 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp303.phy.lolipop.jp (LOLIPOP-Fsecure); Mon, 15 Feb 2016 22:33:13 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de, perex@perex.cz Date: Mon, 15 Feb 2016 22:33:12 +0900 Message-Id: <1455543193-28109-5-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455543193-28109-1-git-send-email-o-takashi@sakamocchi.jp> References: <1455543193-28109-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 4/5] control: add a function to add an element of bytes type X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP ALSA Ctl core allows userspace applications to add elements of bytes type, while there's no APIs for this purpose in alsa-lib. This commit adds the missing function. Signed-off-by: Takashi Sakamoto --- src/control/control.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/control/control.c b/src/control/control.c index 3533ffe..38d66e8 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -488,6 +488,51 @@ int snd_ctl_elem_add_enumerated(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id, } /** + * \brief Create and add a user-defined control element of bytes type. + * \param[in] ctl Control device handle. + * \param[in/out] id ID of the new control element. + * \param[in] channels The number of channels which one control element includes + * \return Zero on success, otherwise a negative error code. + * + * This function creates a user control element, This control element is not + * controlled by device drivers in kernel but that is handled by the same way as + * the control elements added by the device drivers. + * + * The fields of \a id, except numid, must be set with unique values to identify + * the new element. After returning, all fields of \a id are filled. + * + * All of channels in the new element are locked; these values are initialized + * with the minimum value. + * + * \par Errors: + *
+ *
-EBUSY
A control element with ID \a id already exists. + *
-EINVAL
\a channels is not between 1 to 511. + *
-ENOMEM
Out of memory, or there are too many user control elements. + *
-ENXIO
This driver does not support (bytes) user controls. + *
-ENODEV
Device unplugged. + *
+ * + * \par Compatibility: + * This function is added in ALSA 1.1.1. + */ +int snd_ctl_elem_add_bytes(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id, + unsigned int channels) +{ + snd_ctl_elem_info_t *info; + + assert(ctl && id && id->name[0]); + + snd_ctl_elem_info_alloca(&info); + info->id = *id; + info->type = SND_CTL_ELEM_TYPE_BYTES; + info->owner = 1; + info->count = channels; + + return ctl->ops->element_add(ctl, info); +} + +/** * \brief Create and add a user-defined control element of IEC958 type. * \param[in] ctl CTL handle * \param[in/out] id ID of the new control element.