mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Shengjiu Wang <shengjiu.wang@gmail.com>
Cc: 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,
	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 10/11] media: imx-asrc: Add memory to memory driver
Date: Wed, 18 Oct 2023 14:57:52 +0200	[thread overview]
Message-ID: <83c7dae1-4910-4e85-8b7e-bd803eac9523@xs4all.nl> (raw)
In-Reply-To: <CAA+D8ANKVwwqoYKo=rZGx029BykH9eDv=-VCQ3PP9p-k8faJ_w@mail.gmail.com>

On 18/10/2023 14:53, Shengjiu Wang wrote:
> On Mon, Oct 16, 2023 at 10:01 PM Hans Verkuil <hverkuil@xs4all.nl> wrote:
>>
>> On 13/10/2023 10:31, Shengjiu Wang wrote:
>>> Implement the ASRC memory to memory function using
>>> the v4l2 framework, user can use this function with
>>> v4l2 ioctl interface.
>>>
>>> User send the output and capture buffer to driver and
>>> driver store the converted data to the capture buffer.
>>>
>>> This feature can be shared by ASRC and EASRC drivers
>>>
>>> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
>>> ---
>>>  drivers/media/platform/nxp/Kconfig    |   12 +
>>>  drivers/media/platform/nxp/Makefile   |    1 +
>>>  drivers/media/platform/nxp/imx-asrc.c | 1248 +++++++++++++++++++++++++
>>>  3 files changed, 1261 insertions(+)
>>>  create mode 100644 drivers/media/platform/nxp/imx-asrc.c
>>>
>>> diff --git a/drivers/media/platform/nxp/Kconfig b/drivers/media/platform/nxp/Kconfig
>>> index 40e3436669e2..8234644ee341 100644
>>> --- a/drivers/media/platform/nxp/Kconfig
>>> +++ b/drivers/media/platform/nxp/Kconfig
>>> @@ -67,3 +67,15 @@ config VIDEO_MX2_EMMAPRP
>>>
>>>  source "drivers/media/platform/nxp/dw100/Kconfig"
>>>  source "drivers/media/platform/nxp/imx-jpeg/Kconfig"
>>> +
>>> +config VIDEO_IMX_ASRC
>>> +     tristate "NXP i.MX ASRC M2M support"
>>> +     depends on V4L_MEM2MEM_DRIVERS
>>> +     depends on MEDIA_SUPPORT
>>> +     select VIDEOBUF2_DMA_CONTIG
>>> +     select V4L2_MEM2MEM_DEV
>>> +     help
>>> +         Say Y if you want to add ASRC M2M support for NXP CPUs.
>>> +         It is a complement for ASRC M2P and ASRC P2M features.
>>> +         This option is only useful for out-of-tree drivers since
>>> +         in-tree drivers select it automatically.
>>> diff --git a/drivers/media/platform/nxp/Makefile b/drivers/media/platform/nxp/Makefile
>>> index 4d90eb713652..1325675e34f5 100644
>>> --- a/drivers/media/platform/nxp/Makefile
>>> +++ b/drivers/media/platform/nxp/Makefile
>>> @@ -9,3 +9,4 @@ obj-$(CONFIG_VIDEO_IMX8MQ_MIPI_CSI2) += imx8mq-mipi-csi2.o
>>>  obj-$(CONFIG_VIDEO_IMX_MIPI_CSIS) += imx-mipi-csis.o
>>>  obj-$(CONFIG_VIDEO_IMX_PXP) += imx-pxp.o
>>>  obj-$(CONFIG_VIDEO_MX2_EMMAPRP) += mx2_emmaprp.o
>>> +obj-$(CONFIG_VIDEO_IMX_ASRC) += imx-asrc.o
>>> diff --git a/drivers/media/platform/nxp/imx-asrc.c b/drivers/media/platform/nxp/imx-asrc.c
>>> new file mode 100644
>>> index 000000000000..373ca2b5ec90
>>> --- /dev/null
>>> +++ b/drivers/media/platform/nxp/imx-asrc.c
>>> @@ -0,0 +1,1248 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +//
>>> +// Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
>>> +// Copyright (C) 2019-2023 NXP
>>> +//
>>> +// Freescale ASRC Memory to Memory (M2M) driver
>>> +
>>> +#include <linux/dma/imx-dma.h>
>>> +#include <linux/pm_runtime.h>
>>> +#include <media/v4l2-ctrls.h>
>>> +#include <media/v4l2-device.h>
>>> +#include <media/v4l2-event.h>
>>> +#include <media/v4l2-fh.h>
>>> +#include <media/v4l2-ioctl.h>
>>> +#include <media/v4l2-mem2mem.h>
>>> +#include <media/videobuf2-dma-contig.h>
>>> +#include <sound/dmaengine_pcm.h>
>>> +#include <sound/fsl_asrc_common.h>
>>> +
>>> +#define V4L_CAP OUT
>>> +#define V4L_OUT IN
>>> +
>>> +#define ASRC_xPUT_DMA_CALLBACK(dir) \
>>> +     (((dir) == V4L_OUT) ? asrc_input_dma_callback \
>>> +     : asrc_output_dma_callback)
>>> +
>>> +#define DIR_STR(dir) (dir) == V4L_OUT ? "out" : "cap"
>>> +
>>> +#define ASRC_M2M_BUFFER_SIZE (512 * 1024)
>>> +#define ASRC_M2M_PERIOD_SIZE (48 * 1024)
>>> +#define ASRC_M2M_SG_NUM (20)
>>
>> Where do all these values come from? How do they relate?
>> Some comments would be welcome.
>>
>> Esp. ASRC_M2M_SG_NUM is a bit odd.
>>
>>> +
>>> +struct asrc_fmt {
>>> +     u32     fourcc;
>>> +     snd_pcm_format_t     format;
>>
>> Do you need this field? If not, then you can drop the whole
>> struct and just use u32 fourcc in the formats[] array.
>>
>>> +};
>>> +
>>> +struct asrc_pair_m2m {
>>> +     struct fsl_asrc_pair *pair;
>>> +     struct asrc_m2m *m2m;
>>> +     struct v4l2_fh fh;
>>> +     struct v4l2_ctrl_handler ctrl_handler;
>>> +     int channels[2];
>>> +     struct v4l2_ctrl_fixed_point src_rate;
>>> +     struct v4l2_ctrl_fixed_point dst_rate;
>>> +
>>> +};
>>> +
>>> +struct asrc_m2m {
>>> +     struct fsl_asrc_m2m_pdata pdata;
>>> +     struct v4l2_device v4l2_dev;
>>> +     struct v4l2_m2m_dev *m2m_dev;
>>> +     struct video_device *dec_vdev;
>>> +     struct mutex mlock; /* v4l2 ioctls serialization */
>>> +     struct platform_device *pdev;
>>> +};
>>> +
>>> +static struct asrc_fmt formats[] = {
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_S8,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_S16_LE,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_U16_LE,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_S24_LE,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_S24_3LE,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_U24_LE,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_U24_3LE,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_S32_LE,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_U32_LE,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_S20_3LE,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_U20_3LE,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_FLOAT_LE,
>>> +     },
>>> +     {
>>> +             .fourcc = V4L2_AUDIO_FMT_IEC958_SUBFRAME_LE,
>>> +     },
>>> +};
>>> +
>>> +#define NUM_FORMATS ARRAY_SIZE(formats)
>>> +
>>> +static snd_pcm_format_t convert_fourcc(u32 fourcc) {
>>> +
>>> +     return (__force snd_pcm_format_t)v4l2_fourcc_to_audfmt(fourcc);
>>
>> Is this cast something that should be done in the v4l2_fourcc_to_audfmt
>> define instead?
> 
> need to avoid include asound.h in videodev2.h,  so add this cast in driver.

It's a #define, so just including videodev2.h won't require asound.h.

Regards,

	Hans


  reply	other threads:[~2023-10-18 12:58 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
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 [this message]
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=83c7dae1-4910-4e85-8b7e-bd803eac9523@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

all inboxes | Powered by JetHome®