Re: [PATCH v4 8/8] r8a7791-koelsch.dts: add HDMI input

2016-05-11 Thread Simon Horman
On Wed, May 11, 2016 at 04:02:56PM +0200, Ulrich Hecht wrote:
> From: Hans Verkuil 
> 
> Add support in the dts for the HDMI input. Based on the Lager dts
> patch from Ultich Hecht.

Please use "ARM: dts: koelsch:" as the prefix for this patch title.

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


cron job: media_tree daily build: OK

2016-05-11 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 May 12 04:00:23 CEST 2016
git branch: test
git hash:   d1532d5575696965a52b19553dd7dacf75f3fec5
gcc version:i686-linux-gcc (GCC) 5.3.0
sparse version: v0.5.0-56-g7647c77
smatch version: v0.5.0-3428-gdfe27cf
host hardware:  x86_64
host os:4.5.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12.23-i686: OK
linux-3.13.11-i686: OK
linux-3.14.9-i686: OK
linux-3.15.2-i686: OK
linux-3.16.7-i686: OK
linux-3.17.8-i686: OK
linux-3.18.7-i686: OK
linux-3.19-i686: OK
linux-4.0-i686: OK
linux-4.1.1-i686: OK
linux-4.2-i686: OK
linux-4.3-i686: OK
linux-4.4-i686: OK
linux-4.5-i686: OK
linux-4.6-rc1-i686: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12.23-x86_64: OK
linux-3.13.11-x86_64: OK
linux-3.14.9-x86_64: OK
linux-3.15.2-x86_64: OK
linux-3.16.7-x86_64: OK
linux-3.17.8-x86_64: OK
linux-3.18.7-x86_64: OK
linux-3.19-x86_64: OK
linux-4.0-x86_64: OK
linux-4.1.1-x86_64: OK
linux-4.2-x86_64: OK
linux-4.3-x86_64: OK
linux-4.4-x86_64: OK
linux-4.5-x86_64: OK
linux-4.6-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: 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/media.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH/RFC v2 2/4] v4l: Add metadata video device type

2016-05-11 Thread Laurent Pinchart
The metadata video device is used to transfer metadata between
userspace and kernelspace. It supports the metadata buffer type only.

Signed-off-by: Laurent Pinchart 
---
 Documentation/DocBook/media/v4l/dev-meta.xml | 10 +++---
 drivers/media/v4l2-core/v4l2-dev.c   | 21 -
 drivers/media/v4l2-core/v4l2-ioctl.c | 15 ++-
 include/media/v4l2-dev.h |  3 ++-
 include/uapi/linux/media.h   |  2 ++
 5 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/dev-meta.xml 
b/Documentation/DocBook/media/v4l/dev-meta.xml
index 9b5b1fba2007..75bd22521af7 100644
--- a/Documentation/DocBook/media/v4l/dev-meta.xml
+++ b/Documentation/DocBook/media/v4l/dev-meta.xml
@@ -14,9 +14,13 @@ intended for transfer of metadata to userspace and control 
of that operation.
   
 
   
-The metadata interface is implemented on video capture devices. The device can
-be dedicated to metadata or can implement both video and metadata capture as
-specified in its reported capabilities.
+The metadata interface can be implemented on video capture devices, metadata
+devices or both, at the discretion of drivers. Metadata devices are accessed
+through character device special files named
+/dev/v4l-meta[0-9]+ with major number 81 and dynamically
+allocated minor numbers. Video devices that support metadata capture can be
+dedicated to metadata or can implement both metadata capture and video capture
+and/or output, as specified in the device's reported capabilities.
   
 
   
diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index 74b79e60ac38..5a8d7b03ab97 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -527,6 +527,7 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI;
bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO;
bool is_sdr = vdev->vfl_type == VFL_TYPE_SDR;
+   bool is_meta = vdev->vfl_type == VFL_TYPE_META;
bool is_rx = vdev->vfl_dir != VFL_DIR_TX;
bool is_tx = vdev->vfl_dir != VFL_DIR_RX;
 
@@ -664,9 +665,18 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
if (ops->vidioc_try_fmt_sdr_out)
set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
+   } else if (is_meta && is_rx) {
+   if (ops->vidioc_enum_fmt_meta_cap)
+   set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
+   if (ops->vidioc_g_fmt_meta_cap)
+   set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
+   if (ops->vidioc_s_fmt_meta_cap)
+   set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
+   if (ops->vidioc_try_fmt_meta_cap)
+   set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
}
 
-   if (is_vid || is_vbi || is_sdr) {
+   if (is_vid || is_vbi || is_sdr || is_meta) {
/* ioctls valid for video, metadata, vbi or sdr */
SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs);
SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf);
@@ -767,6 +777,10 @@ static int video_register_media_controller(struct 
video_device *vdev, int type)
intf_type = MEDIA_INTF_T_V4L_SUBDEV;
/* Entity will be created via v4l2_device_register_subdev() */
break;
+   case VFL_TYPE_META:
+   intf_type = MEDIA_INTF_T_V4L_META;
+   vdev->entity.function = MEDIA_ENT_F_IO_META;
+   break;
default:
return 0;
}
@@ -849,6 +863,8 @@ static int video_register_media_controller(struct 
video_device *vdev, int type)
  * %VFL_TYPE_SUBDEV - A subdevice
  *
  * %VFL_TYPE_SDR - Software Defined Radio
+ *
+ * %VFL_TYPE_META - Metadata
  */
 int __video_register_device(struct video_device *vdev, int type, int nr,
int warn_if_nr_in_use, struct module *owner)
@@ -892,6 +908,9 @@ int __video_register_device(struct video_device *vdev, int 
type, int nr,
/* Use device name 'swradio' because 'sdr' was already taken. */
name_base = "swradio";
break;
+   case VFL_TYPE_META:
+   name_base = "v4l-meta";
+   break;
default:
printk(KERN_ERR "%s called with unknown type: %d\n",
   __func__, type);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 5d003152ff68..256938fff9e0 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -935,6 +935,7 @@ static int check_fmt(struct file *file, enum v4l2_buf_type 
type)
bool is_vid = vfd->vfl_type == 

[PATCH/RFC v2 3/4] v4l: Define a pixel format for the R-Car VSP1 1-D histogram engine

2016-05-11 Thread Laurent Pinchart
The format is used on the R-Car VSP1 video queues that carry
1-D histogram statistics data.

Signed-off-by: Laurent Pinchart 
Acked-by: Sakari Ailus 
---
 .../DocBook/media/v4l/pixfmt-meta-vsp1-hgo.xml | 307 +
 Documentation/DocBook/media/v4l/pixfmt.xml |   9 +
 drivers/media/v4l2-core/v4l2-ioctl.c   |   1 +
 include/uapi/linux/videodev2.h |   3 +
 4 files changed, 320 insertions(+)
 create mode 100644 Documentation/DocBook/media/v4l/pixfmt-meta-vsp1-hgo.xml

diff --git a/Documentation/DocBook/media/v4l/pixfmt-meta-vsp1-hgo.xml 
b/Documentation/DocBook/media/v4l/pixfmt-meta-vsp1-hgo.xml
new file mode 100644
index ..b40bd10695d2
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/pixfmt-meta-vsp1-hgo.xml
@@ -0,0 +1,307 @@
+
+  
+V4L2_META_FMT_VSP1_HGO ('VSPH')
+
+  
+  
+
+  V4L2_META_FMT_VSP1_HGO
+
+Renesas R-Car VSP1 1-D Histogram Data
+  
+  
+Description
+
+This format describes histogram data generated by the Renesas R-Car VSP1 1-D
+Histogram (HGO) engine.
+
+
+The VSP1 HGO is a histogram computation engine that can operate on RGB, YCrCb
+or HSV data. It operates on a possibly cropped and subsampled input image and
+computes the minimum, maximum and sum of all pixels as well as per-channel
+histograms.
+
+The HGO can compute histograms independently per channel, on the maximum of the
+three channels (RGB data only) or on the Y channel only (YCbCr only). It can
+additionally output the histogram with 64 or 256 bins, resulting in four
+possible modes of operation.
+  
+   
+ 
+   In 64 bins normal mode, the HGO operates
+   on the three channels independently to compute three 64-bins
+   histograms. RGB, YCbCr and HSV image formats are supported.
+ 
+   
+   
+ 
+   In 64 bins maximum mode, the HGO operates
+   on the maximum of the (R, G, B) channels to compute a single
+   64-bins histogram. Only the RGB image format is supported.
+ 
+   
+   
+ 
+   In 256 bins normal mode, the HGO operates
+   on the Y channel to compute a single 256-bins histogram. Only the
+   YCbCr image format is supported.
+ 
+   
+   
+ 
+   In 256 bins maximum mode, the HGO operates
+   on the maximum of the (R, G, B) channels to compute a single
+   256-bins histogram. Only the RGB image format is supported.
+ 
+   
+  
+
+
+
+All data is stored in memory in little endian format. Each cell in the tables
+below contains one byte.
+
+
+  VSP1 HGO Data - 64 Bins, Normal Mode (792 bytes)
+  
+   
+   
+   
+   
+   
+   
+   
+ 
+   Offset
+   Memory
+ 
+ 
+   
+   [31:24]
+   [23:16]
+   [15:8]
+   [7:0]
+ 
+   
+   
+ 
+   0
+   -
+   R/Cr/H max [7:0]
+   -
+   R/Cr/H min [7:0]
+ 
+ 
+   4
+   -
+   G/Y/S max [7:0]
+   -
+   G/Y/S min [7:0]
+ 
+ 
+   8
+   -
+   B/Cb/V max [7:0]
+   -
+   B/Cb/V min [7:0]
+ 
+ 
+   12
+   R/Cr/H sum [31:0]
+ 
+ 
+   16
+   G/Y/S sum [31:0]
+ 
+ 
+   20
+   B/Cb/V sum [31:0]
+ 
+ 
+   24
+   R/Cr/H bin 0 [31:0]
+ 
+ 
+   
+   ...
+ 
+ 
+   276
+   R/Cr/H bin 63 [31:0]
+ 
+ 
+   280
+   G/Y/S bin 0 [31:0]
+ 
+ 
+   
+   ...
+ 
+ 
+   532
+   G/Y/S bin 63 [31:0]
+ 
+ 
+   536
+   B/Cb/V bin 0 [31:0]
+ 
+ 
+   
+   ...
+ 
+ 
+   788
+   B/Cb/V bin 63 [31:0]
+ 
+   
+  
+
+
+  VSP1 HGO Data - 64 Bins, Max Mode (264 bytes)
+  
+   
+   
+   
+   
+   
+   
+   
+ 
+   Offset
+   Memory
+ 
+ 
+   
+   [31:24]
+   [23:16]
+   [15:8]
+   [7:0]
+ 
+   
+   
+ 
+   0
+   -
+   max(R,G,B) max [7:0]
+   -
+   max(R,G,B) min [7:0]
+ 
+ 
+   4
+   max(R,G,B) sum [31:0]
+ 
+ 
+   8
+   max(R,G,B) bin 0 [31:0]
+ 
+ 
+   
+   ...
+ 
+ 
+   260
+   max(R,G,B) bin 63 [31:0]
+ 
+   
+  
+
+
+  

[PATCH/RFC v2 4/4] v4l: vsp1: Add HGO support

2016-05-11 Thread Laurent Pinchart
The HGO is a Histogram Generator One-Dimension. It computes per-channel
histograms over a configurable region of the image with optional
subsampling.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/Kconfig|   1 +
 drivers/media/platform/vsp1/Makefile  |   2 +
 drivers/media/platform/vsp1/vsp1.h|   3 +
 drivers/media/platform/vsp1/vsp1_drm.c|   2 +-
 drivers/media/platform/vsp1/vsp1_drv.c|  37 ++-
 drivers/media/platform/vsp1/vsp1_entity.c | 131 +++-
 drivers/media/platform/vsp1/vsp1_entity.h |   7 +-
 drivers/media/platform/vsp1/vsp1_hgo.c| 496 ++
 drivers/media/platform/vsp1/vsp1_hgo.h|  50 +++
 drivers/media/platform/vsp1/vsp1_histo.c  | 307 ++
 drivers/media/platform/vsp1/vsp1_histo.h  |  68 
 drivers/media/platform/vsp1/vsp1_pipe.c   |  30 +-
 drivers/media/platform/vsp1/vsp1_pipe.h   |   2 +
 drivers/media/platform/vsp1/vsp1_regs.h   |  24 +-
 drivers/media/platform/vsp1/vsp1_video.c  |  22 +-
 15 files changed, 1143 insertions(+), 39 deletions(-)
 create mode 100644 drivers/media/platform/vsp1/vsp1_hgo.c
 create mode 100644 drivers/media/platform/vsp1/vsp1_hgo.h
 create mode 100644 drivers/media/platform/vsp1/vsp1_histo.c
 create mode 100644 drivers/media/platform/vsp1/vsp1_histo.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index a3304466e628..0141af8cfdbc 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -266,6 +266,7 @@ config VIDEO_RENESAS_VSP1
depends on (ARCH_RENESAS && OF) || COMPILE_TEST
depends on !ARM64 || VIDEO_RENESAS_FCP
select VIDEOBUF2_DMA_CONTIG
+   select VIDEOBUF2_VMALLOC
---help---
  This is a V4L2 driver for the Renesas VSP1 video processing engine.
 
diff --git a/drivers/media/platform/vsp1/Makefile 
b/drivers/media/platform/vsp1/Makefile
index 95b3ac2ea7ef..a12356bf2135 100644
--- a/drivers/media/platform/vsp1/Makefile
+++ b/drivers/media/platform/vsp1/Makefile
@@ -3,5 +3,7 @@ vsp1-y  += vsp1_dl.o vsp1_drm.o 
vsp1_video.o
 vsp1-y += vsp1_rpf.o vsp1_rwpf.o vsp1_wpf.o
 vsp1-y += vsp1_hsit.o vsp1_lif.o vsp1_lut.o
 vsp1-y += vsp1_bru.o vsp1_sru.o vsp1_uds.o
+vsp1-y += vsp1_hgo.o vsp1_histo.o
+vsp1-y += vsp1_lif.o
 
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)   += vsp1.o
diff --git a/drivers/media/platform/vsp1/vsp1.h 
b/drivers/media/platform/vsp1/vsp1.h
index 7cb0f5e428df..6bf6d54c0ae4 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -31,6 +31,7 @@ struct vsp1_drm;
 struct vsp1_entity;
 struct vsp1_platform_data;
 struct vsp1_bru;
