S/G_SELECTION: The target flag usage for capture/output buftype
Hi All, I need your help in understanding target flag usage in S/G_SELECTION ioctls. I see that some of the applications like GStreamer has the the hardcoding of target flag as V4L2_SEL_TGT_CROP for capture buftype. https://github.com/Xilinx/gst-plugins-good-xlnx/blob/master/sys/v4l2/gstv4l2object.c#L4027 And on the other side, I see that few up-streamed drivers are clearly restricting to use CROP for output buftype and COMPOSE for capture buftype. I do not have the concrete data from V4L2 specifications. At this point in time, I can only share other up-streamed drivers as examples. https://elixir.bootlin.com/linux/latest/source/drivers/media/platform/sti/bdisp/bdisp-v4l2.c#L935 https://elixir.bootlin.com/linux/latest/source/drivers/media/platform/rockchip/rga/rga.c#L622 Any references from V4L2 specification? Regards, Satish
S/G_SELECTION: The target flag usage for capture/output buftype
Hi All, I need your help in understanding target flag usage in S/G_SELECTION ioctls. I see that some of the applications like GStreamer has the the hardcoding of target flag as V4L2_SEL_TGT_CROP for capture buftype. https://github.com/Xilinx/gst-plugins-good-xlnx/blob/master/sys/v4l2/gstv4l2object.c#L4027 And on the other side, I see that few up-streamed drivers are clearly restricting to use CROP for output buftype and COMPOSE for capture buftype. I do not have the concrete data from V4L2 specifications. At this point in time, I can only share other up-streamed drivers as examples. https://elixir.bootlin.com/linux/latest/source/drivers/media/platform/sti/bdisp/bdisp-v4l2.c#L935 https://elixir.bootlin.com/linux/latest/source/drivers/media/platform/rockchip/rga/rga.c#L622 Any references from V4L2 specification? Regards, Satish
[PATCH 0/8] Add support for multi-planar formats and 10 bit formats
The patches are for xilinx v4l. The patcheset enable support to handle multiplanar formats and 10 bit formats. The implemenation has handling of single plane formats too for backward compatibility of some existing applications. Some patches are included as dependencies and are intended to sync downstream with upstream as well. Hyun Kwon (1): media: xilinx: vip: Add the pixel format for RGB24 Jeffrey Mouroux (1): uapi: media: New fourcc codes needed by Xilinx Video IP Radhey Shyam Pandey (1): v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format Rohit Athavale (1): media-bus: uapi: Add YCrCb 420 media bus format Satish Kumar Nagireddy (4): v4l: xilinx: dma: Update video format descriptor v4l: xilinx: dma: Add multi-planar support v4l: xilinx: dma: Add scaling and padding factor functions v4l: xilinx: dma: Get scaling and padding factor to calculate DMA params drivers/media/platform/xilinx/xilinx-dma.c | 365 drivers/media/platform/xilinx/xilinx-dma.h | 2 +- drivers/media/platform/xilinx/xilinx-vip.c | 61 - drivers/media/platform/xilinx/xilinx-vip.h | 13 +- drivers/media/platform/xilinx/xilinx-vipp.c | 22 +- include/uapi/linux/media-bus-format.h | 3 +- include/uapi/linux/videodev2.h | 11 + 7 files changed, 409 insertions(+), 68 deletions(-) -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH 7/8] v4l: xilinx: dma: Add scaling and padding factor functions
scaling_factor function returns multiplying factor to calculate bytes per component based on color format. For eg. scaling factor of YUV420 8 bit format is 1 so multiplying factor is 1 (8/8) scaling factor of YUV420 10 bit format is 1.25 (10/8) padding_factor function returns multiplying factor to calculate actual width of video according to color format. For eg. padding factor of YUV420 8 bit format: 8 bits per 1 component no padding bits here, so multiplying factor is 1 padding factor of YUV422 10 bit format: 32 bits per 3 components each component is 10 bit and the factor is 32/30 Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-vip.c | 43 ++ drivers/media/platform/xilinx/xilinx-vip.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index 51b7ef6..7543b75 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -94,6 +94,49 @@ const struct xvip_video_format *xvip_get_format_by_fourcc(u32 fourcc) EXPORT_SYMBOL_GPL(xvip_get_format_by_fourcc); /** + * xvip_bpl_scaling_factor - Retrieve bpl scaling factor for a 4CC + * @fourcc: the format 4CC + * + * Return: Return numerator and denominator values by address + */ +void xvip_bpl_scaling_factor(u32 fourcc, u32 *numerator, u32 *denominator) +{ + switch (fourcc) { + case V4L2_PIX_FMT_XV15M: + *numerator = 10; + *denominator = 8; + break; + default: + *numerator = 1; + *denominator = 1; + break; + } +} +EXPORT_SYMBOL_GPL(xvip_bpl_scaling_factor); + +/** + * xvip_width_padding_factor - Retrieve width's padding factor for a 4CC + * @fourcc: the format 4CC + * + * Return: Return numerator and denominator values by address + */ +void xvip_width_padding_factor(u32 fourcc, u32 *numerator, u32 *denominator) +{ + switch (fourcc) { + case V4L2_PIX_FMT_XV15M: + /* 32 bits are required per 30 bits of data */ + *numerator = 32; + *denominator = 30; + break; + default: + *numerator = 1; + *denominator = 1; + break; + } +} +EXPORT_SYMBOL_GPL(xvip_width_padding_factor); + +/** * xvip_of_get_format - Parse a device tree node and return format information * @node: the device tree node * diff --git a/drivers/media/platform/xilinx/xilinx-vip.h b/drivers/media/platform/xilinx/xilinx-vip.h index 006dcf77..26fada7 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.h +++ b/drivers/media/platform/xilinx/xilinx-vip.h @@ -135,6 +135,8 @@ struct xvip_video_format { const struct xvip_video_format *xvip_get_format_by_code(unsigned int code); const struct xvip_video_format *xvip_get_format_by_fourcc(u32 fourcc); const struct xvip_video_format *xvip_of_get_format(struct device_node *node); +void xvip_bpl_scaling_factor(u32 fourcc, u32 *numerator, u32 *denominator); +void xvip_width_padding_factor(u32 fourcc, u32 *numerator, u32 *denominator); void xvip_set_format_size(struct v4l2_mbus_framefmt *format, const struct v4l2_subdev_format *fmt); int xvip_enum_mbus_code(struct v4l2_subdev *subdev, -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH 2/8] media: xilinx: vip: Add the pixel format for RGB24
From: Hyun Kwon The pixel format for RGB24 is missing, and the driver always falls back to YUYV as no format descriptor matches with RGB24 fourcc. The pixel format is added to RGB24 format descriptor so that user can use the format. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-vip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index 3112591..d306f44 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -32,7 +32,7 @@ static const struct xvip_video_format xvip_video_formats[] = { { XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24, 3, V4L2_PIX_FMT_YUV444, "4:4:4, packed, YUYV" }, { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, - 3, 0, NULL }, + 3, V4L2_PIX_FMT_RGB24, "24-bit RGB" }, { XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8, 1, V4L2_PIX_FMT_GREY, "Greyscale 8-bit" }, { XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8, -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH 8/8] v4l: xilinx: dma: Get scaling and padding factor to calculate DMA params
Get multiplying factor to calculate bpp especially in case of 10 bit formats. Get multiplying factor to calculate padding width Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 29 ++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 656a87e..47b22e5 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -417,6 +417,7 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) struct xvip_dma_buffer *buf = to_xvip_dma_buffer(vbuf); struct dma_async_tx_descriptor *desc; u32 flags, luma_size; + u32 padding_factor_nume, padding_factor_deno, bpl_nume, bpl_deno; dma_addr_t addr = vb2_dma_contig_plane_dma_addr(vb, 0); if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE || @@ -442,8 +443,15 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) struct v4l2_pix_format_mplane *pix_mp; pix_mp = &dma->format.fmt.pix_mp; + xvip_width_padding_factor (pix_mp->pixelformat, + &padding_factor_nume, + &padding_factor_deno); + xvip_bpl_scaling_factor (pix_mp->pixelformat, &bpl_nume, +&bpl_deno); dma->xt.frame_size = dma->fmtinfo->num_planes; - dma->sgl[0].size = pix_mp->width * dma->fmtinfo->bpl_factor; + dma->sgl[0].size = (pix_mp->width * dma->fmtinfo->bpl_factor * + padding_factor_nume * bpl_nume)/ + (padding_factor_deno * bpl_deno); dma->sgl[0].icg = pix_mp->plane_fmt[0].bytesperline - dma->sgl[0].size; dma->xt.numf = pix_mp->height; @@ -472,8 +480,15 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) struct v4l2_pix_format *pix; pix = &dma->format.fmt.pix; + xvip_width_padding_factor (pix->pixelformat, + &padding_factor_nume, + &padding_factor_deno); + xvip_bpl_scaling_factor (pix->pixelformat, &bpl_nume, +&bpl_deno); dma->xt.frame_size = dma->fmtinfo->num_planes; - dma->sgl[0].size = pix->width * dma->fmtinfo->bpl_factor; + dma->sgl[0].size = (pix->width * dma->fmtinfo->bpl_factor * + padding_factor_nume * bpl_nume)/ + (padding_factor_deno * bpl_deno); dma->sgl[0].icg = pix->bytesperline - dma->sgl[0].size; dma->xt.numf = pix->height; dma->sgl[0].dst_icg = dma->sgl[0].size; @@ -682,6 +697,8 @@ __xvip_dma_try_format(struct xvip_dma *dma, unsigned int align; unsigned int bpl; unsigned int i, hsub, vsub, plane_width, plane_height; + unsigned int padding_factor_nume, padding_factor_deno; + unsigned int bpl_nume, bpl_deno; /* Retrieve format information and select the default format if the * requested format isn't supported. @@ -696,6 +713,10 @@ __xvip_dma_try_format(struct xvip_dma *dma, if (IS_ERR(info)) info = xvip_get_format_by_fourcc(XVIP_DMA_DEF_FORMAT); + xvip_width_padding_factor (info->fourcc, &padding_factor_nume, + &padding_factor_deno); + xvip_bpl_scaling_factor (info->fourcc, &bpl_nume, &bpl_deno); + /* The transfer alignment requirements are expressed in bytes. Compute * the minimum and maximum values, clamp the requested width and convert * it back to pixels. @@ -739,7 +760,9 @@ __xvip_dma_try_format(struct xvip_dma *dma, for (i = 0; i < info->num_planes; i++) { plane_width = pix_mp->width / (i ? hsub : 1); plane_height = pix_mp->height / (i ? vsub : 1); - min_bpl = plane_width * info->bpl_factor; + min_bpl = (plane_width * info->bpl_factor * + padding_factor_nume * bpl_nume)/ + (padding_factor_deno * bpl_deno); max_bpl = rounddown(XVIP_DMA_MAX_WIDTH, dma->align); bpl = pix_mp->plane_fmt[i].bytesperline; -- 2.7.4 This e
[PATCH 4/8] media-bus: uapi: Add YCrCb 420 media bus format
From: Rohit Athavale This commit adds a YUV 420 media bus format. Currently, one doesn't exist. VYYUYY8_1X24 does not describe the way the pixels are sent over the bus, but is an approximation. Signed-off-by: Satish Kumar Nagireddy --- include/uapi/linux/media-bus-format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h index 9e35117..0297e19 100644 --- a/include/uapi/linux/media-bus-format.h +++ b/include/uapi/linux/media-bus-format.h @@ -62,7 +62,7 @@ #define MEDIA_BUS_FMT_RGB121212_1X36 0x1019 #define MEDIA_BUS_FMT_RGB161616_1X48 0x101a -/* YUV (including grey) - next is 0x202c */ +/* YUV (including grey) - next is 0x202d */ #define MEDIA_BUS_FMT_Y8_1X8 0x2001 #define MEDIA_BUS_FMT_UV8_1X8 0x2015 #define MEDIA_BUS_FMT_UYVY8_1_5X8 0x2002 @@ -106,6 +106,7 @@ #define MEDIA_BUS_FMT_YUV12_1X36 0x2029 #define MEDIA_BUS_FMT_YUV16_1X48 0x202a #define MEDIA_BUS_FMT_UYYVYY16_0_5X48 0x202b +#define MEDIA_BUS_FMT_VYYUYY8_1X24 0x202c /* Bayer - next is 0x3021 */ #define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001 -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH 3/8] uapi: media: New fourcc codes needed by Xilinx Video IP
From: Jeffrey Mouroux The Xilinx Video Framebuffer DMA IP supports video memory formats that are not represented in the current V4L2 fourcc library. This patch adds those missing fourcc codes. This includes both new 8-bit and 10-bit pixel formats. Signed-off-by: Satish Kumar Nagireddy --- include/uapi/linux/videodev2.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 9827189..9fa4313c 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -509,7 +509,10 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_XBGR32 v4l2_fourcc('X', 'R', '2', '4') /* 32 BGRX-8-8-8-8 */ #define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */ #define V4L2_PIX_FMT_ARGB32 v4l2_fourcc('B', 'A', '2', '4') /* 32 ARGB-8-8-8-8 */ +#define V4L2_PIX_FMT_BGRA32 v4l2_fourcc('A', 'B', 'G', 'R') /* 32 ABGR-8-8-8-8 */ #define V4L2_PIX_FMT_XRGB32 v4l2_fourcc('B', 'X', '2', '4') /* 32 XRGB-8-8-8-8 */ +#define V4L2_PIX_FMT_BGRX32 v4l2_fourcc('X', 'B', 'G', 'R') /* 32 XBGR-8-8-8-8 */ +#define V4L2_PIX_FMT_XBGR30 v4l2_fourcc('R', 'X', '3', '0') /* 32 XBGR-2-10-10-10 */ /* Grey formats */ #define V4L2_PIX_FMT_GREYv4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ @@ -537,12 +540,16 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_VYUYv4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */ #define V4L2_PIX_FMT_Y41Pv4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */ #define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 */ +#define V4L2_PIX_FMT_XVUY32 v4l2_fourcc('X', 'V', '3', '2') /* 32 XVUY 8:8:8:8 */ +#define V4L2_PIX_FMT_AVUY32 v4l2_fourcc('A', 'V', '3', '2') /* 32 AVUY 8:8:8:8 */ +#define V4L2_PIX_FMT_VUY24 v4l2_fourcc('V', 'U', '2', '4') /* 24 VUY 8:8:8 */ #define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */ #define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */ #define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */ #define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */ #define V4L2_PIX_FMT_HM12v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */ #define V4L2_PIX_FMT_M420v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */ +#define V4L2_PIX_FMT_XVUY10 v4l2_fourcc('X', 'Y', '1', '0') /* 32 XVUY 2-10-10-10 */ /* two planes -- one Y, one Cr + Cb interleaved */ #define V4L2_PIX_FMT_NV12v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */ @@ -551,6 +558,8 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_NV61v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */ #define V4L2_PIX_FMT_NV24v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */ #define V4L2_PIX_FMT_NV42v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */ +#define V4L2_PIX_FMT_XV20v4l2_fourcc('X', 'V', '2', '0') /* 32 XY/UV 4:2:2 10-bit */ +#define V4L2_PIX_FMT_XV15v4l2_fourcc('X', 'V', '1', '5') /* 32 XY/UV 4:2:0 10-bit */ /* two non contiguous planes - one Y, one Cr + Cb interleaved */ #define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */ @@ -558,6 +567,8 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_NV16M v4l2_fourcc('N', 'M', '1', '6') /* 16 Y/CbCr 4:2:2 */ #define V4L2_PIX_FMT_NV61M v4l2_fourcc('N', 'M', '6', '1') /* 16 Y/CrCb 4:2:2 */ #define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */ +#define V4L2_PIX_FMT_XV20M v4l2_fourcc('X', 'M', '2', '0') /* 32 XY/UV 4:2:2 10-bit */ +#define V4L2_PIX_FMT_XV15M v4l2_fourcc('X', 'M', '1', '5') /* 32 XY/UV 4:2:0 10-bit */ #define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 macroblocks */ /* three planes - Y Cb, Cr */ -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH 1/8] v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format
From: Radhey Shyam Pandey In current implementation driver only checks the colorspace between the last subdev in the pipeline and the connected video node, the pipeline could be configured with wrong colorspace information until the very end. It thus makes little sense to check the colorspace only at the video node. So check can be dropped until we find a better solution to carry colorspace information through pipelines and to userspace. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 522cdfd..cb20ada 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -75,8 +75,7 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) if (dma->fmtinfo->code != fmt.format.code || dma->format.height != fmt.format.height || - dma->format.width != fmt.format.width || - dma->format.colorspace != fmt.format.colorspace) + dma->format.width != fmt.format.width) return -EINVAL; return 0; -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH 6/8] v4l: xilinx: dma: Add multi-planar support
The current v4l driver supports single plane formats. This patch will add support to handle multi-planar formats. Updated driver capabilities to multi-planar, where it can handle both single and multi-planar formats Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 343 +++- drivers/media/platform/xilinx/xilinx-dma.h | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 22 +- 3 files changed, 309 insertions(+), 58 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index cb20ada..656a87e 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -63,6 +63,7 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) struct v4l2_subdev_format fmt; struct v4l2_subdev *subdev; int ret; + int width, height; subdev = xvip_dma_remote_subdev(&dma->pad, &fmt.pad); if (subdev == NULL) @@ -73,9 +74,18 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) if (ret < 0) return ret == -ENOIOCTLCMD ? -EINVAL : ret; - if (dma->fmtinfo->code != fmt.format.code || - dma->format.height != fmt.format.height || - dma->format.width != fmt.format.width) + if (dma->fmtinfo->code != fmt.format.code) + return -EINVAL; + + if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) { + width = dma->format.fmt.pix_mp.width; + height = dma->format.fmt.pix_mp.height; + } else { + width = dma->format.fmt.pix.width; + height = dma->format.fmt.pix.height; + } + + if (width != fmt.format.width || height != fmt.format.height) return -EINVAL; return 0; @@ -302,6 +312,8 @@ static void xvip_dma_complete(void *param) { struct xvip_dma_buffer *buf = param; struct xvip_dma *dma = buf->dma; + u8 num_planes, i; + int sizeimage; spin_lock(&dma->queued_lock); list_del(&buf->queue); @@ -310,7 +322,28 @@ static void xvip_dma_complete(void *param) buf->buf.field = V4L2_FIELD_NONE; buf->buf.sequence = dma->sequence++; buf->buf.vb2_buf.timestamp = ktime_get_ns(); - vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma->format.sizeimage); + + if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) { + /* Handling contiguous data with mplanes */ + if (dma->fmtinfo->buffers == 1) { + sizeimage = + dma->format.fmt.pix_mp.plane_fmt[0].sizeimage; + vb2_set_plane_payload(&buf->buf.vb2_buf, 0, sizeimage); + } else { + /* Handling non-contiguous data with mplanes */ + num_planes = dma->format.fmt.pix_mp.num_planes; + for (i = 0; i < num_planes; i++) { + sizeimage = +dma->format.fmt.pix_mp.plane_fmt[i].sizeimage; + vb2_set_plane_payload(&buf->buf.vb2_buf, i, + sizeimage); + } + } + } else { + sizeimage = dma->format.fmt.pix.sizeimage; + vb2_set_plane_payload(&buf->buf.vb2_buf, 0, sizeimage); + } + vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); } @@ -320,13 +353,48 @@ xvip_dma_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct xvip_dma *dma = vb2_get_drv_priv(vq); + u8 i; + int sizeimage; + + /* Multi planar case: Make sure the image size is large enough */ + if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) { + if (*nplanes) { + if (*nplanes != dma->format.fmt.pix_mp.num_planes) + return -EINVAL; + + for (i = 0; i < *nplanes; i++) { +sizeimage = + dma->format.fmt.pix_mp.plane_fmt[i].sizeimage; + if (sizes[i] < sizeimage) + return -EINVAL; + } + } else { + /* Handling contiguous data with mplanes */ + if (dma->fmtinfo->buffers == 1) { + *nplanes = 1; + sizes[0] = + dma->format.fmt.pix_mp.plane_fmt[0].sizeimage; + return 0; + } else { + /* Handling non-contiguous data with mplanes */ +
[PATCH 5/8] v4l: xilinx: dma: Update video format descriptor
This patch updates video format descriptor to help information viz., number of planes per color format and chroma sub sampling factors. This commit adds the various 8-bit and 10-bit that are supported to the table queried by drivers. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-vip.c | 18 ++ drivers/media/platform/xilinx/xilinx-vip.h | 11 ++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index d306f44..51b7ef6 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -27,22 +27,24 @@ */ static const struct xvip_video_format xvip_video_formats[] = { + { XVIP_VF_YUV_420, 10, NULL, MEDIA_BUS_FMT_VYYUYY8_1X24, + 1, 15, V4L2_PIX_FMT_XV15M, 2, 2, 1, 2, "4:2:0, 10-bit 2-plane non-cont" }, { XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16, - 2, V4L2_PIX_FMT_YUYV, "4:2:2, packed, YUYV" }, + 2, 16, V4L2_PIX_FMT_YUYV, 1, 1, 2, 1, "4:2:2, packed, YUYV" }, { XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24, - 3, V4L2_PIX_FMT_YUV444, "4:4:4, packed, YUYV" }, + 3, 24, V4L2_PIX_FMT_VUY24, 1, 1, 1, 1, "4:4:4, packed, YUYV" }, { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, - 3, V4L2_PIX_FMT_RGB24, "24-bit RGB" }, + 3, 24, V4L2_PIX_FMT_RGB24, 1, 1, 1, 1, "24-bit RGB" }, { XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8, - 1, V4L2_PIX_FMT_GREY, "Greyscale 8-bit" }, + 1, 8, V4L2_PIX_FMT_GREY, 1, 1, 1, 1, "Greyscale 8-bit" }, { XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8, - 1, V4L2_PIX_FMT_SGRBG8, "Bayer 8-bit RGGB" }, + 1, 8, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, "Bayer 8-bit RGGB" }, { XVIP_VF_MONO_SENSOR, 8, "grbg", MEDIA_BUS_FMT_SGRBG8_1X8, - 1, V4L2_PIX_FMT_SGRBG8, "Bayer 8-bit GRBG" }, + 1, 8, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, "Bayer 8-bit GRBG" }, { XVIP_VF_MONO_SENSOR, 8, "gbrg", MEDIA_BUS_FMT_SGBRG8_1X8, - 1, V4L2_PIX_FMT_SGBRG8, "Bayer 8-bit GBRG" }, + 1, 8, V4L2_PIX_FMT_SGBRG8, 1, 1, 1, 1, "Bayer 8-bit GBRG" }, { XVIP_VF_MONO_SENSOR, 8, "bggr", MEDIA_BUS_FMT_SBGGR8_1X8, - 1, V4L2_PIX_FMT_SBGGR8, "Bayer 8-bit BGGR" }, + 1, 8, V4L2_PIX_FMT_SBGGR8, 1, 1, 1, 1, "Bayer 8-bit BGGR" }, }; /** diff --git a/drivers/media/platform/xilinx/xilinx-vip.h b/drivers/media/platform/xilinx/xilinx-vip.h index 42fee20..006dcf77 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.h +++ b/drivers/media/platform/xilinx/xilinx-vip.h @@ -109,8 +109,12 @@ struct xvip_device { * @width: AXI4 format width in bits per component * @pattern: CFA pattern for Mono/Sensor formats * @code: media bus format code - * @bpp: bytes per pixel (when stored in memory) + * @bpl_factor: Bytes per line factor * @fourcc: V4L2 pixel format FCC identifier + * @num_planes: number of planes w.r.t. color format + * @buffers: number of buffers per format + * @hsub: Horizontal sampling factor of Chroma + * @vsub: Vertical sampling factor of Chroma * @description: format description, suitable for userspace */ struct xvip_video_format { @@ -118,8 +122,13 @@ struct xvip_video_format { unsigned int width; const char *pattern; unsigned int code; + unsigned int bpl_factor; unsigned int bpp; u32 fourcc; + u8 num_planes; + u8 buffers; + u8 hsub; + u8 vsub; const char *description; }; -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
RE: [PATCH 0/8] Add support for multi-planar formats and 10 bit formats
Hi Sakari, Thanks for the review. I will provide the rst documentation. Regards, Satish > -Original Message- > From: linux-media-ow...@vger.kernel.org [mailto:linux-media- > ow...@vger.kernel.org] On Behalf Of Sakari Ailus > Sent: Wednesday, February 07, 2018 2:34 PM > To: Satish Kumar Nagireddy > Cc: linux-media@vger.kernel.org; laurent.pinch...@ideasonboard.com; > michal.si...@xilinx.com; Hyun Kwon ; Satish Kumar > Nagireddy > Subject: Re: [PATCH 0/8] Add support for multi-planar formats and 10 bit > formats > > Hi Satish, > > On Wed, Feb 07, 2018 at 02:29:30PM -0800, Satish Kumar Nagireddy wrote: > > Jeffrey Mouroux (1): > > uapi: media: New fourcc codes needed by Xilinx Video IP > > > > Rohit Athavale (1): > > media-bus: uapi: Add YCrCb 420 media bus format > > Could you add ReST documentation for these formats? > > -- > Regards, > > Sakari Ailus > e-mail: sakari.ai...@iki.fi
[PATCH v2 7/9] v4l: xilinx: dma: Add scaling and padding factor functions
scaling_factor function returns multiplying factor to calculate bytes per component based on color format. For eg. scaling factor of YUV420 8 bit format is 1 so multiplying factor is 1 (8/8) scaling factor of YUV420 10 bit format is 1.25 (10/8) padding_factor function returns multiplying factor to calculate actual width of video according to color format. For eg. padding factor of YUV420 8 bit format: 8 bits per 1 component no padding bits here, so multiplying factor is 1 padding factor of YUV422 10 bit format: 32 bits per 3 components each component is 10 bit and the factor is 32/30 Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-vip.c | 43 ++ drivers/media/platform/xilinx/xilinx-vip.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index 51b7ef6..7543b75 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -94,6 +94,49 @@ const struct xvip_video_format *xvip_get_format_by_fourcc(u32 fourcc) EXPORT_SYMBOL_GPL(xvip_get_format_by_fourcc); /** + * xvip_bpl_scaling_factor - Retrieve bpl scaling factor for a 4CC + * @fourcc: the format 4CC + * + * Return: Return numerator and denominator values by address + */ +void xvip_bpl_scaling_factor(u32 fourcc, u32 *numerator, u32 *denominator) +{ + switch (fourcc) { + case V4L2_PIX_FMT_XV15M: + *numerator = 10; + *denominator = 8; + break; + default: + *numerator = 1; + *denominator = 1; + break; + } +} +EXPORT_SYMBOL_GPL(xvip_bpl_scaling_factor); + +/** + * xvip_width_padding_factor - Retrieve width's padding factor for a 4CC + * @fourcc: the format 4CC + * + * Return: Return numerator and denominator values by address + */ +void xvip_width_padding_factor(u32 fourcc, u32 *numerator, u32 *denominator) +{ + switch (fourcc) { + case V4L2_PIX_FMT_XV15M: + /* 32 bits are required per 30 bits of data */ + *numerator = 32; + *denominator = 30; + break; + default: + *numerator = 1; + *denominator = 1; + break; + } +} +EXPORT_SYMBOL_GPL(xvip_width_padding_factor); + +/** * xvip_of_get_format - Parse a device tree node and return format information * @node: the device tree node * diff --git a/drivers/media/platform/xilinx/xilinx-vip.h b/drivers/media/platform/xilinx/xilinx-vip.h index 006dcf77..26fada7 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.h +++ b/drivers/media/platform/xilinx/xilinx-vip.h @@ -135,6 +135,8 @@ struct xvip_video_format { const struct xvip_video_format *xvip_get_format_by_code(unsigned int code); const struct xvip_video_format *xvip_get_format_by_fourcc(u32 fourcc); const struct xvip_video_format *xvip_of_get_format(struct device_node *node); +void xvip_bpl_scaling_factor(u32 fourcc, u32 *numerator, u32 *denominator); +void xvip_width_padding_factor(u32 fourcc, u32 *numerator, u32 *denominator); void xvip_set_format_size(struct v4l2_mbus_framefmt *format, const struct v4l2_subdev_format *fmt); int xvip_enum_mbus_code(struct v4l2_subdev *subdev, -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v2 3/9] uapi: media: New fourcc codes needed by Xilinx Video IP
From: Jeffrey Mouroux The Xilinx Video Framebuffer DMA IP supports video memory formats that are not represented in the current V4L2 fourcc library. This patch adds those missing fourcc codes. This includes both new 8-bit and 10-bit pixel formats. Signed-off-by: Satish Kumar Nagireddy --- include/uapi/linux/videodev2.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 9827189..9fa4313c 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -509,7 +509,10 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_XBGR32 v4l2_fourcc('X', 'R', '2', '4') /* 32 BGRX-8-8-8-8 */ #define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */ #define V4L2_PIX_FMT_ARGB32 v4l2_fourcc('B', 'A', '2', '4') /* 32 ARGB-8-8-8-8 */ +#define V4L2_PIX_FMT_BGRA32 v4l2_fourcc('A', 'B', 'G', 'R') /* 32 ABGR-8-8-8-8 */ #define V4L2_PIX_FMT_XRGB32 v4l2_fourcc('B', 'X', '2', '4') /* 32 XRGB-8-8-8-8 */ +#define V4L2_PIX_FMT_BGRX32 v4l2_fourcc('X', 'B', 'G', 'R') /* 32 XBGR-8-8-8-8 */ +#define V4L2_PIX_FMT_XBGR30 v4l2_fourcc('R', 'X', '3', '0') /* 32 XBGR-2-10-10-10 */ /* Grey formats */ #define V4L2_PIX_FMT_GREYv4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ @@ -537,12 +540,16 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_VYUYv4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */ #define V4L2_PIX_FMT_Y41Pv4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */ #define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 */ +#define V4L2_PIX_FMT_XVUY32 v4l2_fourcc('X', 'V', '3', '2') /* 32 XVUY 8:8:8:8 */ +#define V4L2_PIX_FMT_AVUY32 v4l2_fourcc('A', 'V', '3', '2') /* 32 AVUY 8:8:8:8 */ +#define V4L2_PIX_FMT_VUY24 v4l2_fourcc('V', 'U', '2', '4') /* 24 VUY 8:8:8 */ #define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */ #define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */ #define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */ #define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */ #define V4L2_PIX_FMT_HM12v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */ #define V4L2_PIX_FMT_M420v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */ +#define V4L2_PIX_FMT_XVUY10 v4l2_fourcc('X', 'Y', '1', '0') /* 32 XVUY 2-10-10-10 */ /* two planes -- one Y, one Cr + Cb interleaved */ #define V4L2_PIX_FMT_NV12v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */ @@ -551,6 +558,8 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_NV61v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */ #define V4L2_PIX_FMT_NV24v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */ #define V4L2_PIX_FMT_NV42v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */ +#define V4L2_PIX_FMT_XV20v4l2_fourcc('X', 'V', '2', '0') /* 32 XY/UV 4:2:2 10-bit */ +#define V4L2_PIX_FMT_XV15v4l2_fourcc('X', 'V', '1', '5') /* 32 XY/UV 4:2:0 10-bit */ /* two non contiguous planes - one Y, one Cr + Cb interleaved */ #define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */ @@ -558,6 +567,8 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_NV16M v4l2_fourcc('N', 'M', '1', '6') /* 16 Y/CbCr 4:2:2 */ #define V4L2_PIX_FMT_NV61M v4l2_fourcc('N', 'M', '6', '1') /* 16 Y/CrCb 4:2:2 */ #define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */ +#define V4L2_PIX_FMT_XV20M v4l2_fourcc('X', 'M', '2', '0') /* 32 XY/UV 4:2:2 10-bit */ +#define V4L2_PIX_FMT_XV15M v4l2_fourcc('X', 'M', '1', '5') /* 32 XY/UV 4:2:0 10-bit */ #define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 macroblocks */ /* three planes - Y Cb, Cr */ -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v2 0/9] Add support for multi-planar formats and 10 bit formats
The patches are for xilinx v4l. The patcheset enable support to handle multiplanar formats and 10 bit formats. The implemenation has handling of single plane formats too for backward compatibility of some existing applications. Some patches are included as dependencies and are intended to sync downstream with upstream as well. Hyun Kwon (1): media: xilinx: vip: Add the pixel format for RGB24 Jeffrey Mouroux (1): uapi: media: New fourcc codes needed by Xilinx Video IP Radhey Shyam Pandey (1): v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format Rohit Athavale (1): media-bus: uapi: Add YCrCb 420 media bus format Satish Kumar Nagireddy (4): v4l: xilinx: dma: Update video format descriptor v4l: xilinx: dma: Add multi-planar support v4l: xilinx: dma: Add scaling and padding factor functions v4l: xilinx: dma: Get scaling and padding factor to calculate DMA params drivers/media/platform/xilinx/xilinx-dma.c | 365 drivers/media/platform/xilinx/xilinx-dma.h | 2 +- drivers/media/platform/xilinx/xilinx-vip.c | 61 - drivers/media/platform/xilinx/xilinx-vip.h | 13 +- drivers/media/platform/xilinx/xilinx-vipp.c | 22 +- include/uapi/linux/media-bus-format.h | 3 +- include/uapi/linux/videodev2.h | 11 + 7 files changed, 409 insertions(+), 68 deletions(-) -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v2 5/9] v4l: xilinx: dma: Update video format descriptor
This patch updates video format descriptor to help information viz., number of planes per color format and chroma sub sampling factors. This commit adds the various 8-bit and 10-bit that are supported to the table queried by drivers. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-vip.c | 18 ++ drivers/media/platform/xilinx/xilinx-vip.h | 11 ++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index d306f44..51b7ef6 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -27,22 +27,24 @@ */ static const struct xvip_video_format xvip_video_formats[] = { + { XVIP_VF_YUV_420, 10, NULL, MEDIA_BUS_FMT_VYYUYY8_1X24, + 1, 15, V4L2_PIX_FMT_XV15M, 2, 2, 1, 2, "4:2:0, 10-bit 2-plane non-cont" }, { XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16, - 2, V4L2_PIX_FMT_YUYV, "4:2:2, packed, YUYV" }, + 2, 16, V4L2_PIX_FMT_YUYV, 1, 1, 2, 1, "4:2:2, packed, YUYV" }, { XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24, - 3, V4L2_PIX_FMT_YUV444, "4:4:4, packed, YUYV" }, + 3, 24, V4L2_PIX_FMT_VUY24, 1, 1, 1, 1, "4:4:4, packed, YUYV" }, { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, - 3, V4L2_PIX_FMT_RGB24, "24-bit RGB" }, + 3, 24, V4L2_PIX_FMT_RGB24, 1, 1, 1, 1, "24-bit RGB" }, { XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8, - 1, V4L2_PIX_FMT_GREY, "Greyscale 8-bit" }, + 1, 8, V4L2_PIX_FMT_GREY, 1, 1, 1, 1, "Greyscale 8-bit" }, { XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8, - 1, V4L2_PIX_FMT_SGRBG8, "Bayer 8-bit RGGB" }, + 1, 8, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, "Bayer 8-bit RGGB" }, { XVIP_VF_MONO_SENSOR, 8, "grbg", MEDIA_BUS_FMT_SGRBG8_1X8, - 1, V4L2_PIX_FMT_SGRBG8, "Bayer 8-bit GRBG" }, + 1, 8, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, "Bayer 8-bit GRBG" }, { XVIP_VF_MONO_SENSOR, 8, "gbrg", MEDIA_BUS_FMT_SGBRG8_1X8, - 1, V4L2_PIX_FMT_SGBRG8, "Bayer 8-bit GBRG" }, + 1, 8, V4L2_PIX_FMT_SGBRG8, 1, 1, 1, 1, "Bayer 8-bit GBRG" }, { XVIP_VF_MONO_SENSOR, 8, "bggr", MEDIA_BUS_FMT_SBGGR8_1X8, - 1, V4L2_PIX_FMT_SBGGR8, "Bayer 8-bit BGGR" }, + 1, 8, V4L2_PIX_FMT_SBGGR8, 1, 1, 1, 1, "Bayer 8-bit BGGR" }, }; /** diff --git a/drivers/media/platform/xilinx/xilinx-vip.h b/drivers/media/platform/xilinx/xilinx-vip.h index 42fee20..006dcf77 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.h +++ b/drivers/media/platform/xilinx/xilinx-vip.h @@ -109,8 +109,12 @@ struct xvip_device { * @width: AXI4 format width in bits per component * @pattern: CFA pattern for Mono/Sensor formats * @code: media bus format code - * @bpp: bytes per pixel (when stored in memory) + * @bpl_factor: Bytes per line factor * @fourcc: V4L2 pixel format FCC identifier + * @num_planes: number of planes w.r.t. color format + * @buffers: number of buffers per format + * @hsub: Horizontal sampling factor of Chroma + * @vsub: Vertical sampling factor of Chroma * @description: format description, suitable for userspace */ struct xvip_video_format { @@ -118,8 +122,13 @@ struct xvip_video_format { unsigned int width; const char *pattern; unsigned int code; + unsigned int bpl_factor; unsigned int bpp; u32 fourcc; + u8 num_planes; + u8 buffers; + u8 hsub; + u8 vsub; const char *description; }; -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v2 1/9] v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format
From: Radhey Shyam Pandey In current implementation driver only checks the colorspace between the last subdev in the pipeline and the connected video node, the pipeline could be configured with wrong colorspace information until the very end. It thus makes little sense to check the colorspace only at the video node. So check can be dropped until we find a better solution to carry colorspace information through pipelines and to userspace. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 522cdfd..cb20ada 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -75,8 +75,7 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) if (dma->fmtinfo->code != fmt.format.code || dma->format.height != fmt.format.height || - dma->format.width != fmt.format.width || - dma->format.colorspace != fmt.format.colorspace) + dma->format.width != fmt.format.width) return -EINVAL; return 0; -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v2 4/9] media-bus: uapi: Add YCrCb 420 media bus format
From: Rohit Athavale This commit adds a YUV 420 media bus format. Currently, one doesn't exist. VYYUYY8_1X24 does not describe the way the pixels are sent over the bus, but is an approximation. Signed-off-by: Satish Kumar Nagireddy --- include/uapi/linux/media-bus-format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h index 9e35117..ade7e9d 100644 --- a/include/uapi/linux/media-bus-format.h +++ b/include/uapi/linux/media-bus-format.h @@ -62,7 +62,7 @@ #define MEDIA_BUS_FMT_RGB121212_1X36 0x1019 #define MEDIA_BUS_FMT_RGB161616_1X48 0x101a -/* YUV (including grey) - next is 0x202c */ +/* YUV (including grey) - next is 0x202d */ #define MEDIA_BUS_FMT_Y8_1X8 0x2001 #define MEDIA_BUS_FMT_UV8_1X8 0x2015 #define MEDIA_BUS_FMT_UYVY8_1_5X8 0x2002 @@ -106,6 +106,7 @@ #define MEDIA_BUS_FMT_YUV12_1X36 0x2029 #define MEDIA_BUS_FMT_YUV16_1X48 0x202a #define MEDIA_BUS_FMT_UYYVYY16_0_5X48 0x202b +#define MEDIA_BUS_FMT_VYYUYY8_1X24 0x202c /* Bayer - next is 0x3021 */ #define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001 -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v2 6/9] v4l: xilinx: dma: Add multi-planar support
The current v4l driver supports single plane formats. This patch will add support to handle multi-planar formats. Updated driver capabilities to multi-planar, where it can handle both single and multi-planar formats Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 341 +++- drivers/media/platform/xilinx/xilinx-dma.h | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 22 +- 3 files changed, 307 insertions(+), 58 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index cb20ada..664981b 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -63,6 +63,7 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) struct v4l2_subdev_format fmt; struct v4l2_subdev *subdev; int ret; + int width, height; subdev = xvip_dma_remote_subdev(&dma->pad, &fmt.pad); if (subdev == NULL) @@ -73,9 +74,18 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) if (ret < 0) return ret == -ENOIOCTLCMD ? -EINVAL : ret; - if (dma->fmtinfo->code != fmt.format.code || - dma->format.height != fmt.format.height || - dma->format.width != fmt.format.width) + if (dma->fmtinfo->code != fmt.format.code) + return -EINVAL; + + if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) { + width = dma->format.fmt.pix_mp.width; + height = dma->format.fmt.pix_mp.height; + } else { + width = dma->format.fmt.pix.width; + height = dma->format.fmt.pix.height; + } + + if (width != fmt.format.width || height != fmt.format.height) return -EINVAL; return 0; @@ -302,6 +312,8 @@ static void xvip_dma_complete(void *param) { struct xvip_dma_buffer *buf = param; struct xvip_dma *dma = buf->dma; + u8 num_planes, i; + int sizeimage; spin_lock(&dma->queued_lock); list_del(&buf->queue); @@ -310,7 +322,28 @@ static void xvip_dma_complete(void *param) buf->buf.field = V4L2_FIELD_NONE; buf->buf.sequence = dma->sequence++; buf->buf.vb2_buf.timestamp = ktime_get_ns(); - vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma->format.sizeimage); + + if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) { + /* Handling contiguous data with mplanes */ + if (dma->fmtinfo->buffers == 1) { + sizeimage = + dma->format.fmt.pix_mp.plane_fmt[0].sizeimage; + vb2_set_plane_payload(&buf->buf.vb2_buf, 0, sizeimage); + } else { + /* Handling non-contiguous data with mplanes */ + num_planes = dma->format.fmt.pix_mp.num_planes; + for (i = 0; i < num_planes; i++) { + sizeimage = +dma->format.fmt.pix_mp.plane_fmt[i].sizeimage; + vb2_set_plane_payload(&buf->buf.vb2_buf, i, + sizeimage); + } + } + } else { + sizeimage = dma->format.fmt.pix.sizeimage; + vb2_set_plane_payload(&buf->buf.vb2_buf, 0, sizeimage); + } + vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); } @@ -320,13 +353,48 @@ xvip_dma_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct xvip_dma *dma = vb2_get_drv_priv(vq); + u8 i; + int sizeimage; + + /* Multi planar case: Make sure the image size is large enough */ + if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) { + if (*nplanes) { + if (*nplanes != dma->format.fmt.pix_mp.num_planes) + return -EINVAL; + + for (i = 0; i < *nplanes; i++) { +sizeimage = + dma->format.fmt.pix_mp.plane_fmt[i].sizeimage; + if (sizes[i] < sizeimage) + return -EINVAL; + } + } else { + /* Handling contiguous data with mplanes */ + if (dma->fmtinfo->buffers == 1) { + *nplanes = 1; + sizes[0] = + dma->format.fmt.pix_mp.plane_fmt[0].sizeimage; + return 0; + } else { + /* Handling non-contiguous data with mplanes */ +
[PATCH v2 2/9] media: xilinx: vip: Add the pixel format for RGB24
From: Hyun Kwon The pixel format for RGB24 is missing, and the driver always falls back to YUYV as no format descriptor matches with RGB24 fourcc. The pixel format is added to RGB24 format descriptor so that user can use the format. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-vip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index 3112591..d306f44 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -32,7 +32,7 @@ static const struct xvip_video_format xvip_video_formats[] = { { XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24, 3, V4L2_PIX_FMT_YUV444, "4:4:4, packed, YUYV" }, { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, - 3, 0, NULL }, + 3, V4L2_PIX_FMT_RGB24, "24-bit RGB" }, { XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8, 1, V4L2_PIX_FMT_GREY, "Greyscale 8-bit" }, { XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8, -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v2 9/9] [media] Add documentation for YUV420 bus format
The code is MEDIA_BUS_FMT_VYYUYY8_1X24 Signed-off-by: Satish Kumar Nagireddy --- Documentation/media/uapi/v4l/subdev-formats.rst | 34 + 1 file changed, 34 insertions(+) diff --git a/Documentation/media/uapi/v4l/subdev-formats.rst b/Documentation/media/uapi/v4l/subdev-formats.rst index b1eea44..a4d7d87 100644 --- a/Documentation/media/uapi/v4l/subdev-formats.rst +++ b/Documentation/media/uapi/v4l/subdev-formats.rst @@ -7283,6 +7283,40 @@ The following table list existing packed 48bit wide YUV formats. - y\ :sub:`1` - y\ :sub:`0` + - MEDIA_BUS_FMT_VYYUYY8_1X24 + - 0x202c + - + - + - + - + - + - + - + - + - v\ :sub:`7` + - v\ :sub:`6` + - v\ :sub:`5` + - v\ :sub:`4` + - v\ :sub:`3` + - v\ :sub:`2` + - v\ :sub:`1` + - v\ :sub:`0` + - u\ :sub:`7` + - u\ :sub:`6` + - u\ :sub:`5` + - u\ :sub:`4` + - u\ :sub:`3` + - u\ :sub:`2` + - u\ :sub:`1` + - u\ :sub:`0` + - y\ :sub:`7` + - y\ :sub:`6` + - y\ :sub:`5` + - y\ :sub:`4` + - y\ :sub:`3` + - y\ :sub:`2` + - y\ :sub:`1` + - y\ :sub:`0` .. raw:: latex -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v2 8/9] v4l: xilinx: dma: Get scaling and padding factor to calculate DMA params
Get multiplying factor to calculate bpp especially in case of 10 bit formats. Get multiplying factor to calculate padding width Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 29 ++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 664981b..3c2fd02 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -417,6 +417,7 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) struct xvip_dma_buffer *buf = to_xvip_dma_buffer(vbuf); struct dma_async_tx_descriptor *desc; u32 flags, luma_size; + u32 padding_factor_nume, padding_factor_deno, bpl_nume, bpl_deno; dma_addr_t addr = vb2_dma_contig_plane_dma_addr(vb, 0); if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE || @@ -442,8 +443,15 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) struct v4l2_pix_format_mplane *pix_mp; pix_mp = &dma->format.fmt.pix_mp; + xvip_width_padding_factor(pix_mp->pixelformat, + &padding_factor_nume, + &padding_factor_deno); + xvip_bpl_scaling_factor(pix_mp->pixelformat, &bpl_nume, + &bpl_deno); dma->xt.frame_size = dma->fmtinfo->num_planes; - dma->sgl[0].size = pix_mp->width * dma->fmtinfo->bpl_factor; + dma->sgl[0].size = (pix_mp->width * dma->fmtinfo->bpl_factor * + padding_factor_nume * bpl_nume) / + (padding_factor_deno * bpl_deno); dma->sgl[0].icg = pix_mp->plane_fmt[0].bytesperline - dma->sgl[0].size; dma->xt.numf = pix_mp->height; @@ -472,8 +480,15 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) struct v4l2_pix_format *pix; pix = &dma->format.fmt.pix; + xvip_width_padding_factor(pix->pixelformat, + &padding_factor_nume, + &padding_factor_deno); + xvip_bpl_scaling_factor(pix->pixelformat, &bpl_nume, + &bpl_deno); dma->xt.frame_size = dma->fmtinfo->num_planes; - dma->sgl[0].size = pix->width * dma->fmtinfo->bpl_factor; + dma->sgl[0].size = (pix->width * dma->fmtinfo->bpl_factor * + padding_factor_nume * bpl_nume) / + (padding_factor_deno * bpl_deno); dma->sgl[0].icg = pix->bytesperline - dma->sgl[0].size; dma->xt.numf = pix->height; dma->sgl[0].dst_icg = dma->sgl[0].size; @@ -682,6 +697,8 @@ __xvip_dma_try_format(struct xvip_dma *dma, unsigned int align; unsigned int bpl; unsigned int i, hsub, vsub, plane_width, plane_height; + unsigned int padding_factor_nume, padding_factor_deno; + unsigned int bpl_nume, bpl_deno; /* Retrieve format information and select the default format if the * requested format isn't supported. @@ -694,6 +711,10 @@ __xvip_dma_try_format(struct xvip_dma *dma, if (IS_ERR(info)) info = xvip_get_format_by_fourcc(XVIP_DMA_DEF_FORMAT); + xvip_width_padding_factor(info->fourcc, &padding_factor_nume, + &padding_factor_deno); + xvip_bpl_scaling_factor(info->fourcc, &bpl_nume, &bpl_deno); + /* The transfer alignment requirements are expressed in bytes. Compute * the minimum and maximum values, clamp the requested width and convert * it back to pixels. @@ -737,7 +758,9 @@ __xvip_dma_try_format(struct xvip_dma *dma, for (i = 0; i < info->num_planes; i++) { plane_width = pix_mp->width / (i ? hsub : 1); plane_height = pix_mp->height / (i ? vsub : 1); - min_bpl = plane_width * info->bpl_factor; + min_bpl = (plane_width * info->bpl_factor * + padding_factor_nume * bpl_nume) / + (padding_factor_deno * bpl_deno); max_bpl = rounddown(XVIP_DMA_MAX_WIDTH, dma->align); bpl = pix_mp->plane_fmt[i].bytesperline; -- 2.7.4 This e
[PATCH v3 0/9] Add support for multi-planar formats and 10 bit formats
The patches are for xilinx v4l. The patcheset enable support to handle multiplanar formats and 10 bit formats. The implemenation has handling of single plane formats too for backward compatibility of some existing applications. Some patches are included as dependencies and are intended to sync downstream with upstream as well. Hyun Kwon (1): media: xilinx: vip: Add the pixel format for RGB24 Jeffrey Mouroux (1): uapi: media: New fourcc codes needed by Xilinx Video IP Radhey Shyam Pandey (1): v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format Rohit Athavale (1): media-bus: uapi: Add YCrCb 420 media bus format Satish Kumar Nagireddy (5): [media] Add documentation for YUV420 bus format v4l: xilinx: dma: Update video format descriptor v4l: xilinx: dma: Add multi-planar support v4l: xilinx: dma: Add scaling and padding factor functions v4l: xilinx: dma: Get scaling and padding factor to calculate DMA params drivers/media/platform/xilinx/xilinx-dma.c | 365 drivers/media/platform/xilinx/xilinx-dma.h | 2 +- drivers/media/platform/xilinx/xilinx-vip.c | 61 - drivers/media/platform/xilinx/xilinx-vip.h | 13 +- drivers/media/platform/xilinx/xilinx-vipp.c | 22 +- include/uapi/linux/media-bus-format.h | 3 +- include/uapi/linux/videodev2.h | 11 + 7 files changed, 409 insertions(+), 68 deletions(-) -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v3 2/9] media: xilinx: vip: Add the pixel format for RGB24
From: Hyun Kwon The pixel format for RGB24 is missing, and the driver always falls back to YUYV as no format descriptor matches with RGB24 fourcc. The pixel format is added to RGB24 format descriptor so that user can use the format. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-vip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index 3112591..d306f44 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -32,7 +32,7 @@ static const struct xvip_video_format xvip_video_formats[] = { { XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24, 3, V4L2_PIX_FMT_YUV444, "4:4:4, packed, YUYV" }, { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, - 3, 0, NULL }, + 3, V4L2_PIX_FMT_RGB24, "24-bit RGB" }, { XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8, 1, V4L2_PIX_FMT_GREY, "Greyscale 8-bit" }, { XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8, -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v3 8/9] v4l: xilinx: dma: Add scaling and padding factor functions
scaling_factor function returns multiplying factor to calculate bytes per component based on color format. For eg. scaling factor of YUV420 8 bit format is 1 so multiplying factor is 1 (8/8) scaling factor of YUV420 10 bit format is 1.25 (10/8) padding_factor function returns multiplying factor to calculate actual width of video according to color format. For eg. padding factor of YUV420 8 bit format: 8 bits per 1 component no padding bits here, so multiplying factor is 1 padding factor of YUV422 10 bit format: 32 bits per 3 components each component is 10 bit and the factor is 32/30 Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-vip.c | 43 ++ drivers/media/platform/xilinx/xilinx-vip.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index 51b7ef6..7543b75 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -94,6 +94,49 @@ const struct xvip_video_format *xvip_get_format_by_fourcc(u32 fourcc) EXPORT_SYMBOL_GPL(xvip_get_format_by_fourcc); /** + * xvip_bpl_scaling_factor - Retrieve bpl scaling factor for a 4CC + * @fourcc: the format 4CC + * + * Return: Return numerator and denominator values by address + */ +void xvip_bpl_scaling_factor(u32 fourcc, u32 *numerator, u32 *denominator) +{ + switch (fourcc) { + case V4L2_PIX_FMT_XV15M: + *numerator = 10; + *denominator = 8; + break; + default: + *numerator = 1; + *denominator = 1; + break; + } +} +EXPORT_SYMBOL_GPL(xvip_bpl_scaling_factor); + +/** + * xvip_width_padding_factor - Retrieve width's padding factor for a 4CC + * @fourcc: the format 4CC + * + * Return: Return numerator and denominator values by address + */ +void xvip_width_padding_factor(u32 fourcc, u32 *numerator, u32 *denominator) +{ + switch (fourcc) { + case V4L2_PIX_FMT_XV15M: + /* 32 bits are required per 30 bits of data */ + *numerator = 32; + *denominator = 30; + break; + default: + *numerator = 1; + *denominator = 1; + break; + } +} +EXPORT_SYMBOL_GPL(xvip_width_padding_factor); + +/** * xvip_of_get_format - Parse a device tree node and return format information * @node: the device tree node * diff --git a/drivers/media/platform/xilinx/xilinx-vip.h b/drivers/media/platform/xilinx/xilinx-vip.h index 006dcf77..26fada7 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.h +++ b/drivers/media/platform/xilinx/xilinx-vip.h @@ -135,6 +135,8 @@ struct xvip_video_format { const struct xvip_video_format *xvip_get_format_by_code(unsigned int code); const struct xvip_video_format *xvip_get_format_by_fourcc(u32 fourcc); const struct xvip_video_format *xvip_of_get_format(struct device_node *node); +void xvip_bpl_scaling_factor(u32 fourcc, u32 *numerator, u32 *denominator); +void xvip_width_padding_factor(u32 fourcc, u32 *numerator, u32 *denominator); void xvip_set_format_size(struct v4l2_mbus_framefmt *format, const struct v4l2_subdev_format *fmt); int xvip_enum_mbus_code(struct v4l2_subdev *subdev, -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v3 7/9] v4l: xilinx: dma: Add multi-planar support
The current v4l driver supports single plane formats. This patch will add support to handle multi-planar formats. Updated driver capabilities to multi-planar, where it can handle both single and multi-planar formats Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 341 +++- drivers/media/platform/xilinx/xilinx-dma.h | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 22 +- 3 files changed, 307 insertions(+), 58 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index cb20ada..664981b 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -63,6 +63,7 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) struct v4l2_subdev_format fmt; struct v4l2_subdev *subdev; int ret; + int width, height; subdev = xvip_dma_remote_subdev(&dma->pad, &fmt.pad); if (subdev == NULL) @@ -73,9 +74,18 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) if (ret < 0) return ret == -ENOIOCTLCMD ? -EINVAL : ret; - if (dma->fmtinfo->code != fmt.format.code || - dma->format.height != fmt.format.height || - dma->format.width != fmt.format.width) + if (dma->fmtinfo->code != fmt.format.code) + return -EINVAL; + + if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) { + width = dma->format.fmt.pix_mp.width; + height = dma->format.fmt.pix_mp.height; + } else { + width = dma->format.fmt.pix.width; + height = dma->format.fmt.pix.height; + } + + if (width != fmt.format.width || height != fmt.format.height) return -EINVAL; return 0; @@ -302,6 +312,8 @@ static void xvip_dma_complete(void *param) { struct xvip_dma_buffer *buf = param; struct xvip_dma *dma = buf->dma; + u8 num_planes, i; + int sizeimage; spin_lock(&dma->queued_lock); list_del(&buf->queue); @@ -310,7 +322,28 @@ static void xvip_dma_complete(void *param) buf->buf.field = V4L2_FIELD_NONE; buf->buf.sequence = dma->sequence++; buf->buf.vb2_buf.timestamp = ktime_get_ns(); - vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma->format.sizeimage); + + if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) { + /* Handling contiguous data with mplanes */ + if (dma->fmtinfo->buffers == 1) { + sizeimage = + dma->format.fmt.pix_mp.plane_fmt[0].sizeimage; + vb2_set_plane_payload(&buf->buf.vb2_buf, 0, sizeimage); + } else { + /* Handling non-contiguous data with mplanes */ + num_planes = dma->format.fmt.pix_mp.num_planes; + for (i = 0; i < num_planes; i++) { + sizeimage = +dma->format.fmt.pix_mp.plane_fmt[i].sizeimage; + vb2_set_plane_payload(&buf->buf.vb2_buf, i, + sizeimage); + } + } + } else { + sizeimage = dma->format.fmt.pix.sizeimage; + vb2_set_plane_payload(&buf->buf.vb2_buf, 0, sizeimage); + } + vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); } @@ -320,13 +353,48 @@ xvip_dma_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct xvip_dma *dma = vb2_get_drv_priv(vq); + u8 i; + int sizeimage; + + /* Multi planar case: Make sure the image size is large enough */ + if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) { + if (*nplanes) { + if (*nplanes != dma->format.fmt.pix_mp.num_planes) + return -EINVAL; + + for (i = 0; i < *nplanes; i++) { +sizeimage = + dma->format.fmt.pix_mp.plane_fmt[i].sizeimage; + if (sizes[i] < sizeimage) + return -EINVAL; + } + } else { + /* Handling contiguous data with mplanes */ + if (dma->fmtinfo->buffers == 1) { + *nplanes = 1; + sizes[0] = + dma->format.fmt.pix_mp.plane_fmt[0].sizeimage; + return 0; + } else { + /* Handling non-contiguous data with mplanes */ +
[PATCH v3 4/9] media-bus: uapi: Add YCrCb 420 media bus format
From: Rohit Athavale This commit adds a YUV 420 media bus format. Currently, one doesn't exist. VYYUYY8_1X24 does not describe the way the pixels are sent over the bus, but is an approximation. Signed-off-by: Satish Kumar Nagireddy --- include/uapi/linux/media-bus-format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h index 9e35117..ade7e9d 100644 --- a/include/uapi/linux/media-bus-format.h +++ b/include/uapi/linux/media-bus-format.h @@ -62,7 +62,7 @@ #define MEDIA_BUS_FMT_RGB121212_1X36 0x1019 #define MEDIA_BUS_FMT_RGB161616_1X48 0x101a -/* YUV (including grey) - next is 0x202c */ +/* YUV (including grey) - next is 0x202d */ #define MEDIA_BUS_FMT_Y8_1X8 0x2001 #define MEDIA_BUS_FMT_UV8_1X8 0x2015 #define MEDIA_BUS_FMT_UYVY8_1_5X8 0x2002 @@ -106,6 +106,7 @@ #define MEDIA_BUS_FMT_YUV12_1X36 0x2029 #define MEDIA_BUS_FMT_YUV16_1X48 0x202a #define MEDIA_BUS_FMT_UYYVYY16_0_5X48 0x202b +#define MEDIA_BUS_FMT_VYYUYY8_1X24 0x202c /* Bayer - next is 0x3021 */ #define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001 -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v3 6/9] v4l: xilinx: dma: Update video format descriptor
This patch updates video format descriptor to help information viz., number of planes per color format and chroma sub sampling factors. This commit adds the various 8-bit and 10-bit that are supported to the table queried by drivers. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-vip.c | 18 ++ drivers/media/platform/xilinx/xilinx-vip.h | 11 ++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index d306f44..51b7ef6 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -27,22 +27,24 @@ */ static const struct xvip_video_format xvip_video_formats[] = { + { XVIP_VF_YUV_420, 10, NULL, MEDIA_BUS_FMT_VYYUYY8_1X24, + 1, 15, V4L2_PIX_FMT_XV15M, 2, 2, 1, 2, "4:2:0, 10-bit 2-plane non-cont" }, { XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16, - 2, V4L2_PIX_FMT_YUYV, "4:2:2, packed, YUYV" }, + 2, 16, V4L2_PIX_FMT_YUYV, 1, 1, 2, 1, "4:2:2, packed, YUYV" }, { XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24, - 3, V4L2_PIX_FMT_YUV444, "4:4:4, packed, YUYV" }, + 3, 24, V4L2_PIX_FMT_VUY24, 1, 1, 1, 1, "4:4:4, packed, YUYV" }, { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, - 3, V4L2_PIX_FMT_RGB24, "24-bit RGB" }, + 3, 24, V4L2_PIX_FMT_RGB24, 1, 1, 1, 1, "24-bit RGB" }, { XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8, - 1, V4L2_PIX_FMT_GREY, "Greyscale 8-bit" }, + 1, 8, V4L2_PIX_FMT_GREY, 1, 1, 1, 1, "Greyscale 8-bit" }, { XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8, - 1, V4L2_PIX_FMT_SGRBG8, "Bayer 8-bit RGGB" }, + 1, 8, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, "Bayer 8-bit RGGB" }, { XVIP_VF_MONO_SENSOR, 8, "grbg", MEDIA_BUS_FMT_SGRBG8_1X8, - 1, V4L2_PIX_FMT_SGRBG8, "Bayer 8-bit GRBG" }, + 1, 8, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, "Bayer 8-bit GRBG" }, { XVIP_VF_MONO_SENSOR, 8, "gbrg", MEDIA_BUS_FMT_SGBRG8_1X8, - 1, V4L2_PIX_FMT_SGBRG8, "Bayer 8-bit GBRG" }, + 1, 8, V4L2_PIX_FMT_SGBRG8, 1, 1, 1, 1, "Bayer 8-bit GBRG" }, { XVIP_VF_MONO_SENSOR, 8, "bggr", MEDIA_BUS_FMT_SBGGR8_1X8, - 1, V4L2_PIX_FMT_SBGGR8, "Bayer 8-bit BGGR" }, + 1, 8, V4L2_PIX_FMT_SBGGR8, 1, 1, 1, 1, "Bayer 8-bit BGGR" }, }; /** diff --git a/drivers/media/platform/xilinx/xilinx-vip.h b/drivers/media/platform/xilinx/xilinx-vip.h index 42fee20..006dcf77 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.h +++ b/drivers/media/platform/xilinx/xilinx-vip.h @@ -109,8 +109,12 @@ struct xvip_device { * @width: AXI4 format width in bits per component * @pattern: CFA pattern for Mono/Sensor formats * @code: media bus format code - * @bpp: bytes per pixel (when stored in memory) + * @bpl_factor: Bytes per line factor * @fourcc: V4L2 pixel format FCC identifier + * @num_planes: number of planes w.r.t. color format + * @buffers: number of buffers per format + * @hsub: Horizontal sampling factor of Chroma + * @vsub: Vertical sampling factor of Chroma * @description: format description, suitable for userspace */ struct xvip_video_format { @@ -118,8 +122,13 @@ struct xvip_video_format { unsigned int width; const char *pattern; unsigned int code; + unsigned int bpl_factor; unsigned int bpp; u32 fourcc; + u8 num_planes; + u8 buffers; + u8 hsub; + u8 vsub; const char *description; }; -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v3 5/9] [media] Add documentation for YUV420 bus format
The code is MEDIA_BUS_FMT_VYYUYY8_1X24 Signed-off-by: Satish Kumar Nagireddy --- Documentation/media/uapi/v4l/subdev-formats.rst | 34 + 1 file changed, 34 insertions(+) diff --git a/Documentation/media/uapi/v4l/subdev-formats.rst b/Documentation/media/uapi/v4l/subdev-formats.rst index b1eea44..afff6d5 100644 --- a/Documentation/media/uapi/v4l/subdev-formats.rst +++ b/Documentation/media/uapi/v4l/subdev-formats.rst @@ -7283,6 +7283,40 @@ The following table list existing packed 48bit wide YUV formats. - y\ :sub:`1` - y\ :sub:`0` + - MEDIA_BUS_FMT_VYYUYY8_1X24 + - 0x202c + - + - + - + - + - + - + - + - + - v\ :sub:`3` + - v\ :sub:`2` + - v\ :sub:`1` + - v\ :sub:`0` + - y\ :sub:`7` + - y\ :sub:`6` + - y\ :sub:`5` + - y\ :sub:`4` + - y\ :sub:`3` + - y\ :sub:`2` + - y\ :sub:`1` + - y\ :sub:`0` + - u\ :sub:`3` + - u\ :sub:`2` + - u\ :sub:`1` + - u\ :sub:`0` + - y\ :sub:`7` + - y\ :sub:`6` + - y\ :sub:`5` + - y\ :sub:`4` + - y\ :sub:`3` + - y\ :sub:`2` + - y\ :sub:`1` + - y\ :sub:`0` .. raw:: latex -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v3 1/9] v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format
From: Radhey Shyam Pandey In current implementation driver only checks the colorspace between the last subdev in the pipeline and the connected video node, the pipeline could be configured with wrong colorspace information until the very end. It thus makes little sense to check the colorspace only at the video node. So check can be dropped until we find a better solution to carry colorspace information through pipelines and to userspace. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 522cdfd..cb20ada 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -75,8 +75,7 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) if (dma->fmtinfo->code != fmt.format.code || dma->format.height != fmt.format.height || - dma->format.width != fmt.format.width || - dma->format.colorspace != fmt.format.colorspace) + dma->format.width != fmt.format.width) return -EINVAL; return 0; -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v3 3/9] uapi: media: New fourcc codes needed by Xilinx Video IP
From: Jeffrey Mouroux The Xilinx Video Framebuffer DMA IP supports video memory formats that are not represented in the current V4L2 fourcc library. This patch adds those missing fourcc codes. This includes both new 8-bit and 10-bit pixel formats. Signed-off-by: Satish Kumar Nagireddy --- include/uapi/linux/videodev2.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 9827189..9fa4313c 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -509,7 +509,10 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_XBGR32 v4l2_fourcc('X', 'R', '2', '4') /* 32 BGRX-8-8-8-8 */ #define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */ #define V4L2_PIX_FMT_ARGB32 v4l2_fourcc('B', 'A', '2', '4') /* 32 ARGB-8-8-8-8 */ +#define V4L2_PIX_FMT_BGRA32 v4l2_fourcc('A', 'B', 'G', 'R') /* 32 ABGR-8-8-8-8 */ #define V4L2_PIX_FMT_XRGB32 v4l2_fourcc('B', 'X', '2', '4') /* 32 XRGB-8-8-8-8 */ +#define V4L2_PIX_FMT_BGRX32 v4l2_fourcc('X', 'B', 'G', 'R') /* 32 XBGR-8-8-8-8 */ +#define V4L2_PIX_FMT_XBGR30 v4l2_fourcc('R', 'X', '3', '0') /* 32 XBGR-2-10-10-10 */ /* Grey formats */ #define V4L2_PIX_FMT_GREYv4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ @@ -537,12 +540,16 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_VYUYv4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */ #define V4L2_PIX_FMT_Y41Pv4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */ #define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 */ +#define V4L2_PIX_FMT_XVUY32 v4l2_fourcc('X', 'V', '3', '2') /* 32 XVUY 8:8:8:8 */ +#define V4L2_PIX_FMT_AVUY32 v4l2_fourcc('A', 'V', '3', '2') /* 32 AVUY 8:8:8:8 */ +#define V4L2_PIX_FMT_VUY24 v4l2_fourcc('V', 'U', '2', '4') /* 24 VUY 8:8:8 */ #define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */ #define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */ #define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */ #define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */ #define V4L2_PIX_FMT_HM12v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */ #define V4L2_PIX_FMT_M420v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */ +#define V4L2_PIX_FMT_XVUY10 v4l2_fourcc('X', 'Y', '1', '0') /* 32 XVUY 2-10-10-10 */ /* two planes -- one Y, one Cr + Cb interleaved */ #define V4L2_PIX_FMT_NV12v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */ @@ -551,6 +558,8 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_NV61v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */ #define V4L2_PIX_FMT_NV24v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */ #define V4L2_PIX_FMT_NV42v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */ +#define V4L2_PIX_FMT_XV20v4l2_fourcc('X', 'V', '2', '0') /* 32 XY/UV 4:2:2 10-bit */ +#define V4L2_PIX_FMT_XV15v4l2_fourcc('X', 'V', '1', '5') /* 32 XY/UV 4:2:0 10-bit */ /* two non contiguous planes - one Y, one Cr + Cb interleaved */ #define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */ @@ -558,6 +567,8 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_NV16M v4l2_fourcc('N', 'M', '1', '6') /* 16 Y/CbCr 4:2:2 */ #define V4L2_PIX_FMT_NV61M v4l2_fourcc('N', 'M', '6', '1') /* 16 Y/CrCb 4:2:2 */ #define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */ +#define V4L2_PIX_FMT_XV20M v4l2_fourcc('X', 'M', '2', '0') /* 32 XY/UV 4:2:2 10-bit */ +#define V4L2_PIX_FMT_XV15M v4l2_fourcc('X', 'M', '1', '5') /* 32 XY/UV 4:2:0 10-bit */ #define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 macroblocks */ /* three planes - Y Cb, Cr */ -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
[PATCH v3 9/9] v4l: xilinx: dma: Get scaling and padding factor to calculate DMA params
Get multiplying factor to calculate bpp especially in case of 10 bit formats. Get multiplying factor to calculate padding width Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 29 ++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 664981b..3c2fd02 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -417,6 +417,7 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) struct xvip_dma_buffer *buf = to_xvip_dma_buffer(vbuf); struct dma_async_tx_descriptor *desc; u32 flags, luma_size; + u32 padding_factor_nume, padding_factor_deno, bpl_nume, bpl_deno; dma_addr_t addr = vb2_dma_contig_plane_dma_addr(vb, 0); if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE || @@ -442,8 +443,15 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) struct v4l2_pix_format_mplane *pix_mp; pix_mp = &dma->format.fmt.pix_mp; + xvip_width_padding_factor(pix_mp->pixelformat, + &padding_factor_nume, + &padding_factor_deno); + xvip_bpl_scaling_factor(pix_mp->pixelformat, &bpl_nume, + &bpl_deno); dma->xt.frame_size = dma->fmtinfo->num_planes; - dma->sgl[0].size = pix_mp->width * dma->fmtinfo->bpl_factor; + dma->sgl[0].size = (pix_mp->width * dma->fmtinfo->bpl_factor * + padding_factor_nume * bpl_nume) / + (padding_factor_deno * bpl_deno); dma->sgl[0].icg = pix_mp->plane_fmt[0].bytesperline - dma->sgl[0].size; dma->xt.numf = pix_mp->height; @@ -472,8 +480,15 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) struct v4l2_pix_format *pix; pix = &dma->format.fmt.pix; + xvip_width_padding_factor(pix->pixelformat, + &padding_factor_nume, + &padding_factor_deno); + xvip_bpl_scaling_factor(pix->pixelformat, &bpl_nume, + &bpl_deno); dma->xt.frame_size = dma->fmtinfo->num_planes; - dma->sgl[0].size = pix->width * dma->fmtinfo->bpl_factor; + dma->sgl[0].size = (pix->width * dma->fmtinfo->bpl_factor * + padding_factor_nume * bpl_nume) / + (padding_factor_deno * bpl_deno); dma->sgl[0].icg = pix->bytesperline - dma->sgl[0].size; dma->xt.numf = pix->height; dma->sgl[0].dst_icg = dma->sgl[0].size; @@ -682,6 +697,8 @@ __xvip_dma_try_format(struct xvip_dma *dma, unsigned int align; unsigned int bpl; unsigned int i, hsub, vsub, plane_width, plane_height; + unsigned int padding_factor_nume, padding_factor_deno; + unsigned int bpl_nume, bpl_deno; /* Retrieve format information and select the default format if the * requested format isn't supported. @@ -694,6 +711,10 @@ __xvip_dma_try_format(struct xvip_dma *dma, if (IS_ERR(info)) info = xvip_get_format_by_fourcc(XVIP_DMA_DEF_FORMAT); + xvip_width_padding_factor(info->fourcc, &padding_factor_nume, + &padding_factor_deno); + xvip_bpl_scaling_factor(info->fourcc, &bpl_nume, &bpl_deno); + /* The transfer alignment requirements are expressed in bytes. Compute * the minimum and maximum values, clamp the requested width and convert * it back to pixels. @@ -737,7 +758,9 @@ __xvip_dma_try_format(struct xvip_dma *dma, for (i = 0; i < info->num_planes; i++) { plane_width = pix_mp->width / (i ? hsub : 1); plane_height = pix_mp->height / (i ? vsub : 1); - min_bpl = plane_width * info->bpl_factor; + min_bpl = (plane_width * info->bpl_factor * + padding_factor_nume * bpl_nume) / + (padding_factor_deno * bpl_deno); max_bpl = rounddown(XVIP_DMA_MAX_WIDTH, dma->align); bpl = pix_mp->plane_fmt[i].bytesperline; -- 2.7.4 This e
RE: [PATCH v3 7/9] v4l: xilinx: dma: Add multi-planar support
Hi Hyun, Thanks a lot for the comments. I will fix them in v4 patch-set. Regards, Satish > -Original Message- > From: Hyun Kwon [mailto:hyun.k...@xilinx.com] > Sent: Friday, February 16, 2018 9:05 AM > To: Satish Kumar Nagireddy > Cc: linux-media@vger.kernel.org; laurent.pinch...@ideasonboard.com; > michal.si...@xilinx.com; Hyun Kwon ; Satish Kumar > Nagireddy > Subject: Re: [PATCH v3 7/9] v4l: xilinx: dma: Add multi-planar support > > Hi Satish, > > Thanks for the patch. > > On Wed, 2018-02-14 at 22:42:43 -0800, Satish Kumar Nagireddy wrote: > > The current v4l driver supports single plane formats. This patch will > > add support to handle multi-planar formats. Updated driver > > capabilities to multi-planar, where it can handle both single and > > multi-planar formats > > > > Signed-off-by: Satish Kumar Nagireddy > > --- > > drivers/media/platform/xilinx/xilinx-dma.c | 341 > +++- > > drivers/media/platform/xilinx/xilinx-dma.h | 2 +- > > drivers/media/platform/xilinx/xilinx-vipp.c | 22 +- > > 3 files changed, 307 insertions(+), 58 deletions(-) > > > > diff --git a/drivers/media/platform/xilinx/xilinx-dma.c > > b/drivers/media/platform/xilinx/xilinx-dma.c > > index cb20ada..664981b 100644 > > --- a/drivers/media/platform/xilinx/xilinx-dma.c > > +++ b/drivers/media/platform/xilinx/xilinx-dma.c > > @@ -63,6 +63,7 @@ static int xvip_dma_verify_format(struct xvip_dma > *dma) > > struct v4l2_subdev_format fmt; > > struct v4l2_subdev *subdev; > > int ret; > > + int width, height; > > > > subdev = xvip_dma_remote_subdev(&dma->pad, &fmt.pad); > > if (subdev == NULL) > > @@ -73,9 +74,18 @@ static int xvip_dma_verify_format(struct xvip_dma > *dma) > > if (ret < 0) > > return ret == -ENOIOCTLCMD ? -EINVAL : ret; > > > > - if (dma->fmtinfo->code != fmt.format.code || > > - dma->format.height != fmt.format.height || > > - dma->format.width != fmt.format.width) > > + if (dma->fmtinfo->code != fmt.format.code) > > + return -EINVAL; > > + > > + if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) { > > As discussed, let's plan to remove this check. :-) I think now it's safe to > assume there's no backward compatibility issue. > > > + width = dma->format.fmt.pix_mp.width; > > + height = dma->format.fmt.pix_mp.height; > > + } else { > > + width = dma->format.fmt.pix.width; > > + height = dma->format.fmt.pix.height; > > + } > > + > > + if (width != fmt.format.width || height != fmt.format.height) > > return -EINVAL; > > > > return 0; > > @@ -302,6 +312,8 @@ static void xvip_dma_complete(void *param) { > > struct xvip_dma_buffer *buf = param; > > struct xvip_dma *dma = buf->dma; > > + u8 num_planes, i; > > + int sizeimage; > > > > spin_lock(&dma->queued_lock); > > list_del(&buf->queue); > > @@ -310,7 +322,28 @@ static void xvip_dma_complete(void *param) > > buf->buf.field = V4L2_FIELD_NONE; > > buf->buf.sequence = dma->sequence++; > > buf->buf.vb2_buf.timestamp = ktime_get_ns(); > > - vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma- > >format.sizeimage); > > + > > + if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) { > > + /* Handling contiguous data with mplanes */ > > + if (dma->fmtinfo->buffers == 1) { > > + sizeimage = > > + dma- > >format.fmt.pix_mp.plane_fmt[0].sizeimage; > > + vb2_set_plane_payload(&buf->buf.vb2_buf, 0, > sizeimage); > > + } else { > > + /* Handling non-contiguous data with mplanes */ > > + num_planes = dma- > >format.fmt.pix_mp.num_planes; > > + for (i = 0; i < num_planes; i++) { > > + sizeimage = > > +dma- > >format.fmt.pix_mp.plane_fmt[i].sizeimage; > > + vb2_set_plane_payload(&buf->buf.vb2_buf, > i, > > + sizeimage); > > + } > > + } > > Can this be done in a single loop with number of buffers? > > > + } else { > > + sizeimage = dma->format.fmt.pix.sizeimage; > > + vb2_set
[PATCH v4 08/10] v4l: xilinx: dma: Update video format descriptor
This patch updates video format descriptor to help information viz., number of planes per color format and chroma sub sampling factors. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 12 ++-- drivers/media/platform/xilinx/xilinx-vip.c | 28 +++- drivers/media/platform/xilinx/xilinx-vip.h | 8 +++- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 16aeb46..658586e 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -366,7 +366,7 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) } dma->xt.frame_size = 1; - dma->sgl[0].size = dma->format.width * dma->fmtinfo->bpp; + dma->sgl[0].size = dma->format.width * dma->fmtinfo->bpp[0]; dma->sgl[0].icg = dma->format.bytesperline - dma->sgl[0].size; dma->xt.numf = dma->format.height; @@ -569,12 +569,12 @@ __xvip_dma_try_format(struct xvip_dma *dma, struct v4l2_pix_format *pix, * the minimum and maximum values, clamp the requested width and convert * it back to pixels. */ - align = lcm(dma->align, info->bpp); + align = lcm(dma->align, info->bpp[0]); min_width = roundup(XVIP_DMA_MIN_WIDTH, align); max_width = rounddown(XVIP_DMA_MAX_WIDTH, align); - width = rounddown(pix->width * info->bpp, align); + width = rounddown(pix->width * info->bpp[0], align); - pix->width = clamp(width, min_width, max_width) / info->bpp; + pix->width = clamp(width, min_width, max_width) / info->bpp[0]; pix->height = clamp(pix->height, XVIP_DMA_MIN_HEIGHT, XVIP_DMA_MAX_HEIGHT); @@ -582,7 +582,7 @@ __xvip_dma_try_format(struct xvip_dma *dma, struct v4l2_pix_format *pix, * line value is zero, the module doesn't support user configurable line * sizes. Override the requested value with the minimum in that case. */ - min_bpl = pix->width * info->bpp; + min_bpl = pix->width * info->bpp[0]; max_bpl = rounddown(XVIP_DMA_MAX_WIDTH, dma->align); bpl = rounddown(pix->bytesperline, dma->align); @@ -676,7 +676,7 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma, dma->format.field = V4L2_FIELD_NONE; dma->format.width = XVIP_DMA_DEF_WIDTH; dma->format.height = XVIP_DMA_DEF_HEIGHT; - dma->format.bytesperline = dma->format.width * dma->fmtinfo->bpp; + dma->format.bytesperline = dma->format.width * dma->fmtinfo->bpp[0]; dma->format.sizeimage = dma->format.bytesperline * dma->format.height; /* Initialize the media entity... */ diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index 3112591..81cc0d2 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -27,22 +27,32 @@ */ static const struct xvip_video_format xvip_video_formats[] = { + { XVIP_VF_YUV_420, 8, NULL, MEDIA_BUS_FMT_VYYUYY8_1X24, + {1, 2, 0}, V4L2_PIX_FMT_NV12, 2, 2, 2, "4:2:0, semi-planar, YUV" }, + { XVIP_VF_YUV_420, 10, NULL, MEDIA_BUS_FMT_VYYUYY8_1X24, + {1, 2, 0}, V4L2_PIX_FMT_XV15, 2, 2, 2, "4:2:0, 10-bit 2-plane cont" }, { XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16, - 2, V4L2_PIX_FMT_YUYV, "4:2:2, packed, YUYV" }, - { XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24, - 3, V4L2_PIX_FMT_YUV444, "4:4:4, packed, YUYV" }, + {2, 0, 0}, V4L2_PIX_FMT_YUYV, 1, 2, 1, "4:2:2, packed, YUYV" }, + { XVIP_VF_VUY_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16, + {2, 0, 0}, V4L2_PIX_FMT_UYVY, 1, 2, 1, "4:2:2, packed, UYVY" }, + { XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16, + {1, 2, 0}, V4L2_PIX_FMT_NV16, 2, 2, 1, "4:2:2, semi-planar, YUV" }, + { XVIP_VF_YUV_422, 10, NULL, MEDIA_BUS_FMT_UYVY8_1X16, + {1, 2, 0}, V4L2_PIX_FMT_XV20, 2, 2, 1, "4:2:2, 10-bit 2-plane cont" }, + { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, + {3, 0, 0}, V4L2_PIX_FMT_BGR24, 1, 1, 1, "24-bit RGB" }, { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, - 3, 0, NULL }, + {3, 0, 0}, V4L2_PIX_FMT_RGB24, 1, 1, 1, "24-bit RGB" }, { XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8, - 1, V4L2_PIX_FMT_GREY, "Greyscale 8-bit" }, + {1, 0, 0}, V4L2_PIX_FMT_GREY, 1, 1, 1, "Greyscale 8-bit" }, { XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8, -
[PATCH v4 04/10] Documentation: uapi: media: v4l: New pixel format
From: Jeffrey Mouroux These descriptions are for YUV 420 and YUV 422 10 bit formats. Signed-off-by: Jeffrey Mouroux Signed-off-by: Satish Kumar Nagireddy --- Documentation/media/uapi/v4l/pixfmt-xv15.rst | 135 ++ Documentation/media/uapi/v4l/pixfmt-xv20.rst | 136 +++ Documentation/media/uapi/v4l/yuv-formats.rst | 2 + 3 files changed, 273 insertions(+) create mode 100644 Documentation/media/uapi/v4l/pixfmt-xv15.rst create mode 100644 Documentation/media/uapi/v4l/pixfmt-xv20.rst diff --git a/Documentation/media/uapi/v4l/pixfmt-xv15.rst b/Documentation/media/uapi/v4l/pixfmt-xv15.rst new file mode 100644 index 000..313d056 --- /dev/null +++ b/Documentation/media/uapi/v4l/pixfmt-xv15.rst @@ -0,0 +1,135 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _V4L2-PIX-FMT-XV15: +.. _V4L2-PIX-FMT-XV15M: + +*** +V4L2_PIX_FMT_XV15 ('XV15'), V4L2_PIX_FMT_XV15 ('XV15M') +*** + +Semi-planar YUV 420 10-bit + + +Description +=== + +This is the 10-bit version of YUV 420 semi-planar format. +XV15M differs from XV15 insofar as the chroma plane is not contiguous with the +luma plane in memory. + +Each pixel of YUV 420 contains a single luma component of 10-bits in length. +Three luma components are stored per word with the remaining two bits serving +as padding. + +The chroma plane is subsampled and is only 1/2 the size of the luma plane. A +single chroma component serves two pixels on a given row and is re-used on the +adjacent row of luma data. + +**Data Layout of Luma Plane** +Each cell is one 32-bit word. + +.. flat-table:: +:header-rows: 0 +:stub-columns: 0 + +* - word + 0: + - X'\ :sub:`[31:30]` + - Y'\ :sub:`02 [29:20]` + - Y'\ :sub:`01 [19:10]` + - Y'\ :sub:`00 [09:00]` + - +* - word + 1: + - X'\ :sub:`[31:30]` + - Y'\ :sub:`05 [29:20]` + - Y'\ :sub:`04 [19:10]` + - Y'\ :sub:`03 [09:00]` + - +* - word + 2: + - X'\ :sub:`[31:30]` + - Y'\ :sub:`08 [29:20]` + - Y'\ :sub:`07 [19:10]` + - Y'\ :sub:`06 [09:00]` + - + + +**Data Layout of Chroma Plane** + +.. flat-table:: +:header-rows: 0 +:stub-columns: 0 + +* - word + 0: + - X'\ :sub:`[31:30]` + - U'\ :sub:`02 [29:20]` + - V'\ :sub:`01 [19:10]` + - U'\ :sub:`00 [09:00]` + - +* - word + 1: + - X'\ :sub:`[31:30]` + - V'\ :sub:`05 [29:20]` + - U'\ :sub:`04 [19:10]` + - V'\ :sub:`03 [09:00]` + - +* - word + 2: + - X'\ :sub:`[31:30]` + - U'\ :sub:`08 [29:20]` + - V'\ :sub:`07 [19:10]` + - U'\ :sub:`06 [09:00]` + - + +**Color Sample Location** + +.. flat-table:: +:header-rows: 0 +:stub-columns: 0 + +* - + - 0 + - + - 1 + - 2 + - + - 3 +* - 0 + - Y + - + - Y + - Y + - + - Y +* - + - + - C + - + - + - C + - +* - 1 + - Y + - + - Y + - Y + - + - Y +* - +* - 2 + - Y + - + - Y + - Y + - + - Y +* - + - + - C + - + - + - C + - +* - 3 + - Y + - + - Y + - Y + - + - Y diff --git a/Documentation/media/uapi/v4l/pixfmt-xv20.rst b/Documentation/media/uapi/v4l/pixfmt-xv20.rst new file mode 100644 index 000..fe9dac2 --- /dev/null +++ b/Documentation/media/uapi/v4l/pixfmt-xv20.rst @@ -0,0 +1,136 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _V4L2-PIX-FMT-XV20: +.. _V4L2-PIX-FMT-XV20M: + +*** +V4L2_PIX_FMT_XV20 ('XV20'), V4L2_PIX_FMT_XV20 ('XV20M') +*** + +Semi-planar YUV422 10-bit + + +Description +=== + +This is the 10-bit version of YUV 422 semi-planar format. +XV20M differs from XV20 insofar as the chroma plane is not contiquous with the +luma plane in memory. + + +Each pixel of YUV 422 contains a single luma component of 10-bits in length. +Three luma components are stored per word with the remaining two bits serving +as padding. + +The chroma plane is subsampled in and is the size of the luma plane. A single +chroma component (U or V) serves two pixels on a given row. + +**Data Layout of Luma Plane** +Each cell is one 32-bit word. + +.. flat-table:: +:header-rows: 0 +:stub-columns: 0 + +* - word + 0: + - X'\ :sub:`[31:30]` + - Y'\ :sub:`02 [29:20]` + - Y'\ :sub:`01 [19:10]` + - Y'\ :sub:`00 [09:00]` + - +* - word + 1: + - X'\ :sub:`[31:30]` + - Y'\ :sub:`05 [29:20]` + - Y'\ :sub:`04 [19:10]` + - Y'\ :sub:`03 [
[PATCH v4 01/10] v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format
From: Radhey Shyam Pandey In current implementation driver only checks the colorspace between the last subdev in the pipeline and the connected video node, the pipeline could be configured with wrong colorspace information until the very end. It thus makes little sense to check the colorspace only at the video node. So check can be dropped until we find a better solution to carry colorspace information through pipelines and to userspace. Signed-off-by: Radhey Shyam Pandey Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 522cdfd..cb20ada 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -75,8 +75,7 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) if (dma->fmtinfo->code != fmt.format.code || dma->format.height != fmt.format.height || - dma->format.width != fmt.format.width || - dma->format.colorspace != fmt.format.colorspace) + dma->format.width != fmt.format.width) return -EINVAL; return 0; -- 2.1.1
[PATCH v4 02/10] xilinx: v4l: dma: Use the dmaengine_terminate_all() wrapper
From: Laurent Pinchart Calling dmaengine_device_control() to terminate transfers is an internal API that will disappear, use the stable API wrapper instead. Signed-off-by: Laurent Pinchart Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index cb20ada..a5bf345 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -434,6 +434,7 @@ static int xvip_dma_start_streaming(struct vb2_queue *vq, unsigned int count) return 0; error_stop: + dmaengine_terminate_all(dma->dma); media_pipeline_stop(&dma->video.entity); error: -- 2.1.1
[PATCH v4 00/10] Add support for multi-planar formats and 10 bit formats
The patches are for xilinx v4l. The patcheset enable support to handle multiplanar formats and 10 bit formats. The implemenation has handling of single plane formats too for backward compatibility of some existing applications. Changes in v4 (Thanks to Sakari Ailus, Hyun Kwon and Ian Arkver): - rst documentation is moved to 24 bit yuv formats group - Single plane implementation is removed as multi-plane supports both - num_buffers and bpl_factor parameters are removed to have clean implementation - macropixel concept is used to calculate number of bytes in a row for 10 bit formats - Video format descriptor table updated with 10 bit format information Changes in v3: - Fixed table alignment issue in rst file. Ensured the output is proper uisng 'make pdfdocs' Changes in v2: - Added rst documentation for MEDIA_BUS_FMT_VYYUYY8_1X24 Jeffrey Mouroux (2): Documentation: uapi: media: v4l: New pixel format uapi: media: New fourcc codes needed by Xilinx Video IP Laurent Pinchart (1): xilinx: v4l: dma: Use the dmaengine_terminate_all() wrapper Radhey Shyam Pandey (1): v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format Rohit Athavale (2): xilinx: v4l: dma: Update driver to allow for probe defer media: Add new dt-bindings/vf_codes for supported formats Satish Kumar Nagireddy (4): media-bus: uapi: Add YCrCb 420 media bus format v4l: xilinx: dma: Update video format descriptor v4l: xilinx: dma: Add multi-planar support v4l: xilinx: dma: Add support for 10 bit formats Documentation/media/uapi/v4l/pixfmt-xv15.rst| 135 ++ Documentation/media/uapi/v4l/pixfmt-xv20.rst| 136 ++ Documentation/media/uapi/v4l/subdev-formats.rst | 38 - Documentation/media/uapi/v4l/yuv-formats.rst| 2 + drivers/media/platform/xilinx/xilinx-dma.c | 177 +++- drivers/media/platform/xilinx/xilinx-dma.h | 4 +- drivers/media/platform/xilinx/xilinx-vip.c | 45 -- drivers/media/platform/xilinx/xilinx-vip.h | 13 +- drivers/media/platform/xilinx/xilinx-vipp.c | 16 +-- include/dt-bindings/media/xilinx-vip.h | 2 + include/uapi/linux/media-bus-format.h | 3 +- include/uapi/linux/videodev2.h | 4 + 12 files changed, 488 insertions(+), 87 deletions(-) create mode 100644 Documentation/media/uapi/v4l/pixfmt-xv15.rst create mode 100644 Documentation/media/uapi/v4l/pixfmt-xv20.rst -- 2.1.1
[PATCH v4 03/10] xilinx: v4l: dma: Update driver to allow for probe defer
From: Rohit Athavale Update xvip_dma_init() to use dma_request_chan(), enabling probe deferral. Also update the cleanup routine to prevent dereferencing an ERR_PTR(). Signed-off-by: Rohit Athavale Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index a5bf345..16aeb46 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -730,10 +730,13 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma, /* ... and the DMA channel. */ snprintf(name, sizeof(name), "port%u", port); - dma->dma = dma_request_slave_channel(dma->xdev->dev, name); - if (dma->dma == NULL) { - dev_err(dma->xdev->dev, "no VDMA channel found\n"); - ret = -ENODEV; + dma->dma = dma_request_chan(dma->xdev->dev, name); + if (IS_ERR(dma->dma)) { + ret = PTR_ERR(dma->dma); + if (ret != -EPROBE_DEFER) + dev_err(dma->xdev->dev, + "No Video DMA channel found"); + goto error; } @@ -757,7 +760,7 @@ void xvip_dma_cleanup(struct xvip_dma *dma) if (video_is_registered(&dma->video)) video_unregister_device(&dma->video); - if (dma->dma) + if (!IS_ERR(dma->dma)) dma_release_channel(dma->dma); media_entity_cleanup(&dma->video.entity); -- 2.1.1
[PATCH v4 05/10] uapi: media: New fourcc codes needed by Xilinx Video IP
From: Jeffrey Mouroux The Xilinx Video Framebuffer DMA IP supports video memory formats that are not represented in the current V4L2 fourcc library. This patch adds those missing fourcc codes. This includes both new 8-bit and 10-bit pixel formats. Signed-off-by: Jeffrey Mouroux Signed-off-by: Satish Kumar Nagireddy --- include/uapi/linux/videodev2.h | 4 1 file changed, 4 insertions(+) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 600877b..97b6633 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -510,6 +510,7 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */ #define V4L2_PIX_FMT_ARGB32 v4l2_fourcc('B', 'A', '2', '4') /* 32 ARGB-8-8-8-8 */ #define V4L2_PIX_FMT_XRGB32 v4l2_fourcc('B', 'X', '2', '4') /* 32 XRGB-8-8-8-8 */ +#define V4L2_PIX_FMT_BGRX32 v4l2_fourcc('X', 'B', 'G', 'R') /* 32 XBGR-8-8-8-8 */ /* Grey formats */ #define V4L2_PIX_FMT_GREYv4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ @@ -537,6 +538,7 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_VYUYv4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */ #define V4L2_PIX_FMT_Y41Pv4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */ #define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 */ +#define V4L2_PIX_FMT_VUY24 v4l2_fourcc('V', 'U', '2', '4') /* 24 VUY 8:8:8 */ #define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */ #define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */ #define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */ @@ -551,6 +553,8 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_NV61v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */ #define V4L2_PIX_FMT_NV24v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */ #define V4L2_PIX_FMT_NV42v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */ +#define V4L2_PIX_FMT_XV20v4l2_fourcc('X', 'V', '2', '0') /* 32 XY/UV 4:2:2 10-bit */ +#define V4L2_PIX_FMT_XV15v4l2_fourcc('X', 'V', '1', '5') /* 32 XY/UV 4:2:0 10-bit */ /* two non contiguous planes - one Y, one Cr + Cb interleaved */ #define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */ -- 2.1.1
[PATCH v4 10/10] v4l: xilinx: dma: Add support for 10 bit formats
This patch adds xvip_format_plane_width_bytes function to calculate number of bytes for a macropixel formats and also adds new 10 bit pixel formats to video descriptor table. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 5 ++-- drivers/media/platform/xilinx/xilinx-vip.c | 43 +- drivers/media/platform/xilinx/xilinx-vip.h | 5 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index a714057..b33e4b9 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -370,7 +370,8 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) } dma->xt.frame_size = dma->fmtinfo->num_planes; - dma->sgl[0].size = pix_mp->width * dma->fmtinfo->bpp[0]; + dma->sgl[0].size = xvip_fmt_plane_width_bytes(dma->fmtinfo, + pix_mp->width); dma->sgl[0].icg = pix_mp->plane_fmt[0].bytesperline - dma->sgl[0].size; dma->xt.numf = pix_mp->height; dma->sgl[0].dst_icg = 0; @@ -596,7 +597,7 @@ __xvip_dma_try_format(struct xvip_dma *dma, * with the minimum in that case. */ max_bpl = rounddown(XVIP_DMA_MAX_WIDTH, align); - min_bpl = pix_mp->width * info->bpp[0]; + min_bpl = xvip_fmt_plane_width_bytes(info, pix_mp->width); min_bpl = roundup(min_bpl, align); bpl = roundup(plane_fmt[0].bytesperline, align); plane_fmt[0].bytesperline = clamp(bpl, min_bpl, max_bpl); diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index 81cc0d2..1825f5d 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -28,31 +28,31 @@ static const struct xvip_video_format xvip_video_formats[] = { { XVIP_VF_YUV_420, 8, NULL, MEDIA_BUS_FMT_VYYUYY8_1X24, - {1, 2, 0}, V4L2_PIX_FMT_NV12, 2, 2, 2, "4:2:0, semi-planar, YUV" }, + {1, 2, 0}, V4L2_PIX_FMT_NV12, 2, 2, 2, 1, 1, "4:2:0, semi-planar, YUV" }, { XVIP_VF_YUV_420, 10, NULL, MEDIA_BUS_FMT_VYYUYY8_1X24, - {1, 2, 0}, V4L2_PIX_FMT_XV15, 2, 2, 2, "4:2:0, 10-bit 2-plane cont" }, + {1, 2, 0}, V4L2_PIX_FMT_XV15, 2, 2, 2, 4, 3, "4:2:0, 10-bit 2-plane cont" }, { XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16, - {2, 0, 0}, V4L2_PIX_FMT_YUYV, 1, 2, 1, "4:2:2, packed, YUYV" }, + {2, 0, 0}, V4L2_PIX_FMT_YUYV, 1, 2, 1, 1, 1, "4:2:2, packed, YUYV" }, { XVIP_VF_VUY_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16, - {2, 0, 0}, V4L2_PIX_FMT_UYVY, 1, 2, 1, "4:2:2, packed, UYVY" }, + {2, 0, 0}, V4L2_PIX_FMT_UYVY, 1, 2, 1, 1, 1, "4:2:2, packed, UYVY" }, { XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16, - {1, 2, 0}, V4L2_PIX_FMT_NV16, 2, 2, 1, "4:2:2, semi-planar, YUV" }, + {1, 2, 0}, V4L2_PIX_FMT_NV16, 2, 2, 1, 1, 1, "4:2:2, semi-planar, YUV" }, { XVIP_VF_YUV_422, 10, NULL, MEDIA_BUS_FMT_UYVY8_1X16, - {1, 2, 0}, V4L2_PIX_FMT_XV20, 2, 2, 1, "4:2:2, 10-bit 2-plane cont" }, + {1, 2, 0}, V4L2_PIX_FMT_XV20, 2, 2, 1, 4, 3, "4:2:2, 10-bit 2-plane cont" }, { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, - {3, 0, 0}, V4L2_PIX_FMT_BGR24, 1, 1, 1, "24-bit RGB" }, + {3, 0, 0}, V4L2_PIX_FMT_BGR24, 1, 1, 1, 1, 1, "24-bit RGB" }, { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, - {3, 0, 0}, V4L2_PIX_FMT_RGB24, 1, 1, 1, "24-bit RGB" }, + {3, 0, 0}, V4L2_PIX_FMT_RGB24, 1, 1, 1, 1, 1, "24-bit RGB" }, { XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8, - {1, 0, 0}, V4L2_PIX_FMT_GREY, 1, 1, 1, "Greyscale 8-bit" }, + {1, 0, 0}, V4L2_PIX_FMT_GREY, 1, 1, 1, 1, 1, "Greyscale 8-bit" }, { XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8, - {1, 0, 0}, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, "Bayer 8-bit RGGB" }, + {1, 0, 0}, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, 1, "Bayer 8-bit RGGB" }, { XVIP_VF_MONO_SENSOR, 8, "grbg", MEDIA_BUS_FMT_SGRBG8_1X8, - {1, 0, 0}, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, "Bayer 8-bit GRBG" }, + {1, 0, 0}, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, 1, "Bayer 8-bit GRBG" }, { XVIP_VF_MONO_SENSOR, 8, "gbrg", MEDIA_BUS_FMT_SGBRG8_1X8, - {1, 0, 0}, V4L2_PIX_FMT_SGBRG8, 1, 1, 1, "Bayer 8-bit GBRG" }, + {1, 0, 0}, V4L2_PIX_FMT_SGBRG8, 1, 1, 1, 1, 1, "Bayer 8-bit GBRG" }, { XVIP_VF_MONO_SENSOR, 8, "bggr", MEDIA_BUS_FMT_SBGGR8_1X8, -
[PATCH v4 09/10] v4l: xilinx: dma: Add multi-planar support
The current v4l driver supports single plane formats. This patch adds support to handle multi-planar formats. Driver can handle both single and multi-planar formats. Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 159 ++-- drivers/media/platform/xilinx/xilinx-dma.h | 4 +- drivers/media/platform/xilinx/xilinx-vipp.c | 16 +-- 3 files changed, 111 insertions(+), 68 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 658586e..a714057 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -74,8 +74,8 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) return ret == -ENOIOCTLCMD ? -EINVAL : ret; if (dma->fmtinfo->code != fmt.format.code || - dma->format.height != fmt.format.height || - dma->format.width != fmt.format.width) + dma->format.fmt.pix_mp.width != fmt.format.width || + dma->format.fmt.pix_mp.height != fmt.format.height) return -EINVAL; return 0; @@ -310,7 +310,8 @@ static void xvip_dma_complete(void *param) buf->buf.field = V4L2_FIELD_NONE; buf->buf.sequence = dma->sequence++; buf->buf.vb2_buf.timestamp = ktime_get_ns(); - vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma->format.sizeimage); + vb2_set_plane_payload(&buf->buf.vb2_buf, 0, + dma->format.fmt.pix_mp.plane_fmt[0].sizeimage); vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); } @@ -320,13 +321,15 @@ xvip_dma_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct xvip_dma *dma = vb2_get_drv_priv(vq); + s32 sizeimage; /* Make sure the image size is large enough. */ + sizeimage = dma->format.fmt.pix_mp.plane_fmt[0].sizeimage; if (*nplanes) - return sizes[0] < dma->format.sizeimage ? -EINVAL : 0; + return sizes[0] < sizeimage ? -EINVAL : 0; *nplanes = 1; - sizes[0] = dma->format.sizeimage; + sizes[0] = sizeimage; return 0; } @@ -350,14 +353,15 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) struct dma_async_tx_descriptor *desc; dma_addr_t addr = vb2_dma_contig_plane_dma_addr(vb, 0); u32 flags; + struct v4l2_pix_format_mplane *pix_mp = &dma->format.fmt.pix_mp; - if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { + if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK; dma->xt.dir = DMA_DEV_TO_MEM; dma->xt.src_sgl = false; dma->xt.dst_sgl = true; dma->xt.dst_start = addr; - } else { + } else if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK; dma->xt.dir = DMA_MEM_TO_DEV; dma->xt.src_sgl = true; @@ -365,10 +369,11 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) dma->xt.src_start = addr; } - dma->xt.frame_size = 1; - dma->sgl[0].size = dma->format.width * dma->fmtinfo->bpp[0]; - dma->sgl[0].icg = dma->format.bytesperline - dma->sgl[0].size; - dma->xt.numf = dma->format.height; + dma->xt.frame_size = dma->fmtinfo->num_planes; + dma->sgl[0].size = pix_mp->width * dma->fmtinfo->bpp[0]; + dma->sgl[0].icg = pix_mp->plane_fmt[0].bytesperline - dma->sgl[0].size; + dma->xt.numf = pix_mp->height; + dma->sgl[0].dst_icg = 0; desc = dmaengine_prep_interleaved_dma(dma->dma, &dma->xt, flags); if (!desc) { @@ -497,10 +502,15 @@ xvip_dma_querycap(struct file *file, void *fh, struct v4l2_capability *cap) cap->capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING | dma->xdev->v4l2_caps; - if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) - cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; - else - cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; + cap->device_caps = V4L2_CAP_STREAMING; + switch (dma->queue.type) { + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: + cap->device_caps |= V4L2_CAP_VIDEO_CAPTURE_MPLANE; + break; + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + cap->device_caps |= V4L2_CAP_VIDEO_OUTPUT_MPLANE; + break; + } strlcpy(cap->driver, "xilinx-vipp", sizeof(cap->driver)); strlc
[PATCH v4 06/10] media-bus: uapi: Add YCrCb 420 media bus format
This commit adds YUV 420 media bus format. VYYUYY8_1X24 is an approximate way to descrive the pixels sent over the bus. This patch also contain rst documentation for media bus format. Signed-off-by: Satish Kumar Nagireddy --- Documentation/media/uapi/v4l/subdev-formats.rst | 38 - include/uapi/linux/media-bus-format.h | 3 +- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Documentation/media/uapi/v4l/subdev-formats.rst b/Documentation/media/uapi/v4l/subdev-formats.rst index 9fcabe7..904c52b 100644 --- a/Documentation/media/uapi/v4l/subdev-formats.rst +++ b/Documentation/media/uapi/v4l/subdev-formats.rst @@ -6640,6 +6640,43 @@ the following codes. - u\ :sub:`2` - u\ :sub:`1` - u\ :sub:`0` +* .. _MEDIA-BUS-FMT-VYYUYY8-1X24: + + - MEDIA_BUS_FMT_VYYUYY8_1X24 + - 0x202c + - + - + - + - + - + - + - + - + - + - v\ :sub:`3` + - v\ :sub:`2` + - v\ :sub:`1` + - v\ :sub:`0` + - y\ :sub:`7` + - y\ :sub:`6` + - y\ :sub:`5` + - y\ :sub:`4` + - y\ :sub:`3` + - y\ :sub:`2` + - y\ :sub:`1` + - y\ :sub:`0` + - u\ :sub:`3` + - u\ :sub:`2` + - u\ :sub:`1` + - u\ :sub:`0` + - y\ :sub:`7` + - y\ :sub:`6` + - y\ :sub:`5` + - y\ :sub:`4` + - y\ :sub:`3` + - y\ :sub:`2` + - y\ :sub:`1` + - y\ :sub:`0` * .. _MEDIA-BUS-FMT-YUV10-1X30: - MEDIA_BUS_FMT_YUV10_1X30 @@ -7287,7 +7324,6 @@ The following table list existing packed 48bit wide YUV formats. - y\ :sub:`1` - y\ :sub:`0` - .. raw:: latex \endgroup diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h index 9e35117..ade7e9d 100644 --- a/include/uapi/linux/media-bus-format.h +++ b/include/uapi/linux/media-bus-format.h @@ -62,7 +62,7 @@ #define MEDIA_BUS_FMT_RGB121212_1X36 0x1019 #define MEDIA_BUS_FMT_RGB161616_1X48 0x101a -/* YUV (including grey) - next is 0x202c */ +/* YUV (including grey) - next is 0x202d */ #define MEDIA_BUS_FMT_Y8_1X8 0x2001 #define MEDIA_BUS_FMT_UV8_1X8 0x2015 #define MEDIA_BUS_FMT_UYVY8_1_5X8 0x2002 @@ -106,6 +106,7 @@ #define MEDIA_BUS_FMT_YUV12_1X36 0x2029 #define MEDIA_BUS_FMT_YUV16_1X48 0x202a #define MEDIA_BUS_FMT_UYYVYY16_0_5X48 0x202b +#define MEDIA_BUS_FMT_VYYUYY8_1X24 0x202c /* Bayer - next is 0x3021 */ #define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001 -- 2.1.1
[PATCH v4 07/10] media: Add new dt-bindings/vf_codes for supported formats
From: Rohit Athavale This commit adds new entries to the exisiting vf_codes that are used to describe the media bus formats in the DT bindings. The newly added 8-bit and 10-bit color depth related formats will need these updates. Signed-off-by: Rohit Athavale Signed-off-by: Satish Kumar Nagireddy --- include/dt-bindings/media/xilinx-vip.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/dt-bindings/media/xilinx-vip.h b/include/dt-bindings/media/xilinx-vip.h index 6298fec..fcd34d7 100644 --- a/include/dt-bindings/media/xilinx-vip.h +++ b/include/dt-bindings/media/xilinx-vip.h @@ -35,5 +35,7 @@ #define XVIP_VF_CUSTOM213 #define XVIP_VF_CUSTOM314 #define XVIP_VF_CUSTOM415 +#define XVIP_VF_VUY_42216 +#define XVIP_VF_XBGR 17 #endif /* __DT_BINDINGS_MEDIA_XILINX_VIP_H__ */ -- 2.1.1
RE: [PATCH v4 09/10] v4l: xilinx: dma: Add multi-planar support
Hi Ian, Thanks for the review. > -Original Message- > From: Ian Arkver [mailto:ian.arkver@gmail.com] > Sent: Monday, April 30, 2018 11:44 PM > To: Satish Kumar Nagireddy ; linux- > me...@vger.kernel.org; laurent.pinch...@ideasonboard.com; > michal.si...@xilinx.com; Hyun Kwon > Subject: Re: [PATCH v4 09/10] v4l: xilinx: dma: Add multi-planar support > > Hi Satish, > > On 01/05/18 02:35, Satish Kumar Nagireddy wrote: > > The current v4l driver supports single plane formats. This patch adds > > support to handle multi-planar formats. Driver can handle both single > > and multi-planar formats. > > > > Signed-off-by: Satish Kumar Nagireddy > > > > --- > > drivers/media/platform/xilinx/xilinx-dma.c | 159 ++--- > --- > > drivers/media/platform/xilinx/xilinx-dma.h | 4 +- > > drivers/media/platform/xilinx/xilinx-vipp.c | 16 +-- > > 3 files changed, 111 insertions(+), 68 deletions(-) > > > > diff --git a/drivers/media/platform/xilinx/xilinx-dma.c > > b/drivers/media/platform/xilinx/xilinx-dma.c > > index 658586e..a714057 100644 > > --- a/drivers/media/platform/xilinx/xilinx-dma.c > > +++ b/drivers/media/platform/xilinx/xilinx-dma.c > > @@ -74,8 +74,8 @@ static int xvip_dma_verify_format(struct xvip_dma > *dma) > > return ret == -ENOIOCTLCMD ? -EINVAL : ret; > > > > if (dma->fmtinfo->code != fmt.format.code || > > - dma->format.height != fmt.format.height || > > - dma->format.width != fmt.format.width) > > + dma->format.fmt.pix_mp.width != fmt.format.width || > > + dma->format.fmt.pix_mp.height != fmt.format.height) > > return -EINVAL; > > > > return 0; > > @@ -310,7 +310,8 @@ static void xvip_dma_complete(void *param) > > buf->buf.field = V4L2_FIELD_NONE; > > buf->buf.sequence = dma->sequence++; > > buf->buf.vb2_buf.timestamp = ktime_get_ns(); > > - vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma- > >format.sizeimage); > > + vb2_set_plane_payload(&buf->buf.vb2_buf, 0, > > + dma- > >format.fmt.pix_mp.plane_fmt[0].sizeimage); > > vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); > > } > > > > @@ -320,13 +321,15 @@ xvip_dma_queue_setup(struct vb2_queue *vq, > > unsigned int sizes[], struct device *alloc_devs[]) > > { > > struct xvip_dma *dma = vb2_get_drv_priv(vq); > > + s32 sizeimage; > > > > /* Make sure the image size is large enough. */ > > + sizeimage = dma->format.fmt.pix_mp.plane_fmt[0].sizeimage; > > if (*nplanes) > > - return sizes[0] < dma->format.sizeimage ? -EINVAL : 0; > > + return sizes[0] < sizeimage ? -EINVAL : 0; > > > > *nplanes = 1; > > - sizes[0] = dma->format.sizeimage; > > + sizes[0] = sizeimage; > > > > return 0; > > } > > @@ -350,14 +353,15 @@ static void xvip_dma_buffer_queue(struct > vb2_buffer *vb) > > struct dma_async_tx_descriptor *desc; > > dma_addr_t addr = vb2_dma_contig_plane_dma_addr(vb, 0); > > u32 flags; > > + struct v4l2_pix_format_mplane *pix_mp = &dma- > >format.fmt.pix_mp; > > > > - if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { > > + if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) > { > > flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK; > > dma->xt.dir = DMA_DEV_TO_MEM; > > dma->xt.src_sgl = false; > > dma->xt.dst_sgl = true; > > dma->xt.dst_start = addr; > > - } else { > > + } else if (dma->queue.type == > V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { > > flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK; > > dma->xt.dir = DMA_MEM_TO_DEV; > > dma->xt.src_sgl = true; > > @@ -365,10 +369,11 @@ static void xvip_dma_buffer_queue(struct > vb2_buffer *vb) > > dma->xt.src_start = addr; > > } > > > > - dma->xt.frame_size = 1; > > - dma->sgl[0].size = dma->format.width * dma->fmtinfo->bpp[0]; > > - dma->sgl[0].icg = dma->format.bytesperline - dma->sgl[0].size; > > - dma->xt.numf = dma->format.height; > > + dma->xt.frame_size = dma->fmtinfo->num_planes; > > + dma->sgl[0].size = pix_mp->width * dma->fmtinfo->bpp[0]; > > + dma->sgl[0].icg = pix_mp->plane_fmt[0].bytesperline - dma- > >sg
RE: [PATCH v4 09/10] v4l: xilinx: dma: Add multi-planar support
Hi Hyun, Thanks for the review. > -Original Message- > From: Hyun Kwon [mailto:hyun.k...@xilinx.com] > Sent: Tuesday, May 01, 2018 2:25 PM > To: Satish Kumar Nagireddy > Cc: linux-media@vger.kernel.org; laurent.pinch...@ideasonboard.com; > michal.si...@xilinx.com; Hyun Kwon ; Satish Kumar > Nagireddy > Subject: Re: [PATCH v4 09/10] v4l: xilinx: dma: Add multi-planar support > > On Mon, 2018-04-30 at 18:35:12 -0700, Satish Kumar Nagireddy wrote: > > The current v4l driver supports single plane formats. This patch adds > > support to handle multi-planar formats. Driver can handle both single > > and multi-planar formats. > > > > Signed-off-by: Satish Kumar Nagireddy > > > > --- > > drivers/media/platform/xilinx/xilinx-dma.c | 159 ++ > -- > > drivers/media/platform/xilinx/xilinx-dma.h | 4 +- > > drivers/media/platform/xilinx/xilinx-vipp.c | 16 +-- > > 3 files changed, 111 insertions(+), 68 deletions(-) > > > > diff --git a/drivers/media/platform/xilinx/xilinx-dma.c > > b/drivers/media/platform/xilinx/xilinx-dma.c > > index 658586e..a714057 100644 > > --- a/drivers/media/platform/xilinx/xilinx-dma.c > > +++ b/drivers/media/platform/xilinx/xilinx-dma.c > > @@ -74,8 +74,8 @@ static int xvip_dma_verify_format(struct xvip_dma > *dma) > > return ret == -ENOIOCTLCMD ? -EINVAL : ret; > > > > if (dma->fmtinfo->code != fmt.format.code || > > - dma->format.height != fmt.format.height || > > - dma->format.width != fmt.format.width) > > + dma->format.fmt.pix_mp.width != fmt.format.width || > > + dma->format.fmt.pix_mp.height != fmt.format.height) > > return -EINVAL; > > > > return 0; > > @@ -310,7 +310,8 @@ static void xvip_dma_complete(void *param) > > buf->buf.field = V4L2_FIELD_NONE; > > buf->buf.sequence = dma->sequence++; > > buf->buf.vb2_buf.timestamp = ktime_get_ns(); > > - vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma- > >format.sizeimage); > > + vb2_set_plane_payload(&buf->buf.vb2_buf, 0, > > + dma- > >format.fmt.pix_mp.plane_fmt[0].sizeimage); > > vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); } > > > > @@ -320,13 +321,15 @@ xvip_dma_queue_setup(struct vb2_queue *vq, > > unsigned int sizes[], struct device *alloc_devs[]) { > > struct xvip_dma *dma = vb2_get_drv_priv(vq); > > + s32 sizeimage; > > u32? > > > > > /* Make sure the image size is large enough. */ > > + sizeimage = dma->format.fmt.pix_mp.plane_fmt[0].sizeimage; > > I'm a little confused again. :-) This doesn't seem handling nplanes > 1, while > there are such formats in the format table. is my understanding correct? [satish]: Current implementation of driver supports only contiguous multi-planar formats like V4L2_PIX_FMT_NV12 And not supporting non-contiguous formats like V4L2_PIX_FMT_NV12M. > > > if (*nplanes) > > - return sizes[0] < dma->format.sizeimage ? -EINVAL : 0; > > + return sizes[0] < sizeimage ? -EINVAL : 0; > > > > *nplanes = 1; > > - sizes[0] = dma->format.sizeimage; > > + sizes[0] = sizeimage; > > > > return 0; > > } > > @@ -350,14 +353,15 @@ static void xvip_dma_buffer_queue(struct > vb2_buffer *vb) > > struct dma_async_tx_descriptor *desc; > > dma_addr_t addr = vb2_dma_contig_plane_dma_addr(vb, 0); > > u32 flags; > > + struct v4l2_pix_format_mplane *pix_mp = &dma- > >format.fmt.pix_mp; > > > > - if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { > > + if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) > { > > flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK; > > dma->xt.dir = DMA_DEV_TO_MEM; > > dma->xt.src_sgl = false; > > dma->xt.dst_sgl = true; > > dma->xt.dst_start = addr; > > - } else { > > + } else if (dma->queue.type == > V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { > > I'd do 'else' even if any other value is not possible at this point. > > > flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK; > > dma->xt.dir = DMA_MEM_TO_DEV; > > dma->xt.src_sgl = true; > > @@ -365,10 +369,11 @@ static void xvip_dma_buffer_queue(struct > vb2_buffer *vb) > > dma->xt.src_start = addr; > > } > > > >
[PATCH v5 5/8] v4l: xilinx: dma: Update video format descriptor
This patch updates video format descriptor to help information viz., number of planes per color format and chroma sub sampling factors. Signed-off-by: Satish Kumar Nagireddy --- Changes in v5: - Added YUV420 10 bit format to video descriptor table Changes in v4: - Introduced bpp (bits per pixel) per plane drivers/media/platform/xilinx/xilinx-dma.c | 12 ++-- drivers/media/platform/xilinx/xilinx-vip.c | 18 ++ drivers/media/platform/xilinx/xilinx-vip.h | 10 -- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 727dc6e..518d572 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -366,7 +366,7 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) } dma->xt.frame_size = 1; - dma->sgl[0].size = dma->format.width * dma->fmtinfo->bpp; + dma->sgl[0].size = dma->format.width * dma->fmtinfo->bpp[0]; dma->sgl[0].icg = dma->format.bytesperline - dma->sgl[0].size; dma->xt.numf = dma->format.height; @@ -569,12 +569,12 @@ __xvip_dma_try_format(struct xvip_dma *dma, struct v4l2_pix_format *pix, * the minimum and maximum values, clamp the requested width and convert * it back to pixels. */ - align = lcm(dma->align, info->bpp); + align = lcm(dma->align, info->bpp[0]); min_width = roundup(XVIP_DMA_MIN_WIDTH, align); max_width = rounddown(XVIP_DMA_MAX_WIDTH, align); - width = rounddown(pix->width * info->bpp, align); + width = rounddown(pix->width * info->bpp[0], align); - pix->width = clamp(width, min_width, max_width) / info->bpp; + pix->width = clamp(width, min_width, max_width) / info->bpp[0]; pix->height = clamp(pix->height, XVIP_DMA_MIN_HEIGHT, XVIP_DMA_MAX_HEIGHT); @@ -582,7 +582,7 @@ __xvip_dma_try_format(struct xvip_dma *dma, struct v4l2_pix_format *pix, * line value is zero, the module doesn't support user configurable line * sizes. Override the requested value with the minimum in that case. */ - min_bpl = pix->width * info->bpp; + min_bpl = pix->width * info->bpp[0]; max_bpl = rounddown(XVIP_DMA_MAX_WIDTH, dma->align); bpl = rounddown(pix->bytesperline, dma->align); @@ -676,7 +676,7 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma, dma->format.field = V4L2_FIELD_NONE; dma->format.width = XVIP_DMA_DEF_WIDTH; dma->format.height = XVIP_DMA_DEF_HEIGHT; - dma->format.bytesperline = dma->format.width * dma->fmtinfo->bpp; + dma->format.bytesperline = dma->format.width * dma->fmtinfo->bpp[0]; dma->format.sizeimage = dma->format.bytesperline * dma->format.height; /* Initialize the media entity... */ diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index 3112591..fb1a08f 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -27,22 +27,24 @@ */ static const struct xvip_video_format xvip_video_formats[] = { + { XVIP_VF_YUV_420, 8, NULL, MEDIA_BUS_FMT_VYYUYY8_1X24, + {1, 2, 0}, V4L2_PIX_FMT_NV12, 2, 2, 2, "4:2:0, semi-planar, YUV" }, { XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16, - 2, V4L2_PIX_FMT_YUYV, "4:2:2, packed, YUYV" }, + {2, 0, 0}, V4L2_PIX_FMT_YUYV, 1, 2, 1, "4:2:2, packed, YUYV" }, { XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24, - 3, V4L2_PIX_FMT_YUV444, "4:4:4, packed, YUYV" }, + {3, 0, 0}, V4L2_PIX_FMT_YUV444, 1, 1, 1, "4:4:4, packed, YUYV" }, { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, - 3, 0, NULL }, + {3, 0, 0}, V4L2_PIX_FMT_RGB24, 1, 1, 1, "24-bit RGB" }, { XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8, - 1, V4L2_PIX_FMT_GREY, "Greyscale 8-bit" }, + {1, 0, 0}, V4L2_PIX_FMT_GREY, 1, 1, 1, "Greyscale 8-bit" }, { XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8, - 1, V4L2_PIX_FMT_SGRBG8, "Bayer 8-bit RGGB" }, + {1, 0, 0}, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, "Bayer 8-bit RGGB" }, { XVIP_VF_MONO_SENSOR, 8, "grbg", MEDIA_BUS_FMT_SGRBG8_1X8, - 1, V4L2_PIX_FMT_SGRBG8, "Bayer 8-bit GRBG" }, + {1, 0, 0}, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, "Bayer 8-bit GRBG" }, { XVIP_VF_MONO_SENSOR, 8, "gbrg", MEDIA_BUS_FMT_SGBRG8_1X8, - 1, V4L2_PIX_FMT_SGBRG8, "Bayer 8-bit GBRG" }, + {1, 0,
[PATCH v5 2/8] xilinx: v4l: dma: Update driver to allow for probe defer
From: Rohit Athavale Update xvip_dma_init() to use dma_request_chan(), enabling probe deferral. Also update the cleanup routine to prevent dereferencing an ERR_PTR(). Signed-off-by: Rohit Athavale Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index cb20ada..5426efe 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -729,10 +729,13 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma, /* ... and the DMA channel. */ snprintf(name, sizeof(name), "port%u", port); - dma->dma = dma_request_slave_channel(dma->xdev->dev, name); - if (dma->dma == NULL) { - dev_err(dma->xdev->dev, "no VDMA channel found\n"); - ret = -ENODEV; + dma->dma = dma_request_chan(dma->xdev->dev, name); + if (IS_ERR(dma->dma)) { + ret = PTR_ERR(dma->dma); + if (ret != -EPROBE_DEFER) + dev_err(dma->xdev->dev, + "No Video DMA channel found"); + goto error; } @@ -756,7 +759,7 @@ void xvip_dma_cleanup(struct xvip_dma *dma) if (video_is_registered(&dma->video)) video_unregister_device(&dma->video); - if (dma->dma) + if (!IS_ERR(dma->dma)) dma_release_channel(dma->dma); media_entity_cleanup(&dma->video.entity); -- 2.7.4
[PATCH v5 0/8] Add support for multi-planar formats and 10 bit formats
The patches are for xilinx v4l. The patcheset enable support to handle multiplanar formats and 10 bit formats. Single planar implementation is removed as mplane can handle both. Patch-set has downstream changes and bug fixes. Added new media bus format MEDIA_BUS_FMT_VYYUYY8_1X24, new pixel format V4L2_PIX_FMT_XV15 and rst documentation. Jeffrey Mouroux (1): uapi: media: New fourcc code and rst for 10 bit format Radhey Shyam Pandey (1): v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format Rohit Athavale (1): xilinx: v4l: dma: Update driver to allow for probe defer Satish Kumar Nagireddy (4): media-bus: uapi: Add YCrCb 420 media bus format and rst v4l: xilinx: dma: Update video format descriptor v4l: xilinx: dma: Add multi-planar support v4l: xilinx: dma: Add support for 10 bit formats Vishal Sagar (1): xilinx: v4l: dma: Terminate DMA when media pipeline fail to start Documentation/media/uapi/v4l/pixfmt-xv15.rst| 134 +++ Documentation/media/uapi/v4l/subdev-formats.rst | 38 +- Documentation/media/uapi/v4l/yuv-formats.rst| 1 + drivers/media/platform/xilinx/xilinx-dma.c | 170 +++- drivers/media/platform/xilinx/xilinx-dma.h | 4 +- drivers/media/platform/xilinx/xilinx-vip.c | 37 -- drivers/media/platform/xilinx/xilinx-vip.h | 15 ++- drivers/media/platform/xilinx/xilinx-vipp.c | 16 +-- include/uapi/linux/media-bus-format.h | 3 +- include/uapi/linux/videodev2.h | 1 + 10 files changed, 333 insertions(+), 86 deletions(-) create mode 100644 Documentation/media/uapi/v4l/pixfmt-xv15.rst -- 2.7.4
[PATCH v5 4/8] media-bus: uapi: Add YCrCb 420 media bus format and rst
This commit adds YUV 420 media bus format. VYYUYY8_1X24 is an approximate way to descrive the pixels sent over the bus. This patch also contain rst documentation for media bus format. Signed-off-by: Satish Kumar Nagireddy --- Changes in v3: - Fixed table alignment issue in rst file. Ensured the output is proper uisng 'make pdfdocs' Changes in v2: - Added rst documentation for MEDIA_BUS_FMT_VYYUYY8_1X24 Documentation/media/uapi/v4l/subdev-formats.rst | 38 - include/uapi/linux/media-bus-format.h | 3 +- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Documentation/media/uapi/v4l/subdev-formats.rst b/Documentation/media/uapi/v4l/subdev-formats.rst index 9fcabe7..904c52b 100644 --- a/Documentation/media/uapi/v4l/subdev-formats.rst +++ b/Documentation/media/uapi/v4l/subdev-formats.rst @@ -6640,6 +6640,43 @@ the following codes. - u\ :sub:`2` - u\ :sub:`1` - u\ :sub:`0` +* .. _MEDIA-BUS-FMT-VYYUYY8-1X24: + + - MEDIA_BUS_FMT_VYYUYY8_1X24 + - 0x202c + - + - + - + - + - + - + - + - + - + - v\ :sub:`3` + - v\ :sub:`2` + - v\ :sub:`1` + - v\ :sub:`0` + - y\ :sub:`7` + - y\ :sub:`6` + - y\ :sub:`5` + - y\ :sub:`4` + - y\ :sub:`3` + - y\ :sub:`2` + - y\ :sub:`1` + - y\ :sub:`0` + - u\ :sub:`3` + - u\ :sub:`2` + - u\ :sub:`1` + - u\ :sub:`0` + - y\ :sub:`7` + - y\ :sub:`6` + - y\ :sub:`5` + - y\ :sub:`4` + - y\ :sub:`3` + - y\ :sub:`2` + - y\ :sub:`1` + - y\ :sub:`0` * .. _MEDIA-BUS-FMT-YUV10-1X30: - MEDIA_BUS_FMT_YUV10_1X30 @@ -7287,7 +7324,6 @@ The following table list existing packed 48bit wide YUV formats. - y\ :sub:`1` - y\ :sub:`0` - .. raw:: latex \endgroup diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h index 9e35117..ade7e9d 100644 --- a/include/uapi/linux/media-bus-format.h +++ b/include/uapi/linux/media-bus-format.h @@ -62,7 +62,7 @@ #define MEDIA_BUS_FMT_RGB121212_1X36 0x1019 #define MEDIA_BUS_FMT_RGB161616_1X48 0x101a -/* YUV (including grey) - next is 0x202c */ +/* YUV (including grey) - next is 0x202d */ #define MEDIA_BUS_FMT_Y8_1X8 0x2001 #define MEDIA_BUS_FMT_UV8_1X8 0x2015 #define MEDIA_BUS_FMT_UYVY8_1_5X8 0x2002 @@ -106,6 +106,7 @@ #define MEDIA_BUS_FMT_YUV12_1X36 0x2029 #define MEDIA_BUS_FMT_YUV16_1X48 0x202a #define MEDIA_BUS_FMT_UYYVYY16_0_5X48 0x202b +#define MEDIA_BUS_FMT_VYYUYY8_1X24 0x202c /* Bayer - next is 0x3021 */ #define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001 -- 2.7.4
[PATCH v5 7/8] uapi: media: New fourcc code and rst for 10 bit format
From: Jeffrey Mouroux This patch adds new fourcc code and rst documentation for YUV420 10 bit format. Signed-off-by: Jeffrey Mouroux Signed-off-by: Satish Kumar Nagireddy --- Changes in v5: - Squashed rst documentation and new pixel format of YUV420 10 bit into single patch Changes in v4: - Added rst documentation for YUV420 10 bit format Documentation/media/uapi/v4l/pixfmt-xv15.rst | 134 +++ Documentation/media/uapi/v4l/yuv-formats.rst | 1 + include/uapi/linux/videodev2.h | 1 + 3 files changed, 136 insertions(+) create mode 100644 Documentation/media/uapi/v4l/pixfmt-xv15.rst diff --git a/Documentation/media/uapi/v4l/pixfmt-xv15.rst b/Documentation/media/uapi/v4l/pixfmt-xv15.rst new file mode 100644 index 000..fc829c3 --- /dev/null +++ b/Documentation/media/uapi/v4l/pixfmt-xv15.rst @@ -0,0 +1,134 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _V4L2-PIX-FMT-XV15: + +** +V4L2_PIX_FMT_XV15 ('XV15') +** + + +Semi-planar YUV 420 10-bit + + +Description +=== + +This is the 10-bit version of YUV 420 semi-planar format. XV15 is the one +where chroma plane is contiguous with the luma plane in memory. + +Each pixel of YUV 420 contains a single luma component of 10-bits in length. +Three luma components are stored per word with the remaining two bits serving +as padding. + +The chroma plane is subsampled and is only 1/2 the size of the luma plane. A +single chroma component serves two pixels on a given row and is re-used on the +adjacent row of luma data. + +**Data Layout of Luma Plane** +Each cell is one 32-bit word. + +.. flat-table:: +:header-rows: 0 +:stub-columns: 0 + +* - word + 0: + - X'\ :sub:`[31:30]` + - Y'\ :sub:`02 [29:20]` + - Y'\ :sub:`01 [19:10]` + - Y'\ :sub:`00 [09:00]` + - +* - word + 1: + - X'\ :sub:`[31:30]` + - Y'\ :sub:`05 [29:20]` + - Y'\ :sub:`04 [19:10]` + - Y'\ :sub:`03 [09:00]` + - +* - word + 2: + - X'\ :sub:`[31:30]` + - Y'\ :sub:`08 [29:20]` + - Y'\ :sub:`07 [19:10]` + - Y'\ :sub:`06 [09:00]` + - + + +**Data Layout of Chroma Plane** + +.. flat-table:: +:header-rows: 0 +:stub-columns: 0 + +* - word + 0: + - X'\ :sub:`[31:30]` + - U'\ :sub:`02 [29:20]` + - V'\ :sub:`01 [19:10]` + - U'\ :sub:`00 [09:00]` + - +* - word + 1: + - X'\ :sub:`[31:30]` + - V'\ :sub:`05 [29:20]` + - U'\ :sub:`04 [19:10]` + - V'\ :sub:`03 [09:00]` + - +* - word + 2: + - X'\ :sub:`[31:30]` + - U'\ :sub:`08 [29:20]` + - V'\ :sub:`07 [19:10]` + - U'\ :sub:`06 [09:00]` + - + +**Color Sample Location** + +.. flat-table:: +:header-rows: 0 +:stub-columns: 0 + +* - + - 0 + - + - 1 + - 2 + - + - 3 +* - 0 + - Y + - + - Y + - Y + - + - Y +* - + - + - C + - + - + - C + - +* - 1 + - Y + - + - Y + - Y + - + - Y +* - +* - 2 + - Y + - + - Y + - Y + - + - Y +* - + - + - C + - + - + - C + - +* - 3 + - Y + - + - Y + - Y + - + - Y diff --git a/Documentation/media/uapi/v4l/yuv-formats.rst b/Documentation/media/uapi/v4l/yuv-formats.rst index 3334ea4..c500bc1 100644 --- a/Documentation/media/uapi/v4l/yuv-formats.rst +++ b/Documentation/media/uapi/v4l/yuv-formats.rst @@ -49,6 +49,7 @@ to brightness information. pixfmt-nv12 pixfmt-nv12m pixfmt-nv12mt +pixfmt-xv15 pixfmt-nv16 pixfmt-nv16m pixfmt-nv24 diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 600877b..873bafa 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -551,6 +551,7 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_NV61v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */ #define V4L2_PIX_FMT_NV24v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */ #define V4L2_PIX_FMT_NV42v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */ +#define V4L2_PIX_FMT_XV15v4l2_fourcc('X', 'V', '1', '5') /* 32 XY/UV 4:2:0 10-bit */ /* two non contiguous planes - one Y, one Cr + Cb interleaved */ #define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */ -- 2.7.4
[PATCH v5 6/8] v4l: xilinx: dma: Add multi-planar support
The current v4l driver supports single plane formats. This patch adds support to handle multi-planar formats. Driver can handle both single and multi-planar formats. Signed-off-by: Satish Kumar Nagireddy --- Changes in v5: - Added default height - Corrected sizeimage declaration with u32 Changes in v4: - Single plane implementation is removed as multi-plane supports both - num_buffers and bpl_factor parameters are removed to have clean implementation drivers/media/platform/xilinx/xilinx-dma.c | 150 +--- drivers/media/platform/xilinx/xilinx-dma.h | 4 +- drivers/media/platform/xilinx/xilinx-vipp.c | 16 +-- 3 files changed, 104 insertions(+), 66 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 518d572..2ffc276 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -74,8 +74,8 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) return ret == -ENOIOCTLCMD ? -EINVAL : ret; if (dma->fmtinfo->code != fmt.format.code || - dma->format.height != fmt.format.height || - dma->format.width != fmt.format.width) + dma->format.fmt.pix_mp.width != fmt.format.width || + dma->format.fmt.pix_mp.height != fmt.format.height) return -EINVAL; return 0; @@ -310,7 +310,8 @@ static void xvip_dma_complete(void *param) buf->buf.field = V4L2_FIELD_NONE; buf->buf.sequence = dma->sequence++; buf->buf.vb2_buf.timestamp = ktime_get_ns(); - vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma->format.sizeimage); + vb2_set_plane_payload(&buf->buf.vb2_buf, 0, + dma->format.fmt.pix_mp.plane_fmt[0].sizeimage); vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); } @@ -320,13 +321,15 @@ xvip_dma_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct xvip_dma *dma = vb2_get_drv_priv(vq); + u32 sizeimage; /* Make sure the image size is large enough. */ + sizeimage = dma->format.fmt.pix_mp.plane_fmt[0].sizeimage; if (*nplanes) - return sizes[0] < dma->format.sizeimage ? -EINVAL : 0; + return sizes[0] < sizeimage ? -EINVAL : 0; *nplanes = 1; - sizes[0] = dma->format.sizeimage; + sizes[0] = sizeimage; return 0; } @@ -350,8 +353,9 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) struct dma_async_tx_descriptor *desc; dma_addr_t addr = vb2_dma_contig_plane_dma_addr(vb, 0); u32 flags; + struct v4l2_pix_format_mplane *pix_mp = &dma->format.fmt.pix_mp; - if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { + if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK; dma->xt.dir = DMA_DEV_TO_MEM; dma->xt.src_sgl = false; @@ -365,10 +369,11 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) dma->xt.src_start = addr; } - dma->xt.frame_size = 1; - dma->sgl[0].size = dma->format.width * dma->fmtinfo->bpp[0]; - dma->sgl[0].icg = dma->format.bytesperline - dma->sgl[0].size; - dma->xt.numf = dma->format.height; + dma->xt.frame_size = dma->fmtinfo->num_planes; + dma->sgl[0].size = pix_mp->width * dma->fmtinfo->bpp[0]; + dma->sgl[0].icg = pix_mp->plane_fmt[0].bytesperline - dma->sgl[0].size; + dma->xt.numf = pix_mp->height; + dma->sgl[0].dst_icg = 0; desc = dmaengine_prep_interleaved_dma(dma->dma, &dma->xt, flags); if (!desc) { @@ -496,11 +501,12 @@ xvip_dma_querycap(struct file *file, void *fh, struct v4l2_capability *cap) cap->capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING | dma->xdev->v4l2_caps; + cap->device_caps = V4L2_CAP_STREAMING; - if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) - cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; + if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + cap->device_caps |= V4L2_CAP_VIDEO_CAPTURE_MPLANE; else - cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; + cap->device_caps |= V4L2_CAP_VIDEO_OUTPUT_MPLANE; strlcpy(cap->driver, "xilinx-vipp", sizeof(cap->driver)); strlcpy(cap->card, dma->video.name, sizeof(cap->card)); @@ -524,7 +530,7 @@ xvip_dma_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f) if (f->index > 0) return
[PATCH v5 1/8] v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format
From: Radhey Shyam Pandey In current implementation driver only checks the colorspace between the last subdev in the pipeline and the connected video node, the pipeline could be configured with wrong colorspace information until the very end. It thus makes little sense to check the colorspace only at the video node. So check can be dropped until we find a better solution to carry colorspace information through pipelines and to userspace. Signed-off-by: Radhey Shyam Pandey Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 522cdfd..cb20ada 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -75,8 +75,7 @@ static int xvip_dma_verify_format(struct xvip_dma *dma) if (dma->fmtinfo->code != fmt.format.code || dma->format.height != fmt.format.height || - dma->format.width != fmt.format.width || - dma->format.colorspace != fmt.format.colorspace) + dma->format.width != fmt.format.width) return -EINVAL; return 0; -- 2.7.4
[PATCH v5 3/8] xilinx: v4l: dma: Terminate DMA when media pipeline fail to start
From: Vishal Sagar If an incorrectly configured media pipeline is started, the allocated dma descriptors aren't freed. This leads to kernel oops when pipeline is configured correctly and run subsequently. This patch also replaces dmaengine_terminate_all() with dmaengine_terminate_sync() as the former one is deprecated. Signed-off-by: Vishal Sagar Signed-off-by: Satish Kumar Nagireddy --- drivers/media/platform/xilinx/xilinx-dma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 5426efe..727dc6e 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -437,6 +437,7 @@ static int xvip_dma_start_streaming(struct vb2_queue *vq, unsigned int count) media_pipeline_stop(&dma->video.entity); error: + dmaengine_terminate_sync(dma->dma); /* Give back all queued buffers to videobuf2. */ spin_lock_irq(&dma->queued_lock); list_for_each_entry_safe(buf, nbuf, &dma->queued_bufs, queue) { @@ -458,7 +459,7 @@ static void xvip_dma_stop_streaming(struct vb2_queue *vq) xvip_pipeline_set_stream(pipe, false); /* Stop and reset the DMA engine. */ - dmaengine_terminate_all(dma->dma); + dmaengine_terminate_sync(dma->dma); /* Cleanup the pipeline and mark it as being stopped. */ xvip_pipeline_cleanup(pipe); -- 2.7.4
[PATCH v5 8/8] v4l: xilinx: dma: Add support for 10 bit formats
This patch adds xvip_format_plane_width_bytes function to calculate number of bytes for a macropixel formats and also adds new 10 bit pixel formats to video descriptor table. Signed-off-by: Satish Kumar Nagireddy --- Changes in v4: - Introduced macropixel concept to calculate bytes for a given width for 10 bit formats drivers/media/platform/xilinx/xilinx-dma.c | 5 ++-- drivers/media/platform/xilinx/xilinx-vip.c | 37 ++ drivers/media/platform/xilinx/xilinx-vip.h | 5 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 2ffc276..89afa24 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -370,7 +370,8 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb) } dma->xt.frame_size = dma->fmtinfo->num_planes; - dma->sgl[0].size = pix_mp->width * dma->fmtinfo->bpp[0]; + dma->sgl[0].size = xvip_fmt_plane_width_bytes(dma->fmtinfo, + pix_mp->width); dma->sgl[0].icg = pix_mp->plane_fmt[0].bytesperline - dma->sgl[0].size; dma->xt.numf = pix_mp->height; dma->sgl[0].dst_icg = 0; @@ -591,7 +592,7 @@ __xvip_dma_try_format(struct xvip_dma *dma, * with the minimum in that case. */ max_bpl = rounddown(XVIP_DMA_MAX_WIDTH, align); - min_bpl = pix_mp->width * info->bpp[0]; + min_bpl = xvip_fmt_plane_width_bytes(info, pix_mp->width); min_bpl = roundup(min_bpl, align); bpl = roundup(plane_fmt[0].bytesperline, align); plane_fmt[0].bytesperline = clamp(bpl, min_bpl, max_bpl); diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c index fb1a08f..7569f05 100644 --- a/drivers/media/platform/xilinx/xilinx-vip.c +++ b/drivers/media/platform/xilinx/xilinx-vip.c @@ -28,23 +28,25 @@ static const struct xvip_video_format xvip_video_formats[] = { { XVIP_VF_YUV_420, 8, NULL, MEDIA_BUS_FMT_VYYUYY8_1X24, - {1, 2, 0}, V4L2_PIX_FMT_NV12, 2, 2, 2, "4:2:0, semi-planar, YUV" }, + {1, 2, 0}, V4L2_PIX_FMT_NV12, 2, 2, 2, 1, 1, "4:2:0, semi-planar, YUV" }, { XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16, - {2, 0, 0}, V4L2_PIX_FMT_YUYV, 1, 2, 1, "4:2:2, packed, YUYV" }, + {2, 0, 0}, V4L2_PIX_FMT_YUYV, 1, 2, 1, 1, 1, "4:2:2, packed, YUYV" }, { XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24, - {3, 0, 0}, V4L2_PIX_FMT_YUV444, 1, 1, 1, "4:4:4, packed, YUYV" }, + {3, 0, 0}, V4L2_PIX_FMT_YUV444, 1, 1, 1, 1, 1, "4:4:4, packed, YUYV" }, + { XVIP_VF_YUV_420, 10, NULL, MEDIA_BUS_FMT_VYYUYY8_1X24, + {1, 2, 0}, V4L2_PIX_FMT_XV15, 2, 2, 2, 4, 3, "4:2:0, 10-bit 2-plane cont" }, { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24, - {3, 0, 0}, V4L2_PIX_FMT_RGB24, 1, 1, 1, "24-bit RGB" }, + {3, 0, 0}, V4L2_PIX_FMT_RGB24, 1, 1, 1, 1, 1, "24-bit RGB" }, { XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8, - {1, 0, 0}, V4L2_PIX_FMT_GREY, 1, 1, 1, "Greyscale 8-bit" }, + {1, 0, 0}, V4L2_PIX_FMT_GREY, 1, 1, 1, 1, 1, "Greyscale 8-bit" }, { XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8, - {1, 0, 0}, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, "Bayer 8-bit RGGB" }, + {1, 0, 0}, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, 1, "Bayer 8-bit RGGB" }, { XVIP_VF_MONO_SENSOR, 8, "grbg", MEDIA_BUS_FMT_SGRBG8_1X8, - {1, 0, 0}, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, "Bayer 8-bit GRBG" }, + {1, 0, 0}, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, 1, "Bayer 8-bit GRBG" }, { XVIP_VF_MONO_SENSOR, 8, "gbrg", MEDIA_BUS_FMT_SGBRG8_1X8, - {1, 0, 0}, V4L2_PIX_FMT_SGBRG8, 1, 1, 1, "Bayer 8-bit GBRG" }, + {1, 0, 0}, V4L2_PIX_FMT_SGBRG8, 1, 1, 1, 1, 1, "Bayer 8-bit GBRG" }, { XVIP_VF_MONO_SENSOR, 8, "bggr", MEDIA_BUS_FMT_SBGGR8_1X8, - {1, 0, 0}, V4L2_PIX_FMT_SBGGR8, 1, 1, 1, "Bayer 8-bit BGGR" }, + {1, 0, 0}, V4L2_PIX_FMT_SBGGR8, 1, 1, 1, 1, 1, "Bayer 8-bit BGGR" }, }; /** @@ -94,6 +96,23 @@ const struct xvip_video_format *xvip_get_format_by_fourcc(u32 fourcc) EXPORT_SYMBOL_GPL(xvip_get_format_by_fourcc); /** + * xvip_fmt_plane_width_bytes - bytes of the given width of the plane + * @info: VIP format description + * @width: width + * + * Return: Returns the number of bytes for given @width + */ +int xvip_fmt_plane_width_bytes(const struct xvip_video_format *info, u32 width) +{ + if (!info) + return 0; + + return DIV_ROUND_UP(width * info->bytes_per_m