Re: [PATCH v5] v4l2-async: Match parent devices

2017-12-06 Thread Sakari Ailus
On Wed, Dec 06, 2017 at 02:58:39PM +, Kieran Bingham wrote:
> From: Kieran Bingham 
> 
> Devices supporting multiple endpoints on a single device node must set
> their subdevice fwnode to the endpoint to allow distinct comparisons.
> 
> Adapt the match_fwnode call to compare against the provided fwnodes
> first, but to also perform a cross reference comparison against the
> parent fwnodes of each other.
> 
> This allows notifiers to pass the endpoint for comparison and still
> support existing subdevices which store their default parent device
> node.
> 
> Signed-off-by: Kieran Bingham 
> Signed-off-by: Sakari Ailus 
> 
> ---
> 
> Hi Sakari,
> 
> Since you signed-off on this patch - it has had to be reworked due to the
> changes on the of_node_full_name() functionality.
> 
> I believe it is correct now to *just* do the pointer matching, as that matches
> the current implementation, and converting to device_nodes will be just as
> equal as the fwnodes, as they are simply containers.
> 
> Let me know if you are happy to maintain your SOB on this patch - and if we 
> need
> to work towards getting this integrated upstream, especially in light of your 
> new
> endpoint matching work.

I'd really want to avoid resorting to matching opportunistically --- please
see my reply to Niklas on "[RFC 1/1] v4l: async: Use endpoint node, not
device node, for fwnode match".

-- 
Regards,

Sakari Ailus
sakari.ai...@linux.intel.com


Re: [RFC 1/1] v4l: async: Use endpoint node, not device node, for fwnode match

2017-12-06 Thread Sakari Ailus
Hej Niklas,

Tack för dina kommentarer!

On Wed, Dec 06, 2017 at 04:57:48PM +0100, Niklas Söderlund wrote:
> CC Jacopo, Kieran
> 
> Hi Sakari,
> 
> Thanks for your patch.
> 
> On 2017-12-04 23:03:02 +0200, Sakari Ailus wrote:
> > V4L2 async framework can use both device's fwnode and endpoints's fwnode
> > for matching the async sub-device with the sub-device. In order to proceed
> > moving towards endpoint matching assign the endpoint to the async
> > sub-device.
> 
> Endpoint matching I think is the way to go forward. It will solve a set 
> of problems that exists today. So I think this a good step in the right 
> direction.
> 
> > 
> > As most async sub-device drivers (and the related hardware) only supports
> > a single endpoint, use the first endpoint found. This works for all
> > current drivers --- we only ever supported a single async sub-device per
> > device to begin with.
> 
> This assumption is not true, the adv748x exposes multiple subdevice from 
> a single device node in DT and registers them using different endpoints.  
> Now the only user of the adv748x driver I know of is the rcar-csi2 
> driver which is not yet upstream so this can be consider a special case.

Right, the adv748x is an exception to this but I could argue it should
never have been merged in its current state: it does not work with other
bridge / ISP drivers.

> 
> Unfortunately this patch do break already existing configurations 
> upstream :-( For example the Koelsch board, from r8a7791-koelsch.dts:
> 
> hdmi-in {
> compatible = "hdmi-connector";
> type = "a";
> 
> port {
> hdmi_con_in: endpoint {
> remote-endpoint = <_in>;
> };
> };
> };
> 
> hdmi-in@4c {
> compatible = "adi,adv7612";
> reg = <0x4c>;
> interrupt-parent = <>;
> interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
> default-input = <0>;
> 
> ports {
> #address-cells = <1>;
> #size-cells = <0>;
> 
> port@0 {
> reg = <0>;
> adv7612_in: endpoint {
> remote-endpoint = <_con_in>;
> };
> };
> 
> port@2 {
> reg = <2>;
> adv7612_out: endpoint {
> remote-endpoint = <>;
> };
> };
> };
> };
> 
>  {
> status = "okay";
> pinctrl-0 = <_pins>;
> pinctrl-names = "default";
> 
> port {
> #address-cells = <1>;
> #size-cells = <0>;
> 
> vin0ep2: endpoint {
> remote-endpoint = <_out>;
> bus-width = <24>;
> hsync-active = <0>;
> vsync-active = <0>;
> pclk-sample = <1>;
> data-active = <1>;
> };
> };
> };
> 
> Here the adv7612 driver would register a subdevice using the endpoint 
> 'hdmi-in@4c/ports/port@0/endpoint' while the rcar-vin driver which uses 

The adv7612 needs to register both of these endpoints. I wonder if there
are repercussions by doing that. 

> the async parsing helpers would register a notifier looking for 
> 'hdmi-in@4c/ports/port@2/endpoint'.
> 
> Something like Kieran's '[PATCH v5] v4l2-async: Match parent devices' 
> would be needed in addition to this patch. I tried Kieran's patch 
> together with this and it did not solve the problem upstream. I did make 

The more I've been working on this problem, the less I think
opportunistically matching devices or endpoints is a good idea. Lens
devices will always use device nodes and flash devices use LED nodes found
under device nodes.

It's getting messy with opportunistic matching. And as this patch shows,
it's not that hard to convert all drivers either, so why not to do just
that?

-- 
Hälsningar,

Sakari Ailus
sakari.ai...@linux.intel.com


cron job: media_tree daily build: ERRORS

2017-12-06 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:   Thu Dec  7 05:00:17 CET 2017
media-tree git hash:781b045baefdabf7e0bc9f33672ca830d3db9f27
media_build git hash:   320b9b80ebbf318a67a9479c18a0e4be244c8409
v4l-utils git hash: 58803000a99c22dceabfb45bec402e746ce966c3
gcc version:i686-linux-gcc (GCC) 7.1.0
sparse version: v0.5.0-3911-g6f737e1f
smatch version: v0.5.0-3911-g6f737e1f
host hardware:  x86_64
host os:4.13.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: OK
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: ERRORS
linux-3.13.11-i686: ERRORS
linux-3.14.9-i686: ERRORS
linux-3.15.2-i686: ERRORS
linux-3.16.7-i686: ERRORS
linux-3.17.8-i686: ERRORS
linux-3.18.7-i686: ERRORS
linux-3.19-i686: ERRORS
linux-4.0.9-i686: ERRORS
linux-4.1.33-i686: ERRORS
linux-4.2.8-i686: ERRORS
linux-4.3.6-i686: ERRORS
linux-4.4.22-i686: ERRORS
linux-4.5.7-i686: ERRORS
linux-4.6.7-i686: ERRORS
linux-4.7.5-i686: ERRORS
linux-4.8-i686: ERRORS
linux-4.9.26-i686: ERRORS
linux-4.10.14-i686: ERRORS
linux-4.11-i686: ERRORS
linux-4.12.1-i686: ERRORS
linux-4.13-i686: ERRORS
linux-4.14-i686: ERRORS
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: ERRORS
linux-3.13.11-x86_64: ERRORS
linux-3.14.9-x86_64: ERRORS
linux-3.15.2-x86_64: ERRORS
linux-3.16.7-x86_64: ERRORS
linux-3.17.8-x86_64: ERRORS
linux-3.18.7-x86_64: ERRORS
linux-3.19-x86_64: ERRORS
linux-4.0.9-x86_64: ERRORS
linux-4.1.33-x86_64: ERRORS
linux-4.2.8-x86_64: ERRORS
linux-4.3.6-x86_64: ERRORS
linux-4.4.22-x86_64: ERRORS
linux-4.5.7-x86_64: ERRORS
linux-4.6.7-x86_64: ERRORS
linux-4.7.5-x86_64: ERRORS
linux-4.8-x86_64: ERRORS
linux-4.9.26-x86_64: ERRORS
linux-4.10.14-x86_64: ERRORS
linux-4.11-x86_64: ERRORS
linux-4.12.1-x86_64: ERRORS
linux-4.13-x86_64: ERRORS
linux-4.14-x86_64: ERRORS
apps: OK
spec-git: OK
smatch: OK

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


Re: build failure on ubuntu 16.04 LTS

2017-12-06 Thread Jasmin J.
Hello Hans!

> Jasmin, you've done some work on this in the past. Let me know if you
> have time to look at this, I would really appreciate that.
THX!

> No, it really is broken. I don't quite understand why it is failing ...
I noticed this already, but I am currently very busy to finish al my work
before my vacation. But I will try to find some time over the weekend.
I hope I can find it, even if you say it is difficult.

BR,
   Jasmin

***

On 12/06/2017 12:14 PM, Hans Verkuil wrote:
> On 12/06/17 11:43, Vincent McIntyre wrote:
>> Hi,
>>
>> the build has been broken for over a week for me.
>> Possibly my checkout is out of date??
> 
> No, it really is broken. I don't quite understand why it is failing or
> how to fix it, and I lack time to dig into this. Hopefully I can find
> some time next week for this.
> 
> Jasmin, you've done some work on this in the past. Let me know if you
> have time to look at this, I would really appreciate that.
> 
> Regards,
> 
>   Hans
> 
>> I am using the normal build --main-git method.
>>
>> Setup details:
>>
>> + date
>> Wednesday 6 December  21:25:28 AEDT 2017
>> + uname -a
>> Linux ubuntu 4.4.0-101-generic #124-Ubuntu SMP Fri Nov 10 18:29:59 UTC 2017 
>> x86_64 x86_64 x86_64 GNU/Linux
>> + cat /proc/version_signature
>> Ubuntu 4.4.0-101.124-generic 4.4.95
>>
>> + git --no-pager log -1
>> commit 320b9b80ebbf318a67a9479c18a0e4be244c8409
>> Author: Hans Verkuil 
>> Date:   Tue Nov 28 08:48:04 2017 +0100
>>
>> Update backports/pr_fmt.patch
>>
>> Signed-off-by: Hans Verkuil 
>>
>> + cd media
>> + git --no-pager log -1
>> commit 781b045baefdabf7e0bc9f33672ca830d3db9f27
>> Author: Sakari Ailus 
>> Date:   Wed Nov 1 05:40:58 2017 -0400
>>
>> media: imx274: Fix error handling, add MAINTAINERS entry
>>
>> Add the missing MAINTAINERS entry for imx274, fix error handling in 
>> driver
>> probe and unregister the correct control handler in driver remove.
>>
>> Signed-off-by: Sakari Ailus 
>> Signed-off-by: Mauro Carvalho Chehab 
>>
>>
>> This is the build failure
>> ...
>>
>> Created default (all yes) .config file
>> ./scripts/fix_kconfig.pl
>> make[1]: Leaving directory '/home/me/git/clones/media_build/v4l'
>> $ make
>> make -C /home/me/git/clones/media_build/v4l
>> make[1]: Entering directory '/home/me/git/clones/media_build/v4l'
>> scripts/make_makefile.pl
>> ./scripts/make_myconfig.pl
>> perl scripts/make_config_compat.pl /lib/modules/4.4.0-101-generic/build 
>> ./.myconfig ./config-compat.h
>> creating symbolic links...
>> Kernel build directory is /lib/modules/4.4.0-101-generic/build
>> make -C ../linux apply_patches
>> make[2]: Entering directory '/home/me/git/clones/media_build/linux'
>> Syncing with dir ../media/
>> Patches for 4.4.0-101-generic already applied.
>> make[2]: Leaving directory '/home/me/git/clones/media_build/linux'
>> make -C /lib/modules/4.4.0-101-generic/build 
>> SUBDIRS=/home/me/git/clones/media_build/v4l  modules
>> make[2]: Entering directory '/usr/src/linux-headers-4.4.0-101-generic'
>>   CC [M]  /home/me/git/clones/media_build/v4l/msp3400-driver.o
>> In file included from include/linux/compiler.h:56:0,
>>  from include/asm-generic/bug.h:4,
>>  from ./arch/x86/include/asm/bug.h:35,
>>  from include/linux/bug.h:4,
>>  from include/linux/mmdebug.h:4,
>>  from /home/me/git/clones/media_build/v4l/config-compat.h:12,
>>  from /home/me/git/clones/media_build/v4l/compat.h:10,
>>  from :0:
>> /home/me/git/clones/media_build/v4l/../linux/include/linux/compiler-gcc.h:3:2:
>>  error: #error "Please don't include  directly, 
>> include  instead."
>>  #error "Please don't include  directly, include 
>>  instead."
>>   ^
>> scripts/Makefile.build:258: recipe for target 
>> '/home/me/git/clones/media_build/v4l/msp3400-driver.o' failed
>> make[3]: *** [/home/me/git/clones/media_build/v4l/msp3400-driver.o] Error 1
>> Makefile:1423: recipe for target 
>> '_module_/home/me/git/clones/media_build/v4l' failed
>> make[2]: *** [_module_/home/me/git/clones/media_build/v4l] Error 2
>> make[2]: Leaving directory '/usr/src/linux-headers-4.4.0-101-generic'
>> Makefile:51: recipe for target 'default' failed
>> make[1]: *** [default] Error 2
>> make[1]: Leaving directory '/home/me/git/clones/media_build/v4l'
>> Makefile:26: recipe for target 'all' failed
>> make: *** [all] Error 2
>> build failed at ./build line 526
>> + status=29
>>
>> I'm struggling to follow the depedency chain here so I thought I'd better 
>> ask.
>>
>> ubuntu(master)$ grep -r compiler-gcc.h|grep -F '#include'
>>
>> media/include/linux/compiler_types.h:#include 
>> media/tools/include/linux/compiler.h:#include 
>>
>> Cheers
>> Vince
>>
>>
> 


Re: [PATCH for 4.15] ddbridge update to 0.9.32

2017-12-06 Thread Daniel Scheller
Am Sun, 15 Oct 2017 22:51:49 +0200
schrieb Daniel Scheller :

> From: Daniel Scheller 
> 
> For the 4.15 merge window. These patches update the mainline ddbridge
> driver to version 0.9.32, which was released ~3 weeks ago by upstream.
> 
> Nothing really fancy in this series, in fact upstream applied many of
> the changes that went into the mainline driver, which was released as
> 0.9.32. A few more changes were applied though, namely the CI DuoFlex/
> PCIe Bridge support has been split from -core (like ie. the MaxS8 card
> support), upstream named the files with the MaxS8 support code
> "-max.[c|h]" (thus the rename), and everything was made checkpatch-
> strict clean.
> 
> One condition in stv0910.c:read_status() was missing in mainline and
> is being added in 7/8.
> 
> The series was tested for bisect safety and checked with smatch.
> 
> Please pull for 4.15.

Ping.

Best regards,
Daniel Scheller
-- 
https://github.com/herrnst


[PATCH 1/2] [media] ddbridge: improve error handling logic on fe attach failures

2017-12-06 Thread Daniel Scheller
From: Daniel Scheller 

This change makes sure that demod frontends are always detached whenever
a tuner frontend attach failed. Achieve this by moving the detach-on-
failure logic at the end of dvb_input_attach(), and adding a goto to this
block on every tuner attach failure case, so if an error occurs, there are
no stray attached frontends left. As a side effect, this removes some
duplicated code.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 49 ++
 1 file changed, 22 insertions(+), 27 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 348cc8b3d1f9..11c5cae92408 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1449,48 +1449,43 @@ static int dvb_input_attach(struct ddb_input *input)
if (demod_attach_stv0900(input, 0) < 0)
return -ENODEV;
if (tuner_attach_stv6110(input, 0) < 0)
-   return -ENODEV;
+   goto err_tuner;
break;
case DDB_TUNER_DVBS_ST_AA:
if (demod_attach_stv0900(input, 1) < 0)
return -ENODEV;
if (tuner_attach_stv6110(input, 1) < 0)
-   return -ENODEV;
+   goto err_tuner;
break;
case DDB_TUNER_DVBS_STV0910:
if (demod_attach_stv0910(input, 0) < 0)
return -ENODEV;
if (tuner_attach_stv6111(input, 0) < 0)
-   return -ENODEV;
+   goto err_tuner;
break;
case DDB_TUNER_DVBS_STV0910_PR:
if (demod_attach_stv0910(input, 1) < 0)
return -ENODEV;
if (tuner_attach_stv6111(input, 1) < 0)
-   return -ENODEV;
+   goto err_tuner;
break;
case DDB_TUNER_DVBS_STV0910_P:
if (demod_attach_stv0910(input, 0) < 0)
return -ENODEV;
if (tuner_attach_stv6111(input, 1) < 0)
-   return -ENODEV;
+   goto err_tuner;
break;
case DDB_TUNER_DVBCT_TR:
if (demod_attach_drxk(input) < 0)
return -ENODEV;
if (tuner_attach_tda18271(input) < 0)
-   return -ENODEV;
+   goto err_tuner;
break;
case DDB_TUNER_DVBCT_ST:
if (demod_attach_stv0367(input) < 0)
return -ENODEV;
-   if (tuner_attach_tda18212(input, port->type) < 0) {
-   if (dvb->fe2)
-   dvb_frontend_detach(dvb->fe2);
-   if (dvb->fe)
-   dvb_frontend_detach(dvb->fe);
-   return -ENODEV;
-   }
+   if (tuner_attach_tda18212(input, port->type) < 0)
+   goto err_tuner;
break;
case DDB_TUNER_DVBC2T2I_SONY_P:
if (input->port->dev->link[input->port->lnr].info->ts_quirks &
@@ -1509,13 +1504,8 @@ static int dvb_input_attach(struct ddb_input *input)
par = 1;
if (demod_attach_cxd28xx(input, par, osc24) < 0)
return -ENODEV;
-   if (tuner_attach_tda18212(input, port->type) < 0) {
-   if (dvb->fe2)
-   dvb_frontend_detach(dvb->fe2);
-   if (dvb->fe)
-   dvb_frontend_detach(dvb->fe);
-   return -ENODEV;
-   }
+   if (tuner_attach_tda18212(input, port->type) < 0)
+   goto err_tuner;
break;
case DDB_TUNER_DVBC2T2I_SONY:
osc24 = 1;
@@ -1525,13 +1515,8 @@ static int dvb_input_attach(struct ddb_input *input)
case DDB_TUNER_ISDBT_SONY:
if (demod_attach_cxd28xx(input, 0, osc24) < 0)
return -ENODEV;
-   if (tuner_attach_tda18212(input, port->type) < 0) {
-   if (dvb->fe2)
-   dvb_frontend_detach(dvb->fe2);
-   if (dvb->fe)
-   dvb_frontend_detach(dvb->fe);
-   return -ENODEV;
-   }
+   if (tuner_attach_tda18212(input, port->type) < 0)
+   goto err_tuner;
break;
default:
return 0;
@@ -1554,6 +1539,16 @@ static int dvb_input_attach(struct ddb_input *input)
 
dvb->attached = 0x31;
return 0;
+
+err_tuner:
+   dev_warn(port->dev->dev, "tuner attach failed!\n");
+
+   if 

[PATCH 0/2] ddbridge: error handling improvements

2017-12-06 Thread Daniel Scheller
From: Daniel Scheller 

Two commits which will improve the error handling when attaching of
(tuner) frontends fail, which complements the recent fixes in the
DVB core (esp. dvb_frontend.c), making sure that on failure there
won't be any frontend drivers left with a usecount > 0 and thus can
be unloaded without -f on rmmod.

Also, don't miserably fail and stop hard when a single frontend failed
to attach as other frontends connected to the current (or even other)
bridge(s) can still work perfectly fine, so rather initialise as much
as possible. (If a single PCI device fails to init, the kernel doesn't
stop probing everything else on the bus)

This goes ontop of the ddbridge-0.9.32 bump (see [1]) which should
have been merged for kernel 4.15rc1 originally, but unfortunately
wasn't. No idea (didn't test) if this applies without the 0.9.32
changes (and please don't try to find out to avoid any merge errors/
conflicts - thanks.).

[1] http://www.spinics.net/lists/linux-media/msg123707.html

Daniel Scheller (2):
  [media] ddbridge: improve error handling logic on fe attach failures
  [media] ddbridge: don't break on single/last port attach failure

 drivers/media/pci/ddbridge/ddbridge-core.c | 51 ++
 1 file changed, 23 insertions(+), 28 deletions(-)

-- 
2.13.6



[PATCH 2/2] [media] ddbridge: don't break on single/last port attach failure

2017-12-06 Thread Daniel Scheller
From: Daniel Scheller 

As all error handling improved quite a bit, don't stop attaching frontends
if one of them failed, since - if other tuner modules are connected to
the PCIe bridge - other hardware may just work, so lets not break on a
single port failure, but rather initialise as much as possible. Ie. if
there are issues with a C2T2-equipped PCIe bridge card which has
additional DuoFlex modules connected and the bridge generally works,
the DuoFlex tuners can still work fine. Also, this only had an effect
anyway if the failed device/port was the last one being enumerated.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 11c5cae92408..b43c40e0bf73 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1962,7 +1962,7 @@ int ddb_ports_attach(struct ddb *dev)
}
for (i = 0; i < dev->port_num; i++) {
port = >port[i];
-   ret = ddb_port_attach(port);
+   ddb_port_attach(port);
}
return ret;
 }
