Re: [PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-10-23 Thread Rui Miguel Silva
Hi Steve,
On Tue 22 Oct 2019 at 17:26, Steve Longerbeam wrote:
> Hi Laurent, Rui,
>
> Besides field type ANY, the imx7 CSI should probably be dealing with other 
> field
> type conversions as well. I may be mistaken, but like the imx6, the imx7 does
> not have the ability to detect whether a captured field is a top field or a
> bottom field, so it can't support ALTERNATE mode. It should probably capture 
> two
> consecutive fields and in that case and report seq-tb or seq-bt at its output.
> Also the imx6 supports interlacing field lines, if that is the case for imx7 
> it
> should also support converting ALTERNATE to INTERLACED at its output.
>

Yeah, that makes sense to me, I already saw yours csi_try_field
that does something in this lines.

I will try to handle that in imx7 also.

Thanks for your inputs here.

Cheers,
Rui
>
> Steve
>
>
> On 10/22/19 6:34 AM, Rui Miguel Silva wrote:
>> Hi Laurent,
>> On Tue 22 Oct 2019 at 02:44, Laurent Pinchart wrote:
>>> Hi Steve,
>>>
>>> On Tue, May 21, 2019 at 06:03:17PM -0700, Steve Longerbeam wrote:
 Retask imx_media_fill_default_mbus_fields() to try colorimetry parameters,
 renaming it to to imx_media_try_colorimetry(), and call it at both sink and
 source pad try_fmt's. The unrelated check for uninitialized field value is
 moved out to appropriate places in each subdev try_fmt.

 The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both limited
 and full range quantization for both YUV and RGB space, so allow those
 for pipelines that route through the IC.

 Signed-off-by: Steve Longerbeam 
 ---
 Changes in v7:
 - squashed with "media: imx: Allow Rec.709 encoding for IC routes".
 - remove the RGB full-range quantization restriction for IC routes.
 ---
   drivers/staging/media/imx/imx-ic-prp.c  |  6 +-
   drivers/staging/media/imx/imx-ic-prpencvf.c |  8 +--
   drivers/staging/media/imx/imx-media-csi.c   | 19 +++---
   drivers/staging/media/imx/imx-media-utils.c | 73 ++---
   drivers/staging/media/imx/imx-media-vdic.c  |  5 +-
   drivers/staging/media/imx/imx-media.h   |  5 +-
   drivers/staging/media/imx/imx7-media-csi.c  |  8 +--
   7 files changed, 62 insertions(+), 62 deletions(-)

 diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
 b/drivers/staging/media/imx/imx-ic-prp.c
 index 10ffe00f1a54..f87fe0203720 100644
 --- a/drivers/staging/media/imx/imx-ic-prp.c
 +++ b/drivers/staging/media/imx/imx-ic-prp.c
 @@ -193,8 +193,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
sdformat->format.code = cc->codes[0];
}

 -  imx_media_fill_default_mbus_fields(>format, infmt,
 - true);
 +  if (sdformat->format.field == V4L2_FIELD_ANY)
 +  sdformat->format.field = V4L2_FIELD_NONE;
break;
case PRP_SRC_PAD_PRPENC:
case PRP_SRC_PAD_PRPVF:
 @@ -203,6 +203,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
break;
}

 +  imx_media_try_colorimetry(>format, true);
 +
fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
*fmt = sdformat->format;
   out:
 diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
 b/drivers/staging/media/imx/imx-ic-prpencvf.c
 index e8b36a181ccc..f2fe3c11c70e 100644
 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
 +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
 @@ -907,8 +907,6 @@ static void prp_try_fmt(struct prp_priv *priv,
/* propagate colorimetry from sink */
sdformat->format.colorspace = infmt->colorspace;
sdformat->format.xfer_func = infmt->xfer_func;
 -  sdformat->format.quantization = infmt->quantization;
 -  sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
} else {
v4l_bound_align_image(>format.width,
  MIN_W_SINK, MAX_W_SINK, W_ALIGN_SINK,
 @@ -916,9 +914,11 @@ static void prp_try_fmt(struct prp_priv *priv,
  MIN_H_SINK, MAX_H_SINK, H_ALIGN_SINK,
  S_ALIGN);

 -  imx_media_fill_default_mbus_fields(>format, infmt,
 - true);
 +  if (sdformat->format.field == V4L2_FIELD_ANY)
 +  sdformat->format.field = V4L2_FIELD_NONE;
}
 +
 +  imx_media_try_colorimetry(>format, true);
   }

   static int prp_set_fmt(struct v4l2_subdev *sd,
 diff --git a/drivers/staging/media/imx/imx-media-csi.c 
 b/drivers/staging/media/imx/imx-media-csi.c
 index 1d248aca40a9..dce4addadff4 100644
 --- a/drivers/staging/media/imx/imx-media-csi.c
 +++ b/drivers/staging/media/imx/imx-media-csi.c
 @@ -1375,9 

Re: [PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-10-22 Thread Steve Longerbeam

Hi Laurent, Rui,

Besides field type ANY, the imx7 CSI should probably be dealing with 
other field type conversions as well. I may be mistaken, but like the 
imx6, the imx7 does not have the ability to detect whether a captured 
field is a top field or a bottom field, so it can't support ALTERNATE 
mode. It should probably capture two consecutive fields and in that case 
and report seq-tb or seq-bt at its output. Also the imx6 supports 
interlacing field lines, if that is the case for imx7 it should also 
support converting ALTERNATE to INTERLACED at its output.


Steve


On 10/22/19 6:34 AM, Rui Miguel Silva wrote:

Hi Laurent,
On Tue 22 Oct 2019 at 02:44, Laurent Pinchart wrote:

Hi Steve,

On Tue, May 21, 2019 at 06:03:17PM -0700, Steve Longerbeam wrote:

Retask imx_media_fill_default_mbus_fields() to try colorimetry parameters,
renaming it to to imx_media_try_colorimetry(), and call it at both sink and
source pad try_fmt's. The unrelated check for uninitialized field value is
moved out to appropriate places in each subdev try_fmt.

The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both limited
and full range quantization for both YUV and RGB space, so allow those
for pipelines that route through the IC.

Signed-off-by: Steve Longerbeam 
---
Changes in v7:
- squashed with "media: imx: Allow Rec.709 encoding for IC routes".
- remove the RGB full-range quantization restriction for IC routes.
---
  drivers/staging/media/imx/imx-ic-prp.c  |  6 +-
  drivers/staging/media/imx/imx-ic-prpencvf.c |  8 +--
  drivers/staging/media/imx/imx-media-csi.c   | 19 +++---
  drivers/staging/media/imx/imx-media-utils.c | 73 ++---
  drivers/staging/media/imx/imx-media-vdic.c  |  5 +-
  drivers/staging/media/imx/imx-media.h   |  5 +-
  drivers/staging/media/imx/imx7-media-csi.c  |  8 +--
  7 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
b/drivers/staging/media/imx/imx-ic-prp.c
index 10ffe00f1a54..f87fe0203720 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -193,8 +193,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
sdformat->format.code = cc->codes[0];
}

-   imx_media_fill_default_mbus_fields(>format, infmt,
-  true);
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = V4L2_FIELD_NONE;
break;
case PRP_SRC_PAD_PRPENC:
case PRP_SRC_PAD_PRPVF:
@@ -203,6 +203,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
break;
}