+struct vsp1_hgo;
 struct vsp1_hsit;
 struct vsp1_lif;
 struct vsp1_lut;
@@ -46,6 +47,7 @@ struct vsp1_uds;
 #define VSP1_HAS_LUT   (1 << 1)
 #define VSP1_HAS_SRU   (1 << 2)
 #define VSP1_HAS_BRU   (1 << 3)
+#define VSP1_HAS_HGO   (1 << 4)
 
 struct vsp1_device_info {
u32 version;
@@ -66,6 +68,7 @@ struct vsp1_device {
struct rcar_fcp_device *fcp;
 
struct vsp1_bru *bru;
+   struct vsp1_hgo *hgo;
struct vsp1_hsit *hsi;
struct vsp1_hsit *hst;
struct vsp1_lif *lif;
diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
b/drivers/media/platform/vsp1/vsp1_drm.c
index 14730119687f..ff961b2c084e 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -489,7 +489,7 @@ void vsp1_du_atomic_flush(struct device *dev)
}
}
 
-   vsp1_entity_route_setup(entity, pipe->dl);
+   vsp1_entity_route_setup(entity, pipe, pipe->dl);
 
if (entity->ops->configure)
entity->ops->configure(entity, pipe, pipe->dl);
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c 
b/drivers/media/platform/vsp1/vsp1_drv.c
index e655639af7e2..c737f15ad1f4 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -29,6 +29,7 @@
 #include "vsp1_bru.h"
 #include "vsp1_dl.h"
 #include "vsp1_drm.h"
+#include "vsp1_hgo.h"
 #include "vsp1_hsit.h"
 #include "vsp1_lif.h"
 #include "vsp1_lut.h"
