[PATCH v4 02/12] [media] cxd2880-spi: Add support for CXD2880 SPI interface

2017-10-12 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is the SPI adapter part of the driver for the
Sony CXD2880 DVB-T2/T tuner + demodulator.

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---

[Change list]
Changes in V4
   drivers/media/spi/cxd2880-spi.c
  -removed Camel case
  -removed unnecessary initialization at variable declaration
  -removed unnecessary brace {}

Changes in V3
   drivers/media/spi/cxd2880-spi.c
  -adjusted of indent spaces
  -removed unnecessary cast
  -changed debugging code
  -changed timeout method
  -modified coding style of if()
  -changed hexadecimal code to lower case. 

Changes in V2
   drivers/media/spi/cxd2880-spi.c
  -Modified PID filter setting.

 drivers/media/spi/cxd2880-spi.c | 695 
 1 file changed, 695 insertions(+)
 create mode 100644 drivers/media/spi/cxd2880-spi.c

diff --git a/drivers/media/spi/cxd2880-spi.c b/drivers/media/spi/cxd2880-spi.c
new file mode 100644
index ..387cb32f90b8
--- /dev/null
+++ b/drivers/media/spi/cxd2880-spi.c
@@ -0,0 +1,695 @@
+/*
+ * cxd2880-spi.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * SPI adapter
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
+
+#include 
+#include 
+
+#include "dvb_demux.h"
+#include "dmxdev.h"
+#include "dvb_frontend.h"
+#include "cxd2880.h"
+
+#define CXD2880_MAX_FILTER_SIZE 32
+#define BURST_WRITE_MAX 128
+#define MAX_TRANS_PACKET 300
+
+struct cxd2880_ts_buf_info {
+   u8 read_ready;
+   u8 almost_full;
+   u8 almost_empty;
+   u8 overflow;
+   u8 underflow;
+   u16 packet_num;
+};
+
+struct cxd2880_pid_config {
+   u8 is_enable;
+   u16 pid;
+};
+
+struct cxd2880_pid_filter_config {
+   u8 is_negative;
+   struct cxd2880_pid_config pid_config[CXD2880_MAX_FILTER_SIZE];
+};
+
+struct cxd2880_dvb_spi {
+   struct dvb_frontend dvb_fe;
+   struct dvb_adapter adapter;
+   struct dvb_demux demux;
+   struct dmxdev dmxdev;
+   struct dmx_frontend dmx_fe;
+   struct task_struct *cxd2880_ts_read_thread;
+   struct spi_device *spi;
+   struct mutex spi_mutex; /* For SPI access exclusive control */
+   int feed_count;
+   int all_pid_feed_count;
+   u8 *ts_buf;
+   struct cxd2880_pid_filter_config filter_config;
+};
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+static int cxd2880_write_spi(struct spi_device *spi, u8 *data, u32 size)
+{
+   struct spi_message msg;
+   struct spi_transfer tx;
+   int ret;
+
+   if ((!spi) || (!data)) {
+   pr_err("invalid arg\n");
+   return -EINVAL;
+   }
+
+   memset(, 0, sizeof(tx));
+   tx.tx_buf = data;
+   tx.len = size;
+
+   spi_message_init();
+   spi_message_add_tail(, );
+   ret = spi_sync(spi, );
+
+   return ret;
+}
+
+static int cxd2880_write_reg(struct spi_device *spi,
+u8 sub_address, const u8 *data, u32 size)
+{
+   u8 send_data[BURST_WRITE_MAX + 4];
+   const u8 *write_data_top = NULL;
+   int ret = 0;
+
+   if ((!spi) || (!data)) {
+   pr_err("invalid arg\n");
+   return -EINVAL;
+   }
+   if (size > BURST_WRITE_MAX) {
+   pr_err("data size > WRITE_MAX\n");
+   return -EINVAL;
+   }
+
+   if (sub_address + size > 0x100) {
+   pr_err("out of range\n");
+   return -EINVAL;
+   }
+
+   

[PATCH v4 01/12] [dt-bindings] [media] Add document file for CXD2880 SPI I/F

2017-10-12 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is the document file for Sony CXD2880 DVB-T2/T tuner + demodulator.
It contains the description of the SPI adapter binding.

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
Acked-by: Rob Herring 
---

No change since version 1.

 .../devicetree/bindings/media/spi/sony-cxd2880.txt | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt

diff --git a/Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt 
b/Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt
new file mode 100644
index ..fc5aa263abe5
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt
@@ -0,0 +1,14 @@
+Sony CXD2880 DVB-T2/T tuner + demodulator driver SPI adapter
+
+Required properties:
+- compatible: Should be "sony,cxd2880".
+- reg: SPI chip select number for the device.
+- spi-max-frequency: Maximum bus speed, should be set to <5500> (55MHz).
+
+Example:
+
+cxd2880@0 {
+   compatible = "sony,cxd2880";
+   reg = <0>; /* CE0 */
+   spi-max-frequency = <5500>; /* 55MHz */
+};
-- 
2.13.0



[PATCH v4 00/12] [dt-bindings] [media] Add document file and driver for Sony CXD2880 DVB-T2/T tuner + demodulator

2017-10-12 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Hi,

This is the patch series (version 4) of Sony CXD2880 DVB-T2/T tuner + 
demodulator driver.The driver supports DVB-API and interfaces through 
SPI.

We have tested the driver on Raspberry Pi 3 and got picture and sound 
from a media player.

The change history of this patch series is as below.

[Change list]
Changes in V4
(1)Total patch number was changed from 14 to 12.
 We put [PATCH v3 12/14], [PATCH v3 13/14] and [PATCH v3 14/14]
   in [PATCH v4 12/12].

(2)Removed another file.
 These below files were removed because we changed it so that
   demodulator does not wait for locking the signal.

[PATCH v4 09/12]
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
  -removed
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.h
  -removed
[PATCH v4 11/12]
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
  -removed
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.h
  -removed

(3)The detail change items of each files are as below.
[PATCH v4 02/12]
   drivers/media/spi/cxd2880-spi.c
  -removed Camel case
  -removed unnecessary initialization at variable declaration
  -removed unnecessary brace {}

[PATCH v4 03/12]
   drivers/media/dvb-frontends/cxd2880/cxd2880_io.c
  -removed unnecessary initialization at variable declaration
  -modified how to write consecutive registers

[PATCH v4 04/12]
   drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c
  -removed unnecessary initialization at variable declaration

[PATCH v4 05/12]
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
  -used over 80 columns limit, it makes fine to read codes
  -removed unnecessary initialization at variable declaration
  -modified how to write consecutive registers
  -removed unnecessary brace {}
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h
  -adjusted of indent spaces of macro
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
  -updated version information
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c
  -removed unnecessary brace {}

[PATCH v4 06/12]
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
  -removed unnecessary initialization at variable declaration

[PATCH v4 07/12]
   drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
  -modified typo "inavlid" to "invalid" at pr_err
  -removed unnecessary initialization at variable declaration
  -removed unnecessary brace {}
  -changed to use cxd2880_dvbt_tune and cxd2880_dvbt2_tune 
   instead of cxd2880_integ_dvbt_tune and cxd2880_integ_dvbt2_tune
(because we changed it so that demodulator does not 
 wait for locking the signal.) 

[PATCH v4 08/12]
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c
  -used over 80 columns limit, it makes fine to read codes
  -removed unnecessary initialization at variable declaration
  -removed unnecessary brace {}
  -modified how to write consecutive registers

[PATCH v4 09/12]
   #drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
  -cxd2880_integ_dvbt.c file was removed from V4.
   #drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.h
  -cxd2880_integ_dvbt.h file was removed from V4.
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.c
  -removed unnecessary initialization at variable declaration
  -removed unnecessary brace {}
  -changed position of static const (to top part of the file)

[PATCH v4 10/12]
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.c
  -removed unnecessary initialization at variable declaration
  -removed unnecessary brace {}
  -modified how to write consecutive registers

[PATCH v4 11/12]
   #drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
  -cxd2880_integ_dvbt2.c file was removed from V4.
   #drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.h
  -cxd2880_integ_dvbt2.h file was removed from V4.
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.c
  -removed unnecessary initialization at variable declaration
  -removed unnecessary brace {}
  -changed position of static const (to top part of the file)

[PATCH v4 12/12]
   drivers/media/dvb-frontends/cxd2880/Makefile
  -removed cxd2880_integ_dvbt2.o and cxd2880_integ_dvbt.o 

Changes in V3
(1)Total patch number was changed from 15 to 14,
   due to the all files of [PATCH v2 04/15] were removed.
   drivers/media/dvb-frontends/cxd2880/cxd2880_math.c
  -Removed
   drivers/media/dvb-frontends/cxd2880/cxd2880_math.h
  -Removed

(2)Removed another 

cron job: media_tree daily build: ERRORS

2017-10-12 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Fri Oct 13 05:00:16 CEST 2017
media-tree git hash:8382e556b1a2f30c4bf866f021b33577a64f9ebf
media_build git hash:   33629e38ddda7a5a6ed0f727535c45f08c788bf3
v4l-utils git hash: 01c04f7c8ad1a91af33e20621eba9200f447737e
gcc version:i686-linux-gcc (GCC) 7.1.0
sparse version: v0.5.0
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.12.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: OK
linux-git-arm-pxa: OK
linux-git-arm-stm32: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: WARNINGS
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.36.4-i686: ERRORS
linux-2.6.37.6-i686: ERRORS
linux-2.6.38.8-i686: ERRORS
linux-2.6.39.4-i686: ERRORS
linux-3.0.60-i686: ERRORS
linux-3.1.10-i686: ERRORS
linux-3.2.37-i686: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.4.27-i686: ERRORS
linux-3.5.7-i686: ERRORS
linux-3.6.11-i686: ERRORS
linux-3.7.4-i686: ERRORS
linux-3.8-i686: ERRORS
linux-3.9.2-i686: ERRORS
linux-3.10.1-i686: ERRORS
linux-3.11.1-i686: ERRORS
linux-3.12.67-i686: WARNINGS
linux-3.13.11-i686: ERRORS
linux-3.14.9-i686: WARNINGS
linux-3.15.2-i686: WARNINGS
linux-3.16.7-i686: WARNINGS
linux-3.17.8-i686: WARNINGS
linux-3.18.7-i686: WARNINGS
linux-3.19-i686: WARNINGS
linux-4.0.9-i686: WARNINGS
linux-4.1.33-i686: WARNINGS
linux-4.2.8-i686: WARNINGS
linux-4.3.6-i686: WARNINGS
linux-4.4.22-i686: WARNINGS
linux-4.5.7-i686: WARNINGS
linux-4.6.7-i686: WARNINGS
linux-4.7.5-i686: WARNINGS
linux-4.8-i686: OK
linux-4.9.26-i686: OK
linux-4.10.14-i686: OK
linux-4.11-i686: OK
linux-4.12.1-i686: OK
linux-4.13-i686: OK
linux-2.6.36.4-x86_64: ERRORS
linux-2.6.37.6-x86_64: ERRORS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-x86_64: ERRORS
linux-3.0.60-x86_64: ERRORS
linux-3.1.10-x86_64: ERRORS
linux-3.2.37-x86_64: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: ERRORS
linux-3.5.7-x86_64: ERRORS
linux-3.6.11-x86_64: ERRORS
linux-3.7.4-x86_64: ERRORS
linux-3.8-x86_64: ERRORS
linux-3.9.2-x86_64: ERRORS
linux-3.10.1-x86_64: ERRORS
linux-3.11.1-x86_64: ERRORS
linux-3.12.67-x86_64: WARNINGS
linux-3.13.11-x86_64: ERRORS
linux-3.14.9-x86_64: WARNINGS
linux-3.15.2-x86_64: WARNINGS
linux-3.16.7-x86_64: WARNINGS
linux-3.17.8-x86_64: WARNINGS
linux-3.18.7-x86_64: WARNINGS
linux-3.19-x86_64: WARNINGS
linux-4.0.9-x86_64: WARNINGS
linux-4.1.33-x86_64: WARNINGS
linux-4.2.8-x86_64: WARNINGS
linux-4.3.6-x86_64: WARNINGS
linux-4.4.22-x86_64: WARNINGS
linux-4.5.7-x86_64: WARNINGS
linux-4.6.7-x86_64: WARNINGS
linux-4.7.5-x86_64: WARNINGS
linux-4.8-x86_64: WARNINGS
linux-4.9.26-x86_64: WARNINGS
linux-4.10.14-x86_64: WARNINGS
linux-4.11-x86_64: WARNINGS
linux-4.12.1-x86_64: WARNINGS
linux-4.13-x86_64: OK
apps: OK
spec-git: OK

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Friday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Friday.tar.bz2

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/index.html


[PATCH v2] media: uvcvideo: Fix uvc dev reference management

2017-10-12 Thread Jeffy Chen
Remove the kref_get() in uvc_register_video(), which is not needed as
the kref_init() already initializes refcount to 1 for us.

Fixes: 9d15cd958c17 ("media: uvcvideo: Convert from using an atomic variable to 
a reference count")
Signed-off-by: Jeffy Chen 
---

Changes in v2:
Rewrite commit message.

 drivers/media/usb/uvc/uvc_driver.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_driver.c 
b/drivers/media/usb/uvc/uvc_driver.c
index 6d22b22cb35b..dd6106411eb0 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1939,7 +1939,6 @@ static int uvc_register_video(struct uvc_device *dev,
else
stream->chain->caps |= V4L2_CAP_VIDEO_OUTPUT;
 
-   kref_get(>ref);
return 0;
 }
 
-- 
2.11.0




Re: [PATCH v3 00/15] V4L2 Explicit Synchronization support

2017-10-12 Thread Brian Starkey

Hi,

On Wed, Oct 04, 2017 at 05:08:55PM -0300, Gustavo Padovan wrote:

Hi Brian,

On Mon, 2017-10-02 at 14:41 +0100, Brian Starkey wrote:

Hi Gustavo,

On Thu, Sep 07, 2017 at 03:42:11PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan 
>
> Hi,
>
> Refer to the documentation on the first patch for the details. The
> previous
> iteration is here: https://www.mail-archive.com/linux-media@vger.ke
> rnel.org/msg118077.html
>
> The 2nd patch proposes an userspace API for fences, then on patch 3
> we
> prepare to the addition of in-fences in patch 4, by introducing the
> infrastructure on vb2 to wait on an in-fence signal before queueing
> the
> buffer in the driver.
>
> Patch 5 fix uvc v4l2 event handling and patch 6 configure q->dev
> for
> vivid drivers to enable to subscribe and dequeue events on it.
>
> Patches 7-9 enables support to notify BUF_QUEUED events, the event
> send
> to userspace the out-fence fd and the index of the buffer that was
> queued.
>
> Patches 10-11 add support to mark queues as ordered. Finally
> patches 12
> and 13 add more fence infrastructure to support out-fences, patch
> 13 exposes
> close_fd() and patch 14 adds support to out-fences.
>
> It only works for ordered queues for now, see open question at the
> end
> of the letter.
>
> Test tool can be found at:
> https://git.collabora.com/cgit/user/padovan/v4l2-test.git/
>
> Main Changes
> 
>
> * out-fences: change in behavior: the out-fence fd now comes out of
> the
> BUF_QUEUED event along with the buffer id.

The more I think about this, the more unfortunate it seems.
Especially
for our use-case (m2m engine which sits in front of the display
processor to convert the format of some buffers), having to wait for
the in-fence to signal before we can get an out-fence removes a lot
of
the advantages of having fences at all.


Does your m2m driver ensures ordering between the buffer queued to it?



I'm not so familiar with the code, how can I check that?



Ideally, we'd like to queue up our m2m work (while the GPU is still
rendering that buffer, holding the in-fence), immediately get the
out-fence for the m2m work, and pass that to DRM as the in-fence for
display. With the current behaviour we need to wait in userspace
before we can pass the buffer to display.

Wouldn't it be possible to enforce that the buffers aren't queued
out-of-order in VB2? An easy way might be to (in qbuf) set a buffer's
->in_fence to be a fence_array of all the ->in_fences from the
buffers
before it in the queue (and its own). That would then naturally order
the enqueue-ing in the driver, and allow you to return the out-fence
immediately.

This would also solve your output devices question from below - a
buffer can never get queued in the driver until all of the buffers
which were QBUF'd before it are queued in the driver.


What you say makes sense, what this proposal lacks the most now is
feedback regarding its usecases. We can create a control setting to
enforce ordering in the queue, if it's set we create the fence arrays.
For output devices this should be set by default.


Yeah that could work. I can see that in some cases queueing
out-of-order as the fences signal would be the right thing to do, so
makes sense to allow both.

Thanks,
-Brian



Gustavo

--
Gustavo Padovan
Principal Software Engineer
Collabora Ltd.


Re: [PATCH] build: Add bsearch if not defined

2017-10-12 Thread Jasmin J.
Hi!

Even with this patch Kernel 2.6.x still can't be compiled due to
the next error "ida_simple_get" missing.
I will try to fix the "ida_simple_get" error tomorrow.

BR,
   Jasmin


[PATCH] build: Add bsearch if not defined

2017-10-12 Thread Jasmin J.
From: Jasmin Jessich 

Compiling for Kernel 2.6.x failed in "rc-main.c" with
  linux/bsearch.h: No such file or directory
Beside adding the missing function, also the include of "linux/bsearch.h"
has been removed by new patch "v2.6_rc_main_bsearch_h.patch".

Signed-off-by: Jasmin Jessich 
---
 backports/backports.txt|  3 +++
 backports/v2.6_rc_main_bsearch_h.patch | 10 ++
 v4l/compat.h   | 25 +
 v4l/scripts/make_config_compat.pl  |  1 +
 4 files changed, 39 insertions(+)
 create mode 100644 backports/v2.6_rc_main_bsearch_h.patch

diff --git a/backports/backports.txt b/backports/backports.txt
index 87b9ee8..b245e3b 100644
--- a/backports/backports.txt
+++ b/backports/backports.txt
@@ -127,6 +127,9 @@ add no_atomic_include.patch
 add v4l2-compat-timespec.patch
 add v3.0_ida2bit.patch
 
+[2.6.39]
+add v2.6_rc_main_bsearch_h.patch
+
 [2.6.38]
 add v2.6.38_use_getkeycode_new_setkeycode_new.patch
 add v2.6.38_config_of_for_of_node.patch
diff --git a/backports/v2.6_rc_main_bsearch_h.patch 
b/backports/v2.6_rc_main_bsearch_h.patch
new file mode 100644
index 000..9ed45b4
--- /dev/null
+++ b/backports/v2.6_rc_main_bsearch_h.patch
@@ -0,0 +1,10 @@
+--- a/drivers/media/rc/rc-main.c
 b/drivers/media/rc/rc-main.c
+@@ -16,7 +16,6 @@
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+ 
+ #include 
+-#include 
+ #include 
+ #include 
+ #include 
diff --git a/v4l/compat.h b/v4l/compat.h
index 15f2cd6..3504288 100644
--- a/v4l/compat.h
+++ b/v4l/compat.h
@@ -2170,4 +2170,29 @@ static inline unsigned long nsecs_to_jiffies_static(u64 
n)
 #define U32_MAX ((u32)~0U)
 #endif
 
+#ifdef NEED_BSEARCH
+static inline void *bsearch(const void *key, const void *base, size_t num, 
size_t size,
+int (*cmp)(const void *key, const void *elt))
+{
+const char *pivot;
+int result;
+
+while (num > 0) {
+pivot = base + (num >> 1) * size;
+result = cmp(key, pivot);
+
+if (result == 0)
+return (void *)pivot;
+
+if (result > 0) {
+base = pivot + size;
+num--;
+}
+num >>= 1;
+}
+
+return NULL;
+}
+#endif
+
 #endif /*  _COMPAT_H */
diff --git a/v4l/scripts/make_config_compat.pl 
b/v4l/scripts/make_config_compat.pl
index 9fdf10d..8ebeea3 100644
--- a/v4l/scripts/make_config_compat.pl
+++ b/v4l/scripts/make_config_compat.pl
@@ -705,6 +705,7 @@ sub check_other_dependencies()
check_files_for_func("PCI_DEVICE_SUB", "NEED_PCI_DEVICE_SUB", 
"include/linux/pci.h");
check_files_for_func("annotate_reachable", "NEED_ANNOTATE_REACHABLE", 
"include/linux/compiler.h");
check_files_for_func("U32_MAX", "NEED_U32_MAX", 
"include/linux/kernel.h");
+   check_files_for_func("bsearch", "NEED_BSEARCH", 
"include/linux/bsearch.h");
 
# For tests for uapi-dependent logic
check_files_for_func_uapi("usb_endpoint_maxp", 
"NEED_USB_ENDPOINT_MAXP", "usb/ch9.h");
-- 
2.7.4



[ragnatech:media-tree 2742/2771] drivers/media//dvb-core/dvb_frontend.c:2447:1: warning: the frame size of 1048 bytes is larger than 1024 bytes

2017-10-12 Thread kbuild test robot
tree:   git://git.ragnatech.se/linux media-tree
head:   8382e556b1a2f30c4bf866f021b33577a64f9ebf
commit: d73dcf0cdb95a47f7e4e991ab63dd30f6eb67b4e [2742/2771] media: 
dvb_frontend: cleanup ioctl handling logic
config: i386-randconfig-h1-10130413 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
git checkout d73dcf0cdb95a47f7e4e991ab63dd30f6eb67b4e
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   Cyclomatic Complexity 5 include/linux/compiler.h:__read_once_size
   Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:constant_test_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:variable_test_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls
   Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u32
   Cyclomatic Complexity 3 include/linux/log2.h:is_power_of_2
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_read
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_set
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_inc
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_dec_and_test
   Cyclomatic Complexity 1 arch/x86/include/asm/current.h:get_current
   Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
   Cyclomatic Complexity 2 include/linux/thread_info.h:test_ti_thread_flag
   Cyclomatic Complexity 2 include/linux/thread_info.h:check_object_size
   Cyclomatic Complexity 2 include/linux/thread_info.h:copy_overflow
   Cyclomatic Complexity 4 include/linux/thread_info.h:check_copy_size
   Cyclomatic Complexity 70 include/linux/ktime.h:ktime_divns
   Cyclomatic Complexity 1 include/linux/ktime.h:ktime_to_us
   Cyclomatic Complexity 1 include/linux/ktime.h:ktime_us_delta
   Cyclomatic Complexity 1 include/linux/ktime.h:ktime_add_us
   Cyclomatic Complexity 1 include/linux/timekeeping.h:ktime_get_boottime
   Cyclomatic Complexity 1 include/linux/refcount.h:refcount_set
   Cyclomatic Complexity 1 include/linux/refcount.h:refcount_inc
   Cyclomatic Complexity 1 include/linux/refcount.h:refcount_dec_and_test
   Cyclomatic Complexity 1 include/linux/sched.h:task_thread_info
   Cyclomatic Complexity 1 include/linux/sched.h:test_tsk_thread_flag
   Cyclomatic Complexity 1 include/linux/sched/signal.h:signal_pending
   Cyclomatic Complexity 1 include/linux/kasan.h:kasan_kmalloc
   Cyclomatic Complexity 28 include/linux/slab.h:kmalloc_index
   Cyclomatic Complexity 1 include/linux/slab.h:kmem_cache_alloc_trace
   Cyclomatic Complexity 1 include/linux/slab.h:kmalloc_order_trace
   Cyclomatic Complexity 67 include/linux/slab.h:kmalloc_large
   Cyclomatic Complexity 5 include/linux/slab.h:kmalloc
   Cyclomatic Complexity 1 include/linux/slab.h:kzalloc
   Cyclomatic Complexity 1 include/linux/semaphore.h:sema_init
   Cyclomatic Complexity 2 include/linux/uaccess.h:copy_to_user
   Cyclomatic Complexity 4 include/linux/poll.h:poll_wait
   Cyclomatic Complexity 1 include/linux/kref.h:kref_init
   Cyclomatic Complexity 1 include/linux/kref.h:kref_get
   Cyclomatic Complexity 2 include/linux/kref.h:kref_put
   Cyclomatic Complexity 2 include/linux/freezer.h:freezing
   Cyclomatic Complexity 2 include/linux/freezer.h:try_to_freeze_unsafe
   Cyclomatic Complexity 2 include/linux/freezer.h:try_to_freeze
   Cyclomatic Complexity 1 
drivers/media//dvb-core/dvb_frontend.c:dvb_frontend_put
   Cyclomatic Complexity 1 
drivers/media//dvb-core/dvb_frontend.c:dvb_frontend_get
   Cyclomatic Complexity 1 
drivers/media//dvb-core/dvb_frontend.c:has_get_frontend
   Cyclomatic Complexity 5 drivers/media//dvb-core/dvb_frontend.c:dvbv3_type
   Cyclomatic Complexity 5 
drivers/media//dvb-core/dvb_frontend.c:dvb_frontend_init
   Cyclomatic Complexity 2 
drivers/media//dvb-core/dvb_frontend.c:dvb_frontend_swzigzag_update_delay
   Cyclomatic Complexity 20 
drivers/media//dvb-core/dvb_frontend.c:dvb_frontend_swzigzag_autotune
   Cyclomatic Complexity 6 
drivers/media//dvb-core/dvb_frontend.c:dvb_frontend_is_exiting
   Cyclomatic Complexity 2 
drivers/media//dvb-core/dvb_frontend.c:dvb_frontend_should_wakeup
   Cyclomatic Complexity 3 
drivers/media//dvb-core/dvb_frontend.c:is_dvbv3_delsys
   Cyclomatic Complexity 4 
drivers/media//dvb-core/dvb_frontend.c:emulate_delivery_system
   Cyclomatic Complexity 10 
drivers/media//dvb-core/dvb_frontend.c:dvbv5_set_delivery_system
   Cyclomatic Complexity 7 
drivers/media//dvb-core/dvb_frontend.c:dvbv3_set_delivery_system
   Cyclomatic Complexity 2 
drivers/media//dvb-core/dvb_frontend.c:dvb_frontend_poll
   Cyclomatic Complexity 4 
drivers/media//dvb-core/dvb_frontend.c:dvb_frontend_suspend
   Cyclomatic Complexity 2 
drivers/media//dvb-core/dvb_frontend.c:dvb_frontend_invoke_release
   Cyclomatic Complexity 1 

[Patch 4/6] dt-bindings: media: ti-vpe: Document VPE driver

2017-10-12 Thread Benoit Parrot
Device Tree bindings for the Video Processing Engine (VPE) driver.

Signed-off-by: Benoit Parrot 
---
 Documentation/devicetree/bindings/media/ti-vpe.txt | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/ti-vpe.txt

diff --git a/Documentation/devicetree/bindings/media/ti-vpe.txt 
b/Documentation/devicetree/bindings/media/ti-vpe.txt
new file mode 100644
index ..c2ef93d08417
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/ti-vpe.txt
@@ -0,0 +1,41 @@
+Texas Instruments DRA7x VIDEO PROCESSING ENGINE (VPE)
+--
+
+The Video Processing Engine (VPE) is a key component for image post
+processing applications. VPE consist of a single memory to memory
+path which can perform chroma up/down sampling, deinterlacing,
+scaling and color space conversion.
+
+Required properties:
+- compatible: must be "ti,vpe"
+- reg: physical base address and length of the registers set for the 8
+   memory regions required;
+- reg-names: name associated with the memory regions described is ;
+- interrupts: should contain IRQ line for VPE;
+
+Example:
+   vpe {
+   compatible = "ti,vpe";
+   ti,hwmods = "vpe";
+   clocks = <_core_h23x2_ck>;
+   clock-names = "fck";
+   reg =   <0x489d 0x120>,
+   <0x489d0300 0x20>,
+   <0x489d0400 0x20>,
+   <0x489d0500 0x20>,
+   <0x489d0600 0x3c>,
+   <0x489d0700 0x80>,
+   <0x489d5700 0x18>,
+   <0x489dd000 0x400>;
+   reg-names = "vpe_top",
+   "vpe_chr_us0",
+   "vpe_chr_us1",
+   "vpe_chr_us2",
+   "vpe_dei",
+   "sc",
+   "csc",
+   "vpdma";
+   interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   };
-- 
2.9.0



[Patch 0/6] ARM: dts/hwmod: Add CAL and VPE nodes

2017-10-12 Thread Benoit Parrot
This patch series adds the needed HWMOD and DTSI nodes
for the CAL and VPE modules.
We also document the VPE DT bindings.

Benoit Parrot (6):
  ARM: dts: DRA72: Add CAL dtsi node
  ARM: DRA7: hwmod: Add CAL nodes
  ARM: OMAP: DRA7xx: Make CAM clock domain SWSUP only
  dt-bindings: media: ti-vpe: Document VPE driver
  ARM: DRA7: hwmod: Add VPE nodes
  ARM: dts: dra7: Add VPE dtsi node

 Documentation/devicetree/bindings/media/ti-vpe.txt | 41 ++
 arch/arm/boot/dts/dra7.dtsi| 26 +++
 arch/arm/boot/dts/dra72x.dtsi  | 31 
 arch/arm/mach-omap2/clockdomains7xx_data.c |  2 +-
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c  | 87 ++
 5 files changed, 186 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/media/ti-vpe.txt

-- 
2.9.0



[Patch 2/6] ARM: DRA7: hwmod: Add CAL nodes

2017-10-12 Thread Benoit Parrot
This patch adds the required hwmod nodes to support the Camera
Adaptation Layer (CAL) for the DRA72 family of devices.

- Added CAL hwmod entry in the DRA72x section.

The DRA72x TRM (Literature Number SPRUHP2x) states that CAL only
support NO_IDLE, FORCE_IDLE and SMART_IDLE.
Although CAL does not support standby mode per se hwmod would not
enabled the functional/interface clock if module is not a master.
Hence the SWSUP mode flags ifor SIDLE ans MSTANDBY are also enabled.
This ensure that i/f clocks are available when CAL is enabled.

Signed-off-by: Benoit Parrot 
---
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c | 44 +++
 1 file changed, 44 insertions(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
index 2f4f7002f38d..fc53b498975c 100644
--- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
@@ -240,6 +240,41 @@ static struct omap_hwmod dra7xx_bb2d_hwmod = {
 };
 
 /*
+ * 'cal' class
+ *
+ */
+
+static struct omap_hwmod_class_sysconfig dra7xx_cal_sysc = {
+   .sysc_offs  = 0x0010,
+   .sysc_flags = (SYSC_HAS_SIDLEMODE | SYSC_HAS_RESET_STATUS |
+  SYSC_HAS_SOFTRESET | SYSC_HAS_MIDLEMODE),
+   .idlemodes  = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+  MSTANDBY_FORCE | MSTANDBY_NO),
+   .sysc_fields= _hwmod_sysc_type2,
+};
+
+static struct omap_hwmod_class dra7xx_cal_hwmod_class = {
+   .name   = "cal",
+   .sysc   = _cal_sysc,
+};
+
+/* cal */
+static struct omap_hwmod dra7xx_cal_hwmod = {
+   .name   = "cal",
+   .class  = _cal_hwmod_class,
+   .clkdm_name = "cam_clkdm",
+   .main_clk   = "vip2_gclk_mux",
+   .flags  = (HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY),
+   .prcm = {
+   .omap4 = {
+   .clkctrl_offs = DRA7XX_CM_CAM_VIP2_CLKCTRL_OFFSET,
+   .context_offs = DRA7XX_RM_CAM_VIP2_CONTEXT_OFFSET,
+   .modulemode   = MODULEMODE_HWCTRL,
+   },
+   },
+};
+
+/*
  * 'counter' class
  *
  */
@@ -3901,6 +3936,14 @@ static struct omap_hwmod_ocp_if dra7xx_l4_per2__vcp2 = {
.user   = OCP_USER_MPU | OCP_USER_SDMA,
 };
 
+/* l4_per3 -> cal */
+static struct omap_hwmod_ocp_if dra7xx_l4_per3__cal = {
+   .master = _l4_per3_hwmod,
+   .slave  = _cal_hwmod,
+   .clk= "l3_iclk_div",
+   .user   = OCP_USER_MPU | OCP_USER_SDMA,
+};
+
 /* l4_wkup -> wd_timer2 */
 static struct omap_hwmod_ocp_if dra7xx_l4_wkup__wd_timer2 = {
.master = _l4_wkup_hwmod,
@@ -4082,6 +4125,7 @@ static struct omap_hwmod_ocp_if *dra74x_hwmod_ocp_ifs[] 
__initdata = {
 };
 
 static struct omap_hwmod_ocp_if *dra72x_hwmod_ocp_ifs[] __initdata = {
+   _l4_per3__cal,
NULL,
 };
 
-- 
2.9.0



[Patch 6/6] ARM: dts: dra7: Add VPE dtsi node

2017-10-12 Thread Benoit Parrot
Add the necessary node and configuration data for the VPE (Video
Processing Engine) hardware block on DRA7x.

The corresponding driver for this entry is in
drivers/media/platform/ti-vpe/vpe.c.

Signed-off-by: Benoit Parrot 
---
 arch/arm/boot/dts/dra7.dtsi | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 02a136a4661a..f302d2e5eede 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -2018,6 +2018,32 @@
clocks = <_iclk_div>;
clock-names = "fck";
};
+
+   vpe {
+   compatible = "ti,vpe";
+   ti,hwmods = "vpe";
+   clocks = <_core_h23x2_ck>;
+   clock-names = "fck";
+   reg = <0x489d 0x120>,
+ <0x489d0300 0x20>,
+ <0x489d0400 0x20>,
+ <0x489d0500 0x20>,
+ <0x489d0600 0x3c>,
+ <0x489d0700 0x80>,
+ <0x489d5700 0x18>,
+ <0x489dd000 0x400>;
+   reg-names = "vpe_top",
+   "vpe_chr_us0",
+   "vpe_chr_us1",
+   "vpe_chr_us2",
+   "vpe_dei",
+   "sc",
+   "csc",
+   "vpdma";
+   interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   };
};
 
