Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp535768imn; Thu, 28 Jul 2022 08:11:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uhrvRb+A7Gl/aG0/O7ckm7EsVwh8rAIGpchOJiArj3YGpgflLMXls4kBjBpG+TIVK2jX7Z X-Received: by 2002:a17:902:d4ca:b0:16d:c3ba:cd4d with SMTP id o10-20020a170902d4ca00b0016dc3bacd4dmr3305837plg.142.1659021094750; Thu, 28 Jul 2022 08:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659021094; cv=none; d=google.com; s=arc-20160816; b=FM5xCTMKHL1sGj49w16qfatX9DCxKBnNW/FuT0WGQoo+kKpBx/oJuVWZvYgrtd8/dy kGxPgs1MWnALD6Clckcq0uKWjcrjTLobr8MwLt0cOJrtLx9VMZoMT3JCnjftxD6n8PWy KjrTh7rc2W+5qPUAjVyMzI4qZ8+U9AQJGqcr4p2GWYP5VrGOXO/H78yTPRwkjGcCPgf2 8qG6zBirLhSHJk0GQsSVhBMcpXhs5hXvQ/PBdCKsS0PtPc4em1vwqrzm9fmhqcXl8Usy 2AUBa+NprHQXvs772EXBi1vnWxiPv7tSApuO3NW81PUxPRbrs+i4F+juvSfcwMLCSION 2/Qw== 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=LTACp+8q+0Z06Gy0gErnoIH5sE2U0d21qaAKCALgktc=; b=LcZ+2MBrFspmq2ygJwEJU4PxsAeFxHGu8PAGnjYpyreAsXpudFerR5TjtgPlmTnGdE kcmY8UdhBVU7oVzpZQx9sokwcLWY0bo5ZEg4R5m5mmaOtwF6TgClmMcfZxUniozpVlKb 1WqWPyYZEwzqkgFdAgJhK/0iYy5nCQI9Y3IJLQbJFKXa2bFzuAgzqdLRRNmtIjA3rcnQ li24UvyxjwQM8ort4p7ZWGFhkn905w5b4VvBXV8S/k2KiT+8SuSw2kkd6fjLXMX8dD0t LQ5cZ0DFd2bPGuK4g1fWkzkNgzGVCatfy7Q6JugLfLYP0hGe+T8KmYqvDQZq7zXn7vlT F63Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=ZdxDrewP; 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 w13-20020a17090a1b8d00b001e3022c3e0bsi5105909pjc.30.2022.07.28.08.11.19; Thu, 28 Jul 2022 08:11:34 -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=ZdxDrewP; 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 S231500AbiG1OUV (ORCPT + 99 others); Thu, 28 Jul 2022 10:20:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbiG1OUT (ORCPT ); Thu, 28 Jul 2022 10:20:19 -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 C61FFCFF; Thu, 28 Jul 2022 07:20:18 -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 3F76B56D; Thu, 28 Jul 2022 16:20:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659018016; bh=q2BB39MP0tZQIZRXCzJWG56ZohL9stJRt4VHYJFO6jI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZdxDrewPgpInaF+/7uxPx56GKvm1lJ9F8meoFeXq4J7bQBXB7t8kpFLE/IGm6bKUx bUA5e4m0I2FcgWDEZ/LA1AFzIAMjQAiYhb1iSWxQBMUHS503HkRXj9bvVTItANOGX2 TtGyE9q2UGlzqYgGlSxfCffkO0t1Wvi+XtARQiYE= Date: Thu, 28 Jul 2022 17:20:13 +0300 From: Laurent Pinchart To: paul.elder@ideasonboard.com 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 2/2] media: rkisp1: Add UYVY as an output format Message-ID: References: <20220714112603.1117335-1-paul.elder@ideasonboard.com> <20220714112603.1117335-3-paul.elder@ideasonboard.com> <20220728125259.GL3984498@pyrite.rasen.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220728125259.GL3984498@pyrite.rasen.tech> 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, On Thu, Jul 28, 2022 at 09:52:59PM +0900, paul.elder@ideasonboard.com wrote: > On Wed, Jul 20, 2022 at 01:29:57AM +0300, Laurent Pinchart wrote: > > On Thu, Jul 14, 2022 at 08:26:03PM +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 > > > > > > --- > > > 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. > > > > I'm tempted to drop it then, as the code below isn't correct given that > > you use the same register for both MP and SP. Let's address MP only for > > now. > > The same register is used for both MP and SP. They just have different > bits. Which is why we'd need the read-write cycle, assuming that there > exists a device that has both an SP and the MI_OUTPUT_ALIGN_FORMAT > register. Indeed, I had missed that. The documentation is confusing, the register is described as "Output align format for main path", has both mp_byte_swap and sp_byte_swap, but no sp equivalent to mp_lsb_alignment (maybe the self path doesn't support raw outputs though ?). I'm OK keeping support for both paths, but I think the MI_OUTPUT_ALIGN_FORMAT register should then be initialized to a default value somewhere. > > > --- > > > .../platform/rockchip/rkisp1/rkisp1-capture.c | 40 +++++++++++++++++++ > > > 1 file changed, 40 insertions(+) > > > > > > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c > > > index 85fd85fe208c..77496ccef7ec 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); > > > } > > > > > > + /* > > > + * uv swapping with the MI_XTD_FORMAT_CTRL register only works for > > > > s@uv@U/V@ > > > > > + * 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); > > > > As the register is not initialized anywhere, it would be better to write > > it fully here instead of a read-modify-write cycle. Same comments below. > > > > > + } > > > + > > > rkisp1_mi_config_ctrl(cap); > > > > > > reg = rkisp1_read(rkisp1, RKISP1_CIF_MI_CTRL); > > > @@ -505,6 +532,19 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap) > > > rkisp1_write(rkisp1, RKISP1_CIF_MI_XTD_FORMAT_CTRL, reg); > > > } > > > > > > + /* > > > + * uv 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); > > > + } > > > > Missing blank line. > > > > Reviewed-by: Laurent Pinchart > > > > > rkisp1_mi_config_ctrl(cap); > > > > > > mi_ctrl = rkisp1_read(rkisp1, RKISP1_CIF_MI_CTRL); -- Regards, Laurent Pinchart