-- 
2.13.6



[PATCH 09/45] drivers: media: remove duplicate includes

2017-12-06 Thread Pravin Shedge
These duplicate includes have been found with scripts/checkincludes.pl but
they have been removed manually to avoid removing false positives.

Signed-off-by: Pravin Shedge 
---
 drivers/media/platform/pxa_camera.c | 1 -
 drivers/media/platform/ti-vpe/cal.c | 3 ---
 drivers/media/v4l2-core/v4l2-mc.c   | 2 --
 3 files changed, 6 deletions(-)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index 9d3f0cb..2a9f02e 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -32,7 +32,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
diff --git a/drivers/media/platform/ti-vpe/cal.c 
b/drivers/media/platform/ti-vpe/cal.c
index 8b586c8..719ed1d 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -28,10 +28,7 @@
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include "cal_regs.h"
diff --git a/drivers/media/v4l2-core/v4l2-mc.c 
b/drivers/media/v4l2-core/v4l2-mc.c
index 303980b..1d550af 100644
--- a/drivers/media/v4l2-core/v4l2-mc.c
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -25,8 +25,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 
 int v4l2_mc_create_media_graph(struct media_device *mdev)
-- 
2.7.4



[PATCH] media: pxa_camera: disable and unprepare the clock source on error

2017-12-06 Thread Flavio Ceolin
pxa_camera_probe() was not calling pxa_camera_deactivate(),
responsible to call clk_disable_unprepare(), on the failure path. This
was leading to unbalancing source clock.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Flavio Ceolin 
---
 drivers/media/platform/pxa_camera.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index 9d3f0cb..7877037 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2489,7 +2489,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
dev_set_drvdata(>dev, pcdev);
err = v4l2_device_register(>dev, >v4l2_dev);
if (err)
-   goto exit_free_dma;
+   goto exit_deactivate;
 
pcdev->asds[0] = >asd;
pcdev->notifier.subdevs = pcdev->asds;
@@ -2525,6 +2525,8 @@ static int pxa_camera_probe(struct platform_device *pdev)
v4l2_clk_unregister(pcdev->mclk_clk);
 exit_free_v4l2dev:
v4l2_device_unregister(>v4l2_dev);
+exit_deactivate:
+   pxa_camera_deactivate(pcdev);
 exit_free_dma:
dma_release_channel(pcdev->dma_chans[2]);
 exit_free_dma_u:
-- 
2.9.5



[PATCH] media: s5p-jpeg: Fix off-by-one problem

2017-12-06 Thread Flavio Ceolin
s5p_jpeg_runtime_resume() does not call clk_disable_unprepare() for
jpeg->clocks[0] when one of the clk_prepare_enable() fails.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Flavio Ceolin 
---
 drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c 
