[PATCH v2 7/8] [media] vcodec: mediatek: Add Mediatek VP8 Video Encoder Driver

2015-12-11 Thread Tiffany Lin
Add vp8 encoder driver for MT8173

Signed-off-by: Daniel Hsiao 
Signed-off-by: Tiffany Lin 
---
 drivers/media/platform/mtk-vcodec/Makefile |2 +
 drivers/media/platform/mtk-vcodec/venc_drv_if.c|3 +
 drivers/media/platform/mtk-vcodec/vp8_enc/Makefile |8 +
 .../platform/mtk-vcodec/vp8_enc/venc_vp8_if.c  |  384 
 .../platform/mtk-vcodec/vp8_enc/venc_vp8_if.h  |  141 +++
 .../platform/mtk-vcodec/vp8_enc/venc_vp8_vpu.c |  221 +++
 .../platform/mtk-vcodec/vp8_enc/venc_vp8_vpu.h |   28 ++
 7 files changed, 787 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vcodec/vp8_enc/Makefile
 create mode 100644 drivers/media/platform/mtk-vcodec/vp8_enc/venc_vp8_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vp8_enc/venc_vp8_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vp8_enc/venc_vp8_vpu.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vp8_enc/venc_vp8_vpu.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index ce38689..f4ef502 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -5,4 +5,6 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk_vcodec_intr.o \
   mtk_vcodec_enc_pm.o \
   venc_drv_if.o
 
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += vp8_enc/
+
 ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-vcodec/venc_drv_if.c 
b/drivers/media/platform/mtk-vcodec/venc_drv_if.c
index 63e7df0..384e0d2 100644
--- a/drivers/media/platform/mtk-vcodec/venc_drv_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc_drv_if.c
@@ -24,6 +24,7 @@
 #include "mtk_vpu.h"
 
 #include "venc_drv_base.h"
