From patchwork Sat Jan 14 08:24:01 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: 9516963 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 075F8601DA for ; Sat, 14 Jan 2017 12:33:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E909D28529 for ; Sat, 14 Jan 2017 12:33:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD79328541; Sat, 14 Jan 2017 12:33:45 +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 B08F628529 for ; Sat, 14 Jan 2017 12:33:43 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 382D6266D15; Sat, 14 Jan 2017 13:33:42 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B4069266CC5; Sat, 14 Jan 2017 13:31:23 +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 A3D4C266834; Sat, 14 Jan 2017 09:20:50 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by alsa0.perex.cz (Postfix) with ESMTP id B6EAC2666FB for ; Sat, 14 Jan 2017 09:20:48 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP; 14 Jan 2017 00:20:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,226,1477983600"; d="scan'208";a="213264395" Received: from amanda-haswell-pc.sh.intel.com ([10.239.159.21]) by fmsmga004.fm.intel.com with ESMTP; 14 Jan 2017 00:20:45 -0800 From: mengdong.lin@linux.intel.com To: alsa-devel@alsa-project.org Date: Sat, 14 Jan 2017 16:24:01 +0800 Message-Id: <214d83794100e1b132bed219d34ec68454d23b56.1484381554.git.mengdong.lin@linux.intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: Cc: tiwai@suse.de, liam.r.girdwood@linux.intel.com, Mengdong Lin , mengdong.lin@intel.com Subject: [alsa-devel] [PATCH v4 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..ae22bde 100644 --- a/include/use-case.h +++ b/include/use-case.h @@ -230,6 +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} 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;