@@ -104,7 +105,8 @@ static int vsp1_create_sink_links(struct vsp1_device *vsp1,
if (source->type == sink->type)
continue;
 
-   if (source->type == VSP1_ENTITY_LIF ||
+   if (source->type == VSP1_ENTITY_HGO ||
+   source->type == VSP1_ENTITY_LIF ||
source->type == VSP1_ENTITY_WPF)
continue;
 
@@ -147,6 +149,16 @@ static int vsp1_uapi_create_links(struct vsp1_device *vsp1)
return ret;
}
 
+   if 

[PATCH/RFC v2 1/4] v4l: Add metadata buffer type and format

2016-05-11 Thread Laurent Pinchart
The metadata buffer type is used to transfer metadata between userspace
and kernelspace through a V4L2 buffers queue. It comes with a new
metadata capture capability and format description.

Signed-off-by: Laurent Pinchart 
---
 Documentation/DocBook/media/v4l/dev-meta.xml  | 93 +++
 Documentation/DocBook/media/v4l/v4l2.xml  |  1 +
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 19 ++
 drivers/media/v4l2-core/v4l2-dev.c| 16 +++--
 drivers/media/v4l2-core/v4l2-ioctl.c  | 34 ++
 drivers/media/v4l2-core/videobuf2-v4l2.c  |  3 +
 include/media/v4l2-ioctl.h|  8 +++
 include/uapi/linux/videodev2.h| 14 
 8 files changed, 182 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/dev-meta.xml

diff --git a/Documentation/DocBook/media/v4l/dev-meta.xml 
b/Documentation/DocBook/media/v4l/dev-meta.xml
new file mode 100644
index ..9b5b1fba2007
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/dev-meta.xml
@@ -0,0 +1,93 @@
+  Metadata Interface
+
+  
+Experimental
+This is an  experimental 
+interface and may change in the future.
+  
+
+  
+Metadata refers to any non-image data that supplements video frames with
+additional information. This may include statistics computed over the image
+or frame capture parameters supplied by the image source. This interface is
+intended for transfer of metadata to userspace and control of that operation.
+  
+
+  
+The metadata interface is implemented on video capture devices. The device can
+be dedicated to metadata or can implement both video and metadata capture as
+specified in its reported capabilities.
+  
+
+  
+Querying Capabilities
+
+
+Devices supporting the metadata interface set the
+V4L2_CAP_META_CAPTURE flag in the
+capabilities field of 
+returned by the  ioctl. That flag means the device can capture
+metadata to memory.
+
+
+At least one of the read/write or streaming I/O methods must be supported.
+
+  
+
+  
+Data Format Negotiation
+
+
+The metadata device uses the format ioctls to
+select the capture format. The metadata buffer content format is bound to that
+selectable format. In addition to the basic
+format ioctls, the  ioctl
+must be supported as well.
+
+
+
+To use the format ioctls applications set the
+type field of a  to
+V4L2_BUF_TYPE_META_CAPTURE and use the 
+meta member of the fmt
+union as needed per the desired operation.
+Currently there are two fields, dataformat and
+buffersize, of struct  that are
+used. Content of the dataformat is the V4L2 FourCC
+code of the data format. The buffersize field is the
+maximum buffer size in bytes required for data transfer, set by the driver in
+order to inform applications.
+
+
+
+  struct v4l2_meta_format
+  
+
+
+  
+__u32
+dataformat
+
+The data format, set by the application. This is a little endian
+four character code.
+V4L2 defines metadata formats in .
+   
+  
+  
+__u32
+buffersize
+
+Maximum size in bytes required for data. Value is set by the driver.
+   
+  
+  
+__u8
+reserved[24]
+This array is reserved for future extensions.
+Drivers and applications must set it to zero.
+  
+
+  
+
+
+  
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml 
b/Documentation/DocBook/media/v4l/v4l2.xml
index 42e626d6c936..5c83b5d342dd 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -605,6 +605,7 @@ and discussions on the V4L mailing list.
   
   
   
+  
   
   
   
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c 
b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index bacecbd68a6d..da2d836e8887 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -161,6 +161,20 @@ static inline int put_v4l2_sdr_format(struct 
v4l2_sdr_format *kp, struct v4l2_sd
return 0;
 }
 
+static inline int get_v4l2_meta_format(struct v4l2_meta_format *kp, struct 
v4l2_meta_format __user *up)
+{
+   if (copy_from_user(kp, up, sizeof(struct v4l2_meta_format)))
+   return -EFAULT;
+   return 0;
+}
+
+static inline int put_v4l2_meta_format(struct v4l2_meta_format *kp, struct 
v4l2_meta_format __user *up)
+{
+   if (copy_to_user(up, kp, sizeof(struct v4l2_meta_format)))
+   return -EFAULT;
+   return 0;
+}
+
 struct v4l2_format32 {
__u32   type;   /* enum v4l2_buf_type */
union {
@@ -170,6 +184,7 @@ struct v4l2_format32 {
struct v4l2_vbi_format  vbi;
struct v4l2_sliced_vbi_format   sliced;
struct v4l2_sdr_format  sdr;
+   

[PATCH/RFC v2 0/4] Meta-data video device type

2016-05-11 Thread Laurent Pinchart
Hello,

This RFC patch series is a second attempt at adding support for passing
statistics data to userspace using a standard API.

The core requirements haven't changed. Statistics data capture requires
zero-copy and decoupling statistics buffers from images buffers, in order to
make statistics data available to userspace as soon as they're captured. For
those reasons the early consensus we have reached is to use a video device
node with a buffer queue to pass statistics buffers using the V4L2 API, and
this new RFC version doesn't challenge that.

The major change compared to the previous version is how the first patch has
been split in two. Patch 1/4 now adds a new metadata buffer type and format
(including their support in videobuf2-v4l2), usable with regular V4L2 video
device nodes, while patch 2/4 adds the new metadata video device type.
Metadata buffer queues are thus usable on both the regular V4L2 device nodes
and the new metadata device nodes.

This change was driven by the fact that an important category of use cases
doesn't differentiate between metadata and image data in hardware at the DMA
engine level. With such hardware (CSI-2 receivers in particular, but other bus
types could also fall into this category) a stream containing both metadata
and image data virtual streams is transmitted over a single physical link. The
receiver demultiplexes, filters and routes the virtual streams to further
hardware blocks, and in many cases, directly to DMA engines that are part of
the receiver. Those DMA engines can capture a single virtual stream to memory,
with as many DMA engines physically present in the device as the number of
virtual streams that can be captured concurrently. All those DMA engines are
usually identical and don't care about the type of data they receive and
capture. For that reason limiting the metadata buffer type to metadata device
nodes would require creating two device nodes for each DMA engine (and
possibly more later if we need to capture other types of data). Not only would
this make the API more complex to use for applications, it wouldn't bring any
added value as the video and metadata device nodes associated with a DMA
engine couldn't be used concurrently anyway, as they both correspond to the
same hardware resource.

For this reason the ability to capture metadata on a video device node is
useful and desired, and is implemented patch 1/4 using a dedicated video
buffers queue. In the CSI-2 case a driver will create two buffer queues
internally for the same DMA engine, and can select which one to use based on
the buffer type passed for instance to the REQBUFS ioctl (details still need
to be discussed here). A device that contains DMA engines dedicated to
metadata would create a single buffer queue and implement metadata capture
only.

Patch 2/4 then adds a dedicated metadata device node type that is limited to
metadata capture. Support for metadata on video device nodes isn't removed
though, both device node types support metadata capture. I have included this
patch as the code existed in the previous version of the series (and was
explicitly requested during review of an earlier version), but I don't really
see what value this would bring compared to just using video device nodes.

As before patch 3/4 defines a first metadata format for the R-Car VSP1 1-D
statistics format as an example, and the new patch 4/4 adds support for the
histogram engine to the VSP1 driver. The implementation uses a metadata device
node, and switching to a video device node wouldn't require more than applying
the following one-liner patch.

-   histo->queue.type = V4L2_BUF_TYPE_META_CAPTURE;
+   histo->queue.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

Beside whether patch 2/4 should be included or not (I would prefer dropping
it) and how to select the active queue on a multi-type video device node
(through the REQBUFS ioctl or through a diffent mean), one point that remains
to be discussed is what information to include in the metadata format. Patch
1/1 defines the new metadata format as

struct v4l2_meta_format {
__u32   dataformat;
__u32   buffersize;
__u8reserved[24];
} __attribute__ ((packed));

but at least in the CSI-2 case metadata is, as image data, transmitted in
lines and the receiver needs to be programmed with the line length and the
number of lines for proper operation. We started discussing this on IRC but
haven't reached a conclusion yet.

Laurent Pinchart (4):
  v4l: Add metadata buffer type and format
  v4l: Add metadata video device type
  v4l: Define a pixel format for the R-Car VSP1 1-D histogram engine
  v4l: vsp1: Add HGO support

 Documentation/DocBook/media/v4l/dev-meta.xml   |  97 
 .../DocBook/media/v4l/pixfmt-meta-vsp1-hgo.xml | 307 +
 Documentation/DocBook/media/v4l/pixfmt.xml |   9 +
 Documentation/DocBook/media/v4l/v4l2.xml   |   1 

Re: Patch: V4L stable versions 4.5.3 and 4.5.4

2016-05-11 Thread Sakari Ailus
Hi Mauro and David,

On Wed, May 11, 2016 at 05:38:23PM -0300, Mauro Carvalho Chehab wrote:
> Hi David,
> 
> Em Wed, 11 May 2016 20:05:22 +0100
> David R  escreveu:
> 
> > On 11/05/16 19:47, David R wrote:
> > > Hi
> > > 
> > > Please consider applying the attached patch (or something like it) to
> > > V4L2, and whatever is appropriate to the mainstream kernel. Without this
> > > my media server crashes and burns at boot.
> > > 
> > > See https://lkml.org/lkml/2016/5/7/88 for more details
> > > 
> > > Thanks
> > > David
> > >   
> > I see the offending patch was reverted earlier today. My box is fine
> > with my (more simple) alternative, but your call.
> 
> Yes, I noticed the bug earlier today, while testing a DVB device.
> As this affects 2 stable releases plus the upcoming Kernel 4.6,
> I decided to just revert it for now, while we don't solve the
> issue.
> 
> Your patch looks good. So, eventually it will be merged on a new
> version of this patch, after we test it properly.

Indeed vb2_core_dqbuf() is called with pb == NULL in file I/O, which was
unfortunately missed until now.

The proposed fix looks good to me.

-- 
Kind regards,

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


Re: Patch: V4L stable versions 4.5.3 and 4.5.4

2016-05-11 Thread Mauro Carvalho Chehab
Hi David,

Em Wed, 11 May 2016 20:05:22 +0100
David R  escreveu:

> On 11/05/16 19:47, David R wrote:
> > Hi
> > 
> > Please consider applying the attached patch (or something like it) to
> > V4L2, and whatever is appropriate to the mainstream kernel. Without this
> > my media server crashes and burns at boot.
> > 
> > See https://lkml.org/lkml/2016/5/7/88 for more details
> > 
> > Thanks
> > David
> >   
> I see the offending patch was reverted earlier today. My box is fine
> with my (more simple) alternative, but your call.

Yes, I noticed the bug earlier today, while testing a DVB device.
As this affects 2 stable releases plus the upcoming Kernel 4.6,
I decided to just revert it for now, while we don't solve the
issue.

Your patch looks good. So, eventually it will be merged on a new
version of this patch, after we test it properly.

Thanks!
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: Patch: V4L stable versions 4.5.3 and 4.5.4

2016-05-11 Thread David R
On 11/05/16 19:47, David R wrote:
> Hi
> 
> Please consider applying the attached patch (or something like it) to
> V4L2, and whatever is appropriate to the mainstream kernel. Without this
> my media server crashes and burns at boot.
> 
> See https://lkml.org/lkml/2016/5/7/88 for more details
> 
> Thanks
> David
> 
I see the offending patch was reverted earlier today. My box is fine
with my (more simple) alternative, but your call.

David
--
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 stable versions 4.5.3 and 4.5.4

2016-05-11 Thread David R
Hi

Please consider applying the attached patch (or something like it) to
V4L2, and whatever is appropriate to the mainstream kernel. Without this
my media server crashes and burns at boot.

See https://lkml.org/lkml/2016/5/7/88 for more details

Thanks
David
--- drivers/media/v4l2-core/videobuf2-core.c.old	2016-05-11 18:44:50.917083559 +0100
+++ drivers/media/v4l2-core/videobuf2-core.c	2016-05-11 18:45:10.136184837 +0100
@@ -1665,7 +1665,7 @@ static int __vb2_get_done_vb(struct vb2_
 	 * Only remove the buffer from done_list if v4l2_buffer can handle all
 	 * the planes.
 	 */
-	ret = call_bufop(q, verify_planes_array, *vb, pb);
+	ret = pb ? call_bufop(q, verify_planes_array, *vb, pb) : 0;
 	if (!ret)
 		list_del(&(*vb)->done_entry);
 	spin_unlock_irqrestore(>done_lock, flags);


[PATCH v2] media: dvb_ringbuffer: Add memory barriers

2016-05-11 Thread Soeren Moch
Implement memory barriers according to Documentation/circular-buffers.txt:
- use smp_store_release() to update ringbuffer read/write pointers
- use smp_load_acquire() to load write pointer on reader side
- use ACCESS_ONCE() to load read pointer on writer side

This fixes data stream corruptions observed e.g. on an ARM Cortex-A9
quad core system with different types (PCI, USB) of DVB tuners.

Signed-off-by: Soeren Moch 
Cc: sta...@vger.kernel.org # 3.14+
---
Cc: Mauro Carvalho Chehab 
Cc: linux-media@vger.kernel.org
Cc: linux-ker...@vger.kernel.org

Since smp_store_release() and smp_load_acquire() were introduced in linux-3.14,
a 3.14+ stable tag was added. Is it desired to apply a similar patch to older
stable kernels?

changes in v2:
- add comments for smp_store_release() and smp_load_acquire() calls
  to avoid checkpatch warnings
---
 drivers/media/dvb-core/dvb_ringbuffer.c | 74 +++--
 1 file changed, 61 insertions(+), 13 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ringbuffer.c 
b/drivers/media/dvb-core/dvb_ringbuffer.c
index 1100e98..7df7fb3 100644
--- a/drivers/media/dvb-core/dvb_ringbuffer.c
+++ b/drivers/media/dvb-core/dvb_ringbuffer.c
@@ -55,7 +55,13 @@ void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void 
*data, size_t len)
 
 int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf)
 {
-   return (rbuf->pread==rbuf->pwrite);
+   /* smp_load_acquire() to load write pointer on reader side
+* this pairs with smp_store_release() in dvb_ringbuffer_write(),
+* dvb_ringbuffer_write_user(), or dvb_ringbuffer_reset()
+*
+* for memory barriers also see Documentation/circular-buffers.txt
+*/
+   return (rbuf->pread == smp_load_acquire(>pwrite));
 }
 
 
@@ -64,7 +70,12 @@ ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf)
 {
ssize_t free;
 
-   free = rbuf->pread - rbuf->pwrite;
+   /* ACCESS_ONCE() to load read pointer on writer side
+* this pairs with smp_store_release() in dvb_ringbuffer_read(),
+* dvb_ringbuffer_read_user(), dvb_ringbuffer_flush(),
+* or dvb_ringbuffer_reset()
+*/
+   free = ACCESS_ONCE(rbuf->pread) - rbuf->pwrite;
if (free <= 0)
free += rbuf->size;
return free-1;
@@ -76,7 +87,11 @@ ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf)
 {
ssize_t avail;
 
-   avail = rbuf->pwrite - rbuf->pread;
+   /* smp_load_acquire() to load write pointer on reader side
+* this pairs with smp_store_release() in dvb_ringbuffer_write(),
+* dvb_ringbuffer_write_user(), or dvb_ringbuffer_reset()
+*/
+   avail = smp_load_acquire(>pwrite) - rbuf->pread;
if (avail < 0)
avail += rbuf->size;
return avail;
@@ -86,14 +101,25 @@ ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf)
 
 void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf)
 {
-   rbuf->pread = rbuf->pwrite;
+   /* dvb_ringbuffer_flush() counts as read operation
+* smp_load_acquire() to load write pointer
+* smp_store_release() to update read pointer, this ensures that the
+* correct pointer is visible for subsequent dvb_ringbuffer_free()
+* calls on other cpu cores
+*/
+   smp_store_release(>pread, smp_load_acquire(>pwrite));
rbuf->error = 0;
 }
 EXPORT_SYMBOL(dvb_ringbuffer_flush);
 
 void dvb_ringbuffer_reset(struct dvb_ringbuffer *rbuf)
 {
-   rbuf->pread = rbuf->pwrite = 0;
+   /* dvb_ringbuffer_reset() counts as read and write operation
+* smp_store_release() to update read pointer
+*/
+   smp_store_release(>pread, 0);
+   /* smp_store_release() to update write pointer */
+   smp_store_release(>pwrite, 0);
rbuf->error = 0;
 }
 
@@ -119,12 +145,17 @@ ssize_t dvb_ringbuffer_read_user(struct dvb_ringbuffer 
*rbuf, u8 __user *buf, si
return -EFAULT;
buf += split;
todo -= split;
-   rbuf->pread = 0;
+   /* smp_store_release() for read pointer update to ensure
+* that buf is not overwritten until read is complete,
+* this pairs with ACCESS_ONCE() in dvb_ringbuffer_free()
+*/
+   smp_store_release(>pread, 0);
}
if (copy_to_user(buf, rbuf->data+rbuf->pread, todo))
return -EFAULT;
 
-   rbuf->pread = (rbuf->pread + todo) % rbuf->size;
+   /* smp_store_release() to update read pointer, see above */
+   smp_store_release(>pread, (rbuf->pread + todo) % rbuf->size);
 
return len;
 }
