* [v4l-utils] [PATCH 0/8] Support for the generic line-based metadata support
@ 2024-04-02 0:00 Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags Laurent Pinchart
` (7 more replies)
0 siblings, 8 replies; 18+ messages in thread
From: Laurent Pinchart @ 2024-04-02 0:00 UTC (permalink / raw)
To: linux-media; +Cc: Sakari Ailus, Tomi Valkeinen, Hans Verkuil, Gregor Jasny
Hello,
This patch series adds support for the generic line-based metadata
support API. The API is currently under development, with the latest
version v8 posted to the linux-media mailing list in [1].
The series starts with two improvements to media-ctl (1/8) and
v4l2-compliance (2/8). They do not depend on the new API, and can be
merged already. The next 6 patches then implement support for the new
API, and should not be merged until the API is ready to be merged in the
kernel.
This has been tested on a Raspberry Pi 4 with an IMX219 sensor, and the
in-progress work to upstream the Raspberry Pi Unicam driver. The kernel
code can be found in [2], and will be posted shortly to the linux-media
mailing list.
[1] https://lore.kernel.org/linux-media/20240313072516.241106-1-sakari.ailus@linux.intel.com
[2] https://git.kernel.org/pub/scm/linux/kernel/git/pinchartl/linux.git/log/?h=rpi/v6.9/unicam/next
Laurent Pinchart (5):
v4l2-compliance: Constify pointers and references in formats tests
v4l-utils: sync-with-kernel
v4l2-compliance: Support the changed routing API
v4l2-compliance: Add tests for V4L2_FMT_FLAG_META_LINE_BASED flag
v4l2-compliance: Test IMMUTABLE route flag
Sakari Ailus (3):
utils: media-ctl: Print MUST_CONNECT pad flags
utils: media-ctl: Support changed routing API
utils: media-ctl: Also print INTERNAL pad flag
contrib/freebsd/include/linux/videodev2.h | 20 ++++++++
contrib/test/ioctl_32.h | 4 +-
contrib/test/ioctl_64.h | 4 +-
include/linux/media-bus-format.h | 13 +++++
include/linux/media.h | 1 +
include/linux/v4l2-mediabus.h | 18 ++++---
include/linux/v4l2-subdev.h | 14 ++++--
include/linux/videodev2.h | 20 ++++++++
utils/common/v4l2-pix-formats.h | 9 ++++
utils/media-ctl/libv4l2subdev.c | 4 +-
utils/media-ctl/media-ctl.c | 54 ++++++++++++---------
utils/v4l2-compliance/v4l2-compliance.cpp | 12 +++--
utils/v4l2-compliance/v4l2-test-formats.cpp | 47 ++++++++++++------
utils/v4l2-compliance/v4l2-test-subdevs.cpp | 24 +++++----
utils/v4l2-tracer/retrace-gen.cpp | 12 +++++
utils/v4l2-tracer/trace-gen.cpp | 3 ++
utils/v4l2-tracer/v4l2-tracer-info-gen.h | 4 ++
17 files changed, 197 insertions(+), 66 deletions(-)
base-commit: a04dfa5b72df01c6dbdf68fd9365e2d913fe5a0f
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 18+ messages in thread
* [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags
2024-04-02 0:00 [v4l-utils] [PATCH 0/8] Support for the generic line-based metadata support Laurent Pinchart
@ 2024-04-02 0:00 ` Laurent Pinchart
2024-04-03 8:40 ` Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 2/8] v4l2-compliance: Constify pointers and references in formats tests Laurent Pinchart
` (6 subsequent siblings)
7 siblings, 1 reply; 18+ messages in thread
From: Laurent Pinchart @ 2024-04-02 0:00 UTC (permalink / raw)
To: linux-media
Cc: Sakari Ailus, Tomi Valkeinen, Hans Verkuil, Gregor Jasny,
Sakari Ailus
From: Sakari Ailus <sakari.ailus@linux.intel.com>
Print the MUST_CONNECT pad flag for each pad.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
utils/media-ctl/media-ctl.c | 50 +++++++++++++++++++++----------------
1 file changed, 28 insertions(+), 22 deletions(-)
diff --git a/utils/media-ctl/media-ctl.c b/utils/media-ctl/media-ctl.c
index 2081f111f2db..1b40552253f1 100644
--- a/utils/media-ctl/media-ctl.c
+++ b/utils/media-ctl/media-ctl.c
@@ -368,26 +368,6 @@ static const char *media_entity_subtype_to_string(unsigned type)
}
}
-static const char *media_pad_type_to_string(unsigned flag)
-{
- static const struct {
- __u32 flag;
- const char *name;
- } flags[] = {
- { MEDIA_PAD_FL_SINK, "Sink" },
- { MEDIA_PAD_FL_SOURCE, "Source" },
- };
-
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(flags); i++) {
- if (flags[i].flag & flag)
- return flags[i].name;
- }
-
- return "Unknown";
-}
-
static void media_print_topology_dot(struct media_device *media)
{
unsigned int nents = media_get_entities_count(media);
@@ -525,6 +505,25 @@ static void media_print_pad_text(struct media_entity *entity,
v4l2_subdev_print_subdev_dv(entity);
}
+static unsigned int weight(uint32_t word)
+{
+ unsigned int w = 0, i;
+
+ for (i = 0; i < sizeof(word) << 3; i++, word >>= 1)
+ w += word & 1U;
+
+ return w;
+}
+
+static const char *comma(uint32_t flag, uint32_t prev_flags, uint32_t flags)
+{
+ static const char *empty = "", *comma = ", ";
+ if (!(flag & flags))
+ return empty;
+
+ return weight(prev_flags & flags) ? comma : empty;
+}
+
static void media_print_topology_text_entity(struct media_device *media,
struct media_entity *entity)
{
@@ -567,8 +566,15 @@ static void media_print_topology_text_entity(struct media_device *media,
for (j = 0; j < info->pads; j++) {
const struct media_pad *pad = media_entity_get_pad(entity, j);
- printf("\tpad%u: %s\n", j, media_pad_type_to_string(pad->flags));
-
+ printf("\tpad%u: %s%s%s%s%s\n", j,
+ pad->flags & MEDIA_PAD_FL_SINK ? "Sink" : "",
+ comma(MEDIA_PAD_FL_SOURCE, MEDIA_PAD_FL_SINK,
+ pad->flags),
+ pad->flags & MEDIA_PAD_FL_SOURCE ? "Source" : "",
+ comma(MEDIA_PAD_FL_MUST_CONNECT,
+ MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE,
+ pad->flags),
+ pad->flags & MEDIA_PAD_FL_MUST_CONNECT ? "Must connect" : "");
media_print_pad_text(entity, pad, routes, num_routes);
for (k = 0; k < num_links; k++) {
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [v4l-utils] [PATCH 2/8] v4l2-compliance: Constify pointers and references in formats tests
2024-04-02 0:00 [v4l-utils] [PATCH 0/8] Support for the generic line-based metadata support Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags Laurent Pinchart
@ 2024-04-02 0:00 ` Laurent Pinchart
2024-04-03 8:44 ` Tomi Valkeinen
2024-04-03 8:46 ` Hans Verkuil
2024-04-02 0:00 ` [v4l-utils] [PATCH 3/8] v4l-utils: sync-with-kernel Laurent Pinchart
` (5 subsequent siblings)
7 siblings, 2 replies; 18+ messages in thread
From: Laurent Pinchart @ 2024-04-02 0:00 UTC (permalink / raw)
To: linux-media; +Cc: Sakari Ailus, Tomi Valkeinen, Hans Verkuil, Gregor Jasny
Multiple variables point to or reference data that never needs to be
modified. Make them const.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
utils/v4l2-compliance/v4l2-test-formats.cpp | 30 ++++++++++-----------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp
index 8a16613c3097..423567fe573b 100644
--- a/utils/v4l2-compliance/v4l2-test-formats.cpp
+++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
@@ -49,7 +49,7 @@ static int testEnumFrameIntervals(struct node *node, __u32 pixfmt,
__u32 w, __u32 h, __u32 type)
{
struct v4l2_frmivalenum frmival;
- struct v4l2_frmival_stepwise *sw = &frmival.stepwise;
+ const struct v4l2_frmival_stepwise *sw = &frmival.stepwise;
bool found_stepwise = false;
unsigned f = 0;
int ret;
@@ -129,7 +129,7 @@ static int testEnumFrameIntervals(struct node *node, __u32 pixfmt,
static int testEnumFrameSizes(struct node *node, __u32 pixfmt)
{
struct v4l2_frmsizeenum frmsize;
- struct v4l2_frmsize_stepwise *sw = &frmsize.stepwise;
+ const struct v4l2_frmsize_stepwise *sw = &frmsize.stepwise;
bool found_stepwise = false;
__u64 cookie;
unsigned f = 0;
@@ -438,15 +438,15 @@ static void createInvalidFmt(struct v4l2_format &fmt, struct v4l2_clip &clip, un
static int testFormatsType(struct node *node, int ret, unsigned type, struct v4l2_format &fmt, bool have_clip = false)
{
- pixfmt_map &map = node->buftype_pixfmts[type];
- pixfmt_map *map_splane;
- struct v4l2_pix_format &pix = fmt.fmt.pix;
- struct v4l2_pix_format_mplane &pix_mp = fmt.fmt.pix_mp;
- struct v4l2_window &win = fmt.fmt.win;
- struct v4l2_vbi_format &vbi = fmt.fmt.vbi;
- 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;
+ const pixfmt_map &map = node->buftype_pixfmts[type];
+ const pixfmt_map *map_splane;
+ const struct v4l2_pix_format &pix = fmt.fmt.pix;
+ const struct v4l2_pix_format_mplane &pix_mp = fmt.fmt.pix_mp;
+ const struct v4l2_window &win = fmt.fmt.win;
+ const struct v4l2_vbi_format &vbi = fmt.fmt.vbi;
+ const struct v4l2_sliced_vbi_format &sliced = fmt.fmt.sliced;
+ const struct v4l2_sdr_format &sdr = fmt.fmt.sdr;
+ const struct v4l2_meta_format &meta = fmt.fmt.meta;
unsigned min_data_samples;
unsigned min_sampling_rate;
v4l2_std_id std;
@@ -497,7 +497,7 @@ static int testFormatsType(struct node *node, int ret, unsigned type, struct v4
return fail("pix_mp.reserved not zeroed\n");
fail_on_test(pix_mp.num_planes == 0 || pix_mp.num_planes >= VIDEO_MAX_PLANES);
for (int i = 0; i < pix_mp.num_planes; i++) {
- struct v4l2_plane_pix_format &pfmt = pix_mp.plane_fmt[i];
+ const struct v4l2_plane_pix_format &pfmt = pix_mp.plane_fmt[i];
ret = check_0(pfmt.reserved, sizeof(pfmt.reserved));
if (ret)
@@ -559,7 +559,7 @@ static int testFormatsType(struct node *node, int ret, unsigned type, struct v4
if (have_clip)
fail_on_test(!win.clipcount && (node->fbuf_caps & V4L2_FBUF_CAP_LIST_CLIPPING));
if (win.clipcount) {
- struct v4l2_rect *r = &win.clips->c;
+ const struct v4l2_rect *r = &win.clips->c;
struct v4l2_framebuffer fb;
fail_on_test(doioctl(node, VIDIOC_G_FBUF, &fb));
@@ -1281,8 +1281,8 @@ int testSlicedVBICap(struct node *node)
static int testParmStruct(struct node *node, struct v4l2_streamparm &parm)
{
bool is_stateful_enc = node->codec_mask & STATEFUL_ENCODER;
- struct v4l2_captureparm *cap = &parm.parm.capture;
- struct v4l2_outputparm *out = &parm.parm.output;
+ const struct v4l2_captureparm *cap = &parm.parm.capture;
+ const struct v4l2_outputparm *out = &parm.parm.output;
int ret;
switch (parm.type) {
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [v4l-utils] [PATCH 3/8] v4l-utils: sync-with-kernel
2024-04-02 0:00 [v4l-utils] [PATCH 0/8] Support for the generic line-based metadata support Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 2/8] v4l2-compliance: Constify pointers and references in formats tests Laurent Pinchart
@ 2024-04-02 0:00 ` Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 4/8] utils: media-ctl: Support changed routing API Laurent Pinchart
` (4 subsequent siblings)
7 siblings, 0 replies; 18+ messages in thread
From: Laurent Pinchart @ 2024-04-02 0:00 UTC (permalink / raw)
To: linux-media; +Cc: Sakari Ailus, Tomi Valkeinen, Hans Verkuil, Gregor Jasny
Update v4l-utils to the latest kernel headers, taken from the metadata
API v8..
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
contrib/freebsd/include/linux/videodev2.h | 20 ++++++++++++++++++++
contrib/test/ioctl_32.h | 4 ++--
contrib/test/ioctl_64.h | 4 ++--
include/linux/media-bus-format.h | 13 +++++++++++++
include/linux/media.h | 1 +
include/linux/v4l2-mediabus.h | 18 ++++++++++++------
include/linux/v4l2-subdev.h | 14 +++++++++++---
include/linux/videodev2.h | 20 ++++++++++++++++++++
utils/common/v4l2-pix-formats.h | 9 +++++++++
utils/v4l2-tracer/retrace-gen.cpp | 12 ++++++++++++
utils/v4l2-tracer/trace-gen.cpp | 3 +++
utils/v4l2-tracer/v4l2-tracer-info-gen.h | 4 ++++
12 files changed, 109 insertions(+), 13 deletions(-)
diff --git a/contrib/freebsd/include/linux/videodev2.h b/contrib/freebsd/include/linux/videodev2.h
index 4815944b0b8c..5d3fb63f2c9f 100644
--- a/contrib/freebsd/include/linux/videodev2.h
+++ b/contrib/freebsd/include/linux/videodev2.h
@@ -606,6 +606,8 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_Y10BPACK v4l2_fourcc('Y', '1', '0', 'B') /* 10 Greyscale bit-packed */
#define V4L2_PIX_FMT_Y10P v4l2_fourcc('Y', '1', '0', 'P') /* 10 Greyscale, MIPI RAW10 packed */
#define V4L2_PIX_FMT_IPU3_Y10 v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */
+#define V4L2_PIX_FMT_Y12P v4l2_fourcc('Y', '1', '2', 'P') /* 12 Greyscale, MIPI RAW12 packed */
+#define V4L2_PIX_FMT_Y14P v4l2_fourcc('Y', '1', '4', 'P') /* 14 Greyscale, MIPI RAW14 packed */
/* Palette formats */
#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */
@@ -846,6 +848,14 @@ 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 */
+#define V4L2_META_FMT_GENERIC_8 v4l2_fourcc('M', 'E', 'T', '8') /* Generic 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_10 v4l2_fourcc('M', 'C', '1', 'A') /* 10-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_12 v4l2_fourcc('M', 'C', '1', 'C') /* 12-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_14 v4l2_fourcc('M', 'C', '1', 'E') /* 14-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_16 v4l2_fourcc('M', 'C', '1', 'G') /* 16-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_20 v4l2_fourcc('M', 'C', '1', 'K') /* 20-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_24 v4l2_fourcc('M', 'C', '1', 'O') /* 24-bit CSI-2 packed 8-bit metadata */
+
/* priv field value to indicates that subsequent fields are valid. */
#define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe
@@ -876,6 +886,7 @@ struct v4l2_fmtdesc {
#define V4L2_FMT_FLAG_CSC_YCBCR_ENC 0x0080
#define V4L2_FMT_FLAG_CSC_HSV_ENC V4L2_FMT_FLAG_CSC_YCBCR_ENC
#define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100
+#define V4L2_FMT_FLAG_META_LINE_BASED 0x0200
/* Frame Size and frame rate enumeration */
/*
@@ -2394,10 +2405,19 @@ struct v4l2_sdr_format {
* struct v4l2_meta_format - metadata format definition
* @dataformat: little endian four character code (fourcc)
* @buffersize: maximum size in bytes required for data
+ * @width: number of data units of data per line (valid for line
+ * based formats only, see format documentation)
+ * @height: number of lines of data per buffer (valid for line based
+ * formats only)
+ * @bytesperline: offset between the beginnings of two adjacent lines in
+ * bytes (valid for line based formats only)
*/
struct v4l2_meta_format {
uint32_t dataformat;
uint32_t buffersize;
+ uint32_t width;
+ uint32_t height;
+ uint32_t bytesperline;
} __attribute__ ((packed));
/**
diff --git a/contrib/test/ioctl_32.h b/contrib/test/ioctl_32.h
index 97f58676fce1..42997b76cf8d 100644
--- a/contrib/test/ioctl_32.h
+++ b/contrib/test/ioctl_32.h
@@ -103,7 +103,7 @@
#define CMD32_VIDIOC_SUBDEV_G_EDID 0xc0245628
#define CMD32_VIDIOC_SUBDEV_G_FMT 0xc0585604
#define CMD32_VIDIOC_SUBDEV_G_FRAME_INTERVAL 0xc0305615
-#define CMD32_VIDIOC_SUBDEV_G_ROUTING 0xc0285626
+#define CMD32_VIDIOC_SUBDEV_G_ROUTING 0xc0405626
#define CMD32_VIDIOC_SUBDEV_G_SELECTION 0xc040563d
#define CMD32_VIDIOC_SUBDEV_G_STD 0x80085617
#define CMD32_VIDIOC_SUBDEV_QUERYCAP 0x80405600
@@ -115,7 +115,7 @@
#define CMD32_VIDIOC_SUBDEV_S_EDID 0xc0245629
#define CMD32_VIDIOC_SUBDEV_S_FMT 0xc0585605
#define CMD32_VIDIOC_SUBDEV_S_FRAME_INTERVAL 0xc0305616
-#define CMD32_VIDIOC_SUBDEV_S_ROUTING 0xc0285627
+#define CMD32_VIDIOC_SUBDEV_S_ROUTING 0xc0405627
#define CMD32_VIDIOC_SUBDEV_S_SELECTION 0xc040563e
#define CMD32_VIDIOC_SUBDEV_S_STD 0x40085618
#define CMD32_VIDIOC_SUBSCRIBE_EVENT 0x4020565a
diff --git a/contrib/test/ioctl_64.h b/contrib/test/ioctl_64.h
index 2bad335dab60..8539622cf329 100644
--- a/contrib/test/ioctl_64.h
+++ b/contrib/test/ioctl_64.h
@@ -103,7 +103,7 @@
#define CMD64_VIDIOC_SUBDEV_G_EDID 0xc0285628
#define CMD64_VIDIOC_SUBDEV_G_FMT 0xc0585604
#define CMD64_VIDIOC_SUBDEV_G_FRAME_INTERVAL 0xc0305615
-#define CMD64_VIDIOC_SUBDEV_G_ROUTING 0xc0285626
+#define CMD64_VIDIOC_SUBDEV_G_ROUTING 0xc0405626
#define CMD64_VIDIOC_SUBDEV_G_SELECTION 0xc040563d
#define CMD64_VIDIOC_SUBDEV_G_STD 0x80085617
#define CMD64_VIDIOC_SUBDEV_QUERYCAP 0x80405600
@@ -115,7 +115,7 @@
#define CMD64_VIDIOC_SUBDEV_S_EDID 0xc0285629
#define CMD64_VIDIOC_SUBDEV_S_FMT 0xc0585605
#define CMD64_VIDIOC_SUBDEV_S_FRAME_INTERVAL 0xc0305616
-#define CMD64_VIDIOC_SUBDEV_S_ROUTING 0xc0285627
+#define CMD64_VIDIOC_SUBDEV_S_ROUTING 0xc0405627
#define CMD64_VIDIOC_SUBDEV_S_SELECTION 0xc040563e
#define CMD64_VIDIOC_SUBDEV_S_STD 0x40085618
#define CMD64_VIDIOC_SUBSCRIBE_EVENT 0x4020565a
diff --git a/include/linux/media-bus-format.h b/include/linux/media-bus-format.h
index f05f747e444d..13e68c2ccb61 100644
--- a/include/linux/media-bus-format.h
+++ b/include/linux/media-bus-format.h
@@ -174,4 +174,17 @@
*/
#define MEDIA_BUS_FMT_METADATA_FIXED 0x7001
+/* Generic line based metadata formats for serial buses. Next is 0x8008. */
+#define MEDIA_BUS_FMT_META_8 0x8001
+#define MEDIA_BUS_FMT_META_10 0x8002
+#define MEDIA_BUS_FMT_META_12 0x8003
+#define MEDIA_BUS_FMT_META_14 0x8004
+#define MEDIA_BUS_FMT_META_16 0x8005
+#define MEDIA_BUS_FMT_META_20 0x8006
+#define MEDIA_BUS_FMT_META_24 0x8007
+
+/* Specific metadata formats. Next is 0x9003. */
+#define MEDIA_BUS_FMT_CCS_EMBEDDED 0x9001
+#define MEDIA_BUS_FMT_OV2740_EMBEDDED 0x9002
+
#endif /* __LINUX_MEDIA_BUS_FORMAT_H */
diff --git a/include/linux/media.h b/include/linux/media.h
index b5a77bbf4062..4a733b9beb27 100644
--- a/include/linux/media.h
+++ b/include/linux/media.h
@@ -206,6 +206,7 @@ struct media_entity_desc {
#define MEDIA_PAD_FL_SINK (1U << 0)
#define MEDIA_PAD_FL_SOURCE (1U << 1)
#define MEDIA_PAD_FL_MUST_CONNECT (1U << 2)
+#define MEDIA_PAD_FL_INTERNAL (1U << 3)
struct media_pad_desc {
__u32 entity; /* entity ID */
diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
index 2c318de10485..0651b09dee68 100644
--- a/include/linux/v4l2-mediabus.h
+++ b/include/linux/v4l2-mediabus.h
@@ -19,12 +19,18 @@
* @width: image width
* @height: image height
* @code: data format code (from enum v4l2_mbus_pixelcode)
- * @field: used interlacing type (from enum v4l2_field)
- * @colorspace: colorspace of the data (from enum v4l2_colorspace)
- * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
- * @hsv_enc: HSV encoding of the data (from enum v4l2_hsv_encoding)
- * @quantization: quantization of the data (from enum v4l2_quantization)
- * @xfer_func: transfer function of the data (from enum v4l2_xfer_func)
+ * @field: used interlacing type (from enum v4l2_field), zero on metadata
+ * mbus codes
+ * @colorspace: colorspace of the data (from enum v4l2_colorspace), zero on
+ * metadata mbus codes
+ * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding), zero
+ * on metadata mbus codes
+ * @hsv_enc: HSV encoding of the data (from enum v4l2_hsv_encoding), zero on
+ * metadata mbus codes
+ * @quantization: quantization of the data (from enum v4l2_quantization), zero
+ * on metadata mbus codes
+ * @xfer_func: transfer function of the data (from enum v4l2_xfer_func), zero
+ * on metadata mbus codes
* @flags: flags (V4L2_MBUS_FRAMEFMT_*)
* @reserved: reserved bytes that can be later used
*/
diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
index 7048c51581c6..7e501cb45e4e 100644
--- a/include/linux/v4l2-subdev.h
+++ b/include/linux/v4l2-subdev.h
@@ -200,6 +200,11 @@ struct v4l2_subdev_capability {
* on a video node.
*/
#define V4L2_SUBDEV_ROUTE_FL_ACTIVE (1U << 0)
+/*
+ * Is the route immutable. The ACTIVE flag of an immutable route may not be
+ * changed.
+ */
+#define V4L2_SUBDEV_ROUTE_FL_IMMUTABLE (1U << 1)
/**
* struct v4l2_subdev_route - A route inside a subdev
@@ -224,15 +229,18 @@ struct v4l2_subdev_route {
* struct v4l2_subdev_routing - Subdev routing information
*
* @which: configuration type (from enum v4l2_subdev_format_whence)
- * @num_routes: the total number of routes in the routes array
+ * @len_routes: the length of the routes array, in routes
* @routes: pointer to the routes array
+ * @num_routes: the total number of routes, possibly more than fits in the
+ * routes array
* @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_routing {
__u32 which;
- __u32 num_routes;
+ __u32 len_routes;
__u64 routes;
- __u32 reserved[6];
+ __u32 num_routes;
+ __u32 reserved[11];
};
/*
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index b21e7f2c67cd..b2424a44b0ef 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -572,6 +572,8 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_Y10BPACK v4l2_fourcc('Y', '1', '0', 'B') /* 10 Greyscale bit-packed */
#define V4L2_PIX_FMT_Y10P v4l2_fourcc('Y', '1', '0', 'P') /* 10 Greyscale, MIPI RAW10 packed */
#define V4L2_PIX_FMT_IPU3_Y10 v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */
+#define V4L2_PIX_FMT_Y12P v4l2_fourcc('Y', '1', '2', 'P') /* 12 Greyscale, MIPI RAW12 packed */
+#define V4L2_PIX_FMT_Y14P v4l2_fourcc('Y', '1', '4', 'P') /* 14 Greyscale, MIPI RAW14 packed */
/* Palette formats */
#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */
@@ -812,6 +814,14 @@ 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 */
+#define V4L2_META_FMT_GENERIC_8 v4l2_fourcc('M', 'E', 'T', '8') /* Generic 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_10 v4l2_fourcc('M', 'C', '1', 'A') /* 10-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_12 v4l2_fourcc('M', 'C', '1', 'C') /* 12-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_14 v4l2_fourcc('M', 'C', '1', 'E') /* 14-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_16 v4l2_fourcc('M', 'C', '1', 'G') /* 16-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_20 v4l2_fourcc('M', 'C', '1', 'K') /* 20-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_24 v4l2_fourcc('M', 'C', '1', 'O') /* 24-bit CSI-2 packed 8-bit metadata */
+
/* priv field value to indicates that subsequent fields are valid. */
#define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe
@@ -842,6 +852,7 @@ struct v4l2_fmtdesc {
#define V4L2_FMT_FLAG_CSC_YCBCR_ENC 0x0080
#define V4L2_FMT_FLAG_CSC_HSV_ENC V4L2_FMT_FLAG_CSC_YCBCR_ENC
#define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100
+#define V4L2_FMT_FLAG_META_LINE_BASED 0x0200
/* Frame Size and frame rate enumeration */
/*
@@ -2360,10 +2371,19 @@ struct v4l2_sdr_format {
* struct v4l2_meta_format - metadata format definition
* @dataformat: little endian four character code (fourcc)
* @buffersize: maximum size in bytes required for data
+ * @width: number of data units of data per line (valid for line
+ * based formats only, see format documentation)
+ * @height: number of lines of data per buffer (valid for line based
+ * formats only)
+ * @bytesperline: offset between the beginnings of two adjacent lines in
+ * bytes (valid for line based formats only)
*/
struct v4l2_meta_format {
__u32 dataformat;
__u32 buffersize;
+ __u32 width;
+ __u32 height;
+ __u32 bytesperline;
} __attribute__ ((packed));
/**
diff --git a/utils/common/v4l2-pix-formats.h b/utils/common/v4l2-pix-formats.h
index e8d2e441fdfc..90c1b31257b2 100644
--- a/utils/common/v4l2-pix-formats.h
+++ b/utils/common/v4l2-pix-formats.h
@@ -52,6 +52,8 @@
case V4L2_PIX_FMT_Y10BPACK: return "10-bit Greyscale (Packed)";
case V4L2_PIX_FMT_Y10P: return "10-bit Greyscale (MIPI Packed)";
case V4L2_PIX_FMT_IPU3_Y10: return "10-bit greyscale (IPU3 Packed)";
+ case V4L2_PIX_FMT_Y12P: return "12-bit Greyscale (MIPI Packed)";
+ case V4L2_PIX_FMT_Y14P: return "14-bit Greyscale (MIPI Packed)";
case V4L2_PIX_FMT_Y8I: return "Interleaved 8-bit Greyscale";
case V4L2_PIX_FMT_Y12I: return "Interleaved 12-bit Greyscale";
case V4L2_PIX_FMT_Z16: return "16-bit Depth";
@@ -192,6 +194,13 @@
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_META_FMT_GENERIC_8: return "8-bit Generic Metadata";
+ case V4L2_META_FMT_GENERIC_CSI2_10: return "8b Generic Meta, 10b CSI-2";
+ case V4L2_META_FMT_GENERIC_CSI2_12: return "8b Generic Meta, 12b CSI-2";
+ case V4L2_META_FMT_GENERIC_CSI2_14: return "8b Generic Meta, 14b CSI-2";
+ case V4L2_META_FMT_GENERIC_CSI2_16: return "8b Generic Meta, 16b CSI-2";
+ case V4L2_META_FMT_GENERIC_CSI2_20: return "8b Generic Meta, 20b CSI-2";
+ case V4L2_META_FMT_GENERIC_CSI2_24: return "8b Generic Meta, 24b CSI-2";
case V4L2_PIX_FMT_MJPEG: return "Motion-JPEG";
case V4L2_PIX_FMT_JPEG: return "JFIF JPEG";
case V4L2_PIX_FMT_DV: return "1394";
diff --git a/utils/v4l2-tracer/retrace-gen.cpp b/utils/v4l2-tracer/retrace-gen.cpp
index 08ed96164c28..514fbcf47b2b 100644
--- a/utils/v4l2-tracer/retrace-gen.cpp
+++ b/utils/v4l2-tracer/retrace-gen.cpp
@@ -4930,6 +4930,18 @@ struct v4l2_meta_format *retrace_v4l2_meta_format_gen(json_object *parent_obj, s
if (json_object_object_get_ex(v4l2_meta_format_obj, "buffersize", &buffersize_obj))
p->buffersize = (__u32) json_object_get_int64(buffersize_obj);
+ json_object *width_obj;
+ if (json_object_object_get_ex(v4l2_meta_format_obj, "width", &width_obj))
+ p->width = (__u32) json_object_get_int64(width_obj);
+
+ json_object *height_obj;
+ if (json_object_object_get_ex(v4l2_meta_format_obj, "height", &height_obj))
+ p->height = (__u32) json_object_get_int64(height_obj);
+
+ json_object *bytesperline_obj;
+ if (json_object_object_get_ex(v4l2_meta_format_obj, "bytesperline", &bytesperline_obj))
+ p->bytesperline = (__u32) json_object_get_int64(bytesperline_obj);
+
return p;
}
struct v4l2_format *retrace_v4l2_format_gen(json_object *parent_obj, std::string key_name = "")
diff --git a/utils/v4l2-tracer/trace-gen.cpp b/utils/v4l2-tracer/trace-gen.cpp
index fd58d9182905..82b5f3a76813 100644
--- a/utils/v4l2-tracer/trace-gen.cpp
+++ b/utils/v4l2-tracer/trace-gen.cpp
@@ -2736,6 +2736,9 @@ void trace_v4l2_meta_format_gen(void *arg, json_object *parent_obj, std::string
json_object_object_add(v4l2_meta_format_obj, "dataformat", json_object_new_int64(p->dataformat));
json_object_object_add(v4l2_meta_format_obj, "buffersize", json_object_new_int64(p->buffersize));
+ json_object_object_add(v4l2_meta_format_obj, "width", json_object_new_int64(p->width));
+ json_object_object_add(v4l2_meta_format_obj, "height", json_object_new_int64(p->height));
+ json_object_object_add(v4l2_meta_format_obj, "bytesperline", json_object_new_int64(p->bytesperline));
if (key_name.empty())
json_object_object_add(parent_obj, "v4l2_meta_format", v4l2_meta_format_obj);
diff --git a/utils/v4l2-tracer/v4l2-tracer-info-gen.h b/utils/v4l2-tracer/v4l2-tracer-info-gen.h
index 022c435c34cf..51eeb7b7ec60 100644
--- a/utils/v4l2-tracer/v4l2-tracer-info-gen.h
+++ b/utils/v4l2-tracer/v4l2-tracer-info-gen.h
@@ -1288,6 +1288,8 @@ constexpr val_def v4l2_pix_fmt_val_def[] = {
{ V4L2_PIX_FMT_Y10BPACK, "V4L2_PIX_FMT_Y10BPACK" },
{ V4L2_PIX_FMT_Y10P, "V4L2_PIX_FMT_Y10P" },
{ V4L2_PIX_FMT_IPU3_Y10, "V4L2_PIX_FMT_IPU3_Y10" },
+ { V4L2_PIX_FMT_Y12P, "V4L2_PIX_FMT_Y12P" },
+ { V4L2_PIX_FMT_Y14P, "V4L2_PIX_FMT_Y14P" },
{ V4L2_PIX_FMT_PAL8, "V4L2_PIX_FMT_PAL8" },
{ V4L2_PIX_FMT_UV8, "V4L2_PIX_FMT_UV8" },
{ V4L2_PIX_FMT_YUYV, "V4L2_PIX_FMT_YUYV" },
@@ -1482,6 +1484,7 @@ constexpr flag_def v4l2_fmt_flag_def[] = {
{ V4L2_FMT_FLAG_CSC_YCBCR_ENC, "V4L2_FMT_FLAG_CSC_YCBCR_ENC" },
{ V4L2_FMT_FLAG_CSC_HSV_ENC, "V4L2_FMT_FLAG_CSC_HSV_ENC" },
{ V4L2_FMT_FLAG_CSC_QUANTIZATION, "V4L2_FMT_FLAG_CSC_QUANTIZATION" },
+ { V4L2_FMT_FLAG_META_LINE_BASED, "V4L2_FMT_FLAG_META_LINE_BASED" },
{ 0, "" }
};
@@ -1849,6 +1852,7 @@ constexpr flag_def media_pad_flag_def[] = {
{ MEDIA_PAD_FL_SINK, "MEDIA_PAD_FL_SINK" },
{ MEDIA_PAD_FL_SOURCE, "MEDIA_PAD_FL_SOURCE" },
{ MEDIA_PAD_FL_MUST_CONNECT, "MEDIA_PAD_FL_MUST_CONNECT" },
+ { MEDIA_PAD_FL_INTERNAL, "MEDIA_PAD_FL_INTERNAL" },
{ 0, "" }
};
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [v4l-utils] [PATCH 4/8] utils: media-ctl: Support changed routing API
2024-04-02 0:00 [v4l-utils] [PATCH 0/8] Support for the generic line-based metadata support Laurent Pinchart
` (2 preceding siblings ...)
2024-04-02 0:00 ` [v4l-utils] [PATCH 3/8] v4l-utils: sync-with-kernel Laurent Pinchart
@ 2024-04-02 0:00 ` Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 5/8] utils: media-ctl: Also print INTERNAL pad flag Laurent Pinchart
` (3 subsequent siblings)
7 siblings, 0 replies; 18+ messages in thread
From: Laurent Pinchart @ 2024-04-02 0:00 UTC (permalink / raw)
To: linux-media
Cc: Sakari Ailus, Tomi Valkeinen, Hans Verkuil, Gregor Jasny,
Sakari Ailus
From: Sakari Ailus <sakari.ailus@linux.intel.com>
Set len_routes of struct v4l2_subdev_routing. ENOSPC error code is no
longer used, i.e. having room for fewer routes than exist in the
configuration is not considered an error anymore.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
utils/media-ctl/libv4l2subdev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index c614f4a2e0fd..e0df686e01c7 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -258,7 +258,7 @@ int v4l2_subdev_get_routing(struct media_entity *entity,
}
ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_ROUTING, &routing);
- if (ret == -1 && errno != ENOSPC)
+ if (ret == -1)
return -errno;
if (!routing.num_routes) {
@@ -272,6 +272,7 @@ int v4l2_subdev_get_routing(struct media_entity *entity,
return -ENOMEM;
routing.routes = (uintptr_t)r;
+ routing.len_routes = routing.num_routes;
ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_ROUTING, &routing);
if (ret) {
free(r);
@@ -292,6 +293,7 @@ int v4l2_subdev_set_routing(struct media_entity *entity,
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
.routes = (uintptr_t)routes,
.num_routes = num_routes,
+ .len_routes = num_routes,
};
int ret;
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [v4l-utils] [PATCH 5/8] utils: media-ctl: Also print INTERNAL pad flag
2024-04-02 0:00 [v4l-utils] [PATCH 0/8] Support for the generic line-based metadata support Laurent Pinchart
` (3 preceding siblings ...)
2024-04-02 0:00 ` [v4l-utils] [PATCH 4/8] utils: media-ctl: Support changed routing API Laurent Pinchart
@ 2024-04-02 0:00 ` Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 6/8] v4l2-compliance: Support the changed routing API Laurent Pinchart
` (2 subsequent siblings)
7 siblings, 0 replies; 18+ messages in thread
From: Laurent Pinchart @ 2024-04-02 0:00 UTC (permalink / raw)
To: linux-media
Cc: Sakari Ailus, Tomi Valkeinen, Hans Verkuil, Gregor Jasny,
Sakari Ailus
From: Sakari Ailus <sakari.ailus@linux.intel.com>
Print INTERNAL pad flag for each pad.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
utils/media-ctl/media-ctl.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/utils/media-ctl/media-ctl.c b/utils/media-ctl/media-ctl.c
index 1b40552253f1..2a7d994a7b74 100644
--- a/utils/media-ctl/media-ctl.c
+++ b/utils/media-ctl/media-ctl.c
@@ -566,7 +566,7 @@ static void media_print_topology_text_entity(struct media_device *media,
for (j = 0; j < info->pads; j++) {
const struct media_pad *pad = media_entity_get_pad(entity, j);
- printf("\tpad%u: %s%s%s%s%s\n", j,
+ printf("\tpad%u: %s%s%s%s%s%s%s\n", j,
pad->flags & MEDIA_PAD_FL_SINK ? "Sink" : "",
comma(MEDIA_PAD_FL_SOURCE, MEDIA_PAD_FL_SINK,
pad->flags),
@@ -574,7 +574,11 @@ static void media_print_topology_text_entity(struct media_device *media,
comma(MEDIA_PAD_FL_MUST_CONNECT,
MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE,
pad->flags),
- pad->flags & MEDIA_PAD_FL_MUST_CONNECT ? "Must connect" : "");
+ pad->flags & MEDIA_PAD_FL_MUST_CONNECT ? "Must connect" : "",
+ comma(MEDIA_PAD_FL_INTERNAL,
+ MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE |
+ MEDIA_PAD_FL_MUST_CONNECT, pad->flags),
+ pad->flags & MEDIA_PAD_FL_INTERNAL ? "Internal" : "");
media_print_pad_text(entity, pad, routes, num_routes);
for (k = 0; k < num_links; k++) {
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [v4l-utils] [PATCH 6/8] v4l2-compliance: Support the changed routing API
2024-04-02 0:00 [v4l-utils] [PATCH 0/8] Support for the generic line-based metadata support Laurent Pinchart
` (4 preceding siblings ...)
2024-04-02 0:00 ` [v4l-utils] [PATCH 5/8] utils: media-ctl: Also print INTERNAL pad flag Laurent Pinchart
@ 2024-04-02 0:00 ` Laurent Pinchart
2024-04-02 10:54 ` Tomi Valkeinen
2024-04-02 0:00 ` [v4l-utils] [PATCH 7/8] v4l2-compliance: Add tests for V4L2_FMT_FLAG_META_LINE_BASED flag Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 8/8] v4l2-compliance: Test IMMUTABLE route flag Laurent Pinchart
7 siblings, 1 reply; 18+ messages in thread
From: Laurent Pinchart @ 2024-04-02 0:00 UTC (permalink / raw)
To: linux-media; +Cc: Sakari Ailus, Tomi Valkeinen, Hans Verkuil, Gregor Jasny
Set len_routes of struct v4l2_subdev_routing. ENOSPC error code is no
longer used, i.e. having room for fewer routes than exist in the
configuration is not considered an error anymore.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
utils/v4l2-compliance/v4l2-compliance.cpp | 12 +++++++-----
utils/v4l2-compliance/v4l2-test-subdevs.cpp | 19 +++++++++++--------
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index 2cf979096bd0..72fe0bd778ab 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -1272,15 +1272,17 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
for (unsigned which = V4L2_SUBDEV_FORMAT_TRY;
which <= V4L2_SUBDEV_FORMAT_ACTIVE; which++) {
+ struct v4l2_subdev_routing &routing = sd_routing[which];
- sd_routing[which].which = which;
- sd_routing[which].routes = (__u64)sd_routes[which];
- sd_routing[which].num_routes = NUM_ROUTES_MAX;
+ routing.which = which;
+ routing.routes = (__u64)sd_routes[which];
+ routing.len_routes = NUM_ROUTES_MAX;
+ routing.num_routes = 0;
- ret = doioctl(&node, VIDIOC_SUBDEV_G_ROUTING, &sd_routing[which]);
+ ret = doioctl(&node, VIDIOC_SUBDEV_G_ROUTING, &routing);
if (ret) {
fail("VIDIOC_SUBDEV_G_ROUTING: failed to get routing\n");
- sd_routing[which].num_routes = 0;
+ routing.num_routes = 0;
}
}
}
diff --git a/utils/v4l2-compliance/v4l2-test-subdevs.cpp b/utils/v4l2-compliance/v4l2-test-subdevs.cpp
index ebca1b94f5c0..714857021fc6 100644
--- a/utils/v4l2-compliance/v4l2-test-subdevs.cpp
+++ b/utils/v4l2-compliance/v4l2-test-subdevs.cpp
@@ -587,17 +587,15 @@ int testSubDevRouting(struct node *node, unsigned which)
routing.which = which;
routing.routes = (__u64)&routes;
+ routing.len_routes = 0;
routing.num_routes = 0;
memset(routing.reserved, 0xff, sizeof(routing.reserved));
- /*
- * First test that G_ROUTING either returns success, or ENOSPC and
- * updates num_routes.
- */
+ /* First test that G_ROUTING returns success even when len_routes is 0. */
ret = doioctl(node, VIDIOC_SUBDEV_G_ROUTING, &routing);
- fail_on_test(ret && ret != ENOSPC);
- fail_on_test(ret == ENOSPC && routing.num_routes == 0);
+ fail_on_test(ret);
+ fail_on_test(routing.num_routes > NUM_ROUTES_MAX);
fail_on_test(check_0(routing.reserved, sizeof(routing.reserved)));
if (!routing.num_routes)
@@ -609,7 +607,8 @@ int testSubDevRouting(struct node *node, unsigned which)
*/
uint32_t num_routes = routing.num_routes;
- routing.num_routes = num_routes + 1;
+ routing.len_routes = NUM_ROUTES_MAX;
+ routing.num_routes = 0;
fail_on_test(doioctl(node, VIDIOC_SUBDEV_G_ROUTING, &routing));
fail_on_test(routing.num_routes != num_routes);
@@ -633,10 +632,14 @@ int testSubDevRouting(struct node *node, unsigned which)
}
}
- /* Set the same routes back, which should always succeed. */
+ /*
+ * Set the same routes back, which should always succeed and report the
+ * same number of routes.
+ */
memset(routing.reserved, 0xff, sizeof(routing.reserved));
fail_on_test(doioctl(node, VIDIOC_SUBDEV_S_ROUTING, &routing));
+ fail_on_test(routing.num_routes != num_routes);
fail_on_test(check_0(routing.reserved, sizeof(routing.reserved)));
/* Test setting invalid pads */
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [v4l-utils] [PATCH 7/8] v4l2-compliance: Add tests for V4L2_FMT_FLAG_META_LINE_BASED flag
2024-04-02 0:00 [v4l-utils] [PATCH 0/8] Support for the generic line-based metadata support Laurent Pinchart
` (5 preceding siblings ...)
2024-04-02 0:00 ` [v4l-utils] [PATCH 6/8] v4l2-compliance: Support the changed routing API Laurent Pinchart
@ 2024-04-02 0:00 ` Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 8/8] v4l2-compliance: Test IMMUTABLE route flag Laurent Pinchart
7 siblings, 0 replies; 18+ messages in thread
From: Laurent Pinchart @ 2024-04-02 0:00 UTC (permalink / raw)
To: linux-media; +Cc: Sakari Ailus, Tomi Valkeinen, Hans Verkuil, Gregor Jasny
The metadata API supports a new flag, V4L2_FMT_FLAG_META_LINE_BASED. It
can be set for metadata formats only, and is the only flag that can be
set for metadata formats. When set, the width, height and bytesperline
fields must not be zero. Add corresponding tests.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
utils/v4l2-compliance/v4l2-test-formats.cpp | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp
index 423567fe573b..5507e45ef3dd 100644
--- a/utils/v4l2-compliance/v4l2-test-formats.cpp
+++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
@@ -281,12 +281,23 @@ static int testEnumFormatsType(struct node *node, unsigned type)
V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL |
V4L2_FMT_FLAG_CSC_COLORSPACE |
V4L2_FMT_FLAG_CSC_YCBCR_ENC | V4L2_FMT_FLAG_CSC_HSV_ENC |
- V4L2_FMT_FLAG_CSC_QUANTIZATION | V4L2_FMT_FLAG_CSC_XFER_FUNC))
+ V4L2_FMT_FLAG_CSC_QUANTIZATION | V4L2_FMT_FLAG_CSC_XFER_FUNC |
+ V4L2_FMT_FLAG_META_LINE_BASED))
return fail("unknown flag %08x returned\n", fmtdesc.flags);
if (!(fmtdesc.flags & V4L2_FMT_FLAG_COMPRESSED))
fail_on_test(fmtdesc.flags & (V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM |
V4L2_FMT_FLAG_DYN_RESOLUTION |
V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL));
+
+ // Checks for metadata formats.
+ // The META_LINE_BASED flag can be set for metadata formats only.
+ if (type == V4L2_BUF_TYPE_META_OUTPUT || type == V4L2_BUF_TYPE_META_CAPTURE)
+ fail_on_test(fmtdesc.flags & ~V4L2_FMT_FLAG_META_LINE_BASED);
+ // Only the META_LINE_BASED flag is valid for metadata formats.
+ if (fmtdesc.flags & V4L2_FMT_FLAG_META_LINE_BASED)
+ fail_on_test(type != V4L2_BUF_TYPE_META_OUTPUT &&
+ type != V4L2_BUF_TYPE_META_CAPTURE);
+
ret = testEnumFrameSizes(node, fmtdesc.pixelformat);
if (ret)
fail_on_test(node->codec_mask & STATEFUL_ENCODER);
@@ -590,6 +601,10 @@ static int testFormatsType(struct node *node, int ret, unsigned type, struct v4
return fail("dataformat %08x (%s) for buftype %d not reported by ENUM_FMT\n",
meta.dataformat, fcc2s(meta.dataformat).c_str(), type);
fail_on_test(meta.buffersize == 0);
+ if (map.at(meta.dataformat) & V4L2_FMT_FLAG_META_LINE_BASED) {
+ fail_on_test(!meta.width || !meta.height);
+ fail_on_test(!meta.bytesperline);
+ }
break;
case V4L2_BUF_TYPE_PRIVATE:
break;
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [v4l-utils] [PATCH 8/8] v4l2-compliance: Test IMMUTABLE route flag
2024-04-02 0:00 [v4l-utils] [PATCH 0/8] Support for the generic line-based metadata support Laurent Pinchart
` (6 preceding siblings ...)
2024-04-02 0:00 ` [v4l-utils] [PATCH 7/8] v4l2-compliance: Add tests for V4L2_FMT_FLAG_META_LINE_BASED flag Laurent Pinchart
@ 2024-04-02 0:00 ` Laurent Pinchart
7 siblings, 0 replies; 18+ messages in thread
From: Laurent Pinchart @ 2024-04-02 0:00 UTC (permalink / raw)
To: linux-media; +Cc: Sakari Ailus, Tomi Valkeinen, Hans Verkuil, Gregor Jasny
Accept the new V4L2_SUBDEV_ROUTE_FL_IMMUTABLE route flag when testing
routing, and verify that immutable routes are active as mandated by the
routing API specification.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
utils/v4l2-compliance/v4l2-test-subdevs.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/utils/v4l2-compliance/v4l2-test-subdevs.cpp b/utils/v4l2-compliance/v4l2-test-subdevs.cpp
index 714857021fc6..e26d09ed8586 100644
--- a/utils/v4l2-compliance/v4l2-test-subdevs.cpp
+++ b/utils/v4l2-compliance/v4l2-test-subdevs.cpp
@@ -579,7 +579,8 @@ int testSubDevSelection(struct node *node, unsigned which, unsigned pad, unsigne
int testSubDevRouting(struct node *node, unsigned which)
{
- const uint32_t all_route_flags_mask = V4L2_SUBDEV_ROUTE_FL_ACTIVE;
+ const uint32_t all_route_flags_mask = V4L2_SUBDEV_ROUTE_FL_ACTIVE
+ | V4L2_SUBDEV_ROUTE_FL_IMMUTABLE;
struct v4l2_subdev_routing routing = {};
struct v4l2_subdev_route routes[NUM_ROUTES_MAX] = {};
unsigned int i;
@@ -629,6 +630,8 @@ int testSubDevRouting(struct node *node, unsigned which)
fail_on_test(!(sink->flags & MEDIA_PAD_FL_SINK));
fail_on_test(!(source->flags & MEDIA_PAD_FL_SOURCE));
fail_on_test(route->flags & ~all_route_flags_mask);
+ fail_on_test((route->flags & V4L2_SUBDEV_ROUTE_FL_IMMUTABLE) &&
+ !(route->flags & V4L2_SUBDEV_ROUTE_FL_ACTIVE));
}
}
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [v4l-utils] [PATCH 6/8] v4l2-compliance: Support the changed routing API
2024-04-02 0:00 ` [v4l-utils] [PATCH 6/8] v4l2-compliance: Support the changed routing API Laurent Pinchart
@ 2024-04-02 10:54 ` Tomi Valkeinen
2024-04-05 6:37 ` Sakari Ailus
0 siblings, 1 reply; 18+ messages in thread
From: Tomi Valkeinen @ 2024-04-02 10:54 UTC (permalink / raw)
To: Laurent Pinchart, linux-media; +Cc: Sakari Ailus, Hans Verkuil, Gregor Jasny
On 02/04/2024 03:00, Laurent Pinchart wrote:
> Set len_routes of struct v4l2_subdev_routing. ENOSPC error code is no
> longer used, i.e. having room for fewer routes than exist in the
> configuration is not considered an error anymore.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> utils/v4l2-compliance/v4l2-compliance.cpp | 12 +++++++-----
> utils/v4l2-compliance/v4l2-test-subdevs.cpp | 19 +++++++++++--------
> 2 files changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
> index 2cf979096bd0..72fe0bd778ab 100644
> --- a/utils/v4l2-compliance/v4l2-compliance.cpp
> +++ b/utils/v4l2-compliance/v4l2-compliance.cpp
> @@ -1272,15 +1272,17 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
>
> for (unsigned which = V4L2_SUBDEV_FORMAT_TRY;
> which <= V4L2_SUBDEV_FORMAT_ACTIVE; which++) {
> + struct v4l2_subdev_routing &routing = sd_routing[which];
>
> - sd_routing[which].which = which;
> - sd_routing[which].routes = (__u64)sd_routes[which];
> - sd_routing[which].num_routes = NUM_ROUTES_MAX;
> + routing.which = which;
> + routing.routes = (__u64)sd_routes[which];
> + routing.len_routes = NUM_ROUTES_MAX;
> + routing.num_routes = 0;
Not part of this series, but something I noticed while testing. Our routing code is broken for 32-bit userspace: we convert the routes pointer to u64, which ends up sign extending the address.
Interestingly gcc gives "cast from pointer to integer of different size [-Wpointer-to-int-cast]", but g++ doesn't, and "command-line option ‘-Wpointer-to-int-cast’ is valid for C/ObjC but not for C++". So we don't get any warnings for the bugs.
With a quick look I found these places to fix. Will you add a patch to your series, or should I send this as a separate one?
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index 72fe0bd7..a969b69c 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -1275,7 +1275,7 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
struct v4l2_subdev_routing &routing = sd_routing[which];
routing.which = which;
- routing.routes = (__u64)sd_routes[which];
+ routing.routes = (__u64)(uintptr_t)sd_routes[which];
routing.len_routes = NUM_ROUTES_MAX;
routing.num_routes = 0;
@@ -1307,7 +1307,7 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
routes = sd_routes[which];
} else {
dummy_routing.num_routes = 1;
- dummy_routing.routes = (__u64)&dummy_routes;
+ dummy_routing.routes = (__u64)(uintptr_t)&dummy_routes;
dummy_routes[0].source_pad = pad;
dummy_routes[0].source_stream = 0;
dummy_routes[0].sink_pad = pad;
diff --git a/utils/v4l2-compliance/v4l2-test-subdevs.cpp b/utils/v4l2-compliance/v4l2-test-subdevs.cpp
index e26d09ed..21d7776a 100644
--- a/utils/v4l2-compliance/v4l2-test-subdevs.cpp
+++ b/utils/v4l2-compliance/v4l2-test-subdevs.cpp
@@ -587,7 +587,7 @@ int testSubDevRouting(struct node *node, unsigned which)
int ret;
routing.which = which;
- routing.routes = (__u64)&routes;
+ routing.routes = (__u64)(uintptr_t)&routes;
routing.len_routes = 0;
routing.num_routes = 0;
memset(routing.reserved, 0xff, sizeof(routing.reserved));
Tomi
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags
2024-04-02 0:00 ` [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags Laurent Pinchart
@ 2024-04-03 8:40 ` Laurent Pinchart
2024-04-03 8:43 ` Tomi Valkeinen
0 siblings, 1 reply; 18+ messages in thread
From: Laurent Pinchart @ 2024-04-03 8:40 UTC (permalink / raw)
To: linux-media
Cc: Sakari Ailus, Tomi Valkeinen, Hans Verkuil, Gregor Jasny,
Sakari Ailus
Hi Sakari,
Thank you for the patch.
On Tue, Apr 02, 2024 at 03:00:26AM +0300, Laurent Pinchart wrote:
> From: Sakari Ailus <sakari.ailus@linux.intel.com>
>
> Print the MUST_CONNECT pad flag for each pad.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> utils/media-ctl/media-ctl.c | 50 +++++++++++++++++++++----------------
> 1 file changed, 28 insertions(+), 22 deletions(-)
>
> diff --git a/utils/media-ctl/media-ctl.c b/utils/media-ctl/media-ctl.c
> index 2081f111f2db..1b40552253f1 100644
> --- a/utils/media-ctl/media-ctl.c
> +++ b/utils/media-ctl/media-ctl.c
> @@ -368,26 +368,6 @@ static const char *media_entity_subtype_to_string(unsigned type)
> }
> }
>
> -static const char *media_pad_type_to_string(unsigned flag)
> -{
> - static const struct {
> - __u32 flag;
> - const char *name;
> - } flags[] = {
> - { MEDIA_PAD_FL_SINK, "Sink" },
> - { MEDIA_PAD_FL_SOURCE, "Source" },
> - };
> -
> - unsigned int i;
> -
> - for (i = 0; i < ARRAY_SIZE(flags); i++) {
> - if (flags[i].flag & flag)
> - return flags[i].name;
> - }
> -
> - return "Unknown";
> -}
> -
> static void media_print_topology_dot(struct media_device *media)
> {
> unsigned int nents = media_get_entities_count(media);
> @@ -525,6 +505,25 @@ static void media_print_pad_text(struct media_entity *entity,
> v4l2_subdev_print_subdev_dv(entity);
> }
>
> +static unsigned int weight(uint32_t word)
> +{
> + unsigned int w = 0, i;
> +
> + for (i = 0; i < sizeof(word) << 3; i++, word >>= 1)
> + w += word & 1U;
> +
> + return w;
> +}
> +
> +static const char *comma(uint32_t flag, uint32_t prev_flags, uint32_t flags)
> +{
> + static const char *empty = "", *comma = ", ";
> + if (!(flag & flags))
> + return empty;
> +
> + return weight(prev_flags & flags) ? comma : empty;
Unless I'm mistaken, we can write this
return prev_flags & flags ? comma : empty;
and drop the weight function.
> +}
> +
> static void media_print_topology_text_entity(struct media_device *media,
> struct media_entity *entity)
> {
> @@ -567,8 +566,15 @@ static void media_print_topology_text_entity(struct media_device *media,
> for (j = 0; j < info->pads; j++) {
> const struct media_pad *pad = media_entity_get_pad(entity, j);
>
> - printf("\tpad%u: %s\n", j, media_pad_type_to_string(pad->flags));
> -
> + printf("\tpad%u: %s%s%s%s%s\n", j,
> + pad->flags & MEDIA_PAD_FL_SINK ? "Sink" : "",
> + comma(MEDIA_PAD_FL_SOURCE, MEDIA_PAD_FL_SINK,
> + pad->flags),
> + pad->flags & MEDIA_PAD_FL_SOURCE ? "Source" : "",
> + comma(MEDIA_PAD_FL_MUST_CONNECT,
> + MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE,
> + pad->flags),
> + pad->flags & MEDIA_PAD_FL_MUST_CONNECT ? "Must connect" : "");
To be honest, this looks overly complicated. How about printing the
flags with a loop ?
> media_print_pad_text(entity, pad, routes, num_routes);
>
> for (k = 0; k < num_links; k++) {
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags
2024-04-03 8:40 ` Laurent Pinchart
@ 2024-04-03 8:43 ` Tomi Valkeinen
2024-04-03 8:56 ` Hans Verkuil
0 siblings, 1 reply; 18+ messages in thread
From: Tomi Valkeinen @ 2024-04-03 8:43 UTC (permalink / raw)
To: Laurent Pinchart, linux-media
Cc: Sakari Ailus, Hans Verkuil, Gregor Jasny, Sakari Ailus
On 03/04/2024 11:40, Laurent Pinchart wrote:
> Hi Sakari,
>
> Thank you for the patch.
>
> On Tue, Apr 02, 2024 at 03:00:26AM +0300, Laurent Pinchart wrote:
>> From: Sakari Ailus <sakari.ailus@linux.intel.com>
>>
>> Print the MUST_CONNECT pad flag for each pad.
>>
>> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>> ---
>> utils/media-ctl/media-ctl.c | 50 +++++++++++++++++++++----------------
>> 1 file changed, 28 insertions(+), 22 deletions(-)
>>
>> diff --git a/utils/media-ctl/media-ctl.c b/utils/media-ctl/media-ctl.c
>> index 2081f111f2db..1b40552253f1 100644
>> --- a/utils/media-ctl/media-ctl.c
>> +++ b/utils/media-ctl/media-ctl.c
>> @@ -368,26 +368,6 @@ static const char *media_entity_subtype_to_string(unsigned type)
>> }
>> }
>>
>> -static const char *media_pad_type_to_string(unsigned flag)
>> -{
>> - static const struct {
>> - __u32 flag;
>> - const char *name;
>> - } flags[] = {
>> - { MEDIA_PAD_FL_SINK, "Sink" },
>> - { MEDIA_PAD_FL_SOURCE, "Source" },
>> - };
>> -
>> - unsigned int i;
>> -
>> - for (i = 0; i < ARRAY_SIZE(flags); i++) {
>> - if (flags[i].flag & flag)
>> - return flags[i].name;
>> - }
>> -
>> - return "Unknown";
>> -}
>> -
>> static void media_print_topology_dot(struct media_device *media)
>> {
>> unsigned int nents = media_get_entities_count(media);
>> @@ -525,6 +505,25 @@ static void media_print_pad_text(struct media_entity *entity,
>> v4l2_subdev_print_subdev_dv(entity);
>> }
>>
>> +static unsigned int weight(uint32_t word)
>> +{
>> + unsigned int w = 0, i;
>> +
>> + for (i = 0; i < sizeof(word) << 3; i++, word >>= 1)
>> + w += word & 1U;
>> +
>> + return w;
>> +}
>> +
>> +static const char *comma(uint32_t flag, uint32_t prev_flags, uint32_t flags)
>> +{
>> + static const char *empty = "", *comma = ", ";
>> + if (!(flag & flags))
>> + return empty;
>> +
>> + return weight(prev_flags & flags) ? comma : empty;
>
> Unless I'm mistaken, we can write this
>
> return prev_flags & flags ? comma : empty;
>
> and drop the weight function.
>
>> +}
>> +
>> static void media_print_topology_text_entity(struct media_device *media,
>> struct media_entity *entity)
>> {
>> @@ -567,8 +566,15 @@ static void media_print_topology_text_entity(struct media_device *media,
>> for (j = 0; j < info->pads; j++) {
>> const struct media_pad *pad = media_entity_get_pad(entity, j);
>>
>> - printf("\tpad%u: %s\n", j, media_pad_type_to_string(pad->flags));
>> -
>> + printf("\tpad%u: %s%s%s%s%s\n", j,
>> + pad->flags & MEDIA_PAD_FL_SINK ? "Sink" : "",
>> + comma(MEDIA_PAD_FL_SOURCE, MEDIA_PAD_FL_SINK,
>> + pad->flags),
>> + pad->flags & MEDIA_PAD_FL_SOURCE ? "Source" : "",
>> + comma(MEDIA_PAD_FL_MUST_CONNECT,
>> + MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE,
>> + pad->flags),
>> + pad->flags & MEDIA_PAD_FL_MUST_CONNECT ? "Must connect" : "");
>
> To be honest, this looks overly complicated. How about printing the
> flags with a loop ?
I was just about to reply that this looks a bit too "smart" to me... I'd
prefer just a simple loop here for readability's and maintainability's
sake, even if it's not as optimal.
Tomi
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [v4l-utils] [PATCH 2/8] v4l2-compliance: Constify pointers and references in formats tests
2024-04-02 0:00 ` [v4l-utils] [PATCH 2/8] v4l2-compliance: Constify pointers and references in formats tests Laurent Pinchart
@ 2024-04-03 8:44 ` Tomi Valkeinen
2024-04-03 8:46 ` Hans Verkuil
1 sibling, 0 replies; 18+ messages in thread
From: Tomi Valkeinen @ 2024-04-03 8:44 UTC (permalink / raw)
To: Laurent Pinchart, linux-media; +Cc: Sakari Ailus, Hans Verkuil, Gregor Jasny
On 02/04/2024 03:00, Laurent Pinchart wrote:
> Multiple variables point to or reference data that never needs to be
> modified. Make them const.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> utils/v4l2-compliance/v4l2-test-formats.cpp | 30 ++++++++++-----------
> 1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp
> index 8a16613c3097..423567fe573b 100644
> --- a/utils/v4l2-compliance/v4l2-test-formats.cpp
> +++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
> @@ -49,7 +49,7 @@ static int testEnumFrameIntervals(struct node *node, __u32 pixfmt,
> __u32 w, __u32 h, __u32 type)
> {
> struct v4l2_frmivalenum frmival;
> - struct v4l2_frmival_stepwise *sw = &frmival.stepwise;
> + const struct v4l2_frmival_stepwise *sw = &frmival.stepwise;
> bool found_stepwise = false;
> unsigned f = 0;
> int ret;
> @@ -129,7 +129,7 @@ static int testEnumFrameIntervals(struct node *node, __u32 pixfmt,
> static int testEnumFrameSizes(struct node *node, __u32 pixfmt)
> {
> struct v4l2_frmsizeenum frmsize;
> - struct v4l2_frmsize_stepwise *sw = &frmsize.stepwise;
> + const struct v4l2_frmsize_stepwise *sw = &frmsize.stepwise;
> bool found_stepwise = false;
> __u64 cookie;
> unsigned f = 0;
> @@ -438,15 +438,15 @@ static void createInvalidFmt(struct v4l2_format &fmt, struct v4l2_clip &clip, un
>
> static int testFormatsType(struct node *node, int ret, unsigned type, struct v4l2_format &fmt, bool have_clip = false)
> {
> - pixfmt_map &map = node->buftype_pixfmts[type];
> - pixfmt_map *map_splane;
> - struct v4l2_pix_format &pix = fmt.fmt.pix;
> - struct v4l2_pix_format_mplane &pix_mp = fmt.fmt.pix_mp;
> - struct v4l2_window &win = fmt.fmt.win;
> - struct v4l2_vbi_format &vbi = fmt.fmt.vbi;
> - 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;
> + const pixfmt_map &map = node->buftype_pixfmts[type];
> + const pixfmt_map *map_splane;
> + const struct v4l2_pix_format &pix = fmt.fmt.pix;
> + const struct v4l2_pix_format_mplane &pix_mp = fmt.fmt.pix_mp;
> + const struct v4l2_window &win = fmt.fmt.win;
> + const struct v4l2_vbi_format &vbi = fmt.fmt.vbi;
> + const struct v4l2_sliced_vbi_format &sliced = fmt.fmt.sliced;
> + const struct v4l2_sdr_format &sdr = fmt.fmt.sdr;
> + const struct v4l2_meta_format &meta = fmt.fmt.meta;
> unsigned min_data_samples;
> unsigned min_sampling_rate;
> v4l2_std_id std;
> @@ -497,7 +497,7 @@ static int testFormatsType(struct node *node, int ret, unsigned type, struct v4
> return fail("pix_mp.reserved not zeroed\n");
> fail_on_test(pix_mp.num_planes == 0 || pix_mp.num_planes >= VIDEO_MAX_PLANES);
> for (int i = 0; i < pix_mp.num_planes; i++) {
> - struct v4l2_plane_pix_format &pfmt = pix_mp.plane_fmt[i];
> + const struct v4l2_plane_pix_format &pfmt = pix_mp.plane_fmt[i];
>
> ret = check_0(pfmt.reserved, sizeof(pfmt.reserved));
> if (ret)
> @@ -559,7 +559,7 @@ static int testFormatsType(struct node *node, int ret, unsigned type, struct v4
> if (have_clip)
> fail_on_test(!win.clipcount && (node->fbuf_caps & V4L2_FBUF_CAP_LIST_CLIPPING));
> if (win.clipcount) {
> - struct v4l2_rect *r = &win.clips->c;
> + const struct v4l2_rect *r = &win.clips->c;
> struct v4l2_framebuffer fb;
>
> fail_on_test(doioctl(node, VIDIOC_G_FBUF, &fb));
> @@ -1281,8 +1281,8 @@ int testSlicedVBICap(struct node *node)
> static int testParmStruct(struct node *node, struct v4l2_streamparm &parm)
> {
> bool is_stateful_enc = node->codec_mask & STATEFUL_ENCODER;
> - struct v4l2_captureparm *cap = &parm.parm.capture;
> - struct v4l2_outputparm *out = &parm.parm.output;
> + const struct v4l2_captureparm *cap = &parm.parm.capture;
> + const struct v4l2_outputparm *out = &parm.parm.output;
> int ret;
>
> switch (parm.type) {
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tomi
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [v4l-utils] [PATCH 2/8] v4l2-compliance: Constify pointers and references in formats tests
2024-04-02 0:00 ` [v4l-utils] [PATCH 2/8] v4l2-compliance: Constify pointers and references in formats tests Laurent Pinchart
2024-04-03 8:44 ` Tomi Valkeinen
@ 2024-04-03 8:46 ` Hans Verkuil
1 sibling, 0 replies; 18+ messages in thread
From: Hans Verkuil @ 2024-04-03 8:46 UTC (permalink / raw)
To: Laurent Pinchart, linux-media; +Cc: Sakari Ailus, Tomi Valkeinen, Gregor Jasny
On 02/04/2024 02:00, Laurent Pinchart wrote:
> Multiple variables point to or reference data that never needs to be
> modified. Make them const.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
> utils/v4l2-compliance/v4l2-test-formats.cpp | 30 ++++++++++-----------
> 1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp
> index 8a16613c3097..423567fe573b 100644
> --- a/utils/v4l2-compliance/v4l2-test-formats.cpp
> +++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
> @@ -49,7 +49,7 @@ static int testEnumFrameIntervals(struct node *node, __u32 pixfmt,
> __u32 w, __u32 h, __u32 type)
> {
> struct v4l2_frmivalenum frmival;
> - struct v4l2_frmival_stepwise *sw = &frmival.stepwise;
> + const struct v4l2_frmival_stepwise *sw = &frmival.stepwise;
> bool found_stepwise = false;
> unsigned f = 0;
> int ret;
> @@ -129,7 +129,7 @@ static int testEnumFrameIntervals(struct node *node, __u32 pixfmt,
> static int testEnumFrameSizes(struct node *node, __u32 pixfmt)
> {
> struct v4l2_frmsizeenum frmsize;
> - struct v4l2_frmsize_stepwise *sw = &frmsize.stepwise;
> + const struct v4l2_frmsize_stepwise *sw = &frmsize.stepwise;
> bool found_stepwise = false;
> __u64 cookie;
> unsigned f = 0;
> @@ -438,15 +438,15 @@ static void createInvalidFmt(struct v4l2_format &fmt, struct v4l2_clip &clip, un
>
> static int testFormatsType(struct node *node, int ret, unsigned type, struct v4l2_format &fmt, bool have_clip = false)
> {
> - pixfmt_map &map = node->buftype_pixfmts[type];
> - pixfmt_map *map_splane;
> - struct v4l2_pix_format &pix = fmt.fmt.pix;
> - struct v4l2_pix_format_mplane &pix_mp = fmt.fmt.pix_mp;
> - struct v4l2_window &win = fmt.fmt.win;
> - struct v4l2_vbi_format &vbi = fmt.fmt.vbi;
> - 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;
> + const pixfmt_map &map = node->buftype_pixfmts[type];
> + const pixfmt_map *map_splane;
> + const struct v4l2_pix_format &pix = fmt.fmt.pix;
> + const struct v4l2_pix_format_mplane &pix_mp = fmt.fmt.pix_mp;
> + const struct v4l2_window &win = fmt.fmt.win;
> + const struct v4l2_vbi_format &vbi = fmt.fmt.vbi;
> + const struct v4l2_sliced_vbi_format &sliced = fmt.fmt.sliced;
> + const struct v4l2_sdr_format &sdr = fmt.fmt.sdr;
> + const struct v4l2_meta_format &meta = fmt.fmt.meta;
> unsigned min_data_samples;
> unsigned min_sampling_rate;
> v4l2_std_id std;
> @@ -497,7 +497,7 @@ static int testFormatsType(struct node *node, int ret, unsigned type, struct v4
> return fail("pix_mp.reserved not zeroed\n");
> fail_on_test(pix_mp.num_planes == 0 || pix_mp.num_planes >= VIDEO_MAX_PLANES);
> for (int i = 0; i < pix_mp.num_planes; i++) {
> - struct v4l2_plane_pix_format &pfmt = pix_mp.plane_fmt[i];
> + const struct v4l2_plane_pix_format &pfmt = pix_mp.plane_fmt[i];
>
> ret = check_0(pfmt.reserved, sizeof(pfmt.reserved));
> if (ret)
> @@ -559,7 +559,7 @@ static int testFormatsType(struct node *node, int ret, unsigned type, struct v4
> if (have_clip)
> fail_on_test(!win.clipcount && (node->fbuf_caps & V4L2_FBUF_CAP_LIST_CLIPPING));
> if (win.clipcount) {
> - struct v4l2_rect *r = &win.clips->c;
> + const struct v4l2_rect *r = &win.clips->c;
> struct v4l2_framebuffer fb;
>
> fail_on_test(doioctl(node, VIDIOC_G_FBUF, &fb));
> @@ -1281,8 +1281,8 @@ int testSlicedVBICap(struct node *node)
> static int testParmStruct(struct node *node, struct v4l2_streamparm &parm)
> {
> bool is_stateful_enc = node->codec_mask & STATEFUL_ENCODER;
> - struct v4l2_captureparm *cap = &parm.parm.capture;
> - struct v4l2_outputparm *out = &parm.parm.output;
> + const struct v4l2_captureparm *cap = &parm.parm.capture;
> + const struct v4l2_outputparm *out = &parm.parm.output;
> int ret;
>
> switch (parm.type) {
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags
2024-04-03 8:43 ` Tomi Valkeinen
@ 2024-04-03 8:56 ` Hans Verkuil
2024-04-04 20:17 ` Sakari Ailus
0 siblings, 1 reply; 18+ messages in thread
From: Hans Verkuil @ 2024-04-03 8:56 UTC (permalink / raw)
To: Tomi Valkeinen, Laurent Pinchart, linux-media
Cc: Sakari Ailus, Gregor Jasny, Sakari Ailus
On 03/04/2024 10:43, Tomi Valkeinen wrote:
> On 03/04/2024 11:40, Laurent Pinchart wrote:
>> Hi Sakari,
>>
>> Thank you for the patch.
>>
>> On Tue, Apr 02, 2024 at 03:00:26AM +0300, Laurent Pinchart wrote:
>>> From: Sakari Ailus <sakari.ailus@linux.intel.com>
>>>
>>> Print the MUST_CONNECT pad flag for each pad.
>>>
>>> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>>> ---
>>> utils/media-ctl/media-ctl.c | 50 +++++++++++++++++++++----------------
>>> 1 file changed, 28 insertions(+), 22 deletions(-)
>>>
>>> diff --git a/utils/media-ctl/media-ctl.c b/utils/media-ctl/media-ctl.c
>>> index 2081f111f2db..1b40552253f1 100644
>>> --- a/utils/media-ctl/media-ctl.c
>>> +++ b/utils/media-ctl/media-ctl.c
>>> @@ -368,26 +368,6 @@ static const char *media_entity_subtype_to_string(unsigned type)
>>> }
>>> }
>>> -static const char *media_pad_type_to_string(unsigned flag)
>>> -{
>>> - static const struct {
>>> - __u32 flag;
>>> - const char *name;
>>> - } flags[] = {
>>> - { MEDIA_PAD_FL_SINK, "Sink" },
>>> - { MEDIA_PAD_FL_SOURCE, "Source" },
>>> - };
>>> -
>>> - unsigned int i;
>>> -
>>> - for (i = 0; i < ARRAY_SIZE(flags); i++) {
>>> - if (flags[i].flag & flag)
>>> - return flags[i].name;
>>> - }
>>> -
>>> - return "Unknown";
>>> -}
>>> -
>>> static void media_print_topology_dot(struct media_device *media)
>>> {
>>> unsigned int nents = media_get_entities_count(media);
>>> @@ -525,6 +505,25 @@ static void media_print_pad_text(struct media_entity *entity,
>>> v4l2_subdev_print_subdev_dv(entity);
>>> }
>>> +static unsigned int weight(uint32_t word)
>>> +{
>>> + unsigned int w = 0, i;
>>> +
>>> + for (i = 0; i < sizeof(word) << 3; i++, word >>= 1)
>>> + w += word & 1U;
>>> +
>>> + return w;
>>> +}
>>> +
>>> +static const char *comma(uint32_t flag, uint32_t prev_flags, uint32_t flags)
>>> +{
>>> + static const char *empty = "", *comma = ", ";
>>> + if (!(flag & flags))
>>> + return empty;
>>> +
>>> + return weight(prev_flags & flags) ? comma : empty;
>>
>> Unless I'm mistaken, we can write this
>>
>> return prev_flags & flags ? comma : empty;
>>
>> and drop the weight function.
>>
>>> +}
>>> +
>>> static void media_print_topology_text_entity(struct media_device *media,
>>> struct media_entity *entity)
>>> {
>>> @@ -567,8 +566,15 @@ static void media_print_topology_text_entity(struct media_device *media,
>>> for (j = 0; j < info->pads; j++) {
>>> const struct media_pad *pad = media_entity_get_pad(entity, j);
>>> - printf("\tpad%u: %s\n", j, media_pad_type_to_string(pad->flags));
>>> -
>>> + printf("\tpad%u: %s%s%s%s%s\n", j,
>>> + pad->flags & MEDIA_PAD_FL_SINK ? "Sink" : "",
>>> + comma(MEDIA_PAD_FL_SOURCE, MEDIA_PAD_FL_SINK,
>>> + pad->flags),
>>> + pad->flags & MEDIA_PAD_FL_SOURCE ? "Source" : "",
>>> + comma(MEDIA_PAD_FL_MUST_CONNECT,
>>> + MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE,
>>> + pad->flags),
>>> + pad->flags & MEDIA_PAD_FL_MUST_CONNECT ? "Must connect" : "");
>>
>> To be honest, this looks overly complicated. How about printing the
>> flags with a loop ?
>
> I was just about to reply that this looks a bit too "smart" to me... I'd prefer just a simple loop here for readability's and maintainability's sake, even if it's not as optimal.
Same comment from me :-)
Regards,
Hans
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags
2024-04-03 8:56 ` Hans Verkuil
@ 2024-04-04 20:17 ` Sakari Ailus
2024-04-04 22:04 ` Laurent Pinchart
0 siblings, 1 reply; 18+ messages in thread
From: Sakari Ailus @ 2024-04-04 20:17 UTC (permalink / raw)
To: Hans Verkuil
Cc: Tomi Valkeinen, Laurent Pinchart, linux-media, Gregor Jasny,
Sakari Ailus
Hi Hans, Tomi,
On Wed, Apr 03, 2024 at 10:56:55AM +0200, Hans Verkuil wrote:
> On 03/04/2024 10:43, Tomi Valkeinen wrote:
> > On 03/04/2024 11:40, Laurent Pinchart wrote:
> >> Hi Sakari,
> >>
> >> Thank you for the patch.
> >>
> >> On Tue, Apr 02, 2024 at 03:00:26AM +0300, Laurent Pinchart wrote:
> >>> From: Sakari Ailus <sakari.ailus@linux.intel.com>
> >>>
> >>> Print the MUST_CONNECT pad flag for each pad.
> >>>
> >>> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> >>> ---
> >>> utils/media-ctl/media-ctl.c | 50 +++++++++++++++++++++----------------
> >>> 1 file changed, 28 insertions(+), 22 deletions(-)
> >>>
> >>> diff --git a/utils/media-ctl/media-ctl.c b/utils/media-ctl/media-ctl.c
> >>> index 2081f111f2db..1b40552253f1 100644
> >>> --- a/utils/media-ctl/media-ctl.c
> >>> +++ b/utils/media-ctl/media-ctl.c
> >>> @@ -368,26 +368,6 @@ static const char *media_entity_subtype_to_string(unsigned type)
> >>> }
> >>> }
> >>> -static const char *media_pad_type_to_string(unsigned flag)
> >>> -{
> >>> - static const struct {
> >>> - __u32 flag;
> >>> - const char *name;
> >>> - } flags[] = {
> >>> - { MEDIA_PAD_FL_SINK, "Sink" },
> >>> - { MEDIA_PAD_FL_SOURCE, "Source" },
> >>> - };
> >>> -
> >>> - unsigned int i;
> >>> -
> >>> - for (i = 0; i < ARRAY_SIZE(flags); i++) {
> >>> - if (flags[i].flag & flag)
> >>> - return flags[i].name;
> >>> - }
> >>> -
> >>> - return "Unknown";
> >>> -}
> >>> -
> >>> static void media_print_topology_dot(struct media_device *media)
> >>> {
> >>> unsigned int nents = media_get_entities_count(media);
> >>> @@ -525,6 +505,25 @@ static void media_print_pad_text(struct media_entity *entity,
> >>> v4l2_subdev_print_subdev_dv(entity);
> >>> }
> >>> +static unsigned int weight(uint32_t word)
> >>> +{
> >>> + unsigned int w = 0, i;
> >>> +
> >>> + for (i = 0; i < sizeof(word) << 3; i++, word >>= 1)
> >>> + w += word & 1U;
> >>> +
> >>> + return w;
> >>> +}
> >>> +
> >>> +static const char *comma(uint32_t flag, uint32_t prev_flags, uint32_t flags)
> >>> +{
> >>> + static const char *empty = "", *comma = ", ";
> >>> + if (!(flag & flags))
> >>> + return empty;
> >>> +
> >>> + return weight(prev_flags & flags) ? comma : empty;
> >>
> >> Unless I'm mistaken, we can write this
> >>
> >> return prev_flags & flags ? comma : empty;
> >>
> >> and drop the weight function.
Correct. An earlier version of the patch used it and I forgot to remove it.
It should be possible to write this as:
static const char *comma(uint32_t flag, uint32_t prev_flags, uint32_t flags)
{
return flag & flags && prev_flags & flags ? ", " : "";
}
This nicely demonstrates C operator precedence.
> >>
> >>> +}
> >>> +
> >>> static void media_print_topology_text_entity(struct media_device *media,
> >>> struct media_entity *entity)
> >>> {
> >>> @@ -567,8 +566,15 @@ static void media_print_topology_text_entity(struct media_device *media,
> >>> for (j = 0; j < info->pads; j++) {
> >>> const struct media_pad *pad = media_entity_get_pad(entity, j);
> >>> - printf("\tpad%u: %s\n", j, media_pad_type_to_string(pad->flags));
> >>> -
> >>> + printf("\tpad%u: %s%s%s%s%s\n", j,
> >>> + pad->flags & MEDIA_PAD_FL_SINK ? "Sink" : "",
> >>> + comma(MEDIA_PAD_FL_SOURCE, MEDIA_PAD_FL_SINK,
> >>> + pad->flags),
> >>> + pad->flags & MEDIA_PAD_FL_SOURCE ? "Source" : "",
> >>> + comma(MEDIA_PAD_FL_MUST_CONNECT,
> >>> + MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE,
> >>> + pad->flags),
> >>> + pad->flags & MEDIA_PAD_FL_MUST_CONNECT ? "Must connect" : "");
> >>
> >> To be honest, this looks overly complicated. How about printing the
> >> flags with a loop ?
> >
> > I was just about to reply that this looks a bit too "smart" to me... I'd prefer just a simple loop here for readability's and maintainability's sake, even if it's not as optimal.
>
> Same comment from me :-)
The above gets it done as a single printf call. Perhaps it doesn't matter
much if it doesn't though, this isn't printk. Still do note that checking
whether the commas will be printed isn't trivial so replacing this with a
loop isn't necessarily making the code notably simpler.
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags
2024-04-04 20:17 ` Sakari Ailus
@ 2024-04-04 22:04 ` Laurent Pinchart
0 siblings, 0 replies; 18+ messages in thread
From: Laurent Pinchart @ 2024-04-04 22:04 UTC (permalink / raw)
To: Sakari Ailus
Cc: Hans Verkuil, Tomi Valkeinen, linux-media, Gregor Jasny,
Sakari Ailus
On Thu, Apr 04, 2024 at 08:17:09PM +0000, Sakari Ailus wrote:
> On Wed, Apr 03, 2024 at 10:56:55AM +0200, Hans Verkuil wrote:
> > On 03/04/2024 10:43, Tomi Valkeinen wrote:
> > > On 03/04/2024 11:40, Laurent Pinchart wrote:
> > >> On Tue, Apr 02, 2024 at 03:00:26AM +0300, Laurent Pinchart wrote:
> > >>> From: Sakari Ailus <sakari.ailus@linux.intel.com>
> > >>>
> > >>> Print the MUST_CONNECT pad flag for each pad.
> > >>>
> > >>> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > >>> ---
> > >>> utils/media-ctl/media-ctl.c | 50 +++++++++++++++++++++----------------
> > >>> 1 file changed, 28 insertions(+), 22 deletions(-)
> > >>>
> > >>> diff --git a/utils/media-ctl/media-ctl.c b/utils/media-ctl/media-ctl.c
> > >>> index 2081f111f2db..1b40552253f1 100644
> > >>> --- a/utils/media-ctl/media-ctl.c
> > >>> +++ b/utils/media-ctl/media-ctl.c
> > >>> @@ -368,26 +368,6 @@ static const char *media_entity_subtype_to_string(unsigned type)
> > >>> }
> > >>> }
> > >>> -static const char *media_pad_type_to_string(unsigned flag)
> > >>> -{
> > >>> - static const struct {
> > >>> - __u32 flag;
> > >>> - const char *name;
> > >>> - } flags[] = {
> > >>> - { MEDIA_PAD_FL_SINK, "Sink" },
> > >>> - { MEDIA_PAD_FL_SOURCE, "Source" },
> > >>> - };
> > >>> -
> > >>> - unsigned int i;
> > >>> -
> > >>> - for (i = 0; i < ARRAY_SIZE(flags); i++) {
> > >>> - if (flags[i].flag & flag)
> > >>> - return flags[i].name;
> > >>> - }
> > >>> -
> > >>> - return "Unknown";
> > >>> -}
> > >>> -
> > >>> static void media_print_topology_dot(struct media_device *media)
> > >>> {
> > >>> unsigned int nents = media_get_entities_count(media);
> > >>> @@ -525,6 +505,25 @@ static void media_print_pad_text(struct media_entity *entity,
> > >>> v4l2_subdev_print_subdev_dv(entity);
> > >>> }
> > >>> +static unsigned int weight(uint32_t word)
> > >>> +{
> > >>> + unsigned int w = 0, i;
> > >>> +
> > >>> + for (i = 0; i < sizeof(word) << 3; i++, word >>= 1)
> > >>> + w += word & 1U;
> > >>> +
> > >>> + return w;
> > >>> +}
> > >>> +
> > >>> +static const char *comma(uint32_t flag, uint32_t prev_flags, uint32_t flags)
> > >>> +{
> > >>> + static const char *empty = "", *comma = ", ";
> > >>> + if (!(flag & flags))
> > >>> + return empty;
> > >>> +
> > >>> + return weight(prev_flags & flags) ? comma : empty;
> > >>
> > >> Unless I'm mistaken, we can write this
> > >>
> > >> return prev_flags & flags ? comma : empty;
> > >>
> > >> and drop the weight function.
>
> Correct. An earlier version of the patch used it and I forgot to remove it.
>
> It should be possible to write this as:
>
> static const char *comma(uint32_t flag, uint32_t prev_flags, uint32_t flags)
> {
> return flag & flags && prev_flags & flags ? ", " : "";
> }
>
> This nicely demonstrates C operator precedence.
>
> > >>
> > >>> +}
> > >>> +
> > >>> static void media_print_topology_text_entity(struct media_device *media,
> > >>> struct media_entity *entity)
> > >>> {
> > >>> @@ -567,8 +566,15 @@ static void media_print_topology_text_entity(struct media_device *media,
> > >>> for (j = 0; j < info->pads; j++) {
> > >>> const struct media_pad *pad = media_entity_get_pad(entity, j);
> > >>> - printf("\tpad%u: %s\n", j, media_pad_type_to_string(pad->flags));
> > >>> -
> > >>> + printf("\tpad%u: %s%s%s%s%s\n", j,
> > >>> + pad->flags & MEDIA_PAD_FL_SINK ? "Sink" : "",
> > >>> + comma(MEDIA_PAD_FL_SOURCE, MEDIA_PAD_FL_SINK,
> > >>> + pad->flags),
> > >>> + pad->flags & MEDIA_PAD_FL_SOURCE ? "Source" : "",
> > >>> + comma(MEDIA_PAD_FL_MUST_CONNECT,
> > >>> + MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE,
> > >>> + pad->flags),
> > >>> + pad->flags & MEDIA_PAD_FL_MUST_CONNECT ? "Must connect" : "");
> > >>
> > >> To be honest, this looks overly complicated. How about printing the
> > >> flags with a loop ?
> > >
> > > I was just about to reply that this looks a bit too "smart" to me... I'd prefer just a simple loop here for readability's and maintainability's sake, even if it's not as optimal.
> >
> > Same comment from me :-)
>
> The above gets it done as a single printf call. Perhaps it doesn't matter
> much if it doesn't though, this isn't printk. Still do note that checking
> whether the commas will be printed isn't trivial so replacing this with a
> loop isn't necessarily making the code notably simpler.
See https://lore.kernel.org/linux-media/20240404220312.8019-1-laurent.pinchart@ideasonboard.com
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [v4l-utils] [PATCH 6/8] v4l2-compliance: Support the changed routing API
2024-04-02 10:54 ` Tomi Valkeinen
@ 2024-04-05 6:37 ` Sakari Ailus
0 siblings, 0 replies; 18+ messages in thread
From: Sakari Ailus @ 2024-04-05 6:37 UTC (permalink / raw)
To: Tomi Valkeinen; +Cc: Laurent Pinchart, linux-media, Hans Verkuil, Gregor Jasny
Moi,
On Tue, Apr 02, 2024 at 01:54:00PM +0300, Tomi Valkeinen wrote:
> On 02/04/2024 03:00, Laurent Pinchart wrote:
> > Set len_routes of struct v4l2_subdev_routing. ENOSPC error code is no
> > longer used, i.e. having room for fewer routes than exist in the
> > configuration is not considered an error anymore.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > utils/v4l2-compliance/v4l2-compliance.cpp | 12 +++++++-----
> > utils/v4l2-compliance/v4l2-test-subdevs.cpp | 19 +++++++++++--------
> > 2 files changed, 18 insertions(+), 13 deletions(-)
> >
> > diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
> > index 2cf979096bd0..72fe0bd778ab 100644
> > --- a/utils/v4l2-compliance/v4l2-compliance.cpp
> > +++ b/utils/v4l2-compliance/v4l2-compliance.cpp
> > @@ -1272,15 +1272,17 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
> > for (unsigned which = V4L2_SUBDEV_FORMAT_TRY;
> > which <= V4L2_SUBDEV_FORMAT_ACTIVE; which++) {
> > + struct v4l2_subdev_routing &routing = sd_routing[which];
> > - sd_routing[which].which = which;
> > - sd_routing[which].routes = (__u64)sd_routes[which];
> > - sd_routing[which].num_routes = NUM_ROUTES_MAX;
> > + routing.which = which;
> > + routing.routes = (__u64)sd_routes[which];
> > + routing.len_routes = NUM_ROUTES_MAX;
> > + routing.num_routes = 0;
>
> Not part of this series, but something I noticed while testing. Our
> routing code is broken for 32-bit userspace: we convert the routes
> pointer to u64, which ends up sign extending the address.
>
> Interestingly gcc gives "cast from pointer to integer of different size
> [-Wpointer-to-int-cast]", but g++ doesn't, and "command-line option
> ‘-Wpointer-to-int-cast’ is valid for C/ObjC but not for C++". So we don't
> get any warnings for the bugs.
Nice find!
>
> With a quick look I found these places to fix. Will you add a patch to
> your series, or should I send this as a separate one?
>
> diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
> index 72fe0bd7..a969b69c 100644
> --- a/utils/v4l2-compliance/v4l2-compliance.cpp
> +++ b/utils/v4l2-compliance/v4l2-compliance.cpp
> @@ -1275,7 +1275,7 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
> struct v4l2_subdev_routing &routing = sd_routing[which];
> routing.which = which;
> - routing.routes = (__u64)sd_routes[which];
> + routing.routes = (__u64)(uintptr_t)sd_routes[which];
I don't think you need the second cast anymore as it's already an integer.
Same for the rest.
> routing.len_routes = NUM_ROUTES_MAX;
> routing.num_routes = 0;
> @@ -1307,7 +1307,7 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
> routes = sd_routes[which];
> } else {
> dummy_routing.num_routes = 1;
> - dummy_routing.routes = (__u64)&dummy_routes;
> + dummy_routing.routes = (__u64)(uintptr_t)&dummy_routes;
> dummy_routes[0].source_pad = pad;
> dummy_routes[0].source_stream = 0;
> dummy_routes[0].sink_pad = pad;
> diff --git a/utils/v4l2-compliance/v4l2-test-subdevs.cpp b/utils/v4l2-compliance/v4l2-test-subdevs.cpp
> index e26d09ed..21d7776a 100644
> --- a/utils/v4l2-compliance/v4l2-test-subdevs.cpp
> +++ b/utils/v4l2-compliance/v4l2-test-subdevs.cpp
> @@ -587,7 +587,7 @@ int testSubDevRouting(struct node *node, unsigned which)
> int ret;
> routing.which = which;
> - routing.routes = (__u64)&routes;
> + routing.routes = (__u64)(uintptr_t)&routes;
> routing.len_routes = 0;
> routing.num_routes = 0;
> memset(routing.reserved, 0xff, sizeof(routing.reserved));
>
>
> Tomi
>
--
Terveisin,
Sakari Ailus
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2024-04-05 6:37 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-02 0:00 [v4l-utils] [PATCH 0/8] Support for the generic line-based metadata support Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 1/8] utils: media-ctl: Print MUST_CONNECT pad flags Laurent Pinchart
2024-04-03 8:40 ` Laurent Pinchart
2024-04-03 8:43 ` Tomi Valkeinen
2024-04-03 8:56 ` Hans Verkuil
2024-04-04 20:17 ` Sakari Ailus
2024-04-04 22:04 ` Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 2/8] v4l2-compliance: Constify pointers and references in formats tests Laurent Pinchart
2024-04-03 8:44 ` Tomi Valkeinen
2024-04-03 8:46 ` Hans Verkuil
2024-04-02 0:00 ` [v4l-utils] [PATCH 3/8] v4l-utils: sync-with-kernel Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 4/8] utils: media-ctl: Support changed routing API Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 5/8] utils: media-ctl: Also print INTERNAL pad flag Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 6/8] v4l2-compliance: Support the changed routing API Laurent Pinchart
2024-04-02 10:54 ` Tomi Valkeinen
2024-04-05 6:37 ` Sakari Ailus
2024-04-02 0:00 ` [v4l-utils] [PATCH 7/8] v4l2-compliance: Add tests for V4L2_FMT_FLAG_META_LINE_BASED flag Laurent Pinchart
2024-04-02 0:00 ` [v4l-utils] [PATCH 8/8] v4l2-compliance: Test IMMUTABLE route flag Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox