Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3485874imm; Fri, 25 May 2018 06:35:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrvwEk3uDNH0s+v37/SCmtdG5UqoJkbYeqpenGHK2Q7vYYlFsHueYs8Mi/bhLDRAE/Y9B99 X-Received: by 2002:a63:2783:: with SMTP id n125-v6mr2001570pgn.377.1527255334103; Fri, 25 May 2018 06:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527255334; cv=none; d=google.com; s=arc-20160816; b=ZTS1qnnC51hJLgD7G8i/E+H3PzQEF3UTVBRVOZ/xuyg0mDqXfiizPHTuMMALjuvHcb Th296A9NKsbIVI6YMbuKclpgpYCbediQIYEU4nUyDVkrz/Rl9JUl0fwwd+zi1uRckJ4V t324E5vR+5WFJiR24SvQfiJZBXnZKJNYE668rMjn6xzaAo0r8W+VRvTTsFwcK8vObK1q /Oh50x7y/b5/+dlYN+raYufF4ZrH6LlaKhbhjEn2a7Cr0emtDX9cioFLoP/6vz4LRURn lM+2jz6EvRJSPnB9Mc+WDDC6fbplAp4FZPaTtz/O/t7CPmWphQV2t1NqUeIG+yW+7plz 1X0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=HWspjScbSPOJq3NgOzDuVSZt30DNJcatuIHKjiL/sIA=; b=08M1DzcJQlttnPDLRbxWqrJ/kqK3dtWH/cBqz+1TJkNO/RFfMVzKnOwVVkQHuBUvm2 ngKKvKPxZf39TjerzTW0p8Lk6bpPXIXTIOi3X0WVLyb44P9nVF/UUJ0yrdwvOr1JF4Cw kmswjRcEcMgpLOGS3nCmoM3Uy3GIKKHPp0WKKh2iwWDjYyJ2PdVdZvNoRe8Ia/XyevYg kX29vk2j7JT92JaYQl7h6JDPIJJfqGfzjZ7TT2lZMxJgaq1agU+UX1Q1AsLodu0+ESpW IxC7AAT395+m2g4bjwyKMNEZ2FhRwEktaPPYvO9tjDk8k/tcJHD/QhvdyBsAtibfOiQC MVYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v80-v6si24146112pfa.173.2018.05.25.06.35.19; Fri, 25 May 2018 06:35:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935737AbeEYNfH (ORCPT + 99 others); Fri, 25 May 2018 09:35:07 -0400 Received: from mga01.intel.com ([192.55.52.88]:27768 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933214AbeEYNfG (ORCPT ); Fri, 25 May 2018 09:35:06 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 May 2018 06:35:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,440,1520924400"; d="scan'208";a="231625568" Received: from snc-desk.iind.intel.com (HELO snc-desk) ([10.223.96.118]) by fmsmga005.fm.intel.com with ESMTP; 25 May 2018 06:35:02 -0700 Date: Fri, 25 May 2018 19:03:23 +0530 From: Shreyas NC To: Guenter Roeck Cc: Takashi Iwai , Mark Brown , Liam Girdwood , alsa-devel@alsa-project.org, Pierre-Louis Bossart , linux-kernel@vger.kernel.org, Chintan Patel , Guenter Roeck , vkoul@kernel.org Subject: Re: [alsa-devel] [PATCH v2 1/3] ASoC: topology: Improve backwards compatibility with v4 topology files Message-ID: <20180525133323.GI3116@snc-desk> References: <1527191363-21021-1-git-send-email-linux@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1527191363-21021-1-git-send-email-linux@roeck-us.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding Vinod to help review as well.. > Commit dc31e741db49 ("ASoC: topology: ABI - Add the types for BE > DAI") introduced sound topology files version 5. Initially, this > change made the topology code incompatible with v4 topology files. > Backwards compatibility with v4 configuration files was > subsequently added with commit 288b8da7e992 ("ASoC: topology: > Support topology file of ABI v4"). > > Unfortunately, backwards compatibility was never fully implemented. > > First, the manifest size in (Skylake) v4 configuration files is set > to 0, which causes manifest_new_ver() to bail out with error messages > similar to the following. > > snd_soc_skl 0000:00:1f.3: ASoC: invalid manifest size > snd_soc_skl 0000:00:1f.3: tplg component load failed-22 > snd_soc_skl 0000:00:1f.3: Failed to init topology! > snd_soc_skl 0000:00:1f.3: ASoC: failed to probe component -22 > skl_n88l25_m98357a skl_n88l25_m98357a: ASoC: failed to instantiate card -22 > skl_n88l25_m98357a: probe of skl_n88l25_m98357a failed with error -22 > > After this problem is fixed, the following error message is seen instead. > > snd_soc_skl 0000:00:1f.3: ASoC: old version of manifest > snd_soc_skl 0000:00:1f.3: Invalid descriptor token 1093938482 > snd_soc_skl 0000:00:1f.3: ASoC: failed to load widget media0_in cpr 0 > snd_soc_skl 0000:00:1f.3: tPlg component load failed-22 > > This message is seen because backwards compatibility for loading widgets > was never implemented. > > The lack of audio support when running the upstream kernel on recent > Chromebooks has been reported in various forums, and can be traced back > to this problem. Attempts to fix the problem, usually by providing v5 > configuration files, were only partially successful. > > Let's implement backward compatibility properly to solve the problem > for good. > > Signed-off-by: Guenter Roeck > --- > Tested on Caroline (Samsung Chromebook Pro) and Chell (HP Chromebook 13 > G1) running v4.17-rc6 plus this patch, with original (v4) configuration > files. Also tested on several other Chromebooks with this patch on top > of chromeos-4.14. > > v2: > - Move on from RFC/RFT to real patch > - Move v4 structure definitions into header file > - Add support for copying private capabilities > - Declare skl_dfw_v4_module_caps as __packed > - Drop duplicate assignment of mconfig->pipe->state > > sound/soc/intel/skylake/skl-topology.c | 169 +++++++++++++++++++ > sound/soc/intel/skylake/skl-tplg-interface.h | 74 ++++++++ > sound/soc/soc-topology.c | 7 +- > 3 files changed, 248 insertions(+), 2 deletions(-) > > diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c > index 3b1dca419883..9e4c2cb88dea 100644 > --- a/sound/soc/intel/skylake/skl-topology.c > +++ b/sound/soc/intel/skylake/skl-topology.c > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -2724,6 +2725,167 @@ static int skl_tplg_get_desc_blocks(struct device *dev, > return -EINVAL; > } > > +/* Functions to parse private data from configuration file format v4 */ > + > +/* > + * Add pipeline from topology binary into driver pipeline list > + * > + * If already added we return that instance > + * Otherwise we create a new instance and add into driver list > + */ > +static int skl_tplg_add_pipe_v4(struct device *dev, > + struct skl_module_cfg *mconfig, struct skl *skl, > + struct skl_dfw_v4_pipe *dfw_pipe) > +{ > + struct skl_pipeline *ppl; > + struct skl_pipe *pipe; > + struct skl_pipe_params *params; > + > + list_for_each_entry(ppl, &skl->ppl_list, node) { > + if (ppl->pipe->ppl_id == dfw_pipe->pipe_id) { > + mconfig->pipe = ppl->pipe; > + return 0; > + } > + } > + > + ppl = devm_kzalloc(dev, sizeof(*ppl), GFP_KERNEL); > + if (!ppl) > + return -ENOMEM; > + > + pipe = devm_kzalloc(dev, sizeof(*pipe), GFP_KERNEL); > + if (!pipe) > + return -ENOMEM; > + > + params = devm_kzalloc(dev, sizeof(*params), GFP_KERNEL); > + if (!params) > + return -ENOMEM; > + > + pipe->ppl_id = dfw_pipe->pipe_id; > + pipe->memory_pages = dfw_pipe->memory_pages; > + pipe->pipe_priority = dfw_pipe->pipe_priority; > + pipe->conn_type = dfw_pipe->conn_type; > + pipe->state = SKL_PIPE_INVALID; > + pipe->p_params = params; > + INIT_LIST_HEAD(&pipe->w_list); > + > + ppl->pipe = pipe; > + list_add(&ppl->node, &skl->ppl_list); > + > + mconfig->pipe = pipe; > + > + return 0; > +} > + > +static void skl_fill_module_pin_info_v4(struct skl_dfw_v4_module_pin *dfw_pin, > + struct skl_module_pin *m_pin, > + bool is_dynamic, int max_pin) > +{ > + int i; > + > + for (i = 0; i < max_pin; i++) { > + m_pin[i].id.module_id = dfw_pin[i].module_id; > + m_pin[i].id.instance_id = dfw_pin[i].instance_id; > + m_pin[i].in_use = false; > + m_pin[i].is_dynamic = is_dynamic; > + m_pin[i].pin_state = SKL_PIN_UNBIND; > + } > +} > + > +static void skl_tplg_fill_fmt_v4(struct skl_module_pin_fmt *dst_fmt, > + struct skl_dfw_v4_module_fmt *src_fmt, > + int pins) > +{ > + int i; > + > + for (i = 0; i < pins; i++) { > + dst_fmt[i].fmt.channels = src_fmt[i].channels; > + dst_fmt[i].fmt.s_freq = src_fmt[i].freq; > + dst_fmt[i].fmt.bit_depth = src_fmt[i].bit_depth; > + dst_fmt[i].fmt.valid_bit_depth = src_fmt[i].valid_bit_depth; > + dst_fmt[i].fmt.ch_cfg = src_fmt[i].ch_cfg; > + dst_fmt[i].fmt.ch_map = src_fmt[i].ch_map; > + dst_fmt[i].fmt.interleaving_style = > + src_fmt[i].interleaving_style; > + dst_fmt[i].fmt.sample_type = src_fmt[i].sample_type; > + } > +} > + > +static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w, > + struct skl *skl, struct device *dev, > + struct skl_module_cfg *mconfig) > +{ > + struct skl_dfw_v4_module *dfw = > + (struct skl_dfw_v4_module *)tplg_w->priv.data; > + int ret; > + > + dev_dbg(dev, "Parsing Skylake v4 widget topology data\n"); > + > + ret = guid_parse(dfw->uuid, (guid_t *)mconfig->guid); > + if (ret) > + return ret; > + mconfig->id.module_id = -1; > + mconfig->id.instance_id = dfw->instance_id; > + mconfig->module->resources[0].cps = dfw->max_mcps; > + mconfig->module->resources[0].ibs = dfw->ibs; > + mconfig->module->resources[0].obs = dfw->obs; > + mconfig->core_id = dfw->core_id; > + mconfig->module->max_input_pins = dfw->max_in_queue; > + mconfig->module->max_output_pins = dfw->max_out_queue; > + mconfig->module->loadable = dfw->is_loadable; > + skl_tplg_fill_fmt_v4(mconfig->module->formats[0].inputs, dfw->in_fmt, > + MAX_IN_QUEUE); > + skl_tplg_fill_fmt_v4(mconfig->module->formats[0].outputs, dfw->out_fmt, > + MAX_OUT_QUEUE); > + > + mconfig->params_fixup = dfw->params_fixup; > + mconfig->converter = dfw->converter; > + mconfig->m_type = dfw->module_type; > + mconfig->vbus_id = dfw->vbus_id; > + mconfig->module->resources[0].is_pages = dfw->mem_pages; > + > + ret = skl_tplg_add_pipe_v4(dev, mconfig, skl, &dfw->pipe); > + if (ret) > + return ret; > + > + mconfig->dev_type = dfw->dev_type; > + mconfig->hw_conn_type = dfw->hw_conn_type; > + mconfig->time_slot = dfw->time_slot; > + mconfig->formats_config.caps_size = dfw->caps.caps_size; > + > + mconfig->m_in_pin = devm_kzalloc(dev, > + MAX_IN_QUEUE * sizeof(*mconfig->m_in_pin), > + GFP_KERNEL); > + if (!mconfig->m_in_pin) > + return -ENOMEM; > + > + mconfig->m_out_pin = devm_kzalloc(dev, > + MAX_OUT_QUEUE * sizeof(*mconfig->m_out_pin), > + GFP_KERNEL); > + if (!mconfig->m_out_pin) > + return -ENOMEM; > + > + skl_fill_module_pin_info_v4(dfw->in_pin, mconfig->m_in_pin, > + dfw->is_dynamic_in_pin, > + mconfig->module->max_input_pins); > + skl_fill_module_pin_info_v4(dfw->out_pin, mconfig->m_out_pin, > + dfw->is_dynamic_out_pin, > + mconfig->module->max_output_pins); > + > + if (mconfig->formats_config.caps_size) { > + mconfig->formats_config.set_params = dfw->caps.set_params; > + mconfig->formats_config.param_id = dfw->caps.param_id; > + mconfig->formats_config.caps = > + devm_kzalloc(dev, mconfig->formats_config.caps_size, > + GFP_KERNEL); > + if (!mconfig->formats_config.caps) > + return -ENOMEM; > + memcpy(mconfig->formats_config.caps, dfw->caps.caps, > + dfw->caps.caps_size); > + } > + > + return 0; > +} > + > /* > * Parse the private data for the token and corresponding value. > * The private data can have multiple data blocks. So, a data block > @@ -2739,6 +2901,13 @@ static int skl_tplg_get_pvt_data(struct snd_soc_tplg_dapm_widget *tplg_w, > char *data; > int ret; > > + /* > + * v4 configuration files have a valid UUID at the start of > + * the widget's private data. > + */ > + if (uuid_is_valid((char *)tplg_w->priv.data)) > + return skl_tplg_get_pvt_data_v4(tplg_w, skl, dev, mconfig); > + > /* Read the NUM_DATA_BLOCKS descriptor */ > array = (struct snd_soc_tplg_vendor_array *)tplg_w->priv.data; > ret = skl_tplg_get_desc_blocks(dev, array); > diff --git a/sound/soc/intel/skylake/skl-tplg-interface.h b/sound/soc/intel/skylake/skl-tplg-interface.h > index f8d1749a2e0c..b0e3d376594c 100644 > --- a/sound/soc/intel/skylake/skl-tplg-interface.h > +++ b/sound/soc/intel/skylake/skl-tplg-interface.h > @@ -169,4 +169,78 @@ enum skl_tuple_type { > SKL_TYPE_DATA > }; > > +/* v4 configuration data */ > + > +struct skl_dfw_v4_module_pin { > + u16 module_id; > + u16 instance_id; > +} __packed; > + > +struct skl_dfw_v4_module_fmt { > + u32 channels; > + u32 freq; > + u32 bit_depth; > + u32 valid_bit_depth; > + u32 ch_cfg; > + u32 interleaving_style; > + u32 sample_type; > + u32 ch_map; > +} __packed; > + > +struct skl_dfw_v4_module_caps { > + u32 set_params:2; > + u32 rsvd:30; > + u32 param_id; > + u32 caps_size; > + u32 caps[HDA_SST_CFG_MAX]; > +} __packed; > + > +struct skl_dfw_v4_pipe { > + u8 pipe_id; > + u8 pipe_priority; > + u16 conn_type:4; > + u16 rsvd:4; > + u16 memory_pages:8; > +} __packed; > + > +struct skl_dfw_v4_module { > + char uuid[SKL_UUID_STR_SZ]; > + > + u16 module_id; > + u16 instance_id; > + u32 max_mcps; > + u32 mem_pages; > + u32 obs; > + u32 ibs; > + u32 vbus_id; > + > + u32 max_in_queue:8; > + u32 max_out_queue:8; > + u32 time_slot:8; > + u32 core_id:4; > + u32 rsvd1:4; > + > + u32 module_type:8; > + u32 conn_type:4; > + u32 dev_type:4; > + u32 hw_conn_type:4; > + u32 rsvd2:12; > + > + u32 params_fixup:8; > + u32 converter:8; > + u32 input_pin_type:1; > + u32 output_pin_type:1; > + u32 is_dynamic_in_pin:1; > + u32 is_dynamic_out_pin:1; > + u32 is_loadable:1; > + u32 rsvd3:11; > + > + struct skl_dfw_v4_pipe pipe; > + struct skl_dfw_v4_module_fmt in_fmt[MAX_IN_QUEUE]; > + struct skl_dfw_v4_module_fmt out_fmt[MAX_OUT_QUEUE]; > + struct skl_dfw_v4_module_pin in_pin[MAX_IN_QUEUE]; > + struct skl_dfw_v4_module_pin out_pin[MAX_OUT_QUEUE]; > + struct skl_dfw_v4_module_caps caps; > +} __packed; > + > #endif > diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c > index 986b8b2f90fb..d66b2e5ccd67 100644 > --- a/sound/soc/soc-topology.c > +++ b/sound/soc/soc-topology.c > @@ -2293,8 +2293,11 @@ static int manifest_new_ver(struct soc_tplg *tplg, > *manifest = NULL; > > if (src->size != sizeof(*src_v4)) { > - dev_err(tplg->dev, "ASoC: invalid manifest size\n"); > - return -EINVAL; > + dev_warn(tplg->dev, "ASoC: invalid manifest size %d\n", > + src->size); > + if (src->size) > + return -EINVAL; > + src->size = sizeof(*src_v4); > } > > dev_warn(tplg->dev, "ASoC: old version of manifest\n"); > -- > 2.17.0.441.gb46fe60e1d-goog > > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel --