Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp730744pxb; Wed, 6 Oct 2021 14:14:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsJTXdc6PwzAoSoSeUwxKVh/fFZwnFmAlhI+ZBCS8rfN0xDFlxRizSGPvGAnXvbJAoccyv X-Received: by 2002:a05:6402:26c5:: with SMTP id x5mr676005edd.297.1633554857296; Wed, 06 Oct 2021 14:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633554857; cv=none; d=google.com; s=arc-20160816; b=qFvbgQBFH+fLpV6lfBgDTWOhAKIaBn0ntqIex5EWn5Rv3E6QYCRlezpCgPIS+nL/7U Ed/d+qsYE7UmM5x2OVxxxf2kE1zmb5wBBHul2LbY+OiDBpxq9yI9UOpGkn/qfvTVy+D6 PKd2lCilJpEXhHlQ6OtLKv8YBAfg+LQsDPYBYEijH806j1RdgLgEp1YVHvLhd/iT8dGh h+nKoeMKJdLnXzuNeReu6OhzLX+2I2KV8/CdpjhwaUzjyhIQEUlNhek1VET7B7PTKMOC dWpPpfJkXvsW8f19WB4LEpBWoHPI5FHzbrXhl2R3v0VGd0XBgGQQPQ0AqkFyp5Y8CxCo CMag== 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; bh=owD/WlBr/RmNItj5pD31BpikD8MN6x/WDOOh2Lnqq50=; b=dxpq/1jxuOemZtYU7WGQhH4vld4Wy9mPc5jsBtm8lpns80Bv30ySEvrPQfyO6Rf3sa xj5PMyreqAZTcjrpMd+WWGU4blRhwejyN0Upqm//OHn5u3fnvz27TRx0obQEb9NwSKym 7i05QRC00H2wZKEaYFIrMoAhzv1cCzyWIALEOo7cKj69LgOITadLOEU8n9RjYT9uRfhw q++6512fM1Bv2MxLKAosoz2aDuKcO/cHeTYJgS8aYU2NMfBA9Zmg9HZh36sHo7SZ0ITx fU5227u747BfpzLgb5Xr/A0Uuy2TzyVj9TC+i7vo1qTr7xQ6usjkveVFCt7BEgNxFQyp D4uQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 7si25839346ejd.0.2021.10.06.14.13.53; Wed, 06 Oct 2021 14:14:17 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239603AbhJFVLS (ORCPT + 99 others); Wed, 6 Oct 2021 17:11:18 -0400 Received: from mga05.intel.com ([192.55.52.43]:34574 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239454AbhJFVLH (ORCPT ); Wed, 6 Oct 2021 17:11:07 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10129"; a="312311556" X-IronPort-AV: E=Sophos;i="5.85,352,1624345200"; d="scan'208";a="312311556" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2021 14:09:10 -0700 X-IronPort-AV: E=Sophos;i="5.85,352,1624345200"; d="scan'208";a="440035623" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2021 14:09:06 -0700 Received: from paasikivi.fi.intel.com (localhost [127.0.0.1]) by paasikivi.fi.intel.com (Postfix) with SMTP id 784B820375; Thu, 7 Oct 2021 00:08:33 +0300 (EEST) Date: Thu, 7 Oct 2021 00:08:33 +0300 From: Sakari Ailus To: Pratyush Yadav Cc: Mauro Carvalho Chehab , Laurent Pinchart , Nikhil Devshatwar , Tomi Valkeinen , Vignesh Raghavendra , Benoit Parrot , Maxime Ripard , Rob Herring , Niklas =?iso-8859-1?Q?S=F6derlund?= , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [PATCH v4 08/11] media: ti: Add CSI2RX support for J721E Message-ID: References: <20210915120240.21572-1-p.yadav@ti.com> <20210915120240.21572-9-p.yadav@ti.com> <20211006210141.3mi2popzfsalskm3@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211006210141.3mi2popzfsalskm3@ti.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 07, 2021 at 02:31:43AM +0530, Pratyush Yadav wrote: > On 06/10/21 11:28PM, Sakari Ailus wrote: > > Hi Pratyush, > > > > On Wed, Sep 15, 2021 at 05:32:37PM +0530, Pratyush Yadav wrote: > > ... > > > +/* > > > + * Find the input format. This is done by finding the first device in the > > > + * pipeline which can tell us the current format. This could be the sensor, or > > > + * this could be another device in the middle which is capable of format > > > + * conversions. > > > + */ > > > +static int ti_csi2rx_validate_pipeline(struct ti_csi2rx_dev *csi) > > > +{ > > > + struct media_pipeline *pipe = &csi->pipe; > > > + struct media_entity *entity; > > > + struct v4l2_subdev *sd; > > > + struct v4l2_subdev_format fmt; > > > + struct v4l2_pix_format *pix = &csi->v_fmt.fmt.pix; > > > + struct media_device *mdev = &csi->mdev; > > > + const struct ti_csi2rx_fmt *ti_fmt; > > > + int ret; > > > + > > > + mutex_lock(&mdev->graph_mutex); > > > + ret = media_graph_walk_init(&pipe->graph, mdev); > > > + if (ret) { > > > + mutex_unlock(&mdev->graph_mutex); > > > + return ret; > > > + } > > > + > > > + media_graph_walk_start(&pipe->graph, &csi->vdev.entity); > > > + > > > + while ((entity = media_graph_walk_next(&pipe->graph))) { > > > + if (!is_media_entity_v4l2_subdev(entity)) > > > + continue; > > > > You shouldn't rely on media_graph_walk_next() to return entities in a > > particular order. > > Ah, right. Need to drop this. > > > > > I'd suggest approach taken in isp_video_check_external_subdevs() (in > > drivers/media/platform/omap3isp/ispvideo.c). > > > > > + > > > + sd = media_entity_to_v4l2_subdev(entity); > > > + > > > + fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; > > > + fmt.pad = media_get_pad_index(entity, 0, PAD_SIGNAL_DEFAULT); > > > + > > > + ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt); > > > + if (ret && ret != -ENOIOCTLCMD) { > > > + media_graph_walk_cleanup(&pipe->graph); > > > + mutex_unlock(&mdev->graph_mutex); > > > + return ret; > > > + } > > > + > > > + if (!ret) > > > + break; > > > + } > > > + > > > + media_graph_walk_cleanup(&pipe->graph); > > > + mutex_unlock(&mdev->graph_mutex); > > > + > > > + /* Could not find input format. */ > > > + if (!entity) > > > + return -EPIPE; > > > + > > > + if (fmt.format.width != pix->width) > > > + return -EPIPE; > > > + if (fmt.format.height != pix->height) > > > + return -EPIPE; > > > > Pipeline validation should take place during media_pipeline_start(). Why > > are you doing it here? > > How would be do that? Via the link_validate callback? Yes, please. See other drivers for examples --- such as omap3isp. -- Sakari Ailus