Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4444802rdh; Wed, 29 Nov 2023 01:30:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBAr0wwoTYufEDqltR7dE4xBbisy8ji4Nr+CgHhl11SWaBblupZ8L9GhSlt3gvwUboyj1r X-Received: by 2002:a17:902:ea02:b0:1cf:c9c2:5fcb with SMTP id s2-20020a170902ea0200b001cfc9c25fcbmr11648256plg.47.1701250226300; Wed, 29 Nov 2023 01:30:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701250226; cv=none; d=google.com; s=arc-20160816; b=zuRdIw2k3v6NqL2BeZZGCXP0euVK8qn8CmrtFekFz2wcBMUaaep2w1GYwoIEnTzC/g A8hOSsnmKKoFC6jOWRK3r4AjM9tQ6Ew2FbLKgXXgBctpbZr7oN75HZu9wM7nZ0vZlWz8 9j33ngsL6bw1qEa6b5R6lvD5x54GwU4iMPih2JAAoWCk/WL7QkBW6/fFRqYLtWhNtbfT oxFH3hoPVtICDcGKz/SjV2K0KQ9Gx9tYmrvvyDFfD3e+tO507hyNdT4Bfhn3K47jbzD9 lhhr8BJMxQtpD7GfbyvGj39v9k+hbME7HJrjhImE0W813dO5mC1HvShunOSaIJSgIqEL EMdA== 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=ASBYU4Rf4Sh3+HS3ga5IeuS2RCfXT5rS1k5+Nje4Hsc=; fh=9TGZi8GZBh0Z4pe+JUoyBc66OzVUR/Oowb7otIyZbDQ=; b=cUPGVduuCJzl1+ATawV/8wMAQHBM5RB0aCy+hlDO/6/AeSW3JOdg+8fXuNOtIK8sLx 9dRaCdEMo6PLchoM8mZHJFQBfQfyJy4OsVQ/S1uQj2ax70N0D006Nd7yxgP53dwxIWai MaQrrdrE3PKzEaE3WKz1azbbnCl7dGgfE6x0ymi5VQ3GdEnmRL9TOrM7/IEBIblAi9Ju ePAbi04vejDAURAcSMOLnUZ0O5qPEEUtph8IIl7S+k7zBzSW/Xos40Hs1k3Ept/ooKVX TRCpKxajWGMmkLG1Wg6YjnQyVXz79CJuse7m8HrVscKzVGVxcHkpU2EimthcQFLzetGj Bw7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=guI2PODG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n18-20020a170902d2d200b001cfe100a9a6si4690684plc.405.2023.11.29.01.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:30:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=guI2PODG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DE4F180775B2; Wed, 29 Nov 2023 01:30:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231858AbjK2JaG (ORCPT + 99 others); Wed, 29 Nov 2023 04:30:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231286AbjK2J3d (ORCPT ); Wed, 29 Nov 2023 04:29:33 -0500 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 F003A2681; Wed, 29 Nov 2023 01:29:19 -0800 (PST) Received: from pyrite.hamster-moth.ts.net (h175-177-049-135.catv02.itscom.jp [175.177.49.135]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2FE9F89D; Wed, 29 Nov 2023 10:28:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1701250123; bh=hMDTsYVpENkOb/goyZczC7N4lOaLGYZGWPzUfGG6bSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=guI2PODGUgIfKM7luOV9n/G7uIIWwci26E+jIQaEwgx4O3phqlwFHkpILCRN+iBx6 5K0s2oaUFZondTKw6XM+uVe/pc+Oc/kJH320UQjFjkD3kAuessb2Yi7+oLcestA/0a M/B5kaCi6JXVskN4OoPdOFvtXGrz7HutE39Q5psA= From: Paul Elder To: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org Cc: kieran.bingham@ideasonboard.com, tomi.valkeinen@ideasonboard.com, umang.jain@ideasonboard.com, aford173@gmail.com, Paul Elder , Laurent Pinchart , Dafna Hirschfeld , Mauro Carvalho Chehab , Heiko Stuebner , linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 11/11] media: rkisp1: Add UYVY as an output format Date: Wed, 29 Nov 2023 18:27:59 +0900 Message-Id: <20231129092759.242641-12-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231129092759.242641-1-paul.elder@ideasonboard.com> References: <20231129092759.242641-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, T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:30:22 -0800 (PST) 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 Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- .../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 a352893308b6..b50b044d22af 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); @@ -507,6 +534,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.39.2