Hi Stefan, Thank you for the patch. On Thu, Feb 27, 2025 at 12:44:59PM +0100, Stefan Klug wrote: > When color space JPEG is requested, the ISP sets the quantization > incorrectly to limited range. To fix that, set the xfer_func, ycbcr_enc > and quantization to the defaults for the requested color space if they > are not specified explicitly. The commit message fails to explain why you're addressing xfer_func and ycbcr_enc to fix the quantization issue. > Do this only in case we are converting > from RAW to YUV. And this should explain why. > Signed-off-by: Stefan Klug <stefan.klug@xxxxxxxxxxxxxxxx> > --- > .../media/platform/rockchip/rkisp1/rkisp1-isp.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c > index d94917211828..468f5a7d03c7 100644 > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c > @@ -680,10 +680,23 @@ static void rkisp1_isp_set_src_fmt(struct rkisp1_isp *isp, Adding a bit more context: set_csc = format->flags & V4L2_MBUS_FRAMEFMT_SET_CSC; if (set_csc && src_info->pixel_enc == V4L2_PIXEL_ENC_YUV) { If V4L2_MBUS_FRAMEFMT_SET_CSC isn't set, the colorspace fields on the source pad will be copied from the sink pad, which doesn't seem right. It's a separate issue, but fixing both together may lead to better code. > if (sink_info->pixel_enc == V4L2_PIXEL_ENC_BAYER) { > if (format->colorspace != V4L2_COLORSPACE_DEFAULT) > src_fmt->colorspace = format->colorspace; > - if (format->xfer_func != V4L2_XFER_FUNC_DEFAULT) > + > + if (format->xfer_func == V4L2_XFER_FUNC_DEFAULT) Are you sure the condition should be inverted ? > src_fmt->xfer_func = format->xfer_func; > + else > + src_fmt->xfer_func = > + V4L2_MAP_XFER_FUNC_DEFAULT(format->colorspace); > + > if (format->ycbcr_enc != V4L2_YCBCR_ENC_DEFAULT) > src_fmt->ycbcr_enc = format->ycbcr_enc; > + else > + src_fmt->ycbcr_enc = > + V4L2_MAP_YCBCR_ENC_DEFAULT(format->colorspace); > + > + if (format->quantization == V4L2_QUANTIZATION_DEFAULT) > + src_fmt->quantization = > + V4L2_MAP_QUANTIZATION_DEFAULT(false, > + format->colorspace, format->ycbcr_enc); Shouldn't this use src_fmt instead of format ? I think quantization handling could be moved below. > } > > if (format->quantization != V4L2_QUANTIZATION_DEFAULT) -- Regards, Laurent Pinchart