All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] media: staging: rkisp1: add support for RGB formats
@ 2020-04-12 12:05 Dafna Hirschfeld
  2020-04-12 12:05 ` [PATCH v2 1/4] media: staging: rkisp1: rsz: get the capture format info from the capture struct Dafna Hirschfeld
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dafna Hirschfeld @ 2020-04-12 12:05 UTC (permalink / raw)
  To: linux-media, dafna.hirschfeld, helen.koike, ezequiel, hverkuil,
	kernel, dafna3, laurent.pinchart, linux-rockchip, sakari.ailus

Add support for RGB formats in rkisp1, (currently only RGB565 is correctly captured)
The patchset is rebased on top of v3 of the patchset
"rkisp1: use enum v4l2_pixel_encoding instead of rkisp1_fmt_pix_type"

patches summary:

patch 1: fix a redundant call to v4l2_format_info in the resizer code
patch 2: remove a redundant if statement that checks that the resizer format is YUV
patch 3: fix a bug that changes the default hdiv,vdiv in the resizer scale for RGB formats.
This bug changes the YUV ratios from 4:2:2 to 4:4:4 and the capture for RGB times out
patch 4: removes the restriction in the validation function of the capture that forces the
mbus encoding to be the same as the capture encoding. This is because for RGB formats
the mbus format should be MEDIA_BUS_FMT_YUYV8_2X8

changes from v1:
* rebase the patchset on top of v3 of "rkisp1: use enum v4l2_pixel_encoding instead of rkisp1_fmt_pix_type"
* patch 1 - use cap->pix.info directly instead of saving it to a variable
* add another patch that removes a redundant if statement in func rkisp1_rsz_config
* patch 4 - change the if statement in rkisp1_capture_link_validate to list the supported
options instead of the unsupported options


Dafna Hirschfeld (4):
  media: staging: rkisp1: rsz: get the capture format info from the
    capture struct
  media: staging: rkisp1: rsz: remove redundant if statement and add
    inline doc
  media: staging: rkisp1: rsz: change (hv)div only if capture format is
    YUV
  media: staging: rkisp1: cap: enable RGB capture format with YUV media
    bus

 drivers/staging/media/rkisp1/rkisp1-capture.c |  6 ++++-
 drivers/staging/media/rkisp1/rkisp1-resizer.c | 26 +++++++++++++------
 2 files changed, 23 insertions(+), 9 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/4] media: staging: rkisp1: rsz: get the capture format info from the capture struct
  2020-04-12 12:05 [PATCH v2 0/4] media: staging: rkisp1: add support for RGB formats Dafna Hirschfeld
@ 2020-04-12 12:05 ` Dafna Hirschfeld
  2020-04-12 12:05 ` [PATCH v2 2/4] media: staging: rkisp1: rsz: remove redundant if statement and add inline doc Dafna Hirschfeld
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dafna Hirschfeld @ 2020-04-12 12:05 UTC (permalink / raw)
  To: linux-media, dafna.hirschfeld, helen.koike, ezequiel, hverkuil,
	kernel, dafna3, laurent.pinchart, linux-rockchip, sakari.ailus

Currently the format info of the capture is retrieved by calling
the function  v4l2_format_info. This is not needed since it is
already save in the capture object.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
---
 drivers/staging/media/rkisp1/rkisp1-resizer.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/rkisp1/rkisp1-resizer.c b/drivers/staging/media/rkisp1/rkisp1-resizer.c
index 7b6b7ddd4169..84f23a91b0a0 100644
--- a/drivers/staging/media/rkisp1/rkisp1-resizer.c
+++ b/drivers/staging/media/rkisp1/rkisp1-resizer.c
@@ -387,11 +387,9 @@ static void rkisp1_rsz_config(struct rkisp1_resizer *rsz,
 	if (rsz->pixel_enc == V4L2_PIXEL_ENC_YUV) {
 		struct rkisp1_capture *cap =
 			&rsz->rkisp1->capture_devs[rsz->id];
-		const struct v4l2_format_info *pixfmt_info =
-			v4l2_format_info(cap->pix.fmt.pixelformat);
 
-		hdiv = pixfmt_info->hdiv;
-		vdiv = pixfmt_info->vdiv;
+		hdiv = cap->pix.info->hdiv;
+		vdiv = cap->pix.info->vdiv;
 	}
 	src_c.width = src_y.width / hdiv;
 	src_c.height = src_y.height / vdiv;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/4] media: staging: rkisp1: rsz: remove redundant if statement and add inline doc
  2020-04-12 12:05 [PATCH v2 0/4] media: staging: rkisp1: add support for RGB formats Dafna Hirschfeld
  2020-04-12 12:05 ` [PATCH v2 1/4] media: staging: rkisp1: rsz: get the capture format info from the capture struct Dafna Hirschfeld