b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index faac816..79b63da 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -3086,7 +3086,7 @@ static int s5p_jpeg_runtime_resume(struct device *dev)
for (i = 0; i < jpeg->variant->num_clocks; i++) {
ret = clk_prepare_enable(jpeg->clocks[i]);
if (ret) {
-   while (--i > 0)
+   while (--i >= 0)
clk_disable_unprepare(jpeg->clocks[i]);
return ret;
}
-- 
2.9.5



Re: [RFC 1/1] v4l: async: Use endpoint node, not device node, for fwnode match

2017-12-06 Thread Kieran Bingham
Hi Niklas,

On 06/12/17 15:57, Niklas Söderlund wrote:
> CC Jacopo, Kieran
> 
> Hi Sakari,
> 
> Thanks for your patch.
> 
> On 2017-12-04 23:03:02 +0200, Sakari Ailus wrote:
>> V4L2 async framework can use both device's fwnode and endpoints's fwnode
>> for matching the async sub-device with the sub-device. In order to proceed
>> moving towards endpoint matching assign the endpoint to the async
>> sub-device.
> 
> Endpoint matching I think is the way to go forward. It will solve a set 
> of problems that exists today. So I think this a good step in the right 
> direction.
> 
>>
>> As most async sub-device drivers (and the related hardware) only supports
>> a single endpoint, use the first endpoint found. This works for all
>> current drivers --- we only ever supported a single async sub-device per
>> device to begin with.
> 
> This assumption is not true, the adv748x exposes multiple subdevice from 
> a single device node in DT and registers them using different endpoints.  
> Now the only user of the adv748x driver I know of is the rcar-csi2 
> driver which is not yet upstream so this can be consider a special case.

Quite - but the match parent patch still hasn't got upstream yet either - so
it's still not supported.

I'd love to know if there are other devices with an ADV748x out there though!




> Here the adv7612 driver would register a subdevice using the endpoint 
> 'hdmi-in@4c/ports/port@0/endpoint' while the rcar-vin driver which uses 
> the async parsing helpers would register a notifier looking for 
> 'hdmi-in@4c/ports/port@2/endpoint'.
> 
> Something like Kieran's '[PATCH v5] v4l2-async: Match parent devices' 
> would be needed in addition to this patch. I tried Kieran's patch 
> together with this and it did not solve the problem upstream. I did make 
> a hack on-top of Kieran's patch to add a comparison 'sd_parent == 
> asd_parent' in match_fwnode() which got rcar-gen2 working again, but I'm 
> not sure if that will have other side effects.

Matching parent == parent will have the side effect that all devices with
multiple endpoints, will discover all endpoints successfully match on both
device comparisons.

Thus, this in effect will completely undo all endpoint matching efforts.




Regards

Kieran


Re: [RFC 1/1] v4l: async: Use endpoint node, not device node, for fwnode match

2017-12-06 Thread Niklas Söderlund
CC Jacopo, Kieran

Hi Sakari,

Thanks for your patch.

On 2017-12-04 23:03:02 +0200, Sakari Ailus wrote:
> V4L2 async framework can use both device's fwnode and endpoints's fwnode
> for matching the async sub-device with the sub-device. In order to proceed
> moving towards endpoint matching assign the endpoint to the async
> sub-device.

Endpoint matching I think is the way to go forward. It will solve a set 
of problems that exists today. So I think this a good step in the right 
direction.

> 
> As most async sub-device drivers (and the related hardware) only supports
> a single endpoint, use the first endpoint found. This works for all
> current drivers --- we only ever supported a single async sub-device per
> device to begin with.

This assumption is not true, the adv748x exposes multiple subdevice from 
a single device node in DT and registers them using different endpoints.  
Now the only user of the adv748x driver I know of is the rcar-csi2 
driver which is not yet upstream so this can be consider a special case.

Unfortunately this patch do break already existing configurations 
upstream :-( For example the Koelsch board, from r8a7791-koelsch.dts:

hdmi-in {
compatible = "hdmi-connector";
type = "a";

port {
hdmi_con_in: endpoint {
remote-endpoint = <_in>;
};
};
};

hdmi-in@4c {
compatible = "adi,adv7612";
reg = <0x4c>;
interrupt-parent = <>;
interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
default-input = <0>;

ports {
#address-cells = <1>;
#size-cells = <0>;

port@0 {
reg = <0>;
adv7612_in: endpoint {
remote-endpoint = <_con_in>;
};
};

port@2 {
reg = <2>;
adv7612_out: endpoint {
remote-endpoint = <>;
};
};
};
};

 {
status = "okay";
pinctrl-0 = <_pins>;
pinctrl-names = "default";

port {
#address-cells = <1>;
#size-cells = <0>;

vin0ep2: endpoint {
remote-endpoint = <_out>;
bus-width = <24>;
hsync-active = <0>;
vsync-active = <0>;
pclk-sample = <1>;
data-active = <1>;
};
};
};

Here the adv7612 driver would register a subdevice using the endpoint 
'hdmi-in@4c/ports/port@0/endpoint' while the rcar-vin driver which uses 
the async parsing helpers would register a notifier looking for 
'hdmi-in@4c/ports/port@2/endpoint'.

Something like Kieran's '[PATCH v5] v4l2-async: Match parent devices' 
would be needed in addition to this patch. I tried Kieran's patch 
together with this and it did not solve the problem upstream. I did make 
a hack on-top of Kieran's patch to add a comparison 'sd_parent == 
asd_parent' in match_fwnode() which got rcar-gen2 working again, but I'm 
not sure if that will have other side effects.

> 
> For async devices that have no endpoints, continue to use the fwnode
> related to the device. This includes e.g. lens devices.
> 
> Signed-off-by: Sakari Ailus 
> ---
> Hi Niklas,
> 
> What do you think of this one? I've tested this on N9, both sensor and
> flash devices work nicely there. No opportunistic checks for backwards
> compatibility are needed.

Over all I like it, endpoint matching I think is a good thing! If we can 
sort out the issue above I be happy to use the new async parsing helpers 
in rcar-csi2 driver.

> 
> The changes were surprisingly simple, there are only two drivers that
> weren't entirely trivial to change (this part is truly weird in exynos4-is
> and xilinx-vipp). Converting the two to use the common parsing functions
> would be quite a bit more work and would be very nice to test. The changes
> in this patch were still relatively simple.
> 
>  drivers/media/platform/am437x/am437x-vpfe.c|  2 +-
>  drivers/media/platform/atmel/atmel-isc.c   |  2 +-
>  drivers/media/platform/atmel/atmel-isi.c   |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  2 +-
>  drivers/media/platform/exynos4-is/media-dev.c  | 14 ++
>  drivers/media/platform/pxa_camera.c|  2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
>  drivers/media/platform/rcar_drif.c |  2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c  |  2 +-
>  drivers/media/platform/ti-vpe/cal.c|  2 +-
>  drivers/media/platform/xilinx/xilinx-vipp.c| 16 +---
>  drivers/media/v4l2-core/v4l2-async.c   |  8 ++--
>  drivers/media/v4l2-core/v4l2-fwnode.c  |  2 +-
>  13 files changed, 39 insertions(+), 19 

Re: [PATCH v5] v4l2-async: Match parent devices

2017-12-06 Thread Kieran Bingham
Hi Jacopo,

On 06/12/17 15:33, jacopo mondi wrote:
> Hi Kieran,
> 
> On Wed, Dec 06, 2017 at 02:58:39PM +, Kieran Bingham wrote:
>> From: Kieran Bingham 
>>
>> Devices supporting multiple endpoints on a single device node must set
>> their subdevice fwnode to the endpoint to allow distinct comparisons.
>>
>> Adapt the match_fwnode call to compare against the provided fwnodes
>> first, but to also perform a cross reference comparison against the
>> parent fwnodes of each other.
>>
>> This allows notifiers to pass the endpoint for comparison and still
>> support existing subdevices which store their default parent device
>> node.
>>
>> Signed-off-by: Kieran Bingham 
>> Signed-off-by: Sakari Ailus 
> 
> please append:
> 
> Reported-by: Jacopo Mondi 

Ahh yes of course!



> Thanks
>j
> 
>>
>> ---
>>
>> Hi Sakari,
>>
>> Since you signed-off on this patch - it has had to be reworked due to the
>> changes on the of_node_full_name() functionality.
>>
>> I believe it is correct now to *just* do the pointer matching, as that 
>> matches
>> the current implementation, and converting to device_nodes will be just as
>> equal as the fwnodes, as they are simply containers.
>>
>> Let me know if you are happy to maintain your SOB on this patch - and if we 
>> need
>> to work towards getting this integrated upstream, especially in light of 
>> your new
>> endpoint matching work.
>>
>> --
>> Regards
>>
>> Kieran
>>
>>
>> v2:
>>  - Added documentation comments
>>  - simplified the OF match by adding match_fwnode_of()
>>
>> v3:
>>  - Fix comments
>>  - Fix sd_parent, and asd_parent usage
>>
>> v4:
>>  - Clean up and simplify match_fwnode and comparisons
>>
>> v5:
>>  - Updated for v4.15-rc1:
>>of_node no longer specifies a full path, and only returns the
>>basename with of_node_full_name(), thus this ends up matching
>>"endpoint" for all endpoints. Fall back to pointer matching,
>>whilst maintaining the parent comparisons.
>> ---
>>  drivers/media/v4l2-core/v4l2-async.c | 17 -
>>  1 file changed, 16 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/v4l2-core/v4l2-async.c 
>> b/drivers/media/v4l2-core/v4l2-async.c
>> index fcadad305336..780bda70d8b3 100644
>> --- a/drivers/media/v4l2-core/v4l2-async.c
>> +++ b/drivers/media/v4l2-core/v4l2-async.c
>> @@ -71,9 +71,24 @@ static bool match_devname(struct v4l2_subdev *sd,
>>  return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
>>  }
>>
>> +/*
>> + * As a measure to support drivers which have not been converted to use
>> + * endpoint matching, we also find the parent devices for cross-matching.
>> + *
>> + * This also allows continued support for matching subdevices which will not
>> + * have an endpoint themselves.
>> + */
>>  static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev 
>> *asd)
>>  {
>> -return sd->fwnode == asd->match.fwnode.fwnode;
>> +struct fwnode_handle *asd_fwnode = asd->match.fwnode.fwnode;
>> +struct fwnode_handle *sd_parent, *asd_parent;
>> +
>> +sd_parent = fwnode_graph_get_port_parent(sd->fwnode);
>> +asd_parent = fwnode_graph_get_port_parent(asd_fwnode);
>> +
>> +return sd->fwnode == asd_fwnode ||
>> +   sd->fwnode == asd_parent ||
>> +   sd_parent == asd_fwnode;
>>  }
>>
>>  static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev 
>> *asd)
>> --
>> 2.7.4
>>


Re: [PATCH v5] v4l2-async: Match parent devices

2017-12-06 Thread jacopo mondi
Hi Kieran,

On Wed, Dec 06, 2017 at 02:58:39PM +, Kieran Bingham wrote:
> From: Kieran Bingham 
>
> Devices supporting multiple endpoints on a single device node must set
> their subdevice fwnode to the endpoint to allow distinct comparisons.
>
> Adapt the match_fwnode call to compare against the provided fwnodes
> first, but to also perform a cross reference comparison against the
> parent fwnodes of each other.
>
> This allows notifiers to pass the endpoint for comparison and still
> support existing subdevices which store their default parent device
> node.
>
> Signed-off-by: Kieran Bingham 
> Signed-off-by: Sakari Ailus 

please append:

Reported-by: Jacopo Mondi 

Thanks
   j

>
> ---
>
> Hi Sakari,
>
> Since you signed-off on this patch - it has had to be reworked due to the
> changes on the of_node_full_name() functionality.
>
> I believe it is correct now to *just* do the pointer matching, as that matches
> the current implementation, and converting to device_nodes will be just as
> equal as the fwnodes, as they are simply containers.
>
> Let me know if you are happy to maintain your SOB on this patch - and if we 
> need
> to work towards getting this integrated upstream, especially in light of your 
> new
> endpoint matching work.
>
> --
> Regards
>
> Kieran
>
>
> v2:
>  - Added documentation comments
>  - simplified the OF match by adding match_fwnode_of()
>
> v3:
>  - Fix comments
>  - Fix sd_parent, and asd_parent usage
>
> v4:
>  - Clean up and simplify match_fwnode and comparisons
>
> v5:
>  - Updated for v4.15-rc1:
>of_node no longer specifies a full path, and only returns the
>basename with of_node_full_name(), thus this ends up matching
>"endpoint" for all endpoints. Fall back to pointer matching,
>whilst maintaining the parent comparisons.
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 17 -
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-async.c 
> b/drivers/media/v4l2-core/v4l2-async.c
> index fcadad305336..780bda70d8b3 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -71,9 +71,24 @@ static bool match_devname(struct v4l2_subdev *sd,
>   return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
>  }
>
> +/*
> + * As a measure to support drivers which have not been converted to use
> + * endpoint matching, we also find the parent devices for cross-matching.
> + *
> + * This also allows continued support for matching subdevices which will not
> + * have an endpoint themselves.
> + */
>  static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev 
> *asd)
>  {
> - return sd->fwnode == asd->match.fwnode.fwnode;
> + struct fwnode_handle *asd_fwnode = asd->match.fwnode.fwnode;
> + struct fwnode_handle *sd_parent, *asd_parent;
> +
> + sd_parent = fwnode_graph_get_port_parent(sd->fwnode);
> + asd_parent = fwnode_graph_get_port_parent(asd_fwnode);
> +
> + return sd->fwnode == asd_fwnode ||
> +sd->fwnode == asd_parent ||
> +sd_parent == asd_fwnode;
>  }
>
>  static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev 
> *asd)
> --
> 2.7.4
>


[PATCH v8] uvcvideo: Add a metadata device node

2017-12-06 Thread Guennadi Liakhovetski
From: Guennadi Liakhovetski 

Some UVC video cameras contain metadata in their payload headers. This
patch extracts that data, adding more clock synchronisation information,
on both bulk and isochronous endpoints and makes it available to the user
space on a separate video node, using the V4L2_CAP_META_CAPTURE capability
and the V4L2_BUF_TYPE_META_CAPTURE buffer queue type. By default, only the
V4L2_META_FMT_UVC pixel format is available from those nodes. However,
cameras can be added to the device ID table to additionally specify their
own metadata format, in which case that format will also become available
from the metadata node.

Signed-off-by: Guennadi Liakhovetski 
---

v8: addressed comments and integrated changes from Laurent, thanks again, 
e.g.:

- multiple stylistic changes
- remove the UVC_DEV_FLAG_METADATA_NODE flag / quirk: nodes are now 
  created unconditionally
- reuse uvc_ioctl_querycap()
- reuse code in uvc_register_video()
- set an error flag when the metadata buffer overflows

 drivers/media/usb/uvc/Makefile   |   2 +-
 drivers/media/usb/uvc/uvc_driver.c   |  15 ++-
 drivers/media/usb/uvc/uvc_isight.c   |   2 +-
 drivers/media/usb/uvc/uvc_metadata.c | 179 +++
 drivers/media/usb/uvc/uvc_queue.c|  44 +++--
 drivers/media/usb/uvc/uvc_video.c| 132 --
 drivers/media/usb/uvc/uvcvideo.h |  16 +++-
 include/uapi/linux/uvcvideo.h|  26 +
 8 files changed, 394 insertions(+), 22 deletions(-)
 create mode 100644 drivers/media/usb/uvc/uvc_metadata.c

diff --git a/drivers/media/usb/uvc/Makefile b/drivers/media/usb/uvc/Makefile
index c26d12f..06c7cd3 100644
--- a/drivers/media/usb/uvc/Makefile
+++ b/drivers/media/usb/uvc/Makefile
@@ -1,5 +1,5 @@
 uvcvideo-objs  := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \
- uvc_status.o uvc_isight.o uvc_debugfs.o
+ uvc_status.o uvc_isight.o uvc_debugfs.o uvc_metadata.o
 ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
 uvcvideo-objs  += uvc_entity.o
 endif
diff --git a/drivers/media/usb/uvc/uvc_driver.c 
b/drivers/media/usb/uvc/uvc_driver.c
index 88032c2..36061f3 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1883,6 +1883,7 @@ static void uvc_unregister_video(struct uvc_device *dev)
continue;
 
video_unregister_device(>vdev);
+   video_unregister_device(>meta.vdev);
 
uvc_debugfs_cleanup_stream(stream);
}
@@ -1930,6 +1931,9 @@ int uvc_register_video_device(struct uvc_device *dev,
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
vdev->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
break;
+   case V4L2_BUF_TYPE_META_CAPTURE:
+   vdev->device_caps = V4L2_CAP_META_CAPTURE | V4L2_CAP_STREAMING;
+   break;
}
 
strlcpy(vdev->name, dev->name, sizeof vdev->name);
@@ -1965,7 +1969,8 @@ static int uvc_register_video(struct uvc_device *dev,
}
 
if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
-   stream->chain->caps |= V4L2_CAP_VIDEO_CAPTURE;
+   stream->chain->caps |= V4L2_CAP_VIDEO_CAPTURE
+   | V4L2_CAP_META_CAPTURE;
else
stream->chain->caps |= V4L2_CAP_VIDEO_OUTPUT;
 
@@ -2003,6 +2008,11 @@ static int uvc_register_terms(struct uvc_device *dev,
if (ret < 0)
return ret;
 
+   /* Register a metadata node, but ignore a possible failure,
+* complete registration of video nodes anyway.
+*/
+   uvc_meta_register(stream);
+
term->vdev = >vdev;
}
 
@@ -2037,6 +2047,7 @@ static int uvc_register_chains(struct uvc_device *dev)
 
 struct uvc_device_info {
u32 quirks;
+   u32 meta_format;
 };
 
 static int uvc_probe(struct usb_interface *intf,
@@ -2074,6 +2085,8 @@ static int uvc_probe(struct usb_interface *intf,
dev->intfnum = intf->cur_altsetting->desc.bInterfaceNumber;
dev->quirks = (uvc_quirks_param == -1)
? quirks : uvc_quirks_param;
+   if (info)
+   dev->meta_format = info->meta_format;
 
if (udev->product != NULL)
strlcpy(dev->name, udev->product, sizeof dev->name);
diff --git a/drivers/media/usb/uvc/uvc_isight.c 
b/drivers/media/usb/uvc/uvc_isight.c
index 8510e725..fb940cf 100644
--- a/drivers/media/usb/uvc/uvc_isight.c
+++ b/drivers/media/usb/uvc/uvc_isight.c
@@ -100,7 +100,7 @@ static int isight_decode(struct uvc_video_queue *queue, 
struct uvc_buffer *buf,
 }
 
 void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream,
-   struct uvc_buffer *buf)
+   struct uvc_buffer *buf, struct uvc_buffer *meta_buf)
 {
int ret, i;
 
diff --git 

Re: [PATCH 3/3 v7] uvcvideo: add a metadata device node

2017-12-06 Thread Guennadi Liakhovetski
Hi Laurent,

While testing the new patch version, we did introduce a couple of 
differences:

1. We cannot (easily) reuse .vidioc_querycap() - the metadata node uses 
v4l2_fh_open() directly, so, it has a different struct file::private_data 
pointer.

2. After your video device unification, the order has swapped: now 
/dev/video0 is a metadata node and /dev/video1 is a video node. Is that 
how you wanted to have this or you don't mind or shall I swap them back? 
For now I've swapped them back, I think that would be more appropriate.

Thanks
Guennadi


[PATCH v5] v4l2-async: Match parent devices

2017-12-06 Thread Kieran Bingham
From: Kieran Bingham 

Devices supporting multiple endpoints on a single device node must set
their subdevice fwnode to the endpoint to allow distinct comparisons.

Adapt the match_fwnode call to compare against the provided fwnodes
first, but to also perform a cross reference comparison against the
parent fwnodes of each other.

This allows notifiers to pass the endpoint for comparison and still
support existing subdevices which store their default parent device
node.

Signed-off-by: Kieran Bingham 
Signed-off-by: Sakari Ailus 

---

Hi Sakari,

Since you signed-off on this patch - it has had to be reworked due to the
changes on the of_node_full_name() functionality.

I believe it is correct now to *just* do the pointer matching, as that matches
the current implementation, and converting to device_nodes will be just as
equal as the fwnodes, as they are simply containers.

Let me know if you are happy to maintain your SOB on this patch - and if we need
to work towards getting this integrated upstream, especially in light of your 
new
endpoint matching work.

--
Regards

Kieran


v2:
 - Added documentation comments
 - simplified the OF match by adding match_fwnode_of()

v3:
 - Fix comments
 - Fix sd_parent, and asd_parent usage

v4:
 - Clean up and simplify match_fwnode and comparisons

v5:
 - Updated for v4.15-rc1:
   of_node no longer specifies a full path, and only returns the
   basename with of_node_full_name(), thus this ends up matching
   "endpoint" for all endpoints. Fall back to pointer matching,
   whilst maintaining the parent comparisons.
---
 drivers/media/v4l2-core/v4l2-async.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index fcadad305336..780bda70d8b3 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -71,9 +71,24 @@ static bool match_devname(struct v4l2_subdev *sd,
return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
 }
 
+/*
+ * As a measure to support drivers which have not been converted to use
+ * endpoint matching, we also find the parent devices for cross-matching.
+ *
+ * This also allows continued support for matching subdevices which will not
+ * have an endpoint themselves.
+ */
 static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
-   return sd->fwnode == asd->match.fwnode.fwnode;
+   struct fwnode_handle *asd_fwnode = asd->match.fwnode.fwnode;
+   struct fwnode_handle *sd_parent, *asd_parent;
+
+   sd_parent = fwnode_graph_get_port_parent(sd->fwnode);
+   asd_parent = fwnode_graph_get_port_parent(asd_fwnode);
+
+   return sd->fwnode == asd_fwnode ||
+  sd->fwnode == asd_parent ||
+  sd_parent == asd_fwnode;
 }
 
 static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
-- 
2.7.4



Re: [PATCH] media: platform: sti: Adopt SPDX identifier

2017-12-06 Thread Fabien DESSENNE


On 05/12/17 15:52, Benjamin Gaignard wrote:
> Add SPDX identifiers to files under sti directory
>
> Signed-off-by: Benjamin Gaignard 

For the bdisp part:
Reviewed-by: Fabien Dessenne 
> ---
>   drivers/media/platform/sti/bdisp/bdisp-debug.c   |  2 +-
>   drivers/media/platform/sti/bdisp/bdisp-filter.h  |  2 +-
>   drivers/media/platform/sti/bdisp/bdisp-hw.c  |  2 +-
>   drivers/media/platform/sti/bdisp/bdisp-reg.h |  2 +-
>   drivers/media/platform/sti/bdisp/bdisp-v4l2.c|  2 +-
>   drivers/media/platform/sti/bdisp/bdisp.h |  2 +-
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c  |  5 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.h  |  5 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c|  5 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.h|  5 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c |  9 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.h |  9 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c | 11 +--
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.h |  5 +
>   drivers/media/platform/sti/cec/stih-cec.c|  5 +
>   drivers/media/platform/sti/delta/delta-cfg.h |  2 +-
>   drivers/media/platform/sti/delta/delta-debug.c   |  2 +-
>   drivers/media/platform/sti/delta/delta-debug.h   |  2 +-
>   drivers/media/platform/sti/delta/delta-ipc.c |  2 +-
>   drivers/media/platform/sti/delta/delta-ipc.h |  2 +-
>   drivers/media/platform/sti/delta/delta-mem.c |  2 +-
>   drivers/media/platform/sti/delta/delta-mem.h |  2 +-
>   drivers/media/platform/sti/delta/delta-mjpeg-dec.c   |  2 +-
>   drivers/media/platform/sti/delta/delta-mjpeg-fw.h|  2 +-
>   drivers/media/platform/sti/delta/delta-mjpeg-hdr.c   |  2 +-
>   drivers/media/platform/sti/delta/delta-mjpeg.h   |  2 +-
>   drivers/media/platform/sti/delta/delta-v4l2.c|  2 +-
>   drivers/media/platform/sti/delta/delta.h |  2 +-
>   drivers/media/platform/sti/hva/hva-debugfs.c |  2 +-
>   drivers/media/platform/sti/hva/hva-h264.c|  2 +-
>   drivers/media/platform/sti/hva/hva-hw.c  |  2 +-
>   drivers/media/platform/sti/hva/hva-hw.h  |  2 +-
>   drivers/media/platform/sti/hva/hva-mem.c |  2 +-
>   drivers/media/platform/sti/hva/hva-mem.h |  2 +-
>   drivers/media/platform/sti/hva/hva-v4l2.c|  2 +-
>   drivers/media/platform/sti/hva/hva.h |  2 +-
>   36 files changed, 36 insertions(+), 77 deletions(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c 
> b/drivers/media/platform/sti/bdisp/bdisp-debug.c
> index 2cc289e4dea1..c6a4e2de5c0c 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-debug.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
> @@ -1,7 +1,7 @@
> +// SPDX-License-Identifier: GPL-2.0
>   /*
>* Copyright (C) STMicroelectronics SA 2014
>* Authors: Fabien Dessenne  for STMicroelectronics.
> - * License terms:  GNU General Public License (GPL), version 2
>*/
>   
>   #include 
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-filter.h 
> b/drivers/media/platform/sti/bdisp/bdisp-filter.h
> index 53e52fb4127f..d25adb57e3d0 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-filter.h
> +++ b/drivers/media/platform/sti/bdisp/bdisp-filter.h
> @@ -1,7 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
>   /*
>* Copyright (C) STMicroelectronics SA 2014
>* Authors: Fabien Dessenne  for STMicroelectronics.
> - * License terms:  GNU General Public License (GPL), version 2
>*/
>   
>   #define BDISP_HF_NB 64
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c 
> b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> index b7892f3efd98..e7836b307d21 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> @@ -1,7 +1,7 @@
> +// SPDX-License-Identifier: GPL-2.0
>   /*
>* Copyright (C) STMicroelectronics SA 2014
>* Authors: Fabien Dessenne  for STMicroelectronics.
> - * License terms:  GNU General Public License (GPL), version 2
>*/
>   
>   #include 
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-reg.h 
> b/drivers/media/platform/sti/bdisp/bdisp-reg.h
> index e7e1a425f65a..b07ecc903707 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-reg.h
> +++ b/drivers/media/platform/sti/bdisp/bdisp-reg.h
> @@ -1,7 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
>   /*
>* Copyright (C) STMicroelectronics SA 2014
>* Authors: Fabien Dessenne  for STMicroelectronics.
> - * License terms:  GNU General Public 

[PATCH v3 00/12] Rockchip ISP1 Driver

2017-12-06 Thread Jacob Chen
changes in V3:
  - add some comments
  - fix wrong use of v4l2_async_subdev_notifier_register
  - optimize two paths capture at a time
  - remove compose
  - re-struct headers
  - add a tmp wiki page: http://opensource.rock-chips.com/wiki_Rockchip-isp1

changes in V2:
  mipi-phy:
- use async probing
- make it be a child device of the GRF

  isp:
- add dummy buffer
- change the way to get bus configuration, which make it possible to
add parallel sensor support in the future(without mipi-phy driver).

This patch series add a ISP(Camera) v4l2 driver for rockchip rk3288/rk3399 SoC.

Kernel Branch:
https://github.com/wzyy2/linux/tree/rkisp1/drivers/media/platform/rockchip/isp1

Wiki Pages:
http://opensource.rock-chips.com/wiki_Rockchip-isp1

Jacob Chen (8):
  media: doc: add document for rkisp1 meta buffer format
  media: rkisp1: add rockchip isp1 driver
  media: rkisp1: add Rockchip MIPI Synopsys DPHY driver
  dt-bindings: Document the Rockchip ISP1 bindings
  dt-bindings: Document the Rockchip MIPI RX D-PHY bindings
  ARM: dts: rockchip: add isp node for rk3288
  ARM: dts: rockchip: add rx0 mipi-phy for rk3288
  MAINTAINERS: add entry for Rockchip ISP1 driver

Jeffy Chen (1):
  media: rkisp1: Add user space ABI definitions

Shunqian Zheng (3):
  media: videodev2.h, v4l2-ioctl: add rkisp1 meta buffer format
  arm64: dts: rockchip: add isp0 node for rk3399
  arm64: dts: rockchip: add rx0 mipi-phy for rk3399

 .../devicetree/bindings/media/rockchip-isp1.txt|   57 +
 .../bindings/media/rockchip-mipi-dphy.txt  |   71 +
 Documentation/media/uapi/v4l/meta-formats.rst  |2 +
 .../media/uapi/v4l/pixfmt-meta-rkisp1-params.rst   |   17 +
 .../media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst |   18 +
 MAINTAINERS|   10 +
 arch/arm/boot/dts/rk3288.dtsi  |   24 +
 arch/arm64/boot/dts/rockchip/rk3399.dtsi   |   26 +
 drivers/media/platform/Kconfig |   10 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/rockchip/isp1/Makefile  |8 +
 drivers/media/platform/rockchip/isp1/capture.c | 1684 
 drivers/media/platform/rockchip/isp1/capture.h |  194 +++
 drivers/media/platform/rockchip/isp1/common.h  |  137 ++
 drivers/media/platform/rockchip/isp1/dev.c |  655 
 drivers/media/platform/rockchip/isp1/dev.h |  120 ++
 drivers/media/platform/rockchip/isp1/isp_params.c  | 1543 ++
 drivers/media/platform/rockchip/isp1/isp_params.h  |   76 +
 drivers/media/platform/rockchip/isp1/isp_stats.c   |  521 ++
 drivers/media/platform/rockchip/isp1/isp_stats.h   |   85 +
 .../media/platform/rockchip/isp1/mipi_dphy_sy.c|  787 +
 drivers/media/platform/rockchip/isp1/regs.c|  264 +++
 drivers/media/platform/rockchip/isp1/regs.h| 1582 ++
 drivers/media/platform/rockchip/isp1/rkisp1.c  | 1201 ++
 drivers/media/platform/rockchip/isp1/rkisp1.h  |  131 ++
 drivers/media/v4l2-core/v4l2-ioctl.c   |2 +
 include/uapi/linux/rkisp1-config.h |  785 +
 include/uapi/linux/videodev2.h |4 +
 28 files changed, 10015 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/rockchip-isp1.txt
 create mode 100644 
Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-params.rst
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst
 create mode 100644 drivers/media/platform/rockchip/isp1/Makefile
 create mode 100644 drivers/media/platform/rockchip/isp1/capture.c
 create mode 100644 drivers/media/platform/rockchip/isp1/capture.h
 create mode 100644 drivers/media/platform/rockchip/isp1/common.h
 create mode 100644 drivers/media/platform/rockchip/isp1/dev.c
 create mode 100644 drivers/media/platform/rockchip/isp1/dev.h
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_params.c
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_params.h
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_stats.c
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_stats.h
 create mode 100644 drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
 create mode 100644 drivers/media/platform/rockchip/isp1/regs.c
 create mode 100644 drivers/media/platform/rockchip/isp1/regs.h
 create mode 100644 drivers/media/platform/rockchip/isp1/rkisp1.c
 create mode 100644 drivers/media/platform/rockchip/isp1/rkisp1.h
 create mode 100644 include/uapi/linux/rkisp1-config.h

-- 
2.15.0



[PATCH v3 06/12] dt-bindings: Document the Rockchip ISP1 bindings

2017-12-06 Thread Jacob Chen
From: Jacob Chen 

Add DT bindings documentation for Rockchip ISP1

Signed-off-by: Jacob Chen 
---
 .../devicetree/bindings/media/rockchip-isp1.txt| 57 ++
 1 file changed, 57 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/rockchip-isp1.txt

diff --git a/Documentation/devicetree/bindings/media/rockchip-isp1.txt 
b/Documentation/devicetree/bindings/media/rockchip-isp1.txt
new file mode 100644
index ..0971ed94ed69
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rockchip-isp1.txt
@@ -0,0 +1,57 @@
+Rockchip SoC Image Signal Processing unit v1
+--
+
+Rockchip ISP1 is the Camera interface for the Rockchip series of SoCs
+which contains image processing, scaling, and compression funcitons.
+
+Required properties:
+  - compatible: value should be one of the following
+  "rockchip,rk3288-cif-isp";
+  "rockchip,rk3399-cif-isp";
+  - reg : offset and length of the register set for the device.
+  - interrupts: should contain ISP interrupt.
+  - clocks: phandle to the required clocks.
+  - clock-names: required clock name.
+  - iommus: required a iommu node.
+
+The device node should contain one 'port' child node with child 'endpoint'
+nodes, according to the bindings defined in Documentation/devicetree/bindings/
+media/video-interfaces.txt.
+
+For sensor with a parallel video bus, it could be linked directly to the isp.
+For sensor with a MIPI CSI-2 video bus, it should be linked through the
+MIPI-DPHY, which is defined in rockchip-mipi-dphy.txt.
+
+Device node example
+---
+
+   isp0: isp0@ff91 {
+   compatible = "rockchip,rk3399-cif-isp";
+   reg = <0x0 0xff91 0x0 0x4000>;
+   interrupts = ;
+   clocks = < SCLK_ISP0>,
+< ACLK_ISP0>, < ACLK_ISP0_WRAPPER>,
+< HCLK_ISP0>, < HCLK_ISP0_WRAPPER>;
+   clock-names = "clk_isp",
+ "aclk_isp", "aclk_isp_wrap",
+ "hclk_isp", "hclk_isp_wrap";
+   power-domains = < RK3399_PD_ISP0>;
+   iommus = <_mmu>;
+   
+   port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   /* mipi */
+   isp0_mipi_in: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = <_rx0_out>;
+   };
+
+   /* parallel */
+   isp0_parallel_in: endpoint@1 {
+   reg = <1>;
+   remote-endpoint = <_out>;
+   };
+   };
+   };
-- 
2.15.0



