From patchwork Fri Oct 24 07:25:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Henningsson X-Patchwork-Id: 5144431 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 89071C11AC for ; Fri, 24 Oct 2014 07:25:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B5BEC2025B for ; Fri, 24 Oct 2014 07:25:44 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 44F6A2025A for ; Fri, 24 Oct 2014 07:25:43 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D5BF626049E; Fri, 24 Oct 2014 09:25:41 +0200 (CEST) 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 [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id E70742604B5; Fri, 24 Oct 2014 09:25:32 +0200 (CEST) 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 BA3052604BC; Fri, 24 Oct 2014 09:25:31 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by alsa0.perex.cz (Postfix) with ESMTP id AD1C626049E for ; Fri, 24 Oct 2014 09:25:23 +0200 (CEST) Received: from hd9483857.selulk5.dyn.perspektivbredband.net ([217.72.56.87] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1XhZFR-0001I4-7I; Fri, 24 Oct 2014 07:25:21 +0000 From: David Henningsson To: tiwai@suse.de, alsa-devel@alsa-project.org Date: Fri, 24 Oct 2014 09:25:19 +0200 Message-Id: <1414135519-6096-1-git-send-email-david.henningsson@canonical.com> X-Mailer: git-send-email 1.9.1 Cc: David Henningsson Subject: [alsa-devel] [PATCH] hda-emu: Add snd_ctl_enum_info 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 Signed-off-by: David Henningsson --- include/sound/control.h | 2 ++ snd-control.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/sound/control.h b/include/sound/control.h index 47b92c5..eaaada4 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -101,6 +101,8 @@ int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); +int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels, + unsigned int items, const char *const names[]); /* * virtual master control diff --git a/snd-control.c b/snd-control.c index 3e3686f..a4a7a14 100644 --- a/snd-control.c +++ b/snd-control.c @@ -153,6 +153,24 @@ int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol, } #endif +int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels, + unsigned int items, const char *const names[]) +{ + info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + info->count = channels; + info->value.enumerated.items = items; + if (!items) + return 0; + if (info->value.enumerated.item >= items) + info->value.enumerated.item = items - 1; + if (strlen(names[info->value.enumerated.item]) >= sizeof(info->value.enumerated.name)) + hda_log(HDA_LOG_WARN, "ALSA: too long item name '%s'\n", names[info->value.enumerated.item]); + strlcpy(info->value.enumerated.name, + names[info->value.enumerated.item], + sizeof(info->value.enumerated.name)); + return 0; +} + int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id, int active) {