@ 2020-04-12 12:05 ` Dafna Hirschfeld
  2020-04-12 12:05 ` [PATCH v2 3/4] media: staging: rkisp1: rsz: change (hv)div only if capture format is YUV Dafna Hirschfeld
  2020-04-12 12:05 ` [PATCH v2 4/4] media: staging: rkisp1: cap: enable RGB capture format with YUV media bus Dafna Hirschfeld
  3 siblings, 0 replies; 5+ messages in thread
From: Dafna Hirschfeld @ 2020-04-12 12:05 UTC (permalink / raw)
  To: linux-media, dafna.hirschfeld, helen.koike, ezequiel, hverkuil,
	kernel, dafna3, laurent.pinchart, linux-rockchip, sakari.ailus

The statement "if (rsz->fmt_type == V4L2_PIXEL_ENC_YUV)"
can be removed since the value of rsz->fmt_type is either
V4L2_PIXEL_ENC_YUV or V4L2_PIXEL_ENC_BAYER and the function
returns if it is bayer. In addition some doc with clarification
is added.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
---
 drivers/staging/media/rkisp1/rkisp1-resizer.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/rkisp1/rkisp1-resizer.c b/drivers/staging/media/rkisp1/rkisp1-resizer.c
index 84f23a91b0a0..c28919b9af44 100644
--- a/drivers/staging/media/rkisp1/rkisp1-resizer.c
+++ b/drivers/staging/media/rkisp1/rkisp1-resizer.c
@@ -365,12 +365,17 @@ static void rkisp1_rsz_config(struct rkisp1_resizer *rsz,
 	struct v4l2_rect sink_y, sink_c, src_y, src_c;
 	struct v4l2_mbus_framefmt *src_fmt;
 	struct v4l2_rect *sink_crop;
+	struct rkisp1_capture *cap = &rsz->rkisp1->capture_devs[rsz->id];
 
 	sink_crop = rkisp1_rsz_get_pad_crop(rsz, NULL, RKISP1_RSZ_PAD_SINK,
 					    V4L2_SUBDEV_FORMAT_ACTIVE);
 	src_fmt = rkisp1_rsz_get_pad_fmt(rsz, NULL, RKISP1_RSZ_PAD_SRC,
 					 V4L2_SUBDEV_FORMAT_ACTIVE);
 
+	/*
+	 * The resizer only works on yuv formats,
+	 * so return if it is bayer format.
+	 */
 	if (rsz->pixel_enc == V4L2_PIXEL_ENC_BAYER) {
 		rkisp1_rsz_disable(rsz, when);
 		return;
@@ -384,13 +389,15 @@ static void rkisp1_rsz_config(struct rkisp1_resizer *rsz,
 	sink_c.width = sink_y.width / RKISP1_MBUS_FMT_HDIV;
 	sink_c.height = sink_y.height / RKISP1_MBUS_FMT_VDIV;
 
-	if (rsz->pixel_enc == V4L2_PIXEL_ENC_YUV) {
-		struct rkisp1_capture *cap =
-			&rsz->rkisp1->capture_devs[rsz->id];
+	/*
+	 * The resizer is used not only to change the dimensions of the frame
+	 * but also to change the scale for YUV formats,
+	 * (4:2:2 -> 4:2:0 for example). So the width/height of the CbCr
+	 * streams should be set according to the pixel format in the capture.
+	 */
+	hdiv = cap->pix.info->hdiv;
+	vdiv = cap->pix.info->vdiv;
 
-		hdiv = cap->pix.info->hdiv;
-		vdiv = cap->pix.info->vdiv;
-	}
 	src_c.width = src_y.width / hdiv;
 	src_c.height = src_y.height / vdiv;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/4] media: staging: rkisp1: rsz: change (hv)div only if capture format is YUV
  2020-04-12 12:05 [PATCH v2 0/4] media: staging: rkisp1: add support for RGB formats Dafna Hirschfeld
  2020-04-12 12:05 ` [PATCH v2 1/4] media: staging: rkisp1: rsz: get the capture format info from the capture struct Dafna Hirschfeld
  2020-04-12 12:05 ` [PATCH v2 2/4] media: staging: rkisp1: rsz: remove redundant if statement and add inline doc Dafna Hirschfeld
@ 2020-04-12 12:05 ` Dafna Hirschfeld
  2020-04-12 12:05 ` [PATCH v2 4/4] media: staging: rkisp1: cap: enable RGB capture format with YUV media bus Dafna Hirschfeld
  3 siblings, 0 replies; 5+ messages in thread
From: Dafna Hirschfeld @ 2020-04-12 12:05 UTC (permalink / raw)
  To: linux-media, dafna.hirschfeld, helen.koike, ezequiel, hverkuil,
	kernel, dafna3, laurent.pinchart, linux-rockchip, sakari.ailus

RGB formats in selfpath should receive input format as YUV422.
The resizer input format is always YUV422 and therefore
if the capture format is RGB, the resizer should not change
the YUV rations.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
---
 drivers/staging/media/rkisp1/rkisp1-resizer.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/rkisp1/rkisp1-resizer.c b/drivers/staging/media/rkisp1/rkisp1-resizer.c
index c28919b9af44..d049374413dc 100644
--- a/drivers/staging/media/rkisp1/rkisp1-resizer.c
+++ b/drivers/staging/media/rkisp1/rkisp1-resizer.c
@@ -394,9 +394,14 @@ static void rkisp1_rsz_config(struct rkisp1_resizer *rsz,
 	 * but also to change the scale for YUV formats,
 	 * (4:2:2 -> 4:2:0 for example). So the width/height of the CbCr
 	 * streams should be set according to the pixel format in the capture.
+	 * The resizer always gets the input as YUV422. If the capture format
+	 * is RGB then the memory input should be YUV422 so we don't change the
+	 * default hdiv, vdiv in that case.
 	 */
-	hdiv = cap->pix.info->hdiv;
-	vdiv = cap->pix.info->vdiv;
+	if (v4l2_is_format_yuv(cap->pix.info)) {
+		hdiv = cap->pix.info->hdiv;
+		vdiv = cap->pix.info->vdiv;
+	}
 
 	src_c.width = src_y.width / hdiv;
 	src_c.height = src_y.height / vdiv;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 4/4] media: staging: rkisp1: cap: enable RGB capture format with YUV media bus
  2020-04-12 12:05 [PATCH v2 0/4] media: staging: rkisp1: add support for RGB formats Dafna Hirschfeld
                   ` (2 preceding siblings ...)
  2020-04-12 12:05 ` [PATCH v2 3/4] media: staging: rkisp1: rsz: change (hv)div only if capture format is YUV Dafna Hirschfeld
@ 2020-04-12 12:05 ` Dafna Hirschfeld
  3 siblings, 0 replies; 5+ messages in thread
