From patchwork Tue Jan 3 05:13:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mengdong.lin@linux.intel.com X-Patchwork-Id: 9494481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6DDF260414 for ; Tue, 3 Jan 2017 06:38:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E865205AD for ; Tue, 3 Jan 2017 06:38:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50845269E2; Tue, 3 Jan 2017 06:38:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 778BD205AD for ; Tue, 3 Jan 2017 06:38:41 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id DDBCC266DCC; Tue, 3 Jan 2017 07:38:39 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 89F6A266DB8; Tue, 3 Jan 2017 07:36:21 +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 15F73266D5A; Tue, 3 Jan 2017 06:10:19 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by alsa0.perex.cz (Postfix) with ESMTP id EB600266D2C for ; Tue, 3 Jan 2017 06:10:15 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 02 Jan 2017 21:10:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.33,451,1477983600"; d="scan'208"; a="1089196974" Received: from amanda-haswell-pc.sh.intel.com ([10.239.159.21]) by fmsmga001.fm.intel.com with ESMTP; 02 Jan 2017 21:10:12 -0800 From: mengdong.lin@linux.intel.com To: alsa-devel@alsa-project.org, broonie@kernel.org Date: Tue, 3 Jan 2017 13:13:15 +0800 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: References: Cc: Mengdong Lin , tiwai@suse.de, mengdong.lin@intel.com, liam.r.girdwood@linux.intel.com, vinod.koul@intel.com, pierre-louis.bossart@intel.com Subject: [alsa-devel] [PATCH v2 2/2] ucm: Add command 'get _file' to get the config file name of the opened card 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 From: Mengdong Lin After opening a card, this command can show the name of the actually loaded configuration file, either matches the card name or card long name. So developers can check if there is a device-sepcific configuration file available for a given card. Signed-off-by: Mengdong Lin diff --git a/include/use-case.h b/include/use-case.h index 8911645..15036fb 100644 --- a/include/use-case.h +++ b/include/use-case.h @@ -230,7 +230,7 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr, * Known identifiers: * - NULL - return current card * - _verb - return current verb - * + * - _file - return configuration file loaded for current card * - [=]{NAME}[/[{modifier}|{/device}][/{verb}]] * - value identifier {NAME} * - Search starts at given modifier or device if any, diff --git a/src/ucm/main.c b/src/ucm/main.c index 38a5e81..2d33886 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -1528,6 +1528,20 @@ int snd_use_case_get(snd_use_case_mgr_t *uc_mgr, goto __end; } err = 0; + } else if (strcmp(identifier, "_file") == 0) { + /* get the conf file name of the opened card */ + if ((uc_mgr->card_name == NULL) + || (uc_mgr->conf_file_name[0] == '\0')) { + err = -ENOENT; + goto __end; + } + *value = strndup(uc_mgr->conf_file_name, MAX_FILE); + if (*value == NULL) { + err = -ENOMEM; + goto __end; + } + err = 0; + } else if (identifier[0] == '_') { err = -ENOENT; goto __end;