[PATCH v3 02/12] media: doc: add document for rkisp1 meta buffer format

2017-12-06 Thread Jacob Chen
Signed-off-by: Jacob Chen 
---
 Documentation/media/uapi/v4l/meta-formats.rst  |  2 ++
 .../media/uapi/v4l/pixfmt-meta-rkisp1-params.rst   | 17 +
 .../media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst | 18 ++
 3 files changed, 37 insertions(+)
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-params.rst
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst

diff --git a/Documentation/media/uapi/v4l/meta-formats.rst 
b/Documentation/media/uapi/v4l/meta-formats.rst
index 01e24e3df571..1b8281423aa2 100644
--- a/Documentation/media/uapi/v4l/meta-formats.rst
+++ b/Documentation/media/uapi/v4l/meta-formats.rst
@@ -14,3 +14,5 @@ These formats are used for the :ref:`metadata` interface only.
 
 pixfmt-meta-vsp1-hgo
 pixfmt-meta-vsp1-hgt
+pixfmt-meta-rkisp1-params
+pixfmt-meta-rkisp1-stat
diff --git a/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-params.rst 
b/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-params.rst
new file mode 100644
index ..ed344d463b52
--- /dev/null
+++ b/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-params.rst
@@ -0,0 +1,17 @@
+.. -*- coding: utf-8; mode: rst -*-
+
+.. _v4l2-meta-fmt-rkisp1-params:
+
+***
+V4L2_META_FMT_RK_ISP1_PARAMS
+***
+
+Rockchip ISP1 Parameters Data
+
+Description
+===
+
+This format describes input parameters for the Rockchip ISP1.
+
+The data use c-struct :c:type:`rkisp1_isp_params_cfg`, which is defined in
+the ``linux/rkisp1-config.h`` header file, See it for details.
diff --git a/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst 
b/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst
new file mode 100644
index ..5ecc4031295f
--- /dev/null
+++ b/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst
@@ -0,0 +1,18 @@
+.. -*- coding: utf-8; mode: rst -*-
+
+.. _v4l2-meta-fmt-rkisp1-stat:
+
+***
+V4L2_META_FMT_RK_ISP1_STAT_3A
+***
+
+Rockchip ISP1 Statistics Data
+
+Description
+===
+
+This format describes image color statistics information generated by the 
Rockchip
+ISP1.
+
+The data use c-struct :c:type:`rkisp1_stat_buffer`, which is defined in
+the ``linux/cifisp_stat.h`` header file, See it for details.
-- 
2.15.0



[PATCH v3 05/12] media: rkisp1: add Rockchip MIPI Synopsys DPHY driver

2017-12-06 Thread Jacob Chen
From: Jacob Chen 

This commit adds a subdev driver for Rockchip MIPI Synopsys DPHY driver.

Signed-off-by: Jacob Chen 
Signed-off-by: Shunqian Zheng 
Signed-off-by: Tomasz Figa 
---
 drivers/media/platform/rockchip/isp1/Makefile  |   1 +
 .../media/platform/rockchip/isp1/mipi_dphy_sy.c| 787 +
 2 files changed, 788 insertions(+)
 create mode 100644 drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c

diff --git a/drivers/media/platform/rockchip/isp1/Makefile 
b/drivers/media/platform/rockchip/isp1/Makefile
index 8f52f959398e..18af64853734 100644
--- a/drivers/media/platform/rockchip/isp1/Makefile
+++ b/drivers/media/platform/rockchip/isp1/Makefile
@@ -4,4 +4,5 @@ video_rkisp1-objs  +=   rkisp1.o \
regs.o \
isp_stats.o \
isp_params.o \
+   mipi_dphy_sy.o \
capture.o
diff --git a/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c 
b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
new file mode 100644
index ..942118366f49
--- /dev/null
+++ b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
@@ -0,0 +1,787 @@
+/*
+ * Rockchip MIPI Synopsys DPHY driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define RK3288_GRF_SOC_CON60x025c
+#define RK3288_GRF_SOC_CON80x0264
+#define RK3288_GRF_SOC_CON90x0268
+#define RK3288_GRF_SOC_CON10   0x026c
+#define RK3288_GRF_SOC_CON14   0x027c
+#define RK3288_GRF_SOC_STATUS210x02d4
+#define RK3288_GRF_IO_VSEL 0x0380
+#define RK3288_GRF_SOC_CON15   0x03a4
+
+#define RK3399_GRF_SOC_CON90x6224
+#define RK3399_GRF_SOC_CON21   0x6254
+#define RK3399_GRF_SOC_CON22   0x6258
+#define RK3399_GRF_SOC_CON23   0x625c
+#define RK3399_GRF_SOC_CON24   0x6260
+#define RK3399_GRF_SOC_CON25   0x6264
+#define RK3399_GRF_SOC_STATUS1 0xe2a4
+
+#define CLOCK_LANE_HS_RX_CONTROL   0x34
+#define LANE0_HS_RX_CONTROL0x44
+#define LANE1_HS_RX_CONTROL0x54
+#define LANE2_HS_RX_CONTROL0x84
+#define LANE3_HS_RX_CONTROL0x94
+#define HS_RX_DATA_LANES_THS_SETTLE__CONTROL   0x75
+
+#define HIWORD_UPDATE(val, mask, shift) \
+   ((val) << (shift) | (mask) << ((shift) + 16))
+
+enum mipi_dphy_sy_pads {
+   MIPI_DPHY_SY_PAD_SINK = 0,
+   MIPI_DPHY_SY_PAD_SOURCE,
+   MIPI_DPHY_SY_PADS_NUM,
+};
+
+enum dphy_reg_id {
+   GRF_DPHY_RX0_TURNDISABLE = 0,
+   GRF_DPHY_RX0_FORCERXMODE,
+   GRF_DPHY_RX0_FORCETXSTOPMODE,
+   GRF_DPHY_RX0_ENABLE,
+   GRF_DPHY_RX0_TESTCLR,
+   GRF_DPHY_RX0_TESTCLK,
+   GRF_DPHY_RX0_TESTEN,
+   GRF_DPHY_RX0_TESTDIN,
+   GRF_DPHY_RX0_TURNREQUEST,
+   GRF_DPHY_RX0_TESTDOUT,
+   GRF_DPHY_TX0_TURNDISABLE,
+   GRF_DPHY_TX0_FORCERXMODE,
+   GRF_DPHY_TX0_FORCETXSTOPMODE,
+   GRF_DPHY_TX0_TURNREQUEST,
+   GRF_DPHY_TX1RX1_TURNDISABLE,
+   GRF_DPHY_TX1RX1_FORCERXMODE,
+   GRF_DPHY_TX1RX1_FORCETXSTOPMODE,
+   GRF_DPHY_TX1RX1_ENABLE,
+   GRF_DPHY_TX1RX1_MASTERSLAVEZ,
+   GRF_DPHY_TX1RX1_BASEDIR,
+   GRF_DPHY_TX1RX1_ENABLECLK,
+   GRF_DPHY_TX1RX1_TURNREQUEST,
+   GRF_DPHY_RX1_SRC_SEL,
+   /* rk3288 only */
+   GRF_CON_DISABLE_ISP,
+   

[PATCH v3 07/12] dt-bindings: Document the Rockchip MIPI RX D-PHY bindings

2017-12-06 Thread Jacob Chen
From: Jacob Chen 

Add DT bindings documentation for Rockchip MIPI D-PHY RX

Signed-off-by: Jacob Chen 
---
 .../bindings/media/rockchip-mipi-dphy.txt  | 71 ++
 1 file changed, 71 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt

diff --git a/Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt 
b/Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt
new file mode 100644
index ..cef9450db051
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt
@@ -0,0 +1,71 @@
+Rockchip SoC MIPI RX D-PHY
+-
+
+Required properties:
+
+- compatible: value should be one of the following
+"rockchip,rk3288-mipi-dphy";
+"rockchip,rk3399-mipi-dphy";
+- rockchip,grf: GRF regs.
+- bus-width : maximum number of data lanes supported (SoC specific);
+- clocks : list of clock specifiers, corresponding to entries in
+   clock-names property;
+- clock-names: required clock name.
+
+The device node should contain two 'port' child node, according to the bindings
+defined in Documentation/devicetree/bindings/media/video-interfaces.txt.
+The first port should be connected to sensor nodes, and the second port should 
be
+connected to isp node. The following are properties specific to those nodes.
+
+endpoint node
+-
+
+- data-lanes : (required) an array specifying active physical MIPI-CSI2
+   data input lanes and their mapping to logical lanes; the
+   array's content is unused, only its length is meaningful;
+
+Device node example
+---
+
+mipi_dphy_rx0: mipi-dphy-rx0 {
+compatible = "rockchip,rk3399-mipi-dphy";
+clocks = < SCLK_MIPIDPHY_REF>,
+< SCLK_DPHY_RX0_CFG>,
+< PCLK_VIO_GRF>;
+clock-names = "dphy-ref", "dphy-cfg", "grf";
+power-domains = < RK3399_PD_VIO>;
+bus-width = <4>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+port@0 {
+reg = <0>;
+#address-cells = <1>;
+#size-cells = <0>;
+
+mipi_in_wcam: endpoint@0 {
+reg = <0>;
+remote-endpoint = <_out>;
+data-lanes = <1 2>;
+};
+mipi_in_ucam: endpoint@1 {
+reg = <1>;
+remote-endpoint = <_out>;
+data-lanes = <1>;
+};
+};
+
+port@1 {
+reg = <1>;
+#address-cells = <1>;
+#size-cells = <0>;
+
+dphy_rx0_out: endpoint@0 {
+reg = <0>;
+remote-endpoint = <_mipi_in>;
+};
+};
+};
+};
\ No newline at end of file
-- 
2.15.0



[PATCH v3 09/12] ARM: dts: rockchip: add rx0 mipi-phy for rk3288

2017-12-06 Thread Jacob Chen
From: Jacob Chen 

It's a Designware MIPI D-PHY, used by ISP in rk3288.

Signed-off-by: Jacob Chen 
---
 arch/arm/boot/dts/rk3288.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index ea1dda001043..baeedd2cb351 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -864,6 +864,13 @@
status = "disabled";
};
 
+   mipi_phy_rx0: mipi-phy-rx0 {
+   compatible = "rockchip,rk3288-mipi-dphy";
+   clocks = < SCLK_MIPIDSI_24M>, < PCLK_MIPI_CSI>;
+   clock-names = "dphy-ref", "pclk";
+   status = "disabled";
+   };
+
io_domains: io-domains {
compatible = "rockchip,rk3288-io-voltage-domain";
status = "disabled";
-- 
2.15.0



[PATCH v3 11/12] arm64: dts: rockchip: add rx0 mipi-phy for rk3399

2017-12-06 Thread Jacob Chen
From: Shunqian Zheng 

It's a Designware MIPI D-PHY, used for ISP0 in rk3399.

Signed-off-by: Shunqian Zheng 
Signed-off-by: Jacob Chen 
---
 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index 66a912fab5dd..a65b110afaf3 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -1292,6 +1292,17 @@
status = "disabled";
};
 
