Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp467040imn; Thu, 28 Jul 2022 06:19:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uDkqqFMLcYNozTq31+irGfohqI+WpEo8Jfr4j4xqGLx7foPDnbDLDrSBjl7jSViefbfZED X-Received: by 2002:a17:902:d2d1:b0:16c:223e:a3db with SMTP id n17-20020a170902d2d100b0016c223ea3dbmr27033787plc.37.1659014342166; Thu, 28 Jul 2022 06:19:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659014342; cv=none; d=google.com; s=arc-20160816; b=Q6t/j1M72J6bVO0L8kSUY6ymUP1kdvn4J7xZ2rUVTelsXJ7kUjgOEpLGeNioTG085C f2zQvj8eaV1Ba0odFztEvh+afNrrX21OaJebNahXxvVpoc88I5dtUrcMOvXtGEJ4c3aD Zb4DErPMpke1kBh07IFkr4mr37EIn4mlk3qk34PYZPs2DGlsVX1XcqojA4usmBa0Yyy9 +8pwYfZtsoWSo99T/19Nk9qCAI29EpZeoO3akudk5UDv7l+FRcP2szGQvzRw0QwwpLel uaJDO6XhV8Zs7uLR8+5b7c77OPKbtlQZFTX/BO48i0O2Z7HUmf5FlngdBYo+6lDR5OCE 1QsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pznWxJVvM3H9MjXnxSqCzXRRHK2e+nZrzD61KYv2TM8=; b=JwTO94h30+IqqFpE5h2M7NFnc7haNtvK8E/TPPSjq5+dITrryU3eYUNWBZypuivVg9 vzXSBVNWequjR8qAt9aJSr35fhboaeqecb4HeLQjLMCJdB65HocZG5dD7vHnWo8OhUtY HuakuxDZZblH3OLK+sMvdjFwBAVpMGe3cTpPio1/Wc+A7F+ANP1wMB4iJWnFB9xqymoY hogyZyfnx1N4j3qs0nhLuKtcTopiTGSZQKgOCiy/vXm2cHQSapFr+IpnOiF1RDwptMUN FHDz2TJ++k6QHe1ae26GJSQ/1GnzUYAM06WuCgvUAzjw2Fmq3rudUgh94ae0Xm08avk1 I7Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=DMBQ2EPp; 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 l9-20020a056a00140900b005255d5ad6e7si682198pfu.305.2022.07.28.06.18.46; Thu, 28 Jul 2022 06:19:02 -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=DMBQ2EPp; 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 S238894AbiG1NFb (ORCPT + 99 others); Thu, 28 Jul 2022 09:05:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238882AbiG1NF1 (ORCPT ); Thu, 28 Jul 2022 09:05:27 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E9DA2A71E; Thu, 28 Jul 2022 06:05:26 -0700 (PDT) Received: from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 71351929; Thu, 28 Jul 2022 15:05:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659013525; bh=iSS96asCHdlSO5kOO2ha28NMVQwWlmimeQf+T8KhMT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DMBQ2EPpx07tNxWqiwJtzuzpwYoWV36ddz6ouL56rhy2OpG81I026EjpxxABKtgl7 8B4mql2o+A/l5jU2iIGnlnZv8j8T6ES3HhMzw3ju766GPdXaEeQnvjzdwK0hr1Mj9/ 8oopfe8AATOVBiqTlzPaLockp7Se/CsEFeb6ynm4= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , Dafna Hirschfeld , Mauro Carvalho Chehab , Heiko Stuebner , laurent.pinchart@ideasonboard.com, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] media: rkisp1: Add UYVY as an output format Date: Thu, 28 Jul 2022 22:05:05 +0900 Message-Id: <20220728130505.2077842-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220728130505.2077842-1-paul.elder@ideasonboard.com> References: <20220728130505.2077842-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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); + } + 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); -- 2.30.2