Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1609222imn; Sun, 31 Jul 2022 14:10:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR7toWox8bMQyrahmEui5qqzHToOdm+eZUDFC8/FLM7nlGFy8J/TK40oRXYoF/WJTp5LiYff X-Received: by 2002:a63:9042:0:b0:41b:b362:157c with SMTP id a63-20020a639042000000b0041bb362157cmr8367442pge.117.1659301838489; Sun, 31 Jul 2022 14:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659301838; cv=none; d=google.com; s=arc-20160816; b=bNPigWAJz/4Wh1C7Ft9F0L0tjTx/IXx+fb4TSPCKdbJphi1JR5fR6fbXVTnXM+clBi ExvpzHvjzCuNAi+LpTGRU0c5OUTv56W31pBqpYmkmLMy5EtjemB5AbclYHscHUwlY8KT q+xUu6b0KPLAoozmEBxFRs/2AeV9sh+MpW8EObruV5dArQ9L2/VnNhU1mcUxNSrupg2p nusF7GiIsGyNJtkOUImQ5Fv7OUDTuGFBLnQy7ve6JwIBXgyhDhR3r3JNpqCOtGX8tG8/ wU6Kwb6VC7yJX96RNhSZzTk//TYZk18cES9bzfSQaTP93UFbJpEHQ9XNv6LyOxTJsw+v sWOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kpHkKVd6abp2oCrKDYiCGKQ1rkD5fGbjsNPGpqL8/OQ=; b=W1vNwl7s5MsW/+OU9AqyqrstJ68D9kJczvocU+fGH37SF2EnG3mfuQRlF+OVxTNlAs 0hTpMu/74U5JR6pg5nNiJjXDO7qmzwM7Exxu4R0I7OKY0yj67xUM2QD6dV18M2vG6SQl 6g6qjuig/F9Q4ZLXw57Pj420yasg2DHQxH/SAuRmRHYmrWPOMfYr2tTcsDt9OtpsuHYz jBwEEtUOoJo17cQrBeRnK/0P0HqJIcvxEjLjLm86AsVwQ/KBvXQF6RXnOLfdTxuKfKNS Uol/nCQK3WYhn7qiQxjNQ90rGBrIT7AQYPf1NvCoCEW+pAoavxVzxKAOo6eTjYrVXiWs XJtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=qRKDl5CW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x6-20020a170902820600b0016eede748f2si1002824pln.191.2022.07.31.14.10.16; Sun, 31 Jul 2022 14:10:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=qRKDl5CW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238380AbiGaUzt (ORCPT + 99 others); Sun, 31 Jul 2022 16:55:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231264AbiGaUzs (ORCPT ); Sun, 31 Jul 2022 16:55:48 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6129263A7; Sun, 31 Jul 2022 13:55:46 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7C36B415; Sun, 31 Jul 2022 22:55:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659300944; bh=z/icKT+ON5rGVjV3cQOF9rm7J26cV7YZ1upIXjkT4Is=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qRKDl5CWFyiu/lIHNsnj8p6f8yxrCWisd92TkIo90hhjXHZ9cgcD74QomFA1mqjby QTdbqeR+0Fp2YQjuIfTWCH20A7n8rXjd5QqGrWcI5w89CC40djiJaNRUlaTPmtCXQo GTfISRFqByInYlhivZpTeheWzV13RAX9PD1PzFWQ= Date: Sun, 31 Jul 2022 23:55:40 +0300 From: Laurent Pinchart To: Paul Elder Cc: linux-media@vger.kernel.org, Dafna Hirschfeld , Mauro Carvalho Chehab , Heiko Stuebner , linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] media: rkisp1: Add UYVY as an output format Message-ID: References: <20220728130505.2077842-1-paul.elder@ideasonboard.com> <20220728130505.2077842-3-paul.elder@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220728130505.2077842-3-paul.elder@ideasonboard.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, Thank you for the patch. On Thu, Jul 28, 2022 at 10:05:05PM +0900, Paul Elder wrote: > Add support for UYVY as an output format. The uv_swap bit in the > MI_XTD_FORMAT_CTRL register that is used for the NV formats does not > work for packed YUV formats. Thus, UYVY support is implemented via > byte-swapping. This method clearly does not work for implementing > support for YVYU and VYUY. > > Signed-off-by: Paul Elder > > --- > Changes in v2: > - s@uv@U/V@ > - SP has been kept (so, uh, *not* changed in v2) > > UYVY for the self path has not been tested because no device supports > it. The rk3399 has a self path, but does not have the > MI_OUTPUT_ALIGN_FORMAT register and thus does not support UYVY. The > i.MX8MP does support UYVY, but does not have a self path. > --- > .../platform/rockchip/rkisp1/rkisp1-capture.c | 41 +++++++++++++++++++ > 1 file changed, 41 insertions(+) > > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c > index 9fb4879e65fa..0d5e3373e1f5 100644 > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c > @@ -97,6 +97,12 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_mp_fmts[] = { > .uv_swap = 0, > .write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT, > .mbus = MEDIA_BUS_FMT_YUYV8_2X8, > + }, { > + .fourcc = V4L2_PIX_FMT_UYVY, > + .uv_swap = 0, > + .yc_swap = 1, > + .write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT, > + .mbus = MEDIA_BUS_FMT_YUYV8_2X8, > }, { > .fourcc = V4L2_PIX_FMT_YUV422P, > .uv_swap = 0, > @@ -231,6 +237,13 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = { > .write_format = RKISP1_MI_CTRL_SP_WRITE_INT, > .output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422, > .mbus = MEDIA_BUS_FMT_YUYV8_2X8, > + }, { > + .fourcc = V4L2_PIX_FMT_UYVY, > + .uv_swap = 0, > + .yc_swap = 1, > + .write_format = RKISP1_MI_CTRL_SP_WRITE_INT, > + .output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422, > + .mbus = MEDIA_BUS_FMT_YUYV8_2X8, > }, { > .fourcc = V4L2_PIX_FMT_YUV422P, > .uv_swap = 0, > @@ -464,6 +477,20 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap) > rkisp1_write(rkisp1, RKISP1_CIF_MI_XTD_FORMAT_CTRL, reg); > } > > + /* > + * U/V swapping with the MI_XTD_FORMAT_CTRL register only works for > + * NV12/NV21 and NV16/NV61, so instead use byte swap to support UYVY. > + * YVYU and VYUY cannot be supported with this method. > + */ > + if (rkisp1->info->features & RKISP1_FEATURE_MI_OUTPUT_ALIGN) { > + reg = rkisp1_read(rkisp1, RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT); > + if (cap->pix.cfg->yc_swap) > + reg |= RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_BYTE_SWAP_BYTES; > + else > + reg &= ~RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_BYTE_SWAP_BYTES; > + rkisp1_write(rkisp1, RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT, reg); > + } I dislike read-modify-write sequences when the register isn't fully initialized to a known value somewhere. This issue applies to other registers too, so we could fix it globally on top. Reviewed-by: Laurent Pinchart > + > rkisp1_mi_config_ctrl(cap); > > reg = rkisp1_read(rkisp1, RKISP1_CIF_MI_CTRL); > @@ -505,6 +532,20 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap) > rkisp1_write(rkisp1, RKISP1_CIF_MI_XTD_FORMAT_CTRL, reg); > } > > + /* > + * U/V swapping with the MI_XTD_FORMAT_CTRL register only works for > + * NV12/NV21 and NV16/NV61, so instead use byte swap to support UYVY. > + * YVYU and VYUY cannot be supported with this method. > + */ > + if (rkisp1->info->features & RKISP1_FEATURE_MI_OUTPUT_ALIGN) { > + reg = rkisp1_read(rkisp1, RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT); > + if (cap->pix.cfg->yc_swap) > + reg |= RKISP1_CIF_OUTPUT_ALIGN_FORMAT_SP_BYTE_SWAP_BYTES; > + else > + reg &= ~RKISP1_CIF_OUTPUT_ALIGN_FORMAT_SP_BYTE_SWAP_BYTES; > + rkisp1_write(rkisp1, RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT, reg); > + } > + > rkisp1_mi_config_ctrl(cap); > > mi_ctrl = rkisp1_read(rkisp1, RKISP1_CIF_MI_CTRL); -- Regards, Laurent Pinchart