ivtv kernel panic

2016-10-12 Thread Rajil Saraswat
Hello,

I have a system with 4GB ram and two Hauppauge PVR-500 cards (each
with a daughter card). With kernel 4.0.9 both the cards were working
fine. However, after upgrading to 8GB ram, the kernel paniced with an
error, "Random memory could be DMA written".

I upgraded to kernel 4.2.21 which is latest stable release for gentoo.
The system again panicked on bootup. However, if i disable the
following module options
(https://www.mythtv.org/wiki/Hauppauge_PVR-350)  the system boots up
fine.

options ivtv enc_mpg_buffers=16 enc_yuv_buffers=20 enc_pcm_buffers=640 debug=3

Any idea how can i use these options?

Thanks
Rajil
--
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 10/10] mm: replace access_process_vm() write parameter with gup_flags

2016-10-12 Thread Lorenzo Stoakes
This patch removes the write parameter from access_process_vm() and replaces it
with a gup_flags parameter as use of this function previously _implied_
FOLL_FORCE, whereas after this patch callers explicitly pass this flag.

We make this explicit as use of FOLL_FORCE can result in surprising behaviour
(and hence bugs) within the mm subsystem.

Signed-off-by: Lorenzo Stoakes 
---
 arch/alpha/kernel/ptrace.c |  9 ++---
 arch/blackfin/kernel/ptrace.c  |  5 +++--
 arch/cris/arch-v32/kernel/ptrace.c |  4 ++--
 arch/ia64/kernel/ptrace.c  | 14 +-
 arch/m32r/kernel/ptrace.c  | 15 ++-
 arch/mips/kernel/ptrace32.c|  5 +++--
 arch/powerpc/kernel/ptrace32.c |  5 +++--
 arch/score/kernel/ptrace.c | 10 ++
 arch/sparc/kernel/ptrace_64.c  | 24 
 arch/x86/kernel/step.c |  3 ++-
 arch/x86/um/ptrace_32.c|  3 ++-
 arch/x86/um/ptrace_64.c|  3 ++-
 include/linux/mm.h |  3 ++-
 kernel/ptrace.c| 16 ++--
 mm/memory.c|  8 ++--
 mm/nommu.c |  6 +++---
 mm/util.c  |  5 +++--
 17 files changed, 84 insertions(+), 54 deletions(-)

diff --git a/arch/alpha/kernel/ptrace.c b/arch/alpha/kernel/ptrace.c
index d9ee817..940dfb4 100644
--- a/arch/alpha/kernel/ptrace.c
+++ b/arch/alpha/kernel/ptrace.c
@@ -157,14 +157,16 @@ put_reg(struct task_struct *task, unsigned long regno, 
unsigned long data)
 static inline int
 read_int(struct task_struct *task, unsigned long addr, int * data)
 {
-   int copied = access_process_vm(task, addr, data, sizeof(int), 0);
+   int copied = access_process_vm(task, addr, data, sizeof(int),
+   FOLL_FORCE);
return (copied == sizeof(int)) ? 0 : -EIO;
 }
 
 static inline int
 write_int(struct task_struct *task, unsigned long addr, int data)
 {
-   int copied = access_process_vm(task, addr, , sizeof(int), 1);
+   int copied = access_process_vm(task, addr, , sizeof(int),
+   FOLL_FORCE | FOLL_WRITE);
return (copied == sizeof(int)) ? 0 : -EIO;
 }
 
