linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Shengjiu Wang <shengjiu.wang@nxp.com>,
	sakari.ailus@iki.fi, tfiga@chromium.org,
	m.szyprowski@samsung.com, mchehab@kernel.org,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com,
	nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org,
	perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [RFC PATCH v6 07/11] media: v4l2: Add audio capture and output support
Date: Mon, 16 Oct 2023 14:24:05 +0200	[thread overview]
Message-ID: <d1ca2a68-3a1c-4fee-a284-9fd1c68066f8@xs4all.nl> (raw)
In-Reply-To: <1697185865-27528-8-git-send-email-shengjiu.wang@nxp.com>

On 13/10/2023 10:31, Shengjiu Wang wrote:
> Audio signal processing has the requirement for memory to
> memory similar as Video.
> 
> This patch is to add this support in v4l2 framework, defined
> new buffer type V4L2_BUF_TYPE_AUDIO_CAPTURE and
> V4L2_BUF_TYPE_AUDIO_OUTPUT, defined new format v4l2_audio_format
> for audio case usage.
> 
> The created audio device is named "/dev/v4l-audioX".
> 
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
>  .../userspace-api/media/v4l/buffer.rst        |  6 ++
>  .../media/v4l/dev-audio-mem2mem.rst           | 71 +++++++++++++++++++
>  .../userspace-api/media/v4l/devices.rst       |  1 +
>  .../media/v4l/vidioc-enum-fmt.rst             |  2 +
>  .../userspace-api/media/v4l/vidioc-g-fmt.rst  |  4 ++
>  .../media/videodev2.h.rst.exceptions          |  2 +
>  .../media/common/videobuf2/videobuf2-v4l2.c   |  4 ++
>  drivers/media/v4l2-core/v4l2-dev.c            | 17 +++++
>  drivers/media/v4l2-core/v4l2-ioctl.c          | 53 ++++++++++++++
>  include/media/v4l2-dev.h                      |  2 +
>  include/media/v4l2-ioctl.h                    | 34 +++++++++
>  include/uapi/linux/videodev2.h                | 17 +++++
>  12 files changed, 213 insertions(+)
>  create mode 100644 Documentation/userspace-api/media/v4l/dev-audio-mem2mem.rst
> 
> diff --git a/Documentation/userspace-api/media/v4l/buffer.rst b/Documentation/userspace-api/media/v4l/buffer.rst
> index 04dec3e570ed..80cf2cb20dfe 100644
> --- a/Documentation/userspace-api/media/v4l/buffer.rst
> +++ b/Documentation/userspace-api/media/v4l/buffer.rst
> @@ -438,6 +438,12 @@ enum v4l2_buf_type
>      * - ``V4L2_BUF_TYPE_META_OUTPUT``
>        - 14
>        - Buffer for metadata output, see :ref:`metadata`.
> +    * - ``V4L2_BUF_TYPE_AUDIO_CAPTURE``
> +      - 15
> +      - Buffer for audio capture, see :ref:`audio`.
> +    * - ``V4L2_BUF_TYPE_AUDIO_OUTPUT``
> +      - 16
> +      - Buffer for audio output, see :ref:`audio`.
>  
>  
>  .. _buffer-flags:
> diff --git a/Documentation/userspace-api/media/v4l/dev-audio-mem2mem.rst b/Documentation/userspace-api/media/v4l/dev-audio-mem2mem.rst
> new file mode 100644
> index 000000000000..2ea493d0a73b
> --- /dev/null
> +++ b/Documentation/userspace-api/media/v4l/dev-audio-mem2mem.rst
> @@ -0,0 +1,71 @@
> +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
> +
> +.. _audiomem2mem:
> +
> +********************************
> +Audio Memory-To-Memory Interface
> +********************************
> +
> +A audio memory-to-memory device can compress, decompress, transform, or

A -> An

> +otherwise convert audio data from one format into another format, in memory.
> +Such memory-to-memory devices set the ``V4L2_CAP_AUDIO_M2M`` capability.
> +Examples of memory-to-memory devices are codecs, audio preprocessing,

codecs -> audio codecs

Reason: within V4L2 'codec' refers to a video codec by default, so for audio
codecs it is better to be explicit and mention 'audio'.

