<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 28, 2023 at 3:59 PM Tomasz Figa <<a href="mailto:tfiga@chromium.org">tfiga@chromium.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Shengjiu,<br>
<br>
On Tue, Jul 25, 2023 at 02:12:17PM +0800, Shengjiu Wang wrote:<br>
> Audio signal processing has the requirement for memory to<br>
> memory similar as Video.<br>
> <br>
> This patch is to add this support in v4l2 framework, defined<br>
> new buffer type V4L2_BUF_TYPE_AUDIO_CAPTURE and<br>
> V4L2_BUF_TYPE_AUDIO_OUTPUT, defined new format v4l2_audio_format<br>
> for audio case usage.<br>
> <br>
> The created audio device is named "/dev/audioX".<br>
> <br>
> Signed-off-by: Shengjiu Wang <<a href="mailto:shengjiu.wang@nxp.com" target="_blank">shengjiu.wang@nxp.com</a>><br>
> ---<br>
>  .../media/common/videobuf2/videobuf2-v4l2.c   |  4 ++<br>
>  drivers/media/v4l2-core/v4l2-dev.c            | 17 ++++++<br>
>  drivers/media/v4l2-core/v4l2-ioctl.c          | 52 +++++++++++++++++++<br>
>  include/media/v4l2-dev.h                      |  2 +<br>
>  include/media/v4l2-ioctl.h                    | 34 ++++++++++++<br>
>  include/uapi/linux/videodev2.h                | 19 +++++++<br>
>  6 files changed, 128 insertions(+)<br>
> <br>
<br>
Thanks for the patch! Please check my comments inline.<br></blockquote><div><br></div><div>Thanks for reviewing.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c<br>
> index c7a54d82a55e..12f2be2773a2 100644<br>
> --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c<br>
> +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c<br>
> @@ -785,6 +785,10 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)<br>
>       case V4L2_BUF_TYPE_META_OUTPUT:<br>
>               requested_sizes[0] = f->fmt.meta.buffersize;<br>
>               break;<br>
> +     case V4L2_BUF_TYPE_AUDIO_CAPTURE:<br>
> +     case V4L2_BUF_TYPE_AUDIO_OUTPUT:<br>
> +             requested_sizes[0] = f->fmt.audio.buffersize;<br>
> +             break;<br>
>       default:<br>
>               return -EINVAL;<br>
>       }<br>
> diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c<br>
> index f81279492682..67484f4c6eaf 100644<br>
> --- a/drivers/media/v4l2-core/v4l2-dev.c<br>
> +++ b/drivers/media/v4l2-core/v4l2-dev.c<br>
> @@ -553,6 +553,7 @@ static void determine_valid_ioctls(struct video_device *vdev)<br>
>       bool is_tch = vdev->vfl_type == VFL_TYPE_TOUCH;<br>
>       bool is_meta = vdev->vfl_type == VFL_TYPE_VIDEO &&<br>
>                      (vdev->device_caps & meta_caps);<br>
> +     bool is_audio = vdev->vfl_type == VFL_TYPE_AUDIO;<br>
>       bool is_rx = vdev->vfl_dir != VFL_DIR_TX;<br>
>       bool is_tx = vdev->vfl_dir != VFL_DIR_RX;<br>
>       bool is_io_mc = vdev->device_caps & V4L2_CAP_IO_MC;<br>
> @@ -664,6 +665,19 @@ static void determine_valid_ioctls(struct video_device *vdev)<br>
>               SET_VALID_IOCTL(ops, VIDIOC_S_FMT, vidioc_s_fmt_meta_out);<br>
>               SET_VALID_IOCTL(ops, VIDIOC_TRY_FMT, vidioc_try_fmt_meta_out);<br>
>       }<br>
> +     if (is_audio && is_rx) {<br>
> +             /* audio capture specific ioctls */<br>
> +             SET_VALID_IOCTL(ops, VIDIOC_ENUM_FMT, vidioc_enum_fmt_audio_cap);<br>
> +             SET_VALID_IOCTL(ops, VIDIOC_G_FMT, vidioc_g_fmt_audio_cap);<br>
> +             SET_VALID_IOCTL(ops, VIDIOC_S_FMT, vidioc_s_fmt_audio_cap);<br>
> +             SET_VALID_IOCTL(ops, VIDIOC_TRY_FMT, vidioc_try_fmt_audio_cap);<br>
> +     } else if (is_audio && is_tx) {<br>
> +             /* audio output specific ioctls */<br>
> +             SET_VALID_IOCTL(ops, VIDIOC_ENUM_FMT, vidioc_enum_fmt_audio_out);<br>
> +             SET_VALID_IOCTL(ops, VIDIOC_G_FMT, vidioc_g_fmt_audio_out);<br>
> +             SET_VALID_IOCTL(ops, VIDIOC_S_FMT, vidioc_s_fmt_audio_out);<br>
> +             SET_VALID_IOCTL(ops, VIDIOC_TRY_FMT, vidioc_try_fmt_audio_out);<br>
> +     }<br>
>       if (is_vbi) {<br>
>               /* vbi specific ioctls */<br>
>               if ((is_rx && (ops->vidioc_g_fmt_vbi_cap ||<br>
> @@ -927,6 +941,9 @@ int __video_register_device(struct video_device *vdev,<br>
>       case VFL_TYPE_TOUCH:<br>
>               name_base = "v4l-touch";<br>
>               break;<br>
> +     case VFL_TYPE_AUDIO:<br>
> +             name_base = "audio";<br>
<br>
I think it was mentioned before that "audio" could be confusing. Wasn't<br>
there actually some other kind of /dev/audio device long ago?<br>
<br>
Seems like for touch, "v4l-touch" was introduced. Maybe it would also<br>
make sense to call it "v4l-audio" for audio?<br></blockquote><div><br></div><div>Ok,  will change to use "v4l-audio". </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> +             break;<br>
>       default:<br>
>               pr_err("%s called with unknown type: %d\n",<br>
>                      __func__, type);<br>
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c<br>
> index 01ba27f2ef87..aa9d872bba8d 100644<br>
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c<br>
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c<br>
> @@ -188,6 +188,8 @@ const char *v4l2_type_names[] = {<br>
>       [V4L2_BUF_TYPE_SDR_OUTPUT]         = "sdr-out",<br>
>       [V4L2_BUF_TYPE_META_CAPTURE]       = "meta-cap",<br>
>       [V4L2_BUF_TYPE_META_OUTPUT]        = "meta-out",<br>
> +     [V4L2_BUF_TYPE_AUDIO_CAPTURE]      = "audio-cap",<br>
> +     [V4L2_BUF_TYPE_AUDIO_OUTPUT]       = "audio-out",<br>
>  };<br>
>  EXPORT_SYMBOL(v4l2_type_names);<br>
>  <br>
> @@ -276,6 +278,7 @@ static void v4l_print_format(const void *arg, bool write_only)<br>
>       const struct v4l2_sliced_vbi_format *sliced;<br>
>       const struct v4l2_window *win;<br>
>       const struct v4l2_meta_format *meta;<br>
> +     const struct v4l2_audio_format *audio;<br>
>       u32 pixelformat;<br>
>       u32 planes;<br>
>       unsigned i;<br>
> @@ -346,6 +349,12 @@ static void v4l_print_format(const void *arg, bool write_only)<br>
>               pr_cont(", dataformat=%p4cc, buffersize=%u\n",<br>
>                       &pixelformat, meta->buffersize);<br>
>               break;<br>
> +     case V4L2_BUF_TYPE_AUDIO_CAPTURE:<br>
> +     case V4L2_BUF_TYPE_AUDIO_OUTPUT:<br>
> +             audio = &p->fmt.audio;<br>
> +             pr_cont(", rate=%u, format=%u, channels=%u, buffersize=%u\n",<br>
> +                     audio->rate, audio->format, audio->channels, audio->buffersize);<br>
> +             break;<br>
>       }<br>
>  }<br>
>  <br>
> @@ -927,6 +936,7 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)<br>
>       bool is_tch = vfd->vfl_type == VFL_TYPE_TOUCH;<br>
>       bool is_meta = vfd->vfl_type == VFL_TYPE_VIDEO &&<br>
>                      (vfd->device_caps & meta_caps);<br>
> +     bool is_audio = vfd->vfl_type == VFL_TYPE_AUDIO;<br>
>       bool is_rx = vfd->vfl_dir != VFL_DIR_TX;<br>
>       bool is_tx = vfd->vfl_dir != VFL_DIR_RX;<br>
>  <br>
> @@ -992,6 +1002,14 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)<br>
>               if (is_meta && is_tx && ops->vidioc_g_fmt_meta_out)<br>
>                       return 0;<br>
>               break;<br>
> +     case V4L2_BUF_TYPE_AUDIO_CAPTURE:<br>
> +             if (is_audio && is_rx && ops->vidioc_g_fmt_audio_cap)<br>
> +                     return 0;<br>
> +             break;<br>
> +     case V4L2_BUF_TYPE_AUDIO_OUTPUT:<br>
> +             if (is_audio && is_tx && ops->vidioc_g_fmt_audio_out)<br>
> +                     return 0;<br>
> +             break;<br>
>       default:<br>
>               break;<br>
>       }<br>
> @@ -1594,6 +1612,16 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,<br>
>                       break;<br>
>               ret = ops->vidioc_enum_fmt_meta_out(file, fh, arg);<br>
>               break;<br>
> +     case V4L2_BUF_TYPE_AUDIO_CAPTURE:<br>
> +             if (unlikely(!ops->vidioc_enum_fmt_audio_cap))<br>
> +                     break;<br>
> +             ret = ops->vidioc_enum_fmt_audio_cap(file, fh, arg);<br>
> +             break;<br>
> +     case V4L2_BUF_TYPE_AUDIO_OUTPUT:<br>
> +             if (unlikely(!ops->vidioc_enum_fmt_audio_out))<br>
> +                     break;<br>
> +             ret = ops->vidioc_enum_fmt_audio_out(file, fh, arg);<br>
> +             break;<br>
>       }<br>
>       if (ret == 0)<br>
>               v4l_fill_fmtdesc(p);<br>
> @@ -1670,6 +1698,10 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,<br>
>               return ops->vidioc_g_fmt_meta_cap(file, fh, arg);<br>
>       case V4L2_BUF_TYPE_META_OUTPUT:<br>
>               return ops->vidioc_g_fmt_meta_out(file, fh, arg);<br>
> +     case V4L2_BUF_TYPE_AUDIO_CAPTURE:<br>
> +             return ops->vidioc_g_fmt_audio_cap(file, fh, arg);<br>
> +     case V4L2_BUF_TYPE_AUDIO_OUTPUT:<br>
> +             return ops->vidioc_g_fmt_audio_out(file, fh, arg);<br>
>       }<br>
>       return -EINVAL;<br>
>  }<br>
> @@ -1781,6 +1813,16 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,<br>
>                       break;<br>
>               memset_after(p, 0, fmt.meta);<br>
>               return ops->vidioc_s_fmt_meta_out(file, fh, arg);<br>
> +     case V4L2_BUF_TYPE_AUDIO_CAPTURE:<br>
> +             if (unlikely(!ops->vidioc_s_fmt_audio_cap))<br>
> +                     break;<br>
> +             memset_after(p, 0, fmt.audio);<br>
> +             return ops->vidioc_s_fmt_audio_cap(file, fh, arg);<br>
> +     case V4L2_BUF_TYPE_AUDIO_OUTPUT:<br>
> +             if (unlikely(!ops->vidioc_s_fmt_audio_out))<br>
> +                     break;<br>
> +             memset_after(p, 0, fmt.audio);<br>
> +             return ops->vidioc_s_fmt_audio_out(file, fh, arg);<br>
>       }<br>
>       return -EINVAL;<br>
>  }<br>
> @@ -1889,6 +1931,16 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,<br>
>                       break;<br>
>               memset_after(p, 0, fmt.meta);<br>
>               return ops->vidioc_try_fmt_meta_out(file, fh, arg);<br>
> +     case V4L2_BUF_TYPE_AUDIO_CAPTURE:<br>
> +             if (unlikely(!ops->vidioc_try_fmt_audio_cap))<br>
> +                     break;<br>
> +             memset_after(p, 0, fmt.audio);<br>
> +             return ops->vidioc_try_fmt_audio_cap(file, fh, arg);<br>
> +     case V4L2_BUF_TYPE_AUDIO_OUTPUT:<br>
> +             if (unlikely(!ops->vidioc_try_fmt_audio_out))<br>
> +                     break;<br>
> +             memset_after(p, 0, fmt.audio);<br>
> +             return ops->vidioc_try_fmt_audio_out(file, fh, arg);<br>
>       }<br>
>       return -EINVAL;<br>
>  }<br>
> diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h<br>
> index e0a13505f88d..0924e6d1dab1 100644<br>
> --- a/include/media/v4l2-dev.h<br>
> +++ b/include/media/v4l2-dev.h<br>
> @@ -30,6 +30,7 @@<br>
>   * @VFL_TYPE_SUBDEV: for V4L2 subdevices<br>
>   * @VFL_TYPE_SDR:    for Software Defined Radio tuners<br>
>   * @VFL_TYPE_TOUCH:  for touch sensors<br>
> + * @VFL_TYPE_AUDIO:  for audio input/output devices<br>
>   * @VFL_TYPE_MAX:    number of VFL types, must always be last in the enum<br>
>   */<br>
>  enum vfl_devnode_type {<br>
> @@ -39,6 +40,7 @@ enum vfl_devnode_type {<br>
>       VFL_TYPE_SUBDEV,<br>
>       VFL_TYPE_SDR,<br>
>       VFL_TYPE_TOUCH,<br>
> +     VFL_TYPE_AUDIO,<br>
>       VFL_TYPE_MAX /* Shall be the last one */<br>
>  };<br>
>  <br>
> diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h<br>
> index edb733f21604..f840cf740ce1 100644<br>
> --- a/include/media/v4l2-ioctl.h<br>
> +++ b/include/media/v4l2-ioctl.h<br>
> @@ -45,6 +45,12 @@ struct v4l2_fh;<br>
>   * @vidioc_enum_fmt_meta_out: pointer to the function that implements<br>
>   *   :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic<br>
>   *   for metadata output<br>
> + * @vidioc_enum_fmt_audio_cap: pointer to the function that implements<br>
> + *   :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic<br>
> + *   for audio capture<br>
> + * @vidioc_enum_fmt_audio_out: pointer to the function that implements<br>
> + *   :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic<br>
> + *   for audio output<br>
>   * @vidioc_g_fmt_vid_cap: pointer to the function that implements<br>
>   *   :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video capture<br>
>   *   in single plane mode<br>
> @@ -79,6 +85,10 @@ struct v4l2_fh;<br>
>   *   :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for metadata capture<br>
>   * @vidioc_g_fmt_meta_out: pointer to the function that implements<br>
>   *   :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for metadata output<br>
> + * @vidioc_g_fmt_audio_cap: pointer to the function that implements<br>
> + *   :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for audio capture<br>
> + * @vidioc_g_fmt_audio_out: pointer to the function that implements<br>
> + *   :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for audio output<br>
>   * @vidioc_s_fmt_vid_cap: pointer to the function that implements<br>
>   *   :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video capture<br>
>   *   in single plane mode<br>
> @@ -113,6 +123,10 @@ struct v4l2_fh;<br>
>   *   :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for metadata capture<br>
>   * @vidioc_s_fmt_meta_out: pointer to the function that implements<br>
>   *   :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for metadata output<br>
> + * @vidioc_s_fmt_audio_cap: pointer to the function that implements<br>
> + *   :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for audio capture<br>
> + * @vidioc_s_fmt_audio_out: pointer to the function that implements<br>
> + *   :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for audio output<br>
>   * @vidioc_try_fmt_vid_cap: pointer to the function that implements<br>
>   *   :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video capture<br>
>   *   in single plane mode<br>
> @@ -149,6 +163,10 @@ struct v4l2_fh;<br>
>   *   :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for metadata capture<br>
>   * @vidioc_try_fmt_meta_out: pointer to the function that implements<br>
>   *   :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for metadata output<br>
> + * @vidioc_try_fmt_audio_cap: pointer to the function that implements<br>
> + *   :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for audio capture<br>
> + * @vidioc_try_fmt_audio_out: pointer to the function that implements<br>
> + *   :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for audio output<br>
>   * @vidioc_reqbufs: pointer to the function that implements<br>
>   *   :ref:`VIDIOC_REQBUFS <vidioc_reqbufs>` ioctl<br>
>   * @vidioc_querybuf: pointer to the function that implements<br>
> @@ -315,6 +333,10 @@ struct v4l2_ioctl_ops {<br>
>                                       struct v4l2_fmtdesc *f);<br>
>       int (*vidioc_enum_fmt_meta_out)(struct file *file, void *fh,<br>
>                                       struct v4l2_fmtdesc *f);<br>
> +     int (*vidioc_enum_fmt_audio_cap)(struct file *file, void *fh,<br>
> +                                      struct v4l2_fmtdesc *f);<br>
> +     int (*vidioc_enum_fmt_audio_out)(struct file *file, void *fh,<br>
> +                                      struct v4l2_fmtdesc *f);<br>
>  <br>
>       /* VIDIOC_G_FMT handlers */<br>
>       int (*vidioc_g_fmt_vid_cap)(struct file *file, void *fh,<br>
> @@ -345,6 +367,10 @@ struct v4l2_ioctl_ops {<br>
>                                    struct v4l2_format *f);<br>
>       int (*vidioc_g_fmt_meta_out)(struct file *file, void *fh,<br>
>                                    struct v4l2_format *f);<br>
> +     int (*vidioc_g_fmt_audio_cap)(struct file *file, void *fh,<br>
> +                                   struct v4l2_format *f);<br>
> +     int (*vidioc_g_fmt_audio_out)(struct file *file, void *fh,<br>
> +                                   struct v4l2_format *f);<br>
>  <br>
>       /* VIDIOC_S_FMT handlers */<br>
>       int (*vidioc_s_fmt_vid_cap)(struct file *file, void *fh,<br>
> @@ -375,6 +401,10 @@ struct v4l2_ioctl_ops {<br>
>                                    struct v4l2_format *f);<br>
>       int (*vidioc_s_fmt_meta_out)(struct file *file, void *fh,<br>
>                                    struct v4l2_format *f);<br>
> +     int (*vidioc_s_fmt_audio_cap)(struct file *file, void *fh,<br>
> +                                   struct v4l2_format *f);<br>
> +     int (*vidioc_s_fmt_audio_out)(struct file *file, void *fh,<br>
> +                                   struct v4l2_format *f);<br>
>  <br>
>       /* VIDIOC_TRY_FMT handlers */<br>
>       int (*vidioc_try_fmt_vid_cap)(struct file *file, void *fh,<br>
> @@ -405,6 +435,10 @@ struct v4l2_ioctl_ops {<br>
>                                      struct v4l2_format *f);<br>
>       int (*vidioc_try_fmt_meta_out)(struct file *file, void *fh,<br>
>                                      struct v4l2_format *f);<br>
> +     int (*vidioc_try_fmt_audio_cap)(struct file *file, void *fh,<br>
> +                                     struct v4l2_format *f);<br>
> +     int (*vidioc_try_fmt_audio_out)(struct file *file, void *fh,<br>
> +                                     struct v4l2_format *f);<br>
>  <br>
>       /* Buffer handlers */<br>
>       int (*vidioc_reqbufs)(struct file *file, void *fh,<br>
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h<br>
> index 3af6a82d0cad..e5051410928a 100644<br>
> --- a/include/uapi/linux/videodev2.h<br>
> +++ b/include/uapi/linux/videodev2.h<br>
> @@ -153,6 +153,8 @@ enum v4l2_buf_type {<br>
>       V4L2_BUF_TYPE_SDR_OUTPUT           = 12,<br>
>       V4L2_BUF_TYPE_META_CAPTURE         = 13,<br>
>       V4L2_BUF_TYPE_META_OUTPUT          = 14,<br>
> +     V4L2_BUF_TYPE_AUDIO_CAPTURE        = 15,<br>
> +     V4L2_BUF_TYPE_AUDIO_OUTPUT         = 16,<br>
>       /* Deprecated, do not use */<br>
>       V4L2_BUF_TYPE_PRIVATE              = 0x80,<br>
>  };<br>
> @@ -169,6 +171,7 @@ enum v4l2_buf_type {<br>
>        || (type) == V4L2_BUF_TYPE_VBI_OUTPUT                  \<br>
>        || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT           \<br>
>        || (type) == V4L2_BUF_TYPE_SDR_OUTPUT                  \<br>
> +      || (type) == V4L2_BUF_TYPE_AUDIO_OUTPUT                \<br>
>        || (type) == V4L2_BUF_TYPE_META_OUTPUT)<br>
>  <br>
>  #define V4L2_TYPE_IS_CAPTURE(type) (!V4L2_TYPE_IS_OUTPUT(type))<br>
> @@ -2415,6 +2418,20 @@ struct v4l2_meta_format {<br>
>       __u32                           buffersize;<br>
>  } __attribute__ ((packed));<br>
>  <br>
> +/**<br>
> + * struct v4l2_audio_format - audio data format definition<br>
> + * @rate:            sample rate<br>
> + * @format:          sample format<br>
> + * @channels:                channel numbers<br>
> + * @buffersize:              maximum size in bytes required for data<br>
> + */<br>
> +struct v4l2_audio_format {<br>
> +     __u32                           rate;<br>
> +     __u32                           format;<br>
<br>
What are the values for the rate and format fields? Since they are part<br>
of the UAPI, they need to be defined.<br>
<br></blockquote><div>The range for sample rate is [5512, 768000].<br></div><div>The format is defined in include/uapi/sound/asound.h,  they are</div><div>SNDRV_PCM_FORMAT_S8, SNDRV_PCM_FORMAT_U8, ...<br></div><div><br></div><div>Where should I put these info?</div><div><br></div><div>best regards</div><div>wang shengjiu</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Best regards,<br>
Tomasz<br>
<br>
> +     __u32                           channels;<br>
> +     __u32                           buffersize;<br>
> +} __attribute__ ((packed));<br>
> +<br>
>  /**<br>
>   * struct v4l2_format - stream data format<br>
>   * @type:    enum v4l2_buf_type; type of the data stream<br>
> @@ -2423,6 +2440,7 @@ struct v4l2_meta_format {<br>
>   * @win:     definition of an overlaid image<br>
>   * @vbi:     raw VBI capture or output parameters<br>
>   * @sliced:  sliced VBI capture or output parameters<br>
> + * @audio:   definition of an audio format<br>
>   * @raw_data:        placeholder for future extensions and custom formats<br>
>   * @fmt:     union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, @meta<br>
>   *           and @raw_data<br>
> @@ -2437,6 +2455,7 @@ struct v4l2_format {<br>
>               struct v4l2_sliced_vbi_format   sliced;  /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */<br>
>               struct v4l2_sdr_format          sdr;     /* V4L2_BUF_TYPE_SDR_CAPTURE */<br>
>               struct v4l2_meta_format         meta;    /* V4L2_BUF_TYPE_META_CAPTURE */<br>
> +             struct v4l2_audio_format        audio;   /* V4L2_BUF_TYPE_AUDIO_CAPTURE */<br>
>               __u8    raw_data[200];                   /* user-defined */<br>
>       } fmt;<br>
>  };<br>
> -- <br>
> 2.34.1<br>
> <br>
</blockquote></div></div>