+   mipi_dphy_rx0: mipi-dphy-rx0 {
+   compatible = "rockchip,rk3399-mipi-dphy";
+   clocks = < SCLK_MIPIDPHY_REF>,
+   < SCLK_DPHY_RX0_CFG>,
+   < PCLK_VIO_GRF>;
+   clock-names = "dphy-ref", "dphy-cfg", "grf";
+   power-domains = < RK3399_PD_VIO>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
u2phy0: usb2-phy@e450 {
compatible = "rockchip,rk3399-usb2phy";
reg = <0xe450 0x10>;
-- 
2.15.0



[PATCH v3 10/12] arm64: dts: rockchip: add isp0 node for rk3399

2017-12-06 Thread Jacob Chen
From: Shunqian Zheng 

rk3399 have two ISP, but we havn't test isp1, so just add isp0 at present.

Signed-off-by: Shunqian Zheng 
Signed-off-by: Jacob Chen 
---
 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index d340b58ab184..66a912fab5dd 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -1588,6 +1588,21 @@
status = "disabled";
};
 
+   isp0: isp0@ff91 {
+   compatible = "rockchip,rk3399-cif-isp";
+   reg = <0x0 0xff91 0x0 0x4000>;
+   interrupts = ;
+   clocks = < SCLK_ISP0>,
+< ACLK_ISP0>, < ACLK_ISP0_WRAPPER>,
+< HCLK_ISP0>, < HCLK_ISP0_WRAPPER>;
+   clock-names = "clk_isp",
+ "aclk_isp", "aclk_isp_wrap",
+ "hclk_isp", "hclk_isp_wrap";
+   power-domains = < RK3399_PD_ISP0>;
+   iommus = <_mmu>;
+   status = "disabled";
+   };
+
isp0_mmu: iommu@ff914000 {
compatible = "rockchip,iommu";
reg = <0x0 0xff914000 0x0 0x100>, <0x0 0xff915000 0x0 0x100>;
-- 
2.15.0



[PATCH v3 12/12] MAINTAINERS: add entry for Rockchip ISP1 driver

2017-12-06 Thread Jacob Chen
From: Jacob Chen 

Add MAINTAINERS entry for the rockchip isp1 driver.
This driver is maintained by rockchip officially and it
will be used for rockchip SoC on all linux-kernel based OS.

Signed-off-by: Jacob Chen 
---
 MAINTAINERS | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index b05bc2c5e85c..614196ed7265 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11665,6 +11665,16 @@ F: drivers/hid/hid-roccat*
 F: include/linux/hid-roccat*
 F: Documentation/ABI/*/sysfs-driver-hid-roccat*
 
+ROCKCHIP ISP V1 DRIVER
+M: Jacob chen 
+M: Shunqian Zheng 
+M: Yichong Zhong 
+L: linux-media@vger.kernel.org
+S: Maintained
+F: drivers/media/platform/rockchip/isp1/
+F: Documentation/devicetree/bindings/media/rockchip-isp1.txt
+F: Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt
+
 ROCKCHIP RASTER 2D GRAPHIC ACCELERATION UNIT DRIVER
 M: Jacob chen 
 L: linux-media@vger.kernel.org
-- 
2.15.0



[PATCH v3 08/12] ARM: dts: rockchip: add isp node for rk3288

2017-12-06 Thread Jacob Chen
From: Jacob Chen 

rk3288 have a Embedded 13M ISP

Signed-off-by: Jacob Chen 
---
 arch/arm/boot/dts/rk3288.dtsi | 17 +
 1 file changed, 17 insertions(+)

diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index a3c015628421..ea1dda001043 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -962,6 +962,23 @@
status = "disabled";
};
 
+   isp: isp@ff91 {
+   compatible = "rockchip,rk3288-cif-isp";
+   reg = <0x0 0xff91 0x0 0x4000>;
+   interrupts = ;
+   clocks = < SCLK_ISP>, < ACLK_ISP>,
+< HCLK_ISP>, < PCLK_ISP_IN>,
+< SCLK_ISP_JPE>;
+   clock-names = "clk_isp", "aclk_isp",
+ "hclk_isp", "pclk_isp_in",
+ "sclk_isp_jpe";
+   assigned-clocks = < SCLK_ISP>, < SCLK_ISP_JPE>;
+   assigned-clock-rates = <4>, <4>;
+   power-domains = < RK3288_PD_VIO>;
+   iommus = <_mmu>;
+   status = "disabled";
+   };
+
isp_mmu: iommu@ff914000 {
compatible = "rockchip,iommu";
reg = <0x0 0xff914000 0x0 0x100>, <0x0 0xff915000 0x0 0x100>;
-- 
2.15.0



[PATCH v3 03/12] media: rkisp1: Add user space ABI definitions

2017-12-06 Thread Jacob Chen
From: Jeffy Chen 

Add the header for userspace

Signed-off-by: Jeffy Chen 
Signed-off-by: Jacob Chen 
---
 include/uapi/linux/rkisp1-config.h | 785 +
 1 file changed, 785 insertions(+)
 create mode 100644 include/uapi/linux/rkisp1-config.h

diff --git a/include/uapi/linux/rkisp1-config.h 
b/include/uapi/linux/rkisp1-config.h
new file mode 100644
index ..82fecbee23a9
--- /dev/null
+++ b/include/uapi/linux/rkisp1-config.h
@@ -0,0 +1,785 @@
+/*
+ * Rockchip isp1 driver
+ *
+ * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _UAPI_RKISP1_CONFIG_H
+#define _UAPI_RKISP1_CONFIG_H
+
+#include 
+#include 
+
+#define CIFISP_MODULE_DPCC  (1 << 0)
+#define CIFISP_MODULE_BLS   (1 << 1)
+#define CIFISP_MODULE_SDG   (1 << 2)
+#define CIFISP_MODULE_HST   (1 << 3)
+#define CIFISP_MODULE_LSC   (1 << 4)
+#define CIFISP_MODULE_AWB_GAIN  (1 << 5)
+#define CIFISP_MODULE_FLT   (1 << 6)
+#define CIFISP_MODULE_BDM   (1 << 7)
+#define CIFISP_MODULE_CTK   (1 << 8)
+#define CIFISP_MODULE_GOC   (1 << 9)
+#define CIFISP_MODULE_CPROC (1 << 10)
+#define CIFISP_MODULE_AFC   (1 << 11)
+#define CIFISP_MODULE_AWB   (1 << 12)
+#define CIFISP_MODULE_IE(1 << 13)
+#define CIFISP_MODULE_AEC   (1 << 14)
+#define CIFISP_MODULE_WDR   (1 << 15)
+#define CIFISP_MODULE_DPF   (1 << 16)
+#define CIFISP_MODULE_DPF_STRENGTH  (1 << 17)
+
+#define CIFISP_CTK_COEFF_MAX0x100
+#define CIFISP_CTK_OFFSET_MAX   0x800
+
+#define CIFISP_AE_MEAN_MAX  25
+#define CIFISP_HIST_BIN_N_MAX   16
+#define CIFISP_AFM_MAX_WINDOWS  3
+#define CIFISP_DEGAMMA_CURVE_SIZE   17
+
+#define CIFISP_BDM_MAX_TH   0xFF
+
+/*
+ * Black level compensation
+ */
+/* maximum value for horizontal start address */
+#define CIFISP_BLS_START_H_MAX 0x0FFF
+/* maximum value for horizontal stop address */
+#define CIFISP_BLS_STOP_H_MAX  0x0FFF
+/* maximum value for vertical start address */
+#define CIFISP_BLS_START_V_MAX 0x0FFF
+/* maximum value for vertical stop address */
+#define CIFISP_BLS_STOP_V_MAX  0x0FFF
+/* maximum is 2^18 = 262144*/
+#define CIFISP_BLS_SAMPLES_MAX 0x0012
+/* maximum value for fixed black level */
+#define CIFISP_BLS_FIX_SUB_MAX 0x0FFF
+/* minimum value for fixed black level */
+#define CIFISP_BLS_FIX_SUB_MIN 0xF000
+/* 13 bit range (signed)*/
+#define CIFISP_BLS_FIX_MASK0x1FFF
+
+/*
+ * Automatic white balance measurments
+ */
+#define CIFISP_AWB_MAX_GRID1
+#define CIFISP_AWB_MAX_FRAMES  7
+
+/*
+ * Gamma out
+ */
+/* Maximum number of color samples supported */
+#define CIFISP_GAMMA_OUT_MAX_SAMPLES   17
+
+/*
+ * Lens shade correction
+ */
+#define CIFISP_LSC_GRAD_TBL_SIZE   8
+#define CIFISP_LSC_SIZE_TBL_SIZE   8
+/*
+ * The following matches the tuning process,
+ * not the max capabilities of the chip.
+ * Last value unused.
+ */
+#defineCIFISP_LSC_DATA_TBL_SIZE   290
+
+/*
+ * Histogram calculation
+ */
+/* Last 3 values unused. */
+#define CIFISP_HISTOGRAM_WEIGHT_GRIDS_SIZE 28
+
+/*
+ * Defect Pixel Cluster Correction
+ */
+#define CIFISP_DPCC_METHODS_MAX   3
+
+/*
+ * Denoising pre filter
+ */

[PATCH v3 01/12] media: videodev2.h, v4l2-ioctl: add rkisp1 meta buffer format

2017-12-06 Thread Jacob Chen
From: Shunqian Zheng 

Add the Rockchip ISP1 specific processing parameter format
V4L2_META_FMT_RK_ISP1_PARAMS and metadata format
V4L2_META_FMT_RK_ISP1_STAT_3A for 3A.

Signed-off-by: Shunqian Zheng 
Signed-off-by: Jacob Chen 
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 2 ++
 include/uapi/linux/videodev2.h   | 4 
 2 files changed, 6 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index d6587b3ec33e..0604ae9ea444 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1252,6 +1252,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_TCH_FMT_TU08: descr = "8-bit unsigned touch data"; 
break;
case V4L2_META_FMT_VSP1_HGO:descr = "R-Car VSP1 1-D Histogram"; 
break;
case V4L2_META_FMT_VSP1_HGT:descr = "R-Car VSP1 2-D Histogram"; 
break;
+   case V4L2_META_FMT_RK_ISP1_PARAMS:  descr = "Rockchip ISP1 3A 
params"; break;
+   case V4L2_META_FMT_RK_ISP1_STAT_3A: descr = "Rockchip ISP1 3A 
statistics"; break;
 
default:
/* Compressed formats */
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 7c871291c1fa..961545e64c12 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -691,6 +691,10 @@ struct v4l2_pix_format {
 #define V4L2_META_FMT_VSP1_HGOv4l2_fourcc('V', 'S', 'P', 'H') /* R-Car 
VSP1 1-D Histogram */
 #define V4L2_META_FMT_VSP1_HGTv4l2_fourcc('V', 'S', 'P', 'T') /* R-Car 
VSP1 2-D Histogram */
 
+/* Vendor specific - used for IPU3 camera sub-system */
+#define V4L2_META_FMT_RK_ISP1_PARAMS   v4l2_fourcc('R', 'K', '1', 'P') /* 
Rockchip ISP1 params */
+#define V4L2_META_FMT_RK_ISP1_STAT_3A  v4l2_fourcc('R', 'K', '1', 'S') /* 
Rockchip ISP1 3A statistics */
+
 /* priv field value to indicates that subsequent fields are valid. */
 #define V4L2_PIX_FMT_PRIV_MAGIC0xfeedcafe
 
-- 
2.15.0



Re: build failure on ubuntu 16.04 LTS

2017-12-06 Thread Hans Verkuil
On 12/06/17 11:43, Vincent McIntyre wrote:
> Hi,
> 
> the build has been broken for over a week for me.
> Possibly my checkout is out of date??

No, it really is broken. I don't quite understand why it is failing or
how to fix it, and I lack time to dig into this. Hopefully I can find
some time next week for this.

Jasmin, you've done some work on this in the past. Let me know if you
have time to look at this, I would really appreciate that.

Regards,

Hans

> I am using the normal build --main-git method.
> 
> Setup details:
> 
> + date
> Wednesday 6 December  21:25:28 AEDT 2017
> + uname -a
> Linux ubuntu 4.4.0-101-generic #124-Ubuntu SMP Fri Nov 10 18:29:59 UTC 2017 
> x86_64 x86_64 x86_64 GNU/Linux
> + cat /proc/version_signature
> Ubuntu 4.4.0-101.124-generic 4.4.95
> 
> + git --no-pager log -1
> commit 320b9b80ebbf318a67a9479c18a0e4be244c8409
> Author: Hans Verkuil 
> Date:   Tue Nov 28 08:48:04 2017 +0100
> 
> Update backports/pr_fmt.patch
> 
> Signed-off-by: Hans Verkuil 
> 
> + cd media
> + git --no-pager log -1
> commit 781b045baefdabf7e0bc9f33672ca830d3db9f27
> Author: Sakari Ailus 
> Date:   Wed Nov 1 05:40:58 2017 -0400
> 
> media: imx274: Fix error handling, add MAINTAINERS entry
> 
> Add the missing MAINTAINERS entry for imx274, fix error handling in driver
> probe and unregister the correct control handler in driver remove.
> 
> Signed-off-by: Sakari Ailus 
> Signed-off-by: Mauro Carvalho Chehab 
> 
> 
> This is the build failure
> ...
> 
> Created default (all yes) .config file
> ./scripts/fix_kconfig.pl
> make[1]: Leaving directory '/home/me/git/clones/media_build/v4l'
> $ make
> make -C /home/me/git/clones/media_build/v4l
> make[1]: Entering directory '/home/me/git/clones/media_build/v4l'
> scripts/make_makefile.pl
> ./scripts/make_myconfig.pl
> perl scripts/make_config_compat.pl /lib/modules/4.4.0-101-generic/build 
> ./.myconfig ./config-compat.h
> creating symbolic links...
> Kernel build directory is /lib/modules/4.4.0-101-generic/build
> make -C ../linux apply_patches
> make[2]: Entering directory '/home/me/git/clones/media_build/linux'
> Syncing with dir ../media/
> Patches for 4.4.0-101-generic already applied.
> make[2]: Leaving directory '/home/me/git/clones/media_build/linux'
> make -C /lib/modules/4.4.0-101-generic/build 
> SUBDIRS=/home/me/git/clones/media_build/v4l  modules
> make[2]: Entering directory '/usr/src/linux-headers-4.4.0-101-generic'
>   CC [M]  /home/me/git/clones/media_build/v4l/msp3400-driver.o
> In file included from include/linux/compiler.h:56:0,
>  from include/asm-generic/bug.h:4,
>  from ./arch/x86/include/asm/bug.h:35,
>  from include/linux/bug.h:4,
>  from include/linux/mmdebug.h:4,
>  from /home/me/git/clones/media_build/v4l/config-compat.h:12,
>  from /home/me/git/clones/media_build/v4l/compat.h:10,
>  from :0:
> /home/me/git/clones/media_build/v4l/../linux/include/linux/compiler-gcc.h:3:2:
>  error: #error "Please don't include  directly, include 
>  instead."
>  #error "Please don't include  directly, include 
>  instead."
>   ^
> scripts/Makefile.build:258: recipe for target 
> '/home/me/git/clones/media_build/v4l/msp3400-driver.o' failed
> make[3]: *** [/home/me/git/clones/media_build/v4l/msp3400-driver.o] Error 1
> Makefile:1423: recipe for target 
> '_module_/home/me/git/clones/media_build/v4l' failed
> make[2]: *** [_module_/home/me/git/clones/media_build/v4l] Error 2
> make[2]: Leaving directory '/usr/src/linux-headers-4.4.0-101-generic'
> Makefile:51: recipe for target 'default' failed
> make[1]: *** [default] Error 2
> make[1]: Leaving directory '/home/me/git/clones/media_build/v4l'
> Makefile:26: recipe for target 'all' failed
> make: *** [all] Error 2
> build failed at ./build line 526
> + status=29
> 
> I'm struggling to follow the depedency chain here so I thought I'd better ask.
> 
> ubuntu(master)$ grep -r compiler-gcc.h|grep -F '#include'
> 
> media/include/linux/compiler_types.h:#include 
> media/tools/include/linux/compiler.h:#include 
> 
> Cheers
> Vince
> 
> 



Re: [RFC 1/1] v4l: async: Use endpoint node, not device node, for fwnode match

2017-12-06 Thread Kieran Bingham
Hi Sakari,

Thanks for the patch.

On 04/12/17 21:03, Sakari Ailus wrote:
> V4L2 async framework can use both device's fwnode and endpoints's fwnode
> for matching the async sub-device with the sub-device. In order to proceed
> moving towards endpoint matching assign the endpoint to the async
> sub-device.
> 
> As most async sub-device drivers (and the related hardware) only supports
> a single endpoint, use the first endpoint found. This works for all
> current drivers --- we only ever supported a single async sub-device per
> device to begin with.
> 
> For async devices that have no endpoints, continue to use the fwnode
> related to the device. This includes e.g. lens devices.
> 
> Signed-off-by: Sakari Ailus 

Excellent - this looks like some good progression towards full endpoint matching
which I think is essential for more complicated devices... (I would say that
though wouldn't I :D )

Spotted that the error messages hadn't been updated in this patch - but as this
is an RFC, then that's not entirely unexpected, though I've highlighted them 
anyway.

Regards

Kieran

> ---
> Hi Niklas,
> 
> What do you think of this one? I've tested this on N9, both sensor and
> flash devices work nicely there. No opportunistic checks for backwards
> compatibility are needed.
> 
> The changes were surprisingly simple, there are only two drivers that
> weren't entirely trivial to change (this part is truly weird in exynos4-is
> and xilinx-vipp). Converting the two to use the common parsing functions
> would be quite a bit more work and would be very nice to test. The changes
> in this patch were still relatively simple.
> 
>  drivers/media/platform/am437x/am437x-vpfe.c|  2 +-
>  drivers/media/platform/atmel/atmel-isc.c   |  2 +-
>  drivers/media/platform/atmel/atmel-isi.c   |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  2 +-
>  drivers/media/platform/exynos4-is/media-dev.c  | 14 ++
>  drivers/media/platform/pxa_camera.c|  2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
>  drivers/media/platform/rcar_drif.c |  2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c  |  2 +-
>  drivers/media/platform/ti-vpe/cal.c|  2 +-
>  drivers/media/platform/xilinx/xilinx-vipp.c| 16 +---
>  drivers/media/v4l2-core/v4l2-async.c   |  8 ++--
>  drivers/media/v4l2-core/v4l2-fwnode.c  |  2 +-
>  13 files changed, 39 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c 
> b/drivers/media/platform/am437x/am437x-vpfe.c
> index 0997c640191d..892d9e935d25 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2493,7 +2493,7 @@ vpfe_get_pdata(struct platform_device *pdev)
>   if (flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
>   sdinfo->vpfe_param.vdpol = 1;
>  
> - rem = of_graph_get_remote_port_parent(endpoint);
> + rem = of_graph_get_remote_endpoint(endpoint);
>   if (!rem) {
>   dev_err(>dev, "Remote device at %pOF not found\n",
>   endpoint);
> diff --git a/drivers/media/platform/atmel/atmel-isc.c 
> b/drivers/media/platform/atmel/atmel-isc.c
> index 13f1c1c797b0..c8bb60eeb629 100644
> --- a/drivers/media/platform/atmel/atmel-isc.c
> +++ b/drivers/media/platform/atmel/atmel-isc.c
> @@ -2044,7 +2044,7 @@ static int isc_parse_dt(struct device *dev, struct 
> isc_device *isc)
>   if (!epn)
>   break;
>  
> - rem = of_graph_get_remote_port_parent(epn);
> + rem = of_graph_get_remote_endpoint(epn);
>   if (!rem) {
>   dev_notice(dev, "Remote device at %pOF not found\n",
>  epn);
> diff --git a/drivers/media/platform/atmel/atmel-isi.c 
> b/drivers/media/platform/atmel/atmel-isi.c
> index e900995143a3..eafdf91a4541 100644
> --- a/drivers/media/platform/atmel/atmel-isi.c
> +++ b/drivers/media/platform/atmel/atmel-isi.c
> @@ -1119,7 +1119,7 @@ static int isi_graph_parse(struct atmel_isi *isi, 
> struct device_node *node)
>   if (!ep)
>   return -EINVAL;
>  
> - remote = of_graph_get_remote_port_parent(ep);
> + remote = of_graph_get_remote_endpoint(ep);
>   if (!remote) {
>   of_node_put(ep);
>   return -EINVAL;
> diff --git a/drivers/media/platform/davinci/vpif_capture.c 
> b/drivers/media/platform/davinci/vpif_capture.c
> index fca4dc829f73..7c9c2b2bb710 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1572,7 +1572,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)
>   if (flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
>   chan->vpif_if.vd_pol = 1;
>  
> - 

build failure on ubuntu 16.04 LTS

2017-12-06 Thread Vincent McIntyre
Hi,

the build has been broken for over a week for me.
Possibly my checkout is out of date??
I am using the normal build --main-git method.

Setup details:

+ date
Wednesday 6 December  21:25:28 AEDT 2017
+ uname -a
Linux ubuntu 4.4.0-101-generic #124-Ubuntu SMP Fri Nov 10 18:29:59 UTC 2017 
x86_64 x86_64 x86_64 GNU/Linux
+ cat /proc/version_signature
Ubuntu 4.4.0-101.124-generic 4.4.95

+ git --no-pager log -1
commit 320b9b80ebbf318a67a9479c18a0e4be244c8409
Author: Hans Verkuil 
Date:   Tue Nov 28 08:48:04 2017 +0100

Update backports/pr_fmt.patch

Signed-off-by: Hans Verkuil 

+ cd media
+ git --no-pager log -1
commit 781b045baefdabf7e0bc9f33672ca830d3db9f27
Author: Sakari Ailus 
Date:   Wed Nov 1 05:40:58 2017 -0400

media: imx274: Fix error handling, add MAINTAINERS entry

Add the missing MAINTAINERS entry for imx274, fix error handling in driver
probe and unregister the correct control handler in driver remove.

Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 


This is the build failure
...

Created default (all yes) .config file
./scripts/fix_kconfig.pl
make[1]: Leaving directory '/home/me/git/clones/media_build/v4l'
$ make
make -C /home/me/git/clones/media_build/v4l
make[1]: Entering directory '/home/me/git/clones/media_build/v4l'
scripts/make_makefile.pl
./scripts/make_myconfig.pl
perl scripts/make_config_compat.pl /lib/modules/4.4.0-101-generic/build 
./.myconfig ./config-compat.h
creating symbolic links...
Kernel build directory is /lib/modules/4.4.0-101-generic/build
make -C ../linux apply_patches
make[2]: Entering directory '/home/me/git/clones/media_build/linux'
Syncing with dir ../media/
Patches for 4.4.0-101-generic already applied.
make[2]: Leaving directory '/home/me/git/clones/media_build/linux'
make -C /lib/modules/4.4.0-101-generic/build 
SUBDIRS=/home/me/git/clones/media_build/v4l  modules
make[2]: Entering directory '/usr/src/linux-headers-4.4.0-101-generic'
  CC [M]  /home/me/git/clones/media_build/v4l/msp3400-driver.o
In file included from include/linux/compiler.h:56:0,
 from include/asm-generic/bug.h:4,
 from ./arch/x86/include/asm/bug.h:35,
 from include/linux/bug.h:4,
 from include/linux/mmdebug.h:4,
 from /home/me/git/clones/media_build/v4l/config-compat.h:12,
 from /home/me/git/clones/media_build/v4l/compat.h:10,
 from :0:
/home/me/git/clones/media_build/v4l/../linux/include/linux/compiler-gcc.h:3:2: 
error: #error "Please don't include  directly, include 
 instead."
 #error "Please don't include  directly, include 
 instead."
  ^
scripts/Makefile.build:258: recipe for target 
'/home/me/git/clones/media_build/v4l/msp3400-driver.o' failed
make[3]: *** [/home/me/git/clones/media_build/v4l/msp3400-driver.o] Error 1
Makefile:1423: recipe for target '_module_/home/me/git/clones/media_build/v4l' 
failed
make[2]: *** [_module_/home/me/git/clones/media_build/v4l] Error 2
make[2]: Leaving directory '/usr/src/linux-headers-4.4.0-101-generic'
Makefile:51: recipe for target 'default' failed
make[1]: *** [default] Error 2
make[1]: Leaving directory '/home/me/git/clones/media_build/v4l'
Makefile:26: recipe for target 'all' failed
make: *** [all] Error 2
build failed at ./build line 526
+ status=29

I'm struggling to follow the depedency chain here so I thought I'd better ask.

ubuntu(master)$ grep -r compiler-gcc.h|grep -F '#include'

media/include/linux/compiler_types.h:#include 
media/tools/include/linux/compiler.h:#include 

Cheers
Vince




Re: [PATCH v2 3/4] media: ov5640: add support of DVP parallel interface

2017-12-06 Thread Hugues FRUCHET
Hi Fabio,

I will do.

On 11/30/2017 08:09 PM, Fabio Estevam wrote:
> Hi Hugues,
> 
> On Wed, Nov 29, 2017 at 3:11 PM, Hugues Fruchet  wrote:
>> Add support of DVP parallel mode in addition of
>> existing MIPI CSI mode. The choice between two modes
>> and configuration is made through device tree.
> 
> What about explaining how to select between the two modes in
> Documentation/devicetree/bindings/media/i2c/ov5640.txt ?
> 
> Thanks
> 

Best regards,
Hugues.

Re: [PATCH v2 2/4] media: ov5640: check chip id

2017-12-06 Thread Hugues FRUCHET
Thanks Fabio for review,

This make sense, I'll try to change my code that way.

On 11/30/2017 08:07 PM, Fabio Estevam wrote:
> Hi Hugues,
> 
> On Wed, Nov 29, 2017 at 3:11 PM, Hugues Fruchet  wrote:
> 
>>   /* read exposure, in number of line periods */
>>   static int ov5640_get_exposure(struct ov5640_dev *sensor)
>>   {
>> @@ -1562,6 +1586,10 @@ static int ov5640_set_power(struct ov5640_dev 
>> *sensor, bool on)
>>  ov5640_reset(sensor);
>>  ov5640_power(sensor, true);
>>
>> +   ret = ov5640_check_chip_id(sensor);
>> +   if (ret)
>> +   goto power_off;
> 
> Wouldn't it make more sense to add this check in ov5640_probe()
> function instead?
> 

Best regards,
Hugues.

Re: [PATCH v2 3/4] media: ov5640: add support of DVP parallel interface

2017-12-06 Thread Hugues FRUCHET
Hi Steve,

On 12/03/2017 10:58 PM, Steve Longerbeam wrote:
> 
> 
> On 11/29/2017 09:11 AM, Hugues Fruchet wrote:
>> Add support of DVP parallel mode in addition of
>> existing MIPI CSI mode. The choice between two modes
>> and configuration is made through device tree.
>>
>> Signed-off-by: Hugues Fruchet 
>> ---
>>   drivers/media/i2c/ov5640.c | 101 
>> +
>>   1 file changed, 83 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
>> index a576d11..826b102 100644
>> --- a/drivers/media/i2c/ov5640.c
>> +++ b/drivers/media/i2c/ov5640.c
>> @@ -34,14 +34,20 @@
>>   #define OV5640_DEFAULT_SLAVE_ID 0x3c
>> +#define OV5640_REG_SYS_CTRL0    0x3008
>>   #define OV5640_REG_CHIP_ID_HIGH    0x300a
>>   #define OV5640_REG_CHIP_ID_LOW    0x300b
>> +#define OV5640_REG_IO_MIPI_CTRL00    0x300e
>> +#define OV5640_REG_PAD_OUTPUT_ENABLE01    0x3017
>> +#define OV5640_REG_PAD_OUTPUT_ENABLE02    0x3018
>>   #define OV5640_REG_PAD_OUTPUT00    0x3019
>> +#define OV5640_REG_SYSTEM_CONTROL1    0x302e
>>   #define OV5640_REG_SC_PLL_CTRL0    0x3034
>>   #define OV5640_REG_SC_PLL_CTRL1    0x3035
>>   #define OV5640_REG_SC_PLL_CTRL2    0x3036
>>   #define OV5640_REG_SC_PLL_CTRL3    0x3037
>>   #define OV5640_REG_SLAVE_ID    0x3100
>> +#define OV5640_REG_SCCB_SYS_CTRL1    0x3103
>>   #define OV5640_REG_SYS_ROOT_DIVIDER    0x3108
>>   #define OV5640_REG_AWB_R_GAIN    0x3400
>>   #define OV5640_REG_AWB_G_GAIN    0x3402
>> @@ -1006,7 +1012,65 @@ static int ov5640_get_gain(struct ov5640_dev 
>> *sensor)
>>   return gain & 0x3ff;
>>   }
>> -static int ov5640_set_stream(struct ov5640_dev *sensor, bool on)
>> +static int ov5640_set_stream_dvp(struct ov5640_dev *sensor, bool on)
>> +{
>> +    int ret;
>> +
>> +    if (on) {
>> +    /*
>> + * reset MIPI PCLK/SERCLK divider
>> + *
>> + * SC PLL CONTRL1 0
>> + * - [3..0]:    MIPI PCLK/SERCLK divider
>> + */
>> +    ret = ov5640_mod_reg(sensor, OV5640_REG_SC_PLL_CTRL1, 0xF, 0);
>> +    if (ret)
>> +    return ret;
>> +    }
>> +
>> +    /*
>> + * powerdown MIPI TX/RX PHY & disable MIPI
>> + *
>> + * MIPI CONTROL 00
>> + * 4: PWDN PHY TX
>> + * 3: PWDN PHY RX
>> + * 2: MIPI enable
>> + */
>> +    ret = ov5640_write_reg(sensor,
>> +   OV5640_REG_IO_MIPI_CTRL00, on ? 0x18 : 0);
>> +    if (ret)
>> +    return ret;
>> +
>> +    /*
>> + * enable VSYNC/HREF/PCLK DVP control lines
>> + * & D[9:6] DVP data lines
>> + *
>> + * PAD OUTPUT ENABLE 01
>> + * - 6:    VSYNC output enable
>> + * - 5:    HREF output enable
>> + * - 4:    PCLK output enable
>> + * - [3:0]:    D[9:6] output enable
>> + */
>> +    ret = ov5640_write_reg(sensor,
>> +   OV5640_REG_PAD_OUTPUT_ENABLE01, on ? 0x7f : 0);
>> +    if (ret)
>> +    return ret;
>> +
>> +    /*
>> + * enable D[5:2] DVP data lines (D[0:1] are unused with 8 bits
>> + * parallel mode, 8 bits output are mapped on D[9:2])
>> + *
>> + * PAD OUTPUT ENABLE 02
>> + * - [7:4]:    D[5:2] output enable
>> + *    0:1 are unused with 8 bits
>> + *    parallel mode (8 bits output
>> + *    are on D[9:2])
>> + */
> 
> It should be verified in this driver, at probe, that the device tree
> endpoint for the OV5640 output parallel interface has specified this
> with "bus-width=<8>; data-shift=<2>;"
> 
> Steve
> 

I have changed the code enabling the whole 10 bits:
/*
 * enable VSYNC/HREF/PCLK DVP control lines
 * & D[9:6] DVP data lines
 *
 * PAD OUTPUT ENABLE 01
 * - 6: VSYNC output enable
 * - 5: HREF output enable
 * - 4: PCLK output enable
 * - [3:0]: D[9:6] output enable
 */
ret = ov5640_write_reg(sensor,
   OV5640_REG_PAD_OUTPUT_ENABLE01,
   on ? 0x7F : 0);

doing so, no need to verify bus-width/data-shift, and sensor is ready 
for 10 bits output.
In addition to this I can do a check at probe verifying that 
bus-width/data-shift are valid, ie 8/2 or 10/0, what do you think about 
this ?


>> +    return ov5640_write_reg(sensor,
>> +    OV5640_REG_PAD_OUTPUT_ENABLE02, on ? 0xf0 : 0);
>> +}
>> +
>> +static int ov5640_set_stream_mipi(struct ov5640_dev *sensor, bool on)
>>   {
>>   int ret;
>> @@ -1598,17 +1662,19 @@ static int ov5640_set_power(struct ov5640_dev 
>> *sensor, bool on)
>>   if (ret)
>>   goto power_off;
>> -    /*
>> - * start streaming briefly followed by stream off in
>> - * order to coax the clock lane into LP-11 state.
>> - */
>> -    ret = ov5640_set_stream(sensor, true);
>> -    if (ret)
>> -    goto power_off;
>> 

Re: [PATCH v2 2/4] media: ov5640: check chip id

2017-12-06 Thread Hugues FRUCHET
Hi Steve,
thanks for review, comments below.

On 12/03/2017 10:34 PM, Steve Longerbeam wrote:
> 
> 
> On 11/29/2017 09:11 AM, Hugues Fruchet wrote:
>> Verify that chip identifier is correct before starting streaming
>>
>> Signed-off-by: Hugues Fruchet 
>> ---
>>   drivers/media/i2c/ov5640.c | 30 +-
>>   1 file changed, 29 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
>> index 61071f5..a576d11 100644
>> --- a/drivers/media/i2c/ov5640.c
>> +++ b/drivers/media/i2c/ov5640.c
>> @@ -34,7 +34,8 @@
>>   #define OV5640_DEFAULT_SLAVE_ID 0x3c
>> -#define OV5640_REG_CHIP_ID    0x300a
>> +#define OV5640_REG_CHIP_ID_HIGH    0x300a
>> +#define OV5640_REG_CHIP_ID_LOW    0x300b
> 
> There is no need to separate low and high byte addresses.
> See below.
> 
>>   #define OV5640_REG_PAD_OUTPUT00    0x3019
>>   #define OV5640_REG_SC_PLL_CTRL0    0x3034
>>   #define OV5640_REG_SC_PLL_CTRL1    0x3035
>> @@ -926,6 +927,29 @@ static int ov5640_load_regs(struct ov5640_dev 
>> *sensor,
>>   return ret;
>>   }
>> +static int ov5640_check_chip_id(struct ov5640_dev *sensor)
>> +{
>> +    struct i2c_client *client = sensor->i2c_client;
>> +    int ret;
>> +    u8 chip_id_h, chip_id_l;
>> +
>> +    ret = ov5640_read_reg(sensor, OV5640_REG_CHIP_ID_HIGH, _id_h);
>> +    if (ret)
>> +    return ret;
>> +
>> +    ret = ov5640_read_reg(sensor, OV5640_REG_CHIP_ID_LOW, _id_l);
>> +    if (ret)
>> +    return ret;
>> +
>> +    if (!(chip_id_h == 0x56 && chip_id_l == 0x40)) {
>> +    dev_err(>dev, "%s: wrong chip identifier, expected 
>> 0x5640, got 0x%x%x\n",
>> +    __func__, chip_id_h, chip_id_l);
>> +    return -EINVAL;
>> +    }
>> +
> 
> This should all be be replaced by:
> 
> u16 chip_id;
> 
> ret = ov5640_read_reg16(sensor, OV5640_REG_CHIP_ID, _id);
> 
> etc.
> 

Done, thanks.

>> +    return 0;
>> +}
>> +
>>   /* read exposure, in number of line periods */
>>   static int ov5640_get_exposure(struct ov5640_dev *sensor)
>>   {
>> @@ -1562,6 +1586,10 @@ static int ov5640_set_power(struct ov5640_dev 
>> *sensor, bool on)
>>   ov5640_reset(sensor);
>>   ov5640_power(sensor, true);
>> +    ret = ov5640_check_chip_id(sensor);
>> +    if (ret)
>> +    goto power_off;
>> +
>>   ret = ov5640_init_slave_id(sensor);
>>   if (ret)
>>   goto power_off;
> 

Best regards,
Hugues.