@@ -281,7 +283,8 @@ long arch_ptrace(struct task_struct *child, long request,
/* When I and D space are separate, these will need to be fixed.  */
case PTRACE_PEEKTEXT: /* read word at location addr. */
case PTRACE_PEEKDATA:
-   copied = access_process_vm(child, addr, , sizeof(tmp), 0);
+   copied = access_process_vm(child, addr, , sizeof(tmp),
+   FOLL_FORCE);
ret = -EIO;
if (copied != sizeof(tmp))
break;
diff --git a/arch/blackfin/kernel/ptrace.c b/arch/blackfin/kernel/ptrace.c
index 8b8fe67..8d79286 100644
--- a/arch/blackfin/kernel/ptrace.c
+++ b/arch/blackfin/kernel/ptrace.c
@@ -271,7 +271,7 @@ long arch_ptrace(struct task_struct *child, long request,
case BFIN_MEM_ACCESS_CORE:
case BFIN_MEM_ACCESS_CORE_ONLY:
copied = access_process_vm(child, addr, ,
-  to_copy, 0);
+  to_copy, FOLL_FORCE);
if (copied)
break;
 
@@ -324,7 +324,8 @@ long arch_ptrace(struct task_struct *child, long request,
case BFIN_MEM_ACCESS_CORE:
case BFIN_MEM_ACCESS_CORE_ONLY:
copied = access_process_vm(child, addr, ,
-  to_copy, 1);
+  to_copy,
+  FOLL_FORCE | 
FOLL_WRITE);
break;
case BFIN_MEM_ACCESS_DMA:
if (safe_dma_memcpy(paddr, , to_copy))
diff --git a/arch/cris/arch-v32/kernel/ptrace.c 
b/arch/cris/arch-v32/kernel/ptrace.c
index f085229..f0df654 100644
--- a/arch/cris/arch-v32/kernel/ptrace.c
+++ b/arch/cris/arch-v32/kernel/ptrace.c
@@ -147,7 +147,7 @@ long arch_ptrace(struct task_struct *child, long request,
/* The trampoline page is globally mapped, no 
page table to traverse.*/
tmp = *(unsigned long*)addr;
} else {
-   copied = access_process_vm(child, addr, , 
sizeof(tmp), 0);
+   copied = access_process_vm(child, addr, , 
sizeof(tmp), FOLL_FORCE);
 
if (copied != sizeof(tmp))
break;
@@ -279,7 +279,7 @@ static int insn_size(struct task_struct *child, unsigned 
long pc)
   int opsize = 0;
 
   /* Read the 

[PATCH 06/10] mm: replace get_user_pages() write/force parameters with gup_flags

2016-10-12 Thread Lorenzo Stoakes
This patch removes the write and force parameters from get_user_pages() and
replaces them with a gup_flags parameter to make the use of FOLL_FORCE explicit
in callers as use of this flag can result in surprising behaviour (and hence
bugs) within the mm subsystem.

Signed-off-by: Lorenzo Stoakes 
---
 arch/cris/arch-v32/drivers/cryptocop.c |  4 +---
 arch/ia64/kernel/err_inject.c  |  2 +-
 arch/x86/mm/mpx.c  |  5 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|  7 +--
 drivers/gpu/drm/radeon/radeon_ttm.c|  3 ++-
 drivers/gpu/drm/via/via_dmablit.c  |  4 ++--
 drivers/infiniband/core/umem.c |  6 +-
 drivers/infiniband/hw/mthca/mthca_memfree.c|  2 +-
 drivers/infiniband/hw/qib/qib_user_pages.c |  3 ++-
 drivers/infiniband/hw/usnic/usnic_uiom.c   |  5 -
 drivers/media/v4l2-core/videobuf-dma-sg.c  |  7 +--
 drivers/misc/mic/scif/scif_rma.c   |  3 +--
 drivers/misc/sgi-gru/grufault.c|  2 +-
 drivers/platform/goldfish/goldfish_pipe.c  |  3 ++-
 drivers/rapidio/devices/rio_mport_cdev.c   |  3 ++-
 .../vc04_services/interface/vchiq_arm/vchiq_2835_arm.c |  3 +--
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |  3 +--
 drivers/virt/fsl_hypervisor.c  |  4 ++--
 include/linux/mm.h |  2 +-
 mm/gup.c   | 12 +++-
 mm/mempolicy.c |  2 +-
 mm/nommu.c | 18 --
 22 files changed, 49 insertions(+), 54 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/cryptocop.c 
b/arch/cris/arch-v32/drivers/cryptocop.c
index b5698c8..099e170 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -2722,7 +2722,6 @@ static int cryptocop_ioctl_process(struct inode *inode, 
struct file *filp, unsig
err = get_user_pages((unsigned long int)(oper.indata + prev_ix),
 noinpages,
 0,  /* read access only for in data */
-0, /* no force */
 inpages,
 NULL);
 
@@ -2736,8 +2735,7 @@ static int cryptocop_ioctl_process(struct inode *inode, 
struct file *filp, unsig
if (oper.do_cipher){
err = get_user_pages((unsigned long int)oper.cipher_outdata,
 nooutpages,
-1, /* write access for out data */
-0, /* no force */
+FOLL_WRITE, /* write access for out data */
 outpages,
 NULL);
up_read(>mm->mmap_sem);
diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
index 09f8457..5ed0ea9 100644
--- a/arch/ia64/kernel/err_inject.c
+++ b/arch/ia64/kernel/err_inject.c
@@ -142,7 +142,7 @@ store_virtual_to_phys(struct device *dev, struct 
device_attribute *attr,
u64 virt_addr=simple_strtoull(buf, NULL, 16);
int ret;
 
-   ret = get_user_pages(virt_addr, 1, VM_READ, 0, NULL, NULL);
+   ret = get_user_pages(virt_addr, 1, FOLL_WRITE, NULL, NULL);
if (ret<=0) {
 #ifdef ERR_INJ_DEBUG
printk("Virtual address %lx is not existing.\n",virt_addr);
diff --git a/arch/x86/mm/mpx.c b/arch/x86/mm/mpx.c
index 8047687..e4f8009 100644
--- a/arch/x86/mm/mpx.c
+++ b/arch/x86/mm/mpx.c
@@ -544,10 +544,9 @@ static int mpx_resolve_fault(long __user *addr, int write)
 {
long gup_ret;
int nr_pages = 1;
-   int force = 0;
 
-   gup_ret = get_user_pages((unsigned long)addr, nr_pages, write,
-   force, NULL, NULL);
+   gup_ret = get_user_pages((unsigned long)addr, nr_pages,
+   write ? FOLL_WRITE : 0, NULL, NULL);
/*
 * get_user_pages() returns number of pages gotten.
 * 0 means we failed to fault in and get anything,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 887483b..dcaf691 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -555,10 +555,13 @@ struct amdgpu_ttm_tt {
 int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages)
 {
struct amdgpu_ttm_tt *gtt = (void *)ttm;
-   int write = !(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY);
+   unsigned int flags = 0;
unsigned pinned = 0;
int r;
 
+   if (!(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY))
+   flags |= FOLL_WRITE;
+
if (gtt->userflags & 

[PATCH 05/10] mm: replace get_vaddr_frames() write/force parameters with gup_flags

2016-10-12 Thread Lorenzo Stoakes
This patch removes the write and force parameters from get_vaddr_frames() and
replaces them with a gup_flags parameter to make the use of FOLL_FORCE explicit
in callers as use of this flag can result in surprising behaviour (and hence
bugs) within the mm subsystem.

Signed-off-by: Lorenzo Stoakes 
---
 drivers/gpu/drm/exynos/exynos_drm_g2d.c|  3 ++-
 drivers/media/platform/omap/omap_vout.c|  2 +-
 drivers/media/v4l2-core/videobuf2-memops.c |  6 +-
 include/linux/mm.h |  2 +-
 mm/frame_vector.c  | 13 ++---
 5 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c 
b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index aa92dec..fbd13fa 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -488,7 +488,8 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct 
drm_device *drm_dev,
goto err_free;
}
 
-   ret = get_vaddr_frames(start, npages, true, true, g2d_userptr->vec);
+   ret = get_vaddr_frames(start, npages, FOLL_FORCE | FOLL_WRITE,
+   g2d_userptr->vec);
if (ret != npages) {
DRM_ERROR("failed to get user pages from userptr.\n");
if (ret < 0)
diff --git a/drivers/media/platform/omap/omap_vout.c 
b/drivers/media/platform/omap/omap_vout.c
index e668dde..a31b95c 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -214,7 +214,7 @@ static int omap_vout_get_userptr(struct videobuf_buffer 
*vb, u32 virtp,
if (!vec)
return -ENOMEM;
 
-   ret = get_vaddr_frames(virtp, 1, true, false, vec);
+   ret = get_vaddr_frames(virtp, 1, FOLL_WRITE, vec);
if (ret != 1) {
frame_vector_destroy(vec);
return -EINVAL;
diff --git a/drivers/media/v4l2-core/videobuf2-memops.c 
b/drivers/media/v4l2-core/videobuf2-memops.c
index 3c3b517..1cd322e 100644
--- a/drivers/media/v4l2-core/videobuf2-memops.c
+++ b/drivers/media/v4l2-core/videobuf2-memops.c
@@ -42,6 +42,10 @@ struct frame_vector *vb2_create_framevec(unsigned long start,
unsigned long first, last;
unsigned long nr;
struct frame_vector *vec;
+   unsigned int flags = FOLL_FORCE;
+
+   if (write)
+   flags |= FOLL_WRITE;
 
first = start >> PAGE_SHIFT;
last = (start + length - 1) >> PAGE_SHIFT;
@@ -49,7 +53,7 @@ struct frame_vector *vb2_create_framevec(unsigned long start,
vec = frame_vector_create(nr);
if (!vec)
return ERR_PTR(-ENOMEM);
-   ret = get_vaddr_frames(start & PAGE_MASK, nr, write, true, vec);
+   ret = get_vaddr_frames(start & PAGE_MASK, nr, flags, vec);
if (ret < 0)
goto out_destroy;
/* We accept only complete set of PFNs */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 27ab538..5ff084f6 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1305,7 +1305,7 @@ struct frame_vector {
 struct frame_vector *frame_vector_create(unsigned int nr_frames);
 void frame_vector_destroy(struct frame_vector *vec);
 int get_vaddr_frames(unsigned long start, unsigned int nr_pfns,
-bool write, bool force, struct frame_vector *vec);
+unsigned int gup_flags, struct frame_vector *vec);
 void put_vaddr_frames(struct frame_vector *vec);
 int frame_vector_to_pages(struct frame_vector *vec);
 void frame_vector_to_pfns(struct frame_vector *vec);
diff --git a/mm/frame_vector.c b/mm/frame_vector.c
index 81b6749..db77dcb 100644
--- a/mm/frame_vector.c
+++ b/mm/frame_vector.c
@@ -11,10 +11,7 @@
  * get_vaddr_frames() - map virtual addresses to pfns
  * @start: starting user address
  * @nr_frames: number of pages / pfns from start to map
- * @write: whether pages will be written to by the caller
- * @force: whether to force write access even if user mapping is
- * readonly. See description of the same argument of
-   get_user_pages().
+ * @gup_flags: flags modifying lookup behaviour
  * @vec:   structure which receives pages / pfns of the addresses mapped.
  * It should have space for at least nr_frames entries.
  *
@@ -34,23 +31,17 @@
  * This function takes care of grabbing mmap_sem as necessary.
  */
 int get_vaddr_frames(unsigned long start, unsigned int nr_frames,
-bool write, bool force, struct frame_vector *vec)
+unsigned int gup_flags, struct frame_vector *vec)
 {
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
int ret = 0;
int err;
int locked;
-   unsigned int gup_flags = 0;
 
if (nr_frames == 0)
return 0;
 
-   if (write)
-   gup_flags |= FOLL_WRITE;
-   if (force)
-   gup_flags |= FOLL_FORCE;
-
if 

[PATCH 08/10] mm: replace __access_remote_vm() write parameter with gup_flags

2016-10-12 Thread Lorenzo Stoakes
This patch removes the write parameter from __access_remote_vm() and replaces it
with a gup_flags parameter as use of this function previously _implied_
FOLL_FORCE, whereas after this patch callers explicitly pass this flag.

We make this explicit as use of FOLL_FORCE can result in surprising behaviour
(and hence bugs) within the mm subsystem.

Signed-off-by: Lorenzo Stoakes 
---
 mm/memory.c | 23 +++
 mm/nommu.c  |  9 ++---
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 20a9adb..79ebed3 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3869,14 +3869,11 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
  * given task for page fault accounting.
  */
 static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
-   unsigned long addr, void *buf, int len, int write)
+   unsigned long addr, void *buf, int len, unsigned int gup_flags)
 {
struct vm_area_struct *vma;
void *old_buf = buf;
-   unsigned int flags = FOLL_FORCE;
-
-   if (write)
-   flags |= FOLL_WRITE;
+   int write = gup_flags & FOLL_WRITE;
 
down_read(>mmap_sem);
/* ignore errors, just check how much was successfully transferred */
@@ -3886,7 +3883,7 @@ static int __access_remote_vm(struct task_struct *tsk, 
struct mm_struct *mm,
struct page *page = NULL;
 
ret = get_user_pages_remote(tsk, mm, addr, 1,
-   flags, , );
+   gup_flags, , );
if (ret <= 0) {
 #ifndef CONFIG_HAVE_IOREMAP_PROT
break;
@@ -3945,7 +3942,12 @@ static int __access_remote_vm(struct task_struct *tsk, 
struct mm_struct *mm,
 int access_remote_vm(struct mm_struct *mm, unsigned long addr,
void *buf, int len, int write)
 {
-   return __access_remote_vm(NULL, mm, addr, buf, len, write);
+   unsigned int flags = FOLL_FORCE;
+
+   if (write)
+   flags |= FOLL_WRITE;
+
+   return __access_remote_vm(NULL, mm, addr, buf, len, flags);
 }
 
 /*
@@ -3958,12 +3960,17 @@ int access_process_vm(struct task_struct *tsk, unsigned 
long addr,
 {
struct mm_struct *mm;
int ret;
+   unsigned int flags = FOLL_FORCE;
 
mm = get_task_mm(tsk);
if (!mm)
return 0;
 
-   ret = __access_remote_vm(tsk, mm, addr, buf, len, write);
+   if (write)
+   flags |= FOLL_WRITE;
+
+   ret = __access_remote_vm(tsk, mm, addr, buf, len, flags);
+
mmput(mm);
 
return ret;
diff --git a/mm/nommu.c b/mm/nommu.c
index 70cb844..bde7df3 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1809,9 +1809,10 @@ void filemap_map_pages(struct fault_env *fe,
 EXPORT_SYMBOL(filemap_map_pages);
 
 static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
-   unsigned long addr, void *buf, int len, int write)
+   unsigned long addr, void *buf, int len, unsigned int gup_flags)
 {
struct vm_area_struct *vma;
+   int write = gup_flags & FOLL_WRITE;
 
down_read(>mmap_sem);
 
@@ -1853,7 +1854,8 @@ static int __access_remote_vm(struct task_struct *tsk, 
struct mm_struct *mm,
 int access_remote_vm(struct mm_struct *mm, unsigned long addr,
void *buf, int len, int write)
 {
-   return __access_remote_vm(NULL, mm, addr, buf, len, write);
+   return __access_remote_vm(NULL, mm, addr, buf, len,
+   write ? FOLL_WRITE : 0);
 }
 
 /*
@@ -1871,7 +1873,8 @@ int access_process_vm(struct task_struct *tsk, unsigned 
long addr, void *buf, in
if (!mm)
return 0;
 
-   len = __access_remote_vm(tsk, mm, addr, buf, len, write);
+   len = __access_remote_vm(tsk, mm, addr, buf, len,
+   write ? FOLL_WRITE : 0);
 
mmput(mm);
return len;
-- 
2.10.0

--
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 09/10] mm: replace access_remote_vm() write parameter with gup_flags

2016-10-12 Thread Lorenzo Stoakes
This patch removes the write parameter from access_remote_vm() and replaces it
with a gup_flags parameter as use of this function previously _implied_
FOLL_FORCE, whereas after this patch callers explicitly pass this flag.

We make this explicit as use of FOLL_FORCE can result in surprising behaviour
(and hence bugs) within the mm subsystem.

Signed-off-by: Lorenzo Stoakes 
---
 fs/proc/base.c | 19 +--
 include/linux/mm.h |  2 +-
 mm/memory.c| 11 +++
 mm/nommu.c |  7 +++
 4 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index c2964d8..8e65446 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -252,7 +252,7 @@ static ssize_t proc_pid_cmdline_read(struct file *file, 
char __user *buf,
 * Inherently racy -- command line shares address space
 * with code and data.
 */
-   rv = access_remote_vm(mm, arg_end - 1, , 1, 0);
+   rv = access_remote_vm(mm, arg_end - 1, , 1, FOLL_FORCE);
if (rv <= 0)
goto out_free_page;
 
@@ -270,7 +270,8 @@ static ssize_t proc_pid_cmdline_read(struct file *file, 
char __user *buf,
int nr_read;
 
_count = min3(count, len, PAGE_SIZE);
-   nr_read = access_remote_vm(mm, p, page, _count, 0);
+   nr_read = access_remote_vm(mm, p, page, _count,
+   FOLL_FORCE);
if (nr_read < 0)
rv = nr_read;
if (nr_read <= 0)
@@ -305,7 +306,8 @@ static ssize_t proc_pid_cmdline_read(struct file *file, 
char __user *buf,
bool final;
 
_count = min3(count, len, PAGE_SIZE);
-   nr_read = access_remote_vm(mm, p, page, _count, 0);
+   nr_read = access_remote_vm(mm, p, page, _count,
+   FOLL_FORCE);
if (nr_read < 0)
rv = nr_read;
if (nr_read <= 0)
@@ -354,7 +356,8 @@ static ssize_t proc_pid_cmdline_read(struct file *file, 
char __user *buf,
bool final;
 
_count = min3(count, len, PAGE_SIZE);
-   nr_read = access_remote_vm(mm, p, page, _count, 0);
+   nr_read = access_remote_vm(mm, p, page, _count,
+   FOLL_FORCE);
if (nr_read < 0)
rv = nr_read;
if (nr_read <= 0)
@@ -832,6 +835,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
unsigned long addr = *ppos;
ssize_t copied;
char *page;
+   unsigned int flags = FOLL_FORCE;
 
if (!mm)
return 0;
@@ -844,6 +848,9 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
if (!atomic_inc_not_zero(>mm_users))
goto free;
 
+   if (write)
+   flags |= FOLL_WRITE;
+
while (count > 0) {
int this_len = min_t(int, count, PAGE_SIZE);
 
@@ -852,7 +859,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
break;
}
 
-   this_len = access_remote_vm(mm, addr, page, this_len, write);
+   this_len = access_remote_vm(mm, addr, page, this_len, flags);
if (!this_len) {
if (!copied)
copied = -EIO;
@@ -965,7 +972,7 @@ static ssize_t environ_read(struct file *file, char __user 
*buf,
this_len = min(max_len, this_len);
 
retval = access_remote_vm(mm, (env_start + src),
-   page, this_len, 0);
+   page, this_len, FOLL_FORCE);
 
if (retval <= 0) {
ret = retval;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 2a481d3..3e5234e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1268,7 +1268,7 @@ static inline int fixup_user_fault(struct task_struct 
*tsk,
 
 extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void 
*buf, int len, int write);
 extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
-   void *buf, int len, int write);
+   void *buf, int len, unsigned int gup_flags);
 
 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
  unsigned long start, unsigned long nr_pages,
diff --git a/mm/memory.c b/mm/memory.c
index 79ebed3..bac2d99 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3935,19 +3935,14 @@ static int __access_remote_vm(struct task_struct *tsk, 
struct mm_struct *mm,
  * @addr:  start address to access
  * @buf:   source or destination buffer
  * @len:   number of bytes to transfer
- * @write: 

cron job: media_tree daily build: ERRORS

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

Results of the daily build of media_tree:

date:   Thu Oct 13 05:00:16 CEST 2016
media-tree git hash:9fce0c226536fc36c7fb0a8ca38a995be43e
media_build git hash:   ecfc9bfca3012b0c6e19967ce90f621f71a6da94
v4l-utils git hash: 79186f9d3d9d3b6bee4a611bd92435d11807
gcc version:i686-linux-gcc (GCC) 6.2.0
sparse version: v0.5.0-3553-g78b2ea6
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.7.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: OK
linux-git-arm-pxa: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: WARNINGS
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: ERRORS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: WARNINGS
linux-3.1.10-i686: ERRORS
linux-3.2.37-i686: ERRORS
linux-3.3.8-i686: ERRORS
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: OK
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-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: WARNINGS
linux-3.1.10-x86_64: ERRORS
linux-3.2.37-x86_64: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: 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: OK
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: OK
apps: WARNINGS
spec-git: OK
smatch: ERRORS
sparse: WARNINGS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/index.html
--
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 07/10] mm: replace get_user_pages_remote() write/force parameters with gup_flags

2016-10-12 Thread Lorenzo Stoakes
This patch removes the write and force parameters from get_user_pages_remote()
and replaces them with a gup_flags parameter to make the use of FOLL_FORCE
explicit in callers as use of this flag can result in surprising behaviour (and
hence bugs) within the mm subsystem.

Signed-off-by: Lorenzo Stoakes 
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c   |  7 +--
 drivers/gpu/drm/i915/i915_gem_userptr.c |  6 +-
 drivers/infiniband/core/umem_odp.c  |  7 +--
 fs/exec.c   |  9 +++--
 include/linux/mm.h  |  2 +-
 kernel/events/uprobes.c |  6 --
 mm/gup.c| 22 +++---
 mm/memory.c |  6 +-
 security/tomoyo/domain.c|  2 +-
 9 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index 5ce3603..0370b84 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -748,19 +748,22 @@ static struct page **etnaviv_gem_userptr_do_get_pages(
int ret = 0, pinned, npages = etnaviv_obj->base.size >> PAGE_SHIFT;
struct page **pvec;
uintptr_t ptr;
+   unsigned int flags = 0;
 
pvec = drm_malloc_ab(npages, sizeof(struct page *));
if (!pvec)
return ERR_PTR(-ENOMEM);
 
+   if (!etnaviv_obj->userptr.ro)
+   flags |= FOLL_WRITE;
+
pinned = 0;
ptr = etnaviv_obj->userptr.ptr;
 
down_read(>mmap_sem);
while (pinned < npages) {
ret = get_user_pages_remote(task, mm, ptr, npages - pinned,
-   !etnaviv_obj->userptr.ro, 0,
-   pvec + pinned, NULL);
+   flags, pvec + pinned, NULL);
if (ret < 0)
break;
 
diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c 
b/drivers/gpu/drm/i915/i915_gem_userptr.c
index e537930..c6f780f 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -508,6 +508,10 @@ __i915_gem_userptr_get_pages_worker(struct work_struct 
*_work)
pvec = drm_malloc_gfp(npages, sizeof(struct page *), GFP_TEMPORARY);
if (pvec != NULL) {
struct mm_struct *mm = obj->userptr.mm->mm;
+   unsigned int flags = 0;
+
+   if (!obj->userptr.read_only)
+   flags |= FOLL_WRITE;
 
ret = -EFAULT;
if (atomic_inc_not_zero(>mm_users)) {
@@ -517,7 +521,7 @@ __i915_gem_userptr_get_pages_worker(struct work_struct 
*_work)
(work->task, mm,
 obj->userptr.ptr + pinned * PAGE_SIZE,
 npages - pinned,
-!obj->userptr.read_only, 0,
+flags,
 pvec + pinned, NULL);
if (ret < 0)
break;
diff --git a/drivers/infiniband/core/umem_odp.c 
b/drivers/infiniband/core/umem_odp.c
index 75077a0..1f0fe32 100644
--- a/drivers/infiniband/core/umem_odp.c
+++ b/drivers/infiniband/core/umem_odp.c
@@ -527,6 +527,7 @@ int ib_umem_odp_map_dma_pages(struct ib_umem *umem, u64 
user_virt, u64 bcnt,
u64 off;
int j, k, ret = 0, start_idx, npages = 0;
u64 base_virt_addr;
+   unsigned int flags = 0;
 
if (access_mask == 0)
return -EINVAL;
@@ -556,6 +557,9 @@ int ib_umem_odp_map_dma_pages(struct ib_umem *umem, u64 
user_virt, u64 bcnt,
goto out_put_task;
}
 
+   if (access_mask & ODP_WRITE_ALLOWED_BIT)
+   flags |= FOLL_WRITE;
+
start_idx = (user_virt - ib_umem_start(umem)) >> PAGE_SHIFT;
k = start_idx;
 
@@ -574,8 +578,7 @@ int ib_umem_odp_map_dma_pages(struct ib_umem *umem, u64 
user_virt, u64 bcnt,
 */
npages = get_user_pages_remote(owning_process, owning_mm,
user_virt, gup_num_pages,
-   access_mask & ODP_WRITE_ALLOWED_BIT,
-   0, local_page_list, NULL);
+   flags, local_page_list, NULL);
up_read(_mm->mmap_sem);
 
if (npages < 0)
diff --git a/fs/exec.c b/fs/exec.c
index 6fcfb3f..4e497b9 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -191,6 +191,7 @@ static struct page *get_arg_page(struct linux_binprm *bprm, 
unsigned long pos,
 {
struct page *page;
int ret;
+   unsigned int gup_flags = FOLL_FORCE;
 
 #ifdef CONFIG_STACK_GROWSUP
if (write) {
@@ -199,12 +200,16 @@ static struct page *get_arg_page(struct linux_binprm 
*bprm, unsigned 

[PATCH 01/10] mm: remove write/force parameters from __get_user_pages_locked()

2016-10-12 Thread Lorenzo Stoakes
This patch removes the write and force parameters from __get_user_pages_locked()
to make the use of FOLL_FORCE explicit in callers as use of this flag can result
in surprising behaviour (and hence bugs) within the mm subsystem.

Signed-off-by: Lorenzo Stoakes 
---
 mm/gup.c | 47 +--
 1 file changed, 33 insertions(+), 14 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 96b2b2f..ba83942 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -729,7 +729,6 @@ static __always_inline long __get_user_pages_locked(struct 
task_struct *tsk,
struct mm_struct *mm,
unsigned long start,
unsigned long nr_pages,
-   int write, int force,
struct page **pages,
struct vm_area_struct **vmas,
int *locked, bool notify_drop,
@@ -747,10 +746,6 @@ static __always_inline long __get_user_pages_locked(struct 
task_struct *tsk,
 
if (pages)
flags |= FOLL_GET;
-   if (write)
-   flags |= FOLL_WRITE;
-   if (force)
-   flags |= FOLL_FORCE;
 
pages_done = 0;
lock_dropped = false;
@@ -846,9 +841,15 @@ long get_user_pages_locked(unsigned long start, unsigned 
long nr_pages,
   int write, int force, struct page **pages,
   int *locked)
 {
+   unsigned int flags = FOLL_TOUCH;
+
+   if (write)
+   flags |= FOLL_WRITE;
+   if (force)
+   flags |= FOLL_FORCE;
+
return __get_user_pages_locked(current, current->mm, start, nr_pages,
-  write, force, pages, NULL, locked, true,
-  FOLL_TOUCH);
+  pages, NULL, locked, true, flags);
 }
 EXPORT_SYMBOL(get_user_pages_locked);
 
@@ -869,9 +870,15 @@ __always_inline long __get_user_pages_unlocked(struct 
task_struct *tsk, struct m
 {
long ret;
int locked = 1;
+
+   if (write)
+   gup_flags |= FOLL_WRITE;
+   if (force)
+   gup_flags |= FOLL_FORCE;
+
down_read(>mmap_sem);
-   ret = __get_user_pages_locked(tsk, mm, start, nr_pages, write, force,
- pages, NULL, , false, gup_flags);
+   ret = __get_user_pages_locked(tsk, mm, start, nr_pages, pages, NULL,
+ , false, gup_flags);
if (locked)
up_read(>mmap_sem);
return ret;
@@ -963,9 +970,15 @@ long get_user_pages_remote(struct task_struct *tsk, struct 
mm_struct *mm,
int write, int force, struct page **pages,
struct vm_area_struct **vmas)
 {
-   return __get_user_pages_locked(tsk, mm, start, nr_pages, write, force,
-  pages, vmas, NULL, false,
-  FOLL_TOUCH | FOLL_REMOTE);
+   unsigned int flags = FOLL_TOUCH | FOLL_REMOTE;
+
+   if (write)
+   flags |= FOLL_WRITE;
+   if (force)
+   flags |= FOLL_FORCE;
+
+   return __get_user_pages_locked(tsk, mm, start, nr_pages, pages, vmas,
+  NULL, false, flags);
 }
 EXPORT_SYMBOL(get_user_pages_remote);
 
@@ -979,9 +992,15 @@ long get_user_pages(unsigned long start, unsigned long 
nr_pages,
int write, int force, struct page **pages,
struct vm_area_struct **vmas)
 {
+   unsigned int flags = FOLL_TOUCH;
+
+   if (write)
+   flags |= FOLL_WRITE;
+   if (force)
+   flags |= FOLL_FORCE;
+
return __get_user_pages_locked(current, current->mm, start, nr_pages,
-  write, force, pages, vmas, NULL, false,
-  FOLL_TOUCH);
+  pages, vmas, NULL, false, flags);
 }
 EXPORT_SYMBOL(get_user_pages);
 
-- 
2.10.0

--
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 03/10] mm: replace get_user_pages_unlocked() write/force parameters with gup_flags

2016-10-12 Thread Lorenzo Stoakes
This patch removes the write and force parameters from get_user_pages_unlocked()
and replaces them with a gup_flags parameter to make the use of FOLL_FORCE
explicit in callers as use of this flag can result in surprising behaviour (and
hence bugs) within the mm subsystem.

Signed-off-by: Lorenzo Stoakes 
---
 arch/mips/mm/gup.c |  2 +-
 arch/s390/mm/gup.c |  3 ++-
 arch/sh/mm/gup.c   |  3 ++-
 arch/sparc/mm/gup.c|  3 ++-
 arch/x86/mm/gup.c  |  2 +-
 drivers/media/pci/ivtv/ivtv-udma.c |  4 ++--
 drivers/media/pci/ivtv/ivtv-yuv.c  |  5 +++--
 drivers/scsi/st.c  |  5 ++---
 drivers/video/fbdev/pvr2fb.c   |  4 ++--
 include/linux/mm.h |  2 +-
 mm/gup.c   | 14 --
 mm/nommu.c | 11 ++-
 mm/util.c  |  3 ++-
 net/ceph/pagevec.c |  2 +-
 14 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/arch/mips/mm/gup.c b/arch/mips/mm/gup.c
index 42d124f..d8c3c15 100644
--- a/arch/mips/mm/gup.c
+++ b/arch/mips/mm/gup.c
@@ -287,7 +287,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, 
int write,
pages += nr;
 
ret = get_user_pages_unlocked(start, (end - start) >> PAGE_SHIFT,
- write, 0, pages);
+ pages, write ? FOLL_WRITE : 0);
 
/* Have to be a bit careful with return values */
if (nr > 0) {
diff --git a/arch/s390/mm/gup.c b/arch/s390/mm/gup.c
index adb0c34..18d4107 100644
--- a/arch/s390/mm/gup.c
+++ b/arch/s390/mm/gup.c
@@ -266,7 +266,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages, 
int write,
/* Try to get the remaining pages with get_user_pages */
start += nr << PAGE_SHIFT;
pages += nr;
-   ret = get_user_pages_unlocked(start, nr_pages - nr, write, 0, pages);
+   ret = get_user_pages_unlocked(start, nr_pages - nr, pages,
+ write ? FOLL_WRITE : 0);
/* Have to be a bit careful with return values */
if (nr > 0)
ret = (ret < 0) ? nr : ret + nr;
diff --git a/arch/sh/mm/gup.c b/arch/sh/mm/gup.c
index 40fa6c8..063c298 100644
--- a/arch/sh/mm/gup.c
+++ b/arch/sh/mm/gup.c
@@ -258,7 +258,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages, 
int write,
pages += nr;
 
ret = get_user_pages_unlocked(start,
-   (end - start) >> PAGE_SHIFT, write, 0, pages);
+   (end - start) >> PAGE_SHIFT, pages,
+   write ? FOLL_WRITE : 0);
 
/* Have to be a bit careful with return values */
if (nr > 0) {
diff --git a/arch/sparc/mm/gup.c b/arch/sparc/mm/gup.c
index 4e06750..cd0e32b 100644
--- a/arch/sparc/mm/gup.c
+++ b/arch/sparc/mm/gup.c
@@ -238,7 +238,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages, 
int write,
pages += nr;
 
ret = get_user_pages_unlocked(start,
-   (end - start) >> PAGE_SHIFT, write, 0, pages);
+   (end - start) >> PAGE_SHIFT, pages,
+   write ? FOLL_WRITE : 0);
 
/* Have to be a bit careful with return values */
if (nr > 0) {
diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
index b8b6a60..0d4fb3e 100644
--- a/arch/x86/mm/gup.c
+++ b/arch/x86/mm/gup.c
@@ -435,7 +435,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, 
int write,
 
ret = get_user_pages_unlocked(start,
  (end - start) >> PAGE_SHIFT,
- write, 0, pages);
+ pages, write ? FOLL_WRITE : 0);
 
/* Have to be a bit careful with return values */
if (nr > 0) {
diff --git a/drivers/media/pci/ivtv/ivtv-udma.c 
b/drivers/media/pci/ivtv/ivtv-udma.c
index 4769469..2c9232e 100644
--- a/drivers/media/pci/ivtv/ivtv-udma.c
+++ b/drivers/media/pci/ivtv/ivtv-udma.c
@@ -124,8 +124,8 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long 
ivtv_dest_addr,
}
 
/* Get user pages for DMA Xfer */
-   err = get_user_pages_unlocked(user_dma.uaddr, user_dma.page_count, 0,
-   1, dma->map);
+   err = get_user_pages_unlocked(user_dma.uaddr, user_dma.page_count,
+   dma->map, FOLL_FORCE);
 
if (user_dma.page_count != err) {
IVTV_DEBUG_WARN("failed to map user pages, returned %d instead 
of %d\n",
diff --git a/drivers/media/pci/ivtv/ivtv-yuv.c 
b/drivers/media/pci/ivtv/ivtv-yuv.c
index b094054..f7299d3 100644
--- a/drivers/media/pci/ivtv/ivtv-yuv.c
+++ b/drivers/media/pci/ivtv/ivtv-yuv.c
@@ -76,11 +76,12 @@ static int ivtv_yuv_prep_user_dma(struct ivtv *itv, struct 

[PATCH 02/10] mm: remove write/force parameters from __get_user_pages_unlocked()

2016-10-12 Thread Lorenzo Stoakes
This patch removes the write and force parameters from
__get_user_pages_unlocked() to make the use of FOLL_FORCE explicit in callers as
use of this flag can result in surprising behaviour (and hence bugs) within the
mm subsystem.

Signed-off-by: Lorenzo Stoakes 
---
 include/linux/mm.h |  3 +--
 mm/gup.c   | 17 +
 mm/nommu.c | 12 +---
 mm/process_vm_access.c |  7 +--
 virt/kvm/async_pf.c|  3 ++-
 virt/kvm/kvm_main.c| 11 ---
 6 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index e9caec6..2db98b6 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1285,8 +1285,7 @@ long get_user_pages_locked(unsigned long start, unsigned 
long nr_pages,
int write, int force, struct page **pages, int *locked);
 long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
   unsigned long start, unsigned long nr_pages,
-  int write, int force, struct page **pages,
-  unsigned int gup_flags);
+  struct page **pages, unsigned int gup_flags);
 long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
int write, int force, struct page **pages);
 int get_user_pages_fast(unsigned long start, int nr_pages, int write,
diff --git a/mm/gup.c b/mm/gup.c
index ba83942..3d620dd 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -865,17 +865,11 @@ EXPORT_SYMBOL(get_user_pages_locked);
  */
 __always_inline long __get_user_pages_unlocked(struct task_struct *tsk, struct 
mm_struct *mm,
   unsigned long start, unsigned 
long nr_pages,
-  int write, int force, struct 
page **pages,
-  unsigned int gup_flags)
+  struct page **pages, unsigned 
int gup_flags)
 {
long ret;
int locked = 1;
 
-   if (write)
-   gup_flags |= FOLL_WRITE;
-   if (force)
-   gup_flags |= FOLL_FORCE;
-
down_read(>mmap_sem);
ret = __get_user_pages_locked(tsk, mm, start, nr_pages, pages, NULL,
  , false, gup_flags);
@@ -905,8 +899,15 @@ EXPORT_SYMBOL(__get_user_pages_unlocked);
 long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
 int write, int force, struct page **pages)
 {
+   unsigned int flags = FOLL_TOUCH;
+
+   if (write)
+   flags |= FOLL_WRITE;
+   if (force)
+   flags |= FOLL_FORCE;
+
return __get_user_pages_unlocked(current, current->mm, start, nr_pages,
-write, force, pages, FOLL_TOUCH);
+pages, flags);
 }
 EXPORT_SYMBOL(get_user_pages_unlocked);
 
diff --git a/mm/nommu.c b/mm/nommu.c
index 95daf81..925dcc1 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -185,8 +185,7 @@ EXPORT_SYMBOL(get_user_pages_locked);
 
 long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
   unsigned long start, unsigned long nr_pages,
-  int write, int force, struct page **pages,
-  unsigned int gup_flags)
+  struct page **pages, unsigned int gup_flags)
 {
long ret;
down_read(>mmap_sem);
@@ -200,8 +199,15 @@ EXPORT_SYMBOL(__get_user_pages_unlocked);
 long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
 int write, int force, struct page **pages)
 {
+   unsigned int flags = 0;
+
+   if (write)
+   flags |= FOLL_WRITE;
+   if (force)
+   flags |= FOLL_FORCE;
+
return __get_user_pages_unlocked(current, current->mm, start, nr_pages,
-write, force, pages, 0);
+pages, flags);
 }
 EXPORT_SYMBOL(get_user_pages_unlocked);
 
diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
index 07514d4..be8dc8d 100644
--- a/mm/process_vm_access.c
+++ b/mm/process_vm_access.c
@@ -88,12 +88,16 @@ static int process_vm_rw_single_vec(unsigned long addr,
ssize_t rc = 0;
unsigned long max_pages_per_loop = PVM_MAX_KMALLOC_PAGES
/ sizeof(struct pages *);
+   unsigned int flags = FOLL_REMOTE;
 
/* Work out address and page range required */
if (len == 0)
return 0;
nr_pages = (addr + len - 1) / PAGE_SIZE - addr / PAGE_SIZE + 1;
 
+   if (vm_write)
+   flags |= FOLL_WRITE;
+
while (!rc && nr_pages && iov_iter_count(iter)) {
int pages = min(nr_pages, max_pages_per_loop);
size_t bytes;
@@ -104,8 

[PATCH 00/10] mm: adjust get_user_pages* functions to explicitly pass FOLL_* flags

2016-10-12 Thread Lorenzo Stoakes
This patch series adjusts functions in the get_user_pages* family such that
desired FOLL_* flags are passed as an argument rather than implied by flags.

The purpose of this change is to make the use of FOLL_FORCE explicit so it is
easier to grep for and clearer to callers that this flag is being used. The use
of FOLL_FORCE is an issue as it overrides missing VM_READ/VM_WRITE flags for the
VMA whose pages we are reading from/writing to, which can result in surprising
behaviour.

The patch series came out of the discussion around commit 38e0885, which
addressed a BUG_ON() being triggered when a page was faulted in with PROT_NONE
set but having been overridden by FOLL_FORCE. do_numa_page() was run on the
assumption the page _must_ be one marked for NUMA node migration as an actual
PROT_NONE page would have been dealt with prior to this code path, however
FOLL_FORCE introduced a situation where this assumption did not hold.

See https://marc.info/?l=linux-mm=147585445805166 for the patch proposal.

Lorenzo Stoakes (10):
  mm: remove write/force parameters from __get_user_pages_locked()
  mm: remove write/force parameters from __get_user_pages_unlocked()
  mm: replace get_user_pages_unlocked() write/force parameters with gup_flags
  mm: replace get_user_pages_locked() write/force parameters with gup_flags
  mm: replace get_vaddr_frames() write/force parameters with gup_flags
  mm: replace get_user_pages() write/force parameters with gup_flags
  mm: replace get_user_pages_remote() write/force parameters with gup_flags
  mm: replace __access_remote_vm() write parameter with gup_flags
  mm: replace access_remote_vm() write parameter with gup_flags
  mm: replace access_process_vm() write parameter with gup_flags

 arch/alpha/kernel/ptrace.c |  9 ++--
 arch/blackfin/kernel/ptrace.c  |  5 ++-
 arch/cris/arch-v32/drivers/cryptocop.c |  4 +-
 arch/cris/arch-v32/kernel/ptrace.c |  4 +-
 arch/ia64/kernel/err_inject.c  |  2 +-
 arch/ia64/kernel/ptrace.c  | 14 +++---
 arch/m32r/kernel/ptrace.c  | 15 ---
 arch/mips/kernel/ptrace32.c|  5 ++-
 arch/mips/mm/gup.c |  2 +-
 arch/powerpc/kernel/ptrace32.c |  5 ++-
 arch/s390/mm/gup.c |  3 +-
 arch/score/kernel/ptrace.c | 10 +++--
 arch/sh/mm/gup.c   |  3 +-
 arch/sparc/kernel/ptrace_64.c  | 24 +++
 arch/sparc/mm/gup.c|  3 +-
 arch/x86/kernel/step.c |  3 +-
 arch/x86/mm/gup.c  |  2 +-
 arch/x86/mm/mpx.c  |  5 +--
 arch/x86/um/ptrace_32.c|  3 +-
 arch/x86/um/ptrace_64.c|  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|  7 ++-
 drivers/gpu/drm/etnaviv/etnaviv_gem.c  |  7 ++-
 drivers/gpu/drm/exynos/exynos_drm_g2d.c|  3 +-
 drivers/gpu/drm/i915/i915_gem_userptr.c|  6 ++-
 drivers/gpu/drm/radeon/radeon_ttm.c|  3 +-
 drivers/gpu/drm/via/via_dmablit.c  |  4 +-
 drivers/infiniband/core/umem.c |  6 ++-
 drivers/infiniband/core/umem_odp.c |  7 ++-
 drivers/infiniband/hw/mthca/mthca_memfree.c|  2 +-
 drivers/infiniband/hw/qib/qib_user_pages.c |  3 +-
 drivers/infiniband/hw/usnic/usnic_uiom.c   |  5 ++-
 drivers/media/pci/ivtv/ivtv-udma.c |  4 +-
 drivers/media/pci/ivtv/ivtv-yuv.c  |  5 ++-
 drivers/media/platform/omap/omap_vout.c|  2 +-
 drivers/media/v4l2-core/videobuf-dma-sg.c  |  7 ++-
 drivers/media/v4l2-core/videobuf2-memops.c |  6 ++-
 drivers/misc/mic/scif/scif_rma.c   |  3 +-
 drivers/misc/sgi-gru/grufault.c|  2 +-
 drivers/platform/goldfish/goldfish_pipe.c  |  3 +-
 drivers/rapidio/devices/rio_mport_cdev.c   |  3 +-
 drivers/scsi/st.c  |  5 +--
 .../interface/vchiq_arm/vchiq_2835_arm.c   |  3 +-
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |  3 +-
 drivers/video/fbdev/pvr2fb.c   |  4 +-
 drivers/virt/fsl_hypervisor.c  |  4 +-
 fs/exec.c  |  9 +++-
 fs/proc/base.c | 19 +---
 include/linux/mm.h | 18 
 kernel/events/uprobes.c|  6 ++-
 kernel/ptrace.c| 16 ---
 mm/frame_vector.c  |  9 ++--
 mm/gup.c   | 50 ++
 mm/memory.c| 16 ---

Re: [RFC 0/6] Module for tracking/accounting shared memory buffers

2016-10-12 Thread Dave Hansen
On 10/11/2016 04:50 PM, Ruchi Kandoi wrote:
> Any process holding a reference to these buffers will keep the kernel from
> reclaiming its backing pages.  mm counters don't provide a complete picture of
> these allocations, since they only account for pages that are mapped into a
> process's address space.  This problem is especially bad for systems like
> Android that use dma-buf fds to share graphics and multimedia buffers between
> processes: these allocations are often large, have complex sharing patterns,
> and are rarely mapped into every process that holds a reference to them.

What do you end up _doing_ with all this new information that you have
here?  You know which processes have "pinned" these shared buffers, and
exported that information in /proc.  But, then what?
--
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 resent 27/34] [media] DaVinci-VPIF-Capture: Adjust ten checks for null pointers

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 15:20:34 +0200

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 
---

Another send try because of the following notification:

Mailer Daemon wrote on 2016-10-12 at 17:06:
> This message was created automatically by mail delivery software.
> 
> A message that you sent could not be delivered to one or more of
> its recipients. This is a permanent error. The following address(es)
> failed:
> 
> linux-media@vger.kernel.org:
> SMTP error from remote server for TEXT command, host: vger.kernel.org 
> (209.132.180.67) reason: 550 5.7.1 Content-Policy reject msg: Wrong MIME 
> labeling on 8-bit characte
> r texts. BF:; S933375AbcJLPGr
> 
> kernel-janit...@vger.kernel.org:
> SMTP error from remote server for TEXT command, host: vger.kernel.org 
> (209.132.180.67) reason: 550 5.7.1 Content-Policy reject msg: Wrong MIME 
> labeling on 8-bit characte
> r texts. BF:; S933375AbcJLPGr
> 
> linux-ker...@vger.kernel.org:
> SMTP error from remote server for TEXT command, host: vger.kernel.org 
> (209.132.180.67) reason: 550 5.7.1 Content-Policy reject msg: Wrong MIME 
> labeling on 8-bit characte
> r texts. BF:; S933375AbcJLPGr


 drivers/media/platform/davinci/vpif_capture.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index 24d1f61..d9fc591 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -291,10 +291,10 @@ static void vpif_stop_streaming(struct vb2_queue *vq)
vb2_buffer_done(>cur_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
} else {
-   if (common->cur_frm != NULL)
+   if (common->cur_frm)
vb2_buffer_done(>cur_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
-   if (common->next_frm != NULL)
+   if (common->next_frm)
vb2_buffer_done(>next_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
}
@@ -648,7 +648,7 @@ static int vpif_input_to_subdev(
vpif_dbg(2, debug, "vpif_input_to_subdev\n");
 
subdev_name = chan_cfg->inputs[input_index].subdev_name;
-   if (subdev_name == NULL)
+   if (!subdev_name)
return -1;
 
/* loop through the sub device list to get the sub device info */
@@ -764,7 +764,7 @@ static int vpif_g_std(struct file *file, void *priv, 
v4l2_std_id *std)
 
vpif_dbg(2, debug, "vpif_g_std\n");
 
-   if (config->chan_config[ch->channel_id].inputs == NULL)
+   if (!config->chan_config[ch->channel_id].inputs)
return -ENODATA;
 
chan_cfg = >chan_config[ch->channel_id];
@@ -794,7 +794,7 @@ static int vpif_s_std(struct file *file, void *priv, 
v4l2_std_id std_id)
 
vpif_dbg(2, debug, "vpif_s_std\n");
 
-   if (config->chan_config[ch->channel_id].inputs == NULL)
+   if (!config->chan_config[ch->channel_id].inputs)
return -ENODATA;
 
chan_cfg = >chan_config[ch->channel_id];
@@ -1050,7 +1050,7 @@ vpif_enum_dv_timings(struct file *file, void *priv,
struct v4l2_input input;
int ret;
 
-   if (config->chan_config[ch->channel_id].inputs == NULL)
+   if (!config->chan_config[ch->channel_id].inputs)
return -ENODATA;
 
chan_cfg = >chan_config[ch->channel_id];
@@ -1084,7 +1084,7 @@ vpif_query_dv_timings(struct file *file, void *priv,
struct v4l2_input input;
int ret;
 
-   if (config->chan_config[ch->channel_id].inputs == NULL)
+   if (!config->chan_config[ch->channel_id].inputs)
return -ENODATA;
 
chan_cfg = >chan_config[ch->channel_id];
@@ -1120,7 +1120,7 @@ static int vpif_s_dv_timings(struct file *file, void 
*priv,
struct v4l2_input input;
int ret;
 
-   if (config->chan_config[ch->channel_id].inputs == NULL)
+   if (!config->chan_config[ch->channel_id].inputs)
return -ENODATA;
 
chan_cfg = >chan_config[ch->channel_id];
@@ -1218,7 +1218,7 @@ static int vpif_g_dv_timings(struct file *file, void 
*priv,
struct vpif_capture_chan_config *chan_cfg;
struct v4l2_input input;
 
-   if (config->chan_config[ch->channel_id].inputs == NULL)
+   if (!config->chan_config[ch->channel_id].inputs)
return -ENODATA;
 
chan_cfg = >chan_config[ch->channel_id];
@@ -1465,7 +1465,7 @@ static __init int vpif_probe(struct platform_device *pdev)
 
subdev_count = vpif_obj.config->subdev_count;
vpif_obj.sd = kcalloc(subdev_count, sizeof(*vpif_obj.sd), GFP_KERNEL);
-   if 

[PATCH resent 03/34] [media] DaVinci-VPBE: Adjust 16 checks for null pointers

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 11 Oct 2016 13:37:10 +0200

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 
---

Another send try because of the following notification:

Mailer Daemon wrote on 2016-10-12 at 16:39:
> This message was created automatically by mail delivery software.
> 
> A message that you sent could not be delivered to one or more of
> its recipients. This is a permanent error. The following address(es)
> failed:
> 
> linux-ker...@vger.kernel.org:
> SMTP error from remote server for TEXT command, host: vger.kernel.org 
> (209.132.180.67) reason: 550 5.7.1 Content-Policy reject msg: Wrong MIME 
> labeling on 8-bit characte
> r texts. BF:; S1755378AbcJLOjE
> 
> linux-media@vger.kernel.org:
> SMTP error from remote server for TEXT command, host: vger.kernel.org 
> (209.132.180.67) reason: 550 5.7.1 Content-Policy reject msg: Wrong MIME 
> labeling on 8-bit characte
> r texts. BF:; S1755378AbcJLOjE
> 
> kernel-janit...@vger.kernel.org:
> SMTP error from remote server for TEXT command, host: vger.kernel.org 
> (209.132.180.67) reason: 550 5.7.1 Content-Policy reject msg: Wrong MIME 
> labeling on 8-bit characte
> r texts. BF:; S1755378AbcJLOjE


 drivers/media/platform/davinci/vpbe.c | 29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index b479747..496b27f 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -107,7 +107,7 @@ static int vpbe_find_encoder_sd_index(struct vpbe_config 
*cfg,
 static int vpbe_g_cropcap(struct vpbe_device *vpbe_dev,
  struct v4l2_cropcap *cropcap)
 {
-   if (NULL == cropcap)
+   if (!cropcap)
return -EINVAL;
cropcap->bounds.left = 0;
cropcap->bounds.top = 0;
@@ -149,7 +149,7 @@ static int vpbe_get_mode_info(struct vpbe_device *vpbe_dev, 
char *mode,
int curr_output = output_index;
int i;
 
-   if (NULL == mode)
+   if (!mode)
return -EINVAL;
 
for (i = 0; i < cfg->outputs[curr_output].num_modes; i++) {
@@ -166,7 +166,7 @@ static int vpbe_get_mode_info(struct vpbe_device *vpbe_dev, 
char *mode,
 static int vpbe_get_current_mode_info(struct vpbe_device *vpbe_dev,
  struct vpbe_enc_mode_info *mode_info)
 {
-   if (NULL == mode_info)
+   if (!mode_info)
return -EINVAL;
 
*mode_info = vpbe_dev->current_timings;
@@ -356,7 +356,7 @@ static int vpbe_s_dv_timings(struct vpbe_device *vpbe_dev,
 
ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video,
s_dv_timings, dv_timings);
-   if (!ret && (vpbe_dev->amp != NULL)) {
+   if (!ret && vpbe_dev->amp) {
/* Call amplifier subdevice */
ret = v4l2_subdev_call(vpbe_dev->amp, video,
s_dv_timings, dv_timings);
@@ -512,7 +512,7 @@ static int vpbe_set_mode(struct vpbe_device *vpbe_dev,
int ret = 0;
int i;
 
-   if ((NULL == mode_info) || (NULL == mode_info->name))
+   if (!mode_info || !mode_info->name)
return -EINVAL;
 
for (i = 0; i < cfg->outputs[out_index].num_modes; i++) {
@@ -536,7 +536,7 @@ static int vpbe_set_mode(struct vpbe_device *vpbe_dev,
}
 
/* Only custom timing should reach here */
-   if (preset_mode == NULL)
+   if (!preset_mode)
return -EINVAL;
 
mutex_lock(_dev->lock);
@@ -570,9 +570,9 @@ static int platform_device_get(struct device *dev, void 
*data)
struct platform_device *pdev = to_platform_device(dev);
struct vpbe_device *vpbe_dev = data;
 
-   if (strstr(pdev->name, "vpbe-osd") != NULL)
+   if (strstr(pdev->name, "vpbe-osd"))
vpbe_dev->osd_device = platform_get_drvdata(pdev);
-   if (strstr(pdev->name, "vpbe-venc") != NULL)
+   if (strstr(pdev->name, "vpbe-venc"))
vpbe_dev->venc_device = dev_get_platdata(>dev);
 
return 0;
@@ -606,7 +606,7 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
 * from the platform device by iteration of platform drivers and
 * matching with device name
 */
-   if (NULL == vpbe_dev || NULL == dev) {
+   if (!vpbe_dev || !dev) {
printk(KERN_ERR "Null device pointers.\n");
return -ENODEV;
}
@@ -652,7 +652,7 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
vpbe_dev->venc = venc_sub_dev_init(_dev->v4l2_dev,
   vpbe_dev->cfg->venc.module_name);
/* register venc sub device 

[PATCH v3 2/2] Add support for Omnivision OV5647

2016-10-12 Thread Ramiro Oliveira
Signed-off-by: Ramiro Oliveira 
---
 MAINTAINERS|   7 +
 drivers/media/i2c/Kconfig  |  12 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/ov5647.c | 891 +
 4 files changed, 911 insertions(+)
 create mode 100644 drivers/media/i2c/ov5647.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0560911..11c414b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8661,6 +8661,13 @@ M:   Harald Welte 
 S: Maintained
 F: drivers/char/pcmcia/cm4040_cs.*
 
+OMNIVISION OV5647 SENSOR DRIVER
+M: Ramiro Oliveira 
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: drivers/media/i2c/ov5647.c
+
 OMNIVISION OV7670 SENSOR DRIVER
 M: Jonathan Corbet 
 L: linux-media@vger.kernel.org
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 2669b4b..4237165 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -531,6 +531,18 @@ config VIDEO_OV2659
  To compile this driver as a module, choose M here: the
  module will be called ov2659.
 
+config VIDEO_OV5647
+   tristate "OmniVision OV5647 sensor support"
+   depends on OF
+   depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+   depends on MEDIA_CAMERA_SUPPORT
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV5647 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov5647.
+
 config VIDEO_OV7640
tristate "OmniVision OV7640 sensor support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 92773b2..0d9014c 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -82,3 +82,4 @@ obj-$(CONFIG_VIDEO_IR_I2C)  += ir-kbd-i2c.o
 obj-$(CONFIG_VIDEO_ML86V7667)  += ml86v7667.o
 obj-$(CONFIG_VIDEO_OV2659) += ov2659.o
 obj-$(CONFIG_VIDEO_TC358743)   += tc358743.o
+obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
new file mode 100644
index 000..ba9a874
--- /dev/null
+++ b/drivers/media/i2c/ov5647.c
@@ -0,0 +1,891 @@
+/*
+ * A V4L2 driver for OmniVision OV5647 cameras.
+ *
+ * Based on Samsung S5K6AAFX SXGA 1/6" 1.3M CMOS Image Sensor driver
+ * Copyright (C) 2011 Sylwester Nawrocki 
+ *
+ * Based on Omnivision OV7670 Camera Driver
+ * Copyright (C) 2006-7 Jonathan Corbet 
+ *
+ * Copyright (C) 2016, Synopsys, Inc.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static bool debug;
+module_param(debug, bool, 0644);
+MODULE_PARM_DESC(debug, "Debug level (0-1)");
+
+/*
+ * The ov5647 sits on i2c with ID 0x6c
+ */
+#define OV5647_I2C_ADDR 0x6c
+#define SENSOR_NAME "ov5647"
+
+#define OV5647_REG_CHIPID_H0x300A
+#define OV5647_REG_CHIPID_L0x300B
+
+#define REG_TERM 0xfffe
+#define VAL_TERM 0xfe
+#define REG_DLY  0x
+
+/*define the voltage level of control signal*/
+#define CSI_STBY_ON1
+#define CSI_STBY_OFF   0
+#define CSI_RST_ON 0
+#define CSI_RST_OFF1
+#define CSI_PWR_ON 1
+#define CSI_PWR_OFF0
+#define CSI_AF_PWR_ON  1
+#define CSI_AF_PWR_OFF 0
+
+
+#define OV5647_ROW_START   0x01
+#define OV5647_ROW_START_MIN   0
+#define OV5647_ROW_START_MAX   2004
+#define OV5647_ROW_START_DEF   54
+
+#define OV5647_COLUMN_START0x02
+#define OV5647_COLUMN_START_MIN0
+#define OV5647_COLUMN_START_MAX2750
+#define OV5647_COLUMN_START_DEF16
+
+#define OV5647_WINDOW_HEIGHT   0x03
+#define OV5647_WINDOW_HEIGHT_MIN   2
+#define OV5647_WINDOW_HEIGHT_MAX   2006
+#define OV5647_WINDOW_HEIGHT_DEF   1944
+
+#define OV5647_WINDOW_WIDTH0x04
+#define OV5647_WINDOW_WIDTH_MIN2
+#define OV5647_WINDOW_WIDTH_MAX2752
+#define OV5647_WINDOW_WIDTH_DEF2592
+
+enum power_seq_cmd {
+   CSI_SUBDEV_PWR_OFF = 0x00,
+   CSI_SUBDEV_PWR_ON = 0x01,
+};
+
+struct regval_list {
+   uint16_t addr;
+   uint8_t data;
+};
+
+struct cfg_array {
+   struct regval_list *regs;
+   int size;
+};
+
+struct sensor_win_size {
+   int width;
+   int height;
+   unsigned int hoffset;
+   unsigned int voffset;
+   unsigned int hts;
+   unsigned int vts;
+   unsigned int pclk;
+   unsigned int mipi_bps;
+   unsigned int fps_fixed;
+   unsigned int bin_factor;
+   unsigned int intg_min;
+   unsigned int intg_max;
+   void *regs;
+   int regs_size;
+   int (*set_size)(struct v4l2_subdev *subdev);
+};
+
+
+struct ov5647 {
+   

[PATCH v3 1/2] Add OV5647 device tree documentation

2016-10-12 Thread Ramiro Oliveira
Signed-off-by: Ramiro Oliveira 
---
 .../devicetree/bindings/media/i2c/ov5647.txt  | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5647.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov5647.txt 
b/Documentation/devicetree/bindings/media/i2c/ov5647.txt
new file mode 100644
index 000..4c91b3b
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov5647.txt
@@ -0,0 +1,19 @@
+Omnivision OV5647 raw image sensor
+-
+
+OV5647 is a raw image sensor with MIPI CSI-2 and CCP2 image data interfaces
+and CCI (I2C compatible) control bus.
+
+Required properties:
+
+- compatible   : "ovti,ov5647";
+- reg  : I2C slave address of the sensor;
+
+The common video interfaces bindings (see video-interfaces.txt) should be
+used to specify link to the image data receiver. The OV5647 device
+node should contain one 'port' child node with an 'endpoint' subnode.
+
+Following properties are valid for the endpoint node:
+
+- data-lanes : (optional) specifies MIPI CSI-2 data lanes as covered in
+  video-interfaces.txt.  The sensor supports only two data lanes.
-- 
2.9.3


--
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 v3 0/2] OV5647 Sensor driver

2016-10-12 Thread Ramiro Oliveira
Hello,

This patch adds support for the Omnivision OV5647 sensor.

At the moment it only supports 640x480 in Raw 8.

v3: Re-sending after no reply to previous patch.

Ramiro Oliveira (2):
  Add OV5647 device tree documentation
  Add support for Omnivision OV5647

 .../devicetree/bindings/media/i2c/ov5647.txt   |  19 +
 MAINTAINERS|   7 +
 drivers/media/i2c/Kconfig  |  12 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/ov5647.c | 891 +
 5 files changed, 930 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5647.txt
 create mode 100644 drivers/media/i2c/ov5647.c

-- 
2.9.3


--
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


V4L2_DEC_CMD_STOP and last_buffer_dequeued

2016-10-12 Thread 李務誠
Hi,
I'm trying to use V4L2_DEC_CMD_STOP to implement flush. First the
userspace sent V4L2_DEC_CMD_STOP to initiate the flush. The driver set
V4L2_BUF_FLAG_LAST on the last CAPTURE buffer. I thought implementing
V4L2_DEC_CMD_START in the driver was enough to start the decoder. But
last_buffer_dequeued had been set to true in v4l2 core. I couldn't
clear last_buffer_dequeued without calling STREAMOFF from the
userspace. If I need to call STREAMOFF/STREAMON after
V4L2_DEC_CMD_STOP, it looks like V4L2_DEC_CMD_START is not useful. Did
I miss anything?

Regards,
Wu-Cheng
--
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 32/34] [media] DaVinci-VPIF-Display: Adjust 11 checks for null pointers

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 15:40:32 +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/vpif_display.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index 3347fa14..fff1ece 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -271,10 +271,10 @@ static void vpif_stop_streaming(struct vb2_queue *vq)
vb2_buffer_done(>cur_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
} else {
-   if (common->cur_frm != NULL)
+   if (common->cur_frm)
vb2_buffer_done(>cur_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
-   if (common->next_frm != NULL)
+   if (common->next_frm)
vb2_buffer_done(>next_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
}
@@ -686,7 +686,7 @@ static int vpif_s_std(struct file *file, void *priv, 
v4l2_std_id std_id)
struct v4l2_output output;
int ret;
 
-   if (config->chan_config[ch->channel_id].outputs == NULL)
+   if (!config->chan_config[ch->channel_id].outputs)
return -ENODATA;
 
chan_cfg = >chan_config[ch->channel_id];
@@ -732,7 +732,7 @@ static int vpif_g_std(struct file *file, void *priv, 
v4l2_std_id *std)
struct vpif_display_chan_config *chan_cfg;
struct v4l2_output output;
 
-   if (config->chan_config[ch->channel_id].outputs == NULL)
+   if (!config->chan_config[ch->channel_id].outputs)
return -ENODATA;
 
chan_cfg = >chan_config[ch->channel_id];
@@ -783,11 +783,11 @@ vpif_output_to_subdev(struct vpif_display_config 
*vpif_cfg,
 
vpif_dbg(2, debug, "vpif_output_to_subdev\n");
 
-   if (chan_cfg->outputs == NULL)
+   if (!chan_cfg->outputs)
return -1;
 
subdev_name = chan_cfg->outputs[index].subdev_name;
-   if (subdev_name == NULL)
+   if (!subdev_name)
return -1;
 
/* loop through the sub device list to get the sub device info */
@@ -833,7 +833,7 @@ static int vpif_set_output(struct vpif_display_config 
*vpif_cfg,
}
ch->output_idx = index;
ch->sd = sd;
-   if (chan_cfg->outputs != NULL)
+   if (chan_cfg->outputs)
/* update tvnorms from the sub device output info */
ch->video_dev.tvnorms = chan_cfg->outputs[index].output.std;
return 0;
@@ -885,7 +885,7 @@ vpif_enum_dv_timings(struct file *file, void *priv,
struct v4l2_output output;
int ret;
 
-   if (config->chan_config[ch->channel_id].outputs == NULL)
+   if (!config->chan_config[ch->channel_id].outputs)
return -ENODATA;
 
chan_cfg = >chan_config[ch->channel_id];
@@ -922,7 +922,7 @@ static int vpif_s_dv_timings(struct file *file, void *priv,
struct v4l2_output output;
int ret;
 
-   if (config->chan_config[ch->channel_id].outputs == NULL)
+   if (!config->chan_config[ch->channel_id].outputs)
return -ENODATA;
 
chan_cfg = >chan_config[ch->channel_id];
@@ -1021,7 +1021,7 @@ static int vpif_g_dv_timings(struct file *file, void 
*priv,
struct video_obj *vid_ch = >video;
struct v4l2_output output;
 
-   if (config->chan_config[ch->channel_id].outputs == NULL)
+   if (!config->chan_config[ch->channel_id].outputs)
goto error;
 
chan_cfg = >chan_config[ch->channel_id];
@@ -1280,7 +1280,7 @@ static __init int vpif_probe(struct platform_device *pdev)
subdev_count = vpif_obj.config->subdev_count;
subdevdata = vpif_obj.config->subdevinfo;
vpif_obj.sd = kcalloc(subdev_count, sizeof(*vpif_obj.sd), GFP_KERNEL);
-   if (vpif_obj.sd == NULL) {
+   if (!vpif_obj.sd) {
err = -ENOMEM;
goto vpif_unregister;
}
-- 
2.10.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 33/34] [media] DaVinci-VPIF-Display: Delete an unnecessary variable initialisation in vpif_channel_isr()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 15:43:12 +0200

The local variable "channel_id" will be reassigned with the following
statement at the beginning. Thus omit the explicit initialisation.

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

diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index fff1ece..cd44990 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -363,7 +363,7 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
struct channel_obj *ch;
struct common_obj *common;
int fid = -1, i;
-   int channel_id = 0;
+   int channel_id;
 
channel_id = *(int *)(dev_id);
if (!vpif_intr_status(channel_id + 2))
-- 
2.10.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 30/34] [media] DaVinci-VPIF-Display: Use kcalloc() in vpif_probe()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 15:30:44 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  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/vpif_display.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index 75b2723..80121e8 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -1279,8 +1279,7 @@ static __init int vpif_probe(struct platform_device *pdev)
vpif_obj.config = pdev->dev.platform_data;
subdev_count = vpif_obj.config->subdev_count;
subdevdata = vpif_obj.config->subdevinfo;
-   vpif_obj.sd = kzalloc(sizeof(struct v4l2_subdev *) * subdev_count,
-   GFP_KERNEL);
+   vpif_obj.sd = kcalloc(subdev_count, sizeof(*vpif_obj.sd), GFP_KERNEL);
if (vpif_obj.sd == NULL) {
vpif_err("unable to allocate memory for subdevice pointers\n");
err = -ENOMEM;
-- 
2.10.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 29/34] [media] DaVinci-VPIF-Capture: Delete an unnecessary variable initialisation in vpif_channel_isr()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 15:25:08 +0200

The local variable "channel_id" will be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

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

diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index 4197ca4..d3e2235 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -375,7 +375,7 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
struct vpif_device *dev = _obj;
struct common_obj *common;
struct channel_obj *ch;
-   int channel_id = 0;
+   int channel_id;
int fid = -1, i;
 
channel_id = *(int *)(dev_id);
-- 
2.10.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 31/34] [media] DaVinci-VPIF-Display: Delete an error message for a failed memory allocation

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 15:38:41 +0200

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

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/media/platform/davinci/vpif_display.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index 80121e8..3347fa14 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -1281,7 +1281,6 @@ static __init int vpif_probe(struct platform_device *pdev)
subdevdata = vpif_obj.config->subdevinfo;
vpif_obj.sd = kcalloc(subdev_count, sizeof(*vpif_obj.sd), GFP_KERNEL);
if (vpif_obj.sd == NULL) {
-   vpif_err("unable to allocate memory for subdevice pointers\n");
err = -ENOMEM;
goto vpif_unregister;
}
-- 
2.10.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 34/34] [media] DaVinci-VPIF-Display: Delete an unnecessary variable initialisation in process_progressive_mode()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 15:45:03 +0200

The local variable "addr" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

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

diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index cd44990..a48a5111 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -301,7 +301,7 @@ static struct vb2_ops video_qops = {
 
 static void process_progressive_mode(struct common_obj *common)
 {
-   unsigned long addr = 0;
+   unsigned long addr;
 
spin_lock(>irqlock);
/* Get the next buffer from buffer queue */
-- 
2.10.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 25/34] [media] DaVinci-VPIF-Capture: Use kcalloc() in vpif_probe()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 15:15:34 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  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/vpif_capture.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index 5104cc0..fb9e850 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1464,8 +1464,7 @@ static __init int vpif_probe(struct platform_device *pdev)
vpif_obj.config = pdev->dev.platform_data;
 
subdev_count = vpif_obj.config->subdev_count;
-   vpif_obj.sd = kzalloc(sizeof(struct v4l2_subdev *) * subdev_count,
-   GFP_KERNEL);
+   vpif_obj.sd = kcalloc(subdev_count, sizeof(*vpif_obj.sd), GFP_KERNEL);
if (vpif_obj.sd == NULL) {
vpif_err("unable to allocate memory for subdevice pointers\n");
err = -ENOMEM;
-- 
2.10.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 28/34] [media] DaVinci-VPIF-Capture: Delete an unnecessary variable initialisation in vpif_querystd()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 15:22:45 +0200

The local variable "ret" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

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

diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index d9fc591..4197ca4 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -731,7 +731,7 @@ static int vpif_querystd(struct file *file, void *priv, 
v4l2_std_id *std_id)
 {
struct video_device *vdev = video_devdata(file);
struct channel_obj *ch = video_get_drvdata(vdev);
-   int ret = 0;
+   int ret;
 
vpif_dbg(2, debug, "vpif_querystd\n");
 
-- 
2.10.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 26/34] [media] DaVinci-VPIF-Capture: Delete an error message for a failed memory allocation

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 15:18:45 +0200

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

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/media/platform/davinci/vpif_capture.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index fb9e850..24d1f61 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1466,7 +1466,6 @@ static __init int vpif_probe(struct platform_device *pdev)
subdev_count = vpif_obj.config->subdev_count;
vpif_obj.sd = kcalloc(subdev_count, sizeof(*vpif_obj.sd), GFP_KERNEL);
if (vpif_obj.sd == NULL) {
-   vpif_err("unable to allocate memory for subdevice pointers\n");
err = -ENOMEM;
goto vpif_unregister;
}
-- 
2.10.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 24/34] [media] DaVinci-VPFE-Capture: Delete an unnecessary return statement in vpfe_unregister_ccdc_device()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 15:10:54 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement here.

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

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index e264c90..a79e1d5 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -281,7 +281,6 @@ void vpfe_unregister_ccdc_device(struct ccdc_hw_device *dev)
mutex_lock(_lock);
ccdc_dev = NULL;
mutex_unlock(_lock);
-   return;
 }
 EXPORT_SYMBOL(vpfe_unregister_ccdc_device);
 
-- 
2.10.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 20/34] [media] DaVinci-VPFE-Capture: Adjust 13 checks for null pointers

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 10:46:28 +0200

Convert comparisons with the preprocessor symbol "NULL" to condition checks
without it.

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

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index e370400..9da353b 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -229,7 +229,7 @@ int vpfe_register_ccdc_device(struct ccdc_hw_device *dev)
BUG_ON(!dev->hw_ops.getfid);
 
mutex_lock(_lock);
-   if (NULL == ccdc_cfg) {
+   if (!ccdc_cfg) {
/*
 * TODO. Will this ever happen? if so, we need to fix it.
 * Proabably we need to add the request to a linked list and
@@ -265,7 +265,7 @@ EXPORT_SYMBOL(vpfe_register_ccdc_device);
  */
 void vpfe_unregister_ccdc_device(struct ccdc_hw_device *dev)
 {
-   if (NULL == dev) {
+   if (!dev) {
printk(KERN_ERR "invalid ccdc device ptr\n");
return;
}
@@ -469,7 +469,7 @@ static int vpfe_initialize_device(struct vpfe_device 
*vpfe_dev)
 
/* now open the ccdc device to initialize it */
mutex_lock(_lock);
-   if (NULL == ccdc_dev) {
+   if (!ccdc_dev) {
v4l2_err(_dev->v4l2_dev, "ccdc device not registered\n");
ret = -ENODEV;
goto unlock;
@@ -582,7 +582,7 @@ static irqreturn_t vpfe_isr(int irq, void *dev_id)
goto clear_intr;
 
/* only for 6446 this will be applicable */
-   if (NULL != ccdc_dev->hw_ops.reset)
+   if (ccdc_dev->hw_ops.reset)
ccdc_dev->hw_ops.reset();
 
if (field == V4L2_FIELD_NONE) {
@@ -822,7 +822,7 @@ static const struct vpfe_pixel_format *
int temp, found;
 
vpfe_pix_fmt = vpfe_lookup_pix_format(pixfmt->pixelformat);
-   if (NULL == vpfe_pix_fmt) {
+   if (!vpfe_pix_fmt) {
/*
 * use current pixel format in the vpfe device. We
 * will find this pix format in the table
@@ -965,7 +965,7 @@ static int vpfe_enum_fmt_vid_cap(struct file *file, void  
*priv,
 
/* Fill in the information about format */
pix_fmt = vpfe_lookup_pix_format(pix);
-   if (NULL != pix_fmt) {
+   if (pix_fmt) {
temp_index = fmt->index;
*fmt = pix_fmt->fmtdesc;
fmt->index = temp_index;
@@ -991,8 +991,7 @@ static int vpfe_s_fmt_vid_cap(struct file *file, void *priv,
 
/* Check for valid frame format */
pix_fmts = vpfe_check_format(vpfe_dev, >fmt.pix);
-
-   if (NULL == pix_fmts)
+   if (!pix_fmts)
return -EINVAL;
 
/* store the pixel format in the device  object */
@@ -1018,7 +1017,7 @@ static int vpfe_try_fmt_vid_cap(struct file *file, void 
*priv,
v4l2_dbg(1, debug, _dev->v4l2_dev, "vpfe_try_fmt_vid_cap\n");
 
pix_fmts = vpfe_check_format(vpfe_dev, >fmt.pix);
-   if (NULL == pix_fmts)
+   if (!pix_fmts)
return -EINVAL;
return 0;
 }
@@ -1833,7 +1832,7 @@ static int vpfe_probe(struct platform_device *pdev)
 
vpfe_dev->pdev = >dev;
 
-   if (NULL == pdev->dev.platform_data) {
+   if (!pdev->dev.platform_data) {
v4l2_err(pdev->dev.driver, "Unable to get vpfe config\n");
ret = -ENODEV;
goto probe_free_dev_mem;
@@ -1841,9 +1840,7 @@ static int vpfe_probe(struct platform_device *pdev)
 
vpfe_cfg = pdev->dev.platform_data;
vpfe_dev->cfg = vpfe_cfg;
-   if (NULL == vpfe_cfg->ccdc ||
-   NULL == vpfe_cfg->card_name ||
-   NULL == vpfe_cfg->sub_devs) {
+   if (!vpfe_cfg->ccdc || !vpfe_cfg->card_name || !vpfe_cfg->sub_devs) {
v4l2_err(pdev->dev.driver, "null ptr in vpfe_cfg\n");
ret = -ENOENT;
goto probe_free_dev_mem;
@@ -1938,7 +1935,7 @@ static int vpfe_probe(struct platform_device *pdev)
vpfe_dev->sd = kmalloc_array(num_subdevs,
 sizeof(*vpfe_dev->sd),
 GFP_KERNEL);
-   if (NULL == vpfe_dev->sd) {
+   if (!vpfe_dev->sd) {
ret = -ENOMEM;
goto probe_out_video_unregister;
}
-- 
2.10.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 19/34] [media] DaVinci-VPFE-Capture: Improve another size determination in vpfe_open()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 10:44:05 +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.

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

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index ee7b3e3..e370400 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -511,7 +511,7 @@ static int vpfe_open(struct file *file)
}
 
/* Allocate memory for the file handle object */
-   fh = kmalloc(sizeof(struct vpfe_fh), GFP_KERNEL);
+   fh = kmalloc(sizeof(*fh), GFP_KERNEL);
if (!fh)
return -ENOMEM;
 
-- 
2.10.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 18/34] [media] DaVinci-VPFE-Capture: Combine substrings for an error message in vpfe_enum_input()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 10:40:10 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix an affected source code place.

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

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index 87ee35d..ee7b3e3 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -1086,8 +1086,8 @@ static int vpfe_enum_input(struct file *file, void *priv,
,
,
inp->index) < 0) {
-   v4l2_err(_dev->v4l2_dev, "input information not found"
-" for the subdev\n");
+   v4l2_err(_dev->v4l2_dev,
+"input information not found for the subdev\n");
return -EINVAL;
}
sdinfo = _dev->cfg->sub_devs[subdev];
-- 
2.10.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 22/34] [media] DaVinci-VPFE-Capture: Move two assignments in vpfe_s_input()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 11:22:23 +0200

Move assignments for two local variables into an else branch so that
their setting will only be performed after corresponding data processing
succeeded by this function.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/davinci/vpfe_capture.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index ba71310..f0467fe 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -,7 +,7 @@ static int vpfe_s_input(struct file *file, void *priv, 
unsigned int index)
struct vpfe_subdev_info *sdinfo;
int subdev_index, inp_index;
struct vpfe_route *route;
-   u32 input = 0, output = 0;
+   u32 input, output;
int ret;
 
v4l2_dbg(1, debug, _dev->v4l2_dev, "vpfe_s_input\n");
@@ -1144,6 +1144,9 @@ static int vpfe_s_input(struct file *file, void *priv, 
unsigned int index)
if (route && sdinfo->can_route) {
input = route->input;
output = route->output;
+   } else {
+   input = 0;
+   output = 0;
}
 
if (sd)
-- 
2.10.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 21/34] [media] DaVinci-VPFE-Capture: Delete an unnecessary variable initialisation in 11 functions

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 10:50:54 +0200

The local variable "ret" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

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

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index 9da353b..ba71310 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -384,7 +384,7 @@ static int vpfe_config_image_format(struct vpfe_device 
*vpfe_dev,
};
struct v4l2_mbus_framefmt *mbus_fmt = 
struct v4l2_pix_format *pix = _dev->fmt.fmt.pix;
-   int i, ret = 0;
+   int i, ret;
 
for (i = 0; i < ARRAY_SIZE(vpfe_standards); i++) {
if (vpfe_standards[i].std_id & std_id) {
@@ -453,7 +453,7 @@ static int vpfe_config_image_format(struct vpfe_device 
*vpfe_dev,
 
 static int vpfe_initialize_device(struct vpfe_device *vpfe_dev)
 {
-   int ret = 0;
+   int ret;
 
/* set first input of current subdevice as the current input */
vpfe_dev->current_input = 0;
@@ -979,7 +979,7 @@ static int vpfe_s_fmt_vid_cap(struct file *file, void *priv,
 {
struct vpfe_device *vpfe_dev = video_drvdata(file);
const struct vpfe_pixel_format *pix_fmts;
-   int ret = 0;
+   int ret;
 
v4l2_dbg(1, debug, _dev->v4l2_dev, "vpfe_s_fmt_vid_cap\n");
 
@@ -1112,7 +1112,7 @@ static int vpfe_s_input(struct file *file, void *priv, 
unsigned int index)
int subdev_index, inp_index;
struct vpfe_route *route;
u32 input = 0, output = 0;
-   int ret = -EINVAL;
+   int ret;
 
v4l2_dbg(1, debug, _dev->v4l2_dev, "vpfe_s_input\n");
 
@@ -1178,7 +1178,7 @@ static int vpfe_querystd(struct file *file, void *priv, 
v4l2_std_id *std_id)
 {
struct vpfe_device *vpfe_dev = video_drvdata(file);
struct vpfe_subdev_info *sdinfo;
-   int ret = 0;
+   int ret;
 
v4l2_dbg(1, debug, _dev->v4l2_dev, "vpfe_querystd\n");
 
@@ -1197,7 +1197,7 @@ static int vpfe_s_std(struct file *file, void *priv, 
v4l2_std_id std_id)
 {
struct vpfe_device *vpfe_dev = video_drvdata(file);
struct vpfe_subdev_info *sdinfo;
-   int ret = 0;
+   int ret;
 
v4l2_dbg(1, debug, _dev->v4l2_dev, "vpfe_s_std\n");
 
@@ -1346,7 +1346,7 @@ static int vpfe_reqbufs(struct file *file, void *priv,
 {
struct vpfe_device *vpfe_dev = video_drvdata(file);
struct vpfe_fh *fh = file->private_data;
-   int ret = 0;
+   int ret;
 
v4l2_dbg(1, debug, _dev->v4l2_dev, "vpfe_reqbufs\n");
 
@@ -1478,7 +1478,7 @@ static int vpfe_streamon(struct file *file, void *priv,
struct vpfe_fh *fh = file->private_data;
struct vpfe_subdev_info *sdinfo;
unsigned long addr;
-   int ret = 0;
+   int ret;
 
v4l2_dbg(1, debug, _dev->v4l2_dev, "vpfe_streamon\n");
 
@@ -1561,7 +1561,7 @@ static int vpfe_streamoff(struct file *file, void *priv,
struct vpfe_device *vpfe_dev = video_drvdata(file);
struct vpfe_fh *fh = file->private_data;
struct vpfe_subdev_info *sdinfo;
-   int ret = 0;
+   int ret;
 
v4l2_dbg(1, debug, _dev->v4l2_dev, "vpfe_streamoff\n");
 
@@ -1647,7 +1647,7 @@ static int vpfe_s_selection(struct file *file, void *priv,
 {
struct vpfe_device *vpfe_dev = video_drvdata(file);
struct v4l2_rect rect = sel->r;
-   int ret = 0;
+   int ret;
 
v4l2_dbg(1, debug, _dev->v4l2_dev, "vpfe_s_selection\n");
 
@@ -1705,7 +1705,7 @@ static long vpfe_param_handler(struct file *file, void 
*priv,
bool valid_prio, unsigned int cmd, void *param)
 {
struct vpfe_device *vpfe_dev = video_drvdata(file);
-   int ret = 0;
+   int ret;
 
v4l2_dbg(2, debug, _dev->v4l2_dev, "vpfe_param_handler\n");
 
-- 
2.10.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 14/34] [media] DaVinci-VPFE-Capture: Delete three error messages for a failed memory allocation

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 10:22:47 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: Possible unnecessary 'out of memory' message

Thus remove such a logging statement in two functions.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/media/platform/davinci/vpfe_capture.c | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index 5c1b8cf..23142f0 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -512,11 +512,9 @@ static int vpfe_open(struct file *file)
 
/* Allocate memory for the file handle object */
fh = kmalloc(sizeof(struct vpfe_fh), GFP_KERNEL);
-   if (NULL == fh) {
-   v4l2_err(_dev->v4l2_dev,
-   "unable to allocate memory for file handle object\n");
+   if (!fh)
return -ENOMEM;
-   }
+
/* store pointer to fh in private_data member of file */
file->private_data = fh;
fh->vpfe_dev = vpfe_dev;
@@ -1853,11 +1851,8 @@ static int vpfe_probe(struct platform_device *pdev)
 
/* Allocate memory for ccdc configuration */
ccdc_cfg = kmalloc(sizeof(struct ccdc_config), GFP_KERNEL);
-   if (NULL == ccdc_cfg) {
-   v4l2_err(pdev->dev.driver,
-"Memory allocation failed for ccdc_cfg\n");
+   if (!ccdc_cfg)
goto probe_free_dev_mem;
-   }
 
mutex_lock(_lock);
 
@@ -1944,8 +1939,6 @@ static int vpfe_probe(struct platform_device *pdev)
 sizeof(*vpfe_dev->sd),
 GFP_KERNEL);
if (NULL == vpfe_dev->sd) {
-   v4l2_err(_dev->v4l2_dev,
-   "unable to allocate memory for subdevice pointers\n");
ret = -ENOMEM;
goto probe_out_video_unregister;
}
-- 
2.10.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 12/34] [media] DaVinci-VPBE: Delete an unnecessary variable initialisation in vpbe_set_output()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 10:16:23 +0200

The local variable "ret" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

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

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index e68a792..b2c5d8f 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -229,7 +229,7 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, 
int index)
struct venc_platform_data *venc_device = vpbe_dev->venc_device;
int enc_out_index;
int sd_index;
-   int ret = 0;
+   int ret;
 
if (index >= cfg->num_outputs)
return -EINVAL;
-- 
2.10.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 13/34] [media] DaVinci-VPFE-Capture: Use kmalloc_array() in vpfe_probe()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 10:20:02 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  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/vpfe_capture.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index 6efb2f1..5c1b8cf 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -1940,8 +1940,9 @@ static int vpfe_probe(struct platform_device *pdev)
video_set_drvdata(_dev->video_dev, vpfe_dev);
i2c_adap = i2c_get_adapter(vpfe_cfg->i2c_adapter_id);
num_subdevs = vpfe_cfg->num_subdevs;
-   vpfe_dev->sd = kmalloc(sizeof(struct v4l2_subdev *) * num_subdevs,
-   GFP_KERNEL);
+   vpfe_dev->sd = kmalloc_array(num_subdevs,
+sizeof(*vpfe_dev->sd),
+GFP_KERNEL);
if (NULL == vpfe_dev->sd) {
v4l2_err(_dev->v4l2_dev,
"unable to allocate memory for subdevice pointers\n");
-- 
2.10.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 17/34] [media] DaVinci-VPFE-Capture: Improve another size determination in vpfe_enum_input()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 10:33:42 +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.

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

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index 8314c39..87ee35d 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -1091,7 +1091,7 @@ static int vpfe_enum_input(struct file *file, void *priv,
return -EINVAL;
}
sdinfo = _dev->cfg->sub_devs[subdev];
-   memcpy(inp, >inputs[index], sizeof(struct v4l2_input));
+   memcpy(inp, >inputs[index], sizeof(*inp));
return 0;
 }
 
-- 
2.10.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 11/34] [media] DaVinci-VPBE: Rename a jump label in vpbe_set_output()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 10:10:19 +0200

Adjust jump labels according to the Linux coding style convention.

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

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index 6e7b0df..e68a792 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -253,20 +253,20 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, 
int index)
sd_index = vpbe_find_encoder_sd_index(cfg, index);
if (sd_index < 0) {
ret = -EINVAL;
-   goto out;
+   goto unlock;
}
 
ret = venc_device->setup_if_config(cfg
   ->outputs[index].if_params);
if (ret)
-   goto out;
+   goto unlock;
}
 
/* Set output at the encoder */
ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video,
   s_routing, 0, enc_out_index, 0);
if (ret)
-   goto out;
+   goto unlock;
 
/*
 * It is assumed that venc or extenal encoder will set a default
@@ -288,7 +288,7 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, 
int index)
vpbe_dev->current_sd_index = sd_index;
vpbe_dev->current_out_index = index;
}
-out:
+unlock:
mutex_unlock(_dev->lock);
return ret;
 }
-- 
2.10.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 15/34] [media] DaVinci-VPFE-Capture: Improve another size determination in vpfe_probe()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 10:24:57 +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.

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

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index 23142f0..4db3212 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -1850,7 +1850,7 @@ static int vpfe_probe(struct platform_device *pdev)
}
 
/* Allocate memory for ccdc configuration */
-   ccdc_cfg = kmalloc(sizeof(struct ccdc_config), GFP_KERNEL);
+   ccdc_cfg = kmalloc(sizeof(*ccdc_cfg), GFP_KERNEL);
if (!ccdc_cfg)
goto probe_free_dev_mem;
 
-- 
2.10.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 16/34] [media] DaVinci-VPFE-Capture: Delete an unnecessary variable initialisation in vpfe_probe()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 10:30:28 +0200

* Return an error code as a constant after a failed call of
  the function "vpfe_initialize".

* The local variable "ret" will be set then to an appropriate value
  a bit later. Thus omit the explicit initialisation at the beginning.

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

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index 4db3212..8314c39 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -1819,7 +1819,7 @@ static int vpfe_probe(struct platform_device *pdev)
struct vpfe_device *vpfe_dev;
struct i2c_adapter *i2c_adap;
struct video_device *vfd;
-   int ret = -ENOMEM, i, j;
+   int ret, i, j;
int num_subdevs = 0;
 
/* Get the pointer to the device object */
@@ -1828,7 +1828,7 @@ static int vpfe_probe(struct platform_device *pdev)
if (!vpfe_dev) {
v4l2_err(pdev->dev.driver,
"Failed to allocate memory for vpfe_dev\n");
-   return ret;
+   return -ENOMEM;
}
 
vpfe_dev->pdev = >dev;
-- 
2.10.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 09/34] [media] DaVinci-VPBE: Reduce the scope for a variable in vpbe_set_default_output()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 09:54:26 +0200

* Move the definition for the variable "ret" into an if branch
  so that an extra initialisation can be avoided at the beginning
  by this refactoring.

* Return a success code as a constant at the end.

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

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index d6a0221..19611a2 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -297,19 +297,19 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, 
int index)
 static int vpbe_set_default_output(struct vpbe_device *vpbe_dev)
 {
struct vpbe_config *cfg = vpbe_dev->cfg;
-   int ret = 0;
int i;
 
for (i = 0; i < cfg->num_outputs; i++) {
if (!strcmp(def_output,
cfg->outputs[i].output.name)) {
-   ret = vpbe_set_output(vpbe_dev, i);
+   int ret = vpbe_set_output(vpbe_dev, i);
+
if (!ret)
vpbe_dev->current_out_index = i;
return ret;
}
}
-   return ret;
+   return 0;
 }
 
 /**
-- 
2.10.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 10/34] [media] DaVinci-VPBE: Check return value of a setup_if_config() call in vpbe_set_output()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 09:56:56 +0200

* A function was called over the pointer "setup_if_config" in the data
  structure "venc_platform_data". But the return value was not used so far.
  Thus assign it to the local variable "ret" which will be checked with
  the next statement.

  Fixes: 9a7f95ad1c946efdd7a7a72df27db738260a0fd8 ("[media] davinci vpbe: add 
dm365 VPBE display driver changes")

* Pass a value to this function call without storing it in an intermediate
  variable before.

* Delete the local variable "if_params" which became unnecessary with
  this refactoring.

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

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index 19611a2..6e7b0df 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -227,7 +227,6 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, 
int index)
vpbe_current_encoder_info(vpbe_dev);
struct vpbe_config *cfg = vpbe_dev->cfg;
struct venc_platform_data *venc_device = vpbe_dev->venc_device;
-   u32 if_params;
int enc_out_index;
int sd_index;
int ret = 0;
@@ -257,8 +256,8 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, 
int index)
goto out;
}
 
-   if_params = cfg->outputs[index].if_params;
-   venc_device->setup_if_config(if_params);
+   ret = venc_device->setup_if_config(cfg
+  ->outputs[index].if_params);
if (ret)
goto out;
}
-- 
2.10.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 v4l-utils v7 1/7] mediactl: Add support for v4l2-ctrl-binding config

2016-10-12 Thread Jacek Anaszewski
Make struct v4l2_subdev capable of aggregating v4l2-ctrl-bindings -
media device configuration entries. Added are also functions for
validating support for the control on given media entity and checking
whether a v4l2-ctrl-binding has been defined for a media entity.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
---
 utils/media-ctl/libv4l2subdev.c | 32 
 utils/media-ctl/v4l2subdev.h| 19 +++
 2 files changed, 51 insertions(+)

diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index c3439d7..4f8ee7f 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -50,7 +50,15 @@ int v4l2_subdev_create(struct media_entity *entity)
 
entity->sd->fd = -1;
 
+   entity->sd->v4l2_ctrl_bindings = malloc(sizeof(__u32));
+   if (entity->sd->v4l2_ctrl_bindings == NULL)
+   goto err_v4l2_ctrl_bindings_alloc;
+
return 0;
+
+err_v4l2_ctrl_bindings_alloc:
+   free(entity->sd);
+   return -ENOMEM;
 }
 
 int v4l2_subdev_create_opened(struct media_entity *entity, int fd)
@@ -102,6 +110,7 @@ void v4l2_subdev_close(struct media_entity *entity)
if (entity->sd->fd_owner)
close(entity->sd->fd);
 
+   free(entity->sd->v4l2_ctrl_bindings);
free(entity->sd);
 }
 
@@ -884,3 +893,26 @@ const enum v4l2_mbus_pixelcode 
*v4l2_subdev_pixelcode_list(unsigned int *length)
 
return mbus_codes;
 }
+
+int v4l2_subdev_supports_v4l2_ctrl(struct media_device *media,
+  struct media_entity *entity,
+  __u32 ctrl_id)
+{
+   struct v4l2_queryctrl queryctrl = {};
+   int ret;
+
+   ret = v4l2_subdev_open(entity);
+   if (ret < 0)
+   return ret;
+
+   queryctrl.id = ctrl_id;
+
+   ret = ioctl(entity->sd->fd, VIDIOC_QUERYCTRL, );
+   if (ret < 0)
+   return ret;
+
+   media_dbg(media, "Validated control \"%s\" (0x%8.8x) on entity %s\n",
+ queryctrl.name, queryctrl.id, entity->info.name);
+
+   return 0;
+}
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index 011fab1..4dee6b1 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -26,10 +26,14 @@
 
 struct media_device;
 struct media_entity;
+struct media_device;
 
 struct v4l2_subdev {
int fd;
unsigned int fd_owner:1;
+
+   __u32 *v4l2_ctrl_bindings;
+   unsigned int num_v4l2_ctrl_bindings;
 };
 
 /**
@@ -314,4 +318,19 @@ enum v4l2_field v4l2_subdev_string_to_field(const char 
*string);
 const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list(
unsigned int *length);
 
+/**
+ * @brief Check if sub-device supports given v4l2 control
+ * @param media - media device.
+ * @param entity - media entity.
+ * @param ctrl_id - id of the v4l2 control to check.
+ *
+ * Verify if the sub-device associated with given media entity
+ * supports v4l2-control with given ctrl_id.
+ *
+ * @return 1 if the control is supported, 0 otherwise.
+ */
+int v4l2_subdev_supports_v4l2_ctrl(struct media_device *device,
+  struct media_entity *entity,
+  __u32 ctrl_id);
+
 #endif
-- 
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 v4l-utils v7 0/7] Add a plugin for Exynos4 camera

2016-10-12 Thread Jacek Anaszewski
This is a seventh version of the patch series adding a plugin for the 
Exynos4 camera. Last version [0] of the patch set was posted in
January.

The plugin doesn't link against libmediactl, but has its sources
compiled in. Currently utils are built after the plugins, but
libv4l-exynos4-camera plugin depends on the utils. In order to link
the plugin against libmediactl the build system would have to be
modified.


Changes from v6:


- close v4l2 sub-devices on media device release
- moved non-generic code from libmediactl to the plugin
- resigned from adding libmedia_ioctl library and moved all its
  code to the plugin, since it depended on pipeline representation,
  which was not generic for all possible media device topologies
- used media_get_info()->name instead of adding media_entity_get_name
- renamed media_get_backlinks_by_entity() to media_entity_get_backlinks(()
- moved pipeline from struct media_device to the plugin
- changed the way of associating video device file descriptor with media device
- switched to using auto-generated media-bus-format-names.h header file
- renamed v4l2-ctrl-redir config entry name to v4l2-ctrl-binding


Changes from v5:


- fixed and tested use cases with S5K6A3 sensor and FIMC-IS-ISP
- added conversion "colorspace id to string"


Changes from v4:


- removed some redundant functions for traversing media device graph
  and switched over to using existing ones
- avoided accessing struct v4l2_subdev from libmediactl
- applied various improvements


Changes from v3:


- added struct v4l2_subdev and put entity fd and 
  information about supported controls to it
- improved functions for negotiating and setting
  pipeline format by using available libv4lsubdev API
- applied minor improvements and cleanups


Changes from v2:


- switched to using mediatext library for parsing
  the media device configuration
- extended libmediactl
- switched to using libmediactl


Changes from v1:


- removed redundant mbus code negotiation
- split the parser, media device helpers and ioctl wrappers
  to the separate modules
- added mechanism for querying extended controls
- applied various fixes and modifications



The plugin was tested on v4.8-rc2 (exynos4-is driver doesn't proble properly
with current master branch of linux-media.git) with patches fixing several
issues for Exynos4 camera: [1], [2], [3].

The plugin expects a configuration file:
/var/lib/libv4l/exynos4_capture_conf

Exemplary configuration file for pipeline with sensor
S5C73M3 (rear camera):

==

link-conf "s5p-mipi-csis.0":1 -> "FIMC.0":0 [1]
v4l2-ctrl-binding 0x0098091f -> "fimc.0.capture"
v4l2-ctrl-binding 0x00980902 -> "S5C73M3"
v4l2-ctrl-binding 0x00980922 -> "fimc.0.capture"
v4l2-ctrl-binding 0x009a0914 -> "S5C73M3"

==

With this settings the plugin can be tested on the exynos4412-trats2 board
using following gstreamer pipeline:

gst-launch-1.0 v4l2src device=/dev/video1 
extra-controls="c,rotate=90,color_effects=2" ! video/x-raw,width=960,height=720 
! fbdevsink

Exemplary configuration file for pipeline with sensor
S5K6A3 (front camera):

==

link-conf "s5p-mipi-csis.1":1 -> "FIMC-LITE.1":0 [1]
link-conf "FIMC-LITE.1":2 -> "FIMC-IS-ISP":0 [1]
link-conf "FIMC-IS-ISP":1 -> "FIMC.0":1 [1]

==

gst-launch-1.0 v4l2src device=/dev/video1 
extra-controls="c,rotate=270,color_effects=2,horizontal_flip=1" ! 
video/x-raw,width=960,height=920 ! fbdevsink

Best Regards,
Jacek Anaszewski

[0] http://www.spinics.net/lists/linux-media/msg96510.html
[1] https://patchwork.kernel.org/patch/9335197/
[2] https://patchwork.kernel.org/patch/9270985/
[3] https://patchwork.kernel.org/patch/9308923/
[4] https://patchwork.kernel.org/patch/9335273/


Jacek Anaszewski (7):
  mediactl: Add support for v4l2-ctrl-binding config
  mediatext: Add library
  mediactl: Add media_entity_get_backlinks()
  mediactl: Add media_device creation helpers
  mediactl: libv4l2subdev: Add colorspace logging
  mediactl: libv4l2subdev: add support for comparing mbus formats
  Add a libv4l plugin for Exynos4 camera

 configure.ac  |1 +
 lib/Makefile.am   |5 +
 lib/libv4l-exynos4-camera/Makefile.am |   19 +
 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c | 1325 +
 utils/media-ctl/Makefile.am   |   10 +-
 utils/media-ctl/libmediactl.c |  152 ++-
 utils/media-ctl/libmediatext.pc.in|   10 +
 utils/media-ctl/libv4l2subdev.c   |  106 ++
 utils/media-ctl/mediactl.h|   42 +
 utils/media-ctl/mediatext-test.c  

[PATCH v4l-utils v7 3/7] mediactl: Add media_entity_get_backlinks()

2016-10-12 Thread Jacek Anaszewski
Add a new graph helper useful for discovering video pipeline.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
---
 utils/media-ctl/libmediactl.c | 21 +
 utils/media-ctl/mediactl.h| 15 +++
 2 files changed, 36 insertions(+)

diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index 91ed003..155b65f 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -36,6 +36,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include "mediactl.h"
@@ -172,6 +173,26 @@ const struct media_entity_desc 
*media_entity_get_info(struct media_entity *entit
return >info;
 }
 
+int media_entity_get_backlinks(struct media_entity *entity,
+   struct media_link **backlinks,
+   unsigned int *num_backlinks)
+{
+   unsigned int num_bklinks = 0;
+   int i;
+
+   if (entity == NULL || backlinks == NULL || num_backlinks == NULL)
+   return -EINVAL;
+
+   for (i = 0; i < entity->num_links; ++i)
+   if ((entity->links[i].flags & MEDIA_LNK_FL_ENABLED) &&
+   (entity->links[i].sink->entity == entity))
+   backlinks[num_bklinks++] = >links[i];
+
+   *num_backlinks = num_bklinks;
+
+   return 0;
+}
+
 /* 
-
  * Open/close
  */
diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h
index 336cbf9..b1f33cd 100644
--- a/utils/media-ctl/mediactl.h
+++ b/utils/media-ctl/mediactl.h
@@ -434,6 +434,20 @@ int media_parse_setup_link(struct media_device *media,
 int media_parse_setup_links(struct media_device *media, const char *p);
 
 /**
+ * @brief Get entity's enabled backlinks
+ * @param entity - media entity.
+ * @param backlinks - array of pointers to matching backlinks.
+ * @param num_backlinks - number of matching backlinks.
+ *
+ * Get links that are connected to the entity sink pads.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int media_entity_get_backlinks(struct media_entity *entity,
+   struct media_link **backlinks,
+   unsigned int *num_backlinks);
+
+/**
  * @brief Get v4l2_subdev for the entity
  * @param entity - media entity
  *
@@ -443,4 +457,5 @@ int media_parse_setup_links(struct media_device *media, 
const char *p);
  */
 struct v4l2_subdev *media_entity_get_v4l2_subdev(struct media_entity *entity);
 
+
 #endif
-- 
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 v4l-utils v7 4/7] mediactl: Add media_device creation helpers

2016-10-12 Thread Jacek Anaszewski
Add helper functions that allow for easy instantiation of media_device
object basing on whether the media device contains v4l2 subdev with
given file descriptor.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
---
 utils/media-ctl/libmediactl.c | 131 +-
 utils/media-ctl/mediactl.h|  27 +
 2 files changed, 156 insertions(+), 2 deletions(-)

diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index 155b65f..d347a40 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -27,6 +27,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -440,8 +441,9 @@ static int media_get_devname_udev(struct udev *udev,
return -EINVAL;
 
devnum = makedev(entity->info.v4l.major, entity->info.v4l.minor);
-   media_dbg(entity->media, "looking up device: %u:%u\n",
- major(devnum), minor(devnum));
+   if (entity->media)
+   media_dbg(entity->media, "looking up device: %u:%u\n",
+ major(devnum), minor(devnum));
device = udev_device_new_from_devnum(udev, 'c', devnum);
if (device) {
p = udev_device_get_devnode(device);
@@ -523,6 +525,7 @@ static int media_get_devname_sysfs(struct media_entity 
*entity)
return 0;
 }
 
+
 static int media_enum_entities(struct media_device *media)
 {
struct media_entity *entity;
@@ -707,6 +710,92 @@ struct media_device *media_device_new(const char *devnode)
return media;
 }
 
+struct media_device *media_device_new_by_subdev_fd(int fd, struct media_entity 
**fd_entity)
+{
+   char video_devname[32], device_dir_path[256], media_dev_path[256], 
media_major_minor[10];
+   struct media_device *media = NULL;
+   struct dirent *entry;
+   struct media_entity tmp_entity;
+   DIR *device_dir;
+   struct udev *udev;
+   char *p;
+   int ret, i;
+
+   if (fd_entity == NULL)
+   return NULL;
+
+   ret = media_get_devname_by_fd(fd, video_devname);
+   if (ret < 0)
+   return NULL;
+
+   p = strrchr(video_devname, '/');
+   if (p == NULL)
+   return NULL;
+
+   ret = media_udev_open();
+   if (ret < 0)
+   return NULL;
+
+   sprintf(device_dir_path, "/sys/class/video4linux/%s/device/", p + 1);
+
+   device_dir = opendir(device_dir_path);
+   if (device_dir == NULL)
+   return NULL;
+
+   while ((entry = readdir(device_dir))) {
+   if (strncmp(entry->d_name, "media", 4))
+   continue;
+
+   sprintf(media_dev_path, "%s%s/dev", device_dir_path, 
entry->d_name);
+
+   fd = open(media_dev_path, O_RDONLY);
+   if (fd < 0)
+   continue;
+
+   ret = read(fd, media_major_minor, sizeof(media_major_minor));
+   if (ret < 0)
+   continue;
+
+   sscanf(media_major_minor, "%d:%d", _entity.info.dev.major, 
_entity.info.dev.minor);
+
+   /* Try to get the device name via udev */
+   if (media_get_devname_udev(udev, _entity)) {
+   /* Fall back to get the device name via sysfs */
+   if (media_get_devname_sysfs(_entity))
+   continue;
+   }
+
+   media = media_device_new(tmp_entity.devname);
+   if (media == NULL)
+   continue;
+
+   ret = media_device_enumerate(media);
+   if (ret < 0) {
+   media_dbg(media, "Failed to enumerate %s (%d)\n",
+ tmp_entity.devname, ret);
+   media_device_unref(media);
+   media = NULL;
+   continue;
+   }
+
+   /* Get the entity associated with given fd */
+   for (i = 0; i < media->entities_count; i++) {
+   struct media_entity *entity = >entities[i];
+
+   if (!strcmp(entity->devname, video_devname)) {
+   *fd_entity = >entities[i];
+   break;
+   }
+   }
+
+   break;
+   }
+
+   media_udev_close(udev);
+
+   return media;
+}
+
 struct media_device *media_device_new_emulated(struct media_device_info *info)
 {
struct media_device *media;
@@ -748,6 +837,44 @@ void media_device_unref(struct media_device *media)
free(media);
 }
 
+int media_get_devname_by_fd(int fd, char *node_name)
+{
+   struct udev *udev;
+   struct media_entity tmp_entity;
+   struct stat stat;
+   int ret, ret_udev;
+
+   if (node_name == NULL)
+   return -EINVAL;
+
+   ret = fstat(fd, );
+   if (ret < 0)
+  

[PATCH 06/34] [media] DaVinci-VPBE: Return an error code only by a single variable in vpbe_initialize()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 11 Oct 2016 14:15:57 +0200

An error code was assigned to the local variable "err" in an if branch.
But this variable was not used further then.

Use the local variable "ret" instead like at other places in this function.

Fixes: 66715cdc3224a4e241c1a92856b9a4af3b70e06d ("[media] davinci vpbe:
VPBE display driver")
Signed-off-by: Markus Elfring 
---
 drivers/media/platform/davinci/vpbe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index 4c4cd81..afa8ff7 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -665,7 +665,7 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
if (err) {
v4l2_err(_dev->v4l2_dev,
 "unable to initialize the OSD device");
-   err = -ENOMEM;
+   ret = -ENOMEM;
goto fail_dev_unregister;
}
}
-- 
2.10.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 v4l-utils v7 5/7] mediactl: libv4l2subdev: Add colorspace logging

2016-10-12 Thread Jacek Anaszewski
Add a function for obtaining colorspace name by id.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
---
 utils/media-ctl/libv4l2subdev.c | 32 
 utils/media-ctl/v4l2subdev.h| 10 ++
 2 files changed, 42 insertions(+)

diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 4f8ee7f..31393bb 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -33,6 +33,7 @@
 #include 
 
 #include 
+#include 
 
 #include "mediactl.h"
 #include "mediactl-priv.h"
@@ -831,6 +832,37 @@ const char *v4l2_subdev_pixelcode_to_string(enum 
v4l2_mbus_pixelcode code)
return "unknown";
 }
 
+static struct {
+   const char *name;
+   enum v4l2_colorspace cs;
+} colorspaces[] = {
+{ "DEFAULT", V4L2_COLORSPACE_DEFAULT },
+{ "SMPTE170M", V4L2_COLORSPACE_SMPTE170M },
+{ "SMPTE240M", V4L2_COLORSPACE_SMPTE240M },
+{ "REC709", V4L2_COLORSPACE_REC709 },
+{ "BT878", V4L2_COLORSPACE_BT878 },
+{ "470_SYSTEM_M", V4L2_COLORSPACE_470_SYSTEM_M },
+{ "470_SYSTEM_BG", V4L2_COLORSPACE_470_SYSTEM_BG },
+{ "JPEG", V4L2_COLORSPACE_JPEG },
+{ "SRGB", V4L2_COLORSPACE_SRGB },
+{ "ADOBERGB", V4L2_COLORSPACE_ADOBERGB },
+{ "BT2020", V4L2_COLORSPACE_BT2020 },
+{ "RAW", V4L2_COLORSPACE_RAW },
+{ "DCI_P3", V4L2_COLORSPACE_DCI_P3 },
+};
+
+const char *v4l2_subdev_colorspace_to_string(enum v4l2_colorspace cs)
+{
+   unsigned int i;
+
+   for (i = 0; i < ARRAY_SIZE(colorspaces); ++i) {
+   if (colorspaces[i].cs == cs)
+   return colorspaces[i].name;
+   }
+
+   return "unknown";
+}
+
 enum v4l2_mbus_pixelcode v4l2_subdev_string_to_pixelcode(const char *string)
 {
unsigned int i;
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index 4dee6b1..cf1250d 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -278,6 +278,16 @@ int v4l2_subdev_parse_setup_formats(struct media_device 
*media, const char *p);
 const char *v4l2_subdev_pixelcode_to_string(enum v4l2_mbus_pixelcode code);
 
 /**
+ * @brief Convert colorspace to string.
+ * @param code - input string
+ *
+ * Convert colorspace @a to a human-readable string.
+ *
+ * @return A pointer to a string on success, NULL on failure.
+ */
+const char *v4l2_subdev_colorspace_to_string(enum v4l2_colorspace cs);
+
+/**
  * @brief Parse string to media bus pixel code.
  * @param string - nul terminalted string, textual media bus pixel code
  *
-- 
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 v4l-utils v7 7/7] Add a libv4l plugin for Exynos4 camera

2016-10-12 Thread Jacek Anaszewski
The plugin provides support for the media device on Exynos4 SoC.
It performs single plane <-> multi plane API conversion,
video pipeline linking and takes care of automatic data format
negotiation for the whole pipeline, after intercepting
VIDIOC_S_FMT or VIDIOC_TRY_FMT ioctls.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
---
 configure.ac  |1 +
 lib/Makefile.am   |5 +
 lib/libv4l-exynos4-camera/Makefile.am |   19 +
 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c | 1325 +
 4 files changed, 1350 insertions(+)
 create mode 100644 lib/libv4l-exynos4-camera/Makefile.am
 create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c

diff --git a/configure.ac b/configure.ac
index 8447f05..692718a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,7 @@ AC_CONFIG_FILES([Makefile
lib/libdvbv5/Makefile
lib/libv4l2rds/Makefile
lib/libv4l-mplane/Makefile
+   lib/libv4l-exynos4-camera/Makefile
 
utils/Makefile
utils/libv4l2util/Makefile
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a105c95..b5e52db 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -5,6 +5,11 @@ SUBDIRS = \
libv4l2rds \
libv4l-mplane
 
+if WITH_V4LUTILS
+SUBDIRS += \
+   libv4l-exynos4-camera
+endif
+
 if WITH_LIBDVBV5
 SUBDIRS += \
libdvbv5
diff --git a/lib/libv4l-exynos4-camera/Makefile.am 
b/lib/libv4l-exynos4-camera/Makefile.am
new file mode 100644
index 000..c38b7f6
--- /dev/null
+++ b/lib/libv4l-exynos4-camera/Makefile.am
@@ -0,0 +1,19 @@
+if WITH_V4L_PLUGINS
+libv4l2plugin_LTLIBRARIES = libv4l-exynos4-camera.la
+endif
+
+media-bus-format-names.h: ../../include/linux/media-bus-format.h
+   sed -e '/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; 
s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \
+   < $< > $@
+
+media-bus-format-codes.h: ../../include/linux/media-bus-format.h
+   sed -e '/#define MEDIA_BUS_FMT/ ! d; s/.*#define //; /FIXED/ d; 
s/\t.*//; s/.*/ &,/;' \
+   < $< > $@
+
+BUILT_SOURCES = media-bus-format-names.h media-bus-format-codes.h
+CLEANFILES = $(BUILT_SOURCES)
+
+nodist_libv4l_exynos4_camera_la_SOURCES = $(BUILT_SOURCES)
+libv4l_exynos4_camera_la_SOURCES = libv4l-exynos4-camera.c 
../../utils/media-ctl/libmediactl.c ../../utils/media-ctl/libv4l2subdev.c 
../../utils/media-ctl/mediatext.c
+libv4l_exynos4_camera_la_CFLAGS = -fvisibility=hidden -std=gnu99
+libv4l_exynos4_camera_la_LDFLAGS = -avoid-version -module -shared 
-export-dynamic -lpthread
diff --git a/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c 
b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
new file mode 100644
index 000..c219fe5
--- /dev/null
+++ b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
@@ -0,0 +1,1325 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../../utils/media-ctl/mediactl.h"
+#include "../../utils/media-ctl/mediatext.h"
+#include "../../utils/media-ctl/v4l2subdev.h"
+#include "libv4l-plugin.h"
+
+#ifdef DEBUG
+#define V4L2_EXYNOS4_DBG(format, ARG...)\
+   printf("[%s:%d] [%s] " format " \n", __FILE__, __LINE__, __func__, 
##ARG)
+#else
+#define V4L2_EXYNOS4_DBG(format, ARG...)
+#endif
+
+#define V4L2_EXYNOS4_ERR(format, ARG...)\
+   fprintf(stderr, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG)
+
+#define V4L2_EXYNOS4_LOG(format, ARG...)\
+   fprintf(stdout, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG)
+
+#define VIDIOC_CTRL(type)  \
+   ((type) == VIDIOC_S_CTRL ? "VIDIOC_S_CTRL" :\
+  "VIDIOC_G_CTRL")
+
+#if HAVE_VISIBILITY
+#define PLUGIN_PUBLIC __attribute__ ((visibility("default")))
+#else
+#define PLUGIN_PUBLIC
+#endif
+
+#define SYS_IOCTL(fd, cmd, arg) \
+   syscall(SYS_ioctl, (int)(fd), (unsigned long)(cmd), (void *)(arg))
+
+#define SIMPLE_CONVERT_IOCTL(fd, cmd, arg, __struc) ({  \
+   int __ret;  \
+   struct __struc *req = arg;  \
+   uint32_t type = req->type;  \
+   req->type = 

[PATCH v4l-utils v7 2/7] mediatext: Add library

2016-10-12 Thread Jacek Anaszewski
libmediatext is a helper library for converting configurations (Media
controller links, V4L2 controls and V4L2 sub-device media bus formats and
selections) from text-based form into IOCTLs.

libmediatext depends on libv4l2subdev and libmediactl.

Signed-off-by: Sakari Ailus 
Signed-off-by: Teemu Tuominen 
Signed-off-by: Jacek Anaszewski 
---
 utils/media-ctl/Makefile.am|  10 +-
 utils/media-ctl/libmediatext.pc.in |  10 ++
 utils/media-ctl/mediatext-test.c   |  64 
 utils/media-ctl/mediatext.c| 312 +
 utils/media-ctl/mediatext.h|  52 +++
 5 files changed, 446 insertions(+), 2 deletions(-)
 create mode 100644 utils/media-ctl/libmediatext.pc.in
 create mode 100644 utils/media-ctl/mediatext-test.c
 create mode 100644 utils/media-ctl/mediatext.c
 create mode 100644 utils/media-ctl/mediatext.h

diff --git a/utils/media-ctl/Makefile.am b/utils/media-ctl/Makefile.am
index ee7dcc9..2f12357 100644
--- a/utils/media-ctl/Makefile.am
+++ b/utils/media-ctl/Makefile.am
@@ -1,4 +1,4 @@
-noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la
+noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la libmediatext.la
 
 libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h
 libmediactl_la_CFLAGS = -static $(LIBUDEV_CFLAGS)
@@ -21,9 +21,15 @@ libv4l2subdev_la_LIBADD = libmediactl.la
 libv4l2subdev_la_CFLAGS = -static
 libv4l2subdev_la_LDFLAGS = -static
 
+libmediatext_la_SOURCES = mediatext.c
+libmediatext_la_CFLAGS = -static $(LIBUDEV_CFLAGS)
+libmediatext_la_LDFLAGS = -static $(LIBUDEV_LIBS)
+
 mediactl_includedir=$(includedir)/mediactl
 noinst_HEADERS = mediactl.h v4l2subdev.h
 
-bin_PROGRAMS = media-ctl
+bin_PROGRAMS = media-ctl mediatext-test
 media_ctl_SOURCES = media-ctl.c options.c options.h tools.h
 media_ctl_LDADD = libmediactl.la libv4l2subdev.la
+mediatext_test_SOURCES = mediatext-test.c
+mediatext_test_LDADD = libmediatext.la libmediactl.la libv4l2subdev.la
diff --git a/utils/media-ctl/libmediatext.pc.in 
b/utils/media-ctl/libmediatext.pc.in
new file mode 100644
index 000..6aa6353
--- /dev/null
+++ b/utils/media-ctl/libmediatext.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libmediatext
+Description: Media controller and V4L2 text-based configuration library
+Version: @PACKAGE_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lmediatext
diff --git a/utils/media-ctl/mediatext-test.c b/utils/media-ctl/mediatext-test.c
new file mode 100644
index 000..b8b9282
--- /dev/null
+++ b/utils/media-ctl/mediatext-test.c
@@ -0,0 +1,64 @@
+/*
+ * libmediatext test program
+ *
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Contact: Sakari Ailus 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+#include 
+#include 
+#include 
+
+#include "mediactl.h"
+#include "mediatext.h"
+
+int main(int argc, char *argv[])
+{
+   struct media_device *device;
+   int rval;
+
+   if (argc != 3) {
+   fprintf(stderr, "usage: %s  \n\n", 
argv[0]);
+   fprintf(stderr, "\tstring := [ v4l2-ctrl |�v4l2-mbus | 
link-reset | link-conf]\n\n");
+   fprintf(stderr, "\tv4l2-ctrl := \"entity\" ctrl_type ctrl_id 
ctrl_value\n");
+   fprintf(stderr, "\tctrl_type := [ int | int64 | bitmask ]\n");
+   fprintf(stderr, "\tctrl_value := [ %%d | %%PRId64 | 
bitmask_value ]\n");
+   fprintf(stderr, "\tbitmask_value := b\n\n");
+   fprintf(stderr, "\tv4l2-mbus := \n");
+   fprintf(stderr, "\tlink-conf := \"entity\":pad -> 
\"entity\":pad[link-flags]\n");
+   fprintf(stderr, "\tv4l2-ctrl-binding := ctrl_id -> 
\"entity\"\n");
+   return EXIT_FAILURE;
+   }
+
+   device = media_device_new(argv[1]);
+   if (!device)
+   return EXIT_FAILURE;
+
+   rval = media_device_enumerate(device);
+   if (rval)
+   return EXIT_FAILURE;
+
+   rval = mediatext_parse(device, argv[2]);
+   if (rval) {
+   fprintf(stderr, "bad string %s (%s)\n", argv[2], 
strerror(-rval));
+   return EXIT_FAILURE;
+   }
+
+   media_device_unref(device);
+
+   return EXIT_SUCCESS;
+}
diff --git 

[PATCH v4l-utils v7 6/7] mediactl: libv4l2subdev: add support for comparing mbus formats

2016-10-12 Thread Jacek Anaszewski
This patch adds a function for checking whether two mbus formats
are compatible.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
---
 utils/media-ctl/libv4l2subdev.c | 42 +
 utils/media-ctl/v4l2subdev.h| 21 +
 2 files changed, 63 insertions(+)

diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 31393bb..2ec9b5e 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -948,3 +948,45 @@ int v4l2_subdev_supports_v4l2_ctrl(struct media_device 
*media,
 
return 0;
 }
+
+enum v4l2_subdev_fmt_mismatch v4l2_subdev_format_compare(
+   struct v4l2_mbus_framefmt *fmt1,
+   struct v4l2_mbus_framefmt *fmt2)
+{
+   if (fmt1 == NULL || fmt2 == NULL)
+   return 0;
+
+   if (fmt1->width != fmt2->width) {
+   printf("width mismatch (fmt1: %d, fmt2: %d)\n",
+  fmt1->width, fmt2->width);
+   return FMT_MISMATCH_WIDTH;
+   }
+
+   if (fmt1->height != fmt2->height) {
+   printf("height mismatch (fmt1: %d, fmt2: %d)\n",
+  fmt1->height, fmt2->height);
+   return FMT_MISMATCH_HEIGHT;
+   }
+
+   if (fmt1->code != fmt2->code) {
+   printf("mbus code mismatch (fmt1: %s, fmt2: %s)\n",
+   v4l2_subdev_pixelcode_to_string(fmt1->code),
+   v4l2_subdev_pixelcode_to_string(fmt2->code));
+   return FMT_MISMATCH_CODE;
+   }
+
+   if (fmt1->field != fmt2->field) {
+   printf("field mismatch (fmt1: %d, fmt2: %d)\n",
+  fmt1->field, fmt2->field);
+   return FMT_MISMATCH_FIELD;
+   }
+
+   if (fmt1->colorspace != fmt2->colorspace) {
+   printf("colorspace mismatch (fmt1: %s, fmt2: %s)\n",
+   v4l2_subdev_colorspace_to_string(fmt1->colorspace),
+   v4l2_subdev_colorspace_to_string(fmt2->colorspace));
+   return FMT_MISMATCH_COLORSPACE;
+   }
+
+   return FMT_MISMATCH_NONE;
+}
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index cf1250d..c438f71 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -28,6 +28,15 @@ struct media_device;
 struct media_entity;
 struct media_device;
 
+enum v4l2_subdev_fmt_mismatch {
+   FMT_MISMATCH_NONE = 0,
+   FMT_MISMATCH_WIDTH,
+   FMT_MISMATCH_HEIGHT,
+   FMT_MISMATCH_CODE,
+   FMT_MISMATCH_FIELD,
+   FMT_MISMATCH_COLORSPACE,
+};
+
 struct v4l2_subdev {
int fd;
unsigned int fd_owner:1;
@@ -342,5 +351,17 @@ const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list(
 int v4l2_subdev_supports_v4l2_ctrl(struct media_device *device,
   struct media_entity *entity,
   __u32 ctrl_id);
+/**
+ * @brief Compare mbus formats
+ * @param fmt1 - 1st mbus format to compare.
+ * @param fmt2 - 2nd mbus format to compare.
+ *
+ * Check whether two mbus formats are compatible.
+ *
+ * @return 1 if formats are compatible, 0 otherwise.
+ */
+enum v4l2_subdev_fmt_mismatch v4l2_subdev_format_compare(
+   struct v4l2_mbus_framefmt *fmt1,
+   struct v4l2_mbus_framefmt *fmt2);
 
 #endif
-- 
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 08/34] [media] DaVinci-VPBE: Return the success indication only as a constant in vpbe_set_mode()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 09:51:29 +0200

* Return a success code without storing it in an intermediate variable.

* Delete the local variable "ret" which became unnecessary with
  this refactoring.

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

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index 9fdd8c0..d6a0221 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -509,7 +509,6 @@ static int vpbe_set_mode(struct vpbe_device *vpbe_dev,
struct v4l2_dv_timings dv_timings;
struct osd_state *osd_device;
int out_index = vpbe_dev->current_out_index;
-   int ret = 0;
int i;
 
if (!mode_info || !mode_info->name)
@@ -549,8 +548,7 @@ static int vpbe_set_mode(struct vpbe_device *vpbe_dev,
vpbe_dev->current_timings.upper_margin);
 
mutex_unlock(_dev->lock);
-
-   return ret;
+   return 0;
 }
 
 static int vpbe_set_default_mode(struct vpbe_device *vpbe_dev)
-- 
2.10.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 07/34] [media] DaVinci-VPBE: Delete an unnecessary variable initialisation in vpbe_initialize()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 09:45:39 +0200

The local variable "ret" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

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

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index afa8ff7..9fdd8c0 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -597,7 +597,7 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
struct osd_state *osd_device;
struct i2c_adapter *i2c_adap;
int num_encoders;
-   int ret = 0;
+   int ret;
int err;
int i;
 
-- 
2.10.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 05/34] [media] DaVinci-VPBE: Return an error code only as a constant in vpbe_probe()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 11 Oct 2016 13:43:25 +0200

* Return an error code without storing it in an intermediate variable.

* Delete the local variable "ret" which became unnecessary with
  this refactoring.

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

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index 625bddf..4c4cd81 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -821,7 +821,6 @@ static int vpbe_probe(struct platform_device *pdev)
 {
struct vpbe_device *vpbe_dev;
struct vpbe_config *cfg;
-   int ret = -EINVAL;
 
if (!pdev->dev.platform_data) {
v4l2_err(pdev->dev.driver, "No platform data\n");
@@ -834,7 +833,7 @@ static int vpbe_probe(struct platform_device *pdev)
!cfg->venc.module_name[0]) {
v4l2_err(pdev->dev.driver,
 "vpbe display module names not defined\n");
-   return ret;
+   return -EINVAL;
}
 
vpbe_dev = kzalloc(sizeof(*vpbe_dev), GFP_KERNEL);
-- 
2.10.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 04/34] [media] DaVinci-VPBE: Combine substrings for four messages

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 11 Oct 2016 13:40:14 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

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

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index 496b27f..625bddf 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -702,15 +702,15 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
  "v4l2 sub device %s registered\n",
  enc_info->module_name);
else {
-   v4l2_err(_dev->v4l2_dev, "encoder %s"
-" failed to register",
+   v4l2_err(_dev->v4l2_dev,
+"encoder %s failed to register",
 enc_info->module_name);
ret = -ENODEV;
goto fail_kfree_encoders;
}
} else
-   v4l2_warn(_dev->v4l2_dev, "non-i2c encoders"
-" currently not supported");
+   v4l2_warn(_dev->v4l2_dev,
+"non-i2c encoders currently not supported");
}
/* Add amplifier subdevice for dm365 */
if ((strcmp(vpbe_dev->cfg->module_name, "dm365-vpbe-display") == 0) &&
@@ -731,9 +731,9 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
  "v4l2 sub device %s registered\n",
  amp_info->module_name);
} else {
-   vpbe_dev->amp = NULL;
-   v4l2_warn(_dev->v4l2_dev, "non-i2c amplifiers"
-   " currently not supported");
+   vpbe_dev->amp = NULL;
+   v4l2_warn(_dev->v4l2_dev,
+ "non-i2c amplifiers currently not supported");
}
} else {
vpbe_dev->amp = NULL;
@@ -832,8 +832,8 @@ static int vpbe_probe(struct platform_device *pdev)
if (!cfg->module_name[0] ||
!cfg->osd.module_name[0] ||
!cfg->venc.module_name[0]) {
-   v4l2_err(pdev->dev.driver, "vpbe display module names not"
-" defined\n");
+   v4l2_err(pdev->dev.driver,
+"vpbe display module names not defined\n");
return ret;
}
 
-- 
2.10.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 02/34] [media] DaVinci-VPBE: Delete two error messages for a failed memory allocation

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 11 Oct 2016 09:56:13 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: Possible unnecessary 'out of memory' message

Thus remove such a logging statement in two functions.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf

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

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index 8c062ff..b479747 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -680,8 +680,6 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
   sizeof(*vpbe_dev->encoders),
   GFP_KERNEL);
if (NULL == vpbe_dev->encoders) {
-   v4l2_err(_dev->v4l2_dev,
-   "unable to allocate memory for encoders sub devices");
ret = -ENOMEM;
goto fail_dev_unregister;
}
@@ -841,11 +839,9 @@ static int vpbe_probe(struct platform_device *pdev)
}
 
vpbe_dev = kzalloc(sizeof(*vpbe_dev), GFP_KERNEL);
-   if (vpbe_dev == NULL) {
-   v4l2_err(pdev->dev.driver, "Unable to allocate memory"
-" for vpbe_device\n");
+   if (!vpbe_dev)
return -ENOMEM;
-   }
+
vpbe_dev->cfg = cfg;
vpbe_dev->ops = vpbe_dev_ops;
vpbe_dev->pdev = >dev;
-- 
2.10.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 01/34] [media] DaVinci-VPBE: Use kmalloc_array() in vpbe_initialize()

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 11 Oct 2016 09:40:41 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  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.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index 9a6c2cc..8c062ff 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -676,9 +676,9 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
 * store venc sd index.
 */
num_encoders = vpbe_dev->cfg->num_ext_encoders + 1;
-   vpbe_dev->encoders = kmalloc(
-   sizeof(struct v4l2_subdev *)*num_encoders,
-   GFP_KERNEL);
+   vpbe_dev->encoders = kmalloc_array(num_encoders,
+  sizeof(*vpbe_dev->encoders),
+  GFP_KERNEL);
if (NULL == vpbe_dev->encoders) {
v4l2_err(_dev->v4l2_dev,
"unable to allocate memory for encoders sub devices");
-- 
2.10.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 00/34] [media] DaVinci-Video Processing: Fine-tuning for several function implementations

2016-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 12 Oct 2016 16:20:02 +0200

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

Markus Elfring (34):
  Use kmalloc_array() in vpbe_initialize()
  Delete two error messages for a failed memory allocation
  Adjust 16 checks for null pointers
  Combine substrings for four messages
  Return an error code only as a constant in vpbe_probe()
  Return an error code only by a single variable in vpbe_initialize()
  Delete an unnecessary variable initialisation in vpbe_initialize()
  Return the success indication only as a constant in vpbe_set_mode()
  Reduce the scope for a variable in vpbe_set_default_output()
  Check return value of a setup_if_config() call in vpbe_set_output()
  Rename a jump label in vpbe_set_output()
  Delete an unnecessary variable initialisation in vpbe_set_output()
  Capture: Use kmalloc_array() in vpfe_probe()
  Capture: Delete three error messages for a failed memory allocation
  Capture: Improve another size determination in vpfe_probe()
  Capture: Delete an unnecessary variable initialisation in vpfe_probe()
  Capture: Improve another size determination in vpfe_enum_input()
  Capture: Combine substrings for an error message in vpfe_enum_input()
  Capture: Improve another size determination in vpfe_open()
  Capture: Adjust 13 checks for null pointers
  Capture: Delete an unnecessary variable initialisation in 11 functions
  Capture: Move two assignments in vpfe_s_input()
  Capture: Delete unnecessary braces in vpfe_isr()
  Capture: Delete an unnecessary return statement in 
vpfe_unregister_ccdc_device()
  Capture: Use kcalloc() in vpif_probe()
  Capture: Delete an error message for a failed memory allocation
  Capture: Adjust ten checks for null pointers
  Capture: Delete an unnecessary variable initialisation in vpif_querystd()
  Capture: Delete an unnecessary variable initialisation in vpif_channel_isr()
  Display: Use kcalloc() in vpif_probe()
  Display: Delete an error message for a failed memory allocation
  Display: Adjust 11 checks for null pointers
  Display: Delete an unnecessary variable initialisation in vpif_channel_isr()
  Display: Delete an unnecessary variable initialisation in 
process_progressive_mode()

 drivers/media/platform/davinci/vpbe.c | 93 ---
 drivers/media/platform/davinci/vpfe_capture.c | 88 -
 drivers/media/platform/davinci/vpif_capture.c | 28 
 drivers/media/platform/davinci/vpif_display.c | 30 -
 4 files changed, 109 insertions(+), 130 deletions(-)

-- 
2.10.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


[RFC 5/5] doc_rst: media: New SDR formats SC16, SC18 & SC20

2016-10-12 Thread Ramesh Shanmugasundaram
This patch adds documentation for the three new SDR formats

V4L2_SDR_FMT_SCU16BE
V4L2_SDR_FMT_SCU18BE
V4L2_SDR_FMT_SCU20BE

Signed-off-by: Ramesh Shanmugasundaram 
---
 .../media/uapi/v4l/pixfmt-sdr-scu16be.rst  | 44 
 .../media/uapi/v4l/pixfmt-sdr-scu18be.rst  | 48 ++
 .../media/uapi/v4l/pixfmt-sdr-scu20be.rst  | 48 ++
 Documentation/media/uapi/v4l/sdr-formats.rst   |  3 ++
 4 files changed, 143 insertions(+)
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-sdr-scu16be.rst
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-sdr-scu18be.rst
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-sdr-scu20be.rst

diff --git a/Documentation/media/uapi/v4l/pixfmt-sdr-scu16be.rst 
b/Documentation/media/uapi/v4l/pixfmt-sdr-scu16be.rst
new file mode 100644
index 000..d6c2123
--- /dev/null
+++ b/Documentation/media/uapi/v4l/pixfmt-sdr-scu16be.rst
@@ -0,0 +1,44 @@
+.. -*- coding: utf-8; mode: rst -*-
+
+.. _V4L2-SDR-FMT-SCU16BE:
+
+**
+V4L2_SDR_FMT_SCU16BE ('SCU16')
+**
+
+Sliced complex unsigned 16-bit big endian IQ sample
+
+
+Description
+===
+
+This format contains a sequence of complex number samples. Each complex
+number consist of two parts called In-phase and Quadrature (IQ). Both I
+and Q are represented as a 16 bit unsigned big endian number. I value
+starts first and Q value starts at an offset equalling half of the buffer
+size. 14 bit data is stored in 16 bit space with unused stuffed bits
+padded with 0.
+
+**Byte Order.**
+Each cell is one byte.
+
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  .. row 1
+
+   -  start + 0:
+
+   -  I'\ :sub:`0[D13:D6]`
+
+   -  I'\ :sub:`0[D5:D0]`
+
+-  .. row 2
+
+   -  start + buffer_size/2:
+
+   -  Q'\ :sub:`0[D13:D6]`
+
+   -  Q'\ :sub:`0[D5:D0]`
diff --git a/Documentation/media/uapi/v4l/pixfmt-sdr-scu18be.rst 
b/Documentation/media/uapi/v4l/pixfmt-sdr-scu18be.rst
new file mode 100644
index 000..e6e0aff
--- /dev/null
+++ b/Documentation/media/uapi/v4l/pixfmt-sdr-scu18be.rst
@@ -0,0 +1,48 @@
+.. -*- coding: utf-8; mode: rst -*-
+
+.. _V4L2-SDR-FMT-SCU18BE:
+
+**
+V4L2_SDR_FMT_SCU18BE ('SCU18')
+**
+
+Sliced complex unsigned 18-bit big endian IQ sample
+
+
+Description
+===
+
+This format contains a sequence of complex number samples. Each complex
+number consist of two parts called In-phase and Quadrature (IQ). Both I
+and Q are represented as a 18 bit unsigned big endian number. I value
+starts first and Q value starts at an offset equalling half of the buffer
+size. 16 bit data is stored in 18 bit space with unused stuffed bits
+padded with 0.
+
+**Byte Order.**
+Each cell is one byte.
+
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  .. row 1
+
+   -  start + 0:
+
+   -  I'\ :sub:`0[D17:D10]`
+
+   -  I'\ :sub:`0[D9:D2]`
+
+   -  I'\ :sub:`0[D1:D0]`
+
+-  .. row 2
+
+   -  start + buffer_size/2:
+
+   -  Q'\ :sub:`0[D17:D10]`
+
+   -  Q'\ :sub:`0[D9:D2]`
+
+   -  Q'\ :sub:`0[D1:D0]`
diff --git a/Documentation/media/uapi/v4l/pixfmt-sdr-scu20be.rst 
b/Documentation/media/uapi/v4l/pixfmt-sdr-scu20be.rst
new file mode 100644
index 000..374e0a3
--- /dev/null
+++ b/Documentation/media/uapi/v4l/pixfmt-sdr-scu20be.rst
@@ -0,0 +1,48 @@
+.. -*- coding: utf-8; mode: rst -*-
+
+.. _V4L2-SDR-FMT-SCU20BE:
+
+**
+V4L2_SDR_FMT_SCU20BE ('SCU20')
+**
+
+Sliced complex unsigned 20-bit big endian IQ sample
+
+
+Description
+===
+
+This format contains a sequence of complex number samples. Each complex
+number consist of two parts called In-phase and Quadrature (IQ). Both I
+and Q are represented as a 20 bit unsigned big endian number. I value
+starts first and Q value starts at an offset equalling half of the buffer
+size. 18 bit data is stored in 20 bit space with unused stuffed bits
+padded with 0.
+
+**Byte Order.**
+Each cell is one byte.
+
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  .. row 1
+
+   -  start + 0:
+
+   -  I'\ :sub:`0[D19:D12]`
+
+   -  I'\ :sub:`0[D11:D4]`
+
+   -  I'\ :sub:`0[D3:D0]`
+
+-  .. row 2
+
+   -  start + buffer_size/2:
+
+   -  Q'\ :sub:`0[D19:D12]`
+
+   -  Q'\ :sub:`0[D11:D4]`
+
+   -  Q'\ :sub:`0[D3:D0]`
diff --git a/Documentation/media/uapi/v4l/sdr-formats.rst 
b/Documentation/media/uapi/v4l/sdr-formats.rst
index f863c08..4c01cf9 100644
--- a/Documentation/media/uapi/v4l/sdr-formats.rst
+++ b/Documentation/media/uapi/v4l/sdr-formats.rst
@@ -17,3 +17,6 @@ These formats are used for :ref:`SDR ` interface only.
 pixfmt-sdr-cs08
 pixfmt-sdr-cs14le
 pixfmt-sdr-ru12le
+pixfmt-sdr-scu16be
+pixfmt-sdr-scu18be
+

[RFC 3/5] media: platform: rcar_drif: Add DRIF support

2016-10-12 Thread Ramesh Shanmugasundaram
This patch adds Digital Radio Interface (DRIF) support to R-Car Gen3 SoCs.
The driver exposes each instance of DRIF as a V4L2 SDR device. A DRIF
device represents a channel and each channel can have one or two
sub-channels respectively depending on the target board.

DRIF supports only Rx functionality. It receives samples from a RF
frontend tuner chip it is interfaced with. The combination of DRIF and the
tuner device, which is registered as a sub-device, determines the receive
sample rate and format.

In order to be compliant as a V4L2 SDR device, DRIF needs to bind with
the tuner device, which can be provided by a third party vendor. DRIF acts
as a slave device and the tuner device acts as a master transmitting the
samples. The driver allows asynchronous binding of a tuner device that
is registered as a v4l2 sub-device. The driver can learn about the tuner
it is interfaced with based on port endpoint properties of the device in
device tree. The V4L2 SDR device inherits the controls exposed by the
tuner device.

The device can also be configured to use either one or both of the data
pins at runtime based on the master (tuner) configuration.

Signed-off-by: Ramesh Shanmugasundaram 
---
 .../devicetree/bindings/media/renesas,drif.txt |  109 ++
 drivers/media/platform/Kconfig |   25 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/rcar_drif.c | 1534 
 4 files changed, 1669 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,drif.txt
 create mode 100644 drivers/media/platform/rcar_drif.c

diff --git a/Documentation/devicetree/bindings/media/renesas,drif.txt 
b/Documentation/devicetree/bindings/media/renesas,drif.txt
new file mode 100644
index 000..24239d9
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/renesas,drif.txt
@@ -0,0 +1,109 @@
+Renesas R-Car Gen3 DRIF controller (DRIF)
+-
+
+Required properties:
+
+- compatible: "renesas,drif-r8a7795" if DRIF controller is a part of R8A7795 
SoC.
+ "renesas,rcar-gen3-drif" for a generic R-Car Gen3 compatible 
device.
+ When compatible with the generic version, nodes must list the
+ SoC-specific version corresponding to the platform first
+ followed by the generic version.
+
+- reg: offset and length of each sub-channel.
+- interrupts: associated with each sub-channel.
+- clocks: phandles and clock specifiers for each sub-channel.
+- clock-names: clock input name strings: "fck0", "fck1".
+- pinctrl-0: pin control group to be used for this controller.
+- pinctrl-names: must be "default".
+- dmas: phandles to the DMA channels for each sub-channel.
+- dma-names: names for the DMA channels: "rx0", "rx1".
+
+Required child nodes:
+-
+- Each DRIF channel can have one or both of the sub-channels enabled in a
+  setup. The sub-channels are represented as a child node. The name of the
+  child nodes are "sub-channel0" and "sub-channel1" respectively. Each child
+  node supports the "status" property only, which is used to enable/disable
+  the respective sub-channel.
+
+Optional properties:
+
+- port: video interface child port node of a channel that defines the local
+  and remote endpoints. The remote endpoint is assumed to a tuner subdevice
+  endpoint.
+- power-domains: phandle to respective power domain.
+- renesas,syncmd   : sync mode
+0 (Frame start sync pulse mode. 1-bit width pulse
+   indicates start of a frame)
+1 (L/R sync or I2S mode) (default)
+- renesas,lsb-first: empty property indicates lsb bit is received first.
+When not defined msb bit is received first (default)
+- renesas,syncac-pol-high  : empty property indicates sync signal polarity.
+When defined, active high or high->low sync signal.
+When not defined, active low or low->high sync signal
+(default)
+- renesas,dtdl : delay between sync signal and start of reception.
+Must contain one of the following values:
+0   (no bit delay)
+50  (0.5-clock-cycle delay)
+100 (1-clock-cycle delay) (default)
+150 (1.5-clock-cycle delay)
+200 (2-clock-cycle delay)
+- renesas,syncdl   : delay between end of reception and sync signal edge.
+Must contain one of the following values:
+0   (no bit delay) (default)
+50  (0.5-clock-cycle delay)
+100 (1-clock-cycle delay)
+150 (1.5-clock-cycle delay)
+200 (2-clock-cycle delay)
+   

[RFC 0/5] Add V4L2 SDR (DRIF & MAX2175) driver

2016-10-12 Thread Ramesh Shanmugasundaram
Hi All,

This RFC patch set contains two drivers
 - Digital Radio Interface (DRIF) driver
 - Maxim's MAX2175 RF to Bits tuner driver

These patches were based on top of Mauro's media-next repo
commit: 02a628e5c024cf67bf10bc822fb9169713f8ea74

These two drivers combined together expose a V4L2 SDR device that is compliant
with the V4L2 framework.

Brief description of devices below

DRIF:
-
This is a receive only slave controller that receives data into a FIFO from a
master device and uses DMA engine to move it from device to memory. It is a
serial I/O like controller with a design goal to act as digital radio receiver
targeting SDR solutions.

MAX2175:

This is a RF front end tuner device that supports tuning to different bands &
frequency. It supports I2S output with programmable word lengths & single/dual
data lines usage based on selected receive mode. Each receive mode is
designated with a sample rate.

+-++-+
| |-SCK--->| |
| MAX2175 (master)|-SS>|  DRIF (slave)   |
| |-SD0--->| |
| |-SD1--->| |
+-++-+

Driver design:
--

Some important design decisions are listed below

- DRIF registers as main V4L2 SDR device & MAX2175 registers as V4L2 sub-device.
- DRIF expects a tuner device to attach asynchronously at runtime and the module
  loading order is independent of each other.
- The tuner device can be provided by any third party vendor (in this case
  MAX2175).
- The mapping between DRIF & tuner device is achieved through device tree port
  & endpoint configuration of the board.

  e.g.

  drif node:

port {
drif0_ep: endpoint {
 remote-endpoint = <_0_ep>;
};
};

  max2175 node:

port {
max2175_0_ep: endpoint {
remote-endpoint = <_ep>;
};
};

- The combined driver is V4L2 compliant as here [1]
- In this RFC patch the MAX2175 tuner supports only DAB1.2 mode, which uses
  16bit word length.

New SDR formats:

The combined driver exposes new SDR formats. DRIF as such requires the receive
word length as the only programmable parameter in a normal case. Otherwise it is
agnostic of the tuner.

V4L2 framework requires publishing SDR formats about position of I & Q data
within the buffers. I have published three such formats to give an example.

Topic for discussion:
-
One of the design goals is keep DRIF & tuner driver as much independent as
possible. However, there are few things that are up for discussion

- SDR formats:
  --
  For e.g. when MAX2175 is configured in one of the FM modes it can do 80bit
  word length. By default only 18bits would be valid data in each data line
  and 2 bits would be status bits and the rest are stuff bits (zeros typically).
  However, it also supports a mode for some cases where it can do
  I multiplexing by using SD0 data line alone. In that case, the device
  can send the samples in one of the following combinations

  <-- 80 bits >
  <--14I + 2Status + 14Q + 2Status--- 48 stuff bits --> I2S mode = 2
  <--18I + 2Status + 18Q + 2Status--- 40 stuff bits --> I2S mode = 3
  <--16I + 16Q -- 48 stuff bits --> I2S mode = 4

  DRIF will receive these 80bit word as four 32bits each having 20bit of valid
  data. Usually the 80bit word is received as

  <---32bits--->
  <--20bits data 12bits zeros--> 0
  <--20bits data 12bits zeros--> 1
  <--20bits data 12bits zeros--> 2
  <--20bits data 12bits zeros--> 3

  For e.g. if MAX2175 uses 80bits=>14I+2+14Q+2 format, the placement of I & Q
  bits in DRIF buffers would be as below

  <-32bits-->
  <--- 20bits = I[13:0]+2+Q[13:10] 12bit zeros--> 0
  <--- 20bits = Q[9:0]+2+ stuffbits[7:0]---12bit zeros--> 1
  <--- 20bits = stuffbits  --- 12bit zeros--> 2
  <--- 20bits = stuffbits  --- 12bit zeros--> 3

  As you can see neither MAX2175 or DRIF alone can fully define the
  V4L2 SDR format. It is a combination of both.

  - Should we define a SDR format for each such possibility?
  - If a new tuner vendors wants to add support, existing formats MAY still be
reusable and new formats may be needed based on the tuner capability.

I would appreciate any feedback you may have?


References:

[1] v4l2-compliance test report

root@salvator-x:~# v4l2-compliance -S /dev/swradio0
v4l2-compliance SHA   : 7c2664b9a9b411d8b183009146e4f8548ca1d81a

Driver Info:
Driver name   : rcar_drif
Card type : R-Car DRIF
Bus info  : platform:R-Car DRIF
Driver version: 

[RFC 4/5] media: Add new SDR formats SC16, SC18 & SC20

2016-10-12 Thread Ramesh Shanmugasundaram
This patch adds support for the three new SDR formats. These formats
were prefixed with "sliced" indicating I data constitutes the top half and
Q data constitutes the bottom half of the received buffer.

V4L2_SDR_FMT_SCU16BE - 14-bit complex (I & Q) unsigned big-endian sample
inside 16-bit. V4L2 FourCC: SC16

V4L2_SDR_FMT_SCU18BE - 16-bit complex (I & Q) unsigned big-endian sample
inside 18-bit. V4L2 FourCC: SC18

V4L2_SDR_FMT_SCU20BE - 18-bit complex (I & Q) unsigned big-endian sample
inside 20-bit. V4L2 FourCC: SC20

Signed-off-by: Ramesh Shanmugasundaram 
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 3 +++
 include/uapi/linux/videodev2.h   | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index cd3641b..2b9be1c 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1259,6 +1259,9 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_SDR_FMT_CS8:  descr = "Complex S8"; break;
case V4L2_SDR_FMT_CS14LE:   descr = "Complex S14LE"; break;
case V4L2_SDR_FMT_RU12LE:   descr = "Real U12LE"; break;
+   case V4L2_SDR_FMT_SCU16BE:  descr = "Sliced Complex U16BE"; break;
+   case V4L2_SDR_FMT_SCU18BE:  descr = "Sliced Complex U18BE"; break;
+   case V4L2_SDR_FMT_SCU20BE:  descr = "Sliced Complex U20BE"; break;
case V4L2_TCH_FMT_DELTA_TD16:   descr = "16-bit signed deltas"; break;
case V4L2_TCH_FMT_DELTA_TD08:   descr = "8-bit signed deltas"; break;
case V4L2_TCH_FMT_TU16: descr = "16-bit unsigned touch data"; 
break;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 2b12548..369a199 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -643,6 +643,9 @@ struct v4l2_pix_format {
 #define V4L2_SDR_FMT_CS8  v4l2_fourcc('C', 'S', '0', '8') /* complex 
s8 */
 #define V4L2_SDR_FMT_CS14LE   v4l2_fourcc('C', 'S', '1', '4') /* complex 
s14le */
 #define V4L2_SDR_FMT_RU12LE   v4l2_fourcc('R', 'U', '1', '2') /* real 
u12le */
+#define V4L2_SDR_FMT_SCU16BE v4l2_fourcc('S', 'C', '1', '6') /* sliced 
complex u16be */
+#define V4L2_SDR_FMT_SCU18BE v4l2_fourcc('S', 'C', '1', '8') /* sliced 
complex u18be */
+#define V4L2_SDR_FMT_SCU20BE v4l2_fourcc('S', 'C', '2', '0') /* sliced 
complex u20be */
 
 /* Touch formats - used for Touch devices */
 #define V4L2_TCH_FMT_DELTA_TD16v4l2_fourcc('T', 'D', '1', '6') /* 
16-bit signed deltas */
-- 
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


[RFC 1/5] media: i2c: max2175: Add MAX2175 support

2016-10-12 Thread Ramesh Shanmugasundaram
This patch adds driver support for MAX2175 chip. This is Maxim
Integrated's RF to Bits tuner front end chip designed for software-defined
radio solutions. This driver exposes the tuner as a sub-device instance
with standard and custom controls to configure the device.

Signed-off-by: Ramesh Shanmugasundaram 
---
 .../devicetree/bindings/media/i2c/max2175.txt  |   60 +
 drivers/media/i2c/Kconfig  |4 +
 drivers/media/i2c/Makefile |2 +
 drivers/media/i2c/max2175/Kconfig  |8 +
 drivers/media/i2c/max2175/Makefile |4 +
 drivers/media/i2c/max2175/max2175.c| 1624 
 drivers/media/i2c/max2175/max2175.h|  124 ++
 7 files changed, 1826 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/max2175.txt
 create mode 100644 drivers/media/i2c/max2175/Kconfig
 create mode 100644 drivers/media/i2c/max2175/Makefile
 create mode 100644 drivers/media/i2c/max2175/max2175.c
 create mode 100644 drivers/media/i2c/max2175/max2175.h

diff --git a/Documentation/devicetree/bindings/media/i2c/max2175.txt 
b/Documentation/devicetree/bindings/media/i2c/max2175.txt
new file mode 100644
index 000..2250d5f
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/max2175.txt
@@ -0,0 +1,60 @@
+Maxim Integrated MAX2175 RF to Bits tuner
+-
+
+The MAX2175 IC is an advanced analog/digital hybrid-radio receiver with
+RF to Bits® front-end designed for software-defined radio solutions.
+
+Required properties:
+
+- compatible: "maxim,max2175" for MAX2175 RF-to-bits tuner.
+- clocks: phandle to the fixed xtal clock.
+- clock-names: name of the fixed xtal clock.
+- port: video interface child port node of a tuner that defines the local
+  and remote endpoints. The remote endpoint is assumed to be an SDR device
+  that is capable of receiving the digital samples from the tuner.
+
+Optional properties:
+
+- maxim,slave : empty property indicates this is a slave of another
+master tuner. This is used to define two tuners in
+diversity mode (1 master, 1 slave). By default each
+tuner is an individual master.
+- maxim,refout-load: load capacitance value (in pF) on reference output
+drive level. The mapping of these load values to
+respective bit values are given below.
+0 - Reference output disabled
+1 - 10pF load
+2 - 20pF load
+3 - 30pF load
+4 - 40pF load
+5 - 60pF load
+6 - 70pF load
+
+Example:
+
+
+Board specific DTS file
+
+/* Fixed XTAL clock node */
+maxim_xtal: maximextal {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <36864000>;
+};
+
+/* A tuner device instance under i2c bus */
+max2175_0: tuner@60 {
+   #clock-cells = <0>;
+   compatible = "maxim,max2175";
+   reg = <0x60>;
+   clocks = <_xtal>;
+   clock-names = "xtal";
+   maxim,refout-load = <10>;
+
+   port {
+   max2175_0_ep: endpoint {
+   remote-endpoint = <_rx_v4l2_sdr_device>;
+   };
+   };
+
+};
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 2669b4b..66c73b0 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -749,6 +749,10 @@ config VIDEO_SAA6752HS
  To compile this driver as a module, choose M here: the
  module will be called saa6752hs.
 
+comment "SDR tuner chips"
+
+source "drivers/media/i2c/max2175/Kconfig"
+
 comment "Miscellaneous helper chips"
 
 config VIDEO_THS7303
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 92773b2..cfae721 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -6,6 +6,8 @@ obj-$(CONFIG_VIDEO_CX25840) += cx25840/
 obj-$(CONFIG_VIDEO_M5MOLS) += m5mols/
 obj-y  += soc_camera/
 
+obj-$(CONFIG_SDR_MAX2175)  += max2175/
+
 obj-$(CONFIG_VIDEO_APTINA_PLL) += aptina-pll.o
 obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o
 obj-$(CONFIG_VIDEO_TDA7432) += tda7432.o
diff --git a/drivers/media/i2c/max2175/Kconfig 
b/drivers/media/i2c/max2175/Kconfig
new file mode 100644
index 000..a8a0664
--- /dev/null
+++ b/drivers/media/i2c/max2175/Kconfig
@@ -0,0 +1,8 @@
+config SDR_MAX2175
+   tristate "Maxim 2175 RF to Bits tuner"
+   depends on VIDEO_V4L2 && MEDIA_SDR_SUPPORT && I2C && 
VIDEO_V4L2_SUBDEV_API
+   ---help---
+ Support for Maxim 2175 tuner
+
+ To compile this driver as a module, choose M here; the
+ module will be called max2175.
diff --git a/drivers/media/i2c/max2175/Makefile 
b/drivers/media/i2c/max2175/Makefile
new 

[RFC 2/5] media: v4l2-ctrls: Reserve controls for MAX217X

2016-10-12 Thread Ramesh Shanmugasundaram
Reserve controls for MAX217X RF to Bits tuner (family) chips. These hybrid
radio receiver chips are highly programmable and hence reserving 32
controls.

Signed-off-by: Ramesh Shanmugasundaram 
---
 include/uapi/linux/v4l2-controls.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index b6a357a..b7404c9 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -180,6 +180,11 @@ enum v4l2_colorfx {
  * We reserve 16 controls for this driver. */
 #define V4L2_CID_USER_TC358743_BASE(V4L2_CID_USER_BASE + 0x1080)
 
+/* The base for the max217x driver controls.
+ * We reserve 32 controls for this driver
+ */
+#define V4L2_CID_USER_MAX217X_BASE (V4L2_CID_USER_BASE + 0x1090)
+
 /* MPEG-class control IDs */
 /* The MPEG controls are applicable to all codec controls
  * and the 'MPEG' part of the define is historical */
-- 
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


Re: [PATCH 02/22] [media] v4l2-async: allow subdevices to add further subdevices to the notifier waiting list

2016-10-12 Thread Philipp Zabel
On Fri, Oct 7, 2016 at 11:52 PM, Sakari Ailus  wrote:
> Hi Philipp,
>
> On Fri, Oct 07, 2016 at 06:00:47PM +0200, Philipp Zabel wrote:
>> Currently the v4l2_async_notifier needs to be given a list of matches
>> for all expected subdevices on creation. When chaining subdevices that
>> are asynchronously probed via device tree, the bridge device that sets
>> up the notifier does not know the complete list of subdevices, as it
>> can only parse its own device tree node to obtain information about
>> the nearest neighbor subdevices.
>> To support indirectly connected subdevices, we need to support amending
>> the existing notifier waiting list with newly found neighbor subdevices
>> with each registered subdevice.
>
> Could you elaborate a little what's the exact use case for this? What kind
> of a device?

On i.MX6 there's a

DW MIPI CSI2 host -> Mux -> IPU/CSI

path and all three are asynchronous subdevices in my patchset and only
the last one is directly known to the media device from the device
tree, since each driver should only parse its own device tree node an
can not follow the of_graph over multiple steps.
Another use case I have seen in the wild are external GPIO controlled
multiplexers or LVDS serializer/deserializer pairs between a parallel
camera and parallel capture interface. In each case the bridge node
can only determine its closest neighbor from the device tree (the mux,
the LVDS deserializer) but does not know about the indirectly
connected device nodes further upstream.

regards
Philipp
--
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 0/6] Module for tracking/accounting shared memory buffers

2016-10-12 Thread Christian König

Am 12.10.2016 um 01:50 schrieb Ruchi Kandoi:

This patchstack adds memtrack hooks into dma-buf and ion.  If there's upstream
interest in memtrack, it can be extended to other memory allocators as well,
such as GEM implementations.
We have run into similar problems before. Because of this I already 
proposed a solution for this quite a while ago, but never pushed on 
upstreaming this since it was only done for a special use case.


Instead of keeping track of how much memory a process has bound (which 
is very fragile) my solution  only added some more debugging info on a 
per fd basis (e.g. how much memory is bound to this fd).


This information was then used by the OOM killer (for example) to make a 
better decision on which process to reap.


Shouldn't be to hard to expose this through debugfs or maybe a new fcntl 
to userspace for debugging.


I haven't looked at the code in detail, but messing with the per process 
memory accounting like you did in this proposal is clearly not a good 
idea if you ask me.


Regards,
Christian.
--
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 0/4] reST-directive kernel-cmd / include contentent from scripts

2016-10-12 Thread Jani Nikula
On Tue, 11 Oct 2016, Markus Heiser  wrote:
> Anyway, these are only my 2cent. I'am interested in what Jon says
> in general about using (Perl) scripts to generate reST content.

I think I've said all that I have to say on the subject. Up to Jon.

BR,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center
--
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 00/11] Introduce writeback connectors

2016-10-12 Thread Brian Starkey

Hi Eric,

On Tue, Oct 11, 2016 at 12:01:14PM -0700, Eric Anholt wrote:

Brian Starkey  writes:


Hi,

This RFC series introduces a new connector type:
 DRM_MODE_CONNECTOR_WRITEBACK
It is a follow-on from a previous discussion: [1]

Writeback connectors are used to expose the memory writeback engines
found in some display controllers, which can write a CRTC's
composition result to a memory buffer.
This is useful e.g. for testing, screen-recording, screenshots,
wireless display, display cloning, memory-to-memory composition.

Patches 1-7 include the core framework changes required, and patches
8-11 implement a writeback connector for the Mali-DP writeback engine.
The Mali-DP patches depend on this other series: [2].

The connector is given the FB_ID property for the output framebuffer,
and two new read-only properties: PIXEL_FORMATS and
PIXEL_FORMATS_SIZE, which expose the supported framebuffer pixel
formats of the engine.

The EDID property is not exposed for writeback connectors.

Writeback connector usage:
--
Due to connector routing changes being treated as "full modeset"
operations, any client which wishes to use a writeback connector
should include the connector in every modeset. The writeback will not
actually become active until a framebuffer is attached.

The writeback itself is enabled by attaching a framebuffer to the
FB_ID property of the connector. The driver must then ensure that the
CRTC content of that atomic commit is written into the framebuffer.

The writeback works in a one-shot mode with each atomic commit. This
prevents the same content from being written multiple times.
In some cases (front-buffer rendering) there might be a desire for
continuous operation - I think a property could be added later for
this kind of control.

Writeback can be disabled by setting FB_ID to zero.


I think this sounds great, and the interface is just right IMO.



Thanks, glad you like it! Hopefully you're equally agreeable with the
changes Daniel has been suggesting.


I don't really see a use for continuous mode -- a sequence of one-shots
makes a lot more sense because then you can know what data has changed,
which anyone trying to use the writeback buffer would need to know.



Agreed - we've never found a use for it.


Known issues:
-
 * I'm not sure what "DPMS" should mean for writeback connectors.
   It could be used to disable writeback (even when a framebuffer is
   attached), or it could be hidden entirely (which would break the
   legacy DPMS call for writeback connectors).
 * With Daniel's recent re-iteration of the userspace API rules, I
   fully expect to provide some userspace code to support this. The
   question is what, and where? We want to use writeback for testing,
   so perhaps some tests in igt is suitable.
 * Documentation. Probably some portion of this cover letter needs to
   make it into Documentation/
 * Synchronisation. Our hardware will finish the writeback by the next
   vsync. I've not implemented fence support here, but it would be an
   obvious addition.


My hardware won't necessarily finish by the next vsync -- it trickles
out at whatever rate it can find memory bandwidth to get the job done,
and fires an interrupt when it's finished.



Is it bounded? You presumably have to finish the write-out before you
can change any input buffers?


So I would like some definition for how syncing works.  One answer would
be that these flips don't trigger their pageflip events until the
writeback is done (so I need to collect both the vsync irq and the
writeback irq before sending).  Another would be that manage an
independent fence for the writeback fb, so that you still immediately
know when framebuffers from the previous scanout-only frame are idle.



I much prefer the sound of the explicit fence approach.

Hopefully we can agree that a new atomic commit can't be completed
whilst there's a writeback ongoing, otherwise managing the fence and
framebuffer lifetime sounds really tricky - they'd need to be decoupled
from the atomic_state and outlive the commit that spawned them.

Cheers,
-Brian


Also, tests for this in igt, please.  Writeback in igt will give us so
much more ability to cover KMS functionality on non-Intel hardware.

--
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 0/4] reST-directive kernel-cmd / include contentent from scripts

2016-10-12 Thread Markus Heiser

Am 11.10.2016 um 18:45 schrieb Mauro Carvalho Chehab :

> If we allow such scripts (and we do since day zero, due to
> kernel-doc), then there are 3 options:
> 
> 1) use a single python script to run the scripts needed in the
>   build process (e. g. merging kernel-cmd extension upstream);
> 
> 2) use a dedicated python script for every non-phyton script;
> 
> 3) use only python scripts to extend Sphinx functionality.
> 
> The (2) scenario seems to be the worse case, as it will end by
> having a perl(/shell?) script/python script pair for every 
> non-python script we need to run, we're actually making it twice
> worse.
> 
> For (3) to happen, we'll need to convert both kernel-doc and
> parse-headers.pl to Python. This could be a long term goal,
> but I prefer to not rewrite those scripts for a while, as
> it is a lot easier to maintain them in perl, at least to me, and it
> is less disruptive, as rewriting kernel-doc to Python can introduce
> regressions.
> 

Hi Mauro,

its a bit OT in this thread, but in the linuxdoc project,
the kernel-doc is already converted to python.

  https://return42.github.io/linuxdoc/cmd-line.html#kernel-doc

and you have used it already, when you lint with kernel-lint.
Hence I see more progressions than regression ;-)

> So, the way I see, (1) is the best approach.

agree

--Markus--

> 
>> Anyway, these are only my 2cent. I'am interested in what Jon says
>> in general about using (Perl) scripts to generate reST content.
>> 
>> --Markus--
>> 
> 
> Regards,
> Mauro

--
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 00/11] Introduce writeback connectors

2016-10-12 Thread Daniel Vetter
On Tue, Oct 11, 2016 at 10:24:23PM +0100, Brian Starkey wrote:
> On Tue, Oct 11, 2016 at 10:02:43PM +0200, Daniel Vetter wrote:
> > The problem with just that is that there's lots of different things
> > that can feed into the overall needs_modeset variable. That's why we
> > split it up into multiple booleans.
> > 
> > So yes you're supposed to clear connectors_changed if there is some
> > change that you can handle without a full modeset. If you want, think
> > of connectors_changed as
> > needs_modeset_due_to_change_in_connnector_state, but that's cumbersome
> > to type and too long ;-)
> > 
> 
> All right, got it :-). This intention wasn't clear to me from the
> comments in the code.

A patch to update the kernel-doc to make it clearer (there's mode_changed,
connectors_changed and active_changed, plus drm_crtc_needs_modeset) would
be awesome. I'm trying to write useful docs, but since I designed this all
I sometimes forget to make the non-obvious assumptions clear enough.

Volunteered?

> > > > tbh I don't like that, I think it'd be better to make this truly
> > > > one-shot. Otherwise we'll have real fun problems with hw where the
> > > > writeback can take longer than a vblank (it happens ...). So one-shot,
> > > > with auto-clearing to NULL/0 is imo the right approach.
> > > 
> > > That's an interesting point about hardware which won't finish within
> > > one frame; but I don't see how "true one-shot" helps.
> > > 
> > > What's the expected behaviour if userspace makes a new atomic commit
> > > with a writeback framebuffer whilst a previous writeback is ongoing?
> > > 
> > > In both cases, you either need to block or fail the commit - whether
> > > the framebuffer gets removed when it's done is immaterial.
> > 
> > See Eric's question. We need to define that, and I think the simplest
> > approach is a completion fence/sync_file. It's destaged now in 4.9, we
> > can use them. I think the simplest uabi would be a pointer property
> > (u64) where we write the fd of the fence we'll signal when write-out
> > completes.
> > 
> 
> That tells userspace that the previous writeback is finished, I agree that's
> needed. It doesn't define any behaviour in case userspace asks for another
> writeback before that fence fires though.

Hm, good point. I guess we could just state that if userspace does a
writeback, and issues a new writeback before both a) the atomic flip and
b) the write back complete fence signalled will lead to undefined
behaviour. Undefined as in: data corruption, rejected atomic commit or
anything else than a kernel crash is allowed. This is similar to doing a
page flip and starting to render to the old buffers before the flip event
signalled completion: Userspace gets the mess it asked for ;-)
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
--
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