From: Dafna Hirschfeld @ 2020-04-12 12:05 UTC (permalink / raw)
  To: linux-media, dafna.hirschfeld, helen.koike, ezequiel, hverkuil,
	kernel, dafna3, laurent.pinchart, linux-rockchip, sakari.ailus

In selfpath, RGB capture formats are received in the sink pad as YUV
and are converted to RGB only when writing to memory. So the validation
function should accept YUV bus formats with RGB capture encoding.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
---
 drivers/staging/media/rkisp1/rkisp1-capture.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c
index fbf62399fe3d..a94483170e9c 100644
--- a/drivers/staging/media/rkisp1/rkisp1-capture.c
+++ b/drivers/staging/media/rkisp1/rkisp1-capture.c
@@ -1208,6 +1208,8 @@ static int rkisp1_capture_link_validate(struct media_link *link)
 		media_entity_to_v4l2_subdev(link->source->entity);
 	struct rkisp1_capture *cap = video_get_drvdata(vdev);
 	struct rkisp1_isp *isp = &cap->rkisp1->isp;
+	u8 isp_pix_enc = isp->src_fmt->pixel_enc;
+	u8 cap_pix_enc = cap->pix.info->pixel_enc;
 	struct v4l2_subdev_format sd_fmt;
 	int ret;
 
@@ -1218,7 +1220,9 @@ static int rkisp1_capture_link_validate(struct media_link *link)
 		return -EPIPE;
 	}
 
-	if (cap->pix.info->pixel_enc != isp->src_fmt->pixel_enc) {
+	if (cap_pix_enc != isp_pix_enc &&
+	    !(isp_pix_enc == V4L2_PIXEL_ENC_YUV &&
+	      cap_pix_enc == V4L2_PIXEL_ENC_RGB)) {
 		dev_err(cap->rkisp1->dev,
 			"format type mismatch in link '%s:%d->%s:%d'\n",
 			link->source->entity->name, link->source->index,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-12 12:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12 12:05 [PATCH v2 0/4] media: staging: rkisp1: add support for RGB formats Dafna Hirschfeld
2020-04-12 12:05 ` [PATCH v2 1/4] media: staging: rkisp1: rsz: get the capture format info from the capture struct Dafna Hirschfeld
2020-04-12 12:05 ` [PATCH v2 2/4] media: staging: rkisp1: rsz: remove redundant if statement and add inline doc Dafna Hirschfeld
2020-04-12 12:05 ` [PATCH v2 3/4] media: staging: rkisp1: rsz: change (hv)div only if capture format is YUV Dafna Hirschfeld
2020-04-12 12:05 ` [PATCH v2 4/4] media: staging: rkisp1: cap: enable RGB capture format with YUV media bus Dafna Hirschfeld

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.