Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp869980rwe; Fri, 26 Aug 2022 17:01:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ivqzsdiFa1XTnTHjImCBk+Fccp6uZGVgY5/SMZyhf7bdpOuKVnKiblRklbzwzSUTrMVe2 X-Received: by 2002:a17:90b:1d83:b0:1fb:6795:5cc9 with SMTP id pf3-20020a17090b1d8300b001fb67955cc9mr6925965pjb.162.1661558470767; Fri, 26 Aug 2022 17:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661558470; cv=none; d=google.com; s=arc-20160816; b=B+Ol6Yf+aZhHxxBNgf3rKCuEIKX7LurITOOZ3U0HoyfNq5Z+oJxydSLxQZZcSHYstc WbO26d3puiXKvUc/oC16grOyK8DCsbuAO+T5Vyfqg0qmaOvSLtWnkRqJPI9r8OILd2xR JPrMLjUWYePlyIbSFB7YMugWfqXSl1rX3oPJnuwtK1FxnuhVvRsTr+8OZwI/yEE0P4fA P4eQltyFJid2YcuZ1KG7wszLzXh8MDnUrYWWrlw3KlavdJq+4kqOctTViYYHBCB3LcJe 6xr+o6ttqV3Abnd5mR7TQVZbGUNQTs22j8RDWJVCjE1WUrg9yZubF8PpaSoGrw4g1u1J Gwcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ukbc81al0dpG3nT5Yo2lGIFJZLQ5VBU3mo3suh/KUhs=; b=nZN75v6lIj6qqtj9WZmDt1k3tw1eU50sce+SIjuF20aIXcBi8r7kJON2eOI9pxr1Iv y1OjVnWHcfpbXX+MQFxvzTnZKhkzYk9q+tVUWMpkZ88zVf52At3fkNzjZ/9iL37bUKs6 xlH3Z67i4cGNUBj4Pu/LKjsbWpyLGUK6S4ZL5vrkdNBMjSR2MfLPhqrON8KIXBF7cX7X wat4sbvdq4YIrFqsA5PZ/wX29mO/knGvMTuXO5XiCZQPaT4MP9tju2++fyGdtEnqbh65 U5cOGHnUbOnx88rqVY8cgSvbos9L4hCJTcXBhX5EE9Y9l3i0ZSVZ0ALgRLJsfjDhbAS7 IsQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=eYUKTzF6; 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 u8-20020a170902a60800b00170934fe139si2508907plq.597.2022.08.26.17.00.59; Fri, 26 Aug 2022 17:01:10 -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=eYUKTzF6; 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 S1345319AbiHZWj7 (ORCPT + 99 others); Fri, 26 Aug 2022 18:39:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231216AbiHZWj4 (ORCPT ); Fri, 26 Aug 2022 18:39:56 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D019564C1; Fri, 26 Aug 2022 15:39:53 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D925230B; Sat, 27 Aug 2022 00:39:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1661553592; bh=R8qukP2RffLfxf6EBUyFnNoBjpObxeBRg1U0SiCvU9E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eYUKTzF6QSKxmelG0IGUX5fRApy+oFTa6yaxqckT7jFur3bMN2VPKUHjCfiA1D7Dl s7m6NBji3WfpvsbirYWASI+L4MTJBY7CcsEX7FwALMxXpad6hEN4t2JjLH+Zy5h+Hr W1y03MKpyhsE4sK5Wn/oU4StLWJ8WPIGG+scy2vo= Date: Sat, 27 Aug 2022 01:39:44 +0300 From: Laurent Pinchart To: Paul Kocialkowski Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Hans Verkuil , Maxime Ripard , Thomas Petazzoni Subject: Re: [PATCH v6 5/6] media: sun6i-csi: Detect the availability of the ISP Message-ID: References: <20220826184144.605605-1-paul.kocialkowski@bootlin.com> <20220826184144.605605-6-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220826184144.605605-6-paul.kocialkowski@bootlin.com> 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 Hi Paul, Thank you for the patch. On Fri, Aug 26, 2022 at 08:41:43PM +0200, Paul Kocialkowski wrote: > Add a helper to detect whether the ISP is available and connected > and store the indication in a driver-wide variable. This sounds like it would be a global variable, while it's stored in the driver-specific device structure. > > 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 00521f966cee..b16166cba2ef 100644 > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c > @@ -24,6 +24,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; No need to initialize this to NULL. > + > + /* ISP is not available if disabled in kernel config. */ > + if (!IS_ENABLED(CONFIG_VIDEO_SUN6I_ISP)) > + return 0; Hmmm... The ISP driver may be disabled when compiling the sun6i-csi driver, but later enabled and deployed. Disabling ISP support silently like this could be confusing. Could it be better to move this check after the graph check, and print a warning message in this case ? > + > + /* > + * ISP is not available if not connected via fwnode graph. > + * This weill also check that the remote parent node is available. s/weill/will/ * ISP is not available if not connected via fwnode graph. This will * 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"); You could make that a debug message, it's not crucial information that needs to be printed when the driver is loaded. If you prefer keeping an info message, then I'd move it to the probe function and print that the CSI has been probed, and indicate in that message if the ISP is available. > + csi_dev->isp_available = true; > + > + return 0; > +} > + > /* Media */ > > static const struct media_device_ops sun6i_csi_media_ops = { > @@ -290,6 +319,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 e611bdd6e9b2..8e232cd91ebe 100644 > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h > @@ -21,6 +21,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 { > @@ -44,6 +45,8 @@ struct sun6i_csi_device { > struct clk *clock_mod; > struct clk *clock_ram; > struct reset_control *reset; > + > + bool isp_available; > }; > > struct sun6i_csi_variant { -- Regards, Laurent Pinchart