cron job: media_tree daily build: WARNINGS

2017-09-08 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:   Sat Sep  9 05:00:20 CEST 2017
media-tree git hash:1efdf1776e2253b77413c997bed862410e4b6aaf
media_build git hash:   bbd9f669f0da6705fe44aff89281c0d6e7bfd73e
v4l-utils git hash: 3296adfa7fa169111bf37c041c0ca70ac8506054
gcc version:i686-linux-gcc (GCC) 7.1.0
sparse version: v0.5.0
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.12.0-164

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

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


Re: [PATCH] em28xx: add support for Hauppauge WinTV-dualHD DVB tuner

2017-09-08 Thread Brad Love
Hi Mauro,


On 2017-09-07 09:52, Mauro Carvalho Chehab wrote:
> Hi Brad,
>
> Em Wed, 31 May 2017 15:01:00 -0500
> Brad Love  escreveu:
>
>> Christian et al,
>>
>> I am an engineer at Hauppauge. This repo is the staging area for all the
>> patches I am testing, with the intention of getting them upstreamed. I
>> will be inaccessible for the next 18 days however, so I will not be able
>> to put any effort until I get back.
> Any news on such patchset?
>
> On a side note, I took a quick look on some of the patches at the
> git repository at:
>
>   
> https://github.com/b-rad-NDi/Ubuntu-media-tree-kernel-builder/tree/master/patches/ubuntu-zesty-4.10.0/extra
>
> I suspect that some of the patches there could have some side effect on
> existing drivers, like this one that unconditionally changes the size
> of URB:
>
>   
> https://github.com/b-rad-NDi/Ubuntu-media-tree-kernel-builder/blob/master/patches/ubuntu-zesty-4.10.0/extra/0003-em28xx-usb-packet-size-tweaks.patch
>
> So, it would be good to be able to test this set also with older
> em28xx devices that also support bulk transfers.
>
> Thanks,
> Mauro

I apologize for delay of action on my growing patchset, summer has been
quite busy for me. I can find time to work on this now though. There is
an initial cluster of the set that I think are ready, but I agree the
unconditional URB size change should be tested against other em28xx
devices. We've found the size changes optimal, but haven't tested
against anyone else's hardware. I will try and source and source some
bulk models from other manufacturers to verify they still operate with
the modification.

Regards,

Brad



Travelers List

2017-09-08 Thread Nancy McCarthy


Hi,

Greeting of the day!

I hope this note finds you well!

Would you be interested in acquiring an email list of "Travelers" from USA?

We also have data for Frequent Travelers List, Camping and Outdoor List, Scuba 
Divers List, Cruise Travelers List, Vacation Travelers List,Boat Owners List, 
Fishing Enthusiasts List, Apparel Buyers List, Luxury Brand Buyers List, Gift 
buyers List and many more.

Each record in the list contains Contact Name (First, Middle and Last Name), 
Mailing Address, List type and Opt-in email address.

All the contacts are opt-in verified, Complete permission based and can be used 
for unlimited multi-channel marketing.

Let me know if you'd be interested in hearing more about it.

Waiting for your valuable and sincere reply.

Best Regards,
Nancy McCarthy
Business Development & Data Specialist



Re: [PATCH] media: default for RC_CORE should be n

2017-09-08 Thread Mauro Carvalho Chehab
Em Fri, 8 Sep 2017 12:06:48 -0700
Stephen Hemminger  escreveu:

> On Fri, 8 Sep 2017 19:52:47 +0100
> Sean Young  wrote:
> 
> > On Fri, Sep 08, 2017 at 09:39:29AM -0700, Stephen Hemminger wrote:  
> > > The Linus policy on Kconfig is that the default should be no
> > > for all new devices. I.e the user rebuild a new kernel from an
> > > old config should not by default get a larger kernel.
> > 
> > That might make sense for new config, but RC_CORE has been present for
> > 7 years; I don't see how changing defaults for existing config makes
> > sense.
> >   
> 
> I took existing config for 4.13 and did 'make oldconfig' and just
> hitting return caused it to turned on.
> 
> The problem is that in my config media is disabled, and now your new
> reconfiguration makes RC_CORE not dependent on media.
> 
> It is a common problem, developers never test with their subsystem disabled.

Hi Sean,

Yes, it makes sense to default 'n' for RC_CORE now that this is an
independent menu option and it builds the RC core when enabled.

Regards,
Mauro


Re: [PATCH v9 23/24] dt: bindings: smiapp: Document lens-focus and flash properties

2017-09-08 Thread Pavel Machek
On Fri 2017-09-08 16:42:26, Sakari Ailus wrote:
> Hi Pavel,
> 
> On Fri, Sep 08, 2017 at 03:36:52PM +0200, Pavel Machek wrote:
> > Hi!
> > 
> > > Document optional lens-focus and flash properties for the smiapp driver.
> > > 
> > > Signed-off-by: Sakari Ailus 
> > > ---
> > >  Documentation/devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt 
> > > b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
> > > index 855e1faf73e2..a052969365d9 100644
> > > --- a/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
> > > +++ b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
> > > @@ -27,6 +27,8 @@ Optional properties
> > >  - nokia,nvm-size: The size of the NVM, in bytes. If the size is not 
> > > given,
> > >the NVM contents will not be read.
> > >  - reset-gpios: XSHUTDOWN GPIO
> > > +- flash-leds: One or more phandles to refer to flash LEDs
> > > +- lens-focus: Phandle for lens focus
> > 
> > Should we simply reference the generic documentation here? If it needs
> > changing, it will be easier changing single place.
> 
> Good question.
> 
> Ideally the properties at least would never change; we do have a common
> parser for the properties which is part of the patchset so in theory it
> would be possible to change the documentation in a backward-compatible way.
> 
> I added these properties as well as all the other properties supported by
> the sensor driver are documented here. That has been the practice AFAIU,
> albeit omissions do happen occasionally.
> 
> The issue I see with omitting the documentation here is that the user
> otherwise won't know whether a driver uses a given property or not: it
> shouldn't be necessary to read driver code to write DT source.

I see... OTOH documentation in central place _is_ a bit more verbose:

+- flash-leds: An array of phandles, each referring to a flash LED, a sub-node
+  of the LED driver device node.

What about:

flash-leds, lens-focus: see 

?

Thanks,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


[PATCH] [media] tuners: mxl5005s: make arrays static const, reduces object code size

2017-09-08 Thread Colin King
From: Colin Ian King 

Don't populate the arrays RegAddr on the stack, instead make them static
const.  Makes the object code smaller by over 980 bytes:

Before:
   textdata bss dec hex filename
  64923 304   0   65227fecb drivers/media/tuners/mxl5005s.o

After:
   textdata bss dec hex filename
  63779 464   0   64243faf3 drivers/media/tuners/mxl5005s.o

Signed-off-by: Colin Ian King 
---
 drivers/media/tuners/mxl5005s.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/media/tuners/mxl5005s.c b/drivers/media/tuners/mxl5005s.c
