[PATCH] uvcvideo: Implement DMABUF exporter role

2015-04-14 Thread Laurent Pinchart
Now that videobuf2-vmalloc supports exporting buffers, add support for
the DMABUF exporter role by plugging in the videobuf2 ioctl helper.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/usb/uvc/uvc_queue.c | 12 
 drivers/media/usb/uvc/uvc_v4l2.c  | 13 +
 drivers/media/usb/uvc/uvcvideo.h  |  2 ++
 3 files changed, 27 insertions(+)

diff --git a/drivers/media/usb/uvc/uvc_queue.c 
b/drivers/media/usb/uvc/uvc_queue.c
index efb9828..61a47bbe 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -272,6 +272,18 @@ int uvc_queue_buffer(struct uvc_video_queue *queue, struct 
v4l2_buffer *buf)
return ret;
 }
 
+int uvc_export_buffer(struct uvc_video_queue *queue,
+ struct v4l2_exportbuffer *exp)
+{
+   int ret;
+
+   mutex_lock(&queue->mutex);
+   ret = vb2_expbuf(&queue->queue, exp);
+   mutex_unlock(&queue->mutex);
+
+   return ret;
+}
+
 int uvc_dequeue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf,
   int nonblocking)
 {
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index c4b1ac6..69d0180 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -723,6 +723,18 @@ static int uvc_ioctl_qbuf(struct file *file, void *fh, 
struct v4l2_buffer *buf)
return uvc_queue_buffer(&stream->queue, buf);
 }
 