thermal_zones: thermal-zones {
-- 
2.9.0



[Patch 1/6] ARM: dts: DRA72: Add CAL dtsi node

2017-10-12 Thread Benoit Parrot
This patch adds the required dtsi node to support the Camera
Adaptation Layer (CAL) for the DRA72 family of devices.

- Added CAL entry in dra72x.dtsi.

Signed-off-by: Benoit Parrot 
---
 arch/arm/boot/dts/dra72x.dtsi | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/arch/arm/boot/dts/dra72x.dtsi b/arch/arm/boot/dts/dra72x.dtsi
index 67107605fb4c..d0ba4f238084 100644
--- a/arch/arm/boot/dts/dra72x.dtsi
+++ b/arch/arm/boot/dts/dra72x.dtsi
@@ -17,6 +17,37 @@
interrupt-parent = <>;
interrupts = ;
};
+
+   ocp {
+   cal: cal@4845b000 {
+   compatible = "ti,dra72-cal";
+   ti,hwmods = "cal";
+   reg = <0x4845B000 0x400>,
+ <0x4845B800 0x40>,
+ <0x4845B900 0x40>,
+ <0x4A002e94 0x4>;
+   reg-names = "cal_top",
+   "cal_rx_core0",
+   "cal_rx_core1",
+   "camerrx_control";
+   interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   csi2_0: port@0 {
+   reg = <0>;
+   };
+   csi2_1: port@1 {
+   reg = <1>;
+   };
+   };
+   };
+   };
 };
 
  {
-- 
2.9.0



[Patch 3/6] ARM: OMAP: DRA7xx: Make CAM clock domain SWSUP only

2017-10-12 Thread Benoit Parrot
HWSUP on this domain is only working when VIP1 probes.
If only VIP2 on DRA74x or CAL on DRA72x probes the domain does
not get enabled. This might indicates an issue in the HW Auto
state-machine for this domain.

Work around is to set the CAM domain to use SWSUP only.

Signed-off-by: Benoit Parrot 
---
 arch/arm/mach-omap2/clockdomains7xx_data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/clockdomains7xx_data.c 
b/arch/arm/mach-omap2/clockdomains7xx_data.c
index 67ebff829cf2..dd37efa2c652 100644
--- a/arch/arm/mach-omap2/clockdomains7xx_data.c
+++ b/arch/arm/mach-omap2/clockdomains7xx_data.c
@@ -609,7 +609,7 @@ static struct clockdomain cam_7xx_clkdm = {
.dep_bit  = DRA7XX_CAM_STATDEP_SHIFT,
.wkdep_srcs   = cam_wkup_sleep_deps,
.sleepdep_srcs= cam_wkup_sleep_deps,
-   .flags= CLKDM_CAN_HWSUP_SWSUP,
+   .flags= CLKDM_CAN_SWSUP,
 };
 
 static struct clockdomain l4per_7xx_clkdm = {
-- 
2.9.0



[Patch 5/6] ARM: DRA7: hwmod: Add VPE nodes

2017-10-12 Thread Benoit Parrot
Add hwmod entries for VPE (Video Processing Engine) hardware block
found in DRA7x family of devices.

DRA75x_DRA74x_ES1.1 Version T Technical Reference Manual
(Literature Number SPRUHI2T) states that VPE only support NO_STANDBY,
FORCE_STANDBY, NO_IDLE, FORCE_IDLE and SMART_IDLE.
The hwmod flags were set to reflect this fact and make sure that
both are software supervised (SWSUSP).

Signed-off-by: Benoit Parrot 
---
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
index fc53b498975c..c0bbc1099a11 100644
--- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
@@ -240,6 +240,40 @@ static struct omap_hwmod dra7xx_bb2d_hwmod = {
 };
 
 /*
+ * 'vpe' class
+ *
+ */
+
+static struct omap_hwmod_class_sysconfig dra7xx_vpe_sysc = {
+   .sysc_offs  = 0x0010,
+   .sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE),
+   .idlemodes  = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+  MSTANDBY_FORCE | MSTANDBY_NO |
+  MSTANDBY_SMART),
+   .sysc_fields= _hwmod_sysc_type2,
+};
+
+static struct omap_hwmod_class dra7xx_vpe_hwmod_class = {
+   .name   = "vpe",
+   .sysc   = _vpe_sysc,
+};
+
+/* vpe */
+static struct omap_hwmod dra7xx_vpe_hwmod = {
+   .name   = "vpe",
+   .class  = _vpe_hwmod_class,
+   .clkdm_name = "vpe_clkdm",
+   .flags  = (HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY),
+   .prcm = {
+   .omap4 = {
+   .clkctrl_offs = DRA7XX_CM_VPE_VPE_CLKCTRL_OFFSET,
+   .context_offs = DRA7XX_RM_VPE_VPE_CONTEXT_OFFSET,
+   .modulemode   = MODULEMODE_HWCTRL,
+   },
+   },
+};
+
+/*
  * 'cal' class
  *
  */
