media: v4l2: Add extended fmt and buffer ioctls
Subsystems (13)
v2 cover media: v4l2: Add extended fmt and buffer ioctls
Hello,
This RFC follows the discussion started by Hans [1] a few months back. It does not try to address all the problem reported in this thread but instead focuses on the FMT and BUF(S) ioctls.
Note that my primary goal is to unify handling for multiplanar and singleplanar formats and extend things to support the "single dmabuf storing all pixel planes" issue.
This version received a bit more testing than the previous one (added new tests to v4l2-compliance [2] to make sure EXT ioctls work as expected and also checked that !ext -> ext wrappers work correctly by running the old tests). Note that I'm not planning to post those v4l-utils patches on the ML until we've settled down on the userspace API, unless I'm explicitly asked to do so.
Right now I'm focusing on the case I was primarily interested in:
single dmabuf storing all pixel planes (each being at a different offset), and it seems that patching the VB2 core to support that is not a trivial task.
So here are a few questions for V4L/DMABUF experts:
- Can the same dmabuf be mapped several times. I think it's okay apart from the extra/needless time spent doing cache maintenance operations, but there might be issues if an IOMMU is involved (duplicate mappings?). If it's not okay, then we need to find a solution to only attach/map the DMABUF once when it's used for several planes (this is what I tried to do here [3], but I'm not entirely happy with the implementation and started to investigate another approach here [4]).
- How should we pass the offset to drivers that were previously using the get_cookie() (or the dma_sg wrapper) to retrieve an sg table. Adding the offset to the dma_addr or vaddr for vmalloc or dma-contig case can be done in the core, but for an sg-table it's a bit more complicated. Should drivers access this piece of information directly from vb2_plane->dbuf_offset? And in that case, how do we make sure drivers don't simply ignore the offset and assume it's always zero?
Few words about the feedback I got from Brian and Nicolas on my v1:
- modifier field has been moved to v4l2_ext_format as suggested
- v4l2_timecode is still not present in v4l2_ext_buffer, but can be added back thanks to the extra reserved space
- the ENUMFMT is left as is for now, because I think we want Maxime's work on DRM/V4L format unification to land before reworking the ioctl (exposing extra info about the format and not only the 4CC code?). That also means that there's currently no way to know which modifiers are supported
- EXT_FMT/EXT_BUF capability flags to detect whether new ioctls are supported or not have not been added yet
Regards,
Boris
[1]https://www.mail-archive.com/[email protected]/msg135729.html [2]https://github.com/bbrezillon/v4l-utils/commits/master [3]https://github.com/bbrezillon/linux/commit/4882435f80b05a61827649d55cc0f0cee79680a7 [4]https://github.com/bbrezillon/linux/commit/a415216c6aaab2d51f0bd62270b994c8196ddd90
*** BLURB HERE ***
Boris Brezillon (6):
media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap,out}_mplane
media: v4l2: Extend pixel formats to unify single/multi-planar
handling (and more)
media: videobuf2: Expose helpers to implement the _ext_fmt and
_ext_buf hooks
media: mediabus: Add an helper to convert a ext_pix format to an
mbus_fmt
media: vivid: Convert the capture and output drivers to
EXT_FMT/EXT_BUF
media: vimc: Implement the ext_fmt and ext_buf hooks
Hans Verkuil (1):
media: v4l2: Add extended buffer operations
.../media/common/videobuf2/videobuf2-core.c | 2 + .../media/common/videobuf2/videobuf2-v4l2.c | 534 +++++--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 +- .../media/platform/exynos4-is/fimc-capture.c | 2 +- .../platform/exynos4-is/fimc-isp-video.c | 2 +- drivers/media/platform/exynos4-is/fimc-lite.c | 2 +- drivers/media/platform/exynos4-is/fimc-m2m.c | 4 +- .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 4 +- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 4 +- .../platform/mtk-vcodec/mtk_vcodec_dec.c | 4 +- .../platform/mtk-vcodec/mtk_vcodec_enc.c | 4 +- .../media/platform/qcom/camss/camss-video.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 4 +- drivers/media/platform/qcom/venus/venc.c | 4 +- drivers/media/platform/rcar_fdp1.c | 4 +- drivers/media/platform/rcar_jpu.c | 4 +- drivers/media/platform/renesas-ceu.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 4 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 4 +- drivers/media/platform/ti-vpe/vpe.c | 4 +- drivers/media/platform/vicodec/vicodec-core.c | 2 - drivers/media/platform/vimc/vimc-capture.c | 65 +- drivers/media/platform/vimc/vimc-common.c | 4 +- drivers/media/platform/vimc/vimc-common.h | 2 +- drivers/media/platform/vimc/vimc-core.c | 10 +- drivers/media/platform/vivid/vivid-core.c | 36 +- drivers/media/platform/vivid/vivid-vid-cap.c | 171 +-- drivers/media/platform/vivid/vivid-vid-cap.h | 15 +- .../media/platform/vivid/vivid-vid-common.c | 20 - .../media/platform/vivid/vivid-vid-common.h | 2 - drivers/media/platform/vivid/vivid-vid-out.c | 195 +-- drivers/media/platform/vivid/vivid-vid-out.h | 15 +- drivers/media/v4l2-core/v4l2-dev.c | 56 +- drivers/media/v4l2-core/v4l2-ioctl.c | 1141 +++++++++++++++-- drivers/staging/media/ipu3/ipu3-v4l2.c | 4 +- .../media/rockchip/vpu/rockchip_vpu_enc.c | 4 +- include/media/v4l2-ioctl.h | 77 +- include/media/v4l2-mediabus.h | 22 + include/media/videobuf2-core.h | 6 +- include/media/videobuf2-v4l2.h | 26 +- include/uapi/linux/videodev2.h | 211 +++ 42 files changed, 1945 insertions(+), 739 deletions(-)
Signature · 1 line
2.20.1
RFC PATCH v2 1/7 media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap,out}_mplane
Support for multiplanar and singleplanar formats is mutually exclusive, at least in practice. In our attempt to unify support for support for mplane and !mplane in v4l, let's get rid of the ->vidioc_enum_fmt_{vid,out}_cap_mplane() hooks and call ->vidioc_enum_fmt_{vid,out}_cap() instead.
---
Changes in v2:
- None
--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 ++-- .../media/platform/exynos4-is/fimc-capture.c | 2 +- .../platform/exynos4-is/fimc-isp-video.c | 2 +- drivers/media/platform/exynos4-is/fimc-lite.c | 2 +- drivers/media/platform/exynos4-is/fimc-m2m.c | 4 ++-- .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 4 ++-- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 4 ++-- .../platform/mtk-vcodec/mtk_vcodec_dec.c | 4 ++-- .../platform/mtk-vcodec/mtk_vcodec_enc.c | 4 ++-- .../media/platform/qcom/camss/camss-video.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 4 ++-- drivers/media/platform/qcom/venus/venc.c | 4 ++-- drivers/media/platform/rcar_fdp1.c | 4 ++-- drivers/media/platform/rcar_jpu.c | 4 ++-- drivers/media/platform/renesas-ceu.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 4 ++-- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 4 ++-- drivers/media/platform/ti-vpe/vpe.c | 4 ++-- drivers/media/platform/vicodec/vicodec-core.c | 2 -- drivers/media/platform/vivid/vivid-core.c | 6 ++---- .../media/platform/vivid/vivid-vid-common.c | 20 ------------------ .../media/platform/vivid/vivid-vid-common.h | 2 -- drivers/media/v4l2-core/v4l2-dev.c | 2 -- drivers/media/v4l2-core/v4l2-ioctl.c | 21 ++++++++++--------- drivers/staging/media/ipu3/ipu3-v4l2.c | 4 ++-- .../media/rockchip/vpu/rockchip_vpu_enc.c | 4 ++-- include/media/v4l2-ioctl.h | 14 ++----------- 28 files changed, 51 insertions(+), 88 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +1 -1
@@ -1174,7 +1174,7 @@ static const struct v4l2_file_operations cio2_v4l2_fops = {static const struct v4l2_ioctl_ops cio2_v4l2_ioctl_ops = { .vidioc_querycap = cio2_v4l2_querycap, - .vidioc_enum_fmt_vid_cap_mplane = cio2_v4l2_enum_fmt, + .vidioc_enum_fmt_vid_cap = cio2_v4l2_enum_fmt, .vidioc_g_fmt_vid_cap_mplane = cio2_v4l2_g_fmt, .vidioc_s_fmt_vid_cap_mplane = cio2_v4l2_s_fmt, .vidioc_try_fmt_vid_cap_mplane = cio2_v4l2_try_fmt,
drivers/media/platform/exynos-gsc/gsc-m2m.c +2 -2
@@ -562,8 +562,8 @@ static int gsc_m2m_s_selection(struct file *file, void *fh,static const struct v4l2_ioctl_ops gsc_m2m_ioctl_ops = { .vidioc_querycap = gsc_m2m_querycap, - .vidioc_enum_fmt_vid_cap_mplane = gsc_m2m_enum_fmt_mplane, - .vidioc_enum_fmt_vid_out_mplane = gsc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = gsc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_out = gsc_m2m_enum_fmt_mplane, .vidioc_g_fmt_vid_cap_mplane = gsc_m2m_g_fmt_mplane, .vidioc_g_fmt_vid_out_mplane = gsc_m2m_g_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = gsc_m2m_try_fmt_mplane,
drivers/media/platform/exynos4-is/fimc-capture.c +1 -1
@@ -1361,7 +1361,7 @@ static int fimc_cap_s_selection(struct file *file, void *fh,static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops = { .vidioc_querycap = fimc_cap_querycap, - .vidioc_enum_fmt_vid_cap_mplane = fimc_cap_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = fimc_cap_enum_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = fimc_cap_try_fmt_mplane, .vidioc_s_fmt_vid_cap_mplane = fimc_cap_s_fmt_mplane, .vidioc_g_fmt_vid_cap_mplane = fimc_cap_g_fmt_mplane,
drivers/media/platform/exynos4-is/fimc-isp-video.c +1 -1
@@ -551,7 +551,7 @@ static int isp_video_reqbufs(struct file *file, void *priv,static const struct v4l2_ioctl_ops isp_video_ioctl_ops = { .vidioc_querycap = isp_video_querycap, - .vidioc_enum_fmt_vid_cap_mplane = isp_video_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = isp_video_enum_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = isp_video_try_fmt_mplane, .vidioc_s_fmt_vid_cap_mplane = isp_video_s_fmt_mplane, .vidioc_g_fmt_vid_cap_mplane = isp_video_g_fmt_mplane,
drivers/media/platform/exynos4-is/fimc-lite.c +1 -1
@@ -954,7 +954,7 @@ static int fimc_lite_s_selection(struct file *file, void *fh,static const struct v4l2_ioctl_ops fimc_lite_ioctl_ops = { .vidioc_querycap = fimc_lite_querycap, - .vidioc_enum_fmt_vid_cap_mplane = fimc_lite_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = fimc_lite_enum_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = fimc_lite_try_fmt_mplane, .vidioc_s_fmt_vid_cap_mplane = fimc_lite_s_fmt_mplane, .vidioc_g_fmt_vid_cap_mplane = fimc_lite_g_fmt_mplane,
drivers/media/platform/exynos4-is/fimc-m2m.c +2 -2
@@ -533,8 +533,8 @@ static int fimc_m2m_s_selection(struct file *file, void *fh,static const struct v4l2_ioctl_ops fimc_m2m_ioctl_ops = { .vidioc_querycap = fimc_m2m_querycap, - .vidioc_enum_fmt_vid_cap_mplane = fimc_m2m_enum_fmt_mplane, - .vidioc_enum_fmt_vid_out_mplane = fimc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = fimc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_out = fimc_m2m_enum_fmt_mplane, .vidioc_g_fmt_vid_cap_mplane = fimc_m2m_g_fmt_mplane, .vidioc_g_fmt_vid_out_mplane = fimc_m2m_g_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = fimc_m2m_try_fmt_mplane,
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +2 -2
@@ -536,8 +536,8 @@ static int mtk_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)static const struct v4l2_ioctl_ops mtk_jpeg_ioctl_ops = { .vidioc_querycap = mtk_jpeg_querycap, - .vidioc_enum_fmt_vid_cap_mplane = mtk_jpeg_enum_fmt_vid_cap, - .vidioc_enum_fmt_vid_out_mplane = mtk_jpeg_enum_fmt_vid_out, + .vidioc_enum_fmt_vid_cap = mtk_jpeg_enum_fmt_vid_cap, + .vidioc_enum_fmt_vid_out = mtk_jpeg_enum_fmt_vid_out, .vidioc_try_fmt_vid_cap_mplane = mtk_jpeg_try_fmt_vid_cap_mplane, .vidioc_try_fmt_vid_out_mplane = mtk_jpeg_try_fmt_vid_out_mplane, .vidioc_g_fmt_vid_cap_mplane = mtk_jpeg_g_fmt_vid_mplane,
drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c +2 -2
@@ -935,8 +935,8 @@ static int mtk_mdp_m2m_s_selection(struct file *file, void *fh,static const struct v4l2_ioctl_ops mtk_mdp_m2m_ioctl_ops = { .vidioc_querycap = mtk_mdp_m2m_querycap, - .vidioc_enum_fmt_vid_cap_mplane = mtk_mdp_m2m_enum_fmt_mplane_vid_cap, - .vidioc_enum_fmt_vid_out_mplane = mtk_mdp_m2m_enum_fmt_mplane_vid_out, + .vidioc_enum_fmt_vid_cap = mtk_mdp_m2m_enum_fmt_mplane_vid_cap, + .vidioc_enum_fmt_vid_out = mtk_mdp_m2m_enum_fmt_mplane_vid_out, .vidioc_g_fmt_vid_cap_mplane = mtk_mdp_m2m_g_fmt_mplane, .vidioc_g_fmt_vid_out_mplane = mtk_mdp_m2m_g_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = mtk_mdp_m2m_try_fmt_mplane,
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c +2 -2
@@ -1444,8 +1444,8 @@ const struct v4l2_ioctl_ops mtk_vdec_ioctl_ops = { .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_vdec_enum_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out_mplane = vidioc_vdec_enum_fmt_vid_out_mplane, + .vidioc_enum_fmt_vid_cap = vidioc_vdec_enum_fmt_vid_cap_mplane, + .vidioc_enum_fmt_vid_out = vidioc_vdec_enum_fmt_vid_out_mplane, .vidioc_enum_framesizes = vidioc_enum_framesizes, .vidioc_querycap = vidioc_vdec_querycap,
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +2 -2
@@ -725,8 +725,8 @@ const struct v4l2_ioctl_ops mtk_venc_ioctl_ops = { .vidioc_dqbuf = vidioc_venc_dqbuf, .vidioc_querycap = vidioc_venc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap_mplane, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out_mplane, .vidioc_enum_framesizes = vidioc_enum_framesizes, .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap_mplane,
drivers/media/platform/qcom/camss/camss-video.c +1 -1
@@ -703,7 +703,7 @@ static int video_s_input(struct file *file, void *fh, unsigned int input)static const struct v4l2_ioctl_ops msm_vid_ioctl_ops = { .vidioc_querycap = video_querycap, - .vidioc_enum_fmt_vid_cap_mplane = video_enum_fmt, + .vidioc_enum_fmt_vid_cap = video_enum_fmt, .vidioc_g_fmt_vid_cap_mplane = video_g_fmt, .vidioc_s_fmt_vid_cap_mplane = video_s_fmt, .vidioc_try_fmt_vid_cap_mplane = video_try_fmt,
drivers/media/platform/qcom/venus/vdec.c +2 -2
@@ -491,8 +491,8 @@ vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd)static const struct v4l2_ioctl_ops vdec_ioctl_ops = { .vidioc_querycap = vdec_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vdec_enum_fmt, - .vidioc_enum_fmt_vid_out_mplane = vdec_enum_fmt, + .vidioc_enum_fmt_vid_cap = vdec_enum_fmt, + .vidioc_enum_fmt_vid_out = vdec_enum_fmt, .vidioc_s_fmt_vid_cap_mplane = vdec_s_fmt, .vidioc_s_fmt_vid_out_mplane = vdec_s_fmt, .vidioc_g_fmt_vid_cap_mplane = vdec_g_fmt,
drivers/media/platform/qcom/venus/venc.c +2 -2
@@ -616,8 +616,8 @@ static int venc_enum_frameintervals(struct file *file, void *fh,static const struct v4l2_ioctl_ops venc_ioctl_ops = { .vidioc_querycap = venc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = venc_enum_fmt, - .vidioc_enum_fmt_vid_out_mplane = venc_enum_fmt, + .vidioc_enum_fmt_vid_cap = venc_enum_fmt, + .vidioc_enum_fmt_vid_out = venc_enum_fmt, .vidioc_s_fmt_vid_cap_mplane = venc_s_fmt, .vidioc_s_fmt_vid_out_mplane = venc_s_fmt, .vidioc_g_fmt_vid_cap_mplane = venc_g_fmt,
drivers/media/platform/rcar_fdp1.c +2 -2
@@ -1730,8 +1730,8 @@ static const char * const fdp1_ctrl_deint_menu[] = {static const struct v4l2_ioctl_ops fdp1_ioctl_ops = { .vidioc_querycap = fdp1_vidioc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = fdp1_enum_fmt_vid_cap, - .vidioc_enum_fmt_vid_out_mplane = fdp1_enum_fmt_vid_out, + .vidioc_enum_fmt_vid_cap = fdp1_enum_fmt_vid_cap, + .vidioc_enum_fmt_vid_out = fdp1_enum_fmt_vid_out, .vidioc_g_fmt_vid_cap_mplane = fdp1_g_fmt, .vidioc_g_fmt_vid_out_mplane = fdp1_g_fmt, .vidioc_try_fmt_vid_cap_mplane = fdp1_try_fmt,
drivers/media/platform/rcar_jpu.c +2 -2
@@ -948,8 +948,8 @@ static int jpu_streamon(struct file *file, void *priv, enum v4l2_buf_type type)static const struct v4l2_ioctl_ops jpu_ioctl_ops = { .vidioc_querycap = jpu_querycap, - .vidioc_enum_fmt_vid_cap_mplane = jpu_enum_fmt_cap, - .vidioc_enum_fmt_vid_out_mplane = jpu_enum_fmt_out, + .vidioc_enum_fmt_vid_cap = jpu_enum_fmt_cap, + .vidioc_enum_fmt_vid_out = jpu_enum_fmt_out, .vidioc_g_fmt_vid_cap_mplane = jpu_g_fmt, .vidioc_g_fmt_vid_out_mplane = jpu_g_fmt, .vidioc_try_fmt_vid_cap_mplane = jpu_try_fmt,
drivers/media/platform/renesas-ceu.c +1 -1
@@ -1339,7 +1339,7 @@ static int ceu_enum_frameintervals(struct file *file, void *fh,static const struct v4l2_ioctl_ops ceu_ioctl_ops = { .vidioc_querycap = ceu_querycap, - .vidioc_enum_fmt_vid_cap_mplane = ceu_enum_fmt_vid_cap, + .vidioc_enum_fmt_vid_cap = ceu_enum_fmt_vid_cap, .vidioc_try_fmt_vid_cap_mplane = ceu_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap_mplane = ceu_s_fmt_vid_cap, .vidioc_g_fmt_vid_cap_mplane = ceu_g_fmt_vid_cap,
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +2 -2
@@ -887,8 +887,8 @@ static int vidioc_subscribe_event(struct v4l2_fh *fh,/* v4l2_ioctl_ops */ static const struct v4l2_ioctl_ops s5p_mfc_dec_ioctl_ops = { .vidioc_querycap = vidioc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap_mplane, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt, .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt,
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +2 -2
@@ -2343,8 +2343,8 @@ static int vidioc_subscribe_event(struct v4l2_fh *fh,static const struct v4l2_ioctl_ops s5p_mfc_enc_ioctl_ops = { .vidioc_querycap = vidioc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap_mplane, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt, .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt,
drivers/media/platform/ti-vpe/vpe.c +2 -2
@@ -1973,12 +1973,12 @@ static const struct v4l2_ctrl_ops vpe_ctrl_ops = {static const struct v4l2_ioctl_ops vpe_ioctl_ops = { .vidioc_querycap = vpe_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vpe_enum_fmt, + .vidioc_enum_fmt_vid_cap = vpe_enum_fmt, .vidioc_g_fmt_vid_cap_mplane = vpe_g_fmt, .vidioc_try_fmt_vid_cap_mplane = vpe_try_fmt, .vidioc_s_fmt_vid_cap_mplane = vpe_s_fmt, - .vidioc_enum_fmt_vid_out_mplane = vpe_enum_fmt, + .vidioc_enum_fmt_vid_out = vpe_enum_fmt, .vidioc_g_fmt_vid_out_mplane = vpe_g_fmt, .vidioc_try_fmt_vid_out_mplane = vpe_try_fmt, .vidioc_s_fmt_vid_out_mplane = vpe_s_fmt,
drivers/media/platform/vicodec/vicodec-core.c +0 -2
@@ -1140,7 +1140,6 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = { .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_vid_cap, .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_vid_cap,
@@ -1150,7 +1149,6 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = { .vidioc_try_fmt_vid_out = vidioc_try_fmt_vid_out, .vidioc_s_fmt_vid_out = vidioc_s_fmt_vid_out, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt_vid_out, .vidioc_try_fmt_vid_out_mplane = vidioc_try_fmt_vid_out, .vidioc_s_fmt_vid_out_mplane = vidioc_s_fmt_vid_out,
drivers/media/platform/vivid/vivid-core.c +2 -4
@@ -500,20 +500,18 @@ static const struct v4l2_file_operations vivid_radio_fops = {static const struct v4l2_ioctl_ops vivid_ioctl_ops = { .vidioc_querycap = vidioc_querycap, - .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid, + .vidioc_enum_fmt_vid_cap = vivid_enum_fmt_vid, .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_vid_cap_mplane, .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap_mplane, .vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid, + .vidioc_enum_fmt_vid_out = vivid_enum_fmt_vid, .vidioc_g_fmt_vid_out = vidioc_g_fmt_vid_out, .vidioc_try_fmt_vid_out = vidioc_try_fmt_vid_out, .vidioc_s_fmt_vid_out = vidioc_s_fmt_vid_out, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_mplane, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt_vid_out_mplane, .vidioc_try_fmt_vid_out_mplane = vidioc_try_fmt_vid_out_mplane, .vidioc_s_fmt_vid_out_mplane = vidioc_s_fmt_vid_out_mplane,
drivers/media/platform/vivid/vivid-vid-common.c +0 -20
@@ -797,26 +797,6 @@ int vivid_enum_fmt_vid(struct file *file, void *priv,return 0 ; } -int vidioc_enum_fmt_vid_mplane (struct file *file,void *priv, -struct v4l2_fmtdesc *f) -{ -struct vivid_dev *dev =video_drvdata (file); - -if (!dev->multiplanar) -return -ENOTTY ; -return vivid_enum_fmt_vid (file, priv, f); -} - -int vidioc_enum_fmt_vid (struct file *file,void *priv, -struct v4l2_fmtdesc *f) -{ -struct vivid_dev *dev =video_drvdata (file); - -if (dev->multiplanar) -return -ENOTTY ; -return vivid_enum_fmt_vid (file, priv, f); -} -int vidioc_g_std (struct file *file,void *priv,v4l2_std_id *id) {struct vivid_dev *dev =video_drvdata (file);
drivers/media/platform/vivid/vivid-vid-common.h +0 -2
@@ -28,8 +28,6 @@ void vivid_send_source_change(struct vivid_dev *dev, unsigned type);int vivid_vid_adjust_sel (unsigned flags,struct v4l2_rect *r);int vivid_enum_fmt_vid (struct file *file,void *priv,struct v4l2_fmtdesc *f); -int vidioc_enum_fmt_vid_mplane (struct file *file,void *priv,struct v4l2_fmtdesc *f); -int vidioc_enum_fmt_vid (struct file *file,void *priv,struct v4l2_fmtdesc *f);int vidioc_g_std (struct file *file,void *priv,v4l2_std_id *id);int vidioc_g_dv_timings (struct file *file,void *_fh,struct v4l2_dv_timings *timings);int vidioc_enum_dv_timings (struct file *file,void *_fh,struct v4l2_enum_dv_timings *timings);
drivers/media/v4l2-core/v4l2-dev.c +0 -2
@@ -593,11 +593,9 @@ static void determine_valid_ioctls(struct video_device *vdev)if (is_vid || is_tch) {/* video and metadata specific ioctls */ if ((is_rx && (ops->vidioc_enum_fmt_vid_cap || - ops->vidioc_enum_fmt_vid_cap_mplane || ops->vidioc_enum_fmt_vid_overlay || ops->vidioc_enum_fmt_meta_cap)) || (is_tx && (ops->vidioc_enum_fmt_vid_out || - ops->vidioc_enum_fmt_vid_out_mplane || ops->vidioc_enum_fmt_meta_out)))set_bit (_IOC_NR (VIDIOC_ENUM_FMT ), valid_ioctls); if ((is_rx && (ops->vidioc_g_fmt_vid_cap ||
drivers/media/v4l2-core/v4l2-ioctl.c +11 -10
@@ -1380,6 +1380,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)static int v4l_enum_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) { +struct video_device *vdev =video_devdata (file);struct v4l2_fmtdesc *p = arg;int ret =check_fmt (file, p->type);
@@ -1389,30 +1390,30 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : +if (!!(vdev->device_caps &V4L2_CAP_VIDEO_CAPTURE_MPLANE ) != + (p->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE )) +break ; +if (unlikely (!ops->vidioc_enum_fmt_vid_cap))break ; ret = ops->vidioc_enum_fmt_vid_cap (file, fh, arg);break ; -case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : -if (unlikely (!ops->vidioc_enum_fmt_vid_cap_mplane)) -break ; - ret = ops->vidioc_enum_fmt_vid_cap_mplane (file, fh, arg); -break ;case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_enum_fmt_vid_overlay))break ; ret = ops->vidioc_enum_fmt_vid_overlay (file, fh, arg);break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT : +case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : +if (!!(vdev->device_caps &V4L2_CAP_VIDEO_OUTPUT_MPLANE ) != + (p->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE )) +break ; +if (unlikely (!ops->vidioc_enum_fmt_vid_out))break ; ret = ops->vidioc_enum_fmt_vid_out (file, fh, arg);break ; -case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : -if (unlikely (!ops->vidioc_enum_fmt_vid_out_mplane)) -break ; - ret = ops->vidioc_enum_fmt_vid_out_mplane (file, fh, arg); -break ;case V4L2_BUF_TYPE_SDR_CAPTURE :if (unlikely (!ops->vidioc_enum_fmt_sdr_cap))break ;
drivers/staging/media/ipu3/ipu3-v4l2.c +2 -2
@@ -959,12 +959,12 @@ static const struct v4l2_file_operations imgu_v4l2_fops = {static const struct v4l2_ioctl_ops imgu_v4l2_ioctl_ops = { .vidioc_querycap = imgu_vidioc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, .vidioc_g_fmt_vid_cap_mplane = imgu_vidioc_g_fmt, .vidioc_s_fmt_vid_cap_mplane = imgu_vidioc_s_fmt, .vidioc_try_fmt_vid_cap_mplane = imgu_vidioc_try_fmt, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out, .vidioc_g_fmt_vid_out_mplane = imgu_vidioc_g_fmt, .vidioc_s_fmt_vid_out_mplane = imgu_vidioc_s_fmt, .vidioc_try_fmt_vid_out_mplane = imgu_vidioc_try_fmt,
drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c +2 -2
@@ -493,8 +493,8 @@ const struct v4l2_ioctl_ops rockchip_vpu_enc_ioctl_ops = { .vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_cap_mplane, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt_out_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_cap_mplane, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out_mplane, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap_mplane, .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, .vidioc_querybuf = v4l2_m2m_ioctl_querybuf,
include/media/v4l2-ioctl.h +2 -12
@@ -26,19 +26,13 @@ struct v4l2_fh;* :ref:`VIDIOC_QUERYCAP <vidioc_querycap>` ioctl * @vidioc_enum_fmt_vid_cap: pointer to the function that implements * :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic -* for video capture in single plane mode +* for video capture in single and multi plane mode * @vidioc_enum_fmt_vid_overlay: pointer to the function that implements * :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic * for video overlay * @vidioc_enum_fmt_vid_out: pointer to the function that implements * :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic -* for video output in single plane mode -* @vidioc_enum_fmt_vid_cap_mplane: pointer to the function that implements -* :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic -* for video capture in multiplane mode -* @vidioc_enum_fmt_vid_out_mplane: pointer to the function that implements -* :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic -* for video output in multiplane mode +* for video output in single and multi plane mode * @vidioc_enum_fmt_sdr_cap: pointer to the function that implements * :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic * for Software Defined Radio capture
@@ -313,10 +307,6 @@ struct v4l2_ioctl_ops { struct v4l2_fmtdesc *f);int (*vidioc_enum_fmt_vid_out)(struct file *file,void *fh,struct v4l2_fmtdesc *f); -int (*vidioc_enum_fmt_vid_cap_mplane)(struct file *file,void *fh, -struct v4l2_fmtdesc *f); -int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file,void *fh, -struct v4l2_fmtdesc *f);int (*vidioc_enum_fmt_sdr_cap)(struct file *file,void *fh,struct v4l2_fmtdesc *f); int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *fh,
Signature · 1 line
2.20.1
Re: [RFC PATCH v2 1/7] media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap,out}_mplane
Quoted 5 lines · Boris Brezillon
Support for multiplanar and singleplanar formats is mutually exclusive, at least in practice. In our attempt to unify support for support for mplane and !mplane in v4l, let's get rid of the ->vidioc_enum_fmt_{vid,out}_cap_mplane() hooks and call ->vidioc_enum_fmt_{vid,out}_cap() instead.
This is a good idea. This can be done separately from the other patches in this series and merged.
One comment...
Quoted 54 lines
Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- None--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 ++-- .../media/platform/exynos4-is/fimc-capture.c | 2 +- .../platform/exynos4-is/fimc-isp-video.c | 2 +- drivers/media/platform/exynos4-is/fimc-lite.c | 2 +- drivers/media/platform/exynos4-is/fimc-m2m.c | 4 ++-- .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 4 ++-- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 4 ++-- .../platform/mtk-vcodec/mtk_vcodec_dec.c | 4 ++-- .../platform/mtk-vcodec/mtk_vcodec_enc.c | 4 ++-- .../media/platform/qcom/camss/camss-video.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 4 ++-- drivers/media/platform/qcom/venus/venc.c | 4 ++-- drivers/media/platform/rcar_fdp1.c | 4 ++-- drivers/media/platform/rcar_jpu.c | 4 ++-- drivers/media/platform/renesas-ceu.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 4 ++-- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 4 ++-- drivers/media/platform/ti-vpe/vpe.c | 4 ++-- drivers/media/platform/vicodec/vicodec-core.c | 2 -- drivers/media/platform/vivid/vivid-core.c | 6 ++---- .../media/platform/vivid/vivid-vid-common.c | 20 ------------------ .../media/platform/vivid/vivid-vid-common.h | 2 -- drivers/media/v4l2-core/v4l2-dev.c | 2 -- drivers/media/v4l2-core/v4l2-ioctl.c | 21 ++++++++++--------- drivers/staging/media/ipu3/ipu3-v4l2.c | 4 ++-- .../media/rockchip/vpu/rockchip_vpu_enc.c | 4 ++-- include/media/v4l2-ioctl.h | 14 ++----------- 28 files changed, 51 insertions(+), 88 deletions(-)drivers/media/pci/intel/ipu3/ipu3-cio2.c +1
-1@@ -1174,7 +1174,7 @@ static const struct v4l2_file_operations cio2_v4l2_fops = {static const struct v4l2_ioctl_ops cio2_v4l2_ioctl_ops = { .vidioc_querycap = cio2_v4l2_querycap, - .vidioc_enum_fmt_vid_cap_mplane = cio2_v4l2_enum_fmt, + .vidioc_enum_fmt_vid_cap = cio2_v4l2_enum_fmt, .vidioc_g_fmt_vid_cap_mplane = cio2_v4l2_g_fmt, .vidioc_s_fmt_vid_cap_mplane = cio2_v4l2_s_fmt, .vidioc_try_fmt_vid_cap_mplane = cio2_v4l2_try_fmt,drivers/media/platform/exynos-gsc/gsc-m2m.c +0
-0
drivers/media/platform/exynos-gsc/gsc-m2m.c static int gsc_m2m_s_selection(struct file *file, void *fh, · line 566
Quoted 7 lines
drivers/media/platform/exynos-gsc/gsc-m2m.c +2
-2@@ -562,8 +562,8 @@ static int gsc_m2m_s_selection(struct file *file, void *fh,static const struct v4l2_ioctl_ops gsc_m2m_ioctl_ops = { .vidioc_querycap = gsc_m2m_querycap, - .vidioc_enum_fmt_vid_cap_mplane = gsc_m2m_enum_fmt_mplane, - .vidioc_enum_fmt_vid_out_mplane = gsc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = gsc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_out = gsc_m2m_enum_fmt_mplane,
Please rename the functions as well, dropping the _mplane suffix. Here and in the other drivers.
Quoted 372 lines
drivers/media/platform/exynos-gsc/gsc-m2m.c +0
-0.vidioc_g_fmt_vid_cap_mplane = gsc_m2m_g_fmt_mplane, .vidioc_g_fmt_vid_out_mplane = gsc_m2m_g_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = gsc_m2m_try_fmt_mplane,drivers/media/platform/exynos4-is/fimc-capture.c +1
-1@@ -1361,7 +1361,7 @@ static int fimc_cap_s_selection(struct file *file, void *fh,static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops = { .vidioc_querycap = fimc_cap_querycap, - .vidioc_enum_fmt_vid_cap_mplane = fimc_cap_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = fimc_cap_enum_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = fimc_cap_try_fmt_mplane, .vidioc_s_fmt_vid_cap_mplane = fimc_cap_s_fmt_mplane, .vidioc_g_fmt_vid_cap_mplane = fimc_cap_g_fmt_mplane,drivers/media/platform/exynos4-is/fimc-isp-video.c +1
-1@@ -551,7 +551,7 @@ static int isp_video_reqbufs(struct file *file, void *priv,static const struct v4l2_ioctl_ops isp_video_ioctl_ops = { .vidioc_querycap = isp_video_querycap, - .vidioc_enum_fmt_vid_cap_mplane = isp_video_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = isp_video_enum_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = isp_video_try_fmt_mplane, .vidioc_s_fmt_vid_cap_mplane = isp_video_s_fmt_mplane, .vidioc_g_fmt_vid_cap_mplane = isp_video_g_fmt_mplane,drivers/media/platform/exynos4-is/fimc-lite.c +1
-1@@ -954,7 +954,7 @@ static int fimc_lite_s_selection(struct file *file, void *fh,static const struct v4l2_ioctl_ops fimc_lite_ioctl_ops = { .vidioc_querycap = fimc_lite_querycap, - .vidioc_enum_fmt_vid_cap_mplane = fimc_lite_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = fimc_lite_enum_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = fimc_lite_try_fmt_mplane, .vidioc_s_fmt_vid_cap_mplane = fimc_lite_s_fmt_mplane, .vidioc_g_fmt_vid_cap_mplane = fimc_lite_g_fmt_mplane,drivers/media/platform/exynos4-is/fimc-m2m.c +2
-2@@ -533,8 +533,8 @@ static int fimc_m2m_s_selection(struct file *file, void *fh,static const struct v4l2_ioctl_ops fimc_m2m_ioctl_ops = { .vidioc_querycap = fimc_m2m_querycap, - .vidioc_enum_fmt_vid_cap_mplane = fimc_m2m_enum_fmt_mplane, - .vidioc_enum_fmt_vid_out_mplane = fimc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = fimc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_out = fimc_m2m_enum_fmt_mplane, .vidioc_g_fmt_vid_cap_mplane = fimc_m2m_g_fmt_mplane, .vidioc_g_fmt_vid_out_mplane = fimc_m2m_g_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = fimc_m2m_try_fmt_mplane,drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +2
-2@@ -536,8 +536,8 @@ static int mtk_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)static const struct v4l2_ioctl_ops mtk_jpeg_ioctl_ops = { .vidioc_querycap = mtk_jpeg_querycap, - .vidioc_enum_fmt_vid_cap_mplane = mtk_jpeg_enum_fmt_vid_cap, - .vidioc_enum_fmt_vid_out_mplane = mtk_jpeg_enum_fmt_vid_out, + .vidioc_enum_fmt_vid_cap = mtk_jpeg_enum_fmt_vid_cap, + .vidioc_enum_fmt_vid_out = mtk_jpeg_enum_fmt_vid_out, .vidioc_try_fmt_vid_cap_mplane = mtk_jpeg_try_fmt_vid_cap_mplane, .vidioc_try_fmt_vid_out_mplane = mtk_jpeg_try_fmt_vid_out_mplane, .vidioc_g_fmt_vid_cap_mplane = mtk_jpeg_g_fmt_vid_mplane,drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c +2
-2@@ -935,8 +935,8 @@ static int mtk_mdp_m2m_s_selection(struct file *file, void *fh,static const struct v4l2_ioctl_ops mtk_mdp_m2m_ioctl_ops = { .vidioc_querycap = mtk_mdp_m2m_querycap, - .vidioc_enum_fmt_vid_cap_mplane = mtk_mdp_m2m_enum_fmt_mplane_vid_cap, - .vidioc_enum_fmt_vid_out_mplane = mtk_mdp_m2m_enum_fmt_mplane_vid_out, + .vidioc_enum_fmt_vid_cap = mtk_mdp_m2m_enum_fmt_mplane_vid_cap, + .vidioc_enum_fmt_vid_out = mtk_mdp_m2m_enum_fmt_mplane_vid_out, .vidioc_g_fmt_vid_cap_mplane = mtk_mdp_m2m_g_fmt_mplane, .vidioc_g_fmt_vid_out_mplane = mtk_mdp_m2m_g_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = mtk_mdp_m2m_try_fmt_mplane,drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c +2
-2@@ -1444,8 +1444,8 @@ const struct v4l2_ioctl_ops mtk_vdec_ioctl_ops = { .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_vdec_enum_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out_mplane = vidioc_vdec_enum_fmt_vid_out_mplane, + .vidioc_enum_fmt_vid_cap = vidioc_vdec_enum_fmt_vid_cap_mplane, + .vidioc_enum_fmt_vid_out = vidioc_vdec_enum_fmt_vid_out_mplane, .vidioc_enum_framesizes = vidioc_enum_framesizes, .vidioc_querycap = vidioc_vdec_querycap,drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +2
-2@@ -725,8 +725,8 @@ const struct v4l2_ioctl_ops mtk_venc_ioctl_ops = { .vidioc_dqbuf = vidioc_venc_dqbuf, .vidioc_querycap = vidioc_venc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap_mplane, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out_mplane, .vidioc_enum_framesizes = vidioc_enum_framesizes, .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap_mplane,drivers/media/platform/qcom/camss/camss-video.c +1
-1@@ -703,7 +703,7 @@ static int video_s_input(struct file *file, void *fh, unsigned int input)static const struct v4l2_ioctl_ops msm_vid_ioctl_ops = { .vidioc_querycap = video_querycap, - .vidioc_enum_fmt_vid_cap_mplane = video_enum_fmt, + .vidioc_enum_fmt_vid_cap = video_enum_fmt, .vidioc_g_fmt_vid_cap_mplane = video_g_fmt, .vidioc_s_fmt_vid_cap_mplane = video_s_fmt, .vidioc_try_fmt_vid_cap_mplane = video_try_fmt,drivers/media/platform/qcom/venus/vdec.c +2
-2@@ -491,8 +491,8 @@ vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd)static const struct v4l2_ioctl_ops vdec_ioctl_ops = { .vidioc_querycap = vdec_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vdec_enum_fmt, - .vidioc_enum_fmt_vid_out_mplane = vdec_enum_fmt, + .vidioc_enum_fmt_vid_cap = vdec_enum_fmt, + .vidioc_enum_fmt_vid_out = vdec_enum_fmt, .vidioc_s_fmt_vid_cap_mplane = vdec_s_fmt, .vidioc_s_fmt_vid_out_mplane = vdec_s_fmt, .vidioc_g_fmt_vid_cap_mplane = vdec_g_fmt,drivers/media/platform/qcom/venus/venc.c +2
-2@@ -616,8 +616,8 @@ static int venc_enum_frameintervals(struct file *file, void *fh,static const struct v4l2_ioctl_ops venc_ioctl_ops = { .vidioc_querycap = venc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = venc_enum_fmt, - .vidioc_enum_fmt_vid_out_mplane = venc_enum_fmt, + .vidioc_enum_fmt_vid_cap = venc_enum_fmt, + .vidioc_enum_fmt_vid_out = venc_enum_fmt, .vidioc_s_fmt_vid_cap_mplane = venc_s_fmt, .vidioc_s_fmt_vid_out_mplane = venc_s_fmt, .vidioc_g_fmt_vid_cap_mplane = venc_g_fmt,drivers/media/platform/rcar_fdp1.c +2
-2@@ -1730,8 +1730,8 @@ static const char * const fdp1_ctrl_deint_menu[] = {static const struct v4l2_ioctl_ops fdp1_ioctl_ops = { .vidioc_querycap = fdp1_vidioc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = fdp1_enum_fmt_vid_cap, - .vidioc_enum_fmt_vid_out_mplane = fdp1_enum_fmt_vid_out, + .vidioc_enum_fmt_vid_cap = fdp1_enum_fmt_vid_cap, + .vidioc_enum_fmt_vid_out = fdp1_enum_fmt_vid_out, .vidioc_g_fmt_vid_cap_mplane = fdp1_g_fmt, .vidioc_g_fmt_vid_out_mplane = fdp1_g_fmt, .vidioc_try_fmt_vid_cap_mplane = fdp1_try_fmt,drivers/media/platform/rcar_jpu.c +2
-2@@ -948,8 +948,8 @@ static int jpu_streamon(struct file *file, void *priv, enum v4l2_buf_type type)static const struct v4l2_ioctl_ops jpu_ioctl_ops = { .vidioc_querycap = jpu_querycap, - .vidioc_enum_fmt_vid_cap_mplane = jpu_enum_fmt_cap, - .vidioc_enum_fmt_vid_out_mplane = jpu_enum_fmt_out, + .vidioc_enum_fmt_vid_cap = jpu_enum_fmt_cap, + .vidioc_enum_fmt_vid_out = jpu_enum_fmt_out, .vidioc_g_fmt_vid_cap_mplane = jpu_g_fmt, .vidioc_g_fmt_vid_out_mplane = jpu_g_fmt, .vidioc_try_fmt_vid_cap_mplane = jpu_try_fmt,drivers/media/platform/renesas-ceu.c +1
-1@@ -1339,7 +1339,7 @@ static int ceu_enum_frameintervals(struct file *file, void *fh,static const struct v4l2_ioctl_ops ceu_ioctl_ops = { .vidioc_querycap = ceu_querycap, - .vidioc_enum_fmt_vid_cap_mplane = ceu_enum_fmt_vid_cap, + .vidioc_enum_fmt_vid_cap = ceu_enum_fmt_vid_cap, .vidioc_try_fmt_vid_cap_mplane = ceu_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap_mplane = ceu_s_fmt_vid_cap, .vidioc_g_fmt_vid_cap_mplane = ceu_g_fmt_vid_cap,drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +2
-2@@ -887,8 +887,8 @@ static int vidioc_subscribe_event(struct v4l2_fh *fh,/* v4l2_ioctl_ops */ static const struct v4l2_ioctl_ops s5p_mfc_dec_ioctl_ops = { .vidioc_querycap = vidioc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap_mplane, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt, .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt,drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +2
-2@@ -2343,8 +2343,8 @@ static int vidioc_subscribe_event(struct v4l2_fh *fh,static const struct v4l2_ioctl_ops s5p_mfc_enc_ioctl_ops = { .vidioc_querycap = vidioc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap_mplane, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt, .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt,drivers/media/platform/ti-vpe/vpe.c +2
-2@@ -1973,12 +1973,12 @@ static const struct v4l2_ctrl_ops vpe_ctrl_ops = {static const struct v4l2_ioctl_ops vpe_ioctl_ops = { .vidioc_querycap = vpe_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vpe_enum_fmt, + .vidioc_enum_fmt_vid_cap = vpe_enum_fmt, .vidioc_g_fmt_vid_cap_mplane = vpe_g_fmt, .vidioc_try_fmt_vid_cap_mplane = vpe_try_fmt, .vidioc_s_fmt_vid_cap_mplane = vpe_s_fmt, - .vidioc_enum_fmt_vid_out_mplane = vpe_enum_fmt, + .vidioc_enum_fmt_vid_out = vpe_enum_fmt, .vidioc_g_fmt_vid_out_mplane = vpe_g_fmt, .vidioc_try_fmt_vid_out_mplane = vpe_try_fmt, .vidioc_s_fmt_vid_out_mplane = vpe_s_fmt,drivers/media/platform/vicodec/vicodec-core.c +0
-2@@ -1140,7 +1140,6 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = { .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_vid_cap, .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_vid_cap,@@ -1150,7 +1149,6 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = { .vidioc_try_fmt_vid_out = vidioc_try_fmt_vid_out, .vidioc_s_fmt_vid_out = vidioc_s_fmt_vid_out, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt_vid_out, .vidioc_try_fmt_vid_out_mplane = vidioc_try_fmt_vid_out, .vidioc_s_fmt_vid_out_mplane = vidioc_s_fmt_vid_out,drivers/media/platform/vivid/vivid-core.c +2
-4@@ -500,20 +500,18 @@ static const struct v4l2_file_operations vivid_radio_fops = {static const struct v4l2_ioctl_ops vivid_ioctl_ops = { .vidioc_querycap = vidioc_querycap, - .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid, + .vidioc_enum_fmt_vid_cap = vivid_enum_fmt_vid, .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_vid_cap_mplane, .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap_mplane, .vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid, + .vidioc_enum_fmt_vid_out = vivid_enum_fmt_vid, .vidioc_g_fmt_vid_out = vidioc_g_fmt_vid_out, .vidioc_try_fmt_vid_out = vidioc_try_fmt_vid_out, .vidioc_s_fmt_vid_out = vidioc_s_fmt_vid_out, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_mplane, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt_vid_out_mplane, .vidioc_try_fmt_vid_out_mplane = vidioc_try_fmt_vid_out_mplane, .vidioc_s_fmt_vid_out_mplane = vidioc_s_fmt_vid_out_mplane,drivers/media/platform/vivid/vivid-vid-common.c +0
-20@@ -797,26 +797,6 @@ int vivid_enum_fmt_vid(struct file *file, void *priv,return 0 ; } -int vidioc_enum_fmt_vid_mplane (struct file *file,void *priv, -struct v4l2_fmtdesc *f) -{ -struct vivid_dev *dev =video_drvdata (file); - -if (!dev->multiplanar) -return -ENOTTY ; -return vivid_enum_fmt_vid (file, priv, f); -} - -int vidioc_enum_fmt_vid (struct file *file,void *priv, -struct v4l2_fmtdesc *f) -{ -struct vivid_dev *dev =video_drvdata (file); - -if (dev->multiplanar) -return -ENOTTY ; -return vivid_enum_fmt_vid (file, priv, f); -} -int vidioc_g_std (struct file *file,void *priv,v4l2_std_id *id) {struct vivid_dev *dev =video_drvdata (file);drivers/media/platform/vivid/vivid-vid-common.h +0
-2@@ -28,8 +28,6 @@ void vivid_send_source_change(struct vivid_dev *dev, unsigned type);int vivid_vid_adjust_sel (unsigned flags,struct v4l2_rect *r);int vivid_enum_fmt_vid (struct file *file,void *priv,struct v4l2_fmtdesc *f); -int vidioc_enum_fmt_vid_mplane (struct file *file,void *priv,struct v4l2_fmtdesc *f); -int vidioc_enum_fmt_vid (struct file *file,void *priv,struct v4l2_fmtdesc *f);int vidioc_g_std (struct file *file,void *priv,v4l2_std_id *id);int vidioc_g_dv_timings (struct file *file,void *_fh,struct v4l2_dv_timings *timings);int vidioc_enum_dv_timings (struct file *file,void *_fh,struct v4l2_enum_dv_timings *timings);drivers/media/v4l2-core/v4l2-dev.c +0
-2@@ -593,11 +593,9 @@ static void determine_valid_ioctls(struct video_device *vdev)if (is_vid || is_tch) {/* video and metadata specific ioctls */ if ((is_rx && (ops->vidioc_enum_fmt_vid_cap || - ops->vidioc_enum_fmt_vid_cap_mplane || ops->vidioc_enum_fmt_vid_overlay || ops->vidioc_enum_fmt_meta_cap)) || (is_tx && (ops->vidioc_enum_fmt_vid_out || - ops->vidioc_enum_fmt_vid_out_mplane || ops->vidioc_enum_fmt_meta_out)))set_bit (_IOC_NR (VIDIOC_ENUM_FMT ), valid_ioctls); if ((is_rx && (ops->vidioc_g_fmt_vid_cap ||drivers/media/v4l2-core/v4l2-ioctl.c +1
-0@@ -1380,6 +1380,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)static int v4l_enum_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) { +struct video_device *vdev =video_devdata (file);struct v4l2_fmtdesc *p = arg;int ret =check_fmt (file, p->type);
drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, · line 1394
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ioctl.c +2
-0@@ -1389,30 +1390,30 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : + if (!!(vdev->device_caps & V4L2_CAP_VIDEO_CAPTURE_MPLANE) !=
Hmm. I am not sure if all drivers that set V4L2_CAP_VIDEO_CAPTURE_MPLANE also fill in vdev->device_caps. While filling in vdev->device_caps is required for new drivers, older drivers often don't do this.
You would have to check all drivers that set V4L2_CAP_VIDEO_CAPTURE/OUTPUT_MPLANE to verify that they also set vdev->device_caps. I'm fairly certain the Samsung drivers don't fill this in.
Quoted 12 lines
drivers/media/v4l2-core/v4l2-ioctl.c +3
-5+ (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) + break; +if (unlikely (!ops->vidioc_enum_fmt_vid_cap))break ; ret = ops->vidioc_enum_fmt_vid_cap (file, fh, arg);break ; -case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : -if (unlikely (!ops->vidioc_enum_fmt_vid_cap_mplane)) -break ; - ret = ops->vidioc_enum_fmt_vid_cap_mplane (file, fh, arg); -break ;
drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, · line 1411
Quoted 10 lines
drivers/media/v4l2-core/v4l2-ioctl.c +4
-0case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_enum_fmt_vid_overlay))break ; ret = ops->vidioc_enum_fmt_vid_overlay (file, fh, arg);break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT : +case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : +if (!!(vdev->device_caps &V4L2_CAP_VIDEO_OUTPUT_MPLANE ) != + (p->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE )) +break ;
See comment above.
Quoted 75 lines
drivers/media/v4l2-core/v4l2-ioctl.c +1
-5+if (unlikely (!ops->vidioc_enum_fmt_vid_out))break ; ret = ops->vidioc_enum_fmt_vid_out (file, fh, arg);break ; -case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : -if (unlikely (!ops->vidioc_enum_fmt_vid_out_mplane)) -break ; - ret = ops->vidioc_enum_fmt_vid_out_mplane (file, fh, arg); -break ;case V4L2_BUF_TYPE_SDR_CAPTURE :if (unlikely (!ops->vidioc_enum_fmt_sdr_cap))break ;drivers/staging/media/ipu3/ipu3-v4l2.c +2
-2@@ -959,12 +959,12 @@ static const struct v4l2_file_operations imgu_v4l2_fops = {static const struct v4l2_ioctl_ops imgu_v4l2_ioctl_ops = { .vidioc_querycap = imgu_vidioc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, .vidioc_g_fmt_vid_cap_mplane = imgu_vidioc_g_fmt, .vidioc_s_fmt_vid_cap_mplane = imgu_vidioc_s_fmt, .vidioc_try_fmt_vid_cap_mplane = imgu_vidioc_try_fmt, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out, .vidioc_g_fmt_vid_out_mplane = imgu_vidioc_g_fmt, .vidioc_s_fmt_vid_out_mplane = imgu_vidioc_s_fmt, .vidioc_try_fmt_vid_out_mplane = imgu_vidioc_try_fmt,drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c +2
-2@@ -493,8 +493,8 @@ const struct v4l2_ioctl_ops rockchip_vpu_enc_ioctl_ops = { .vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_cap_mplane, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt_out_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_cap_mplane, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out_mplane, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap_mplane, .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, .vidioc_querybuf = v4l2_m2m_ioctl_querybuf,include/media/v4l2-ioctl.h +2
-8@@ -26,19 +26,13 @@ struct v4l2_fh;* :ref:`VIDIOC_QUERYCAP <vidioc_querycap>` ioctl * @vidioc_enum_fmt_vid_cap: pointer to the function that implements * :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic -* for video capture in single plane mode +* for video capture in single and multi plane mode * @vidioc_enum_fmt_vid_overlay: pointer to the function that implements * :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic * for video overlay * @vidioc_enum_fmt_vid_out: pointer to the function that implements * :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic -* for video output in single plane mode -* @vidioc_enum_fmt_vid_cap_mplane: pointer to the function that implements -* :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic -* for video capture in multiplane mode -* @vidioc_enum_fmt_vid_out_mplane: pointer to the function that implements -* :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic -* for video output in multiplane mode +* for video output in single and multi plane mode * @vidioc_enum_fmt_sdr_cap: pointer to the function that implements * :ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic * for Software Defined Radio capture
include/media/v4l2-ioctl.h struct v4l2_ioctl_ops { · line 312
Quoted 10 lines
include/media/v4l2-ioctl.h +0
-4@@ -313,10 +307,6 @@ struct v4l2_ioctl_ops { struct v4l2_fmtdesc *f);int (*vidioc_enum_fmt_vid_out)(struct file *file,void *fh,struct v4l2_fmtdesc *f); -int (*vidioc_enum_fmt_vid_cap_mplane)(struct file *file,void *fh, -struct v4l2_fmtdesc *f); -int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file,void *fh, -struct v4l2_fmtdesc *f);int (*vidioc_enum_fmt_sdr_cap)(struct file *file,void *fh,struct v4l2_fmtdesc *f); int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *fh,
Regards,
Hans
Re: [RFC PATCH v2 1/7] media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap,out}_mplane
Quoted 9 lines · On Thu, 11 Apr 2019 09:59:19 +0200 Hans Verkuil <[email protected]> wrote:
Quoted 5 lines · Boris Brezillon
Support for multiplanar and singleplanar formats is mutually exclusive, at least in practice. In our attempt to unify support for support for mplane and !mplane in v4l, let's get rid of the ->vidioc_enum_fmt_{vid,out}_cap_mplane() hooks and call ->vidioc_enum_fmt_{vid,out}_cap() instead.
This is a good idea. This can be done separately from the other patches in this series and merged.
Sure, I'll send this patch separately.
Quoted 58 lines
One comment...
Quoted 55 lines
Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- None--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 ++-- .../media/platform/exynos4-is/fimc-capture.c | 2 +- .../platform/exynos4-is/fimc-isp-video.c | 2 +- drivers/media/platform/exynos4-is/fimc-lite.c | 2 +- drivers/media/platform/exynos4-is/fimc-m2m.c | 4 ++-- .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 4 ++-- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 4 ++-- .../platform/mtk-vcodec/mtk_vcodec_dec.c | 4 ++-- .../platform/mtk-vcodec/mtk_vcodec_enc.c | 4 ++-- .../media/platform/qcom/camss/camss-video.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 4 ++-- drivers/media/platform/qcom/venus/venc.c | 4 ++-- drivers/media/platform/rcar_fdp1.c | 4 ++-- drivers/media/platform/rcar_jpu.c | 4 ++-- drivers/media/platform/renesas-ceu.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 4 ++-- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 4 ++-- drivers/media/platform/ti-vpe/vpe.c | 4 ++-- drivers/media/platform/vicodec/vicodec-core.c | 2 -- drivers/media/platform/vivid/vivid-core.c | 6 ++---- .../media/platform/vivid/vivid-vid-common.c | 20 ------------------ .../media/platform/vivid/vivid-vid-common.h | 2 -- drivers/media/v4l2-core/v4l2-dev.c | 2 -- drivers/media/v4l2-core/v4l2-ioctl.c | 21 ++++++++++--------- drivers/staging/media/ipu3/ipu3-v4l2.c | 4 ++-- .../media/rockchip/vpu/rockchip_vpu_enc.c | 4 ++-- include/media/v4l2-ioctl.h | 14 ++----------- 28 files changed, 51 insertions(+), 88 deletions(-)drivers/media/pci/intel/ipu3/ipu3-cio2.c +1
-1@@ -1174,7 +1174,7 @@ static const struct v4l2_file_operations cio2_v4l2_fops = {static const struct v4l2_ioctl_ops cio2_v4l2_ioctl_ops = { .vidioc_querycap = cio2_v4l2_querycap, - .vidioc_enum_fmt_vid_cap_mplane = cio2_v4l2_enum_fmt, + .vidioc_enum_fmt_vid_cap = cio2_v4l2_enum_fmt, .vidioc_g_fmt_vid_cap_mplane = cio2_v4l2_g_fmt, .vidioc_s_fmt_vid_cap_mplane = cio2_v4l2_s_fmt, .vidioc_try_fmt_vid_cap_mplane = cio2_v4l2_try_fmt,drivers/media/platform/exynos-gsc/gsc-m2m.c +0
-0@@ -562,8 +562,8 @@ static int gsc_m2m_s_selection(struct file *file, void *fh,
Quoted 10 lines
drivers/media/platform/exynos-gsc/gsc-m2m.c static int gsc_m2m_s_selection(struct file *file, void *fh, · line 566
Quoted 6 lines
drivers/media/platform/exynos-gsc/gsc-m2m.c +2
-2static const struct v4l2_ioctl_ops gsc_m2m_ioctl_ops = { .vidioc_querycap = gsc_m2m_querycap, - .vidioc_enum_fmt_vid_cap_mplane = gsc_m2m_enum_fmt_mplane, - .vidioc_enum_fmt_vid_out_mplane = gsc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = gsc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_out = gsc_m2m_enum_fmt_mplane,Please rename the functions as well, dropping the
_mplanesuffix. Here and in the other drivers.
Okay, I'm remove those _mplane suffix.
Quoted 23 lines
Quoted 13 lines
drivers/media/v4l2-core/v4l2-ioctl.c +1
-0@@ -1380,6 +1380,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)static int v4l_enum_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) { +struct video_device *vdev =video_devdata (file);struct v4l2_fmtdesc *p = arg;int ret =check_fmt (file, p->type);drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, · line 1394
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ioctl.c +2
-0@@ -1389,30 +1390,30 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : + if (!!(vdev->device_caps & V4L2_CAP_VIDEO_CAPTURE_MPLANE) !=Hmm. I am not sure if all drivers that set
V4L2_CAP_VIDEO_CAPTURE_MPLANEalso fill invdev->device_caps. While filling invdev->device_capsis required for new drivers, older drivers often don't do this.
Quoted 3 lines
You would have to check all drivers that set V4L2_CAP_VIDEO_CAPTURE/OUTPUT_MPLANE to verify that they also set
vdev->device_caps. I'm fairly certain the Samsung drivers don't fill this in.
I'll check that and fix those that don't set the flag. Or do you have another solution to handle that case?
Re: [RFC PATCH v2 1/7] media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap,out}_mplane
Quoted 109 lines · Boris Brezillon
Quoted 9 lines · On Thu, 11 Apr 2019 09:59:19 +0200 Hans Verkuil <[email protected]> wrote:
Quoted 5 lines · Boris Brezillon
Support for multiplanar and singleplanar formats is mutually exclusive, at least in practice. In our attempt to unify support for support for mplane and !mplane in v4l, let's get rid of the ->vidioc_enum_fmt_{vid,out}_cap_mplane() hooks and call ->vidioc_enum_fmt_{vid,out}_cap() instead.
This is a good idea. This can be done separately from the other patches in this series and merged.
Sure, I'll send this patch separately.
Quoted 58 lines
One comment...
Quoted 55 lines
Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- None--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 ++-- .../media/platform/exynos4-is/fimc-capture.c | 2 +- .../platform/exynos4-is/fimc-isp-video.c | 2 +- drivers/media/platform/exynos4-is/fimc-lite.c | 2 +- drivers/media/platform/exynos4-is/fimc-m2m.c | 4 ++-- .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 4 ++-- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 4 ++-- .../platform/mtk-vcodec/mtk_vcodec_dec.c | 4 ++-- .../platform/mtk-vcodec/mtk_vcodec_enc.c | 4 ++-- .../media/platform/qcom/camss/camss-video.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 4 ++-- drivers/media/platform/qcom/venus/venc.c | 4 ++-- drivers/media/platform/rcar_fdp1.c | 4 ++-- drivers/media/platform/rcar_jpu.c | 4 ++-- drivers/media/platform/renesas-ceu.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 4 ++-- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 4 ++-- drivers/media/platform/ti-vpe/vpe.c | 4 ++-- drivers/media/platform/vicodec/vicodec-core.c | 2 -- drivers/media/platform/vivid/vivid-core.c | 6 ++---- .../media/platform/vivid/vivid-vid-common.c | 20 ------------------ .../media/platform/vivid/vivid-vid-common.h | 2 -- drivers/media/v4l2-core/v4l2-dev.c | 2 -- drivers/media/v4l2-core/v4l2-ioctl.c | 21 ++++++++++--------- drivers/staging/media/ipu3/ipu3-v4l2.c | 4 ++-- .../media/rockchip/vpu/rockchip_vpu_enc.c | 4 ++-- include/media/v4l2-ioctl.h | 14 ++----------- 28 files changed, 51 insertions(+), 88 deletions(-)drivers/media/pci/intel/ipu3/ipu3-cio2.c +1
-1@@ -1174,7 +1174,7 @@ static const struct v4l2_file_operations cio2_v4l2_fops = {static const struct v4l2_ioctl_ops cio2_v4l2_ioctl_ops = { .vidioc_querycap = cio2_v4l2_querycap, - .vidioc_enum_fmt_vid_cap_mplane = cio2_v4l2_enum_fmt, + .vidioc_enum_fmt_vid_cap = cio2_v4l2_enum_fmt, .vidioc_g_fmt_vid_cap_mplane = cio2_v4l2_g_fmt, .vidioc_s_fmt_vid_cap_mplane = cio2_v4l2_s_fmt, .vidioc_try_fmt_vid_cap_mplane = cio2_v4l2_try_fmt,drivers/media/platform/exynos-gsc/gsc-m2m.c +0
-0@@ -562,8 +562,8 @@ static int gsc_m2m_s_selection(struct file *file, void *fh,Quoted 10 lines
drivers/media/platform/exynos-gsc/gsc-m2m.c static int gsc_m2m_s_selection(struct file *file, void *fh, · line 566
Quoted 6 lines
drivers/media/platform/exynos-gsc/gsc-m2m.c +2
-2static const struct v4l2_ioctl_ops gsc_m2m_ioctl_ops = { .vidioc_querycap = gsc_m2m_querycap, - .vidioc_enum_fmt_vid_cap_mplane = gsc_m2m_enum_fmt_mplane, - .vidioc_enum_fmt_vid_out_mplane = gsc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_cap = gsc_m2m_enum_fmt_mplane, + .vidioc_enum_fmt_vid_out = gsc_m2m_enum_fmt_mplane,Please rename the functions as well, dropping the
_mplanesuffix. Here and in the other drivers.Okay, I'm remove those
_mplanesuffix.Quoted 23 lines
Quoted 13 lines
drivers/media/v4l2-core/v4l2-ioctl.c +1
-0@@ -1380,6 +1380,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)static int v4l_enum_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) { +struct video_device *vdev =video_devdata (file);struct v4l2_fmtdesc *p = arg;int ret =check_fmt (file, p->type);drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, · line 1394
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ioctl.c +2
-0@@ -1389,30 +1390,30 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : + if (!!(vdev->device_caps & V4L2_CAP_VIDEO_CAPTURE_MPLANE) !=Hmm. I am not sure if all drivers that set
V4L2_CAP_VIDEO_CAPTURE_MPLANEalso fill invdev->device_caps. While filling invdev->device_capsis required for new drivers, older drivers often don't do this.
Quoted 7 lines
Quoted 3 lines
You would have to check all drivers that set V4L2_CAP_VIDEO_CAPTURE/OUTPUT_MPLANE to verify that they also set
vdev->device_caps. I'm fairly certain the Samsung drivers don't fill this in.I'll check that and fix those that don't set the flag. Or do you have another solution to handle that case?
There might be other solutions as well, but regardless of that it would be a very good idea for other reasons as well if all MPLANE drivers would fill in vdev->device_caps.
Regards,
Hans
Re: [RFC PATCH v2 1/7] media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap,out}_mplane
Quoted 27 lines · On Thu, 11 Apr 2019 12:38:06 +0200 Hans Verkuil <[email protected]> wrote:
Quoted 27 lines
Quoted 26 lines
Quoted 13 lines
drivers/media/v4l2-core/v4l2-ioctl.c +1
-0@@ -1380,6 +1380,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)static int v4l_enum_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) { +struct video_device *vdev =video_devdata (file);struct v4l2_fmtdesc *p = arg;int ret =check_fmt (file, p->type);drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, · line 1394
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ioctl.c +2
-0@@ -1389,30 +1390,30 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : + if (!!(vdev->device_caps & V4L2_CAP_VIDEO_CAPTURE_MPLANE) !=Hmm. I am not sure if all drivers that set
V4L2_CAP_VIDEO_CAPTURE_MPLANEalso fill invdev->device_caps. While filling invdev->device_capsis required for new drivers, older drivers often don't do this.You would have to check all drivers that set V4L2_CAP_VIDEO_CAPTURE/OUTPUT_MPLANE to verify that they also set
vdev->device_caps. I'm fairly certain the Samsung drivers don't fill this in.
Quoted 6 lines
Quoted 3 lines
I'll check that and fix those that don't set the flag. Or do you have another solution to handle that case?
There might be other solutions as well, but regardless of that it would be a very good idea for other reasons as well if all MPLANE drivers would fill in
vdev->device_caps.
Looks like all drivers except fimc-isp-video.c have the _MPLANE caps properly set/reported.
Re: [RFC PATCH v2 1/7] media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap,out}_mplane
Quoted 34 lines · On Fri, 12 Apr 2019 10:25:26 +0200 Boris Brezillon…
Quoted 31 lines · On Thu, 11 Apr 2019 12:38:06 +0200 Hans Verkuil <[email protected]> wrote:
Quoted 30 lines
Quoted 23 lines
Quoted 13 lines
drivers/media/v4l2-core/v4l2-ioctl.c +1
-0@@ -1380,6 +1380,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)static int v4l_enum_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) { +struct video_device *vdev =video_devdata (file);struct v4l2_fmtdesc *p = arg;int ret =check_fmt (file, p->type);drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, · line 1394
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ioctl.c +2
-0@@ -1389,30 +1390,30 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : + if (!!(vdev->device_caps & V4L2_CAP_VIDEO_CAPTURE_MPLANE) !=Hmm. I am not sure if all drivers that set
V4L2_CAP_VIDEO_CAPTURE_MPLANEalso fill invdev->device_caps. While filling invdev->device_capsis required for new drivers, older drivers often don't do this.Quoted 3 lines
You would have to check all drivers that set V4L2_CAP_VIDEO_CAPTURE/OUTPUT_MPLANE to verify that they also set
vdev->device_caps. I'm fairly certain the Samsung drivers don't fill this in.I'll check that and fix those that don't set the flag. Or do you have another solution to handle that case?
Quoted 5 lines
Quoted 2 lines
There might be other solutions as well, but regardless of that it would be a very good idea for other reasons as well if all MPLANE drivers would fill in
vdev->device_caps.Looks like all drivers except
fimc-isp-video.chave the_MPLANEcaps properly set/reported.
Oh, and fimc-lite too.
Re: [RFC PATCH v2 1/7] media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap,out}_mplane
In reply to Boris BrezillonQuoted 34 lines · Boris Brezillon
Quoted 31 lines · On Thu, 11 Apr 2019 12:38:06 +0200 Hans Verkuil <[email protected]> wrote:
Quoted 30 lines
Quoted 23 lines
Quoted 13 lines
drivers/media/v4l2-core/v4l2-ioctl.c +1
-0@@ -1380,6 +1380,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)static int v4l_enum_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) { +struct video_device *vdev =video_devdata (file);struct v4l2_fmtdesc *p = arg;int ret =check_fmt (file, p->type);drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, · line 1394
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ioctl.c +2
-0@@ -1389,30 +1390,30 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : + if (!!(vdev->device_caps & V4L2_CAP_VIDEO_CAPTURE_MPLANE) !=Hmm. I am not sure if all drivers that set
V4L2_CAP_VIDEO_CAPTURE_MPLANEalso fill invdev->device_caps. While filling invdev->device_capsis required for new drivers, older drivers often don't do this.Quoted 3 lines
You would have to check all drivers that set V4L2_CAP_VIDEO_CAPTURE/OUTPUT_MPLANE to verify that they also set
vdev->device_caps. I'm fairly certain the Samsung drivers don't fill this in.I'll check that and fix those that don't set the flag. Or do you have another solution to handle that case?
Quoted 6 lines
Quoted 2 lines
There might be other solutions as well, but regardless of that it would be a very good idea for other reasons as well if all MPLANE drivers would fill in
vdev->device_caps.Looks like all drivers except
fimc-isp-video.chave the_MPLANEcaps properly set/reported.
That's not enough, they need to fill in vdev->device_caps as well. I.e., they shouldn't fill in device_caps and capabilities in their querycap implementation, instead they should just set device_caps in the struct video_device. That way the V4L2 core will know the video device capabilities since it is now stored in an internal structure.
Regards,
Hans
RFC PATCH v2 2/7 media: v4l2: Extend pixel formats to unify single/multi-planar handling (and more)
In reply to Boris BrezillonThis is part of the multiplanar and singleplanar unification process. v4l2_ext_pix_format is supposed to work for both cases.
We also add the concept of modifiers already employed in DRM to expose HW-specific formats (like tiled or compressed formats) and allow exchanging this information with the DRM subsystem in a consistent way.
Note that V4L2_BUF_TYPE_VIDEO[_OUTPUT]_OVERLAY and V4L2_BUF_TYPE_VIDEO_{CAPTURE,OUTPUT}_MPLANE types are no longer accepted in v4l2_ext_format and will be rejected if you use the {G,S,TRY}EXT_FMT ioctls. V4L2_BUF_TYPE_VIDEO_{CAPTURE,OUTPUT}_MPLANE is dropped as part of the multiplanar/singleplanar unification. V4L2_BUF_TYPE_VIDEO[_OUTPUT]_OVERLAY seems to be used mostly on old drivers and supporting it would require some extra rework.
New hooks have been added to v4l2_ioctl_ops to support those new ioctls in drivers, but, in the meantime, the core takes care of converting {S,G,TRY}_EXT_FMT requests into {S,G,TRY}_FMT so that old drivers can still work if the userspace app/lib uses the new ioctls.
The conversion is also done the other around to allow userspace apps/libs using {S,G,TRY}_FMT to work with drivers implementing the _ext_ hooks.
---
Changes in v2:
- Move the modifier in v4l2_ext_format (was formerly placed in v4l2_ext_plane)
- Fix a few bugs in the converters and add a strict parameter to allow conversion of uninitialized/mis-initialized objects
--- drivers/media/v4l2-core/v4l2-dev.c | 24 +- drivers/media/v4l2-core/v4l2-ioctl.c | 692 ++++++++++++++++++++++++--- include/media/v4l2-ioctl.h | 33 ++ include/uapi/linux/videodev2.h | 81 ++++ 4 files changed, 749 insertions(+), 81 deletions(-)
drivers/media/v4l2-core/v4l2-dev.c +18 -6
@@ -599,32 +599,44 @@ static void determine_valid_ioctls(struct video_device *vdev) ops->vidioc_enum_fmt_meta_out)))set_bit (_IOC_NR (VIDIOC_ENUM_FMT ), valid_ioctls);if ((is_rx && (ops->vidioc_g_fmt_vid_cap || + ops->vidioc_g_ext_fmt_vid_cap || ops->vidioc_g_fmt_vid_cap_mplane || ops->vidioc_g_fmt_vid_overlay || ops->vidioc_g_fmt_meta_cap)) || (is_tx && (ops->vidioc_g_fmt_vid_out || + ops->vidioc_g_ext_fmt_vid_out || ops->vidioc_g_fmt_vid_out_mplane || ops->vidioc_g_fmt_vid_out_overlay || - ops->vidioc_g_fmt_meta_out))) -set_bit (_IOC_NR (VIDIOC_G_FMT ), valid_ioctls); + ops->vidioc_g_fmt_meta_out))) { +set_bit (_IOC_NR (VIDIOC_G_FMT ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_G_EXT_FMT ), valid_ioctls); + }if ((is_rx && (ops->vidioc_s_fmt_vid_cap || + ops->vidioc_s_ext_fmt_vid_cap || ops->vidioc_s_fmt_vid_cap_mplane || ops->vidioc_s_fmt_vid_overlay || ops->vidioc_s_fmt_meta_cap)) || (is_tx && (ops->vidioc_s_fmt_vid_out || + ops->vidioc_s_ext_fmt_vid_out || ops->vidioc_s_fmt_vid_out_mplane || ops->vidioc_s_fmt_vid_out_overlay || - ops->vidioc_s_fmt_meta_out))) -set_bit (_IOC_NR (VIDIOC_S_FMT ), valid_ioctls); + ops->vidioc_s_fmt_meta_out))) { +set_bit (_IOC_NR (VIDIOC_S_FMT ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_S_EXT_FMT ), valid_ioctls); + }if ((is_rx && (ops->vidioc_try_fmt_vid_cap || + ops->vidioc_try_ext_fmt_vid_cap || ops->vidioc_try_fmt_vid_cap_mplane || ops->vidioc_try_fmt_vid_overlay || ops->vidioc_try_fmt_meta_cap)) || (is_tx && (ops->vidioc_try_fmt_vid_out || + ops->vidioc_try_ext_fmt_vid_out || ops->vidioc_try_fmt_vid_out_mplane || ops->vidioc_try_fmt_vid_out_overlay || - ops->vidioc_try_fmt_meta_out))) -set_bit (_IOC_NR (VIDIOC_TRY_FMT ), valid_ioctls); + ops->vidioc_try_fmt_meta_out))) { +set_bit (_IOC_NR (VIDIOC_TRY_FMT ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_TRY_EXT_FMT ), valid_ioctls); + }SET_VALID_IOCTL (ops,VIDIOC_OVERLAY , vidioc_overlay);SET_VALID_IOCTL (ops,VIDIOC_G_FBUF , vidioc_g_fbuf);SET_VALID_IOCTL (ops,VIDIOC_S_FBUF , vidioc_s_fbuf);
drivers/media/v4l2-core/v4l2-ioctl.c +617 -75
810 lines not on this page · raw message
include/media/v4l2-ioctl.h +33 -0
@@ -48,11 +48,16 @@ struct v4l2_fh;* @vidioc_g_fmt_vid_cap: pointer to the function that implements * :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video capture * in single plane mode +* @vidioc_g_ext_fmt_vid_cap: pointer to the function that implements +* :ref:`VIDIOC_G_EXT_FMT <vidioc_g_ext_fmt>` ioctl logic for video +* capture * @vidioc_g_fmt_vid_overlay: pointer to the function that implements * :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video overlay * @vidioc_g_fmt_vid_out: pointer to the function that implements * :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video out * in single plane mode +* @vidioc_g_ext_fmt_vid_out: pointer to the function that implements +* :ref:`VIDIOC_G_EXT_FMT <vidioc_g_ext_fmt>` ioctl logic for video out * @vidioc_g_fmt_vid_out_overlay: pointer to the function that implements * :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video overlay output * @vidioc_g_fmt_vbi_cap: pointer to the function that implements
@@ -82,11 +87,16 @@ struct v4l2_fh;* @vidioc_s_fmt_vid_cap: pointer to the function that implements * :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video capture * in single plane mode +* @vidioc_s_ext_fmt_vid_cap: pointer to the function that implements +* :ref:`VIDIOC_S_EXT_FMT <vidioc_s_ext_fmt>` ioctl logic for video +* capture * @vidioc_s_fmt_vid_overlay: pointer to the function that implements * :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video overlay * @vidioc_s_fmt_vid_out: pointer to the function that implements * :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video out * in single plane mode +* @vidioc_s_ext_fmt_vid_out: pointer to the function that implements +* :ref:`VIDIOC_S_EXT_FMT <vidioc_g_fmt>` ioctl logic for video out * @vidioc_s_fmt_vid_out_overlay: pointer to the function that implements * :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video overlay output * @vidioc_s_fmt_vbi_cap: pointer to the function that implements
@@ -116,11 +126,16 @@ struct v4l2_fh;* @vidioc_try_fmt_vid_cap: pointer to the function that implements * :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video capture * in single plane mode +* @vidioc_try_ext_fmt_vid_cap: pointer to the function that implements +* :ref:`VIDIOC_TRY_EXT_FMT <vidioc_try_ext_fmt>` ioctl logic for video +capture * @vidioc_try_fmt_vid_overlay: pointer to the function that implements * :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video overlay * @vidioc_try_fmt_vid_out: pointer to the function that implements * :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video out * in single plane mode +* @vidioc_try_ext_fmt_vid_out: pointer to the function that implements +* :ref:`VIDIOC_TRY_EXT_FMT <vidioc_g_fmt>` ioctl logic for video out * @vidioc_try_fmt_vid_out_overlay: pointer to the function that implements * :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video overlay * output
@@ -319,10 +334,14 @@ struct v4l2_ioctl_ops {/* VIDIOC_G_FMT handlers */ int (*vidioc_g_fmt_vid_cap)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_g_ext_fmt_vid_cap)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_g_fmt_vid_overlay)(struct file *file,void *fh,struct v4l2_format *f);int (*vidioc_g_fmt_vid_out)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_g_ext_fmt_vid_out)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_g_fmt_vid_out_overlay)(struct file *file,void *fh,struct v4l2_format *f); int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *fh,
@@ -349,10 +368,14 @@ struct v4l2_ioctl_ops {/* VIDIOC_S_FMT handlers */ int (*vidioc_s_fmt_vid_cap)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_s_ext_fmt_vid_cap)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_s_fmt_vid_overlay)(struct file *file,void *fh,struct v4l2_format *f);int (*vidioc_s_fmt_vid_out)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_s_ext_fmt_vid_out)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_s_fmt_vid_out_overlay)(struct file *file,void *fh,struct v4l2_format *f); int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *fh,
@@ -379,10 +402,14 @@ struct v4l2_ioctl_ops {/* VIDIOC_TRY_FMT handlers */ int (*vidioc_try_fmt_vid_cap)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_try_ext_fmt_vid_cap)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_try_fmt_vid_overlay)(struct file *file,void *fh,struct v4l2_format *f);int (*vidioc_try_fmt_vid_out)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_try_ext_fmt_vid_out)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_try_fmt_vid_out_overlay)(struct file *file,void *fh,struct v4l2_format *f); int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *fh,
@@ -722,4 +749,10 @@ long int video_usercopy(struct file *file, unsigned int cmd,long int video_ioctl2 (struct file *file,unsigned int cmd,unsigned long int arg); +int v4l2_format_to_ext_format (const struct v4l2_format *f, +struct v4l2_ext_format *e,bool strict); +int v4l2_ext_format_to_format (const struct v4l2_ext_format *e, +struct v4l2_format *f, +bool mplane_cap,bool strict); +#endif /* _V4L2_IOCTL_H */
include/uapi/linux/videodev2.h +81 -0
99 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [RFC PATCH v2 2/7] media: v4l2: Extend pixel formats to unify single/multi-planar handling (and more)
Quoted 184 lines · Boris Brezillon
This is part of the multiplanar and singleplanar unification process.
v4l2_ext_pix_formatis supposed to work for both cases.We also add the concept of modifiers already employed in DRM to expose HW-specific formats (like tiled or compressed formats) and allow exchanging this information with the DRM subsystem in a consistent way.
Note that V4L2_BUF_TYPE_VIDEO[_OUTPUT]_OVERLAY and V4L2_BUF_TYPE_VIDEO_{CAPTURE,OUTPUT}_MPLANE types are no longer accepted in
v4l2_ext_formatand will be rejected if you use the {G,S,TRY}EXT_FMT ioctls. V4L2_BUF_TYPE_VIDEO_{CAPTURE,OUTPUT}_MPLANE is dropped as part of the multiplanar/singleplanar unification. V4L2_BUF_TYPE_VIDEO[_OUTPUT]_OVERLAY seems to be used mostly on old drivers and supporting it would require some extra rework.New hooks have been added to
v4l2_ioctl_opsto support those new ioctls in drivers, but, in the meantime, the core takes care of converting {S,G,TRY}_EXT_FMT requests into {S,G,TRY}_FMT so that old drivers can still work if the userspace app/lib uses the new ioctls.
The conversion is also done the other around to allow userspace apps/libs using {S,G,TRY}_FMT to work with drivers implementing the _ext_ hooks.Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- Move the modifier inv4l2_ext_format(was formerly placed inv4l2_ext_plane)
- Fix a few bugs in the converters and add a strict parameter to allow conversion of uninitialized/mis-initialized objects--- drivers/media/v4l2-core/v4l2-dev.c | 24 +- drivers/media/v4l2-core/v4l2-ioctl.c | 692 ++++++++++++++++++++++++--- include/media/v4l2-ioctl.h | 33 ++ include/uapi/linux/videodev2.h | 81 ++++ 4 files changed, 749 insertions(+), 81 deletions(-)drivers/media/v4l2-core/v4l2-dev.c +18
-6@@ -599,32 +599,44 @@ static void determine_valid_ioctls(struct video_device *vdev) ops->vidioc_enum_fmt_meta_out)))set_bit (_IOC_NR (VIDIOC_ENUM_FMT ), valid_ioctls);if ((is_rx && (ops->vidioc_g_fmt_vid_cap || + ops->vidioc_g_ext_fmt_vid_cap || ops->vidioc_g_fmt_vid_cap_mplane || ops->vidioc_g_fmt_vid_overlay || ops->vidioc_g_fmt_meta_cap)) || (is_tx && (ops->vidioc_g_fmt_vid_out || + ops->vidioc_g_ext_fmt_vid_out || ops->vidioc_g_fmt_vid_out_mplane || ops->vidioc_g_fmt_vid_out_overlay || - ops->vidioc_g_fmt_meta_out))) -set_bit (_IOC_NR (VIDIOC_G_FMT ), valid_ioctls); + ops->vidioc_g_fmt_meta_out))) { +set_bit (_IOC_NR (VIDIOC_G_FMT ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_G_EXT_FMT ), valid_ioctls); + }if ((is_rx && (ops->vidioc_s_fmt_vid_cap || + ops->vidioc_s_ext_fmt_vid_cap || ops->vidioc_s_fmt_vid_cap_mplane || ops->vidioc_s_fmt_vid_overlay || ops->vidioc_s_fmt_meta_cap)) || (is_tx && (ops->vidioc_s_fmt_vid_out || + ops->vidioc_s_ext_fmt_vid_out || ops->vidioc_s_fmt_vid_out_mplane || ops->vidioc_s_fmt_vid_out_overlay || - ops->vidioc_s_fmt_meta_out))) -set_bit (_IOC_NR (VIDIOC_S_FMT ), valid_ioctls); + ops->vidioc_s_fmt_meta_out))) { +set_bit (_IOC_NR (VIDIOC_S_FMT ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_S_EXT_FMT ), valid_ioctls); + }if ((is_rx && (ops->vidioc_try_fmt_vid_cap || + ops->vidioc_try_ext_fmt_vid_cap || ops->vidioc_try_fmt_vid_cap_mplane || ops->vidioc_try_fmt_vid_overlay || ops->vidioc_try_fmt_meta_cap)) || (is_tx && (ops->vidioc_try_fmt_vid_out || + ops->vidioc_try_ext_fmt_vid_out || ops->vidioc_try_fmt_vid_out_mplane || ops->vidioc_try_fmt_vid_out_overlay || - ops->vidioc_try_fmt_meta_out))) -set_bit (_IOC_NR (VIDIOC_TRY_FMT ), valid_ioctls); + ops->vidioc_try_fmt_meta_out))) { +set_bit (_IOC_NR (VIDIOC_TRY_FMT ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_TRY_EXT_FMT ), valid_ioctls); + }SET_VALID_IOCTL (ops,VIDIOC_OVERLAY , vidioc_overlay);SET_VALID_IOCTL (ops,VIDIOC_G_FBUF , vidioc_g_fbuf);SET_VALID_IOCTL (ops,VIDIOC_S_FBUF , vidioc_s_fbuf);drivers/media/v4l2-core/v4l2-ioctl.c +76
-1@@ -381,6 +381,82 @@ static void v4l_print_format(const void *arg, bool write_only) } } +static void v4l_print_ext_format (const void *arg,bool write_only) +{ +const struct v4l2_ext_format *p = arg; +const struct v4l2_ext_pix_format *pix; +const struct v4l2_vbi_format *vbi; +const struct v4l2_sliced_vbi_format *sliced; +const struct v4l2_sdr_format *sdr; +const struct v4l2_meta_format *meta; +unsigned int i; +u32 planes; + +pr_cont ("type=%s" ,prt_names (p->type, v4l2_type_names)); +switch (p->type) { +case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_OUTPUT : + pix = &p->fmt.pix; +pr_cont (", width=%u, height=%u, format=%c%c%c%c, modifier %llx, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n" , + pix->width, pix->height, + (pix->pixelformat &0xff ), + (pix->pixelformat >>8 ) &0xff , + (pix->pixelformat >>16 ) &0xff , + (pix->pixelformat >>24 ) &0xff , + pix->modifier,prt_names (pix->field, v4l2_field_names), + pix->colorspace, pix->num_planes, pix->flags, + pix->ycbcr_enc, pix->quantization, pix->xfer_func); + planes =min_t (u32, pix->num_planes,VIDEO_MAX_PLANES ); +for (i =0 ; i < planes; i++) +pr_debug ("plane %u: bytesperline=%u sizeimage=%u\n" , + i, pix->plane_fmt[i].bytesperline, + pix->plane_fmt[i].sizeimage); +break ; +case V4L2_BUF_TYPE_VBI_CAPTURE : +case V4L2_BUF_TYPE_VBI_OUTPUT : + vbi = &p->fmt.vbi; +pr_cont (", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%c%c%c%c, start=%u,%u, count=%u,%u\n" , + vbi->sampling_rate, vbi->offset, + vbi->samples_per_line, + (vbi->sample_format &0xff ), + (vbi->sample_format >>8 ) &0xff , + (vbi->sample_format >>16 ) &0xff , + (vbi->sample_format >>24 ) &0xff , + vbi->start[0 ], vbi->start[1 ], + vbi->count[0 ], vbi->count[1 ]); +break ; +case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE : +case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT : + sliced = &p->fmt.sliced; +pr_cont (", service_set=0x%08x, io_size=%d\n" , + sliced->service_set, sliced->io_size); +for (i =0 ; i <24 ; i++) +pr_debug ("line[%02u]=0x%04x, 0x%04x\n" , i, + sliced->service_lines[0 ][i], + sliced->service_lines[1 ][i]); +break ; +case V4L2_BUF_TYPE_SDR_CAPTURE : +case V4L2_BUF_TYPE_SDR_OUTPUT : + sdr = &p->fmt.sdr; +pr_cont (", pixelformat=%c%c%c%c\n" , + (sdr->pixelformat >>0 ) &0xff , + (sdr->pixelformat >>8 ) &0xff , + (sdr->pixelformat >>16 ) &0xff , + (sdr->pixelformat >>24 ) &0xff ); +break ; +case V4L2_BUF_TYPE_META_CAPTURE : +case V4L2_BUF_TYPE_META_OUTPUT : + meta = &p->fmt.meta; +pr_cont (", dataformat=%c%c%c%c, buffersize=%u\n" , + (meta->dataformat >>0 ) &0xff , + (meta->dataformat >>8 ) &0xff , + (meta->dataformat >>16 ) &0xff , + (meta->dataformat >>24 ) &0xff , + meta->buffersize); +break ; + } +} +static void v4l_print_framebuffer (const void *arg,bool write_only) {const struct v4l2_framebuffer *p = arg;@@ -951,11 +1027,15 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)switch (type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : if ((is_vid || is_tch) && is_rx && - (ops->vidioc_g_fmt_vid_cap || ops->vidioc_g_fmt_vid_cap_mplane))
drivers/media/v4l2-core/v4l2-ioctl.c static int check_fmt(struct file *file, enum v4l2_buf_type type) · line 1038
Quoted 10 lines
drivers/media/v4l2-core/v4l2-ioctl.c +6
-1+ (ops->vidioc_g_fmt_vid_cap || + ops->vidioc_g_ext_fmt_vid_cap || + ops->vidioc_g_fmt_vid_cap_mplane)) return 0;break ;case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : -if (is_vid && is_rx && ops->vidioc_g_fmt_vid_cap_mplane) +if (is_vid && is_rx && + (ops->vidioc_g_fmt_vid_cap_mplane || + ops->vidioc_g_ext_fmt_vid_cap))
Is this right? I thought that V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE was to be refused when used with the new ioctls? Perhaps check_fmt needs an extra argument that tells it whether it is called from the new ioctls or not.
Quoted 226 lines
drivers/media/v4l2-core/v4l2-ioctl.c +200
-2return 0 ;break ;case V4L2_BUF_TYPE_VIDEO_OVERLAY :@@ -964,11 +1044,15 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT :if (is_vid && is_tx && - (ops->vidioc_g_fmt_vid_out || ops->vidioc_g_fmt_vid_out_mplane)) + (ops->vidioc_g_fmt_vid_out || + ops->vidioc_g_ext_fmt_vid_out || + ops->vidioc_g_fmt_vid_out_mplane))return 0 ;break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : -if (is_vid && is_tx && ops->vidioc_g_fmt_vid_out_mplane) +if (is_vid && is_tx && + (ops->vidioc_g_ext_fmt_vid_out || + ops->vidioc_g_fmt_vid_out_mplane))return 0 ;break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :@@ -1048,6 +1132,197 @@ static void v4l_sanitize_format(struct v4l2_format *fmt) sizeof(fmt->fmt.pix) - offset); } +int v4l2_ext_format_to_format (const struct v4l2_ext_format *e, +struct v4l2_format *f,bool mplane_cap, +bool strict) +{ +const struct v4l2_plane_ext_pix_format *pe; +struct v4l2_plane_pix_format *p; +unsigned int i; + +memset (f,0 ,sizeof (*f)); + +switch (e->type) { +case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_OUTPUT : +/* +* Make sure no modifier is required before doing the +* conversion. +*/ +if (e->fmt.pix.modifier && strict) +return -EINVAL ; + +if ((e->fmt.pix.num_planes >VIDEO_MAX_PLANES || + !e->fmt.pix.num_planes) && strict) +return -EINVAL ; + +if (e->fmt.pix.num_planes >1 && !mplane_cap && strict) +return -EINVAL ; + +if (!mplane_cap) { + f->fmt.pix.width = e->fmt.pix.width; + f->fmt.pix.height = e->fmt.pix.height; + f->fmt.pix.pixelformat = e->fmt.pix.pixelformat; + f->fmt.pix.field = e->fmt.pix.field; + f->fmt.pix.colorspace = e->fmt.pix.colorspace; + f->fmt.pix.flags = e->fmt.pix.flags; + f->fmt.pix.ycbcr_enc = e->fmt.pix.ycbcr_enc; + f->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; + f->fmt.pix.quantization = e->fmt.pix.quantization; + pe = &e->fmt.pix.plane_fmt[0 ]; + f->fmt.pix.bytesperline = pe->bytesperline; + f->fmt.pix.sizeimage = pe->sizeimage; + f->type = e->type; +break ; + } + + f->fmt.pix_mp.width = e->fmt.pix.width; + f->fmt.pix_mp.height = e->fmt.pix.height; + f->fmt.pix_mp.pixelformat = e->fmt.pix.pixelformat; + f->fmt.pix_mp.field = e->fmt.pix.field; + f->fmt.pix_mp.colorspace = e->fmt.pix.colorspace; + f->fmt.pix_mp.flags = e->fmt.pix.flags; + f->fmt.pix_mp.ycbcr_enc = e->fmt.pix.ycbcr_enc; + f->fmt.pix_mp.quantization = e->fmt.pix.quantization; +if (e->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE ) + f->type =V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ; +else + f->type =V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ; + +for (i =0 ; i <VIDEO_MAX_PLANES ; i++) { + pe = &e->fmt.pix.plane_fmt[i]; + p = &f->fmt.pix_mp.plane_fmt[i]; + p->bytesperline = pe->bytesperline; + p->sizeimage = pe->sizeimage; + } +break ; + +case V4L2_BUF_TYPE_VBI_CAPTURE : +case V4L2_BUF_TYPE_VBI_OUTPUT : + f->type = e->type; + f->fmt.vbi = e->fmt.vbi; +break ; + +case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE : +case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT : + f->type = e->type; + f->fmt.sliced = e->fmt.sliced; +break ; + +case V4L2_BUF_TYPE_SDR_CAPTURE : +case V4L2_BUF_TYPE_SDR_OUTPUT : + f->type = e->type; + f->fmt.sdr = e->fmt.sdr; +break ; + +case V4L2_BUF_TYPE_META_CAPTURE : +case V4L2_BUF_TYPE_META_OUTPUT : + f->type = e->type; + f->fmt.meta = e->fmt.meta; +break ; + +default : +return -EINVAL ; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (v4l2_ext_format_to_format); + +int v4l2_format_to_ext_format (const struct v4l2_format *f, +struct v4l2_ext_format *e,bool strict) +{ +const struct v4l2_plane_pix_format *p; +struct v4l2_plane_ext_pix_format *pe; +unsigned int i; + +memset (e,0 ,sizeof (*e)); + +switch (f->type) { +case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_OUTPUT : + e->fmt.pix.width = f->fmt.pix.width; + e->fmt.pix.height = f->fmt.pix.height; + e->fmt.pix.pixelformat = f->fmt.pix.pixelformat; + e->fmt.pix.field = f->fmt.pix.field; + e->fmt.pix.colorspace = f->fmt.pix.colorspace; + e->fmt.pix.flags = f->fmt.pix.flags; + e->fmt.pix.ycbcr_enc = f->fmt.pix.ycbcr_enc; + e->fmt.pix.quantization = f->fmt.pix.quantization; + e->fmt.pix.num_planes =1 ; + e->fmt.pix.plane_fmt[0 ].bytesperline = f->fmt.pix.bytesperline; + e->fmt.pix.plane_fmt[0 ].sizeimage = f->fmt.pix.sizeimage; + e->type = f->type; +break ; + +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : +case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : +if ((f->fmt.pix_mp.num_planes >VIDEO_MAX_PLANES || + !f->fmt.pix_mp.num_planes) && strict) +return -EINVAL ; + + e->fmt.pix.width = f->fmt.pix_mp.width; + e->fmt.pix.height = f->fmt.pix_mp.height; + e->fmt.pix.pixelformat = f->fmt.pix_mp.pixelformat; + e->fmt.pix.field = f->fmt.pix_mp.field; + e->fmt.pix.colorspace = f->fmt.pix_mp.colorspace; + e->fmt.pix.flags = f->fmt.pix_mp.flags; + e->fmt.pix.ycbcr_enc = f->fmt.pix_mp.ycbcr_enc; + e->fmt.pix.quantization = f->fmt.pix_mp.quantization; + e->fmt.pix.num_planes = f->fmt.pix_mp.num_planes; +if (f->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) + e->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; +else + e->type =V4L2_BUF_TYPE_VIDEO_OUTPUT ; + +for (i =0 ; i <VIDEO_MAX_PLANES ; i++) { + pe = &e->fmt.pix.plane_fmt[i]; + p = &f->fmt.pix_mp.plane_fmt[i]; + pe->bytesperline = p->bytesperline; + pe->sizeimage = p->sizeimage; + } +break ; + +case V4L2_BUF_TYPE_VIDEO_OVERLAY : +case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY : +/* +* OVERLAY formats are not supported by the _EXT_FMT +* ioctl()s. +*/ +return -EINVAL ; + +case V4L2_BUF_TYPE_VBI_CAPTURE : +case V4L2_BUF_TYPE_VBI_OUTPUT : + e->type = f->type; + e->fmt.vbi = f->fmt.vbi; +break ; + +case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE : +case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT : + e->type = f->type; + e->fmt.sliced = f->fmt.sliced; +break ; + +case V4L2_BUF_TYPE_SDR_CAPTURE : +case V4L2_BUF_TYPE_SDR_OUTPUT : + e->type = f->type; + e->fmt.sdr = f->fmt.sdr; +break ; + +case V4L2_BUF_TYPE_META_CAPTURE : +case V4L2_BUF_TYPE_META_OUTPUT : + e->type = f->type; + e->fmt.meta = f->fmt.meta; +break ; + +default : +return -EINVAL ; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (v4l2_format_to_ext_format); +static int v4l_querycap (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) {@@ -1440,6 +1715,38 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,return ret; } +static int v4l_g_fmt_ext_pix (const struct v4l2_ioctl_ops *ops, +struct file *file,void *fh, +struct v4l2_format *f)
drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, · line 1730
Quoted 10 lines
drivers/media/v4l2-core/v4l2-ioctl.c +10
-0+{ +struct v4l2_ext_format ef = { + .type = f->type, + }; +int ret; + +switch (f->type) { +case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : + ret = ops->vidioc_g_ext_fmt_vid_cap (file, fh, &ef.fmt.pix);
This will call vidioc_g_ext_fmt_vid_cap with type _MPLANE, which we said we wouldn't support for the extended ioctls.
Quoted 31 lines
drivers/media/v4l2-core/v4l2-ioctl.c +19
-5+break ; + +case V4L2_BUF_TYPE_VIDEO_OUTPUT : +case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : + ret = ops->vidioc_g_ext_fmt_vid_out (file, fh, &ef.fmt.pix); +break ; + +default : +return -EINVAL ; + } + +if (ret) +return ret; + +return v4l2_ext_format_to_format (&ef, f, +V4L2_TYPE_IS_MULTIPLANAR (f->type), + true); +} +static int v4l_g_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) {@@ -1475,15 +1782,22 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : -if (unlikely (!ops->vidioc_g_fmt_vid_cap)) -break ; - p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; - ret = ops->vidioc_g_fmt_vid_cap (file, fh, arg); -/* just in case the driver zeroed it again */
drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, · line 1792
Quoted 10 lines
drivers/media/v4l2-core/v4l2-ioctl.c +8
-2- p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; -return ret; +if (ops->vidioc_g_fmt_vid_cap) { + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; + ret = ops->vidioc_g_fmt_vid_cap (file, fh, arg); +/* just in case the driver zeroed it again */ + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; +return ret; + }else if (ops->vidioc_g_ext_fmt_vid_cap) { +return v4l_g_fmt_ext_pix (ops, file, fh, p);
Test for the extended op first. Same elsewhere below. E.g.:
if (ops->vidioc_g_ext_fmt_vid_cap) return v4l_g_fmt_ext_pix(ops, file, fh, p); if (unlikely(!ops->vidioc_g_fmt_vid_cap)) break; p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC; ...
Quoted 135 lines
drivers/media/v4l2-core/v4l2-ioctl.c +93
-12+ } +break ;case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : -return ops->vidioc_g_fmt_vid_cap_mplane (file, fh, arg); +if (ops->vidioc_g_fmt_vid_cap_mplane) +return ops->vidioc_g_fmt_vid_cap_mplane (file, fh, arg); +else if (ops->vidioc_g_ext_fmt_vid_cap) +return v4l_g_fmt_ext_pix (ops, file, fh, p); +break ;case V4L2_BUF_TYPE_VIDEO_OVERLAY :return ops->vidioc_g_fmt_vid_overlay (file, fh, arg);case V4L2_BUF_TYPE_VBI_CAPTURE :@@ -1491,15 +1805,22 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE :return ops->vidioc_g_fmt_sliced_vbi_cap (file, fh, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT : -if (unlikely (!ops->vidioc_g_fmt_vid_out)) -break ; - p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; - ret = ops->vidioc_g_fmt_vid_out (file, fh, arg); -/* just in case the driver zeroed it again */ - p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; -return ret; +if (ops->vidioc_g_fmt_vid_out) { + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; + ret = ops->vidioc_g_fmt_vid_out (file, fh, arg); +/* just in case the driver zeroed it again */ + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; +return ret; + }else if (ops->vidioc_g_ext_fmt_vid_out) { +return v4l_g_fmt_ext_pix (ops, file, fh, p); + } +break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : -return ops->vidioc_g_fmt_vid_out_mplane (file, fh, arg); +if (ops->vidioc_g_fmt_vid_out_mplane) +return ops->vidioc_g_fmt_vid_out_mplane (file, fh, arg); +else if (ops->vidioc_g_ext_fmt_vid_out) +return v4l_g_fmt_ext_pix (ops, file, fh, p); +break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :return ops->vidioc_g_fmt_vid_out_overlay (file, fh, arg);case V4L2_BUF_TYPE_VBI_OUTPUT :@@ -1518,6 +1839,43 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,return -EINVAL ; } +static int v4l_g_ext_fmt (const struct v4l2_ioctl_ops *ops, +struct file *file,void *fh,void *arg) +{ +struct v4l2_ext_format *ef = arg; +struct v4l2_format f = { + .type = ef->type, + }; +int ret; + + ret =check_fmt (file, ef->type); +if (ret) +return ret; + +memset (&ef->fmt,0 ,sizeof (ef->fmt)); + +switch (ef->type) { +case V4L2_BUF_TYPE_VIDEO_CAPTURE : +if (ops->vidioc_g_ext_fmt_vid_cap) +return ops->vidioc_g_ext_fmt_vid_cap (file, fh, + &ef->fmt.pix); +break ; +case V4L2_BUF_TYPE_VIDEO_OUTPUT : +if (ops->vidioc_g_ext_fmt_vid_out) +return ops->vidioc_g_ext_fmt_vid_out (file, fh, + &ef->fmt.pix); +break ; +default : +break ; + } + + ret =v4l_g_fmt (ops, file, fh, &f); +if (ret) +return ret; + +return v4l2_format_to_ext_format (&f, ef, true); +} +static void v4l_pix_format_touch (struct v4l2_pix_format *p) {/* @@ -1533,6 +1891,40 @@ static void v4l_pix_format_touch(struct v4l2_pix_format *p) p->xfer_func =0 ; } +static int v4l_s_fmt_ext_pix (const struct v4l2_ioctl_ops *ops, +struct file *file,void *fh, +struct v4l2_format *f) +{ +struct v4l2_ext_format ef; +int ret; + + ret =v4l2_format_to_ext_format (f, &ef, false); +if (ret) +return ret; + +switch (f->type) { +case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : + ret = ops->vidioc_s_ext_fmt_vid_cap (file, fh, &ef.fmt.pix); +break ; + +case V4L2_BUF_TYPE_VIDEO_OUTPUT : +case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : + ret = ops->vidioc_s_ext_fmt_vid_out (file, fh, &ef.fmt.pix); +break ; + +default : +return -EINVAL ; + } + +if (ret) +return ret; + +return v4l2_ext_format_to_format (&ef, f, +V4L2_TYPE_IS_MULTIPLANAR (f->type), + true); +} +static int v4l_s_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) {@@ -1551,23 +1943,31 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : -if (unlikely (!ops->vidioc_s_fmt_vid_cap)) -break ; -CLEAR_AFTER_FIELD (p, fmt.pix);
drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, · line 1952
Quoted 10 lines
drivers/media/v4l2-core/v4l2-ioctl.c +7
-3- ret = ops->vidioc_s_fmt_vid_cap (file, fh, arg); -/* just in case the driver zeroed it again */ - p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; +if (ops->vidioc_s_fmt_vid_cap) { +CLEAR_AFTER_FIELD (p, fmt.pix); + ret = ops->vidioc_s_fmt_vid_cap (file, fh, arg); +/* just in case the driver zeroed it again */ + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; + }else if (ops->vidioc_s_ext_fmt_vid_cap) { + ret =v4l_s_fmt_ext_pix (ops, file, fh, arg);
The helper functions v4l_[g/s/try]_fmt_ext_pix are confusingly named. How about: v4l_[g/s/try]_fmt_using_ext_fmt.
Quoted 516 lines
drivers/media/v4l2-core/v4l2-ioctl.c +198
-49+ }else { + ret = -EINVAL ; + } +if (vfd->vfl_type ==VFL_TYPE_TOUCH )v4l_pix_format_touch (&p->fmt.pix);return ret;case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : -if (unlikely (!ops->vidioc_s_fmt_vid_cap_mplane)) -break ; -CLEAR_AFTER_FIELD (p, fmt.pix_mp.xfer_func); -for (i =0 ; i < p->fmt.pix_mp.num_planes; i++) -CLEAR_AFTER_FIELD (&p->fmt.pix_mp.plane_fmt[i], - bytesperline); -return ops->vidioc_s_fmt_vid_cap_mplane (file, fh, arg); +if (ops->vidioc_s_fmt_vid_cap_mplane) { +CLEAR_AFTER_FIELD (p, fmt.pix_mp.xfer_func); +for (i =0 ; i < p->fmt.pix_mp.num_planes; i++) +CLEAR_AFTER_FIELD (&p->fmt.pix_mp.plane_fmt[i], + bytesperline); +return ops->vidioc_s_fmt_vid_cap_mplane (file, fh, arg); + }else if (ops->vidioc_s_ext_fmt_vid_cap) { +return v4l_s_fmt_ext_pix (ops, file, fh, arg); + } +break ;case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_s_fmt_vid_overlay))break ;@@ -1584,21 +1984,27 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,CLEAR_AFTER_FIELD (p, fmt.sliced);return ops->vidioc_s_fmt_sliced_vbi_cap (file, fh, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT : -if (unlikely (!ops->vidioc_s_fmt_vid_out)) -break ; -CLEAR_AFTER_FIELD (p, fmt.pix); - ret = ops->vidioc_s_fmt_vid_out (file, fh, arg); -/* just in case the driver zeroed it again */ - p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; -return ret; +if (ops->vidioc_s_fmt_vid_out) { +CLEAR_AFTER_FIELD (p, fmt.pix); + ret = ops->vidioc_s_fmt_vid_out (file, fh, arg); +/* just in case the driver zeroed it again */ + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; +return ret; + }else if (ops->vidioc_s_ext_fmt_vid_out) { +return v4l_s_fmt_ext_pix (ops, file, fh, arg); + } +break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : -if (unlikely (!ops->vidioc_s_fmt_vid_out_mplane)) -break ; -CLEAR_AFTER_FIELD (p, fmt.pix_mp.xfer_func); -for (i =0 ; i < p->fmt.pix_mp.num_planes; i++) -CLEAR_AFTER_FIELD (&p->fmt.pix_mp.plane_fmt[i], - bytesperline); -return ops->vidioc_s_fmt_vid_out_mplane (file, fh, arg); +if (ops->vidioc_s_fmt_vid_out_mplane) { +CLEAR_AFTER_FIELD (p, fmt.pix_mp.xfer_func); +for (i =0 ; i < p->fmt.pix_mp.num_planes; i++) +CLEAR_AFTER_FIELD (&p->fmt.pix_mp.plane_fmt[i], + bytesperline); +return ops->vidioc_s_fmt_vid_out_mplane (file, fh, arg); + }else if (ops->vidioc_s_ext_fmt_vid_out) { +return v4l_s_fmt_ext_pix (ops, file, fh, arg); + } +break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :if (unlikely (!ops->vidioc_s_fmt_vid_out_overlay))break ;@@ -1638,6 +2044,84 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,return -EINVAL ; } +static int v4l_s_ext_fmt (const struct v4l2_ioctl_ops *ops, +struct file *file,void *fh,void *arg) +{ +struct video_device *vfd =video_devdata (file); +struct v4l2_ext_format *ef = arg; +struct v4l2_format f; +int ret; + + ret =check_fmt (file, ef->type); +if (ret) +return ret; + +switch (ef->type) { +case V4L2_BUF_TYPE_VIDEO_CAPTURE : +if (ops->vidioc_s_ext_fmt_vid_cap) +return ops->vidioc_s_ext_fmt_vid_cap (file, fh, + &ef->fmt.pix); +break ; +case V4L2_BUF_TYPE_VIDEO_OUTPUT : +if (ops->vidioc_s_ext_fmt_vid_out) +return ops->vidioc_s_ext_fmt_vid_out (file, fh, + &ef->fmt.pix); +break ; +default : +break ; + } + + ret =v4l2_ext_format_to_format (ef, &f, + vfd->device_caps & + (V4L2_CAP_VIDEO_CAPTURE_MPLANE | +V4L2_CAP_VIDEO_OUTPUT_MPLANE | +V4L2_CAP_VIDEO_M2M_MPLANE ), + false); +if (ret) +return ret; + + ret =v4l_s_fmt (ops, file, fh, &f); +if (ret) +return ret; + +return v4l2_format_to_ext_format (&f, ef, true); +} + +static int v4l_try_fmt_ext_pix (const struct v4l2_ioctl_ops *ops, +struct file *file,void *fh, +struct v4l2_format *f) +{ +struct v4l2_ext_format ef; +int ret; + + ret =v4l2_format_to_ext_format (f, &ef, false); +if (ret) +return ret; + +switch (f->type) { +case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : + ret = ops->vidioc_try_ext_fmt_vid_cap (file, fh, &ef.fmt.pix); +break ; + +case V4L2_BUF_TYPE_VIDEO_OUTPUT : +case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : + ret = ops->vidioc_try_ext_fmt_vid_out (file, fh, &ef.fmt.pix); +break ; + +default : +return -EINVAL ; + } + +if (ret) +return ret; + +return v4l2_ext_format_to_format (&ef, f, +V4L2_TYPE_IS_MULTIPLANAR (f->type), + true); + +} +static int v4l_try_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) {@@ -1652,21 +2136,27 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : -if (unlikely (!ops->vidioc_try_fmt_vid_cap)) -break ; -CLEAR_AFTER_FIELD (p, fmt.pix); - ret = ops->vidioc_try_fmt_vid_cap (file, fh, arg); -/* just in case the driver zeroed it again */ - p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; -return ret; +if (ops->vidioc_try_fmt_vid_cap) { +CLEAR_AFTER_FIELD (p, fmt.pix); + ret = ops->vidioc_try_fmt_vid_cap (file, fh, arg); +/* just in case the driver zeroed it again */ + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; +return ret; + }else if (ops->vidioc_try_ext_fmt_vid_cap) { +return v4l_try_fmt_ext_pix (ops, file, fh, p); + } +break ;case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : -if (unlikely (!ops->vidioc_try_fmt_vid_cap_mplane)) -break ; -CLEAR_AFTER_FIELD (p, fmt.pix_mp.xfer_func); -for (i =0 ; i < p->fmt.pix_mp.num_planes; i++) -CLEAR_AFTER_FIELD (&p->fmt.pix_mp.plane_fmt[i], - bytesperline); -return ops->vidioc_try_fmt_vid_cap_mplane (file, fh, arg); +if (ops->vidioc_try_fmt_vid_cap_mplane) { +CLEAR_AFTER_FIELD (p, fmt.pix_mp.xfer_func); +for (i =0 ; i < p->fmt.pix_mp.num_planes; i++) +CLEAR_AFTER_FIELD (&p->fmt.pix_mp.plane_fmt[i], + bytesperline); +return ops->vidioc_try_fmt_vid_cap_mplane (file, fh, arg); + }else if (ops->vidioc_try_ext_fmt_vid_cap) { +return v4l_try_fmt_ext_pix (ops, file, fh, p); + } +break ;case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_try_fmt_vid_overlay))break ;@@ -1683,21 +2173,27 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,CLEAR_AFTER_FIELD (p, fmt.sliced);return ops->vidioc_try_fmt_sliced_vbi_cap (file, fh, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT : -if (unlikely (!ops->vidioc_try_fmt_vid_out)) -break ; -CLEAR_AFTER_FIELD (p, fmt.pix); - ret = ops->vidioc_try_fmt_vid_out (file, fh, arg); -/* just in case the driver zeroed it again */ - p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; -return ret; +if (ops->vidioc_try_fmt_vid_out) { +CLEAR_AFTER_FIELD (p, fmt.pix); + ret = ops->vidioc_try_fmt_vid_out (file, fh, arg); +/* just in case the driver zeroed it again */ + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; +return ret; + }else if (ops->vidioc_try_ext_fmt_vid_cap) { +return v4l_try_fmt_ext_pix (ops, file, fh, p); + } +break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : -if (unlikely (!ops->vidioc_try_fmt_vid_out_mplane)) -break ; -CLEAR_AFTER_FIELD (p, fmt.pix_mp.xfer_func); -for (i =0 ; i < p->fmt.pix_mp.num_planes; i++) -CLEAR_AFTER_FIELD (&p->fmt.pix_mp.plane_fmt[i], - bytesperline); -return ops->vidioc_try_fmt_vid_out_mplane (file, fh, arg); +if (ops->vidioc_try_fmt_vid_out_mplane) { +CLEAR_AFTER_FIELD (p, fmt.pix_mp.xfer_func); +for (i =0 ; i < p->fmt.pix_mp.num_planes; i++) +CLEAR_AFTER_FIELD (&p->fmt.pix_mp.plane_fmt[i], + bytesperline); +return ops->vidioc_try_fmt_vid_out_mplane (file, fh, arg); + }else if (ops->vidioc_try_ext_fmt_vid_cap) { +return v4l_try_fmt_ext_pix (ops, file, fh, p); + } +break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :if (unlikely (!ops->vidioc_try_fmt_vid_out_overlay))break ;@@ -1737,6 +2233,49 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,return -EINVAL ; } +static int v4l_try_ext_fmt (const struct v4l2_ioctl_ops *ops, +struct file *file,void *fh,void *arg) +{ +struct video_device *vfd =video_devdata (file); +struct v4l2_ext_format *ef = arg; +struct v4l2_format f; +int ret; + + ret =check_fmt (file, ef->type); +if (ret) +return ret; + +switch (ef->type) { +case V4L2_BUF_TYPE_VIDEO_CAPTURE : +if (ops->vidioc_try_ext_fmt_vid_cap) +return ops->vidioc_try_ext_fmt_vid_cap (file, fh, + &ef->fmt.pix); +break ; +case V4L2_BUF_TYPE_VIDEO_OUTPUT : +if (ops->vidioc_try_ext_fmt_vid_out) +return ops->vidioc_try_ext_fmt_vid_out (file, fh, + &ef->fmt.pix); +break ; +default : +break ; + } + + ret =v4l2_ext_format_to_format (ef, &f, + vfd->device_caps & + (V4L2_CAP_VIDEO_CAPTURE_MPLANE | +V4L2_CAP_VIDEO_OUTPUT_MPLANE | +V4L2_CAP_VIDEO_M2M_MPLANE ), + false); +if (ret) +return ret; + + ret =v4l_try_fmt (ops, file, fh, &f); +if (ret) +return ret; + +return v4l2_format_to_ext_format (&f, ef, true); +} +static int v4l_streamon (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) {@@ -2655,7 +3194,9 @@ static const struct v4l2_ioctl_info v4l2_ioctls[] = {IOCTL_INFO (VIDIOC_QUERYCAP , v4l_querycap, v4l_print_querycap,0 ),IOCTL_INFO (VIDIOC_ENUM_FMT , v4l_enum_fmt, v4l_print_fmtdesc,INFO_FL_CLEAR (v4l2_fmtdesc, type)),IOCTL_INFO (VIDIOC_G_FMT , v4l_g_fmt, v4l_print_format,0 ), +IOCTL_INFO (VIDIOC_G_EXT_FMT , v4l_g_ext_fmt, v4l_print_ext_format,0 ),IOCTL_INFO (VIDIOC_S_FMT , v4l_s_fmt, v4l_print_format,INFO_FL_PRIO ), +IOCTL_INFO (VIDIOC_S_EXT_FMT , v4l_s_ext_fmt, v4l_print_ext_format,INFO_FL_PRIO ),IOCTL_INFO (VIDIOC_REQBUFS , v4l_reqbufs, v4l_print_requestbuffers,INFO_FL_PRIO |INFO_FL_QUEUE ),IOCTL_INFO (VIDIOC_QUERYBUF , v4l_querybuf, v4l_print_buffer,INFO_FL_QUEUE |INFO_FL_CLEAR (v4l2_buffer, length)), IOCTL_INFO(VIDIOC_G_FBUF, v4l_stub_g_fbuf, v4l_print_framebuffer, 0),@@ -2702,6 +3243,7 @@ static const struct v4l2_ioctl_info v4l2_ioctls[] = {IOCTL_INFO (VIDIOC_S_JPEGCOMP , v4l_stub_s_jpegcomp, v4l_print_jpegcompression,INFO_FL_PRIO ),IOCTL_INFO (VIDIOC_QUERYSTD , v4l_querystd, v4l_print_std,0 ),IOCTL_INFO (VIDIOC_TRY_FMT , v4l_try_fmt, v4l_print_format,0 ), +IOCTL_INFO (VIDIOC_TRY_EXT_FMT , v4l_try_ext_fmt, v4l_print_ext_format,0 ),IOCTL_INFO (VIDIOC_ENUMAUDIO , v4l_stub_enumaudio, v4l_print_audio,INFO_FL_CLEAR (v4l2_audio, index)),IOCTL_INFO (VIDIOC_ENUMAUDOUT , v4l_stub_enumaudout, v4l_print_audioout,INFO_FL_CLEAR (v4l2_audioout, index)), IOCTL_INFO(VIDIOC_G_PRIORITY, v4l_g_priority, v4l_print_u32, 0),include/media/v4l2-ioctl.h +33
-0@@ -48,11 +48,16 @@ struct v4l2_fh;* @vidioc_g_fmt_vid_cap: pointer to the function that implements * :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video capture * in single plane mode +* @vidioc_g_ext_fmt_vid_cap: pointer to the function that implements +* :ref:`VIDIOC_G_EXT_FMT <vidioc_g_ext_fmt>` ioctl logic for video +* capture * @vidioc_g_fmt_vid_overlay: pointer to the function that implements * :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video overlay * @vidioc_g_fmt_vid_out: pointer to the function that implements * :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video out * in single plane mode +* @vidioc_g_ext_fmt_vid_out: pointer to the function that implements +* :ref:`VIDIOC_G_EXT_FMT <vidioc_g_ext_fmt>` ioctl logic for video out * @vidioc_g_fmt_vid_out_overlay: pointer to the function that implements * :ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video overlay output * @vidioc_g_fmt_vbi_cap: pointer to the function that implements @@ -82,11 +87,16 @@ struct v4l2_fh;* @vidioc_s_fmt_vid_cap: pointer to the function that implements * :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video capture * in single plane mode +* @vidioc_s_ext_fmt_vid_cap: pointer to the function that implements +* :ref:`VIDIOC_S_EXT_FMT <vidioc_s_ext_fmt>` ioctl logic for video +* capture * @vidioc_s_fmt_vid_overlay: pointer to the function that implements * :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video overlay * @vidioc_s_fmt_vid_out: pointer to the function that implements * :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video out * in single plane mode +* @vidioc_s_ext_fmt_vid_out: pointer to the function that implements +* :ref:`VIDIOC_S_EXT_FMT <vidioc_g_fmt>` ioctl logic for video out * @vidioc_s_fmt_vid_out_overlay: pointer to the function that implements * :ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video overlay output * @vidioc_s_fmt_vbi_cap: pointer to the function that implements @@ -116,11 +126,16 @@ struct v4l2_fh;* @vidioc_try_fmt_vid_cap: pointer to the function that implements * :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video capture * in single plane mode +* @vidioc_try_ext_fmt_vid_cap: pointer to the function that implements +* :ref:`VIDIOC_TRY_EXT_FMT <vidioc_try_ext_fmt>` ioctl logic for video +capture * @vidioc_try_fmt_vid_overlay: pointer to the function that implements * :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video overlay * @vidioc_try_fmt_vid_out: pointer to the function that implements * :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video out * in single plane mode +* @vidioc_try_ext_fmt_vid_out: pointer to the function that implements +* :ref:`VIDIOC_TRY_EXT_FMT <vidioc_g_fmt>` ioctl logic for video out * @vidioc_try_fmt_vid_out_overlay: pointer to the function that implements * :ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video overlay * output @@ -319,10 +334,14 @@ struct v4l2_ioctl_ops {/* VIDIOC_G_FMT handlers */ int (*vidioc_g_fmt_vid_cap)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_g_ext_fmt_vid_cap)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_g_fmt_vid_overlay)(struct file *file,void *fh,struct v4l2_format *f);int (*vidioc_g_fmt_vid_out)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_g_ext_fmt_vid_out)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_g_fmt_vid_out_overlay)(struct file *file,void *fh,struct v4l2_format *f); int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *fh,@@ -349,10 +368,14 @@ struct v4l2_ioctl_ops {/* VIDIOC_S_FMT handlers */ int (*vidioc_s_fmt_vid_cap)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_s_ext_fmt_vid_cap)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_s_fmt_vid_overlay)(struct file *file,void *fh,struct v4l2_format *f);int (*vidioc_s_fmt_vid_out)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_s_ext_fmt_vid_out)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_s_fmt_vid_out_overlay)(struct file *file,void *fh,struct v4l2_format *f); int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *fh,@@ -379,10 +402,14 @@ struct v4l2_ioctl_ops {/* VIDIOC_TRY_FMT handlers */ int (*vidioc_try_fmt_vid_cap)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_try_ext_fmt_vid_cap)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_try_fmt_vid_overlay)(struct file *file,void *fh,struct v4l2_format *f);int (*vidioc_try_fmt_vid_out)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_try_ext_fmt_vid_out)(struct file *file,void *fh, +struct v4l2_ext_pix_format *f);int (*vidioc_try_fmt_vid_out_overlay)(struct file *file,void *fh,struct v4l2_format *f); int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *fh,@@ -722,4 +749,10 @@ long int video_usercopy(struct file *file, unsigned int cmd,long int video_ioctl2 (struct file *file,unsigned int cmd,unsigned long int arg); +int v4l2_format_to_ext_format (const struct v4l2_format *f, +struct v4l2_ext_format *e,bool strict); +int v4l2_ext_format_to_format (const struct v4l2_ext_format *e, +struct v4l2_format *f, +bool mplane_cap,bool strict); +#endif /* _V4L2_IOCTL_H */ include/uapi/linux/videodev2.h +78
-0@@ -2171,6 +2171,55 @@ struct v4l2_pix_format_mplane {__u8 reserved[7 ]; } __attribute__ ((packed)); +/** +* struct v4l2_plane_ext_pix_format - additional, per-plane format definition +* @sizeimage: maximum size in bytes required for data, for which +* this plane will be used +* @bytesperline: distance in bytes between the leftmost pixels in two +* adjacent lines +*/ +struct v4l2_plane_ext_pix_format { +__u32 sizeimage; +__u32 bytesperline; +}; + +/** +* struct v4l2_ext_pix_format - extended single/multiplanar format definition +* @width: image width in pixels +* @height: image height in pixels +* @field: enum v4l2_field; field order (for interlaced video) +* @pixelformat: little endian four character code (fourcc) +* @modifier: modifier applied to the format (used for tiled formats and other +* kind of HW-specific formats, like compressed formats) +* @colorspace: enum v4l2_colorspace; supplemental to pixelformat +* @num_planes: number of planes for this format. Should be equal to 1 +* for single-planar formats and greater than 1 for +* multiplanar ones +* @plane_fmt: per-plane information +* @flags: format flags (V4L2_PIX_FMT_FLAG_*) +* @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding +* @hsv_enc: enum v4l2_hsv_encoding, HSV encoding +* @quantization: enum v4l2_quantization, colorspace quantization +* @xfer_func: enum v4l2_xfer_func, colorspace transfer function +*/ +struct v4l2_ext_pix_format { +__u32 width; +__u32 height; +__u32 field; +__u32 pixelformat; +__u64 modifier; +__u32 colorspace; +__u32 num_planes; +struct v4l2_plane_ext_pix_format plane_fmt[VIDEO_MAX_PLANES ]; +__u8 flags; +union { +__u8 ycbcr_enc; +__u8 hsv_enc; + }; +__u8 quantization; +__u8 xfer_func; +}; +/** * struct v4l2_sdr_format - SDR format definition * @pixelformat: little endian four character code (fourcc) @@ -2216,6 +2265,35 @@ struct v4l2_format { } fmt; }; +/** +* struct v4l2_ext_format - extended stream data format +* @type: enum v4l2_buf_type; type of the data stream. +* V4L2_BUF_TYPE_VIDEO[_OUTPUT]_OVERLAY and +* V4L2_BUF_TYPE_VIDEO_{CAPTURE,OUTPUT}_MPLANE are not supported +* @pix: definition of an image format. Used for +* V4L2_BUF_TYPE_VIDEO_{CAPTURE,OUTPUT} types +* @vbi: raw VBI capture or output parameters. Used for +* V4L2_BUF_TYPE_VBI_{CAPTURE,OUTPUT} types +* @sliced: sliced VBI capture or output parameters. Used for +* V4L2_BUF_TYPE_SLICED_VBI_{CAPTURE,OUTPUT} types. +* @sdr: SDR capture or output parameters. Used for +* V4L2_BUF_TYPE_SDR_{CAPTURE,OUTPUT} types +* @meta: meta capture or output parameters. Used for +* V4L2_BUF_TYPE_META_{CAPTURE,OUTPUT} types +* @raw_data: placeholder for future extensions and custom formats +*/ +struct v4l2_ext_format { +__u32 type; +union { +struct v4l2_ext_pix_format pix; +struct v4l2_vbi_format vbi; +struct v4l2_sliced_vbi_format sliced; +struct v4l2_sdr_format sdr; +struct v4l2_meta_format meta; +__u8 raw_data[200 ]; + } fmt; +}; +/* Stream type-dependent parameters */ struct v4l2_streamparm {
include/uapi/linux/videodev2.h struct v4l2_create_buffers { · line 2566
Quoted 9 lines
include/uapi/linux/videodev2.h +3
-0@@ -2480,6 +2558,9 @@ struct v4l2_create_buffers {#define VIDIOC_QUERY_EXT_CTRL _IOWR('V', 103, struct v4l2_query_ext_ctrl) +#define VIDIOC_G_EXT_FMT _IOWR('V', 104, struct v4l2_ext_format) +#define VIDIOC_S_EXT_FMT _IOWR('V', 105, struct v4l2_ext_format) +#define VIDIOC_TRY_EXT_FMT _IOWR('V', 106, struct v4l2_ext_format)/* Reminder: when adding new ioctls please add support for them to drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */
Regards,
Hans
Re: [RFC PATCH v2 2/7] media: v4l2: Extend pixel formats to unify single/multi-planar handling (and more)
Quoted 14 lines · On Thu, 11 Apr 2019 10:24:16 +0200 Hans Verkuil <[email protected]> wrote:
Quoted 14 lines
static void
v4l_print_framebuffer(const void *arg, bool write_only){drivers/media/v4l2-core/v4l2-ioctl.c +3
-1const struct v4l2_framebuffer *p = arg;@@ -951,11 +1027,15 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)switch (type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE :if ((is_vid || is_tch) && is_rx && - (ops->vidioc_g_fmt_vid_cap || ops->vidioc_g_fmt_vid_cap_mplane)) + (ops->vidioc_g_fmt_vid_cap || + ops->vidioc_g_ext_fmt_vid_cap || + ops->vidioc_g_fmt_vid_cap_mplane))return 0 ;break ;case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE :
Quoted 8 lines
drivers/media/v4l2-core/v4l2-ioctl.c static int check_fmt(struct file *file, enum v4l2_buf_type type) · line 1038
Quoted 4 lines
drivers/media/v4l2-core/v4l2-ioctl.c +3
-1-if (is_vid && is_rx && ops->vidioc_g_fmt_vid_cap_mplane) +if (is_vid && is_rx && + (ops->vidioc_g_fmt_vid_cap_mplane || + ops->vidioc_g_ext_fmt_vid_cap))Is this right? I thought that
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANEwas to be refused when used with the new ioctls? Perhapscheck_fmtneeds an extra argument that tells it whether it is called from the new ioctls or not.
Or maybe we should do the format conversion (or just a type conversion) before calling check_fmt().
Quoted 27 lines
Quoted 25 lines
drivers/media/v4l2-core/v4l2-ioctl.c +6
-2return 0 ;break ;case V4L2_BUF_TYPE_VIDEO_OVERLAY :@@ -964,11 +1044,15 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT :if (is_vid && is_tx && - (ops->vidioc_g_fmt_vid_out || ops->vidioc_g_fmt_vid_out_mplane)) + (ops->vidioc_g_fmt_vid_out || + ops->vidioc_g_ext_fmt_vid_out || + ops->vidioc_g_fmt_vid_out_mplane))return 0 ;break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : -if (is_vid && is_tx && ops->vidioc_g_fmt_vid_out_mplane) +if (is_vid && is_tx && + (ops->vidioc_g_ext_fmt_vid_out || + ops->vidioc_g_fmt_vid_out_mplane))return 0 ;break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :@@ -1048,6 +1132,197 @@ static void v4l_sanitize_format(struct v4l2_format *fmt) sizeof(fmt->fmt.pix) - offset); }
Quoted 16 lines
drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, · line 1730
Quoted 13 lines
drivers/media/v4l2-core/v4l2-ioctl.c +13
-0+static int v4l_g_fmt_ext_pix (const struct v4l2_ioctl_ops *ops, +struct file *file,void *fh, +struct v4l2_format *f) +{ +struct v4l2_ext_format ef = { + .type = f->type, + }; +int ret; + +switch (f->type) { +case V4L2_BUF_TYPE_VIDEO_CAPTURE : +case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : + ret = ops->vidioc_g_ext_fmt_vid_cap (file, fh, &ef.fmt.pix);This will call
vidioc_g_ext_fmt_vid_capwith type_MPLANE, which we said we wouldn't support for the extended ioctls.
That's okay because we don't pass ef around just the ef.fmt.pix which does not contain the format type. This being said, we should definitely have
ef.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
for the v4l2_ext_format_to_format() conversion that happens at the end of the function.
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ioctl.c static void v4l_sanitize_format(struct v4l2_format *fmt) · line 1259
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ioctl.c +4
-0+break ; + +case V4L2_BUF_TYPE_VIDEO_OUTPUT : +case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE :
Same here:
ef.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
Quoted 40 lines
Quoted 27 lines
drivers/media/v4l2-core/v4l2-ioctl.c +15
-5+ ret = ops->vidioc_g_ext_fmt_vid_out (file, fh, &ef.fmt.pix); +break ; + +default : +return -EINVAL ; + } + +if (ret) +return ret; + +return v4l2_ext_format_to_format (&ef, f, +V4L2_TYPE_IS_MULTIPLANAR (f->type), + true); +} +static int v4l_g_fmt (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) {@@ -1475,15 +1782,22 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : -if (unlikely (!ops->vidioc_g_fmt_vid_cap)) -break ; - p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; - ret = ops->vidioc_g_fmt_vid_cap (file, fh, arg); -/* just in case the driver zeroed it again */ drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, · line 1792
Quoted 10 lines
drivers/media/v4l2-core/v4l2-ioctl.c +8
-2- p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; -return ret; +if (ops->vidioc_g_fmt_vid_cap) { + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; + ret = ops->vidioc_g_fmt_vid_cap (file, fh, arg); +/* just in case the driver zeroed it again */ + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; +return ret; + }else if (ops->vidioc_g_ext_fmt_vid_cap) { +return v4l_g_fmt_ext_pix (ops, file, fh, p);Test for the extended op first. Same elsewhere below. E.g.:
Quoted 6 lines
if (ops->vidioc_g_ext_fmt_vid_cap) return v4l_g_fmt_ext_pix(ops, file, fh, p); if (unlikely(!ops->vidioc_g_fmt_vid_cap)) break; p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC; ...
Sure, I'll change the order.
Quoted 61 lines
Quoted 61 lines
drivers/media/v4l2-core/v4l2-ioctl.c +22
-9+ } +break ;case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : -return ops->vidioc_g_fmt_vid_cap_mplane (file, fh, arg); +if (ops->vidioc_g_fmt_vid_cap_mplane) +return ops->vidioc_g_fmt_vid_cap_mplane (file, fh, arg); +else if (ops->vidioc_g_ext_fmt_vid_cap) +return v4l_g_fmt_ext_pix (ops, file, fh, p); +break ;case V4L2_BUF_TYPE_VIDEO_OVERLAY :return ops->vidioc_g_fmt_vid_overlay (file, fh, arg);case V4L2_BUF_TYPE_VBI_CAPTURE :@@ -1491,15 +1805,22 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE :return ops->vidioc_g_fmt_sliced_vbi_cap (file, fh, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT : -if (unlikely (!ops->vidioc_g_fmt_vid_out)) -break ; - p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; - ret = ops->vidioc_g_fmt_vid_out (file, fh, arg); -/* just in case the driver zeroed it again */ - p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; -return ret; +if (ops->vidioc_g_fmt_vid_out) { + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; + ret = ops->vidioc_g_fmt_vid_out (file, fh, arg); +/* just in case the driver zeroed it again */ + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; +return ret; + }else if (ops->vidioc_g_ext_fmt_vid_out) { +return v4l_g_fmt_ext_pix (ops, file, fh, p); + } +break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : -return ops->vidioc_g_fmt_vid_out_mplane (file, fh, arg); +if (ops->vidioc_g_fmt_vid_out_mplane) +return ops->vidioc_g_fmt_vid_out_mplane (file, fh, arg); +else if (ops->vidioc_g_ext_fmt_vid_out) +return v4l_g_fmt_ext_pix (ops, file, fh, p); +break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :return ops->vidioc_g_fmt_vid_out_overlay (file, fh, arg);case V4L2_BUF_TYPE_VBI_OUTPUT :static int v4l_s_fmt(const struct
v4l2_ioctl_ops*ops,drivers/media/v4l2-core/v4l2-ioctl.c +2
-6struct file *file, void *fh, void *arg) {@@ -1551,23 +1943,31 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,switch (p->type) {case V4L2_BUF_TYPE_VIDEO_CAPTURE : -if (unlikely (!ops->vidioc_s_fmt_vid_cap)) -break ; -CLEAR_AFTER_FIELD (p, fmt.pix); - ret = ops->vidioc_s_fmt_vid_cap (file, fh, arg); -/* just in case the driver zeroed it again */ - p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; +if (ops->vidioc_s_fmt_vid_cap) { +CLEAR_AFTER_FIELD (p, fmt.pix);
Quoted 8 lines
drivers/media/v4l2-core/v4l2-ioctl.c static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, · line 1952
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ioctl.c +5
-0+ ret = ops->vidioc_s_fmt_vid_cap (file, fh, arg); +/* just in case the driver zeroed it again */ + p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; + }else if (ops->vidioc_s_ext_fmt_vid_cap) { + ret =v4l_s_fmt_ext_pix (ops, file, fh, arg);The helper functions v4l_[g/s/try]_fmt_ext_pix are confusingly named. How about: v4l_[g/s/try]_fmt_using_ext_fmt.
Yep, that's definitely a better name.
RFC PATCH v2 3/7 media: v4l2: Add extended buffer operations
In reply to Boris BrezillonFrom: Hans Verkuil <[email protected]>
Those extended buffer ops have several purpose:
1/ Fix y2038 issues by converting the timestamp into an u64 counting
the number of ns elapsed since 1970
2/ Unify single/multiplanar handling
3/ Add a new start offset field to each v4l2 plane buffer info struct
to support the case where a single buffer object is storing all planes data, each one being placed at a different offset
New hooks are created in v4l2_ioctl_ops so that drivers can start using these new objects.
The core takes care of converting new ioctls requests to old ones if the driver does not support the new hooks, and vice versa.
Note that the timecode field is gone, since there doesn't seem to be in-kernel users, but can be added back in the reserved area if needed.
---
Changes in v2:
- Add reserved space to v4l2_ext_buffer so that new fields can be added later on
Hans,
I kept initial autorship as this patch is heavily based on your initial proposal [1]. Please let me know if you want me to change it.
Regards,
Boris
--- drivers/media/v4l2-core/v4l2-dev.c | 30 +- drivers/media/v4l2-core/v4l2-ioctl.c | 428 +++++++++++++++++++++++++-- include/media/v4l2-ioctl.h | 30 ++ include/uapi/linux/videodev2.h | 130 ++++++++ 4 files changed, 591 insertions(+), 27 deletions(-)
drivers/media/v4l2-core/v4l2-dev.c +24 -6
@@ -700,12 +700,30 @@ static void determine_valid_ioctls(struct video_device *vdev)if (is_vid || is_vbi || is_sdr || is_tch) {/* ioctls valid for video, metadata, vbi or sdr */ SET_VALID_IOCTL (ops,VIDIOC_REQBUFS , vidioc_reqbufs); -SET_VALID_IOCTL (ops,VIDIOC_QUERYBUF , vidioc_querybuf); -SET_VALID_IOCTL (ops,VIDIOC_QBUF , vidioc_qbuf); -SET_VALID_IOCTL (ops,VIDIOC_EXPBUF , vidioc_expbuf); -SET_VALID_IOCTL (ops,VIDIOC_DQBUF , vidioc_dqbuf); -SET_VALID_IOCTL (ops,VIDIOC_CREATE_BUFS , vidioc_create_bufs); -SET_VALID_IOCTL (ops,VIDIOC_PREPARE_BUF , vidioc_prepare_buf); +if (ops->vidioc_querybuf || ops->vidioc_ext_querybuf) { +set_bit (_IOC_NR (VIDIOC_QUERYBUF ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_EXT_QUERYBUF ), valid_ioctls); + } +if (ops->vidioc_qbuf || ops->vidioc_ext_qbuf) { +set_bit (_IOC_NR (VIDIOC_QBUF ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_EXT_QBUF ), valid_ioctls); + } +if (ops->vidioc_expbuf || ops->vidioc_ext_expbuf) { +set_bit (_IOC_NR (VIDIOC_EXPBUF ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_EXT_EXPBUF ), valid_ioctls); + } +if (ops->vidioc_dqbuf || ops->vidioc_ext_dqbuf) { +set_bit (_IOC_NR (VIDIOC_DQBUF ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_EXT_DQBUF ), valid_ioctls); + } +if (ops->vidioc_create_bufs || ops->vidioc_ext_create_bufs) { +set_bit (_IOC_NR (VIDIOC_CREATE_BUFS ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_EXT_CREATE_BUFS ), valid_ioctls); + } +if (ops->vidioc_prepare_buf || ops->vidioc_ext_prepare_buf) { +set_bit (_IOC_NR (VIDIOC_PREPARE_BUF ), valid_ioctls); +set_bit (_IOC_NR (VIDIOC_EXT_PREPARE_BUF ), valid_ioctls); + }SET_VALID_IOCTL (ops,VIDIOC_STREAMON , vidioc_streamon);SET_VALID_IOCTL (ops,VIDIOC_STREAMOFF , vidioc_streamoff); }
drivers/media/v4l2-core/v4l2-ioctl.c +407 -21
514 lines not on this page · raw message
include/media/v4l2-ioctl.h +30 -0
@@ -168,16 +168,28 @@ struct v4l2_fh;* :ref:`VIDIOC_REQBUFS <vidioc_reqbufs>` ioctl * @vidioc_querybuf: pointer to the function that implements * :ref:`VIDIOC_QUERYBUF <vidioc_querybuf>` ioctl +* @vidioc_ext_querybuf: pointer to the function that implements +* :ref:`VIDIOC_EXT_QUERYBUF <vidioc_ext_querybuf>` ioctl * @vidioc_qbuf: pointer to the function that implements * :ref:`VIDIOC_QBUF <vidioc_qbuf>` ioctl +* @vidioc_ext_qbuf: pointer to the function that implements +* :ref:`VIDIOC_EXT_QBUF <vidioc_ext_qbuf>` ioctl * @vidioc_expbuf: pointer to the function that implements * :ref:`VIDIOC_EXPBUF <vidioc_expbuf>` ioctl +* @vidioc_ext_expbuf: pointer to the function that implements +* :ref:`VIDIOC_EXT_EXPBUF <vidioc_ext_expbuf>` ioctl * @vidioc_dqbuf: pointer to the function that implements * :ref:`VIDIOC_DQBUF <vidioc_qbuf>` ioctl +* @vidioc_ext_dqbuf: pointer to the function that implements +* :ref:`VIDIOC_EXT_DQBUF <vidioc_ext_qbuf>` ioctl * @vidioc_create_bufs: pointer to the function that implements * :ref:`VIDIOC_CREATE_BUFS <vidioc_create_bufs>` ioctl +* @vidioc_ext_create_bufs: pointer to the function that implements +* :ref:`VIDIOC_EXT_CREATE_BUFS <vidioc_ext_create_bufs>` ioctl * @vidioc_prepare_buf: pointer to the function that implements * :ref:`VIDIOC_PREPARE_BUF <vidioc_prepare_buf>` ioctl +* @vidioc_ext_prepare_buf: pointer to the function that implements +* :ref:`VIDIOC_EXT_PREPARE_BUF <vidioc_ext_prepare_buf>` ioctl * @vidioc_overlay: pointer to the function that implements * :ref:`VIDIOC_OVERLAY <vidioc_overlay>` ioctl * @vidioc_g_fbuf: pointer to the function that implements
@@ -438,17 +450,29 @@ struct v4l2_ioctl_ops { struct v4l2_requestbuffers *b);int (*vidioc_querybuf)(struct file *file,void *fh,struct v4l2_buffer *b); +int (*vidioc_ext_querybuf)(struct file *file,void *fh, +struct v4l2_ext_buffer *b);int (*vidioc_qbuf)(struct file *file,void *fh,struct v4l2_buffer *b); +int (*vidioc_ext_qbuf)(struct file *file,void *fh, +struct v4l2_ext_buffer *b);int (*vidioc_expbuf)(struct file *file,void *fh,struct v4l2_exportbuffer *e); +int (*vidioc_ext_expbuf)(struct file *file,void *fh, +struct v4l2_ext_exportbuffer *e);int (*vidioc_dqbuf)(struct file *file,void *fh,struct v4l2_buffer *b); +int (*vidioc_ext_dqbuf)(struct file *file,void *fh, +struct v4l2_ext_buffer *b);int (*vidioc_create_bufs)(struct file *file,void *fh,struct v4l2_create_buffers *b); +int (*vidioc_ext_create_bufs)(struct file *file,void *fh, +struct v4l2_ext_create_buffers *b);int (*vidioc_prepare_buf)(struct file *file,void *fh,struct v4l2_buffer *b); +int (*vidioc_ext_prepare_buf)(struct file *file,void *fh, +struct v4l2_ext_buffer *b);int (*vidioc_overlay)(struct file *file,void *fh,unsigned int i); int (*vidioc_g_fbuf)(struct file *file, void *fh,
@@ -755,4 +779,10 @@ int v4l2_ext_format_to_format(const struct v4l2_ext_format *e,struct v4l2_format *f, bool mplane_cap, bool strict); +int v4l2_ext_buffer_to_buffer (const struct v4l2_ext_buffer *e, +struct v4l2_buffer *b, +bool mplane_cap); +int v4l2_buffer_to_ext_buffer (const struct v4l2_buffer *b, +struct v4l2_ext_buffer *e); +#endif /* _V4L2_IOCTL_H */
include/uapi/linux/videodev2.h +130 -0
160 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [RFC PATCH v2 3/7] media: v4l2: Add extended buffer operations
Quoted 19 lines · On Thu, 4 Apr 2019 10:16:56 +0200 Boris Brezillon…
include/uapi/linux/videodev2.h +19
-0+/** +* struct v4l2_ext_buffer - extended video buffer info +* @index: id number of the buffer +* @type: enum v4l2_buf_type; buffer type. _MPLANE and _OVERLAY formats are +* invalid +* @flags: buffer informational flags +* @field: enum v4l2_field; field order of the image in the buffer +* @timestamp: frame timestamp +* @sequence: sequence count of this frame +* @memory: enum v4l2_memory; the method, in which the actual video data is +* passed +* @planes: per-plane buffer information +* @num_planes: number of plane buffers +* @request_fd: fd of the request that this buffer should use +* @reserved: some extra space reserved to add future fields (like timecode). +* Must be set to 0 +* +* Contains data exchanged by application and driver using one of the Streaming +* I/O methods.
include/uapi/linux/videodev2.h struct v4l2_buffer { · line 1059
Quoted 10 lines
include/uapi/linux/videodev2.h +10
-0+*/ +struct v4l2_ext_buffer { +__u32 index; +__u32 type; +__u32 flags; +__u32 field; +__u64 timestamp; +__u32 sequence; +__u32 memory; +struct v4l2_ext_plane planes[VIDEO_MAX_PLANES ];
I had a discussion with Tomasz last week, and he made me realize I was misunderstanding the concept of V4L2 planes. I thought it was encoding pixel-component planes, but it's actually memory planes, and sometimes those one memory planes might contain all component planes placed next to each others (like the V4L2_PIX_FMT_NV12 format).
So, the question is, what do we want v4l2_ext_plane to encode (memory planes or pixel component planes)?
If we go for the pixel component plane approach (which IMHO would be a good thing), that means we'll have to convert V4L2_PIX_FMT_NV12-like single-memory-plane buffers into v4l2_ext_buffer containing X planes, each pointing to the same memory object but at a different offset.
Quoted 12 lines
include/uapi/linux/videodev2.h +5
-0+__u32 num_planes; +__u32 request_fd; +__u32 reserved[10 ]; +}; +/** * v4l2_timeval_to_ns - Convert timeval to nanoseconds * @ts: pointer to the timeval variable to be converted @@ -1062,6 +1139,35 @@ struct v4l2_exportbuffer {__u32 reserved[11 ]; };
Re: [RFC PATCH v2 3/7] media: v4l2: Add extended buffer operations
Hi Boris,
Quoted 40 lines · Boris Brezillon
Quoted 19 lines · On Thu, 4 Apr 2019 10:16:56 +0200 Boris Brezillon…
include/uapi/linux/videodev2.h +19
-0+/** +* struct v4l2_ext_buffer - extended video buffer info +* @index: id number of the buffer +* @type: enum v4l2_buf_type; buffer type. _MPLANE and _OVERLAY formats are +* invalid +* @flags: buffer informational flags +* @field: enum v4l2_field; field order of the image in the buffer +* @timestamp: frame timestamp +* @sequence: sequence count of this frame +* @memory: enum v4l2_memory; the method, in which the actual video data is +* passed +* @planes: per-plane buffer information +* @num_planes: number of plane buffers +* @request_fd: fd of the request that this buffer should use +* @reserved: some extra space reserved to add future fields (like timecode). +* Must be set to 0 +* +* Contains data exchanged by application and driver using one of the Streaming +* I/O methods. include/uapi/linux/videodev2.h struct v4l2_buffer { · line 1059
Quoted 10 lines
include/uapi/linux/videodev2.h +10
-0+*/ +struct v4l2_ext_buffer { +__u32 index; +__u32 type; +__u32 flags; +__u32 field; +__u64 timestamp; +__u32 sequence; +__u32 memory; +struct v4l2_ext_plane planes[VIDEO_MAX_PLANES ];I had a discussion with Tomasz last week, and he made me realize I was misunderstanding the concept of V4L2 planes. I thought it was encoding pixel-component planes, but it's actually memory planes, and sometimes those one memory planes might contain all component planes placed next to each others (like the
V4L2_PIX_FMT_NV12format).
Quoted 6 lines
So, the question is, what do we want
v4l2_ext_planeto encode (memory planes or pixel component planes)?
If we go for the pixel component plane approach (which IMHO would be a good thing), that means we'll have to convert V4L2_PIX_FMT_NV12-like single-memory-plane buffers intov4l2_ext_buffercontaining X planes, each pointing to the same memory object but at a different offset.
First of all my apologies for the long delay in replying.
I think v4l2_ext_plane should encode pixel component planes, that way it becomes much easier to describe e.g. NV12 formats that use a single memory range, but where each component plane has its own bytesperline value and where each component plane starts at e.g. a page boundary due to hardware restrictions.
This is currently impossible to describe without creating a new pixel format.
But it is of course possible that different component planes use different memory ranges.
I think that the memory information in v4l2_ext_plane should describe the memory for that component plane and any following component planes that are part of that memory. The memory information for those following component planes should be 0 or some other value that makes it clear that it is part of the same memory buffer as the preceding component plane.
Regards,
Hans
Quoted 14 lines
Quoted 13 lines
include/uapi/linux/videodev2.h +5
-0+__u32 num_planes; +__u32 request_fd; +__u32 reserved[10 ]; +}; +/** * v4l2_timeval_to_ns - Convert timeval to nanoseconds * @ts: pointer to the timeval variable to be converted @@ -1062,6 +1139,35 @@ struct v4l2_exportbuffer {__u32 reserved[11 ]; };
Tomasz Figa
maintainerRe: [RFC PATCH v2 3/7] media: v4l2: Add extended buffer operations
Quoted 53 lines · Hans Verkuil
Hi Boris,
Quoted 40 lines · Boris Brezillon
Quoted 19 lines · On Thu, 4 Apr 2019 10:16:56 +0200 Boris Brezillon…
include/uapi/linux/videodev2.h +19
-0+/** +* struct v4l2_ext_buffer - extended video buffer info +* @index: id number of the buffer +* @type: enum v4l2_buf_type; buffer type. _MPLANE and _OVERLAY formats are +* invalid +* @flags: buffer informational flags +* @field: enum v4l2_field; field order of the image in the buffer +* @timestamp: frame timestamp +* @sequence: sequence count of this frame +* @memory: enum v4l2_memory; the method, in which the actual video data is +* passed +* @planes: per-plane buffer information +* @num_planes: number of plane buffers +* @request_fd: fd of the request that this buffer should use +* @reserved: some extra space reserved to add future fields (like timecode). +* Must be set to 0 +* +* Contains data exchanged by application and driver using one of the Streaming +* I/O methods. include/uapi/linux/videodev2.h struct v4l2_buffer { · line 1059
Quoted 10 lines
include/uapi/linux/videodev2.h +10
-0+*/ +struct v4l2_ext_buffer { +__u32 index; +__u32 type; +__u32 flags; +__u32 field; +__u64 timestamp; +__u32 sequence; +__u32 memory; +struct v4l2_ext_plane planes[VIDEO_MAX_PLANES ];I had a discussion with Tomasz last week, and he made me realize I was misunderstanding the concept of V4L2 planes. I thought it was encoding pixel-component planes, but it's actually memory planes, and sometimes those one memory planes might contain all component planes placed next to each others (like the
V4L2_PIX_FMT_NV12format).Quoted 6 lines
So, the question is, what do we want
v4l2_ext_planeto encode (memory planes or pixel component planes)?
If we go for the pixel component plane approach (which IMHO would be a good thing), that means we'll have to convert V4L2_PIX_FMT_NV12-like single-memory-plane buffers intov4l2_ext_buffercontaining X planes, each pointing to the same memory object but at a different offset.First of all my apologies for the long delay in replying.
Quoted 8 lines
I think
v4l2_ext_planeshould encode pixel component planes, that way it becomes much easier to describe e.g. NV12 formats that use a single memory range, but where each component plane has its own bytesperline value and where each component plane starts at e.g. a page boundary due to hardware restrictions.This is currently impossible to describe without creating a new pixel format.
Agreed with the above.
Quoted 9 lines
But it is of course possible that different component planes use different memory ranges.
I think that the memory information in
v4l2_ext_planeshould describe the memory for that component plane and any following component planes that are part of that memory. The memory information for those following component planes should be 0 or some other value that makes it clear that it is part of the same memory buffer as the preceding component plane.
That could be an option too, but there are also cases where the userspace has no idea to know if all the memory buffers are the same, e.g. when it gets dup()ed DMA-buf FDs for all the color planes.
We should let the userspace set file descriptors for all the color planes and then the framework figure out if that matches the driver (or format) expectations.
Best regards,
Tomasz
RFC PATCH v2 4/7 media: videobuf2: Expose helpers to implement the _ext_fmt and _ext_buf hooks
In reply to Boris BrezillonThe VB2 layer is used by a lot of drivers. Patch it to support the _EXT_FMT and _EXT_BUF ioctls in order to ease conversion of existing drivers to these new APIs.
Note that internally, the VB2 core is now only using ext structs and old APIs are supported through conversion wrappers.
---
Changes in v2:
- New patch
--- .../media/common/videobuf2/videobuf2-core.c | 2 + .../media/common/videobuf2/videobuf2-v4l2.c | 534 +++++++++++------- include/media/videobuf2-core.h | 6 +- include/media/videobuf2-v4l2.h | 26 +- 4 files changed, 352 insertions(+), 216 deletions(-)
drivers/media/common/videobuf2/videobuf2-core.c +2 -0
@@ -1176,6 +1176,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb) vb->planes[plane].length =0 ; vb->planes[plane].m.fd =0 ; vb->planes[plane].data_offset =0 ; + vb->planes[plane].dbuf_offset =0 ;/* Acquire each plane's memory */ mem_priv = call_ptr_memop(vb, attach_dmabuf,
@@ -1219,6 +1220,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb) vb->planes[plane].length = planes[plane].length; vb->planes[plane].m.fd = planes[plane].m.fd; vb->planes[plane].data_offset = planes[plane].data_offset; + vb->planes[plane].dbuf_offset = planes[plane].dbuf_offset; }if (reacquired) {
drivers/media/common/videobuf2/videobuf2-v4l2.c +321 -213
743 lines not on this page · raw message
include/media/videobuf2-core.h +5 -1
@@ -151,6 +151,8 @@ struct vb2_mem_ops {* @mem_priv: private data with this plane. * @dbuf: dma_buf - shared buffer object. * @dbuf_mapped: flag to show whether dbuf is mapped or not +* @dbuf_offset: offset where the plane starts. Usually 0, unless the buffer +* is shared by all planes of a multi-planar format. * @bytesused: number of bytes occupied by data in the plane (payload). * @length: size of this plane (NOT the payload) in bytes. * @min_length: minimum required size of this plane (NOT the payload) in bytes.
@@ -174,6 +176,7 @@ struct vb2_plane {void *mem_priv;struct dma_buf *dbuf;unsigned int dbuf_mapped; +unsigned int dbuf_offset;unsigned int bytesused;unsigned int length;unsigned int min_length;
@@ -441,7 +444,8 @@ struct vb2_ops {* struct vb2_buffer. * For V4L2 this is a &struct vb2_v4l2_buffer. * @fill_user_buffer: given a &vb2_buffer fill in the userspace structure. -* For V4L2 this is a &struct v4l2_buffer. +* For V4L2 this is a &struct v4l2_buffer or +* &struct v4l2_ext_buffer. * @fill_vb2_buffer: given a userspace structure, fill in the &vb2_buffer. * If the userspace structure is invalid, then this op * will return an error.
include/media/videobuf2-v4l2.h +24 -2
@@ -36,7 +36,7 @@* @planes: plane information (userptr/fd, length, bytesused, data_offset). * * Should contain enough information to be able to cover all the fields -* of &struct v4l2_buffer at ``videodev2.h``. +* of &struct v4l2_buffer and &struct v4l2_ext_buffer at ``videodev2.h``. */ struct vb2_v4l2_buffer {struct vb2_buffer vb2_buf;
@@ -72,6 +72,7 @@ int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp, unsigned int start_idx);int vb2_querybuf (struct vb2_queue *q,struct v4l2_buffer *b); +int vb2_ext_querybuf (struct vb2_queue *q,struct v4l2_ext_buffer *b);/** * vb2_reqbufs() - Wrapper for vb2_core_reqbufs() that also verifies
@@ -92,6 +93,8 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);* &v4l2_ioctl_ops->vidioc_create_bufs handler in driver */ int vb2_create_bufs (struct vb2_queue *q,struct v4l2_create_buffers *create); +int vb2_ext_create_bufs (struct vb2_queue *q, +struct v4l2_ext_create_buffers *create);/** * vb2_prepare_buf() - Pass ownership of a buffer from userspace to the kernel
@@ -117,6 +120,8 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create);*/ int vb2_prepare_buf (struct vb2_queue *q,struct media_device *mdev,struct v4l2_buffer *b); +int vb2_ext_prepare_buf (struct vb2_queue *q,struct media_device *mdev, +struct v4l2_ext_buffer *b);/** * vb2_qbuf() - Queue a buffer from userspace
@@ -143,6 +148,8 @@ int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev,*/ int vb2_qbuf (struct vb2_queue *q,struct media_device *mdev,struct v4l2_buffer *b); +int vb2_ext_qbuf (struct vb2_queue *q,struct media_device *mdev, +struct v4l2_ext_buffer *b);/** * vb2_expbuf() - Export a buffer as a file descriptor
@@ -154,6 +161,7 @@ int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,* from &v4l2_ioctl_ops->vidioc_expbuf handler in driver. */ int vb2_expbuf (struct vb2_queue *q,struct v4l2_exportbuffer *eb); +int vb2_ext_expbuf (struct vb2_queue *q,struct v4l2_ext_exportbuffer *eb);/** * vb2_dqbuf() - Dequeue a buffer to the userspace
@@ -180,6 +188,8 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb);* from &v4l2_ioctl_ops->vidioc_dqbuf handler in driver. */ int vb2_dqbuf (struct vb2_queue *q,struct v4l2_buffer *b,bool nonblocking); +int vb2_ext_dqbuf (struct vb2_queue *q,struct v4l2_ext_buffer *b, +bool nonblocking);/** * vb2_streamon - start streaming
@@ -276,15 +286,27 @@ int vb2_ioctl_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p);int vb2_ioctl_create_bufs (struct file *file,void *priv,struct v4l2_create_buffers *p); +int vb2_ioctl_ext_create_bufs (struct file *file,void *priv, +struct v4l2_ext_create_buffers *p);int vb2_ioctl_prepare_buf (struct file *file,void *priv,struct v4l2_buffer *p); +int vb2_ioctl_ext_prepare_buf (struct file *file,void *priv, +struct v4l2_ext_buffer *p);int vb2_ioctl_querybuf (struct file *file,void *priv,struct v4l2_buffer *p); +int vb2_ioctl_ext_querybuf (struct file *file,void *priv, +struct v4l2_ext_buffer *p);int vb2_ioctl_qbuf (struct file *file,void *priv,struct v4l2_buffer *p); +int vb2_ioctl_ext_qbuf (struct file *file,void *priv, +struct v4l2_ext_buffer *p);int vb2_ioctl_dqbuf (struct file *file,void *priv,struct v4l2_buffer *p); +int vb2_ioctl_ext_dqbuf (struct file *file,void *priv, +struct v4l2_ext_buffer *p);int vb2_ioctl_streamon (struct file *file,void *priv,enum v4l2_buf_type i);int vb2_ioctl_streamoff (struct file *file,void *priv,enum v4l2_buf_type i);int vb2_ioctl_expbuf (struct file *file,void *priv, -struct v4l2_exportbuffer *p); +struct v4l2_exportbuffer *p); +int vb2_ioctl_ext_expbuf (struct file *file,void *priv, +struct v4l2_ext_exportbuffer *p);/* struct v4l2_file_operations helpers */
Signature · 1 line
2.20.1
RFC PATCH v2 5/7 media: mediabus: Add an helper to convert a ext_pix format to an mbus_fmt
In reply to Boris BrezillonJust a new version of v4l2_fill_mbus_format() to deal with the new v4l2_ext_pix_format struct.
This is needed to convert the VIMC driver to the EXT_FMT/EXT_BUF iocts.
---
Changes in v2:
- New patch
--- include/media/v4l2-mediabus.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
include/media/v4l2-mediabus.h +22 -0
@@ -185,4 +185,26 @@ v4l2_fill_mbus_format_mplane(struct v4l2_mbus_framefmt *mbus_fmt, mbus_fmt->xfer_func = pix_mp_fmt->xfer_func; } +/** +* v4l2_fill_mbus_format_ext - Ancillary routine that fills a &struct +* v4l2_mbus_framefmt from a &struct v4l2_ext_pix_format. +* +* @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled +* @pix_fmt: pointer to &struct v4l2_ext_pix_format to be used as model +* @code: data format code (from &enum v4l2_mbus_pixelcode) +*/ +static inline void +v4l2_fill_mbus_format_ext (struct v4l2_mbus_framefmt *mbus_fmt, +const struct v4l2_ext_pix_format *pix_fmt,u32 code) +{ + mbus_fmt->width = pix_fmt->width; + mbus_fmt->height = pix_fmt->height; + mbus_fmt->field = pix_fmt->field; + mbus_fmt->colorspace = pix_fmt->colorspace; + mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc; + mbus_fmt->quantization = pix_fmt->quantization; + mbus_fmt->xfer_func = pix_fmt->xfer_func; + mbus_fmt->code = code; +} +#endif
Signature · 1 line
2.20.1
RFC PATCH v2 6/7 media: vivid: Convert the capture and output drivers to EXT_FMT/EXT_BUF
In reply to Boris BrezillonThis should simplify things a bit as we now have a single implementation instead of the MPLANE and !MPLANE versions.
---
Changes in v2:
- New patch
--- drivers/media/platform/vivid/vivid-core.c | 30 ++- drivers/media/platform/vivid/vivid-vid-cap.c | 171 +++++----------- drivers/media/platform/vivid/vivid-vid-cap.h | 15 +- drivers/media/platform/vivid/vivid-vid-out.c | 195 +++++++------------ drivers/media/platform/vivid/vivid-vid-out.h | 15 +- 5 files changed, 142 insertions(+), 284 deletions(-)
drivers/media/platform/vivid/vivid-core.c +12 -18
@@ -501,20 +501,14 @@ static const struct v4l2_ioctl_ops vivid_ioctl_ops = { .vidioc_querycap = vidioc_querycap, .vidioc_enum_fmt_vid_cap = vivid_enum_fmt_vid, - .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, - .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, - .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, - .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_vid_cap_mplane, - .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap_mplane, - .vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_vid_cap_mplane, + .vidioc_g_ext_fmt_vid_cap = vivid_g_fmt_vid_cap, + .vidioc_try_ext_fmt_vid_cap = vivid_try_fmt_vid_cap, + .vidioc_s_ext_fmt_vid_cap = vivid_s_fmt_vid_cap, .vidioc_enum_fmt_vid_out = vivid_enum_fmt_vid, - .vidioc_g_fmt_vid_out = vidioc_g_fmt_vid_out, - .vidioc_try_fmt_vid_out = vidioc_try_fmt_vid_out, - .vidioc_s_fmt_vid_out = vidioc_s_fmt_vid_out, - .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt_vid_out_mplane, - .vidioc_try_fmt_vid_out_mplane = vidioc_try_fmt_vid_out_mplane, - .vidioc_s_fmt_vid_out_mplane = vidioc_s_fmt_vid_out_mplane, + .vidioc_g_ext_fmt_vid_out = vivid_g_fmt_vid_out, + .vidioc_try_ext_fmt_vid_out = vivid_try_fmt_vid_out, + .vidioc_s_ext_fmt_vid_out = vivid_s_fmt_vid_out, .vidioc_g_selection = vidioc_g_selection, .vidioc_s_selection = vidioc_s_selection,
@@ -559,12 +553,12 @@ static const struct v4l2_ioctl_ops vivid_ioctl_ops = { .vidioc_s_fbuf = vidioc_s_fbuf, .vidioc_reqbufs = vb2_ioctl_reqbufs, - .vidioc_create_bufs = vb2_ioctl_create_bufs, - .vidioc_prepare_buf = vb2_ioctl_prepare_buf, - .vidioc_querybuf = vb2_ioctl_querybuf, - .vidioc_qbuf = vb2_ioctl_qbuf, - .vidioc_dqbuf = vb2_ioctl_dqbuf, - .vidioc_expbuf = vb2_ioctl_expbuf, + .vidioc_ext_create_bufs = vb2_ioctl_ext_create_bufs, + .vidioc_ext_prepare_buf = vb2_ioctl_ext_prepare_buf, + .vidioc_ext_querybuf = vb2_ioctl_ext_querybuf, + .vidioc_ext_qbuf = vb2_ioctl_ext_qbuf, + .vidioc_ext_dqbuf = vb2_ioctl_ext_dqbuf, + .vidioc_ext_expbuf = vb2_ioctl_ext_expbuf, .vidioc_streamon = vb2_ioctl_streamon, .vidioc_streamoff = vb2_ioctl_streamoff,
drivers/media/platform/vivid/vivid-vid-cap.c +53 -118
292 lines not on this page · raw message
drivers/media/platform/vivid/vivid-vid-cap.h +6 -9
@@ -17,15 +17,12 @@ extern const char * const vivid_ctrl_standard_strings[];extern const struct vb2_ops vivid_vid_cap_qops; -int vivid_g_fmt_vid_cap (struct file *file,void *priv,struct v4l2_format *f); -int vivid_try_fmt_vid_cap (struct file *file,void *priv,struct v4l2_format *f); -int vivid_s_fmt_vid_cap (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_g_fmt_vid_cap_mplane (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_try_fmt_vid_cap_mplane (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_s_fmt_vid_cap_mplane (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_g_fmt_vid_cap (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_try_fmt_vid_cap (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_s_fmt_vid_cap (struct file *file,void *priv,struct v4l2_format *f); +int vivid_g_fmt_vid_cap (struct file *file,void *priv, +struct v4l2_ext_pix_format *f); +int vivid_try_fmt_vid_cap (struct file *file,void *priv, +struct v4l2_ext_pix_format *f); +int vivid_s_fmt_vid_cap (struct file *file,void *priv, +struct v4l2_ext_pix_format *f);int vivid_vid_cap_g_selection (struct file *file,void *priv,struct v4l2_selection *sel);int vivid_vid_cap_s_selection (struct file *file,void *fh,struct v4l2_selection *s);int vivid_vid_cap_g_pixelaspect (struct file *file,void *priv,int type,struct v4l2_fract *f);
drivers/media/platform/vivid/vivid-vid-out.c +65 -130
313 lines not on this page · raw message
drivers/media/platform/vivid/vivid-vid-out.h +6 -9
@@ -12,15 +12,12 @@ extern const struct vb2_ops vivid_vid_out_qops;void vivid_update_format_out (struct vivid_dev *dev); -int vivid_g_fmt_vid_out (struct file *file,void *priv,struct v4l2_format *f); -int vivid_try_fmt_vid_out (struct file *file,void *priv,struct v4l2_format *f); -int vivid_s_fmt_vid_out (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_g_fmt_vid_out_mplane (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_try_fmt_vid_out_mplane (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_s_fmt_vid_out_mplane (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_g_fmt_vid_out (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_try_fmt_vid_out (struct file *file,void *priv,struct v4l2_format *f); -int vidioc_s_fmt_vid_out (struct file *file,void *priv,struct v4l2_format *f); +int vivid_g_fmt_vid_out (struct file *file,void *priv, +struct v4l2_ext_pix_format *f); +int vivid_try_fmt_vid_out (struct file *file,void *priv, +struct v4l2_ext_pix_format *f); +int vivid_s_fmt_vid_out (struct file *file,void *priv, +struct v4l2_ext_pix_format *f);int vivid_vid_out_g_selection (struct file *file,void *priv,struct v4l2_selection *sel);int vivid_vid_out_s_selection (struct file *file,void *fh,struct v4l2_selection *s);int vivid_vid_out_g_pixelaspect (struct file *file,void *priv,int type,struct v4l2_fract *f);
Signature · 1 line
2.20.1
RFC PATCH v2 7/7 media: vimc: Implement the ext_fmt and ext_buf hooks
In reply to Boris BrezillonConvert the driver to the _ext_fmt and _ext_buf API.
---
Changes in v2:
- New patch
--- drivers/media/platform/vimc/vimc-capture.c | 65 +++++++++++----------- drivers/media/platform/vimc/vimc-common.c | 4 +- drivers/media/platform/vimc/vimc-common.h | 2 +- drivers/media/platform/vimc/vimc-core.c | 10 +--- 4 files changed, 38 insertions(+), 43 deletions(-)
drivers/media/platform/vimc/vimc-capture.c +33 -32
@@ -32,7 +32,7 @@ struct vimc_cap_device {struct vimc_ent_device ved;struct video_device vdev;struct device *dev; -struct v4l2_pix_format format; +struct v4l2_ext_pix_format format;struct vb2_queue queue;struct list_head buf_list;/*
@@ -48,12 +48,13 @@ struct vimc_cap_device {struct vimc_stream stream; }; -static const struct v4l2_pix_format fmt_default = { +static const struct v4l2_ext_pix_format fmt_default = { .width =640 , .height =480 , .pixelformat =V4L2_PIX_FMT_RGB24 , .field =V4L2_FIELD_NONE , .colorspace =V4L2_COLORSPACE_DEFAULT , + .num_planes =1 , };struct vimc_cap_buffer {
@@ -79,7 +80,7 @@ static int vimc_cap_querycap(struct file *file, void *priv, }static void vimc_cap_get_format (struct vimc_ent_device *ved, -struct v4l2_pix_format *fmt) +struct v4l2_ext_pix_format *fmt) { struct vimc_cap_device *vcap = container_of(ved, struct vimc_cap_device, ved);
@@ -88,19 +89,18 @@ static void vimc_cap_get_format(struct vimc_ent_device *ved, }static int vimc_cap_g_fmt_vid_cap (struct file *file,void *priv, -struct v4l2_format *f) +struct v4l2_ext_pix_format *f) {struct vimc_cap_device *vcap =video_drvdata (file); - f->fmt.pix = vcap->format; + *f = vcap->format;return 0 ; }static int vimc_cap_try_fmt_vid_cap (struct file *file,void *priv, -struct v4l2_format *f) +struct v4l2_ext_pix_format *format) { -struct v4l2_pix_format *format = &f->fmt.pix;const struct vimc_pix_map *vpix; format->width = clamp_t(u32, format->width, VIMC_FRAME_MIN_WIDTH,
@@ -115,8 +115,10 @@ static int vimc_cap_try_fmt_vid_cap(struct file *file, void *priv, vpix =vimc_pix_map_by_pixelformat (format->pixelformat); }/* TODO: Add support for custom bytesperline values */ - format->bytesperline = format->width * vpix->bpp; - format->sizeimage = format->bytesperline * format->height; + format->num_planes =1 ; + format->plane_fmt[0 ].bytesperline = format->width * vpix->bpp; + format->plane_fmt[0 ].sizeimage = format->plane_fmt[0 ].bytesperline * + format->height;if (format->field ==V4L2_FIELD_ANY ) format->field = fmt_default.field;
@@ -127,7 +129,7 @@ static int vimc_cap_try_fmt_vid_cap(struct file *file, void *priv, }static int vimc_cap_s_fmt_vid_cap (struct file *file,void *priv, -struct v4l2_format *f) +struct v4l2_ext_pix_format *f) {struct vimc_cap_device *vcap =video_drvdata (file);
@@ -146,12 +148,10 @@ static int vimc_cap_s_fmt_vid_cap(struct file *file, void *priv, vcap->format.quantization, vcap->format.xfer_func, vcap->format.ycbcr_enc,/* new */ - f->fmt.pix.width, f->fmt.pix.height, - f->fmt.pix.pixelformat, f->fmt.pix.colorspace, - f->fmt.pix.quantization, f->fmt.pix.xfer_func, - f->fmt.pix.ycbcr_enc); + f->width, f->height, f->pixelformat, f->colorspace, + f->quantization, f->xfer_func, f->ycbcr_enc); - vcap->format = f->fmt.pix; + vcap->format = *f;return 0 ; }
@@ -206,19 +206,19 @@ static const struct v4l2_file_operations vimc_cap_fops = {static const struct v4l2_ioctl_ops vimc_cap_ioctl_ops = { .vidioc_querycap = vimc_cap_querycap, - .vidioc_g_fmt_vid_cap = vimc_cap_g_fmt_vid_cap, - .vidioc_s_fmt_vid_cap = vimc_cap_s_fmt_vid_cap, - .vidioc_try_fmt_vid_cap = vimc_cap_try_fmt_vid_cap, + .vidioc_g_ext_fmt_vid_cap = vimc_cap_g_fmt_vid_cap, + .vidioc_s_ext_fmt_vid_cap = vimc_cap_s_fmt_vid_cap, + .vidioc_try_ext_fmt_vid_cap = vimc_cap_try_fmt_vid_cap, .vidioc_enum_fmt_vid_cap = vimc_cap_enum_fmt_vid_cap, .vidioc_enum_framesizes = vimc_cap_enum_framesizes, .vidioc_reqbufs = vb2_ioctl_reqbufs, - .vidioc_create_bufs = vb2_ioctl_create_bufs, - .vidioc_prepare_buf = vb2_ioctl_prepare_buf, - .vidioc_querybuf = vb2_ioctl_querybuf, - .vidioc_qbuf = vb2_ioctl_qbuf, - .vidioc_dqbuf = vb2_ioctl_dqbuf, - .vidioc_expbuf = vb2_ioctl_expbuf, + .vidioc_ext_create_bufs = vb2_ioctl_ext_create_bufs, + .vidioc_ext_prepare_buf = vb2_ioctl_ext_prepare_buf, + .vidioc_ext_querybuf = vb2_ioctl_ext_querybuf, + .vidioc_ext_qbuf = vb2_ioctl_ext_qbuf, + .vidioc_ext_dqbuf = vb2_ioctl_ext_dqbuf, + .vidioc_ext_expbuf = vb2_ioctl_ext_expbuf, .vidioc_streamon = vb2_ioctl_streamon, .vidioc_streamoff = vb2_ioctl_streamoff, };
@@ -299,10 +299,11 @@ static int vimc_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,struct vimc_cap_device *vcap =vb2_get_drv_priv (vq);if (*nplanes) -return sizes[0 ] < vcap->format.sizeimage ? -EINVAL :0 ; +return sizes[0 ] < vcap->format.plane_fmt[0 ].sizeimage ? + -EINVAL :0 ;/* We don't support multiplanes for now */ *nplanes =1 ; - sizes[0 ] = vcap->format.sizeimage; + sizes[0 ] = vcap->format.plane_fmt[0 ].sizeimage;return 0 ; }
@@ -310,7 +311,7 @@ static int vimc_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,static int vimc_cap_buffer_prepare (struct vb2_buffer *vb) {struct vimc_cap_device *vcap =vb2_get_drv_priv (vb->vb2_queue); -unsigned long size = vcap->format.sizeimage; +unsigned long size = vcap->format.plane_fmt[0 ].sizeimage;if (vb2_plane_size (vb,0 ) < size) { dev_err(vcap->dev, "%s: buffer too small (%lu < %lu)\n",
@@ -382,11 +383,11 @@ static void *vimc_cap_process_frame(struct vimc_ent_device *ved, vbuf =vb2_plane_vaddr (&vimc_buf->vb2.vb2_buf,0 ); -memcpy (vbuf, frame, vcap->format.sizeimage); +memcpy (vbuf, frame, vcap->format.plane_fmt[0 ].sizeimage);/* Set it as ready */ vb2_set_plane_payload (&vimc_buf->vb2.vb2_buf,0 , - vcap->format.sizeimage); + vcap->format.plane_fmt[0 ].sizeimage);vb2_buffer_done (&vimc_buf->vb2.vb2_buf,VB2_BUF_STATE_DONE );return NULL ; }
@@ -452,9 +453,9 @@ static int vimc_cap_comp_bind(struct device *comp, struct device *master,/* Set default frame format */ vcap->format = fmt_default; vpix =vimc_pix_map_by_pixelformat (vcap->format.pixelformat); - vcap->format.bytesperline = vcap->format.width * vpix->bpp; - vcap->format.sizeimage = vcap->format.bytesperline * - vcap->format.height; + vcap->format.plane_fmt[0 ].bytesperline = vcap->format.width * vpix->bpp; + vcap->format.plane_fmt[0 ].sizeimage = vcap->format.plane_fmt[0 ].bytesperline * + vcap->format.height;/* Fill the vimc_ent_device struct */ vcap->ved.ent = &vcap->vdev.entity;
drivers/media/platform/vimc/vimc-common.c +2 -2
@@ -278,14 +278,14 @@ static int vimc_get_mbus_format(struct media_pad *pad, entity);struct vimc_ent_device *ved =video_get_drvdata (vdev);const struct vimc_pix_map *vpix; -struct v4l2_pix_format vdev_fmt; +struct v4l2_ext_pix_format vdev_fmt;if (!ved->vdev_get_format)return -ENOIOCTLCMD ; ved->vdev_get_format (ved, &vdev_fmt); vpix =vimc_pix_map_by_pixelformat (vdev_fmt.pixelformat); -v4l2_fill_mbus_format (&fmt->format, &vdev_fmt, vpix->code); +v4l2_fill_mbus_format_ext (&fmt->format, &vdev_fmt, vpix->code); }else {return -EINVAL ; }
drivers/media/platform/vimc/vimc-common.h +1 -1
@@ -118,7 +118,7 @@ struct vimc_ent_device {void * (*process_frame)(struct vimc_ent_device *ved,const void *frame);void (*vdev_get_format)(struct vimc_ent_device *ved, -struct v4l2_pix_format *fmt); +struct v4l2_ext_pix_format *fmt); };/**
drivers/media/platform/vimc/vimc-core.c +2 -8
@@ -244,13 +244,7 @@ static void vimc_comp_unbind(struct device *master)static int vimc_comp_compare (struct device *comp,void *data) { -const struct platform_device *pdev =to_platform_device (comp); -const char *name = data; - -if (!pdev->dev.platform_data) -return 0 ; - -return !strcmp (pdev->dev.platform_data, name); +return comp == data; }static struct component_match *vimc_add_subdevs (struct vimc_device *vimc)
@@ -280,7 +274,7 @@ static struct component_match *vimc_add_subdevs(struct vimc_device *vimc) }component_match_add (&vimc->pdev.dev, &match, vimc_comp_compare, - (void *)vimc->pipe_cfg->ents[i].name); + &vimc->subdevs[i]->dev); }return match;
Signature · 1 line
2.20.1
Hi Boris,
Quoted 42 lines · Boris Brezillon
Hello,
This RFC follows the discussion started by Hans [1] a few months back. It does not try to address all the problem reported in this thread but instead focuses on the FMT and BUF(S) ioctls.
Note that my primary goal is to unify handling for multiplanar and singleplanar formats and extend things to support the "single dmabuf storing all pixel planes" issue.
This version received a bit more testing than the previous one (added new tests to v4l2-compliance [2] to make sure EXT ioctls work as expected and also checked that !ext -> ext wrappers work correctly by running the old tests). Note that I'm not planning to post those v4l-utils patches on the ML until we've settled down on the userspace API, unless I'm explicitly asked to do so.
Right now I'm focusing on the case I was primarily interested in:
single dmabuf storing all pixel planes (each being at a different offset), and it seems that patching the VB2 core to support that is not a trivial task.So here are a few questions for V4L/DMABUF experts:
- Can the same dmabuf be mapped several times. I think it's okay apart from the extra/needless time spent doing cache maintenance operations, but there might be issues if an IOMMU is involved (duplicate mappings?). If it's not okay, then we need to find a solution to only attach/map the DMABUF once when it's used for several planes (this is what I tried to do here [3], but I'm not entirely happy with the implementation and started to investigate another approach here [4]).
- How should we pass the offset to drivers that were previously using theget_cookie()(or thedma_sgwrapper) to retrieve an sg table. Adding the offset to thedma_addror vaddr for vmalloc or dma-contig case can be done in the core, but for an sg-table it's a bit more complicated. Should drivers access this piece of information directly fromvb2_plane->dbuf_offset? And in that case, how do we make sure drivers don't simply ignore the offset and assume it's always zero?Few words about the feedback I got from Brian and Nicolas on my v1:
Quoted 10 lines
- modifier field has been moved to
v4l2_ext_formatas suggested
-v4l2_timecodeis still not present inv4l2_ext_buffer, but can be added back thanks to the extra reserved space
- the ENUMFMT is left as is for now, because I think we want Maxime's work on DRM/V4L format unification to land before reworking the ioctl (exposing extra info about the format and not only the 4CC code?). That also means that there's currently no way to know which modifiers are supported
- EXT_FMT/EXT_BUF capability flags to detect whether new ioctls are supported or not have not been added yet
Can you post a v3, rebased on top of our current master branch? No other changes needed, just a rebase.
I want to discuss this series during the media summit in Lyon and this one is getting a bit old. Also, the new patchwork is much better at keeping patch series together, so that makes it handy to link to this series.
Regards,
Hans
Quoted 71 lines
Regards,
Boris
[1]https://www.mail-archive.com/[email protected]/msg135729.html [2]https://github.com/bbrezillon/v4l-utils/commits/master [3]https://github.com/bbrezillon/linux/commit/4882435f80b05a61827649d55cc0f0cee79680a7 [4]https://github.com/bbrezillon/linux/commit/a415216c6aaab2d51f0bd62270b994c8196ddd90
*** BLURB HERE ***
Boris Brezillon (6):
media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap,out}_mplane
media: v4l2: Extend pixel formats to unify single/multi-planar
handling (and more)
media: videobuf2: Expose helpers to implement the_ext_fmtand
_ext_bufhooks
media: mediabus: Add an helper to convert aext_pixformat to an
mbus_fmt
media: vivid: Convert the capture and output drivers to
EXT_FMT/EXT_BUF
media: vimc: Implement theext_fmtandext_bufhooksHans Verkuil (1):
media: v4l2: Add extended buffer operations.../media/common/videobuf2/videobuf2-core.c | 2 + .../media/common/videobuf2/videobuf2-v4l2.c | 534 +++++--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 +- .../media/platform/exynos4-is/fimc-capture.c | 2 +- .../platform/exynos4-is/fimc-isp-video.c | 2 +- drivers/media/platform/exynos4-is/fimc-lite.c | 2 +- drivers/media/platform/exynos4-is/fimc-m2m.c | 4 +- .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 4 +- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 4 +- .../platform/mtk-vcodec/mtk_vcodec_dec.c | 4 +- .../platform/mtk-vcodec/mtk_vcodec_enc.c | 4 +- .../media/platform/qcom/camss/camss-video.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 4 +- drivers/media/platform/qcom/venus/venc.c | 4 +- drivers/media/platform/rcar_fdp1.c | 4 +- drivers/media/platform/rcar_jpu.c | 4 +- drivers/media/platform/renesas-ceu.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 4 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 4 +- drivers/media/platform/ti-vpe/vpe.c | 4 +- drivers/media/platform/vicodec/vicodec-core.c | 2 - drivers/media/platform/vimc/vimc-capture.c | 65 +- drivers/media/platform/vimc/vimc-common.c | 4 +- drivers/media/platform/vimc/vimc-common.h | 2 +- drivers/media/platform/vimc/vimc-core.c | 10 +- drivers/media/platform/vivid/vivid-core.c | 36 +- drivers/media/platform/vivid/vivid-vid-cap.c | 171 +-- drivers/media/platform/vivid/vivid-vid-cap.h | 15 +- .../media/platform/vivid/vivid-vid-common.c | 20 - .../media/platform/vivid/vivid-vid-common.h | 2 - drivers/media/platform/vivid/vivid-vid-out.c | 195 +-- drivers/media/platform/vivid/vivid-vid-out.h | 15 +- drivers/media/v4l2-core/v4l2-dev.c | 56 +- drivers/media/v4l2-core/v4l2-ioctl.c | 1141 +++++++++++++++-- drivers/staging/media/ipu3/ipu3-v4l2.c | 4 +- .../media/rockchip/vpu/rockchip_vpu_enc.c | 4 +- include/media/v4l2-ioctl.h | 77 +- include/media/v4l2-mediabus.h | 22 + include/media/videobuf2-core.h | 6 +- include/media/videobuf2-v4l2.h | 26 +- include/uapi/linux/videodev2.h | 211 +++ 42 files changed, 1945 insertions(+), 739 deletions(-)
Quoted 56 lines · On Mon, 23 Sep 2019 13:41:07 +0200 Hans Verkuil <[email protected]> wrote:
Hi Boris,
Quoted 42 lines · Boris Brezillon
Hello,
This RFC follows the discussion started by Hans [1] a few months back. It does not try to address all the problem reported in this thread but instead focuses on the FMT and BUF(S) ioctls.
Note that my primary goal is to unify handling for multiplanar and singleplanar formats and extend things to support the "single dmabuf storing all pixel planes" issue.
This version received a bit more testing than the previous one (added new tests to v4l2-compliance [2] to make sure EXT ioctls work as expected and also checked that !ext -> ext wrappers work correctly by running the old tests). Note that I'm not planning to post those v4l-utils patches on the ML until we've settled down on the userspace API, unless I'm explicitly asked to do so.
Right now I'm focusing on the case I was primarily interested in:
single dmabuf storing all pixel planes (each being at a different offset), and it seems that patching the VB2 core to support that is not a trivial task.So here are a few questions for V4L/DMABUF experts:
- Can the same dmabuf be mapped several times. I think it's okay apart from the extra/needless time spent doing cache maintenance operations, but there might be issues if an IOMMU is involved (duplicate mappings?). If it's not okay, then we need to find a solution to only attach/map the DMABUF once when it's used for several planes (this is what I tried to do here [3], but I'm not entirely happy with the implementation and started to investigate another approach here [4]).
- How should we pass the offset to drivers that were previously using theget_cookie()(or thedma_sgwrapper) to retrieve an sg table. Adding the offset to thedma_addror vaddr for vmalloc or dma-contig case can be done in the core, but for an sg-table it's a bit more complicated. Should drivers access this piece of information directly fromvb2_plane->dbuf_offset? And in that case, how do we make sure drivers don't simply ignore the offset and assume it's always zero?Few words about the feedback I got from Brian and Nicolas on my v1:
Quoted 10 lines
- modifier field has been moved to
v4l2_ext_formatas suggested
-v4l2_timecodeis still not present inv4l2_ext_buffer, but can be added back thanks to the extra reserved space
- the ENUMFMT is left as is for now, because I think we want Maxime's work on DRM/V4L format unification to land before reworking the ioctl (exposing extra info about the format and not only the 4CC code?). That also means that there's currently no way to know which modifiers are supported
- EXT_FMT/EXT_BUF capability flags to detect whether new ioctls are supported or not have not been added yet
Quoted 2 lines
Can you post a v3, rebased on top of our current master branch? No other changes needed, just a rebase.
Ok, I'll try to do that next week.
Quoted 59 lines · Boris Brezillon
Quoted 56 lines · On Mon, 23 Sep 2019 13:41:07 +0200 Hans Verkuil <[email protected]> wrote:
Hi Boris,
Quoted 52 lines · Boris Brezillon
Hello,
This RFC follows the discussion started by Hans [1] a few months back. It does not try to address all the problem reported in this thread but instead focuses on the FMT and BUF(S) ioctls.
Note that my primary goal is to unify handling for multiplanar and singleplanar formats and extend things to support the "single dmabuf storing all pixel planes" issue.
This version received a bit more testing than the previous one (added new tests to v4l2-compliance [2] to make sure EXT ioctls work as expected and also checked that !ext -> ext wrappers work correctly by running the old tests). Note that I'm not planning to post those v4l-utils patches on the ML until we've settled down on the userspace API, unless I'm explicitly asked to do so.
Right now I'm focusing on the case I was primarily interested in:
single dmabuf storing all pixel planes (each being at a different offset), and it seems that patching the VB2 core to support that is not a trivial task.So here are a few questions for V4L/DMABUF experts:
- Can the same dmabuf be mapped several times. I think it's okay apart from the extra/needless time spent doing cache maintenance operations, but there might be issues if an IOMMU is involved (duplicate mappings?). If it's not okay, then we need to find a solution to only attach/map the DMABUF once when it's used for several planes (this is what I tried to do here [3], but I'm not entirely happy with the implementation and started to investigate another approach here [4]).
- How should we pass the offset to drivers that were previously using theget_cookie()(or thedma_sgwrapper) to retrieve an sg table. Adding the offset to thedma_addror vaddr for vmalloc or dma-contig case can be done in the core, but for an sg-table it's a bit more complicated. Should drivers access this piece of information directly fromvb2_plane->dbuf_offset? And in that case, how do we make sure drivers don't simply ignore the offset and assume it's always zero?Few words about the feedback I got from Brian and Nicolas on my v1:
- modifier field has been moved to
v4l2_ext_formatas suggested
-v4l2_timecodeis still not present inv4l2_ext_buffer, but can be added back thanks to the extra reserved space
- the ENUMFMT is left as is for now, because I think we want Maxime's work on DRM/V4L format unification to land before reworking the ioctl (exposing extra info about the format and not only the 4CC code?). That also means that there's currently no way to know which modifiers are supported
- EXT_FMT/EXT_BUF capability flags to detect whether new ioctls are supported or not have not been added yet
Quoted 5 lines
Quoted 2 lines
Can you post a v3, rebased on top of our current master branch? No other changes needed, just a rebase.
Ok, I'll try to do that next week.
Great. Then it's also best to wait until v5.4-rc1 has been merged back into our tree.
Regards,
Hans