Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4161158imu; Mon, 10 Dec 2018 14:16:08 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vt8P6yt08mInrPEtmytOSPfeuWyEe6CqbBXwbcciHKsjhdUHq6t5xgxLdocvDZDhyJMKa4 X-Received: by 2002:a17:902:830a:: with SMTP id bd10mr13793215plb.321.1544480168153; Mon, 10 Dec 2018 14:16:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544480168; cv=none; d=google.com; s=arc-20160816; b=NuUfziDzkvpbmszBpLdVy3GAC8gp2LqrCxoPSCKmCXjGttk85KP5Fyb/tRxZQ7R4RU IJpRQnGnheEQylb9vmQwmBg3Ngk2QapDHzdpuaQZ2z7Cr4r6L3cTaxqe3ed0GNJFSz1+ SEVA7UIIUrSIood94hrK3M7D2eNcykszeL/G11BewhIJmTcZoFSlocYVmrn8Ls8YKa3P dlgkuNrbKd8z479VxhlW9LD90At395co5LBxTmQ9CjvWDsw9TZHLe85IrokdzP4Lp7dr 9/B4rH8Ed1DsMsP25FkocYvMfGxJeEY0q2GZUJWXuxcrZxVe9tPLAN95VLo9TkSpL299 0BhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=+Z4cJNoUDdc4GPxswmj6JsPzEmpLOhjva3HgqoYU28o=; b=gBdzKfJRKQkta45ZejmnFIJgcSOAtdXoSzQ0A9toEyKHhyuEQY8MlJJiLzu84WTAxR 2B26ImegFFiJoZSuj6IYzfd1McBqs1/JFEZflKG0+DUhDZ8AHcqVQZo+FW5caXZ4NPQ6 8LnRlWLbNa8S0+w8wiEwfgZG/YC2S0tas4t6mvFd5f8jucoMJ1wVvCg+/9J5CMpweKXu XkQ8EkCoDGAy8sYtXQ2zm2JKuNog3ZzogZt0oo8gp3iBEWTGMnsmoHustWNIa2daq8Nu kHgntdgzrd2GqV0+tNZfjucJjSUqWM3Vp8CVKOVOYPt3PaIxjbYRrnBT+AYqq1KN/gvo 1ntA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ov3oLr17; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si10875851plm.431.2018.12.10.14.15.52; Mon, 10 Dec 2018 14:16:08 -0800 (PST) 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; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ov3oLr17; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728586AbeLJVpT (ORCPT + 99 others); Mon, 10 Dec 2018 16:45:19 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:38441 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726562AbeLJVpT (ORCPT ); Mon, 10 Dec 2018 16:45:19 -0500 Received: by mail-wm1-f66.google.com with SMTP id m22so177219wml.3 for ; Mon, 10 Dec 2018 13:45:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+Z4cJNoUDdc4GPxswmj6JsPzEmpLOhjva3HgqoYU28o=; b=ov3oLr178GAc65keIkipFB3wQNL9ciYd02Xuww2EJDHQzve8gSIHiNq6zG1XHy4v/1 jWNFFIs2HVtScTGluIFmlGJECpxr03MsvrqvCJe4KyuDjEeQG04zI14gXxDF611TAFy5 1/kPduDO6MAK99C2aGqm+7o0jLV3iboBTWZ6g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+Z4cJNoUDdc4GPxswmj6JsPzEmpLOhjva3HgqoYU28o=; b=eyPglMqCCK4tB3jHcAn6ubOqLZW1kRAyT2ziukBGR2D6h6nI0m/61HqCo/zbOsoRDZ acvIPdOxNzwDG0Cb66W58NjVDQVHI9fWtuDiUX1nSVkvAa9jmH47V2HWOC026pgT55/+ 7vvx9N9YOlt0QoVLQVVHNY0F1jgIS/J9V59XQChY07kGrZPpkfHTB1J/l4qcF0a5eUdy WRbcY6QzdiST4Y0qKF7vyQMU9nMJv4IrFcmyz6eVNCwnkiegX9e5nXAPNdS2s7ULZ2Gw fFiligawthg1+i/iW6HWLpz0WjkuEwdLHKefDRLQ2rSmSBbBbDP6qJHXxjBQRqqPVerH Wfgg== X-Gm-Message-State: AA+aEWaGDf8ErGdYh7OvFpV0SSqOcSRQftgpv/wwOG9uhl6gwPj9SGVo 2yWNyrCQ4u3vkrUssGAl8sFim0U9M55wK78A47LFoA== X-Received: by 2002:a1c:b456:: with SMTP id d83mr58223wmf.115.1544478314321; Mon, 10 Dec 2018 13:45:14 -0800 (PST) MIME-Version: 1.0 References: <850c2502-217c-a9f0-b433-0cd26d0419fd@xs4all.nl> <20181209193912.GC12193@w540> In-Reply-To: <20181209193912.GC12193@w540> From: Michael Nazzareno Trimarchi Date: Mon, 10 Dec 2018 22:45:02 +0100 Message-ID: Subject: Re: Configure video PAL decoder into media pipeline To: jacopo@jmondi.org Cc: hverkuil@xs4all.nl, Jagan Teki , mchehab@kernel.org, linux-media@vger.kernel.org, LKML , Lars-Peter Clausen , Philipp Zabel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacopo Let's see what I have done On Sun, Dec 9, 2018 at 8:39 PM jacopo mondi wrote: > > Hi Michael, Jagan, Hans, > > On Sat, Dec 08, 2018 at 06:07:04PM +0100, Michael Nazzareno Trimarchi wrote: > > Hi > > > > Down you have my tentative of connection > > > > I need to hack a bit to have tuner registered. I'm using imx-media > > > > On Sat, Dec 8, 2018 at 12:48 PM Michael Nazzareno Trimarchi > > wrote: > > > > > > Hi > > > > > > On Fri, Dec 7, 2018 at 1:11 PM Hans Verkuil wrote: > > > > > > > > On 12/07/2018 12:51 PM, Jagan Teki wrote: > > > > > Hi, > > > > > > > > > > We have some unconventional setup for parallel CSI design where analog > > > > > input data is converted into to digital composite using PAL decoder > > > > > and it feed to adv7180, camera sensor. > > > > > > > > > > Analog input => Video PAL Decoder => ADV7180 => IPU-CSI0 > > > > > > > > Just PAL? No NTSC support? > > > > > > > For now does not matter. I have registere the TUNER that support it > > > but seems that media-ctl is not suppose to work with the MEDIA_ENT_F_TUNER > > > > > > Is this correct? > > > > > media-types.rst reports: > > * - ``MEDIA_ENT_F_IF_VID_DECODER`` > - IF-PLL video decoder. It receives the IF from a PLL and decodes > the analog TV video signal. This is commonly found on some very > old analog tuners, like Philips MK3 designs. They all contain a > tda9887 (or some software compatible similar chip, like tda9885). > Those devices use a different I2C address than the tuner PLL. > > Is this what you were looking for? > > > > > > > > > > > The PAL decoder is I2C based, tda9885 chip. We setup it up via dt > > > > > bindings and the chip is > > > > > detected fine. > > > > > > > > > > But we need to know, is this to be part of media control subdev > > > > > pipeline? so-that we can configure pads, links like what we do on > > > > > conventional pipeline or it should not to be part of media pipeline? > > > > > > > > Yes, I would say it should be part of the pipeline. > > > > > > > > > > Ok I have created a draft patch to add the adv some new endpoint but > > > is sufficient to declare tuner type in media control? > > > > > > Michael > > > > > > > > > > > > > Please advise for best possible way to fit this into the design. > > > > > > > > > > Another observation is since the IPU has more than one sink, source > > > > > pads, we source or sink the other components on the pipeline but look > > > > > like the same thing seems not possible with adv7180 since if has only > > > > > one pad. If it has only one pad sourcing to adv7180 from tda9885 seems > > > > > not possible, If I'm not mistaken. > > > > > > > > Correct, in all cases where the adv7180 is used it is directly connected > > > > to the video input connector on a board. > > > > > > > > So to support this the adv7180 driver should be modified to add an input pad > > > > so you can connect the decoder. It will be needed at some point anyway once > > > > we add support for connector entities. > > > > > > > > Regards, > > > > > > > > Hans > > > > > > > > > > > > > > I tried to look for similar design in mainline, but I couldn't find > > > > > it. is there any design similar to this in mainline? > > > > > > > > > > Please let us know if anyone has any suggestions on this. > > > > > > > > > [ 3.379129] imx-media: ipu1_vdic:2 -> ipu1_ic_prp:0 > > [ 3.384262] imx-media: ipu2_vdic:2 -> ipu2_ic_prp:0 > > [ 3.389217] imx-media: ipu1_ic_prp:1 -> ipu1_ic_prpenc:0 > > [ 3.394616] imx-media: ipu1_ic_prp:2 -> ipu1_ic_prpvf:0 > > [ 3.399867] imx-media: ipu2_ic_prp:1 -> ipu2_ic_prpenc:0 > > [ 3.405289] imx-media: ipu2_ic_prp:2 -> ipu2_ic_prpvf:0 > > [ 3.410552] imx-media: ipu1_csi0:1 -> ipu1_ic_prp:0 > > [ 3.415502] imx-media: ipu1_csi0:1 -> ipu1_vdic:0 > > [ 3.420305] imx-media: ipu1_csi0_mux:5 -> ipu1_csi0:0 > > [ 3.425427] imx-media: ipu1_csi1:1 -> ipu1_ic_prp:0 > > [ 3.430328] imx-media: ipu1_csi1:1 -> ipu1_vdic:0 > > [ 3.435142] imx-media: ipu1_csi1_mux:5 -> ipu1_csi1:0 > > [ 3.440321] imx-media: adv7180 2-0020:1 -> ipu1_csi0_mux:4 > > > > with > > tuner: tuner@43 { > > compatible = "tuner"; > > reg = <0x43>; > > pinctrl-names = "default"; > > pinctrl-0 = <&pinctrl_tuner>; > > > > ports { > > #address-cells = <1>; > > #size-cells = <0>; > > port@1 { > > reg = <1>; > > > > tuner_in: endpoint { > > Nit: This is the tuner output, I would call this "tuner_out" > Done > > remote-endpoint = <&tuner_out>; > > }; > > }; > > }; > > }; > > > > adv7180: camera@20 { > > compatible = "adi,adv7180"; > > One minor thing first: look at the adv7180 bindings documentation, and > you'll find out that only devices compatible with "adv7180cp" and > "adv7180st" shall declare a 'ports' node. This is minor issues (also, > I don't see it enforced in driver's code, but still worth pointing it > out from the very beginning) > > > reg = <0x20>; > > pinctrl-names = "default"; > > pinctrl-0 = <&pinctrl_adv7180>; > > powerdown-gpios = <&gpio3 20 GPIO_ACTIVE_LOW>; /* PDEC_PWRDN */ > > > > ports { > > #address-cells = <1>; > > #size-cells = <0>; > > > > port@1 { > > reg = <1>; > > > > adv7180_to_ipu1_csi0_mux: endpoint { > > remote-endpoint = > > <&ipu1_csi0_mux_from_parallel_sensor>; > > bus-width = <8>; > > }; > > }; > > > > port@0 { > > reg = <0>; > > > > tuner_out: endpoint { > > Nit: That's an adv7180 endpoint, I would call it 'adv7180_in' > Done > > remote-endpoint = <&tuner_in>; > > }; > > }; > > }; > > }; > > > > Any help is appreciate > > > > The adv7180(cp|st) bindings says the device can declare one (or more) > input endpoints, but that's just to make possible to connect in device > tree the 7180's device node with the video input port. You can see an > example in arch/arm64/boot/dts/renesas/r8a77995-draak.dts which is > similar to what you've done here. > > The video input port does not show up in the media graph, as it is > just a 'place holder' to describe an input port in DTs, the > adv7180 driver does not register any sink pad, where to connect any > video source to. > > Your proposed bindings here look almost correct, but to have it > working for real you should add a sink pad to the adv7180 registered > media entity (possibly only conditionally to the presence of an input > endpoint in DTs...). You should then register a subdev-notifier, which > registers on an async-subdevice that uses the remote endpoint > connected to your newly registered input pad to find out which device > you're linked to; then at 'bound' (or possibly 'complete') time > register a link between the two entities, on which you can operate on > from userspace. > > Your tuner driver for tda9885 (which I don't see in mainline, so I > assume it's downstream or custom code) should register an async subdevice, > so that the adv7180 registered subdev-notifier gets matched and your > callbacks invoked. > > If I were you, I would: > 1) Add dt-parsing routine to tda7180, to find out if any input > endpoint is registered in DT. Done > 2) If it is, then register a SINK pad, along with the single SOURCE pad > which is registered today. Done > 3) When parsing DT, for input endpoints, get a reference to the remote > endpoint connected to your input and register a subdev-notifier Done > 4) Fill in the notifier 'bound' callback and register the link to > your remote device there. Both are subdevice that has not a v4l2_device, so bound is not called from two sub-device. Is this expected? > 5) Make sure your tuner driver registers its subdevice with > v4l2_async_register_subdev() > > A good example on how to register subdev notifier is provided in the > rcsi2_parse_dt() function in rcar-csi2.c driver (I'm quite sure imx > now uses subdev notifiers from v4.19 on too if you want to have a look > there). Already seen it > > -- Entering slippery territory here: you might want more inputs on this > > To make thing simpler&nicer (TM), if you blindly do what I've suggested > here, you're going to break all current adv7180 users in mainline :( > > That's because the v4l2-async design 'completes' the root notifier, > only if all subdev-notifiers connected to it have completed first. > If you add a notifier for the adv7180 input ports unconditionally, and I don't get to complete. So let's proceed by step Michael > to the input port is connected a plain simple "composite-video-connector", > as all DTs in mainline are doing right now, the newly registered > subdev-notifier will never complete, as the "composite-video-connector" > does not register any subdevice to match with. Bummer! > > A quick look in the code base, returns me that, in example: > drivers/gpu/drm/meson/meson_drv.c filters on > "composite-video-connector" and a few other compatible values. You > might want to do the same, and register a notifier if and only if the > remote input endpoint is one of those known not to register a > subdevice. I'm sure there are other ways to deal with this issue, but > that's the best I can come up with... > --- > > Hope this is reasonably clear and that I'm not misleading you. I had to > use adv7180 recently, and its single pad design confused me a bit as well :) > > Thanks > j > > > Michael > > > > > > > Jagan. > > > > > > > > > > > > > > > > > > -- -- | Michael Nazzareno Trimarchi Amarula Solutions BV | | COO - Founder Cruquiuskade 47 | | +31(0)851119172 Amsterdam 1018 AM NL | | [`as] http://www.amarulasolutions.com |