@@ -3936,6 +3970,14 @@ static struct omap_hwmod_ocp_if dra7xx_l4_per2__vcp2 = {
.user   = OCP_USER_MPU | OCP_USER_SDMA,
 };
 
+/* l4_per3 -> vpe */
+static struct omap_hwmod_ocp_if dra7xx_l4_per3__vpe = {
+   .master = _l4_per3_hwmod,
+   .slave  = _vpe_hwmod,
+   .clk= "l3_iclk_div",
+   .user   = OCP_USER_MPU | OCP_USER_SDMA,
+};
+
 /* l4_per3 -> cal */
 static struct omap_hwmod_ocp_if dra7xx_l4_per3__cal = {
.master = _l4_per3_hwmod,
@@ -4099,6 +4141,7 @@ static struct omap_hwmod_ocp_if *dra7xx_hwmod_ocp_ifs[] 
__initdata = {
_l4_per2__vcp1,
_l3_main_1__vcp2,
_l4_per2__vcp2,
+   _l4_per3__vpe,
_l4_wkup__wd_timer2,
_l4_per2__epwmss0,
_l4_per2__epwmss1,
-- 
2.9.0



[PATCH 4/4] media: ov7670: add get_fmt() pad ops callback

2017-10-12 Thread Akinobu Mita
This enables to print the current format on the source pad of the ov7670
subdev by media-ctl.

Cc: Jonathan Corbet 
Cc: Mauro Carvalho Chehab 
Signed-off-by: Akinobu Mita 
---
 drivers/media/i2c/ov7670.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 38e1876..9fe99c5 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -234,6 +234,7 @@ struct ov7670_info {
struct v4l2_ctrl *hue;
};
struct ov7670_format_struct *fmt;  /* Current format */
+   struct ov7670_win_size *wsize;  /* Current format */
struct clk *clk;
struct gpio_desc *resetb_gpio;
struct gpio_desc *pwdn_gpio;
@@ -875,6 +876,36 @@ static int ov7670_set_framerate_legacy(struct v4l2_subdev 
*sd,
return ov7670_write(sd, REG_CLKRC, info->clkrc);
 }
 
+static int ov7670_get_fmt(struct v4l2_subdev *sd,
+   struct v4l2_subdev_pad_config *cfg,
+   struct v4l2_subdev_format *fmt)
+{
+   struct ov7670_info *info = to_state(sd);
+
+   if (fmt->pad)
+   return -EINVAL;
+
+   if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
+#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
+   struct v4l2_mbus_framefmt *mf;
+
+   mf = v4l2_subdev_get_try_format(sd, cfg, 0);
+   fmt->format = *mf;
+   return 0;
+#else
+   return -ENOTTY;
+#endif
+   }
+
+   fmt->format.colorspace = info->fmt->colorspace;
+   fmt->format.code = info->fmt->mbus_code;
+   fmt->format.field = V4L2_FIELD_NONE;
+   fmt->format.width = info->wsize->width;
+   fmt->format.height = info->wsize->height;
+
+   return 0;
+}
+
 /*
  * Store a set of start/stop values into the camera.
  */
@@ -1026,6 +1057,7 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
if (wsize->regs)
ret = ov7670_write_array(sd, wsize->regs);
info->fmt = ovfmt;
+   info->wsize = wsize;
 
/*
 * If we're running RGB565, we must rewrite clkrc after setting
@@ -1529,6 +1561,7 @@ static const struct v4l2_subdev_pad_ops ov7670_pad_ops = {
.enum_frame_interval = ov7670_enum_frame_interval,
.enum_frame_size = ov7670_enum_frame_size,
.enum_mbus_code = ov7670_enum_mbus_code,
+   .get_fmt = ov7670_get_fmt,
.set_fmt = ov7670_set_fmt,
 };
 
@@ -1647,6 +1680,7 @@ static int ov7670_probe(struct i2c_client *client,
 
info->devtype = _devdata[id->driver_data];
info->fmt = _formats[0];
+   info->wsize = >devtype->win_sizes[0];
info->clkrc = 0;
 
/* Set default frame rate to 30 fps */
-- 
2.7.4



[PATCH 3/4] media: ov7670: add media controller support

2017-10-12 Thread Akinobu Mita
Create a source pad and set the media controller type to the sensor.

Cc: Jonathan Corbet 
Cc: Mauro Carvalho Chehab 
Signed-off-by: Akinobu Mita 
---
 drivers/media/i2c/ov7670.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 4f89a51..38e1876 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -214,6 +214,9 @@ struct ov7670_devtype {
 struct ov7670_format_struct;  /* coming later */
 struct ov7670_info {
struct v4l2_subdev sd;
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_pad pad;
+#endif
struct v4l2_ctrl_handler hdl;
struct {
/* gain cluster */
@@ -1654,6 +1657,14 @@ static int ov7670_probe(struct i2c_client *client,
if (info->pclk_hb_disable)
ov7670_write(sd, REG_COM10, COM10_PCLK_HB);
 
+#ifdef CONFIG_MEDIA_CONTROLLER
+   info->pad.flags = MEDIA_PAD_FL_SOURCE;
+   sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
+   ret = media_entity_pads_init(>entity, 1, >pad);
+   if (ret)
+   goto clk_disable;
+#endif
+
v4l2_ctrl_handler_init(>hdl, 10);
v4l2_ctrl_new_std(>hdl, _ctrl_ops,
V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
@@ -1700,6 +1711,9 @@ static int ov7670_probe(struct i2c_client *client,
 
 hdl_free:
v4l2_ctrl_handler_free(>hdl);
+#ifdef CONFIG_MEDIA_CONTROLLER
+   media_entity_cleanup(>entity);
+#endif
 clk_disable:
clk_disable_unprepare(info->clk);
return ret;
@@ -1713,6 +1727,9 @@ static int ov7670_remove(struct i2c_client *client)
 
v4l2_async_unregister_subdev(sd);
v4l2_ctrl_handler_free(>hdl);
+#ifdef CONFIG_MEDIA_CONTROLLER
+   media_entity_cleanup(>entity);
+#endif
clk_disable_unprepare(info->clk);
return 0;
 }
-- 
2.7.4



[PATCH 1/4] media: ov7670: create subdevice device node

2017-10-12 Thread Akinobu Mita
Set the V4L2_SUBDEV_FL_HAS_DEVNODE flag for the subdevice so it is
possible to create a subdevice device node.

Cc: Jonathan Corbet 
Cc: Mauro Carvalho Chehab 
Signed-off-by: Akinobu Mita 
---
 drivers/media/i2c/ov7670.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index e88549f..d3f7d61 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -1585,6 +1585,7 @@ static int ov7670_probe(struct i2c_client *client,
return -ENOMEM;
sd = >sd;
v4l2_i2c_subdev_init(sd, client, _ops);
+   sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
info->clock_speed = 30; /* default: a guess */
if (client->dev.platform_data) {
-- 
2.7.4



[PATCH 2/4] media: ov7670: use v4l2_async_unregister_subdev()

2017-10-12 Thread Akinobu Mita
The sub-device for ov7670 is registered by v4l2_async_register_subdev().
So it should be unregistered by v4l2_async_unregister_subdev() instead of
v4l2_device_unregister_subdev().

Cc: Jonathan Corbet 
Cc: Mauro Carvalho Chehab 
Signed-off-by: Akinobu Mita 
---
 drivers/media/i2c/ov7670.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index d3f7d61..4f89a51 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1710,7 +1711,7 @@ static int ov7670_remove(struct i2c_client *client)
struct v4l2_subdev *sd = i2c_get_clientdata(client);
struct ov7670_info *info = to_state(sd);
 
-   v4l2_device_unregister_subdev(sd);
+   v4l2_async_unregister_subdev(sd);
v4l2_ctrl_handler_free(>hdl);
clk_disable_unprepare(info->clk);
return 0;
-- 
2.7.4



[PATCH 0/4] media: ov7670: add media controller support

2017-10-12 Thread Akinobu Mita
This series adds media controller support and other related changes to the
OV7670 which is cheap and highly available CMOS image sensor for hobbyists.

This enables to control a video pipeline system with the OV7670.  I've
tested this with the xilinx video IP pipeline.

Akinobu Mita (4):
  media: ov7670: create subdevice device node
  media: ov7670: use v4l2_async_unregister_subdev()
  media: ov7670: add media controller support
  media: ov7670: add get_fmt() pad ops callback

 drivers/media/i2c/ov7670.c | 55 +-
 1 file changed, 54 insertions(+), 1 deletion(-)

Cc: Jonathan Corbet 
Cc: Mauro Carvalho Chehab 
-- 
2.7.4



[PATCH] media: xilinx-video: fix bad of_node_put() on endpoint error

2017-10-12 Thread Akinobu Mita
When iterating through all endpoints using of_graph_get_next_endpoint(),
the refcount of the returned endpoint node is incremented and the refcount
of the node which is passed as previous endpoint is decremented.

So the caller doesn't need to call of_node_put() for each iterated node
except for error exit paths.  Otherwise we get "OF: ERROR: Bad
of_node_put() on ..." messages.

Cc: Hyun Kwon 
Cc: Laurent Pinchart 
Signed-off-by: Akinobu Mita 
---
 drivers/media/platform/xilinx/xilinx-vipp.c | 16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c 
b/drivers/media/platform/xilinx/xilinx-vipp.c
index ebfdf33..e5c80c9 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -76,20 +76,16 @@ static int xvip_graph_build_one(struct 
xvip_composite_device *xdev,
struct xvip_graph_entity *ent;
struct v4l2_fwnode_link link;
struct device_node *ep = NULL;
-   struct device_node *next;
int ret = 0;
 
dev_dbg(xdev->dev, "creating links for entity %s\n", local->name);
 
while (1) {
/* Get the next endpoint and parse its link. */
-   next = of_graph_get_next_endpoint(entity->node, ep);
-   if (next == NULL)
+   ep = of_graph_get_next_endpoint(entity->node, ep);
+   if (ep == NULL)
break;
 
-   of_node_put(ep);
-   ep = next;
-
dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep);
 
ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), );
@@ -200,7 +196,6 @@ static int xvip_graph_build_dma(struct 
xvip_composite_device *xdev)
struct xvip_graph_entity *ent;
struct v4l2_fwnode_link link;
struct device_node *ep = NULL;
-   struct device_node *next;
struct xvip_dma *dma;
int ret = 0;
 
@@ -208,13 +203,10 @@ static int xvip_graph_build_dma(struct 
xvip_composite_device *xdev)
 
while (1) {
/* Get the next endpoint and parse its link. */
-   next = of_graph_get_next_endpoint(node, ep);
-   if (next == NULL)
+   ep = of_graph_get_next_endpoint(node, ep);
+   if (ep == NULL)
break;
 
-   of_node_put(ep);
-   ep = next;
-
dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep);
 
ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), );
-- 
2.7.4



[PATCH] dt-bindings: media: xilinx: fix typo in example

2017-10-12 Thread Akinobu Mita
Fix typo s/:/;/

Cc: Rob Herring 
Cc: Hyun Kwon 
Cc: Laurent Pinchart 
Signed-off-by: Akinobu Mita 
---
 Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt 
b/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt
index 9dd86b3..439351a 100644
--- a/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt
+++ b/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt
@@ -66,6 +66,6 @@ Example:
tpg1_out: endpoint {
remote-endpoint = <_in0>;
};
-   }:
+   };
};
};
-- 
2.7.4



Re: [PATCH v3 04/26] media: lirc_zilog: remove receiver

2017-10-12 Thread Sean Young
Hi Devin, Andy,

On Wed, Oct 11, 2017 at 10:25:34PM -0400, Devin Heitmueller wrote:
> Hi Andy,
> 
> > 5. Rx and IR Learn both use the same external hardware.  Not
> > coordinating Rx with Learn mode in the same driver, will prevent Learn
> > operation from working.  That is, if Learn mode is ever implemented.
> > (Once upon a time, I was planning on doing that.  But I have no time
> > for that anymore.)
> 
> There's not really any infrastructure in Linux that maps to the
> Zilog's "learning mode" functionality.  Usually I would just tell
> users to do the learning under Windows and send me the resulting .ini
> file (which we could then add to the database).
> 
> I had planned on getting rid of the database entirely and just
> converting an MCE compatible pulse train to the blasting format
> required by the Zilog firmware (using the awesome work you sent me
> privately), but the fact of the matter is that nobody cares and MCEUSB
> devices are $20 online.

I wouldn't mind working on that, if I had the blasting format. :)

Note that you can have IR Rx and Tx on a gpio port, so it can get even
cheaper than $20. The hauppauge solution with a z8 microcontroller
with it's non-obvious firmware and i2c format seem a bit ludricous.

> > I'm glad someone remembers all this stuff.  I'm assuming you had more
> > pain with this than I ever did.
> 
> This would be a safe assumption.  I probably put about a month's worth
> of engineering into driver work for the Zilog, which seems
> extraordinary given how simple something like an IR blaster/receiver
> is supposed to be.  I guess that's the fun of proving out a new
> hardware design as opposed to just making something work under Linux
> that is already known to work under Windows.
> 
> > I never owned an HD-PVR.
> 
> I'm sure I have a spare or two if you really want one (not that you
> have the time to muck with such things nowadays).  :-)
> 
> The HD-PVR was a bit of a weird case compared to devices like ivtv and
> cx18 because it was technically multi-master (I2C commands came both
> from the host and from the onboard SOC).  Hence you could have weird
> cases where one would block the other at unexpected times.  I2C
> commands to the Zilog would hold the bus which would delay the onboard
> firmware from issuing commands to the video decoder (fun timing
> issues).  There was also some weird edge case I don't recall the
> details of that prompted them to add an I2C gate in later board
> revisions.

