Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp329729imm; Wed, 18 Jul 2018 02:56:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeIsa6X+A9zTouQTAUQNUJhEZCcFq6HWjA4L+vUUBAvSOUskku+tcqXieFXOWxHy2FXah4l X-Received: by 2002:a17:902:9302:: with SMTP id bc2-v6mr5265723plb.280.1531907804682; Wed, 18 Jul 2018 02:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531907804; cv=none; d=google.com; s=arc-20160816; b=dSSQFa2EZGSm9W/eGZ5qxqRdXgI1SGZ241ct7zhzVpzh2mwGfyOebv7A7z2owmNirV UQaP00kyj4t25q0IedUpaingzCZLbNIqLLL0geUgtDv3XMmP2KDbwfxz17heMo25Mjee Dxw8/1YZ/cMAd34u8GaRW8qYFWdhZeHFEenV1GXxjNMHd2kcdKaXJzPNzf6xRfCWEhNo EH24AhGi2TwnOGTeDFl8yfGu823vy1YhbkYDYBywqReb/vF8d/94nFtUdrNdtVwisxd8 87wTz7Ned5VFQgn8bPTAB8GqxWRWniT/y5E4QGZ+Kx2v30TbNCoUC0z5wHgxMLIIZd2b tKzw== 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:arc-authentication-results; bh=aee4BQ7wQpqMZYq+SO3HzYBOO38wrG7qSib0/aQ1T3w=; b=XSbcKg5qUOF1CtHsvW2lMvWtBkp1QRL5yd9Nda3a0hn/TmPKXqfL0GzDuQ/JgqNokR NcQPIJPvy9RhYrnEDd+OeUgD0AARE/nQahqth+2kpI1PdV5dv58qMgqTU/ynFTvZJvFh gB7q8MrnMFmsEIrxk6DddNMzd2HXTi7qU+CfY3QvPqV12G1VRo3j4LoQNorWFeRKD/PE hR0fN+KhKLx7F6GP10+ig4Rn/j3agCdHCz5VaNM1xd+3ZEOcSDlyBvDNbhlOfRiV2sxB CA9odOtp2PBlkMgbOVjyMYlASFUodX5RYNNm4GdghDKuiyF0qSEV0t7htMh2JpLJiiKw Rxuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id g65-v6si3070465pfc.36.2018.07.18.02.56.26; Wed, 18 Jul 2018 02:56:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730838AbeGRKc1 (ORCPT + 99 others); Wed, 18 Jul 2018 06:32:27 -0400 Received: from mga05.intel.com ([192.55.52.43]:22368 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbeGRKc1 (ORCPT ); Wed, 18 Jul 2018 06:32:27 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jul 2018 02:55:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,369,1526367600"; d="scan'208";a="65556826" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by FMSMGA003.fm.intel.com with ESMTP; 18 Jul 2018 02:55:14 -0700 Received: by paasikivi.fi.intel.com (Postfix, from userid 1000) id 3C9FE203A8; Wed, 18 Jul 2018 12:55:14 +0300 (EEST) Date: Wed, 18 Jul 2018 12:55:14 +0300 From: Sakari Ailus To: Yong Cc: Sakari Ailus , Maxime Ripard , Mauro Carvalho Chehab , Rob Herring , Mark Rutland , Chen-Yu Tsai , "David S. Miller" , Greg Kroah-Hartman , Andrew Morton , Linus Walleij , Randy Dunlap , Hans Verkuil , Arnd Bergmann , Stanimir Varbanov , Philipp Zabel , Ramesh Shanmugasundaram , Jacob Chen , Yannick Fertre , Thierry Reding , Benjamin Gaignard , Todor Tomov , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: Re: [PATCH v10 2/2] media: V3s: Add support for Allwinner CSI. Message-ID: <20180718095513.4cm77g2iuilvfmd6@paasikivi.fi.intel.com> References: <1525417745-37964-1-git-send-email-yong.deng@magewell.com> <20180626110821.wkal6fcnoncsze6y@valkosipuli.retiisi.org.uk> <20180705154802.03604f156709be11892b19c0@magewell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180705154802.03604f156709be11892b19c0@magewell.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yong, On Thu, Jul 05, 2018 at 03:48:02PM +0800, Yong wrote: > > > + > > > +/* ----------------------------------------------------------------------------- > > > + * Media Operations > > > + */ > > > +static int sun6i_video_formats_init(struct sun6i_video *video, > > > + const struct media_pad *remote) > > > +{ > > > + struct v4l2_subdev_mbus_code_enum mbus_code = { 0 }; > > > + struct sun6i_csi *csi = video->csi; > > > + struct v4l2_format format; > > > + struct v4l2_subdev *subdev; > > > + u32 pad; > > > + const u32 *pixformats; > > > + int pixformat_count = 0; > > > + u32 subdev_codes[32]; /* subdev format codes, 32 should be enough */ > > > + int codes_count = 0; > > > + int num_fmts = 0; > > > + int i, j; > > > + > > > + pad = remote->index; > > > + subdev = media_entity_to_v4l2_subdev(remote->entity); > > > + if (subdev == NULL) > > > + return -ENXIO; > > > + > > > + /* Get supported pixformats of CSI */ > > > + pixformat_count = sun6i_csi_get_supported_pixformats(csi, &pixformats); > > > + if (pixformat_count <= 0) > > > + return -ENXIO; > > > + > > > + /* Get subdev formats codes */ > > > + mbus_code.pad = pad; > > > + mbus_code.which = V4L2_SUBDEV_FORMAT_ACTIVE; > > > + while (!v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, > > > + &mbus_code)) { > > > > The formats supported by the external sub-device may depend on horizontal > > and vertical flipping. You shouldn't assume any particular configuration > > here: instead, bridge drivers generally just need to make sure the formats > > match in link validation when streaming is started. At least the CSI-2 > > receiver driver and the DMA engine driver (video device) should check the > > configuration is valid. See e.g. the IPU3 driver: > > drivers/media/pci/intel/ipu3/ipu3-cio2.c . > > Can mbus_code be added dynamically ? > The code here only enum the mbus code and get the possible supported > pairs of pixformat and mbus by SoC. Not try to check if the formats > (width height ...) is valid or not. The formats validation will be > in link validation when streaming is started as per your advise. The formats that can be enumerated from the sensor here are those settable using SUBDEV_S_FMT. The enumeration will change on raw sensors if you use the flipping controls. As the bridge driver implements MC as well as subdev APIs, generally the sensor configuration is out of scope of this driver since it's directly configured from the user space. Just check that the pipeline is valid before starting streaming in your driver. -- Kind regards, Sakari Ailus sakari.ailus@linux.intel.com