META_OUTPUT buffer type support for v4l2-compliance
cover META_OUTPUT buffer type support for v4l2-compliance
Hi all,
Here are the patches needed to support the META_OUTPUT queue type for v4l2-compliance. The patch that adds the support is preceded by the kernel header update --- the headers have been recently updated and there were no other changes.
Sakari Ailus (1):
Update uAPI headers from the kernel
Yong Zhi (1):
v4l2-compliance: Add support for metadata output
include/linux/videodev2.h | 2 ++ utils/common/v4l-helpers.h | 14 +++++++++++++- utils/common/v4l2-info.cpp | 4 ++++ utils/v4l2-compliance/v4l2-compliance.cpp | 7 ++++--- utils/v4l2-compliance/v4l2-compliance.h | 2 +- utils/v4l2-compliance/v4l2-test-formats.cpp | 7 +++++++ 6 files changed, 31 insertions(+), 5 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/2 Update uAPI headers from the kernel
This brings the META_OUTPUT buffer type as well as the related capability.
--- include/linux/videodev2.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/videodev2.h +2 -0
@@ -143,6 +143,7 @@ enum v4l2_buf_type {V4L2_BUF_TYPE_SDR_CAPTURE =11 ,V4L2_BUF_TYPE_SDR_OUTPUT =12 ,V4L2_BUF_TYPE_META_CAPTURE =13 , +V4L2_BUF_TYPE_META_OUTPUT =14 ,/* Deprecated, do not use */ V4L2_BUF_TYPE_PRIVATE = 0x80, };
@@ -463,6 +464,7 @@ struct v4l2_capability {#define V4L2_CAP_READWRITE 0x01000000/* read/write systemcalls */ #define V4L2_CAP_ASYNCIO 0x02000000/* async I/O */ #define V4L2_CAP_STREAMING 0x04000000/* streaming I/O ioctls */ +#define V4L2_CAP_META_OUTPUT 0x08000000/* Is a metadata output device */ #define V4L2_CAP_TOUCH 0x10000000/* Is a touch device */
Signature · 1 line
2.11.0
PATCH 2/2 v4l2-compliance: Add support for metadata output
In reply to Sakari AilusFrom: Yong Zhi <[email protected]>
Add support for metadata output video nodes, in other words, V4L2_CAP_META_OUTPUT and V4L2_BUF_TYPE_META_OUTPUT.
--- utils/common/v4l-helpers.h | 14 +++++++++++++- utils/common/v4l2-info.cpp | 4 ++++ utils/v4l2-compliance/v4l2-compliance.cpp | 7 ++++--- utils/v4l2-compliance/v4l2-compliance.h | 2 +- utils/v4l2-compliance/v4l2-test-formats.cpp | 7 +++++++ 5 files changed, 29 insertions(+), 5 deletions(-)
utils/common/v4l-helpers.h +13 -1
@@ -392,6 +392,11 @@ static inline bool v4l_has_meta_cap(const struct v4l_fd *f)return v4l_g_caps (f) &V4L2_CAP_META_CAPTURE ; } +static inline bool v4l_has_meta_out (const struct v4l_fd *f) +{ +return v4l_g_caps (f) &V4L2_CAP_META_OUTPUT ; +} +static inline bool v4l_has_touch (const struct v4l_fd *f) {return v4l_g_caps (f) &V4L2_CAP_TOUCH ;
@@ -440,6 +445,9 @@ static inline __u32 v4l_determine_type(const struct v4l_fd *f)return V4L2_BUF_TYPE_SDR_OUTPUT ;if (v4l_has_meta_cap (f))return V4L2_BUF_TYPE_META_CAPTURE ; +if (v4l_has_meta_out (f)) +return V4L2_BUF_TYPE_META_OUTPUT ; +return 0 ; }
@@ -672,6 +680,7 @@ static inline void v4l_format_s_pixelformat(struct v4l2_format *fmt, __u32 pixel fmt->fmt.vbi.sample_format = pixelformat;break ;case V4L2_BUF_TYPE_META_CAPTURE : +case V4L2_BUF_TYPE_META_OUTPUT : fmt->fmt.meta.dataformat = pixelformat;break ; }
@@ -693,6 +702,7 @@ static inline __u32 v4l_format_g_pixelformat(const struct v4l2_format *fmt)case V4L2_BUF_TYPE_VBI_OUTPUT :return fmt->fmt.vbi.sample_format;case V4L2_BUF_TYPE_META_CAPTURE : +case V4L2_BUF_TYPE_META_OUTPUT :return fmt->fmt.meta.dataformat;default :return 0 ;
@@ -1031,6 +1041,7 @@ v4l_format_g_sizeimage(const struct v4l2_format *fmt, unsigned plane)case V4L2_BUF_TYPE_SDR_OUTPUT :return plane ?0 : fmt->fmt.sdr.buffersize;case V4L2_BUF_TYPE_META_CAPTURE : +case V4L2_BUF_TYPE_META_OUTPUT :return plane ?0 : fmt->fmt.meta.buffersize;default :return 0 ;
@@ -1152,7 +1163,8 @@ static inline bool v4l_type_is_sdr(unsigned type)static inline bool v4l_type_is_meta (unsigned type) { -return type ==V4L2_BUF_TYPE_META_CAPTURE ; +return type ==V4L2_BUF_TYPE_META_CAPTURE || + type ==V4L2_BUF_TYPE_META_OUTPUT ; }static inline unsigned v4l_type_invert (unsigned type)
utils/common/v4l2-info.cpp +4 -0
@@ -95,6 +95,8 @@ static std::string cap2s(unsigned cap) s += "\t\tSDR Output\n"; if (cap & V4L2_CAP_META_CAPTURE) s += "\t\tMetadata Capture\n"; + if (cap & V4L2_CAP_META_OUTPUT) + s += "\t\tMetadata Output\n"; if (cap & V4L2_CAP_TUNER) s += "\t\tTuner\n"; if (cap & V4L2_CAP_TOUCH)
@@ -188,6 +190,8 @@ std::string buftype2s(int type) return "SDR Output"; case V4L2_BUF_TYPE_META_CAPTURE: return "Metadata Capture"; + case V4L2_BUF_TYPE_META_OUTPUT: + return "Metadata Output"; case V4L2_BUF_TYPE_PRIVATE: return "Private"; default:
utils/v4l2-compliance/v4l2-compliance.cpp +4 -3
@@ -476,7 +476,7 @@ static int testCap(struct node *node) const __u32 output_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_VIDEO_OUTPUT_OVERLAY | V4L2_CAP_VBI_OUTPUT | V4L2_CAP_SDR_OUTPUT | V4L2_CAP_SLICED_VBI_OUTPUT | - V4L2_CAP_MODULATOR; + 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 io_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
@@ -702,12 +702,13 @@ void testNode(struct node &node, struct node &expbuf_node, media_type type, 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_RDS_OUTPUT | V4L2_CAP_SDR_OUTPUT | + V4L2_CAP_META_OUTPUT)) node.can_output = true; if (node.g_caps() & (V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE)) node.is_planar = true; - if (node.g_caps() & V4L2_CAP_META_CAPTURE) { + if (node.g_caps() & (V4L2_CAP_META_CAPTURE | V4L2_CAP_META_OUTPUT)) { node.is_video = false; node.is_meta = true; }
utils/v4l2-compliance/v4l2-compliance.h +1 -1
@@ -69,7 +69,7 @@ typedef std::map<__u32, unsigned> frmsizes_count_map;struct base_node ; -#define V4L2_BUF_TYPE_LAST V4L2_BUF_TYPE_META_CAPTURE +#define V4L2_BUF_TYPE_LAST V4L2_BUF_TYPE_META_OUTPUTstruct base_node {bool is_video;
utils/v4l2-compliance/v4l2-test-formats.cpp +7 -0
@@ -47,6 +47,7 @@ static const __u32 buftype2cap[] = { V4L2_CAP_SDR_CAPTURE, V4L2_CAP_SDR_OUTPUT, V4L2_CAP_META_CAPTURE, + V4L2_CAP_META_OUTPUT, }; static int testEnumFrameIntervals(struct node *node, __u32 pixfmt,
@@ -298,6 +299,7 @@ int testEnumFormats(struct node *node) case V4L2_BUF_TYPE_SDR_CAPTURE: case V4L2_BUF_TYPE_SDR_OUTPUT: case V4L2_BUF_TYPE_META_CAPTURE: + case V4L2_BUF_TYPE_META_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());
@@ -545,6 +547,7 @@ static int testFormatsType(struct node *node, int ret, unsigned type, struct v4 fail_on_test(check_0(sdr.reserved, sizeof(sdr.reserved))); break; case V4L2_BUF_TYPE_META_CAPTURE: + case V4L2_BUF_TYPE_META_OUTPUT: if (map.find(meta.dataformat) == map.end()) return fail("dataformat %08x (%s) for buftype %d not reported by ENUM_FMT\n", meta.dataformat, fcc2s(meta.dataformat).c_str(), type);
@@ -584,6 +587,7 @@ int testGetFormats(struct node *node) case V4L2_BUF_TYPE_SDR_CAPTURE: case V4L2_BUF_TYPE_SDR_OUTPUT: case V4L2_BUF_TYPE_META_CAPTURE: + case V4L2_BUF_TYPE_META_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());
@@ -640,6 +644,7 @@ static bool matchFormats(const struct v4l2_format &f1, const struct v4l2_format case V4L2_BUF_TYPE_SDR_OUTPUT: return !memcmp(&f1.fmt.sdr, &f2.fmt.sdr, sizeof(f1.fmt.sdr)); case V4L2_BUF_TYPE_META_CAPTURE: + case V4L2_BUF_TYPE_META_OUTPUT: return !memcmp(&f1.fmt.meta, &f2.fmt.meta, sizeof(f1.fmt.meta)); }
@@ -717,6 +722,7 @@ int testTryFormats(struct node *node) pixelformat = fmt.fmt.sdr.pixelformat; break; case V4L2_BUF_TYPE_META_CAPTURE: + case V4L2_BUF_TYPE_META_OUTPUT: pixelformat = fmt.fmt.meta.dataformat; break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
@@ -968,6 +974,7 @@ int testSetFormats(struct node *node) switch (type) { case V4L2_BUF_TYPE_META_CAPTURE: + case V4L2_BUF_TYPE_META_OUTPUT: pixelformat = fmt_set.fmt.meta.dataformat; break; case V4L2_BUF_TYPE_SDR_CAPTURE:
Signature · 1 line
2.11.0
Quoted 6 lines · Sakari Ailus
Hi all,
Here are the patches needed to support the
META_OUTPUTqueue type for v4l2-compliance. The patch that adds the support is preceded by the kernel header update --- the headers have been recently updated and there were no other changes.
Looks good for v4l2-compliance, but v4l2-ctl should also be updated.
I have alreaedy prepared v4l2-ctl-meta.cpp (should work automatically with this patch series applied), but there are two other places where you need to add META_OUTPUT support. Just add a third patch for v4l2-ctl.
Regards,
Hans
Quoted 15 lines
Sakari Ailus (1):
Update uAPI headers from the kernelYong Zhi (1):
v4l2-compliance: Add support for metadata outputinclude/linux/videodev2.h | 2 ++ utils/common/v4l-helpers.h | 14 +++++++++++++- utils/common/v4l2-info.cpp | 4 ++++ utils/v4l2-compliance/v4l2-compliance.cpp | 7 ++++--- utils/v4l2-compliance/v4l2-compliance.h | 2 +- utils/v4l2-compliance/v4l2-test-formats.cpp | 7 +++++++ 6 files changed, 31 insertions(+), 5 deletions(-)