Interesting.

Thanks

Sean


Re: [PATCH v3 2/2] ARM: dts: tegra20: Add video decoder node

2017-10-12 Thread Dmitry Osipenko
Hello Vladimir,

On 12.10.2017 10:43, Vladimir Zapolskiy wrote:
> Hello Dmitry,
> 
> On 10/11/2017 11:08 PM, Dmitry Osipenko wrote:
>> Add a device node for the video decoder engine found on Tegra20.
>>
>> Signed-off-by: Dmitry Osipenko 
>> ---
>>  arch/arm/boot/dts/tegra20.dtsi | 17 +
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
>> index 7c85f97f72ea..1b5d54b6c0cb 100644
>> --- a/arch/arm/boot/dts/tegra20.dtsi
>> +++ b/arch/arm/boot/dts/tegra20.dtsi
>> @@ -249,6 +249,23 @@
>>  */
>>  };
>>  
>> +vde@6001a000 {
>> +compatible = "nvidia,tegra20-vde";
>> +reg = <0x6001a000 0x3D00/* VDE registers */
>> +   0x4400 0x3FC00>; /* IRAM region */
> 
> this notation of a used region in IRAM is non-standard and potentially it
> may lead to conflicts for IRAM resource between users.
> 
> My proposal is to add a valid device tree node to describe an IRAM region
> firstly, then reserve a subregion in it by using a new "iram" property.
> 

The defined in DT IRAM region used by VDE isn't exactly correct, actually it
should be much smaller. I don't know exactly what parts of IRAM VDE uses, for
now it is just safer to assign the rest of the IRAM region to VDE.

I'm not sure whether it really worthy to use a dynamic allocator for a single
static allocation, but maybe it would come handy later.. Stephen / Jon /
Thierry, what do you think?

> 8<
> From: Vladimir Zapolskiy 
> Date: Thu, 12 Oct 2017 10:25:45 +0300
> Subject: [PATCH] ARM: tegra: add device tree node to describe IRAM on Tegra20
> 
> All Tegra20 SoCs contain 256KiB IRAM, which is used to store
> resume code and by a video decoder engine.
> 
> Signed-off-by: Vladimir Zapolskiy 
> ---
>  arch/arm/boot/dts/tegra20.dtsi | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
> index 7c85f97f72ea..fd2843c90920 100644
> --- a/arch/arm/boot/dts/tegra20.dtsi
> +++ b/arch/arm/boot/dts/tegra20.dtsi
> @@ -9,6 +9,14 @@
>   compatible = "nvidia,tegra20";
>   interrupt-parent = <>;
>  
> + iram@4000 {
> + compatible = "mmio-sram";
> + reg = <0x4000 0x4>;
> + #address-cells = <1>;
> + #size-cells = <1>;
> + ranges = <0 0x4000 0x4>;
> + };
> +
>   host1x@5000 {
>   compatible = "nvidia,tegra20-host1x", "simple-bus";
>   reg = <0x5000 0x00024000>;
> 8<
> 
> Please add the change above to your next version of the series, or
> if you wish I can send it separately for review by Thierry.
> 
> After applying that change you do define a region in IRAM for the exclusive
> usage by a video decoder engine and add an 'iram' property:
> 

Newer Tegra generations also have the IRAM, so I think Tegra30/114/124 DT's
should also include the same IRAM node for consistency. I'll extend your patch
to cover other Tegra's and include it in v4 if you don't mind and if Stephen /
Jon / Thierry would approve your proposal.

> 8<
> diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
> index fd2843c90920..5133fbac2185 100644
> --- a/arch/arm/boot/dts/tegra20.dtsi
> +++ b/arch/arm/boot/dts/tegra20.dtsi
> @@ -15,6 +15,11 @@
>   #address-cells = <1>;
>   #size-cells = <1>;
>   ranges = <0 0x4000 0x4>;
> +
> + vde_pool: vde {
> + reg = <0x400 0x3fc00>;
> + pool;
> + };
>   };
>  
>   host1x@5000 {
> [snip]
> 
> + vde@6001a000 {
> + compatible = "nvidia,tegra20-vde";
> + reg = <0x6001a000 0x3d00>;  /* VDE registers */
> + iram = <_pool>; /* IRAM region */
> [snip]
> 8<
> 
> And finally in the driver you'll use genalloc API to access the IRAM
> region, for that you can find ready examples in the kernel source code.
> 

Thank you very much for taking a look at the patch!


Re: [PATCH v3 04/26] media: lirc_zilog: remove receiver

2017-10-12 Thread Sean Young
On Wed, Oct 11, 2017 at 08:25:12PM -0400, Devin Heitmueller wrote:
> > There's an ir_lock mutex in the driver to prevent simultaneous access to 
> > the Rx and Tx functions of the z8.  Accessing Rx and Tx functions of the 
> > chip together can cause it to do the wrong thing (sometimes hang?), IIRC.
> >
> > I'll see if I can dig up my old disassembly of the z8's firmware to see if 
> > that interlock is strictly necessary.
> >
> > Yes I know ir-kbd-i2c is in mainline, but as I said, I had reasons for 
> > avoiding it when using Tx operation of the chip.  It's been 7 years, and 
> > I'm getting too old to remember the reasons. :P
> 
> Yeah, you definitely don't want to be issuing requests to the Rx and
> Tx addresses at the same time.  Very bad things will happen.

Right, ok. That's good to know. I'll have to merge the Tx code with 
ir-kbd-i2c or port lirc_zilog Rx to rc-core.

> Also, what is the polling interval for ir-kbd-i2c?

lirc_zilog polls every 260ms and ir-kbd-i2c polls every 100ms.

>  If it's too high
> you can wedge the I2C bus (depending on the hardware design).
> Likewise, many people disable IR RX entirely (which is trivial to do
> with lirc_zilog through a modprobe optoin).

Yes, lirc_zilog has a tx_only option.

>  This is because early
> versions of the HDPVR had issues where polling too often can interfere
> with traffic that configures the component receiver chip.  This was
> improved in later versions of the design, but many people found it was
> just easiest to disable RX since they don't use it (i.e. they would
> use the blaster for controlling their STB but use a separate IR
> receiver).

That's very interesting.

> Are you testing with video capture actively in use?  If you're testing
> the IR interface without an active HD capture in progress you're
> likely to miss some of these edge cases (in particular those which
> would hang the encoder).

I had not, but I'll do that now.

> I'm not against the removal of duplicate code in general, but you have
> to tread carefully because there are plenty of non-obvious edge cases
> to consider.

Absolutely, thank you for your insights. 

Rather than relying on ir-kbd-i2c for receive, I can port lirc_zilog
to rc-core and leave much of it in place.

Thanks

Sean


Re: [PATCH v3 2/2] ARM: dts: tegra20: Add video decoder node

2017-10-12 Thread Dmitry Osipenko
On 12.10.2017 13:57, Jon Hunter wrote:
> 
> On 12/10/17 11:51, Dmitry Osipenko wrote:
>> On 12.10.2017 11:49, Jon Hunter wrote:
>>>
>>> On 11/10/17 21:08, Dmitry Osipenko wrote:
 Add a device node for the video decoder engine found on Tegra20.

 Signed-off-by: Dmitry Osipenko 
 ---
  arch/arm/boot/dts/tegra20.dtsi | 17 +
  1 file changed, 17 insertions(+)

 diff --git a/arch/arm/boot/dts/tegra20.dtsi 
 b/arch/arm/boot/dts/tegra20.dtsi
 index 7c85f97f72ea..1b5d54b6c0cb 100644
 --- a/arch/arm/boot/dts/tegra20.dtsi
 +++ b/arch/arm/boot/dts/tegra20.dtsi
 @@ -249,6 +249,23 @@
*/
};
  
 +  vde@6001a000 {
 +  compatible = "nvidia,tegra20-vde";
 +  reg = <0x6001a000 0x3D00/* VDE registers */
 + 0x4400 0x3FC00>; /* IRAM region */
 +  reg-names = "regs", "iram";
 +  interrupts = , /* UCQ error 
 interrupt */
 +   , /* Sync token 
 interrupt */
 +   , /* BSE-V 
 interrupt */
 +   , /* BSE-A 
 interrupt */
 +   ; /* SXE interrupt 
 */
 +  interrupt-names = "ucq-error", "sync-token", "bsev", "bsea", 
 "sxe";
 +  clocks = <_car TEGRA20_CLK_VDE>;
 +  clock-names = "vde";
 +  resets = <_car 61>;
 +  reset-names = "vde";
 +  };
 +
>>>
>>> I don't see any binding documentation for this node. We need to make
>>> sure we add this.
>>>
>>
>> It's in the first patch.
>>
>> +++ b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-vde.txt
>>
> 
> Ah yes indeed, then that needs to be a separate patch.
> 

Okay


Re: [PATCH v3 2/2] ARM: dts: tegra20: Add video decoder node

2017-10-12 Thread Jon Hunter

On 12/10/17 11:51, Dmitry Osipenko wrote:
> On 12.10.2017 11:49, Jon Hunter wrote:
>>
>> On 11/10/17 21:08, Dmitry Osipenko wrote:
>>> Add a device node for the video decoder engine found on Tegra20.
>>>
>>> Signed-off-by: Dmitry Osipenko 
>>> ---
>>>  arch/arm/boot/dts/tegra20.dtsi | 17 +
>>>  1 file changed, 17 insertions(+)
>>>
>>> diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
>>> index 7c85f97f72ea..1b5d54b6c0cb 100644
>>> --- a/arch/arm/boot/dts/tegra20.dtsi
>>> +++ b/arch/arm/boot/dts/tegra20.dtsi
>>> @@ -249,6 +249,23 @@
>>> */
>>> };
>>>  
>>> +   vde@6001a000 {
>>> +   compatible = "nvidia,tegra20-vde";
>>> +   reg = <0x6001a000 0x3D00/* VDE registers */
>>> +  0x4400 0x3FC00>; /* IRAM region */
>>> +   reg-names = "regs", "iram";
>>> +   interrupts = , /* UCQ error 
>>> interrupt */
>>> +, /* Sync token 
>>> interrupt */
>>> +, /* BSE-V 
>>> interrupt */
>>> +, /* BSE-A 
>>> interrupt */
>>> +; /* SXE interrupt 
>>> */
>>> +   interrupt-names = "ucq-error", "sync-token", "bsev", "bsea", 
>>> "sxe";
>>> +   clocks = <_car TEGRA20_CLK_VDE>;
>>> +   clock-names = "vde";
>>> +   resets = <_car 61>;
>>> +   reset-names = "vde";
>>> +   };
>>> +
>>
>> I don't see any binding documentation for this node. We need to make
>> sure we add this.
>>
> 
> It's in the first patch.
> 
> +++ b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-vde.txt
>

