Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1540410ybk; Sat, 16 May 2020 14:52:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ6ZrTau5qGtUM1uJ1uB3mx0gJUDeId2QrSp91pkk4hEQmrQ3nvdTCUHY1NgBppzpaDmYF X-Received: by 2002:a05:6402:a48:: with SMTP id bt8mr8463770edb.197.1589665977928; Sat, 16 May 2020 14:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589665977; cv=none; d=google.com; s=arc-20160816; b=IuZUwkSt3BSg+Y00+B3ef58fR0AX7i5keNL77rOrZGOfsC0vZd2+I4dWDZg+i8dFXW YL6LB8LtNaND2F0dGLhuDuZn6c3sRpqtishszet6KWK7tXqhIbsfGnPnxnygtfm6rtNg +ILVcenbmMDILAK3BBG/0q/+tJA82gj/0lo7HLNdTJrv+hSgJufxbBIZezQ7WoMxb7PQ XT4aem4DvKmmfyG5oQ2A81i/85b5ef3jzVo2D5zz38LIavi3Sdi7o1UmW1TULNYxkdUn xYLjoZ2MGXytsnjhMRC+niWey37rrAOPvo+jJJ3MBcOT1HVKT34GNN1f6fZ6FpDWnM6Y Vk0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=wzq4F5/TTimACs1e0WlctF4OEUJhpzsIGkVZ8qgEqjw=; b=HYdMglxF7d+QIVyhWjs/+K+Wo49LKAYAvtNPxm0Qy4Wa7lCZU3gFWWheKCmvB3dJFY 9kykaVwPXGgkWEphwMZ5wMd/vFldRZuKaa70pXOkWLyvIoWExFTTHS4DK69Le2cSwU52 s6kTD6xIq7ZS+qI9zx0qn8pkQhlkJfLsUC1gepPd0g0d//66aVpbDCQIPZATiXFK3v3L wEFeTeTSwDiBt1TF1jH8XSQjCOj33y+UN8JSdo04yxM6bXCvooRKh6cfO8L2YunIwFHy V52zORYTg2+ocVdDf92Nx8cq+B08YhKcNvM8ocOa9pWhrq9AjpDIgW9oMnBTZBMDmJE5 LKsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p24si3605840edi.428.2020.05.16.14.52.34; Sat, 16 May 2020 14:52:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbgEPVvL (ORCPT + 99 others); Sat, 16 May 2020 17:51:11 -0400 Received: from retiisi.org.uk ([95.216.213.190]:54420 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726668AbgEPVvL (ORCPT ); Sat, 16 May 2020 17:51:11 -0400 Received: from valkosipuli.localdomain (valkosipuli.retiisi.org.uk [IPv6:2a01:4f9:c010:4572::80:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by hillosipuli.retiisi.org.uk (Postfix) with ESMTPS id 5153E634C87; Sun, 17 May 2020 00:51:03 +0300 (EEST) Received: from sailus by valkosipuli.localdomain with local (Exim 4.92) (envelope-from ) id 1ja4hz-0000O6-9a; Sun, 17 May 2020 00:51:03 +0300 Date: Sun, 17 May 2020 00:51:03 +0300 From: Sakari Ailus To: Kieran Bingham Cc: linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Kieran Bingham , Laurent Pinchart , Jacopo Mondi , Niklas =?iso-8859-1?Q?S=F6derlund?= , Hans Verkuil , Hyun Kwon , Manivannan Sadhasivam , Rob Herring , Jacopo Mondi , Laurent Pinchart , Niklas =?iso-8859-1?Q?S=F6derlund?= Subject: Re: [PATCH v9 2/4] media: i2c: Add MAX9286 driver Message-ID: <20200516215103.GA857@valkosipuli.retiisi.org.uk> References: <20200512155105.1068064-1-kieran.bingham+renesas@ideasonboard.com> <20200512155105.1068064-3-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200512155105.1068064-3-kieran.bingham+renesas@ideasonboard.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kieran, Thanks for the update. On Tue, May 12, 2020 at 04:51:03PM +0100, Kieran Bingham wrote: ... > +static int max9286_enum_mbus_code(struct v4l2_subdev *sd, > + struct v4l2_subdev_pad_config *cfg, > + struct v4l2_subdev_mbus_code_enum *code) > +{ > + if (code->pad || code->index > 0) > + return -EINVAL; > + > + code->code = MEDIA_BUS_FMT_UYVY8_2X8; Why UYVY8_2X8 and not UYVY8_1X16? In general, the single sample / pixel variant of the format is generally used on the serial busses. This choice was made when serial busses were introduced. > + > + return 0; > +} > + > +static struct v4l2_mbus_framefmt * > +max9286_get_pad_format(struct max9286_priv *priv, > + struct v4l2_subdev_pad_config *cfg, > + unsigned int pad, u32 which) > +{ > + switch (which) { > + case V4L2_SUBDEV_FORMAT_TRY: > + return v4l2_subdev_get_try_format(&priv->sd, cfg, pad); > + case V4L2_SUBDEV_FORMAT_ACTIVE: > + return &priv->fmt[pad]; > + default: > + return NULL; > + } > +} > + > +static int max9286_set_fmt(struct v4l2_subdev *sd, > + struct v4l2_subdev_pad_config *cfg, > + struct v4l2_subdev_format *format) > +{ > + struct max9286_priv *priv = sd_to_max9286(sd); > + struct v4l2_mbus_framefmt *cfg_fmt; > + > + if (format->pad >= MAX9286_SRC_PAD) > + return -EINVAL; You can remove these checks; it's been already done by the caller. ... > +static int max9286_parse_dt(struct max9286_priv *priv) > +{ > + struct device *dev = &priv->client->dev; > + struct device_node *i2c_mux; > + struct device_node *node = NULL; > + unsigned int i2c_mux_mask = 0; > + > + of_node_get(dev->of_node); > + i2c_mux = of_find_node_by_name(dev->of_node, "i2c-mux"); > + if (!i2c_mux) { > + dev_err(dev, "Failed to find i2c-mux node\n"); > + of_node_put(dev->of_node); > + return -EINVAL; > + } > + > + /* Identify which i2c-mux channels are enabled */ > + for_each_child_of_node(i2c_mux, node) { > + u32 id = 0; > + > + of_property_read_u32(node, "reg", &id); > + if (id >= MAX9286_NUM_GMSL) > + continue; > + > + if (!of_device_is_available(node)) { > + dev_dbg(dev, "Skipping disabled I2C bus port %u\n", id); > + continue; > + } > + > + i2c_mux_mask |= BIT(id); > + } > + of_node_put(node); > + of_node_put(i2c_mux); > + > + /* Parse the endpoints */ > + for_each_endpoint_of_node(dev->of_node, node) { > + struct max9286_source *source; > + struct of_endpoint ep; > + > + of_graph_parse_endpoint(node, &ep); > + dev_dbg(dev, "Endpoint %pOF on port %d", > + ep.local_node, ep.port); > + > + if (ep.port > MAX9286_NUM_GMSL) { > + dev_err(dev, "Invalid endpoint %s on port %d", > + of_node_full_name(ep.local_node), ep.port); > + continue; > + } > + > + /* For the source endpoint just parse the bus configuration. */ > + if (ep.port == MAX9286_SRC_PAD) { > + struct v4l2_fwnode_endpoint vep = { > + .bus_type = V4L2_MBUS_CSI2_DPHY > + }; > + int ret; > + > + ret = v4l2_fwnode_endpoint_parse( > + of_fwnode_handle(node), &vep); > + if (ret) { > + of_node_put(node); > + of_node_put(dev->of_node); > + return ret; > + } > + > + if (vep.bus_type != V4L2_MBUS_CSI2_DPHY) { This won't happen, the bus type will stay if you set it to a non-zero value. > + dev_err(dev, > + "Media bus %u type not supported\n", > + vep.bus_type); > + v4l2_fwnode_endpoint_free(&vep); > + of_node_put(node); > + of_node_put(dev->of_node); > + return -EINVAL; > + } > + > + priv->csi2_data_lanes = > + vep.bus.mipi_csi2.num_data_lanes; > + v4l2_fwnode_endpoint_free(&vep); No need to call this unless you use v4l2_fwnode_endpoint_alloc_parse(). And as you don't, you also won't know which frequencies are known to be safe to use. That said, perhaps where this device is used having a random frequency on that bus could not be an issue. Perhaps. > + > + continue; > + } > + > + /* Skip if the corresponding GMSL link is unavailable. */ > + if (!(i2c_mux_mask & BIT(ep.port))) > + continue; > + > + if (priv->sources[ep.port].fwnode) { > + dev_err(dev, > + "Multiple port endpoints are not supported: %d", > + ep.port); > + > + continue; > + } > + > + source = &priv->sources[ep.port]; > + source->fwnode = fwnode_graph_get_remote_endpoint( > + of_fwnode_handle(node)); > + if (!source->fwnode) { > + dev_err(dev, > + "Endpoint %pOF has no remote endpoint connection\n", > + ep.local_node); > + > + continue; > + } > + > + priv->source_mask |= BIT(ep.port); > + priv->nsources++; > + } > + of_node_put(node); > + of_node_put(dev->of_node); > + > + priv->route_mask = priv->source_mask; > + > + return 0; > +} -- Kind regards, Sakari Ailus