index dd59c2c0e4a5..20ab7b0171f9 100644
--- a/drivers/media/tuners/mxl5005s.c
+++ b/drivers/media/tuners/mxl5005s.c
@@ -3591,10 +3591,11 @@ static u16 MXL_GetInitRegister(struct dvb_frontend *fe, 
u8 *RegNum,
u16 status = 0;
int i ;
 
-   u8 RegAddr[] = {
+   static const u8 RegAddr[] = {
11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73,
76, 77, 91, 134, 135, 137, 147,
-   156, 166, 167, 168, 25 };
+   156, 166, 167, 168, 25
+   };
 
*count = ARRAY_SIZE(RegAddr);
 
@@ -3616,11 +3617,15 @@ static u16 MXL_GetCHRegister(struct dvb_frontend *fe, 
u8 *RegNum, u8 *RegVal,
 
 /* add 77, 166, 167, 168 register for 2.6.12 */
 #ifdef _MXL_PRODUCTION
-   u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106,
-  107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
+   static const u8 RegAddr[] = {
+   14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106,
+   107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168
+   };
 #else
-   u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106,
-  107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
+   static const u8 RegAddr[] = {
+   14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106,
+   107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168
+   };
/*
u8 RegAddr[171];
for (i = 0; i <= 170; i++)
-- 
2.14.1



[PATCH 3/3] [media] s5p-mfc: Adjust a null pointer check in four functions

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 22:37:00 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index abfb70b07032..cf68aed59e0d 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -470,7 +470,7 @@ static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev,
 {
mfc_err("Interrupt Error: %08x\n", err);
 
-   if (ctx != NULL) {
+   if (ctx) {
/* Error recovery is dependent on the state of context */
switch (ctx->state) {
case MFCINST_RES_CHANGE_INIT:
@@ -508,7 +508,7 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx,
 {
struct s5p_mfc_dev *dev;
 
-   if (ctx == NULL)
+   if (!ctx)
return;
dev = ctx->dev;
if (ctx->c_ops->post_seq_start) {
@@ -562,7 +562,7 @@ static void s5p_mfc_handle_init_buffers(struct s5p_mfc_ctx 
*ctx,
struct s5p_mfc_buf *src_buf;
struct s5p_mfc_dev *dev;
 
-   if (ctx == NULL)
+   if (!ctx)
return;
dev = ctx->dev;
s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
@@ -1289,7 +1289,7 @@ static int s5p_mfc_probe(struct platform_device *pdev)
return PTR_ERR(dev->regs_base);
 
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-   if (res == NULL) {
+   if (!res) {
dev_err(>dev, "failed to get irq resource\n");
return -ENOENT;
}
-- 
2.14.1



[PATCH 2/3] [media] s5p-mfc: Improve a size determination in s5p_mfc_alloc_memdev()

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 22:30:09 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 8af45d53846f..abfb70b07032 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1083,7 +1083,7 @@ static struct device *s5p_mfc_alloc_memdev(struct device 
*dev,
struct device *child;
int ret;
 
-   child = devm_kzalloc(dev, sizeof(struct device), GFP_KERNEL);
+   child = devm_kzalloc(dev, sizeof(*child), GFP_KERNEL);
if (!child)
return NULL;
 
-- 
2.14.1



[PATCH 1/3] [media] s5p-mfc: Delete an error message for a failed memory allocation in s5p_mfc_probe()

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 22:25:17 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 1afde5021ca6..8af45d53846f 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1270,10 +1270,8 @@ static int s5p_mfc_probe(struct platform_device *pdev)
 
pr_debug("%s++\n", __func__);
dev = devm_kzalloc(>dev, sizeof(*dev), GFP_KERNEL);
-   if (!dev) {
-   dev_err(>dev, "Not enough memory for MFC device\n");
+   if (!dev)
return -ENOMEM;
-   }
 
spin_lock_init(>irqlock);
spin_lock_init(>condlock);
-- 
2.14.1



[PATCH 0/3] S5P MFC: Adjustments for five function implementations

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 22:44:55 +0200

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Delete an error message for a failed memory allocation in s5p_mfc_probe()
  Improve a size determination ins5p_mfc_alloc_memdev()
  Adjust a null pointer check in four functions

 drivers/media/platform/s5p-mfc/s5p_mfc.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

-- 
2.14.1



[PATCH] [media] pxa_camera: Delete an error message for a failed memory allocation in pxa_camera_probe()

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 22:05:14 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/pxa_camera.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index edca993c2b1f..d2a4432a98ea 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2362,10 +2362,8 @@ static int pxa_camera_probe(struct platform_device *pdev)
return -ENODEV;
 
pcdev = devm_kzalloc(>dev, sizeof(*pcdev), GFP_KERNEL);
-   if (!pcdev) {
-   dev_err(>dev, "Could not allocate pcdev\n");
+   if (!pcdev)
return -ENOMEM;
-   }
 
pcdev->clk = devm_clk_get(>dev, NULL);
if (IS_ERR(pcdev->clk))
-- 
2.14.1



Re: [PATCH 0/3] AS3645A fixes

2017-09-08 Thread Jacek Anaszewski
Hi Sakari,

Thanks for the patch set.

On 09/08/2017 02:42 PM, Sakari Ailus wrote:
> Hi folks,
> 
> Here are a few fixes for the as3645a DTS as well as changes in bindings.
> The driver is not in a release yet. I'd like to get these in as through
> the media tree fixes branch.
> 
> Sakari Ailus (3):
>   as3645a: Use ams,input-max-microamp as documented in DT bindings
>   dt: bindings: as3645a: Use LED number to refer to LEDs
>   as3645a: Use integer numbers for parsing LEDs
> 
>  .../devicetree/bindings/leds/ams,as3645a.txt   | 28 
> ++
>  arch/arm/boot/dts/omap3-n950-n9.dtsi   | 10 +---
>  drivers/leds/leds-as3645a.c| 28 
> +++---
>  3 files changed, 50 insertions(+), 16 deletions(-)
> 

Acked-by: Jacek Anaszewski 

-- 
Best regards,
Jacek Anaszewski


[PATCH 3/3] [media] fsl-viu: Adjust six checks for null pointers

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 21:16:50 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/fsl-viu.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
index 1fe2a295db93..a133dfdd869a 100644
--- a/drivers/media/platform/fsl-viu.c
+++ b/drivers/media/platform/fsl-viu.c
@@ -313,7 +313,7 @@ static int restart_video_queue(struct viu_dmaqueue *vidq)
if (list_empty(>queued))
return 0;
buf = list_entry(vidq->queued.next, struct viu_buf, vb.queue);
-   if (prev == NULL) {
+   if (!prev) {
list_move_tail(>vb.queue, >active);
 
dprintk(1, "Restarting video dma\n");
@@ -450,7 +450,7 @@ static int buffer_prepare(struct videobuf_queue *vq,
struct viu_buf *buf = container_of(vb, struct viu_buf, vb);
int rc;
 
-   BUG_ON(fh->fmt == NULL);
+   BUG_ON(!fh->fmt);
 
if (fh->width  < 48 || fh->width  > norm_maxw() ||
fh->height < 32 || fh->height > norm_maxh())
@@ -668,9 +668,9 @@ static int verify_preview(struct viu_dev *dev, struct 
v4l2_window *win)
enum v4l2_field field;
int maxw, maxh;
 
-   if (dev->ovbuf.base == NULL)
+   if (!dev->ovbuf.base)
return -EINVAL;
-   if (dev->ovfmt == NULL)
+   if (!dev->ovfmt)
return -EINVAL;
if (win->w.width < 48 || win->w.height < 32)
return -EINVAL;
@@ -825,7 +825,7 @@ int vidioc_s_fbuf(struct file *file, void *priv, const 
struct v4l2_framebuffer *
 
/* check args */
fmt = format_by_fourcc(fb->fmt.pixelformat);
-   if (fmt == NULL)
+   if (!fmt)
return -EINVAL;
 
/* ok, accept it */
@@ -1472,7 +1472,7 @@ static int viu_of_probe(struct platform_device *op)
 
/* Allocate memory for video device */
vdev = video_device_alloc();
-   if (vdev == NULL) {
+   if (!vdev) {
ret = -ENOMEM;
goto err_vdev;
}
-- 
2.14.1



[PATCH] media: rc: Use bsearch library function

2017-09-08 Thread Thomas Meyer
Replace self coded binary search, by existing library version.

Signed-off-by: Thomas Meyer 
---
 drivers/media/rc/rc-main.c | 34 --
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 981cccd6b988..d3d6537867fb 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -15,6 +15,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -460,6 +461,18 @@ static int ir_setkeytable(struct rc_dev *dev,
return rc;
 }
 
+static int rc_map_cmp(const void *key, const void *elt)
+{
+   unsigned int scancode = *(unsigned int *) key;
+   struct rc_map_table *e = (struct rc_map_table *) elt;
+
+   if (e->scancode > scancode)
+   return -1;
+   else if (e->scancode < scancode)
+   return 1;
+   return 0;
+}
+
 /**
  * ir_lookup_by_scancode() - locate mapping by scancode
  * @rc_map:the struct rc_map to search
@@ -472,21 +485,14 @@ static int ir_setkeytable(struct rc_dev *dev,
 static unsigned int ir_lookup_by_scancode(const struct rc_map *rc_map,
  unsigned int scancode)
 {
-   int start = 0;
-   int end = rc_map->len - 1;
-   int mid;
-
-   while (start <= end) {
-   mid = (start + end) / 2;
-   if (rc_map->scan[mid].scancode < scancode)
-   start = mid + 1;
-   else if (rc_map->scan[mid].scancode > scancode)
-   end = mid - 1;
-   else
-   return mid;
-   }
+   struct rc_map_table *res;
 
-   return -1U;
+   res = bsearch(, rc_map->scan, rc_map->len,
+ sizeof(struct rc_map_table), rc_map_cmp);
+   if (res == NULL)
+   return -1U;
+   else
+   return res - rc_map->scan;
 }
 
 /**
-- 
2.11.0



[PATCH 2/3] [media] fsl-viu: Improve two size determinations in viu_of_probe()

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 21:12:52 +0200

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/fsl-viu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
index 526f80649864..1fe2a295db93 100644
--- a/drivers/media/platform/fsl-viu.c
+++ b/drivers/media/platform/fsl-viu.c
@@ -1421,5 +1421,5 @@ static int viu_of_probe(struct platform_device *op)
}
 
/* remap registers */
-   viu_regs = devm_ioremap(>dev, r.start, sizeof(struct viu_reg));
+   viu_regs = devm_ioremap(>dev, r.start, sizeof(*viu_regs));
if (!viu_regs) {
@@ -1429,5 +1429,5 @@ static int viu_of_probe(struct platform_device *op)
}
 
/* Prepare our private structure */
-   viu_dev = devm_kzalloc(>dev, sizeof(struct viu_dev), GFP_ATOMIC);
+   viu_dev = devm_kzalloc(>dev, sizeof(*viu_dev), GFP_ATOMIC);
if (!viu_dev) {
-- 
2.14.1



[PATCH 1/3] [media] fsl-viu: Delete an error message for a failed memory allocation in viu_of_probe()

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 21:03:22 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/fsl-viu.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
index fb43025df573..526f80649864 100644
--- a/drivers/media/platform/fsl-viu.c
+++ b/drivers/media/platform/fsl-viu.c
@@ -1433,5 +1433,4 @@ static int viu_of_probe(struct platform_device *op)
if (!viu_dev) {
-   dev_err(>dev, "Can't allocate private structure\n");
ret = -ENOMEM;
goto err;
}
-- 
2.14.1



[RFC PATCH v8 0/2] mmap: safely enable support for new flags

2017-09-08 Thread Dan Williams
Changes since v7 [1]:
* rebase on the mid-merge-window state of the tree to pick up new mmap
  implementations.

* expand the mmap operation handler conversion beyond 'struct
  file_operations' to include, 'struct etnaviv_gem_ops', 'struct
  dma_buf_ops', 'struct drm_driver', 'struct fb_ops', and 'struct
  v4l2_file_operations'

* pass 'map_flags' through to all sub-handlers (Christoph)

* rework the mmap flag validation mechanism to the MAP_SHARED_VALIDATE
  scheme (Linus)

[1]: https://lwn.net/Articles/732886/

---

In order to safely add new mmap flags we want all mmap implementations
to both opt-in to the new flags they support and have the ability to
reject flags on a per-mmap-call basis. An alternative to all the churn
in patch1 is to add a new ->map_flags attribute to 'struct
vma_area_struct', but that bloats the runtime state everywhere for the
few mmap implementations that will care about new flags. Of course, this
also assumes that there are no general objections to the plans to
eventually add MAP_SYNC and/or MAP_DIRECT for DAX mappings [2].

The current request is to merge the final version of patch1 next week,
right before -rc1, i.e. before new ->mmap() handlers start landing in
-next. Given that the drm, media, and sound pull requests are already
merged only some small tweaks are expected from here on out. Patch2 is
included for review, but it can wait and go in with the new MAP_ flags.

Please holler if anything does not look right.

[2]: "Two more approaches to persistent-memory writes"
 https://lwn.net/Articles/731706/

---

Dan Williams (2):
  vfs: add flags parameter to all ->mmap() handlers
  mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap 
flags


 arch/alpha/include/uapi/asm/mman.h |1 
 arch/arc/kernel/arc_hostlink.c |3 +
 arch/mips/include/uapi/asm/mman.h  |1 
 arch/mips/kernel/vdso.c|2 -
 arch/parisc/include/uapi/asm/mman.h|1 
 arch/powerpc/kernel/proc_powerpc.c |3 +
 arch/powerpc/kvm/book3s_64_vio.c   |3 +
 arch/powerpc/platforms/cell/spufs/file.c   |   21 ++
 arch/powerpc/platforms/powernv/memtrace.c  |3 +
 arch/powerpc/platforms/powernv/opal-prd.c  |3 +
 arch/tile/mm/elf.c |3 +
 arch/um/drivers/mmapper_kern.c |3 +
 arch/xtensa/include/uapi/asm/mman.h|1 
 drivers/android/binder.c   |3 +
 drivers/auxdisplay/cfag12864bfb.c  |3 +
 drivers/auxdisplay/ht16k33.c   |3 +
 drivers/char/agp/frontend.c|3 +
 drivers/char/bsr.c |3 +
 drivers/char/hpet.c|6 ++-
 drivers/char/mbcs.c|3 +
 drivers/char/mbcs.h|3 +
 drivers/char/mem.c |   11 +++--
 drivers/char/mspec.c   |9 +++-
 drivers/char/uv_mmtimer.c  |6 ++-
 drivers/dax/device.c   |3 +
 drivers/dma-buf/dma-buf.c  |   11 +++--
 drivers/firewire/core-cdev.c   |3 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|3 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h|3 +
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c   |5 +-
 drivers/gpu/drm/armada/armada_gem.c|3 +
 drivers/gpu/drm/ast/ast_drv.h  |3 +
 drivers/gpu/drm/ast/ast_ttm.c  |3 +
 drivers/gpu/drm/bochs/bochs.h  |3 +
 drivers/gpu/drm/bochs/bochs_fbdev.c|2 -
 drivers/gpu/drm/bochs/bochs_mm.c   |3 +
 drivers/gpu/drm/cirrus/cirrus_drv.h|3 +
 drivers/gpu/drm/cirrus/cirrus_ttm.c|3 +
 drivers/gpu/drm/drm_fb_cma_helper.c|8 ++--
 drivers/gpu/drm/drm_gem.c  |3 +
 drivers/gpu/drm/drm_gem_cma_helper.c   |8 ++--
 drivers/gpu/drm/drm_prime.c|5 +-
 drivers/gpu/drm/drm_vm.c   |3 +
 drivers/gpu/drm/etnaviv/etnaviv_drv.h  |6 ++-
 drivers/gpu/drm/etnaviv/etnaviv_gem.c  |   11 +++--
 drivers/gpu/drm/etnaviv/etnaviv_gem.h  |3 +
 drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c|9 ++--
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c  |2 -
 drivers/gpu/drm/exynos/exynos_drm_gem.c|   10 +++--
 drivers/gpu/drm/exynos/exynos_drm_gem.h|6 ++-
 drivers/gpu/drm/gma500/framebuffer.c   |3 +
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h|3 +
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c   

[PATCH 0/3] [media] Freescale VIU: Adjustments for five function implementations

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 21:28:12 +0200

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Delete an error message for a failed memory allocation in viu_of_probe()
  Improve two size determinations in viu_of_probe()
  Adjust six checks for null pointers

 drivers/media/platform/fsl-viu.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

-- 
2.14.1



Re: [PATCH 1/1] media: i2c: as3645a: Remove driver

2017-09-08 Thread Pavel Machek
On Fri 2017-09-08 16:51:40, Sakari Ailus wrote:
1;2802;0c> Remove the V4L2 AS3645A sub-device driver in favour of the LED flash 
class
> driver for the same hardware, drivers/leds/leds-as3645a.c. The latter uses
> the V4L2 flash LED class framework to provide V4L2 sub-device interface.
> 
> Signed-off-by: Sakari Ailus 

Acked-by: Pavel Machek 

Thanks!
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH] media: default for RC_CORE should be n

2017-09-08 Thread Stephen Hemminger
On Fri, 8 Sep 2017 19:52:47 +0100
Sean Young  wrote:

> On Fri, Sep 08, 2017 at 09:39:29AM -0700, Stephen Hemminger wrote:
> > The Linus policy on Kconfig is that the default should be no
> > for all new devices. I.e the user rebuild a new kernel from an
> > old config should not by default get a larger kernel.  
> 
> That might make sense for new config, but RC_CORE has been present for
> 7 years; I don't see how changing defaults for existing config makes
> sense.
> 

I took existing config for 4.13 and did 'make oldconfig' and just
hitting return caused it to turned on.

The problem is that in my config media is disabled, and now your new
reconfiguration makes RC_CORE not dependent on media.

It is a common problem, developers never test with their subsystem disabled.

config-linux-next
Description: Binary data


Re: [PATCH] media: default for RC_CORE should be n

2017-09-08 Thread Sean Young
On Fri, Sep 08, 2017 at 09:39:29AM -0700, Stephen Hemminger wrote:
> The Linus policy on Kconfig is that the default should be no
> for all new devices. I.e the user rebuild a new kernel from an
> old config should not by default get a larger kernel.

That might make sense for new config, but RC_CORE has been present for
7 years; I don't see how changing defaults for existing config makes
sense.


Sean

> 
> Fixes: b4c184e506a4 ("[media] media: reorganize the main Kconfig items")
> Signed-off-by: Stephen Hemminger 
> ---
>  drivers/media/rc/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
> index d9ce8ff55d0c..5aa384afcfef 100644
> --- a/drivers/media/rc/Kconfig
> +++ b/drivers/media/rc/Kconfig
> @@ -2,7 +2,7 @@
>  menuconfig RC_CORE
>   tristate "Remote Controller support"
>   depends on INPUT
> - default y
> + default n
>   ---help---
> Enable support for Remote Controllers on Linux. This is
> needed in order to support several video capture adapters,
> -- 
> 2.11.0


[PATCH] media: default for RC_CORE should be n

2017-09-08 Thread Stephen Hemminger
The Linus policy on Kconfig is that the default should be no
for all new devices. I.e the user rebuild a new kernel from an
old config should not by default get a larger kernel.

Fixes: b4c184e506a4 ("[media] media: reorganize the main Kconfig items")
Signed-off-by: Stephen Hemminger 
---
 drivers/media/rc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index d9ce8ff55d0c..5aa384afcfef 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -2,7 +2,7 @@
 menuconfig RC_CORE
tristate "Remote Controller support"
depends on INPUT
-   default y
+   default n
---help---
  Enable support for Remote Controllers on Linux. This is
  needed in order to support several video capture adapters,
-- 
2.11.0



Re: [Outreachy kernel] [PATCH] Staging: media: imx: Prefer using BIT macro

2017-09-08 Thread Srishti Sharma
On Fri, Sep 8, 2017 at 8:59 PM, Sean Paul  wrote:
> On Fri, Sep 8, 2017 at 11:11 AM, Srishti Sharma  wrote:
>> Use BIT(x) instead of (1<>
>> Signed-off-by: Srishti Sharma 
>> ---
>>  drivers/staging/media/imx/imx-media.h | 16 
>>  1 file changed, 8 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/staging/media/imx/imx-media.h 
>> b/drivers/staging/media/imx/imx-media.h
>> index d409170..e5b8d29 100644
>> --- a/drivers/staging/media/imx/imx-media.h
>> +++ b/drivers/staging/media/imx/imx-media.h
>> @@ -310,16 +310,16 @@ void imx_media_capture_device_set_format(struct 
>> imx_media_video_dev *vdev,
>>  void imx_media_capture_device_error(struct imx_media_video_dev *vdev);
>>
>>  /* subdev group ids */
>> -#define IMX_MEDIA_GRP_ID_SENSOR(1 << 8)
>> -#define IMX_MEDIA_GRP_ID_VIDMUX(1 << 9)
>> -#define IMX_MEDIA_GRP_ID_CSI2  (1 << 10)
>> +#define IMX_MEDIA_GRP_ID_SENSORBIT(8)
>> +#define IMX_MEDIA_GRP_ID_VIDMUXBIT(9)
>> +#define IMX_MEDIA_GRP_ID_CSI2  BIT(10)
>>  #define IMX_MEDIA_GRP_ID_CSI_BIT   11
>>  #define IMX_MEDIA_GRP_ID_CSI   (0x3 << IMX_MEDIA_GRP_ID_CSI_BIT)
>> -#define IMX_MEDIA_GRP_ID_CSI0  (1 << IMX_MEDIA_GRP_ID_CSI_BIT)
>> +#define IMX_MEDIA_GRP_ID_CSI0  BIT(IMX_MEDIA_GRP_ID_CSI_BIT)
>>  #define IMX_MEDIA_GRP_ID_CSI1  (2 << IMX_MEDIA_GRP_ID_CSI_BIT)
>> -#define IMX_MEDIA_GRP_ID_VDIC  (1 << 13)
>> -#define IMX_MEDIA_GRP_ID_IC_PRP(1 << 14)
>> -#define IMX_MEDIA_GRP_ID_IC_PRPENC (1 << 15)
>> -#define IMX_MEDIA_GRP_ID_IC_PRPVF  (1 << 16)
>> +#define IMX_MEDIA_GRP_ID_VDIC  BIT(13)
>> +#define IMX_MEDIA_GRP_ID_IC_PRPBIT(14)
>> +#define IMX_MEDIA_GRP_ID_IC_PRPENC BIT(15)
>> +#define IMX_MEDIA_GRP_ID_IC_PRPVF  BIT(16)
>
> Hi Srishti,
> Thanks for your patch.
>
> Perhaps this is just personal preference, but I find the previous
> version more readable. Since IMX_MEDIA_GRP_ID_CSI and
> IMX_MEDIA_GRP_ID_CSI1 are multi-bit fields, you can't fully eliminate
> the bit shift operations, so you end up with a mix, which is kind of
> ugly.

 Thanks, for pointing that out .
 Regards,
 Srishti
>
> Sean
>
>>
>>  #endif
>> --
>> 2.7.4
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "outreachy-kernel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to outreachy-kernel+unsubscr...@googlegroups.com.
>> To post to this group, send email to outreachy-ker...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/outreachy-kernel/1504883469-8127-1-git-send-email-srishtishar%40gmail.com.
>> For more options, visit https://groups.google.com/d/optout.


[PATCH] v4l-ioctl: Fix typo on v4l_print_frmsizeenum

2017-09-08 Thread Ricardo Ribalda Delgado
max_width and max_height are swap with step_width and step_height.

Signed-off-by: Ricardo Ribalda Delgado 
---

Since that this bug has been here for ever. I do not know if we should
notify stable or not

I have also cut the lines to respect the 80 char limit

 drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index b60a6b0841d1..79614992ee21 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -730,9 +730,12 @@ static void v4l_print_frmsizeenum(const void *arg, bool 
write_only)
break;
case V4L2_FRMSIZE_TYPE_STEPWISE:
pr_cont(", min=%ux%u, max=%ux%u, step=%ux%u\n",
-   p->stepwise.min_width,  p->stepwise.min_height,
-   p->stepwise.step_width, p->stepwise.step_height,
-   p->stepwise.max_width,  p->stepwise.max_height);
+   p->stepwise.min_width,
+   p->stepwise.min_height,
+   p->stepwise.max_width,
+   p->stepwise.max_height,
+   p->stepwise.step_width,
+   p->stepwise.step_height);
break;
case V4L2_FRMSIZE_TYPE_CONTINUOUS:
/* fall through */
-- 
2.14.1



Re: [Outreachy kernel] [PATCH] Staging: media: imx: Prefer using BIT macro

2017-09-08 Thread Sean Paul
On Fri, Sep 8, 2017 at 11:11 AM, Srishti Sharma  wrote:
> Use BIT(x) instead of (1<
> Signed-off-by: Srishti Sharma 
> ---
>  drivers/staging/media/imx/imx-media.h | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx-media.h 
> b/drivers/staging/media/imx/imx-media.h
> index d409170..e5b8d29 100644
> --- a/drivers/staging/media/imx/imx-media.h
> +++ b/drivers/staging/media/imx/imx-media.h
> @@ -310,16 +310,16 @@ void imx_media_capture_device_set_format(struct 
> imx_media_video_dev *vdev,
>  void imx_media_capture_device_error(struct imx_media_video_dev *vdev);
>
>  /* subdev group ids */
> -#define IMX_MEDIA_GRP_ID_SENSOR(1 << 8)
> -#define IMX_MEDIA_GRP_ID_VIDMUX(1 << 9)
> -#define IMX_MEDIA_GRP_ID_CSI2  (1 << 10)
> +#define IMX_MEDIA_GRP_ID_SENSORBIT(8)
> +#define IMX_MEDIA_GRP_ID_VIDMUXBIT(9)
> +#define IMX_MEDIA_GRP_ID_CSI2  BIT(10)
>  #define IMX_MEDIA_GRP_ID_CSI_BIT   11
>  #define IMX_MEDIA_GRP_ID_CSI   (0x3 << IMX_MEDIA_GRP_ID_CSI_BIT)
> -#define IMX_MEDIA_GRP_ID_CSI0  (1 << IMX_MEDIA_GRP_ID_CSI_BIT)
> +#define IMX_MEDIA_GRP_ID_CSI0  BIT(IMX_MEDIA_GRP_ID_CSI_BIT)
>  #define IMX_MEDIA_GRP_ID_CSI1  (2 << IMX_MEDIA_GRP_ID_CSI_BIT)
> -#define IMX_MEDIA_GRP_ID_VDIC  (1 << 13)
> -#define IMX_MEDIA_GRP_ID_IC_PRP(1 << 14)
> -#define IMX_MEDIA_GRP_ID_IC_PRPENC (1 << 15)
> -#define IMX_MEDIA_GRP_ID_IC_PRPVF  (1 << 16)
> +#define IMX_MEDIA_GRP_ID_VDIC  BIT(13)
> +#define IMX_MEDIA_GRP_ID_IC_PRPBIT(14)
> +#define IMX_MEDIA_GRP_ID_IC_PRPENC BIT(15)
> +#define IMX_MEDIA_GRP_ID_IC_PRPVF  BIT(16)

Hi Srishti,
Thanks for your patch.

Perhaps this is just personal preference, but I find the previous
version more readable. Since IMX_MEDIA_GRP_ID_CSI and
IMX_MEDIA_GRP_ID_CSI1 are multi-bit fields, you can't fully eliminate
the bit shift operations, so you end up with a mix, which is kind of
ugly.

Sean

>
>  #endif
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1504883469-8127-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.


[PATCH] Staging: media: imx: Prefer using BIT macro

2017-09-08 Thread Srishti Sharma
Use BIT(x) instead of (1<
---
 drivers/staging/media/imx/imx-media.h | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media.h 
b/drivers/staging/media/imx/imx-media.h
index d409170..e5b8d29 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -310,16 +310,16 @@ void imx_media_capture_device_set_format(struct 
imx_media_video_dev *vdev,
 void imx_media_capture_device_error(struct imx_media_video_dev *vdev);

 /* subdev group ids */
-#define IMX_MEDIA_GRP_ID_SENSOR(1 << 8)
-#define IMX_MEDIA_GRP_ID_VIDMUX(1 << 9)
-#define IMX_MEDIA_GRP_ID_CSI2  (1 << 10)
+#define IMX_MEDIA_GRP_ID_SENSORBIT(8)
+#define IMX_MEDIA_GRP_ID_VIDMUXBIT(9)
+#define IMX_MEDIA_GRP_ID_CSI2  BIT(10)
 #define IMX_MEDIA_GRP_ID_CSI_BIT   11
 #define IMX_MEDIA_GRP_ID_CSI   (0x3 << IMX_MEDIA_GRP_ID_CSI_BIT)
-#define IMX_MEDIA_GRP_ID_CSI0  (1 << IMX_MEDIA_GRP_ID_CSI_BIT)
+#define IMX_MEDIA_GRP_ID_CSI0  BIT(IMX_MEDIA_GRP_ID_CSI_BIT)
 #define IMX_MEDIA_GRP_ID_CSI1  (2 << IMX_MEDIA_GRP_ID_CSI_BIT)
-#define IMX_MEDIA_GRP_ID_VDIC  (1 << 13)
-#define IMX_MEDIA_GRP_ID_IC_PRP(1 << 14)
-#define IMX_MEDIA_GRP_ID_IC_PRPENC (1 << 15)
-#define IMX_MEDIA_GRP_ID_IC_PRPVF  (1 << 16)
+#define IMX_MEDIA_GRP_ID_VDIC  BIT(13)
+#define IMX_MEDIA_GRP_ID_IC_PRPBIT(14)
+#define IMX_MEDIA_GRP_ID_IC_PRPENC BIT(15)
+#define IMX_MEDIA_GRP_ID_IC_PRPVF  BIT(16)

 #endif
--
2.7.4



Re: [PATCH] Staging: media: omap4iss: Use WARN_ON() instead of BUG_ON().

2017-09-08 Thread Srishti Sharma
On Fri, Sep 8, 2017 at 8:08 PM, Dan Carpenter  wrote:
> On Fri, Sep 08, 2017 at 07:38:18PM +0530, Srishti Sharma wrote:
>> Use WARN_ON() instead of BUG_ON() to avoid crashing the kernel.
>>
>> Signed-off-by: Srishti Sharma 
>> ---
>>  drivers/staging/media/omap4iss/iss.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/media/omap4iss/iss.c 
>> b/drivers/staging/media/omap4iss/iss.c
>> index c26c99fd..b1036ba 100644
>> --- a/drivers/staging/media/omap4iss/iss.c
>> +++ b/drivers/staging/media/omap4iss/iss.c
>> @@ -893,7 +893,7 @@ void omap4iss_put(struct iss_device *iss)
>>   return;
>>
>>   mutex_lock(>iss_mutex);
>> - BUG_ON(iss->ref_count == 0);
>> + WARN_ON(iss->ref_count == 0);
>
> ref_counting bugs often have a security aspect.  BUG_ON() is probably
> safer here.  Better to crash than to lose all your bitcoin.

Okay, Thanks for this.

Regards,
Srishti

>
> regards,
> dan carpenter
>


[GIT FIXES FOR v4.14] Fixes for 4.14

2017-09-08 Thread Hans Verkuil
The following changes since commit 1efdf1776e2253b77413c997bed862410e4b6aaf:

  media: leds: as3645a: add V4L2_FLASH_LED_CLASS dependency (2017-09-05 
16:32:45 -0400)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v4.14l

for you to fetch changes up to d87a23d49ba85a482d968ceba30a1de22dd7fb0d:

  cec-pin.c: use proper ktime accessor functions (2017-09-08 16:53:30 +0200)


Colin Ian King (1):
  media: qcom: camss: Make function vfe_set_selection static

Hans Verkuil (1):
  cec-pin.c: use proper ktime accessor functions

Laurent Pinchart (1):
  media: staging/imx: Fix uninitialized variable warning

Stanimir Varbanov (1):
  media: venus: init registered list on streamoff

 drivers/media/cec/cec-pin.c| 37 
++---
 drivers/media/platform/qcom/camss-8x16/camss-vfe.c |  2 +-
 drivers/media/platform/qcom/venus/helpers.c|  1 +
 drivers/staging/media/imx/imx-media-dev.c  |  4 ++--
 4 files changed, 26 insertions(+), 18 deletions(-)


Re: [PATCH] Staging: media: omap4iss: Use WARN_ON() instead of BUG_ON().

2017-09-08 Thread Dan Carpenter
On Fri, Sep 08, 2017 at 07:38:18PM +0530, Srishti Sharma wrote:
> Use WARN_ON() instead of BUG_ON() to avoid crashing the kernel.
> 
> Signed-off-by: Srishti Sharma 
> ---
>  drivers/staging/media/omap4iss/iss.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/omap4iss/iss.c 
> b/drivers/staging/media/omap4iss/iss.c
> index c26c99fd..b1036ba 100644
> --- a/drivers/staging/media/omap4iss/iss.c
> +++ b/drivers/staging/media/omap4iss/iss.c
> @@ -893,7 +893,7 @@ void omap4iss_put(struct iss_device *iss)
>   return;
> 
>   mutex_lock(>iss_mutex);
> - BUG_ON(iss->ref_count == 0);
> + WARN_ON(iss->ref_count == 0);

ref_counting bugs often have a security aspect.  BUG_ON() is probably
safer here.  Better to crash than to lose all your bitcoin.

regards,
dan carpenter



[GIT PULL FOR v4.15] Cleanup fixes

2017-09-08 Thread Hans Verkuil
coccinelle, checkpatch, coverity, etc. etc.

Regards,

Hans

The following changes since commit 1efdf1776e2253b77413c997bed862410e4b6aaf:

  media: leds: as3645a: add V4L2_FLASH_LED_CLASS dependency (2017-09-05 
16:32:45 -0400)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v4.15a

for you to fetch changes up to d50cd4ba25f6a9b5cfd7012cbe0d8c146212cda1:

  media: cx23885: make const array buf static, reduces object code size 
(2017-09-08 16:13:36 +0200)


Bhumika Goyal (2):
  usb: make i2c_client const
  pci: make i2c_client const

Colin Ian King (5):
  rtl28xxu: make array rc_nec_tab static const
  cx25840: make array stds static const, reduces object code size
  cobalt: remove redundant zero check on retval
  ov9640: make const arrays res_x/y static const, reduces object code size
  media: cx23885: make const array buf static, reduces object code size

Daniel Scheller (1):
  dvb-frontends/mxl5xx: declare LIST_HEAD(mxllist) static

Markus Elfring (62):
  Cypress: Delete an error message for a failed memory allocation in 
cypress_load_firmware()
  Cypress: Improve a size determination in cypress_load_firmware()
  Siano: Delete an error message for a failed memory allocation in three 
functions
  Siano: Improve a size determination in six functions
  Siano: Adjust five checks for null pointers
  zr364xx: Delete an error message for a failed memory allocation in two 
functions
  zr364xx: Improve a size determination in zr364xx_probe()
  zr364xx: Adjust ten checks for null pointers
  as102_fe: Delete an error message for a failed memory allocation in 
as102_attach()
  as102_fe: Improve a size determination in as102_attach()
  cx24113: Delete an error message for a failed memory allocation in 
cx24113_attach()
  cx24113: Return directly after a failed kzalloc() in cx24113_attach()
  cx24113: Improve a size determination in cx24113_attach()
  cx24116: Delete an error message for a failed memory allocation in 
cx24116_writeregN()
  cx24116: Return directly after a failed kmalloc() in cx24116_writeregN()
  cx24116: Delete an unnecessary variable initialisation in 
cx24116_writeregN()
  cx24116: Improve a size determination in cx24116_attach()
  cx24116: Delete an unnecessary variable initialisation in cx24116_attach()
  cx24116: Delete jump targets in cx24116_attach()
  drxd: Delete an error message for a failed memory allocation in 
load_firmware()
  drxd: Adjust a null pointer check in three functions
  ds3000: Delete an error message for a failed memory allocation in two 
functions
  ds3000: Improve a size determination in ds3000_attach()
  ds3000: Delete an unnecessary variable initialisation in ds3000_attach()
  ds3000: Delete jump targets in ds3000_attach()
  mb86a20s: Delete an error message for a failed memory allocation in 
mb86a20s_attach()
  mb86a20s: Improve a size determination in mb86a20s_attach()
  mb86a20s: Delete a jump target in mb86a20s_attach()
  si2168: Delete an error message for a failed memory allocation in 
si2168_probe()
  sp2: Delete an error message for a failed memory allocation in sp2_probe()
  sp2: Improve a size determination in sp2_probe()
  sp2: Adjust three null pointer checks in sp2_exit()
  adv7604: Delete an error message for a failed memory allocation in 
adv76xx_probe()
  adv7604: Adjust a null pointer check in three functions
  adv7842: Delete an error message for a failed memory allocation in 
adv7842_probe()
  adv7842: Improve a size determination in adv7842_probe()
  cx18: Delete an error message for a failed memory allocation in 
cx18_probe()
  cx18: Improve a size determination in cx18_probe()
  cx18: Adjust ten checks for null pointers
  Hopper: Delete an error message for a failed memory allocation in 
hopper_pci_probe()
  Hopper: Improve a size determination in hopper_pci_probe()
  Hopper: Adjust a null pointer check in two functions
  Hopper: Delete an unnecessary variable initialisation in 
hopper_pci_probe()
  Mantis: Delete an error message for a failed memory allocation in 
mantis_pci_probe()
  Mantis: Improve a size determination in mantis_pci_probe()
  Mantis: Delete an unnecessary variable initialisation in 
mantis_pci_probe()
  meye: Delete three error messages for a failed memory allocation in 
meye_probe()
  meye: Adjust two function calls together with a variable assignment
  saa7164: Delete an error message for a failed memory allocation in 
saa7164_buffer_alloc()
  saa7164: Improve a size determination in two functions
  Hexium Gemini: Delete an error message for a failed memory allocation in 
hexium_attach()
  Hexium Gemini: Improve a size determination in hexium_attach()
  Hexium Orion: Delete an 

Re: [Outreachy kernel] [PATCH] Staging: media: omap4iss: Use WARN_ON() instead of BUG_ON().

2017-09-08 Thread Srishti Sharma
On Fri, Sep 8, 2017 at 7:40 PM, Julia Lawall  wrote:
>
>
> On Fri, 8 Sep 2017, Srishti Sharma wrote:
>
>> Use WARN_ON() instead of BUG_ON() to avoid crashing the kernel.
>>
>> Signed-off-by: Srishti Sharma 
>> ---
>>  drivers/staging/media/omap4iss/iss.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/media/omap4iss/iss.c 
>> b/drivers/staging/media/omap4iss/iss.c
>> index c26c99fd..b1036ba 100644
>> --- a/drivers/staging/media/omap4iss/iss.c
>> +++ b/drivers/staging/media/omap4iss/iss.c
>> @@ -893,7 +893,7 @@ void omap4iss_put(struct iss_device *iss)
>>   return;
>>
>>   mutex_lock(>iss_mutex);
>> - BUG_ON(iss->ref_count == 0);
>> + WARN_ON(iss->ref_count == 0);
>>   if (--iss->ref_count == 0) {
>
> Won't this then infinite loop?

 Oh.. yes ! It would, sorry . Please drop this patch .

 Regards,
 Srishti

>
> julia
>
>>   iss_disable_interrupts(iss);
>>   /* Reset the ISS if an entity has failed to stop. This is the
>> --
>> 2.7.4
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "outreachy-kernel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to outreachy-kernel+unsubscr...@googlegroups.com.
>> To post to this group, send email to outreachy-ker...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/outreachy-kernel/1504879698-5855-1-git-send-email-srishtishar%40gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>>


Re: [Outreachy kernel] [PATCH] Staging: media: omap4iss: Use WARN_ON() instead of BUG_ON().

2017-09-08 Thread Julia Lawall


On Fri, 8 Sep 2017, Srishti Sharma wrote:

> Use WARN_ON() instead of BUG_ON() to avoid crashing the kernel.
>
> Signed-off-by: Srishti Sharma 
> ---
>  drivers/staging/media/omap4iss/iss.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/omap4iss/iss.c 
> b/drivers/staging/media/omap4iss/iss.c
> index c26c99fd..b1036ba 100644
> --- a/drivers/staging/media/omap4iss/iss.c
> +++ b/drivers/staging/media/omap4iss/iss.c
> @@ -893,7 +893,7 @@ void omap4iss_put(struct iss_device *iss)
>   return;
>
>   mutex_lock(>iss_mutex);
> - BUG_ON(iss->ref_count == 0);
> + WARN_ON(iss->ref_count == 0);
>   if (--iss->ref_count == 0) {

Won't this then infinite loop?

julia

>   iss_disable_interrupts(iss);
>   /* Reset the ISS if an entity has failed to stop. This is the
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1504879698-5855-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


[PATCH] Staging: media: omap4iss: Use WARN_ON() instead of BUG_ON().

2017-09-08 Thread Srishti Sharma
Use WARN_ON() instead of BUG_ON() to avoid crashing the kernel.

Signed-off-by: Srishti Sharma 
---
 drivers/staging/media/omap4iss/iss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/omap4iss/iss.c 
b/drivers/staging/media/omap4iss/iss.c
index c26c99fd..b1036ba 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -893,7 +893,7 @@ void omap4iss_put(struct iss_device *iss)
return;

mutex_lock(>iss_mutex);
-   BUG_ON(iss->ref_count == 0);
+   WARN_ON(iss->ref_count == 0);
if (--iss->ref_count == 0) {
iss_disable_interrupts(iss);
/* Reset the ISS if an entity has failed to stop. This is the
--
2.7.4



Re: [PATCH v9 17/24] ACPI: Document how to refer to LEDs from remote nodes

2017-09-08 Thread Mika Westerberg
On Fri, Sep 08, 2017 at 04:54:07PM +0300, Sakari Ailus wrote:
> On Fri, Sep 08, 2017 at 04:43:20PM +0300, Mika Westerberg wrote:
> > On Fri, Sep 08, 2017 at 04:18:15PM +0300, Sakari Ailus wrote:
> > > + Device (LED)
> > > + {
> > > + Name ((_DSD), Package () {
> > > + ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
> > > + Package () {
> > > + Package () { "led0", "LED0" },
> > > + Package () { "led1", "LED1" },
> > > + }
> > > + })
> > > + Name ((LED0), Package () {
> > > + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> > > + Package () {
> > > + Package () { "led", 0 },
> > > + Package () { "flash-max-microamp", 100 },
> > > + Package () { "led-max-microamp", 10 },
> > > + Package () { "label", "led:salama" },
> > > + }
> > > + })
> > > + Name ((LED1), Package () {
> > > + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> > > + Package () {
> > > + Package () { "led", 1 },
> > > + Package () { "led-max-microamp", 1 },
> > > + Package () { "label", "led:huomiovalo" },
> > > + }
> > > + })
> > > + }
> > > +
> > > + Device (SEN)
> > > + {
> > > + Name ((_DSD), Package () {
> > > + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> > > + Package () {
> > > + Package () {
> > > + "flash-leds",
> > > + Package () { \\LED, 0, \\LED, 1 },
> > > + }
> > > + }
> > > + })
> > > + }
> > 
> > You should probably try to compile these examples first ;-)
> 
> Do you think I'm missing something else than s//^/g ? :-)

Well, you should write

Name (_DSD, Package () {

instead of

Name ((_DSD), Package () {

but I guess the compiler accepts the former. However, please fix it and
make sure it compiles without issues so that we get good, working
examples.


Re: [PATCH v9 17/24] ACPI: Document how to refer to LEDs from remote nodes

2017-09-08 Thread Sakari Ailus
On Fri, Sep 08, 2017 at 04:43:20PM +0300, Mika Westerberg wrote:
> On Fri, Sep 08, 2017 at 04:18:15PM +0300, Sakari Ailus wrote:
> > +   Device (LED)
> > +   {
> > +   Name ((_DSD), Package () {
> > +   ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
> > +   Package () {
> > +   Package () { "led0", "LED0" },
> > +   Package () { "led1", "LED1" },
> > +   }
> > +   })
> > +   Name ((LED0), Package () {
> > +   ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> > +   Package () {
> > +   Package () { "led", 0 },
> > +   Package () { "flash-max-microamp", 100 },
> > +   Package () { "led-max-microamp", 10 },
> > +   Package () { "label", "led:salama" },
> > +   }
> > +   })
> > +   Name ((LED1), Package () {
> > +   ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> > +   Package () {
> > +   Package () { "led", 1 },
> > +   Package () { "led-max-microamp", 1 },
> > +   Package () { "label", "led:huomiovalo" },
> > +   }
> > +   })
> > +   }
> > +
> > +   Device (SEN)
> > +   {
> > +   Name ((_DSD), Package () {
> > +   ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> > +   Package () {
> > +   Package () {
> > +   "flash-leds",
> > +   Package () { \\LED, 0, \\LED, 1 },
> > +   }
> > +   }
> > +   })
> > +   }
> 
> You should probably try to compile these examples first ;-)

Do you think I'm missing something else than s//^/g ? :-)

Yes, I tested it but then changed the tested ASL afterwards. :-P

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi


[PATCH 1/1] media: i2c: as3645a: Remove driver

2017-09-08 Thread Sakari Ailus
Remove the V4L2 AS3645A sub-device driver in favour of the LED flash class
driver for the same hardware, drivers/leds/leds-as3645a.c. The latter uses
the V4L2 flash LED class framework to provide V4L2 sub-device interface.

Signed-off-by: Sakari Ailus 
---
 MAINTAINERS |   8 -
 drivers/media/i2c/Kconfig   |   8 -
 drivers/media/i2c/Makefile  |   1 -
 drivers/media/i2c/as3645a.c | 880 
 include/media/i2c/as3645a.h |  66 
 5 files changed, 963 deletions(-)
 delete mode 100644 drivers/media/i2c/as3645a.c
 delete mode 100644 include/media/i2c/as3645a.h

diff --git a/MAINTAINERS b/MAINTAINERS
index eb930ebecfcb..40964ab8cbbd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2129,14 +2129,6 @@ L:   linux-l...@vger.kernel.org
 S: Maintained
 F: drivers/leds/leds-as3645a.c
 
-AS3645A LED FLASH CONTROLLER DRIVER
-M: Laurent Pinchart 
-L: linux-media@vger.kernel.org
-T: git git://linuxtv.org/media_tree.git
-S: Maintained
-F: drivers/media/i2c/as3645a.c
-F: include/media/i2c/as3645a.h
-
 ASAHI KASEI AK8974 DRIVER
 M: Linus Walleij 
 L: linux-...@vger.kernel.org
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 94153895fcd4..559ee95a47cf 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -796,14 +796,6 @@ config VIDEO_ADP1653
  This is a driver for the ADP1653 flash controller. It is used for
  example in Nokia N900.
 
-config VIDEO_AS3645A
-   tristate "AS3645A flash driver support"
-   depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER
-   depends on MEDIA_CAMERA_SUPPORT
-   ---help---
- This is a driver for the AS3645A and LM3555 flash controllers. It has
- build in control for flash, torch and indicator LEDs.
-
 config VIDEO_LM3560
tristate "LM3560 dual flash driver support"
depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index c843c181dfb9..e88cdb20eb72 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -83,7 +83,6 @@ obj-$(CONFIG_VIDEO_S5K4ECGX)  += s5k4ecgx.o
 obj-$(CONFIG_VIDEO_S5K5BAF)+= s5k5baf.o
 obj-$(CONFIG_VIDEO_S5C73M3)+= s5c73m3/
 obj-$(CONFIG_VIDEO_ADP1653)+= adp1653.o
-obj-$(CONFIG_VIDEO_AS3645A)+= as3645a.o
 obj-$(CONFIG_VIDEO_LM3560) += lm3560.o
 obj-$(CONFIG_VIDEO_LM3646) += lm3646.o
 obj-$(CONFIG_VIDEO_SMIAPP_PLL) += smiapp-pll.o
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
deleted file mode 100644
index af5db71a0888..
--- a/drivers/media/i2c/as3645a.c
+++ /dev/null
@@ -1,880 +0,0 @@
-/*
- * drivers/media/i2c/as3645a.c - AS3645A and LM3555 flash controllers driver
- *
- * Copyright (C) 2008-2011 Nokia Corporation
- * Copyright (c) 2011, Intel Corporation.
- *
- * Contact: Laurent Pinchart 
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * TODO:
- * - Check hardware FSTROBE control when sensor driver add support for this
- *
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-#define AS_TIMER_MS_TO_CODE(t) (((t) - 100) / 50)
-#define AS_TIMER_CODE_TO_MS(c) (50 * (c) + 100)
-
-/* Register definitions */
-
-/* Read-only Design info register: Reset state:  0001 */
-#define AS_DESIGN_INFO_REG 0x00
-#define AS_DESIGN_INFO_FACTORY(x)  (((x) >> 4))
-#define AS_DESIGN_INFO_MODEL(x)((x) & 0x0f)
-
-/* Read-only Version control register: Reset state:  
- * for first engineering samples
- */
-#define AS_VERSION_CONTROL_REG 0x01
-#define AS_VERSION_CONTROL_RFU(x)  (((x) >> 4))
-#define AS_VERSION_CONTROL_VERSION(x)  ((x) & 0x0f)
-
-/* Read / Write(Indicator and timer register): Reset state:   
*/
-#define AS_INDICATOR_AND_TIMER_REG 0x02
-#define AS_INDICATOR_AND_TIMER_TIMEOUT_SHIFT   0
-#define AS_INDICATOR_AND_TIMER_VREF_SHIFT  4
-#define AS_INDICATOR_AND_TIMER_INDICATOR_SHIFT 6
-
-/* Read / Write(Current set register): Reset state: 0110 1001 */
-#define AS_CURRENT_SET_REG 0x03
-#define AS_CURRENT_ASSIST_LIGHT_SHIFT  0
-#define AS_CURRENT_LED_DET_ON  (1 << 3)
-#define AS_CURRENT_FLASH_CURRENT_SHIFT 4
-
-/* Read / Write(Control register): Reset 

Re: [PATCH 3/3] as3645a: Use integer numbers for parsing LEDs

2017-09-08 Thread Sakari Ailus
On Fri, Sep 08, 2017 at 03:38:41PM +0200, Pavel Machek wrote:
> On Fri 2017-09-08 16:23:34, Sakari Ailus wrote:
> > Hi Pavel,
> > 
> > Thanks for the review.
> > 
> > On Fri, Sep 08, 2017 at 03:17:58PM +0200, Pavel Machek wrote:
> > > On Fri 2017-09-08 15:42:13, Sakari Ailus wrote:
> > > > Use integer numbers for LEDs, 0 is the flash and 1 is the indicator.
> > > > 
> > > > Signed-off-by: Sakari Ailus 
> > > 
> > > Dunno. Old code is shorter, old device tree is shorter, ... IMO both
> > > versions are fine, because the LEDs are really different. Do we have
> > > documentation somewhere saying that reg= should be used for this? Are
> > > you doing this for consistency?
> > 
> > Well, actually for ACPI support. :-) It requires less driver changes this
> > way. See 17th and 18th patches in "[PATCH v9 00/23] Unified fwnode endpoint
> > parser, async sub-device notifier support, N9 flash DTS".
> 
> ACPI, I hate ACPI.

:-D

> 
> > A number of chips have LED binding that is aligned, see e.g.
> > Documentation/devicetree/bindings/leds/leds-bcm6328.txt .
> 
> Ok, yes, that's common way LED controllers are handled. Usually all
> the LEDs are "same", but...

I presume that's the case with most LED driver chips: all the outputs are
alike.

> 
> Acked-by: Pavel Machek 

Thanks!

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi


Re: [PATCH v9 17/24] ACPI: Document how to refer to LEDs from remote nodes

2017-09-08 Thread Mika Westerberg
On Fri, Sep 08, 2017 at 04:18:15PM +0300, Sakari Ailus wrote:
> + Device (LED)
> + {
> + Name ((_DSD), Package () {
> + ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
> + Package () {
> + Package () { "led0", "LED0" },
> + Package () { "led1", "LED1" },
> + }
> + })
> + Name ((LED0), Package () {
> + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> + Package () {
> + Package () { "led", 0 },
> + Package () { "flash-max-microamp", 100 },
> + Package () { "led-max-microamp", 10 },
> + Package () { "label", "led:salama" },
> + }
> + })
> + Name ((LED1), Package () {
> + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> + Package () {
> + Package () { "led", 1 },
> + Package () { "led-max-microamp", 1 },
> + Package () { "label", "led:huomiovalo" },
> + }
> + })
> + }
> +
> + Device (SEN)
> + {
> + Name ((_DSD), Package () {
> + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> + Package () {
> + Package () {
> + "flash-leds",
> + Package () { \\LED, 0, \\LED, 1 },
> + }
> + }
> + })
> + }

You should probably try to compile these examples first ;-)


Re: [PATCH v9 23/24] dt: bindings: smiapp: Document lens-focus and flash properties

2017-09-08 Thread Sakari Ailus
Hi Pavel,

On Fri, Sep 08, 2017 at 03:36:52PM +0200, Pavel Machek wrote:
> Hi!
> 
> > Document optional lens-focus and flash properties for the smiapp driver.
> > 
> > Signed-off-by: Sakari Ailus 
> > ---
> >  Documentation/devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt 
> > b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
> > index 855e1faf73e2..a052969365d9 100644
> > --- a/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
> > +++ b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
> > @@ -27,6 +27,8 @@ Optional properties
> >  - nokia,nvm-size: The size of the NVM, in bytes. If the size is not given,
> >the NVM contents will not be read.
> >  - reset-gpios: XSHUTDOWN GPIO
> > +- flash-leds: One or more phandles to refer to flash LEDs
> > +- lens-focus: Phandle for lens focus
> 
> Should we simply reference the generic documentation here? If it needs
> changing, it will be easier changing single place.

Good question.

Ideally the properties at least would never change; we do have a common
parser for the properties which is part of the patchset so in theory it
would be possible to change the documentation in a backward-compatible way.

I added these properties as well as all the other properties supported by
the sensor driver are documented here. That has been the practice AFAIU,
albeit omissions do happen occasionally.

The issue I see with omitting the documentation here is that the user
otherwise won't know whether a driver uses a given property or not: it
shouldn't be necessary to read driver code to write DT source.

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi


Re: [PATCH 3/4] [media] sp2: Adjust a jump target in sp2_probe()

2017-09-08 Thread Hans Verkuil
Hi Markus,

On 09/01/17 21:44, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Fri, 1 Sep 2017 21:08:38 +0200
> 
> * Adjust a jump target so that a null pointer will not be passed to a call
>   of the function "kfree".
> 
> * Move this function call into an if branch.
> 
> Signed-off-by: Markus Elfring 
> ---
>  drivers/media/dvb-frontends/sp2.c | 13 +++--
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/sp2.c 
> b/drivers/media/dvb-frontends/sp2.c
> index dd556012ceb6..b2a7a54174ae 100644
> --- a/drivers/media/dvb-frontends/sp2.c
> +++ b/drivers/media/dvb-frontends/sp2.c
> @@ -384,7 +384,7 @@ static int sp2_probe(struct i2c_client *client,
>   s = kzalloc(sizeof(*s), GFP_KERNEL);
>   if (!s) {
>   ret = -ENOMEM;
> - goto err;
> + goto report_failure;
>   }
>  
>   s->client = client;
> @@ -395,15 +395,16 @@ static int sp2_probe(struct i2c_client *client,
>   i2c_set_clientdata(client, s);
>  
>   ret = sp2_init(s);
> - if (ret)
> - goto err;
> + if (ret) {
> + kfree(s);
> + goto report_failure;
> + }
>  
>   dev_info(>client->dev, "CIMaX SP2 successfully attached\n");
>   return 0;
> -err:
> - dev_dbg(>dev, "init failed=%d\n", ret);
> - kfree(s);
>  
> +report_failure:
> + dev_dbg(>dev, "init failed=%d\n", ret);
>   return ret;
>  }
>  
> 

It's perfectly fine to call kfree() with a NULL pointer, and I don't think
that this patch makes the code more readable, so I'm dropping this patch.

Regards,

Hans


Re: [PATCH 3/3] as3645a: Use integer numbers for parsing LEDs

2017-09-08 Thread Pavel Machek
On Fri 2017-09-08 16:23:34, Sakari Ailus wrote:
> Hi Pavel,
> 
> Thanks for the review.
> 
> On Fri, Sep 08, 2017 at 03:17:58PM +0200, Pavel Machek wrote:
> > On Fri 2017-09-08 15:42:13, Sakari Ailus wrote:
> > > Use integer numbers for LEDs, 0 is the flash and 1 is the indicator.
> > > 
> > > Signed-off-by: Sakari Ailus 
> > 
> > Dunno. Old code is shorter, old device tree is shorter, ... IMO both
> > versions are fine, because the LEDs are really different. Do we have
> > documentation somewhere saying that reg= should be used for this? Are
> > you doing this for consistency?
> 
> Well, actually for ACPI support. :-) It requires less driver changes this
> way. See 17th and 18th patches in "[PATCH v9 00/23] Unified fwnode endpoint
> parser, async sub-device notifier support, N9 flash DTS".

ACPI, I hate ACPI.

> A number of chips have LED binding that is aligned, see e.g.
> Documentation/devicetree/bindings/leds/leds-bcm6328.txt .

Ok, yes, that's common way LED controllers are handled. Usually all
the LEDs are "same", but...

Acked-by: Pavel Machek 

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v9 23/24] dt: bindings: smiapp: Document lens-focus and flash properties

2017-09-08 Thread Pavel Machek
Hi!

> Document optional lens-focus and flash properties for the smiapp driver.
> 
> Signed-off-by: Sakari Ailus 
> ---
>  Documentation/devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt 
> b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
> index 855e1faf73e2..a052969365d9 100644
> --- a/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
> +++ b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
> @@ -27,6 +27,8 @@ Optional properties
>  - nokia,nvm-size: The size of the NVM, in bytes. If the size is not given,
>the NVM contents will not be read.
>  - reset-gpios: XSHUTDOWN GPIO
> +- flash-leds: One or more phandles to refer to flash LEDs
> +- lens-focus: Phandle for lens focus

Should we simply reference the generic documentation here? If it needs
changing, it will be easier changing single place.
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH 3/3] as3645a: Use integer numbers for parsing LEDs

2017-09-08 Thread Sakari Ailus
Hi Pavel,

Thanks for the review.

On Fri, Sep 08, 2017 at 03:17:58PM +0200, Pavel Machek wrote:
> On Fri 2017-09-08 15:42:13, Sakari Ailus wrote:
> > Use integer numbers for LEDs, 0 is the flash and 1 is the indicator.
> > 
> > Signed-off-by: Sakari Ailus 
> 
> Dunno. Old code is shorter, old device tree is shorter, ... IMO both
> versions are fine, because the LEDs are really different. Do we have
> documentation somewhere saying that reg= should be used for this? Are
> you doing this for consistency?

Well, actually for ACPI support. :-) It requires less driver changes this
way. See 17th and 18th patches in "[PATCH v9 00/23] Unified fwnode endpoint
parser, async sub-device notifier support, N9 flash DTS".

A number of chips have LED binding that is aligned, see e.g.
Documentation/devicetree/bindings/leds/leds-bcm6328.txt .

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi


Re: [PATCH v9 00/23] Unified fwnode endpoint parser, async sub-device notifier support, N9 flash DTS

2017-09-08 Thread Sakari Ailus
On Fri, Sep 08, 2017 at 04:11:51PM +0300, Sakari Ailus wrote:
> With this, the as3645a driver successfully registers a sub-device to the
> media device created by the omap3isp driver. The kernel also has the
> information it's related to the sensor driven by the smiapp driver but we
> don't have a way to expose that information yet.

The patches are also available here:



-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi


[PATCH v9 05/24] v4l: fwnode: Support generic parsing of graph endpoints in a device

2017-09-08 Thread Sakari Ailus
The current practice is that drivers iterate over their endpoints and
parse each endpoint separately. This is very similar in a number of
drivers, implement a generic function for the job. Driver specific matters
can be taken into account in the driver specific callback.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c  |  30 
 drivers/media/v4l2-core/v4l2-fwnode.c | 136 ++
 include/media/v4l2-async.h|  24 +-
 include/media/v4l2-fwnode.h   |  56 ++
 4 files changed, 244 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 831f185ecd47..ad099b9bb71d 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -22,6 +22,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
@@ -219,6 +220,35 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
 }
 EXPORT_SYMBOL(v4l2_async_notifier_unregister);
 
+void v4l2_async_notifier_release(struct v4l2_async_notifier *notifier)
+{
+   unsigned int i;
+
+   if (!notifier->max_subdevs)
+   return;
+
+   for (i = 0; i < notifier->num_subdevs; i++) {
+   struct v4l2_async_subdev *asd = notifier->subdevs[i];
+
+   switch (asd->match_type) {
+   case V4L2_ASYNC_MATCH_FWNODE:
+   fwnode_handle_put(asd->match.fwnode.fwnode);
+   break;
+   default:
+   WARN_ON_ONCE(1);
+   }
+
+   kfree(asd);
+   }
+
+   notifier->max_subdevs = 0;
+   notifier->num_subdevs = 0;
+
+   kvfree(notifier->subdevs);
+   notifier->subdevs = NULL;
+}
+EXPORT_SYMBOL_GPL(v4l2_async_notifier_release);
+
 int v4l2_async_register_subdev(struct v4l2_subdev *sd)
 {
struct v4l2_async_notifier *notifier;
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 706f9e7b90f1..d978f2d714ca 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -19,6 +19,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -26,6 +27,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 enum v4l2_fwnode_bus_type {
@@ -313,6 +315,140 @@ void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link)
 }
 EXPORT_SYMBOL_GPL(v4l2_fwnode_put_link);
 
+static int v4l2_async_notifier_realloc(struct v4l2_async_notifier *notifier,
+  unsigned int max_subdevs)
+{
+   struct v4l2_async_subdev **subdevs;
+
+   if (max_subdevs <= notifier->max_subdevs)
+   return 0;
+
+   subdevs = kvmalloc_array(
+   max_subdevs, sizeof(*notifier->subdevs),
+   GFP_KERNEL | __GFP_ZERO);
+   if (!subdevs)
+   return -ENOMEM;
+
+   if (notifier->subdevs) {
+   memcpy(subdevs, notifier->subdevs,
+  sizeof(*subdevs) * notifier->num_subdevs);
+
+   kvfree(notifier->subdevs);
+   }
+
+   notifier->subdevs = subdevs;
+   notifier->max_subdevs = max_subdevs;
+
+   return 0;
+}
+
+static int v4l2_async_notifier_fwnode_parse_endpoint(
+   struct device *dev, struct v4l2_async_notifier *notifier,
+   struct fwnode_handle *endpoint, unsigned int asd_struct_size,
+   int (*parse_endpoint)(struct device *dev,
+   struct v4l2_fwnode_endpoint *vep,
+   struct v4l2_async_subdev *asd))
+{
+   struct v4l2_async_subdev *asd;
+   struct v4l2_fwnode_endpoint *vep;
+   int ret = 0;
+
+   asd = kzalloc(asd_struct_size, GFP_KERNEL);
+   if (!asd)
+   return -ENOMEM;
+
+   asd->match.fwnode.fwnode =
+   fwnode_graph_get_remote_port_parent(endpoint);
+   if (!asd->match.fwnode.fwnode) {
+   dev_warn(dev, "bad remote port parent\n");
+   ret = -EINVAL;
+   goto out_err;
+   }
+
+   /* Ignore endpoints the parsing of which failed. */
+   vep = v4l2_fwnode_endpoint_alloc_parse(endpoint);
+   if (IS_ERR(vep)) {
+   ret = PTR_ERR(vep);
+   dev_warn(dev, "unable to parse V4L2 fwnode endpoint (%d)\n",
+ret);
+   goto out_err;
+   }
+
+   ret = parse_endpoint ? parse_endpoint(dev, vep, asd) : 0;
+   if (ret == -ENOTCONN)
+   dev_dbg(dev, "ignoring endpoint %u,%u\n", vep->base.port,
+   vep->base.id);
+   else if (ret < 0)
+   dev_warn(dev, "driver could not parse endpoint %u,%u (%d)\n",
+vep->base.port, vep->base.id, ret);
+   v4l2_fwnode_endpoint_free(vep);
+   if (ret < 0)
+   goto out_err;
+
+

[PATCH v9 11/24] v4l: async: Introduce helpers for calling async ops callbacks

2017-09-08 Thread Sakari Ailus
Add three helper functions to call async operations callbacks. Besides
simplifying callbacks, this allows async notifiers to have no ops set,
i.e. it can be left NULL.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c | 49 ++--
 include/media/v4l2-async.h   |  1 +
 2 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index a2df85ea00f4..c34f93593b41 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -25,6 +25,34 @@
 #include 
 #include 
 
+static int v4l2_async_notifier_call_bound(struct v4l2_async_notifier *n,
+ struct v4l2_subdev *subdev,
+ struct v4l2_async_subdev *asd)
+{
+   if (!n->ops || !n->ops->bound)
+   return 0;
+
+   return n->ops->bound(n, subdev, asd);
+}
+
+static void v4l2_async_notifier_call_unbind(struct v4l2_async_notifier *n,
+   struct v4l2_subdev *subdev,
+   struct v4l2_async_subdev *asd)
+{
+   if (!n->ops || !n->ops->unbind)
+   return;
+
+   n->ops->unbind(n, subdev, asd);
+}
+
+static int v4l2_async_notifier_call_complete(struct v4l2_async_notifier *n)
+{
+   if (!n->ops || !n->ops->complete)
+   return 0;
+
+   return n->ops->complete(n);
+}
+
 static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
 #if IS_ENABLED(CONFIG_I2C)
@@ -102,16 +130,13 @@ static int v4l2_async_match_notify(struct 
v4l2_async_notifier *notifier,
 {
int ret;
 
-   if (notifier->ops->bound) {
-   ret = notifier->ops->bound(notifier, sd, asd);
-   if (ret < 0)
-   return ret;
-   }
+   ret = v4l2_async_notifier_call_bound(notifier, sd, asd);
+   if (ret < 0)
+   return ret;
 
ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
if (ret < 0) {
-   if (notifier->ops->unbind)
-   notifier->ops->unbind(notifier, sd, asd);
+   v4l2_async_notifier_call_unbind(notifier, sd, asd);
return ret;
}
 
@@ -123,8 +148,8 @@ static int v4l2_async_match_notify(struct 
v4l2_async_notifier *notifier,
/* Move from the global subdevice list to notifier's done */
list_move(>async_list, >done);
 
-   if (list_empty(>waiting) && notifier->ops->complete)
-   return notifier->ops->complete(notifier);
+   if (list_empty(>waiting))
+   return v4l2_async_notifier_call_complete(notifier);
 
return 0;
 }
@@ -210,8 +235,7 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
list_for_each_entry_safe(sd, tmp, >done, async_list) {
v4l2_async_cleanup(sd);
 
-   if (notifier->ops->unbind)
-   notifier->ops->unbind(notifier, sd, sd->asd);
+   v4l2_async_notifier_call_unbind(notifier, sd, sd->asd);
}
 
mutex_unlock(_lock);
@@ -300,8 +324,7 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
 
v4l2_async_cleanup(sd);
 
-   if (notifier->ops->unbind)
-   notifier->ops->unbind(notifier, sd, sd->asd);
+   v4l2_async_notifier_call_unbind(notifier, sd, sd->asd);
 
mutex_unlock(_lock);
 }
diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
index 3c48f8b66d12..3bc8a7c0d83f 100644
--- a/include/media/v4l2-async.h
+++ b/include/media/v4l2-async.h
@@ -164,4 +164,5 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd);
  * @sd: pointer to  v4l2_subdev
  */
 void v4l2_async_unregister_subdev(struct v4l2_subdev *sd);
+
 #endif
-- 
2.11.0



[PATCH v9 12/24] v4l: async: Register sub-devices before calling bound callback

2017-09-08 Thread Sakari Ailus
Register the sub-device before calling the notifier's bound callback.
Doing this the other way around is problematic as the struct v4l2_device
has not assigned for the sub-device yet and may be required by the bound
callback.

Signed-off-by: Sakari Ailus 
Acked-by: Hans Verkuil 
---
 drivers/media/v4l2-core/v4l2-async.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index c34f93593b41..7b396ff4302b 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -130,13 +130,13 @@ static int v4l2_async_match_notify(struct 
v4l2_async_notifier *notifier,
 {
int ret;
 
-   ret = v4l2_async_notifier_call_bound(notifier, sd, asd);
+   ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
if (ret < 0)
return ret;
 
-   ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
+   ret = v4l2_async_notifier_call_bound(notifier, sd, asd);
if (ret < 0) {
-   v4l2_async_notifier_call_unbind(notifier, sd, asd);
+   v4l2_device_unregister_subdev(sd);
return ret;
}
 
-- 
2.11.0



[PATCH v9 06/24] omap3isp: Use generic parser for parsing fwnode endpoints

2017-09-08 Thread Sakari Ailus
Instead of using driver implementation, use
v4l2_async_notifier_parse_fwnode_endpoints() to parse the fwnode endpoints
of the device.

Signed-off-by: Sakari Ailus 
Acked-by: Hans Verkuil 
---
 drivers/media/platform/omap3isp/isp.c | 115 +++---
 drivers/media/platform/omap3isp/isp.h |   5 +-
 2 files changed, 37 insertions(+), 83 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index 1a428fe9f070..a546cf774d40 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -2001,6 +2001,7 @@ static int isp_remove(struct platform_device *pdev)
__omap3isp_put(isp, false);
 
media_entity_enum_cleanup(>crashed);
+   v4l2_async_notifier_release(>notifier);
 
return 0;
 }
@@ -2011,44 +2012,41 @@ enum isp_of_phy {
ISP_OF_PHY_CSIPHY2,
 };
 
-static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwnode,
-   struct isp_async_subdev *isd)
+static int isp_fwnode_parse(struct device *dev,
+   struct v4l2_fwnode_endpoint *vep,
+   struct v4l2_async_subdev *asd)
 {
+   struct isp_async_subdev *isd =
+   container_of(asd, struct isp_async_subdev, asd);
struct isp_bus_cfg *buscfg = >bus;
-   struct v4l2_fwnode_endpoint vep;
-   unsigned int i;
-   int ret;
bool csi1 = false;
-
-   ret = v4l2_fwnode_endpoint_parse(fwnode, );
-   if (ret)
-   return ret;
+   unsigned int i;
 
dev_dbg(dev, "parsing endpoint %pOF, interface %u\n",
-   to_of_node(fwnode), vep.base.port);
+   to_of_node(vep->base.local_fwnode), vep->base.port);
 
-   switch (vep.base.port) {
+   switch (vep->base.port) {
case ISP_OF_PHY_PARALLEL:
buscfg->interface = ISP_INTERFACE_PARALLEL;
buscfg->bus.parallel.data_lane_shift =
-   vep.bus.parallel.data_shift;
+   vep->bus.parallel.data_shift;
buscfg->bus.parallel.clk_pol =
-   !!(vep.bus.parallel.flags
+   !!(vep->bus.parallel.flags
   & V4L2_MBUS_PCLK_SAMPLE_FALLING);
buscfg->bus.parallel.hs_pol =
-   !!(vep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW);
+   !!(vep->bus.parallel.flags & 
V4L2_MBUS_VSYNC_ACTIVE_LOW);
buscfg->bus.parallel.vs_pol =
-   !!(vep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW);
+   !!(vep->bus.parallel.flags & 
V4L2_MBUS_HSYNC_ACTIVE_LOW);
buscfg->bus.parallel.fld_pol =
-   !!(vep.bus.parallel.flags & V4L2_MBUS_FIELD_EVEN_LOW);
+   !!(vep->bus.parallel.flags & V4L2_MBUS_FIELD_EVEN_LOW);
buscfg->bus.parallel.data_pol =
-   !!(vep.bus.parallel.flags & V4L2_MBUS_DATA_ACTIVE_LOW);
-   buscfg->bus.parallel.bt656 = vep.bus_type == V4L2_MBUS_BT656;
+   !!(vep->bus.parallel.flags & V4L2_MBUS_DATA_ACTIVE_LOW);
+   buscfg->bus.parallel.bt656 = vep->bus_type == V4L2_MBUS_BT656;
break;
 
case ISP_OF_PHY_CSIPHY1:
case ISP_OF_PHY_CSIPHY2:
-   switch (vep.bus_type) {
+   switch (vep->bus_type) {
case V4L2_MBUS_CCP2:
case V4L2_MBUS_CSI1:
dev_dbg(dev, "CSI-1/CCP-2 configuration\n");
@@ -2060,11 +2058,11 @@ static int isp_fwnode_parse(struct device *dev, struct 
fwnode_handle *fwnode,
break;
default:
dev_err(dev, "unsupported bus type %u\n",
-   vep.bus_type);
+   vep->bus_type);
return -EINVAL;
}
 
-   switch (vep.base.port) {
+   switch (vep->base.port) {
case ISP_OF_PHY_CSIPHY1:
if (csi1)
buscfg->interface = ISP_INTERFACE_CCP2B_PHY1;
@@ -2080,47 +2078,47 @@ static int isp_fwnode_parse(struct device *dev, struct 
fwnode_handle *fwnode,
}
if (csi1) {
buscfg->bus.ccp2.lanecfg.clk.pos =
-   vep.bus.mipi_csi1.clock_lane;
+   vep->bus.mipi_csi1.clock_lane;
buscfg->bus.ccp2.lanecfg.clk.pol =
-   vep.bus.mipi_csi1.lane_polarity[0];
+   vep->bus.mipi_csi1.lane_polarity[0];
dev_dbg(dev, "clock lane polarity %u, pos %u\n",
buscfg->bus.ccp2.lanecfg.clk.pol,

[PATCH v9 10/24] v4l: async: Move async subdev notifier operations to a separate structure

2017-09-08 Thread Sakari Ailus
From: Laurent Pinchart 

The async subdev notifier .bound(), .unbind() and .complete() operations
are function pointers stored directly in the v4l2_async_subdev
structure. As the structure isn't immutable, this creates a potential
security risk as the function pointers are mutable.

To fix this, move the function pointers to a new
v4l2_async_subdev_operations structure that can be made const in
drivers.

Signed-off-by: Laurent Pinchart 
Acked-by: Hans Verkuil 
---
 drivers/media/platform/am437x/am437x-vpfe.c|  8 +--
 drivers/media/platform/atmel/atmel-isc.c   | 10 ++---
 drivers/media/platform/atmel/atmel-isi.c   | 10 ++---
 drivers/media/platform/davinci/vpif_capture.c  |  8 +--
 drivers/media/platform/davinci/vpif_display.c  |  8 +--
 drivers/media/platform/exynos4-is/media-dev.c  |  8 +--
 drivers/media/platform/omap3isp/isp.c  |  6 +-
 drivers/media/platform/pxa_camera.c|  8 +--
 drivers/media/platform/qcom/camss-8x16/camss.c |  8 +--
 drivers/media/platform/rcar-vin/rcar-core.c| 10 ++---
 drivers/media/platform/rcar_drif.c | 10 ++---
 drivers/media/platform/soc_camera/soc_camera.c | 14 +++--
 drivers/media/platform/stm32/stm32-dcmi.c  | 10 ++---
 drivers/media/platform/ti-vpe/cal.c|  8 +--
 drivers/media/platform/xilinx/xilinx-vipp.c|  8 +--
 drivers/media/v4l2-core/v4l2-async.c   | 20 +-
 drivers/staging/media/imx/imx-media-dev.c  |  8 +--
 include/media/v4l2-async.h | 29 +-
 18 files changed, 131 insertions(+), 60 deletions(-)

diff --git a/drivers/media/platform/am437x/am437x-vpfe.c 
b/drivers/media/platform/am437x/am437x-vpfe.c
index dfcc484cab89..0997c640191d 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -2417,6 +2417,11 @@ static int vpfe_async_complete(struct 
v4l2_async_notifier *notifier)
return vpfe_probe_complete(vpfe);
 }
 
+static const struct v4l2_async_notifier_operations vpfe_async_ops = {
+   .bound = vpfe_async_bound,
+   .complete = vpfe_async_complete,
+};
+
 static struct vpfe_config *
 vpfe_get_pdata(struct platform_device *pdev)
 {
@@ -2590,8 +2595,7 @@ static int vpfe_probe(struct platform_device *pdev)
 
vpfe->notifier.subdevs = vpfe->cfg->asd;
vpfe->notifier.num_subdevs = ARRAY_SIZE(vpfe->cfg->asd);
-   vpfe->notifier.bound = vpfe_async_bound;
-   vpfe->notifier.complete = vpfe_async_complete;
+   vpfe->notifier.ops = _async_ops;
ret = v4l2_async_notifier_register(>v4l2_dev,
>notifier);
if (ret) {
diff --git a/drivers/media/platform/atmel/atmel-isc.c 
b/drivers/media/platform/atmel/atmel-isc.c
index d7103c5f92c3..48544c4137cb 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -1639,6 +1639,12 @@ static int isc_async_complete(struct v4l2_async_notifier 
*notifier)
return 0;
 }
 
+static const struct v4l2_async_notifier_operations isc_async_ops = {
+   .bound = isc_async_bound,
+   .unbind = isc_async_unbind,
+   .complete = isc_async_complete,
+};
+
 static void isc_subdev_cleanup(struct isc_device *isc)
 {
struct isc_subdev_entity *subdev_entity;
@@ -1851,9 +1857,7 @@ static int atmel_isc_probe(struct platform_device *pdev)
list_for_each_entry(subdev_entity, >subdev_entities, list) {
subdev_entity->notifier.subdevs = _entity->asd;
subdev_entity->notifier.num_subdevs = 1;
-   subdev_entity->notifier.bound = isc_async_bound;
-   subdev_entity->notifier.unbind = isc_async_unbind;
-   subdev_entity->notifier.complete = isc_async_complete;
+   subdev_entity->notifier.ops = _async_ops;
 
ret = v4l2_async_notifier_register(>v4l2_dev,
   _entity->notifier);
diff --git a/drivers/media/platform/atmel/atmel-isi.c 
b/drivers/media/platform/atmel/atmel-isi.c
index 891fa2505efa..eadbf9def358 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -1105,6 +1105,12 @@ static int isi_graph_notify_bound(struct 
v4l2_async_notifier *notifier,
return 0;
 }
 
+static const struct v4l2_async_notifier_operations isi_graph_notify_ops = {
+   .bound = isi_graph_notify_bound,
+   .unbind = isi_graph_notify_unbind,
+   .complete = isi_graph_notify_complete,
+};
+
 static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)
 {
struct device_node *ep = NULL;
@@ -1152,9 +1158,7 @@ static int isi_graph_init(struct atmel_isi *isi)
 
isi->notifier.subdevs = subdevs;
isi->notifier.num_subdevs = 1;
-   

[PATCH v9 20/24] v4l: fwnode: Add a helper function to obtain device / interger references

2017-09-08 Thread Sakari Ailus
v4l2_fwnode_reference_parse_int_prop() will find an fwnode such that under
the device's own fwnode, it will follow child fwnodes with the given
property -- value pair and return the resulting fwnode.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 93 +++
 1 file changed, 93 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 4821c4989119..56eee5bbd3b5 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -496,6 +496,99 @@ static int v4l2_fwnode_reference_parse(
return ret;
 }
 
+static struct fwnode_handle *v4l2_fwnode_reference_get_int_prop(
+   struct fwnode_handle *fwnode, const char *prop, unsigned int index,
+   const char **props, unsigned int nprops)
+{
+   struct fwnode_reference_args fwnode_args;
+   unsigned int *args = fwnode_args.args;
+   struct fwnode_handle *child;
+   int ret;
+
+   ret = fwnode_property_get_reference_args(fwnode, prop, NULL, nprops,
+index, _args);
+   if (ret)
+   return ERR_PTR(ret == -EINVAL ? -ENOENT : ret);
+
+   for (fwnode = fwnode_args.fwnode;
+nprops; nprops--, fwnode = child, props++, args++) {
+   u32 val;
+
+   fwnode_for_each_child_node(fwnode, child) {
+   if (fwnode_property_read_u32(child, *props, ))
+   continue;
+
+   if (val == *args)
+   break;
+   }
+
+   fwnode_handle_put(fwnode);
+
+   if (!child) {
+   fwnode = ERR_PTR(-ENOENT);
+   break;
+   }
+   }
+
+   return fwnode;
+}
+
+static int v4l2_fwnode_reference_parse_int_props(
+   struct device *dev, struct v4l2_async_notifier *notifier,
+   const char *prop, const char **props, unsigned int nprops)
+{
+   struct fwnode_handle *fwnode;
+   unsigned int index = 0;
+   int ret;
+
+   while (!IS_ERR((fwnode = v4l2_fwnode_reference_get_int_prop(
+   dev_fwnode(dev), prop, index, props,
+   nprops {
+   fwnode_handle_put(fwnode);
+   index++;
+   }
+
+   if (PTR_ERR(fwnode) != -ENOENT)
+   return PTR_ERR(fwnode);
+
+   ret = v4l2_async_notifier_realloc(notifier,
+ notifier->num_subdevs + index);
+   if (ret)
+   return -ENOMEM;
+
+   for (index = 0; !IS_ERR((fwnode = v4l2_fwnode_reference_get_int_prop(
+dev_fwnode(dev), prop, index, props,
+nprops))); ) {
+   struct v4l2_async_subdev *asd;
+
+   if (WARN_ON(notifier->num_subdevs >= notifier->max_subdevs)) {
+   ret = -EINVAL;
+   goto error;
+   }
+
+   asd = kzalloc(sizeof(struct v4l2_async_subdev), GFP_KERNEL);
+   if (!asd) {
+   ret = -ENOMEM;
+   goto error;
+   }
+
+   notifier->subdevs[notifier->num_subdevs] = asd;
+   asd->match.fwnode.fwnode = fwnode;
+   asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
+   notifier->num_subdevs++;
+
+   fwnode_handle_put(fwnode);
+
+   index++;
+   }
+
+   return PTR_ERR(fwnode) == -ENOENT ? 0 : PTR_ERR(fwnode);
+
+error:
+   fwnode_handle_put(fwnode);
+   return ret;
+}
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Sakari Ailus ");
 MODULE_AUTHOR("Sylwester Nawrocki ");
-- 
2.11.0



[PATCH v9 16/24] dt: bindings: Add lens-focus binding for image sensors

2017-09-08 Thread Sakari Ailus
The lens-focus property contains a phandle to the lens voice coil driver
that is associated to the sensor; typically both are contained in the same
camera module.

Signed-off-by: Sakari Ailus 
Acked-by: Pavel Machek 
Reviewed-by: Sebastian Reichel 
Acked-by: Rob Herring 
Acked-by: Hans Verkuil 
---
 Documentation/devicetree/bindings/media/video-interfaces.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt 
b/Documentation/devicetree/bindings/media/video-interfaces.txt
index fdba30479b47..b535bdde861c 100644
--- a/Documentation/devicetree/bindings/media/video-interfaces.txt
+++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
@@ -74,6 +74,8 @@ Optional properties
 - flash-leds: An array of phandles, each referring to a flash LED, a sub-node
   of the LED driver device node.
 
+- lens-focus: A phandle to the node of the focus lens controller.
+
 
 Optional endpoint properties
 
-- 
2.11.0



[PATCH v9 15/24] dt: bindings: Add a binding for flash LED devices associated to a sensor

2017-09-08 Thread Sakari Ailus
Camera flash drivers (and LEDs) are separate from the sensor devices in
DT. In order to make an association between the two, provide the
association information to the software.

Signed-off-by: Sakari Ailus 
Acked-by: Rob Herring 
Acked-by: Hans Verkuil 
---
 Documentation/devicetree/bindings/media/video-interfaces.txt | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt 
b/Documentation/devicetree/bindings/media/video-interfaces.txt
index 852041a7480c..fdba30479b47 100644
--- a/Documentation/devicetree/bindings/media/video-interfaces.txt
+++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
@@ -67,6 +67,14 @@ are required in a relevant parent node:
identifier, should be 1.
  - #size-cells: should be zero.
 
+
+Optional properties
+---
+
+- flash-leds: An array of phandles, each referring to a flash LED, a sub-node
+  of the LED driver device node.
+
+
 Optional endpoint properties
 
 
-- 
2.11.0



[PATCH v9 13/24] v4l: async: Allow async notifier register call succeed with no subdevs

2017-09-08 Thread Sakari Ailus
The information on how many async sub-devices would be bindable to a
notifier is typically dependent on information from platform firmware and
it's not driver's business to be aware of that.

Many V4L2 main drivers are perfectly usable (and useful) without async
sub-devices and so if there aren't any around, just proceed call the
notifier's complete callback immediately without registering the notifier
itself.

If a driver needs to check whether there are async sub-devices available,
it can be done by inspecting the notifier's num_subdevs field which tells
the number of async sub-devices.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 7b396ff4302b..9ebc2e079d03 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -170,10 +170,12 @@ int v4l2_async_notifier_register(struct v4l2_device 
*v4l2_dev,
struct v4l2_async_subdev *asd;
int i;
 
-   if (!v4l2_dev || !notifier->num_subdevs ||
-   notifier->num_subdevs > V4L2_MAX_SUBDEVS)
+   if (!v4l2_dev || notifier->num_subdevs > V4L2_MAX_SUBDEVS)
return -EINVAL;
 
+   if (!notifier->num_subdevs)
+   return v4l2_async_notifier_call_complete(notifier);
+
notifier->v4l2_dev = v4l2_dev;
INIT_LIST_HEAD(>waiting);
INIT_LIST_HEAD(>done);
-- 
2.11.0



[PATCH v9 24/24] arm: dts: omap3: N9/N950: Add flash references to the camera

2017-09-08 Thread Sakari Ailus
Add flash and indicator LED phandles to the sensor node.

Signed-off-by: Sakari Ailus 
---
 arch/arm/boot/dts/omap3-n9.dts   | 1 +
 arch/arm/boot/dts/omap3-n950-n9.dtsi | 4 ++--
 arch/arm/boot/dts/omap3-n950.dts | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-n9.dts b/arch/arm/boot/dts/omap3-n9.dts
index b9e58c536afd..39e35f8b8206 100644
--- a/arch/arm/boot/dts/omap3-n9.dts
+++ b/arch/arm/boot/dts/omap3-n9.dts
@@ -26,6 +26,7 @@
clocks = < 0>;
clock-frequency = <960>;
nokia,nvm-size = <(16 * 64)>;
+   flash-leds = <_flash _indicator>;
port {
smia_1_1: endpoint {
link-frequencies = /bits/ 64 <19920 
21000 49920>;
diff --git a/arch/arm/boot/dts/omap3-n950-n9.dtsi 
b/arch/arm/boot/dts/omap3-n950-n9.dtsi
index 1b0bd72945f2..12fbb3da5fce 100644
--- a/arch/arm/boot/dts/omap3-n950-n9.dtsi
+++ b/arch/arm/boot/dts/omap3-n950-n9.dtsi
@@ -271,14 +271,14 @@
#size-cells = <0>;
reg = <0x30>;
compatible = "ams,as3645a";
-   flash@0 {
+   as3645a_flash: flash@0 {
reg = <0x0>;
flash-timeout-us = <15>;
flash-max-microamp = <32>;
led-max-microamp = <6>;
ams,input-max-microamp = <175>;
};
-   indicator@1 {
+   as3645a_indicator: indicator@1 {
reg = <0x1>;
led-max-microamp = <1>;
};
diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts
index 646601a3ebd8..c354a1ed1e70 100644
--- a/arch/arm/boot/dts/omap3-n950.dts
+++ b/arch/arm/boot/dts/omap3-n950.dts
@@ -60,6 +60,7 @@
clocks = < 0>;
clock-frequency = <960>;
nokia,nvm-size = <(16 * 64)>;
+   flash-leds = <_flash _indicator>;
port {
smia_1_1: endpoint {
link-frequencies = /bits/ 64 <21000 
33360 39840>;
-- 
2.11.0



[PATCH v9 08/24] omap3isp: Fix check for our own sub-devices

2017-09-08 Thread Sakari Ailus
We only want to link sub-devices that were bound to the async notifier the
isp driver registered but there may be other sub-devices in the
v4l2_device as well. Check for the correct async notifier.

Signed-off-by: Sakari Ailus 
Acked-by: Hans Verkuil 
---
 drivers/media/platform/omap3isp/isp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index a546cf774d40..3b1a9cd0e591 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -2155,7 +2155,7 @@ static int isp_subdev_notifier_complete(struct 
v4l2_async_notifier *async)
return ret;
 
list_for_each_entry(sd, _dev->subdevs, list) {
-   if (!sd->asd)
+   if (sd->notifier != >notifier)
continue;
 
ret = isp_link_entity(isp, >entity,
-- 
2.11.0



[PATCH v9 17/24] ACPI: Document how to refer to LEDs from remote nodes

2017-09-08 Thread Sakari Ailus
Document referring to LEDs from remote device nodes, such as from camera
sensors.

Signed-off-by: Sakari Ailus 
---
 Documentation/acpi/dsd/leds.txt | 92 +
 1 file changed, 92 insertions(+)
 create mode 100644 Documentation/acpi/dsd/leds.txt

diff --git a/Documentation/acpi/dsd/leds.txt b/Documentation/acpi/dsd/leds.txt
new file mode 100644
index ..6217fcda15c9
--- /dev/null
+++ b/Documentation/acpi/dsd/leds.txt
@@ -0,0 +1,92 @@
+Describing and referring to LEDs in ACPI
+
+Individual LEDs are described by hierarchical data extension [6] nodes
+under the device node, the LED driver chip. The "led" property in the
+LED specific nodes tells the numerical ID of each individual LED. The
+"led" property is used here in a similar fashion as the "reg" property
+in DT. [3]
+
+Referring to LEDs in Devicetree is documented in [4], in "flash-leds"
+property documentation. In short, LEDs are directly referred to by
+using phandles.
+
+While Devicetree allows referring to any node in the tree[1], in ACPI
+references are limited to device nodes only [2]. For this reason using
+the same mechanism on ACPI is not possible.
+
+ACPI allows (as does DT) using integer arguments after the reference.
+A combination of the LED driver device reference and an integer
+argument, referring to the "led" property of the relevant LED, are
+use to individual LEDs. The value of the LED property is a contract
+between the firmware and software, it uniquely identifies the LED
+driver outputs.
+
+An ASL example of a camera sensor device and a LED driver device for
+two LEDs:
+
+   Device (LED)
+   {
+   Name ((_DSD), Package () {
+   ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
+   Package () {
+   Package () { "led0", "LED0" },
+   Package () { "led1", "LED1" },
+   }
+   })
+   Name ((LED0), Package () {
+   ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+   Package () {
+   Package () { "led", 0 },
+   Package () { "flash-max-microamp", 100 },
+   Package () { "led-max-microamp", 10 },
+   Package () { "label", "led:salama" },
+   }
+   })
+   Name ((LED1), Package () {
+   ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+   Package () {
+   Package () { "led", 1 },
+   Package () { "led-max-microamp", 1 },
+   Package () { "label", "led:huomiovalo" },
+   }
+   })
+   }
+
+   Device (SEN)
+   {
+   Name ((_DSD), Package () {
+   ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+   Package () {
+   Package () {
+   "flash-leds",
+   Package () { \\LED, 0, \\LED, 1 },
+   }
+   }
+   })
+   }
+
+where
+
+   LED LED driver device
+   LED0First LED
+   LED1Second LED
+   SEN Camera sensor device (or another device the LED is
+   related to)
+
+[1] Devicetree. , referenced 2016-10-03.
+
+[2] Advanced Configuration and Power Interface Specification.
+,
+referenced 2016-10-04.
+
+[3] Documentation/devicetree/bindings/leds/common.txt
+
+[4] Documentation/devicetree/bindings/media/video-interfaces.txt
+
+[5] Device Properties UUID For _DSD.
+
,
+referenced 2016-10-04.
+
+[6] Hierarchical Data Extension UUID For _DSD.
+
,
+referenced 2016-10-04.
-- 
2.11.0



[PATCH v9 19/24] v4l: fwnode: Add a helper function for parsing generic references

2017-09-08 Thread Sakari Ailus
Add function v4l2_fwnode_reference_count() for counting external
references and v4l2_fwnode_reference_parse() for parsing them as async
sub-devices.

This can be done on e.g. flash or lens async sub-devices that are not part
of but are associated with a sensor.

struct v4l2_async_notifier.max_subdevs field is added to contain the
maximum number of sub-devices in a notifier to reflect the memory
allocated for the subdevs array.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 47 +++
 1 file changed, 47 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index d978f2d714ca..4821c4989119 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -449,6 +449,53 @@ int v4l2_async_notifier_parse_fwnode_endpoints(
 }
 EXPORT_SYMBOL_GPL(v4l2_async_notifier_parse_fwnode_endpoints);
 
+static int v4l2_fwnode_reference_parse(
+   struct device *dev, struct v4l2_async_notifier *notifier,
+   const char *prop)
+{
+   struct fwnode_reference_args args;
+   unsigned int index = 0;
+   int ret;
+
+   for (; !fwnode_property_get_reference_args(
+dev_fwnode(dev), prop, NULL, 0, index, ); index++)
+   fwnode_handle_put(args.fwnode);
+
+   ret = v4l2_async_notifier_realloc(notifier,
+ notifier->num_subdevs + index);
+   if (ret)
+   return -ENOMEM;
+
+   for (ret = -ENOENT, index = 0;
+!fwnode_property_get_reference_args(
+dev_fwnode(dev), prop, NULL, 0, index, );
+index++) {
+   struct v4l2_async_subdev *asd;
+
+   if (WARN_ON(notifier->num_subdevs >= notifier->max_subdevs)) {
+   ret = -EINVAL;
+   goto error;
+   }
+
+   asd = kzalloc(sizeof(*asd), GFP_KERNEL);
+   if (!asd) {
+   ret = -ENOMEM;
+   goto error;
+   }
+
+   notifier->subdevs[notifier->num_subdevs] = asd;
+   asd->match.fwnode.fwnode = args.fwnode;
+   asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
+   notifier->num_subdevs++;
+   }
+
+   return 0;
+
+error:
+   fwnode_handle_put(args.fwnode);
+   return ret;
+}
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Sakari Ailus ");
 MODULE_AUTHOR("Sylwester Nawrocki ");
-- 
2.11.0



[PATCH v9 14/24] v4l: async: Allow binding notifiers to sub-devices

2017-09-08 Thread Sakari Ailus
Registering a notifier has required the knowledge of struct v4l2_device
for the reason that sub-devices generally are registered to the
v4l2_device (as well as the media device, also available through
v4l2_device).

This information is not available for sub-device drivers at probe time.

What this patch does is that it allows registering notifiers without
having v4l2_device around. Instead the sub-device pointer is stored in the
notifier. Once the sub-device of the driver that registered the notifier
is registered, the notifier will gain the knowledge of the v4l2_device,
and the binding of async sub-devices from the sub-device driver's notifier
may proceed.

The root notifier's complete callback is only called when all sub-device
notifiers are completed.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c | 217 ++-
 include/media/v4l2-async.h   |  16 ++-
 2 files changed, 202 insertions(+), 31 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 9ebc2e079d03..6f788b2e922a 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -53,6 +53,10 @@ static int v4l2_async_notifier_call_complete(struct 
v4l2_async_notifier *n)
return n->ops->complete(n);
 }
 
+static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,
+  struct v4l2_subdev *sd,
+  struct v4l2_async_subdev *asd);
+
 static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
 #if IS_ENABLED(CONFIG_I2C)
@@ -124,14 +128,128 @@ static struct v4l2_async_subdev *v4l2_async_find_match(
return NULL;
 }
 
+/* Get the sub-device notifier registered by a sub-device driver. */
+static struct v4l2_async_notifier *v4l2_async_get_subdev_notifier(
+   struct v4l2_subdev *sd)
+{
+   struct v4l2_async_notifier *n;
+
+   list_for_each_entry(n, _list, list)
+   if (n->sd == sd)
+   return n;
+
+   return NULL;
+}
+
+/* Return true if all sub-device notifiers are complete, false otherwise. */
+static bool v4l2_async_subdev_notifiers_complete(
+   struct v4l2_async_notifier *notifier)
+{
+   struct v4l2_subdev *sd;
+
+   if (!list_empty(>waiting))
+   return false;
+
+   list_for_each_entry(sd, >done, async_list) {
+   struct v4l2_async_notifier *subdev_notifier =
+   v4l2_async_get_subdev_notifier(sd);
+
+   if (!subdev_notifier)
+   continue;
+
+   if (!v4l2_async_subdev_notifiers_complete(subdev_notifier))
+   return false;
+   }
+
+   return true;
+}
+
+/* Get v4l2_device related to the notifier if one can be found. */
+static struct v4l2_device *v4l2_async_notifier_get_v4l2_dev(
+   struct v4l2_async_notifier *notifier)
+{
+   while (notifier->parent)
+   notifier = notifier->parent;
+
+   return notifier->v4l2_dev;
+}
+
+/* Test all async sub-devices in a notifier for a match. */
+static int v4l2_async_notifier_try_all_subdevs(
+   struct v4l2_async_notifier *notifier)
+{
+   struct v4l2_subdev *sd;
+
+   if (!v4l2_async_notifier_get_v4l2_dev(notifier))
+   return 0;
+
+again:
+   list_for_each_entry(sd, _list, async_list) {
+   struct v4l2_async_subdev *asd;
+   int ret;
+
+   asd = v4l2_async_find_match(notifier, sd);
+   if (!asd)
+   continue;
+
+   ret = v4l2_async_match_notify(notifier, sd, asd);
+   if (ret < 0)
+   return ret;
+
+   /*
+* v4l2_async_match_notify() may lead to registering a
+* new notifier and thus changing the async subdevs
+* list. In order to proceed safely from here, restart
+* parsing the list from the beginning.
+*/
+   goto again;
+   }
+
+   return 0;
+}
+
+/* Try completing a notifier. */
+static int v4l2_async_notifier_try_complete(
+   struct v4l2_async_notifier *notifier)
+{
+   do {
+   int ret;
+
+   /* Any local async sub-devices left? */
+   if (!list_empty(>waiting))
+   return 0;
+
+   /*
+* Any sub-device notifiers waiting for async subdevs
+* to be bound?
+*/
+   if (!v4l2_async_subdev_notifiers_complete(notifier))
+   return 0;
+
+   /* Proceed completing the notifier */
+   ret = v4l2_async_notifier_call_complete(notifier);
+   if (ret < 0)
+   return ret;
+
+   /*
+* Obtain notifier's parent. If there is one, repeat
+* the 

[PATCH v9 23/24] dt: bindings: smiapp: Document lens-focus and flash properties

2017-09-08 Thread Sakari Ailus
Document optional lens-focus and flash properties for the smiapp driver.

Signed-off-by: Sakari Ailus 
---
 Documentation/devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt 
b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
index 855e1faf73e2..a052969365d9 100644
--- a/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
+++ b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
@@ -27,6 +27,8 @@ Optional properties
 - nokia,nvm-size: The size of the NVM, in bytes. If the size is not given,
   the NVM contents will not be read.
 - reset-gpios: XSHUTDOWN GPIO
+- flash-leds: One or more phandles to refer to flash LEDs
+- lens-focus: Phandle for lens focus
 
 
 Endpoint node mandatory properties
-- 
2.11.0



[PATCH v9 09/24] omap3isp: Print the name of the entity where no source pads could be found

2017-09-08 Thread Sakari Ailus
If no source pads are found in an entity, print the name of the entity.

Signed-off-by: Sakari Ailus 
Acked-by: Hans Verkuil 
---
 drivers/media/platform/omap3isp/isp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index 3b1a9cd0e591..9a694924e46e 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1669,8 +1669,8 @@ static int isp_link_entity(
break;
}
if (i == entity->num_pads) {
-   dev_err(isp->dev, "%s: no source pad in external entity\n",
-   __func__);
+   dev_err(isp->dev, "%s: no source pad in external entity %s\n",
+   __func__, entity->name);
return -EINVAL;
}
 
-- 
2.11.0



[PATCH v9 22/24] smiapp: Add support for flash and lens devices

2017-09-08 Thread Sakari Ailus
Parse async sub-devices by using
v4l2_subdev_fwnode_reference_parse_sensor_common().

These types devices aren't directly related to the sensor, but are
nevertheless handled by the smiapp driver due to the relationship of these
component to the main part of the camera module --- the sensor.

This does not yet address providing the user space with information on how
to associate the sensor or lens devices but the kernel now has the
necessary information to do that.

Signed-off-by: Sakari Ailus 
---
 drivers/media/i2c/smiapp/smiapp-core.c | 18 --
 drivers/media/i2c/smiapp/smiapp.h  |  4 +++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 700f433261d0..2a7cf430270c 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -31,7 +31,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -2887,6 +2887,11 @@ static int smiapp_probe(struct i2c_client *client,
v4l2_i2c_subdev_init(>src->sd, client, _ops);
sensor->src->sd.internal_ops = _internal_src_ops;
 
+   rval = v4l2_fwnode_reference_parse_sensor_common(
+   >dev, >notifier);
+   if (rval < 0 && rval != -ENOENT)
+   return rval;
+
sensor->vana = devm_regulator_get(>dev, "vana");
if (IS_ERR(sensor->vana)) {
dev_err(>dev, "could not get regulator for vana\n");
@@ -3092,9 +3097,14 @@ static int smiapp_probe(struct i2c_client *client,
if (rval < 0)
goto out_media_entity_cleanup;
 
+   rval = v4l2_async_subdev_notifier_register(>src->sd,
+  >notifier);
+   if (rval)
+   goto out_media_entity_cleanup;
+
rval = v4l2_async_register_subdev(>src->sd);
if (rval < 0)
-   goto out_media_entity_cleanup;
+   goto out_unregister_async_notifier;
 
pm_runtime_set_active(>dev);
pm_runtime_get_noresume(>dev);
@@ -3105,6 +3115,9 @@ static int smiapp_probe(struct i2c_client *client,
 
return 0;
 
+out_unregister_async_notifier:
+   v4l2_async_notifier_unregister(>notifier);
+
 out_media_entity_cleanup:
media_entity_cleanup(>src->sd.entity);
 
@@ -3124,6 +3137,7 @@ static int smiapp_remove(struct i2c_client *client)
unsigned int i;
 
v4l2_async_unregister_subdev(subdev);
+   v4l2_async_notifier_unregister(>notifier);
 
pm_runtime_disable(>dev);
if (!pm_runtime_status_suspended(>dev))
diff --git a/drivers/media/i2c/smiapp/smiapp.h 
b/drivers/media/i2c/smiapp/smiapp.h
index f74d695018b9..be92cb5713f4 100644
--- a/drivers/media/i2c/smiapp/smiapp.h
+++ b/drivers/media/i2c/smiapp/smiapp.h
@@ -20,9 +20,10 @@
 #define __SMIAPP_PRIV_H_
 
 #include 
+#include 
+#include 
 #include 
 #include 
-#include 
 
 #include "smiapp-pll.h"
 #include "smiapp-reg.h"
@@ -172,6 +173,7 @@ struct smiapp_subdev {
  * struct smiapp_sensor - Main device structure
  */
 struct smiapp_sensor {
+   struct v4l2_async_notifier notifier;
/*
 * "mutex" is used to serialise access to all fields here
 * except v4l2_ctrls at the end of the struct. "mutex" is also
-- 
2.11.0



[PATCH v9 21/24] v4l: fwnode: Add convenience function for parsing common external refs

2017-09-08 Thread Sakari Ailus
Add v4l2_fwnode_parse_reference_sensor_common for parsing common
sensor properties that refer to adjacent devices such as flash or lens
driver chips.

As this is an association only, there's little a regular driver needs to
know about these devices as such.

Signed-off-by: Sakari Ailus 
Acked-by: Hans Verkuil 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 35 +++
 include/media/v4l2-fwnode.h   | 13 +
 2 files changed, 48 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 56eee5bbd3b5..b9e60a0e8f86 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -589,6 +589,41 @@ static int v4l2_fwnode_reference_parse_int_props(
return ret;
 }
 
+int v4l2_fwnode_reference_parse_sensor_common(
+   struct device *dev, struct v4l2_async_notifier *notifier)
+{
+   static const char *led_props[] = { "led" };
+   static const struct {
+   const char *name;
+   const char **props;
+   unsigned int nprops;
+   } props[] = {
+   { "flash-leds", led_props, ARRAY_SIZE(led_props) },
+   { "lens-focus", NULL, 0 },
+   };
+   unsigned int i;
+
+   for (i = 0; i < ARRAY_SIZE(props); i++) {
+   int ret;
+
+   if (props[i].props && is_acpi_node(dev_fwnode(dev)))
+   ret = v4l2_fwnode_reference_parse_int_props(
+   dev, notifier, props[i].name,
+   props[i].props, props[i].nprops);
+   else
+   ret = v4l2_fwnode_reference_parse(
+   dev, notifier, props[i].name);
+   if (ret) {
+   dev_warn(dev, "parsing property \"%s\" failed (%d)\n",
+props[i].name, ret);
+   return ret;
+   }
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_fwnode_reference_parse_sensor_common);
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Sakari Ailus ");
 MODULE_AUTHOR("Sylwester Nawrocki ");
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index 3819a73c3c8a..bcec1ce101dc 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -257,4 +257,17 @@ int v4l2_async_notifier_parse_fwnode_endpoints(
  struct v4l2_fwnode_endpoint *vep,
  struct v4l2_async_subdev *asd));
 
+/**
+ * v4l2_fwnode_reference_parse_sensor_common - parse common references on
+ *sensors for async sub-devices
+ * @dev: the device node the properties of which are parsed for references
+ * @notifier: the async notifier where the async subdevs will be added
+ *
+ * Return: 0 on success
+ *-ENOMEM if memory allocation failed
+ *-EINVAL if property parsing failed
+ */
+int v4l2_fwnode_reference_parse_sensor_common(
+   struct device *dev, struct v4l2_async_notifier *notifier);
+
 #endif /* _V4L2_FWNODE_H */
-- 
2.11.0



[PATCH v9 07/24] rcar-vin: Use generic parser for parsing fwnode endpoints

2017-09-08 Thread Sakari Ailus
Instead of using driver implementation, use
v4l2_async_notifier_parse_fwnode_endpoints() to parse the fwnode endpoints
of the device.

Signed-off-by: Sakari Ailus 
Acked-by: Hans Verkuil 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 112 +---
 drivers/media/platform/rcar-vin/rcar-dma.c  |  10 +--
 drivers/media/platform/rcar-vin/rcar-v4l2.c |  14 ++--
 drivers/media/platform/rcar-vin/rcar-vin.h  |   4 +-
 4 files changed, 48 insertions(+), 92 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index 142de447..62b4a94f9a39 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 #include "rcar-vin.h"
@@ -77,14 +78,14 @@ static int rvin_digital_notify_complete(struct 
v4l2_async_notifier *notifier)
int ret;
 
/* Verify subdevices mbus format */
-   if (!rvin_mbus_supported(>digital)) {
+   if (!rvin_mbus_supported(vin->digital)) {
vin_err(vin, "Unsupported media bus format for %s\n",
-   vin->digital.subdev->name);
+   vin->digital->subdev->name);
return -EINVAL;
}
 
vin_dbg(vin, "Found media bus format for %s: %d\n",
-   vin->digital.subdev->name, vin->digital.code);
+   vin->digital->subdev->name, vin->digital->code);
 
ret = v4l2_device_register_subdev_nodes(>v4l2_dev);
if (ret < 0) {
@@ -103,7 +104,7 @@ static void rvin_digital_notify_unbind(struct 
v4l2_async_notifier *notifier,
 
vin_dbg(vin, "unbind digital subdev %s\n", subdev->name);
rvin_v4l2_remove(vin);
-   vin->digital.subdev = NULL;
+   vin->digital->subdev = NULL;
 }
 
 static int rvin_digital_notify_bound(struct v4l2_async_notifier *notifier,
@@ -120,117 +121,70 @@ static int rvin_digital_notify_bound(struct 
v4l2_async_notifier *notifier,
ret = rvin_find_pad(subdev, MEDIA_PAD_FL_SOURCE);
if (ret < 0)
return ret;
-   vin->digital.source_pad = ret;
+   vin->digital->source_pad = ret;
 
ret = rvin_find_pad(subdev, MEDIA_PAD_FL_SINK);
-   vin->digital.sink_pad = ret < 0 ? 0 : ret;
+   vin->digital->sink_pad = ret < 0 ? 0 : ret;
 
-   vin->digital.subdev = subdev;
+   vin->digital->subdev = subdev;
 
vin_dbg(vin, "bound subdev %s source pad: %u sink pad: %u\n",
-   subdev->name, vin->digital.source_pad,
-   vin->digital.sink_pad);
+   subdev->name, vin->digital->source_pad,
+   vin->digital->sink_pad);
 
return 0;
 }
 
-static int rvin_digitial_parse_v4l2(struct rvin_dev *vin,
-   struct device_node *ep,
-   struct v4l2_mbus_config *mbus_cfg)
+static int rvin_digital_parse_v4l2(struct device *dev,
+  struct v4l2_fwnode_endpoint *vep,
+  struct v4l2_async_subdev *asd)
 {
-   struct v4l2_fwnode_endpoint v4l2_ep;
-   int ret;
+   struct rvin_dev *vin = dev_get_drvdata(dev);
+   struct rvin_graph_entity *rvge =
+   container_of(asd, struct rvin_graph_entity, asd);
 
-   ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), _ep);
-   if (ret) {
-   vin_err(vin, "Could not parse v4l2 endpoint\n");
-   return -EINVAL;
-   }
+   if (vep->base.port || vep->base.id)
+   return -ENOTCONN;
 
-   mbus_cfg->type = v4l2_ep.bus_type;
+   rvge->mbus_cfg.type = vep->bus_type;
 
-   switch (mbus_cfg->type) {
+   switch (rvge->mbus_cfg.type) {
case V4L2_MBUS_PARALLEL:
vin_dbg(vin, "Found PARALLEL media bus\n");
-   mbus_cfg->flags = v4l2_ep.bus.parallel.flags;
+   rvge->mbus_cfg.flags = vep->bus.parallel.flags;
break;
case V4L2_MBUS_BT656:
vin_dbg(vin, "Found BT656 media bus\n");
-   mbus_cfg->flags = 0;
+   rvge->mbus_cfg.flags = 0;
break;
default:
vin_err(vin, "Unknown media bus type\n");
return -EINVAL;
}
 
-   return 0;
-}
-
-static int rvin_digital_graph_parse(struct rvin_dev *vin)
-{
-   struct device_node *ep, *np;
-   int ret;
-
-   vin->digital.asd.match.fwnode.fwnode = NULL;
-   vin->digital.subdev = NULL;
-
-   /*
-* Port 0 id 0 is local digital input, try to get it.
-* Not all instances can or will have this, that is OK
-*/
-   ep = of_graph_get_endpoint_by_regs(vin->dev->of_node, 0, 0);
-   if (!ep)
-   return 0;
-
-   np = of_graph_get_remote_port_parent(ep);
-   if (!np) {
-   vin_err(vin, "No remote parent 

[PATCH v9 18/24] as3645a: Switch to fwnode property API

2017-09-08 Thread Sakari Ailus
Switch the as3645a from OF to the fwnode property API. Also add ACPI
support.

Signed-off-by: Sakari Ailus 
---
 drivers/leds/leds-as3645a.c | 81 +
 1 file changed, 46 insertions(+), 35 deletions(-)

diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
index 605e0c64e974..2e73c3f818f1 100644
--- a/drivers/leds/leds-as3645a.c
+++ b/drivers/leds/leds-as3645a.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #include 
@@ -148,8 +148,8 @@ struct as3645a {
struct v4l2_flash *vf;
struct v4l2_flash *vfind;
 
-   struct device_node *flash_node;
-   struct device_node *indicator_node;
+   struct fwnode_handle *flash_node;
+   struct fwnode_handle *indicator_node;
 
struct as3645a_config cfg;
 
@@ -492,30 +492,33 @@ static int as3645a_detect(struct as3645a *flash)
 
 static int as3645a_parse_node(struct as3645a *flash,
  struct as3645a_names *names,
- struct device_node *node)
+ struct fwnode_handle *fwnode)
 {
struct as3645a_config *cfg = >cfg;
-   struct device_node *child;
+   struct fwnode_handle *child;
const char *name;
+   const char *str;
int rval;
 
-   for_each_child_of_node(node, child) {
+   fwnode_for_each_child_node(fwnode, child) {
u32 id = 0;
 
-   of_property_read_u32(child, "reg", );
+   fwnode_property_read_u32(
+   child, is_of_node(child) ? "reg" : "led", );
 
switch (id) {
case AS_LED_FLASH:
-   flash->flash_node = of_node_get(child);
+   flash->flash_node = child;
break;
case AS_LED_INDICATOR:
-   flash->indicator_node = of_node_get(child);
+   flash->indicator_node = child;
break;
default:
dev_warn(>client->dev,
 "unknown LED %u encountered, ignoring\n", id);
break;
}
+   fwnode_handle_get(child);
}
 
if (!flash->flash_node) {
@@ -523,14 +526,18 @@ static int as3645a_parse_node(struct as3645a *flash,
return -ENODEV;
}
 
-   rval = of_property_read_string(flash->flash_node, "label", );
-   if (!rval)
+   rval = fwnode_property_read_string(flash->flash_node, "label", );
+   if (!rval) {
strlcpy(names->flash, name, sizeof(names->flash));
-   else
+   } else if (is_of_node(fwnode)) {
snprintf(names->flash, sizeof(names->flash),
-"%s:flash", node->name);
+"%s:flash", to_of_node(fwnode)->name);
+   } else {
+   dev_err(>client->dev, "flash node has no label!\n");
+   return -EINVAL;
+   }
 
-   rval = of_property_read_u32(flash->flash_node, "flash-timeout-us",
+   rval = fwnode_property_read_u32(flash->flash_node, "flash-timeout-us",
>flash_timeout_us);
if (rval < 0) {
dev_err(>client->dev,
@@ -538,7 +545,7 @@ static int as3645a_parse_node(struct as3645a *flash,
goto out_err;
}
 
-   rval = of_property_read_u32(flash->flash_node, "flash-max-microamp",
+   rval = fwnode_property_read_u32(flash->flash_node, "flash-max-microamp",
>flash_max_ua);
if (rval < 0) {
dev_err(>client->dev,
@@ -546,7 +553,7 @@ static int as3645a_parse_node(struct as3645a *flash,
goto out_err;
}
 
-   rval = of_property_read_u32(flash->flash_node, "led-max-microamp",
+   rval = fwnode_property_read_u32(flash->flash_node, "led-max-microamp",
>assist_max_ua);
if (rval < 0) {
dev_err(>client->dev,
@@ -554,10 +561,10 @@ static int as3645a_parse_node(struct as3645a *flash,
goto out_err;
}
 
-   of_property_read_u32(flash->flash_node, "voltage-reference",
+   fwnode_property_read_u32(flash->flash_node, "voltage-reference",
 >voltage_reference);
 
-   of_property_read_u32(flash->flash_node, "ams,input-max-microamp",
+   fwnode_property_read_u32(flash->flash_node, "ams,input-max-microamp",
 >peak);
cfg->peak = AS_PEAK_mA_TO_REG(cfg->peak);
 
@@ -567,14 +574,18 @@ static int as3645a_parse_node(struct as3645a *flash,
goto out_err;
}
 
-   rval = of_property_read_string(flash->indicator_node, "label", );
-   if (!rval)
+   rval = fwnode_property_read_string(flash->indicator_node, "label", 
);
+   if (!rval) {

Re: [PATCH 3/3] as3645a: Use integer numbers for parsing LEDs

2017-09-08 Thread Pavel Machek
On Fri 2017-09-08 15:42:13, Sakari Ailus wrote:
> Use integer numbers for LEDs, 0 is the flash and 1 is the indicator.
> 
> Signed-off-by: Sakari Ailus 

Dunno. Old code is shorter, old device tree is shorter, ... IMO both
versions are fine, because the LEDs are really different. Do we have
documentation somewhere saying that reg= should be used for this? Are
you doing this for consistency?

Best regards,
Pavel

>  arch/arm/boot/dts/omap3-n950-n9.dtsi |  8 ++--
>  drivers/leds/leds-as3645a.c  | 26 --


> @@ -267,15 +267,19 @@
>   clock-frequency = <40>;
>  
>   as3645a@30 {
> + #address-cells = <1>;
> + #size-cells = <0>;
>   reg = <0x30>;
>   compatible = "ams,as3645a";
> - flash {
> + flash@0 {
> + reg = <0x0>;
>   flash-timeout-us = <15>;
>   flash-max-microamp = <32>;
>   led-max-microamp = <6>;
>   ams,input-max-microamp = <175>;
>   };
> - indicator {
> + indicator@1 {
> + reg = <0x1>;
>   led-max-microamp = <1>;
>   };
>   };
> diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
> index e3f89c6130d2..605e0c64e974 100644
> --- a/drivers/leds/leds-as3645a.c
> +++ b/drivers/leds/leds-as3645a.c
> @@ -112,6 +112,10 @@
>  #define AS_PEAK_mA_TO_REG(a) \
>   ((min_t(u32, AS_PEAK_mA_MAX, a) - 1250) / 250)
>  
> +/* LED numbers for Devicetree */
> +#define AS_LED_FLASH 0
> +#define AS_LED_INDICATOR 1
> +
>  enum as_mode {
>   AS_MODE_EXT_TORCH = 0 << AS_CONTROL_MODE_SETTING_SHIFT,
>   AS_MODE_INDICATOR = 1 << AS_CONTROL_MODE_SETTING_SHIFT,
> @@ -491,10 +495,29 @@ static int as3645a_parse_node(struct as3645a *flash,
> struct device_node *node)
>  {
>   struct as3645a_config *cfg = >cfg;
> + struct device_node *child;
>   const char *name;
>   int rval;
>  
> - flash->flash_node = of_get_child_by_name(node, "flash");
> + for_each_child_of_node(node, child) {
> + u32 id = 0;
> +
> + of_property_read_u32(child, "reg", );
> +
> + switch (id) {
> + case AS_LED_FLASH:
> + flash->flash_node = of_node_get(child);
> + break;
> + case AS_LED_INDICATOR:
> + flash->indicator_node = of_node_get(child);
> + break;
> + default:
> + dev_warn(>client->dev,
> +  "unknown LED %u encountered, ignoring\n", id);
> + break;
> + }
> + }
> +
>   if (!flash->flash_node) {
>   dev_err(>client->dev, "can't find flash node\n");
>   return -ENODEV;
> @@ -538,7 +561,6 @@ static int as3645a_parse_node(struct as3645a *flash,
>>peak);
>   cfg->peak = AS_PEAK_mA_TO_REG(cfg->peak);
>  
> - flash->indicator_node = of_get_child_by_name(node, "indicator");
>   if (!flash->indicator_node) {
>   dev_warn(>client->dev,
>"can't find indicator node\n");

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH 1/3] as3645a: Use ams,input-max-microamp as documented in DT bindings

2017-09-08 Thread Pavel Machek
On Fri 2017-09-08 15:42:11, Sakari Ailus wrote:
> DT bindings document the property "ams,input-max-microamp" that limits the
> chip's maximum input current. The driver and the DTS however used
> "peak-current-limit" property. Fix this by using the property documented
> in DT binding documentation.
> 
> Signed-off-by: Sakari Ailus 

Acked-by: Pavel Machek 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


[PATCH v9 04/24] v4l: async: Add V4L2 async documentation to the documentation build

2017-09-08 Thread Sakari Ailus
The V4L2 async wasn't part of the documentation build. Fix this.

Signed-off-by: Sakari Ailus 
Reviewed-by: Niklas Söderlund 
Acked-by: Hans Verkuil 
---
 Documentation/media/kapi/v4l2-async.rst | 3 +++
 Documentation/media/kapi/v4l2-core.rst  | 1 +
 2 files changed, 4 insertions(+)
 create mode 100644 Documentation/media/kapi/v4l2-async.rst

diff --git a/Documentation/media/kapi/v4l2-async.rst 
b/Documentation/media/kapi/v4l2-async.rst
new file mode 100644
index ..523ff9eb09a0
--- /dev/null
+++ b/Documentation/media/kapi/v4l2-async.rst
@@ -0,0 +1,3 @@
+V4L2 async kAPI
+^^^
+.. kernel-doc:: include/media/v4l2-async.h
diff --git a/Documentation/media/kapi/v4l2-core.rst 
b/Documentation/media/kapi/v4l2-core.rst
index c7434f38fd9c..5cf292037a48 100644
--- a/Documentation/media/kapi/v4l2-core.rst
+++ b/Documentation/media/kapi/v4l2-core.rst
@@ -19,6 +19,7 @@ Video4Linux devices
 v4l2-mc
 v4l2-mediabus
 v4l2-mem2mem
+v4l2-async
 v4l2-fwnode
 v4l2-rect
 v4l2-tuner
-- 
2.11.0



[PATCH v9 00/23] Unified fwnode endpoint parser, async sub-device notifier support, N9 flash DTS

2017-09-08 Thread Sakari Ailus
Hi folks,

We have a large influx of new, unmerged, drivers that are now parsing
fwnode endpoints and each one of them is doing this a little bit
differently. The needs are still exactly the same for the graph data
structure is device independent. This is still a non-trivial task and the
majority of the driver implementations are buggy, just buggy in different
ways.

Facilitate parsing endpoints by adding a convenience function for parsing
the endpoints, and make the omap3isp and rcar-vin drivers use them as an
example.

To show where we're getting with this, I've added support for async
sub-device notifier support that is notifiers that can be registered by
sub-device drivers as well as V4L2 fwnode improvements to make use of them
and the DTS changes for the Nokia N9. Some of these patches I've posted
previously in this set here:



Since that, the complete callback of the master notifier registering the
V4L2 device is only called once all sub-notifiers have been completed as
well. This way the device node creation can be postponed until all devices
have been successfully initialised.

With this, the as3645a driver successfully registers a sub-device to the
media device created by the omap3isp driver. The kernel also has the
information it's related to the sensor driven by the smiapp driver but we
don't have a way to expose that information yet.

since v8:

- Improve terminology for notifiers. Instead of master / subdev, we
  have root, parent and subdev notifiers.

- Renamed "flash" property as "flash-leds". There are many, and currently
  we make assumptions in a lot of places (e.g. LED bindings) that these
  are LEDs. While we don't have any other types of flashes supported right
  now (e.g. Xenon), it's safer to assume we might have them in the future.

- Use ENOTCONN instead of EPERM to tell from driver's callback function
  that an endpoint is to be skipped but not handled as an error.

- Avoid accessing notifier's subdevs array as well as num_subdevs field
  from rcar-vin driver.

- Add a patch "v4l: async: Allow async notifier register call succeed with no
  subdevs", which allows, well, what the subject says.

- Move checks for subdev / v4l2_dev from __v4l2_async_notifier_register()
  to v4l2_async_notifier_register() and
  v4l2_async_subdev_notifier_register().

- Don't initialise notifier->list. There was no need to do so, as this is
  the entry added to the list and not used otherwise. I.e. regarding this,
  the state before this patchset is restored.

- Clean up error handling in v4l2_async_notifier_fwnode_parse_endpoint().

- WARN_ON() in v4l2_async_notifier_parse_fwnode_endpoints() if the
  asd_struct_size is smaller than size of struct v4l2_async_subdev.

- Make v4l2_fwnode_reference_parse() static as there should be no need to
  use it outside the V4L2 fwnode framework. Also, remove the callback
  function as well as other arguments that always have the same value in
  current usage. (This can be changed later on if needed without affecting
  drivers.)

- Add the patch "v4l: fwnode: Add a helper function to obtain device /
  interger references", which allows similar use than
  v4l2_fwnode_reference_parse() but is more useful on ACPI based systems
  --- on ACPI, you can only refer to device nodes (corresponding struct
  deice in Linux), not to data extension nodes under the devices.

- Improve v4l2_fwnode_reference_parse_sensor_common() to work on ACPI
  based systems.

- Add patch "ACPI: Document how to refer to LEDs from remote nodes" to
  document using and referring to LEDs on ACPI.

- Rebase the set on AS3645A fixes I just sent ("AS3645A fixes")

- In v4l2_fwnode_reference_parse_sensor_common(), tell if parsing a
  property failed.

- Improved documentation for v4l2_async_notifier_parse_fwnode_endpoints().

- Fix v4l2_async_notifier_try_all_subdevs(); it is allowed that the list
  entry being iterated over is deleted but no other changes to the list
  are allowed. This could be the case if a sub-device driver's notifier
  binds a sub-device. Restart the loop whenever a match is found.

- Add patch "as3645a: Switch to fwnode property API" which also adds ACPI
  support.

since v7:

- Added three more patches:

v4l: async: Remove re-probing support
v4l: async: Use more intuitive names for internal functions
dt: bindings: smiapp: Document lens-focus and flash properties

  The last one was already sent previously after the rest of the patchset.

- Removed re-probing support. This is hard to support and only useful in
  special cases. It can be reintroduced later on if there's really a need
  --- note that in e.g. omap3isp this was always broken and no-one ever
  complained.

- Remove smiapp driver's async complete callback (and ops). It is
  redundant: the sub-device nodes are created through the master notifier.

- Improve flash property documentation in video-interfaces.txt.

- Introduce helper 

[PATCH v9 01/24] v4l: fwnode: Move KernelDoc documentation to the header

2017-09-08 Thread Sakari Ailus
In V4L2 the practice is to have the KernelDoc documentation in the header
and not in .c source code files. This consequently makes the V4L2 fwnode
function documentation part of the Media documentation build.

Also correct the link related function and argument naming in
documentation.

Signed-off-by: Sakari Ailus 
Reviewed-by: Niklas Söderlund 
Acked-by: Hans Verkuil 
Acked-by: Pavel Machek 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 75 
 include/media/v4l2-fwnode.h   | 81 ++-
 2 files changed, 80 insertions(+), 76 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 40b2fbfe8865..706f9e7b90f1 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -181,25 +181,6 @@ v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle 
*fwnode,
vep->bus_type = V4L2_MBUS_CSI1;
 }
 
-/**
- * v4l2_fwnode_endpoint_parse() - parse all fwnode node properties
- * @fwnode: pointer to the endpoint's fwnode handle
- * @vep: pointer to the V4L2 fwnode data structure
- *
- * All properties are optional. If none are found, we don't set any flags. This
- * means the port has a static configuration and no properties have to be
- * specified explicitly. If any properties that identify the bus as parallel
- * are found and slave-mode isn't set, we set V4L2_MBUS_MASTER. Similarly, if
- * we recognise the bus as serial CSI-2 and clock-noncontinuous isn't set, we
- * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a
- * reference to @fwnode.
- *
- * NOTE: This function does not parse properties the size of which is variable
- * without a low fixed limit. Please use v4l2_fwnode_endpoint_alloc_parse() in
- * new drivers instead.
- *
- * Return: 0 on success or a negative error code on failure.
- */
 int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
   struct v4l2_fwnode_endpoint *vep)
 {
@@ -239,14 +220,6 @@ int v4l2_fwnode_endpoint_parse(struct fwnode_handle 
*fwnode,
 }
 EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_parse);
 
-/*
- * v4l2_fwnode_endpoint_free() - free the V4L2 fwnode acquired by
- * v4l2_fwnode_endpoint_alloc_parse()
- * @vep - the V4L2 fwnode the resources of which are to be released
- *
- * It is safe to call this function with NULL argument or on a V4L2 fwnode the
- * parsing of which failed.
- */
 void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep)
 {
if (IS_ERR_OR_NULL(vep))
@@ -257,29 +230,6 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint 
*vep)
 }
 EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_free);
 
-/**
- * v4l2_fwnode_endpoint_alloc_parse() - parse all fwnode node properties
- * @fwnode: pointer to the endpoint's fwnode handle
- *
- * All properties are optional. If none are found, we don't set any flags. This
- * means the port has a static configuration and no properties have to be
- * specified explicitly. If any properties that identify the bus as parallel
- * are found and slave-mode isn't set, we set V4L2_MBUS_MASTER. Similarly, if
- * we recognise the bus as serial CSI-2 and clock-noncontinuous isn't set, we
- * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a
- * reference to @fwnode.
- *
- * v4l2_fwnode_endpoint_alloc_parse() has two important differences to
- * v4l2_fwnode_endpoint_parse():
- *
- * 1. It also parses variable size data.
- *
- * 2. The memory it has allocated to store the variable size data must be freed
- *using v4l2_fwnode_endpoint_free() when no longer needed.
- *
- * Return: Pointer to v4l2_fwnode_endpoint if successful, on an error pointer
- * on error.
- */
 struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse(
struct fwnode_handle *fwnode)
 {
@@ -322,24 +272,6 @@ struct v4l2_fwnode_endpoint 
*v4l2_fwnode_endpoint_alloc_parse(
 }
 EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_alloc_parse);
 
-/**
- * v4l2_fwnode_endpoint_parse_link() - parse a link between two endpoints
- * @__fwnode: pointer to the endpoint's fwnode at the local end of the link
- * @link: pointer to the V4L2 fwnode link data structure
- *
- * Fill the link structure with the local and remote nodes and port numbers.
- * The local_node and remote_node fields are set to point to the local and
- * remote port's parent nodes respectively (the port parent node being the
- * parent node of the port node if that node isn't a 'ports' node, or the
- * grand-parent node of the port node otherwise).
- *
- * A reference is taken to both the local and remote nodes, the caller must use
- * v4l2_fwnode_endpoint_put_link() to drop the references when done with the
- * link.
- *
- * Return: 0 on success, or -ENOLINK if the remote endpoint fwnode can't be
- * found.
- */
 int v4l2_fwnode_parse_link(struct fwnode_handle 

[PATCH v9 03/24] v4l: async: Use more intuitive names for internal functions

2017-09-08 Thread Sakari Ailus
Rename internal functions to make the names of the functions better
describe what they do.

Old nameNew name
v4l2_async_test_notify  v4l2_async_match_notify
v4l2_async_belongs  v4l2_async_find_match

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index e109d9da4653..831f185ecd47 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -60,8 +60,8 @@ static LIST_HEAD(subdev_list);
 static LIST_HEAD(notifier_list);
 static DEFINE_MUTEX(list_lock);
 
-static struct v4l2_async_subdev *v4l2_async_belongs(struct v4l2_async_notifier 
*notifier,
-   struct v4l2_subdev *sd)
+static struct v4l2_async_subdev *v4l2_async_find_match(
+   struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd)
 {
bool (*match)(struct v4l2_subdev *, struct v4l2_async_subdev *);
struct v4l2_async_subdev *asd;
@@ -95,9 +95,9 @@ static struct v4l2_async_subdev *v4l2_async_belongs(struct 
v4l2_async_notifier *
return NULL;
 }
 
-static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
- struct v4l2_subdev *sd,
- struct v4l2_async_subdev *asd)
+static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,
+  struct v4l2_subdev *sd,
+  struct v4l2_async_subdev *asd)
 {
int ret;
 
@@ -175,11 +175,11 @@ int v4l2_async_notifier_register(struct v4l2_device 
*v4l2_dev,
list_for_each_entry_safe(sd, tmp, _list, async_list) {
int ret;
 
-   asd = v4l2_async_belongs(notifier, sd);
+   asd = v4l2_async_find_match(notifier, sd);
if (!asd)
continue;
 
-   ret = v4l2_async_test_notify(notifier, sd, asd);
+   ret = v4l2_async_match_notify(notifier, sd, asd);
if (ret < 0) {
mutex_unlock(_lock);
return ret;
@@ -236,9 +236,10 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd)
INIT_LIST_HEAD(>async_list);
 
list_for_each_entry(notifier, _list, list) {
-   struct v4l2_async_subdev *asd = v4l2_async_belongs(notifier, 
sd);
+   struct v4l2_async_subdev *asd = v4l2_async_find_match(notifier,
+ sd);
if (asd) {
-   int ret = v4l2_async_test_notify(notifier, sd, asd);
+   int ret = v4l2_async_match_notify(notifier, sd, asd);
mutex_unlock(_lock);
return ret;
}
-- 
2.11.0



[PATCH v9 02/24] v4l: async: Remove re-probing support

2017-09-08 Thread Sakari Ailus
Remove V4L2 async re-probing support. The re-probing support has been
there to support cases where the sub-devices require resources provided by
the main driver's hardware to function, such as clocks.

Reprobing has allowed unbinding and again binding the main driver without
explicilty unbinding the sub-device drivers. This is certainly not a
common need, and the responsibility will be the user's going forward.

An alternative could have been to introduce notifier specific locks.
Considering the complexity of the re-probing and that it isn't really a
solution to a problem but a workaround, remove re-probing instead.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-async.c | 54 
 1 file changed, 54 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index d741a8e0fdac..e109d9da4653 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -198,78 +198,24 @@ EXPORT_SYMBOL(v4l2_async_notifier_register);
 void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
 {
struct v4l2_subdev *sd, *tmp;
-   unsigned int notif_n_subdev = notifier->num_subdevs;
-   unsigned int n_subdev = min(notif_n_subdev, V4L2_MAX_SUBDEVS);
-   struct device **dev;
-   int i = 0;
 
if (!notifier->v4l2_dev)
return;
 
-   dev = kvmalloc_array(n_subdev, sizeof(*dev), GFP_KERNEL);
-   if (!dev) {
-   dev_err(notifier->v4l2_dev->dev,
-   "Failed to allocate device cache!\n");
-   }
-
mutex_lock(_lock);
 
list_del(>list);
 
list_for_each_entry_safe(sd, tmp, >done, async_list) {
-   struct device *d;
-
-   d = get_device(sd->dev);
-
v4l2_async_cleanup(sd);
 
-   /* If we handled USB devices, we'd have to lock the parent too 
*/
-   device_release_driver(d);
-
if (notifier->unbind)
notifier->unbind(notifier, sd, sd->asd);
-
-   /*
-* Store device at the device cache, in order to call
-* put_device() on the final step
-*/
-   if (dev)
-   dev[i++] = d;
-   else
-   put_device(d);
}
 
mutex_unlock(_lock);
 
-   /*
-* Call device_attach() to reprobe devices
-*
-* NOTE: If dev allocation fails, i is 0, and the whole loop won't be
-* executed.
-*/
-   while (i--) {
-   struct device *d = dev[i];
-
-   if (d && device_attach(d) < 0) {
-   const char *name = "(none)";
-   int lock = device_trylock(d);
-
-   if (lock && d->driver)
-   name = d->driver->name;
-   dev_err(d, "Failed to re-probe to %s\n", name);
-   if (lock)
-   device_unlock(d);
-   }
-   put_device(d);
-   }
-   kvfree(dev);
-
notifier->v4l2_dev = NULL;
-
-   /*
-* Don't care about the waiting list, it is initialised and populated
-* upon notifier registration.
-*/
 }
 EXPORT_SYMBOL(v4l2_async_notifier_unregister);
 
-- 
2.11.0



[PATCH 3/3] as3645a: Use integer numbers for parsing LEDs

2017-09-08 Thread Sakari Ailus
Use integer numbers for LEDs, 0 is the flash and 1 is the indicator.

Signed-off-by: Sakari Ailus 
---
 arch/arm/boot/dts/omap3-n950-n9.dtsi |  8 ++--
 drivers/leds/leds-as3645a.c  | 26 --
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-n950-n9.dtsi 
b/arch/arm/boot/dts/omap3-n950-n9.dtsi
index b86fc83a5a65..1b0bd72945f2 100644
--- a/arch/arm/boot/dts/omap3-n950-n9.dtsi
+++ b/arch/arm/boot/dts/omap3-n950-n9.dtsi
@@ -267,15 +267,19 @@
clock-frequency = <40>;
 
as3645a@30 {
+   #address-cells = <1>;
+   #size-cells = <0>;
reg = <0x30>;
compatible = "ams,as3645a";
-   flash {
+   flash@0 {
+   reg = <0x0>;
flash-timeout-us = <15>;
flash-max-microamp = <32>;
led-max-microamp = <6>;
ams,input-max-microamp = <175>;
};
-   indicator {
+   indicator@1 {
+   reg = <0x1>;
led-max-microamp = <1>;
};
};
diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
index e3f89c6130d2..605e0c64e974 100644
--- a/drivers/leds/leds-as3645a.c
+++ b/drivers/leds/leds-as3645a.c
@@ -112,6 +112,10 @@
 #define AS_PEAK_mA_TO_REG(a) \
((min_t(u32, AS_PEAK_mA_MAX, a) - 1250) / 250)
 
+/* LED numbers for Devicetree */
+#define AS_LED_FLASH   0
+#define AS_LED_INDICATOR   1
+
 enum as_mode {
AS_MODE_EXT_TORCH = 0 << AS_CONTROL_MODE_SETTING_SHIFT,
AS_MODE_INDICATOR = 1 << AS_CONTROL_MODE_SETTING_SHIFT,
@@ -491,10 +495,29 @@ static int as3645a_parse_node(struct as3645a *flash,
  struct device_node *node)
 {
struct as3645a_config *cfg = >cfg;
+   struct device_node *child;
const char *name;
int rval;
 
-   flash->flash_node = of_get_child_by_name(node, "flash");
+   for_each_child_of_node(node, child) {
+   u32 id = 0;
+
+   of_property_read_u32(child, "reg", );
+
+   switch (id) {
+   case AS_LED_FLASH:
+   flash->flash_node = of_node_get(child);
+   break;
+   case AS_LED_INDICATOR:
+   flash->indicator_node = of_node_get(child);
+   break;
+   default:
+   dev_warn(>client->dev,
+"unknown LED %u encountered, ignoring\n", id);
+   break;
+   }
+   }
+
if (!flash->flash_node) {
dev_err(>client->dev, "can't find flash node\n");
return -ENODEV;
@@ -538,7 +561,6 @@ static int as3645a_parse_node(struct as3645a *flash,
 >peak);
cfg->peak = AS_PEAK_mA_TO_REG(cfg->peak);
 
-   flash->indicator_node = of_get_child_by_name(node, "indicator");
if (!flash->indicator_node) {
dev_warn(>client->dev,
 "can't find indicator node\n");
-- 
2.11.0



[PATCH 0/3] AS3645A fixes

2017-09-08 Thread Sakari Ailus
Hi folks,

Here are a few fixes for the as3645a DTS as well as changes in bindings.
The driver is not in a release yet. I'd like to get these in as through
the media tree fixes branch.

Sakari Ailus (3):
  as3645a: Use ams,input-max-microamp as documented in DT bindings
  dt: bindings: as3645a: Use LED number to refer to LEDs
  as3645a: Use integer numbers for parsing LEDs

 .../devicetree/bindings/leds/ams,as3645a.txt   | 28 ++
 arch/arm/boot/dts/omap3-n950-n9.dtsi   | 10 +---
 drivers/leds/leds-as3645a.c| 28 +++---
 3 files changed, 50 insertions(+), 16 deletions(-)

-- 
2.11.0



[PATCH 1/3] as3645a: Use ams,input-max-microamp as documented in DT bindings

2017-09-08 Thread Sakari Ailus
DT bindings document the property "ams,input-max-microamp" that limits the
chip's maximum input current. The driver and the DTS however used
"peak-current-limit" property. Fix this by using the property documented
in DT binding documentation.

Signed-off-by: Sakari Ailus 
---
 arch/arm/boot/dts/omap3-n950-n9.dtsi | 2 +-
 drivers/leds/leds-as3645a.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-n950-n9.dtsi 
b/arch/arm/boot/dts/omap3-n950-n9.dtsi
index cb47ae79a5f9..b86fc83a5a65 100644
--- a/arch/arm/boot/dts/omap3-n950-n9.dtsi
+++ b/arch/arm/boot/dts/omap3-n950-n9.dtsi
@@ -273,7 +273,7 @@
flash-timeout-us = <15>;
flash-max-microamp = <32>;
led-max-microamp = <6>;
-   peak-current-limit = <175>;
+   ams,input-max-microamp = <175>;
};
indicator {
led-max-microamp = <1>;
diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
index e0898233..e3f89c6130d2 100644
--- a/drivers/leds/leds-as3645a.c
+++ b/drivers/leds/leds-as3645a.c
@@ -534,7 +534,7 @@ static int as3645a_parse_node(struct as3645a *flash,
of_property_read_u32(flash->flash_node, "voltage-reference",
 >voltage_reference);
 
-   of_property_read_u32(flash->flash_node, "peak-current-limit",
+   of_property_read_u32(flash->flash_node, "ams,input-max-microamp",
 >peak);
cfg->peak = AS_PEAK_mA_TO_REG(cfg->peak);
 
-- 
2.11.0



[PATCH 2/3] dt: bindings: as3645a: Use LED number to refer to LEDs

2017-09-08 Thread Sakari Ailus
Use integers (reg property) to tell the number of the LED to the driver
instead of the node name. While both of these approaches are currently
used by the LED bindings, using integers will require less driver changes
for ACPI support. Additionally, it will make possible LED naming using
chip and LED node names, effectively making the label property most useful
for human-readable names only.

Signed-off-by: Sakari Ailus 
---
 .../devicetree/bindings/leds/ams,as3645a.txt   | 28 ++
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/Documentation/devicetree/bindings/leds/ams,as3645a.txt 
b/Documentation/devicetree/bindings/leds/ams,as3645a.txt
index 12c5ef26ec73..fdc40e354a64 100644
--- a/Documentation/devicetree/bindings/leds/ams,as3645a.txt
+++ b/Documentation/devicetree/bindings/leds/ams,as3645a.txt
@@ -15,11 +15,14 @@ Required properties
 
 compatible : Must be "ams,as3645a".
 reg: The I2C address of the device. Typically 0x30.
+#address-cells : 1
+#size-cells: 0
 
 
-Required properties of the "flash" child node
-=
+Required properties of the flash child node (0)
+===
 
+reg: 0
 flash-timeout-us: Flash timeout in microseconds. The value must be in
  the range [10, 85] and divisible by 5.
 flash-max-microamp: Maximum flash current in microamperes. Has to be
@@ -33,20 +36,21 @@ ams,input-max-microamp: Maximum flash controller input 
current. The
and divisible by 5.
 
 
-Optional properties of the "flash" child node
-=
+Optional properties of the flash child node
+===
 
 label  : The label of the flash LED.
 
 
-Required properties of the "indicator" child node
-=
+Required properties of the indicator child node (1)
+===
 
+reg: 1
 led-max-microamp: Maximum indicator current. The allowed values are
  2500, 5000, 7500 and 1.
 
-Optional properties of the "indicator" child node
-=
+Optional properties of the indicator child node
+===
 
 label  : The label of the indicator LED.
 
@@ -55,16 +59,20 @@ Example
 ===
 
as3645a@30 {
+   #address-cells: 1
+   #size-cells: 0
reg = <0x30>;
compatible = "ams,as3645a";
-   flash {
+   flash@0 {
+   reg = <0x0>;
flash-timeout-us = <15>;
flash-max-microamp = <32>;
led-max-microamp = <6>;
ams,input-max-microamp = <175>;
label = "as3645a:flash";
};
-   indicator {
+   indicator@1 {
+   reg = <0x1>;
led-max-microamp = <1>;
label = "as3645a:indicator";
};
-- 
2.11.0



Re: [PATCH v8 03/21] v4l: async: Use more intuitive names for internal functions

2017-09-08 Thread Pavel Machek
On Tue 2017-09-05 16:05:35, Sakari Ailus wrote:
> Rename internal functions to make the names of the functions better
> describe what they do.
> 
>   Old nameNew name
>   v4l2_async_test_notify  v4l2_async_match_notify
>   v4l2_async_belongs  v4l2_async_find_match
> 
> Signed-off-by: Sakari Ailus 

Acked-by: Pavel Machek 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v8 01/21] v4l: fwnode: Move KernelDoc documentation to the header

2017-09-08 Thread Pavel Machek
On Tue 2017-09-05 16:05:33, Sakari Ailus wrote:
> In V4L2 the practice is to have the KernelDoc documentation in the header
> and not in .c source code files. This consequientally makes the V4L2
> fwnode function documentation part of the Media documentation build.
> 
> Also correct the link related function and argument naming in
> documentation.
> 
> Signed-off-by: Sakari Ailus 
> Reviewed-by: Niklas Söderlund 
> Acked-by: Hans Verkuil 

Acked-by: Pavel Machek 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


[PATCH 3/3] [media] DaVinci-VPBE-Display: Adjust 12 checks for null pointers

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 14:00:20 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/davinci/vpbe_display.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/davinci/vpbe_display.c 
b/drivers/media/platform/davinci/vpbe_display.c
index afe31900f5de..6aabd21fe69f 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -122,7 +122,7 @@ static irqreturn_t venc_isr(int irq, void *arg)
int fid;
int i;
 
-   if ((NULL == arg) || (NULL == disp_dev->dev[0]))
+   if (!arg || !disp_dev->dev[0])
return IRQ_HANDLED;
 
if (venc_is_second_field(disp_dev))
@@ -337,10 +337,10 @@ static void vpbe_stop_streaming(struct vb2_queue *vq)
vb2_buffer_done(>cur_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
} else {
-   if (layer->cur_frm != NULL)
+   if (layer->cur_frm)
vb2_buffer_done(>cur_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
-   if (layer->next_frm != NULL)
+   if (layer->next_frm)
vb2_buffer_done(>next_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
}
@@ -947,7 +947,7 @@ static int vpbe_display_s_std(struct file *file, void *priv,
if (vb2_is_busy(>buffer_queue))
return -EBUSY;
 
-   if (NULL != vpbe_dev->ops.s_std) {
+   if (vpbe_dev->ops.s_std) {
ret = vpbe_dev->ops.s_std(vpbe_dev, std_id);
if (ret) {
v4l2_err(_dev->v4l2_dev,
@@ -1000,8 +1000,7 @@ static int vpbe_display_enum_output(struct file *file, 
void *priv,
v4l2_dbg(1, debug, _dev->v4l2_dev, "VIDIOC_ENUM_OUTPUT\n");
 
/* Enumerate outputs */
-
-   if (NULL == vpbe_dev->ops.enum_outputs)
+   if (!vpbe_dev->ops.enum_outputs)
return -EINVAL;
 
ret = vpbe_dev->ops.enum_outputs(vpbe_dev, output);
@@ -1030,7 +1029,7 @@ static int vpbe_display_s_output(struct file *file, void 
*priv,
if (vb2_is_busy(>buffer_queue))
return -EBUSY;
 
-   if (NULL == vpbe_dev->ops.set_output)
+   if (!vpbe_dev->ops.set_output)
return -EINVAL;
 
ret = vpbe_dev->ops.set_output(vpbe_dev, i);
@@ -1077,7 +1076,7 @@ vpbe_display_enum_dv_timings(struct file *file, void 
*priv,
v4l2_dbg(1, debug, _dev->v4l2_dev, "VIDIOC_ENUM_DV_TIMINGS\n");
 
/* Enumerate outputs */
-   if (NULL == vpbe_dev->ops.enum_dv_timings)
+   if (!vpbe_dev->ops.enum_dv_timings)
return -EINVAL;
 
ret = vpbe_dev->ops.enum_dv_timings(vpbe_dev, timings);
@@ -1292,7 +1291,7 @@ static int vpbe_device_get(struct device *dev, void *data)
if (strcmp("vpbe_controller", pdev->name) == 0)
vpbe_disp->vpbe_dev = platform_get_drvdata(pdev);
 
-   if (strstr(pdev->name, "vpbe-osd") != NULL)
+   if (strstr(pdev->name, "vpbe-osd"))
vpbe_disp->osd_device = platform_get_drvdata(pdev);
 
return 0;
@@ -1408,7 +1407,7 @@ static int vpbe_display_probe(struct platform_device 
*pdev)
 
v4l2_dev = _dev->vpbe_dev->v4l2_dev;
/* Initialize the vpbe display controller */
-   if (NULL != disp_dev->vpbe_dev->ops.initialize) {
+   if (disp_dev->vpbe_dev->ops.initialize) {
err = disp_dev->vpbe_dev->ops.initialize(>dev,
 disp_dev->vpbe_dev);
if (err) {
@@ -1476,7 +1475,7 @@ static int vpbe_display_probe(struct platform_device 
*pdev)
 probe_out:
for (k = 0; k < VPBE_DISPLAY_MAX_DEVICES; k++) {
/* Unregister video device */
-   if (disp_dev->dev[k] != NULL) {
+   if (disp_dev->dev[k]) {
video_unregister_device(_dev->dev[k]->video_dev);
kfree(disp_dev->dev[k]);
}
@@ -1498,7 +1497,7 @@ static int vpbe_display_remove(struct platform_device 
*pdev)
v4l2_dbg(1, debug, _dev->v4l2_dev, "vpbe_display_remove\n");
 
/* deinitialize the vpbe display controller */
-   if (NULL != vpbe_dev->ops.deinitialize)
+   if (vpbe_dev->ops.deinitialize)
vpbe_dev->ops.deinitialize(>dev, vpbe_dev);
/* un-register device */
for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) {
-- 
2.14.1



[PATCH 2/3] [media] DaVinci-VPBE-Display: Improve a size determination in two functions

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 10:50:32 +0200

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/davinci/vpbe_display.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/davinci/vpbe_display.c 
b/drivers/media/platform/davinci/vpbe_display.c
index 5b6fc550736b..afe31900f5de 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -1305,9 +1305,5 @@ static int init_vpbe_layer(int i, struct vpbe_display 
*disp_dev,
struct video_device *vbd = NULL;
 
/* Allocate memory for four plane display objects */
-
-   disp_dev->dev[i] =
-   kzalloc(sizeof(struct vpbe_layer), GFP_KERNEL);
-
-   /* If memory allocation fails, return error */
+   disp_dev->dev[i] = kzalloc(sizeof(*disp_dev->dev[i]), GFP_KERNEL);
if (!disp_dev->dev[i])
@@ -1396,6 +1392,5 @@ static int vpbe_display_probe(struct platform_device 
*pdev)
 
printk(KERN_DEBUG "vpbe_display_probe\n");
/* Allocate memory for vpbe_display */
-   disp_dev = devm_kzalloc(>dev, sizeof(struct vpbe_display),
-   GFP_KERNEL);
+   disp_dev = devm_kzalloc(>dev, sizeof(*disp_dev), GFP_KERNEL);
if (!disp_dev)
-- 
2.14.1



[PATCH 1/3] [media] DaVinci-VPBE-Display: Delete an error message for a failed memory allocation in init_vpbe_layer()

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 7 Sep 2017 22:37:16 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/davinci/vpbe_display.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/davinci/vpbe_display.c 
b/drivers/media/platform/davinci/vpbe_display.c
index 13d027031ff0..5b6fc550736b 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -1313,7 +1313,6 @@ static int init_vpbe_layer(int i, struct vpbe_display 
*disp_dev,
-   if (!disp_dev->dev[i]) {
-   printk(KERN_ERR "ran out of memory\n");
+   if (!disp_dev->dev[i])
return  -ENOMEM;
-   }
+
spin_lock_init(_dev->dev[i]->irqlock);
mutex_init(_dev->dev[i]->opslock);
 
-- 
2.14.1



[PATCH 0/3] [media] DaVinci-VPBE-Display: Adjustments for some function implementations

2017-09-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Sep 2017 14:12:10 +0200

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Delete an error message for a failed memory allocation in init_vpbe_layer()
  Improve a size determination in two functions
  Adjust 12 checks for null pointers

 drivers/media/platform/davinci/vpbe_display.c | 37 +++
 1 file changed, 15 insertions(+), 22 deletions(-)

-- 
2.14.1



Re: [PATCH v7 11/18] v4l: async: Register sub-devices before calling bound callback

2017-09-08 Thread Pavel Machek
On Sun 2017-09-03 20:49:51, Sakari Ailus wrote:
> Register the sub-device before calling the notifier's bound callback.
> Doing this the other way around is problematic as the struct v4l2_device
> has not assigned for the sub-device yet and may be required by the bound
> callback.
> 
> Signed-off-by: Sakari Ailus 

Acked-by: Pavel Machek 


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v7 1/1] dt: bindings: smiapp: Document lens-focus and flash properties

2017-09-08 Thread Pavel Machek
On Sun 2017-09-03 23:18:05, Sakari Ailus wrote:
> Document optional lens-focus and flash properties for the smiapp driver.
> 
> Signed-off-by: Sakari Ailus 

Acked-by: Pavel Machek 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v3 3/6] drm/exynos/gsc: Add hardware rotation limits

2017-09-08 Thread Robin Murphy
On 08/09/17 07:02, Hoegeun Kwon wrote:
> The gscaler has hardware rotation limits that need to be hardcoded
> into driver. Distinguish them and add them to the property list.
> 
> The hardware rotation limits are related to the cropped source size.
> When swap occurs, use rot_max size instead of crop_max size.
> 
> Also the scaling limits are related to pos size, use pos size to check
> the limits.
> 
> Signed-off-by: Hoegeun Kwon 
> ---
>  drivers/gpu/drm/exynos/exynos_drm_gsc.c | 93 
> +++--
>  include/uapi/drm/exynos_drm.h   |  2 +
>  2 files changed, 66 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c 
> b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> index 0506b2b..a4fb347 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> @@ -17,6 +17,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -150,6 +151,15 @@ struct gsc_context {
>   boolsuspended;
>  };
>  
> +/*
> + * struct gsc_driverdata - per device type driver data for init time.
> + *
> + * @rot_max: rotation max resolution.
> + */
> +struct gsc_driverdata {
> + struct drm_exynos_sz rot_max;
> +};
> +
>  /* 8-tap Filter Coefficient */
>  static const int h_coef_8t[GSC_COEF_RATIO][GSC_COEF_ATTR][GSC_COEF_H_8T] = {
>   {   /* Ratio <= 65536 (~8:8) */
> @@ -1401,6 +1411,23 @@ static int gsc_ippdrv_check_property(struct device 
> *dev,
>   bool swap;
>   int i;
>  
> + config = >config[EXYNOS_DRM_OPS_DST];
> +
> + /* check for degree */
> + switch (config->degree) {
> + case EXYNOS_DRM_DEGREE_90:
> + case EXYNOS_DRM_DEGREE_270:
> + swap = true;
> + break;
> + case EXYNOS_DRM_DEGREE_0:
> + case EXYNOS_DRM_DEGREE_180:
> + swap = false;
> + break;
> + default:
> + DRM_ERROR("invalid degree.\n");
> + goto err_property;
> + }
> +
>   for_each_ipp_ops(i) {
>   if ((i == EXYNOS_DRM_OPS_SRC) &&
>   (property->cmd == IPP_CMD_WB))
> @@ -1416,21 +1443,6 @@ static int gsc_ippdrv_check_property(struct device 
> *dev,
>   goto err_property;
>   }
>  
> - /* check for degree */
> - switch (config->degree) {
> - case EXYNOS_DRM_DEGREE_90:
> - case EXYNOS_DRM_DEGREE_270:
> - swap = true;
> - break;
> - case EXYNOS_DRM_DEGREE_0:
> - case EXYNOS_DRM_DEGREE_180:
> - swap = false;
> - break;
> - default:
> - DRM_ERROR("invalid degree.\n");
> - goto err_property;
> - }
> -
>   /* check for buffer bound */
>   if ((pos->x + pos->w > sz->hsize) ||
>   (pos->y + pos->h > sz->vsize)) {
> @@ -1438,21 +1450,27 @@ static int gsc_ippdrv_check_property(struct device 
> *dev,
>   goto err_property;
>   }
>  
> + /*
> +  * The rotation hardware limits are related to the cropped
> +  * source size. So use rot_max size to check the limits when
> +  * swap happens. And also the scaling limits are related to pos
> +  * size, use pos size to check the limits.
> +  */
>   /* check for crop */
>   if ((i == EXYNOS_DRM_OPS_SRC) && (pp->crop)) {
>   if (swap) {
>   if ((pos->h < pp->crop_min.hsize) ||
> - (sz->vsize > pp->crop_max.hsize) ||
> + (pos->h > pp->rot_max.hsize) ||
>   (pos->w < pp->crop_min.vsize) ||
> - (sz->hsize > pp->crop_max.vsize)) {
> + (pos->w > pp->rot_max.vsize)) {
>   DRM_ERROR("out of crop size.\n");
>   goto err_property;
>   }
>   } else {
>   if ((pos->w < pp->crop_min.hsize) ||
> - (sz->hsize > pp->crop_max.hsize) ||
> + (pos->w > pp->crop_max.hsize) ||
>   (pos->h < pp->crop_min.vsize) ||
> - (sz->vsize > pp->crop_max.vsize)) {
> + (pos->h > pp->crop_max.vsize)) {
>   DRM_ERROR("out of crop size.\n");
>   goto err_property;
>   }
> @@ -1463,17 +1481,17 @@ static int gsc_ippdrv_check_property(struct device 
> *dev,
>   if ((i == 

Re: [PATCH v3 2/6] ARM: dts: exynos: Add clean name of compatible.

2017-09-08 Thread Robin Murphy
On 08/09/17 07:02, Hoegeun Kwon wrote:
> Exynos 5250 and 5420 have different hardware rotation limits. However,
> currently it uses only one compatible - "exynos5-gsc". Since we have
> to distinguish between these two, we add different compatible.
> 
> Signed-off-by: Hoegeun Kwon 
> ---
>  arch/arm/boot/dts/exynos5250.dtsi | 8 
>  arch/arm/boot/dts/exynos5420.dtsi | 4 ++--
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
> b/arch/arm/boot/dts/exynos5250.dtsi
> index 8dbeb87..bf08101 100644
> --- a/arch/arm/boot/dts/exynos5250.dtsi
> +++ b/arch/arm/boot/dts/exynos5250.dtsi
> @@ -637,7 +637,7 @@
>   };
>  
>   gsc_0:  gsc@13e0 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5250-gsc";

These should be the other way round - the most specific compatible
should come first, then the more general fallback afterwards.

(and similarly in all cases below)

Robin.

>   reg = <0x13e0 0x1000>;
>   interrupts = ;
>   power-domains = <_gsc>;
> @@ -647,7 +647,7 @@
>   };
>  
>   gsc_1:  gsc@13e1 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5250-gsc";
>   reg = <0x13e1 0x1000>;
>   interrupts = ;
>   power-domains = <_gsc>;
> @@ -657,7 +657,7 @@
>   };
>  
>   gsc_2:  gsc@13e2 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5250-gsc";
>   reg = <0x13e2 0x1000>;
>   interrupts = ;
>   power-domains = <_gsc>;
> @@ -667,7 +667,7 @@
>   };
>  
>   gsc_3:  gsc@13e3 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5250-gsc";
>   reg = <0x13e3 0x1000>;
>   interrupts = ;
>   power-domains = <_gsc>;
> diff --git a/arch/arm/boot/dts/exynos5420.dtsi 
> b/arch/arm/boot/dts/exynos5420.dtsi
> index 02d2f89..86afe77 100644
> --- a/arch/arm/boot/dts/exynos5420.dtsi
> +++ b/arch/arm/boot/dts/exynos5420.dtsi
> @@ -658,7 +658,7 @@
>   };
>  
>   gsc_0: video-scaler@13e0 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5420-gsc";
>   reg = <0x13e0 0x1000>;
>   interrupts = ;
>   clocks = < CLK_GSCL0>;
> @@ -668,7 +668,7 @@
>   };
>  
>   gsc_1: video-scaler@13e1 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5420-gsc";
>   reg = <0x13e1 0x1000>;
>   interrupts = ;
>   clocks = < CLK_GSCL1>;
> 



Re: [PATCH v3 5/6] [media] exynos-gsc: Remove unnecessary compatible

2017-09-08 Thread Krzysztof Kozlowski
On Fri, Sep 8, 2017 at 8:02 AM, Hoegeun Kwon  wrote:
> Currently, the compatible('samsung,exynos5-gsc') is not used.
> Remove unnecessary compatible.
>
> Signed-off-by: Hoegeun Kwon 
> ---
>  Documentation/devicetree/bindings/media/exynos5-gsc.txt | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/media/exynos5-gsc.txt 
> b/Documentation/devicetree/bindings/media/exynos5-gsc.txt
> index daa56d5..1ea05f1 100644
> --- a/Documentation/devicetree/bindings/media/exynos5-gsc.txt
> +++ b/Documentation/devicetree/bindings/media/exynos5-gsc.txt
> @@ -3,9 +3,9 @@
>  G-Scaler is used for scaling and color space conversion on EXYNOS5 SoCs.
>
>  Required properties:
> -- compatible: should be "samsung,exynos5-gsc" (for Exynos 5250, 5420 and
> - 5422 SoCs) or "samsung,exynos5433-gsc" (Exynos 5433)
> - or "samsung,exynos5250-gsc" or "samsung,exynos5420-gsc"
> +- compatible: should be "samsung,exynos5250-gsc", "samsung,exynos5420-gsc"
> + or "samsung,exynos5433-gsc" (for Exynos 5250, 5420, 5422,
> + and 5433 SoCs)

You should not remove the compatible (neither here nor in the driver)
but mark it as deprecated. Removal should happen slightly later.

Best regards,
Krzysztof

>  - reg: should contain G-Scaler physical address location and length.
>  - interrupts: should contain G-Scaler interrupt number
>
> @@ -16,7 +16,7 @@ Optional properties:
>  Example:
>
>  gsc_0:  gsc@0x13e0 {
> -   compatible = "samsung,exynos5-gsc";
> +   compatible = "samsung,exynos5250-gsc;
> reg = <0x13e0 0x1000>;
> interrupts = <0 85 0>;
>  };


Re: [RFC PATCH v4 3/6] i2c: add docs to clarify DMA handling

2017-09-08 Thread Mauro Carvalho Chehab
Em Fri, 8 Sep 2017 10:56:40 +0200
Wolfram Sang  escreveu:

> Hi Mauro,
> 
> thanks for your comments. Much appreciated!
> 
> > There are also a couple of things here that Sphinx would complain.
> > So, it could be worth to rename it to *.rst, while you're writing
> > it, and see what:
> > make htmldocs
> > will complain and how it will look in html.  
> 
> OK, I'll check that.

Ok.

> > > +Given that I2C is a low-speed bus where largely small messages are 
> > > transferred,
> > > +it is not considered a prime user of DMA access. At this time of 
> > > writing, only
> > > +10% of I2C bus master drivers have DMA support implemented.  
> > 
> > Are you sure about that? I'd say that, on media, at least half of the
> > drivers use DMA for I2C bus access, as the I2C bus is on a remote
> > board that talks with CPU via USB, using DMA, and all communication
> > with USB should be DMA-safe.  
> 
> Well, the DMA-safe requirement comes then from the USB subsystem,
> doesn't it?

Yes, but the statistics that 10% of I2C bus master drivers
are DMA-safe is not true, if you take those into account ;-)

Perhaps you could write it as (or something similar):

At this time of writing, only +10% of I2C bus master
drivers for non-remote boards have DMA support implemented.  


> Or do you really use DMA on the remote board to transfer
> data via I2C to an I2C client?
> 
> > I guess what you really wanted to say on most of this section is
> > about SoC (and other CPUs) where the I2C bus master is is at the
> > mainboard, and not on some peripheral.  
> 
> I might be biased to that, yes. So, it is good talking about it.
> 
> > > And the vast
> > > +majority of transactions are so small that setting up DMA for it will 
> > > likely
> > > +add more overhead than a plain PIO transfer.
> > > +
> > > +Therefore, it is *not* mandatory that the buffer of an I2C message is 
> > > DMA safe.  
> > 
> > Again, that may not be true on media boards. The code that implements the
> > I2C transfers there, on most boards, have to be DMA safe, as it won't
> > otherwise send/receive commands from the chips that are after the USB
> > bridge.  
> 
> That still sounds to me like the DMA-safe requirement comes from USB
> (which is fine, of course.). In any case, a sentence like "Other
> subsystem you might use for bridging I2C might impose other DMA
> requirements" sounds like to nice to have.

Agreed.

> 
> > > +Drivers wishing to implement DMA can use helper functions from the I2C 
> > > core.
> > > +One gives you a DMA-safe buffer for a given i2c_msg as long as a certain
> > > +threshold is met.
> > > +
> > > + dma_buf = i2c_get_dma_safe_msg_buf(msg, threshold_in_byte);  
> > 
> > I'm concerned about the new bits added by this call. Right now,
> > USB drivers just use kalloc() for transfer buffers used to send and
> > receive URB control messages for both setting the main device and
> > for I2C messages. Before this changeset, buffers allocated this
> > way are DMA save and have been working for years.  
> 
> Can you give me a pointer to a driver doing this? I glimpsed around in
> drivers/media/usb and found that most drivers are having their i2c_msg
> buffers on the stack. Which is clearly not DMA-safe.

The way it is implemented depends on the driver, and usually envolves
double-buffering, e. g., on some place of the driver, a buffer that
may not be DMA-save is copied into a DMA safe buffer. 

On most cases, like on this driver:
drivers/media/usb/dvb-usb-v2/az6007.c

The i2c_xfer logic (or the read/write functions) is the one responsible
for double-buffering.

In this specific example, the DVB usbv2 core allocates the device's "state"
struct using kmalloc (it uses .size_of_priv field to know the size of
the "state" buffer).

On struct az6007_device_state, there is a "data" buffer with 4096 bytes.

At the i2c transfer function, it retrieves and use it:

struct az6007_device_state *st = d_to_priv(d)
...
ret = __az6007_read(d->udev, req, value, index, st->data, length);
...
ret =  __az6007_write(d->udev, req, value, index, st->data, length);


In the past, on lots of drivers, the i2c_xfer logic just used to assume
that the I2C client driver allocated a DMA-safe buffer, as it just used to
pass whatever buffer it receives directly to USB core. We did an effort to
change it, as it can be messy, but I'm not sure if this is solved everywhere.

The __az6007_read() and __az6007_write() indirectly do DMA (for most USB
host drivers), when they call usb_control_msg().

> 
> > When you add some flags that would make the I2C subsystem aware
> > that a buffer is now DMA safe, I guess you could be breaking
> > those drivers, as a DMA safe buffer will now be considered as
> > DMA-unsafe.  
> 
> Well, this flag is only relevant for i2c master drivers wishing to do
> DMA. So, grepping in the above directory
> 
>   grep dma $(grep -rl i2c_add_adapter *)

The usage of I2C at the media 

Re: [PATCH 00/11] drm/sun4i: add CEC support

2017-09-08 Thread Hans Verkuil
Hi Maxime,

On 07/18/17 18:29, Maxime Ripard wrote:
> Hi,
> 
> On Tue, Jul 11, 2017 at 11:06:52PM +0200, Hans Verkuil wrote:
>> On 11/07/17 22:39, Maxime Ripard wrote:
>>> On Tue, Jul 11, 2017 at 08:30:33AM +0200, Hans Verkuil wrote:
 From: Hans Verkuil 

 This patch series adds CEC support for the sun4i HDMI controller.

 The CEC hardware support for the A10 is very low-level as it just
 controls the CEC pin. Since I also wanted to support GPIO-based CEC
 hardware most of this patch series is in the CEC framework to
 add a generic low-level CEC pin framework. It is only the final patch
 that adds the sun4i support.

 This patch series first makes some small changes in the CEC framework
 (patches 1-4) to prepare for this CEC pin support.

 Patch 5-7 adds the new API elements and documents it. Patch 6 reworks
 the CEC core event handling.

 Patch 8 adds pin monitoring support (allows userspace to see all
 CEC pin transitions as they happen).

 Patch 9 adds the core cec-pin implementation that translates low-level
 pin transitions into valid CEC messages. Basically this does what any
 SoC with a proper CEC hardware implementation does.

 Patch 10 documents the cec-pin kAPI (and also the cec-notifier kAPI
 which was missing).

 Finally patch 11 adds the actual sun4i_hdmi CEC implementation.

 I tested this on my cubieboard. There were no errors at all
 after 126264 calls of 'cec-ctl --give-device-vendor-id' while at the
 same time running a 'make -j4' of the v4l-utils git repository and
 doing a continuous scp to create network traffic.

 This patch series is based on top of the mainline kernel as of
 yesterday (so with all the sun4i and cec patches for 4.13 merged).
>>>
>>> For the whole serie:
>>> Reviewed-by: Maxime Ripard 
>>>
 Maxime, patches 1-10 will go through the media subsystem. How do you
 want to handle the final patch? It can either go through the media
 subsystem as well, or you can sit on it and handle this yourself during
 the 4.14 merge window. Another option is to separate the Kconfig change
 into its own patch. That way you can merge the code changes and only
 have to handle the Kconfig patch as a final change during the merge
 window.
>>>
>>> We'll probably have a number of reworks for 4.14, so it would be
>>> better if I merged it.
>>>
>>> However, I guess if we just switch to a depends on CEC_PIN instead of
>>> a select, everything would just work even if we merge your patches in
>>> a separate tree, right?
>>
>> This small patch will do it:
>>
>> diff --git a/drivers/gpu/drm/sun4i/Kconfig b/drivers/gpu/drm/sun4i/Kconfig
>> index e884d265c0b3..ebad80aefc87 100644
>> --- a/drivers/gpu/drm/sun4i/Kconfig
>> +++ b/drivers/gpu/drm/sun4i/Kconfig
>> @@ -25,7 +25,7 @@ config DRM_SUN4I_HDMI_CEC
>> bool "Allwinner A10 HDMI CEC Support"
>> depends on DRM_SUN4I_HDMI
>> select CEC_CORE
>> -   select CEC_PIN
>> +   depends on CEC_PIN
>> help
>>Choose this option if you have an Allwinner SoC with an HDMI
>>controller and want to use CEC.

Just a reminder: now that both this driver and the CEC_PIN code has been
merged in 4.14, this 'depends on' can become a 'select' again.

Regards,

Hans


Re: [ANN] Call for topics for the media mini-summit on Friday Oct 27 in Prague

2017-09-08 Thread Alexandre Courbot
Hi!

On Fri, Sep 1, 2017 at 6:46 PM, Hans Verkuil  wrote:
> Hi all,
>
> We are organizing a media mini-summit on Friday October 27 in Prague, 
> co-located
> with the ELCE conference:
>
> http://events.linuxfoundation.org/events/embedded-linux-conference-europe
>
> This is a call for topics to discuss during that mini-summit.
>
> Also, if you plan to attend, please let me know. It is open for all, but it is
> nice if we know beforehand who we can expect.
>
> So if you have a topic that you want to discuss there, then just reply to this
> post. If possible, please add a rough idea of how much time you think you will
> need.

I will be here to discuss the request API:

Topic: request/jobs API
Purpose: overview of the work based on the request API (proposed new
name: jobs API), to hopefully converge to something that can be merged
soon.

I plan to have a concrete, reasonable proposal by then.

Pawel may also attend, but not 100% sure yet.

Looking forward to seeing you all there!

Alex.


Re: [RFC PATCH v4 3/6] i2c: add docs to clarify DMA handling

2017-09-08 Thread Wolfram Sang
Hi Mauro,

thanks for your comments. Much appreciated!

> There are also a couple of things here that Sphinx would complain.
> So, it could be worth to rename it to *.rst, while you're writing
> it, and see what:
>   make htmldocs
> will complain and how it will look in html.

OK, I'll check that.

> > +Given that I2C is a low-speed bus where largely small messages are 
> > transferred,
> > +it is not considered a prime user of DMA access. At this time of writing, 
> > only
> > +10% of I2C bus master drivers have DMA support implemented.
> 
> Are you sure about that? I'd say that, on media, at least half of the
> drivers use DMA for I2C bus access, as the I2C bus is on a remote
> board that talks with CPU via USB, using DMA, and all communication
> with USB should be DMA-safe.

Well, the DMA-safe requirement comes then from the USB subsystem,
doesn't it? Or do you really use DMA on the remote board to transfer
data via I2C to an I2C client?

> I guess what you really wanted to say on most of this section is
> about SoC (and other CPUs) where the I2C bus master is is at the
> mainboard, and not on some peripheral.

I might be biased to that, yes. So, it is good talking about it.

> > And the vast
> > +majority of transactions are so small that setting up DMA for it will 
> > likely
> > +add more overhead than a plain PIO transfer.
> > +
> > +Therefore, it is *not* mandatory that the buffer of an I2C message is DMA 
> > safe.
> 
> Again, that may not be true on media boards. The code that implements the
> I2C transfers there, on most boards, have to be DMA safe, as it won't
> otherwise send/receive commands from the chips that are after the USB
> bridge.

That still sounds to me like the DMA-safe requirement comes from USB
(which is fine, of course.). In any case, a sentence like "Other
subsystem you might use for bridging I2C might impose other DMA
requirements" sounds like to nice to have.

> > +Drivers wishing to implement DMA can use helper functions from the I2C 
> > core.
> > +One gives you a DMA-safe buffer for a given i2c_msg as long as a certain
> > +threshold is met.
> > +
> > +   dma_buf = i2c_get_dma_safe_msg_buf(msg, threshold_in_byte);
> 
> I'm concerned about the new bits added by this call. Right now,
> USB drivers just use kalloc() for transfer buffers used to send and
> receive URB control messages for both setting the main device and
> for I2C messages. Before this changeset, buffers allocated this
> way are DMA save and have been working for years.

Can you give me a pointer to a driver doing this? I glimpsed around in
drivers/media/usb and found that most drivers are having their i2c_msg
buffers on the stack. Which is clearly not DMA-safe.

> When you add some flags that would make the I2C subsystem aware
> that a buffer is now DMA safe, I guess you could be breaking
> those drivers, as a DMA safe buffer will now be considered as
> DMA-unsafe.

Well, this flag is only relevant for i2c master drivers wishing to do
DMA. So, grepping in the above directory

grep dma $(grep -rl i2c_add_adapter *)

only gives one driver which is irrelevant because the i2c master it
registers is not doing any DMA?

Am I missing something? We are clearly not aligned yet...

Regards,

   Wolfram



signature.asc
Description: PGP signature


Re: [PATCH v2 00/10] media: rc: gpio-ir-recv: driver update

2017-09-08 Thread Ladislav Michl
Hi Andi,

On Fri, Sep 08, 2017 at 11:21:10AM +0900, Andi Shyti wrote:
> Hi Ladislav,
> 
> > Serie was rebased on top of current linux.git, but something
> > happened there and my userspace decoder no longer works: driver
> > reports completely bogus timing such as (rc-5):
> > ^427, _1342, ^945, _183, ^1128, _671, ^1586, _91, ^1189, _1525,
> > ^1738, _1433, ^915, _1159, ^1464, _1525, ^213, _1067, ^793, _0
> > (^ used for pulse and _ for space)
> > As it has nothing to do with my changes, I'm sending it anyway
> > for review, which I do not expect to happen until merge window
> > ends.
> 
> This means that your patch is anyway untested.

Previous version is pretty well tested. GPIO IR stopped working
after pulling other changes from linux.git yesterday. And does not
work even without this patch set. I'll try to bisect later as omiting
linux-media merge did not fix it either.

> In any case I don't see much use if patch 1/10 as it doesn't
> simplify much, but the rest (from 2 to 10) looks good to me.

Just look at patch 9 and imagine how it would look without this
change. If you are still unconvinced I'll drop this change.

> Once it's tested you can add
> 
> Acked-by: Andi Shyti 
> 
> Andi
> 
> P.S. I don't see in this V2 the changelog from V1. Next time,
> please add the changelog.

It was just a rebase with conflicts resolved. I do not see how
to describe it better than I did.

ladis


[PATCH v3 6/6] ARM: dts: exynos: Remove unnecessary compatible

2017-09-08 Thread Hoegeun Kwon
Currently, the compatible('samsung,exynos5-gsc') is not used.
Remove unnecessary compatible.

Signed-off-by: Hoegeun Kwon 
---
 arch/arm/boot/dts/exynos5250.dtsi | 8 
 arch/arm/boot/dts/exynos5420.dtsi | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
b/arch/arm/boot/dts/exynos5250.dtsi
index bf08101..e632faf 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -637,7 +637,7 @@
};
 
gsc_0:  gsc@13e0 {
-   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5250-gsc";
+   compatible = "samsung,exynos5250-gsc";
reg = <0x13e0 0x1000>;
interrupts = ;
power-domains = <_gsc>;
@@ -647,7 +647,7 @@
};
 
gsc_1:  gsc@13e1 {
-   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5250-gsc";
+   compatible = "samsung,exynos5250-gsc";
reg = <0x13e1 0x1000>;
interrupts = ;
power-domains = <_gsc>;
@@ -657,7 +657,7 @@
};
 
gsc_2:  gsc@13e2 {
-   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5250-gsc";
+   compatible = "samsung,exynos5250-gsc";
reg = <0x13e2 0x1000>;
interrupts = ;
power-domains = <_gsc>;
@@ -667,7 +667,7 @@
};
 
gsc_3:  gsc@13e3 {
-   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5250-gsc";
+   compatible = "samsung,exynos5250-gsc";
reg = <0x13e3 0x1000>;
interrupts = ;
power-domains = <_gsc>;
diff --git a/arch/arm/boot/dts/exynos5420.dtsi 
b/arch/arm/boot/dts/exynos5420.dtsi
index 86afe77..58392b3 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -658,7 +658,7 @@
};
 
gsc_0: video-scaler@13e0 {
-   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5420-gsc";
+   compatible = "samsung,exynos5420-gsc";
reg = <0x13e0 0x1000>;
interrupts = ;
clocks = < CLK_GSCL0>;
@@ -668,7 +668,7 @@
};
 
gsc_1: video-scaler@13e1 {
-   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5420-gsc";
+   compatible = "samsung,exynos5420-gsc";
reg = <0x13e1 0x1000>;
interrupts = ;
clocks = < CLK_GSCL1>;
-- 
1.9.1



[PATCH v3 5/6] [media] exynos-gsc: Remove unnecessary compatible

2017-09-08 Thread Hoegeun Kwon
Currently, the compatible('samsung,exynos5-gsc') is not used.
Remove unnecessary compatible.

Signed-off-by: Hoegeun Kwon 
---
 Documentation/devicetree/bindings/media/exynos5-gsc.txt | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/exynos5-gsc.txt 
b/Documentation/devicetree/bindings/media/exynos5-gsc.txt
index daa56d5..1ea05f1 100644
--- a/Documentation/devicetree/bindings/media/exynos5-gsc.txt
+++ b/Documentation/devicetree/bindings/media/exynos5-gsc.txt
@@ -3,9 +3,9 @@
 G-Scaler is used for scaling and color space conversion on EXYNOS5 SoCs.
 
 Required properties:
-- compatible: should be "samsung,exynos5-gsc" (for Exynos 5250, 5420 and
- 5422 SoCs) or "samsung,exynos5433-gsc" (Exynos 5433)
- or "samsung,exynos5250-gsc" or "samsung,exynos5420-gsc"
+- compatible: should be "samsung,exynos5250-gsc", "samsung,exynos5420-gsc"
+ or "samsung,exynos5433-gsc" (for Exynos 5250, 5420, 5422,
+ and 5433 SoCs)
 - reg: should contain G-Scaler physical address location and length.
 - interrupts: should contain G-Scaler interrupt number
 
@@ -16,7 +16,7 @@ Optional properties:
 Example:
 
 gsc_0:  gsc@0x13e0 {
-   compatible = "samsung,exynos5-gsc";
+   compatible = "samsung,exynos5250-gsc;
reg = <0x13e0 0x1000>;
interrupts = <0 85 0>;
 };
-- 
1.9.1



[PATCH v3 4/6] [media] exynos-gsc: Add hardware rotation limits

2017-09-08 Thread Hoegeun Kwon
The hardware rotation limits of gsc depends on SOC (Exynos
5250/5420/5433). Distinguish them and add them to the driver data.

Signed-off-by: Hoegeun Kwon 
---
 drivers/media/platform/exynos-gsc/gsc-core.c | 96 
 1 file changed, 83 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
b/drivers/media/platform/exynos-gsc/gsc-core.c
index 4380150..8f8636e 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -943,7 +943,37 @@ static irqreturn_t gsc_irq_handler(int irq, void *priv)
return IRQ_HANDLED;
 }
 
-static struct gsc_pix_max gsc_v_100_max = {
+static struct gsc_pix_max gsc_v_5250_max = {
+   .org_scaler_bypass_w= 8192,
+   .org_scaler_bypass_h= 8192,
+   .org_scaler_input_w = 4800,
+   .org_scaler_input_h = 3344,
+   .real_rot_dis_w = 4800,
+   .real_rot_dis_h = 3344,
+   .real_rot_en_w  = 2016,
+   .real_rot_en_h  = 2016,
+   .target_rot_dis_w   = 4800,
+   .target_rot_dis_h   = 3344,
+   .target_rot_en_w= 2016,
+   .target_rot_en_h= 2016,
+};
+
+static struct gsc_pix_max gsc_v_5420_max = {
+   .org_scaler_bypass_w= 8192,
+   .org_scaler_bypass_h= 8192,
+   .org_scaler_input_w = 4800,
+   .org_scaler_input_h = 3344,
+   .real_rot_dis_w = 4800,
+   .real_rot_dis_h = 3344,
+   .real_rot_en_w  = 2048,
+   .real_rot_en_h  = 2048,
+   .target_rot_dis_w   = 4800,
+   .target_rot_dis_h   = 3344,
+   .target_rot_en_w= 2016,
+   .target_rot_en_h= 2016,
+};
+
+static struct gsc_pix_max gsc_v_5433_max = {
.org_scaler_bypass_w= 8192,
.org_scaler_bypass_h= 8192,
.org_scaler_input_w = 4800,
@@ -979,8 +1009,8 @@ static irqreturn_t gsc_irq_handler(int irq, void *priv)
.target_h   = 2,  /* yuv420 : 2, others : 1 */
 };
 
-static struct gsc_variant gsc_v_100_variant = {
-   .pix_max= _v_100_max,
+static struct gsc_variant gsc_v_5250_variant = {
+   .pix_max= _v_5250_max,
.pix_min= _v_100_min,
.pix_align  = _v_100_align,
.in_buf_cnt = 32,
@@ -992,12 +1022,48 @@ static irqreturn_t gsc_irq_handler(int irq, void *priv)
.local_sc_down  = 2,
 };
 
-static struct gsc_driverdata gsc_v_100_drvdata = {
+static struct gsc_variant gsc_v_5420_variant = {
+   .pix_max= _v_5420_max,
+   .pix_min= _v_100_min,
+   .pix_align  = _v_100_align,
+   .in_buf_cnt = 32,
+   .out_buf_cnt= 32,
+   .sc_up_max  = 8,
+   .sc_down_max= 16,
+   .poly_sc_down_max   = 4,
+   .pre_sc_down_max= 4,
+   .local_sc_down  = 2,
+};
+
+static struct gsc_variant gsc_v_5433_variant = {
+   .pix_max= _v_5433_max,
+   .pix_min= _v_100_min,
+   .pix_align  = _v_100_align,
+   .in_buf_cnt = 32,
+   .out_buf_cnt= 32,
+   .sc_up_max  = 8,
+   .sc_down_max= 16,
+   .poly_sc_down_max   = 4,
+   .pre_sc_down_max= 4,
+   .local_sc_down  = 2,
+};
+
+static struct gsc_driverdata gsc_v_5250_drvdata = {
.variant = {
-   [0] = _v_100_variant,
-   [1] = _v_100_variant,
-   [2] = _v_100_variant,
-   [3] = _v_100_variant,
+   [0] = _v_5250_variant,
+   [1] = _v_5250_variant,
+   [2] = _v_5250_variant,
+   [3] = _v_5250_variant,
+   },
+   .num_entities = 4,
+   .clk_names = { "gscl" },
+   .num_clocks = 1,
+};
+
+static struct gsc_driverdata gsc_v_5420_drvdata = {
+   .variant = {
+   [0] = _v_5420_variant,
+   [1] = _v_5420_variant,
},
.num_entities = 4,
.clk_names = { "gscl" },
@@ -1006,9 +1072,9 @@ static irqreturn_t gsc_irq_handler(int irq, void *priv)
 
 static struct gsc_driverdata gsc_5433_drvdata = {
.variant = {
-   [0] = _v_100_variant,
-   [1] = _v_100_variant,
-   [2] = _v_100_variant,
+   [0] = _v_5433_variant,
+   [1] = _v_5433_variant,
+   [2] = _v_5433_variant,
},
.num_entities = 3,
.clk_names = { "pclk", "aclk", "aclk_xiu", "aclk_gsclbend" },
@@ -1017,8 +1083,12 @@ static irqreturn_t gsc_irq_handler(int irq, void *priv)
 
 static const struct of_device_id exynos_gsc_match[] = {
{
-   .compatible = "samsung,exynos5-gsc",
-   .data = _v_100_drvdata,
+   .compatible = 

[PATCH v3 3/6] drm/exynos/gsc: Add hardware rotation limits

2017-09-08 Thread Hoegeun Kwon
The gscaler has hardware rotation limits that need to be hardcoded
into driver. Distinguish them and add them to the property list.

The hardware rotation limits are related to the cropped source size.
When swap occurs, use rot_max size instead of crop_max size.

Also the scaling limits are related to pos size, use pos size to check
the limits.

Signed-off-by: Hoegeun Kwon 
---
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 93 +++--
 include/uapi/drm/exynos_drm.h   |  2 +
 2 files changed, 66 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c 
b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index 0506b2b..a4fb347 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -150,6 +151,15 @@ struct gsc_context {
boolsuspended;
 };
 
+/*
+ * struct gsc_driverdata - per device type driver data for init time.
+ *
+ * @rot_max: rotation max resolution.
+ */
+struct gsc_driverdata {
+   struct drm_exynos_sz rot_max;
+};
+
 /* 8-tap Filter Coefficient */
 static const int h_coef_8t[GSC_COEF_RATIO][GSC_COEF_ATTR][GSC_COEF_H_8T] = {
{   /* Ratio <= 65536 (~8:8) */
@@ -1401,6 +1411,23 @@ static int gsc_ippdrv_check_property(struct device *dev,
bool swap;
int i;
 
+   config = >config[EXYNOS_DRM_OPS_DST];
+
+   /* check for degree */
+   switch (config->degree) {
+   case EXYNOS_DRM_DEGREE_90:
+   case EXYNOS_DRM_DEGREE_270:
+   swap = true;
+   break;
+   case EXYNOS_DRM_DEGREE_0:
+   case EXYNOS_DRM_DEGREE_180:
+   swap = false;
+   break;
+   default:
+   DRM_ERROR("invalid degree.\n");
+   goto err_property;
+   }
+
for_each_ipp_ops(i) {
if ((i == EXYNOS_DRM_OPS_SRC) &&
(property->cmd == IPP_CMD_WB))
@@ -1416,21 +1443,6 @@ static int gsc_ippdrv_check_property(struct device *dev,
goto err_property;
}
 
-   /* check for degree */
-   switch (config->degree) {
-   case EXYNOS_DRM_DEGREE_90:
-   case EXYNOS_DRM_DEGREE_270:
-   swap = true;
-   break;
-   case EXYNOS_DRM_DEGREE_0:
-   case EXYNOS_DRM_DEGREE_180:
-   swap = false;
-   break;
-   default:
-   DRM_ERROR("invalid degree.\n");
-   goto err_property;
-   }
-
/* check for buffer bound */
if ((pos->x + pos->w > sz->hsize) ||
(pos->y + pos->h > sz->vsize)) {
@@ -1438,21 +1450,27 @@ static int gsc_ippdrv_check_property(struct device *dev,
goto err_property;
}
 
+   /*
+* The rotation hardware limits are related to the cropped
+* source size. So use rot_max size to check the limits when
+* swap happens. And also the scaling limits are related to pos
+* size, use pos size to check the limits.
+*/
/* check for crop */
if ((i == EXYNOS_DRM_OPS_SRC) && (pp->crop)) {
if (swap) {
if ((pos->h < pp->crop_min.hsize) ||
-   (sz->vsize > pp->crop_max.hsize) ||
+   (pos->h > pp->rot_max.hsize) ||
(pos->w < pp->crop_min.vsize) ||
-   (sz->hsize > pp->crop_max.vsize)) {
+   (pos->w > pp->rot_max.vsize)) {
DRM_ERROR("out of crop size.\n");
goto err_property;
}
} else {
if ((pos->w < pp->crop_min.hsize) ||
-   (sz->hsize > pp->crop_max.hsize) ||
+   (pos->w > pp->crop_max.hsize) ||
(pos->h < pp->crop_min.vsize) ||
-   (sz->vsize > pp->crop_max.vsize)) {
+   (pos->h > pp->crop_max.vsize)) {
DRM_ERROR("out of crop size.\n");
goto err_property;
}
@@ -1463,17 +1481,17 @@ static int gsc_ippdrv_check_property(struct device *dev,
if ((i == EXYNOS_DRM_OPS_DST) && (pp->scale)) {
if (swap) {
if ((pos->h < pp->scale_min.hsize) ||
- 

[PATCH v3 2/6] ARM: dts: exynos: Add clean name of compatible.

2017-09-08 Thread Hoegeun Kwon
Exynos 5250 and 5420 have different hardware rotation limits. However,
currently it uses only one compatible - "exynos5-gsc". Since we have
to distinguish between these two, we add different compatible.

Signed-off-by: Hoegeun Kwon 
---
 arch/arm/boot/dts/exynos5250.dtsi | 8 
 arch/arm/boot/dts/exynos5420.dtsi | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
b/arch/arm/boot/dts/exynos5250.dtsi
index 8dbeb87..bf08101 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -637,7 +637,7 @@
};
 
gsc_0:  gsc@13e0 {
-   compatible = "samsung,exynos5-gsc";
+   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5250-gsc";
reg = <0x13e0 0x1000>;
interrupts = ;
power-domains = <_gsc>;
@@ -647,7 +647,7 @@
};
 
gsc_1:  gsc@13e1 {
-   compatible = "samsung,exynos5-gsc";
+   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5250-gsc";
reg = <0x13e1 0x1000>;
interrupts = ;
power-domains = <_gsc>;
@@ -657,7 +657,7 @@
};
 
gsc_2:  gsc@13e2 {
-   compatible = "samsung,exynos5-gsc";
+   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5250-gsc";
reg = <0x13e2 0x1000>;
interrupts = ;
power-domains = <_gsc>;
@@ -667,7 +667,7 @@
};
 
gsc_3:  gsc@13e3 {
-   compatible = "samsung,exynos5-gsc";
+   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5250-gsc";
reg = <0x13e3 0x1000>;
interrupts = ;
power-domains = <_gsc>;
diff --git a/arch/arm/boot/dts/exynos5420.dtsi 
b/arch/arm/boot/dts/exynos5420.dtsi
index 02d2f89..86afe77 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -658,7 +658,7 @@
};
 
gsc_0: video-scaler@13e0 {
-   compatible = "samsung,exynos5-gsc";
+   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5420-gsc";
reg = <0x13e0 0x1000>;
interrupts = ;
clocks = < CLK_GSCL0>;
@@ -668,7 +668,7 @@
};
 
gsc_1: video-scaler@13e1 {
-   compatible = "samsung,exynos5-gsc";
+   compatible = "samsung,exynos5-gsc", 
"samsung,exynos5420-gsc";
reg = <0x13e1 0x1000>;
interrupts = ;
clocks = < CLK_GSCL1>;
-- 
1.9.1



[PATCH v3 0/6] Exynos-gsc: Support the hardware rotation limits

2017-09-08 Thread Hoegeun Kwon
Hello all,

The gscaler has hardware rotation limits. So this patch set support
the rotate hardware limits of gsc.

To avoid problems with bisectability, patches 1~4 must be merged and
then merged 5 and 6.

Changes for V3:
- Fixed of_match_node() to of_device_get_match_data() in drm gsc driver.
- Added hardware rotation limits for gsc driver of v4l2.
- Added the remove unnecessary compatible for DT document and Exynos dts.

Changes for V2:
- Added the interface info in binding document.
- Added clean name of compatible in Exynos dts.
- Added maximum supported picture size hardcoded into driver.

Best regards,
Hoegeun

Hoegeun Kwon (6):
  [media] exynos-gsc: Add compatible for Exynos 5250 and 5420 specific
version
  ARM: dts: exynos: Add clean name of compatible.
  drm/exynos/gsc: Add hardware rotation limits
  [media] exynos-gsc: Add hardware rotation limits
  [media] exynos-gsc: Remove unnecessary compatible
  ARM: dts: exynos: Remove unnecessary compatible

 .../devicetree/bindings/media/exynos5-gsc.txt  |  7 +-
 arch/arm/boot/dts/exynos5250.dtsi  |  8 +-
 arch/arm/boot/dts/exynos5420.dtsi  |  4 +-
 drivers/gpu/drm/exynos/exynos_drm_gsc.c| 93 ++---
 drivers/media/platform/exynos-gsc/gsc-core.c   | 96 +++---
 include/uapi/drm/exynos_drm.h  |  2 +
 6 files changed, 159 insertions(+), 51 deletions(-)

-- 
1.9.1



[PATCH v3 1/6] [media] exynos-gsc: Add compatible for Exynos 5250 and 5420 specific version

2017-09-08 Thread Hoegeun Kwon
Exynos 5250 and 5420 have different hardware rotation limits.
Since we have to distinguish between these two, we add different
compatible(samsung,exynos5250-gsc and samsung,exynos5420-gsc).

Signed-off-by: Hoegeun Kwon 
---
 Documentation/devicetree/bindings/media/exynos5-gsc.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/media/exynos5-gsc.txt 
b/Documentation/devicetree/bindings/media/exynos5-gsc.txt
index 26ca25b..daa56d5 100644
--- a/Documentation/devicetree/bindings/media/exynos5-gsc.txt
+++ b/Documentation/devicetree/bindings/media/exynos5-gsc.txt
@@ -5,6 +5,7 @@ G-Scaler is used for scaling and color space conversion on 
EXYNOS5 SoCs.
 Required properties:
 - compatible: should be "samsung,exynos5-gsc" (for Exynos 5250, 5420 and
  5422 SoCs) or "samsung,exynos5433-gsc" (Exynos 5433)
+ or "samsung,exynos5250-gsc" or "samsung,exynos5420-gsc"
 - reg: should contain G-Scaler physical address location and length.
 - interrupts: should contain G-Scaler interrupt number
 
-- 
1.9.1