Ah yes indeed, then that needs to be a separate patch.

Cheers
Jon

-- 
nvpublic


Re: [PATCH v3 2/2] ARM: dts: tegra20: Add video decoder node

2017-10-12 Thread Dmitry Osipenko
On 12.10.2017 11:49, Jon Hunter wrote:
> 
> On 11/10/17 21:08, Dmitry Osipenko wrote:
>> Add a device node for the video decoder engine found on Tegra20.
>>
>> Signed-off-by: Dmitry Osipenko 
>> ---
>>  arch/arm/boot/dts/tegra20.dtsi | 17 +
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
>> index 7c85f97f72ea..1b5d54b6c0cb 100644
>> --- a/arch/arm/boot/dts/tegra20.dtsi
>> +++ b/arch/arm/boot/dts/tegra20.dtsi
>> @@ -249,6 +249,23 @@
>>  */
>>  };
>>  
>> +vde@6001a000 {
>> +compatible = "nvidia,tegra20-vde";
>> +reg = <0x6001a000 0x3D00/* VDE registers */
>> +   0x4400 0x3FC00>; /* IRAM region */
>> +reg-names = "regs", "iram";
>> +interrupts = , /* UCQ error 
>> interrupt */
>> + , /* Sync token 
>> interrupt */
>> + , /* BSE-V 
>> interrupt */
>> + , /* BSE-A 
>> interrupt */
>> + ; /* SXE interrupt 
>> */
>> +interrupt-names = "ucq-error", "sync-token", "bsev", "bsea", 
>> "sxe";
>> +clocks = <_car TEGRA20_CLK_VDE>;
>> +clock-names = "vde";
>> +resets = <_car 61>;
>> +reset-names = "vde";
>> +};
>> +
> 
> I don't see any binding documentation for this node. We need to make
> sure we add this.
> 

