Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp899400pxb; Fri, 21 Jan 2022 05:59:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDnRC2AMqW1d8OMqLrg0foNzAGMF02HEqF5GODFcz8CikpFjADqyyrx6l1IDwH9iJQa8xp X-Received: by 2002:a17:902:8bcb:b0:149:907d:80c9 with SMTP id r11-20020a1709028bcb00b00149907d80c9mr3687530plo.15.1642773549221; Fri, 21 Jan 2022 05:59:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642773549; cv=none; d=google.com; s=arc-20160816; b=bGZKkBa/w5RGTLYLwbqS2EA2MSGNAPYNppKaLZBtnK5QSmsB7NQzN4FQPEqRfp7dbC ZvYt5EsOj1yTvu8aXnve8LHCbwj/zClVuBuPemr3inWQujNLnnvaupbA+h4erBC0Ii3u 0JkGSKRDcSJzOHJyER0wGWYyC6UTSNXH78tXj6AhxzaqB5a5UdoHaBEwg+ERvfQ7NnGe iBoSLXm0KI9ddKEujFkajH3q34H/Gu79wW8ilg5UAhkK5hOmHP/supAO+lU/4PXUzxzN sOWBn+sFMdexpjcbONIhgZDpSWqSbAOCBAZjIzUm0U+VcVPoxfVuWG4+0EYiLPt4C7v/ /YBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=1h2HlXOHi+5BeGmuK8WmcYLSZSds0okgnYyTkrxk0X4=; b=LUFNCVjebFtW/Uyjtgh0pCdOpjXHoJZLnhbL7eD8BzYatwpWd2U0k6kieQsALcnwxz MlLLg/Wi2LunZXIZUIcGtNoGajPOm/iswWa6duaH75Yge9nuIaEczhWWi0hS/VIdQsF7 U0u3MFGID9kakEMQyJ0PLshp5KUM5Z4fPJpGho+rmBp2k4tPnaSTaIZqaFO4UXafPV6G /M7v+SJ4R4XLysoiDDuU3VFn7Enk1HUCs85uuspuSwooHkPdrRwKf/0f9kcN3iq4bfpS eLol8ouZWKaN6KAy2u35eAmINpGDbaf++U7l+H1rKFn0ZR3PDeElLf3+iK8ZIhMdLDtP NMOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="hD6483/c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a19si6114900pld.341.2022.01.21.05.58.57; Fri, 21 Jan 2022 05:59:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="hD6483/c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350854AbiASCHe (ORCPT + 99 others); Tue, 18 Jan 2022 21:07:34 -0500 Received: from mga09.intel.com ([134.134.136.24]:14240 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350649AbiASCHd (ORCPT ); Tue, 18 Jan 2022 21:07:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642558053; x=1674094053; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=SADnO3+RxA7TLM946fh6hsuryNfZzjZ8vuXRamwkzA0=; b=hD6483/cPfvT/FSLEDd0eyI7o4itsSwTVYEmcTa5dPVKfMOzzcaqj02F KcEnHODx23gVK6SPLJM9IAAzMnycm3x+rxa/JfgbLk1hy3G6ayS22VReF NuP4YCiXaBorWRsSqI3C+Kujhgn+04nR4LX612mco/UVSKJulfEa30RRn MLQgZxR6J0tAkBb/VFgTlQZ6TgepLGZffBspy9A7sUcIwJos+Y35KX/j7 im8T51VEsC2DTQssqXK4rg3Q6gLtXJtTIhPpzFE68tQiyvuGSFz70yNKs GtVQ9q8mspDhnXFLEcBKooam0eYLFdBV6y1FXgB8M8Tr9BMaZdaOjolPr g==; X-IronPort-AV: E=McAfee;i="6200,9189,10231"; a="244756699" X-IronPort-AV: E=Sophos;i="5.88,298,1635231600"; d="scan'208";a="244756699" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 18:07:32 -0800 X-IronPort-AV: E=Sophos;i="5.88,298,1635231600"; d="scan'208";a="622350895" Received: from mdzurick-mobl.amr.corp.intel.com (HELO [10.209.145.208]) ([10.209.145.208]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 18:07:31 -0800 Subject: Re: [PATCH v2 2/2] ASoC: SOF: compress: Implement get_caps and get_codec_caps To: Daniel Baluta , lgirdwood@gmail.com, broonie@kernel.org Cc: alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, cezary.rojewski@intel.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, paul.olaru@nxp.com, daniel.baluta@nxp.com, sound-open-firmware@alsa-project.org References: <20220118212732.281657-1-daniel.baluta@oss.nxp.com> <20220118212732.281657-3-daniel.baluta@oss.nxp.com> From: Pierre-Louis Bossart Message-ID: <41ae6093-8e27-01d4-e532-8a28fb1d9cf1@linux.intel.com> Date: Tue, 18 Jan 2022 19:00:35 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20220118212732.281657-3-daniel.baluta@oss.nxp.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/18/22 3:27 PM, Daniel Baluta wrote: > From: Paul Olaru > > These functions are used by the userspace to determine what the firmware > supports and tools like cplay should use in terms of sample rate, bit > rate, buffer size and channel count. > > The current implementation uses i.MX8 tested scenarios! > > Signed-off-by: Paul Olaru > Signed-off-by: Daniel Baluta > --- > sound/soc/sof/compress.c | 74 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 74 insertions(+) > > diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c > index 91a9c95929cd..e3f3f309f312 100644 > --- a/sound/soc/sof/compress.c > +++ b/sound/soc/sof/compress.c > @@ -308,6 +308,78 @@ static int sof_compr_pointer(struct snd_soc_component *component, > return 0; > } > > +static int sof_compr_get_caps(struct snd_soc_component *component, > + struct snd_compr_stream *cstream, > + struct snd_compr_caps *caps) > +{ > + caps->num_codecs = 3; > + caps->min_fragment_size = 3840; > + caps->max_fragment_size = 3840; > + caps->min_fragments = 2; > + caps->max_fragments = 2; > + caps->codecs[0] = SND_AUDIOCODEC_MP3; > + caps->codecs[1] = SND_AUDIOCODEC_AAC; > + caps->codecs[2] = SND_AUDIOCODEC_PCM; I don't think you can add this unconditionally for all devices/platforms, clearly this wouldn't be true for Intel for now. If the information is not part of a firmware manifest or topology, then it's likely we have to use an abstraction layer to add this for specific platforms. it's really a bit odd to hard-code all of this at the kernel level, this was not really what I had in mind when we come up with the concept of querying capabilities. I understand though that for testing this is convenient, so maybe this can become a set of fall-back properties in case the firmware doesn't advertise anything. > + > + return 0; > +} > + > +static struct snd_compr_codec_caps caps_pcm = { > + .num_descriptors = 1, > + .descriptor[0].max_ch = 2, > + .descriptor[0].sample_rates[0] = 48000, > + .descriptor[0].num_sample_rates = 1, > + .descriptor[0].bit_rate = {1536, 3072}, > + .descriptor[0].num_bitrates = 2, > + .descriptor[0].profiles = SND_AUDIOPROFILE_PCM, > + .descriptor[0].modes = 0, > + .descriptor[0].formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, > +}; > + > +static struct snd_compr_codec_caps caps_mp3 = { > + .num_descriptors = 1, > + .descriptor[0].max_ch = 2, > + .descriptor[0].sample_rates[0] = 48000, > + .descriptor[0].num_sample_rates = 1, > + .descriptor[0].bit_rate = {32, 40, 48, 56, 64, 80, 96, 112, 224, 256, 320}, > + .descriptor[0].num_bitrates = 11, > + .descriptor[0].profiles = 0, > + .descriptor[0].modes = SND_AUDIOCHANMODE_MP3_STEREO, > + .descriptor[0].formats = 0, > +}; > + > +static struct snd_compr_codec_caps caps_aac = { > + .num_descriptors = 1, > + .descriptor[0].max_ch = 2, > + .descriptor[0].sample_rates[0] = 48000, > + .descriptor[0].num_sample_rates = 1, > + .descriptor[0].bit_rate = {128, 192}, > + .descriptor[0].num_bitrates = 2, > + .descriptor[0].profiles = 0, > + .descriptor[0].modes = 0, > + .descriptor[0].formats = SND_AUDIOSTREAMFORMAT_MP4ADTS | SND_AUDIOSTREAMFORMAT_MP2ADTS, > +}; > + > +static int sof_compr_get_codec_caps(struct snd_soc_component *component, > + struct snd_compr_stream *cstream, > + struct snd_compr_codec_caps *codec) > +{ > + switch (codec->codec) { > + case SND_AUDIOCODEC_MP3: > + *codec = caps_mp3; > + break; > + case SND_AUDIOCODEC_AAC: > + *codec = caps_aac; > + break; > + case SND_AUDIOCODEC_PCM: > + *codec = caps_pcm; > + break; > + default: > + return -EINVAL; > + } > + return 0; > +} > + > struct snd_compress_ops sof_compressed_ops = { > .open = sof_compr_open, > .free = sof_compr_free, > @@ -316,5 +388,7 @@ struct snd_compress_ops sof_compressed_ops = { > .trigger = sof_compr_trigger, > .pointer = sof_compr_pointer, > .copy = sof_compr_copy, > + .get_caps = sof_compr_get_caps, > + .get_codec_caps = sof_compr_get_codec_caps, > }; > EXPORT_SYMBOL(sof_compressed_ops); >