Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp343584lqo; Wed, 8 May 2024 01:09:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUQf99gBcAdbqre15ExL2Wv657fn3Jp03gWMtKPXOvcZ8vPKrhMyvEF+3TrPL5+T/rR6Pe9OCFHVmd1+97uSp/vexwjvniNecI4blOnhw== X-Google-Smtp-Source: AGHT+IGMIbmsLxmMgFB/o1bdBJxDIEVac4g6jUB/o/pqeFlShUvr+/GPzyVYINx9T21/TERfJPiS X-Received: by 2002:a17:903:18a:b0:1e0:a2cf:62e8 with SMTP id d9443c01a7336-1ee62f75656mr77382585ad.10.1715155753728; Wed, 08 May 2024 01:09:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715155753; cv=pass; d=google.com; s=arc-20160816; b=zLZ2OzkC5B8wbhCATWlbP3clpwES3cUG6exfpMNoEriKb5QfCTCd6neMcXqQpQikUD BlQs6MYSWxhQ9e1ZbvQjNivCkq0wsAhUMH7V7Y36CN6it7bTjUgEA6WRJB3Yb6WJwV9W Y04yQBwhfJ5/EojYAj6YblnddJ7RmSCgLpfN6cxMG4d9y7blZ9LGyZnHkdact0wzKn9G Uxu6cgT/0B7fGo1ctAzCCP3d6pNM55jjXr8S+VZCIQiKPPluZGrJbl+UtawhR21OqlvZ 0KBYRlHtCQMZ0ve+VtOtw5QpvLp44/a6pGWE3IvGSqEnCYSY/RXP81d4WU19Jdvuwhdb g6fA== 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:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=fd7vK1LYWsWj44vNUpDWB1DaOzV+ZOC1Q0CHiK+7woc=; fh=ZoJU7wpP3bNt05ShVg8mrX94rpeka/rlBBeRXcHIq/Q=; b=uDz/jWWAmjDpjxebC2JCJixY6nVvqSqQeIpuNGzyIjqodbrN5UNqG905/tTrVkNCxY uAY1LY83MSquxvFNjrJKVnvgceSasaQ2WEkeDjckOQ9dJ1xQIPxbRTl/Udje7MoeRhqd /DsGnete0wO8KSg7RXQX7mv4wwIvxcLLr9yqM5Pm2o2o0OUelkk6xCLzmg7v4vyG76Sa 9JFiqPNIglEWAIcnDhefbebf/3pTbr2wY4jpEGM4caYRrDPWo6Wn7iWDXheG/qovyy9B jipRtfEkDer7SXg9IOcByz2fl4xNZCKUO2zJJ0OPte1w+4FnmwIkI1Q44bhZ0UP2lqqm 69sw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-172872-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172872-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id w8-20020a170902e88800b001eb76680de2si10300250plg.42.2024.05.08.01.09.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 01:09:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172872-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-172872-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172872-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8169CB20F7D for ; Wed, 8 May 2024 08:01:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E30D33EA69; Wed, 8 May 2024 08:01:04 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 30A5B364A5; Wed, 8 May 2024 08:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715155264; cv=none; b=NP2C86hHDp4a2fnrEVLbpKO8uHTdvj+iRoWFORh0a5HHOrbzD1IShE9/1MLCIfVHdDOqqzQwnkuoz0ZSS4oBVuNr/tEFR9K503AvTo54Fw2pwkEHCOShwtOFa8f6zUNUpx1GZE4mu6VIo3v0LQjPxAbmWt2JxfABkxoUAxGgaf8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715155264; c=relaxed/simple; bh=j9mtN/+qNGY7X5OKe3ZB4Qyoq6d53u32TUqoKjXORts=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hVOcy7ngHzhE4v5Jp/AQookpIK8YBeTvDpl90CkgQ+fb9OHt1GiBp8Bhtg11SBElC+8gt88/Khd/8E8gQgwfUibIaAFjdQGqXeBr/PbdMQJ8gHsEXUPSF7OKm52qVmXycrhNc5lqRKwMy2faFPqAzUCMssgbhsa0idiENOHKPvs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94F6BC113CC; Wed, 8 May 2024 08:01:00 +0000 (UTC) Message-ID: <22d94c69-7e9f-4aba-ae71-50cc2e5dd8ab@xs4all.nl> Date: Wed, 8 May 2024 10:00:59 +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 Content-Language: en-US, nl To: Shengjiu Wang , Mauro Carvalho Chehab Cc: Mark Brown , Takashi Iwai , 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, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org References: <1710834674-3285-1-git-send-email-shengjiu.wang@nxp.com> <20240430082112.jrovosb6lgblgpfg@basti-XPS-13-9310> <20240430172752.20ffcd56@sal.lan> <87sez0k661.wl-tiwai@suse.de> <20240502095956.0a8c5b26@sal.lan> <20240502102643.4ee7f6c2@sal.lan> <20240503094225.47fe4836@sal.lan> From: Hans Verkuil Autocrypt: addr=hverkuil@xs4all.nl; keydata= xsFNBFQ84W0BEAC7EF1iL4s3tY8cRTVkJT/297h0Hz0ypA+ByVM4CdU9sN6ua/YoFlr9k0K4 BFUlg7JzJoUuRbKxkYb8mmqOe722j7N3HO8+ofnio5cAP5W0WwDpM0kM84BeHU0aPSTsWiGR yw55SOK2JBSq7hueotWLfJLobMWhQii0Zd83hGT9SIt9uHaHjgwmtTH7MSTIiaY6N14nw2Ud C6Uykc1va0Wqqc2ov5ihgk/2k2SKa02ookQI3e79laOrbZl5BOXNKR9LguuOZdX4XYR3Zi6/ BsJ7pVCK9xkiVf8svlEl94IHb+sa1KrlgGv3fn5xgzDw8Z222TfFceDL/2EzUyTdWc4GaPMC E/c1B4UOle6ZHg02+I8tZicj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vkv0Ilelt3Pb9J7zhcx6sm5T7v16VceF96jG61bnJ2GFS+QZerZp3PY27XgtPxRxYj AmFUeF486PHx/2Yi4u1rQpIpC5inPxIgR1+ZFvQrAV36SvLFfuMhyCAxV6WBlQc85ArOiQZB Wm7L0repwr7zEJFEkdy8C81WRhMdPvHkAIh3RoY1SGcdB7rB3wCzfYkAuCBqaF7Zgfw8xkad KEiQTexRbM1sc/I8ACpla3N26SfQwrfg6V7TIoweP0RwDrcf5PVvwSWsRQp2LxFCkwnCXOra gYmkrmv0duG1FStpY+IIQn1TOkuXrciTVfZY1cZD0aVxwlxXBnUNZZNslldvXFtndxR0SFat sflovhDxKyhFwXOP0Rv8H378/+14TaykknRBIKEc0+lcr+EMOSUR5eg4aURb8Gc3Uc7fgQ6q UssTXzHPyj1hAyDpfu8DzAwlh4kKFTodxSsKAjI45SLjadSc94/5Gy8645Y1KgBzBPTH7Q== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 06/05/2024 10:49, Shengjiu Wang wrote: > On Fri, May 3, 2024 at 4:42 PM Mauro Carvalho Chehab wrote: >> >> Em Fri, 3 May 2024 10:47:19 +0900 >> Mark Brown escreveu: >> >>> On Thu, May 02, 2024 at 10:26:43AM +0100, Mauro Carvalho Chehab wrote: >>>> Mauro Carvalho Chehab escreveu: >>> >>>>> There are still time control associated with it, as audio and video >>>>> needs to be in sync. This is done by controlling the buffers size >>>>> and could be fine-tuned by checking when the buffer transfer is done. >>> >>> ... >>> >>>> Just complementing: on media, we do this per video buffer (or >>>> per half video buffer). A typical use case on cameras is to have >>>> buffers transferred 30 times per second, if the video was streamed >>>> at 30 frames per second. >>> >>> IIRC some big use case for this hardware was transcoding so there was a >>> desire to just go at whatever rate the hardware could support as there >>> is no interactive user consuming the output as it is generated. >> >> Indeed, codecs could be used to just do transcoding, but I would >> expect it to be a border use case. See, as the chipsets implementing >> codecs are typically the ones used on mobiles, I would expect that >> the major use cases to be to watch audio and video and to participate >> on audio/video conferences. >> >> Going further, the codec API may end supporting not only transcoding >> (which is something that CPU can usually handle without too much >> processing) but also audio processing that may require more >> complex algorithms - even deep learning ones - like background noise >> removal, echo detection/removal, volume auto-gain, audio enhancement >> and such. >> >> On other words, the typical use cases will either have input >> or output being a physical hardware (microphone or speaker). >> > > All, thanks for spending time to discuss, it seems we go back to > the start point of this topic again. > > Our main request is that there is a hardware sample rate converter > on the chip, so users can use it in user space as a component like > software sample rate converter. It mostly may run as a gstreamer plugin. > so it is a memory to memory component. > > I didn't find such API in ALSA for such purpose, the best option for this > in the kernel is the V4L2 memory to memory framework I found. > As Hans said it is well designed for memory to memory. > > And I think audio is one of 'media'. As I can see that part of Radio > function is in ALSA, part of Radio function is in V4L2. part of HDMI > function is in DRM, part of HDMI function is in ALSA... > So using V4L2 for audio is not new from this point of view. > > Even now I still think V4L2 is the best option, but it looks like there > are a lot of rejects. If develop a new ALSA-mem2mem, it is also > a duplication of code (bigger duplication that just add audio support > in V4L2 I think). After reading this thread I still believe that the mem2mem framework is a reasonable option, unless someone can come up with a method that is easy to implement in the alsa subsystem. From what I can tell from this discussion no such method exists. From the media side there are arguments that it adds extra maintenance load, which is true, but I believe that it is quite limited in practice. That said, perhaps we should make a statement that while we support the use of audio m2m drivers, this is only for simple m2m audio processing like this driver, specifically where there is a 1-to-1 mapping between input and output buffers. At this point we do not want to add audio codec support or similar complex audio processing. Part of the reason is that codecs are hard, and we already have our hands full with all the video codecs. Part of the reason is that the v4l2-mem2mem framework probably needs to be forked to make a more advanced version geared towards codecs since the current framework is too limiting for some of the things we want to do. It was really designed for scalers, deinterlacers, etc. and the codec support was added later. If we ever allow such complex audio processing devices, then we would have to have another discussion, and I believe that will only be possible if most of the maintenance load would be on the alsa subsystem where the audio experts are. So my proposal is to: 1) add a clear statement to dev-audio-mem2mem.rst (patch 08/16) that only simple audio devices with a 1-to-1 mapping of input to output buffer are supported. Perhaps also in videodev2.h before struct v4l2_audio_format. 2) I will experiment a bit trying to solve the main complaint about creating new audio fourcc values and thus duplicating existing SNDRV_PCM_FORMAT_ values. I have some ideas for that. But I do not want to spend time on 2 until we agree that this is the way forward. Regards, Hans