From patchwork Sat Jan 6 16:02:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 185655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp176224dyq; Sat, 6 Jan 2024 08:07:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHFkhxnad0AX3Ul413/k3yIILsNhVVIb8WTfAv1Tbnb8bMfWmxhTfKShgRoXj27BAsRmC4F X-Received: by 2002:a37:c24c:0:b0:783:14c2:5ea with SMTP id j12-20020a37c24c000000b0078314c205eamr726963qkm.121.1704557236710; Sat, 06 Jan 2024 08:07:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704557236; cv=none; d=google.com; s=arc-20160816; b=m0wA46CF+HGjvlii4uiO+f5Uwi+ImfkQkalPQzavBUW0pV4ccKj/UJ6qqDoUITnJ/b yxqkLZIFSnqkgQHzOAt8nrTPkxTYa5Ws/PpTpwkTF8x47Qs/cpan8cDkOi16lkenYcVY IKa+vu1Ayk40Yr6mn1Iwyn9oJ5cg/ZzdYkS9gek/ctS4h91CZDcUAiCV3ZbUkoplUsuX 8W7hgROYphi1fuN5wm6tvabi0O0599fDqSMOdTp55mkYMDz3dlgbkM0YOxV2wYyQzUpH aJzVWBa3bWVikifGkY/5g43CiYPe6UYRg3K0jBwbLUSgi2Jh+Hxu610yyP7U2QqalLXX THrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=f5kqJq29nYgvfChw+Ze4nrXJRpVgH3LMQXIS1i3Q4vs=; fh=umSzPHAeNmSBhpDl7Ba4ElbET6cYzKRFPeRC9WGHErc=; b=o9Ur0ZYwydeHw+frYd/EZ1gjWMae88B85tmsFV4K3fKWc3e85LutTUlrvrzogfPS0r QxLdW63eDEN+QKeZQIKapTMPCGoW8i6CeAPmVwywGvsDh3uLC5f9DRRC1NoR91kNffQD /I3WjL+s7Z4uKoKrqIQ86phoPnVrqm7tzzKWu0hmpEuuxTUHrpldmXSeRc7kn/b7zXXn /Uevi69y1aUvhAmK04GVZH3MjMqhhdiQvNKrLmigrOydm7PazrqrjNur+IdEuCEUmJtx EWw6EtM2Ag4oup8DIPvu5nok6pjGoKXgbol6OZipZNUIfiL1woW+583tvKZqG3gGR/y8 u96Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=lT+g2xwh; spf=pass (google.com: domain of linux-kernel+bounces-18648-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18648-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id pb14-20020a05620a838e00b007811a26404bsi4507308qkn.768.2024.01.06.08.07.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 08:07:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18648-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=lT+g2xwh; spf=pass (google.com: domain of linux-kernel+bounces-18648-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18648-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 801701C218E6 for ; Sat, 6 Jan 2024 16:07:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18D402BB08; Sat, 6 Jan 2024 16:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lT+g2xwh" X-Original-To: linux-kernel@vger.kernel.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F28029421; Sat, 6 Jan 2024 16:03:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from pyrite.hamster-moth.ts.net (unknown [IPv6:2001:268:c203:a8ee:6c57:4243:1eb3:6cb]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 56A4AFF3; Sat, 6 Jan 2024 17:02:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1704556966; bh=W3w09EkUvOHfywGVn/r7PXa9tTVAzXkvkmmno2Wcv6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lT+g2xwh6zEdjQsLbcFI+5g+SCitBGK46NwclV7qTw/RPFIbNpPHoiNNiorD0lTu2 OdF2pJtlmfpb5R1FzvU20L1s/LryqML5BMvtmOa1kZG0xPGlriidqpkQOVBqz6wwHN 7NsoTRAb6bhb+TJykUlRE/Ocpke9le+sY7Ndm6oM= 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 , Alexander Stein , 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 v5 09/10] media: rkisp1: Add YC swap capability Date: Sun, 7 Jan 2024 01:02:20 +0900 Message-Id: <20240106160221.4183409-10-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240106160221.4183409-1-paul.elder@ideasonboard.com> References: <20240106160221.4183409-1-paul.elder@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787357808884527138 X-GMAIL-MSGID: 1787357808884527138 The ISP version in the i.MX8MP has an MI_OUTPUT_ALIGN_FORMAT register that the rk3399 does not have. This register allows swapping bytes, which can be used to implement UYVY from YUYV. Add a feature flag to signify the presence of this feature, and add it to the i.MX8MP match data. Also add it as a flag to the format info in the list of supported formats by the capture v4l2 devices, and update enum_fmt and s_fmt to take it into account. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart Tested-by: Alexander Stein Tested-by: Adam Ford --- .../platform/rockchip/rkisp1/rkisp1-capture.c | 26 ++++++++++++++----- .../platform/rockchip/rkisp1/rkisp1-common.h | 2 ++ .../platform/rockchip/rkisp1/rkisp1-dev.c | 3 ++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c index 1ee7639c42b7..bf63f78dc48c 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c @@ -47,13 +47,15 @@ enum rkisp1_plane { * @fourcc: pixel format * @fmt_type: helper filed for pixel format * @uv_swap: if cb cr swapped, for yuv + * @yc_swap: if y and cb/cr swapped, for yuv * @write_format: defines how YCbCr self picture data is written to memory * @output_format: defines sp output format * @mbus: the mbus code on the src resizer pad that matches the pixel format */ struct rkisp1_capture_fmt_cfg { u32 fourcc; - u8 uv_swap; + u32 uv_swap : 1; + u32 yc_swap : 1; u32 write_format; u32 output_format; u32 mbus; @@ -1162,10 +1164,14 @@ rkisp1_fill_pixfmt(const struct rkisp1_capture *cap, static const struct rkisp1_capture_fmt_cfg * rkisp1_find_fmt_cfg(const struct rkisp1_capture *cap, const u32 pixelfmt) { + bool yc_swap_support = rkisp1_has_feature(cap->rkisp1, MI_OUTPUT_ALIGN); unsigned int i; for (i = 0; i < cap->config->fmt_size; i++) { - if (cap->config->fmts[i].fourcc == pixelfmt) + const struct rkisp1_capture_fmt_cfg *fmt = &cap->config->fmts[i]; + + if (fmt->fourcc == pixelfmt && + (!fmt->yc_swap || yc_swap_support)) return &cap->config->fmts[i]; } return NULL; @@ -1234,23 +1240,29 @@ static int rkisp1_enum_fmt_vid_cap_mplane(struct file *file, void *priv, { struct rkisp1_capture *cap = video_drvdata(file); const struct rkisp1_capture_fmt_cfg *fmt = NULL; + bool yc_swap_support = rkisp1_has_feature(cap->rkisp1, MI_OUTPUT_ALIGN); unsigned int i, n = 0; - if (!f->mbus_code) { - if (f->index >= cap->config->fmt_size) - return -EINVAL; + if (f->index >= cap->config->fmt_size) + return -EINVAL; + if (!f->mbus_code && yc_swap_support) { fmt = &cap->config->fmts[f->index]; f->pixelformat = fmt->fourcc; return 0; } for (i = 0; i < cap->config->fmt_size; i++) { - if (cap->config->fmts[i].mbus != f->mbus_code) + fmt = &cap->config->fmts[i]; + + if (f->mbus_code && fmt->mbus != f->mbus_code) + continue; + + if (!yc_swap_support && fmt->yc_swap) continue; if (n++ == f->index) { - f->pixelformat = cap->config->fmts[i].fourcc; + f->pixelformat = fmt->fourcc; return 0; } } diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index 26573f6ae575..8e2a63ab2cdd 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -115,6 +115,7 @@ enum rkisp1_isp_pad { * @RKISP1_FEATURE_SELF_PATH: The ISP has a self path * @RKISP1_FEATURE_DUAL_CROP: The ISP has the dual crop block at the resizer input * @RKISP1_FEATURE_DMA_34BIT: The ISP uses 34-bit DMA addresses + * @RKISP1_FEATURE_MI_OUTPUT_ALIGN: The ISP has the MI_OUTPUT_ALIGN_FORMAT register * * The ISP features are stored in a bitmask in &rkisp1_info.features and allow * the driver to implement support for features present in some ISP versions @@ -126,6 +127,7 @@ enum rkisp1_feature { RKISP1_FEATURE_SELF_PATH = BIT(2), RKISP1_FEATURE_DUAL_CROP = BIT(3), RKISP1_FEATURE_DMA_34BIT = BIT(4), + RKISP1_FEATURE_MI_OUTPUT_ALIGN = BIT(5), }; #define rkisp1_has_feature(rkisp1, feature) \ diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index fd99355d5fe0..b98909b9473a 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -550,7 +550,8 @@ static const struct rkisp1_info imx8mp_isp_info = { .isr_size = ARRAY_SIZE(imx8mp_isp_isrs), .isp_ver = IMX8MP_V10, .features = RKISP1_FEATURE_MAIN_STRIDE - | RKISP1_FEATURE_DMA_34BIT, + | RKISP1_FEATURE_DMA_34BIT + | RKISP1_FEATURE_MI_OUTPUT_ALIGN, }; static const struct of_device_id rkisp1_of_match[] = {