+#include "vp8_enc/venc_vp8_if.h"
 
 int venc_if_create(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
 {
@@ -34,6 +35,8 @@ int venc_if_create(struct mtk_vcodec_ctx *ctx, unsigned int 
fourcc)
 
switch (fourcc) {
case V4L2_PIX_FMT_VP8:
+ctx->enc_if = get_vp8_enc_comm_if();
+break;
case V4L2_PIX_FMT_H264:
default:
goto err_out;
diff --git a/drivers/media/platform/mtk-vcodec/vp8_enc/Makefile 
b/drivers/media/platform/mtk-vcodec/vp8_enc/Makefile
new file mode 100644
index 000..17a0dfe
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vp8_enc/Makefile
@@ -0,0 +1,8 @@
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += venc_vp8_if.o venc_vp8_vpu.o
+
+ccflags-y += \
+-I$(srctree)/include/ \
+-I$(srctree)/drivers/media/platform/mtk-vcodec/ \
+-I$(srctree)/drivers/media/platform/mtk-vcodec/include \
+-I$(srctree)/drivers/media/platform/mtk-vcodec/vp8_enc \
+-I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-vcodec/vp8_enc/venc_vp8_if.c 
b/drivers/media/platform/mtk-vcodec/vp8_enc/venc_vp8_if.c
new file mode 100644
index 000..5201743
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vp8_enc/venc_vp8_if.c
@@ -0,0 +1,384 @@
+/*
+ * Copyright (c) 2015 MediaTek Inc.
+ * Author: Daniel Hsiao 
+ * PoChun Lin 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_vcodec_drv.h"
+#include "mtk_vcodec_util.h"
+#include "mtk_vcodec_intr.h"
+#include "mtk_vcodec_enc.h"
+#include "mtk_vcodec_pm.h"
+#include "mtk_vpu.h"
+
+#include "venc_vp8_if.h"
+#include "venc_vp8_vpu.h"
+
+#define VENC_PIC_BITSTREAM_BYTE_CNT 0x0098
+#define VENC_PIC_BITSTREAM_BYTE_CNT1 0x00e8
+#define VENC_IRQ_STATUS_ENC_FRM_INT 0x04
+
+#define MAX_AC_TAG_SZ 10
+
+static inline void vp8_enc_write_reg(struct venc_vp8_inst *inst, u32 addr,
+u32 val)
+{
+   writel(val, inst->hw_base + addr);
+}
+
+static inline u32 vp8_enc_read_reg(struct venc_vp8_inst *inst, u32 addr)
+{
+   return readl(inst->hw_base + addr);
+}
+
+static void vp8_enc_free_work_buf(struct venc_vp8_inst *inst)
+{
+   int i;
+
+   mtk_vcodec_debug_enter(inst);
+
+   /* Except the RC_CODEx buffers, other buffers need to be freed by AP. */
+   for (i = 0; i < VENC_VP8_VPU_WORK_BUF_RC_CODE; i++)
+   if (inst->work_bufs[i].va != NULL)
+   mtk_vcodec_mem_free(inst->ctx, >work_bufs[i]);
+
+   mtk_vcodec_debug_leave(inst);
+}
+
+static int vp8_enc_alloc_work_buf(struct venc_vp8_inst *inst)
+{
+   int i;
+   

[PATCH v2 8/8] [media] vcodec: mediatek: Add Mediatek H264 Video Encoder Driver

2015-12-11 Thread Tiffany Lin
Add h264 encoder driver for MT8173

Signed-off-by: Daniel Hsiao 
Signed-off-by: Tiffany Lin 
---
 drivers/media/platform/mtk-vcodec/Makefile |3 +-
 .../media/platform/mtk-vcodec/h264_enc/Makefile|8 +
 .../platform/mtk-vcodec/h264_enc/venc_h264_if.c|  495 
 .../platform/mtk-vcodec/h264_enc/venc_h264_if.h|  161 +++
 .../platform/mtk-vcodec/h264_enc/venc_h264_vpu.c   |  316 +
 .../platform/mtk-vcodec/h264_enc/venc_h264_vpu.h   |   30 ++
 drivers/media/platform/mtk-vcodec/venc_drv_if.c|3 +
 7 files changed, 1015 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/h264_enc/Makefile
 create mode 100644 drivers/media/platform/mtk-vcodec/h264_enc/venc_h264_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/h264_enc/venc_h264_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/h264_enc/venc_h264_vpu.c
 create mode 100644 drivers/media/platform/mtk-vcodec/h264_enc/venc_h264_vpu.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index f4ef502..f47dfc7 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk_vcodec_intr.o \
   mtk_vcodec_enc_pm.o \
   venc_drv_if.o
 
-obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += vp8_enc/
+
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += vp8_enc/ h264_enc/
 
 ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-vcodec/h264_enc/Makefile 
b/drivers/media/platform/mtk-vcodec/h264_enc/Makefile
new file mode 100644
index 000..f1fe5cb
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/h264_enc/Makefile
@@ -0,0 +1,8 @@
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += venc_h264_if.o venc_h264_vpu.o
+
+ccflags-y += \
+-I$(srctree)/include/ \
+-I$(srctree)/drivers/media/platform/mtk-vcodec/ \
+-I$(srctree)/drivers/media/platform/mtk-vcodec/include \
+-I$(srctree)/drivers/media/platform/mtk-vcodec/h264_enc \
+-I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-vcodec/h264_enc/venc_h264_if.c 
b/drivers/media/platform/mtk-vcodec/h264_enc/venc_h264_if.c
new file mode 100644
index 000..3ac80a4
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/h264_enc/venc_h264_if.c
@@ -0,0 +1,495 @@
+/*
+ * Copyright (c) 2015 MediaTek Inc.
+ * Author: Jungchang Tsao 
+ * Daniel Hsiao 
+ * PoChun Lin 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+
+#include "mtk_vcodec_drv.h"
+#include "mtk_vcodec_util.h"
+#include "mtk_vcodec_intr.h"
+#include "mtk_vcodec_enc.h"
+#include "mtk_vcodec_pm.h"
+#include "mtk_vpu.h"
+
+#include "venc_h264_if.h"
+#include "venc_h264_vpu.h"
+
+#define VENC_PIC_BITSTREAM_BYTE_CNT 0x0098
+
+static inline void h264_write_reg(struct venc_h264_inst *inst, u32 addr,
+ u32 val)
+{
+   writel(val, inst->hw_base + addr);
+}
+
+static inline u32 h264_read_reg(struct venc_h264_inst *inst, u32 addr)
+{
+   return readl(inst->hw_base + addr);
+}
+
+enum venc_h264_irq_status {
+   H264_IRQ_STATUS_ENC_SPS_INT = (1 << 0),
+   H264_IRQ_STATUS_ENC_PPS_INT = (1 << 1),
+   H264_IRQ_STATUS_ENC_FRM_INT = (1 << 2),
+};
+
+static int h264_enc_alloc_work_buf(struct venc_h264_inst *inst)
+{
+   int i, j;
+   int ret = 0;
+   struct venc_h264_vpu_buf *wb = inst->vpu_inst.drv->work_bufs;
+
+   mtk_vcodec_debug_enter(inst);
+
+   for (i = 0; i < VENC_H264_VPU_WORK_BUF_MAX; i++) {
+   /*
+* This 'wb' structure is set by VPU side and shared to AP for
+* buffer allocation and IO virtual addr mapping. For most of
+* the buffers, AP will allocate the buffer according to 'size'
+* field and store the IO virtual addr in 'iova' field. There
+* are two exceptions:
+* (1) RC_CODE buffer, it's pre-allocated in the VPU side, and
+* save the VPU addr in the 'vpua' field. The AP will translate
+* the VPU addr to the corresponding IO virtual addr and store
+* in 'iova' field for reg setting in VPU side.
+* (2) SKIP_FRAME buffer, it's pre-allocated in the VPU side,
+

[PATCH v2 5/8] arm64: dts: mediatek: Add Video Encoder for MT8173

2015-12-11 Thread Tiffany Lin
Add video encoder node for MT8173

Signed-off-by: Tiffany Lin 
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   47 ++
 1 file changed, 47 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index b8c8ff0..a6b0fcf 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -545,6 +545,53 @@
#clock-cells = <1>;
};
 
+   larb3: larb@18001000 {
+   compatible = "mediatek,mt8173-smi-larb";
+   reg = <0 0x18001000 0 0x1000>;
+   mediatek,smi = <_common>;
+   power-domains = < MT8173_POWER_DOMAIN_VENC>;
+   clocks = < CLK_VENC_CKE1>,
+< CLK_VENC_CKE0>;
+   clock-names = "apb", "smi";
+   };
+
+   vcodec_enc: vcodec@18002000 {
+   compatible = "mediatek,mt8173-vcodec-enc";
+   reg = <0 0x18002000 0 0x1000>,  /* VENC_SYS */
+ <0 0x19002000 0 0x1000>;  /* VENC_LT_SYS */
+   interrupts = ,
+;
+   larb = <>,
+  <>;
+   iommus = < M4U_LARB3_ID M4U_PORT_VENC_RCPU>,
+< M4U_LARB3_ID M4U_PORT_VENC_REC>,
+< M4U_LARB3_ID M4U_PORT_VENC_BSDMA>,
+< M4U_LARB3_ID M4U_PORT_VENC_SV_COMV>,
+< M4U_LARB3_ID M4U_PORT_VENC_RD_COMV>,
+< M4U_LARB3_ID M4U_PORT_VENC_CUR_LUMA>,
+< M4U_LARB3_ID M4U_PORT_VENC_CUR_CHROMA>,
+< M4U_LARB3_ID M4U_PORT_VENC_REF_LUMA>,
+< M4U_LARB3_ID M4U_PORT_VENC_REF_CHROMA>,
+< M4U_LARB3_ID M4U_PORT_VENC_NBM_RDMA>,
+< M4U_LARB3_ID M4U_PORT_VENC_NBM_WDMA>,
+< M4U_LARB5_ID M4U_PORT_VENC_RCPU_SET2>,
+< M4U_LARB5_ID 
M4U_PORT_VENC_REC_FRM_SET2>,
+< M4U_LARB5_ID M4U_PORT_VENC_BSDMA_SET2>,
+< M4U_LARB5_ID 
M4U_PORT_VENC_SV_COMA_SET2>,
+< M4U_LARB5_ID 
M4U_PORT_VENC_RD_COMA_SET2>,
+< M4U_LARB5_ID 
M4U_PORT_VENC_CUR_LUMA_SET2>,
+< M4U_LARB5_ID 
M4U_PORT_VENC_CUR_CHROMA_SET2>,
+< M4U_LARB5_ID 
M4U_PORT_VENC_REF_LUMA_SET2>,
+< M4U_LARB5_ID 
M4U_PORT_VENC_REC_CHROMA_SET2>;
+   vpu = <>;
+   clocks = < CLK_APMIXED_VENCPLL>,
+< CLK_TOP_VENC_LT_SEL>,
+< CLK_TOP_VCODECPLL_370P5>;
+   clock-names = "vencpll",
+ "venc_lt_sel",
+ "vcodecpll_370p5_ck";
+   };
+
vencltsys: clock-controller@1900 {
compatible = "mediatek,mt8173-vencltsys", "syscon";
reg = <0 0x1900 0 0x1000>;
-- 
1.7.9.5

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


[PATCH v2 6/8] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver

2015-12-11 Thread Tiffany Lin
From: Andrew-CT Chen 

Add v4l2 layer encoder driver for MT8173

Signed-off-by: Tiffany Lin 
---
 drivers/media/platform/Kconfig |   11 +
 drivers/media/platform/Makefile|2 +
 drivers/media/platform/mtk-vcodec/Makefile |8 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |  412 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 1670 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h |   45 +
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |  469 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c  |  122 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c|  102 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.h|   29 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_pm.h  |   26 +
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c|  106 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h|   85 +
 drivers/media/platform/mtk-vcodec/venc_drv_base.h  |   62 +
 drivers/media/platform/mtk-vcodec/venc_drv_if.c|  102 ++
 drivers/media/platform/mtk-vcodec/venc_drv_if.h|  174 ++
 drivers/media/platform/mtk-vcodec/venc_ipi_msg.h   |  212 +++
 17 files changed, 3637 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vcodec/Makefile
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_pm.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_base.h
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_drv_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_ipi_msg.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f3776f5..c80ca5c 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -158,6 +158,17 @@ config VIDEO_MEDIATEK_VPU
codec embedded in new Mediatek's SOCs. It is able
to handle video decoding/encoding in a range of formats.
 
+config VIDEO_MEDIATEK_VCODEC
+tristate "Mediatek Video Codec driver"
+depends on VIDEO_DEV && VIDEO_V4L2
+depends on ARCH_MEDIATEK || COMPILE_TEST
+select VIDEOBUF2_DMA_CONTIG
+select V4L2_MEM2MEM_DEV
+select MEDIATEK_VPU
+default n
+---help---
+Mediatek video codec driver for V4L2
+
 config VIDEO_MEM2MEM_DEINTERLACE
tristate "Deinterlace support"
depends on VIDEO_DEV && VIDEO_V4L2 && DMA_ENGINE
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index e5b19c6..510e06b 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -57,3 +57,5 @@ obj-$(CONFIG_VIDEO_XILINX)+= xilinx/
 ccflags-y += -I$(srctree)/drivers/media/i2c
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
+
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)+= mtk-vcodec/
diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
new file mode 100644
index 000..ce38689
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -0,0 +1,8 @@
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk_vcodec_intr.o \
+  mtk_vcodec_util.o \
+  mtk_vcodec_enc_drv.o \
+  mtk_vcodec_enc.o \
+  mtk_vcodec_enc_pm.o \
+  venc_drv_if.o
+
+ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
new file mode 100644
index 000..1d6adde
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -0,0 +1,412 @@
+/*
+* Copyright (c) 2015 MediaTek Inc.
+* Author: PC Chen 
+* Tiffany Lin 
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* 

[PATCH v2 4/8] dt-bindings: Add a binding for Mediatek Video Encoder

2015-12-11 Thread Tiffany Lin
Add a DT binding documentation of Video Encoder for the
MT8173 SoC from Mediatek.

Signed-off-by: Tiffany Lin 
---
 .../devicetree/bindings/media/mediatek-vcodec.txt  |   58 
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-vcodec.txt

diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt 
b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
new file mode 100644
index 000..510cd81
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
@@ -0,0 +1,58 @@
+Mediatek Video Codec
+
+Mediatek Video Codec is the video codec hw present in Mediatek SoCs which
+supports high resolution encoding functionalities.
+
+Required properties:
+- compatible : "mediatek,mt8173-vcodec-enc" for encoder
+- reg : Physical base address of the video codec registers and length of
+  memory mapped region.
+- interrupts : interrupt number to the cpu.
+- mediatek,larb : must contain the local arbiters in the current Socs.
+- clocks : list of clock specifiers, corresponding to entries in
+  the clock-names property;
+- clock-names: must contain "vencpll", "venc_lt_sel", "vcodecpll_370p5_ck"
+- iommus : list of iommus specifiers should be enabled for hw encode.
+  There are 2 cells needed to enable/disable iommu.
+  The first one is local arbiter index(larbid), and the other is port
+  index(portid) within local arbiter. Specifies the larbid and portid
+  as defined in dt-binding/memory/mt8173-larb-port.h.
+- mediatek,vpu : the node of video processor unit
+
+Example:
+vcodec_enc: vcodec@0x18002000 {
+compatible = "mediatek,mt8173-vcodec-enc";
+reg = <0 0x18002000 0 0x1000>,/*VENC_SYS*/
+  <0 0x19002000 0 0x1000>;/*VENC_LT_SYS*/
+interrupts = ,
+   ;
+larb = <>,
+   <>;
+iommus = < M4U_LARB3_ID M4U_PORT_VENC_RCPU>,
+ < M4U_LARB3_ID M4U_PORT_VENC_REC>,
+ < M4U_LARB3_ID M4U_PORT_VENC_BSDMA>,
+ < M4U_LARB3_ID M4U_PORT_VENC_SV_COMV>,
+ < M4U_LARB3_ID M4U_PORT_VENC_RD_COMV>,
+ < M4U_LARB3_ID M4U_PORT_VENC_CUR_LUMA>,
+ < M4U_LARB3_ID M4U_PORT_VENC_CUR_CHROMA>,
+ < M4U_LARB3_ID M4U_PORT_VENC_REF_LUMA>,
+ < M4U_LARB3_ID M4U_PORT_VENC_REF_CHROMA>,
+ < M4U_LARB3_ID M4U_PORT_VENC_NBM_RDMA>,
+ < M4U_LARB3_ID M4U_PORT_VENC_NBM_WDMA>,
+ < M4U_LARB5_ID M4U_PORT_VENC_RCPU_SET2>,
+ < M4U_LARB5_ID M4U_PORT_VENC_REC_FRM_SET2>,
+ < M4U_LARB5_ID M4U_PORT_VENC_BSDMA_SET2>,
+ < M4U_LARB5_ID M4U_PORT_VENC_SV_COMA_SET2>,
+ < M4U_LARB5_ID M4U_PORT_VENC_RD_COMA_SET2>,
+ < M4U_LARB5_ID M4U_PORT_VENC_CUR_LUMA_SET2>,
+ < M4U_LARB5_ID M4U_PORT_VENC_CUR_CHROMA_SET2>,
+ < M4U_LARB5_ID M4U_PORT_VENC_REF_LUMA_SET2>,
+ < M4U_LARB5_ID M4U_PORT_VENC_REC_CHROMA_SET2>;
+vpu = <>;
+clocks = < CLK_APMIXED_VENCPLL>,
+ < CLK_TOP_VENC_LT_SEL>,
+ < CLK_TOP_VCODECPLL_370P5>;
+clock-names = "vencpll",
+  "venc_lt_sel",
+  "vcodecpll_370p5_ck";
+  };
-- 
1.7.9.5

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


[PATCH v2 1/8] dt-bindings: Add a binding for Mediatek Video Processor

2015-12-11 Thread Tiffany Lin
From: Andrew-CT Chen 

Add a DT binding documentation of Video Processor Unit for the
MT8173 SoC from Mediatek.

Signed-off-by: Andrew-CT Chen 
Signed-off-by: Tiffany Lin 
---
 .../devicetree/bindings/media/mediatek-vpu.txt |   27 
 1 file changed, 27 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-vpu.txt

diff --git a/Documentation/devicetree/bindings/media/mediatek-vpu.txt 
b/Documentation/devicetree/bindings/media/mediatek-vpu.txt
new file mode 100644
index 000..3c3a424
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek-vpu.txt
@@ -0,0 +1,27 @@
+* Mediatek Video Processor Unit
+
+Video Processor Unit is a HW video controller. It controls HW Codec including
+H.264/VP8/VP9 Decode, H.264/VP8 Encode and Image Processor (scale/rotate/color 
convert).
+
+Required properties:
+  - compatible: "mediatek,mt8173-vpu"
+  - reg: Must contain an entry for each entry in reg-names.
+  - reg-names: Must include the following entries:
+"tcm": tcm base
+"cfg_reg": Main configuration registers base
+  - interrupts: interrupt number to the cpu.
+  - clocks : clock name from clock manager
+  - clock-names: must be main. It is the main clock of VPU
+  - iommus : phandle and IOMMU spcifier for the IOMMU that serves the VPU.
+
+Example:
+   vpu: vpu@1002 {
+   compatible = "mediatek,mt8173-vpu";
+   reg = <0 0x1002 0 0x3>,
+ <0 0x1005 0 0x100>;
+   reg-names = "tcm", "cfg_reg";
+   interrupts = ;
+   clocks = < TOP_SCP_SEL>;
+   clock-names = "main";
+   iommus = < M4U_PORT_VENC_RCPU>;
+   };
-- 
1.7.9.5

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


[PATCH v2 0/8] Add MT8173 Video Encoder Driver and VPU Driver

2015-12-11 Thread Tiffany Lin
==
 Introduction
==

The purpose of this RFC is to discuss the driver for a hw video codec
embedded in the Mediatek's MT8173 SoCs. Mediatek Video Codec is able to
handle video encoding of in a range of formats.

This RFC also include VPU driver. Mediatek Video Codec driver rely on
VPU driver to load, communicate with VPU.

Internally the driver uses videobuf2 framework and MTK IOMMU and MTK SMI.
MTK IOMMU and MTK SMI have not yet been merged, but we wanted to start
discussion about the driver earlier so it could be merged sooner. The
driver posted here is the initial version, so I suppose it will require
more work.

[1]http://lists.infradead.org/pipermail/linux-mediatek/2015-October/002525.html

==
 Device interface
==

In principle the driver bases on memory-to-memory framework:
it provides a single video node and each opened file handle gets its own
private context with separate buffer queues. Each context consist of 2
buffer queues: OUTPUT (for source buffers, i.e. raw video frames)
and CAPTURE (for destination buffers, i.e. encoded video frames).

The process of encoding video data from stream is a bit more complicated
than typical memory-to-memory processing. We base on memory-to-memory
framework and add the complicated part in our vb2 and v4l2 callback 
functionss. So we can base on well done m2m memory-to-memory framework, 
reduce duplicate code and make our driver code simple.

==
 VPU (Video Processor Unit)
==
The VPU driver for hw video codec embedded in Mediatek's MT8173 SOCs.
It is able to handle video decoding/encoding of in a range of formats.
The driver provides with VPU firmware download, memory management and
the communication interface between CPU and VPU.
For VPU initialization, it will create virtual memory for CPU access and
IOMMU address for vcodec hw device access. When a decode/encode instance
opens a device node, vpu driver will download vpu firmware to the device.
A decode/encode instant will decode/encode a frame using VPU 
interface to interrupt vpu to handle decoding/encoding jobs.

Please have a look at the code and comments will be very much appreciated.

Change in v2:
Vcodec Part
1.Remove common and include directory in mtk-vcodec
2.Refine vb2ops_venc_start_streaming and vb2ops_venc_stop_streaming and state 
machine
3.Remove venc_if_init and venc_if_deinit
4.Refine debug message
5.Refine lab and vpu decription in mediatek-vcodec.txt

VPU Part
1. Modify VPU Kconfig
2. Move encoder header files to other patch sets
3. Remove marcos for extended virtual/iova address
4. Change register and variable names
5. Add a reference counter for VPU watchdog
6. Remove one busy waiting in function vpu_ipi_send
7. Operate VPU clock in VPU driver (not called by encoder drivers)
8. Refine memory mapping, firmware download and extended memory allocation/free 
functions
9. Release more allocated resources in driver remove function

Andrew-CT Chen (2):
  dt-bindings: Add a binding for Mediatek Video Processor
  [Media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver

Tiffany Lin (6):
  arm64: dts: mediatek: Add node for Mediatek Video Processor Unit
  [media] VPU: mediatek: support Mediatek VPU
  dt-bindings: Add a binding for Mediatek Video Encoder
  arm64: dts: mediatek: Add Video Encoder for MT8173
  [media] vcodec: mediatek: Add Mediatek VP8 Video Encoder Driver
  [media] vcodec: mediatek: Add Mediatek H264 Video Encoder Driver

 .../devicetree/bindings/media/mediatek-vcodec.txt  |   58 +
 .../devicetree/bindings/media/mediatek-vpu.txt |   27 +
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   58 +
 drivers/media/platform/Kconfig |   21 +
 drivers/media/platform/Makefile|4 +
 drivers/media/platform/mtk-vcodec/Makefile |   11 +
 .../media/platform/mtk-vcodec/h264_enc/Makefile|8 +
 .../platform/mtk-vcodec/h264_enc/venc_h264_if.c|  495 ++
 .../platform/mtk-vcodec/h264_enc/venc_h264_if.h|  161 ++
 .../platform/mtk-vcodec/h264_enc/venc_h264_vpu.c   |  316 
 .../platform/mtk-vcodec/h264_enc/venc_h264_vpu.h   |   30 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |  412 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 1670 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h |   45 +
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |  469 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c  |  122 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c|  102 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.h|   29 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_pm.h  |   26 +
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c|  106 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h|   85 +
 drivers/media/platform/mtk-vcodec/venc_drv_base.h  |   62 +
 drivers/media/platform/mtk-vcodec/venc_drv_if.c|  108 ++
 

[PATCH v2 2/8] arm64: dts: mediatek: Add node for Mediatek Video Processor Unit

2015-12-11 Thread Tiffany Lin
Add VPU drivers for MT8173

Signed-off-by: Andrew-CT Chen 
Signed-off-by: Tiffany Lin 
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 4dd5f93..b8c8ff0 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -258,6 +258,17 @@
clock-names = "spi", "wrap";
};
 
+   vpu: vpu@1002 {
+   compatible = "mediatek,mt8173-vpu";
+   reg = <0 0x1002 0 0x3>,
+ <0 0x1005 0 0x100>;
+   reg-names = "tcm", "cfg_reg";
+   interrupts = ;
+   clocks = < CLK_TOP_SCP_SEL>;
+   clock-names = "main";
+   iommus = < M4U_LARB3_ID M4U_PORT_VENC_RCPU>;
+   };
+
sysirq: intpol-controller@10200620 {
compatible = "mediatek,mt8173-sysirq",
 "mediatek,mt6577-sysirq";
-- 
1.7.9.5

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


[PATCH v2 3/8] [media] VPU: mediatek: support Mediatek VPU

2015-12-11 Thread Tiffany Lin
The VPU driver for hw video codec embedded in Mediatek's MT8173 SOCs.
It is able to handle video decoding/encoding of in a range of formats.
The driver provides with VPU firmware download, memory management and
the communication interface between CPU and VPU.
For VPU initialization, it will create virtual memory for CPU access and
IOMMU address for vcodec hw device access. When a decode/encode instance
opens a device node, vpu driver will download vpu firmware to the device.
A decode/encode instant will decode/encode a frame using VPU
interface to interrupt vpu to handle decoding/encoding jobs.

Signed-off-by: Andrew-CT Chen 
Signed-off-by: Tiffany Lin 
---
 drivers/media/platform/Kconfig   |   10 +
 drivers/media/platform/Makefile  |2 +
 drivers/media/platform/mtk-vpu/Makefile  |1 +
 drivers/media/platform/mtk-vpu/mtk_vpu.c |  859 ++
 drivers/media/platform/mtk-vpu/mtk_vpu.h |  149 ++
 5 files changed, 1021 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vpu/Makefile
 create mode 100644 drivers/media/platform/mtk-vpu/mtk_vpu.c
 create mode 100644 drivers/media/platform/mtk-vpu/mtk_vpu.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index ccbc974..f3776f5 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -148,6 +148,16 @@ config VIDEO_CODA
   Coda is a range of video codec IPs that supports
   H.264, MPEG-4, and other video formats.
 
+config VIDEO_MEDIATEK_VPU
+   tristate "Mediatek Video Processor Unit"
+   depends on VIDEO_DEV && VIDEO_V4L2
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   ---help---
+   This driver provides downloading VPU firmware and
+   communicating with VPU. This driver for hw video
+   codec embedded in new Mediatek's SOCs. It is able
+   to handle video decoding/encoding in a range of formats.
+
 config VIDEO_MEM2MEM_DEINTERLACE
tristate "Deinterlace support"
depends on VIDEO_DEV && VIDEO_V4L2 && DMA_ENGINE
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index efa0295..e5b19c6 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -55,3 +55,5 @@ obj-$(CONFIG_VIDEO_AM437X_VPFE)   += am437x/
 obj-$(CONFIG_VIDEO_XILINX) += xilinx/
 
 ccflags-y += -I$(srctree)/drivers/media/i2c
+
+obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
diff --git a/drivers/media/platform/mtk-vpu/Makefile 
b/drivers/media/platform/mtk-vpu/Makefile
new file mode 100644
index 000..d890a66
--- /dev/null
+++ b/drivers/media/platform/mtk-vpu/Makefile
@@ -0,0 +1 @@
+obj-y += mtk_vpu.o
diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c 
b/drivers/media/platform/mtk-vpu/mtk_vpu.c
new file mode 100644
index 000..8994f73
--- /dev/null
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
@@ -0,0 +1,859 @@
+/*
+* Copyright (c) 2015 MediaTek Inc.
+* Author: Andrew-CT Chen 
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*/
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_vpu.h"
+
+/**
+ * VPU (video processor unit) is a tiny processor controlling video hardware
+ * related to video codec, scaling and color format converting.
+ * VPU interfaces with other blocks by share memory and interrupt.
+ **/
+
+#define INIT_TIMEOUT_MS2000U
+#define IPI_TIMEOUT_MS 2000U
+#define VPU_FW_VER_LEN 16
+
+/* maximum program/data TCM (Tightly-Coupled Memory) size */
+#define VPU_PTCM_SIZE  (96 * SZ_1K)
+#define VPU_DTCM_SIZE  (32 * SZ_1K)
+/* the offset to get data tcm address */
+#define VPU_DTCM_OFFSET0x18000UL
+/* daynamic allocated maximum extended memory size */
+#define VPU_EXT_P_SIZE SZ_1M
+#define VPU_EXT_D_SIZE SZ_4M
+/* maximum binary firmware size */
+#define VPU_P_FW_SIZE  (VPU_PTCM_SIZE + VPU_EXT_P_SIZE)
+#define VPU_D_FW_SIZE  (VPU_DTCM_SIZE + VPU_EXT_D_SIZE)
+/* the size of share buffer between Host and  VPU */
+#define SHARE_BUF_SIZE 48
+
+/* binary firmware name */
+#define VPU_P_FW   "vpu_p.bin"
+#define VPU_D_FW   "vpu_d.bin"
+
+#define VPU_RESET  0x0
+#define VPU_TCM_CFG0x0008
+#define VPU_PMEM_EXT0_ADDR 0x000C
+#define VPU_PMEM_EXT1_ADDR 0x0010
+#define VPU_TO_HOST0x001C
+#define 

[PATCH 02/10] media-device: better name Kernelspace/Userspace links

2015-12-11 Thread Mauro Carvalho Chehab
The __media_device_enum_links() copies links definitions from
Kernelspace to userspace. It has to work with 3 structs that
handle with links. Better name them to:
link: Kernelspace internal link representation, of the
type media_link;
klink_desc:  struct media_link_desc pointer to the
kernel memory where the data will be filled;
ulink_desc:  struct media_link_desc pointer to the
memory where the data will be copied to
userspace.

Suggested-by: Laurent Pinchart 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/media-device.c | 27 ++-
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 61883abaf095..14bd568e2f41 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -151,24 +151,25 @@ static long __media_device_enum_links(struct media_device 
*mdev,
}
 
if (links->links) {
-   struct media_link *ent_link;
-   struct media_link_desc __user *ulink = links->links;
+   struct media_link *link;
+   struct media_link_desc __user *ulink_desc = links->links;
 
-   list_for_each_entry(ent_link, >links, list) {
-   struct media_link_desc link;
+   list_for_each_entry(link, >links, list) {
+   struct media_link_desc klink_desc;
 
/* Ignore backlinks. */
-   if (ent_link->source->entity != entity)
+   if (link->source->entity != entity)
continue;
-   memset(, 0, sizeof(link));
-   media_device_kpad_to_upad(ent_link->source,
- );
-   media_device_kpad_to_upad(ent_link->sink,
- );
-   link.flags = ent_link->flags;
-   if (copy_to_user(ulink, , sizeof(*ulink)))
+   memset(_desc, 0, sizeof(klink_desc));
+   media_device_kpad_to_upad(link->source,
+ _desc.source);
+   media_device_kpad_to_upad(link->sink,
+ _desc.sink);
+   klink_desc.flags = link->flags;
+   if (copy_to_user(ulink_desc, _desc,
+sizeof(*ulink_desc)))
return -EFAULT;
-   ulink++;
+   ulink_desc++;
}
}
 
-- 
2.5.0


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


[PATCH 05/10] DocBook: Move media-framework.txt contend to media-device.h

2015-12-11 Thread Mauro Carvalho Chehab
Instead of using a text file, let's put it together with the struct 
documentation
for the Media Controller.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/DocBook/device-drivers.tmpl |   1 +
 Documentation/media-framework.txt | 373 -
 include/media/media-device.h  | 378 ++
 3 files changed, 379 insertions(+), 373 deletions(-)
 delete mode 100644 Documentation/media-framework.txt

diff --git a/Documentation/DocBook/device-drivers.tmpl 
b/Documentation/DocBook/device-drivers.tmpl
index 7b3fcc5effcd..cdd8b24db68d 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -263,6 +263,7 @@ X!Isound/sound_firmware.c
 !Iinclude/media/lirc_dev.h
 
 Media Controller devices
+!Pinclude/media/media-device.h Media Controller
 !Iinclude/media/media-device.h
 !Iinclude/media/media-devnode.h
 !Iinclude/media/media-entity.h
diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
deleted file mode 100644
index ef3663af1db3..
--- a/Documentation/media-framework.txt
+++ /dev/null
@@ -1,373 +0,0 @@
-Linux kernel media framework
-
-
-This document describes the Linux kernel media framework, its data structures,
-functions and their usage.
-
-
-Introduction
-
-
-The media controller API is documented in DocBook format in
-Documentation/DocBook/media/v4l/media-controller.xml. This document will focus
-on the kernel-side implementation of the media framework.
-
-
-Abstract media device model

-
-Discovering a device internal topology, and configuring it at runtime, is one
-of the goals of the media framework. To achieve this, hardware devices are
-modelled as an oriented graph of building blocks called entities connected
-through pads.
-
-An entity is a basic media hardware building block. It can correspond to
-a large variety of logical blocks such as physical hardware devices
-(CMOS sensor for instance), logical hardware devices (a building block
-in a System-on-Chip image processing pipeline), DMA channels or physical
-connectors.
-
-A pad is a connection endpoint through which an entity can interact with
-other entities. Data (not restricted to video) produced by an entity
-flows from the entity's output to one or more entity inputs. Pads should
-not be confused with physical pins at chip boundaries.
-
-A link is a point-to-point oriented connection between two pads, either
-on the same entity or on different entities. Data flows from a source
-pad to a sink pad.
-
-
-Media device
-
-
-A media device is represented by a struct media_device instance, defined in
-include/media/media-device.h. Allocation of the structure is handled by the
-media device driver, usually by embedding the media_device instance in a
-larger driver-specific structure.
-
-Drivers register media device instances by calling
-
-   media_device_register(struct media_device *mdev);
-
-The caller is responsible for initializing the media_device structure before
-registration. The following fields must be set:
-
- - dev must point to the parent device (usually a pci_dev, usb_interface or
-   platform_device instance).
-
- - model must be filled with the device model name as a NUL-terminated UTF-8
-   string. The device/model revision must not be stored in this field.
-
-The following fields are optional:
-
- - serial is a unique serial number stored as a NUL-terminated ASCII string.
-   The field is big enough to store a GUID in text form. If the hardware
-   doesn't provide a unique serial number this field must be left empty.
-
- - bus_info represents the location of the device in the system as a
-   NUL-terminated ASCII string. For PCI/PCIe devices bus_info must be set to
-   "PCI:" (or "PCIe:") followed by the value of pci_name(). For USB devices,
-   the usb_make_path() function must be used. This field is used by
-   applications to distinguish between otherwise identical devices that don't
-   provide a serial number.
-
- - hw_revision is the hardware device revision in a driver-specific format.
-   When possible the revision should be formatted with the KERNEL_VERSION
-   macro.
-
- - driver_version is formatted with the KERNEL_VERSION macro. The version
-   minor must be incremented when new features are added to the userspace API
-   without breaking binary compatibility. The version major must be
-   incremented when binary compatibility is broken.
-
-Upon successful registration a character device named media[0-9]+ is created.
-The device major and minor numbers are dynamic. The model name is exported as
-a sysfs attribute.
-
-Drivers unregister media device instances by calling
-
-   media_device_unregister(struct media_device *mdev);
-
-Unregistering a media device that hasn't been registered is *NOT* safe.
-
-
-Entities, pads and links

[PATCH 08/10] media-entity.c: remove two extra blank lines

2015-12-11 Thread Mauro Carvalho Chehab
No functional changes.

Suggested-by: Laurent Pinchart 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/media-entity.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 849db4f6f1f3..5a5432524c10 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -310,7 +310,6 @@ void media_entity_graph_walk_start(struct 
media_entity_graph *graph,
 }
 EXPORT_SYMBOL_GPL(media_entity_graph_walk_start);
 
-
 /**
  * media_entity_graph_walk_next - Get the next entity in the graph
  * @graph: Media graph structure
@@ -850,7 +849,6 @@ struct media_pad *media_entity_remote_pad(struct media_pad 
*pad)
 }
 EXPORT_SYMBOL_GPL(media_entity_remote_pad);
 
-
 static void media_interface_init(struct media_device *mdev,
 struct media_interface *intf,
 u32 gobj_type,
@@ -915,7 +913,6 @@ struct media_link *media_create_intf_link(struct 
media_entity *entity,
 }
 EXPORT_SYMBOL_GPL(media_create_intf_link);
 
-
 void __media_remove_intf_link(struct media_link *link)
 {
list_del(>list);
-- 
2.5.0


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


[PATCH 03/10] media framework: rename pads init function to media_entity_pads_init()

2015-12-11 Thread Mauro Carvalho Chehab
With the MC next gen rework, what's left for media_entity_init()
is to just initialize the PADs. However, certain devices, like
a FLASH led/light doesn't have any input or output PAD.

So, there's no reason why calling media_entity_init() would be
mandatory. Also, despite its name, what this function actually
does is to initialize the PADs data. So, rename it to
media_entity_pads_init() in order to reflect that.

The media entity actual init happens during entity register,
at media_device_register_entity(). We should move init of
num_links and num_backlinks to it.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media-framework.txt  | 18 +++---
 Documentation/video4linux/v4l2-framework.txt   |  8 
 Documentation/zh_CN/video4linux/v4l2-framework.txt |  8 
 drivers/media/dvb-core/dvbdev.c|  4 ++--
 drivers/media/dvb-frontends/au8522_decoder.c   |  2 +-
 drivers/media/i2c/ad9389b.c|  2 +-
 drivers/media/i2c/adp1653.c|  2 +-
 drivers/media/i2c/adv7180.c|  2 +-
 drivers/media/i2c/adv7511.c|  2 +-
 drivers/media/i2c/adv7604.c|  2 +-
 drivers/media/i2c/adv7842.c|  2 +-
 drivers/media/i2c/as3645a.c|  2 +-
 drivers/media/i2c/cx25840/cx25840-core.c   |  2 +-
 drivers/media/i2c/lm3560.c |  2 +-
 drivers/media/i2c/lm3646.c |  2 +-
 drivers/media/i2c/m5mols/m5mols_core.c |  2 +-
 drivers/media/i2c/mt9m032.c|  2 +-
 drivers/media/i2c/mt9p031.c|  2 +-
 drivers/media/i2c/mt9t001.c|  2 +-
 drivers/media/i2c/mt9v032.c|  2 +-
 drivers/media/i2c/noon010pc30.c|  2 +-
 drivers/media/i2c/ov2659.c |  2 +-
 drivers/media/i2c/ov9650.c |  2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c   |  4 ++--
 drivers/media/i2c/s5k4ecgx.c   |  2 +-
 drivers/media/i2c/s5k5baf.c|  4 ++--
 drivers/media/i2c/s5k6a3.c |  2 +-
 drivers/media/i2c/s5k6aa.c |  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c |  6 +++---
 drivers/media/i2c/tc358743.c   |  2 +-
 drivers/media/i2c/tvp514x.c|  2 +-
 drivers/media/i2c/tvp7002.c|  2 +-
 drivers/media/media-device.c   |  2 ++
 drivers/media/media-entity.c   | 11 ---
 drivers/media/platform/exynos4-is/fimc-capture.c   |  4 ++--
 drivers/media/platform/exynos4-is/fimc-isp-video.c |  2 +-
 drivers/media/platform/exynos4-is/fimc-isp.c   |  2 +-
 drivers/media/platform/exynos4-is/fimc-lite.c  |  4 ++--
 drivers/media/platform/exynos4-is/fimc-m2m.c   |  2 +-
 drivers/media/platform/exynos4-is/mipi-csis.c  |  2 +-
 drivers/media/platform/omap3isp/ispccdc.c  |  2 +-
 drivers/media/platform/omap3isp/ispccp2.c  |  2 +-
 drivers/media/platform/omap3isp/ispcsi2.c  |  2 +-
 drivers/media/platform/omap3isp/isppreview.c   |  2 +-
 drivers/media/platform/omap3isp/ispresizer.c   |  2 +-
 drivers/media/platform/omap3isp/ispstat.c  |  2 +-
 drivers/media/platform/omap3isp/ispvideo.c |  2 +-
 drivers/media/platform/s3c-camif/camif-capture.c   |  4 ++--
 drivers/media/platform/vsp1/vsp1_entity.c  |  2 +-
 drivers/media/platform/vsp1/vsp1_video.c   |  2 +-
 drivers/media/platform/xilinx/xilinx-dma.c |  2 +-
 drivers/media/platform/xilinx/xilinx-tpg.c |  2 +-
 drivers/media/usb/au0828/au0828-video.c|  6 +++---
 drivers/media/usb/cx231xx/cx231xx-video.c  |  4 ++--
 drivers/media/usb/uvc/uvc_entity.c |  4 ++--
 drivers/media/v4l2-core/tuner-core.c   |  2 +-
 drivers/media/v4l2-core/v4l2-flash-led-class.c |  2 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |  2 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c |  2 +-
 drivers/staging/media/davinci_vpfe/dm365_isif.c|  2 +-
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |  6 +++---
 drivers/staging/media/davinci_vpfe/vpfe_video.c|  2 +-
 drivers/staging/media/omap4iss/iss_csi2.c  |  2 +-
 drivers/staging/media/omap4iss/iss_ipipe.c |  2 +-
 drivers/staging/media/omap4iss/iss_ipipeif.c   |  2 +-
 drivers/staging/media/omap4iss/iss_resizer.c   |  2 +-
 drivers/staging/media/omap4iss/iss_video.c |  2 +-
 include/media/media-entity.h   |  2 +-
 68 files changed, 102 insertions(+), 99 deletions(-)

diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
index b424de6c3bb3..7fbfe4bd1f47 100644
--- 

[PATCH 07/10] media-device.h: Improve documentation and update it

2015-12-11 Thread Mauro Carvalho Chehab
Now that we moved the content of the media-framework.txt into
the kerneldoc documentation, move the per-function specific
documentation to the corresponding functions and clean it up.

It would be good if we had already the markdown kernel-doc
patches merged upstream, but, while we doesn't have it,
let's make it less ugly at device-drivers.xml.

Signed-off-by: Mauro Carvalho Chehab 
---
 include/media/media-device.h | 429 +++
 include/media/media-entity.h | 148 +++
 2 files changed, 339 insertions(+), 238 deletions(-)

diff --git a/include/media/media-device.h b/include/media/media-device.h
index 6728528df9e2..7cfcc08a09ea 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -33,23 +33,11 @@
 /**
  * DOC: Media Controller
  *
- * Linux kernel media framework
- * 
- *
- * This document describes the Linux kernel media framework, its data 
structures,
- * functions and their usage.
- *
- *
- * Introduction
- * 
- *
- * The media controller API is documented in DocBook format in
- * Documentation/DocBook/media/v4l/media-controller.xml. This document will 
focus
+ * The media controller userspace API is documented in DocBook format in
+ * Documentation/DocBook/media/v4l/media-controller.xml. This document focus
  * on the kernel-side implementation of the media framework.
  *
- *
- * Abstract media device model
- * ---
+ * * Abstract media device model:
  *
  * Discovering a device internal topology, and configuring it at runtime, is 
one
  * of the goals of the media framework. To achieve this, hardware devices are
@@ -72,195 +60,104 @@
  * pad to a sink pad.
  *
  *
- * Media device
- * 
+ * * Media device:
  *
- * A media device is represented by a struct media_device instance, defined in
+ * A media device is represented by a struct _device instance, defined in
  * include/media/media-device.h. Allocation of the structure is handled by the
- * media device driver, usually by embedding the media_device instance in a
+ * media device driver, usually by embedding the _device instance in a
  * larger driver-specific structure.
  *
  * Drivers register media device instances by calling
+ * __media_device_register() via the macro media_device_register()
+ * and unregistered by calling
+ * media_device_unregister().
  *
- * media_device_register(struct media_device *mdev);
- *
- * The caller is responsible for initializing the media_device structure before
- * registration. The following fields must be set:
- *
- *  - dev must point to the parent device (usually a pci_dev, usb_interface or
- *platform_device instance).
- *
- *  - model must be filled with the device model name as a NUL-terminated UTF-8
- *string. The device/model revision must not be stored in this field.
- *
- * The following fields are optional:
- *
- *  - serial is a unique serial number stored as a NUL-terminated ASCII string.
- *The field is big enough to store a GUID in text form. If the hardware
- *doesn't provide a unique serial number this field must be left empty.
- *
- *  - bus_info represents the location of the device in the system as a
- *NUL-terminated ASCII string. For PCI/PCIe devices bus_info must be set to
- *"PCI:" (or "PCIe:") followed by the value of pci_name(). For USB devices,
- *the usb_make_path() function must be used. This field is used by
- *applications to distinguish between otherwise identical devices that 
don't
- *provide a serial number.
- *
- *  - hw_revision is the hardware device revision in a driver-specific format.
- *When possible the revision should be formatted with the KERNEL_VERSION
- *macro.
- *
- *  - driver_version is formatted with the KERNEL_VERSION macro. The version
- *minor must be incremented when new features are added to the userspace 
API
- *without breaking binary compatibility. The version major must be
- *incremented when binary compatibility is broken.
- *
- * Upon successful registration a character device named media[0-9]+ is 
created.
- * The device major and minor numbers are dynamic. The model name is exported 
as
- * a sysfs attribute.
- *
- * Drivers unregister media device instances by calling
- *
- * media_device_unregister(struct media_device *mdev);
- *
- * Unregistering a media device that hasn't been registered is *NOT* safe.
- *
- *
- * Entities, pads and links
- * 
+ * * Entities, pads and links:
  *
  * - Entities
  *
- * Entities are represented by a struct media_entity instance, defined in
+ * Entities are represented by a struct _entity instance, defined in
  * include/media/media-entity.h. The structure is usually embedded into a
  * higher-level structure, such as a v4l2_subdev or video_device instance,
  * although drivers can allocate entities directly.
  *
  * Drivers initialize entity pads 

[PATCH 10/10] media_entity: get rid of an unused var

2015-12-11 Thread Mauro Carvalho Chehab
> > > + if (rlink != link->reverse) {
> > > + r++;
> >
> > The variable is incremented here but otherwise never used, you can remove 
> > it.

Suggested-by: Laurent Pinchart 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/media-entity.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 452af1d5a20d..57de11281af1 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -592,7 +592,6 @@ static void __media_entity_remove_link(struct media_entity 
*entity,
 {
struct media_link *rlink, *tmp;
struct media_entity *remote;
-   unsigned int r = 0;
 
if (link->source->entity == entity)
remote = link->sink->entity;
@@ -600,10 +599,8 @@ static void __media_entity_remove_link(struct media_entity 
*entity,
remote = link->source->entity;
 
list_for_each_entry_safe(rlink, tmp, >links, list) {
-   if (rlink != link->reverse) {
-   r++;
+   if (rlink != link->reverse)
continue;
-   }
 
if (link->source->entity == entity)
remote->num_backlinks--;
-- 
2.5.0


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


[PATCH 04/10] media-entity.h: get rid of revision and group_id fields

2015-12-11 Thread Mauro Carvalho Chehab
Both revision and group_id fields were never used and were always
initialized to zero. Remove them.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml | 13 ++---
 Documentation/media-framework.txt   | 12 +---
 drivers/media/media-device.c|  4 ++--
 include/media/media-entity.h|  4 
 4 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml 
b/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml
index 27f8817e7abe..9f7614a01234 100644
--- a/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml
+++ b/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml
@@ -59,15 +59,6 @@
 Entity IDs can be non-contiguous. Applications must
 not try to enumerate entities by calling
 MEDIA_IOC_ENUM_ENTITIES with increasing id's until they get an 
error.
-Two or more entities that share a common non-zero
-group_id value are considered as logically
-grouped. Groups are used to report
-
-  ALSA, VBI and video nodes that carry the same media
-  stream
-  lens and flash controllers associated with a 
sensor
-
-
 
 
   struct media_entity_desc
@@ -106,7 +97,7 @@
revision


-   Entity revision in a driver/hardware specific format.
+   Entity revision. Always zero (obsolete)
  
  
__u32
@@ -120,7 +111,7 @@
group_id


-   Entity group ID
+   Entity group ID. Always zero (obsolete)
  
  
__u16
diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
index 7fbfe4bd1f47..ef3663af1db3 100644
--- a/Documentation/media-framework.txt
+++ b/Documentation/media-framework.txt
@@ -110,10 +110,10 @@ If no pads are needed, drivers could directly fill 
entity->num_pads
 with 0 and entity->pads with NULL or to call the above function that
 will do the same.
 
-The media_entity name, type, flags, revision and group_id fields should be
-initialized before calling media_device_register_entity(). Entities embedded
-in higher-level standard structures can have some of those fields set by the
-higher-level framework.
+The media_entity name, type and flags fields should be initialized before
+calling media_device_register_entity(). Entities embedded in higher-level
+standard structures can have some of those fields set by the higher-level
+framework.
 
 As the number of pads is known in advance, the pads array is not allocated
 dynamically but is managed by the entity driver. Most drivers will embed the
@@ -164,9 +164,7 @@ Entities have flags that describe the entity capabilities 
and state.
 
 Logical entity groups can be defined by setting the group ID of all member
 entities to the same non-zero value. An entity group serves no purpose in the
-kernel, but is reported to userspace during entities enumeration. The group_id
-field belongs to the media device driver and must not by touched by entity
-drivers.
+kernel, but is reported to userspace during entities enumeration.
 
 Media device drivers should define groups if several entities are logically
 bound together. Example usages include reporting
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index b8cd7733a31c..537160bb461e 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -109,9 +109,9 @@ static long media_device_enum_entities(struct media_device 
*mdev,
if (ent->name)
strlcpy(u_ent.name, ent->name, sizeof(u_ent.name));
u_ent.type = ent->function;
-   u_ent.revision = ent->revision;
+   u_ent.revision = 0; /* Unused */
u_ent.flags = ent->flags;
-   u_ent.group_id = ent->group_id;
+   u_ent.group_id = 0; /* Unused */
u_ent.pads = ent->num_pads;
u_ent.links = ent->num_links - ent->num_backlinks;
memcpy(_ent.raw, >info, sizeof(ent->info));
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 32fef503d950..031536723d8c 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -153,9 +153,7 @@ struct media_entity_operations {
  * @name:  Entity name.
  * @function:  Entity main function, as defined in uapi/media.h
  * (MEDIA_ENT_F_*)
- * @revision:  Entity revision - OBSOLETE - should be removed soon.
  * @flags: Entity flags, as defined in uapi/media.h (MEDIA_ENT_FL_*)
- * @group_id:  Entity group ID - OBSOLETE - should be removed soon.
  * @num_pads:  Number of sink and source pads.
  * @num_links: Total number of links, forward and back, enabled and disabled.
  * @num_backlinks: Number of backlinks
@@ -180,9 +178,7 @@ struct media_entity {
struct media_gobj 

[PATCH 09/10] media-entity: get rid of forward __media_entity_remove_link() declaration

2015-12-11 Thread Mauro Carvalho Chehab
Move this function to happen earlier, in order to avoid
a uneeded forward declaration.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/media-entity.c | 67 +---
 1 file changed, 32 insertions(+), 35 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 5a5432524c10..452af1d5a20d 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -588,7 +588,38 @@ static struct media_link *media_add_link(struct list_head 
*head)
 }
 
 static void __media_entity_remove_link(struct media_entity *entity,
-  struct media_link *link);
+  struct media_link *link)
+{
+   struct media_link *rlink, *tmp;
+   struct media_entity *remote;
+   unsigned int r = 0;
+
+   if (link->source->entity == entity)
+   remote = link->sink->entity;
+   else
+   remote = link->source->entity;
+
+   list_for_each_entry_safe(rlink, tmp, >links, list) {
+   if (rlink != link->reverse) {
+   r++;
+   continue;
+   }
+
+   if (link->source->entity == entity)
+   remote->num_backlinks--;
+
+   /* Remove the remote link */
+   list_del(>list);
+   media_gobj_remove(>graph_obj);
+   kfree(rlink);
+
+   if (--remote->num_links == 0)
+   break;
+   }
+   list_del(>list);
+   media_gobj_remove(>graph_obj);
+   kfree(link);
+}
 
 int
 media_create_pad_link(struct media_entity *source, u16 source_pad,
@@ -642,40 +673,6 @@ media_create_pad_link(struct media_entity *source, u16 
source_pad,
 }
 EXPORT_SYMBOL_GPL(media_create_pad_link);
 
-static void __media_entity_remove_link(struct media_entity *entity,
-  struct media_link *link)
-{
-   struct media_link *rlink, *tmp;
-   struct media_entity *remote;
-   unsigned int r = 0;
-
-   if (link->source->entity == entity)
-   remote = link->sink->entity;
-   else
-   remote = link->source->entity;
-
-   list_for_each_entry_safe(rlink, tmp, >links, list) {
-   if (rlink != link->reverse) {
-   r++;
-   continue;
-   }
-
-   if (link->source->entity == entity)
-   remote->num_backlinks--;
-
-   /* Remove the remote link */
-   list_del(>list);
-   media_gobj_remove(>graph_obj);
-   kfree(rlink);
-
-   if (--remote->num_links == 0)
-   break;
-   }
-   list_del(>list);
-   media_gobj_remove(>graph_obj);
-   kfree(link);
-}
-
 void __media_entity_remove_links(struct media_entity *entity)
 {
struct media_link *link, *tmp;
-- 
2.5.0


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


[PATCH 06/10] media-entity.h: convert media_entity_cleanup to inline

2015-12-11 Thread Mauro Carvalho Chehab
This function was used in the past to free the links
that were allocated by the media controller core.

However, this is not needed anymore. We should likely
get rid of the funcion on some function, but, for now,
let's just convert into an inlined function and let the
compiler to get rid of it.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/media-entity.c | 6 --
 include/media/media-entity.h | 3 ++-
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index ef2102ac0c66..849db4f6f1f3 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -246,12 +246,6 @@ media_entity_pads_init(struct media_entity *entity, u16 
num_pads,
 }
 EXPORT_SYMBOL_GPL(media_entity_pads_init);
 
-void
-media_entity_cleanup(struct media_entity *entity)
-{
-}
-EXPORT_SYMBOL_GPL(media_entity_cleanup);
-
 /* 
-
  * Graph traversal
  */
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 031536723d8c..e9bc5857899c 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -345,7 +345,8 @@ void media_gobj_remove(struct media_gobj *gobj);
 
 int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
  struct media_pad *pads);
-void media_entity_cleanup(struct media_entity *entity);
+
+static inline void media_entity_cleanup(struct media_entity *entity) {};
 
 __must_check int media_create_pad_link(struct media_entity *source,
u16 source_pad, struct media_entity *sink,
-- 
2.5.0


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


[PATCH 01/10] media-device: put headers in alphabetic order

2015-12-11 Thread Mauro Carvalho Chehab
It is better to keep the headers in alphabetic order.

Suggested-by: Laurent Pinchart 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/media-device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 3d0a77c1c899..61883abaf095 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -24,8 +24,8 @@
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 
 #include 
 #include 
-- 
2.5.0


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


[PATCH] media: use unsigned for pad index

2015-12-11 Thread Mauro Carvalho Chehab
The pad index is unsigned. Replace the occurences of it where
pertinent.

Suggested-by: Laurent Pinchart 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/platform/omap3isp/ispccdc.c  | 2 +-
 drivers/media/platform/omap3isp/ispccp2.c  | 2 +-
 drivers/media/platform/omap3isp/ispcsi2.c  | 2 +-
 drivers/media/platform/omap3isp/isppreview.c   | 2 +-
 drivers/media/platform/omap3isp/ispresizer.c   | 2 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 2 +-
 drivers/staging/media/davinci_vpfe/dm365_isif.c| 2 +-
 drivers/staging/media/davinci_vpfe/dm365_resizer.c | 2 +-
 drivers/staging/media/omap4iss/iss_csi2.c  | 2 +-
 drivers/staging/media/omap4iss/iss_ipipeif.c   | 2 +-
 drivers/staging/media/omap4iss/iss_resizer.c   | 2 +-
 11 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/omap3isp/ispccdc.c 
b/drivers/media/platform/omap3isp/ispccdc.c
index dae674cd3f74..749462c1af8e 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -2513,7 +2513,7 @@ static int ccdc_link_setup(struct media_entity *entity,
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd);
struct isp_device *isp = to_isp_device(ccdc);
-   int index = local->index;
+   unsigned int index = local->index;
 
/* FIXME: this is actually a hack! */
if (is_media_entity_v4l2_subdev(remote->entity))
diff --git a/drivers/media/platform/omap3isp/ispccp2.c 
b/drivers/media/platform/omap3isp/ispccp2.c
index 0c790b25f6f9..59686dd1bb0a 100644
--- a/drivers/media/platform/omap3isp/ispccp2.c
+++ b/drivers/media/platform/omap3isp/ispccp2.c
@@ -956,7 +956,7 @@ static int ccp2_link_setup(struct media_entity *entity,
 {
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd);
-   int index = local->index;
+   unsigned int index = local->index;
 
/* FIXME: this is actually a hack! */
if (is_media_entity_v4l2_subdev(remote->entity))
diff --git a/drivers/media/platform/omap3isp/ispcsi2.c 
b/drivers/media/platform/omap3isp/ispcsi2.c
index f50f6b305204..886f148755b0 100644
--- a/drivers/media/platform/omap3isp/ispcsi2.c
+++ b/drivers/media/platform/omap3isp/ispcsi2.c
@@ -1144,7 +1144,7 @@ static int csi2_link_setup(struct media_entity *entity,
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
struct isp_csi2_ctrl_cfg *ctrl = >ctrl;
-   int index = local->index;
+   unsigned int index = local->index;
 
/*
 * The ISP core doesn't support pipelines with multiple video outputs.
diff --git a/drivers/media/platform/omap3isp/isppreview.c 
b/drivers/media/platform/omap3isp/isppreview.c
index c300cb7219e9..e15ad4133632 100644
--- a/drivers/media/platform/omap3isp/isppreview.c
+++ b/drivers/media/platform/omap3isp/isppreview.c
@@ -2144,7 +2144,7 @@ static int preview_link_setup(struct media_entity *entity,
 {
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct isp_prev_device *prev = v4l2_get_subdevdata(sd);
-   int index = local->index;
+   unsigned int index = local->index;
 
/* FIXME: this is actually a hack! */
if (is_media_entity_v4l2_subdev(remote->entity))
diff --git a/drivers/media/platform/omap3isp/ispresizer.c 
b/drivers/media/platform/omap3isp/ispresizer.c
index cd0a9f6e1fed..20b98d876d7e 100644
--- a/drivers/media/platform/omap3isp/ispresizer.c
+++ b/drivers/media/platform/omap3isp/ispresizer.c
@@ -1623,7 +1623,7 @@ static int resizer_link_setup(struct media_entity *entity,
 {
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct isp_res_device *res = v4l2_get_subdevdata(sd);
-   int index = local->index;
+   unsigned int index = local->index;
 
/* FIXME: this is actually a hack! */
if (is_media_entity_v4l2_subdev(remote->entity))
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
index a54c60fce3d5..633d6456fdce 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
@@ -885,7 +885,7 @@ ipipeif_link_setup(struct media_entity *entity, const 
struct media_pad *local,
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
struct vpfe_device *vpfe = to_vpfe_device(ipipeif);
-   int index = local->index;
+   unsigned int index = local->index;
 
/* FIXME: this is actually a hack! */
if (is_media_entity_v4l2_subdev(remote->entity))
diff --git 

[PATCH 2/2] media-entity.h: move kernel-doc tags from media-entity.c

2015-12-11 Thread Mauro Carvalho Chehab
Several additional functions are described at media-entity.c.
Moving them to the header file, to make the code cleaner and
to have all such macros at the same place.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/media-entity.c | 163 +++
 include/media/media-entity.h | 136 +++-
 2 files changed, 145 insertions(+), 154 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 861c8e7b8773..ada2b44ea4e1 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -26,15 +26,6 @@
 #include 
 #include 
 
-/**
- *  dev_dbg_obj - Prints in debug mode a change on some object
- *
- * @event_name:Name of the event to report. Could be __func__
- * @gobj:  Pointer to the object
- *
- * Enabled only if DEBUG or CONFIG_DYNAMIC_DEBUG. Otherwise, it
- * won't produce any code.
- */
 static inline const char *gobj_type(enum media_gobj_type type)
 {
switch (type) {
@@ -79,6 +70,15 @@ static inline const char *intf_type(struct media_interface 
*intf)
}
 };
 
+/**
+ *  dev_dbg_obj - Prints in debug mode a change on some object
+ *
+ * @event_name:Name of the event to report. Could be __func__
+ * @gobj:  Pointer to the object
+ *
+ * Enabled only if DEBUG or CONFIG_DYNAMIC_DEBUG. Otherwise, it
+ * won't produce any code.
+ */
 static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
 {
 #if defined(DEBUG) || defined (CONFIG_DYNAMIC_DEBUG)
@@ -133,19 +133,6 @@ static void dev_dbg_obj(const char *event_name,  struct 
media_gobj *gobj)
 #endif
 }
 
-/**
- *  media_gobj_create - Initialize a graph object
- *
- * @mdev:  Pointer to the media_device that contains the object
- * @type:  Type of the object
- * @gobj:  Pointer to the object
- *
- * This routine initializes the embedded struct media_gobj inside a
- * media graph object. It is called automatically if media_*_create()
- * calls are used. However, if the object (entity, link, pad, interface)
- * is embedded on some other object, this function should be called before
- * registering the object at the media controller.
- */
 void media_gobj_create(struct media_device *mdev,
   enum media_gobj_type type,
   struct media_gobj *gobj)
@@ -179,13 +166,6 @@ void media_gobj_create(struct media_device *mdev,
dev_dbg_obj(__func__, gobj);
 }
 
-/**
- *  media_gobj_destroy - Stop using a graph object on a media device
- *
- * @graph_obj: Pointer to the object
- *
- * This should be called at media_device_unregister_*() routines
- */
 void media_gobj_destroy(struct media_gobj *gobj)
 {
dev_dbg_obj(__func__, gobj);
@@ -196,31 +176,8 @@ void media_gobj_destroy(struct media_gobj *gobj)
list_del(>list);
 }
 
-/**
- * media_entity_pads_init - Initialize a media entity
- *
- * @num_pads: Total number of sink and source pads.
- * @pads: Array of 'num_pads' pads.
- *
- * The total number of pads is an intrinsic property of entities known by the
- * entity driver, while the total number of links depends on hardware design
- * and is an extrinsic property unknown to the entity driver. However, in most
- * use cases the number of links can safely be assumed to be equal to or
- * larger than the number of pads.
- *
- * For those reasons the links array can be preallocated based on the number
- * of pads and will be reallocated later if extra links need to be created.
- *
- * This function allocates a links array with enough space to hold at least
- * 'num_pads' elements. The media_entity::max_links field will be set to the
- * number of allocated elements.
- *
- * The pads array is managed by the entity driver and passed to
- * media_entity_pads_init() where its pointer will be stored in the entity 
structure.
- */
-int
-media_entity_pads_init(struct media_entity *entity, u16 num_pads,
- struct media_pad *pads)
+int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
+  struct media_pad *pads)
 {
struct media_device *mdev = entity->graph_obj.mdev;
unsigned int i;
@@ -285,16 +242,6 @@ static struct media_entity *stack_pop(struct 
media_entity_graph *graph)
 #define link_top(en)   ((en)->stack[(en)->top].link)
 #define stack_top(en)  ((en)->stack[(en)->top].entity)
 
-/**
- * media_entity_graph_walk_start - Start walking the media graph at a given 
entity
- * @graph: Media graph structure that will be used to walk the graph
- * @entity: Starting entity
- *
- * This function initializes the graph traversal structure to walk the entities
- * graph starting at the given entity. The traversal structure must not be
- * modified by the caller during graph traversal. When done the structure can
- * safely be freed.
- */
 void media_entity_graph_walk_start(struct media_entity_graph *graph,
   struct 

Re: [PATCH 03/10] media framework: rename pads init function to media_entity_pads_init()

2015-12-11 Thread Jacek Anaszewski

On 12/11/2015 02:34 PM, Mauro Carvalho Chehab wrote:

With the MC next gen rework, what's left for media_entity_init()
is to just initialize the PADs. However, certain devices, like
a FLASH led/light doesn't have any input or output PAD.

So, there's no reason why calling media_entity_init() would be
mandatory. Also, despite its name, what this function actually
does is to initialize the PADs data. So, rename it to
media_entity_pads_init() in order to reflect that.

The media entity actual init happens during entity register,
at media_device_register_entity(). We should move init of
num_links and num_backlinks to it.

Signed-off-by: Mauro Carvalho Chehab 

[...]

diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c 
b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index 5c686a24712b..13d5a36bc5d8 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -651,7 +651,7 @@ struct v4l2_flash *v4l2_flash_init(
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
strlcpy(sd->name, config->dev_name, sizeof(sd->name));

-   ret = media_entity_init(>entity, 0, NULL);
+   ret = media_entity_pads_init(>entity, 0, NULL);
if (ret < 0)
return ERR_PTR(ret);



For this part:

Acked-by: Jacek Anaszewski 

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


[PATCH 00/10] Some cleanups after the Media Controller Next gen

2015-12-11 Thread Mauro Carvalho Chehab
This series address the comments from Laurent to this patch:
[PATCH v8.4 24/83] [media] media: convert links from array to list

Most of the patches here are trivial. The most relevant one is the patch
that updates the media framework documentation,  moving it from a
pure text file into the device-drivers.xml DocBook and updating the 
documentation
to reflect the MC next generation changes.

Mauro Carvalho Chehab (10):
  media-device: put headers in alphabetic order
  media-device: better name Kernelspace/Userspace links
  media framework: rename pads init function to media_entity_pads_init()
  media-entity.h: get rid of revision and group_id fields
  DocBook: Move media-framework.txt contend to media-device.h
  media-entity.h: convert media_entity_cleanup to inline
  media-device.h: Improve documentation and update it
  media-entity.c: remove two extra blank lines
  media-entity: get rid of forward __media_entity_remove_link()
declaration
  media_entity: get rid of an unused var

 Documentation/DocBook/device-drivers.tmpl  |   1 +
 .../DocBook/media/v4l/media-ioc-enum-entities.xml  |  13 +-
 Documentation/media-framework.txt  | 371 -
 Documentation/video4linux/v4l2-framework.txt   |   8 +-
 Documentation/zh_CN/video4linux/v4l2-framework.txt |   8 +-
 drivers/media/dvb-core/dvbdev.c|   4 +-
 drivers/media/dvb-frontends/au8522_decoder.c   |   2 +-
 drivers/media/i2c/ad9389b.c|   2 +-
 drivers/media/i2c/adp1653.c|   2 +-
 drivers/media/i2c/adv7180.c|   2 +-
 drivers/media/i2c/adv7511.c|   2 +-
 drivers/media/i2c/adv7604.c|   2 +-
 drivers/media/i2c/adv7842.c|   2 +-
 drivers/media/i2c/as3645a.c|   2 +-
 drivers/media/i2c/cx25840/cx25840-core.c   |   2 +-
 drivers/media/i2c/lm3560.c |   2 +-
 drivers/media/i2c/lm3646.c |   2 +-
 drivers/media/i2c/m5mols/m5mols_core.c |   2 +-
 drivers/media/i2c/mt9m032.c|   2 +-
 drivers/media/i2c/mt9p031.c|   2 +-
 drivers/media/i2c/mt9t001.c|   2 +-
 drivers/media/i2c/mt9v032.c|   2 +-
 drivers/media/i2c/noon010pc30.c|   2 +-
 drivers/media/i2c/ov2659.c |   2 +-
 drivers/media/i2c/ov9650.c |   2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c   |   4 +-
 drivers/media/i2c/s5k4ecgx.c   |   2 +-
 drivers/media/i2c/s5k5baf.c|   4 +-
 drivers/media/i2c/s5k6a3.c |   2 +-
 drivers/media/i2c/s5k6aa.c |   2 +-
 drivers/media/i2c/smiapp/smiapp-core.c |   6 +-
 drivers/media/i2c/tc358743.c   |   2 +-
 drivers/media/i2c/tvp514x.c|   2 +-
 drivers/media/i2c/tvp7002.c|   2 +-
 drivers/media/media-device.c   |  35 +-
 drivers/media/media-entity.c   |  84 ++---
 drivers/media/platform/exynos4-is/fimc-capture.c   |   4 +-
 drivers/media/platform/exynos4-is/fimc-isp-video.c |   2 +-
 drivers/media/platform/exynos4-is/fimc-isp.c   |   2 +-
 drivers/media/platform/exynos4-is/fimc-lite.c  |   4 +-
 drivers/media/platform/exynos4-is/fimc-m2m.c   |   2 +-
 drivers/media/platform/exynos4-is/mipi-csis.c  |   2 +-
 drivers/media/platform/omap3isp/ispccdc.c  |   2 +-
 drivers/media/platform/omap3isp/ispccp2.c  |   2 +-
 drivers/media/platform/omap3isp/ispcsi2.c  |   2 +-
 drivers/media/platform/omap3isp/isppreview.c   |   2 +-
 drivers/media/platform/omap3isp/ispresizer.c   |   2 +-
 drivers/media/platform/omap3isp/ispstat.c  |   2 +-
 drivers/media/platform/omap3isp/ispvideo.c |   2 +-
 drivers/media/platform/s3c-camif/camif-capture.c   |   4 +-
 drivers/media/platform/vsp1/vsp1_entity.c  |   2 +-
 drivers/media/platform/vsp1/vsp1_video.c   |   2 +-
 drivers/media/platform/xilinx/xilinx-dma.c |   2 +-
 drivers/media/platform/xilinx/xilinx-tpg.c |   2 +-
 drivers/media/usb/au0828/au0828-video.c|   6 +-
 drivers/media/usb/cx231xx/cx231xx-video.c  |   4 +-
 drivers/media/usb/uvc/uvc_entity.c |   4 +-
 drivers/media/v4l2-core/tuner-core.c   |   2 +-
 drivers/media/v4l2-core/v4l2-flash-led-class.c |   2 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |   2 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c |   2 +-
 drivers/staging/media/davinci_vpfe/dm365_isif.c|   2 +-
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |   6 +-
 drivers/staging/media/davinci_vpfe/vpfe_video.c|   2 +-
 drivers/staging/media/omap4iss/iss_csi2.c  |   2 +-
 

Problems with TV card "TeVii S472"

2015-12-11 Thread Hendrik Oenings
Hi all,

I've got a DVB-S2 PCI-Express tv card ("Tevii S472", http://tevii.com/P
roducts_S472_1.asp) with Debian testing, but I'm not able to get it
work.
On TeVii's webpage there is a linux driver availible (http://tevii.com/
Support.asp), but if I try to compile the driver, it says that my
kernel version isn't supported (current debian testing installed).

The PCIe bridge is cx23885, the demodulator is m88ds3103 and I assume
that the RF Tuner is m88ts2022.

The kernel messages just say:
> $ dmesg | grep dvb
> $ dmesg | grep cx23885
> [8.295142] cx23885[0]:card=46 - DVBSky T980C
> [8.295143] cx23885[0]:card=47 - DVBSky S950C
> [8.295143] cx23885[0]:card=48 - Technotrend TT-budget
> CT2-4500 CI
> [8.295144] cx23885[0]:card=49 - DVBSky S950
> [8.295145] cx23885[0]:card=50 - DVBSky S952
> [8.295145] cx23885[0]:card=51 - DVBSky T982
> [8.295146] cx23885[0]:card=52 - Hauppauge WinTV-HVR5525
> [8.295147] cx23885[0]:card=53 - Hauppauge WinTV Starburst
> [8.295159] CORE cx23885[0]: subsystem: d472:9022, board:
> UNKNOWN/GENERIC [card=0,autodetected]
> [8.47] cx23885_dev_checkrevision() Hardware revision = 0xa5
> [8.422230] cx23885[0]/0: found at :03:00.0, rev: 4, irq: 19,
> latency: 0, mmio: 0xf7c0
> $ dmesg | grep ds3103
> $ dmesg | grep ts2022

The firmware (dvb-fe-ds3103.fw) was copied to /lib/firmware.

Regards,
Hendrik

--
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] go7007: constify go7007_hpi_ops structures

2015-12-11 Thread Julia Lawall
The go7007_hpi_ops structures are never modified, so declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall 

---
 drivers/media/pci/saa7134/saa7134-go7007.c |2 +-
 drivers/media/usb/go7007/go7007-priv.h |2 +-
 drivers/media/usb/go7007/go7007-usb.c  |4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/go7007/go7007-priv.h 
b/drivers/media/usb/go7007/go7007-priv.h
index 745185e..bebee8c 100644
--- a/drivers/media/usb/go7007/go7007-priv.h
+++ b/drivers/media/usb/go7007/go7007-priv.h
@@ -250,7 +250,7 @@ struct go7007 {
struct i2c_adapter i2c_adapter;
 
/* HPI driver */
-   struct go7007_hpi_ops *hpi_ops;
+   const struct go7007_hpi_ops *hpi_ops;
void *hpi_context;
int interrupt_available;
wait_queue_head_t interrupt_waitq;
diff --git a/drivers/media/usb/go7007/go7007-usb.c 
b/drivers/media/usb/go7007/go7007-usb.c
index 3dbf14c..14d3f8c 100644
--- a/drivers/media/usb/go7007/go7007-usb.c
+++ b/drivers/media/usb/go7007/go7007-usb.c
@@ -932,7 +932,7 @@ static void go7007_usb_release(struct go7007 *go)
kfree(go->hpi_context);
 }
 
-static struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = {
+static const struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = {
.interface_reset= go7007_usb_interface_reset,
.write_interrupt= go7007_usb_ezusb_write_interrupt,
.read_interrupt = go7007_usb_read_interrupt,
@@ -942,7 +942,7 @@ static struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = {
.release= go7007_usb_release,
 };
 
-static struct go7007_hpi_ops go7007_usb_onboard_hpi_ops = {
+static const struct go7007_hpi_ops go7007_usb_onboard_hpi_ops = {
.interface_reset= go7007_usb_interface_reset,
.write_interrupt= go7007_usb_onboard_write_interrupt,
.read_interrupt = go7007_usb_read_interrupt,
diff --git a/drivers/media/pci/saa7134/saa7134-go7007.c 
b/drivers/media/pci/saa7134/saa7134-go7007.c
index 8a2abb3..2799538 100644
--- a/drivers/media/pci/saa7134/saa7134-go7007.c
+++ b/drivers/media/pci/saa7134/saa7134-go7007.c
@@ -378,7 +378,7 @@ static int saa7134_go7007_send_firmware(struct go7007 *go, 
u8 *data, int len)
return 0;
 }
 
-static struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
+static const struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
.interface_reset= saa7134_go7007_interface_reset,
.write_interrupt= saa7134_go7007_write_interrupt,
.read_interrupt = saa7134_go7007_read_interrupt,

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


Re: [PATCH 0/3] adv7604: .g_crop and .cropcap support

2015-12-11 Thread Hans Verkuil
Hi Ulrich,

On 12/11/2015 05:04 PM, Ulrich Hecht wrote:
> Hi!
> 
> The rcar_vin driver relies on these methods.  The third patch makes sure
> that they return up-to-date data if the input signal has changed since
> initialization.
> 
> CU
> Uli
> 
> 
> Ulrich Hecht (3):
>   media: adv7604: implement g_crop
>   media: adv7604: implement cropcap

I'm not keen on these changes. The reason is that these ops are deprecated and
soc-camera is - almost - the last user. The g/s_selection ops should be used 
instead.

Now, I have a patch that changes soc-camera to g/s_selection. The reason it was 
never
applied is that I had a hard time finding hardware to test it with.

Since you clearly have that hardware I think I'll rebase my (by now rather old) 
patch
and post it again. If you can switch the adv7604 patch to g/s_selection and 
everything
works with my patch, then I think I should just make a pull request for it.

I hope to be able to do this on Monday.

If switching soc-camera over to g/s_selection isn't possible, then at the very 
least
your adv7604 changes should provide the g/s_selection implementation. I don't 
want
to have to convert this driver later to g/s_selection.

Regards,

Hans

>   media: adv7604: update timings on change of input signal
> 
>  drivers/media/i2c/adv7604.c | 38 ++
>  1 file changed, 38 insertions(+)
> 

--
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] media: adv7604: implement g_crop

2015-12-11 Thread Ulrich Hecht
The rcar_vin driver relies on this.

Signed-off-by: Ulrich Hecht 
---
 drivers/media/i2c/adv7604.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 129009f..d30e7cc 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1885,6 +1885,17 @@ static int adv76xx_get_format(struct v4l2_subdev *sd,
return 0;
 }
 
+static int adv76xx_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
+{
+   struct adv76xx_state *state = to_state(sd);
+
+   a->c.height = state->timings.bt.height;
+   a->c.width  = state->timings.bt.width;
+   a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+   return 0;
+}
+
 static int adv76xx_set_format(struct v4l2_subdev *sd,
  struct v4l2_subdev_pad_config *cfg,
  struct v4l2_subdev_format *format)
@@ -2407,6 +2418,7 @@ static const struct v4l2_subdev_core_ops adv76xx_core_ops 
= {
 
 static const struct v4l2_subdev_video_ops adv76xx_video_ops = {
.s_routing = adv76xx_s_routing,
+   .g_crop = adv76xx_g_crop,
.g_input_status = adv76xx_g_input_status,
.s_dv_timings = adv76xx_s_dv_timings,
.g_dv_timings = adv76xx_g_dv_timings,
-- 
2.6.3

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


[PATCH] adv7604: add direct interrupt handling

2015-12-11 Thread Ulrich Hecht
When probed from device tree, the i2c client driver can handle the
interrupt on its own.

Signed-off-by: Ulrich Hecht 
---
 drivers/media/i2c/adv7604.c | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index c2df7e8..129009f 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1971,6 +1972,16 @@ static int adv76xx_isr(struct v4l2_subdev *sd, u32 
status, bool *handled)
return 0;
 }
 
+static irqreturn_t adv76xx_irq_handler(int irq, void *devid)
+{
+   struct adv76xx_state *state = devid;
+   bool handled;
+
+   adv76xx_isr(>sd, 0, );
+
+   return handled ? IRQ_HANDLED : IRQ_NONE;
+}
+
 static int adv76xx_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
 {
struct adv76xx_state *state = to_state(sd);
@@ -2833,8 +2844,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
state->pdata.op_656_range = 1;
}
 
-   /* Disable the interrupt for now as no DT-based board uses it. */
-   state->pdata.int1_config = ADV76XX_INT1_CONFIG_DISABLED;
+   state->pdata.int1_config = ADV76XX_INT1_CONFIG_ACTIVE_LOW;
 
/* Use the default I2C addresses. */
state->pdata.i2c_addresses[ADV7604_PAGE_AVLINK] = 0x42;
@@ -3224,6 +3234,16 @@ static int adv76xx_probe(struct i2c_client *client,
v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
client->addr << 1, client->adapter->name);
 
+   if (client->irq) {
+   err = devm_request_threaded_irq(>dev,
+   client->irq,
+   NULL, adv76xx_irq_handler,
+   IRQF_TRIGGER_LOW|IRQF_ONESHOT,
+   dev_name(>dev), state);
+   if (err)
+   goto err_entity;
+   }
+
err = v4l2_async_register_subdev(sd);
if (err)
goto err_entity;
-- 
2.6.3

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


[PATCH 0/3] adv7604: .g_crop and .cropcap support

2015-12-11 Thread Ulrich Hecht
Hi!

The rcar_vin driver relies on these methods.  The third patch makes sure
that they return up-to-date data if the input signal has changed since
initialization.

CU
Uli


Ulrich Hecht (3):
  media: adv7604: implement g_crop
  media: adv7604: implement cropcap
  media: adv7604: update timings on change of input signal

 drivers/media/i2c/adv7604.c | 38 ++
 1 file changed, 38 insertions(+)

-- 
2.6.3

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


[PATCH 2/3] media: adv7604: implement cropcap

2015-12-11 Thread Ulrich Hecht
Used by the rcar_vin driver.

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

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index d30e7cc..1bfa9f3 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1896,6 +1896,22 @@ static int adv76xx_g_crop(struct v4l2_subdev *sd, struct 
v4l2_crop *a)
return 0;
 }
 
+static int adv76xx_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
+{
+   struct adv76xx_state *state = to_state(sd);
+
+   a->bounds.left   = 0;
+   a->bounds.top= 0;
+   a->bounds.width  = state->timings.bt.width;
+   a->bounds.height = state->timings.bt.height;
+   a->defrect   = a->bounds;
+   a->type  = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+   a->pixelaspect.numerator   = 1;
+   a->pixelaspect.denominator = 1;
+
+   return 0;
+}
+
 static int adv76xx_set_format(struct v4l2_subdev *sd,
  struct v4l2_subdev_pad_config *cfg,
  struct v4l2_subdev_format *format)
@@ -2419,6 +2435,7 @@ static const struct v4l2_subdev_core_ops adv76xx_core_ops 
= {
 static const struct v4l2_subdev_video_ops adv76xx_video_ops = {
.s_routing = adv76xx_s_routing,
.g_crop = adv76xx_g_crop,
+   .cropcap = adv76xx_cropcap,
.g_input_status = adv76xx_g_input_status,
.s_dv_timings = adv76xx_s_dv_timings,
.g_dv_timings = adv76xx_g_dv_timings,
-- 
2.6.3

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


[PATCH 3/3] media: adv7604: update timings on change of input signal

2015-12-11 Thread Ulrich Hecht
Without this, g_crop will always return the boot-time state.

Signed-off-by: Ulrich Hecht 
---
 drivers/media/i2c/adv7604.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 1bfa9f3..d7d0bb7 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1975,6 +1975,15 @@ static int adv76xx_isr(struct v4l2_subdev *sd, u32 
status, bool *handled)
 
v4l2_subdev_notify_event(sd, _ev_fmt);
 
+   /* update timings */
+   if (adv76xx_query_dv_timings(sd, >timings)
+   == -ENOLINK) {
+   /* no signal, fall back to default timings */
+   const struct v4l2_dv_timings cea640x480 =
+   V4L2_DV_BT_CEA_640X480P59_94;
+   state->timings = cea640x480;
+   }
+
if (handled)
*handled = true;
}
-- 
2.6.3

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


Re: [PATCH v5 1/3] [media] media-device: check before unregister if mdev was registered

2015-12-11 Thread Shuah Khan
On 12/11/2015 03:57 PM, Javier Martinez Canillas wrote:
> Most media functions that unregister, check if the corresponding register
> function succeed before. So these functions can safely be called even if a
> registration was never made or the component as already been unregistered.
> 
> Add the same check to media_device_unregister() function for consistency.
> 
> This will also allow to split the media_device_register() function in an
> initialization and registration functions without the need to change the
> generic cleanup functions and error code paths for all the media drivers.
> 
> Suggested-by: Sakari Ailus 
> Signed-off-by: Javier Martinez Canillas 
> Acked-by: Sakari Ailus 
> 
> ---
> 
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2:
> - Reword the documentation for media_device_unregister(). Suggested by Sakari.
> - Added Sakari's Acked-by tag for patch #1.
> 
>  drivers/media/media-device.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index c12481c753a0..11c1c7383361 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -577,6 +577,8 @@ EXPORT_SYMBOL_GPL(__media_device_register);
>   * media_device_unregister - unregister a media device
>   * @mdev:The media device
>   *
> + * It is safe to call this function on an unregistered
> + * (but initialised) media device.
>   */
>  void media_device_unregister(struct media_device *mdev)
>  {
> @@ -584,6 +586,10 @@ void media_device_unregister(struct media_device *mdev)
>   struct media_entity *next;
>   struct media_interface *intf, *tmp_intf;
>  
> + /* Check if mdev was ever registered at all */
> + if (!media_devnode_is_registered(>devnode))
> + return;

This is a good check, however, this check will not prevent
media_device_unregister() from getting run twice by two
different drivers. i.e media_devnode gets unregistered
towards the end of at the end of media_device_unregister().

In an example case, if bridge driver and snd-usb-aduio both
call media_device_unregister(), this check won't help prevent
media_device_unregister() being done only once. I think we
need a different state variable in struct media_device
to ensure unregister is done only once.

> +
>   /* Remove all entities from the media device */
>   list_for_each_entry_safe(entity, next, >entities, graph_obj.list)
>   media_device_unregister_entity(entity);
> 


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shua...@osg.samsung.com | (970) 217-8978
--
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 v5 1/2] media: v4l: ti-vpe: Add CAL v4l2 camera capture driver

2015-12-11 Thread Benoit Parrot
Mauro Carvalho Chehab  wrote on Thu [2015-Dec-03 
11:19:22 -0200]:
> Em Wed, 18 Nov 2015 14:47:11 -0600
> Benoit Parrot  escreveu:
> 
> > The Camera Adaptation Layer (CAL) is a block which consists of a dual
> > port CSI2/MIPI camera capture engine.
> > Port #0 can handle CSI2 camera connected to up to 4 data lanes.
> > Port #1 can handle CSI2 camera connected to up to 2 data lanes.
> > The driver implements the required API/ioctls to be V4L2 compliant.
> > Driver supports the following:
> > - V4L2 API using DMABUF/MMAP buffer access based on videobuf2 api
> > - Asynchronous sensor sub device registration
> 
> Please see the comments I did for the git pull request. Additionally,
> see below.

Yes I'll take care of the comments about the MAINTAINERS mods and patch order.

However I do have a few question on your comments, see below.

> 
> > 
> > Signed-off-by: Benoit Parrot 
> > Signed-off-by: Hans Verkuil 
> > ---
> >  drivers/media/platform/Kconfig   |   12 +
> >  drivers/media/platform/Makefile  |2 +
> >  drivers/media/platform/ti-vpe/Makefile   |4 +
> >  drivers/media/platform/ti-vpe/cal.c  | 2143 
> > ++
> >  drivers/media/platform/ti-vpe/cal_regs.h |  779 +++
> >  5 files changed, 2940 insertions(+)
> >  create mode 100644 drivers/media/platform/ti-vpe/cal.c
> >  create mode 100644 drivers/media/platform/ti-vpe/cal_regs.h
> > 
> > diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> > index 0c53805dff0e..db052f5a627a 100644
> > --- a/drivers/media/platform/Kconfig
> > +++ b/drivers/media/platform/Kconfig
> > @@ -120,6 +120,18 @@ source "drivers/media/platform/s5p-tv/Kconfig"
> >  source "drivers/media/platform/am437x/Kconfig"
> >  source "drivers/media/platform/xilinx/Kconfig"
> >  
> > +config VIDEO_TI_CAL
> > +   tristate "TI CAL (Camera Adaptation Layer) driver"
> > +   depends on VIDEO_DEV && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
> > +   depends on SOC_DRA7XX || COMPILE_TEST
> > +   select VIDEOBUF2_DMA_CONTIG
> > +   default n
> > +   ---help---
> > + Support for the TI CAL (Camera Adaptation Layer) block
> > + found on DRA72X SoC.
> > + In TI Technical Reference Manual this module is referred as
> > + Camera Interface Subsystem (CAMSS).
> > +
> >  endif # V4L_PLATFORM_DRIVERS
> >  
> >  menuconfig V4L_MEM2MEM_DRIVERS
> > diff --git a/drivers/media/platform/Makefile 
> > b/drivers/media/platform/Makefile
> > index efa0295af87b..028a7233096b 100644
> > --- a/drivers/media/platform/Makefile
> > +++ b/drivers/media/platform/Makefile
> > @@ -18,6 +18,8 @@ obj-$(CONFIG_VIDEO_VIM2M) += vim2m.o
> >  
> >  obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe/
> >  
> > +obj-$(CONFIG_VIDEO_TI_CAL) += ti-vpe/
> > +
> >  obj-$(CONFIG_VIDEO_MX2_EMMAPRP)+= mx2_emmaprp.o
> >  obj-$(CONFIG_VIDEO_CODA)   += coda/
> >  
> > diff --git a/drivers/media/platform/ti-vpe/Makefile 
> > b/drivers/media/platform/ti-vpe/Makefile
> > index be680f839e77..e236059a60ad 100644
> > --- a/drivers/media/platform/ti-vpe/Makefile
> > +++ b/drivers/media/platform/ti-vpe/Makefile
> > @@ -3,3 +3,7 @@ obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe.o
> >  ti-vpe-y := vpe.o sc.o csc.o vpdma.o
> >  
> >  ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG
> > +
> > +obj-$(CONFIG_VIDEO_TI_CAL) += ti-cal.o
> > +
> > +ti-cal-y := cal.o
> > diff --git a/drivers/media/platform/ti-vpe/cal.c 
> > b/drivers/media/platform/ti-vpe/cal.c
> > new file mode 100644
> > index ..61cd5b9bd8f6
> > --- /dev/null
> > +++ b/drivers/media/platform/ti-vpe/cal.c
> > @@ -0,0 +1,2143 @@
> > +/*
> > + * TI CAL camera interface driver
> > + *
> > + * Copyright (c) 2015 Texas Instruments Inc.
> > + * Benoit Parrot, 
> > + *
> > + * This program is free software; you can redistribute it and/or modify it
> > + * under the terms of the GNU General Public License version 2 as 
> > published by
> > + * the Free Software Foundation
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include "cal_regs.h"
> > +
> > +#define CAL_MODULE_NAME "cal"
> > +
> > +#define MAX_WIDTH 1920
> > +#define MAX_HEIGHT 1200
> > +
> > +#define CAL_VERSION "0.1.0"
> > +
> > +MODULE_DESCRIPTION("TI CAL driver");
> > +MODULE_AUTHOR("Benoit Parrot, ");
> > +MODULE_LICENSE("GPL v2");
> > +MODULE_VERSION(CAL_VERSION);
> > +
> > +static unsigned video_nr = -1;
> > +module_param(video_nr, uint, 0644);
> > +MODULE_PARM_DESC(video_nr, "videoX start number, -1 is autodetect");
> > +
> > +static unsigned debug;
> > 

[PATCH v5 0/3] [media] Fix race between graph enumeration and entities registration

2015-12-11 Thread Javier Martinez Canillas
Hello,

This series fixes the issue of media device nodes being registered before
all the media entities and pads links are created so if user-space tries
to enumerate the graph too early, it may get a partial graph enumeration
since everything may not been registered yet.

The solution (suggested by Sakari Ailus) is to separate the media device
registration from the initialization so drivers can first initialize the
media device, create the graph and then finally register the media device
node once is finished.

This is the fifth version of the series and is a rebase on top of latest
MC next gen and the only important change is the addition of patch 3/3.

Patch #1 adds a check to the media_device_unregister() function to know if
the media device has been registed yet so calling it will be safe and the
cleanup functions of the drivers won't need to be changed in case register
failed.

Patch #2 does the init and registration split, changing all the drivers to
make the change atomic and also adds a cleanup function for media devices.

Patch #3 sets a topology version 0 at media device registration to allow
user-space to know that the graph is "static" (i.e: no graph updates after
the media device was registered).

Best regards,
Javier

Changes in v5:
- Add kernel-doc for media_device_init() and media_device_register().

Changes in v4:
- Remove the model check from BUG_ON() since shold not be fatal.
  Suggested by Sakari Ailus.

Changes in v3:
- Replace the WARN_ON() in media_device_init() for a BUG_ON().
  Suggested by Sakari Ailus.

Changes in v2:
- Reword the documentation for media_device_unregister(). Suggested by Sakari.
- Added Sakari's Acked-by tag for patch #1.
- Reword the documentation for media_device_unregister(). Suggested by Sakari.
- Added Sakari's Acked-by tag for patch #1.
- Change media_device_init() to return void instead of an error.
  Suggested by Sakari Ailus.
- Remove the error messages when media_device_register() fails.
  Suggested by Sakari Ailus.
- Fix typos in commit message of patch #2. Suggested by Sakari Ailus.

Javier Martinez Canillas (3):
  [media] media-device: check before unregister if mdev was registered
  [media] media-device: split media initialization and registration
  [media] media-device: set topology version 0 at media registration

 drivers/media/common/siano/smsdvb-main.c  |  1 +
 drivers/media/media-device.c  | 46 +++
 drivers/media/platform/exynos4-is/media-dev.c | 15 -
 drivers/media/platform/omap3isp/isp.c | 14 
 drivers/media/platform/s3c-camif/camif-core.c | 15 ++---
 drivers/media/platform/vsp1/vsp1_drv.c| 12 +++
 drivers/media/platform/xilinx/xilinx-vipp.c   | 12 +++
 drivers/media/usb/au0828/au0828-core.c| 27 
 drivers/media/usb/cx231xx/cx231xx-cards.c | 30 -
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c   | 23 --
 drivers/media/usb/dvb-usb/dvb-usb-dvb.c   | 24 --
 drivers/media/usb/siano/smsusb.c  |  5 +--
 drivers/media/usb/uvc/uvc_driver.c| 10 --
 include/media/media-device.h  | 26 +++
 14 files changed, 165 insertions(+), 95 deletions(-)

-- 
2.4.3

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


[PATCH v5 2/3] [media] media-device: split media initialization and registration

2015-12-11 Thread Javier Martinez Canillas
The media device node is registered and so made visible to user-space
before entities are registered and links created which means that the
media graph obtained by user-space could be only partially enumerated
if that happens too early before all the graph has been created.

To avoid this race condition, split the media init and registration
in separate functions and only register the media device node when
all the pending subdevices have been registered, either explicitly
by the driver or asynchronously using v4l2_async_register_subdev().

The media_device_register() had a check for drivers not filling dev
and model fields but all drivers in mainline set them and not doing
it will be a driver bug so change the function return to void and
add a BUG_ON() for dev being NULL instead.

Also, add a media_device_cleanup() function that will destroy the
graph_mutex that is initialized in media_device_init().

Suggested-by: Sakari Ailus 
Signed-off-by: Javier Martinez Canillas 
Acked-by: Sakari Ailus 

---

Changes in v5:
- Add kernel-doc for media_device_init() and media_device_register().

Changes in v4:
- Remove the model check from BUG_ON() since shold not be fatal.
  Suggested by Sakari Ailus.

Changes in v3:
- Replace the WARN_ON() in media_device_init() for a BUG_ON().
  Suggested by Sakari Ailus.

Changes in v2:
- Reword the documentation for media_device_unregister(). Suggested by Sakari.
- Added Sakari's Acked-by tag for patch #1.
- Change media_device_init() to return void instead of an error.
  Suggested by Sakari Ailus.
- Remove the error messages when media_device_register() fails.
  Suggested by Sakari Ailus.
- Fix typos in commit message of patch #2. Suggested by Sakari Ailus.

 drivers/media/common/siano/smsdvb-main.c  |  1 +
 drivers/media/media-device.c  | 36 ++-
 drivers/media/platform/exynos4-is/media-dev.c | 15 ++-
 drivers/media/platform/omap3isp/isp.c | 14 +--
 drivers/media/platform/s3c-camif/camif-core.c | 15 +++
 drivers/media/platform/vsp1/vsp1_drv.c| 12 -
 drivers/media/platform/xilinx/xilinx-vipp.c   | 12 +++--
 drivers/media/usb/au0828/au0828-core.c| 27 ++--
 drivers/media/usb/cx231xx/cx231xx-cards.c | 30 +++---
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c   | 23 +
 drivers/media/usb/dvb-usb/dvb-usb-dvb.c   | 24 ++
 drivers/media/usb/siano/smsusb.c  |  5 ++--
 drivers/media/usb/uvc/uvc_driver.c| 10 +---
 include/media/media-device.h  | 26 +++
 14 files changed, 155 insertions(+), 95 deletions(-)

diff --git a/drivers/media/common/siano/smsdvb-main.c 
b/drivers/media/common/siano/smsdvb-main.c
index ab345490a43a..8a1ea2192439 100644
--- a/drivers/media/common/siano/smsdvb-main.c
+++ b/drivers/media/common/siano/smsdvb-main.c
@@ -617,6 +617,7 @@ static void smsdvb_media_device_unregister(struct 
smsdvb_client_t *client)
if (!coredev->media_dev)
return;
media_device_unregister(coredev->media_dev);
+   media_device_cleanup(coredev->media_dev);
kfree(coredev->media_dev);
coredev->media_dev = NULL;
 #endif
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 11c1c7383361..5d5c8a57e7ba 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -529,7 +529,7 @@ static void media_device_release(struct media_devnode *mdev)
 }
 
 /**
- * media_device_register - register a media device
+ * media_device_init() - initialize a media device
  * @mdev:  The media device
  *
  * The caller is responsible for initializing the media device before
@@ -538,13 +538,10 @@ static void media_device_release(struct media_devnode 
*mdev)
  * - dev must point to the parent device
  * - model must be filled with the device model name
  */
-int __must_check __media_device_register(struct media_device *mdev,
-struct module *owner)
+void media_device_init(struct media_device *mdev)
 {
-   int ret;
 
-   if (WARN_ON(mdev->dev == NULL || mdev->model[0] == 0))
-   return -EINVAL;
+   BUG_ON(mdev->dev == NULL);
 
INIT_LIST_HEAD(>entities);
INIT_LIST_HEAD(>interfaces);
@@ -553,6 +550,33 @@ int __must_check __media_device_register(struct 
media_device *mdev,
spin_lock_init(>lock);
mutex_init(>graph_mutex);
 
+   dev_dbg(mdev->dev, "Media device initialized\n");
+}
+EXPORT_SYMBOL_GPL(media_device_init);
+
+/**
+ * media_device_cleanup() - Cleanup a media device
+ * @mdev:  The media device
+ *
+ */
+void media_device_cleanup(struct media_device *mdev)
+{
+   mutex_destroy(>graph_mutex);
+}
+EXPORT_SYMBOL_GPL(media_device_cleanup);
+
+/**
+ * __media_device_register() - register a media device
+ * 

[PATCH v5 1/3] [media] media-device: check before unregister if mdev was registered

2015-12-11 Thread Javier Martinez Canillas
Most media functions that unregister, check if the corresponding register
function succeed before. So these functions can safely be called even if a
registration was never made or the component as already been unregistered.

Add the same check to media_device_unregister() function for consistency.

This will also allow to split the media_device_register() function in an
initialization and registration functions without the need to change the
generic cleanup functions and error code paths for all the media drivers.

Suggested-by: Sakari Ailus 
Signed-off-by: Javier Martinez Canillas 
Acked-by: Sakari Ailus 

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- Reword the documentation for media_device_unregister(). Suggested by Sakari.
- Added Sakari's Acked-by tag for patch #1.

 drivers/media/media-device.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index c12481c753a0..11c1c7383361 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -577,6 +577,8 @@ EXPORT_SYMBOL_GPL(__media_device_register);
  * media_device_unregister - unregister a media device
  * @mdev:  The media device
  *
+ * It is safe to call this function on an unregistered
+ * (but initialised) media device.
  */
 void media_device_unregister(struct media_device *mdev)
 {
@@ -584,6 +586,10 @@ void media_device_unregister(struct media_device *mdev)
struct media_entity *next;
struct media_interface *intf, *tmp_intf;
 
+   /* Check if mdev was ever registered at all */
+   if (!media_devnode_is_registered(>devnode))
+   return;
+
/* Remove all entities from the media device */
list_for_each_entry_safe(entity, next, >entities, graph_obj.list)
media_device_unregister_entity(entity);
-- 
2.4.3

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


[PATCH] v4l-utils: mc_nextgen_test fix compile warnings

2015-12-11 Thread Shuah Khan
Fix the following compile warnings:

  CC   mc_nextgen_test-mc_nextgen_test.o
mc_nextgen_test.c: In function ‘media_get_ifname’:
mc_nextgen_test.c:410:3: warning: ignoring return value of ‘asprintf’, declared 
with attribute warn_unused_result [-Wunused-result]
   asprintf(, "%s", devname);
   ^
mc_nextgen_test.c: In function ‘media_get_ifname_udev’:
mc_nextgen_test.c:335:4: warning: ignoring return value of ‘asprintf’, declared 
with attribute warn_unused_result [-Wunused-result]
asprintf(, "%s", p);
^
mc_nextgen_test.c: In function ‘objname’:
mc_nextgen_test.c:249:2: warning: ignoring return value of ‘asprintf’, declared 
with attribute warn_unused_result [-Wunused-result]
  asprintf(, "%s%c%d", gobj_type(id), delimiter, media_localid(id));
  ^

Signed-off-by: Shuah Khan 
---
 contrib/test/mc_nextgen_test.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/contrib/test/mc_nextgen_test.c b/contrib/test/mc_nextgen_test.c
index 743ddee..cf71bec 100644
--- a/contrib/test/mc_nextgen_test.c
+++ b/contrib/test/mc_nextgen_test.c
@@ -246,7 +246,11 @@ static inline const char *ent_function(uint32_t function)
 static char *objname(uint32_t id, char delimiter)
 {
char *name;
-   asprintf(, "%s%c%d", gobj_type(id), delimiter, media_localid(id));
+   int ret;
+
+   ret = asprintf(, "%s%c%d", gobj_type(id), delimiter, 
media_localid(id));
+   if (ret < 0)
+   return NULL;
 
return name;
 }
@@ -323,6 +327,7 @@ static char *media_get_ifname_udev(struct 
media_v2_intf_devnode *devnode, struct
dev_t devnum;
const char *p;
char *name = NULL;
+   int ret;
 
if (udev == NULL)
return NULL;
@@ -332,7 +337,9 @@ static char *media_get_ifname_udev(struct 
media_v2_intf_devnode *devnode, struct
if (device) {
p = udev_device_get_devnode(device);
if (p) {
-   asprintf(, "%s", p);
+   ret = asprintf(, "%s", p);
+   if (ret < 0)
+   return NULL;
}
}
 
@@ -406,9 +413,11 @@ char *media_get_ifname(struct media_v2_interface *intf, 
void *priv)
 * libudev.
 */
if (major(devstat.st_rdev) == intf->devnode.major &&
-   minor(devstat.st_rdev) == intf->devnode.minor)
-   asprintf(, "%s", devname);
-
+   minor(devstat.st_rdev) == intf->devnode.minor) {
+   ret = asprintf(, "%s", devname);
+   if (ret < 0)
+   return NULL;
+   }
return name;
 }
 
-- 
2.5.0

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


[PATCH v5 3/3] [media] media-device: set topology version 0 at media registration

2015-12-11 Thread Javier Martinez Canillas
The G_TOPOLOGY ioctl is used to get a graph topology and since in the
future a graph can be dynamically updated, there is a way to know the
topology version so userspace can be aware that the graph has changed.

The version 0 is reserved to indicate that the graph is static (i.e no
graphs updates since the media device was registered).

So, now that the media device initialization and registration has been
split and the media device node is not exposed to user-space until all
the entities have been registered and links created, it is safe to set
a topology version 0 in media_device_register().

Suggested-by: Mauro Carvalho Chehab 
Signed-off-by: Javier Martinez Canillas 

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/media/media-device.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 5d5c8a57e7ba..d166cf5ad3ff 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -581,6 +581,10 @@ int __must_check __media_device_register(struct 
media_device *mdev,
mdev->devnode.fops = _device_fops;
mdev->devnode.parent = mdev->dev;
mdev->devnode.release = media_device_release;
+
+   /* Set version 0 to indicate user-space that the graph is static */
+   mdev->topology_version = 0;
+
ret = media_devnode_register(>devnode, owner);
if (ret < 0)
return ret;
-- 
2.4.3

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


cron job: media_tree daily build: ERRORS

2015-12-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:   Sat Dec 12 04:00:19 CET 2015
git branch: test
git hash:   991ce92f8de24cde063d531246602b6e14d3fef2
gcc version:i686-linux-gcc (GCC) 5.1.0
sparse version: v0.5.0
smatch version: v0.5.0-3202-g618e15b
host hardware:  x86_64
host os:4.2.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.32.27-i686: ERRORS
linux-2.6.33.7-i686: ERRORS
linux-2.6.34.7-i686: ERRORS
linux-2.6.35.9-i686: ERRORS
linux-2.6.36.4-i686: ERRORS
linux-2.6.37.6-i686: ERRORS
linux-2.6.38.8-i686: ERRORS
linux-2.6.39.4-i686: ERRORS
linux-3.0.60-i686: ERRORS
linux-3.1.10-i686: ERRORS
linux-3.2.37-i686: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.4.27-i686: ERRORS
linux-3.5.7-i686: ERRORS
linux-3.6.11-i686: ERRORS
linux-3.7.4-i686: ERRORS
linux-3.8-i686: ERRORS
linux-3.9.2-i686: ERRORS
linux-3.10.1-i686: ERRORS
linux-3.11.1-i686: ERRORS
linux-3.12.23-i686: ERRORS
linux-3.13.11-i686: ERRORS
linux-3.14.9-i686: ERRORS
linux-3.15.2-i686: ERRORS
linux-3.16.7-i686: 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-rc1-i686: OK
linux-2.6.32.27-x86_64: ERRORS
linux-2.6.33.7-x86_64: ERRORS
linux-2.6.34.7-x86_64: ERRORS
linux-2.6.35.9-x86_64: ERRORS
linux-2.6.36.4-x86_64: ERRORS
linux-2.6.37.6-x86_64: ERRORS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-x86_64: ERRORS
linux-3.0.60-x86_64: ERRORS
linux-3.1.10-x86_64: ERRORS
linux-3.2.37-x86_64: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: ERRORS
linux-3.5.7-x86_64: ERRORS
linux-3.6.11-x86_64: ERRORS
linux-3.7.4-x86_64: ERRORS
linux-3.8-x86_64: ERRORS
linux-3.9.2-x86_64: ERRORS
linux-3.10.1-x86_64: ERRORS
linux-3.11.1-x86_64: ERRORS
linux-3.12.23-x86_64: ERRORS
linux-3.13.11-x86_64: ERRORS
linux-3.14.9-x86_64: ERRORS
linux-3.15.2-x86_64: ERRORS
linux-3.16.7-x86_64: 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-rc1-x86_64: OK
apps: WARNINGS
spec-git: WARNINGS
sparse: ERRORS
smatch: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/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 07/10] [media] v4l: vsp1: use else if instead of continue when creating links

2015-12-11 Thread Javier Martinez Canillas
The for loop in the vsp1_create_entities() function that create the links,
checks the entity type and call the proper link creation function but then
it uses continue to force the next iteration of the loop to take place and
skipping code in between that creates links for different entities types.

It is more readable and easier to understand if the if else constructs is
used instead of the continue statement.

Suggested-by: Laurent Pinchart 
Signed-off-by: Javier Martinez Canillas 


This patch addresses an issue pointed out by Laurent in patch [0]:

- Use if else instead of continue.

[0]: http://www.spinics.net/lists/linux-media/msg95316.html
END

---

 drivers/media/platform/vsp1/vsp1_drv.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drv.c 
b/drivers/media/platform/vsp1/vsp1_drv.c
index 4209d8615f72..0b251147bfff 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -264,19 +264,15 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
ret = vsp1_wpf_create_links(vsp1, entity);
if (ret < 0)
goto done;
-   continue;
-   }
-
-   if (entity->type == VSP1_ENTITY_RPF) {
+   } else if (entity->type == VSP1_ENTITY_RPF) {
ret = vsp1_rpf_create_links(vsp1, entity);
if (ret < 0)
goto done;
-   continue;
+   } else {
+   ret = vsp1_create_links(vsp1, entity);
+   if (ret < 0)
+   goto done;
}
-
-   ret = vsp1_create_links(vsp1, entity);
-   if (ret < 0)
-   goto done;
}
 
if (vsp1->pdata.features & VSP1_HAS_LIF) {
-- 
2.4.3

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


[PATCH 06/10] [media] v4l: vsp1: remove pads prefix from *_create_pads_links()

2015-12-11 Thread Javier Martinez Canillas
The functions that create entities links are called *_create_pads_links()
but the "pads" prefix is redundant since the driver doesn't handle any
other kind of link so it can be removed.

Suggested-by: Laurent Pinchart 
Signed-off-by: Javier Martinez Canillas 


This patch addresses an issue Laurent pointed in patch [0]:

- Could you please s/pads_links/links/ and s/pads links/links/

[0]: http://www.spinics.net/lists/linux-media/msg95316.html
END

---

 drivers/media/platform/vsp1/vsp1_drv.c  | 4 ++--
 drivers/media/platform/vsp1/vsp1_rpf.c  | 4 ++--
 drivers/media/platform/vsp1/vsp1_rwpf.h | 4 ++--
 drivers/media/platform/vsp1/vsp1_wpf.c  | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drv.c 
b/drivers/media/platform/vsp1/vsp1_drv.c
index 8f995d267646..4209d8615f72 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -261,14 +261,14 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
/* Create links. */
list_for_each_entry(entity, >entities, list_dev) {
if (entity->type == VSP1_ENTITY_LIF) {
-   ret = vsp1_wpf_create_pads_links(vsp1, entity);
+   ret = vsp1_wpf_create_links(vsp1, entity);
if (ret < 0)
goto done;
continue;
}
 
if (entity->type == VSP1_ENTITY_RPF) {
-   ret = vsp1_rpf_create_pads_links(vsp1, entity);
+   ret = vsp1_rpf_create_links(vsp1, entity);
if (ret < 0)
goto done;
continue;
diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c 
b/drivers/media/platform/vsp1/vsp1_rpf.c
index 847fb6d01a5a..924538223d3e 100644
--- a/drivers/media/platform/vsp1/vsp1_rpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rpf.c
@@ -285,13 +285,13 @@ error:
 }
 
 /*
- * vsp1_rpf_create_pads_links_create_pads_links() - RPF pads links creation
+ * vsp1_rpf_create_links() - RPF pads links creation
  * @vsp1: Pointer to VSP1 device
  * @entity: Pointer to VSP1 entity
  *
  * return negative error code or zero on success
  */
-int vsp1_rpf_create_pads_links(struct vsp1_device *vsp1,
+int vsp1_rpf_create_links(struct vsp1_device *vsp1,
   struct vsp1_entity *entity)
 {
struct vsp1_rwpf *rpf = to_rwpf(>subdev);
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h 
b/drivers/media/platform/vsp1/vsp1_rwpf.h
index 6638b3587369..731d36e5258d 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.h
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.h
@@ -50,9 +50,9 @@ static inline struct vsp1_rwpf *to_rwpf(struct v4l2_subdev 
*subdev)
 struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int 
index);
 struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int 
index);
 
-int vsp1_rpf_create_pads_links(struct vsp1_device *vsp1,
+int vsp1_rpf_create_links(struct vsp1_device *vsp1,
   struct vsp1_entity *entity);
-int vsp1_wpf_create_pads_links(struct vsp1_device *vsp1,
+int vsp1_wpf_create_links(struct vsp1_device *vsp1,
   struct vsp1_entity *entity);
 
 int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev,
diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c 
b/drivers/media/platform/vsp1/vsp1_wpf.c
index 969278bc1d41..cbf514a6582d 100644
--- a/drivers/media/platform/vsp1/vsp1_wpf.c
+++ b/drivers/media/platform/vsp1/vsp1_wpf.c
@@ -285,13 +285,13 @@ error:
 }
 
 /*
- * vsp1_wpf_create_pads_links_create_pads_links() - RPF pads links creation
+ * vsp1_wpf_create_links() - RPF pads links creation
  * @vsp1: Pointer to VSP1 device
  * @entity: Pointer to VSP1 entity
  *
  * return negative error code or zero on success
  */
-int vsp1_wpf_create_pads_links(struct vsp1_device *vsp1,
+int vsp1_wpf_create_links(struct vsp1_device *vsp1,
   struct vsp1_entity *entity)
 {
struct vsp1_rwpf *wpf = to_rwpf(>subdev);
-- 
2.4.3

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


[PATCH 09/10] [media] uvcvideo: register entity subdev on init

2015-12-11 Thread Javier Martinez Canillas
The uvc_mc_register_entities() function iterated over the entities three
times to initialize the entities, register the subdev for the ones whose
type was UVC_TT_STREAMING and to create the entities links.

But this can be simplied by merging the init and registration logic in a
single loop.

Suggested-by: Laurent Pinchart 
Signed-off-by: Javier Martinez Canillas 

---

This patch addresses an issue Laurent pointed in patch [0]:

- Move the  v4l2_device_register_subdev() call to uvc_mc_init_entity().

[0]: https://lkml.org/lkml/2015/12/5/253

 drivers/media/usb/uvc/uvc_entity.c | 33 +
 1 file changed, 9 insertions(+), 24 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_entity.c 
b/drivers/media/usb/uvc/uvc_entity.c
index 33119dcb7cec..ac386bb547e6 100644
--- a/drivers/media/usb/uvc/uvc_entity.c
+++ b/drivers/media/usb/uvc/uvc_entity.c
@@ -19,19 +19,6 @@
 
 #include "uvcvideo.h"
 
-/* 
- * Video subdevices registration and unregistration
- */
-
-static int uvc_mc_register_entity(struct uvc_video_chain *chain,
-   struct uvc_entity *entity)
-{
-   if (UVC_ENTITY_TYPE(entity) == UVC_TT_STREAMING)
-   return 0;
-
-   return v4l2_device_register_subdev(>dev->vdev, >subdev);
-}
-
 static int uvc_mc_create_links(struct uvc_video_chain *chain,
struct uvc_entity *entity)
 {
@@ -85,7 +72,8 @@ void uvc_mc_cleanup_entity(struct uvc_entity *entity)
media_entity_cleanup(>vdev->entity);
 }
 
-static int uvc_mc_init_entity(struct uvc_entity *entity)
+static int uvc_mc_init_entity(struct uvc_video_chain *chain,
+ struct uvc_entity *entity)
 {
int ret;
 
@@ -96,6 +84,12 @@ static int uvc_mc_init_entity(struct uvc_entity *entity)
 
ret = media_entity_pads_init(>subdev.entity,
entity->num_pads, entity->pads);
+
+   if (ret < 0)
+   return ret;
+
+   ret = v4l2_device_register_subdev(>dev->vdev,
+ >subdev);
} else if (entity->vdev != NULL) {
ret = media_entity_pads_init(>vdev->entity,
entity->num_pads, entity->pads);
@@ -113,7 +107,7 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain)
int ret;
 
list_for_each_entry(entity, >entities, chain) {
-   ret = uvc_mc_init_entity(entity);
+   ret = uvc_mc_init_entity(chain, entity);
if (ret < 0) {
uvc_printk(KERN_INFO, "Failed to initialize entity for "
   "entity %u\n", entity->id);
@@ -122,15 +116,6 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain)
}
 
list_for_each_entry(entity, >entities, chain) {
-   ret = uvc_mc_register_entity(chain, entity);
-   if (ret < 0) {
-   uvc_printk(KERN_INFO, "Failed to register entity for "
-  "entity %u\n", entity->id);
-   return ret;
-   }
-   }
-
-   list_for_each_entry(entity, >entities, chain) {
ret = uvc_mc_create_links(chain, entity);
if (ret < 0) {
uvc_printk(KERN_INFO, "Failed to create links for "
-- 
2.4.3

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


[PATCH 05/10] [media] staging: omap4iss: remove pads prefix from *_create_pads_links()

2015-12-11 Thread Javier Martinez Canillas
The functions that create ISS internal and external entities links are
called *_create_pads_links() but the "pads" prefix is redundant since
the driver doesn't handle any other kind of link so it can be removed.

Suggested-by: Laurent Pinchart 
Signed-off-by: Javier Martinez Canillas 

---

This patch addresses an issue Laurent pointed in patch [0]:

- Could you please s/pads_links/links/ and s/pads links/links/

[0]: https://lkml.org/lkml/2015/12/5/256

 drivers/staging/media/omap4iss/iss.c | 12 ++--
 drivers/staging/media/omap4iss/iss_csi2.c|  4 ++--
 drivers/staging/media/omap4iss/iss_csi2.h|  2 +-
 drivers/staging/media/omap4iss/iss_ipipeif.c |  4 ++--
 drivers/staging/media/omap4iss/iss_ipipeif.h |  2 +-
 drivers/staging/media/omap4iss/iss_resizer.c |  4 ++--
 drivers/staging/media/omap4iss/iss_resizer.h |  2 +-
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/media/omap4iss/iss.c 
b/drivers/staging/media/omap4iss/iss.c
index 28e4d16544eb..7209b92b1f86 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -1273,28 +1273,28 @@ done:
 }
 
 /*
- * iss_create_pads_links() - Pads links creation for the subdevices
+ * iss_create_links() - Pads links creation for the subdevices
  * @iss : Pointer to ISS device
  *
  * return negative error code or zero on success
  */
-static int iss_create_pads_links(struct iss_device *iss)
+static int iss_create_links(struct iss_device *iss)
 {
int ret;
 
-   ret = omap4iss_csi2_create_pads_links(iss);
+   ret = omap4iss_csi2_create_links(iss);
if (ret < 0) {
dev_err(iss->dev, "CSI2 pads links creation failed\n");
return ret;
}
 
-   ret = omap4iss_ipipeif_create_pads_links(iss);
+   ret = omap4iss_ipipeif_create_links(iss);
if (ret < 0) {
dev_err(iss->dev, "ISP IPIPEIF pads links creation failed\n");
return ret;
}
 
-   ret = omap4iss_resizer_create_pads_links(iss);
+   ret = omap4iss_resizer_create_links(iss);
if (ret < 0) {
dev_err(iss->dev, "ISP RESIZER pads links creation failed\n");
return ret;
@@ -1491,7 +1491,7 @@ static int iss_probe(struct platform_device *pdev)
if (ret < 0)
goto error_modules;
 
-   ret = iss_create_pads_links(iss);
+   ret = iss_create_links(iss);
if (ret < 0)
goto error_entities;
 
diff --git a/drivers/staging/media/omap4iss/iss_csi2.c 
b/drivers/staging/media/omap4iss/iss_csi2.c
index f0fa037ce173..aaca39d751a5 100644
--- a/drivers/staging/media/omap4iss/iss_csi2.c
+++ b/drivers/staging/media/omap4iss/iss_csi2.c
@@ -1339,12 +1339,12 @@ int omap4iss_csi2_init(struct iss_device *iss)
 }
 
 /*
- * omap4iss_csi2_create_pads_links() - CSI2 pads links creation
+ * omap4iss_csi2_create_links() - CSI2 pads links creation
  * @iss: Pointer to ISS device
  *
  * return negative error code or zero on success
  */
-int omap4iss_csi2_create_pads_links(struct iss_device *iss)
+int omap4iss_csi2_create_links(struct iss_device *iss)
 {
struct iss_csi2_device *csi2a = >csi2a;
struct iss_csi2_device *csi2b = >csi2b;
diff --git a/drivers/staging/media/omap4iss/iss_csi2.h 
b/drivers/staging/media/omap4iss/iss_csi2.h
index 1d5a0d8222a9..24ab378d469f 100644
--- a/drivers/staging/media/omap4iss/iss_csi2.h
+++ b/drivers/staging/media/omap4iss/iss_csi2.h
@@ -151,7 +151,7 @@ struct iss_csi2_device {
 void omap4iss_csi2_isr(struct iss_csi2_device *csi2);
 int omap4iss_csi2_reset(struct iss_csi2_device *csi2);
 int omap4iss_csi2_init(struct iss_device *iss);
-int omap4iss_csi2_create_pads_links(struct iss_device *iss);
+int omap4iss_csi2_create_links(struct iss_device *iss);
 void omap4iss_csi2_cleanup(struct iss_device *iss);
 void omap4iss_csi2_unregister_entities(struct iss_csi2_device *csi2);
 int omap4iss_csi2_register_entities(struct iss_csi2_device *csi2,
diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c 
b/drivers/staging/media/omap4iss/iss_ipipeif.c
index 88b22f7f8b13..23de8330731d 100644
--- a/drivers/staging/media/omap4iss/iss_ipipeif.c
+++ b/drivers/staging/media/omap4iss/iss_ipipeif.c
@@ -815,12 +815,12 @@ int omap4iss_ipipeif_init(struct iss_device *iss)
 }
 
 /*
- * omap4iss_ipipeif_create_pads_links() - IPIPEIF pads links creation
+ * omap4iss_ipipeif_create_links() - IPIPEIF pads links creation
  * @iss: Pointer to ISS device
  *
  * return negative error code or zero on success
  */
-int omap4iss_ipipeif_create_pads_links(struct iss_device *iss)
+int omap4iss_ipipeif_create_links(struct iss_device *iss)
 {
struct iss_ipipeif_device *ipipeif = >ipipeif;
 
diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.h 
b/drivers/staging/media/omap4iss/iss_ipipeif.h
index dd906b41cf9b..bad32b1d6ad8 100644
--- 

[PATCH 08/10] [media] uvcvideo: remove pads prefix from uvc_mc_create_pads_links()

2015-12-11 Thread Javier Martinez Canillas
The function uvc_mc_create_pads_links() creates entities links but the
"pads" prefix is redundant since the driver doesn't handle any other
kind of link, so it can be removed.

Suggested-by: Laurent Pinchart 
Signed-off-by: Javier Martinez Canillas 

---

This patch addresses an issue Laurent pointed in patch [0]:

- You can call this uvc_mc_create_links(), there's no other type of links.

[0]: https://lkml.org/lkml/2015/12/5/253

 drivers/media/usb/uvc/uvc_entity.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_entity.c 
b/drivers/media/usb/uvc/uvc_entity.c
index 38e893a1408b..33119dcb7cec 100644
--- a/drivers/media/usb/uvc/uvc_entity.c
+++ b/drivers/media/usb/uvc/uvc_entity.c
@@ -32,7 +32,7 @@ static int uvc_mc_register_entity(struct uvc_video_chain 
*chain,
return v4l2_device_register_subdev(>dev->vdev, >subdev);
 }
 
-static int uvc_mc_create_pads_links(struct uvc_video_chain *chain,
+static int uvc_mc_create_links(struct uvc_video_chain *chain,
struct uvc_entity *entity)
 {
const u32 flags = MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE;
@@ -131,9 +131,9 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain)
}
 
list_for_each_entry(entity, >entities, chain) {
-   ret = uvc_mc_create_pads_links(chain, entity);
+   ret = uvc_mc_create_links(chain, entity);
if (ret < 0) {
-   uvc_printk(KERN_INFO, "Failed to create pads links for "
+   uvc_printk(KERN_INFO, "Failed to create links for "
   "entity %u\n", entity->id);
return ret;
}
-- 
2.4.3

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


[PATCH 10/10] [media] media-entity: remove unneded enclosing parenthesis

2015-12-11 Thread Javier Martinez Canillas
Commit 86ee417578a2 ("[media] media: convert links from array to list")
had many changes that were automated using coccinelle but the semantic
patch was not smart enough to rely on operators precedence and avoid
using unnecessary enclosing parenthesis.

This patch removes them since are not needed.

Suggested-by: Laurent Pinchart 
Signed-off-by: Javier Martinez Canillas 

---

This patch addresses an issue Laurent pointed in patch [0]:

- No need for parentheses

[0]: [media-workshop] [PATCH v8.4 24/83] [media] media: convert links
from array to list

(unfortunately I didn't find a public archive for the media-workshop ML).

 drivers/media/media-entity.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index ada2b44ea4e1..181ca0de6e52 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -225,7 +225,7 @@ static void stack_push(struct media_entity_graph *graph,
return;
}
graph->top++;
-   graph->stack[graph->top].link = (>links)->next;
+   graph->stack[graph->top].link = entity->links.next;
graph->stack[graph->top].entity = entity;
 }
 
@@ -268,7 +268,7 @@ media_entity_graph_walk_next(struct media_entity_graph 
*graph)
 * top of the stack until no more entities on the level can be
 * found.
 */
-   while (link_top(graph) != &(stack_top(graph)->links)) {
+   while (link_top(graph) != _top(graph)->links) {
struct media_entity *entity = stack_top(graph);
struct media_link *link;
struct media_entity *next;
-- 
2.4.3

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


Re: [PATCH 3/3] media: adv7604: update timings on change of input signal

2015-12-11 Thread Sergei Shtylyov

Hello.

On 12/11/2015 07:04 PM, Ulrich Hecht wrote:


Without this, g_crop will always return the boot-time state.

Signed-off-by: Ulrich Hecht 
---
  drivers/media/i2c/adv7604.c | 9 +
  1 file changed, 9 insertions(+)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 1bfa9f3..d7d0bb7 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1975,6 +1975,15 @@ static int adv76xx_isr(struct v4l2_subdev *sd, u32 
status, bool *handled)

v4l2_subdev_notify_event(sd, _ev_fmt);

+   /* update timings */
+   if (adv76xx_query_dv_timings(sd, >timings)
+   == -ENOLINK) {


   Please don't put the binary operators on the continuation line, leave them 
at the end of he broken up line.


[...]

MBR, Sergei

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


[PATCH 04/10] [media] omap3isp: consistently use v4l2_dev var in complete notifier

2015-12-11 Thread Javier Martinez Canillas
The isp_subdev_notifier_complete() complete callback defines a struct
v4l2_device *v4l2_dev to avoid needing two level of indirections to
access the V4L2 subdevs but the var is not always used when possible
as when calling v4l2_device_register_subdev_nodes().

So change that to consistently use the defined v4l2_dev pointer var.

Suggested-by: Sakari Ailus 
Signed-off-by: Javier Martinez Canillas 


This patch addresses an issue pointed out by Sakari in patch [0]:

- Don't mix struct v4l2_device *v4l2_dev and >v4l2_dev usage.

[0]: http://linuxtv.org/pipermail/media-workshop/2015-October/000928.html
END

---

 drivers/media/platform/omap3isp/isp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index fb17746e4209..8226eca83327 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -2365,7 +2365,7 @@ static int isp_subdev_notifier_complete(struct 
v4l2_async_notifier *async)
}
}
 
-   return v4l2_device_register_subdev_nodes(>v4l2_dev);
+   return v4l2_device_register_subdev_nodes(v4l2_dev);
 }
 
 /*
-- 
2.4.3

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


[PATCH 01/10] [media] omap3isp: remove per ISP module link creation functions

2015-12-11 Thread Javier Martinez Canillas
The entities to video nodes links were created on separate functions for
each ISP module but since the only thing that these functions do is to
call media_create_pad_link(), there's no need for that indirection level
and all link creation logic can be just inlined in the caller function.

Also, since the only possible failure for the link creation is a memory
allocation, there is no need for error messages since the core already
reports a very verbose message in that case.

Suggested-by: Laurent Pinchart 
Signed-off-by: Javier Martinez Canillas 

---

This patch addresses 3 of the issues Laurent pointed in patch [0]:

1- Inline entity to video node links creation in the caller.
2- Remove error messages if links creation failed.
3- Replace comment for links between entities.

[0]: https://patchwork.linuxtv.org/patch/31147/

 drivers/media/platform/omap3isp/isp.c| 56 +---
 drivers/media/platform/omap3isp/ispccdc.c| 14 ---
 drivers/media/platform/omap3isp/ispccdc.h|  1 -
 drivers/media/platform/omap3isp/ispccp2.c| 14 ---
 drivers/media/platform/omap3isp/ispccp2.h|  1 -
 drivers/media/platform/omap3isp/ispcsi2.c| 14 ---
 drivers/media/platform/omap3isp/ispcsi2.h|  1 -
 drivers/media/platform/omap3isp/isppreview.c | 20 --
 drivers/media/platform/omap3isp/isppreview.h |  1 -
 drivers/media/platform/omap3isp/ispresizer.c | 20 --
 drivers/media/platform/omap3isp/ispresizer.h |  1 -
 11 files changed, 35 insertions(+), 108 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index cb8ac90086c1..40aee11805c7 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1940,37 +1940,51 @@ static int isp_create_pads_links(struct isp_device *isp)
 {
int ret;
 
-   ret = omap3isp_csi2_create_pads_links(isp);
-   if (ret < 0) {
-   dev_err(isp->dev, "CSI2 pads links creation failed\n");
+   /* Create links between entities and video nodes. */
+   ret = media_create_pad_link(
+   >isp_csi2a.subdev.entity, CSI2_PAD_SOURCE,
+   >isp_csi2a.video_out.video.entity, 0, 0);
+   if (ret < 0)
return ret;
-   }
 
-   ret = omap3isp_ccp2_create_pads_links(isp);
-   if (ret < 0) {
-   dev_err(isp->dev, "CCP2 pads links creation failed\n");
+   ret = media_create_pad_link(
+   >isp_ccp2.video_in.video.entity, 0,
+   >isp_ccp2.subdev.entity, CCP2_PAD_SINK, 0);
+   if (ret < 0)
return ret;
-   }
 
-   ret = omap3isp_ccdc_create_pads_links(isp);
-   if (ret < 0) {
-   dev_err(isp->dev, "CCDC pads links creation failed\n");
+   ret = media_create_pad_link(
+   >isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_OF,
+   >isp_ccdc.video_out.video.entity, 0, 0);
+   if (ret < 0)
return ret;
-   }
 
-   ret = omap3isp_preview_create_pads_links(isp);
-   if (ret < 0) {
-   dev_err(isp->dev, "Preview pads links creation failed\n");
+   ret = media_create_pad_link(
+   >isp_prev.video_in.video.entity, 0,
+   >isp_prev.subdev.entity, PREV_PAD_SINK, 0);
+   if (ret < 0)
return ret;
-   }
 
-   ret = omap3isp_resizer_create_pads_links(isp);
-   if (ret < 0) {
-   dev_err(isp->dev, "Resizer pads links creation failed\n");
+   ret = media_create_pad_link(
+   >isp_prev.subdev.entity, PREV_PAD_SOURCE,
+   >isp_prev.video_out.video.entity, 0, 0);
+   if (ret < 0)
+   return ret;
+
+   ret = media_create_pad_link(
+   >isp_res.video_in.video.entity, 0,
+   >isp_res.subdev.entity, RESZ_PAD_SINK, 0);
+   if (ret < 0)
+   return ret;
+
+   ret = media_create_pad_link(
+   >isp_res.subdev.entity, RESZ_PAD_SOURCE,
+   >isp_res.video_out.video.entity, 0, 0);
+
+   if (ret < 0)
return ret;
-   }
 
-   /* Connect the submodules. */
+   /* Create links between entities. */
ret = media_create_pad_link(
>isp_csi2a.subdev.entity, CSI2_PAD_SOURCE,
>isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0);
diff --git a/drivers/media/platform/omap3isp/ispccdc.c 
b/drivers/media/platform/omap3isp/ispccdc.c
index 749462c1af8e..5e16b5f594b7 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -2718,20 +2718,6 @@ int omap3isp_ccdc_init(struct isp_device *isp)
 }
 
 /*
- * omap3isp_ccdc_create_pads_links - CCDC pads links creation
- * @isp : Pointer to ISP device
- * return negative error 

[PATCH 03/10] [media] omap3isp: rename single labels to just error

2015-12-11 Thread Javier Martinez Canillas
Commit bc36b30fe06b ("[media] omap3isp: separate links creation from
entities init") moved the link creation logic from the entities init
functions and so removed the error_link labels from the error paths.

But after that, some functions have a single error label so it makes
more sense to rename the label to just "error" in thi case.

Suggested-by: Laurent Pinchart 
Signed-off-by: Javier Martinez Canillas 

---

This patch addresses the last remaining issue Laurent pointed in patch [0]:

1- Rename label to just "error" if there is a single error label.

[0]: https://patchwork.linuxtv.org/patch/31147/

 drivers/media/platform/omap3isp/ispccdc.c | 4 ++--
 drivers/media/platform/omap3isp/ispccp2.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/omap3isp/ispccdc.c 
b/drivers/media/platform/omap3isp/ispccdc.c
index 5e16b5f594b7..4eaf926d6073 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -2669,11 +2669,11 @@ static int ccdc_init_entities(struct isp_ccdc_device 
*ccdc)
 
ret = omap3isp_video_init(>video_out, "CCDC");
if (ret < 0)
-   goto error_video;
+   goto error;
 
return 0;
 
-error_video:
+error:
media_entity_cleanup(me);
return ret;
 }
diff --git a/drivers/media/platform/omap3isp/ispccp2.c 
b/drivers/media/platform/omap3isp/ispccp2.c
index 27f5fe4edefc..ca095238510d 100644
--- a/drivers/media/platform/omap3isp/ispccp2.c
+++ b/drivers/media/platform/omap3isp/ispccp2.c
@@ -1102,11 +1102,11 @@ static int ccp2_init_entities(struct isp_ccp2_device 
*ccp2)
 
ret = omap3isp_video_init(>video_in, "CCP2");
if (ret < 0)
-   goto error_video;
+   goto error;
 
return 0;
 
-error_video:
+error:
media_entity_cleanup(>subdev.entity);
return ret;
 }
-- 
2.4.3

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


[PATCH 00/10] [media] Some cleanup and fixes for MC next gen patches

2015-12-11 Thread Javier Martinez Canillas
Hello,

This series contains some cleanup and fixes for the MC next gen patches [0].

These addresses all the issues pointed out by Laurent and Sakari in patches
authored by me:

d125aeaa74da [media] media: don't try to empty links list in 
media_entity_cleanup()
46b30ba56a89 [media] uvcvideo: create pad links after subdev registration
eb9e99898333 [media] v4l: vsp1: separate links creation from entities init
5929e3a39544 [media] staging: omap4iss: separate links creation from entities 
init
f7cc083b0f0d [media] omap3isp: create links after all subdevs have been bound
bc36b30fe06b [media] omap3isp: separate links creation from entities init

and also for one issue in patch (authored by Mauro):

86ee417578a2 [media] media: convert links from array to list

The sha-1 ids are from the media_tree's media-controller branch [1].

This is not the full of the fixes since Mauro is going to post his patches
too but I tested rebasing on top of his media-controller-rc3 branch [3] and
there are no conflicts so it should be safe to post separately.

The patches were tested on an OMAP3 IGEPv2 that has a TVP5151 video encoder
and an Exynos5800 Peach Pi Chromebook that contains a UVC WebCam. For each
patch, the topology was retrieved with media-ctl -p and video capture was
tested using the yavta tool.

NOTE: I'm leaving for holidays tonight and I'll be back on December 20th so
I may not be able to answer and address any feedback before that day, sorry
about that.

[0]: https://www.mail-archive.com/linux-media@vger.kernel.org/msg94222.html
[1]: http://git.linuxtv.org/media_tree.git/log/?h=media-controller
[2]: http://git.linuxtv.org/mchehab/experimental.git/log/?h=media-controller-rc3

Best regards,
Javier


Javier Martinez Canillas (10):
  [media] omap3isp: remove per ISP module link creation functions
  [media] omap3isp: remove pads prefix from isp_create_pads_links()
  [media] omap3isp: rename single labels to just error
  [media] omap3isp: consistently use v4l2_dev var in complete notifier
  [media] staging: omap4iss: remove pads prefix from
*_create_pads_links()
  [media] v4l: vsp1: remove pads prefix from *_create_pads_links()
  [media] v4l: vsp1: use else if instead of continue when creating links
  [media] uvcvideo: remove pads prefix from uvc_mc_create_pads_links()
  [media] uvcvideo: register entity subdev on init
  [media] media-entity: remove unneded enclosing parenthesis

 drivers/media/media-entity.c |  4 +-
 drivers/media/platform/omap3isp/isp.c| 70 +---
 drivers/media/platform/omap3isp/ispccdc.c| 18 +--
 drivers/media/platform/omap3isp/ispccdc.h|  1 -
 drivers/media/platform/omap3isp/ispccp2.c| 18 +--
 drivers/media/platform/omap3isp/ispccp2.h|  1 -
 drivers/media/platform/omap3isp/ispcsi2.c| 14 --
 drivers/media/platform/omap3isp/ispcsi2.h|  1 -
 drivers/media/platform/omap3isp/isppreview.c | 20 
 drivers/media/platform/omap3isp/isppreview.h |  1 -
 drivers/media/platform/omap3isp/ispresizer.c | 20 
 drivers/media/platform/omap3isp/ispresizer.h |  1 -
 drivers/media/platform/vsp1/vsp1_drv.c   | 18 +++
 drivers/media/platform/vsp1/vsp1_rpf.c   |  4 +-
 drivers/media/platform/vsp1/vsp1_rwpf.h  |  4 +-
 drivers/media/platform/vsp1/vsp1_wpf.c   |  4 +-
 drivers/media/usb/uvc/uvc_entity.c   | 39 +---
 drivers/staging/media/omap4iss/iss.c | 12 ++---
 drivers/staging/media/omap4iss/iss_csi2.c|  4 +-
 drivers/staging/media/omap4iss/iss_csi2.h|  2 +-
 drivers/staging/media/omap4iss/iss_ipipeif.c |  4 +-
 drivers/staging/media/omap4iss/iss_ipipeif.h |  2 +-
 drivers/staging/media/omap4iss/iss_resizer.c |  4 +-
 drivers/staging/media/omap4iss/iss_resizer.h |  2 +-
 24 files changed, 90 insertions(+), 178 deletions(-)

-- 
2.4.3

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


[PATCH 02/10] [media] omap3isp: remove pads prefix from isp_create_pads_links()

2015-12-11 Thread Javier Martinez Canillas
The function that creates the links between ISP internal and external
entities is called isp_create_pads_links() but the "pads" prefix is
redundant since the driver doesn't handle any other kind of link so
it can just be removed.

While being there, fix the function's kernel-doc since is not using
a proper format.

Suggested-by: Laurent Pinchart 
Signed-off-by: Javier Martinez Canillas 

---

This patch addresses 2 remaining issues Laurent pointed in patch [0]:

1- Rename isp_create_pads_links() to isp_create_links().
2- Fix kernel-doc for the same function.

[0]: https://patchwork.linuxtv.org/patch/31147/

 drivers/media/platform/omap3isp/isp.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index 40aee11805c7..fb17746e4209 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1932,11 +1932,15 @@ done:
 }
 
 /*
- * isp_create_pads_links - Pads links creation for the subdevices
+ * isp_create_links() - Create links for internal and external ISP entities
  * @isp : Pointer to ISP device
- * return negative error code or zero on success
+ *
+ * This function creates all links between ISP internal and external entities.
+ *
+ * Return: A negative error code on failure or zero on success. Possible error
+ * codes are those returned by media_create_pad_link().
  */
-static int isp_create_pads_links(struct isp_device *isp)
+static int isp_create_links(struct isp_device *isp)
 {
int ret;
 
@@ -2527,7 +2531,7 @@ static int isp_probe(struct platform_device *pdev)
if (ret < 0)
goto error_modules;
 
-   ret = isp_create_pads_links(isp);
+   ret = isp_create_links(isp);
if (ret < 0)
goto error_register_entities;
 
-- 
2.4.3

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


Re: [PATCH v2 1/8] dt-bindings: Add a binding for Mediatek Video Processor

2015-12-11 Thread Rob Herring
On Fri, Dec 11, 2015 at 05:55:36PM +0800, Tiffany Lin wrote:
> From: Andrew-CT Chen 
> 
> Add a DT binding documentation of Video Processor Unit for the
> MT8173 SoC from Mediatek.
> 
> Signed-off-by: Andrew-CT Chen 
> Signed-off-by: Tiffany Lin 

Acked-by: Rob Herring 

> ---
>  .../devicetree/bindings/media/mediatek-vpu.txt |   27 
> 
>  1 file changed, 27 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/mediatek-vpu.txt
> 
> diff --git a/Documentation/devicetree/bindings/media/mediatek-vpu.txt 
> b/Documentation/devicetree/bindings/media/mediatek-vpu.txt
> new file mode 100644
> index 000..3c3a424
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/mediatek-vpu.txt
> @@ -0,0 +1,27 @@
> +* Mediatek Video Processor Unit
> +
> +Video Processor Unit is a HW video controller. It controls HW Codec including
> +H.264/VP8/VP9 Decode, H.264/VP8 Encode and Image Processor 
> (scale/rotate/color convert).
> +
> +Required properties:
> +  - compatible: "mediatek,mt8173-vpu"
> +  - reg: Must contain an entry for each entry in reg-names.
> +  - reg-names: Must include the following entries:
> +"tcm": tcm base
> +"cfg_reg": Main configuration registers base
> +  - interrupts: interrupt number to the cpu.
> +  - clocks : clock name from clock manager
> +  - clock-names: must be main. It is the main clock of VPU
> +  - iommus : phandle and IOMMU spcifier for the IOMMU that serves the VPU.
> +
> +Example:
> + vpu: vpu@1002 {
> + compatible = "mediatek,mt8173-vpu";
> + reg = <0 0x1002 0 0x3>,
> +   <0 0x1005 0 0x100>;
> + reg-names = "tcm", "cfg_reg";
> + interrupts = ;
> + clocks = < TOP_SCP_SEL>;
> + clock-names = "main";
> + iommus = < M4U_PORT_VENC_RCPU>;
> + };
> -- 
> 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


Re: [PATCH v2 4/8] dt-bindings: Add a binding for Mediatek Video Encoder

2015-12-11 Thread Rob Herring
On Fri, Dec 11, 2015 at 05:55:39PM +0800, Tiffany Lin wrote:
> Add a DT binding documentation of Video Encoder for the
> MT8173 SoC from Mediatek.
> 
> Signed-off-by: Tiffany Lin 

A question and minor issue below, otherwise:

Acked-by: Rob Herring 

> ---
>  .../devicetree/bindings/media/mediatek-vcodec.txt  |   58 
> 
>  1 file changed, 58 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> 
> diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt 
> b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> new file mode 100644
> index 000..510cd81
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> @@ -0,0 +1,58 @@
> +Mediatek Video Codec
> +
> +Mediatek Video Codec is the video codec hw present in Mediatek SoCs which
> +supports high resolution encoding functionalities.
> +
> +Required properties:
> +- compatible : "mediatek,mt8173-vcodec-enc" for encoder
> +- reg : Physical base address of the video codec registers and length of
> +  memory mapped region.
> +- interrupts : interrupt number to the cpu.
> +- mediatek,larb : must contain the local arbiters in the current Socs.
> +- clocks : list of clock specifiers, corresponding to entries in
> +  the clock-names property;
> +- clock-names: must contain "vencpll", "venc_lt_sel", "vcodecpll_370p5_ck"
> +- iommus : list of iommus specifiers should be enabled for hw encode.
> +  There are 2 cells needed to enable/disable iommu.
> +  The first one is local arbiter index(larbid), and the other is port
> +  index(portid) within local arbiter. Specifies the larbid and portid
> +  as defined in dt-binding/memory/mt8173-larb-port.h.
> +- mediatek,vpu : the node of video processor unit
> +
> +Example:
> +vcodec_enc: vcodec@0x18002000 {
> +compatible = "mediatek,mt8173-vcodec-enc";
> +reg = <0 0x18002000 0 0x1000>,/*VENC_SYS*/
> +  <0 0x19002000 0 0x1000>;/*VENC_LT_SYS*/
> +interrupts = ,
> +   ;
> +larb = <>,
> +   <>;
> +iommus = < M4U_LARB3_ID M4U_PORT_VENC_RCPU>,

Is this the same iommu as the VPU? If so, you can't have a mixed number 
of cells.

> + < M4U_LARB3_ID M4U_PORT_VENC_REC>,
> + < M4U_LARB3_ID M4U_PORT_VENC_BSDMA>,
> + < M4U_LARB3_ID M4U_PORT_VENC_SV_COMV>,
> + < M4U_LARB3_ID M4U_PORT_VENC_RD_COMV>,
> + < M4U_LARB3_ID M4U_PORT_VENC_CUR_LUMA>,
> + < M4U_LARB3_ID M4U_PORT_VENC_CUR_CHROMA>,
> + < M4U_LARB3_ID M4U_PORT_VENC_REF_LUMA>,
> + < M4U_LARB3_ID M4U_PORT_VENC_REF_CHROMA>,
> + < M4U_LARB3_ID M4U_PORT_VENC_NBM_RDMA>,
> + < M4U_LARB3_ID M4U_PORT_VENC_NBM_WDMA>,
> + < M4U_LARB5_ID M4U_PORT_VENC_RCPU_SET2>,
> + < M4U_LARB5_ID M4U_PORT_VENC_REC_FRM_SET2>,
> + < M4U_LARB5_ID M4U_PORT_VENC_BSDMA_SET2>,
> + < M4U_LARB5_ID M4U_PORT_VENC_SV_COMA_SET2>,
> + < M4U_LARB5_ID M4U_PORT_VENC_RD_COMA_SET2>,
> + < M4U_LARB5_ID M4U_PORT_VENC_CUR_LUMA_SET2>,
> + < M4U_LARB5_ID M4U_PORT_VENC_CUR_CHROMA_SET2>,
> + < M4U_LARB5_ID M4U_PORT_VENC_REF_LUMA_SET2>,
> + < M4U_LARB5_ID M4U_PORT_VENC_REC_CHROMA_SET2>;
> +vpu = <>;

Need to update the example.

> +clocks = < CLK_APMIXED_VENCPLL>,
> + < CLK_TOP_VENC_LT_SEL>,
> + < CLK_TOP_VCODECPLL_370P5>;
> +clock-names = "vencpll",
> +  "venc_lt_sel",
> +  "vcodecpll_370p5_ck";
> +  };
> -- 
> 1.7.9.5
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] media_entity: rename media_obj functions to *_create *_destroy

2015-12-11 Thread Mauro Carvalho Chehab
Those media_obj_* functions are actually creating/destroying
media graph objects. So, rename them to better represent
what they're actually doing.

No functional changes.

This was created via this small shell script:

for i in $(git grep -l media_gobj_init); do sed 
s,media_gobj_init,media_gobj_create,g <$i >a && mv a $i; done
for i in $(git grep -l media_gobj_remove); do sed 
s,media_gobj_remove,media_gobj_destroy,g <$i >a && mv a $i; done

Suggested-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/media-device.c | 10 +-
 drivers/media/media-entity.c | 26 +-
 include/media/media-entity.h |  4 ++--
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 537160bb461e..f09f3a6f9c50 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -591,7 +591,7 @@ void media_device_unregister(struct media_device *mdev)
list_for_each_entry_safe(intf, tmp_intf, >interfaces,
 graph_obj.list) {
__media_remove_intf_links(intf);
-   media_gobj_remove(>graph_obj);
+   media_gobj_destroy(>graph_obj);
kfree(intf);
}
spin_unlock(>lock);
@@ -628,11 +628,11 @@ int __must_check media_device_register_entity(struct 
media_device *mdev,
 
spin_lock(>lock);
/* Initialize media_gobj embedded at the entity */
-   media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, >graph_obj);
+   media_gobj_create(mdev, MEDIA_GRAPH_ENTITY, >graph_obj);
 
/* Initialize objects at the pads */
for (i = 0; i < entity->num_pads; i++)
-   media_gobj_init(mdev, MEDIA_GRAPH_PAD,
+   media_gobj_create(mdev, MEDIA_GRAPH_PAD,
   >pads[i].graph_obj);
 
spin_unlock(>lock);
@@ -673,10 +673,10 @@ void media_device_unregister_entity(struct media_entity 
*entity)
 
/* Remove all pads that belong to this entity */
for (i = 0; i < entity->num_pads; i++)
-   media_gobj_remove(>pads[i].graph_obj);
+   media_gobj_destroy(>pads[i].graph_obj);
 
/* Remove the entity */
-   media_gobj_remove(>graph_obj);
+   media_gobj_destroy(>graph_obj);
 
spin_unlock(>lock);
entity->graph_obj.mdev = NULL;
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 57de11281af1..861c8e7b8773 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -134,7 +134,7 @@ static void dev_dbg_obj(const char *event_name,  struct 
media_gobj *gobj)
 }
 
 /**
- *  media_gobj_init - Initialize a graph object
+ *  media_gobj_create - Initialize a graph object
  *
  * @mdev:  Pointer to the media_device that contains the object
  * @type:  Type of the object
@@ -146,7 +146,7 @@ static void dev_dbg_obj(const char *event_name,  struct 
media_gobj *gobj)
  * is embedded on some other object, this function should be called before
  * registering the object at the media controller.
  */
-void media_gobj_init(struct media_device *mdev,
+void media_gobj_create(struct media_device *mdev,
   enum media_gobj_type type,
   struct media_gobj *gobj)
 {
@@ -180,13 +180,13 @@ void media_gobj_init(struct media_device *mdev,
 }
 
 /**
- *  media_gobj_remove - Stop using a graph object on a media device
+ *  media_gobj_destroy - Stop using a graph object on a media device
  *
  * @graph_obj: Pointer to the object
  *
  * This should be called at media_device_unregister_*() routines
  */
-void media_gobj_remove(struct media_gobj *gobj)
+void media_gobj_destroy(struct media_gobj *gobj)
 {
dev_dbg_obj(__func__, gobj);
 
@@ -235,7 +235,7 @@ media_entity_pads_init(struct media_entity *entity, u16 
num_pads,
pads[i].entity = entity;
pads[i].index = i;
if (mdev)
-   media_gobj_init(mdev, MEDIA_GRAPH_PAD,
+   media_gobj_create(mdev, MEDIA_GRAPH_PAD,
>pads[i].graph_obj);
}
 
@@ -607,14 +607,14 @@ static void __media_entity_remove_link(struct 
media_entity *entity,
 
/* Remove the remote link */
list_del(>list);
-   media_gobj_remove(>graph_obj);
+   media_gobj_destroy(>graph_obj);
kfree(rlink);
 
if (--remote->num_links == 0)
break;
}
list_del(>list);
-   media_gobj_remove(>graph_obj);
+   media_gobj_destroy(>graph_obj);
kfree(link);
 }
 
@@ -638,7 +638,7 @@ media_create_pad_link(struct media_entity *source, u16 
source_pad,
link->flags = flags;
 
/* Initialize graph object embedded at the new link */
-   media_gobj_init(source->graph_obj.mdev, 

[PATCH 2/2] media-device: Use u64 ints for pointers

2015-12-11 Thread Mauro Carvalho Chehab
By using u64 integers and pointers, we can get rid of compat32
logic. So, let's do it!

Suggested-by: Arnd Bergmann 
Suggested-by: Laurent Pinchart 
Signed-off-by: Mauro Carvalho Chehab 
---

This patch is the result of the today's meeting at IRC. In order to test it, a
new version of the mc_nextgen_test is needed. It can be found at:

http://git.linuxtv.org/mchehab/experimental-v4l-utils.git/commit/?h=mc-next-gen-v2

 drivers/media/media-device.c | 77 +++-
 include/uapi/linux/media.h   | 32 +-
 2 files changed, 58 insertions(+), 51 deletions(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index f09f3a6f9c50..6406914a9bf5 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -240,10 +240,10 @@ static long __media_device_get_topology(struct 
media_device *mdev,
struct media_interface *intf;
struct media_pad *pad;
struct media_link *link;
-   struct media_v2_entity uentity;
-   struct media_v2_interface uintf;
-   struct media_v2_pad upad;
-   struct media_v2_link ulink;
+   struct media_v2_entity kentity, *uentity;
+   struct media_v2_interface kintf, *uintf;
+   struct media_v2_pad kpad, *upad;
+   struct media_v2_link klink, *ulink;
unsigned int i;
int ret = 0;
 
@@ -251,10 +251,10 @@ static long __media_device_get_topology(struct 
media_device *mdev,
 
/* Get entities and number of entities */
i = 0;
+   uentity = media_get_uptr(topo->ptr_entities);
media_device_for_each_entity(entity, mdev) {
i++;
-
-   if (ret || !topo->entities)
+   if (ret || !uentity)
continue;
 
if (i > topo->num_entities) {
@@ -263,23 +263,24 @@ static long __media_device_get_topology(struct 
media_device *mdev,
}
 
/* Copy fields to userspace struct if not error */
-   memset(, 0, sizeof(uentity));
-   uentity.id = entity->graph_obj.id;
-   uentity.function = entity->function;
-   strncpy(uentity.name, entity->name,
-   sizeof(uentity.name));
+   memset(, 0, sizeof(kentity));
+   kentity.id = entity->graph_obj.id;
+   kentity.function = entity->function;
+   strncpy(kentity.name, entity->name,
+   sizeof(kentity.name));
 
-   if (copy_to_user(>entities[i - 1], , 
sizeof(uentity)))
+   if (copy_to_user(uentity, , sizeof(kentity)))
ret = -EFAULT;
+   uentity++;
}
topo->num_entities = i;
 
/* Get interfaces and number of interfaces */
i = 0;
+   uintf = media_get_uptr(topo->ptr_interfaces);
media_device_for_each_intf(intf, mdev) {
i++;
-
-   if (ret || !topo->interfaces)
+   if (ret || !uintf)
continue;
 
if (i > topo->num_interfaces) {
@@ -287,33 +288,34 @@ static long __media_device_get_topology(struct 
media_device *mdev,
continue;
}
 
-   memset(, 0, sizeof(uintf));
+   memset(, 0, sizeof(kintf));
 
/* Copy intf fields to userspace struct */
-   uintf.id = intf->graph_obj.id;
-   uintf.intf_type = intf->type;
-   uintf.flags = intf->flags;
+   kintf.id = intf->graph_obj.id;
+   kintf.intf_type = intf->type;
+   kintf.flags = intf->flags;
 
if (media_type(>graph_obj) == MEDIA_GRAPH_INTF_DEVNODE) {
struct media_intf_devnode *devnode;
 
devnode = intf_to_devnode(intf);
 
-   uintf.devnode.major = devnode->major;
-   uintf.devnode.minor = devnode->minor;
+   kintf.devnode.major = devnode->major;
+   kintf.devnode.minor = devnode->minor;
}
 
-   if (copy_to_user(>interfaces[i - 1], , 
sizeof(uintf)))
+   if (copy_to_user(uintf, , sizeof(kintf)))
ret = -EFAULT;
+   uintf++;
}
topo->num_interfaces = i;
 
/* Get pads and number of pads */
i = 0;
+   upad = media_get_uptr(topo->ptr_pads);
media_device_for_each_pad(pad, mdev) {
i++;
-
-   if (ret || !topo->pads)
+   if (ret || !upad)
continue;
 
if (i > topo->num_pads) {
@@ -321,27 +323,29 @@ static long __media_device_get_topology(struct 
media_device *mdev,
continue;
}
 
-   memset(, 0, sizeof(upad));
+   memset(, 0, 

[PATCH 1/2] media-device.h: Let clearer that entity function must be initialized

2015-12-11 Thread Mauro Carvalho Chehab
Improve the documentation to let it clear that the entity function
must be initialized.

Suggested-by: Laurent Pinchart 
Signed-off-by: Mauro Carvalho Chehab 
---
 include/media/media-device.h | 4 
 include/uapi/linux/media.h   | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/media/media-device.h b/include/media/media-device.h
index 7cfcc08a09ea..3448ad6320c4 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -423,6 +423,10 @@ void media_device_unregister(struct media_device *mdev);
  * %MEDIA_ENT_FL_DEFAULT indicates the default entity for a given type.
  * This can be used to report the default audio and video devices or the
  * default camera sensor.
+ *
+ * NOTE: Drivers should set the entity function before calling this function.
+ * Please notice that the values %MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN and
+ * %MEDIA_ENT_F_UNKNOWN should not be used by the drivers.
  */
 int __must_check media_device_register_entity(struct media_device *mdev,
  struct media_entity *entity);
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index ff6a8010c520..8d8e1a3e6e1a 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -92,7 +92,7 @@ struct media_device_info {
  *
  * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
  * in order to preserve backward compatibility.
- * Drivers should change to the proper subdev type before
+ * Drivers must change to the proper subdev type before
  * registering the entity.
  */
 
-- 
2.5.0


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


[PATCH 2/2] [media] media: move MEDIA_LNK_FL_INTERFACE_LINK logic to link creation

2015-12-11 Thread Mauro Carvalho Chehab
Instead of flagging an interface link as MEDIA_LNK_FL_INTERFACE_LINK
only when returning to userspace, do it at link creation time.

That would allow using such flag internally, and cleans up a
little bit the code for G_TOPOLOGY ioctl.

Suggested-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/media-device.c | 3 ---
 drivers/media/media-entity.c | 4 ++--
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 6406914a9bf5..c12481c753a0 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -361,9 +361,6 @@ static long __media_device_get_topology(struct media_device 
*mdev,
klink.sink_id = link->gobj1->id;
klink.flags = link->flags;
 
-   if (media_type(link->gobj0) != MEDIA_GRAPH_PAD)
-   klink.flags |= MEDIA_LNK_FL_INTERFACE_LINK;
-
if (copy_to_user(ulink, , sizeof(klink)))
ret = -EFAULT;
ulink++;
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 181ca0de6e52..7895e17aeee9 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -526,7 +526,7 @@ media_create_pad_link(struct media_entity *source, u16 
source_pad,
 
link->source = >pads[source_pad];
link->sink = >pads[sink_pad];
-   link->flags = flags;
+   link->flags = flags && ~MEDIA_LNK_FL_INTERFACE_LINK;
 
/* Initialize graph object embedded at the new link */
media_gobj_create(source->graph_obj.mdev, MEDIA_GRAPH_LINK,
@@ -756,7 +756,7 @@ struct media_link *media_create_intf_link(struct 
media_entity *entity,
 
link->intf = intf;
link->entity = entity;
-   link->flags = flags;
+   link->flags = flags | MEDIA_LNK_FL_INTERFACE_LINK;
 
/* Initialize graph object embedded at the new link */
media_gobj_create(intf->graph_obj.mdev, MEDIA_GRAPH_LINK,
-- 
2.5.0

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


[PATCH 1/2] [media] media-device.h: remove extra blank lines

2015-12-11 Thread Mauro Carvalho Chehab
No functional changes.

Suggested-by:  Laurent Pinchart 
Signed-off-by: Mauro Carvalho Chehab 
---
 include/media/media-device.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/media/media-device.h b/include/media/media-device.h
index 3448ad6320c4..b0594be5d631 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -467,8 +467,6 @@ struct media_device *media_device_find_devres(struct device 
*dev);
 /* Iterate over all links. */
 #define media_device_for_each_link(link, mdev) \
list_for_each_entry(link, &(mdev)->links, graph_obj.list)
-
-
 #else
 static inline int media_device_register(struct media_device *mdev)
 {
-- 
2.5.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


Re: [PATCH v2 00/32] VSP: Add R-Car Gen3 support

2015-12-11 Thread Khiem Nguyen

Hi Laurent,

On 12/6/2015 5:54 AM, Laurent Pinchart wrote:

Hi Geert,

On Saturday 05 December 2015 11:57:49 Geert Uytterhoeven wrote:

On Sat, Dec 5, 2015 at 3:12 AM, Laurent Pinchart wrote:

This patch set adds support for the Renesas R-Car Gen3 SoC family to the
VSP1 driver. The large number of patches is caused by a change in the
display controller architecture that makes usage of the VSP mandatory as
the display controller has lost the ability to read data from memory.

Patch 01/32 to 27/32 prepare for the implementation of an API exported to
the DRM driver in patch 28/32. Patches 31/32 enables support for the
R-Car Gen3 family, and patch 32/32 finally enhances perfomances by
implementing support for display lists.

The major change compared to v1 is the usage of the IP version register
instead of DT properties to configure device parameters such as the number
of BRU inputs or the availability of the BRU.


Thanks for your series!

As http://git.linuxtv.org/pinchartl/media.git/tag/?id=vsp1-kms-20151112 is
getting old, and has lots of conflicts with recent -next, do you plan to
publish this in a branch, and a separate branch for integration, to ease
integration in renesas-drivers?

Alternatively, I can just import the series you posted, but having the
broken-out integration part would be nice.


The issue I'm facing is that there's more than just two series. Beside the
base VSP patches from this series, I have a series of DRM patches that depend
on this one, a series of V4L2 core patches, another series of VSP patches that
I still need to finish and a bunch of integration patches. As some of these
have dependencies on H3 CCF support that hasn't landed in Simon's tree yet, I
have merged your topic/cpg-mssr-v6 and topic/r8a7795-drivers-sh-v1 branches
into my tree for development.

I could keep all series in separate branches and merge the two topic branches
last, but that's not very handy during development when I have to continuously
rebase my patches. Is there a way I could handle this that would make your
life easier while not making mine more difficult ?

In the meantime I've pushed vsp1-kms-20151206 to
git://linuxtv.org/pinchartl/media.git.


I failed to confirm DU (VGA port) with above branch.

To make DU (VGA port) work,
it seems I need to merge more branches like topic/cpg-mssr-v6
and topic/r8a7795-drivers-sh-v1 branches from renesas-drivers repo, is 
it correct ?


Thanks.

--
Best regards,
KHIEM Nguyen
--
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: v4l2 kernel module debugging methods

2015-12-11 Thread Fabien DESSENNE
Hi Ran,

On 12/10/2015 10:46 PM, Ran Shalit wrote:
> On Sun, Dec 6, 2015 at 2:23 AM, Nicolas Dufresne
>  wrote:
>> Le dimanche 06 décembre 2015 à 00:00 +0200, Ran Shalit a écrit :
>>> Hello,
>>>
>>> I would like to ask a general question regarding methods to debug a
>>> v4l2 device driver.
>>> Since I assume that the kernel driver will probably won't work in
>>> first try after coding everything inside the device driver...
>>>
>>> 1. Do you think qemu/kgdb debugger is a good method for the device
>>> driver debugging , or is it plain printing ?
>>>
>>> 2. Is there a simple way to display the image of a YUV-like buffer in
>>> memory ?
>>
>> Most Linux distribution ships GStreamer. You can with GStreamer read
>> and display a raw YUV images (you need to know the specific format)
>> using videoparse element.
>>
>>gst-launch-1.0 filesrc location=my.yuv ! videoparse format=yuy2 width=320 
>> height=240 ! imagefreeze ! videoconvert ! autovideosink
>>
>> You could also encode and store to various formats, replacing the
>> imagefreeze ... section with an encoder and a filesink. Note that
>> videoparse unfortunatly does not allow passing strides array or
>> offsets. So it will work only if you set the width/height to padded
>> width/height.
>>
>> regards,
>> Nicolas
>
> Hi Nicolas,
>
> Thank you for the comment.
> As someone expreinced with v4l2 device driver, do you recommened using
> debugging technique such as qemu (or kgdb) or do you rather use plain
> printing ?
>
> Thank you very much,
> Ran


You can get several level of logs.
First, you can enable v4l2 core debug logs. Example:
  echo 3 > /sys/class/video4linux/video0/debug
More details: 
https://www.kernel.org/doc/Documentation/video4linux/v4l2-framework.txt

If the tested driver uses the v4l2_mem2mem framework you can get M2M 
logs with:
  echo Y > /sys/module/v4l2_mem2mem/parameters/debug

Get also internal vb2 logs with:
  echo 3 > /sys/module/videobuf2_core/parameters/debug

And optionally more logs using the dynamic debug feature: 
(https://www.kernel.org/doc/Documentation/dynamic-debug-howto.txt). Example:
  echo "module my_driver +p" > /sys/kernel/debug/dynamic_debug/control

FabienN�r��yb�X��ǧv�^�)޺{.n�+{���bj)w*jg����ݢj/���z�ޖ��2�ޙ&�)ߡ�a�����G���h��j:+v���w��٥

[PATCH] [media] media.h: let be clear that tuners need to use connectors

2015-12-11 Thread Mauro Carvalho Chehab
The V4L2 core won't be adding connectors to the tuners and other
entities that need them. Let it be clear.

Suggested-by: Laurent Pinchart 
Signed-off-by: Mauro Carvalho Chehab 
---
 include/uapi/linux/media.h | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 86f9753e5c03..cacfceb0d81d 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -74,10 +74,11 @@ struct media_device_info {
 /*
  * Connectors
  */
+/* It is a responsibility of the entity drivers to add connectors and links */
 #define MEDIA_ENT_F_CONN_RF(MEDIA_ENT_F_BASE + 21)
 #define MEDIA_ENT_F_CONN_SVIDEO(MEDIA_ENT_F_BASE + 22)
 #define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 23)
-   /* For internal test signal generators and other debug connectors */
+/* For internal test signal generators and other debug connectors */
 #define MEDIA_ENT_F_CONN_TEST  (MEDIA_ENT_F_BASE + 24)
 
 /*
@@ -105,6 +106,10 @@ struct media_device_info {
 #define MEDIA_ENT_F_FLASH  (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
 #define MEDIA_ENT_F_LENS   (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
 #define MEDIA_ENT_F_ATV_DECODER(MEDIA_ENT_F_OLD_SUBDEV_BASE + 
4)
+/*
+ * It is a responsibility of the entity drivers to add connectors and links
+ * for the tuner entities.
+ */
 #define MEDIA_ENT_F_TUNER  (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
 
 #define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWNMEDIA_ENT_F_OLD_SUBDEV_BASE
-- 
2.5.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


Re: Media Controller patches

2015-12-11 Thread Mauro Carvalho Chehab
Em Thu, 10 Dec 2015 18:34:11 -0200
Mauro Carvalho Chehab  escreveu:

> Hi,
> 
> I've been working during this week to address the issues pointed during
> the Media Controller really long review process. We should avoid taking
> so long to review patches in the future, as it is really painful to
> go back to the already done work 4/5/7 months after the patchsets
> (yes, there are patches here written 7 months ago that were only
> very recently reviewed!). Shame on us.
> 
> Anyway, The reviewed patches are now at the media-controller topic
> branch, at the main tree.
> 
> I took the care of recompiling and automatically doing runtime tests
> with KASAN enabled, patch by patch, in order to be sure that the
> MC is in a sane state. I also ran kmemleak, and was unable to identify
> any troubles associated with the MC next gen rework.
> 
> So, the media-controller topic branch looks sane to me. It should be
> noticed that there are several items on a TODO list to be addressed
> before being able to merge this branch back at the master branch.
> 
> Please notice that patch 22 was removed from this series:
>   Subject: [media] uapi/media.h: Declare interface types for ALSA
> 
> The idea is that this patch should be part of the patches that Shuah
> will submit and that requires review from the ALSA community before
> being merged.
> 
> Javier and me will start tomorrow on working on the pending items.
> 
> My goal is to have everything needed for Kernel 4.5 merge window
> done up to the next week.
> 
> ---
> 
> The current TODO list, based on the per-patch review is:

As far as I checked, all issues at the TODO for Kernel 4.5 were
already addressed, except for one item:

- Add documentation for the uAPI.

I'll address this last item tomorrow.

The patches that addressed the TODO list were sent already to the ML,
on a few independent patch series.

They're all (including the Javier ones) applied on my experimental
tree at branch media-controller-rc3:
git://linuxtv.org/mchehab/experimental.git media-controller-rc3

The userspace testing tool was also modified for the MC next gen,
at the branch mc-next-gen-v2:
git://linuxtv.org/mchehab/experimental-v4l-utils.git mc-next-gen-v2



Please let me know if something else got missed ASAP, as I'll be 
addressing any missing stuff during this weekend.

My goal is to merge those patches at the main development branch
this Monday.

NOTE:


The TODO list are hosted at: https://etherpad.fr

The original one is on the above site, at: /p/mc-v2-todo
And we added a new version on the same site, at: /p/mc-v2-todo-v2

Things that got postponed to other Kernel versions:
===

1) Sakari: Rethink about media-entity.h name;
2) Laurent: do a non-hacking version of the pad/subdev switch logic (waiting 
for Laurent's comment on this one);
3) Should address on a later series the changes to remove 
MEDIA_ENT_T_SUBDEV_UNKNOWN;
4) Laurent: All exported API functions need kerneldoc. (most are. There are a 
few less used that needs documentation, like the __foo functions);
5) Laurent: remove major/minor fields from entities

6) Remove unused fields from media_entity (major, minor, num_links, 
num_backlinks, num_pads)
7) dynamic entity/interface/link creation and removal;
8) SETUP_LINK_V2 with dynamic support;
9) dynamic pad creation and removal (needed?);
10) multiple function per entity support;
11) indirect interface links support;
12) MC properties API.

Userspace TODO:
==

1) Create a library with v2 API;
2) Use the v2 API library on qv4l2/libdvbv5/xawtv/libv4l;

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