Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp61412lfe; Fri, 15 Apr 2022 19:33:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXwYL84fJeh5hHmNQNs5XT5gJiUCrBoTtKReG3ln1P2K/BkE5nDqDH7bZAo+3C5pPcwGZz X-Received: by 2002:a63:68c4:0:b0:386:231b:f71c with SMTP id d187-20020a6368c4000000b00386231bf71cmr1415144pgc.208.1650076394082; Fri, 15 Apr 2022 19:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650076394; cv=none; d=google.com; s=arc-20160816; b=fjjoRKxDtN8u2VX3BaAt/cRzRA6IyTOROjWsHcb0YCPRBEhlaCuvs4s6L8bIMTJXWg l07JaGc+5oRNpLOWPCOUyU5YxRj8B6XcITscAbdEoEkzI5Xfx+cEVaL2dQtgNAGCthfL 2L5AlioSCdPUOEPhnGza4Vy6asIVg81PgmYT6+pQJ6cuadOuho9zRAAt5gC3/xURUxI0 nwExPV9ZEbMjR31PsXOvc6z3P5UM9W84L8vixMW4j5GAT1TXX4AvJUymd7wQ1KCMvX6D OwmoHqwtEsdhCYDt7A1oKFo3EtzBElFE5qGne6DMN1HTZziQiC2K81+XiUDNlE6C5gVL g3Ig== 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=eJhdnVljXNxVEUMy4in6EAVIykPxuz30jn1QuT2PjaY=; b=HIZ5zTEnrSy/FtbIkqjdkn4MW+LvaVNJtekVpnz6gfbRnBu7gzGxgHGXiF6cV0bfLm 0CL/w1a/Q/kImfCWamqmFKrafVsJJbDhi2pa6rWFboZ3bXkR0Y4RnjvHyBLmge9+ITR0 5lPV6ReElMFnJEk0w50cgqE4l2AcFU3oCE/+wMEADTSX66/FScqDGGYTbMbGuvE2l4yp LT4Y+BxTe4WSrSF01eFeHoZu1FpTYZiYSDULfuB9IRLbSQG0RvGx24wWoUNM3ZlSkxky PUrxwDaK/9+DDonc91c7nLViiQF1diN0s2vZH3HBpR9Db4ROMRxDDlgOU3jWLW7p79eX 3RFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Zk7yFys2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y9-20020a170902700900b001582fa35afasi2661318plk.190.2022.04.15.19.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:33:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Zk7yFys2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9CC091C93D; Fri, 15 Apr 2022 18:42:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349744AbiDOPeg (ORCPT + 99 others); Fri, 15 Apr 2022 11:34:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355562AbiDOPds (ORCPT ); Fri, 15 Apr 2022 11:33:48 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC4B3D5E8C; Fri, 15 Apr 2022 08:29:11 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 1C01BE0009; Fri, 15 Apr 2022 15:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1650036550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eJhdnVljXNxVEUMy4in6EAVIykPxuz30jn1QuT2PjaY=; b=Zk7yFys2c2BJ9az9iLbgPiy+++XOJFjJ9avanOahl/MwOs13EJRsry5ULsFMWtj0sFPkG3 +X9FEp5q09ETZvrFJaR9tm7kh+Y1fkNjfdkfnvTKYVhhiiCCf3crFCA4lKRbkm6AgjWLJJ zNhciEKHvb1qr1qr74A1QNf97sTEHc39Q9XglU1hC1MSyCLlxod8WbOEfC/trL/AcFIKBy ptrTgc9JWO+r8m3gkqwrpyHx7oAfaSmxcnPi3lsGi5Uxxbe73vy3Y/9aohqC9QsYgl8MFj bPE7bE3/gTQx/Z2QXDRgkCRFbkSl+Cwmvc4edQmgBg5wUzKvV6hcA4BPdjnSOQ== From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Cc: Yong Deng , Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Maxime Ripard , Thomas Petazzoni Subject: [PATCH v4 43/45] media: sun6i-csi: Detect the availability of the ISP Date: Fri, 15 Apr 2022 17:28:09 +0200 Message-Id: <20220415152811.636419-44-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220415152811.636419-1-paul.kocialkowski@bootlin.com> References: <20220415152811.636419-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 a helper to detect whether the ISP is available and connected and store the indication in a driver-wide variable. Signed-off-by: Paul Kocialkowski --- .../platform/sunxi/sun6i-csi/sun6i_csi.c | 33 +++++++++++++++++++ .../platform/sunxi/sun6i-csi/sun6i_csi.h | 3 ++ 2 files changed, 36 insertions(+) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c index a88deb8ba1e7..f185cbd113c7 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c @@ -25,6 +25,35 @@ #include "sun6i_csi_capture.h" #include "sun6i_csi_reg.h" +/* ISP */ + +static bool sun6i_csi_isp_detect(struct sun6i_csi_device *csi_dev) +{ + struct device *dev = csi_dev->dev; + struct fwnode_handle *handle = NULL; + + /* ISP is not available if disabled in kernel config. */ + if (!IS_ENABLED(CONFIG_VIDEO_SUN6I_ISP)) + return 0; + + /* + * ISP is not available if not connected via fwnode graph. + * This weill also check that the remote parent node is available. + */ + handle = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev), + SUN6I_CSI_PORT_ISP, 0, + FWNODE_GRAPH_ENDPOINT_NEXT); + if (!handle) + return 0; + + fwnode_handle_put(handle); + + dev_info(dev, "ISP link is available\n"); + csi_dev->isp_available = true; + + return 0; +} + /* Media */ static const struct media_device_ops sun6i_csi_media_ops = { @@ -306,6 +335,10 @@ static int sun6i_csi_probe(struct platform_device *platform_dev) if (ret) return ret; + ret = sun6i_csi_isp_detect(csi_dev); + if (ret) + goto error_resources; + ret = sun6i_csi_v4l2_setup(csi_dev); if (ret) goto error_resources; diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h index 6aa83dd11684..9b105c341047 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h @@ -22,6 +22,7 @@ enum sun6i_csi_port { SUN6I_CSI_PORT_PARALLEL = 0, SUN6I_CSI_PORT_MIPI_CSI2 = 1, + SUN6I_CSI_PORT_ISP = 2, }; struct sun6i_csi_buffer { @@ -46,6 +47,8 @@ struct sun6i_csi_device { struct clk *clock_mod; struct clk *clock_ram; struct reset_control *reset; + + bool isp_available; }; struct sun6i_csi_variant { -- 2.35.2