It's in the first patch.

+++ b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-vde.txt


Re: [PATCHv2 0/9] omapdrm: hdmi4: add CEC support

2017-10-12 Thread Tomi Valkeinen

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

On 12/10/17 12:42, Hans Verkuil wrote:
> On 10/12/17 10:03, Tomi Valkeinen wrote:
>>
>> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
>> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>>
>> On 12/10/17 09:50, Hans Verkuil wrote:
>>
 I can't test with a TV, so no CEC for me... But otherwise I think the
 series works ok now, and looks ok. So I'll apply, but it's a bit late
 for the next merge window, so I'll aim for 4.15 with this.
>>>
>>> What is the status? Do you need anything from me? I'd like to get this in 
>>> for 4.15.
>>
>> Thanks for reminding. I think I would've forgotten...
>>
>> I sent the pull request, so all should be fine.
>>
>> If possible, please test the pull request, preferably with drm-next
>> merged (git://people.freedesktop.org/~airlied/linux drm-next), as I
>> don't have a CEC capable display.
> 
> I'll try to do that tomorrow or Monday.
> 
> I have one other question for you: does keeping ls_oe_gpio high all the
> time affect this old bug fix:
> 
> https://github.com/myfluxi/xxICSKernel/commit/21189f03d3ec3a74d9949907c828410d7a9a86d5

No, the issue is about the HDMI PHY. The i2c lines are not related.
LS_OE only affects the i2c.

> I don't think so, but I'm not 100% sure. As far as I can see the PHY power
> sequence (OFF, TXON, LDOON) does not change and that seems to be the
> crucial fix according to the commit above.
> 
> I would hate being responsible for lots of burnt-out pandaboards :-)
> 
> There is an alternative solution: when there is no HPD then it is also
> possible to pull the ls_oe_gpio high only when transmitting a CEC message.
> 
> That would obviously require some code changes.
> 
> Sorry for raising this issue so late, but this just came up today in
> internal discussions.