@@ -139,11 +170,16 @@ void dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 
*buf, size_t len)
memcpy(buf, rbuf->data+rbuf->pread, split);
buf += split;
todo -= split;
-   rbuf->pread = 0;
+   /* 

Re: [PATCH] [media] v4l2-async: Always unregister the subdev on failure

2016-05-11 Thread Alban Bedel
On Wed, 11 May 2016 12:22:44 -0400
Javier Martinez Canillas  wrote:

> Hello Alban,
> 
> On 05/11/2016 11:40 AM, Alban Bedel wrote:
> > In v4l2_async_test_notify() if the registered_async callback or the
> > complete notifier returns an error the subdev is not unregistered.
> > This leave paths where v4l2_async_register_subdev() can fail but
> > leave the subdev still registered.
> > 
> > Add the required calls to v4l2_device_unregister_subdev() to plug
> > these holes.
> > 
> > Signed-off-by: Alban Bedel 
> > ---
> >  drivers/media/v4l2-core/v4l2-async.c | 10 --
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-async.c 
> > b/drivers/media/v4l2-core/v4l2-async.c
> > index ceb28d4..43393f8 100644
> > --- a/drivers/media/v4l2-core/v4l2-async.c
> > +++ b/drivers/media/v4l2-core/v4l2-async.c
> > @@ -121,13 +121,19 @@ static int v4l2_async_test_notify(struct 
> > v4l2_async_notifier *notifier,
> >  
> > ret = v4l2_subdev_call(sd, core, registered_async);
> > if (ret < 0 && ret != -ENOIOCTLCMD) {
> > +   v4l2_device_unregister_subdev(sd);
> > if (notifier->unbind)
> > notifier->unbind(notifier, sd, asd);
> > return ret;
> > }
> >  
> > -   if (list_empty(>waiting) && notifier->complete)
> > -   return notifier->complete(notifier);
> > +   if (list_empty(>waiting) && notifier->complete) {
> > +   ret = notifier->complete(notifier);
> > +   if (ret < 0) {
> > +   v4l2_device_unregister_subdev(sd);
> 
> Isn't a call to notifier->unbind() missing here as well?
> 
> Also, I think the error path is becoming too duplicated and complex, so
> maybe we can have a single error path and use goto labels as is common
> in Linux? For example something like the following (not tested) can be
> squashed on top of your change:

Yes, that look better. I'll test it and report tomorrow.

Alban


signature.asc
Description: PGP signature


[PATCH] Revert "[media] videobuf2-v4l2: Verify planes array in buffer dequeueing"

2016-05-11 Thread Mauro Carvalho Chehab
This patch causes a Kernel panic when called on a DVB driver.

This reverts commit 2c1f6951a8a82e6de0d82b1158b5e493fc6c54ab.

Cc: Sakari Ailus 
Cc: Hans Verkuil 
Cc: sta...@vgar.kernel.org
Fixes: 2c1f6951a8a8 ("[media] videobuf2-v4l2: Verify planes array in buffer 
dequeueing")
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/v4l2-core/videobuf2-v4l2.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c 
b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 7f366f1b0377..0b1b8c7b6ce5 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -74,11 +74,6 @@ static int __verify_planes_array(struct vb2_buffer *vb, 
const struct v4l2_buffer
return 0;
 }
 
-static int __verify_planes_array_core(struct vb2_buffer *vb, const void *pb)
-{
-   return __verify_planes_array(vb, pb);
-}
-
 /**
  * __verify_length() - Verify that the bytesused value for each plane fits in
  * the plane length and that the data offset doesn't exceed the bytesused 
value.
@@ -442,7 +437,6 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
 }
 
 static const struct vb2_buf_ops v4l2_buf_ops = {
-   .verify_planes_array= __verify_planes_array_core,
.fill_user_buffer   = __fill_v4l2_buffer,
.fill_vb2_buffer= __fill_vb2_buffer,
.copy_timestamp = __copy_timestamp,
-- 
2.5.5

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


Re: [PATCH] [media] v4l2-async: Always unregister the subdev on failure

2016-05-11 Thread Javier Martinez Canillas
Hello Alban,

On 05/11/2016 11:40 AM, Alban Bedel wrote:
> In v4l2_async_test_notify() if the registered_async callback or the
> complete notifier returns an error the subdev is not unregistered.
> This leave paths where v4l2_async_register_subdev() can fail but
> leave the subdev still registered.
> 
> Add the required calls to v4l2_device_unregister_subdev() to plug
> these holes.
> 
> Signed-off-by: Alban Bedel 
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c 
> b/drivers/media/v4l2-core/v4l2-async.c
> index ceb28d4..43393f8 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -121,13 +121,19 @@ static int v4l2_async_test_notify(struct 
> v4l2_async_notifier *notifier,
>  
>   ret = v4l2_subdev_call(sd, core, registered_async);
>   if (ret < 0 && ret != -ENOIOCTLCMD) {
> + v4l2_device_unregister_subdev(sd);
>   if (notifier->unbind)
>   notifier->unbind(notifier, sd, asd);
>   return ret;
>   }
>  
> - if (list_empty(>waiting) && notifier->complete)
> - return notifier->complete(notifier);
> + if (list_empty(>waiting) && notifier->complete) {
> + ret = notifier->complete(notifier);
> + if (ret < 0) {
> + v4l2_device_unregister_subdev(sd);

Isn't a call to notifier->unbind() missing here as well?

Also, I think the error path is becoming too duplicated and complex, so
maybe we can have a single error path and use goto labels as is common
in Linux? For example something like the following (not tested) can be
squashed on top of your change:

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 43393f8c1312..abe512d0b4cb 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -113,29 +113,28 @@ static int v4l2_async_test_notify(struct 
v4l2_async_notifier *notifier,
list_move(>async_list, >done);
 
ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
-   if (ret < 0) {
-   if (notifier->unbind)
-   notifier->unbind(notifier, sd, asd);
-   return ret;
-   }
+   if (ret < 0)
+   goto err_subdev_register;
 
ret = v4l2_subdev_call(sd, core, registered_async);
-   if (ret < 0 && ret != -ENOIOCTLCMD) {
-   v4l2_device_unregister_subdev(sd);
-   if (notifier->unbind)
-   notifier->unbind(notifier, sd, asd);
-   return ret;
-   }
+   if (ret < 0 && ret != -ENOIOCTLCMD)
+   goto err_subdev_call;
 
if (list_empty(>waiting) && notifier->complete) {
ret = notifier->complete(notifier);
-   if (ret < 0) {
-   v4l2_device_unregister_subdev(sd);
-   return ret;
-   }
+   if (ret < 0)
+   goto err_subdev_call;
}
 
return 0;
+
+err_subdev_call:
+   v4l2_device_unregister_subdev(sd);
+err_subdev_register:
+   if (notifier->unbind)
+   notifier->unbind(notifier, sd, asd);
+
+   return ret;
 }
 
 static void v4l2_async_cleanup(struct v4l2_subdev *sd)

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] v4l2-async: Always unregister the subdev on failure

2016-05-11 Thread Alban Bedel
In v4l2_async_test_notify() if the registered_async callback or the
complete notifier returns an error the subdev is not unregistered.
This leave paths where v4l2_async_register_subdev() can fail but
leave the subdev still registered.

Add the required calls to v4l2_device_unregister_subdev() to plug
these holes.

Signed-off-by: Alban Bedel 
---
 drivers/media/v4l2-core/v4l2-async.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index ceb28d4..43393f8 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -121,13 +121,19 @@ static int v4l2_async_test_notify(struct 
v4l2_async_notifier *notifier,
 
ret = v4l2_subdev_call(sd, core, registered_async);
if (ret < 0 && ret != -ENOIOCTLCMD) {
+   v4l2_device_unregister_subdev(sd);
if (notifier->unbind)
notifier->unbind(notifier, sd, asd);
return ret;
}
 
-   if (list_empty(>waiting) && notifier->complete)
-   return notifier->complete(notifier);
+   if (list_empty(>waiting) && notifier->complete) {
+   ret = notifier->complete(notifier);
+   if (ret < 0) {
+   v4l2_device_unregister_subdev(sd);
+   return ret;
+   }
+   }
 
return 0;
 }
-- 
2.8.2

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


Re: [PATCH 4/7] [media] ir-rx51: add DT support to driver

2016-05-11 Thread Rob Herring
On Tue, May 10, 2016 at 04:18:27AM +0200, Sebastian Reichel wrote:
> Hi,
> 
> On Mon, May 09, 2016 at 04:07:35PM -0500, Rob Herring wrote:
> > There's already a pwm-led binding that can be used. Though there
> > may be missing consumer IR to LED subsystem support in the kernel.
> > You could list both compatibles, use the rx51 IR driver now, and
> > then move to pwm-led driver in the future.
> 
> Well from a purely HW point of view it's a PWM connected led. The
> usage is completely different though. Usually PWM is used to control
> the LED's brightness via the duty cycle (basic concept: enabling led
> only 50% of time reduces brightness to 50%).
> 
> In the IR led's case the aim is generating a specific serial pattern
> instead. For this task it uses a dmtimer in PWM mode and a second
> one to reconfigure the pwm timer.

In that case, it will probably never be a generic driver.

> I don't know about a good name, but rx51 should be replaced with
> n900 in the compatible string. So maybe "nokia,n900-infrared-diode".

That's fine, but the shorter '-ir' was too.

Rob
--
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 v4 5/8] media: rcar-vin: add DV timings support

2016-05-11 Thread Ulrich Hecht
Adds ioctls DV_TIMINGS_CAP, ENUM_DV_TIMINGS, G_DV_TIMINGS, S_DV_TIMINGS,
and QUERY_DV_TIMINGS.

Signed-off-by: Ulrich Hecht 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 82 +
 1 file changed, 82 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 3788f8a..10a5c10 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -400,6 +400,10 @@ static int rvin_enum_input(struct file *file, void *priv,
 
i->type = V4L2_INPUT_TYPE_CAMERA;
i->std = vin->vdev.tvnorms;
+
+   if (v4l2_subdev_has_op(sd, pad, dv_timings_cap))
+   i->capabilities = V4L2_IN_CAP_DV_TIMINGS;
+
strlcpy(i->name, "Camera", sizeof(i->name));
 
return 0;
@@ -478,6 +482,78 @@ static int rvin_subscribe_event(struct v4l2_fh *fh,
return v4l2_ctrl_subscribe_event(fh, sub);
 }
 
+static int rvin_enum_dv_timings(struct file *file, void *priv_fh,
+   struct v4l2_enum_dv_timings *timings)
+{
+   struct rvin_dev *vin = video_drvdata(file);
+   struct v4l2_subdev *sd = vin_to_source(vin);
+   int pad, ret;
+
+   pad = timings->pad;
+   timings->pad = vin->src_pad_idx;
+
+   ret = v4l2_subdev_call(sd, pad, enum_dv_timings, timings);
+
+   timings->pad = pad;
+
+   return ret;
+}
+
+static int rvin_s_dv_timings(struct file *file, void *priv_fh,
+   struct v4l2_dv_timings *timings)
+{
+   struct rvin_dev *vin = video_drvdata(file);
+   struct v4l2_subdev *sd = vin_to_source(vin);
+   int err;
+
+   err = v4l2_subdev_call(sd,
+   video, s_dv_timings, timings);
+   if (!err) {
+   vin->source.width = timings->bt.width;
+   vin->source.height = timings->bt.height;
+   vin->format.width = timings->bt.width;
+   vin->format.height = timings->bt.height;
+   }
+   return err;
+}
+
+static int rvin_g_dv_timings(struct file *file, void *priv_fh,
+   struct v4l2_dv_timings *timings)
+{
+   struct rvin_dev *vin = video_drvdata(file);
+   struct v4l2_subdev *sd = vin_to_source(vin);
+
+   return v4l2_subdev_call(sd,
+   video, g_dv_timings, timings);
+}
+
+static int rvin_query_dv_timings(struct file *file, void *priv_fh,
+   struct v4l2_dv_timings *timings)
+{
+   struct rvin_dev *vin = video_drvdata(file);
+   struct v4l2_subdev *sd = vin_to_source(vin);
+
+   return v4l2_subdev_call(sd,
+   video, query_dv_timings, timings);
+}
+
+static int rvin_dv_timings_cap(struct file *file, void *priv_fh,
+   struct v4l2_dv_timings_cap *cap)
+{
+   struct rvin_dev *vin = video_drvdata(file);
+   struct v4l2_subdev *sd = vin_to_source(vin);
+   int pad, ret;
+
+   pad = cap->pad;
+   cap->pad = vin->src_pad_idx;
+
+   ret = v4l2_subdev_call(sd, pad, dv_timings_cap, cap);
+
+   cap->pad = pad;
+
+   return ret;
+}
+
 static const struct v4l2_ioctl_ops rvin_ioctl_ops = {
.vidioc_querycap= rvin_querycap,
.vidioc_try_fmt_vid_cap = rvin_try_fmt_vid_cap,
@@ -494,6 +570,12 @@ static const struct v4l2_ioctl_ops rvin_ioctl_ops = {
.vidioc_g_input = rvin_g_input,
.vidioc_s_input = rvin_s_input,
 
+   .vidioc_dv_timings_cap  = rvin_dv_timings_cap,
+   .vidioc_enum_dv_timings = rvin_enum_dv_timings,
+   .vidioc_g_dv_timings= rvin_g_dv_timings,
+   .vidioc_s_dv_timings= rvin_s_dv_timings,
+   .vidioc_query_dv_timings= rvin_query_dv_timings,
+
.vidioc_querystd= rvin_querystd,
.vidioc_g_std   = rvin_g_std,
.vidioc_s_std   = rvin_s_std,
-- 
2.7.4

--
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 v4 1/8] v4l: subdev: Add pad config allocator and init

2016-05-11 Thread Ulrich Hecht
From: Laurent Pinchart 

Add a new subdev operation to initialize a subdev pad config array, and
a helper function to allocate and initialize the array. This can be used
by bridge drivers to implement try format based on subdev pad
operations.

Signed-off-by: Laurent Pinchart 
Acked-by: Vaibhav Hiremath 
Acked-by: Hans Verkuil 
---
 drivers/media/v4l2-core/v4l2-subdev.c | 19 ++-
 include/media/v4l2-subdev.h   | 10 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index d630838..f32ac0d 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -35,7 +35,7 @@
 static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 {
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-   fh->pad = kzalloc(sizeof(*fh->pad) * sd->entity.num_pads, GFP_KERNEL);
+   fh->pad = v4l2_subdev_alloc_pad_config(sd);
if (fh->pad == NULL)
return -ENOMEM;
 #endif
@@ -569,6 +569,23 @@ int v4l2_subdev_link_validate(struct media_link *link)
sink, link, _fmt, _fmt);
 }
 EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev 
*sd)
+{
+   struct v4l2_subdev_pad_config *cfg;
+
+   if (!sd->entity.num_pads)
+   return NULL;
+
+   cfg = kcalloc(sd->entity.num_pads, sizeof(*cfg), GFP_KERNEL);
+   if (!cfg)
+   return NULL;
+
+   v4l2_subdev_call(sd, pad, init_cfg, cfg);
+
+   return cfg;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
 #endif /* CONFIG_MEDIA_CONTROLLER */
 
 void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops 