+static int uvc_ioctl_expbuf(struct file *file, void *fh,
+   struct v4l2_exportbuffer *exp)
+{
+   struct uvc_fh *handle = fh;
+   struct uvc_streaming *stream = handle->stream;
+
+   if (!uvc_has_privileges(handle))
+   return -EBUSY;
+
+   return uvc_export_buffer(&stream->queue, exp);
+}
+
 static int uvc_ioctl_dqbuf(struct file *file, void *fh, struct v4l2_buffer 
*buf)
 {
struct uvc_fh *handle = fh;
@@ -1478,6 +1490,7 @@ const struct v4l2_ioctl_ops uvc_ioctl_ops = {
.vidioc_reqbufs = uvc_ioctl_reqbufs,
.vidioc_querybuf = uvc_ioctl_querybuf,
.vidioc_qbuf = uvc_ioctl_qbuf,
+   .vidioc_expbuf = uvc_ioctl_expbuf,
.vidioc_dqbuf = uvc_ioctl_dqbuf,
.vidioc_create_bufs = uvc_ioctl_create_bufs,
.vidioc_streamon = uvc_ioctl_streamon,
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 2bd895c..180efb2 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -641,6 +641,8 @@ extern int uvc_create_buffers(struct uvc_video_queue *queue,
struct v4l2_create_buffers *v4l2_cb);
 extern int uvc_queue_buffer(struct uvc_video_queue *queue,
struct v4l2_buffer *v4l2_buf);
+extern int uvc_export_buffer(struct uvc_video_queue *queue,
+   struct v4l2_exportbuffer *exp);
 extern int uvc_dequeue_buffer(struct uvc_video_queue *queue,
struct v4l2_buffer *v4l2_buf, int nonblocking);
 extern int uvc_queue_streamon(struct uvc_video_queue *queue,
-- 
2.0.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH v2 0/5] Add live source objects to DRM

2015-04-14 Thread Daniel Vetter
On Mon, Apr 13, 2015 at 09:39:42PM +0300, Laurent Pinchart wrote:
> Hello,
> 
> Here's a proposal for a different approach to live source in DRM based on an
> idea by Daniel Vetter. The previous version can be found at
> http://lists.freedesktop.org/archives/dri-devel/2015-March/079319.html.

msm is also interested in a drm/v4l bridge on the capture/writeback side.
Although I haven't convinced them yet that rolling their own isn't
awesome.

> The need comes from the Renesas R-Car SoCs in which a video processing engine
> (named VSP1) that operates from memory to memory has one output directly
> connected to a plane of the display engine (DU) without going through memory.
> 
> The VSP1 is supported by a V4L2 driver. While it could be argued that it
> should instead be supported directly by the DRM rcar-du driver, this wouldn't
> be a good idea for at least two reasons. First, the R-Car SoCs contain several
> VSP1 instances, of which only a subset have a direct DU connection. The only
> other instances operate solely in memory to memory mode. Then, the VSP1 is a
> video processing engine and not a display engine. Its features are easily
> supported by the V4L2 API, but don't map to the DRM/KMS API. Significant
> changes to DRM/KMS would be required, beyond what is in my opinion an
> acceptable scope for a display API.
> 
> Now that the need to interface two separate devices supported by two different
> drivers in two separate subsystems has been established, we need an API to do
> so. It should be noted that while that API doesn't exist in the mainline
> kernel, the need isn't limited to Renesas SoCs.
> 
> This patch set proposes one possible solution for the problem in the form of a
> new DRM object named live source. Live sources are created by drivers to model
> hardware connections between a plane input and an external source, and are
> attached to planes through the KMS userspace API.
> 
> Patch 1/5 adds live source objects to DRM, with an in-kernel API for drivers
> to register the sources, and a userspace API to enumerate them.
> 
> Patch 2/5 implements connection between live sources and planes through
> framebuffers. It introduces a new live source flag for framebuffers. When a
> framebuffer is created with that flag set, a live source is associated with
> the framebuffer instead of buffer objects. The framebuffer can then be used
> with a plane to connect it with the live source. This is the biggest
> difference compared to the previous approach, and has several benefits:
> 
> - Changes are less intrusive in the DRM core
> - The implementation supports both the legacy API and atomic updates without
>   any code specific to either
> - No changes to existing drivers are needed
> - The framebuffer format and size configuration API is reused
> 
> The framebuffer format and size should ideally be validated using information
> queried directly from the driver that supports the live source device, but
> I've decided not to implement such communication between V4L2 and DRM/KMS at
> the moment to keep the proposal simple.
> 
> Patches 3/5 to 5/5 then implement support for live sources in the R-Car DU
> driver. The rcar_du_live_framebuffer structure and its associated helper
> functions could be moved to the DRM core later if other drivers need a similar
> implementation. I've decided to keep them in the rcar-du driver for now as
> it's not clear yet what other drivers might need.
> 
> Once again nothing here is set in stone.

Yeah, this looks rather nice&tidy. A few questions/ideas:
- Should we also go right ahead and add live sinks here with this and
  enumerate both live sinks and sources as live resources or something
  similar? The only big difference I see is that sinks will have different
  attachment points than sources.

- Not fully sure about possible_planes. I guess if the justification is
  that the drm core can take care of some input validation for drivers
  then it's useful. But if the idea is that userspace can use this to
  figure out the routing then I think this won't work.

- Do we need other basic checks like max/min width/height? Same concern as
  above.

- I think a live_resource_create callback would be useful so that the
  driver can check additional constraints (maybe just some size will work
  if e.g. it feeds directly into an mpeg encoder). Also I think we should
  figure out whether the addfb2 call or only attaching the live
  source/sink locks down the configuration on the v4l side of things.
  Imo locking down the settings has the advantage that you can do that all
  upfront on both v4l and drm side, and then immediately start the
  pipeline with just connecting it.

- Some helper to connect the drm and v4l side of things might be useful,
  especially to make sure you don't end up with incompatible settings on
  either end. Ties in with the above question of where we want to lock
  down the settings.

- Do we need some additional properties on live sources/sinks to at least
  m

Re: [PATCH] [media] vb2: remove unused variable

2015-04-14 Thread Marek Szyprowski

Hello,

On 2015-04-10 22:24, Arnd Bergmann wrote:

A recent bug fix removed all uses of the 'fileio' variable in
vb2_thread_stop(), which now causes warnings in a lot of
ARM defconfig builds:

drivers/media/v4l2-core/videobuf2-core.c:3228:26: warning: unused variable 
'fileio' [-Wunused-variable]

This removes the variable as well. The commit that introduced
the warning was marked for 3.18+ backports, so this should
probably be backported too.

Signed-off-by: Arnd Bergmann 
Fixes: 0e661006370b7 ("[media] vb2: fix 'UNBALANCED' warnings when calling 
vb2_thread_stop()")
Cc:   # for v3.18 and up


Acked-by: Marek Szyprowski 


diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index c11aee7db884..d3f7bf0db61e 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -3225,7 +3225,6 @@ EXPORT_SYMBOL_GPL(vb2_thread_start);
  int vb2_thread_stop(struct vb2_queue *q)
  {
struct vb2_threadio_data *threadio = q->threadio;
-   struct vb2_fileio_data *fileio = q->fileio;
int err;
  
  	if (threadio == NULL)





Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libdvbv5: Retry FE_GET_PROPERTY ioctl if it returns EAGAIN

2015-04-14 Thread David Howells
Retry the FE_GET_PROPERTY ioctl used to determine if we have a DVBv5 device
if it returns EAGAIN indicating the driver is currently locked by the kernel.

Also skip over subsequent information gathering calls to FE_GET_PROPERTY
that return EAGAIN.

Original-author: Mauro Carvalho Chehab 
Signed-off-by: David Howells 
---
 dvb-fe.c |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/libdvbv5/dvb-fe.c b/lib/libdvbv5/dvb-fe.c
index 04ad907..3657334 100644
--- a/lib/libdvbv5/dvb-fe.c
+++ b/lib/libdvbv5/dvb-fe.c
@@ -171,9 +171,12 @@ struct dvb_v5_fe_parms *dvb_fe_open_flags(int adapter, int 
frontend,
dtv_prop.props = parms->dvb_prop;
 
/* Detect a DVBv3 device */
-   if (ioctl(fd, FE_GET_PROPERTY, &dtv_prop) == -1) {
+   while (ioctl(fd, FE_GET_PROPERTY, &dtv_prop) == -1) {
+   if (errno == EAGAIN)
+   continue;
parms->dvb_prop[0].u.data = 0x300;
parms->dvb_prop[1].u.data = SYS_UNDEFINED;
+   break;
}
parms->p.version = parms->dvb_prop[0].u.data;
parms->p.current_sys = parms->dvb_prop[1].u.data;
@@ -1336,8 +1339,11 @@ int dvb_fe_get_stats(struct dvb_v5_fe_parms *p)
props.props = parms->stats.prop;
 
/* Do a DVBv5.10 stats call */
-   if (ioctl(parms->fd, FE_GET_PROPERTY, &props) == -1)
+   if (ioctl(parms->fd, FE_GET_PROPERTY, &props) == -1) {
+   if (errno == EAGAIN)
+   return 0;
goto dvbv3_fallback;
+   }
 
/*
 * All props with len=0 mean that this device doesn't have any
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] v4l: vb2: remove unused variable

2015-04-14 Thread Sudip Mukherjee
This variable was not being used anywhere.

Signed-off-by: Sudip Mukherjee 
---
 drivers/media/v4l2-core/videobuf2-core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index c11aee7..d3f7bf0 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -3225,7 +3225,6 @@ EXPORT_SYMBOL_GPL(vb2_thread_start);
 int vb2_thread_stop(struct vb2_queue *q)
 {
struct vb2_threadio_data *threadio = q->threadio;
-   struct vb2_fileio_data *fileio = q->fileio;
int err;
 
if (threadio == NULL)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


drivers/media/rc/ir-hix5hd2.c:221: warning: passing argument 1 of 'IS_ERR' discards qualifiers from pointer target type

2015-04-14 Thread kbuild test robot
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   31f7dc796998d2967e999a0f9229d8a50c7b348d
commit: 7f01308e543f33a977750bf464ae6bf3f9733cf0 [media] ir-hix5hd2: fix 
address space casting
date:   7 months ago
config: avr32-allyesconfig (attached as .config)
reproduce:
  wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
  chmod +x ~/bin/make.cross
  git checkout 7f01308e543f33a977750bf464ae6bf3f9733cf0
  # save the attached .config to linux build tree
  make.cross ARCH=avr32 

All warnings:

   drivers/media/rc/ir-hix5hd2.c: In function 'hix5hd2_ir_probe':
>> drivers/media/rc/ir-hix5hd2.c:221: warning: passing argument 1 of 'IS_ERR' 
>> discards qualifiers from pointer target type
>> drivers/media/rc/ir-hix5hd2.c:222: warning: passing argument 1 of 'PTR_ERR' 
>> discards qualifiers from pointer target type

vim +/IS_ERR +221 drivers/media/rc/ir-hix5hd2.c

   215  dev_err(dev, "no power-reg\n");
   216  return -EINVAL;
   217  }
   218  
   219  res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   220  priv->base = devm_ioremap_resource(dev, res);
 > 221  if (IS_ERR((__force void *)priv->base))
 > 222  return PTR_ERR((__force void *)priv->base);
   223  
   224  priv->irq = platform_get_irq(pdev, 0);
   225  if (priv->irq < 0) {

---
0-DAY kernel test infrastructureOpen Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
#
# Automatically generated file; DO NOT EDIT.
# Linux/avr32 3.17.0-rc5 Kernel Configuration
#
CONFIG_AVR32=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_TRACE_IRQFLAGS_SUPPORT=y
CONFIG_RWSEM_GENERIC_SPINLOCK=y
# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
# CONFIG_ARCH_HAS_ILOG2_U32 is not set
# CONFIG_ARCH_HAS_ILOG2_U64 is not set
CONFIG_GENERIC_HWEIGHT=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_GENERIC_BUG=y
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
CONFIG_CONSTRUCTORS=y
CONFIG_IRQ_WORK=y

#
# General setup
#
CONFIG_BROKEN_ON_SMP=y
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
CONFIG_COMPILE_TEST=y
CONFIG_LOCALVERSION=""
CONFIG_LOCALVERSION_AUTO=y
CONFIG_DEFAULT_HOSTNAME="(none)"
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
CONFIG_SYSVIPC_SYSCTL=y
CONFIG_POSIX_MQUEUE=y
CONFIG_POSIX_MQUEUE_SYSCTL=y
CONFIG_CROSS_MEMORY_ATTACH=y
CONFIG_FHANDLE=y
CONFIG_USELIB=y
CONFIG_AUDIT=y

#
# IRQ subsystem
#
CONFIG_GENERIC_IRQ_PROBE=y
CONFIG_GENERIC_IRQ_SHOW=y
CONFIG_HARDIRQS_SW_RESEND=y
CONFIG_IRQ_DOMAIN=y
CONFIG_IRQ_DOMAIN_DEBUG=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_GENERIC_CLOCKEVENTS_BUILD=y

#
# Timers subsystem
#
CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y

#
# CPU/Task time and stats accounting
#
CONFIG_TICK_CPU_ACCOUNTING=y
CONFIG_BSD_PROCESS_ACCT=y
CONFIG_BSD_PROCESS_ACCT_V3=y
CONFIG_TASKSTATS=y
CONFIG_TASK_DELAY_ACCT=y
CONFIG_TASK_XACCT=y
CONFIG_TASK_IO_ACCOUNTING=y

#
# RCU Subsystem
#
CONFIG_TINY_RCU=y
# CONFIG_PREEMPT_RCU is not set
CONFIG_RCU_STALL_COMMON=y
# CONFIG_TREE_RCU_TRACE is not set
CONFIG_BUILD_BIN2C=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_LOG_BUF_SHIFT=17
CONFIG_LOG_CPU_MAX_BUF_SHIFT=12
CONFIG_CGROUPS=y
CONFIG_CGROUP_DEBUG=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CPUSETS=y
CONFIG_PROC_PID_CPUSET=y
# CONFIG_CGROUP_CPUACCT is not set
CONFIG_RESOURCE_COUNTERS=y
CONFIG_MEMCG=y
CONFIG_MEMCG_SWAP=y
CONFIG_MEMCG_SWAP_ENABLED=y
CONFIG_MEMCG_KMEM=y
CONFIG_CGROUP_SCHED=y
CONFIG_FAIR_GROUP_SCHED=y
CONFIG_CFS_BANDWIDTH=y
CONFIG_RT_GROUP_SCHED=y
CONFIG_BLK_CGROUP=y
CONFIG_DEBUG_BLK_CGROUP=y
CONFIG_CHECKPOINT_RESTORE=y
CONFIG_NAMESPACES=y
CONFIG_UTS_NS=y
CONFIG_IPC_NS=y
CONFIG_USER_NS=y
CONFIG_PID_NS=y
CONFIG_NET_NS=y
CONFIG_SCHED_AUTOGROUP=y
CONFIG_SYSFS_DEPRECATED=y
CONFIG_SYSFS_DEPRECATED_V2=y
CONFIG_RELAY=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=""
CONFIG_RD_GZIP=y
CONFIG_RD_BZIP2=y
CONFIG_RD_LZMA=y
CONFIG_RD_XZ=y
CONFIG_RD_LZO=y
CONFIG_RD_LZ4=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_SYSCTL=y
CONFIG_ANON_INODES=y
CONFIG_EXPERT=y
CONFIG_SGETMASK_SYSCALL=y
CONFIG_SYSFS_SYSCALL=y
CONFIG_SYSCTL_SYSCALL=y
CONFIG_KALLSYMS=y
CONFIG_KALLSYMS_ALL=y
CONFIG_PRINTK=y
CONFIG_BUG=y
CONFIG_ELF_CORE=y
CONFIG_BASE_FULL=y
CONFIG_FUTEX=y
CONFIG_EPOLL=y
CONFIG_SIGNALFD=y
CONFIG_TIMERFD=y
CONFIG_EVENTFD=y
CONFIG_SHMEM=y
CONFIG_AIO=y
CONFIG_EMBEDDED=y

#
# Kernel Performance Events And Counters
#
CONFIG_VM_EVENT_COUNTERS=y
CONFIG_SLUB_DEBUG=y
CONFIG_COMPAT_BRK=y
# CONFIG_SLAB is not set
CONFIG_SLUB=y
# CONFIG_SLOB is not set
CONFIG_SYSTEM_TRUSTED_KEYRING=y
CONFIG_PROFILING=y
CONFIG_TRACEPOINTS=y
CONFIG_OPROFILE=y
CONFIG_HAVE_OPROFILE=y
CONFIG_KPROBES=y
# CONFIG_UPROBES is not set
# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
CONFIG_HAVE_KPROBES=y
CONFIG_HAVE_CLK=y
CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG=y
CONF

drivers/media/rc/st_rc.c:270: warning: passing argument 1 of 'IS_ERR' discards qualifiers from pointer target type

2015-04-14 Thread kbuild test robot
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   31f7dc796998d2967e999a0f9229d8a50c7b348d
commit: 8f8218e89d5500f5d53556a3e0739d1ffc591aa1 [media] st_rc: fix address 
space casting
date:   7 months ago
config: avr32-allyesconfig (attached as .config)
reproduce:
  wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
  chmod +x ~/bin/make.cross
  git checkout 8f8218e89d5500f5d53556a3e0739d1ffc591aa1
  # save the attached .config to linux build tree
  make.cross ARCH=avr32 

All warnings:

   drivers/media/rc/st_rc.c: In function 'st_rc_probe':
>> drivers/media/rc/st_rc.c:270: warning: passing argument 1 of 'IS_ERR' 
>> discards qualifiers from pointer target type
>> drivers/media/rc/st_rc.c:271: warning: passing argument 1 of 'PTR_ERR' 
>> discards qualifiers from pointer target type

vim +/IS_ERR +270 drivers/media/rc/st_rc.c

   264  goto err;
   265  }
   266  
   267  res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   268  
   269  rc_dev->base = devm_ioremap_resource(dev, res);
 > 270  if (IS_ERR((__force void *)rc_dev->base)) {
 > 271  ret = PTR_ERR((__force void *)rc_dev->base);
   272  goto err;
   273  }
   274  

---
0-DAY kernel test infrastructureOpen Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
#
# Automatically generated file; DO NOT EDIT.
# Linux/avr32 3.17.0-rc5 Kernel Configuration
#
CONFIG_AVR32=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_TRACE_IRQFLAGS_SUPPORT=y
CONFIG_RWSEM_GENERIC_SPINLOCK=y
# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
# CONFIG_ARCH_HAS_ILOG2_U32 is not set
# CONFIG_ARCH_HAS_ILOG2_U64 is not set
CONFIG_GENERIC_HWEIGHT=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_GENERIC_BUG=y
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
CONFIG_CONSTRUCTORS=y
CONFIG_IRQ_WORK=y

#
# General setup
#
CONFIG_BROKEN_ON_SMP=y
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
CONFIG_COMPILE_TEST=y
CONFIG_LOCALVERSION=""
CONFIG_LOCALVERSION_AUTO=y
CONFIG_DEFAULT_HOSTNAME="(none)"
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
CONFIG_SYSVIPC_SYSCTL=y
CONFIG_POSIX_MQUEUE=y
CONFIG_POSIX_MQUEUE_SYSCTL=y
CONFIG_CROSS_MEMORY_ATTACH=y
CONFIG_FHANDLE=y
CONFIG_USELIB=y
CONFIG_AUDIT=y

#
# IRQ subsystem
#
CONFIG_GENERIC_IRQ_PROBE=y
CONFIG_GENERIC_IRQ_SHOW=y
CONFIG_HARDIRQS_SW_RESEND=y
CONFIG_IRQ_DOMAIN=y
CONFIG_IRQ_DOMAIN_DEBUG=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_GENERIC_CLOCKEVENTS_BUILD=y

#
# Timers subsystem
#
CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y

#
# CPU/Task time and stats accounting
#
CONFIG_TICK_CPU_ACCOUNTING=y
CONFIG_BSD_PROCESS_ACCT=y
CONFIG_BSD_PROCESS_ACCT_V3=y
CONFIG_TASKSTATS=y
CONFIG_TASK_DELAY_ACCT=y
CONFIG_TASK_XACCT=y
CONFIG_TASK_IO_ACCOUNTING=y

#
# RCU Subsystem
#
CONFIG_TINY_RCU=y
# CONFIG_PREEMPT_RCU is not set
CONFIG_RCU_STALL_COMMON=y
# CONFIG_TREE_RCU_TRACE is not set
CONFIG_BUILD_BIN2C=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_LOG_BUF_SHIFT=17
CONFIG_LOG_CPU_MAX_BUF_SHIFT=12
CONFIG_CGROUPS=y
CONFIG_CGROUP_DEBUG=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CPUSETS=y
CONFIG_PROC_PID_CPUSET=y
# CONFIG_CGROUP_CPUACCT is not set
CONFIG_RESOURCE_COUNTERS=y
CONFIG_MEMCG=y
CONFIG_MEMCG_SWAP=y
CONFIG_MEMCG_SWAP_ENABLED=y
CONFIG_MEMCG_KMEM=y
CONFIG_CGROUP_SCHED=y
CONFIG_FAIR_GROUP_SCHED=y
CONFIG_CFS_BANDWIDTH=y
CONFIG_RT_GROUP_SCHED=y
CONFIG_BLK_CGROUP=y
CONFIG_DEBUG_BLK_CGROUP=y
CONFIG_CHECKPOINT_RESTORE=y
CONFIG_NAMESPACES=y
CONFIG_UTS_NS=y
CONFIG_IPC_NS=y
CONFIG_USER_NS=y
CONFIG_PID_NS=y
CONFIG_NET_NS=y
CONFIG_SCHED_AUTOGROUP=y
CONFIG_SYSFS_DEPRECATED=y
CONFIG_SYSFS_DEPRECATED_V2=y
CONFIG_RELAY=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=""
CONFIG_RD_GZIP=y
CONFIG_RD_BZIP2=y
CONFIG_RD_LZMA=y
CONFIG_RD_XZ=y
CONFIG_RD_LZO=y
CONFIG_RD_LZ4=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_SYSCTL=y
CONFIG_ANON_INODES=y
CONFIG_EXPERT=y
CONFIG_SGETMASK_SYSCALL=y
CONFIG_SYSFS_SYSCALL=y
CONFIG_SYSCTL_SYSCALL=y
CONFIG_KALLSYMS=y
CONFIG_KALLSYMS_ALL=y
CONFIG_PRINTK=y
CONFIG_BUG=y
CONFIG_ELF_CORE=y
CONFIG_BASE_FULL=y
CONFIG_FUTEX=y
CONFIG_EPOLL=y
CONFIG_SIGNALFD=y
CONFIG_TIMERFD=y
CONFIG_EVENTFD=y
CONFIG_SHMEM=y
CONFIG_AIO=y
CONFIG_EMBEDDED=y

#
# Kernel Performance Events And Counters
#
CONFIG_VM_EVENT_COUNTERS=y
CONFIG_SLUB_DEBUG=y
CONFIG_COMPAT_BRK=y
# CONFIG_SLAB is not set
CONFIG_SLUB=y
# CONFIG_SLOB is not set
CONFIG_SYSTEM_TRUSTED_KEYRING=y
CONFIG_PROFILING=y
CONFIG_TRACEPOINTS=y
CONFIG_OPROFILE=y
CONFIG_HAVE_OPROFILE=y
CONFIG_KPROBES=y
# CONFIG_UPROBES is not set
# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
CONFIG_HAVE_KPROBES=y
CONFIG_HAVE_CLK=y
CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG=y
CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
# CONFIG_CC_STACKPROTECTOR is not set
CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
CONFIG_MODULE

[PATCH] [media] ir-hix5hd2: Fix build warning

2015-04-14 Thread Fabio Estevam
Building for avr32 leads the following build warning:

drivers/media/rc/ir-hix5hd2.c:221: warning: passing argument 1 of 'IS_ERR' 
discards qualifiers from pointer target type
drivers/media/rc/ir-hix5hd2.c:222: warning: passing argument 1 of 'PTR_ERR' 
discards qualifiers from pointer target type

devm_ioremap_resource() returns void __iomem *, so change 'base' definition 
accordingly.

Reported-by: kbuild test robot 
Signed-off-by: Fabio Estevam 
---
 drivers/media/rc/ir-hix5hd2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/ir-hix5hd2.c b/drivers/media/rc/ir-hix5hd2.c
index 58ec598..3385148 100644
--- a/drivers/media/rc/ir-hix5hd2.c
+++ b/drivers/media/rc/ir-hix5hd2.c
@@ -63,7 +63,7 @@
 
 struct hix5hd2_ir_priv {
int irq;
-   void volatile __iomem   *base;
+   void __iomem*base;
struct device   *dev;
struct rc_dev   *rdev;
struct regmap   *regmap;
@@ -213,8 +213,8 @@ static int hix5hd2_ir_probe(struct platform_device *pdev)
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
priv->base = devm_ioremap_resource(dev, res);
-   if (IS_ERR((__force void *)priv->base))
-   return PTR_ERR((__force void *)priv->base);
+   if (IS_ERR(priv->base))
+   return PTR_ERR(priv->base);
 
priv->irq = platform_get_irq(pdev, 0);
if (priv->irq < 0) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] st_rc: fix build warning

2015-04-14 Thread Fabio Estevam
From: Fabio Estevam 

Building for avr32 leads the following build warning:

drivers/media/rc/st_rc.c:270: warning: passing argument 1 of 'IS_ERR' discards 
qualifiers from pointer target type
drivers/media/rc/st_rc.c:271: warning: passing argument 1 of 'PTR_ERR' discards 
qualifiers from pointer target type

devm_ioremap_resource() returns void __iomem *, so change 'base' and 
'rx_base' definitions accordingly.

Reported-by: kbuild test robot 
Signed-off-by: Fabio Estevam 
---
 drivers/media/rc/st_rc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c
index 0e758ae..fb5c3c8 100644
--- a/drivers/media/rc/st_rc.c
+++ b/drivers/media/rc/st_rc.c
@@ -22,8 +22,8 @@ struct st_rc_device {
int irq;
int irq_wake;
struct clk  *sys_clock;
-   volatile void __iomem   *base;  /* Register base address */
-   volatile void __iomem   *rx_base;/* RX Register base address */
+   void __iomem*base;  /* Register base address */
+   void __iomem*rx_base;/* RX Register base address */
struct rc_dev   *rdev;
booloverclocking;
int sample_mult;
@@ -267,8 +267,8 @@ static int st_rc_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
rc_dev->base = devm_ioremap_resource(dev, res);
-   if (IS_ERR((__force void *)rc_dev->base)) {
-   ret = PTR_ERR((__force void *)rc_dev->base);
+   if (IS_ERR(rc_dev->base)) {
+   ret = PTR_ERR(rc_dev->base);
goto err;
}
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH/RFC 1/2] v4l: Repurpose the v4l2_plane data_offset field

2015-04-14 Thread Laurent Pinchart
The data_offset field has been introduced along with the multiplane API
to convey header size information between kernelspace and userspace.
It's not used by any mainline driver except vivid (for testing purpose).

A different data offset is needed to allow data capture to or data
output from a userspace-selected offset within a buffer (mainly for the
DMABUF and MMAP memory types). As the data_offset field already has the
right name and is unused, repurpose it.

Signed-off-by: Laurent Pinchart 
---
 Documentation/DocBook/media/v4l/io.xml | 19 +++
 include/uapi/linux/videodev2.h |  6 --
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index 1c17f80..416c05a 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -870,7 +870,7 @@ should set this to 0.
  If the application sets this to 0 for an output stream, then
  bytesused will be set to the size of 
the
  plane (see the length field of this 
struct)
- by the driver. Note that the actual image data starts at
+ by the driver. Note that the actual plane data content starts at
  data_offset which may not be 0.
  
  
@@ -917,13 +917,16 @@ should set this to 0.
__u32
data_offset

-   Offset in bytes to video data in the plane.
- Drivers must set this field when type
- refers to an input stream, applications when it refers to an 
output stream.
- Note that data_offset is included in 
bytesused.
- So the size of the image in the plane is
- 
bytesused-data_offset at
- offset data_offset from the start of 
the plane.
+   Offset in bytes from the start of the plane buffer to the 
start of
+ captured or output data. Applications set this field for all 
stream types
+ when calling the VIDIOC_PREPARE_BUF or
+ VIDIOC_QBUF ioctls to instruct 
the driver
+ to capture or output data starting at an offset in the plane 
buffer. If the
+ requested data offset doesn't match device or driver constraints, 
device
+ drivers must return the &EINVAL; and either leave the field value 
untouched
+ if they support data offsets, or set it to 0 if they don't 
support data
+ offsets at all. Note that data_offset 
is not
+ included in bytesused.

  
  
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index fa376f7..261fb66 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -706,8 +706,10 @@ struct v4l2_requestbuffers {
  * pointing to this plane
  * @fd:when memory is V4L2_MEMORY_DMABUF, a userspace 
file
  * descriptor associated with this plane
- * @data_offset:   offset in the plane to the start of data; usually 0,
- * unless there is a header in front of the data
+ * @data_offset:   offset in bytes from the start of the plane buffer to
+ * the start of data; usually 0 unless applications need to
+ * capture data to or output data from elsewhere than the
+ * start of the buffer
  *
  * Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer
  * with two planes can have one plane for Y, and another for interleaved CbCr
-- 
2.0.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH/RFC 2/2] videobuf2: Repurpose the v4l2_plane data_offset field

2015-04-14 Thread Laurent Pinchart
The v4l2_plane data_offset field has been repurposed in the V4L2 API.
Update videobuf2 accordingly.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/v4l2-core/videobuf2-core.c | 46 +++-
 include/media/videobuf2-core.h   |  4 +++
 include/media/videobuf2-dma-contig.h |  2 +-
 3 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 1329dcc..43f8fc5 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -572,15 +572,29 @@ static int __verify_planes_array(struct vb2_buffer *vb, 
const struct v4l2_buffer
 }
 
 /**
- * __verify_length() - Verify that the bytesused value for each plane fits in
- * the plane length and that the data offset doesn't exceed the bytesused 
value.
+ * __verify_length() - Verify for each plane that the data_offset matches 
driver
+ * constraints and that the bytesused plus data_offset value fits in the plane
+ * length.
  */
-static int __verify_length(struct vb2_buffer *vb, const struct v4l2_buffer *b)
+static int __verify_length(struct vb2_buffer *vb, struct v4l2_buffer *b)
 {
unsigned int length;
unsigned int bytesused;
+   unsigned int size;
unsigned int plane;
 
+   if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
+   unsigned int mask = vb->vb2_queue->data_offset_mask;
+
+   for (plane = 0; plane < vb->num_planes; ++plane) {
+   if (b->m.planes[plane].data_offset & ~mask) {
+   if (!mask)
+   b->m.planes[plane].data_offset = 0;
+   return -EINVAL;
+   }
+   }
+   }
+
if (!V4L2_TYPE_IS_OUTPUT(b->type))
return 0;
 
@@ -590,14 +604,16 @@ static int __verify_length(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
  b->memory == V4L2_MEMORY_DMABUF)
   ? b->m.planes[plane].length
   : vb->v4l2_planes[plane].length;
-   bytesused = b->m.planes[plane].bytesused
- ? b->m.planes[plane].bytesused : length;
 
-   if (b->m.planes[plane].bytesused > length)
+   if (b->m.planes[plane].data_offset >= length)
return -EINVAL;
 
-   if (b->m.planes[plane].data_offset > 0 &&
-   b->m.planes[plane].data_offset >= bytesused)
+   size = b->m.planes[plane].bytesused
++ b->m.planes[plane].data_offset;
+
+   /* Protect against integer overflows. */
+   if (size < b->m.planes[plane].bytesused ||
+   size > length)
return -EINVAL;
}
} else {
@@ -1122,11 +1138,13 @@ EXPORT_SYMBOL_GPL(vb2_create_bufs);
  */
 void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no)
 {
+   void *addr;
+
if (plane_no > vb->num_planes || !vb->planes[plane_no].mem_priv)
return NULL;
 
-   return call_ptr_memop(vb, vaddr, vb->planes[plane_no].mem_priv);
-
+   addr = call_ptr_memop(vb, vaddr, vb->planes[plane_no].mem_priv);
+   return addr + vb->v4l2_planes[plane_no].data_offset;
 }
 EXPORT_SYMBOL_GPL(vb2_plane_vaddr);
 
@@ -1258,6 +1276,11 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
}
 
if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
+   for (plane = 0; plane < vb->num_planes; ++plane) {
+   v4l2_planes[plane].data_offset =
+   b->m.planes[plane].data_offset;
+   }
+
if (b->memory == V4L2_MEMORY_USERPTR) {
for (plane = 0; plane < vb->num_planes; ++plane) {
v4l2_planes[plane].m.userptr =
@@ -1302,7 +1325,6 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
else
pdst->bytesused = psrc->bytesused ?
psrc->bytesused : pdst->length;
-   pdst->data_offset = psrc->data_offset;
}
}
} else {
@@ -1618,7 +1640,7 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
call_void_vb_qop(vb, buf_queue, vb);
 }
 
-static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b)
+static int __buf_prepare(struct vb2_buffer *vb, struct v4l2_buffer *b)
 {
struct vb2_queue *q = vb->vb2_queue;
int ret;
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index a5790fd..c51c481 100644
--- a/include/media/

[PATCH/RFC 0/2] Repurpose the v4l2_plane data_offset field

2015-04-14 Thread Laurent Pinchart
Hello,

The v4l2_plane data_offset field has been introduced at the same time as the
the multiplane API to convey header size information between kernelspace and
userspace.

The API then became slightly controversial, both because different developers
understood the purpose of the field differently (resulting for instance in an
out-of-tree driver abusing the field for a different purpose), and because of
competing proposals (see for instance "[RFC] Multi format stream support" at
http://www.spinics.net/lists/linux-media/msg69130.html).

Furthermore, the data_offset field isn't used by any mainline driver except
vivid (for testing purpose).

I need a different data offset in planes to allow data capture to or data
output from a userspace-selected offset within a buffer (mainly for the
DMABUF and MMAP memory types). As the data_offset field already has the
right name, is unused, and ill-defined, I propose repurposing it. This is what
this RFC is about.

If the proposal is accepted I'll add another patch to update data_offset usage
in the vivid driver.

Laurent Pinchart (2):
  v4l: Repurpose the v4l2_plane data_offset field
  videobuf2: Repurpose the v4l2_plane data_offset field

 Documentation/DocBook/media/v4l/io.xml   | 19 +++--
 drivers/media/v4l2-core/videobuf2-core.c | 46 +++-
 include/media/videobuf2-core.h   |  4 +++
 include/media/videobuf2-dma-contig.h |  2 +-
 include/uapi/linux/videodev2.h   |  6 +++--
 5 files changed, 54 insertions(+), 23 deletions(-)

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC 1/2] v4l: Repurpose the v4l2_plane data_offset field

2015-04-14 Thread Sakari Ailus
Hi Laurent,

Thank you for the patchset.

On Tue, Apr 14, 2015 at 10:44:48PM +0300, Laurent Pinchart wrote:
> The data_offset field has been introduced along with the multiplane API
> to convey header size information between kernelspace and userspace.
> It's not used by any mainline driver except vivid (for testing purpose).
> 
> A different data offset is needed to allow data capture to or data
> output from a userspace-selected offset within a buffer (mainly for the
> DMABUF and MMAP memory types). As the data_offset field already has the
> right name and is unused, repurpose it.
> 
> Signed-off-by: Laurent Pinchart 
> ---
>  Documentation/DocBook/media/v4l/io.xml | 19 +++
>  include/uapi/linux/videodev2.h |  6 --
>  2 files changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/Documentation/DocBook/media/v4l/io.xml 
> b/Documentation/DocBook/media/v4l/io.xml
> index 1c17f80..416c05a 100644
> --- a/Documentation/DocBook/media/v4l/io.xml
> +++ b/Documentation/DocBook/media/v4l/io.xml
> @@ -870,7 +870,7 @@ should set this to 0.
> If the application sets this to 0 for an output stream, then
> bytesused will be set to the size of 
> the
> plane (see the length field of this 
> struct)
> -   by the driver. Note that the actual image data starts at
> +   by the driver. Note that the actual plane data content starts at
> data_offset which may not be 0.
> 
> 
> @@ -917,13 +917,16 @@ should set this to 0.
>   __u32
>   data_offset
>   
> - Offset in bytes to video data in the plane.
> -   Drivers must set this field when type
> -   refers to an input stream, applications when it refers to an 
> output stream.
> -   Note that data_offset is included in 
> bytesused.
> -   So the size of the image in the plane is
> -   
> bytesused-data_offset at
> -   offset data_offset from the start of 
> the plane.
> + Offset in bytes from the start of the plane buffer to the 
> start of
> +   captured or output data. Applications set this field for all 
> stream types
> +   when calling the  linkend="vidioc-qbuf">VIDIOC_PREPARE_BUF or
> +   VIDIOC_QBUF ioctls to instruct 
> the driver
> +   to capture or output data starting at an offset in the plane 
> buffer. If the
> +   requested data offset doesn't match device or driver constraints, 
> device
> +   drivers must return the &EINVAL; and either leave the field value 
> untouched
> +   if they support data offsets, or set it to 0 if they don't 
> support data
> +   offsets at all. Note that data_offset 
> is not
> +   included in bytesused.

At most 80 characters per line would be nice.

How does the user discover what data_offsets are possible if the driver
returns an error if the data_offset does not match hardware capabilities?

I'd rather have the driver to adjust data_offset to match what it can do. If
the user needs to know that the data_offset was not modified, it should
check the field value after QBUF/PREPARE_BUF.

>   
> 
> 
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> index fa376f7..261fb66 100644
> --- a/include/uapi/linux/videodev2.h
> +++ b/include/uapi/linux/videodev2.h
> @@ -706,8 +706,10 @@ struct v4l2_requestbuffers {
>   *   pointing to this plane
>   * @fd:  when memory is V4L2_MEMORY_DMABUF, a userspace 
> file
>   *   descriptor associated with this plane
> - * @data_offset: offset in the plane to the start of data; usually 0,
> - *   unless there is a header in front of the data
> + * @data_offset: offset in bytes from the start of the plane buffer to
> + *   the start of data; usually 0 unless applications need to
> + *   capture data to or output data from elsewhere than the
> + *   start of the buffer
>   *
>   * Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer
>   * with two planes can have one plane for Y, and another for interleaved CbCr

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cron job: media_tree daily build: ERRORS

2015-04-14 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:   Wed Apr 15 04:00:22 CEST 2015
git branch: test
git hash:   e183201b9e917daf2530b637b2f34f1d5afb934d
gcc version:i686-linux-gcc (GCC) 4.9.1
sparse version: v0.5.0-44-g40791b9
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:3.19.0-1.slh.1-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: WARNINGS
linux-git-m32r: OK
linux-git-mips: WARNINGS
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.32.27-i686: ERRORS
linux-2.6.33.7-i686: ERRORS
linux-2.6.34.7-i686: ERRORS
linux-2.6.35.9-i686: ERRORS
linux-2.6.36.4-i686: ERRORS
linux-2.6.37.6-i686: ERRORS
linux-2.6.38.8-i686: WARNINGS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12.23-i686: OK
linux-3.13.11-i686: ERRORS
linux-3.14.9-i686: ERRORS
linux-3.15.2-i686: ERRORS
linux-3.16.7-i686: ERRORS
linux-3.17.8-i686: WARNINGS
linux-3.18.7-i686: WARNINGS
linux-3.19-i686: WARNINGS
linux-4.0-rc1-i686: WARNINGS
linux-2.6.32.27-x86_64: ERRORS
linux-2.6.33.7-x86_64: ERRORS
linux-2.6.34.7-x86_64: ERRORS
linux-2.6.35.9-x86_64: ERRORS
linux-2.6.36.4-x86_64: ERRORS
linux-2.6.37.6-x86_64: ERRORS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12.23-x86_64: OK
linux-3.13.11-x86_64: ERRORS
linux-3.14.9-x86_64: ERRORS
linux-3.15.2-x86_64: ERRORS
linux-3.16.7-x86_64: ERRORS
linux-3.17.8-x86_64: OK
linux-3.18.7-x86_64: OK
linux-3.19-x86_64: OK
linux-4.0-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 00/10] LED / flash API integration

2015-04-14 Thread Jacek Anaszewski
This is a fifth non-RFC version of LED / flash API integration
series [1]. It is based on linux-next_linux_next-20150414.


Changes since v4

- adapted leds-max77693 and leds-aat1290 drivers to the recent
  modifications in leds/common.txt bindings documentation and
  changed the behaviour when properties are missing
- modified DT bindings documenation for the aforementioned
  drivers
- removed unjustified use of goto in the leds-aat1290 driver
- fixed lack of of_node_put in leds-aat1290 driver, after parsing
  DT child node 
- removed patch adding 'skyworks' vendor prefix, as the entry
  has been recently added


Changes since v2

- improved leds/common DT bindings documentation
- improved max77693-led DT documentation
- fixed validation of DT confguration for leds-max77693 by
  minimal values in joint iouts case
- removed trigger-type property from leds-max77693 bindings
  and adjusted the driver accordingly
- improved LED Flash class documentation related to v4l2-flash sub-device
  initialization
- excluded from leds-aat1290 DT bindings documentation the part
  related to handling external strobe sources


Changes since v1


- excluded exynos4-is media device related patches, as there is
  consenus required related to flash devices handling in media device
  DT bindings
- modifications around LED Flash class settings and v4l2 flash config
  initialization in LED Flash class drivers and v4l2-flash wrapper
- switched to using DT node name as a device name for leds-max77693
  and leds-aat1290 drivers, in case DT 'label' property is absent
- dropped OF dependecy for v4l2-flash wrapper
- moved LED_FAULTS definitions from led-class-flash.h to uapi/linux/leds.h
- allowed for multiple clients of v4l2-flash sub-device

==
Changes since RFC v13:
==

- reduced number of patches - some of them have been merged
- slightly modified max77693-led device naming
- fixed issues in v4l2-flash helpers detected with yavta
- cleaned up AAT1290 device tree documentation
- added GPIOLIB dependecy to AAT1290 related entry in Kconfig

Thanks,
Jacek Anaszewski

[1] http://www.spinics.net/lists/kernel/msg1944538.html

Jacek Anaszewski (10):
  leds: unify the location of led-trigger API
  DT: Add documentation for the mfd Maxim max77693
  leds: Add support for max77693 mfd flash cell
  DT: Add documentation for the Skyworks AAT1290
  leds: Add driver for AAT1290 flash LED controller
  media: Add registration helpers for V4L2 flash sub-devices
  Documentation: leds: Add description of v4l2-flash sub-device
  leds: max77693: add support for V4L2 Flash sub-device
  DT: aat1290: Document handling external strobe sources
  leds: aat1290: add support for V4L2 Flash sub-device

 .../devicetree/bindings/leds/leds-aat1290.txt  |   73 ++
 Documentation/devicetree/bindings/mfd/max77693.txt |   67 ++
 Documentation/leds/leds-class-flash.txt|   47 +
 drivers/leds/Kconfig   |   19 +
 drivers/leds/Makefile  |2 +
 drivers/leds/leds-aat1290.c|  577 ++
 drivers/leds/leds-max77693.c   | 1100 
 drivers/leds/leds.h|   24 -
 drivers/media/v4l2-core/Kconfig|   11 +
 drivers/media/v4l2-core/Makefile   |2 +
 drivers/media/v4l2-core/v4l2-flash.c   |  619 +++
 include/linux/leds.h   |   25 +
 include/media/v4l2-flash.h |  145 +++
 13 files changed, 2687 insertions(+), 24 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-aat1290.txt
 create mode 100644 drivers/leds/leds-aat1290.c
 create mode 100644 drivers/leds/leds-max77693.c
 create mode 100644 drivers/media/v4l2-core/v4l2-flash.c
 create mode 100644 include/media/v4l2-flash.h

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 08/10] leds: max77693: add support for V4L2 Flash sub-device

2015-04-14 Thread Jacek Anaszewski
Add support for V4L2 Flash sub-device to the max77693 LED Flash class
driver. The support allows for V4L2 Flash sub-device to take the control
of the LED Flash class device.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
Cc: Bryan Wu 
Cc: Richard Purdie 
Cc: Sakari Ailus 
---
 drivers/leds/leds-max77693.c |  128 --
 1 file changed, 122 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/leds-max77693.c b/drivers/leds/leds-max77693.c
index d2b9611..52a66f4 100644
--- a/drivers/leds/leds-max77693.c
+++ b/drivers/leds/leds-max77693.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MODE_OFF   0
 #define MODE_FLASH(a)  (1 << (a))
@@ -62,6 +63,8 @@ struct max77693_sub_led {
struct led_classdev_flash fled_cdev;
/* assures led-triggers compatibility */
struct work_struct work_brightness_set;
+   /* V4L2 Flash device */
+   struct v4l2_flash *v4l2_flash;
 
/* brightness cache */
unsigned int torch_brightness;
@@ -634,7 +637,8 @@ static int max77693_led_flash_timeout_set(
 }
 
 static int max77693_led_parse_dt(struct max77693_led_device *led,
-   struct max77693_led_config_data *cfg)
+   struct max77693_led_config_data *cfg,
+   struct device_node **sub_nodes)
 {
struct device *dev = &led->pdev->dev;
struct max77693_sub_led *sub_leds = led->sub_leds;
@@ -679,6 +683,13 @@ static int max77693_led_parse_dt(struct 
max77693_led_device *led,
return -EINVAL;
}
 
+   if (sub_nodes[fled_id]) {
+   dev_err(dev,
+   "Conflicting \"led-sources\" DT properties\n");
+   return -EINVAL;
+   }
+
+   sub_nodes[fled_id] = child_node;
sub_leds[fled_id].fled_id = fled_id;
 
cfg->label[fled_id] =
@@ -789,11 +800,12 @@ static void max77693_led_validate_configuration(struct 
max77693_led_device *led,
 }
 
 static int max77693_led_get_configuration(struct max77693_led_device *led,
-   struct max77693_led_config_data *cfg)
+   struct max77693_led_config_data *cfg,
+   struct device_node **sub_nodes)
 {
int ret;
 
-   ret = max77693_led_parse_dt(led, cfg);
+   ret = max77693_led_parse_dt(led, cfg, sub_nodes);
if (ret < 0)
return ret;
 
@@ -841,6 +853,66 @@ static void max77693_init_flash_settings(struct 
max77693_sub_led *sub_led,
setting->val = setting->max;
 }
 
+#if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS)
+
+static int max77693_led_external_strobe_set(
+   struct v4l2_flash *v4l2_flash,
+   bool enable)
+{
+   struct max77693_sub_led *sub_led =
+   flcdev_to_sub_led(v4l2_flash->fled_cdev);
+   struct max77693_led_device *led = sub_led_to_led(sub_led);
+   int fled_id = sub_led->fled_id;
+   int ret;
+
+   mutex_lock(&led->lock);
+
+   if (enable)
+   ret = max77693_add_mode(led, MODE_FLASH_EXTERNAL(fled_id));
+   else
+   ret = max77693_clear_mode(led, MODE_FLASH_EXTERNAL(fled_id));
+
+   mutex_unlock(&led->lock);
+
+   return ret;
+}
+
+static void max77693_init_v4l2_flash_config(struct max77693_sub_led *sub_led,
+   struct max77693_led_config_data *led_cfg,
+   struct v4l2_flash_config *v4l2_sd_cfg)
+{
+   struct max77693_led_device *led = sub_led_to_led(sub_led);
+   struct device *dev = &led->pdev->dev;
+   struct max77693_dev *iodev = dev_get_drvdata(dev->parent);
+   struct i2c_client *i2c = iodev->i2c;
+   struct led_flash_setting *s;
+
+   snprintf(v4l2_sd_cfg->dev_name, sizeof(v4l2_sd_cfg->dev_name),
+"%s %d-%04x", sub_led->fled_cdev.led_cdev.name,
+i2c_adapter_id(i2c->adapter), i2c->addr);
+
+   s = &v4l2_sd_cfg->intensity;
+   s->min = TORCH_IOUT_MIN;
+   s->max = sub_led->fled_cdev.led_cdev.max_brightness * TORCH_IOUT_STEP;
+   s->step = TORCH_IOUT_STEP;
+   s->val = s->max;
+
+   /* Init flash faults config */
+   v4l2_sd_cfg->flash_faults = LED_FAULT_OVER_VOLTAGE |
+   LED_FAULT_SHORT_CIRCUIT |
+   LED_FAULT_OVER_CURRENT;
+
+   v4l2_sd_cfg->has_external_strobe = true;
+}
+
+static const struct v4l2_flash_ops v4l2_flash_ops = {
+   .external_strobe_set = max77693_led_external_strobe_set,
+};
+
+#else
+#define max77693_init_v4l2_flash_config(sub_led, led_cfg, v4l2_sd_cfg)
+#endif
+
 static void max77693_init_fled_cdev(struct max77693_sub_led *sub_led,
struct max77693_led_config_data *led_cfg)
 {
@@ -873,12

[PATCH v5 09/10] DT: aat1290: Document handling external strobe sources

2015-04-14 Thread Jacek Anaszewski
This patch adds documentation for a pinctrl-names property.
The property, when present, is used for switching the source
of the strobe signal for the device.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
Cc: Bryan Wu 
Cc: Richard Purdie 
Cc: Sakari Ailus 
Cc: devicet...@vger.kernel.org
---
 .../devicetree/bindings/leds/leds-aat1290.txt  |   36 ++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/leds/leds-aat1290.txt 
b/Documentation/devicetree/bindings/leds/leds-aat1290.txt
index ef88b9c..c05ed91 100644
--- a/Documentation/devicetree/bindings/leds/leds-aat1290.txt
+++ b/Documentation/devicetree/bindings/leds/leds-aat1290.txt
@@ -2,7 +2,9 @@
 
 The device is controlled through two pins: FL_EN and EN_SET. The pins when,
 asserted high, enable flash strobe and movie mode (max 1/2 of flash current)
-respectively.
+respectively. In order to add a capability of selecting the strobe signal 
source
+(e.g. CPU or camera sensor) there is an additional switch required, independent
+of the flash chip. The switch is controlled with pin control.
 
 Required properties:
 
@@ -10,6 +12,13 @@ Required properties:
 - flen-gpios : Must be device tree identifier of the flash device FL_EN pin.
 - enset-gpios : Must be device tree identifier of the flash device EN_SET pin.
 
+Optional properties:
+- pinctrl-names : Must contain entries: "default", "host", "isp". Entries
+   "default" and "host" must refer to the same pin configuration
+   node, which sets the host as a strobe signal provider. Entry
+   "isp" must refer to the pin configuration node, which sets the
+   ISP as a strobe signal provider.
+
 A discrete LED element connected to the device must be represented by a child
 node - see Documentation/devicetree/bindings/leds/common.txt.
 
@@ -25,13 +34,22 @@ Required properties of the LED child node:
 Optional properties of the LED child node:
 - label : see Documentation/devicetree/bindings/leds/common.txt
 
-Example (by Ct = 220nF, Rset = 160kohm):
+Example (by Ct = 220nF, Rset = 160kohm and exynos4412-trats2 board with
+a switch that allows for routing strobe signal either from the host or from
+the camera sensor):
+
+#include "exynos4412.dtsi"
 
 aat1290 {
compatible = "skyworks,aat1290";
flen-gpios = <&gpj1 1 GPIO_ACTIVE_HIGH>;
enset-gpios = <&gpj1 2 GPIO_ACTIVE_HIGH>;
 
+   pinctrl-names = "default", "host", "isp";
+   pinctrl-0 = <&camera_flash_host>;
+   pinctrl-1 = <&camera_flash_host>;
+   pinctrl-2 = <&camera_flash_isp>;
+
camera_flash: flash-led {
label = "aat1290-flash";
led-max-microamp = <520833>;
@@ -39,3 +57,17 @@ aat1290 {
flash-timeout-us = <194>;
};
 };
+
+&pinctrl_0 {
+   camera_flash_host: camera-flash-host {
+   samsung,pins = "gpj1-0";
+   samsung,pin-function = <1>;
+   samsung,pin-val = <0>;
+   };
+
+   camera_flash_isp: camera-flash-isp {
+   samsung,pins = "gpj1-0";
+   samsung,pin-function = <1>;
+   samsung,pin-val = <1>;
+   };
+};
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 01/10] leds: unify the location of led-trigger API

2015-04-14 Thread Jacek Anaszewski
Part of led-trigger API was in the private drivers/leds/leds.h header.
Move it to the include/linux/leds.h header to unify the API location
and announce it as public. It has been already exported from
led-triggers.c with EXPORT_SYMBOL_GPL macro. The no-op definitions are
changed from macros to inline to match the style of the surrounding code.

Signed-off-by: Jacek Anaszewski 
Cc: Bryan Wu 
Cc: Richard Purdie 
---
 drivers/leds/leds.h  |   24 
 include/linux/leds.h |   25 +
 2 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h
index 79efe57..bc89d7a 100644
--- a/drivers/leds/leds.h
+++ b/drivers/leds/leds.h
@@ -13,7 +13,6 @@
 #ifndef __LEDS_H_INCLUDED
 #define __LEDS_H_INCLUDED
 
-#include 
 #include 
 #include 
 
@@ -50,27 +49,4 @@ void led_stop_software_blink(struct led_classdev *led_cdev);
 extern struct rw_semaphore leds_list_lock;
 extern struct list_head leds_list;
 
-#ifdef CONFIG_LEDS_TRIGGERS
-void led_trigger_set_default(struct led_classdev *led_cdev);
-void led_trigger_set(struct led_classdev *led_cdev,
-   struct led_trigger *trigger);
-void led_trigger_remove(struct led_classdev *led_cdev);
-
-static inline void *led_get_trigger_data(struct led_classdev *led_cdev)
-{
-   return led_cdev->trigger_data;
-}
-
-#else
-#define led_trigger_set_default(x) do {} while (0)
-#define led_trigger_set(x, y) do {} while (0)
-#define led_trigger_remove(x) do {} while (0)
-#define led_get_trigger_data(x) (NULL)
-#endif
-
-ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
-   const char *buf, size_t count);
-ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
-   char *buf);
-
 #endif /* __LEDS_H_INCLUDED */
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 9a2b000..b122eea 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -12,6 +12,7 @@
 #ifndef __LINUX_LEDS_H_INCLUDED
 #define __LINUX_LEDS_H_INCLUDED
 
+#include 
 #include 
 #include 
 #include 
@@ -222,6 +223,11 @@ struct led_trigger {
struct list_head  next_trig;
 };
 
+ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count);
+ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
+   char *buf);
+
 /* Registration functions for complex triggers */
 extern int led_trigger_register(struct led_trigger *trigger);
 extern void led_trigger_unregister(struct led_trigger *trigger);
