From patchwork Wed Jan 17 15:02:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 763506 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 1582E210EA for ; Wed, 17 Jan 2024 15:02:39 +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=1705503760; cv=none; b=QYnw19c1DbXuXcNxlewvkAMG74pAjJvGlsdBGN6S763/pfSxjAO6mkHWinSdgeumhnPVnXZEAygYYtBZywCDckT63DqVHjRxcGZsmONQo/WUNJYESpCXJV+ofCwKlgq96FrtXV53eILlsYmSMtYivNHVS87s55CrGRmKelKj4QE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503760; c=relaxed/simple; bh=BoOOzILwT9lD0VCIUQGSH7O4gBRqxtflL4xNsGrFx40=; h=Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=l73b0hrrQR/u6cUXR2HMMnVFOzlsnKree9k7UVDPBSo3lSpToQ5Op2bseM47gfZSdzzirfOjIOyvyzFXCgKkNWWU7+Z4CoybGA39TBA9Hg9rwTFjGGg0xr4JM/MvsIJHDLeyN4Uv6hjjv3J04SYZ6af7buBljW4Ejj6ew2Qvar4= 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 BC80AC43390; Wed, 17 Jan 2024 15:02:38 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Shengjiu Wang , Hans Verkuil Subject: [PATCH 01/10] [DO NOT MERGE] Sync with audio repo Date: Wed, 17 Jan 2024 16:02:09 +0100 Message-ID: <79cf7f3c0fdde2ff151ba05d912ba05b35386d4a.1705503477.git.hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240117150232.1800006-1-hverkuil-cisco@xs4all.nl> References: <20240117150232.1800006-1-hverkuil-cisco@xs4all.nl> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Temporary patch to add the new API pieces to the v4l-utils headers. Signed-off-by: Hans Verkuil --- contrib/freebsd/include/linux/v4l2-controls.h | 9 ++++ contrib/freebsd/include/linux/videodev2.h | 44 ++++++++++++++++++- include/linux/media.h | 2 + include/linux/v4l2-controls.h | 9 ++++ include/linux/videodev2.h | 44 ++++++++++++++++++- utils/common/v4l2-pix-formats.h | 13 ++++++ 6 files changed, 119 insertions(+), 2 deletions(-) diff --git a/contrib/freebsd/include/linux/v4l2-controls.h b/contrib/freebsd/include/linux/v4l2-controls.h index 635d92d2..006d3c8d 100644 --- a/contrib/freebsd/include/linux/v4l2-controls.h +++ b/contrib/freebsd/include/linux/v4l2-controls.h @@ -34,6 +34,7 @@ #define V4L2_CTRL_CLASS_DETECT 0x00a30000 /* Detection controls */ #define V4L2_CTRL_CLASS_CODEC_STATELESS 0x00a40000 /* Stateless codecs controls */ #define V4L2_CTRL_CLASS_COLORIMETRY 0x00a50000 /* Colorimetry controls */ +#define V4L2_CTRL_CLASS_M2M_AUDIO 0x00a60000 /* Audio M2M controls */ /* User-class control IDs */ @@ -3491,6 +3492,14 @@ struct v4l2_ctrl_av1_film_grain { __u8 reserved[4]; }; +#define V4L2_CID_M2M_AUDIO_CLASS_BASE (V4L2_CTRL_CLASS_M2M_AUDIO | 0x900) +#define V4L2_CID_M2M_AUDIO_CLASS (V4L2_CTRL_CLASS_M2M_AUDIO | 1) + +#define V4L2_CID_M2M_AUDIO_SOURCE_RATE (V4L2_CID_M2M_AUDIO_CLASS_BASE + 0) +#define V4L2_CID_M2M_AUDIO_DEST_RATE (V4L2_CID_M2M_AUDIO_CLASS_BASE + 1) +#define V4L2_CID_M2M_AUDIO_SOURCE_RATE_OFFSET (V4L2_CID_M2M_AUDIO_CLASS_BASE + 2) +#define V4L2_CID_M2M_AUDIO_DEST_RATE_OFFSET (V4L2_CID_M2M_AUDIO_CLASS_BASE + 3) + /* MPEG-compression definitions kept for backwards compatibility */ #define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC #define V4L2_CID_MPEG_CLASS V4L2_CID_CODEC_CLASS diff --git a/contrib/freebsd/include/linux/videodev2.h b/contrib/freebsd/include/linux/videodev2.h index 4a8746ce..6daf1501 100644 --- a/contrib/freebsd/include/linux/videodev2.h +++ b/contrib/freebsd/include/linux/videodev2.h @@ -185,6 +185,8 @@ enum v4l2_buf_type { V4L2_BUF_TYPE_SDR_OUTPUT = 12, V4L2_BUF_TYPE_META_CAPTURE = 13, V4L2_BUF_TYPE_META_OUTPUT = 14, + V4L2_BUF_TYPE_AUDIO_CAPTURE = 15, + V4L2_BUF_TYPE_AUDIO_OUTPUT = 16, /* Deprecated, do not use */ V4L2_BUF_TYPE_PRIVATE = 0x80, }; @@ -201,6 +203,7 @@ enum v4l2_buf_type { || (type) == V4L2_BUF_TYPE_VBI_OUTPUT \ || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT \ || (type) == V4L2_BUF_TYPE_SDR_OUTPUT \ + || (type) == V4L2_BUF_TYPE_AUDIO_OUTPUT \ || (type) == V4L2_BUF_TYPE_META_OUTPUT) #define V4L2_TYPE_IS_CAPTURE(type) (!V4L2_TYPE_IS_OUTPUT(type)) @@ -480,6 +483,7 @@ struct v4l2_capability { #define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */ #define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */ #define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */ +#define V4L2_CAP_AUDIO_M2M 0x00000008 /* audio memory to memory */ #define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */ #define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */ #define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */ @@ -846,6 +850,29 @@ struct v4l2_pix_format { #define V4L2_META_FMT_RK_ISP1_PARAMS v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 3A Parameters */ #define V4L2_META_FMT_RK_ISP1_STAT_3A v4l2_fourcc('R', 'K', '1', 'S') /* Rockchip ISP1 3A Statistics */ +/* + * Audio-data formats + * All these audio formats use a fourcc starting with 'AU' + * followed by the SNDRV_PCM_FORMAT_ value from asound.h. + */ +#define V4L2_AUDIO_FMT_S8 v4l2_fourcc('A', 'U', '0', '0') +#define V4L2_AUDIO_FMT_S16_LE v4l2_fourcc('A', 'U', '0', '2') +#define V4L2_AUDIO_FMT_U16_LE v4l2_fourcc('A', 'U', '0', '4') +#define V4L2_AUDIO_FMT_S24_LE v4l2_fourcc('A', 'U', '0', '6') +#define V4L2_AUDIO_FMT_U24_LE v4l2_fourcc('A', 'U', '0', '8') +#define V4L2_AUDIO_FMT_S32_LE v4l2_fourcc('A', 'U', '1', '0') +#define V4L2_AUDIO_FMT_U32_LE v4l2_fourcc('A', 'U', '1', '2') +#define V4L2_AUDIO_FMT_FLOAT_LE v4l2_fourcc('A', 'U', '1', '4') +#define V4L2_AUDIO_FMT_IEC958_SUBFRAME_LE v4l2_fourcc('A', 'U', '1', '8') +#define V4L2_AUDIO_FMT_S24_3LE v4l2_fourcc('A', 'U', '3', '2') +#define V4L2_AUDIO_FMT_U24_3LE v4l2_fourcc('A', 'U', '3', '4') +#define V4L2_AUDIO_FMT_S20_3LE v4l2_fourcc('A', 'U', '3', '6') +#define V4L2_AUDIO_FMT_U20_3LE v4l2_fourcc('A', 'U', '3', '8') + +#define v4l2_fourcc_to_audfmt(fourcc) \ + (snd_pcm_format_t)(((((fourcc) >> 16) & 0xff) - '0') * 10 \ + + ((((fourcc) >> 24) & 0xff) - '0')) + /* priv field value to indicates that subsequent fields are valid. */ #define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe @@ -1925,7 +1952,8 @@ struct v4l2_query_ext_ctrl { uint32_t elems; uint32_t nr_of_dims; uint32_t dims[V4L2_CTRL_MAX_DIMS]; - uint32_t reserved[32]; + uint32_t fraction_bits; + uint32_t reserved[31]; }; /* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */ @@ -2399,6 +2427,18 @@ struct v4l2_meta_format { uint32_t buffersize; } __attribute__ ((packed)); +/** + * struct v4l2_audio_format - audio data format definition + * @audioformat: little endian four character code (fourcc) + * @channels: channel numbers + * @buffersize: maximum size in bytes required for data + */ +struct v4l2_audio_format { + uint32_t audioformat; + uint32_t channels; + uint32_t buffersize; +} __attribute__ ((packed)); + /** * struct v4l2_format - stream data format * @type: enum v4l2_buf_type; type of the data stream @@ -2407,6 +2447,7 @@ struct v4l2_meta_format { * @win: definition of an overlaid image * @vbi: raw VBI capture or output parameters * @sliced: sliced VBI capture or output parameters + * @audio: definition of an audio format * @raw_data: placeholder for future extensions and custom formats * @fmt: union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, @meta * and @raw_data @@ -2421,6 +2462,7 @@ struct v4l2_format { struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */ struct v4l2_sdr_format sdr; /* V4L2_BUF_TYPE_SDR_CAPTURE */ struct v4l2_meta_format meta; /* V4L2_BUF_TYPE_META_CAPTURE */ + struct v4l2_audio_format audio; /* V4L2_BUF_TYPE_AUDIO_CAPTURE */ uint8_t raw_data[200]; /* user-defined */ } fmt; }; diff --git a/include/linux/media.h b/include/linux/media.h index b5a77bbf..9c91341e 100644 --- a/include/linux/media.h +++ b/include/linux/media.h @@ -125,6 +125,7 @@ struct media_device_info { #define MEDIA_ENT_F_PROC_VIDEO_ENCODER (MEDIA_ENT_F_BASE + 0x4007) #define MEDIA_ENT_F_PROC_VIDEO_DECODER (MEDIA_ENT_F_BASE + 0x4008) #define MEDIA_ENT_F_PROC_VIDEO_ISP (MEDIA_ENT_F_BASE + 0x4009) +#define MEDIA_ENT_F_PROC_AUDIO_RESAMPLER (MEDIA_ENT_F_BASE + 0x400a) /* * Switch and bridge entity functions @@ -258,6 +259,7 @@ struct media_links_enum { #define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3) #define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) #define MEDIA_INTF_T_V4L_TOUCH (MEDIA_INTF_T_V4L_BASE + 5) +#define MEDIA_INTF_T_V4L_AUDIO (MEDIA_INTF_T_V4L_BASE + 6) #define MEDIA_INTF_T_ALSA_BASE 0x00000300 #define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE) diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h index 635d92d2..006d3c8d 100644 --- a/include/linux/v4l2-controls.h +++ b/include/linux/v4l2-controls.h @@ -34,6 +34,7 @@ #define V4L2_CTRL_CLASS_DETECT 0x00a30000 /* Detection controls */ #define V4L2_CTRL_CLASS_CODEC_STATELESS 0x00a40000 /* Stateless codecs controls */ #define V4L2_CTRL_CLASS_COLORIMETRY 0x00a50000 /* Colorimetry controls */ +#define V4L2_CTRL_CLASS_M2M_AUDIO 0x00a60000 /* Audio M2M controls */ /* User-class control IDs */ @@ -3491,6 +3492,14 @@ struct v4l2_ctrl_av1_film_grain { __u8 reserved[4]; }; +#define V4L2_CID_M2M_AUDIO_CLASS_BASE (V4L2_CTRL_CLASS_M2M_AUDIO | 0x900) +#define V4L2_CID_M2M_AUDIO_CLASS (V4L2_CTRL_CLASS_M2M_AUDIO | 1) + +#define V4L2_CID_M2M_AUDIO_SOURCE_RATE (V4L2_CID_M2M_AUDIO_CLASS_BASE + 0) +#define V4L2_CID_M2M_AUDIO_DEST_RATE (V4L2_CID_M2M_AUDIO_CLASS_BASE + 1) +#define V4L2_CID_M2M_AUDIO_SOURCE_RATE_OFFSET (V4L2_CID_M2M_AUDIO_CLASS_BASE + 2) +#define V4L2_CID_M2M_AUDIO_DEST_RATE_OFFSET (V4L2_CID_M2M_AUDIO_CLASS_BASE + 3) + /* MPEG-compression definitions kept for backwards compatibility */ #define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC #define V4L2_CID_MPEG_CLASS V4L2_CID_CODEC_CLASS diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 397a99e3..e5d5b898 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -151,6 +151,8 @@ enum v4l2_buf_type { V4L2_BUF_TYPE_SDR_OUTPUT = 12, V4L2_BUF_TYPE_META_CAPTURE = 13, V4L2_BUF_TYPE_META_OUTPUT = 14, + V4L2_BUF_TYPE_AUDIO_CAPTURE = 15, + V4L2_BUF_TYPE_AUDIO_OUTPUT = 16, /* Deprecated, do not use */ V4L2_BUF_TYPE_PRIVATE = 0x80, }; @@ -167,6 +169,7 @@ enum v4l2_buf_type { || (type) == V4L2_BUF_TYPE_VBI_OUTPUT \ || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT \ || (type) == V4L2_BUF_TYPE_SDR_OUTPUT \ + || (type) == V4L2_BUF_TYPE_AUDIO_OUTPUT \ || (type) == V4L2_BUF_TYPE_META_OUTPUT) #define V4L2_TYPE_IS_CAPTURE(type) (!V4L2_TYPE_IS_OUTPUT(type)) @@ -446,6 +449,7 @@ struct v4l2_capability { #define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */ #define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */ #define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */ +#define V4L2_CAP_AUDIO_M2M 0x00000008 /* audio memory to memory */ #define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */ #define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */ #define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */ @@ -812,6 +816,29 @@ struct v4l2_pix_format { #define V4L2_META_FMT_RK_ISP1_PARAMS v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 3A Parameters */ #define V4L2_META_FMT_RK_ISP1_STAT_3A v4l2_fourcc('R', 'K', '1', 'S') /* Rockchip ISP1 3A Statistics */ +/* + * Audio-data formats + * All these audio formats use a fourcc starting with 'AU' + * followed by the SNDRV_PCM_FORMAT_ value from asound.h. + */ +#define V4L2_AUDIO_FMT_S8 v4l2_fourcc('A', 'U', '0', '0') +#define V4L2_AUDIO_FMT_S16_LE v4l2_fourcc('A', 'U', '0', '2') +#define V4L2_AUDIO_FMT_U16_LE v4l2_fourcc('A', 'U', '0', '4') +#define V4L2_AUDIO_FMT_S24_LE v4l2_fourcc('A', 'U', '0', '6') +#define V4L2_AUDIO_FMT_U24_LE v4l2_fourcc('A', 'U', '0', '8') +#define V4L2_AUDIO_FMT_S32_LE v4l2_fourcc('A', 'U', '1', '0') +#define V4L2_AUDIO_FMT_U32_LE v4l2_fourcc('A', 'U', '1', '2') +#define V4L2_AUDIO_FMT_FLOAT_LE v4l2_fourcc('A', 'U', '1', '4') +#define V4L2_AUDIO_FMT_IEC958_SUBFRAME_LE v4l2_fourcc('A', 'U', '1', '8') +#define V4L2_AUDIO_FMT_S24_3LE v4l2_fourcc('A', 'U', '3', '2') +#define V4L2_AUDIO_FMT_U24_3LE v4l2_fourcc('A', 'U', '3', '4') +#define V4L2_AUDIO_FMT_S20_3LE v4l2_fourcc('A', 'U', '3', '6') +#define V4L2_AUDIO_FMT_U20_3LE v4l2_fourcc('A', 'U', '3', '8') + +#define v4l2_fourcc_to_audfmt(fourcc) \ + (snd_pcm_format_t)(((((fourcc) >> 16) & 0xff) - '0') * 10 \ + + ((((fourcc) >> 24) & 0xff) - '0')) + /* priv field value to indicates that subsequent fields are valid. */ #define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe @@ -1891,7 +1918,8 @@ struct v4l2_query_ext_ctrl { __u32 elems; __u32 nr_of_dims; __u32 dims[V4L2_CTRL_MAX_DIMS]; - __u32 reserved[32]; + __u32 fraction_bits; + __u32 reserved[31]; }; /* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */ @@ -2365,6 +2393,18 @@ struct v4l2_meta_format { __u32 buffersize; } __attribute__ ((packed)); +/** + * struct v4l2_audio_format - audio data format definition + * @audioformat: little endian four character code (fourcc) + * @channels: channel numbers + * @buffersize: maximum size in bytes required for data + */ +struct v4l2_audio_format { + __u32 audioformat; + __u32 channels; + __u32 buffersize; +} __attribute__ ((packed)); + /** * struct v4l2_format - stream data format * @type: enum v4l2_buf_type; type of the data stream @@ -2373,6 +2413,7 @@ struct v4l2_meta_format { * @win: definition of an overlaid image * @vbi: raw VBI capture or output parameters * @sliced: sliced VBI capture or output parameters + * @audio: definition of an audio format * @raw_data: placeholder for future extensions and custom formats * @fmt: union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, @meta * and @raw_data @@ -2387,6 +2428,7 @@ struct v4l2_format { struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */ struct v4l2_sdr_format sdr; /* V4L2_BUF_TYPE_SDR_CAPTURE */ struct v4l2_meta_format meta; /* V4L2_BUF_TYPE_META_CAPTURE */ + struct v4l2_audio_format audio; /* V4L2_BUF_TYPE_AUDIO_CAPTURE */ __u8 raw_data[200]; /* user-defined */ } fmt; }; diff --git a/utils/common/v4l2-pix-formats.h b/utils/common/v4l2-pix-formats.h index e8d2e441..db00cf65 100644 --- a/utils/common/v4l2-pix-formats.h +++ b/utils/common/v4l2-pix-formats.h @@ -192,6 +192,19 @@ case V4L2_PIX_FMT_Y210: return "10-bit YUYV Packed"; case V4L2_PIX_FMT_Y212: return "12-bit YUYV Packed"; case V4L2_PIX_FMT_Y216: return "16-bit YUYV Packed"; + case V4L2_AUDIO_FMT_S8: return "8-bit Signed"; + case V4L2_AUDIO_FMT_S16_LE: return "16-bit Signed LE"; + case V4L2_AUDIO_FMT_U16_LE: return "16-bit Unsigned LE"; + case V4L2_AUDIO_FMT_S24_LE: return "24(32)-bit Signed LE"; + case V4L2_AUDIO_FMT_U24_LE: return "24(32)-bit Unsigned LE"; + case V4L2_AUDIO_FMT_S32_LE: return "32-bit Signed LE"; + case V4L2_AUDIO_FMT_U32_LE: return "32-bit Unsigned LE"; + case V4L2_AUDIO_FMT_FLOAT_LE: return "32-bit Float LE"; + case V4L2_AUDIO_FMT_IEC958_SUBFRAME_LE: return "32-bit IEC958 LE"; + case V4L2_AUDIO_FMT_S24_3LE: return "24(24)-bit Signed LE"; + case V4L2_AUDIO_FMT_U24_3LE: return "24(24)-bit Unsigned LE"; + case V4L2_AUDIO_FMT_S20_3LE: return "20(24)-bit Signed LE"; + case V4L2_AUDIO_FMT_U20_3LE: return "20(24)-bit Unsigned LE"; case V4L2_PIX_FMT_MJPEG: return "Motion-JPEG"; case V4L2_PIX_FMT_JPEG: return "JFIF JPEG"; case V4L2_PIX_FMT_DV: return "1394"; From patchwork Wed Jan 17 15:02:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 763505 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 D6A83210E1 for ; Wed, 17 Jan 2024 15:02:42 +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=1705503762; cv=none; b=LQboahpCkSe9q0oLIZUrotS08EIvC22GK19nMAXc7yYI8atXHvn/lgAyzu8948PwP0KTEFSD/bBk0GeNI/fqtZe8Uvm1YM1m4ddIy69kBklEEENCxH+8kE/zZM2wSHdUK2XK/eP9wSNOjR8Rd8f64rkG2r4+Ed2hVZuvyLY/C9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503762; c=relaxed/simple; bh=WarlxSyX91uD5HrX2f6Q+s9xzG5qetIzsG8H9rgTSak=; h=Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=nTZsX9LTWqB1Hg9imtEW1INSaX/pqh3rbV6rbREQFwmWjz4UDk/QifC8DnTv8gN4Vg1g9z9dwT/kSt8L4dhPSM9PTJK+7E3kNQ4BwKFrzPsnRuOAKmXIESMhslbX10Zf8hbnrV7C/mrjMp6N0h1M3ULILL5ch6DWdac5sbWdkWI= 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 7A9FAC43390; Wed, 17 Jan 2024 15:02:41 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Shengjiu Wang , Hans Verkuil Subject: [PATCH 03/10] v4l-utils: common: add v4l-audio support Date: Wed, 17 Jan 2024 16:02:11 +0100 Message-ID: <6bdc0c79b2c4d4ddce4af8d4a5f44cdfbf49cd44.1705503477.git.hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.42.0 In-Reply-To: <79cf7f3c0fdde2ff151ba05d912ba05b35386d4a.1705503477.git.hverkuil-cisco@xs4all.nl> References: <79cf7f3c0fdde2ff151ba05d912ba05b35386d4a.1705503477.git.hverkuil-cisco@xs4all.nl> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The media/v4l2-info sources now understand the new Audio types. Signed-off-by: Hans Verkuil --- utils/common/media-info.cpp | 3 +++ utils/common/media-info.h | 1 + utils/common/v4l2-info.cpp | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/utils/common/media-info.cpp b/utils/common/media-info.cpp index 95e4c74f..060e8b64 100644 --- a/utils/common/media-info.cpp +++ b/utils/common/media-info.cpp @@ -44,6 +44,7 @@ static constexpr struct { { "swradio", MEDIA_TYPE_SDR }, { "v4l-subdev", MEDIA_TYPE_SUBDEV }, { "v4l-touch", MEDIA_TYPE_TOUCH }, + { "v4l-audio", MEDIA_TYPE_AUDIO }, { "media", MEDIA_TYPE_MEDIA }, { "frontend", MEDIA_TYPE_DVB_FRONTEND }, { "demux", MEDIA_TYPE_DVB_DEMUX }, @@ -280,6 +281,7 @@ static constexpr flag_def interface_types_def[] = { { MEDIA_INTF_T_V4L_SUBDEV, "V4L Sub-Device" }, { MEDIA_INTF_T_V4L_SWRADIO, "V4L Software Defined Radio" }, { MEDIA_INTF_T_V4L_TOUCH, "V4L Touch" }, + { MEDIA_INTF_T_V4L_AUDIO, "V4L Audio" }, { MEDIA_INTF_T_ALSA_PCM_CAPTURE, "ALSA PCM Capture" }, { MEDIA_INTF_T_ALSA_PCM_PLAYBACK, "ALSA PCM Playback" }, @@ -335,6 +337,7 @@ static constexpr flag_def entity_functions_def[] = { { MEDIA_ENT_F_PROC_VIDEO_DECODER, "Video Decoder" }, { MEDIA_ENT_F_PROC_VIDEO_ENCODER, "Video Encoder" }, { MEDIA_ENT_F_PROC_VIDEO_ISP, "Image Signal Processor" }, + { MEDIA_ENT_F_PROC_AUDIO_RESAMPLER, "Audio Resampler" }, { MEDIA_ENT_F_VID_MUX, "Video Muxer" }, { MEDIA_ENT_F_VID_IF_BRIDGE, "Video Interface Bridge" }, { 0, nullptr } diff --git a/utils/common/media-info.h b/utils/common/media-info.h index c0dd6304..3c333df3 100644 --- a/utils/common/media-info.h +++ b/utils/common/media-info.h @@ -16,6 +16,7 @@ enum media_type { MEDIA_TYPE_RADIO, MEDIA_TYPE_SDR, MEDIA_TYPE_TOUCH, + MEDIA_TYPE_AUDIO, MEDIA_TYPE_SUBDEV, MEDIA_TYPE_DVB_FRONTEND, MEDIA_TYPE_DVB_DEMUX, diff --git a/utils/common/v4l2-info.cpp b/utils/common/v4l2-info.cpp index 72731bad..6e1e8b8b 100644 --- a/utils/common/v4l2-info.cpp +++ b/utils/common/v4l2-info.cpp @@ -97,6 +97,8 @@ static std::string cap2s(unsigned cap) s += "\t\tExtended Pix Format\n"; if (cap & V4L2_CAP_DEVICE_CAPS) s += "\t\tDevice Capabilities\n"; + if (cap & V4L2_CAP_AUDIO_M2M) + s += "\t\tAudio Memory-to-Memory\n"; return s; } @@ -194,6 +196,10 @@ std::string buftype2s(int type) return "Metadata Capture"; case V4L2_BUF_TYPE_META_OUTPUT: return "Metadata Output"; + case V4L2_BUF_TYPE_AUDIO_CAPTURE: + return "Audio Capture"; + case V4L2_BUF_TYPE_AUDIO_OUTPUT: + return "Audio Output"; case V4L2_BUF_TYPE_PRIVATE: return "Private"; default: From patchwork Wed Jan 17 15:02:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 763504 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 8900720DC9 for ; Wed, 17 Jan 2024 15:02:45 +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=1705503765; cv=none; b=O2eWRlfXPLxeA4wqz9C+qIghzUTyTbm6I3x/Cfavvd6vSrAh6TxWcixfvCNJ05Kj+SHGmoxIt0wZS4RTjK6X2NC1UKlN9CoON3bmCDfsD9SXGlaNIzMgjhkzHAtTWlyVdUPhcnXg8ygcK0NNaTabXtbmqXjODxBdexX33dH8/YI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503765; c=relaxed/simple; bh=O8nJWRN4IlXH4QxG11t+fxfNkM0nAzazg1mwplEvjNI=; h=Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=ZgelwgkyRXONPIpr+lRpJBkLy8WHKYN7xQK66EioQ4N79VP4i2H2JLdhHTDEBcAGhXyE8XZZ6rdIKEMcVR8Z75D0Q9P3CobZ49eYpMtd44eTFX0uJaKoSRs8bknVJyx1A9fzE9gHjEjr+uvdI0lOCff3ABuYW1kZXT3CekzeVa4= 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 38295C43399; Wed, 17 Jan 2024 15:02:44 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Shengjiu Wang , Hans Verkuil Subject: [PATCH 05/10] libv4l2util: recognize V4L2_CAP_AUDIO_M2M Date: Wed, 17 Jan 2024 16:02:13 +0100 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: <79cf7f3c0fdde2ff151ba05d912ba05b35386d4a.1705503477.git.hverkuil-cisco@xs4all.nl> References: <79cf7f3c0fdde2ff151ba05d912ba05b35386d4a.1705503477.git.hverkuil-cisco@xs4all.nl> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Detect the V4L2_CAP_AUDIO_M2M capability. Signed-off-by: Hans Verkuil --- utils/libv4l2util/v4l2_driver.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/libv4l2util/v4l2_driver.c b/utils/libv4l2util/v4l2_driver.c index 6b6366fa..0c881b0c 100644 --- a/utils/libv4l2util/v4l2_driver.c +++ b/utils/libv4l2util/v4l2_driver.c @@ -164,6 +164,8 @@ static char *prt_caps(uint32_t caps) strcat (s,"META_OUTPUT "); if(V4L2_CAP_TOUCH & caps) strcat (s,"TOUCH "); + if(V4L2_CAP_AUDIO_M2M & caps) + strcat (s,"AUDIO_M2M "); if(V4L2_CAP_IO_MC & caps) strcat (s,"IO_MC "); From patchwork Wed Jan 17 15:02:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 763503 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 61BCF20DC9 for ; Wed, 17 Jan 2024 15:02:48 +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=1705503768; cv=none; b=fa7xaqqMp2nHCmGcNGlHtlEQTYXWYZjA3uqCuROTaRCOnOEw0Ga7e9+s2BAOD5I+tqUPBGzCMT4Wg1u1b50KP0BeHcWi0fGpP2CbF/HLvnktqnFkkz2r73N00dx7cRh1L2Oi7cryghGGe9QIPJY1Tb7vCT7lKhPe6iRZO615G2g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503768; c=relaxed/simple; bh=hCSRH7GnB+hscoIRa+FXLwC/so9P59FpBRKWjEq6CGY=; h=Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=pC8Ywjooimp/maERVM7cW3bmLzNXLDnbm0TmEFHT9hLdCJ83Zk/CGNSnshBkCYFFJc77NIvCF34yrwXLYB6zZdQDzt8chWZasJt9+z9NXWYP7g7HTTF0O475SasPV5XI6lf7fjkQ75H4BRBHtPCFvBWAljBMfChnZIJahLXFic0= 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 00115C43394; Wed, 17 Jan 2024 15:02:46 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Shengjiu Wang , Hans Verkuil Subject: [PATCH 07/10] v4l2-compliance: add support for v4l-audioX devices Date: Wed, 17 Jan 2024 16:02:15 +0100 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: <79cf7f3c0fdde2ff151ba05d912ba05b35386d4a.1705503477.git.hverkuil-cisco@xs4all.nl> References: <79cf7f3c0fdde2ff151ba05d912ba05b35386d4a.1705503477.git.hverkuil-cisco@xs4all.nl> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Support compliance testing of v4l-audioX devices. Signed-off-by: Hans Verkuil --- utils/v4l2-compliance/v4l2-compliance.1.in | 7 ++++++ utils/v4l2-compliance/v4l2-compliance.cpp | 16 +++++++++--- utils/v4l2-compliance/v4l2-compliance.h | 3 ++- utils/v4l2-compliance/v4l2-test-buffers.cpp | 10 +++++--- utils/v4l2-compliance/v4l2-test-formats.cpp | 28 +++++++++++++++++++++ utils/v4l2-compliance/v4l2-test-media.cpp | 1 + 6 files changed, 57 insertions(+), 8 deletions(-) diff --git a/utils/v4l2-compliance/v4l2-compliance.1.in b/utils/v4l2-compliance/v4l2-compliance.1.in index fa12ae2d..5113696f 100644 --- a/utils/v4l2-compliance/v4l2-compliance.1.in +++ b/utils/v4l2-compliance/v4l2-compliance.1.in @@ -81,6 +81,13 @@ Otherwise if \fB-z\fR was specified earlier, then \fI\fR is the entity name or interface ID (if prefixed with 0x) as found in the topology of the media device with the bus info string as specified by the \fB-z\fR option. .TP +\fB\-A\fR, \fB\-\-audio\-device\fR \fI\fR +Use device \fI\fR as the audio memory-2-memory device. If \fI\fR is a number, +then /dev/v4l-audio\fI\fR is used. +Otherwise if \fB-z\fR was specified earlier, then \fI\fR is the entity name +or interface ID (if prefixed with 0x) as found in the topology of the media device +with the bus info string as specified by the \fB-z\fR option. +.TP \fB\-u\fR, \fB\-\-subdev\-device\fR \fI\fR Use device \fI\fR as the v4l-subdevX device. If \fI\fR is a number, then /dev/v4l-subdev\fI\fR is used. Otherwise if \fB-z\fR was specified earlier, then \fI\fR is the entity name diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp index 9e2c6983..bea7eb4f 100644 --- a/utils/v4l2-compliance/v4l2-compliance.cpp +++ b/utils/v4l2-compliance/v4l2-compliance.cpp @@ -43,6 +43,7 @@ case is used to retrieve a setting. */ enum Option { OptStreamAllIO = 'a', + OptSetAudioDevice = 'A', OptStreamAllColorTest = 'c', OptColor = 'C', OptSetDevice = 'd', @@ -124,6 +125,7 @@ static struct option long_options[] = { {"subdev-device", required_argument, nullptr, OptSetSubDevDevice}, {"expbuf-device", required_argument, nullptr, OptSetExpBufDevice}, {"touch-device", required_argument, nullptr, OptSetTouchDevice}, + {"audio-device", required_argument, nullptr, OptSetAudioDevice}, {"media-device", required_argument, nullptr, OptSetMediaDevice}, {"media-device-only", required_argument, nullptr, OptSetMediaDeviceOnly}, {"media-bus-info", required_argument, nullptr, OptMediaBusInfo}, @@ -198,6 +200,10 @@ static void usage() printf(" Use device as the touch device.\n"); printf(" If starts with a digit, then /dev/v4l-touch is used.\n"); printf(" See the -d description of how is used in combination with -z.\n"); + printf(" -A, --audio-device \n"); + printf(" Use device as the audio M2M device.\n"); + printf(" If starts with a digit, then /dev/v4l-audio is used.\n"); + printf(" See the -d description of how is used in combination with -z.\n"); printf(" -u, --subdev-device \n"); printf(" Use device as the v4l-subdev device.\n"); printf(" If starts with a digit, then /dev/v4l-subdev is used.\n"); @@ -639,7 +645,7 @@ static int testCap(struct node *node) V4L2_CAP_SDR_OUTPUT | V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_MODULATOR | V4L2_CAP_META_OUTPUT; const __u32 overlay_caps = V4L2_CAP_VIDEO_OVERLAY | V4L2_CAP_VIDEO_OUTPUT_OVERLAY; - const __u32 m2m_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_VIDEO_M2M_MPLANE; + const __u32 m2m_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_AUDIO_M2M; const __u32 io_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; const __u32 mplane_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE; @@ -983,6 +989,7 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_ node.is_radio = type == MEDIA_TYPE_RADIO; node.is_sdr = type == MEDIA_TYPE_SDR; node.is_touch = type == MEDIA_TYPE_TOUCH; + node.is_audio = type == MEDIA_TYPE_AUDIO; if (node.is_v4l2()) { doioctl(&node, VIDIOC_QUERYCAP, &vcap); @@ -1038,13 +1045,13 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_ V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_RDS_CAPTURE | V4L2_CAP_SDR_CAPTURE | - V4L2_CAP_META_CAPTURE)) + V4L2_CAP_META_CAPTURE | V4L2_CAP_AUDIO_M2M)) node.can_capture = true; if (node.g_caps() & (V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_RDS_OUTPUT | V4L2_CAP_SDR_OUTPUT | - V4L2_CAP_META_OUTPUT)) + V4L2_CAP_META_OUTPUT | V4L2_CAP_AUDIO_M2M)) node.can_output = true; if (node.g_caps() & (V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE)) @@ -1706,6 +1713,9 @@ int main(int argc, char **argv) case OptSetTouchDevice: device = make_devname(optarg, "v4l-touch", media_bus_info); break; + case OptSetAudioDevice: + device = make_devname(optarg, "v4l-audio", media_bus_info); + break; case OptSetSubDevDevice: device = make_devname(optarg, "v4l-subdev", media_bus_info); break; diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h index 0cfc9a37..6fc84cf1 100644 --- a/utils/v4l2-compliance/v4l2-compliance.h +++ b/utils/v4l2-compliance/v4l2-compliance.h @@ -102,7 +102,7 @@ using frmsizes_count_map = std::map<__u32, unsigned>; struct base_node; -#define V4L2_BUF_TYPE_LAST V4L2_BUF_TYPE_META_OUTPUT +#define V4L2_BUF_TYPE_LAST V4L2_BUF_TYPE_AUDIO_OUTPUT struct base_node { bool is_video; @@ -111,6 +111,7 @@ struct base_node { bool is_sdr; bool is_meta; bool is_touch; + bool is_audio; bool is_m2m; bool is_io_mc; bool is_planar; diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp index 922b99b5..d5dc2625 100644 --- a/utils/v4l2-compliance/v4l2-test-buffers.cpp +++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp @@ -235,12 +235,14 @@ public: if (v4l_type_is_output(g_type())) fill_output_buf(fill_bytesused); err = node->qbuf(*this); - if (err == 0 && - v4l_type_is_video(g_type()) && v4l_type_is_output(g_type())) { - fail_on_test(g_field() == V4L2_FIELD_ANY); + if (err) + return err; + if (v4l_type_is_output(g_type())) { + if (v4l_type_is_video(g_type())) + fail_on_test(g_field() == V4L2_FIELD_ANY); buffer_info[g_timestamp()] = buf; } - return err; + return 0; } int qbuf(node *node, const cv4l_queue &q) { diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp index 8a16613c..adec678a 100644 --- a/utils/v4l2-compliance/v4l2-test-formats.cpp +++ b/utils/v4l2-compliance/v4l2-test-formats.cpp @@ -43,6 +43,8 @@ static constexpr __u32 buftype2cap[] = { V4L2_CAP_SDR_OUTPUT, V4L2_CAP_META_CAPTURE, V4L2_CAP_META_OUTPUT, + V4L2_CAP_AUDIO_M2M, + V4L2_CAP_AUDIO_M2M, }; static int testEnumFrameIntervals(struct node *node, __u32 pixfmt, @@ -330,6 +332,8 @@ int testEnumFormats(struct node *node) case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: case V4L2_BUF_TYPE_SDR_CAPTURE: case V4L2_BUF_TYPE_SDR_OUTPUT: + case V4L2_BUF_TYPE_AUDIO_CAPTURE: + case V4L2_BUF_TYPE_AUDIO_OUTPUT: if (ret && (node->g_caps() & buftype2cap[type])) return fail("%s cap set, but no %s formats defined\n", buftype2s(type).c_str(), buftype2s(type).c_str()); @@ -447,6 +451,7 @@ static int testFormatsType(struct node *node, int ret, unsigned type, struct v4 struct v4l2_sliced_vbi_format &sliced = fmt.fmt.sliced; struct v4l2_sdr_format &sdr = fmt.fmt.sdr; struct v4l2_meta_format &meta = fmt.fmt.meta; + struct v4l2_audio_format &audio = fmt.fmt.audio; unsigned min_data_samples; unsigned min_sampling_rate; v4l2_std_id std; @@ -591,6 +596,13 @@ static int testFormatsType(struct node *node, int ret, unsigned type, struct v4 meta.dataformat, fcc2s(meta.dataformat).c_str(), type); fail_on_test(meta.buffersize == 0); break; + case V4L2_BUF_TYPE_AUDIO_CAPTURE: + case V4L2_BUF_TYPE_AUDIO_OUTPUT: + if (map.find(audio.audioformat) == map.end()) + return fail("audioformat %08x (%s) for buftype %d not reported by ENUM_FMT\n", + audio.audioformat, fcc2s(audio.audioformat).c_str(), type); + fail_on_test(audio.buffersize == 0); + break; case V4L2_BUF_TYPE_PRIVATE: break; } @@ -626,6 +638,8 @@ int testGetFormats(struct node *node) case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: case V4L2_BUF_TYPE_SDR_CAPTURE: case V4L2_BUF_TYPE_SDR_OUTPUT: + case V4L2_BUF_TYPE_AUDIO_CAPTURE: + case V4L2_BUF_TYPE_AUDIO_OUTPUT: if (ret && (node->g_caps() & buftype2cap[type])) return fail("%s cap set, but no %s formats defined\n", buftype2s(type).c_str(), buftype2s(type).c_str()); @@ -703,6 +717,9 @@ static bool matchFormats(const struct v4l2_format &f1, const struct v4l2_format case V4L2_BUF_TYPE_META_CAPTURE: case V4L2_BUF_TYPE_META_OUTPUT: return !memcmp(&f1.fmt.meta, &f2.fmt.meta, sizeof(f1.fmt.meta)); + case V4L2_BUF_TYPE_AUDIO_CAPTURE: + case V4L2_BUF_TYPE_AUDIO_OUTPUT: + return !memcmp(&f1.fmt.audio, &f2.fmt.audio, sizeof(f1.fmt.audio)); } return false; @@ -782,6 +799,10 @@ int testTryFormats(struct node *node) case V4L2_BUF_TYPE_META_OUTPUT: pixelformat = fmt.fmt.meta.dataformat; break; + case V4L2_BUF_TYPE_AUDIO_CAPTURE: + case V4L2_BUF_TYPE_AUDIO_OUTPUT: + pixelformat = fmt.fmt.audio.audioformat; + break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: pixelformat = fmt.fmt.pix_mp.pixelformat; @@ -860,6 +881,9 @@ static int testM2MFormats(struct node *node) fail_on_test(node->g_fmt(fmt_out, out_type)); fail_on_test(node->g_fmt(fmt_cap, cap_type)); + if (node->has_audio_m2m()) + return 0; + /* * JPEG codec have fixed colorspace, so these tests * are different compared to other m2m devices. @@ -1132,6 +1156,10 @@ int testSetFormats(struct node *node) case V4L2_BUF_TYPE_META_OUTPUT: pixelformat = fmt_set.fmt.meta.dataformat; break; + case V4L2_BUF_TYPE_AUDIO_CAPTURE: + case V4L2_BUF_TYPE_AUDIO_OUTPUT: + pixelformat = fmt_set.fmt.audio.audioformat; + break; case V4L2_BUF_TYPE_SDR_CAPTURE: case V4L2_BUF_TYPE_SDR_OUTPUT: pixelformat = fmt_set.fmt.sdr.pixelformat; diff --git a/utils/v4l2-compliance/v4l2-test-media.cpp b/utils/v4l2-compliance/v4l2-test-media.cpp index 52ab7fb8..ee1d03e0 100644 --- a/utils/v4l2-compliance/v4l2-test-media.cpp +++ b/utils/v4l2-compliance/v4l2-test-media.cpp @@ -573,6 +573,7 @@ void walkTopology(struct node &node, struct node &expbuf_node, case MEDIA_TYPE_RADIO: case MEDIA_TYPE_SDR: case MEDIA_TYPE_TOUCH: + case MEDIA_TYPE_AUDIO: case MEDIA_TYPE_SUBDEV: break; default: From patchwork Wed Jan 17 15:02:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 763502 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 2EF8520DC9 for ; Wed, 17 Jan 2024 15:02:50 +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=1705503771; cv=none; b=CdO71vprCKjhhjOrk8DMR1XutG3wotnlhEJ0v9W3YBtmwoEmBQ6ETg9awMIXa6XIVQJhKodln+qa0zNKNqsa/VbYmaY4XBOk7xpYJNb6je8i6bcSHejRVFfWrciMCZoRy82L0jEowrwGXu9t8PHgMFyDicLzURy0rYRJkRQlc3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503771; c=relaxed/simple; bh=VPc0ZNMS8EeOrUgrUgvnwt+ObuOu7vEqNL8nA98j5m4=; h=Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=PbvS0CK82FrYMqSs6O2MM/MluN4RK737L6uyMLkjjePxQmBJ8pkPt3fvpC73IWdOoVTcUweOaxfzqMgOP7NtAPNf0D7E7j8+0GzK2hxqjl9/omHOdFDjJFMT1pl9RxvhoR+UHN6K2j0j6raUZttll7/UPFGYZNL3g3cKNX6Roqo= 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 B1C6AC43609; Wed, 17 Jan 2024 15:02:49 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Shengjiu Wang , Hans Verkuil Subject: [PATCH 09/10] v4l2-ctl: add fixed point support Date: Wed, 17 Jan 2024 16:02:17 +0100 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: <79cf7f3c0fdde2ff151ba05d912ba05b35386d4a.1705503477.git.hverkuil-cisco@xs4all.nl> References: <79cf7f3c0fdde2ff151ba05d912ba05b35386d4a.1705503477.git.hverkuil-cisco@xs4all.nl> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Correctly report fixed point control values. Signed-off-by: Hans Verkuil --- utils/v4l2-ctl/v4l2-ctl-common.cpp | 156 ++++++++++++++++++++++++----- 1 file changed, 131 insertions(+), 25 deletions(-) diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp index c089c332..4b3308f3 100644 --- a/utils/v4l2-ctl/v4l2-ctl-common.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp @@ -417,6 +417,55 @@ static bool fill_subset(const struct v4l2_query_ext_ctrl &qc, ctrl_subset &subse return false; } +static void print_fp(__s64 v, unsigned int fraction_bits) +{ + __s64 i, f, mask; + + if (!fraction_bits) { + printf("%lld", v); + return; + } + + mask = (1ULL << fraction_bits) - 1; + + /* + * Note: this function does not support fixed point u64 with + * fraction_bits set to 64. At the moment there is no U64 + * control type, but if that is added, then this code will have + * to add support for it. + */ + if (fraction_bits >= 63) + i = v < 0 ? -1 : 0; + else + i = v / (1LL << fraction_bits); + + f = (v & mask) ? (v < 0 ? -((-v) & mask) : (v & mask)) : 0; + + if (!f) { + printf("%lld", i); + } else if (fraction_bits < 20) { + __u64 div = 1ULL << fraction_bits; + + if (!i && f < 0) + printf("-%lld/%llu", -f, div); + else if (!i) + printf("%lld/%llu", f, div); + else if (i < 0 || f < 0) + printf("-%lld-%llu/%llu", -i, -f, div); + else + printf("%lld+%llu/%llu", i, f, div); + } else { + if (!i && f < 0) + printf("-%lld/(2^%u)", -f, fraction_bits); + else if (!i) + printf("%lld/(2^%u)", f, fraction_bits); + else if (i < 0 || f < 0) + printf("-%lld-%llu/(2^%u)", -i, -f, fraction_bits); + else + printf("%lld+%llu/(2^%u)", i, f, fraction_bits); + } +} + static void print_array(const v4l2_query_ext_ctrl &qc, const v4l2_ext_control &ctrl, const ctrl_subset &subset) { @@ -452,7 +501,10 @@ static void print_array(const v4l2_query_ext_ctrl &qc, const v4l2_ext_control &c switch (qc.type) { case V4L2_CTRL_TYPE_U8: for (i = from; i <= to; i++) { - printf("%4u", ctrl.p_u8[idx + i]); + if (qc.fraction_bits) + print_fp(ctrl.p_u8[idx + i], qc.fraction_bits); + else + printf("%4u", ctrl.p_u8[idx + i]); if (i < to) printf(", "); } @@ -460,7 +512,10 @@ static void print_array(const v4l2_query_ext_ctrl &qc, const v4l2_ext_control &c break; case V4L2_CTRL_TYPE_U16: for (i = from; i <= to; i++) { - printf("%6u", ctrl.p_u16[idx + i]); + if (qc.fraction_bits) + print_fp(ctrl.p_u16[idx + i], qc.fraction_bits); + else + printf("%6u", ctrl.p_u16[idx + i]); if (i < to) printf(", "); } @@ -468,7 +523,10 @@ static void print_array(const v4l2_query_ext_ctrl &qc, const v4l2_ext_control &c break; case V4L2_CTRL_TYPE_U32: for (i = from; i <= to; i++) { - printf("%10u", ctrl.p_u32[idx + i]); + if (qc.fraction_bits) + print_fp(ctrl.p_u32[idx + i], qc.fraction_bits); + else + printf("%10u", ctrl.p_u32[idx + i]); if (i < to) printf(", "); } @@ -476,7 +534,10 @@ static void print_array(const v4l2_query_ext_ctrl &qc, const v4l2_ext_control &c break; case V4L2_CTRL_TYPE_INTEGER: for (i = from; i <= to; i++) { - printf("%10i", ctrl.p_s32[idx + i]); + if (qc.fraction_bits) + print_fp(ctrl.p_s32[idx + i], qc.fraction_bits); + else + printf("%10d", ctrl.p_s32[idx + i]); if (i < to) printf(", "); } @@ -484,7 +545,10 @@ static void print_array(const v4l2_query_ext_ctrl &qc, const v4l2_ext_control &c break; case V4L2_CTRL_TYPE_INTEGER64: for (i = from; i <= to; i++) { - printf("%12lli", ctrl.p_s64[idx + i]); + if (qc.fraction_bits) + print_fp(ctrl.p_s64[idx + i], qc.fraction_bits); + else + printf("%12lld", ctrl.p_s64[idx + i]); if (i < to) printf(", "); } @@ -524,13 +588,13 @@ static void print_value(int fd, const v4l2_query_ext_ctrl &qc, const v4l2_ext_co if (qc.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD) { switch (qc.type) { case V4L2_CTRL_TYPE_U8: - printf("%u", *ctrl.p_u8); + print_fp(*ctrl.p_u8, qc.fraction_bits); break; case V4L2_CTRL_TYPE_U16: - printf("%u", *ctrl.p_u16); + print_fp(*ctrl.p_u16, qc.fraction_bits); break; case V4L2_CTRL_TYPE_U32: - printf("%u", *ctrl.p_u32); + print_fp(*ctrl.p_u32, qc.fraction_bits); break; case V4L2_CTRL_TYPE_STRING: printf("'%s'", safename(ctrl.string).c_str()); @@ -546,7 +610,7 @@ static void print_value(int fd, const v4l2_query_ext_ctrl &qc, const v4l2_ext_co } switch (qc.type) { case V4L2_CTRL_TYPE_INTEGER64: - printf("%lld", ctrl.value64); + print_fp(ctrl.value64, qc.fraction_bits); break; case V4L2_CTRL_TYPE_MENU: case V4L2_CTRL_TYPE_INTEGER_MENU: @@ -561,7 +625,7 @@ static void print_value(int fd, const v4l2_query_ext_ctrl &qc, const v4l2_ext_co printf("%d (%lld 0x%llx)", ctrl.value, qmenu.value, qmenu.value); break; default: - printf("%d", ctrl.value); + print_fp(ctrl.value, qc.fraction_bits); break; } } @@ -574,14 +638,30 @@ static void print_qctrl(int fd, const v4l2_query_ext_ctrl &qc, switch (qc.type) { case V4L2_CTRL_TYPE_INTEGER: - printf("%31s %#8.8x (int) : min=%lld max=%lld step=%lld default=%lld", - s.c_str(), qc.id, qc.minimum, qc.maximum, - qc.step, qc.default_value); + printf("%31s %#8.8x (int) :", s.c_str(), qc.id); + if (qc.fraction_bits) { + printf(" min="); print_fp(qc.minimum, qc.fraction_bits); + printf(" max="); print_fp(qc.maximum, qc.fraction_bits); + printf(" step="); print_fp(qc.step, qc.fraction_bits); + printf(" default="); print_fp(qc.default_value, qc.fraction_bits); + } else { + printf(" min=%lld max=%lld step=%lld default=%lld", + qc.minimum, qc.maximum, + qc.step, qc.default_value); + } break; case V4L2_CTRL_TYPE_INTEGER64: - printf("%31s %#8.8x (int64) : min=%lld max=%lld step=%lld default=%lld", - s.c_str(), qc.id, qc.minimum, qc.maximum, - qc.step, qc.default_value); + printf("%31s %#8.8x (int64) :", s.c_str(), qc.id); + if (qc.fraction_bits) { + printf(" min="); print_fp(qc.minimum, qc.fraction_bits); + printf(" max="); print_fp(qc.maximum, qc.fraction_bits); + printf(" step="); print_fp(qc.step, qc.fraction_bits); + printf(" default="); print_fp(qc.default_value, qc.fraction_bits); + } else { + printf(" min=%lld max=%lld step=%lld default=%lld", + qc.minimum, qc.maximum, + qc.step, qc.default_value); + } break; case V4L2_CTRL_TYPE_STRING: printf("%31s %#8.8x (str) : min=%lld max=%lld step=%lld", @@ -609,19 +689,43 @@ static void print_qctrl(int fd, const v4l2_query_ext_ctrl &qc, s.c_str(), qc.id, qc.maximum, qc.default_value); break; case V4L2_CTRL_TYPE_U8: - printf("%31s %#8.8x (u8) : min=%lld max=%lld step=%lld default=%lld", - s.c_str(), qc.id, qc.minimum, qc.maximum, - qc.step, qc.default_value); + printf("%31s %#8.8x (u8) :", s.c_str(), qc.id); + if (qc.fraction_bits) { + printf(" min="); print_fp(qc.minimum, qc.fraction_bits); + printf(" max="); print_fp(qc.maximum, qc.fraction_bits); + printf(" step="); print_fp(qc.step, qc.fraction_bits); + printf(" default="); print_fp(qc.default_value, qc.fraction_bits); + } else { + printf(" min=%lld max=%lld step=%lld default=%lld", + qc.minimum, qc.maximum, + qc.step, qc.default_value); + } break; case V4L2_CTRL_TYPE_U16: - printf("%31s %#8.8x (u16) : min=%lld max=%lld step=%lld default=%lld", - s.c_str(), qc.id, qc.minimum, qc.maximum, - qc.step, qc.default_value); + printf("%31s %#8.8x (u16) :", s.c_str(), qc.id); + if (qc.fraction_bits) { + printf(" min="); print_fp(qc.minimum, qc.fraction_bits); + printf(" max="); print_fp(qc.maximum, qc.fraction_bits); + printf(" step="); print_fp(qc.step, qc.fraction_bits); + printf(" default="); print_fp(qc.default_value, qc.fraction_bits); + } else { + printf(" min=%lld max=%lld step=%lld default=%lld", + qc.minimum, qc.maximum, + qc.step, qc.default_value); + } break; case V4L2_CTRL_TYPE_U32: - printf("%31s %#8.8x (u32) : min=%lld max=%lld step=%lld default=%lld", - s.c_str(), qc.id, qc.minimum, qc.maximum, - qc.step, qc.default_value); + printf("%31s %#8.8x (u32) :", s.c_str(), qc.id); + if (qc.fraction_bits) { + printf(" min="); print_fp(qc.minimum, qc.fraction_bits); + printf(" max="); print_fp(qc.maximum, qc.fraction_bits); + printf(" step="); print_fp(qc.step, qc.fraction_bits); + printf(" default="); print_fp(qc.default_value, qc.fraction_bits); + } else { + printf(" min=%lld max=%lld step=%lld default=%lld", + qc.minimum, qc.maximum, + qc.step, qc.default_value); + } break; case V4L2_CTRL_TYPE_AREA: printf("%31s %#8.8x (area) :", s.c_str(), qc.id); @@ -710,6 +814,8 @@ static void print_qctrl(int fd, const v4l2_query_ext_ctrl &qc, for (i = 0; i < qc.nr_of_dims; i++) printf("[%u]", qc.dims[i]); } + if (qc.fraction_bits) + printf(" fraction_bits=%u", qc.fraction_bits); if (qc.flags) printf(" flags=%s", ctrlflags2s(qc.flags).c_str()); printf("\n");