*ops)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 11e2dfe..6c47cdd 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -607,6 +607,8 @@ struct v4l2_subdev_pad_config {
  *  may be adjusted by the subdev driver to device 
capabilities.
  */
 struct v4l2_subdev_pad_ops {
+   void (*init_cfg)(struct v4l2_subdev *sd,
+struct v4l2_subdev_pad_config *cfg);
int (*enum_mbus_code)(struct v4l2_subdev *sd,
  struct v4l2_subdev_pad_config *cfg,
  struct v4l2_subdev_mbus_code_enum *code);
@@ -801,7 +803,15 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev 
*sd,
  struct v4l2_subdev_format *source_fmt,
  struct v4l2_subdev_format *sink_fmt);
 int v4l2_subdev_link_validate(struct media_link *link);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev 
*sd);
+
+static inline void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config 
*cfg)
+{
+   kfree(cfg);
+}
 #endif /* CONFIG_MEDIA_CONTROLLER */
+
 void v4l2_subdev_init(struct v4l2_subdev *sd,
  const struct v4l2_subdev_ops *ops);
 
-- 
2.7.4

--
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 v4 7/8] ARM: dts: lager: Add entries for VIN HDMI input support

2016-05-11 Thread Ulrich Hecht
From: William Towle 

Add DT entries for vin0, vin0_pins, and adv7612.

Sets the 'default-input' property for ADV7612, enabling image and video
capture without the need to have userspace specifying routing.

Signed-off-by: William Towle 
Signed-off-by: Rob Taylor 
[uli: added interrupt, renamed endpoint, merged default-input]
Signed-off-by: Ulrich Hecht 
---
 arch/arm/boot/dts/r8a7790-lager.dts | 39 +
 1 file changed, 39 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 749ba02..7e53f5c 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -427,6 +427,11 @@
function = "usb2";
};
 
+   vin0_pins: vin0 {
+   groups = "vin0_data24", "vin0_sync", "vin0_clkenb", "vin0_clk";
+   function = "vin0";
+   };
+
vin1_pins: vin {
groups = "vin1_data8", "vin1_clk";
function = "vin1";
@@ -607,6 +612,21 @@
reg = <0x12>;
};
 
+   hdmi-in@4c {
+   compatible = "adi,adv7612";
+   reg = <0x4c>;
+   interrupt-parent = <>;
+   interrupts = <20 IRQ_TYPE_LEVEL_LOW>;
+   remote = <>;
+   default-input = <0>;
+
+   port {
+   adv7612: endpoint {
+   remote-endpoint = <>;
+   };
+   };
+   };
+
composite-in@20 {
compatible = "adi,adv7180";
reg = <0x20>;
@@ -722,6 +742,25 @@
status = "okay";
 };
 
+/* HDMI video input */
+ {
+   pinctrl-0 = <_pins>;
+   pinctrl-names = "default";
+
+   status = "ok";
+
+   port {
+   vin0ep0: endpoint {
+   remote-endpoint = <>;
+   bus-width = <24>;
+   hsync-active = <0>;
+   vsync-active = <0>;
+   pclk-sample = <1>;
+   data-active = <1>;
+   };
+   };
+};
+
 /* composite video input */
  {
pinctrl-0 = <_pins>;
-- 
2.7.4

--
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 v4 8/8] r8a7791-koelsch.dts: add HDMI input

2016-05-11 Thread Ulrich Hecht
From: Hans Verkuil 

Add support in the dts for the HDMI input. Based on the Lager dts
patch from Ultich Hecht.

Signed-off-by: Hans Verkuil 
[uli: removed "renesas," prefixes from pfc nodes]
Signed-off-by: Ulrich Hecht 
---
 arch/arm/boot/dts/r8a7791-koelsch.dts | 41 +++
 1 file changed, 41 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts 
b/arch/arm/boot/dts/r8a7791-koelsch.dts
index da59c28..a96e3fa 100644
--- a/arch/arm/boot/dts/r8a7791-koelsch.dts
+++ b/arch/arm/boot/dts/r8a7791-koelsch.dts
@@ -393,6 +393,11 @@
function = "usb1";
};
 
+   vin0_pins: vin0 {
+   groups = "vin0_data24", "vin0_sync", "vin0_clkenb", "vin0_clk";
+   function = "vin0";
+   };
+
vin1_pins: vin1 {
groups = "vin1_data8", "vin1_clk";
function = "vin1";
@@ -551,6 +556,21 @@
reg = <0x12>;
};
 
+   hdmi-in@4c {
+   compatible = "adi,adv7612";
+   reg = <0x4c>;
+   interrupt-parent = <>;
+   interrupts = <20 IRQ_TYPE_LEVEL_LOW>;
+   remote = <>;
+   default-input = <0>;
+
+   port {
+   adv7612: endpoint {
+   remote-endpoint = <>;
+   };
+   };
+   };
+
composite-in@20 {
compatible = "adi,adv7180";
reg = <0x20>;
@@ -672,6 +692,27 @@
cpu0-supply = <_dvfs>;
 };
 
+/* HDMI video input */
+ {
+   status = "okay";
+   pinctrl-0 = <_pins>;
+   pinctrl-names = "default";
+
+   port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   vin0ep: endpoint {
+   remote-endpoint = <>;
+   bus-width = <24>;
+   hsync-active = <0>;
+   vsync-active = <0>;
+   pclk-sample = <1>;
+   data-active = <1>;
+   };
+   };
+};
+
 /* composite video input */
  {
status = "okay";
-- 
2.7.4

--
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 v4 3/8] media: rcar_vin: Use correct pad number in try_fmt

2016-05-11 Thread Ulrich Hecht
Fix rcar_vin_try_fmt's use of an inappropriate pad number when calling
the subdev set_fmt function - for the ADV7612, IDs should be non-zero.

Signed-off-by: William Towle 
Reviewed-by: Rob Taylor 
Acked-by: Hans Verkuil 
[uli: adapted to rcar-vin rewrite]
Signed-off-by: Ulrich Hecht 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 0bc4487..42dbd35 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -98,7 +98,7 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
struct rvin_source_fmt *source)
 {
struct v4l2_subdev *sd;
-   struct v4l2_subdev_pad_config pad_cfg;
+   struct v4l2_subdev_pad_config *pad_cfg;
struct v4l2_subdev_format format = {
.which = which,
};
@@ -108,10 +108,16 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
 
v4l2_fill_mbus_format(, pix, vin->source.code);
 
+   pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+   if (pad_cfg == NULL)
+   return -ENOMEM;
+
+   format.pad = vin->src_pad_idx;
+
ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, pad, set_fmt,
-_cfg, );
+pad_cfg, );
if (ret < 0)
-   return ret;
+   goto cleanup;
 
v4l2_fill_pix_format(pix, );
 
@@ -121,6 +127,8 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
vin_dbg(vin, "Source resolution: %ux%u\n", source->width,
source->height);
 
+cleanup:
+   v4l2_subdev_free_pad_config(pad_cfg);
return 0;
 }
 
-- 
2.7.4

--
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 v4 2/8] media: adv7604: automatic "default-input" selection

2016-05-11 Thread Ulrich Hecht
From: William Towle 