Well, it would be nice to not have LS_OE enabled all the time. But I'm
not sure how much that really matters. I'm sure it uses some power, but
is that even measurable, I have no idea.

 Tomi



Re: [PATCHv2 0/9] omapdrm: hdmi4: add CEC support

2017-10-12 Thread Hans Verkuil
On 10/12/17 10:03, Tomi Valkeinen wrote:
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> On 12/10/17 09:50, Hans Verkuil wrote:
> 
>>> I can't test with a TV, so no CEC for me... But otherwise I think the
>>> series works ok now, and looks ok. So I'll apply, but it's a bit late
>>> for the next merge window, so I'll aim for 4.15 with this.
>>
>> What is the status? Do you need anything from me? I'd like to get this in 
>> for 4.15.
> 
> Thanks for reminding. I think I would've forgotten...
> 
> I sent the pull request, so all should be fine.
> 
> If possible, please test the pull request, preferably with drm-next
> merged (git://people.freedesktop.org/~airlied/linux drm-next), as I
> don't have a CEC capable display.

I'll try to do that tomorrow or Monday.

I have one other question for you: does keeping ls_oe_gpio high all the
time affect this old bug fix:

https://github.com/myfluxi/xxICSKernel/commit/21189f03d3ec3a74d9949907c828410d7a9a86d5

I don't think so, but I'm not 100% sure. As far as I can see the PHY power
sequence (OFF, TXON, LDOON) does not change and that seems to be the
crucial fix according to the commit above.

I would hate being responsible for lots of burnt-out pandaboards :-)

There is an alternative solution: when there is no HPD then it is also
possible to pull the ls_oe_gpio high only when transmitting a CEC message.

That would obviously require some code changes.

Sorry for raising this issue so late, but this just came up today in
internal discussions.

Regards,

Hans


Re: [PATCH v3 2/2] ARM: dts: tegra20: Add video decoder node

2017-10-12 Thread Jon Hunter

On 11/10/17 21:08, Dmitry Osipenko wrote:
> Add a device node for the video decoder engine found on Tegra20.
> 
> Signed-off-by: Dmitry Osipenko 
> ---
>  arch/arm/boot/dts/tegra20.dtsi | 17 +
>  1 file changed, 17 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
> index 7c85f97f72ea..1b5d54b6c0cb 100644
> --- a/arch/arm/boot/dts/tegra20.dtsi
> +++ b/arch/arm/boot/dts/tegra20.dtsi
> @@ -249,6 +249,23 @@
>   */
>   };
>  
> + vde@6001a000 {
> + compatible = "nvidia,tegra20-vde";
> + reg = <0x6001a000 0x3D00/* VDE registers */
> +0x4400 0x3FC00>; /* IRAM region */
> + reg-names = "regs", "iram";
> + interrupts = , /* UCQ error 
> interrupt */
> +  , /* Sync token 
> interrupt */
> +  , /* BSE-V 
> interrupt */
> +  , /* BSE-A 
> interrupt */
> +  ; /* SXE interrupt 
> */
> + interrupt-names = "ucq-error", "sync-token", "bsev", "bsea", 
> "sxe";
> + clocks = <_car TEGRA20_CLK_VDE>;
> + clock-names = "vde";
> + resets = <_car 61>;
> + reset-names = "vde";
> + };
> +

I don't see any binding documentation for this node. We need to make
sure we add this.

Jon

-- 
nvpublic


Re: [PATCHv2 0/9] omapdrm: hdmi4: add CEC support

2017-10-12 Thread Tomi Valkeinen

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

On 12/10/17 09:50, Hans Verkuil wrote:

>> I can't test with a TV, so no CEC for me... But otherwise I think the
>> series works ok now, and looks ok. So I'll apply, but it's a bit late
>> for the next merge window, so I'll aim for 4.15 with this.
> 
> What is the status? Do you need anything from me? I'd like to get this in for 
> 4.15.

Thanks for reminding. I think I would've forgotten...

I sent the pull request, so all should be fine.

If possible, please test the pull request, preferably with drm-next
merged (git://people.freedesktop.org/~airlied/linux drm-next), as I
don't have a CEC capable display.

 Tomi



Re: [PATCH] uvcvideo: Apply flags from device to actual properties

2017-10-12 Thread Edgar Thier

Use flags the device exposes for UVC controls.
This allows the device to define which property flags are set.

Since some cameras offer auto-adjustments for properties (e.g. auto-gain),
the values of other properties (e.g. gain) can change in the camera.
Examining the flags ensures that the driver is aware of such properties.

Signed-off-by: Edgar Thier 
---
 drivers/media/usb/uvc/uvc_ctrl.c | 64 ++--
 1 file changed, 49 insertions(+), 15 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 20397aba..8f902a41 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1629,6 +1629,40 @@ static void uvc_ctrl_fixup_xu_info(struct uvc_device 
*dev,
}
 }

+/*
+ * Retrieve flags for a given control
+ */
+static int uvc_ctrl_get_flags(struct uvc_device *dev, const struct uvc_control 
*ctrl,
+   const struct uvc_control_info *info)
+{
+   u8 *data;
+   int ret = 0;
+   int flags = 0;
+
+   data = kmalloc(2, GFP_KERNEL);
+   if (data == NULL)
+   return -ENOMEM;
+
+   ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
+info->selector, data, 1);
+   if (ret < 0) {
+   uvc_trace(UVC_TRACE_CONTROL,
+ "GET_INFO failed on control %pUl/%u (%d).\n",
+ info->entity, info->selector, ret);
+   } else {
+   flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
+   | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
+   | (data[0] & UVC_CONTROL_CAP_GET ?
+  UVC_CTRL_FLAG_GET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_SET ?
+  UVC_CTRL_FLAG_SET_CUR : 0)
+   | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
+  UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+   }
+   kfree(data);
+   return flags;
+}
+
 /*
  * Query control information (size and flags) for XU controls.
  */
@@ -1636,6 +1670,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
const struct uvc_control *ctrl, struct uvc_control_info *info)
 {
u8 *data;
+   int flags;
int ret;

data = kmalloc(2, GFP_KERNEL);
@@ -1659,24 +1694,15 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,

info->size = le16_to_cpup((__le16 *)data);

-   /* Query the control information (GET_INFO) */
-   ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
-info->selector, data, 1);
-   if (ret < 0) {
+   flags = uvc_ctrl_get_flags(dev, ctrl, info);
+
+   if (flags < 0) {
uvc_trace(UVC_TRACE_CONTROL,
- "GET_INFO failed on control %pUl/%u (%d).\n",
- info->entity, info->selector, ret);
+ "Failed to retrieve flags (%d).\n", ret);
+   ret = flags;
goto done;
}
-
-   info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
-   | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
-   | (data[0] & UVC_CONTROL_CAP_GET ?
-  UVC_CTRL_FLAG_GET_CUR : 0)
-   | (data[0] & UVC_CONTROL_CAP_SET ?
-  UVC_CTRL_FLAG_SET_CUR : 0)
-   | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
-  UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+   info->flags = flags;

