Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp345086lqo; Thu, 16 May 2024 07:59:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV6y68p8tgp9cswiQxnHSBZHxFPGOnvrQONOEks8lSOkEJpo16Fi1khuOLLRvpCTKuFf1qTHIQjawfex+HROnACquOrjwFZY0FlHXtlPA== X-Google-Smtp-Source: AGHT+IF8Zswot8xz6Mpmnu8/bnmzjcIlmOHoz0gpO3509aHf+4kpSG8iCBKmSb9M3gdNqjvOfiHG X-Received: by 2002:a05:6358:d16:b0:186:2990:adb6 with SMTP id e5c5f4694b2df-193bb4ff5ecmr2052792755d.2.1715871572647; Thu, 16 May 2024 07:59:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715871572; cv=pass; d=google.com; s=arc-20160816; b=WuK69WOZT3CpQSP8eRTm2MR9srdcotQXV6s4pi2cH0U2ljjKSMAIjtJoSRaFNU3kET x25XwmoGYf3z5iI7K94AUnAf3fUlOZ4CUPtH2xDRai5/pHw4pTwdIH8JCzJG1c0l0Zf4 vVFiu+v51zo9SQcJ/tuHJsXH6+iOK15d2PDRyKYtq05S2kGcNB0Z+4rrWpP2M5Ojso4r dsiQC8bvNFMdSGB4oo9wfSKlhZ7KZFhC+hvBbXS+GN1ZjqSYoBIo9AodPyW36XzKqFxN SNzllEyZoGN2tc0CkfiaZRvgisC7JRqLgKsp627iHln1d4EkG0Znu0+n7qupDXQISNpG BCWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature:dkim-filter; bh=E37t/wiEilpJfGfz1Kzwd27xayIRgTZoOH7EN27Xj+4=; fh=3LmbTsv0xggarME55v4N9OUsTIwLTseEnSJva/TeSRs=; b=OVabrWT1UqaiLPsxEOtQIU9Xus2jNCGir630suMdq39nMhgNnGeH6oKt87SIPXpHvJ +Eh9O1nMomNPxVvEICKlXKTYz/R0+inLe9a8hKCr4aVIkSRDR8FC2eg+Fs+HwRKqkWWU nrTqq/GvB4zR0akGKbkVls6pMtOWhTC3WXLL7BKunGJfXgndtKvM4fESFvT0sYqFYJkv 6TNOxITrBCXjmxHZqiGo6Nek8H3LkhnPpSxRvL7wGUhykvqlXUs3EiXJm+Y9rxBxhCK3 iIirXbW5vaD/CKeSwyOim5hSTMiF8qfwkkP+dJPVrdPtxXWODMft83qugMNvkCQGQyF0 QQ8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@perex.cz header.s=default header.b=s0RsLqQM; arc=pass (i=1 spf=pass spfdomain=perex.cz dkim=pass dkdomain=perex.cz dmarc=pass fromdomain=perex.cz); spf=pass (google.com: domain of linux-kernel+bounces-181193-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181193-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=perex.cz Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-63409e82582si17605757a12.67.2024.05.16.07.59.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 07:59:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181193-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@perex.cz header.s=default header.b=s0RsLqQM; arc=pass (i=1 spf=pass spfdomain=perex.cz dkim=pass dkdomain=perex.cz dmarc=pass fromdomain=perex.cz); spf=pass (google.com: domain of linux-kernel+bounces-181193-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181193-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=perex.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1EB8C2842AD for ; Thu, 16 May 2024 14:59:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92B8714C5B3; Thu, 16 May 2024 14:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=perex.cz header.i=@perex.cz header.b="s0RsLqQM" Received: from mail1.perex.cz (mail1.perex.cz [77.48.224.245]) (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 043051E491; Thu, 16 May 2024 14:59:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=77.48.224.245 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715871559; cv=none; b=nxQO4vnQqkMB4p7+W1nADitSZVoqaNccxnnL0/bNuTRYlQN79nnXLMjdekW7YGgUbgBVRtYST3RbBSDpsdvVIhLVJIi/w15yE66DXnpEMZwmIvJupWkzakPBS1F9z91yxldB6cyy+cQTLkhSlFRPfXmEfaeaAALMaZ6Ak/obTWQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715871559; c=relaxed/simple; bh=TEgyeOIBIyfhuIOv446q/MbgUveg9VV8KhGybk9xzWs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=SVo+uxbjzve8XhD+PcAYGmz0YiXk7ZuAKxG2BfkbrSvQ21IHCOTmo7/A5HtTx4Px461BskeLSX0YZNUHgLBsdbmAgvrJ2oVzQsGwd5bnpQXeLUfa8msGOejGMvraDXGlGmJVhEyzwARG1Uf5FErpzwq7SIKIyO60CbMbwshjh70= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=perex.cz; spf=pass smtp.mailfrom=perex.cz; dkim=pass (1024-bit key) header.d=perex.cz header.i=@perex.cz header.b=s0RsLqQM; arc=none smtp.client-ip=77.48.224.245 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=perex.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=perex.cz Received: from mail1.perex.cz (localhost [127.0.0.1]) by smtp1.perex.cz (Perex's E-mail Delivery System) with ESMTP id C6EBE45B9; Thu, 16 May 2024 16:59:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.perex.cz C6EBE45B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perex.cz; s=default; t=1715871553; bh=E37t/wiEilpJfGfz1Kzwd27xayIRgTZoOH7EN27Xj+4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=s0RsLqQM9urENxnM8KAiNXP8CShGtnlMYrnsgJoWIw6isubrtP6i5c+t4YpgsyT3W 8ORHoDKqpEZCKAgzm4PDejj2mPlUwVzRBoOUSk/wQBELCvfT0b+7+Kx2JSGnykXeZE LSefVBMKHI+lkm7fO0lpZx4Hz2vI5CMD7Br1H5m0= Received: from [192.168.100.98] (unknown [192.168.100.98]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: perex) by mail1.perex.cz (Perex's E-mail Delivery System) with ESMTPSA; Thu, 16 May 2024 16:58:53 +0200 (CEST) Message-ID: <2411016f-2289-4a2b-8bf8-39ab2f9f1571@perex.cz> Date: Thu, 16 May 2024 16:58:53 +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: [PATCH v15 00/16] Add audio support in v4l2 framework To: Shengjiu Wang Cc: Takashi Iwai , Hans Verkuil , =?UTF-8?Q?Amadeusz_S=C5=82awi=C5=84ski?= , Mauro Carvalho Chehab , Mark Brown , Sebastian Fricke , Shengjiu Wang , sakari.ailus@iki.fi, tfiga@chromium.org, m.szyprowski@samsung.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, tiwai@suse.com, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org References: <1710834674-3285-1-git-send-email-shengjiu.wang@nxp.com> <20240503094225.47fe4836@sal.lan> <22d94c69-7e9f-4aba-ae71-50cc2e5dd8ab@xs4all.nl> <51408e79-646d-4d23-bc5b-cd173d363327@linux.intel.com> <2f771fe9-7c09-4e74-9b04-de52581133fd@linux.intel.com> <28d423b1-49d8-4180-8394-622b1afd9cd9@perex.cz> <850a80b2-d952-4c14-bd0b-98cb5a5c0233@perex.cz> <8a6f84ac-5813-4954-b852-84f5118e607c@perex.cz> <87o7975qcw.wl-tiwai@suse.de> From: Jaroslav Kysela Content-Language: en-US Autocrypt: addr=perex@perex.cz; keydata= xsFNBFvNeCsBEACUu2ZgwoGXmVFGukNPWjA68/7eMWI7AvNHpekSGv3z42Iy4DGZabs2Jtvk ZeWulJmMOh9ktP9rVWYKL9H54gH5LSdxjYYTQpSCPzM37nisJaksC8XCwD4yTDR+VFCtB5z/ E7U0qujGhU5jDTne3dZpVv1QnYHlVHk4noKxLjvEQIdJWzsF6e2EMp4SLG/OXhdC9ZeNt5IU HQpcKgyIOUdq+44B4VCzAMniaNLKNAZkTQ6Hc0sz0jXdq+8ZpaoPEgLlt7IlztT/MUcH3ABD LwcFvCsuPLLmiczk6/38iIjqM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ZI5xMSnqhaMmWCL99OWwfyJn2omp8R+lBfAJZR31vW6wzsj ssOvKIbgBpV/o3oGyAofIXPYzhY+jhWgOYtiPw9bknu748K+kK3fk0OeEG6doO4leB7LuWig dmLZkcLlJzSE6UhEwHZ8WREOMIGJnMF51WcF0A3JUeKpYYEvSJNDEm7dRtpb0x/Y5HIfrg5/ qAKutAYPY7ClQLu5RHv5uqshiwyfGPaiE8Coyphvd5YbOlMm3mC/DbEstHG7zA89fN9gAzsJ 0TFL5lNz1s/fo+//ktlG9H28EHD8WOwkpibsngpvY+FKUGfJgIxpmdXVOkiORWQpndWyRIqw k8vz1gDNeG7HOIh46GnKIrQiUXVzAuUvM5vI9YaW3YRNTcn3pguQRt+Tl9Y6G+j+yvuLL173 m4zRUU6DOygmpQAVYSOJvKAJ07AhQGaWAAi5msM6BcTU4YGcpW7FHr6+xaFDlRHzf1lkvavX WoxP1IA1DFuBMeYMzfyi4qDWjXc+C51ZaQd39EulYMh+JVaWRoY= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 15. 05. 24 15:34, Shengjiu Wang wrote: > On Wed, May 15, 2024 at 6:46 PM Jaroslav Kysela wrote: >> >> On 15. 05. 24 12:19, Takashi Iwai wrote: >>> On Wed, 15 May 2024 11:50:52 +0200, >>> Jaroslav Kysela wrote: >>>> >>>> On 15. 05. 24 11:17, Hans Verkuil wrote: >>>>> Hi Jaroslav, >>>>> >>>>> On 5/13/24 13:56, Jaroslav Kysela wrote: >>>>>> On 09. 05. 24 13:13, Jaroslav Kysela wrote: >>>>>>> On 09. 05. 24 12:44, Shengjiu Wang wrote: >>>>>>>>>> mem2mem is just like the decoder in the compress pipeline. which is >>>>>>>>>> one of the components in the pipeline. >>>>>>>>> >>>>>>>>> I was thinking of loopback with endpoints using compress streams, >>>>>>>>> without physical endpoint, something like: >>>>>>>>> >>>>>>>>> compress playback (to feed data from userspace) -> DSP (processing) -> >>>>>>>>> compress capture (send data back to userspace) >>>>>>>>> >>>>>>>>> Unless I'm missing something, you should be able to process data as fast >>>>>>>>> as you can feed it and consume it in such case. >>>>>>>>> >>>>>>>> >>>>>>>> Actually in the beginning I tried this, but it did not work well. >>>>>>>> ALSA needs time control for playback and capture, playback and capture >>>>>>>> needs to synchronize. Usually the playback and capture pipeline is >>>>>>>> independent in ALSA design, but in this case, the playback and capture >>>>>>>> should synchronize, they are not independent. >>>>>>> >>>>>>> The core compress API core no strict timing constraints. You can eventually0 >>>>>>> have two half-duplex compress devices, if you like to have really independent >>>>>>> mechanism. If something is missing in API, you can extend this API (like to >>>>>>> inform the user space that it's a producer/consumer processing without any >>>>>>> relation to the real time). I like this idea. >>>>>> >>>>>> I was thinking more about this. If I am right, the mentioned use in gstreamer >>>>>> is supposed to run the conversion (DSP) job in "one shot" (can be handled >>>>>> using one system call like blocking ioctl). The goal is just to offload the >>>>>> CPU work to the DSP (co-processor). If there are no requirements for the >>>>>> queuing, we can implement this ioctl in the compress ALSA API easily using the >>>>>> data management through the dma-buf API. We can eventually define a new >>>>>> direction (enum snd_compr_direction) like SND_COMPRESS_CONVERT or so to allow >>>>>> handle this new data scheme. The API may be extended later on real demand, of >>>>>> course. >>>>>> >>>>>> Otherwise all pieces are already in the current ALSA compress API >>>>>> (capabilities, params, enumeration). The realtime controls may be created >>>>>> using ALSA control API. >>>>> >>>>> So does this mean that Shengjiu should attempt to use this ALSA approach first? >>>> >>>> I've not seen any argument to use v4l2 mem2mem buffer scheme for this >>>> data conversion forcefully. It looks like a simple job and ALSA APIs >>>> may be extended for this simple purpose. >>>> >>>> Shengjiu, what are your requirements for gstreamer support? Would be a >>>> new blocking ioctl enough for the initial support in the compress ALSA >>>> API? >>> >>> If it works with compress API, it'd be great, yeah. >>> So, your idea is to open compress-offload devices for read and write, >>> then and let them convert a la batch jobs without timing control? >>> >>> For full-duplex usages, we might need some more extensions, so that >>> both read and write parameters can be synchronized. (So far the >>> compress stream is a unidirectional, and the runtime buffer for a >>> single stream.) >>> >>> And the buffer management is based on the fixed size fragments. I >>> hope this doesn't matter much for the intended operation? >> >> It's a question, if the standard I/O is really required for this case. My >> quick idea was to just implement a new "direction" for this job supporting >> only one ioctl for the data processing which will execute the job in "one >> shot" at the moment. The I/O may be handled through dma-buf API (which seems >> to be standard nowadays for this purpose and allows future chaining). >> >> So something like: >> >> struct dsp_job { >> int source_fd; /* dma-buf FD with source data - for dma_buf_get() */ >> int target_fd; /* dma-buf FD for target data - for dma_buf_get() */ >> ... maybe some extra data size members here ... >> ... maybe some special parameters here ... >> }; >> >> #define SNDRV_COMPRESS_DSPJOB _IOWR('C', 0x60, struct dsp_job) >> >> This ioctl will be blocking (thus synced). My question is, if it's feasible >> for gstreamer or not. For this particular case, if the rate conversion is >> implemented in software, it will block the gstreamer data processing, too. >> > > Thanks. > > I have several questions: > 1. Compress API alway binds to a sound card. Can we avoid that? > For ASRC, it is just one component, Is this a real issue? Usually, I would expect a sound hardware (card) presence when ASRC is available, or not? Eventually, a separate sound card with one compress device may be created, too. For enumeration - the user space may just iterate through all sound cards / compress devices to find ASRC in the system. The devices/interfaces in the sound card are independent. Also, USB MIDI converters offer only one serial MIDI interface for example, too. > 2. Compress API doesn't seem to support mmap(). Is this a problem > for sending and getting data to/from the driver? I proposed to use dma-buf for I/O (separate source and target buffer). > 3. How does the user get output data from ASRC after each conversion? > it should happen every period. target dma-buf Jaroslav -- Jaroslav Kysela Linux Sound Maintainer; ALSA Project; Red Hat, Inc.