Add logic such that the "default-input" property becomes unnecessary
for chips that only have one suitable input (ADV7611 by design, and
ADV7612 due to commit 7111cddd518f ("[media] media: adv7604: reduce
support to first (digital) input").

Additionally, Ian's documentation in commit bf9c82278c34 ("[media]
media: adv7604: ability to read default input port from DT") states
that the "default-input" property should reside directly in the node
for adv7612. Hence, also adjust the parsing to make the implementation
consistent with this.

Signed-off-by: William Towle 
Signed-off-by: Ulrich Hecht 
---
 drivers/media/i2c/adv7604.c | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 41a1bfc..d722c16 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2788,7 +2788,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
struct device_node *np;
unsigned int flags;
int ret;
-   u32 v;
+   u32 v = -1;
 
np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node;
 
@@ -2810,6 +2810,22 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
 
of_node_put(endpoint);
 
+   if (of_property_read_u32(np, "default-input", )) {
+   /* not specified ... can we choose automatically? */
+   switch (state->info->type) {
+   case ADV7611:
+   v = 0;
+   break;
+   case ADV7612:
+   if (state->info->max_port == ADV76XX_PAD_HDMI_PORT_A)
+   v = 0;
+   /* else is unhobbled, leave unspecified */
+   default:
+   break;
+   }
+   }
+   state->pdata.default_input = v;
+
flags = bus_cfg.bus.parallel.flags;
 
if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
-- 
2.7.4

--
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 v4 4/8] media: rcar-vin: pad-aware driver initialisation

2016-05-11 Thread Ulrich Hecht
Add detection of source pad number for drivers aware of the media controller
API, so that rcar-vin can create device nodes to support modern drivers such
as adv7604.c (for HDMI on Lager) and the converted adv7180.c (for composite)
underneath.

Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in
line with requirements for building the drivers associated with it.

Signed-off-by: William Towle 
Signed-off-by: Rob Taylor 
[uli: adapted to rcar-vin rewrite]
Signed-off-by: Ulrich Hecht 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 16 
 drivers/media/platform/rcar-vin/rcar-vin.h  |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 42dbd35..3788f8a 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -691,6 +691,9 @@ int rvin_v4l2_probe(struct rvin_dev *vin)
struct v4l2_mbus_framefmt *mf = 
struct video_device *vdev = >vdev;
struct v4l2_subdev *sd = vin_to_source(vin);
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   int pad_idx;
+#endif
int ret;
 
v4l2_set_subdev_hostdata(sd, vin);
@@ -737,6 +740,19 @@ int rvin_v4l2_probe(struct rvin_dev *vin)
vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
V4L2_CAP_READWRITE;
 
+   vin->src_pad_idx = 0;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
+   if (sd->entity.pads[pad_idx].flags
+   == MEDIA_PAD_FL_SOURCE)
+   break;
+   if (pad_idx >= sd->entity.num_pads)
+   return -EINVAL;
+
+   vin->src_pad_idx = pad_idx;
+#endif
+   fmt.pad = vin->src_pad_idx;
+
/* Try to improve our guess of a reasonable window format */
ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, );
if (ret) {
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
b/drivers/media/platform/rcar-vin/rcar-vin.h
index 544a3b3..a6dd6db 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -87,6 +87,7 @@ struct rvin_graph_entity {
  *
  * @vdev:  V4L2 video device associated with VIN
  * @v4l2_dev:  V4L2 device
+ * @src_pad_idx:   source pad index for media controller drivers
  * @ctrl_handler:  V4L2 control handler
  * @notifier:  V4L2 asynchronous subdevs notifier
  * @entity:entity in the DT for subdevice
@@ -117,6 +118,7 @@ struct rvin_dev {
 
struct video_device vdev;
struct v4l2_device v4l2_dev;
+   int src_pad_idx;
struct v4l2_ctrl_handler ctrl_handler;
struct v4l2_async_notifier notifier;
struct rvin_graph_entity entity;
-- 
2.7.4

--
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 v4 6/8] media: rcar-vin: initialize EDID data

2016-05-11 Thread Ulrich Hecht
Initializes the decoder subdevice with a fixed EDID blob.

Signed-off-by: Ulrich Hecht 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 46 +
 1 file changed, 46 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 10a5c10..5bb3c3b 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -765,6 +765,41 @@ static void rvin_notify(struct v4l2_subdev *sd,
}
 }
 
+static u8 edid[256] = {
+   0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
+   0x48, 0xAE, 0x9C, 0x27, 0x00, 0x00, 0x00, 0x00,
+   0x19, 0x12, 0x01, 0x03, 0x80, 0x00, 0x00, 0x78,
+   0x0E, 0x00, 0xB2, 0xA0, 0x57, 0x49, 0x9B, 0x26,
+   0x10, 0x48, 0x4F, 0x2F, 0xCF, 0x00, 0x31, 0x59,
+   0x45, 0x59, 0x61, 0x59, 0x81, 0x99, 0x01, 0x01,
+   0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3A,
+   0x80, 0x18, 0x71, 0x38, 0x2D, 0x40, 0x58, 0x2C,
+   0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E,
+   0x00, 0x00, 0x00, 0xFD, 0x00, 0x31, 0x55, 0x18,
+   0x5E, 0x11, 0x00, 0x0A, 0x20, 0x20, 0x20, 0x20,
+   0x20, 0x20, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x43,
+   0x20, 0x39, 0x30, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
+   0x0A, 0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x00, 0x10,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x68,
+   0x02, 0x03, 0x1a, 0xc0, 0x48, 0xa2, 0x10, 0x04,
+   0x02, 0x01, 0x21, 0x14, 0x13, 0x23, 0x09, 0x07,
+   0x07, 0x65, 0x03, 0x0c, 0x00, 0x10, 0x00, 0xe2,
+   0x00, 0x2a, 0x01, 0x1d, 0x00, 0x80, 0x51, 0xd0,
+   0x1c, 0x20, 0x40, 0x80, 0x35, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x1e, 0x8c, 0x0a, 0xd0, 0x8a,
+   0x20, 0xe0, 0x2d, 0x10, 0x10, 0x3e, 0x96, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd7
+};
+
 int rvin_v4l2_probe(struct rvin_dev *vin)
 {
struct v4l2_subdev_format fmt = {
@@ -870,5 +905,16 @@ int rvin_v4l2_probe(struct rvin_dev *vin)
v4l2_info(>v4l2_dev, "Device registered as %s\n",
  video_device_node_name(>vdev));
 
+   {
+   struct v4l2_subdev_edid rvin_edid = {
+   .pad = 0,
+   .start_block = 0,
+   .blocks = 2,
+   .edid = edid,
+   };
+   v4l2_subdev_call(sd, pad, set_edid,
+   _edid);
+   }
+
return ret;
 }
-- 
2.7.4

--
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 v4 0/8] Lager/Koelsch board HDMI input support

2016-05-11 Thread Ulrich Hecht
Hi!

This series implements Lager/Koelsch HDMI input support on top of version 6
of Niklas's rcar-vin rewrite ("[PATCHv6] [media] rcar-vin: add Renesas R-Car
VIN driver").

This revision addresses the issues found in Hans Verkuil's review of the series
(except for the EDID intialization, which I have left in), and adds his Koelsch
support patch.

CU
Uli


Changes since v3:
- rvin_enum_dv_timings(): use vin->src_pad_idx
- rvin_dv_timings_cap(): likewise
- rvin_s_dv_timings(): update vin->format
- add Koelsch support

Changes since v2:
- rebased on top of rcar-vin driver v4
- removed "adv7604: fix SPA register location for ADV7612" (picked up)
- changed prefix of dts patch to "ARM: dts: lager: "


Hans Verkuil (1):
  r8a7791-koelsch.dts: add HDMI input

Laurent Pinchart (1):
  v4l: subdev: Add pad config allocator and init

Ulrich Hecht (4):
  media: rcar_vin: Use correct pad number in try_fmt
  media: rcar-vin: pad-aware driver initialisation
  media: rcar-vin: add DV timings support
  media: rcar-vin: initialize EDID data

William Towle (2):
  media: adv7604: automatic "default-input" selection
  ARM: dts: lager: Add entries for VIN HDMI input support

 arch/arm/boot/dts/r8a7790-lager.dts |  39 +++
 arch/arm/boot/dts/r8a7791-koelsch.dts   |  41 
 drivers/media/i2c/adv7604.c |  18 +++-
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 158 +++-
 drivers/media/platform/rcar-vin/rcar-vin.h  |   2 +
 drivers/media/v4l2-core/v4l2-subdev.c   |  19 +++-
 include/media/v4l2-subdev.h |  10 ++
 7 files changed, 282 insertions(+), 5 deletions(-)

-- 
2.7.4

--
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 RESEND^3] [media] staging/davinci_vfpe: allow modular build

2016-05-11 Thread Arnd Bergmann
It has never been possible to actually build this driver as
a loadable module, only built-in because the Makefile attempts
to build each file into its own module and fails:

ERROR: "mbus_to_pix" [drivers/staging/media/davinci_vpfe/vpfe_video.ko] 
undefined!
ERROR: "vpfe_resizer_register_entities" 
[drivers/staging/media/davinci_vpfe/vpfe_mc_capture.ko] undefined!
ERROR: "rsz_enable" [drivers/staging/media/davinci_vpfe/dm365_resizer.ko] 
undefined!
ERROR: "config_ipipe_hw" [drivers/staging/media/davinci_vpfe/dm365_ipipe.ko] 
undefined!
ERROR: "ipipe_set_lutdpc_regs" 
[drivers/staging/media/davinci_vpfe/dm365_ipipe.ko] undefined!

It took a long time to catch this bug with randconfig builds
because at least 14 other Kconfig symbols have to be enabled in
order to configure this one, and it was clearly only ever tested
as built-in with mainline kernels, if at all.

The solution is really easy: this patch changes the Makefile to
link all files into one module. As discussed previously, the
driver has never before used successfully as a loadable module,
but there is no reason to prevent that configuration.

Signed-off-by: Arnd Bergmann 
Link: http://lkml.iu.edu/hypermail/linux/kernel/1512.1/02383.html
---
I keep running into this bug roughly every 1 randconfig builds,
please apply the fix.

 drivers/staging/media/davinci_vpfe/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/davinci_vpfe/Makefile 
b/drivers/staging/media/davinci_vpfe/Makefile
index c64515c644cd..3019c9ecd548 100644
--- a/drivers/staging/media/davinci_vpfe/Makefile
+++ b/drivers/staging/media/davinci_vpfe/Makefile
@@ -1,3 +1,5 @@
-obj-$(CONFIG_VIDEO_DM365_VPFE) += \
+obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci-vfpe.o
+
+davinci-vfpe-objs := \
dm365_isif.o dm365_ipipe_hw.o dm365_ipipe.o \
dm365_resizer.o dm365_ipipeif.o vpfe_mc_capture.o vpfe_video.o
-- 
2.7.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


[GIT PULL FOR v4.7] Renesas VSP updates

2016-05-11 Thread Laurent Pinchart
Hi Mauro,

The following changes since commit aff093d4bbca91f543e24cde2135f393b8130f4b:

  [media] exynos-gsc: avoid build warning without CONFIG_OF (2016-05-09 
18:38:33 -0300)

are available in the git repository at:

  git://linuxtv.org/pinchartl/media.git vsp1/next

for you to fetch changes up to 01986b08a08353a23bc89a588a14966cb0a09e0d:

  v4l: vsp1: Remove deprecated DRM API (2016-05-11 16:07:44 +0300)

Please note that the pull request includes two patches for the rcar-du-drm 
driver. They depend on previous patches for the vsp1 driver in the same 
series, and the last vsp1 patch depends on them. For this reason I'm 
submitting everything in a single pull request to you, with Dave's ack to get 
the rcar-du-drm patches merged through your tree. They shouldn't conflict with 
anything queued in Dave's tree for v4.7.


Laurent Pinchart (13):
  dt-bindings: Add Renesas R-Car FCP DT bindings
  v4l: Add Renesas R-Car FCP driver
  v4l: vsp1: Implement runtime PM support
  v4l: vsp1: Don't handle clocks manually
  v4l: vsp1: Add FCP support
  v4l: vsp1: Add output node value to routing table
  v4l: vsp1: Replace container_of() with dedicated macro
  v4l: vsp1: Make vsp1_entity_get_pad_compose() more generic
  v4l: vsp1: Move frame sequence number from video node to pipeline
  v4l: vsp1: Group DRM RPF parameters in a structure
  drm: rcar-du: Add alpha support for VSP planes
  drm: rcar-du: Add Z-order support for VSP planes
  v4l: vsp1: Remove deprecated DRM API

 Documentation/devicetree/bindings/media/renesas,fcp.txt |  32 +
 .../devicetree/bindings/media/renesas,vsp1.txt  |   5 +

 MAINTAINERS |  10 ++   

 drivers/gpu/drm/rcar-du/rcar_du_vsp.c   |  45 +++---   

 drivers/gpu/drm/rcar-du/rcar_du_vsp.h   |   2 +

 drivers/media/platform/Kconfig  |  14 ++   

 drivers/media/platform/Makefile |   1 +

 drivers/media/platform/rcar-fcp.c   | 181 +++ 
 drivers/media/platform/vsp1/vsp1.h  |   6 +-   

 drivers/media/platform/vsp1/vsp1_drm.c  |  68 -

 drivers/media/platform/vsp1/vsp1_drv.c  | 120 +++  
   
 drivers/media/platform/vsp1/vsp1_entity.c   |  88  

 drivers/media/platform/vsp1/vsp1_entity.h   |  12 +-   

 drivers/media/platform/vsp1/vsp1_pipe.c |   4 +-   

 drivers/media/platform/vsp1/vsp1_pipe.h |   2 +

 drivers/media/platform/vsp1/vsp1_rpf.c  |   7 +-   

 drivers/media/platform/vsp1/vsp1_video.c|   4 +-   

 drivers/media/platform/vsp1/vsp1_video.h|   1 -

 include/media/rcar-fcp.h|  37 +

 include/media/vsp1.h|  29 ++--
 20 files changed, 497 insertions(+), 171 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,fcp.txt
 create mode 100644 drivers/media/platform/rcar-fcp.c
 create mode 100644 include/media/rcar-fcp.h

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH v2.1] dt-bindings: Add Renesas R-Car FCP DT bindings

2016-05-11 Thread Rob Herring
On Wed, May 11, 2016 at 03:36:30PM +0300, Laurent Pinchart wrote:
> The FCP is a companion module of video processing modules in the Renesas
> R-Car Gen3 SoCs. It provides data compression and decompression, data
> caching, and conversion of AXI transactions in order to reduce the
> memory bandwidth.
> 
> Signed-off-by: Laurent Pinchart 
> ---
>  .../devicetree/bindings/media/renesas,fcp.txt  | 32 
> ++
>  1 file changed, 32 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/renesas,fcp.txt

Acked-by: Rob Herring 
--
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 v2.1] dt-bindings: Add Renesas R-Car FCP DT bindings

2016-05-11 Thread Geert Uytterhoeven
On Wed, May 11, 2016 at 2:36 PM, Laurent Pinchart
 wrote:
> The FCP is a companion module of video processing modules in the Renesas
> R-Car Gen3 SoCs. It provides data compression and decompression, data
> caching, and conversion of AXI transactions in order to reduce the
> memory bandwidth.
>
> Signed-off-by: Laurent Pinchart 

Acked-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
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 v2.1] dt-bindings: Add Renesas R-Car FCP DT bindings

2016-05-11 Thread Laurent Pinchart
The FCP is a companion module of video processing modules in the Renesas
R-Car Gen3 SoCs. It provides data compression and decompression, data
caching, and conversion of AXI transactions in order to reduce the
memory bandwidth.

Signed-off-by: Laurent Pinchart 
---
 .../devicetree/bindings/media/renesas,fcp.txt  | 32 ++
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,fcp.txt