@@ -238,6 +244,16 @@ extern void led_trigger_blink_oneshot(struct led_trigger 
*trigger,
  unsigned long *delay_on,
  unsigned long *delay_off,
  int invert);
+extern void led_trigger_set_default(struct led_classdev *led_cdev);
+extern void led_trigger_set(struct led_classdev *led_cdev,
+   struct led_trigger *trigger);
+extern void led_trigger_remove(struct led_classdev *led_cdev);
+
+static inline void *led_get_trigger_data(struct led_classdev *led_cdev)
+{
+   return led_cdev->trigger_data;
+}
+
 /**
  * led_trigger_rename_static - rename a trigger
  * @name: the new trigger name
@@ -267,6 +283,15 @@ static inline void led_trigger_register_simple(const char 
*name,
 static inline void led_trigger_unregister_simple(struct led_trigger *trigger) 
{}
 static inline void led_trigger_event(struct led_trigger *trigger,
enum led_brightness event) {}
+static inline void led_trigger_set_default(struct led_classdev *led_cdev) {}
+static inline void led_trigger_set(struct led_classdev *led_cdev,
+   struct led_trigger *trigger) {}
+static inline void led_trigger_remove(struct led_classdev *led_cdev) {}
+static inline void *led_get_trigger_data(struct led_classdev *led_cdev)
+{
+   return NULL;
+}
+
 #endif /* CONFIG_LEDS_TRIGGERS */
 
 /* Trigger specific functions */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 02/10] DT: Add documentation for the mfd Maxim max77693

