From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B401376F1; Tue, 20 Aug 2024 06:59:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724137153; cv=none; b=EIE1V89gAcV0ZFpGXfowPJ2j7L0uKSsGtKOLfYbWc7X6nt8WGhbBgwCDnZd97yJimwzd8hHHCYs7uB6K8wguWZv0DlXo54EGlhQPOs1ZXELtUuWocFM45laBlfMcOhx6c5sZzIdxhj3NO3w51AX9A08t8DM+/RIlrNwpzbkbTCQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724137153; c=relaxed/simple; bh=NcREdHOzn6eEuhanW6i690bjb9VwRs6u8txLft1j9/Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dLuvQOki/CYfZlxpOhBGw9KFkaJ8/AyAAEmvhqV009kI398JgxbeF9I2y5KV6gWUkSn0Yf8QU18vnjMpIsiX74kTZW5WI6tnjg7oFUnozzg4Fkq7e2pLkkQgBRg1BWWl6XO6Dc7ca1p5d4mF3iUaPlSucRj1Iskqb0Z18CtwcR4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=f4hco5p5; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="f4hco5p5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724137151; x=1755673151; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=NcREdHOzn6eEuhanW6i690bjb9VwRs6u8txLft1j9/Q=; b=f4hco5p5N58Yp65E8ogHNBNqDOOMy/FpEE5Zi6kH2gpWZ11ihUXBFn2+ ypVpwJrXFH55piL8RZNcxhJRRTDC/ixPzE4iyJmOYv7Wsce1bbJCwwytn qHfHOEUeCRIsxzuWQssNqOlt2QMvtmnG4C4kNShqx8qrsNIJ0z95AJ6d8 CtiQ6KeetOlQ2ASG4ES4BPXLQPUXhaqCypa0oEGJMBe7QL3gtrytme9pX es0A8hfbSMrGGHTHtR2A+5rFPmQQzSyAMowP9rWXRUhb1ohz0YXcClOt/ 97lf1A2qyPL7nVPqVpxQxbFgn96vLxeCptwkbPfsu6UnCIy/4q+TjuauS g==; X-CSE-ConnectionGUID: 0gnHGxVbTzylAv1U2ndF2A== X-CSE-MsgGUID: T+3/T0n0S5mpqyMAxWm9aQ== X-IronPort-AV: E=McAfee;i="6700,10204,11169"; a="25317853" X-IronPort-AV: E=Sophos;i="6.10,161,1719903600"; d="scan'208";a="25317853" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2024 23:59:10 -0700 X-CSE-ConnectionGUID: HkwFrFwHTIadBOLDMsLoOQ== X-CSE-MsgGUID: kQY+sT18QaiAKg8czy5lKA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,161,1719903600"; d="scan'208";a="61179403" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO [10.245.246.176]) ([10.245.246.176]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2024 23:59:07 -0700 Message-ID: Date: Tue, 20 Aug 2024 08:59:04 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 4/6] ASoC: fsl_asrc_m2m: Add memory to memory function To: Shengjiu Wang Cc: Shengjiu Wang , vkoul@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, linuxppc-dev@lists.ozlabs.org References: <1723804959-31921-1-git-send-email-shengjiu.wang@nxp.com> <1723804959-31921-5-git-send-email-shengjiu.wang@nxp.com> <6d83cd58-5f02-414b-b627-a0022e071052@linux.intel.com> Content-Language: en-US From: Pierre-Louis Bossart In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 8/20/24 04:53, Shengjiu Wang wrote: > On Mon, Aug 19, 2024 at 3:42 PM Pierre-Louis Bossart > wrote: >> >> >> >> On 8/16/24 12:42, Shengjiu Wang wrote: >>> Implement the ASRC memory to memory function using >>> the compress framework, user can use this function with >>> compress ioctl interface. >>> >>> Define below private metadata key value for output >>> format, output rate and ratio modifier configuration. >>> ASRC_OUTPUT_FORMAT 0x80000001 >>> ASRC_OUTPUT_RATE 0x80000002 >>> ASRC_RATIO_MOD 0x80000003 >> >> Can the output format/rate change at run-time? > > Seldom I think. > >> >> If no, then these parameters should be moved somewhere else - e.g. >> hw_params or something. > > This means I will do some changes in compress_params.h, add > output format and output rate definition, follow Jaroslav's example > right? yes, having parameters for the PCM case would make sense. >> I am still not very clear on the expanding the SET_METADATA ioctl to >> deal with the ratio changes. This isn't linked to the control layer as >> suggested before, and there's no precedent of calling it multiple times >> during streaming. > > Which control layer? if you means the snd_kcontrol_new? it is bound > with sound card, but in my case, I need to the control bind with > the snd_compr_stream to support multi streams/instances. I can only quote Jaroslav's previous answer: " This argument is not valid. The controls are bound to the card, but the element identifiers have already iface (interface), device and subdevice numbers. We are using controls for PCM devices for example. The binding is straight. Just add SNDRV_CTL_ELEM_IFACE_COMPRESS define and specify the compress device number in the 'struct snd_ctl_elem_id'. " >> I also wonder how it was tested since tinycompress does not support this? > > I wrote a unit test to test these ASRC M2M functions. This should be shared IMHO, usually when we add/extend a new interface it's best to have a userspace test program that can be used by others. >>> +static int fsl_asrc_m2m_fill_codec_caps(struct fsl_asrc *asrc, >>> + struct snd_compr_codec_caps *codec) >>> +{ >>> + struct fsl_asrc_m2m_cap cap; >>> + __u32 rates[MAX_NUM_BITRATES]; >>> + snd_pcm_format_t k; >>> + int i = 0, j = 0; >>> + int ret; >>> + >>> + ret = asrc->m2m_get_cap(&cap); >>> + if (ret) >>> + return -EINVAL; >>> + >>> + if (cap.rate_in & SNDRV_PCM_RATE_5512) >>> + rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_5512); >> >> this doesn't sound compatible with the patch2 definitions? >> >> cap->rate_in = SNDRV_PCM_RATE_8000_768000; > > This ASRC M2M driver is designed for two kinds of hw ASRC modules. > > one cap is : cap->rate_in = SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_5512; > another is : cap->rate_in = SNDRV_PCM_RATE_8000_768000; > they are in patch2 and patch3 > > >> >>> + if (cap.rate_in & SNDRV_PCM_RATE_8000) >>> + rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_8000); >>> + if (cap.rate_in & SNDRV_PCM_RATE_11025) >>> + rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_11025); >>> + if (cap.rate_in & SNDRV_PCM_RATE_16000) >>> + rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_16000); >>> + if (cap.rate_in & SNDRV_PCM_RATE_22050) >>> + rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_22050); >> >> missing 24 kHz > > There is no SNDRV_PCM_RATE_24000 in ALSA. Right, but that doesn't mean 24kHz cannot be supported. We use constraints in those cases. see quote from Takashi found with a 2s Google search https://mailman.alsa-project.org/pipermail/alsa-devel/2013-November/069356.html " CONTINUOUS means that any rate between the specified min and max is fine, if no min or max is specified any rate is fine. KNOT means there are rates supported other than the standard rates defines by ALSA, but the other rates are enumerable. You'd typically specify them by explicitly listing them all and use a list constraint or you'd use one of the ratio constraints. " >>> + if (cap.rate_in & SNDRV_PCM_RATE_32000) >>> + rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_32000); >>> + if (cap.rate_in & SNDRV_PCM_RATE_44100) >>> + rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_44100); >>> + if (cap.rate_in & SNDRV_PCM_RATE_48000) >>> + rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_48000); >> >> missing 64kHz > > Yes, will add it.