diff --git a/Documentation/devicetree/bindings/media/renesas,fcp.txt 
b/Documentation/devicetree/bindings/media/renesas,fcp.txt
new file mode 100644
index ..6a12960609d8
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/renesas,fcp.txt
@@ -0,0 +1,32 @@
+Renesas R-Car Frame Compression Processor (FCP)
+---
+
+The FCP is a companion module of video processing modules in the Renesas R-Car
+Gen3 SoCs. It provides data compression and decompression, data caching, and
+conversion of AXI transactions in order to reduce the memory bandwidth.
+
+There are three types of FCP: FCP for Codec (FCPC), FCP for VSP (FCPV) and FCP
+for FDP (FCPF). Their configuration and behaviour depend on the module they
+are paired with. These DT bindings currently support the FCPV only.
+
+ - compatible: Must be one or more of the following
+
+   - "renesas,r8a7795-fcpv" for R8A7795 (R-Car H3) compatible 'FCP for VSP'
+   - "renesas,fcpv" for generic compatible 'FCP for VSP'
+
+   When compatible with the generic version, nodes must list the
+   SoC-specific version corresponding to the platform first, followed by the
+   family-specific and/or generic versions.
+
+ - reg: the register base and size for the device registers
+ - clocks: Reference to the functional clock
+
+
+Device node example
+---
+
+   fcpvd1: fcp@fea2f000 {
+   compatible = "renesas,r8a7795-fcpv", "renesas,fcpv";
+   reg = <0 0xfea2f000 0 0x200>;
+   clocks = < CPG_MOD 602>;
+   };
-- 
Regards,

Laurent Pinchart

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


[patch V4 13/31] media: use parity8 in vivid-vbi-gen.c

2016-05-11 Thread zengzhaoxiu
From: Zhaoxiu Zeng 

Signed-off-by: Zhaoxiu Zeng 
---
 drivers/media/platform/vivid/vivid-vbi-gen.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-vbi-gen.c 
b/drivers/media/platform/vivid/vivid-vbi-gen.c
index a2159de..d5ba0fc 100644
--- a/drivers/media/platform/vivid/vivid-vbi-gen.c
+++ b/drivers/media/platform/vivid/vivid-vbi-gen.c
@@ -175,14 +175,9 @@ static const u8 vivid_cc_sequence2[30] = {
0x14, 0x2f, /* End of Caption */
 };
 
-static u8 calc_parity(u8 val)
+static inline u8 calc_parity(u8 val)
 {
-   unsigned i;
-   unsigned tot = 0;
-
-   for (i = 0; i < 7; i++)
-   tot += (val & (1 << i)) ? 1 : 0;
-   return val | ((tot & 1) ? 0 : 0x80);
+   return (!parity8(val) << 7) | val;
 }
 
 static void vivid_vbi_gen_set_time_of_day(u8 *packet)
-- 
2.7.4


--
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 v2] [media] v4l2-async: Pass the v4l2_async_subdev to the unbind callback

2016-05-11 Thread Alban Bedel
v4l2_async_cleanup() is always called before calling the unbind()
callback. However v4l2_async_cleanup() clears the asd member, so when
calling the unbind() callback the v4l2_async_subdev is always NULL. To
fix this save the asd before calling v4l2_async_cleanup().

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

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index a4b224d..ceb28d4 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -220,6 +220,7 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
list_del(>list);
 