> +audio postprocessing.
> +
> +A memory-to-memory audio node supports both output (sending frames from

I think it is better to write 'audio frames' instead of just 'frames', for
the same reason as why I prefer 'audio codec'. It makes it explicit that we
are dealing with audio.

> +memory to the hardware) and capture (receiving the processed frames

audio frames

> +from the hardware into memory) stream I/O. An application will have to
> +setup the stream I/O for both sides and finally call
> +:ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>` for both capture and output to
> +start the hardware.
> +
> +Memory-to-memory devices function as a shared resource: you can
> +open the audio node multiple times, each application setting up their
> +own properties that are local to the file handle, and each can use
> +it independently from the others. The driver will arbitrate access to
> +the hardware and reprogram it whenever another file handler gets access.
> +
> +Audio memory-to-memory devices are accessed through character device
> +special files named ``/dev/v4l-audio``
> +
> +Querying Capabilities
> +=====================
> +
> +Device nodes supporting the audio memory-to-memory interface set the
> +``V4L2_CAP_AUDIO_M2M`` flag in the ``device_caps`` field of the
> +:c:type:`v4l2_capability` structure returned by the :c:func:`VIDIOC_QUERYCAP`
> +ioctl.
> +
> +Data Format Negotiation
> +=======================
> +
> +The audio device uses the :ref:`format` ioctls to select the capture format.
> +The audio buffer content format is bound to that selected format. In addition
> +to the basic :ref:`format` ioctls, the :c:func:`VIDIOC_ENUM_FMT` ioctl must be
> +supported as well.
> +
> +To use the :ref:`format` ioctls applications set the ``type`` field of the
> +:c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_AUDIO_CAPTURE`` or to
> +``V4L2_BUF_TYPE_AUDIO_OUTPUT``. Both drivers and applications must set the
> +remainder of the :c:type:`v4l2_format` structure to 0.
> +
> +.. c:type:: v4l2_audio_format
> +
> +.. tabularcolumns:: |p{1.4cm}|p{2.4cm}|p{13.5cm}|
> +
> +.. flat-table:: struct v4l2_audio_format
> +    :header-rows:  0
> +    :stub-columns: 0
> +    :widths:       1 1 2
> +
> +    * - __u32
> +      - ``pixelformat``
> +      - The sample format, set by the application. see :ref:`pixfmt-audio`
> +    * - __u32
> +      - ``channels``
> +      - The channel number, set by the application. channel number range is
> +        [1, 32].
> +    * - __u32
> +      - ``buffersize``
> +      - Maximum buffer size in bytes required for data. The value is set by the
> +        driver.

<snip>

Regards,

	Hans

  reply	other threads:[~2023-10-16 12:24 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13  8:30 [RFC PATCH v6 00/11] Add audio support in v4l2 framework Shengjiu Wang
2023-10-13  8:30 ` [RFC PATCH v6 01/11] ASoC: fsl_asrc: define functions for memory to memory usage Shengjiu Wang
2023-10-13 13:18   ` Mark Brown
2023-10-13  8:30 ` [RFC PATCH v6 02/11] ASoC: fsl_easrc: " Shengjiu Wang
2023-10-13 13:19   ` Mark Brown
2023-10-13  8:30 ` [RFC PATCH v6 03/11] ASoC: fsl_asrc: move fsl_asrc_common.h to include/sound Shengjiu Wang
2023-10-13 13:19   ` Mark Brown
2023-10-13  8:30 ` [RFC PATCH v6 04/11] ASoC: fsl_asrc: register m2m platform device Shengjiu Wang
2023-10-13 13:21   ` Mark Brown
2023-10-13  8:30 ` [RFC PATCH v6 05/11] ASoC: fsl_easrc: " Shengjiu Wang
2023-10-13 13:39   ` Mark Brown
2023-10-13  8:31 ` [RFC PATCH v6 06/11] media: uapi: Add V4L2_CAP_AUDIO_M2M capability flag Shengjiu Wang
2023-10-13  8:31 ` [RFC PATCH v6 07/11] media: v4l2: Add audio capture and output support Shengjiu Wang
2023-10-16 12:24   ` Hans Verkuil [this message]
2023-10-13  8:31 ` [RFC PATCH v6 08/11] media: uapi: define audio sample format fourcc type Shengjiu Wang
2023-10-16 12:32   ` Hans Verkuil
2023-10-13  8:31 ` [RFC PATCH v6 09/11] media: uapi: Add audio rate controls support Shengjiu Wang
2023-10-16 13:16   ` Hans Verkuil
2023-10-17 13:11     ` Shengjiu Wang
2023-10-17 13:37       ` Hans Verkuil
2023-10-18  2:27         ` Shengjiu Wang
2023-10-18  7:23           ` Shengjiu Wang
2023-10-18  7:31             ` Hans Verkuil
2023-10-18  7:40               ` Shengjiu Wang
2023-10-18  7:58                 ` Hans Verkuil
2023-10-18 12:52                   ` Shengjiu Wang
2023-10-18 13:09                     ` Hans Verkuil
2023-10-18 13:50                       ` Shengjiu Wang
2023-10-18 14:17                         ` Hans Verkuil
2023-10-19 10:44                   ` Shengjiu Wang
2023-10-19 10:51                     ` Hans Verkuil
2023-10-13  8:31 ` [RFC PATCH v6 10/11] media: imx-asrc: Add memory to memory driver Shengjiu Wang
2023-10-16 14:01   ` Hans Verkuil
2023-10-18 12:53     ` Shengjiu Wang
2023-10-18 12:57       ` Hans Verkuil
2023-10-13  8:31 ` [RFC PATCH v6 11/11] media: viaudm2m: add virtual driver for audio memory to memory Shengjiu Wang
2023-10-16 14:08   ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d1ca2a68-3a1c-4fee-a284-9fd1c68066f8@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=Xiubo.Lee@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=festevam@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@kernel.org \
    --cc=nicoleotsuka@gmail.com \
    --cc=perex@perex.cz \
    --cc=sakari.ailus@iki.fi \
    --cc=shengjiu.wang@gmail.com \
    --cc=shengjiu.wang@nxp.com \
    --cc=tfiga@chromium.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).