2015-04-14 Thread Jacek Anaszewski
This patch adds device tree binding documentation for
the flash cell of the Maxim max77693 multifunctional device.

Signed-off-by: Jacek Anaszewski 
Signed-off-by: Andrzej Hajda 
Acked-by: Kyungmin Park 
Cc: Lee Jones 
Cc: Chanwoo Choi 
Cc: Bryan Wu 
Cc: Richard Purdie 
Cc: devicet...@vger.kernel.org
---
 Documentation/devicetree/bindings/mfd/max77693.txt |   67 
 1 file changed, 67 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/max77693.txt 
b/Documentation/devicetree/bindings/mfd/max77693.txt
index 38e6440..d342584 100644
--- a/Documentation/devicetree/bindings/mfd/max77693.txt
+++ b/Documentation/devicetree/bindings/mfd/max77693.txt
@@ -76,7 +76,60 @@ Optional properties:
 Valid values: 430, 470, 480, 490
 Default: 430
 
+- led : the LED submodule device node
+
+There are two LED outputs available - FLED1 and FLED2. Each of them can
+control a separate LED or they can be connected together to double
+the maximum current for a single connected LED. One LED is represented
+by one child node.
+
+Required properties:
+- compatible : Must be "maxim,max77693-led".
+
+Optional properties:
+- maxim,boost-mode :
+   In boost mode the device can produce up to 1.2A of total current
+   on both outputs. The maximum current on each output is reduced
+   to 625mA then. If not enabled explicitly, boost setting defaults to
+   LEDS_BOOST_FIXED in case both current sources are used.
+   Possible values:
+   LEDS_BOOST_OFF (0) - no boost,
+   LEDS_BOOST_ADAPTIVE (1) - adaptive mode,
+   LEDS_BOOST_FIXED (2) - fixed mode.
+- maxim,boost-mvout : Output voltage of the boost module in millivolts.
+   Valid values: 3300 - 5500, step by 25 (rounded down)
+   Default: 3300
+- maxim,mvsys-min : Low input voltage level in millivolts. Flash is not fired
+   if chip estimates that system voltage could drop below this level due
+   to flash power consumption.
+   Valid values: 2400 - 3400, step by 33 (rounded down)
+   Default: 2400
+
+Required properties for the LED child node:
+- led-sources : see Documentation/devicetree/bindings/leds/common.txt;
+   device current output identifiers: 0 - FLED1, 1 - FLED2
+- led-max-microamp : see Documentation/devicetree/bindings/leds/common.txt
+   Valid values for a LED connected to one FLED output:
+   15625 - 25, step by 15625 (rounded down)
+   Valid values for a LED connected to both FLED outputs:
+   15625 - 50, step by 15625 (rounded down)
+- flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt
+   Valid values for a single LED connected to one FLED output:
+   (boost mode must be turned off):
+   15625 - 100, step by 15625 (rounded down)
+   Valid values for a single LED connected to both FLED outputs:
+   15625 - 125, step by 15625 (rounded down)
+   Valid values for two LEDs case:
+   15625 - 625000, step by 15625 (rounded down)
+- flash-max-timeout-us : see Documentation/devicetree/bindings/leds/common.txt
+   Valid values: 62500 - 100, step by 62500 (rounded down)
+
+Optional properties for the LED child node:
+- label : see Documentation/devicetree/bindings/leds/common.txt
+
 Example:
+#include 
+
max77693@66 {
compatible = "maxim,max77693";
reg = <0x66>;
@@ -117,5 +170,19 @@ Example:
maxim,thermal-regulation-celsius = <75>;
maxim,battery-overcurrent-microamp = <300>;
maxim,charge-input-threshold-microvolt = <430>;
+
+   led {
+   compatible = "maxim,max77693-led";
+   maxim,boost-mode = ;
+   maxim,boost-mvout = <5000>;
+   maxim,mvsys-min = <2400>;
+
+   camera_flash: flash-led {
+   label = "max77693-flash";
+   led-sources = <0>, <1>;
+   led-max-microamp = <50>;
+   flash-max-microamp = <125>;
+   flash-max-timeout-us = <100>;
+   };
};
};
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 03/10] leds: Add support for max77693 mfd flash cell

2015-04-14 Thread Jacek Anaszewski
This patch adds led-flash support to Maxim max77693 chipset.
A device can be exposed to user space through LED subsystem
sysfs interface. Device supports up to two leds which can
work in flash and torch mode. The leds can be triggered
externally or by software.

Signed-off-by: Jacek Anaszewski 
Signed-off-by: Andrzej Hajda 
Acked-by: Kyungmin Park 
Cc: Bryan Wu 
Cc: Richard Purdie 
Cc: Lee Jones 
Cc: Chanwoo Choi 
---
 drivers/leds/Kconfig |   10 +
 drivers/leds/Makefile|1 +
 drivers/leds/leds-max77693.c |  984 ++
 3 files changed, 995 insertions(+)
 create mode 100644 drivers/leds/leds-max77693.c

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 68fd6b2..97e9699 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -471,6 +471,16 @@ config LEDS_TCA6507
  LED driver chips accessed via the I2C bus.
  Driver support brightness control and hardware-assisted blinking.
 
