From patchwork Mon Nov 28 05:33:34 2016 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: 9449221 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 56A8B6071C for ; Mon, 28 Nov 2016 09:42:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FCE624B5B for ; Mon, 28 Nov 2016 09:42:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 423EE2574A; Mon, 28 Nov 2016 09:42:30 +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 656E824B5B for ; Mon, 28 Nov 2016 09:42:28 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id C576B266D44; Mon, 28 Nov 2016 10:42:26 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id BE985266B24; Mon, 28 Nov 2016 10:40:08 +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 383F0266C6B; Mon, 28 Nov 2016 06:31:43 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by alsa0.perex.cz (Postfix) with ESMTP id 082012669E3 for ; Mon, 28 Nov 2016 06:31:39 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 27 Nov 2016 21:31:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,562,1473145200"; d="scan'208"; a="1091316187" Received: from amanda-haswell-pc.sh.intel.com ([10.239.159.21]) by fmsmga002.fm.intel.com with ESMTP; 27 Nov 2016 21:31:29 -0800 From: mengdong.lin@linux.intel.com To: alsa-devel@alsa-project.org Date: Mon, 28 Nov 2016 13:33:34 +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, broonie@kernel.org Subject: [alsa-devel] [PATCH v3 1/3] ucm: Skip component directories when scanning sound card configuration files 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 Cards are defined by machines. DSPs embedded in SoC and off-soc codecs can be taken as components for machines, and can be reused by different machines/cards. Codec and SoC vendors can define their own UCM config files. If a codec or DSP is used by a machine, the card configuration file can include the conf file of the codec and DSP. Later patches will complete support for this feature. Two new directories will be used to store the UCM configuration files for a specific codec or DSP firmware: - /usr/share/alsa/ucm/dsps ... for DSP embedded in SoC - /usr/share/alsa/ucm/codecs ... for off-soc codecs These two directories will be skipped when UCM manager scans the card directories under /usr/share/alsa/ucm. Signed-off-by: Mengdong Lin diff --git a/src/ucm/parser.c b/src/ucm/parser.c index 13f62d7..5c99ab4 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -36,6 +36,25 @@ /** The name of the environment variable containing the UCM directory */ #define ALSA_CONFIG_UCM_VAR "ALSA_CONFIG_UCM" +/* Directories to store UCM configuration files for components, like + * off-soc codecs or embedded DSPs. Components can define their own + * devices and sequences, to be reused by sound cards/machines. UCM + * manager should not scan these component directories. + * Machine use case files can include component configratuation files + * via alsaconf syntax: + * and . + * Alsaconf will import the included files automatically. After including + * a component file, a machine device's sequence can enable or disable + * a component device via syntax: + * enadev "component_device_name" + * disdev "component_device_name" + */ +static const char * const component_dir[] = { + "codecs", /* for off-soc codecs */ + "dsps", /* for DSPs embedded in SoC */ + NULL, /* terminator */ +}; + static int parse_sequence(snd_use_case_mgr_t *uc_mgr, struct list_head *base, snd_config_t *cfg); @@ -1259,7 +1278,28 @@ static int filename_filter(const struct dirent *dirent) return 0; } -/* scan all cards and comments */ +/* whether input dir is a predefined component directory */ +static int is_component_directory(const char *dir) +{ + int i = 0; + + while (component_dir[i]) { + if (!strncmp(dir, component_dir[i], PATH_MAX)) + return 1; + i++; + }; + + return 0; +} + +/* scan all cards and comments + * + * Cards are defined by machines. Each card/machine installs its UCM + * configuration files in a subdirectory with the same name as the sound + * card under /usr/share/alsa/ucm. This function will scan all the card + * directories and skip the component directories defined in the array + * component_dir. + */ int uc_mgr_scan_master_configs(const char **_list[]) { char filename[MAX_FILE], dfl[MAX_FILE]; @@ -1309,6 +1349,11 @@ int uc_mgr_scan_master_configs(const char **_list[]) } for (i = 0; i < cnt; i++) { + + /* Skip the directories for component devices */ + if (is_component_directory(namelist[i]->d_name)) + continue; + err = load_master_config(namelist[i]->d_name, &cfg); if (err < 0) goto __err;