list_for_each_entry_safe(sd, tmp, >done, async_list) {
+   struct v4l2_async_subdev *asd = sd->asd;
struct device *d;
 
d = get_device(sd->dev);
@@ -230,7 +231,7 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
device_release_driver(d);
 
if (notifier->unbind)
-   notifier->unbind(notifier, sd, sd->asd);
+   notifier->unbind(notifier, sd, asd);
 
/*
 * Store device at the device cache, in order to call
@@ -313,6 +314,7 @@ EXPORT_SYMBOL(v4l2_async_register_subdev);
 void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
 {
struct v4l2_async_notifier *notifier = sd->notifier;
+   struct v4l2_async_subdev *asd = sd->asd;
 
if (!sd->asd) {
if (!list_empty(>async_list))
@@ -327,7 +329,7 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
v4l2_async_cleanup(sd);
 
if (notifier->unbind)
-   notifier->unbind(notifier, sd, sd->asd);
+   notifier->unbind(notifier, sd, asd);
 
mutex_unlock(_lock);
 }
-- 
2.8.2

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


[patch V4 14/31] media: use parity functions in saa7115

2016-05-11 Thread zengzhaoxiu
From: Zhaoxiu Zeng 

Signed-off-by: Zhaoxiu Zeng 
---
 drivers/media/i2c/saa7115.c | 17 ++---
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index d2a1ce2..4c22df8 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -672,15 +672,6 @@ static const unsigned char saa7115_init_misc[] = {
0x00, 0x00
 };
 
-static int saa711x_odd_parity(u8 c)
-{
-   c ^= (c >> 4);
-   c ^= (c >> 2);
-   c ^= (c >> 1);
-
-   return c & 1;
-}
-
 static int saa711x_decode_vps(u8 *dst, u8 *p)
 {
static const u8 biphase_tbl[] = {
@@ -733,7 +724,6 @@ static int saa711x_decode_wss(u8 *p)
static const int wss_bits[8] = {
0, 0, 0, 1, 0, 1, 1, 1
};
-   unsigned char parity;
int wss = 0;
int i;
 
@@ -745,11 +735,8 @@ static int saa711x_decode_wss(u8 *p)
return -1;
wss |= b2 << i;
}
-   parity = wss & 15;
-   parity ^= parity >> 2;
-   parity ^= parity >> 1;
 
-   if (!(parity & 1))
+   if (!parity4(wss))
return -1;
 
return wss;
@@ -1235,7 +1222,7 @@ static int saa711x_decode_vbi_line(struct v4l2_subdev 
*sd, struct v4l2_decode_vb
vbi->type = V4L2_SLICED_TELETEXT_B;
break;
case 4:
-   if (!saa711x_odd_parity(p[0]) || !saa711x_odd_parity(p[1]))
+   if (!parity8(p[0]) || !parity8(p[1]))
return 0;
vbi->type = V4L2_SLICED_CAPTION_525;
break;
-- 
2.7.4


--
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 V4 00/31] bitops: add parity functions

2016-05-11 Thread zengzhaoxiu
From: Zhaoxiu Zeng 

When I do "grep parity -r linux", I found many parity calculations
distributed in many drivers.

This patch series does:
  1. provide generic and architecture-specific parity calculations
  2. remove drivers' local parity calculations, use bitops' parity
 functions instead
  3. replace "hweightN(x) & 1" with "parityN(x)" to improve readability,
 and improve performance on some CPUs that without popcount support

I did not use GCC's __builtin_parity* functions, based on the following reasons:
  1. I don't know where to identify which version of GCC from the beginning
 supported __builtin_parity for the architecture.
  2. For the architecture that doesn't has popcount instruction, GCC instead use
 "call __paritysi2" (__paritydi2 for 64-bits). So if use __builtin_parity, 
we must
 provide __paritysi2 and __paritydi2 functions for these architectures.
 Additionally, parity4,8,16 might be "__builtin_parity(x & mask)", but the 
"& mask"
 operation is totally unnecessary.
  3. For the architecture that has popcount instruction, we do the same things 
as GCC.
  4. For powerpc, sparc, and x86, we do runtime patching to use popcount 
instruction
 if the CPU support.

I have compiled successfully with x86_64_defconfig, i386_defconfig, 
pseries_defconfig
and sparc64_defconfig.

Changes to V3:
- Remove "odd" and "even" from documents. The function parityN returns whether 
an odd
  or even number of bits are on in a N-bit word, does not involve the 
definition of
  odd/even parity. Is it an odd or even parity checking, depends on the 
caller's context.
- Replace "hweightN(x) % 2" with "parityN(x)" in crypto/sahara.c and 
edac/amd64_edac.c
- Use PARITY_MAGIC instead of 0x6996 in powerpc's parity_64.S
- Use PARITY_MAGIC instead of 0x6996 in sparc's parity.S
- Pick up ACKs

Changes to v2:
- X86, remove custom calling convention, use inline asm
- Add constant PARITY_MAGIC (proposals by Sam Ravnborg)
- Add include/asm-generic/bitops/popc-parity.h (proposals by Chris Metcalf)
- Tile uses popc-parity.h directly
- Mips uses popc-parity.h if has usable __builtin_popcount
- Add few comments in powerpc's and sparc's parity.S

Changes to v1:
- Add runtime patching for powerpc, sparc, and x86
- Avr32 use grenric parity too
- Fix error in ssfdc's patch, and add commit message
- Don't change the original code composition of adxrs450.c
- Directly assignement to phy_cap.parity in drivers/scsi/isci/phy.c

Regards,

=== diffstat ===

Zhaoxiu Zeng (31):
  bitops: add parity functions
  bitops: Include generic parity.h in some architectures' bitops.h
  bitops: Add alpha-specific parity functions
  bitops: Add blackfin-specific parity functions
  bitops: Add ia-specific parity functions
  bitops: Tile and MIPS (if has usable __builtin_popcount) use popcount
parity functions
  bitops: Add powerpc-specific parity functions
  bitops: Add sparc-specific parity functions
  bitops: Add x86-specific parity functions
  sunrpc: use parity8
  mips: use parity functions in cerr-sb1.c
  lib: bch: use parity32
  media: use parity8 in vivid-vbi-gen.c
  media: use parity functions in saa7115
  input: use parity32 in grip_mp
  input: use parity64 in sidewinder
  input: use parity16 in ams_delta_serio
  scsi: use parity32 in isci's phy
  mtd: use parity16 in ssfdc
  mtd: use parity functions in inftlcore
  crypto: use parity functions in qat_hal
  mtd: use parity16 in sm_ftl
  ethernet: use parity8 in sun/niu.c
  input: use parity8 in pcips2
  input: use parity8 in saps2
  iio: use parity32 in adxrs450
  serial: use parity32 in max3100
  input: use parity8 in elantech
  ethernet: use parity8 in broadcom/tg3.c
  crypto: use parity_long is sahara.c
  edac: use parity8 in amd64_edac.c

 arch/alpha/include/asm/bitops.h  |  27 +
 arch/arc/include/asm/bitops.h|   1 +
 arch/arm/include/asm/bitops.h|   1 +
 arch/arm64/include/asm/bitops.h  |   1 +
 arch/avr32/include/asm/bitops.h  |   1 +
 arch/blackfin/include/asm/bitops.h   |  31 ++
 arch/c6x/include/asm/bitops.h|   1 +
 arch/cris/include/asm/bitops.h   |   1 +
 arch/frv/include/asm/bitops.h|   1 +
 arch/h8300/include/asm/bitops.h  |   1 +
 arch/hexagon/include/asm/bitops.h|   1 +
 arch/ia64/include/asm/bitops.h   |  31 ++
 arch/m32r/include/asm/bitops.h   |   1 +
 arch/m68k/include/asm/bitops.h   |   1 +
 arch/metag/include/asm/bitops.h  |   1 +
 arch/mips/include/asm/bitops.h   |   7 ++
 arch/mips/mm/cerr-sb1.c  |  67 -
 arch/mn10300/include/asm/bitops.h|   1 +
 arch/openrisc/include/asm/bitops.h   |   1 +
 arch/parisc/include/asm/bitops.h |   1 +
 arch/powerpc/include/asm/bitops.h|  11 +++
 arch/powerpc/lib/Makefile|   2 

[PATCH] [media] vcodec: mediatek: fix sparse warning

2016-05-11 Thread Tiffany Lin
This patch fix sparse warning when running with parameters:
C=2 CF="-D__CHECK_ENDIAN__"

Signed-off-by: Tiffany Lin 
Signed-off-by: PoChun Lin 
---
 .../media/platform/mtk-vcodec/venc/venc_vp8_if.c   |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c 
b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
index 431ae70..5b4ef0f 100644
--- a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
@@ -252,13 +252,18 @@ static int vp8_enc_compose_one_frame(struct venc_vp8_inst 
*inst,
u32 bs_hdr_len;
unsigned int ac_tag_size;
u8 ac_tag[MAX_AC_TAG_SIZE];
+   u32 tag;
 
bs_frm_size = vp8_enc_read_reg(inst, VENC_BITSTREAM_FRAME_SIZE);
bs_hdr_len = vp8_enc_read_reg(inst, VENC_BITSTREAM_HEADER_LEN);
 
/* if a frame is key frame, not_key is 0 */
not_key = !inst->vpu_inst.is_key_frm;
-   *(u32 *)ac_tag = __cpu_to_le32((bs_hdr_len << 5) | 0x10 | not_key);
+   tag = (bs_hdr_len << 5) | 0x10 | not_key;
+   ac_tag[0] = tag & 0xff;
+   ac_tag[1] = (tag >> 8) & 0xff;
+   ac_tag[2] = (tag >> 16) & 0xff;
+
/* key frame */
if (not_key == 0) {
ac_tag_size = MAX_AC_TAG_SIZE;
-- 
1.7.9.5

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


[GIT PULL FOR v4.7 v2] Add HDMI CEC framework

2016-05-11 Thread Hans Verkuil
Hi Mauro,

Here is the pull request for the HDMI CEC framework. The code of this pull
request is identical to the v16 patch series:

http://www.mail-archive.com/linux-media@vger.kernel.org/msg97057.html

plus these fixes:

https://patchwork.linuxtv.org/patch/34262/
https://patchwork.linuxtv.org/patch/34263/
https://patchwork.linuxtv.org/patch/34264/

and rebased to the latest media_tree master.

(I've marked my previous pull request as Superseded).

The pull request is for 4.7, but I am aware that it is likely that it will
slide to 4.8 since we're late in the 4.7 cycle.

The cec DocBook documentation is here:

https://hverkuil.home.xs4all.nl/cec.html#cec

The cec utilities are here:

http://git.linuxtv.org/hverkuil/v4l-utils.git/log/?h=cec

To test with real hardware the easiest is to use a pandaboard. I posted
RFC patches for that here:

http://www.spinics.net/lists/linux-media/msg100046.html

Regards,

Hans

The following changes since commit aff093d4bbca91f543e24cde2135f393b8130f4b:

  [media] exynos-gsc: avoid build warning without CONFIG_OF (2016-05-09 
18:38:33 -0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git cec

for you to fetch changes up to 08bc2ee8e9a4b2ad0282b356f8db49376c9bde3f:

  vivid: add CEC emulation (2016-05-11 09:39:22 +0200)


Hans Verkuil (10):
  input.h: add BUS_CEC type
  cec: add HDMI CEC framework
  cec/TODO: add TODO file so we know why this is still in staging
  cec: add compat32 ioctl support
  cec.txt: add CEC framework documentation
  DocBook/media: add CEC documentation
  cec: adv7604: add cec support.
  cec: adv7842: add cec support
  cec: adv7511: add cec support.
  vivid: add CEC emulation

Kamil Debski (3):
  HID: add HDMI CEC specific keycodes
  rc: Add HDMI CEC protocol handling
  cec: s5p-cec: Add s5p-cec driver

 Documentation/DocBook/device-drivers.tmpl|4 +
 Documentation/DocBook/media/Makefile |2 +
 Documentation/DocBook/media/v4l/biblio.xml   |   10 +
 Documentation/DocBook/media/v4l/cec-api.xml  |   72 ++
 Documentation/DocBook/media/v4l/cec-func-close.xml   |   59 +
 Documentation/DocBook/media/v4l/cec-func-ioctl.xml   |   73 ++
 Documentation/DocBook/media/v4l/cec-func-open.xml|   94 ++
 Documentation/DocBook/media/v4l/cec-func-poll.xml|   89 ++
 Documentation/DocBook/media/v4l/cec-ioc-adap-g-caps.xml  |  140 +++
 Documentation/DocBook/media/v4l/cec-ioc-adap-g-log-addrs.xml |  324 +
 Documentation/DocBook/media/v4l/cec-ioc-adap-g-phys-addr.xml |   82 ++
 Documentation/DocBook/media/v4l/cec-ioc-dqevent.xml  |  190 +++
 Documentation/DocBook/media/v4l/cec-ioc-g-mode.xml   |  245 
 Documentation/DocBook/media/v4l/cec-ioc-receive.xml  |  260 
 Documentation/DocBook/media_api.tmpl |6 +-
 Documentation/cec.txt|  267 
 Documentation/devicetree/bindings/media/s5p-cec.txt  |   31 +
 Documentation/video4linux/vivid.txt  |   36 +-
 MAINTAINERS  |   23 +
 drivers/media/Kconfig|3 +
 drivers/media/Makefile   |2 +
 drivers/media/cec-edid.c |  139 +++
 drivers/media/i2c/Kconfig|   27 +
 drivers/media/i2c/adv7511.c  |  401 +-
 drivers/media/i2c/adv7604.c  |  332 -
 drivers/media/i2c/adv7842.c  |  368 +-
 drivers/media/platform/Kconfig   |   11 +
 drivers/media/platform/Makefile  |1 +
 drivers/media/platform/s5p-cec/Makefile  |2 +
 drivers/media/platform/s5p-cec/exynos_hdmi_cec.h |   38 +
 drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c |  209 
 drivers/media/platform/s5p-cec/regs-cec.h|   96 ++
 drivers/media/platform/s5p-cec/s5p_cec.c |  295 +
 drivers/media/platform/s5p-cec/s5p_cec.h |   76 ++
 drivers/media/platform/vivid/Kconfig |9 +
 drivers/media/platform/vivid/Makefile|4 +
 drivers/media/platform/vivid/vivid-cec.c |  254 
 drivers/media/platform/vivid/vivid-cec.h |   33 +
 drivers/media/platform/vivid/vivid-core.c|  119 +-
 drivers/media/platform/vivid/vivid-core.h|   27 +
 drivers/media/platform/vivid/vivid-kthread-cap.c |   11 +
 drivers/media/platform/vivid/vivid-vid-cap.c |   23 +-
 

[GIT PULL FOR v4.7] uvcvideo fixes

2016-05-11 Thread Laurent Pinchart
Hi Mauro,

The following changes since commit aff093d4bbca91f543e24cde2135f393b8130f4b:

  [media] exynos-gsc: avoid build warning without CONFIG_OF (2016-05-09 
18:38:33 -0300)

are available in the git repository at:

  git://linuxtv.org/pinchartl/media.git uvc/next

for you to fetch changes up to f169fec5a6c40a3328b953c774a6a092e7688df2:

  uvcvideo: Correct speed testing (2016-05-10 01:12:55 +0300)


Nicolas Dufresne (1):
  uvcvideo: Fix bytesperline calculation for planar YUV

Oliver Neukum (1):
  uvcvideo: Correct speed testing

 drivers/media/usb/uvc/uvc_v4l2.c  | 19 +--
 drivers/media/usb/uvc/uvc_video.c |  1 +
 2 files changed, 18 insertions(+), 2 deletions(-)

-- 
Regards,

Laurent Pinchart

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


[PATCH 0/3] CEC Framework fixes

2016-05-11 Thread Hans Verkuil
From: Hans Verkuil 

While stress testing my CEC Framework v16 patch series found here:

http://www.spinics.net/lists/linux-input/msg44422.html

I discovered a few issues when dealing with HDMI disconnects.

The adv7511 patch fixes a potential race condition (never seen it go
wrong, but I feel much safer with the new code). The WARN_ON patch
removes a WARN_ON I thought could never happen when in fact it can
in a disconnect scenario, and the final patch fixes a nasty kernel
oops because the delayed work timer was never cleaned up while the
underlying data structure was freed.

I decided not to post a v17 patch series to avoid spamming everyone,
instead I'll merge these fixes in my cec pull request for Mauro and
update that pull request.

Regards,

Hans

Hans Verkuil (3):
  adv7511: always update CEC irq mask
  cec: remove WARN_ON
  cec: correctly cancel delayed work when the CEC adapter is disabled

 drivers/media/i2c/adv7511.c |  4 ++--
 drivers/staging/media/cec/cec.c | 29 -
 2 files changed, 26 insertions(+), 7 deletions(-)

-- 
2.8.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 3/3] cec: correctly cancel delayed work when the CEC adapter is disabled

2016-05-11 Thread Hans Verkuil
From: Hans Verkuil 

When cleaning up pending work from the wait_queue list, make sure to cancel the
delayed work. Otherwise nasty kernel oopses will occur when the timer goes off
and the cec_data struct has disappeared.

Signed-off-by: Hans Verkuil 
---
 drivers/staging/media/cec/cec.c | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/cec/cec.c b/drivers/staging/media/cec/cec.c
index 9a62aa2..c2a876e 100644
--- a/drivers/staging/media/cec/cec.c
+++ b/drivers/staging/media/cec/cec.c
@@ -393,13 +393,28 @@ static int cec_thread_func(void *_adap)
struct cec_data, list);
cec_data_cancel(data);
}
+   if (adap->transmitting)
+   cec_data_cancel(adap->transmitting);
+
+   /*
+* Cancel the pending timeout work. We have to unlock
+* the mutex when flushing the work since
+* cec_wait_timeout() will take it. This is OK since
+* no new entries can be added to wait_queue as long
+* as adap->transmitting is NULL, which it is due to
+* the cec_data_cancel() above.
+*/
while (!list_empty(>wait_queue)) {
data = list_first_entry(>wait_queue,
struct cec_data, list);
+
+   if (!cancel_delayed_work(>work)) {
+   mutex_unlock(>lock);
+   flush_scheduled_work();
+   mutex_lock(>lock);
+   }
cec_data_cancel(data);
}
-   if (adap->transmitting)
-   cec_data_cancel(adap->transmitting);
goto unlock;
}
 
-- 
2.8.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 2/3] cec: remove WARN_ON

2016-05-11 Thread Hans Verkuil
From: Hans Verkuil 

If a transmit is issued and before cec_transmit_done() is called the HDMI cable
is unplugged, then it is possible that adap->transmitting == NULL.

So drop the WARN_ON, explain why it can happen and just ignore the tranmit.

Signed-off-by: Hans Verkuil 
---
 drivers/staging/media/cec/cec.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/cec/cec.c b/drivers/staging/media/cec/cec.c
index 3c5f084..9a62aa2 100644
--- a/drivers/staging/media/cec/cec.c
+++ b/drivers/staging/media/cec/cec.c
@@ -485,9 +485,13 @@ void cec_transmit_done(struct cec_adapter *adap, u8 
status, u8 arb_lost_cnt,
dprintk(2, "cec_transmit_done %02x\n", status);
mutex_lock(>lock);
data = adap->transmitting;
-   if (WARN_ON(data == NULL)) {
-   /* This is weird and should not happen. Ignore this transmit */
-   dprintk(0, "cec_transmit_done without an ongoing transmit!\n");
+   if (data == NULL) {
+   /*
+* This can happen if a transmit was issued and the cable is
+* unplugged while the transmit is ongoing. Ignore this
+* transmit in that case.
+*/
+   dprintk(1, "cec_transmit_done without an ongoing transmit!\n");
goto unlock;
}
 
-- 
2.8.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 1/3] adv7511: always update CEC irq mask

2016-05-11 Thread Hans Verkuil
From: Hans Verkuil 

Instead of doing:

if (state->cec_enabled_adap)
adv7511_wr_and_or(sd, 0x95, 0xc0, enable ? 0x39 : 0x00);

do:

adv7511_wr_and_or(sd, 0x95, 0xc0,
  (state->cec_enabled_adap && enable) ? 0x39 : 0x00);

This ensures that the cec irq mask is always updated correctly according
to both conditions.

Signed-off-by: Hans Verkuil 
---
 drivers/media/i2c/adv7511.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 002117b..ddcde2d 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -937,8 +937,8 @@ static void adv7511_set_isr(struct v4l2_subdev *sd, bool 
enable)
else if (adv7511_have_hotplug(sd))
irqs |= MASK_ADV7511_EDID_RDY_INT;
 
-   if (state->cec_enabled_adap)
-   adv7511_wr_and_or(sd, 0x95, 0xc0, enable ? 0x39 : 0x00);
+   adv7511_wr_and_or(sd, 0x95, 0xc0,
+ (state->cec_enabled_adap && enable) ? 0x39 : 0x00);
 
/*
 * This i2c write can fail (approx. 1 in 1000 writes). But it
-- 
2.8.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