Received: by 2002:a05:7208:13c3:b0:82:bbfa:f723 with SMTP id r3csp1545760rbe; Wed, 15 May 2024 06:35:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4iUaJTvkFtrWaHr+UcAZLyACMbvlUDoZZD0gHWU2gyegvWlwRsMT6TvocD6Da24jwuXhi6t4+xMt/uXbGUCaAew7zFiYocoGmqu30aw== X-Google-Smtp-Source: AGHT+IEpU7AUg4NO6aKU06RWtVdZbsCZfl5Q5EwWoX8fNHDj3rYr8QHV1fof1PQOatoyMBBkCTMr X-Received: by 2002:a25:f40b:0:b0:de8:bbc4:2b7 with SMTP id 3f1490d57ef6-dee4f324de2mr13885133276.8.1715780106823; Wed, 15 May 2024 06:35:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715780106; cv=pass; d=google.com; s=arc-20160816; b=uEov6ly6TUsBTiiV2v5tG44V7cyhJ8JkdnvVSCG5N9MEYDOtBon55TKE9JVdPgdGyS HO16sH9BJ1YYTrzCKcAInxSUkk0OP8YjCrYUFhceXxvSTZdWR6btBrEWZzvw/oBxMt9m KWy81yvcWHYlGZGKh7zQE3wtyanTtl3WNnEKT5a0lj7+JzgnHwU2d8qFtmoP2og33d5I zJ4h+oH7cRKMp10CqQ+qRuynOcpOMJC0KNnV4sK9GAeHVJxXIF5Oh31dztDQr1NK2cEb qEFm/7Doyq1jVIcIUAcUt3tDp8CTH3ve0/zfCt7u1OchxJ/VTVW4dJny/UZETsUHJct7 T4jQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=qKaNiR2tHzqJJTEKvrwnceIlUex2fFxFPfEzvQnl9LY=; fh=fkCY2i8xXdqfgDBe7N7OL2UdyOfJ/Wld8kIHK9y/EwE=; b=nQZxC+dSQX1v2o9yr30Wb6pDYQqaziyH4nlIFqJWe9vBpn5w1L2CwMoViZoG3oWf7j B+ufTx4QApNNJad9KxTwIoWAXO8zm9d14O9DaZUCb7tuBcy/A6lxmTXq4h9uREt814xQ NPZrlJnuwnBlVPYa9hC76PFzndIVgzaLw4VS8Q2vsVcfAIyWnOmYEWC45LshFwZI1jvQ xA+ECl4TxjQL31fPq4SwxR+XO728XCXjnWzp5iXJ6J4j1OnqTKNtBDM01P3OuIeiUJMk PLfto+7yMf4TqC4tipgQTkNlldcyCyZvN2kgdwlLMP6DsGBdOLYnas9yBVXGbT0nunUx iR6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QH1iQLTf; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-179919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179919-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df549d427si132629221cf.149.2024.05.15.06.35.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 06:35:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QH1iQLTf; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-179919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179919-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 71AC81C21DAE for ; Wed, 15 May 2024 13:35:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82308127B69; Wed, 15 May 2024 13:34:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QH1iQLTf" Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E444585C4E; Wed, 15 May 2024 13:34:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715780097; cv=none; b=t6lgLZGirKoV6pe1Axc1F/pby+czFZ8CDgYQRBGchF5pZskT86Ox+eMBQ6PDugtrLzdPSFB2QxkkrFBeP2pcm9j1nXakX7QHnjKpjH2XGH0SGk8vc4/LGzVJ3Q5OLiwXNIrzPq6yD+USsY45kU6+pVBYe8sAnxVKcC95ZupJOFI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715780097; c=relaxed/simple; bh=I+RNBBkXNRun6dwlq79VjFtLu9GasAAvP0Ewzfa3yQQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=NxQcnTWyPbTbZrSXPPI+EG5ujjZciN+WA+GzYxGqwhHDZ9CoHuraStfJIqKPA7uiUQLRwgdy6p+bDDrrJ2B/8Xi30r3YAXi+1h/7XM6v8tAc5rbfimdxii7FrWadNYUm3a+5g7I9mvoZe0/BA1+s55lIKMxHEDKiVJrlYuatHr8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QH1iQLTf; arc=none smtp.client-ip=209.85.166.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-36c5d26045bso776215ab.0; Wed, 15 May 2024 06:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715780095; x=1716384895; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qKaNiR2tHzqJJTEKvrwnceIlUex2fFxFPfEzvQnl9LY=; b=QH1iQLTflmCophRmBFBBl4ukDwEbt/Ts73+w6sU2TexKo4VBBECHaBt2Ic0L8JMD44 p+zMQZaRqBdLfvcz1MkMB053v/DRG4BoMFsZRMmQ8lzJgWmMeQrQNA+6NY4PFNs+dGf6 pEbyVR4SJy6QvosK5RX1rfjXHCkzlkgC06/EhIqZguIlgY16ly/g2beiOKVseo7QBz8a vQQ+JP5U5PW0N4C2LAwPPgTxZ+Cz4pb1EjXuXsUOVpa2Rhkat1wRTQ0Iv71kO41BUwGc pI+ef2gsJ4Zpkc4zOIB1xeegM1n8NQu0ywRAytS6kZnDisnVyzH7kq5S+1EhX+FlkyFv CDmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715780095; x=1716384895; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qKaNiR2tHzqJJTEKvrwnceIlUex2fFxFPfEzvQnl9LY=; b=EV/+EeDX/kaK1LYCmw65TsCC5C26odakQcPZBWVterPMTE9gp/9OAsP30EbZROk4xc Tg2aEGXy46UDDqusYWd15pI8VEPA1CUDGC2MD4mohjspdS6Mog21wsO+sdcjHP/1ZoL+ uMBAeGyLawzJyfpkFgG2VQXljBClRIc1+HeOxH4PyaRyCChF6qk44cdwdVfSexKfdX+w ku15KOMDUPA+gWcK2sIq0wEiJ24qxAYDaEl8lwSys9/8W1tpDtg6BO0EpsgyMROsLDrI Zky6vxhzLaIq4YINflWPso+4E86y02asde2I2zM6pMFmmGpng1Fxhcf7mJ6P8hSZJ6I/ UxhQ== X-Forwarded-Encrypted: i=1; AJvYcCWtOaxB5HJLtzv3TVxgdN13wJgU5KP/xEljUJA1cnHFfn+HmBLHL7HSjwjYWXmR8rRaLXk1PEPRybC86Dwf7DgsAhDYzKs8Q92ZlKechkrF9rThwF2BfcxcJ07SRihuWKRq5HEYn2Hvv3A= X-Gm-Message-State: AOJu0YxTb+q1oLrQf5mAov9H4wxnZu6yhi96kyvqfBR9U5SDtGCUQGwD /ceDiaYvcf7SLICXBSLN7kNfWSkCHfDtHL7gJnReYmDtw1+hxRVN3nL7xdaM8TkbFsBwxxGzu5o 6VB0F8E61FpaF2L6J4P0M81th3AE= X-Received: by 2002:a05:6e02:12cd:b0:36c:c536:80dd with SMTP id e9e14a558f8ab-36cc536824dmr181987035ab.11.1715780095030; Wed, 15 May 2024 06:34:55 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <1710834674-3285-1-git-send-email-shengjiu.wang@nxp.com> <87sez0k661.wl-tiwai@suse.de> <20240502095956.0a8c5b26@sal.lan> <20240502102643.4ee7f6c2@sal.lan> <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> In-Reply-To: From: Shengjiu Wang Date: Wed, 15 May 2024 21:34:43 +0800 Message-ID: Subject: Re: [PATCH v15 00/16] Add audio support in v4l2 framework To: Jaroslav Kysela Cc: Takashi Iwai , Hans Verkuil , =?UTF-8?B?QW1hZGV1c3ogU8WCYXdpxYRza2k=?= , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 15, 2024 at 6:46=E2=80=AFPM Jaroslav Kysela wr= ote: > > 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 (processin= g) -> > >>>>>>> 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 cap= ture > >>>>>> needs to synchronize. Usually the playback and capture pipeline i= s > >>>>>> independent in ALSA design, but in this case, the playback and ca= pture > >>>>>> should synchronize, they are not independent. > >>>>> > >>>>> The core compress API core no strict timing constraints. You can ev= entually0 > >>>>> have two half-duplex compress devices, if you like to have really i= ndependent > >>>>> 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 with= out 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 ha= ndled > >>>> using one system call like blocking ioctl). The goal is just to off= load 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 d= emand, of > >>>> course. > >>>> > >>>> Otherwise all pieces are already in the current ALSA compress API > >>>> (capabilities, params, enumeration). The realtime controls may be cr= eated > >>>> using ALSA control API. > >>> > >>> So does this mean that Shengjiu should attempt to use this ALSA appro= ach 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 supportin= g > 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 se= ems > 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 feasib= le > 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, 2. Compress API doesn't seem to support mmap(). Is this a problem for sending and getting data to/from the driver? 3. How does the user get output data from ASRC after each conversion? it should happen every period. best regards Shengjiu Wang.