From patchwork Fri Nov 18 09:39:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 22242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp91460wrr; Fri, 18 Nov 2022 01:47:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf70k+lqavgpXGKxn2SqbRLil/Sbvf1wR1RUmyYH4bcEDFeN1xZgXOQH2Y7q7HboON2LJuYP X-Received: by 2002:a17:902:ed8c:b0:186:72bd:371f with SMTP id e12-20020a170902ed8c00b0018672bd371fmr6805184plj.131.1668764827385; Fri, 18 Nov 2022 01:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668764827; cv=none; d=google.com; s=arc-20160816; b=z64Yiwh2rTL2yFLBKUWKgoRdnsu6HSI8gIVUsj+6jyhGrD1Gtv2wdkNzcCHBRoYVOs 2yL7dRayDryHQKQGhZ1IkfSOHbkCvUGC3PMG+5pI/hxv5LRfy5A15XSOMHXXAosqQZsu QbJ1RTSltRin/VwgOSz7DKOBHc8GRA5m3xZSmY4F9jCbyWs5ftW8/zio+/PAoEZg1gs5 wx3N4IJ+cy2uh4VSC+1jShcuDZeCymSHklkOSyTfOjrFYcGih1DBSE030smqJ4pfp0D4 G6wOBZEAdjJWqXVb1cK0tD26Oa1CYdfWGvv0Zcrqn/8ex5UmmxnOyuYX4FdyyG2lHLGp uxtQ== 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=xj0mCwwlKH/Xqoc6rqPLlYcvWNOjT/TLD+73ruKg7g0=; b=UBH6aCLSwBYfQFikeGwvH/zfSAqkDCNJSXhRfBVEh4su1v9ktAalkGe6iLMwvMrlKc EdiX9dYz1J/LOqnMTm/qLTab5xrQWvHu1uTyMjB/9YSArri0LTF1HskBVlIceuSNRRkk XpOI3L0N5zjpo/JYTloK+lCXv+dN0Iydxcg6SD5VKhIGJJoSpRQ/FfjqGGjjcrXSPe/j gE67cf/yBduRhenFVsksPPf6ukn8F6LNcisPJzm4l5dvBLa8JTehw+Cqex9wwZd/ftJy DSCmf2MLHnazOv3strnh35zBxBbsgtSc7ghhyZOwuMe8srH3MjLrWts5ReGl5pL5AkPU ZHpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=YEReXAA3; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne22-20020a17090b375600b00213defacf97si6272492pjb.163.2022.11.18.01.46.54; Fri, 18 Nov 2022 01:47:07 -0800 (PST) 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=YEReXAA3; 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 S241392AbiKRJlx (ORCPT + 99 others); Fri, 18 Nov 2022 04:41:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231534AbiKRJlJ (ORCPT ); Fri, 18 Nov 2022 04:41:09 -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 45DF7942ED; Fri, 18 Nov 2022 01:40:34 -0800 (PST) Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7F0F0CCA; Fri, 18 Nov 2022 10:40:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1668764431; bh=rPo3Gs9GnXlqjb4A0xvmR8+wouEmRjlcCZF2j1gbOsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YEReXAA3sJaQ4DN8Ka4xlIh1Q/ZskhDsEWh9KfpGyWLVi+rXvYVaEAU1yx7/nccAM pGYrpd1iw3+9s55J01o+yIHQPQtXebHp2HOKSgSpN2/rNyFFnpU34ml4DzcvjdIRnH 9Yl39J616EWQwRnL32zqSUzUGKO9EdqwhEYwVagw= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , Dafna Hirschfeld , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Helen Koike , Laurent Pinchart , linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 12/14] media: rkisp1: Support devices without self path Date: Fri, 18 Nov 2022 18:39:29 +0900 Message-Id: <20221118093931.1284465-13-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221118093931.1284465-1-paul.elder@ideasonboard.com> References: <20221118093931.1284465-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749826747408366601?= X-GMAIL-MSGID: =?utf-8?q?1749826747408366601?= Some hardware supported by the rkisp1 driver, such as the ISP in the i.MX8MP, don't have a self path. Add a feature flag for this, and massage the rest of the driver to support the lack of a self path. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- Changes since v2: - Simplify rkisp1_path_count() - Use the rkisp1_has_feature() macro --- .../platform/rockchip/rkisp1/rkisp1-capture.c | 9 ++++++--- .../media/platform/rockchip/rkisp1/rkisp1-common.h | 14 ++++++++++++++ .../media/platform/rockchip/rkisp1/rkisp1-dev.c | 9 ++++++--- .../platform/rockchip/rkisp1/rkisp1-resizer.c | 6 ++++-- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c index 55e863b762e6..94e173706eb4 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c @@ -708,6 +708,7 @@ irqreturn_t rkisp1_capture_isr(int irq, void *ctx) { struct device *dev = ctx; struct rkisp1_device *rkisp1 = dev_get_drvdata(dev); + unsigned int dev_count = rkisp1_path_count(rkisp1); unsigned int i; u32 status; @@ -717,7 +718,7 @@ irqreturn_t rkisp1_capture_isr(int irq, void *ctx) rkisp1_write(rkisp1, RKISP1_CIF_MI_ICR, status); - for (i = 0; i < ARRAY_SIZE(rkisp1->capture_devs); ++i) { + for (i = 0; i < dev_count; ++i) { struct rkisp1_capture *cap = &rkisp1->capture_devs[i]; if (!(status & RKISP1_CIF_MI_FRAME(cap))) @@ -874,6 +875,7 @@ static void rkisp1_cap_stream_enable(struct rkisp1_capture *cap) { struct rkisp1_device *rkisp1 = cap->rkisp1; struct rkisp1_capture *other = &rkisp1->capture_devs[cap->id ^ 1]; + bool has_self_path = rkisp1_has_feature(rkisp1, SELF_PATH); cap->ops->set_data_path(cap); cap->ops->config(cap); @@ -891,7 +893,7 @@ static void rkisp1_cap_stream_enable(struct rkisp1_capture *cap) * This's also required because the second FE maybe corrupt * especially when run at 120fps. */ - if (!other->is_streaming) { + if (!has_self_path || !other->is_streaming) { /* force cfg update */ rkisp1_write(rkisp1, RKISP1_CIF_MI_INIT, RKISP1_CIF_MI_INIT_SOFT_UPD); @@ -1445,10 +1447,11 @@ rkisp1_capture_init(struct rkisp1_device *rkisp1, enum rkisp1_stream_id id) int rkisp1_capture_devs_register(struct rkisp1_device *rkisp1) { + unsigned int dev_count = rkisp1_path_count(rkisp1); unsigned int i; int ret; - for (i = 0; i < ARRAY_SIZE(rkisp1->capture_devs); i++) { + for (i = 0; i < dev_count; i++) { struct rkisp1_capture *cap = &rkisp1->capture_devs[i]; rkisp1_capture_init(rkisp1, i); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index fff5f5264386..8b6c0977ee91 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -118,6 +118,7 @@ enum rkisp1_feature { RKISP1_FEATURE_RSZ_CROP = BIT(2), RKISP1_FEATURE_MAIN_STRIDE = BIT(3), RKISP1_FEATURE_DMA_34BIT = BIT(4), + RKISP1_FEATURE_SELF_PATH = BIT(5), }; #define rkisp1_has_feature(rkisp1, feature) \ @@ -548,6 +549,19 @@ int rkisp1_cap_enum_mbus_codes(struct rkisp1_capture *cap, */ const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_index(unsigned int index); +/* + * rkisp1_path_count - Return the number of paths supported by the device + * + * Some devices only have a main path, while other device have both a main path + * and a self path. This function returns the number of paths that this device + * has, based on the feature flags. It should be used insted of checking + * ARRAY_SIZE of capture_devs/resizer_devs. + */ +static inline unsigned int rkisp1_path_count(struct rkisp1_device *rkisp1) +{ + return rkisp1_has_feature(rkisp1, SELF_PATH) ? 2 : 1; +} + /* * rkisp1_sd_adjust_crop_rect - adjust a rectangle to fit into another rectangle. * diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 2b13962c5c32..8f3001bf7562 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -336,6 +336,7 @@ static const struct dev_pm_ops rkisp1_pm_ops = { static int rkisp1_create_links(struct rkisp1_device *rkisp1) { + unsigned int dev_count = rkisp1_path_count(rkisp1); unsigned int i; int ret; @@ -351,7 +352,7 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1) } /* create ISP->RSZ->CAP links */ - for (i = 0; i < 2; i++) { + for (i = 0; i < dev_count; i++) { struct media_entity *resizer = &rkisp1->resizer_devs[i].sd.entity; struct media_entity *capture = @@ -476,7 +477,8 @@ static const struct rkisp1_info px30_isp_info = { .isr_size = ARRAY_SIZE(px30_isp_isrs), .isp_ver = RKISP1_V12, .features = RKISP1_FEATURE_MIPI_CSI2 - | RKISP1_FEATURE_DUAL_CROP, + | RKISP1_FEATURE_DUAL_CROP + | RKISP1_FEATURE_SELF_PATH, }; static const char * const rk3399_isp_clks[] = { @@ -496,7 +498,8 @@ static const struct rkisp1_info rk3399_isp_info = { .isr_size = ARRAY_SIZE(rk3399_isp_isrs), .isp_ver = RKISP1_V10, .features = RKISP1_FEATURE_MIPI_CSI2 - | RKISP1_FEATURE_DUAL_CROP, + | RKISP1_FEATURE_DUAL_CROP + | RKISP1_FEATURE_SELF_PATH, }; static const char * const imx8mp_isp_clks[] = { diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c index 7ff7b608fc3f..891a622124e2 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c @@ -712,6 +712,7 @@ static int rkisp1_rsz_s_stream(struct v4l2_subdev *sd, int enable) struct rkisp1_device *rkisp1 = rsz->rkisp1; struct rkisp1_capture *other = &rkisp1->capture_devs[rsz->id ^ 1]; enum rkisp1_shadow_regs_when when = RKISP1_SHADOW_REGS_SYNC; + bool has_self_path = rkisp1_has_feature(rkisp1, SELF_PATH); if (!enable) { if (rkisp1_has_feature(rkisp1, DUAL_CROP)) @@ -720,7 +721,7 @@ static int rkisp1_rsz_s_stream(struct v4l2_subdev *sd, int enable) return 0; } - if (other->is_streaming) + if (has_self_path && other->is_streaming) when = RKISP1_SHADOW_REGS_ASYNC; mutex_lock(&rsz->ops_lock); @@ -808,10 +809,11 @@ static int rkisp1_rsz_register(struct rkisp1_resizer *rsz) int rkisp1_resizer_devs_register(struct rkisp1_device *rkisp1) { + unsigned int dev_count = rkisp1_path_count(rkisp1); unsigned int i; int ret; - for (i = 0; i < ARRAY_SIZE(rkisp1->resizer_devs); i++) { + for (i = 0; i < dev_count; i++) { struct rkisp1_resizer *rsz = &rkisp1->resizer_devs[i]; rsz->rkisp1 = rkisp1;