+config LEDS_MAX77693
+   tristate "LED support for MAX77693 Flash"
+   depends on LEDS_CLASS_FLASH
+   depends on MFD_MAX77693
+   depends on OF
+   help
+ This option enables support for the flash part of the MAX77693
+ multifunction device. It has build in control for two leds in flash
+ and torch mode.
+
 config LEDS_MAX8997
tristate "LED support for MAX8997 PMIC"
depends on LEDS_CLASS && MFD_MAX8997
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index bf46093..9413fdb 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_LEDS_MC13783)+= leds-mc13783.o
 obj-$(CONFIG_LEDS_NS2) += leds-ns2.o
 obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o
 obj-$(CONFIG_LEDS_ASIC3)   += leds-asic3.o
+obj-$(CONFIG_LEDS_MAX77693)+= leds-max77693.o
 obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
 obj-$(CONFIG_LEDS_LM355x)  += leds-lm355x.o
 obj-$(CONFIG_LEDS_BLINKM)  += leds-blinkm.o
diff --git a/drivers/leds/leds-max77693.c b/drivers/leds/leds-max77693.c
new file mode 100644
index 000..d2b9611
--- /dev/null
+++ b/drivers/leds/leds-max77693.c
@@ -0,0 +1,984 @@
+/*
+ * LED Flash class driver for the flash cell of max77693 mfd.
+ *
+ * Copyright (C) 2015, Samsung Electronics Co., Ltd.
+ *
+ * Authors: Jacek Anaszewski 
+ *  Andrzej Hajda 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MODE_OFF   0
+#define MODE_FLASH(a)  (1 << (a))
+#define MODE_TORCH(a)  (1 << (2 + (a)))
+#define MODE_FLASH_EXTERNAL(a) (1 << (4 + (a)))
+
+#define MODE_FLASH_MASK(MODE_FLASH(FLED1) | MODE_FLASH(FLED2) 
| \
+MODE_FLASH_EXTERNAL(FLED1) | \
+MODE_FLASH_EXTERNAL(FLED2))
+#define MODE_TORCH_MASK(MODE_TORCH(FLED1) | MODE_TORCH(FLED2))
+
+#define FLED1_IOUT (1 << 0)
+#define FLED2_IOUT (1 << 1)
+
+enum max77693_fled {
+   FLED1,
+   FLED2,
+};
+
+enum max77693_led_mode {
+   FLASH,
+   TORCH,
+};
+
+struct max77693_led_config_data {
+   const char *label[2];
+   u32 iout_torch_max[2];
+   u32 iout_flash_max[2];
+   u32 flash_timeout_max[2];
+   u32 num_leds;
+   u32 boost_mode;
+   u32 boost_vout;
+   u32 low_vsys;
+};
+
+struct max77693_sub_led {
+   /* corresponding FLED output identifier */
+   int fled_id;
+   /* corresponding LED Flash class device */
+   struct led_classdev_flash fled_cdev;
+   /* assures led-triggers compatibility */
+   struct work_struct work_brightness_set;
+
+   /* brightness cache */
+   unsigned int torch_brightness;
+   /* flash timeout cache */
+   unsigned int flash_timeout;
+   /* flash faults that may have occurred */
+   u32 flash_faults;
+};
+
+struct max77693_led_device {
+   /* parent mfd regmap */
+   struct regmap *regmap;
+   /* platform device data */
+   struct platform_device *pdev;
+   /* secures access to the device */
+   struct mutex lock;
+
+   /* sub led data */
+   struct max77693_sub_led sub_leds[2];
+
+   /* maximum torch current values for FLED outputs */
+   u32 iout_torch_max[2];
+   /* maximum flash current values for FLED outputs */
+   u32 iout_flash_max[2];
+
+   /* current flash timeout cache */
+   unsigned int current_flash_timeout;
+   /* ITORCH register cache */
+   u8 torch_iout_reg;
+   /* mode of fled outputs */
+   unsigned int mode_flags;
+   /* recently strobed fled */
+   int strobing_sub_led_id;
+   /* bitmask 

[PATCH v5 06/10] media: Add registration helpers for V4L2 flash sub-devices

2015-04-14 Thread Jacek Anaszewski
This patch adds helper functions for registering/unregistering
LED Flash class devices as V4L2 sub-devices. The functions should
be called from the LED subsystem device driver. In case the
support for V4L2 Flash sub-devices is disabled in the kernel
config the functions' empty versions will be used.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
Cc: Sakari Ailus 
Cc: Hans Verkuil 
---
 drivers/media/v4l2-core/Kconfig  |   11 +
 drivers/media/v4l2-core/Makefile |2 +
 drivers/media/v4l2-core/v4l2-flash.c |  619 ++
 include/media/v4l2-flash.h   |  145 
 4 files changed, 777 insertions(+)
 create mode 100644 drivers/media/v4l2-core/v4l2-flash.c
 create mode 100644 include/media/v4l2-flash.h

diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig
index ba7e21a..f034f1a 100644
--- a/drivers/media/v4l2-core/Kconfig
+++ b/drivers/media/v4l2-core/Kconfig
@@ -44,6 +44,17 @@ config V4L2_MEM2MEM_DEV
 tristate
 depends on VIDEOBUF2_CORE
 
+# Used by LED subsystem flash drivers
+config V4L2_FLASH_LED_CLASS
+   tristate "Enable support for Flash sub-devices"
+   depends on VIDEO_V4L2_SUBDEV_API
+   depends on LEDS_CLASS_FLASH
+   ---help---
+ Say Y here to enable support for Flash sub-devices, which allow
+ to control LED class devices with use of V4L2 Flash controls.
+
+ When in doubt, say N.
+
 # Used by drivers that need Videobuf modules
 config VIDEOBUF_GEN
tristate
diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index 63d29f2..44e858c 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -22,6 +22,8 @@ obj-$(CONFIG_VIDEO_TUNER) += tuner.o
 
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
+obj-$(CONFIG_V4L2_FLASH_LED_CLASS) += v4l2-flash.o
+
 obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o
 obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o
 obj-$(CONFIG_VIDEOBUF_DMA_CONTIG) += videobuf-dma-contig.o
diff --git a/drivers/media/v4l2-core/v4l2-flash.c 
b/drivers/media/v4l2-core/v4l2-flash.c
new file mode 100644
index 000..bed2036
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-flash.c
@@ -0,0 +1,619 @@
+/*
+ * V4L2 Flash LED sub-device registration helpers.
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd
+ * Author: Jacek Anaszewski 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define has_flash_op(v4l2_flash, op)   \
+   (v4l2_flash && v4l2_flash->ops->op)
+
+#define call_flash_op(v4l2_flash, op, arg) \
+   (has_flash_op(v4l2_flash, op) ? \
+   v4l2_flash->ops->op(v4l2_flash, arg) :  \
+   -EINVAL)
+
+static enum led_brightness __intensity_to_led_brightness(
+   struct v4l2_ctrl *ctrl,
+   s32 intensity)
+{
+   s64 intensity64 = intensity - ctrl->minimum;
+
+   do_div(intensity64, ctrl->step);
+
+   /*
+* Indicator LEDs, unlike torch LEDs, are turned on/off basing on
+* the state of V4L2_CID_FLASH_INDICATOR_INTENSITY control only.
+* Therefore it must be possible to set it to 0 level which in
+* the LED subsystem reflects LED_OFF state.
+*/
+   if (ctrl->id != V4L2_CID_FLASH_INDICATOR_INTENSITY)
+   ++intensity64;
+
+   return intensity64;
+}
+
+static s32 __led_brightness_to_intensity(struct v4l2_ctrl *ctrl,
+enum led_brightness brightness)
+{
+   /*
+* Indicator LEDs, unlike torch LEDs, are turned on/off basing on
+* the state of V4L2_CID_FLASH_INDICATOR_INTENSITY control only.
+* Do not decrement brightness read from the LED subsystem for
+* indicator LED as it may equal 0. For torch LEDs this function
+* is called only when V4L2_FLASH_LED_MODE_TORCH is set and the
+* brightness read is guaranteed to be greater than 0. In the mode
+* V4L2_FLASH_LED_MODE_NONE the cached torch intensity value is used.
+*/
+   if (ctrl->id != V4L2_CID_FLASH_INDICATOR_INTENSITY)
+   --brightness;
+
+   return (brightness * ctrl->step) + ctrl->minimum;
+}
+
+static void v4l2_flash_set_led_brightness(struct v4l2_flash *v4l2_flash,
+   struct v4l2_ctrl *ctrl)
+{
+   struct v4l2_ctrl **ctrls = v4l2_flash->ctrls;
+   enum led_brightness brightness;
+
+   if (has_flash_op(v4l2_flash, intensity_to_led_brightness))
+   brightness = call_flash_op(v4l2_flash,
+   intensity_to_led_brightness,
+  

[PATCH v5 07/10] Documentation: leds: Add description of v4l2-flash sub-device

2015-04-14 Thread Jacek Anaszewski
This patch extends LED Flash class documention by
the description of interactions with v4l2-flash sub-device.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
Cc: Bryan Wu 
Cc: Richard Purdie 
---
 Documentation/leds/leds-class-flash.txt |   47 +++
 1 file changed, 47 insertions(+)

diff --git a/Documentation/leds/leds-class-flash.txt 
b/Documentation/leds/leds-class-flash.txt
index 19bb673..ad80eeb 100644
--- a/Documentation/leds/leds-class-flash.txt
+++ b/Documentation/leds/leds-class-flash.txt
@@ -20,3 +20,50 @@ Following sysfs attributes are exposed for controlling flash 
LED devices:
- max_flash_timeout
- flash_strobe
- flash_fault
+
+
+V4L2 Flash wrapper for flash LEDs
+=
+
+A LED subsystem driver can be controlled also from the level of VideoForLinux2
+subsystem. In order to enable this CONFIG_V4L2_FLASH_LED_CLASS symbol has to
+be defined in the kernel config.
+
+The driver must call the v4l2_flash_init function to get registered in the
+V4L2 subsystem. The function takes three arguments:
+- fled_cdev : the LED Flash class device to wrap
+- ops : V4L2 specific ops
+   * external_strobe_set - defines the source of the flash LED strobe -
+   V4L2_CID_FLASH_STROBE control or external source, typically
+   a sensor, which makes it possible to synchronise the flash
+   strobe start with exposure start,
+   * intensity_to_led_brightness and led_brightness_to_intensity - perform
+   enum led_brightness <-> V4L2 intensity conversion in a device
+   specific manner - they can be used for devices with non-linear
+   LED current scale.
+- config : configuration for V4L2 Flash sub-device
+   * dev_name - the name of the media entity, unique in the system,
+   * flash_faults - bitmask of flash faults that the LED Flash class
+   device can report; corresponding LED_FAULT* bit definitions are
+   available in ,
+   * intensity - constraints for the LED in the TORCH or INDICATOR mode,
+   in microamperes,
+   * has_external_strobe - determines whether the flash strobe source
+   can be switched to external,
+   * indicator_led - signifies that a led is of indicator type, which
+   implies that it can have only two V4L2 controls:
+   V4L2_CID_FLASH_INDICATOR_INTENSITY and V4L2_CID_FLASH_FAULT.
+
+On remove the v4l2_flash_release function has to be called, which takes one
+argument - struct v4l2_flash pointer returned previously by v4l2_flash_init.
+
+Please refer to drivers/leds/leds-max77693.c for an exemplary usage of the
+v4l2-flash API.
+
+Once the V4L2 sub-device is registered by the driver which created the Media
+controller device, the sub-device node acts just as a node of a native V4L2
+flash API device would. The calls are simply routed to the LED flash API.
+
+Opening the V4L2 Flash sub-device makes the LED subsystem sysfs interface
+unavailable. The interface is re-enabled after the V4L2 Flash sub-device
+is closed.
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 10/10] leds: aat1290: add support for V4L2 Flash sub-device

2015-04-14 Thread Jacek Anaszewski
Add support for V4L2 Flash sub-device to the aat1290 LED Flash class
driver. The support allows for V4L2 Flash sub-device to take the control
of the LED Flash class device.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
Cc: Bryan Wu 
Cc: Richard Purdie 
Cc: Sakari Ailus 
---
 drivers/leds/Kconfig|1 +
 drivers/leds/leds-aat1290.c |  137 +--
 2 files changed, 132 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index fe2ef1e..ae77316 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -47,6 +47,7 @@ config LEDS_AAT1290
depends on LEDS_CLASS_FLASH
depends on GPIOLIB
depends on OF
+   depends on PINCTRL
help
 This option enables support for the LEDs on the AAT1290.
 
diff --git a/drivers/leds/leds-aat1290.c b/drivers/leds/leds-aat1290.c
index 03e5b96..7415d5ec 100644
--- a/drivers/leds/leds-aat1290.c
+++ b/drivers/leds/leds-aat1290.c
@@ -17,9 +17,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 #define AAT1290_MOVIE_MODE_CURRENT_ADDR17
 #define AAT1290_MAX_MM_CURR_PERCENT_0  16
@@ -52,6 +54,8 @@ struct aat1290_led_config_data {
u32 max_flash_current;
/* maximum flash timeout */
u32 max_flash_tm;
+   /* external strobe capability */
+   bool has_external_strobe;
/* max LED brightness level */
enum led_brightness max_brightness;
 };
@@ -64,6 +68,8 @@ struct aat1290_led {
 
/* corresponding LED Flash class device */
struct led_classdev_flash fled_cdev;
+   /* V4L2 Flash device */
+   struct v4l2_flash *v4l2_flash;
 
/* FLEN pin */
struct gpio_desc *gpio_fl_en;
@@ -230,11 +236,15 @@ static int aat1290_led_flash_timeout_set(struct 
led_classdev_flash *fled_cdev,
 }
 
 static int aat1290_led_parse_dt(struct aat1290_led *led,
-   struct aat1290_led_config_data *cfg)
+   struct aat1290_led_config_data *cfg,
+   struct device_node **sub_node)
 {
struct led_classdev *led_cdev = &led->fled_cdev.led_cdev;
struct device *dev = &led->pdev->dev;
struct device_node *child_node;
+#if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS)
+   struct pinctrl *pinctrl;
+#endif
int ret = 0;
 
led->gpio_fl_en = devm_gpiod_get(dev, "flen");
@@ -251,6 +261,17 @@ static int aat1290_led_parse_dt(struct aat1290_led *led,
return ret;
}
 
+#if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS)
+   pinctrl = devm_pinctrl_get_select_default(&led->pdev->dev);
+   if (IS_ERR(pinctrl)) {
+   cfg->has_external_strobe = false;
+   dev_info(dev,
+"No support for external strobe detected.\n");
+   } else {
+   cfg->has_external_strobe = true;
+   }
+#endif
+
child_node = of_get_next_available_child(dev->of_node, NULL);
if (!child_node) {
dev_err(dev, "No DT child node found for connected LED.\n");
@@ -288,6 +309,8 @@ static int aat1290_led_parse_dt(struct aat1290_led *led,
 
of_node_put(child_node);
 
+   *sub_node = child_node;
+
return ret;
 }
 
@@ -316,7 +339,8 @@ int init_mm_current_scale(struct aat1290_led *led,
int i, max_mm_current =
AAT1290_MAX_MM_CURRENT(cfg->max_flash_current);
 
-   led->mm_current_scale = kzalloc(sizeof(max_mm_current_percent),
+   led->mm_current_scale = devm_kzalloc(&led->pdev->dev,
+   sizeof(max_mm_current_percent),
GFP_KERNEL);
if (!led->mm_current_scale)
return -ENOMEM;
@@ -329,11 +353,12 @@ int init_mm_current_scale(struct aat1290_led *led,
 }
 
 static int aat1290_led_get_configuration(struct aat1290_led *led,
-   struct aat1290_led_config_data *cfg)
+   struct aat1290_led_config_data *cfg,
+   struct device_node **sub_node)
 {
int ret;
 
-   ret = aat1290_led_parse_dt(led, cfg);
+   ret = aat1290_led_parse_dt(led, cfg, sub_node);
if (ret < 0)
return ret;
/*
@@ -346,7 +371,10 @@ static int aat1290_led_get_configuration(struct 
aat1290_led *led,
 
aat1290_led_validate_mm_current(led, cfg);
 
-   kfree(led->mm_current_scale);
+#if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS)
+#else
+   devm_kfree(&led->pdev->dev, led->mm_current_scale);
+#endif
 
return 0;
 }
@@ -365,6 +393,83 @@ static void aat1290_init_flash_timeout(struct aat1290_led 
*led,
setting->val = setting->max;
 }
 
+#if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS)
+enum led_brightness aat1290_intensity_to_brightness(
+   struct v4l2_flash *v4l2_flash,
+ 

[PATCH v5 05/10] leds: Add driver for AAT1290 flash LED controller

2015-04-14 Thread Jacek Anaszewski
This patch adds a driver for the 1.5A Step-Up Current Regulator
for Flash LEDs. The device is programmed through a Skyworks proprietary
AS2Cwire serial digital interface.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
Acked-by: Sakari Ailus 
Cc: Bryan Wu 
Cc: Richard Purdie 
---
 drivers/leds/Kconfig|8 +
 drivers/leds/Makefile   |1 +
 drivers/leds/leds-aat1290.c |  452 +++
 3 files changed, 461 insertions(+)
 create mode 100644 drivers/leds/leds-aat1290.c

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 97e9699..fe2ef1e 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -42,6 +42,14 @@ config LEDS_88PM860X
  This option enables support for on-chip LED drivers found on Marvell
  Semiconductor 88PM8606 PMIC.
 
+config LEDS_AAT1290
+   tristate "LED support for the AAT1290"
+   depends on LEDS_CLASS_FLASH
+   depends on GPIOLIB
+   depends on OF
+   help
+This option enables support for the LEDs on the AAT1290.
+
 config LEDS_LM3530
tristate "LCD Backlight driver for LM3530"
depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 9413fdb..0b3fd0e 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o
 
 # LED Platform Drivers
 obj-$(CONFIG_LEDS_88PM860X)+= leds-88pm860x.o
+obj-$(CONFIG_LEDS_AAT1290) += leds-aat1290.o
 obj-$(CONFIG_LEDS_BD2802)  += leds-bd2802.o
 obj-$(CONFIG_LEDS_LOCOMO)  += leds-locomo.o
 obj-$(CONFIG_LEDS_LM3530)  += leds-lm3530.o
diff --git a/drivers/leds/leds-aat1290.c b/drivers/leds/leds-aat1290.c
new file mode 100644
index 000..03e5b96
--- /dev/null
+++ b/drivers/leds/leds-aat1290.c
@@ -0,0 +1,452 @@
+/*
+ * LED Flash class driver for the AAT1290
+ * 1.5A Step-Up Current Regulator for Flash LEDs
+ *
+ * Copyright (C) 2015, Samsung Electronics Co., Ltd.
+ * Author: Jacek Anaszewski 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define AAT1290_MOVIE_MODE_CURRENT_ADDR17
+#define AAT1290_MAX_MM_CURR_PERCENT_0  16
+#define AAT1290_MAX_MM_CURR_PERCENT_1001
+
+#define AAT1290_FLASH_SAFETY_TIMER_ADDR18
+
+#define AAT1290_MOVIE_MODE_CONFIG_ADDR 19
+#define AAT1290_MOVIE_MODE_OFF 1
+#define AAT1290_MOVIE_MODE_ON  3
+
+#define AAT1290_MM_CURRENT_RATIO_ADDR  20
+#define AAT1290_MM_TO_FL_1_92  1
+
+#define AAT1290_MM_TO_FL_RATIO 1000 / 1920
+#define AAT1290_MAX_MM_CURRENT(fl_max) (fl_max * AAT1290_MM_TO_FL_RATIO)
+
+#define AAT1290_LATCH_TIME_MIN_US  500
+#define AAT1290_LATCH_TIME_MAX_US  1000
+#define AAT1290_EN_SET_TICK_TIME_US1
+#define AAT1290_FLEN_OFF_DELAY_TIME_US 10
+#define AAT1290_FLASH_TM_NUM_LEVELS16
+#define AAT1290_MM_CURRENT_SCALE_SIZE  15
+
+
+struct aat1290_led_config_data {
+   /* maximum LED current in movie mode */
+   u32 max_mm_current;
+   /* maximum LED current in flash mode */
+   u32 max_flash_current;
+   /* maximum flash timeout */
+   u32 max_flash_tm;
+   /* max LED brightness level */
+   enum led_brightness max_brightness;
+};
+
+struct aat1290_led {
+   /* platform device data */
+   struct platform_device *pdev;
+   /* secures access to the device */
+   struct mutex lock;
+
+   /* corresponding LED Flash class device */
+   struct led_classdev_flash fled_cdev;
+
+   /* FLEN pin */
+   struct gpio_desc *gpio_fl_en;
+   /* EN|SET pin  */
+   struct gpio_desc *gpio_en_set;
+   /* movie mode current scale */
+   int *mm_current_scale;
+   /* device mode */
+   bool movie_mode;
+
+   /* brightness cache */
+   unsigned int torch_brightness;
+   /* assures led-triggers compatibility */
+   struct work_struct work_brightness_set;
+};
+
+static struct aat1290_led *fled_cdev_to_led(
+   struct led_classdev_flash *fled_cdev)
+{
+   return container_of(fled_cdev, struct aat1290_led, fled_cdev);
+}
+
+static void aat1290_as2cwire_write(struct aat1290_led *led, int addr, int 
value)
+{
+   int i;
+
+   gpiod_direction_output(led->gpio_fl_en, 0);
+   gpiod_direction_output(led->gpio_en_set, 0);
+
+   udelay(AAT1290_FLEN_OFF_DELAY_TIME_US);
+
+   /* write address */
+   for (i = 0; i < addr; ++i) {
+   udelay(AAT1290_EN_SET_TICK_TIME_US);
+   gpiod_direction_output(led->gpio_en_set, 0);
+   udelay(AAT1290_EN_SET_TICK_TIME_US);
+   gpiod_direction_output(led->gpio_en_set, 1);
+   }
+
+   

[PATCH v5 04/10] DT: Add documentation for the Skyworks AAT1290

2015-04-14 Thread Jacek Anaszewski
This patch adds device tree binding documentation for
1.5A Step-Up Current Regulator for Flash LEDs.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
Cc: Bryan Wu 
Cc: Richard Purdie 
Cc: devicet...@vger.kernel.org
---
 .../devicetree/bindings/leds/leds-aat1290.txt  |   41 
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-aat1290.txt

diff --git a/Documentation/devicetree/bindings/leds/leds-aat1290.txt 
b/Documentation/devicetree/bindings/leds/leds-aat1290.txt
new file mode 100644
index 000..ef88b9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/leds-aat1290.txt
@@ -0,0 +1,41 @@
+* Skyworks Solutions, Inc. AAT1290 Current Regulator for Flash LEDs
+
+The device is controlled through two pins: FL_EN and EN_SET. The pins when,
+asserted high, enable flash strobe and movie mode (max 1/2 of flash current)
+respectively.
+
+Required properties:
+
+- compatible : Must be "skyworks,aat1290".
+- flen-gpios : Must be device tree identifier of the flash device FL_EN pin.
+- enset-gpios : Must be device tree identifier of the flash device EN_SET pin.
+
+A discrete LED element connected to the device must be represented by a child
+node - see Documentation/devicetree/bindings/leds/common.txt.
+
+Required properties of the LED child node:
+- led-max-microamp : see Documentation/devicetree/bindings/leds/common.txt
+- flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt
+   Maximum flash LED supply current can be calculated using
+   following formula: I = 1A * 162kohm / Rset.
+- flash-timeout-us : see Documentation/devicetree/bindings/leds/common.txt
+ Maximum flash timeout can be calculated using following
+ formula: T = 8.82 * 10^9 * Ct.
+
+Optional properties of the LED child node:
+- label : see Documentation/devicetree/bindings/leds/common.txt
+
+Example (by Ct = 220nF, Rset = 160kohm):
+
+aat1290 {
+   compatible = "skyworks,aat1290";
+   flen-gpios = <&gpj1 1 GPIO_ACTIVE_HIGH>;
+   enset-gpios = <&gpj1 2 GPIO_ACTIVE_HIGH>;
+
+   camera_flash: flash-led {
+   label = "aat1290-flash";
+   led-max-microamp = <520833>;
+   flash-max-microamp = <1012500>;
+   flash-timeout-us = <194>;
+   };
+};
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html