Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp445069imw; Thu, 14 Jul 2022 04:36:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uWm6OIeV+eCBvhRvWy8J3wv0IAZcPe9J58DTNuSGXSjkcYbp21AXxte4OvnAyjGiCC0RDz X-Received: by 2002:a63:5a4f:0:b0:412:6081:6cee with SMTP id k15-20020a635a4f000000b0041260816ceemr7158953pgm.246.1657798566682; Thu, 14 Jul 2022 04:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657798566; cv=none; d=google.com; s=arc-20160816; b=AwF71Q6kFo5qRU6l+uVAR4tIbT2AwNiWJrSm8LeTIRaxn6Iq+Hr7OdXNBFj6WJlaRW Lr8ZNMVs/kl89Lid0cHzfpZY/zMWuuIzcnX9OEMUd2rXQWh4pWwV2ZWJKxcMLTYH8ln8 FjAVaW12neE7PhUUeqgMQ8OD+X5uNLIiZBRhH4V3B6nrMayFWZq6FJ8xvtqyMXuawo0x aycJ1Z1UDPfZAeXa1/yZFqC60Gsu2u4lJQHHspLNndMv3HgTTZjBZUJuaiXgAWt3l9BL 4+bKGjoefJ8M8AAtHUbwcO/590qKgKbYCA1jPxS2/t85PVBQASF37gRruIVFcxnC0i1A Eftw== 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=F4v0ltFOIfhWAl96aOqhuM8ZfGTQx53LXqPgQ2tLMxc=; b=M3XJz8Ezk1ermVjo1qzL1sPivUJwZYXxXHk0F9c65mzaL31JJ+af8q9pTHJKctvcdr HyOTahQxaudK6S2sPYHpyUgTzoUCC3Gd0yQLR5/cQqIAIVbDYu81B7uSRTabhHTY5DIR Np59TW9d0kSG3tRUycYQNWJTLegDAFsRmHxLfNCJ7o+Uv2netForLF+8HJdLJX6KsLbl nr3rrHvwzHVEv6N/5UaQY0N99ShGdgZA+oLN9x/a4hW9WK1jmNbfjhwTEfBwssiFUrHx zOFH+1EZmApUR3ok9WIGkCJz64iPRWPHArcYTRsJ431WBqgdvnmL7uQhy2AG2uZtoSnY mgoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=NLHuYk25; 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 o28-20020a635d5c000000b0041203feea99si1539296pgm.238.2022.07.14.04.35.53; Thu, 14 Jul 2022 04:36:06 -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=NLHuYk25; 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 S238787AbiGNL0s (ORCPT + 99 others); Thu, 14 Jul 2022 07:26:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238813AbiGNL0c (ORCPT ); Thu, 14 Jul 2022 07:26:32 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F17D5885A; Thu, 14 Jul 2022 04:26:29 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240121080.bbtec.net [36.240.121.80]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3AEE8A1D; Thu, 14 Jul 2022 13:26:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1657797987; bh=ugkBqo38wIBxdX9iPYWMjbhexB/lDWFHBogAakQ2yC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NLHuYk25JC2deaK7qP+Y/X0e8k3ILzD6SvW40lxguUvUoUy24l4StKtWTF63t4Cjj X8joqb8EDvGblHyzOr4n/A28LY65R6DOonocOlX4S41nAzvZnsm1bRioX6s0v6IgrV Z448zA2rbvZU6LNTIvZ9XykgRoOKOKp9bso1OXAU= 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 1/2] media: rkisp1: Add YC swap capability Date: Thu, 14 Jul 2022 20:26:02 +0900 Message-Id: <20220714112603.1117335-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220714112603.1117335-1-paul.elder@ideasonboard.com> References: <20220714112603.1117335-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 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 --- .../platform/rockchip/rkisp1/rkisp1-capture.c | 27 ++++++++++++++----- .../platform/rockchip/rkisp1/rkisp1-common.h | 1 + .../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 c494afbc21b4..85fd85fe208c 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; @@ -1150,9 +1152,13 @@ static const struct rkisp1_capture_fmt_cfg * rkisp1_find_fmt_cfg(const struct rkisp1_capture *cap, const u32 pixelfmt) { unsigned int i; + bool yc_swap_support = + cap->rkisp1->info->features & RKISP1_FEATURE_MI_OUTPUT_ALIGN; 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; @@ -1223,22 +1229,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; unsigned int i, n = 0; + bool yc_swap_support = + cap->rkisp1->info->features & RKISP1_FEATURE_MI_OUTPUT_ALIGN; - 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 38be565341d6..b0f9221a1922 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -119,6 +119,7 @@ enum rkisp1_feature { RKISP1_FEATURE_MAIN_STRIDE = BIT(3), RKISP1_FEATURE_DMA_34BIT = BIT(4), RKISP1_FEATURE_SELF_PATH = BIT(5), + RKISP1_FEATURE_MI_OUTPUT_ALIGN = BIT(6), }; /* diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 3b549c07a9bb..a475933820fd 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -520,7 +520,8 @@ static const struct rkisp1_info imx8mp_isp_info = { .isp_ver = IMX8MP_V10, .features = RKISP1_FEATURE_RSZ_CROP | 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[] = { -- 2.30.2