+   imx_media_try_colorimetry(>format, true);
+
fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
*fmt = sdformat->format;
  out:
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index e8b36a181ccc..f2fe3c11c70e 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -907,8 +907,6 @@ static void prp_try_fmt(struct prp_priv *priv,
/* propagate colorimetry from sink */
sdformat->format.colorspace = infmt->colorspace;
sdformat->format.xfer_func = infmt->xfer_func;
-   sdformat->format.quantization = infmt->quantization;
-   sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
} else {
v4l_bound_align_image(>format.width,
  MIN_W_SINK, MAX_W_SINK, W_ALIGN_SINK,
@@ -916,9 +914,11 @@ static void prp_try_fmt(struct prp_priv *priv,
  MIN_H_SINK, MAX_H_SINK, H_ALIGN_SINK,
  S_ALIGN);

-   imx_media_fill_default_mbus_fields(>format, infmt,
-  true);
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = V4L2_FIELD_NONE;
}
+
+   imx_media_try_colorimetry(>format, true);
  }

  static int prp_set_fmt(struct v4l2_subdev *sd,
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 1d248aca40a9..dce4addadff4 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1375,9 +1375,15 @@ static void csi_try_field(struct csi_priv *priv,
struct v4l2_mbus_framefmt *infmt =
__csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which);

-   /* no restrictions on sink pad field type */
-   if (sdformat->pad == CSI_SINK_PAD)
+   /*
+* no restrictions on sink pad field type except must
+* be initialized.
+*/
+   if (sdformat->pad == CSI_SINK_PAD) {
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = 

Re: [PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-10-22 Thread Rui Miguel Silva
Hi Laurent,
On Tue 22 Oct 2019 at 02:44, Laurent Pinchart wrote:
> Hi Steve,
>
> On Tue, May 21, 2019 at 06:03:17PM -0700, Steve Longerbeam wrote:
>> Retask imx_media_fill_default_mbus_fields() to try colorimetry parameters,
>> renaming it to to imx_media_try_colorimetry(), and call it at both sink and
>> source pad try_fmt's. The unrelated check for uninitialized field value is
>> moved out to appropriate places in each subdev try_fmt.
>>
>> The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both limited
>> and full range quantization for both YUV and RGB space, so allow those
>> for pipelines that route through the IC.
>>
>> Signed-off-by: Steve Longerbeam 
>> ---
>> Changes in v7:
>> - squashed with "media: imx: Allow Rec.709 encoding for IC routes".
>> - remove the RGB full-range quantization restriction for IC routes.
>> ---
>>  drivers/staging/media/imx/imx-ic-prp.c  |  6 +-
>>  drivers/staging/media/imx/imx-ic-prpencvf.c |  8 +--
>>  drivers/staging/media/imx/imx-media-csi.c   | 19 +++---
>>  drivers/staging/media/imx/imx-media-utils.c | 73 ++---
>>  drivers/staging/media/imx/imx-media-vdic.c  |  5 +-
>>  drivers/staging/media/imx/imx-media.h   |  5 +-
>>  drivers/staging/media/imx/imx7-media-csi.c  |  8 +--
>>  7 files changed, 62 insertions(+), 62 deletions(-)
>>
>> diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
>> b/drivers/staging/media/imx/imx-ic-prp.c
>> index 10ffe00f1a54..f87fe0203720 100644
>> --- a/drivers/staging/media/imx/imx-ic-prp.c
>> +++ b/drivers/staging/media/imx/imx-ic-prp.c
>> @@ -193,8 +193,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>>  sdformat->format.code = cc->codes[0];
>>  }
>>
>> -imx_media_fill_default_mbus_fields(>format, infmt,
>> -   true);
>> +if (sdformat->format.field == V4L2_FIELD_ANY)
>> +sdformat->format.field = V4L2_FIELD_NONE;
>>  break;
>>  case PRP_SRC_PAD_PRPENC:
>>  case PRP_SRC_PAD_PRPVF:
>> @@ -203,6 +203,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>>  break;
>>  }
>>
>> +imx_media_try_colorimetry(>format, true);
>> +
>>  fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
>>  *fmt = sdformat->format;
>>  out:
>> diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
>> b/drivers/staging/media/imx/imx-ic-prpencvf.c
>> index e8b36a181ccc..f2fe3c11c70e 100644
>> --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
>> +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
>> @@ -907,8 +907,6 @@ static void prp_try_fmt(struct prp_priv *priv,
>>  /* propagate colorimetry from sink */
>>  sdformat->format.colorspace = infmt->colorspace;
>>  sdformat->format.xfer_func = infmt->xfer_func;
>> -sdformat->format.quantization = infmt->quantization;
>> -sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
>>  } else {
>>  v4l_bound_align_image(>format.width,
>>MIN_W_SINK, MAX_W_SINK, W_ALIGN_SINK,
>> @@ -916,9 +914,11 @@ static void prp_try_fmt(struct prp_priv *priv,
>>MIN_H_SINK, MAX_H_SINK, H_ALIGN_SINK,
>>S_ALIGN);
>>
>> -imx_media_fill_default_mbus_fields(>format, infmt,
>> -   true);
>> +if (sdformat->format.field == V4L2_FIELD_ANY)
>> +sdformat->format.field = V4L2_FIELD_NONE;
>>  }
>> +
>> +imx_media_try_colorimetry(>format, true);
>>  }
>>
>>  static int prp_set_fmt(struct v4l2_subdev *sd,
>> diff --git a/drivers/staging/media/imx/imx-media-csi.c 
>> b/drivers/staging/media/imx/imx-media-csi.c
>> index 1d248aca40a9..dce4addadff4 100644
>> --- a/drivers/staging/media/imx/imx-media-csi.c
>> +++ b/drivers/staging/media/imx/imx-media-csi.c
>> @@ -1375,9 +1375,15 @@ static void csi_try_field(struct csi_priv *priv,
>>  struct v4l2_mbus_framefmt *infmt =
>>  __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which);
>>
>> -/* no restrictions on sink pad field type */
>> -if (sdformat->pad == CSI_SINK_PAD)
>> +/*
>> + * no restrictions on sink pad field type except must
>> + * be initialized.
>> + */
>> +if (sdformat->pad == CSI_SINK_PAD) {
>> +if (sdformat->format.field == V4L2_FIELD_ANY)
>> +sdformat->format.field = V4L2_FIELD_NONE;
>>  return;
>> +}
>>
>>  switch (infmt->field) {
>>  case V4L2_FIELD_SEQ_TB:
>> @@ -1455,8 +1461,6 @@ static void csi_try_fmt(struct csi_priv *priv,
>>  /* propagate colorimetry from sink */
>>  sdformat->format.colorspace = infmt->colorspace;
>>  sdformat->format.xfer_func = infmt->xfer_func;
>> -sdformat->format.quantization = infmt->quantization;
>> -sdformat->format.ycbcr_enc = 

Re: [PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-10-21 Thread Steve Longerbeam




On 10/21/19 8:26 PM, Steve Longerbeam wrote:

Hi Laurent,

On 10/21/19 6:44 PM, Laurent Pinchart wrote:

Hi Steve,

On Tue, May 21, 2019 at 06:03:17PM -0700, Steve Longerbeam wrote:
Retask imx_media_fill_default_mbus_fields() to try colorimetry 
parameters,
renaming it to to imx_media_try_colorimetry(), and call it at both 
sink and
source pad try_fmt's. The unrelated check for uninitialized field 
value is

moved out to appropriate places in each subdev try_fmt.

The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both 
limited

and full range quantization for both YUV and RGB space, so allow those
for pipelines that route through the IC.

Signed-off-by: Steve Longerbeam 
---
Changes in v7:
- squashed with "media: imx: Allow Rec.709 encoding for IC routes".
- remove the RGB full-range quantization restriction for IC routes.
---
  drivers/staging/media/imx/imx-ic-prp.c  |  6 +-
  drivers/staging/media/imx/imx-ic-prpencvf.c |  8 +--
  drivers/staging/media/imx/imx-media-csi.c   | 19 +++---
  drivers/staging/media/imx/imx-media-utils.c | 73 
++---

  drivers/staging/media/imx/imx-media-vdic.c  |  5 +-
  drivers/staging/media/imx/imx-media.h   |  5 +-
  drivers/staging/media/imx/imx7-media-csi.c  |  8 +--
  7 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
b/drivers/staging/media/imx/imx-ic-prp.c

index 10ffe00f1a54..f87fe0203720 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -193,8 +193,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
  sdformat->format.code = cc->codes[0];
  }
  - imx_media_fill_default_mbus_fields(>format, infmt,
-   true);
+    if (sdformat->format.field == V4L2_FIELD_ANY)
+    sdformat->format.field = V4L2_FIELD_NONE;
  break;
  case PRP_SRC_PAD_PRPENC:
  case PRP_SRC_PAD_PRPVF:
@@ -203,6 +203,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
  break;
  }
  +    imx_media_try_colorimetry(>format, true);
+
  fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
  *fmt = sdformat->format;
  out:
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c

index e8b36a181ccc..f2fe3c11c70e 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -907,8 +907,6 @@ static void prp_try_fmt(struct prp_priv *priv,
  /* propagate colorimetry from sink */
  sdformat->format.colorspace = infmt->colorspace;
  sdformat->format.xfer_func = infmt->xfer_func;
-    sdformat->format.quantization = infmt->quantization;
-    sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
  } else {
v4l_bound_align_image(>format.width,
    MIN_W_SINK, MAX_W_SINK, W_ALIGN_SINK,
@@ -916,9 +914,11 @@ static void prp_try_fmt(struct prp_priv *priv,
    MIN_H_SINK, MAX_H_SINK, H_ALIGN_SINK,
    S_ALIGN);
  - imx_media_fill_default_mbus_fields(>format, infmt,
-   true);
+    if (sdformat->format.field == V4L2_FIELD_ANY)
+    sdformat->format.field = V4L2_FIELD_NONE;
  }
+
+    imx_media_try_colorimetry(>format, true);
  }
    static int prp_set_fmt(struct v4l2_subdev *sd,
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c

index 1d248aca40a9..dce4addadff4 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1375,9 +1375,15 @@ static void csi_try_field(struct csi_priv *priv,
  struct v4l2_mbus_framefmt *infmt =
  __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which);
  -    /* no restrictions on sink pad field type */
-    if (sdformat->pad == CSI_SINK_PAD)
+    /*
+ * no restrictions on sink pad field type except must
+ * be initialized.
+ */
+    if (sdformat->pad == CSI_SINK_PAD) {
+    if (sdformat->format.field == V4L2_FIELD_ANY)
+    sdformat->format.field = V4L2_FIELD_NONE;
  return;
+    }
    switch (infmt->field) {
  case V4L2_FIELD_SEQ_TB:
@@ -1455,8 +1461,6 @@ static void csi_try_fmt(struct csi_priv *priv,
  /* propagate colorimetry from sink */
  sdformat->format.colorspace = infmt->colorspace;
  sdformat->format.xfer_func = infmt->xfer_func;
-    sdformat->format.quantization = infmt->quantization;
-    sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
    break;
  case CSI_SINK_PAD:
@@ -1476,10 +1480,6 @@ static void csi_try_fmt(struct csi_priv *priv,
    csi_try_field(priv, cfg, sdformat);
  -    imx_media_fill_default_mbus_fields(
-    >format, infmt,
-    priv->active_output_pad == CSI_SRC_PAD_DIRECT);
-
  /* Reset crop and compose rectangles */
  crop->left = 0;
  crop->top = 0;
@@ -1495,6 

Re: [PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-10-21 Thread Steve Longerbeam

Hi Laurent,

On 10/21/19 6:44 PM, Laurent Pinchart wrote:

Hi Steve,

On Tue, May 21, 2019 at 06:03:17PM -0700, Steve Longerbeam wrote:

Retask imx_media_fill_default_mbus_fields() to try colorimetry parameters,
renaming it to to imx_media_try_colorimetry(), and call it at both sink and
source pad try_fmt's. The unrelated check for uninitialized field value is
moved out to appropriate places in each subdev try_fmt.

The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both limited
and full range quantization for both YUV and RGB space, so allow those
for pipelines that route through the IC.

Signed-off-by: Steve Longerbeam 
---
Changes in v7:
- squashed with "media: imx: Allow Rec.709 encoding for IC routes".
- remove the RGB full-range quantization restriction for IC routes.
---
  drivers/staging/media/imx/imx-ic-prp.c  |  6 +-
  drivers/staging/media/imx/imx-ic-prpencvf.c |  8 +--
  drivers/staging/media/imx/imx-media-csi.c   | 19 +++---
  drivers/staging/media/imx/imx-media-utils.c | 73 ++---
  drivers/staging/media/imx/imx-media-vdic.c  |  5 +-
  drivers/staging/media/imx/imx-media.h   |  5 +-
  drivers/staging/media/imx/imx7-media-csi.c  |  8 +--
  7 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
b/drivers/staging/media/imx/imx-ic-prp.c
index 10ffe00f1a54..f87fe0203720 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -193,8 +193,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
sdformat->format.code = cc->codes[0];
}
  
-		imx_media_fill_default_mbus_fields(>format, infmt,

-  true);
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = V4L2_FIELD_NONE;
break;
case PRP_SRC_PAD_PRPENC:
case PRP_SRC_PAD_PRPVF:
@@ -203,6 +203,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
break;
}
  
+	imx_media_try_colorimetry(>format, true);

+
fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
*fmt = sdformat->format;
  out:
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index e8b36a181ccc..f2fe3c11c70e 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -907,8 +907,6 @@ static void prp_try_fmt(struct prp_priv *priv,
/* propagate colorimetry from sink */
sdformat->format.colorspace = infmt->colorspace;
sdformat->format.xfer_func = infmt->xfer_func;
-   sdformat->format.quantization = infmt->quantization;
-   sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
} else {
v4l_bound_align_image(>format.width,
  MIN_W_SINK, MAX_W_SINK, W_ALIGN_SINK,
@@ -916,9 +914,11 @@ static void prp_try_fmt(struct prp_priv *priv,
  MIN_H_SINK, MAX_H_SINK, H_ALIGN_SINK,
  S_ALIGN);
  
-		imx_media_fill_default_mbus_fields(>format, infmt,

-  true);
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = V4L2_FIELD_NONE;
}
+
+   imx_media_try_colorimetry(>format, true);
  }
  
  static int prp_set_fmt(struct v4l2_subdev *sd,

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 1d248aca40a9..dce4addadff4 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1375,9 +1375,15 @@ static void csi_try_field(struct csi_priv *priv,
struct v4l2_mbus_framefmt *infmt =
__csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which);
  
-	/* no restrictions on sink pad field type */

-   if (sdformat->pad == CSI_SINK_PAD)
+   /*
+* no restrictions on sink pad field type except must
+* be initialized.
+*/
+   if (sdformat->pad == CSI_SINK_PAD) {
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = V4L2_FIELD_NONE;
return;
+   }
  
  	switch (infmt->field) {

case V4L2_FIELD_SEQ_TB:
@@ -1455,8 +1461,6 @@ static void csi_try_fmt(struct csi_priv *priv,
/* propagate colorimetry from sink */
sdformat->format.colorspace = infmt->colorspace;
sdformat->format.xfer_func = infmt->xfer_func;
-   sdformat->format.quantization = infmt->quantization;
-   sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
  
  		break;

case CSI_SINK_PAD:
@@ -1476,10 +1480,6 @@ static void csi_try_fmt(struct csi_priv *priv,
  
  		csi_try_field(priv, cfg, sdformat);
  
-		

Re: [PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-10-21 Thread Laurent Pinchart
Hi Steve,

On Tue, May 21, 2019 at 06:03:17PM -0700, Steve Longerbeam wrote:
> Retask imx_media_fill_default_mbus_fields() to try colorimetry parameters,
> renaming it to to imx_media_try_colorimetry(), and call it at both sink and
> source pad try_fmt's. The unrelated check for uninitialized field value is
> moved out to appropriate places in each subdev try_fmt.
> 
> The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both limited
> and full range quantization for both YUV and RGB space, so allow those
> for pipelines that route through the IC.
> 
> Signed-off-by: Steve Longerbeam 
> ---
> Changes in v7:
> - squashed with "media: imx: Allow Rec.709 encoding for IC routes".
> - remove the RGB full-range quantization restriction for IC routes.
> ---
>  drivers/staging/media/imx/imx-ic-prp.c  |  6 +-
>  drivers/staging/media/imx/imx-ic-prpencvf.c |  8 +--
>  drivers/staging/media/imx/imx-media-csi.c   | 19 +++---
>  drivers/staging/media/imx/imx-media-utils.c | 73 ++---
>  drivers/staging/media/imx/imx-media-vdic.c  |  5 +-
>  drivers/staging/media/imx/imx-media.h   |  5 +-
>  drivers/staging/media/imx/imx7-media-csi.c  |  8 +--
>  7 files changed, 62 insertions(+), 62 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
> b/drivers/staging/media/imx/imx-ic-prp.c
> index 10ffe00f1a54..f87fe0203720 100644
> --- a/drivers/staging/media/imx/imx-ic-prp.c
> +++ b/drivers/staging/media/imx/imx-ic-prp.c
> @@ -193,8 +193,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>   sdformat->format.code = cc->codes[0];
>   }
>  
> - imx_media_fill_default_mbus_fields(>format, infmt,
> -true);
> + if (sdformat->format.field == V4L2_FIELD_ANY)
> + sdformat->format.field = V4L2_FIELD_NONE;
>   break;
>   case PRP_SRC_PAD_PRPENC:
>   case PRP_SRC_PAD_PRPVF:
> @@ -203,6 +203,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>   break;
>   }
>  
> + imx_media_try_colorimetry(>format, true);
> +
>   fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
>   *fmt = sdformat->format;
>  out:
> diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
> b/drivers/staging/media/imx/imx-ic-prpencvf.c
> index e8b36a181ccc..f2fe3c11c70e 100644
> --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
> +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
> @@ -907,8 +907,6 @@ static void prp_try_fmt(struct prp_priv *priv,
>   /* propagate colorimetry from sink */
>   sdformat->format.colorspace = infmt->colorspace;
>   sdformat->format.xfer_func = infmt->xfer_func;
> - sdformat->format.quantization = infmt->quantization;
> - sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
>   } else {
>   v4l_bound_align_image(>format.width,
> MIN_W_SINK, MAX_W_SINK, W_ALIGN_SINK,
> @@ -916,9 +914,11 @@ static void prp_try_fmt(struct prp_priv *priv,
> MIN_H_SINK, MAX_H_SINK, H_ALIGN_SINK,
> S_ALIGN);
>  
> - imx_media_fill_default_mbus_fields(>format, infmt,
> -true);
> + if (sdformat->format.field == V4L2_FIELD_ANY)
> + sdformat->format.field = V4L2_FIELD_NONE;
>   }
> +
> + imx_media_try_colorimetry(>format, true);
>  }
>  
>  static int prp_set_fmt(struct v4l2_subdev *sd,
> diff --git a/drivers/staging/media/imx/imx-media-csi.c 
> b/drivers/staging/media/imx/imx-media-csi.c
> index 1d248aca40a9..dce4addadff4 100644
> --- a/drivers/staging/media/imx/imx-media-csi.c
> +++ b/drivers/staging/media/imx/imx-media-csi.c
> @@ -1375,9 +1375,15 @@ static void csi_try_field(struct csi_priv *priv,
>   struct v4l2_mbus_framefmt *infmt =
>   __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which);
>  
> - /* no restrictions on sink pad field type */
> - if (sdformat->pad == CSI_SINK_PAD)
> + /*
> +  * no restrictions on sink pad field type except must
> +  * be initialized.
> +  */
> + if (sdformat->pad == CSI_SINK_PAD) {
> + if (sdformat->format.field == V4L2_FIELD_ANY)
> + sdformat->format.field = V4L2_FIELD_NONE;
>   return;
> + }
>  
>   switch (infmt->field) {
>   case V4L2_FIELD_SEQ_TB:
> @@ -1455,8 +1461,6 @@ static void csi_try_fmt(struct csi_priv *priv,
>   /* propagate colorimetry from sink */
>   sdformat->format.colorspace = infmt->colorspace;
>   sdformat->format.xfer_func = infmt->xfer_func;
> - sdformat->format.quantization = infmt->quantization;
> - sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
>  
>   break;
>   case CSI_SINK_PAD:
> @@ -1476,10 +1480,6 @@ static void 

Re: [PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-06-14 Thread Philipp Zabel
Hi Steve,

On Tue, 2019-05-21 at 18:03 -0700, Steve Longerbeam wrote:
> Retask imx_media_fill_default_mbus_fields() to try colorimetry parameters,
> renaming it to to imx_media_try_colorimetry(), and call it at both sink and
> source pad try_fmt's. The unrelated check for uninitialized field value is
> moved out to appropriate places in each subdev try_fmt.
> 
> The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both limited
> and full range quantization for both YUV and RGB space, so allow those
> for pipelines that route through the IC.
> 
> Signed-off-by: Steve Longerbeam 

I've applied them on the imx-drm/next branch with Hans' Acked-by on 5/5.

regards
Philipp


Re: [PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-05-27 Thread Hans Verkuil
On 5/22/19 3:03 AM, Steve Longerbeam wrote:
> Retask imx_media_fill_default_mbus_fields() to try colorimetry parameters,
> renaming it to to imx_media_try_colorimetry(), and call it at both sink and
> source pad try_fmt's. The unrelated check for uninitialized field value is
> moved out to appropriate places in each subdev try_fmt.
> 
> The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both limited
> and full range quantization for both YUV and RGB space, so allow those
> for pipelines that route through the IC.
> 
> Signed-off-by: Steve Longerbeam 

Acked-by: Hans Verkuil 

It's probably easiest to apply this whole series to the gpu subsystem.
You have my Acked-by for this media patch.

Regards,

Hans

> ---
> Changes in v7:
> - squashed with "media: imx: Allow Rec.709 encoding for IC routes".
> - remove the RGB full-range quantization restriction for IC routes.
> ---
>  drivers/staging/media/imx/imx-ic-prp.c  |  6 +-
>  drivers/staging/media/imx/imx-ic-prpencvf.c |  8 +--
>  drivers/staging/media/imx/imx-media-csi.c   | 19 +++---
>  drivers/staging/media/imx/imx-media-utils.c | 73 ++---
>  drivers/staging/media/imx/imx-media-vdic.c  |  5 +-
>  drivers/staging/media/imx/imx-media.h   |  5 +-
>  drivers/staging/media/imx/imx7-media-csi.c  |  8 +--
>  7 files changed, 62 insertions(+), 62 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
> b/drivers/staging/media/imx/imx-ic-prp.c
> index 10ffe00f1a54..f87fe0203720 100644
> --- a/drivers/staging/media/imx/imx-ic-prp.c
> +++ b/drivers/staging/media/imx/imx-ic-prp.c
> @@ -193,8 +193,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>   sdformat->format.code = cc->codes[0];
>   }
>  
> - imx_media_fill_default_mbus_fields(>format, infmt,
> -true);
> + if (sdformat->format.field == V4L2_FIELD_ANY)
> + sdformat->format.field = V4L2_FIELD_NONE;
>   break;
>   case PRP_SRC_PAD_PRPENC:
>   case PRP_SRC_PAD_PRPVF:
> @@ -203,6 +203,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
>   break;
>   }
>  
> + imx_media_try_colorimetry(>format, true);
> +
>   fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
>   *fmt = sdformat->format;
>  out:
> diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
> b/drivers/staging/media/imx/imx-ic-prpencvf.c
> index e8b36a181ccc..f2fe3c11c70e 100644
> --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
> +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
> @@ -907,8 +907,6 @@ static void prp_try_fmt(struct prp_priv *priv,
>   /* propagate colorimetry from sink */
>   sdformat->format.colorspace = infmt->colorspace;
>   sdformat->format.xfer_func = infmt->xfer_func;
> - sdformat->format.quantization = infmt->quantization;
> - sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
>   } else {
>   v4l_bound_align_image(>format.width,
> MIN_W_SINK, MAX_W_SINK, W_ALIGN_SINK,
> @@ -916,9 +914,11 @@ static void prp_try_fmt(struct prp_priv *priv,
> MIN_H_SINK, MAX_H_SINK, H_ALIGN_SINK,
> S_ALIGN);
>  
> - imx_media_fill_default_mbus_fields(>format, infmt,
> -true);
> + if (sdformat->format.field == V4L2_FIELD_ANY)
> + sdformat->format.field = V4L2_FIELD_NONE;
>   }
> +
> + imx_media_try_colorimetry(>format, true);
>  }
>  
>  static int prp_set_fmt(struct v4l2_subdev *sd,
> diff --git a/drivers/staging/media/imx/imx-media-csi.c 
> b/drivers/staging/media/imx/imx-media-csi.c
> index 1d248aca40a9..dce4addadff4 100644
> --- a/drivers/staging/media/imx/imx-media-csi.c
> +++ b/drivers/staging/media/imx/imx-media-csi.c
> @@ -1375,9 +1375,15 @@ static void csi_try_field(struct csi_priv *priv,
>   struct v4l2_mbus_framefmt *infmt =
>   __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which);
>  
> - /* no restrictions on sink pad field type */
> - if (sdformat->pad == CSI_SINK_PAD)
> + /*
> +  * no restrictions on sink pad field type except must
> +  * be initialized.
> +  */
> + if (sdformat->pad == CSI_SINK_PAD) {
> + if (sdformat->format.field == V4L2_FIELD_ANY)
> + sdformat->format.field = V4L2_FIELD_NONE;
>   return;
> + }
>  
>   switch (infmt->field) {
>   case V4L2_FIELD_SEQ_TB:
> @@ -1455,8 +1461,6 @@ static void csi_try_fmt(struct csi_priv *priv,
>   /* propagate colorimetry from sink */
>   sdformat->format.colorspace = infmt->colorspace;
>   sdformat->format.xfer_func = infmt->xfer_func;
> - sdformat->format.quantization = infmt->quantization;
> - 

[PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-05-21 Thread Steve Longerbeam
Retask imx_media_fill_default_mbus_fields() to try colorimetry parameters,
renaming it to to imx_media_try_colorimetry(), and call it at both sink and
source pad try_fmt's. The unrelated check for uninitialized field value is
moved out to appropriate places in each subdev try_fmt.

The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both limited
and full range quantization for both YUV and RGB space, so allow those
for pipelines that route through the IC.

Signed-off-by: Steve Longerbeam 
---
Changes in v7:
- squashed with "media: imx: Allow Rec.709 encoding for IC routes".
- remove the RGB full-range quantization restriction for IC routes.
---
 drivers/staging/media/imx/imx-ic-prp.c  |  6 +-
 drivers/staging/media/imx/imx-ic-prpencvf.c |  8 +--
 drivers/staging/media/imx/imx-media-csi.c   | 19 +++---
 drivers/staging/media/imx/imx-media-utils.c | 73 ++---
 drivers/staging/media/imx/imx-media-vdic.c  |  5 +-
 drivers/staging/media/imx/imx-media.h   |  5 +-
 drivers/staging/media/imx/imx7-media-csi.c  |  8 +--
 7 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
b/drivers/staging/media/imx/imx-ic-prp.c
index 10ffe00f1a54..f87fe0203720 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -193,8 +193,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
sdformat->format.code = cc->codes[0];
}
 
-   imx_media_fill_default_mbus_fields(>format, infmt,
-  true);
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = V4L2_FIELD_NONE;
break;
case PRP_SRC_PAD_PRPENC:
case PRP_SRC_PAD_PRPVF:
@@ -203,6 +203,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
break;
}
 
+   imx_media_try_colorimetry(>format, true);
+
fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
*fmt = sdformat->format;
 out:
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index e8b36a181ccc..f2fe3c11c70e 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -907,8 +907,6 @@ static void prp_try_fmt(struct prp_priv *priv,
/* propagate colorimetry from sink */
sdformat->format.colorspace = infmt->colorspace;
sdformat->format.xfer_func = infmt->xfer_func;
-   sdformat->format.quantization = infmt->quantization;
-   sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
} else {
v4l_bound_align_image(>format.width,
  MIN_W_SINK, MAX_W_SINK, W_ALIGN_SINK,
@@ -916,9 +914,11 @@ static void prp_try_fmt(struct prp_priv *priv,
  MIN_H_SINK, MAX_H_SINK, H_ALIGN_SINK,
  S_ALIGN);
 
-   imx_media_fill_default_mbus_fields(>format, infmt,
-  true);
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = V4L2_FIELD_NONE;
}
+
+   imx_media_try_colorimetry(>format, true);
 }
 
 static int prp_set_fmt(struct v4l2_subdev *sd,
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 1d248aca40a9..dce4addadff4 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1375,9 +1375,15 @@ static void csi_try_field(struct csi_priv *priv,
struct v4l2_mbus_framefmt *infmt =
__csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which);
 
-   /* no restrictions on sink pad field type */
-   if (sdformat->pad == CSI_SINK_PAD)
+   /*
+* no restrictions on sink pad field type except must
+* be initialized.
+*/
+   if (sdformat->pad == CSI_SINK_PAD) {
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = V4L2_FIELD_NONE;
return;
+   }
 
switch (infmt->field) {
case V4L2_FIELD_SEQ_TB:
@@ -1455,8 +1461,6 @@ static void csi_try_fmt(struct csi_priv *priv,
/* propagate colorimetry from sink */
sdformat->format.colorspace = infmt->colorspace;
sdformat->format.xfer_func = infmt->xfer_func;
-   sdformat->format.quantization = infmt->quantization;
-   sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
 
break;
case CSI_SINK_PAD:
@@ -1476,10 +1480,6 @@ static void csi_try_fmt(struct csi_priv *priv,
 
csi_try_field(priv, cfg, sdformat);
 
-   imx_media_fill_default_mbus_fields(
-   >format, infmt,
-