uvc_ctrl_fixup_xu_info(dev, ctrl, info);

@@ -1890,6 +1916,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
struct uvc_control *ctrl,
const struct uvc_control_info *info)
 {
int ret = 0;
+   int flags = 0;

ctrl->info = *info;
INIT_LIST_HEAD(>info.mappings);
@@ -1902,6 +1929,13 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
struct uvc_control *ctrl,
goto done;
}

+   flags = uvc_ctrl_get_flags(dev, ctrl, info);
+   if (flags < 0)
+   uvc_trace(UVC_TRACE_CONTROL,
+ "Failed to retrieve flags (%d).\n", ret);
+   else
+   ctrl->info.flags = flags;
+
ctrl->initialized = 1;

uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
-- 
2.14.2




Re: [PATCH v3 2/2] ARM: dts: tegra20: Add video decoder node

2017-10-12 Thread Vladimir Zapolskiy
Hello Dmitry,

On 10/11/2017 11:08 PM, Dmitry Osipenko wrote:
> Add a device node for the video decoder engine found on Tegra20.
> 
> Signed-off-by: Dmitry Osipenko 
> ---
>  arch/arm/boot/dts/tegra20.dtsi | 17 +
>  1 file changed, 17 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
> index 7c85f97f72ea..1b5d54b6c0cb 100644
> --- a/arch/arm/boot/dts/tegra20.dtsi
> +++ b/arch/arm/boot/dts/tegra20.dtsi
> @@ -249,6 +249,23 @@
>   */
>   };
>  
> + vde@6001a000 {
> + compatible = "nvidia,tegra20-vde";
> + reg = <0x6001a000 0x3D00/* VDE registers */
> +0x4400 0x3FC00>; /* IRAM region */

this notation of a used region in IRAM is non-standard and potentially it
may lead to conflicts for IRAM resource between users.

My proposal is to add a valid device tree node to describe an IRAM region
firstly, then reserve a subregion in it by using a new "iram" property.

8<
From: Vladimir Zapolskiy 
Date: Thu, 12 Oct 2017 10:25:45 +0300
Subject: [PATCH] ARM: tegra: add device tree node to describe IRAM on Tegra20

All Tegra20 SoCs contain 256KiB IRAM, which is used to store
resume code and by a video decoder engine.

Signed-off-by: Vladimir Zapolskiy 
---
 arch/arm/boot/dts/tegra20.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index 7c85f97f72ea..fd2843c90920 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -9,6 +9,14 @@
compatible = "nvidia,tegra20";
interrupt-parent = <>;
 
+   iram@4000 {
+   compatible = "mmio-sram";
+   reg = <0x4000 0x4>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0 0x4000 0x4>;
+   };
+
host1x@5000 {
compatible = "nvidia,tegra20-host1x", "simple-bus";
reg = <0x5000 0x00024000>;
8<

Please add the change above to your next version of the series, or
if you wish I can send it separately for review by Thierry.

After applying that change you do define a region in IRAM for the exclusive
usage by a video decoder engine and add an 'iram' property:

8<
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index fd2843c90920..5133fbac2185 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -15,6 +15,11 @@
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x4000 0x4>;
+
+   vde_pool: vde {
+   reg = <0x400 0x3fc00>;
+   pool;
+   };
};
 
host1x@5000 {
[snip]

+   vde@6001a000 {
+   compatible = "nvidia,tegra20-vde";
+   reg = <0x6001a000 0x3d00>;  /* VDE registers */
+   iram = <_pool>; /* IRAM region */
[snip]
8<

And finally in the driver you'll use genalloc API to access the IRAM
region, for that you can find ready examples in the kernel source code.

--
With best wishes,
Vladimir


Re: [PATCHv2 0/9] omapdrm: hdmi4: add CEC support

2017-10-12 Thread Hans Verkuil
Hi Tomi,

On 08/22/2017 11:44 AM, Tomi Valkeinen wrote:
> Hi Hans,
> 
>>>
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> On 11/08/17 13:57, Tomi Valkeinen wrote:
>>>
 I'm doing some testing with this series on my panda. One issue I see is
 that when I unload the display modules, I get:

 [   75.180206] platform 58006000.encoder: enabled after unload, idling
 [   75.187896] platform 58001000.dispc: enabled after unload, idling
 [   75.198242] platform 5800.dss: enabled after unload, idling
>>>
>>> This one is caused by hdmi_cec_adap_enable() never getting called with
>>> enable=false when unloading the modules. Should that be called
>>> explicitly in hdmi4_cec_uninit, or is the CEC framework supposed to call it?
>>
>> Nicely found!
>>
>> The cec_delete_adapter() function calls 
>> __cec_s_phys_addr(CEC_PHYS_ADDR_INVALID)
>> which would normally call adap_enable(false), except when the device node was
>> already unregistered, in which case it just returns immediately.
>>
>> The patch below should fix this. Let me know if it works, and I'll post a 
>> proper
>> patch and get that in for 4.14 (and possible backported as well, I'll have to
>> look at that).
> 
> Thanks, this fixes the issue.
> 
> I again saw "HDMICORE: omapdss HDMICORE error: operation stopped when
> reading edid" when I loaded the modules. My panda also froze just now
> when unloading the display modules, and it doesn't react to sysrq.
> 
> After testing a bit without the CEC patches, I saw the above error, so I
> don't think it's related to your patches.
> 
> I can't test with a TV, so no CEC for me... But otherwise I think the
> series works ok now, and looks ok. So I'll apply, but it's a bit late
> for the next merge window, so I'll aim for 4.15 with this.

What is the status? Do you need anything from me? I'd like to get this in for 
4.15.

Regards,

Hans


Re: [PATCH v5 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver

2017-10-12 Thread Sakari Ailus
Hi Yong,

One more comment below...

On Thu, Oct 12, 2017 at 01:02:54AM +, Zhi, Yong wrote:
...
> > > +/*** V4L2 sub-device asynchronous registration
> > callbacks***/
> > > +
> > > +struct sensor_async_subdev {
> > > + struct v4l2_async_subdev asd;
> > > + struct csi2_bus_info csi2;
> > > +};
> > > +
> > > +static struct cio2_queue *cio2_find_queue_by_sensor_node(struct
> > cio2_queue *q,
> > > + struct fwnode_handle
> > *fwnode)
> > > +{
> > > + unsigned int i;
> > > +
> > > + for (i = 0; i < CIO2_QUEUES; i++) {
> > > + if (q[i].sensor->fwnode == fwnode)
> > > + return [i];
> > > + }
> > > +
> > > + return NULL;
> > > +}
> > > +
> > > +/* The .bound() notifier callback when a match is found */
> > > +static int cio2_notifier_bound(struct v4l2_async_notifier *notifier,
> > > +struct v4l2_subdev *sd,
> > > +struct v4l2_async_subdev *asd)
> > > +{
> > > + struct cio2_device *cio2 = container_of(notifier,
> > > + struct cio2_device, notifier);
> > > + struct sensor_async_subdev *s_asd = container_of(asd,
> > > + struct sensor_async_subdev, asd);
> > > + struct cio2_queue *q;
> > > + unsigned int i;
> > > +
> > > +
> > > + /* Find first free slot for the subdev */
> > > + for (i = 0; i < CIO2_QUEUES; i++)
> > > + if (!cio2->queue[i].sensor)
> > > + break;

The queues are related to sub-devices with the same number in the name,
whereas the number of the CSI-2 receiver is q->csi2.port. The problem here
is that the CSI-2 receiver that the sensor appears to be connected is a
incrementing number from zero onwards, depending on the order in which the
devices are bound rather than the real number of the receiver.

The easiest way to address this would be to create 1:1 mapping between the
queues and CSI-2 receivers.

> > > +
> > > + if (i >= CIO2_QUEUES) {
> > > + dev_err(>pci_dev->dev, "too many subdevs\n");
> > > + return -ENOSPC;
> > > + }
> > > + q = >queue[i];
> > > +
> > > + q->csi2 = s_asd->csi2;
> > > + q->sensor = sd;
> > > + q->csi_rx_base = cio2->base + CIO2_REG_PIPE_BASE(q->csi2.port);
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +/* The .unbind callback */
> > > +static void cio2_notifier_unbind(struct v4l2_async_notifier *notifier,
> > > +  struct v4l2_subdev *sd,
> > > +  struct v4l2_async_subdev *asd)
> > > +{
> > > + struct cio2_device *cio2 = container_of(notifier,
> > > + struct cio2_device, notifier);
> > > + unsigned int i;
> > > +
> > > + /* Note: sd may here point to unallocated memory. Do not access. */
> > 
> > That may be the case but the patchset that this driver depends on changes
> > it. :-) So you can remove the comment.
> > 
> 
> Ack, will remove.
> 
> > > + for (i = 0; i < CIO2_QUEUES; i++) {
> > > + if (cio2->queue[i].sensor == sd) {
> > > + cio2->queue[i].sensor = NULL;
> > > + return;
> > > + }
> > > + }
> > > +}
> > > +
> > > +/* .complete() is called after all subdevices have been located */
> > > +static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
> > > +{
> > > + struct cio2_device *cio2 = container_of(notifier, struct cio2_device,
> > > + notifier);
> > > + struct sensor_async_subdev *s_asd;
> > > + struct cio2_queue *q;
> > > + unsigned int i, pad;
> > > + int ret;
> > > +
> > > + for (i = 0; i < notifier->num_subdevs; i++) {
> > > + s_asd = container_of(cio2->notifier.subdevs[i],
> > > + struct sensor_async_subdev,
> > > + asd);
> > > +
> > > + q = cio2_find_queue_by_sensor_node(
> > > + cio2->queue,
> > > + s_asd-
> > >asd.match.fwnode.fwnode);
> > > + if (!q) {
> > > + dev_err(>pci_dev->dev,
> > > + "failed to find cio2 queue %d\n", ret);
> > > + return -ENXIO;
> > > + }
> > > +
> > > + for (pad = 0; pad < q->sensor->entity.num_pads; pad++)
> > > + if (q->sensor->entity.pads[pad].flags &
> > > + MEDIA_PAD_FL_SOURCE)
> > > + break;
> > > +
> > > + if (pad == q->sensor->entity.num_pads) {
> > > + dev_err(>pci_dev->dev,
> > > + "failed to find src pad for %s\n",
> > > + q->sensor->name);
> > > + return -ENXIO;
> > > + }
> > > +
> > > + ret = media_create_pad_link(
> > > + >sensor->entity, pad,
> > > + >subdev.entity, CIO2_PAD_SINK,
> > > + 0);
> > > +