[Patch v5 01/12] [media] s5p-mfc: Rename IS_MFCV8 macro

2017-06-18 Thread Smitha T Murthy
This patch renames macro IS_MFCV8 to IS_MFCV8_PLUS so that the MFCv8
code can be resued for MFCv10.10 support. Since the MFCv8 specific code
holds good for MFC v10.10 also.

Signed-off-by: Smitha T Murthy 
Acked-by: Andrzej Hajda 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |  2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |  2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c|  2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 18 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 4220914..5fb2684 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -711,7 +711,7 @@ void s5p_mfc_cleanup_queue(struct list_head *lh, struct 
vb2_queue *vq);
 #define IS_TWOPORT(dev)(dev->variant->port_num == 2 ? 1 : 0)
 #define IS_MFCV6_PLUS(dev) (dev->variant->version >= 0x60 ? 1 : 0)
 #define IS_MFCV7_PLUS(dev) (dev->variant->version >= 0x70 ? 1 : 0)
-#define IS_MFCV8(dev)  (dev->variant->version >= 0x80 ? 1 : 0)
+#define IS_MFCV8_PLUS(dev) (dev->variant->version >= 0x80 ? 1 : 0)
 
 #define MFC_V5_BIT BIT(0)
 #define MFC_V6_BIT BIT(1)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 69ef9c2..3769d22 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -399,7 +399,7 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
s5p_mfc_clear_cmds(dev);
s5p_mfc_clean_dev_int_flags(dev);
/* 3. Send MFC wakeup command and wait for completion*/
-   if (IS_MFCV8(dev))
+   if (IS_MFCV8_PLUS(dev))
ret = s5p_mfc_v8_wait_wakeup(dev);
else
ret = s5p_mfc_wait_wakeup(dev);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 8937b0a..42e9351 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -1177,7 +1177,7 @@ void s5p_mfc_dec_init(struct s5p_mfc_ctx *ctx)
struct v4l2_format f;
f.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_H264;
ctx->src_fmt = find_format(, MFC_FMT_DEC);
-   if (IS_MFCV8(ctx->dev))
+   if (IS_MFCV8_PLUS(ctx->dev))
f.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_NV12M;
else if (IS_MFCV6_PLUS(ctx->dev))
f.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_NV12MT_16X16;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index 88dbb9c..fe14479 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -74,7 +74,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx 
*ctx)
  ctx->luma_size, ctx->chroma_size, ctx->mv_size);
mfc_debug(2, "Totals bufs: %d\n", ctx->total_dpb_count);
} else if (ctx->type == MFCINST_ENCODER) {
-   if (IS_MFCV8(dev))
+   if (IS_MFCV8_PLUS(dev))
ctx->tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V8(mb_width, mb_height),
S5P_FIMV_TMV_BUFFER_ALIGN_V6);
@@ -89,7 +89,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx 
*ctx)
ctx->chroma_dpb_size = ALIGN((mb_width * mb_height) *
S5P_FIMV_CHROMA_MB_TO_PIXEL_V6,
S5P_FIMV_CHROMA_DPB_BUFFER_ALIGN_V6);
-   if (IS_MFCV8(dev))
+   if (IS_MFCV8_PLUS(dev))
ctx->me_buffer_size = ALIGN(S5P_FIMV_ME_BUFFER_SIZE_V8(
ctx->img_width, ctx->img_height,
mb_width, mb_height),
@@ -110,7 +110,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct 
s5p_mfc_ctx *ctx)
switch (ctx->codec_mode) {
case S5P_MFC_CODEC_H264_DEC:
case S5P_MFC_CODEC_H264_MVC_DEC:
-   if (IS_MFCV8(dev))
+   if (IS_MFCV8_PLUS(dev))
ctx->scratch_buf_size =
S5P_FIMV_SCRATCH_BUF_SIZE_H264_DEC_V8(
mb_width,
@@ -167,7 +167,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct 
s5p_mfc_ctx *ctx)
ctx->bank1.size = ctx->scratch_buf_size;
break;
case S5P_MFC_CODEC_VP8_DEC:
-   if (IS_MFCV8(dev))
+   if (IS_MFCV8_PLUS(dev))
ctx->scratch_buf_size =
S5P_FIMV_SCRATCH_BUF_SIZE_VP8_DEC_V8(
mb_width,
@@ -182,7 +182,7 @@ static int 

[Patch v5 03/12] [media] s5p-mfc: Use min scratch buffer size as provided by F/W

2017-06-18 Thread Smitha T Murthy
After MFC v8.0, mfc f/w lets the driver know how much scratch buffer
size is required for decoder. If mfc f/w has the functionality,
E_MIN_SCRATCH_BUFFER_SIZE, driver can know how much scratch buffer size
is required for encoder too.

Signed-off-by: Smitha T Murthy 
Reviewed-by: Andrzej Hajda 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v8.h|  2 +
 drivers/media/platform/s5p-mfc/s5p_mfc.c|  2 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |  1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|  5 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.h|  4 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 68 ++---
 6 files changed, 65 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v8.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
index 75f5f75..bd639ae 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
@@ -17,6 +17,7 @@
 
 /* Additional registers for v8 */
 #define S5P_FIMV_D_MVC_NUM_VIEWS_V80xf104
+#define S5P_FIMV_D_MIN_SCRATCH_BUFFER_SIZE_V8  0xf108
 #define S5P_FIMV_D_FIRST_PLANE_DPB_SIZE_V8 0xf144
 #define S5P_FIMV_D_SECOND_PLANE_DPB_SIZE_V80xf148
 #define S5P_FIMV_D_MV_BUFFER_SIZE_V8   0xf150
@@ -84,6 +85,7 @@
 
 #define S5P_FIMV_E_VBV_BUFFER_SIZE_V8  0xf78c
 #define S5P_FIMV_E_VBV_INIT_DELAY_V8   0xf790
+#define S5P_FIMV_E_MIN_SCRATCH_BUFFER_SIZE_V8   0xf894
 
 #define S5P_FIMV_E_ASPECT_RATIO_V8 0xfb4c
 #define S5P_FIMV_E_EXTENDED_SAR_V8 0xfb50
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 1b032f8..efc36b0 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -526,6 +526,8 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx,
dev);
ctx->mv_count = s5p_mfc_hw_call(dev->mfc_ops, get_mv_count,
dev);
+   ctx->scratch_buf_size = s5p_mfc_hw_call(dev->mfc_ops,
+   get_min_scratch_buf_size, dev);
if (ctx->img_width == 0 || ctx->img_height == 0)
ctx->state = MFCINST_ERROR;
else
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index eb0cf5e..e65e1c3 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -713,6 +713,7 @@ void s5p_mfc_cleanup_queue(struct list_head *lh, struct 
vb2_queue *vq);
 #define IS_MFCV7_PLUS(dev) (dev->variant->version >= 0x70 ? 1 : 0)
 #define IS_MFCV8_PLUS(dev) (dev->variant->version >= 0x80 ? 1 : 0)
 #define IS_MFCV10(dev) (dev->variant->version >= 0xA0 ? 1 : 0)
+#define FW_HAS_E_MIN_SCRATCH_BUF(dev) (IS_MFCV10(dev))
 
 #define MFC_V5_BIT BIT(0)
 #define MFC_V6_BIT BIT(1)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 64b6b6d..eb5352a 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -813,6 +813,11 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
get_enc_dpb_count, dev);
if (ctx->pb_count < enc_pb_count)
ctx->pb_count = enc_pb_count;
+   if (FW_HAS_E_MIN_SCRATCH_BUF(dev)) {
+   ctx->scratch_buf_size = s5p_mfc_hw_call(dev->mfc_ops,
+   get_e_min_scratch_buf_size, dev);
+   ctx->bank1.size += ctx->scratch_buf_size;
+   }
ctx->state = MFCINST_HEAD_PRODUCED;
}
 
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
index 16d553f..e7a2d46 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
@@ -169,6 +169,7 @@ struct s5p_mfc_regs {
void __iomem *d_decoded_third_addr;/* only v7 */
void __iomem *d_used_dpb_flag_upper;/* v7 and v8 */
void __iomem *d_used_dpb_flag_lower;/* v7 and v8 */
+   void __iomem *d_min_scratch_buffer_size; /* v10 */
 
/* encoder registers */
void __iomem *e_frame_width;
@@ -268,6 +269,7 @@ struct s5p_mfc_regs {
void __iomem *e_vp8_hierarchical_qp_layer0;/* v7 and v8 */
void __iomem *e_vp8_hierarchical_qp_layer1;/* v7 and v8 */
void __iomem *e_vp8_hierarchical_qp_layer2;/* v7 and v8 */
+   void __iomem *e_min_scratch_buffer_size; /* v10 */
 };
 
 struct s5p_mfc_hw_ops {
@@ -311,6 +313,8 @@ struct s5p_mfc_hw_ops {
unsigned int (*get_pic_type_bot)(struct s5p_mfc_ctx *ctx);
unsigned int (*get_crop_info_h)(struct s5p_mfc_ctx *ctx);
unsigned int 

[Patch v5 04/12] [media] s5p-mfc: Support MFCv10.10 buffer requirements

2017-06-18 Thread Smitha T Murthy
Aligning the luma_dpb_size, chroma_dpb_size, mv_size and me_buffer_size
for MFCv10.10.

Signed-off-by: Smitha T Murthy 
Reviewed-by: Andrzej Hajda 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v10.h   | 19 +
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 95 +++--
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h |  2 +
 3 files changed, 95 insertions(+), 21 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
index 1ca09d6..3f0dab3 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
@@ -32,5 +32,24 @@
 #define MFC_VERSION_V100xA0
 #define MFC_NUM_PORTS_V10  1
 
+/* MFCv10 codec defines*/
+#define S5P_FIMV_CODEC_HEVC_ENC 26
+
+/* Encoder buffer size for MFC v10.0 */
+#define ENC_V100_BASE_SIZE(x, y) \
+   (((x + 3) * (y + 3) * 8) \
+   +  ((y * 64) + 1280) * DIV_ROUND_UP(x, 8))
+
+#define ENC_V100_H264_ME_SIZE(x, y) \
+   (ENC_V100_BASE_SIZE(x, y) \
+   + (DIV_ROUND_UP(x * y, 64) * 32))
+
+#define ENC_V100_MPEG4_ME_SIZE(x, y) \
+   (ENC_V100_BASE_SIZE(x, y) \
+   + (DIV_ROUND_UP(x * y, 128) * 16))
+
+#define ENC_V100_VP8_ME_SIZE(x, y) \
+   ENC_V100_BASE_SIZE(x, y)
+
 #endif /*_REGS_MFC_V10_H*/
 
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index f1a8c53..83ea733 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -64,6 +64,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx 
*ctx)
 {
struct s5p_mfc_dev *dev = ctx->dev;
unsigned int mb_width, mb_height;
+   unsigned int lcu_width = 0, lcu_height = 0;
int ret;
 
mb_width = MB_WIDTH(ctx->img_width);
@@ -74,7 +75,9 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx 
*ctx)
  ctx->luma_size, ctx->chroma_size, ctx->mv_size);
mfc_debug(2, "Totals bufs: %d\n", ctx->total_dpb_count);
} else if (ctx->type == MFCINST_ENCODER) {
-   if (IS_MFCV8_PLUS(dev))
+   if (IS_MFCV10(dev)) {
+   ctx->tmv_buffer_size = 0;
+   } else if (IS_MFCV8_PLUS(dev))
ctx->tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V8(mb_width, mb_height),
S5P_FIMV_TMV_BUFFER_ALIGN_V6);
@@ -82,13 +85,36 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct 
s5p_mfc_ctx *ctx)
ctx->tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V6(mb_width, mb_height),
S5P_FIMV_TMV_BUFFER_ALIGN_V6);
-
-   ctx->luma_dpb_size = ALIGN((mb_width * mb_height) *
-   S5P_FIMV_LUMA_MB_TO_PIXEL_V6,
-   S5P_FIMV_LUMA_DPB_BUFFER_ALIGN_V6);
-   ctx->chroma_dpb_size = ALIGN((mb_width * mb_height) *
-   S5P_FIMV_CHROMA_MB_TO_PIXEL_V6,
-   S5P_FIMV_CHROMA_DPB_BUFFER_ALIGN_V6);
+   if (IS_MFCV10(dev)) {
+   lcu_width = enc_lcu_width(ctx->img_width);
+   lcu_height = enc_lcu_height(ctx->img_height);
+   if (ctx->codec_mode != S5P_FIMV_CODEC_HEVC_ENC) {
+   ctx->luma_dpb_size =
+   ALIGN((mb_width * 16), 64)
+   * ALIGN((mb_height * 16), 32)
+   + 64;
+   ctx->chroma_dpb_size =
+   ALIGN((mb_width * 16), 64)
+   * (mb_height * 8)
+   + 64;
+   } else {
+   ctx->luma_dpb_size =
+   ALIGN((lcu_width * 32), 64)
+   * ALIGN((lcu_height * 32), 32)
+   + 64;
+   ctx->chroma_dpb_size =
+   ALIGN((lcu_width * 32), 64)
+   * (lcu_height * 16)
+   + 64;
+   }
+   } else {
+   ctx->luma_dpb_size = ALIGN((mb_width * mb_height) *
+   S5P_FIMV_LUMA_MB_TO_PIXEL_V6,
+   S5P_FIMV_LUMA_DPB_BUFFER_ALIGN_V6);
+   ctx->chroma_dpb_size = ALIGN((mb_width * mb_height) *
+   S5P_FIMV_CHROMA_MB_TO_PIXEL_V6,

[Patch v5 00/12] Add MFC v10.10 support

2017-06-18 Thread Smitha T Murthy
This patch series adds MFC v10.10 support. MFC v10.10 is used in some  
of Exynos7 variants.

This adds support for following:

* Add support for HEVC encoder and decoder
* Add support for VP9 decoder
* Update Documentation for control id definitions
* Update computation of min scratch buffer size requirement for V8 onwards

Changes since v4:
 - Addressed review comments by Sylwester Nawrocki.
 - Addressed review comments by Hans Verkuil.
 - Rebased on latest git://linuxtv.org/snawrocki/samsung.git
   for-v4.13/media/next and for-v4.12/media/next-2 branches,
   the same series of patches applies on both branches.
 - Applied r-o-b from Andrzej on respective patches.
 - Built and checked the Documentation.

Smitha T Murthy (12):
  [media] s5p-mfc: Rename IS_MFCV8 macro
  [media] s5p-mfc: Adding initial support for MFC v10.10
  [media] s5p-mfc: Use min scratch buffer size as provided by F/W
  [media] s5p-mfc: Support MFCv10.10 buffer requirements
  [media] videodev2.h: Add v4l2 definition for HEVC
  [media] v4l2-ioctl: add HEVC format description
  Documentation: v4l: Documentation for HEVC v4l2 definition
  [media] s5p-mfc: Add support for HEVC decoder
  [media] s5p-mfc: Add VP9 decoder support
  [media] v4l2: Add v4l2 control IDs for HEVC encoder
  [media] s5p-mfc: Add support for HEVC encoder
  Documention: v4l: Documentation for HEVC CIDs

 .../devicetree/bindings/media/s5p-mfc.txt  |   1 +
 Documentation/media/uapi/v4l/extended-controls.rst | 364 ++
 Documentation/media/uapi/v4l/pixfmt-013.rst|   5 +
 drivers/media/platform/s5p-mfc/regs-mfc-v10.h  |  88 
 drivers/media/platform/s5p-mfc/regs-mfc-v8.h   |   2 +
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |  28 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c|   9 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h|  67 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c  |   6 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |  48 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c   | 542 -
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.h   |  14 +
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c| 383 +--
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h|  15 +
 drivers/media/v4l2-core/v4l2-ctrls.c   | 103 
 drivers/media/v4l2-core/v4l2-ioctl.c   |   1 +
 include/uapi/linux/v4l2-controls.h |  84 
 include/uapi/linux/videodev2.h |   1 +
 18 files changed, 1684 insertions(+), 77 deletions(-)
 create mode 100644 drivers/media/platform/s5p-mfc/regs-mfc-v10.h

-- 
2.7.4



[Patch v5 05/12] [media] videodev2.h: Add v4l2 definition for HEVC

2017-06-18 Thread Smitha T Murthy
Add V4L2 definition for HEVC compressed format

Signed-off-by: Smitha T Murthy 
Reviewed-by: Andrzej Hajda 
---
 include/uapi/linux/videodev2.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 2b8feb8..488de3d 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -629,6 +629,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L') /* SMPTE 421M 
Annex L compliant stream */
 #define V4L2_PIX_FMT_VP8  v4l2_fourcc('V', 'P', '8', '0') /* VP8 */
 #define V4L2_PIX_FMT_VP9  v4l2_fourcc('V', 'P', '9', '0') /* VP9 */
+#define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C') /* HEVC */
 
 /*  Vendor-specific formats   */
 #define V4L2_PIX_FMT_CPIA1v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
-- 
2.7.4



[Patch v5 02/12] [media] s5p-mfc: Adding initial support for MFC v10.10

2017-06-18 Thread Smitha T Murthy
Adding the support for MFC v10.10, with new register file and
necessary hw control, decoder, encoder and structural changes.

CC: Rob Herring 
CC: devicet...@vger.kernel.org
Signed-off-by: Smitha T Murthy 
Reviewed-by: Andrzej Hajda 
Acked-by: Rob Herring 
---
 .../devicetree/bindings/media/s5p-mfc.txt  |  1 +
 drivers/media/platform/s5p-mfc/regs-mfc-v10.h  | 36 ++
 drivers/media/platform/s5p-mfc/s5p_mfc.c   | 25 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h|  9 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c  |  4 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   | 32 ---
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c   | 16 --
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c|  9 --
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h|  2 ++
 9 files changed, 101 insertions(+), 33 deletions(-)
 create mode 100644 drivers/media/platform/s5p-mfc/regs-mfc-v10.h

diff --git a/Documentation/devicetree/bindings/media/s5p-mfc.txt 
b/Documentation/devicetree/bindings/media/s5p-mfc.txt
index d3404b5..aa54c81 100644
--- a/Documentation/devicetree/bindings/media/s5p-mfc.txt
+++ b/Documentation/devicetree/bindings/media/s5p-mfc.txt
@@ -13,6 +13,7 @@ Required properties:
(c) "samsung,mfc-v7" for MFC v7 present in Exynos5420 SoC
(d) "samsung,mfc-v8" for MFC v8 present in Exynos5800 SoC
(e) "samsung,exynos5433-mfc" for MFC v8 present in Exynos5433 SoC
+   (f) "samsung,mfc-v10" for MFC v10 present in Exynos7880 SoC
 
   - reg : Physical base address of the IP registers and length of memory
  mapped region.
diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
new file mode 100644
index 000..1ca09d6
--- /dev/null
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
@@ -0,0 +1,36 @@
+/*
+ * Register definition file for Samsung MFC V10.x Interface (FIMV) driver
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com/
+ *
+ * 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.
+ */
+
+#ifndef _REGS_MFC_V10_H
+#define _REGS_MFC_V10_H
+
+#include 
+#include "regs-mfc-v8.h"
+
+/* MFCv10 register definitions*/
+#define S5P_FIMV_MFC_CLOCK_OFF_V10 0x7120
+#define S5P_FIMV_MFC_STATE_V10 0x7124
+
+/* MFCv10 Context buffer sizes */
+#define MFC_CTX_BUF_SIZE_V10   (30 * SZ_1K)
+#define MFC_H264_DEC_CTX_BUF_SIZE_V10  (2 * SZ_1M)
+#define MFC_OTHER_DEC_CTX_BUF_SIZE_V10 (20 * SZ_1K)
+#define MFC_H264_ENC_CTX_BUF_SIZE_V10  (100 * SZ_1K)
+#define MFC_OTHER_ENC_CTX_BUF_SIZE_V10 (15 * SZ_1K)
+
+/* MFCv10 variant defines */
+#define MAX_FW_SIZE_V10(SZ_1M)
+#define MAX_CPB_SIZE_V10   (3 * SZ_1M)
+#define MFC_VERSION_V100xA0
+#define MFC_NUM_PORTS_V10  1
+
+#endif /*_REGS_MFC_V10_H*/
+
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 43ca572..1b032f8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1614,6 +1614,28 @@ static struct s5p_mfc_variant mfc_drvdata_v8_5433 = {
.num_clocks = 3,
 };
 
+static struct s5p_mfc_buf_size_v6 mfc_buf_size_v10 = {
+   .dev_ctx= MFC_CTX_BUF_SIZE_V10,
+   .h264_dec_ctx   = MFC_H264_DEC_CTX_BUF_SIZE_V10,
+   .other_dec_ctx  = MFC_OTHER_DEC_CTX_BUF_SIZE_V10,
+   .h264_enc_ctx   = MFC_H264_ENC_CTX_BUF_SIZE_V10,
+   .other_enc_ctx  = MFC_OTHER_ENC_CTX_BUF_SIZE_V10,
+};
+
+static struct s5p_mfc_buf_size buf_size_v10 = {
+   .fw = MAX_FW_SIZE_V10,
+   .cpb= MAX_CPB_SIZE_V10,
+   .priv   = _buf_size_v10,
+};
+
+static struct s5p_mfc_variant mfc_drvdata_v10 = {
+   .version= MFC_VERSION_V10,
+   .version_bit= MFC_V10_BIT,
+   .port_num   = MFC_NUM_PORTS_V10,
+   .buf_size   = _size_v10,
+   .fw_name[0] = "s5p-mfc-v10.fw",
+};
+
 static const struct of_device_id exynos_mfc_match[] = {
{
.compatible = "samsung,mfc-v5",
@@ -1630,6 +1652,9 @@ static const struct of_device_id exynos_mfc_match[] = {
}, {
.compatible = "samsung,exynos5433-mfc",
.data = _drvdata_v8_5433,
+   }, {
+   .compatible = "samsung,mfc-v10",
+   .data = _drvdata_v10,
},
{},
 };
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 5fb2684..eb0cf5e 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -23,7 +23,7 @@
 #include 
 #include 
 #include "regs-mfc.h"
-#include 

[Patch v5 09/12] [media] s5p-mfc: Add VP9 decoder support

2017-06-18 Thread Smitha T Murthy
Add support for codec definition and corresponding buffer
requirements for VP9 decoder.

Signed-off-by: Smitha T Murthy 
Reviewed-by: Andrzej Hajda 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v10.h   |  6 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c |  3 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |  1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c|  7 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.h|  2 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 26 +
 6 files changed, 45 insertions(+)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
index 953a073..6754477 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
@@ -18,6 +18,8 @@
 /* MFCv10 register definitions*/
 #define S5P_FIMV_MFC_CLOCK_OFF_V10 0x7120
 #define S5P_FIMV_MFC_STATE_V10 0x7124
+#define S5P_FIMV_D_STATIC_BUFFER_ADDR_V10  0xF570
+#define S5P_FIMV_D_STATIC_BUFFER_SIZE_V10  0xF574
 
 /* MFCv10 Context buffer sizes */
 #define MFC_CTX_BUF_SIZE_V10   (30 * SZ_1K)
@@ -34,8 +36,12 @@
 
 /* MFCv10 codec defines*/
 #define S5P_FIMV_CODEC_HEVC_DEC17
+#define S5P_FIMV_CODEC_VP9_DEC 18
 #define S5P_FIMV_CODEC_HEVC_ENC 26
 
+/* Decoder buffer size for MFC v10 */
+#define DEC_VP9_STATIC_BUFFER_SIZE 20480
+
 /* Encoder buffer size for MFC v10.0 */
 #define ENC_V100_BASE_SIZE(x, y) \
(((x + 3) * (y + 3) * 8) \
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
index 76eca67..102b47e 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
@@ -104,6 +104,9 @@ static int s5p_mfc_open_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
case S5P_MFC_CODEC_HEVC_DEC:
codec_type = S5P_FIMV_CODEC_HEVC_DEC;
break;
+   case S5P_MFC_CODEC_VP9_DEC:
+   codec_type = S5P_FIMV_CODEC_VP9_DEC;
+   break;
case S5P_MFC_CODEC_H264_ENC:
codec_type = S5P_FIMV_CODEC_H264_ENC_V6;
break;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 828e07e..b49f220 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -73,6 +73,7 @@
 #define S5P_MFC_CODEC_VC1RCV_DEC   6
 #define S5P_MFC_CODEC_VP8_DEC  7
 #define S5P_MFC_CODEC_HEVC_DEC 17
+#define S5P_MFC_CODEC_VP9_DEC  18
 
 #define S5P_MFC_CODEC_H264_ENC 20
 #define S5P_MFC_CODEC_H264_MVC_ENC 21
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 4749355..5cf4d99 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -151,6 +151,13 @@ static struct s5p_mfc_fmt formats[] = {
.num_planes = 1,
.versions   = MFC_V10_BIT,
},
+   {
+   .fourcc = V4L2_PIX_FMT_VP9,
+   .codec_mode = S5P_FIMV_CODEC_VP9_DEC,
+   .type   = MFC_FMT_DEC,
+   .num_planes = 1,
+   .versions   = MFC_V10_BIT,
+   },
 };
 
 #define NUM_FORMATS ARRAY_SIZE(formats)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
index e7a2d46..57f4560 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
@@ -170,6 +170,8 @@ struct s5p_mfc_regs {
void __iomem *d_used_dpb_flag_upper;/* v7 and v8 */
void __iomem *d_used_dpb_flag_lower;/* v7 and v8 */
void __iomem *d_min_scratch_buffer_size; /* v10 */
+   void __iomem *d_static_buffer_addr; /* v10 */
+   void __iomem *d_static_buffer_size; /* v10 */
 
/* encoder registers */
void __iomem *e_frame_width;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index ed725db..f3d0a6f 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -226,6 +226,12 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct 
s5p_mfc_ctx *ctx)
ctx->scratch_buf_size +
(ctx->mv_count * ctx->mv_size);
break;
+   case S5P_MFC_CODEC_VP9_DEC:
+   mfc_debug(2, "Use min scratch buffer size\n");
+   ctx->bank1.size =
+   ctx->scratch_buf_size +
+   DEC_VP9_STATIC_BUFFER_SIZE;
+   break;
case S5P_MFC_CODEC_H264_ENC:
if (IS_MFCV10(dev)) {

[Patch v5 06/12] [media] v4l2-ioctl: add HEVC format description

2017-06-18 Thread Smitha T Murthy
HEVC is a video coding format

Signed-off-by: Smitha T Murthy 
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index e5a2187..4f6f8d9 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1257,6 +1257,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_VC1_ANNEX_L:  descr = "VC-1 (SMPTE 412M Annex 
L)"; break;
case V4L2_PIX_FMT_VP8:  descr = "VP8"; break;
case V4L2_PIX_FMT_VP9:  descr = "VP9"; break;
+   case V4L2_PIX_FMT_HEVC: descr = "HEVC"; break;
case V4L2_PIX_FMT_CPIA1:descr = "GSPCA CPiA YUV"; break;
case V4L2_PIX_FMT_WNVA: descr = "WNVA"; break;
case V4L2_PIX_FMT_SN9C10X:  descr = "GSPCA SN9C10X"; break;
-- 
2.7.4



[Patch v5 07/12] Documentation: v4l: Documentation for HEVC v4l2 definition

2017-06-18 Thread Smitha T Murthy
Add V4L2 definition for HEVC compressed format which is also
known as H.265.

Signed-off-by: Smitha T Murthy 
Reviewed-by: Andrzej Hajda 
---
 Documentation/media/uapi/v4l/pixfmt-013.rst | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Documentation/media/uapi/v4l/pixfmt-013.rst 
b/Documentation/media/uapi/v4l/pixfmt-013.rst
index 728d7ed..abec039 100644
--- a/Documentation/media/uapi/v4l/pixfmt-013.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-013.rst
@@ -90,3 +90,8 @@ Compressed Formats
   - ``V4L2_PIX_FMT_VP9``
   - 'VP90'
   - VP9 video elementary stream.
+* .. _V4L2-PIX-FMT-HEVC:
+
+  - ``V4L2_PIX_FMT_HEVC``
+  - 'HEVC'
+  - HEVC/H.265 video elementary stream.
-- 
2.7.4



[Patch v5 10/12] [media] v4l2: Add v4l2 control IDs for HEVC encoder

2017-06-18 Thread Smitha T Murthy
Add v4l2 controls for HEVC encoder

Signed-off-by: Smitha T Murthy 
Reviewed-by: Andrzej Hajda 
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 103 +++
 include/uapi/linux/v4l2-controls.h   |  84 
 2 files changed, 187 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index ec42872..6a7e732 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -479,6 +479,51 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
NULL,
};
 
+   static const char * const hevc_profile[] = {
+   "Main",
+   "Main Still Picture",
+   NULL,
+   };
+   static const char * const hevc_level[] = {
+   "1",
+   "2",
+   "2.1",
+   "3",
+   "3.1",
+   "4",
+   "4.1",
+   "5",
+   "5.1",
+   "5.2",
+   "6",
+   "6.1",
+   "6.2",
+   NULL,
+   };
+   static const char * const hevc_hierarchial_coding_type[] = {
+   "B",
+   "P",
+   NULL,
+   };
+   static const char * const hevc_refresh_type[] = {
+   "None",
+   "CRA",
+   "IDR",
+   NULL,
+   };
+   static const char * const hevc_size_of_length_field[] = {
+   "0",
+   "1",
+   "2",
+   "4",
+   NULL,
+   };
+   static const char * const hevc_tier_flag[] = {
+   "Main",
+   "High",
+   NULL,
+   };
+
 
switch (id) {
case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
@@ -574,6 +619,18 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
return dv_it_content_type;
case V4L2_CID_DETECT_MD_MODE:
return detect_md_mode;
+   case V4L2_CID_MPEG_VIDEO_HEVC_PROFILE:
+   return hevc_profile;
+   case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL:
+   return hevc_level;
+   case V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_TYPE:
+   return hevc_hierarchial_coding_type;
+   case V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_TYPE:
+   return hevc_refresh_type;
+   case V4L2_CID_MPEG_VIDEO_HEVC_SIZE_OF_LENGTH_FIELD:
+   return hevc_size_of_length_field;
+   case V4L2_CID_MPEG_VIDEO_HEVC_TIER_FLAG:
+   return hevc_tier_flag;
 
default:
return NULL;
@@ -775,6 +832,46 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP:return "VPX 
P-Frame QP Value";
case V4L2_CID_MPEG_VIDEO_VPX_PROFILE:   return "VPX 
Profile";
 
+   /* HEVC controls */
+   case V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP:   return "HEVC 
I-Frame QP Value";
+   case V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_QP:   return "HEVC 
P-Frame QP Value";
+   case V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP:   return "HEVC 
B-Frame QP Value";
+   case V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP:   return "HEVC 
Minimum QP Value";
+   case V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP:   return "HEVC 
Maximum QP Value";
+   case V4L2_CID_MPEG_VIDEO_HEVC_PROFILE:  return "HEVC 
Profile";
+   case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL:return "HEVC 
Level";
+   case V4L2_CID_MPEG_VIDEO_HEVC_TIER_FLAG:return "HEVC 
Tier_flag";
+   case V4L2_CID_MPEG_VIDEO_HEVC_FRAME_RATE_RESOLUTION:return "HEVC 
Frame Rate Resolution";
+   case V4L2_CID_MPEG_VIDEO_HEVC_MAX_PARTITION_DEPTH:  return "HEVC 
Maximum Coding Unit Depth";
+   case V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_TYPE: return "HEVC 
Refresh Type";
+   case V4L2_CID_MPEG_VIDEO_HEVC_CONST_INTRA_PRED: return "HEVC 
Constant Intra Prediction";
+   case V4L2_CID_MPEG_VIDEO_HEVC_LOSSLESS_CU:  return "HEVC 
Lossless Encoding";
+   case V4L2_CID_MPEG_VIDEO_HEVC_WAVEFRONT:return "HEVC 
Wavefront";
+   case V4L2_CID_MPEG_VIDEO_HEVC_LF:   return "HEVC 
Loop Filter";
+   case V4L2_CID_MPEG_VIDEO_HEVC_LF_SLICE_BOUNDARY:return "HEVC LF 
Across Slice Boundary";
+   case V4L2_CID_MPEG_VIDEO_HEVC_HIER_QP:  return "HEVC QP 
Values";
+   case V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_TYPE: return "HEVC 
Hierarchical Coding Type";
+   case V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER:return "HEVC 
Hierarchical Coding Layer";
+   case V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER_QP: return "HEVC 
Hierarchical Layer QP";
+   case V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L0_BR:return "HEVC 
Hierarchical Lay 0 Bit Rate";
+   case 

[Patch v5 08/12] [media] s5p-mfc: Add support for HEVC decoder

2017-06-18 Thread Smitha T Murthy
Add support for codec definition and corresponding buffer
requirements for HEVC decoder.

Signed-off-by: Smitha T Murthy 
Reviewed-by: Andrzej Hajda 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v10.h   |  1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c |  3 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |  1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c|  7 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 17 +++--
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h |  3 +++
 6 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
index 3f0dab3..953a073 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
@@ -33,6 +33,7 @@
 #define MFC_NUM_PORTS_V10  1
 
 /* MFCv10 codec defines*/
+#define S5P_FIMV_CODEC_HEVC_DEC17
 #define S5P_FIMV_CODEC_HEVC_ENC 26
 
 /* Encoder buffer size for MFC v10.0 */
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
index b1b1491..76eca67 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
@@ -101,6 +101,9 @@ static int s5p_mfc_open_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
case S5P_MFC_CODEC_VP8_DEC:
codec_type = S5P_FIMV_CODEC_VP8_DEC_V6;
break;
+   case S5P_MFC_CODEC_HEVC_DEC:
+   codec_type = S5P_FIMV_CODEC_HEVC_DEC;
+   break;
case S5P_MFC_CODEC_H264_ENC:
codec_type = S5P_FIMV_CODEC_H264_ENC_V6;
break;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index e65e1c3..828e07e 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -72,6 +72,7 @@
 #define S5P_MFC_CODEC_H263_DEC 5
 #define S5P_MFC_CODEC_VC1RCV_DEC   6
 #define S5P_MFC_CODEC_VP8_DEC  7
+#define S5P_MFC_CODEC_HEVC_DEC 17
 
 #define S5P_MFC_CODEC_H264_ENC 20
 #define S5P_MFC_CODEC_H264_MVC_ENC 21
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 81de3029..4749355 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -144,6 +144,13 @@ static struct s5p_mfc_fmt formats[] = {
.num_planes = 1,
.versions   = MFC_V6PLUS_BITS,
},
+   {
+   .fourcc = V4L2_PIX_FMT_HEVC,
+   .codec_mode = S5P_FIMV_CODEC_HEVC_DEC,
+   .type   = MFC_FMT_DEC,
+   .num_planes = 1,
+   .versions   = MFC_V10_BIT,
+   },
 };
 
 #define NUM_FORMATS ARRAY_SIZE(formats)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index 83ea733..ed725db 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -220,6 +220,12 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct 
s5p_mfc_ctx *ctx)
S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
ctx->bank1.size = ctx->scratch_buf_size;
break;
+   case S5P_MFC_CODEC_HEVC_DEC:
+   mfc_debug(2, "Use min scratch buffer size\n");
+   ctx->bank1.size =
+   ctx->scratch_buf_size +
+   (ctx->mv_count * ctx->mv_size);
+   break;
case S5P_MFC_CODEC_H264_ENC:
if (IS_MFCV10(dev)) {
mfc_debug(2, "Use min scratch buffer size\n");
@@ -321,6 +327,7 @@ static int s5p_mfc_alloc_instance_buffer_v6(struct 
s5p_mfc_ctx *ctx)
switch (ctx->codec_mode) {
case S5P_MFC_CODEC_H264_DEC:
case S5P_MFC_CODEC_H264_MVC_DEC:
+   case S5P_MFC_CODEC_HEVC_DEC:
ctx->ctx.size = buf_size->h264_dec_ctx;
break;
case S5P_MFC_CODEC_MPEG4_DEC:
@@ -434,6 +441,10 @@ static void s5p_mfc_dec_calc_dpb_size_v6(struct 
s5p_mfc_ctx *ctx)
ctx->mv_size = S5P_MFC_DEC_MV_SIZE_V6(ctx->img_width,
ctx->img_height);
}
+   } else if (ctx->codec_mode == S5P_MFC_CODEC_HEVC_DEC) {
+   ctx->mv_size = s5p_mfc_dec_hevc_mv_size(ctx->img_width,
+   ctx->img_height);
+   ctx->mv_size = ALIGN(ctx->mv_size, 32);
} else {
ctx->mv_size = 0;
}
@@ -515,7 +526,8 @@ static int s5p_mfc_set_dec_frame_buffer_v6(struct 
s5p_mfc_ctx *ctx)
buf_size1 -= ctx->scratch_buf_size;
 
if (ctx->codec_mode == S5P_FIMV_CODEC_H264_DEC ||
-   

[Patch v5 11/12] [media] s5p-mfc: Add support for HEVC encoder

2017-06-18 Thread Smitha T Murthy
Add HEVC encoder support and necessary registers, V4L2 CIDs,
and hevc encoder parameters

Signed-off-by: Smitha T Murthy 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v10.h   |  28 +-
 drivers/media/platform/s5p-mfc/s5p_mfc.c|   1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c |   3 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |  53 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c| 521 
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.h|   8 +
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 168 
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h |   8 +
 8 files changed, 788 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
index 6754477..7065b9d 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
@@ -20,13 +20,35 @@
 #define S5P_FIMV_MFC_STATE_V10 0x7124
 #define S5P_FIMV_D_STATIC_BUFFER_ADDR_V10  0xF570
 #define S5P_FIMV_D_STATIC_BUFFER_SIZE_V10  0xF574
+#define S5P_FIMV_E_NUM_T_LAYER_V10 0xFBAC
+#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER0_V10  0xFBB0
+#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER1_V10  0xFBB4
+#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER2_V10  0xFBB8
+#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER3_V10  0xFBBC
+#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER4_V10  0xFBC0
+#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER5_V10  0xFBC4
+#define S5P_FIMV_E_HIERARCHICAL_QP_LAYER6_V10  0xFBC8
+#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER0_V100xFD18
+#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER1_V100xFD1C
+#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER2_V100xFD20
+#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER3_V100xFD24
+#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER4_V100xFD28
+#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER5_V100xFD2C
+#define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER6_V100xFD30
+#define S5P_FIMV_E_HEVC_OPTIONS_V100xFDD4
+#define S5P_FIMV_E_HEVC_REFRESH_PERIOD_V10 0xFDD8
+#define S5P_FIMV_E_HEVC_CHROMA_QP_OFFSET_V10   0xFDDC
+#define S5P_FIMV_E_HEVC_LF_BETA_OFFSET_DIV2_V100xFDE0
+#define S5P_FIMV_E_HEVC_LF_TC_OFFSET_DIV2_V10  0xFDE4
+#define S5P_FIMV_E_HEVC_NAL_CONTROL_V100xFDE8
 
 /* MFCv10 Context buffer sizes */
 #define MFC_CTX_BUF_SIZE_V10   (30 * SZ_1K)
 #define MFC_H264_DEC_CTX_BUF_SIZE_V10  (2 * SZ_1M)
 #define MFC_OTHER_DEC_CTX_BUF_SIZE_V10 (20 * SZ_1K)
 #define MFC_H264_ENC_CTX_BUF_SIZE_V10  (100 * SZ_1K)
-#define MFC_OTHER_ENC_CTX_BUF_SIZE_V10 (15 * SZ_1K)
+#define MFC_HEVC_ENC_CTX_BUF_SIZE_V10  (30 * SZ_1K)
+#define MFC_OTHER_ENC_CTX_BUF_SIZE_V10  (15 * SZ_1K)
 
 /* MFCv10 variant defines */
 #define MAX_FW_SIZE_V10(SZ_1M)
@@ -58,5 +80,9 @@
 #define ENC_V100_VP8_ME_SIZE(x, y) \
ENC_V100_BASE_SIZE(x, y)
 
+#define ENC_V100_HEVC_ME_SIZE(x, y)\
+   (((x + 3) * (y + 3) * 32)   \
++ ((y * 128) + 1280) * DIV_ROUND_UP(x, 4))
+
 #endif /*_REGS_MFC_V10_H*/
 
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index efc36b0..742c2b7 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1621,6 +1621,7 @@ static struct s5p_mfc_buf_size_v6 mfc_buf_size_v10 = {
.h264_dec_ctx   = MFC_H264_DEC_CTX_BUF_SIZE_V10,
.other_dec_ctx  = MFC_OTHER_DEC_CTX_BUF_SIZE_V10,
.h264_enc_ctx   = MFC_H264_ENC_CTX_BUF_SIZE_V10,
+   .hevc_enc_ctx   = MFC_HEVC_ENC_CTX_BUF_SIZE_V10,
.other_enc_ctx  = MFC_OTHER_ENC_CTX_BUF_SIZE_V10,
 };
 
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
index 102b47e..7521fce 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
@@ -122,6 +122,9 @@ static int s5p_mfc_open_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
case S5P_MFC_CODEC_VP8_ENC:
codec_type = S5P_FIMV_CODEC_VP8_ENC_V7;
break;
+   case S5P_MFC_CODEC_HEVC_ENC:
+   codec_type = S5P_FIMV_CODEC_HEVC_ENC;
+   break;
default:
codec_type = S5P_FIMV_CODEC_NONE_V6;
}
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index b49f220..c1ae4f4 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -61,7 +61,7 @@
 #define MFC_ENC_CAP_PLANE_COUNT1
 #define MFC_ENC_OUT_PLANE_COUNT2
 #define STUFF_BYTE 4
-#define MFC_MAX_CTRLS  77
+#define MFC_MAX_CTRLS  128
 
 #define S5P_MFC_CODEC_NONE -1
 #define S5P_MFC_CODEC_H264_DEC  

[Patch v5 12/12] Documention: v4l: Documentation for HEVC CIDs

2017-06-18 Thread Smitha T Murthy
Added V4l2 controls for HEVC encoder

Signed-off-by: Smitha T Murthy 
---
 Documentation/media/uapi/v4l/extended-controls.rst | 364 +
 1 file changed, 364 insertions(+)

diff --git a/Documentation/media/uapi/v4l/extended-controls.rst 
b/Documentation/media/uapi/v4l/extended-controls.rst
index abb1057..7767c70 100644
--- a/Documentation/media/uapi/v4l/extended-controls.rst
+++ b/Documentation/media/uapi/v4l/extended-controls.rst
@@ -1960,6 +1960,370 @@ enum v4l2_vp8_golden_frame_sel -
 1, 2 and 3 corresponding to encoder profiles 0, 1, 2 and 3.
 
 
+High Efficiency Video Coding (HEVC/H.265) Control Reference
+---
+
+The HEVC/H.265 controls include controls for encoding parameters of HEVC/H.265
+video codec.
+
+
+.. _hevc-control-id:
+
+HEVC/H.265 Control IDs
+^^
+
+``V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP (integer)``
+Minimum quantization parameter for HEVC.
+
+``V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP (integer)``
+Maximum quantization parameter for HEVC.
+
+``V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP (integer)``
+Quantization parameter for an I frame for HEVC.
+
+``V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_QP (integer)``
+Quantization parameter for a P frame for HEVC.
+
+``V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP (integer)``
+Quantization parameter for a B frame for HEVC.
+
+``V4L2_CID_MPEG_VIDEO_HEVC_HIER_QP (boolean)``
+HIERARCHICAL_QP allows host to specify the quantization parameter values
+for each temporal layer through HIERARCHICAL_QP_LAYER. This is valid only
+if HIERARCHICAL_CODING_LAYER is greater than 1. Setting the control value
+to 1 enables setting of the QP values for the layers.
+
+.. _v4l2-hevc-hier-coding-type:
+
+``V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_TYPE``
+(enum)
+
+enum v4l2_mpeg_video_hevc_hier_coding_type -
+Selects the hierarchical coding type for encoding. Possible values are:
+
+.. raw:: latex
+
+\begin{adjustbox}{width=\columnwidth}
+
+.. tabularcolumns:: |p{11.0cm}|p{10.0cm}|
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+* - ``V4L2_MPEG_VIDEO_HEVC_HIERARCHICAL_CODING_B``
+  - Use the B frame for hierarchical coding.
+* - ``V4L2_MPEG_VIDEO_HEVC_HIERARCHICAL_CODING_P``
+  - Use the P frame for hierarchical coding.
+
+.. raw:: latex
+
+\end{adjustbox}
+
+
+``V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER (integer)``
+Selects the hierarchical coding layer. In normal encoding
+(non-hierarchial coding), it should be zero. Possible values are 0 ~ 6.
+0 indicates HIERARCHICAL CODING LAYER 0, 1 indicates HIERARCHICAL CODING
+LAYER 1 and so on.
+
+``V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER_QP (integer)``
+Indicates the hierarchical coding layer quantization parameter.
+For HEVC it can have a value of 0-51. Hence in the control value passed
+the LSB 16 bits will indicate the quantization parameter. The MSB 16 bit
+will pass the layer(0-6) it is meant for.
+
+.. _v4l2-hevc-profile:
+
+``V4L2_CID_MPEG_VIDEO_HEVC_PROFILE``
+(enum)
+
+enum v4l2_mpeg_video_hevc_profile -
+Select the desired profile for HEVC encoder.
+
+.. raw:: latex
+
+\begin{adjustbox}{width=\columnwidth}
+
+.. tabularcolumns:: |p{11.0cm}|p{10.0cm}|
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+* - ``V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN``
+  - Main profile.
+* - ``V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE``
+  - Main still picture profile.
+
+.. raw:: latex
+
+\end{adjustbox}
+
+
+.. _v4l2-hevc-level:
+
+``V4L2_CID_MPEG_VIDEO_HEVC_LEVEL``
+(enum)
+
+enum v4l2_mpeg_video_hevc_level -
+Selects the desired level for HEVC encoder.
+
+.. raw:: latex
+
+\begin{adjustbox}{width=\columnwidth}
+
+.. tabularcolumns:: |p{11.0cm}|p{10.0cm}|
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_1``
+  - Level 1.0
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_2``
+  - Level 2.0
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_2_1``
+  - Level 2.1
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_3``
+  - Level 3.0
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_3_1``
+  - Level 3.1
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_4``
+  - Level 4.0
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1``
+  - Level 4.1
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_5``
+  - Level 5.0
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1``
+  - Level 5.1
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2``
+  - Level 5.2
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_6``
+  - Level 6.0
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1``
+  - Level 6.1
+* - ``V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2``
+  - Level 6.2
+
+.. raw:: latex
+
+\end{adjustbox}
+
+
+``V4L2_CID_MPEG_VIDEO_HEVC_FRAME_RATE_RESOLUTION (integer)``
+Indicates the number of evenly spaced subintervals, called ticks, within
+one second. This is a 16bit unsigned integer and has a maximum value up to
+0x.

[PATCH] v4l2-core: Use kvmalloc() for potentially big allocations

2017-06-18 Thread Tomasz Figa
There are multiple places where arrays or otherwise variable sized
buffer are allocated through V4L2 core code, including things like
controls, memory pages, staging buffers for ioctls and so on. Such
allocations can potentially require an order > 0 allocation from the
page allocator, which is not guaranteed to be fulfilled and is likely to
fail on a system with severe memory fragmentation (e.g. a system with
very long uptime).

Since the memory being allocated is intended to be used by the CPU
exclusively, we can consider using vmalloc() as a fallback and this is
exactly what the recently merged kvmalloc() helpers do. A kmalloc() call
is still attempted, even for order > 0 allocations, but it is done
with __GFP_NORETRY and __GFP_NOWARN, with expectation of failing if
requested memory is not available instantly. Only then the vmalloc()
fallback is used. This should give us fast and more reliable allocations
even on systems with higher memory pressure and/or more fragmentation,
while still retaining the same performance level on systems not
suffering from such conditions.

While at it, replace explicit array size calculations on changed
allocations with kvmalloc_array().

Purposedly not touching videobuf1, as it is deprecated, has only few
users remaining and would rather be seen removed instead.

Signed-off-by: Tomasz Figa 
Acked-by: Marek Szyprowski 
Acked-by: Sakari Ailus 
---
Changes since RFC:
 - added explicit includes for ,
 - added Marek's and Sakari's Acked-by.
---
 drivers/media/v4l2-core/v4l2-async.c   |  5 +++--
 drivers/media/v4l2-core/v4l2-ctrls.c   | 26 ++
 drivers/media/v4l2-core/v4l2-event.c   |  8 +---
 drivers/media/v4l2-core/v4l2-ioctl.c   |  7 ---
 drivers/media/v4l2-core/v4l2-subdev.c  |  8 +---
 drivers/media/v4l2-core/videobuf2-dma-sg.c |  8 
 6 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index cbd919d4edd2..46fc8baf8a17 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -209,7 +210,7 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
if (!notifier->v4l2_dev)
return;
 
-   dev = kmalloc_array(n_subdev, sizeof(*dev), GFP_KERNEL);
+   dev = kvmalloc_array(n_subdev, sizeof(*dev), GFP_KERNEL);
if (!dev) {
dev_err(notifier->v4l2_dev->dev,
"Failed to allocate device cache!\n");
@@ -265,7 +266,7 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
}
put_device(d);
}
-   kfree(dev);
+   kvfree(dev);
 
notifier->v4l2_dev = NULL;
 
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 5aed7bd20ad2..1e6363a650c0 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -19,6 +19,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1745,8 +1746,9 @@ int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler 
*hdl,
INIT_LIST_HEAD(>ctrls);
INIT_LIST_HEAD(>ctrl_refs);
hdl->nr_of_buckets = 1 + nr_of_controls_hint / 8;
-   hdl->buckets = kcalloc(hdl->nr_of_buckets, sizeof(hdl->buckets[0]),
-  GFP_KERNEL);
+   hdl->buckets = kvmalloc_array(hdl->nr_of_buckets,
+ sizeof(hdl->buckets[0]),
+ GFP_KERNEL | __GFP_ZERO);
hdl->error = hdl->buckets ? 0 : -ENOMEM;
return hdl->error;
 }
@@ -1773,9 +1775,9 @@ void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl)
list_del(>node);
list_for_each_entry_safe(sev, next_sev, >ev_subs, node)
list_del(>node);
-   kfree(ctrl);
+   kvfree(ctrl);
}
-   kfree(hdl->buckets);
+   kvfree(hdl->buckets);
hdl->buckets = NULL;
hdl->cached = NULL;
hdl->error = 0;
@@ -2023,7 +2025,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
 is_array)
sz_extra += 2 * tot_ctrl_size;
 
-   ctrl = kzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL);
+   ctrl = kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL);
if (ctrl == NULL) {
handler_set_err(hdl, -ENOMEM);
return NULL;
@@ -2072,7 +2074,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
}
 
if (handler_new_ref(hdl, ctrl)) {
-   kfree(ctrl);
+   kvfree(ctrl);
return NULL;
}
mutex_lock(hdl->lock);
@@ -2842,8 +2844,8 @@ int 

Re: [RFC PATCH 2/2] media/uapi/v4l: clarify cropcap/crop/selection behavior

2017-06-18 Thread Sylwester Nawrocki
On 06/16/2017 03:08 PM, Sakari Ailus wrote:
> On Mon, May 08, 2017 at 04:35:06PM +0200, Hans Verkuil wrote:
>> From: Hans Verkuil 
>>
>> Unfortunately the use of 'type' was inconsistent for multiplanar
>> buffer types. Starting with 4.12 both the normal and _MPLANE variants
>> are allowed, thus making it possible to write sensible code.
>>
>> Yes, we messed up :-(
> 
> Things worse than this have happened. :-)
> 
> I don't think in general I would write about driver bugs that have already
> been fixed in developer documentation. That said, I'm not sure how otherwise
> developers would learn about this, but OTOH has it been reported to us as a
> bug?
> 
> Marek, Sylwester: any idea how widely the drivers in question are in use? If
> there's a real chance of hitting this, then it does make sense to mention it
> in the documentation.

I'm not sure how widely are used those drivers, I think we should just assume 
they are deployed and whatever we do should be backwards compatible. I don't 
think it is much helpful for Exynos to add notes like this in the 
documentation, 
so far I didn't receive any related bug report.

And even though now there is some confusion because drivers see "regular" 
buffer type while user space uses _MPLANE I like the $subject patch set
as it makes the API clearer from user perspective.

--
Regards,
Sylwester
































 



Re: [RFC PATCH 1/2] v4l2-ioctl/exynos: fix G/S_SELECTION's type handling

2017-06-18 Thread Sakari Ailus
Hi Sylwester,

On Sun, Jun 18, 2017 at 10:53:48PM +0200, Sylwester Nawrocki wrote:
> >> + */
> >> +static int v4l_g_selection(const struct v4l2_ioctl_ops *ops,
> >> + struct file *file, void *fh, void *arg)
> >> +{
> >> +  struct v4l2_selection *p = arg;
> >> +  u32 old_type = p->type;
> >> +  int ret;
> >> +
> >> +  if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> >> +  p->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> >> +  else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
> >> +  p->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
> >> +  ret = ops->vidioc_g_selection(file, fh, p);
> >> +  p->type = old_type;
> >> +  return ret;
> >> +}
> >> +
> >> +static int v4l_s_selection(const struct v4l2_ioctl_ops *ops,
> >> + struct file *file, void *fh, void *arg)
> >> +{
> >> +  struct v4l2_selection *p = arg;
> >> +  u32 old_type = p->type;
> >> +  int ret;
> >> +
> >> +  if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> >> +  p->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> >> +  else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
> >> +  p->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
> >> +  ret = ops->vidioc_s_selection(file, fh, p);
> > 
> > Can it be that ops->vidioc_s_selection() is NULL here? I don't think it's
> > checked anywhere. Same in v4l_g_selection().
> 
> I think it can't be, there is the valid_ioctls bitmap test before a call back 
> to the driver, to see if driver actually implements an ioctl. And the bitmap 
> is populated beforehand in determine_valid_ioctls().

Ack. Looks good to me then.

Acked-by: Sakari Ailus 

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk


Re: [RFC PATCH 1/2] v4l2-ioctl/exynos: fix G/S_SELECTION's type handling

2017-06-18 Thread Sylwester Nawrocki
Hi,

On 06/16/2017 02:58 PM, Sakari Ailus wrote:
> Hi Hans,
> 
> Cc Sylwester and Marek as well.
> 
> On Mon, May 08, 2017 at 04:35:05PM +0200, Hans Verkuil wrote:
>> From: Hans Verkuil 
>>
>> The type field in struct v4l2_selection is supposed to never use the
>> _MPLANE variants. E.g. if the driver supports 
>> V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
>> then userspace should still pass V4L2_BUF_TYPE_VIDEO_CAPTURE.
>>
>> The reasons for this are lost in the mists of time, but it is really
>> annoying. In addition, the exynos drivers didn't follow this rule and
>> instead expected the _MPLANE type.
>>
>> To fix that code is added to the v4l2 core that maps the _MPLANE buffer
>> types to their regular equivalents before calling the driver.
>>
>> Effectively this allows for userspace to use either _MPLANE or the regular
>> buffer type. This keeps backwards compatibility while making things easier
>> for userspace.
>>
>> Since drivers now never see the _MPLANE buffer types the exynos drivers
>> had to be adapted as well.
>>
>> Signed-off-by: Hans Verkuil 
>> ---
>>   drivers/media/platform/exynos-gsc/gsc-core.c |  4 +-
>>   drivers/media/platform/exynos-gsc/gsc-m2m.c  |  8 ++--
>>   drivers/media/platform/exynos4-is/fimc-capture.c |  4 +-
>>   drivers/media/platform/exynos4-is/fimc-lite.c|  4 +-
>>   drivers/media/v4l2-core/v4l2-ioctl.c | 53 
>> +---
>>   5 files changed, 57 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
>> b/drivers/media/platform/exynos-gsc/gsc-core.c
>> index 59a634201830..107faa04c947 100644
>> --- a/drivers/media/platform/exynos-gsc/gsc-core.c
>> +++ b/drivers/media/platform/exynos-gsc/gsc-core.c

>> +/*
>> + * The selection API specified originally that the _MPLANE buffer types
>> + * shouldn't be used. The reasons for this are lost in the mists of time
>> + * (or just really crappy memories). Regardless, this is really annoying
>> + * for userspace. So to keep things simple we map _MPLANE buffer types
>> + * to their 'regular' counterparts before calling the driver. And we
>> + * restore it afterwards. This way applications can use either buffer
>> + * type and drivers don't need to check for both.

I agree this is annoying the _MPLANE buffer types are excluded this way. 
I suspect one of the main reasons was bias of the original author of the 
selection API to the multi-planar API. Now the API got messy because I didn't
adhere to this rule of buffer type change for VIDIOC_S_SELECTION, and the
code propagated to the other driver. Sorry about that.  

I checked GStreamer and AFAIU there is no change of buffer type for
S_SELECTION there:
https://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/sys/v4l2/gstv4l2object.c?id=3342d86d9b92cf60c419b728d10944968d77ecac#n3722

>> + */
>> +static int v4l_g_selection(const struct v4l2_ioctl_ops *ops,
>> +   struct file *file, void *fh, void *arg)
>> +{
>> +struct v4l2_selection *p = arg;
>> +u32 old_type = p->type;
>> +int ret;
>> +
>> +if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
>> +p->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
>> +else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
>> +p->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
>> +ret = ops->vidioc_g_selection(file, fh, p);
>> +p->type = old_type;
>> +return ret;
>> +}
>> +
>> +static int v4l_s_selection(const struct v4l2_ioctl_ops *ops,
>> +   struct file *file, void *fh, void *arg)
>> +{
>> +struct v4l2_selection *p = arg;
>> +u32 old_type = p->type;
>> +int ret;
>> +
>> +if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
>> +p->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
>> +else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
>> +p->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
>> +ret = ops->vidioc_s_selection(file, fh, p);
> 
> Can it be that ops->vidioc_s_selection() is NULL here? I don't think it's
> checked anywhere. Same in v4l_g_selection().

I think it can't be, there is the valid_ioctls bitmap test before a call back 
to the driver, to see if driver actually implements an ioctl. And the bitmap 
is populated beforehand in determine_valid_ioctls().

--
Regards,
Sylwester















Re: [PATCH v3 2/4] [media] platform: Add Synopsys Designware HDMI RX Controller Driver

2017-06-18 Thread Sylwester Nawrocki
On 06/16/2017 06:38 PM, Jose Abreu wrote:
> This is an initial submission for the Synopsys Designware HDMI RX
> Controller Driver. This driver interacts with a phy driver so that
> a communication between them is created and a video pipeline is
> configured.
> 
> The controller + phy pipeline can then be integrated into a fully
> featured system that can be able to receive video up to 4k@60Hz
> with deep color 48bit RGB, depending on the platform. Although,
> this initial version does not yet handle deep color modes.

> Signed-off-by: Jose Abreu 

> +static int dw_hdmi_phy_init(struct dw_hdmi_dev *dw_dev)
> +{
> + struct dw_phy_pdata *phy = _dev->phy_config;
> + struct platform_device_info pdevinfo;
> +
> + memset(, 0, sizeof(pdevinfo));
> +
> + phy->funcs = _hdmi_phy_funcs;
> + phy->funcs_arg = dw_dev;
> +
> + pdevinfo.parent = dw_dev->dev;
> + pdevinfo.id = PLATFORM_DEVID_NONE;
> + pdevinfo.name = dw_dev->phy_drv;
> + pdevinfo.data = phy;
> + pdevinfo.size_data = sizeof(*phy);
> + pdevinfo.dma_mask = DMA_BIT_MASK(32);
> +
> + request_module(pdevinfo.name);
> +
> + dw_dev->phy_pdev = platform_device_register_full();
> + if (IS_ERR(dw_dev->phy_pdev)) {
> + dev_err(dw_dev->dev, "failed to register phy device\n");
> + return PTR_ERR(dw_dev->phy_pdev);
> + }
> +
> + if (!dw_dev->phy_pdev->dev.driver) {
> + dev_err(dw_dev->dev, "failed to initialize phy driver\n");
> + goto err;
> + }

I think this is not safe because there is nothing preventing unbinding 
or unloading the driver at this point.

> + if (!try_module_get(dw_dev->phy_pdev->dev.driver->owner)) {

So dw_dev->phy_pdev->dev.driver may be already NULL here.

> + dev_err(dw_dev->dev, "failed to get phy module\n");
> + goto err;
> + }
> +
> + dw_dev->phy_sd = dev_get_drvdata(_dev->phy_pdev->dev);
> + if (!dw_dev->phy_sd) {
> + dev_err(dw_dev->dev, "failed to get phy subdev\n");
> + goto err_put;
> + }
> +
> + if (v4l2_device_register_subdev(_dev->v4l2_dev, dw_dev->phy_sd)) {
> + dev_err(dw_dev->dev, "failed to register phy subdev\n");
> + goto err_put;
> + }

I'd suggest usign v4l2-async API, so we use a common pattern for sub-device
registration.  And with recent change [1] you could handle this PHY subdev
in a standard way.  That might be more complicated than it is now but should 
make any future platform integration easier.

[1] https://patchwork.linuxtv.org/patch/41834

> + module_put(dw_dev->phy_pdev->dev.driver->owner);
> + return 0;
> +
> +err_put:
> + module_put(dw_dev->phy_pdev->dev.driver->owner);
> +err:
> + platform_device_unregister(dw_dev->phy_pdev);
> + return -EINVAL;
> +}
> +
> +static void dw_hdmi_phy_exit(struct dw_hdmi_dev *dw_dev)
> +{
> + if (!IS_ERR(dw_dev->phy_pdev))
> + platform_device_unregister(dw_dev->phy_pdev);
> +}

> +static int dw_hdmi_config_hdcp(struct dw_hdmi_dev *dw_dev)
> +{

> + for (i = 0; i < DW_HDMI_HDCP14_KEYS_SIZE; i += 2) {
> + for (j = 0; j < key_write_tries; j++) {
> + if (is_hdcp14_key_write_allowed(dw_dev))
> + break;
> + mdelay(10);

usleep_range()? I've seen more (busy waiting) mdelay() calls in this
patch series.


> +static int __dw_hdmi_power_on(struct dw_hdmi_dev *dw_dev, u32 input)
> +{
> + unsigned long flags;
> + int ret;
> +
> + ret = dw_hdmi_config(dw_dev, input);
> +
> + spin_lock_irqsave(_dev->lock, flags);
> + dw_dev->pending_config = false;
> + spin_unlock_irqrestore(_dev->lock, flags);
> +
> + return ret;
> +}
> +
> +struct dw_hdmi_work_data {
> + struct dw_hdmi_dev *dw_dev;
> + struct work_struct work;
> + u32 input;
> +};
> +
> +static void dw_hdmi_work_handler(struct work_struct *work)
> +{
> + struct dw_hdmi_work_data *data = container_of(work,
> + struct dw_hdmi_work_data, work);
> +
> + __dw_hdmi_power_on(data->dw_dev, data->input);
> + devm_kfree(data->dw_dev->dev, data);
> +}
> +
> +static int dw_hdmi_power_on(struct dw_hdmi_dev *dw_dev, u32 input)
> +{
> + struct dw_hdmi_work_data *data;
> + unsigned long flags;
> +
> + data = devm_kzalloc(dw_dev->dev, sizeof(*data), GFP_KERNEL);

Why use devm_{kzalloc, kfree} when dw_hdmi_power_on() is not only called
in the device's probe() callback, but in other places, including interrupt 
handler?  devm_* API is normally used when life time of a resource is more 
or less equal to life time of struct device or its matched driver.  Were 
there any specific reasons to not just use kzalloc()/kfree() ?

> + if (!data)
> + return -ENOMEM;
> +
> + INIT_WORK(>work, dw_hdmi_work_handler);
> + data->dw_dev = dw_dev;
> + data->input = input;
> +
> + spin_lock_irqsave(_dev->lock, flags);

Re: [PATCH v3 4/4] dt-bindings: media: Document Synopsys Designware HDMI RX

2017-06-18 Thread Sylwester Nawrocki
Hi Jose,

On 06/16/2017 06:38 PM, Jose Abreu wrote:
> Document the bindings for the Synopsys Designware HDMI RX.
> 
> Signed-off-by: Jose Abreu 

> new file mode 100644
> index 000..d30cc1e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/snps,dw-hdmi-rx.txt
> @@ -0,0 +1,45 @@
> +Synopsys DesignWare HDMI RX Decoder
> +===
> +
> +This document defines device tree properties for the Synopsys DesignWare HDMI
> +RX Decoder (DWC HDMI RX). It doesn't constitute a device tree binding
> +specification by itself but is meant to be referenced by platform-specific
> +device tree bindings.
> +
> +When referenced from platform device tree bindings the properties defined in
> +this document are defined as follows.
> +
> +- reg: Memory mapped base address and length of the DWC HDMI RX registers.
> +
> +- interrupts: Reference to the DWC HDMI RX interrupt and 5v sense interrupt.
> +
> +- snps,hdmi-phy-jtag-addr: JTAG address of the phy to be used.
> +
> +- snps,hdmi-phy-version: Version of the phy to be used.
> +
> +- snps,hdmi-phy-cfg-clk: Value of the cfg clk that is delivered to phy.
> +
> +- snps,hdmi-phy-driver: *Exact* name of the phy driver to be used.

I don't think we can put Linux driver name in DT like this, devicetree 
is supposed to be describing hardware in OS agnostic way.

> +- snps,hdmi-ctl-cfg-clk: Value of the cfg clk that is delivered to the
> +controller.

How about creating a separate node for the PHY? The binding could then 
be something like:


/* Fixed clock needed only if respective clock is not already defined
   in the system */

refclk: clock {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <2500>;
};

hdmi_phy: phy@f3 {
/* PHY version can be derived from the compatible string */
compatible = "snps,dw-hdmi-phy-e405";   
/* JTAG address of the PHY */
reg = <0xf3>

clocks = <>
clock-names = "cfg-clk";
}

hdmi-controller@0 {
compatible = "snps,dw-hdmi-rx-controller-vX.X";
reg = <0x0 0x1>;
interrupts = <1 3>; 
phys = <_phy>;

clocks = <>
clock-names = "cfg-clk";
};

Or it might be better to make the PHY node child node of the RX controller 
node, since the RX controller could be considered a controller of the JTAG 
bus IIUC:

refclk: clock {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <2500>;
};

hdmi-controller@0 {
compatible = "snps,dw-hdmi-rx-controller-xxx";
reg = <0x0 0x1>;
interrupts = <1 3>; 
clocks = <>
clock-names = "cfg-clk";
#address-cells = <1>;
#size-cells = <0>;

phy@f3 {
/* PHY version can be derived from the compatible string */
compatible = "snps,dw-hdmi-phy-e405";
/* address of the PHY on the JTAG bus */
reg = <0xf3>

clocks = <>
clock-names = "cfg-clk";
}
};

Then rather than creating platform device in the RX controller driver 
for the PHY just of_platform_populate() could be used.

> +- edid-phandle: phandle to the EDID driver. It can be, for example, the main
> +wrapper driver.
> +
> +A sample binding is now provided. The compatible string is for a wrapper 
> driver
> +which then instantiates the Synopsys Designware HDMI RX decoder driver.

I would avoid talking about drivers in DT binding documentation, we should 
rather refer to hardware blocks.

> +Example:
> +
> +dw_hdmi_wrapper: dw-hdmi-wrapper@0 {
> + compatible = "snps,dw-hdmi-rx-wrapper";
> + reg = <0x0 0x1>; /* controller regbank */
> + interrupts = <1 3>; /* controller interrupt + 5v sense interrupt */
> + snps,hdmi-phy-driver = "dw-hdmi-phy-e405";
> + snps,hdmi-phy-version = <405>;
> + snps,hdmi-phy-cfg-clk = <25>; /* MHz */
> + snps,hdmi-ctl-cfg-clk = <25>; /* MHz */
> + snps,hdmi-phy-jtag-addr = /bits/ 8 <0xfc>;
> + edid-phandle = <_hdmi_wrapper>;
> +};

--
Regards,
Sylwester



Re: [PATCH 03/12] [media] vb2: add in-fence support to QBUF

2017-06-18 Thread kbuild test robot
Hi Gustavo,

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.12-rc5 next-20170616]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Gustavo-Padovan/vb2-add-explicit-fence-user-API/20170618-210740
base:   git://linuxtv.org/media_tree.git master
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   WARNING: convert(1) not found, for SVG to PDF conversion install ImageMagick 
(https://www.imagemagick.org)
   arch/x86/include/asm/uaccess_32.h:1: warning: no structured comments found
   include/linux/init.h:1: warning: no structured comments found
   include/linux/mod_devicetable.h:686: warning: Excess 
struct/union/enum/typedef member 'ver_major' description in 'fsl_mc_device_id'
   include/linux/mod_devicetable.h:686: warning: Excess 
struct/union/enum/typedef member 'ver_minor' description in 'fsl_mc_device_id'
   kernel/sched/core.c:2088: warning: No description found for parameter 'rf'
   kernel/sched/core.c:2088: warning: Excess function parameter 'cookie' 
description in 'try_to_wake_up_local'
   include/linux/kthread.h:26: warning: Excess function parameter '...' 
description in 'kthread_create'
   kernel/sys.c:1: warning: no structured comments found
   include/linux/device.h:969: warning: No description found for parameter 
'dma_ops'
   drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found
   include/linux/iio/iio.h:597: warning: No description found for parameter 
'trig_readonly'
   include/linux/iio/trigger.h:151: warning: No description found for parameter 
'indio_dev'
   include/linux/iio/trigger.h:151: warning: No description found for parameter 
'trig'
   include/linux/device.h:970: warning: No description found for parameter 
'dma_ops'
   include/linux/usb/gadget.h:230: warning: No description found for parameter 
'claimed'
   include/linux/usb/gadget.h:230: warning: No description found for parameter 
'enabled'
   include/linux/usb/gadget.h:408: warning: No description found for parameter 
'quirk_altset_not_supp'
   include/linux/usb/gadget.h:408: warning: No description found for parameter 
'quirk_stall_not_supp'
   include/linux/usb/gadget.h:408: warning: No description found for parameter 
'quirk_zlp_not_supp'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'set_busid'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'irq_handler'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'irq_preinstall'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'irq_postinstall'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'irq_uninstall'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'debugfs_init'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_open_object'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_close_object'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'prime_handle_to_fd'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'prime_fd_to_handle'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_prime_export'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_prime_import'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_prime_pin'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_prime_unpin'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_prime_res_obj'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_prime_get_sg_table'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_prime_import_sg_table'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_prime_vmap'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_prime_vunmap'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_prime_mmap'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'gem_vm_ops'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'major'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'minor'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'patchlevel'
   include/drm/drm_drv.h:524: warning: No description found for parameter 'name'
   include/drm/drm_drv.h:524: warning: No description found for parameter 'desc'
   include/drm/drm_drv.h:524: warning: No description found for parameter 'date'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'driver_features'
   include/drm/drm_drv.h:524: warning: No description found for parameter 
'ioctls'
   include/drm/drm_drv

Re: [PATCH 01/12] [media] vb2: add explicit fence user API

2017-06-18 Thread kbuild test robot
Hi Gustavo,

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.12-rc5 next-20170616]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Gustavo-Padovan/vb2-add-explicit-fence-user-API/20170618-210740
base:   git://linuxtv.org/media_tree.git master
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   drivers/staging/media//atomisp/pci/atomisp2/atomisp_ioctl.c: In function 
'atomisp_qbuf':
>> drivers/staging/media//atomisp/pci/atomisp2/atomisp_ioctl.c:1297:10: error: 
>> 'struct v4l2_buffer' has no member named 'reserved2'; did you mean 
>> 'reserved'?
 (buf->reserved2 & ATOMISP_BUFFER_HAS_PER_FRAME_SETTING)) {
 ^~
   drivers/staging/media//atomisp/pci/atomisp2/atomisp_ioctl.c:1299:50: error: 
'struct v4l2_buffer' has no member named 'reserved2'; did you mean 'reserved'?
  pipe->frame_request_config_id[buf->index] = buf->reserved2 &
 ^~
   drivers/staging/media//atomisp/pci/atomisp2/atomisp_ioctl.c: In function 
'atomisp_dqbuf':
   drivers/staging/media//atomisp/pci/atomisp2/atomisp_ioctl.c:1483:5: error: 
'struct v4l2_buffer' has no member named 'reserved2'; did you mean 'reserved'?
 buf->reserved2 = pipe->frame_config_id[buf->index];
^~
   In file included from include/linux/printk.h:329:0,
from include/linux/kernel.h:13,
from include/linux/delay.h:21,
from 
drivers/staging/media//atomisp/pci/atomisp2/atomisp_ioctl.c:24:
   drivers/staging/media//atomisp/pci/atomisp2/atomisp_ioctl.c:1488:6: error: 
'struct v4l2_buffer' has no member named 'reserved2'; did you mean 'reserved'?
  buf->reserved2);
 ^
   include/linux/dynamic_debug.h:135:9: note: in definition of macro 
'dynamic_dev_dbg'
  ##__VA_ARGS__);  \
^~~
>> drivers/staging/media//atomisp/pci/atomisp2/atomisp_ioctl.c:1486:2: note: in 
>> expansion of macro 'dev_dbg'
 dev_dbg(isp->dev, "dqbuf buffer %d (%s) for asd%d with exp_id %d, 
isp_config_id %d\n",
 ^~~
   drivers/staging/media//atomisp/pci/atomisp2/atomisp_ioctl.c: At top level:
>> cc1: warning: unrecognized command line option '-Wno-implicit-fallthrough'
--
   drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c: In function 
'atomisp_qbuf':
   drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c:1297:10: error: 
'struct v4l2_buffer' has no member named 'reserved2'; did you mean 'reserved'?
 (buf->reserved2 & ATOMISP_BUFFER_HAS_PER_FRAME_SETTING)) {
 ^~
   drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c:1299:50: error: 
'struct v4l2_buffer' has no member named 'reserved2'; did you mean 'reserved'?
  pipe->frame_request_config_id[buf->index] = buf->reserved2 &
 ^~
   drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c: In function 
'atomisp_dqbuf':
   drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c:1483:5: error: 
'struct v4l2_buffer' has no member named 'reserved2'; did you mean 'reserved'?
 buf->reserved2 = pipe->frame_config_id[buf->index];
^~
   In file included from include/linux/printk.h:329:0,
from include/linux/kernel.h:13,
from include/linux/delay.h:21,
from 
drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c:24:
   drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c:1488:6: error: 
'struct v4l2_buffer' has no member named 'reserved2'; did you mean 'reserved'?
  buf->reserved2);
 ^
   include/linux/dynamic_debug.h:135:9: note: in definition of macro 
'dynamic_dev_dbg'
  ##__VA_ARGS__);  \
^~~
   drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c:1486:2: note: in 
expansion of macro 'dev_dbg'
 dev_dbg(isp->dev, "dqbuf buffer %d (%s) for asd%d with exp_id %d, 
isp_config_id %d\n",
 ^~~
   drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c: At top level:
>> cc1: warning: unrecognized command line option '-Wno-implicit-fallthrough'

vim +1297 drivers/staging/media//atomisp/pci/atomisp2/atomisp_ioctl.c

a49d2536 Alan Cox 2017-02-17  1291  
a49d2536 Alan Cox 2017-02-17  1292  done:
a49d2536 Alan Cox 2017-02-17  1293  if (!((buf->flags & NOFLUSH_FLAGS) == 
NOFLUSH_FLAGS))
a49d2536 Alan Cox 2017-02-17  1294  wbinvd();
a49d2536 Alan Cox 2017-02-17  1295  
a49d2536 Alan Cox 2017-02-17  1296  if (!atomisp_is_vf_pipe(pipe) &&
a49d2536 Alan Cox 2017-02-17 @

Re: [PATCH 01/12] [media] vb2: add explicit fence user API

2017-06-18 Thread kbuild test robot
Hi Gustavo,

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.12-rc5 next-20170616]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Gustavo-Padovan/vb2-add-explicit-fence-user-API/20170618-210740
base:   git://linuxtv.org/media_tree.git master
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 6.3.0-18) 6.3.0 20170516
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sh 

All errors (new ones prefixed by >>):

   drivers/media//usb/cpia2/cpia2_v4l.c: In function 'cpia2_dqbuf':
>> drivers/media//usb/cpia2/cpia2_v4l.c:951:5: error: 'struct v4l2_buffer' has 
>> no member named 'reserved2'; did you mean 'reserved'?
 buf->reserved2 = 0;
^~

vim +951 drivers/media//usb/cpia2/cpia2_v4l.c

1b18e7a0 drivers/media/usb/cpia2/cpia2_v4l.c   Sakari Ailus 2012-10-22  945 
| V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
ab33d507 drivers/media/video/cpia2/cpia2_v4l.c Alan Cox 2006-02-27  946 
buf->field = V4L2_FIELD_NONE;
ab33d507 drivers/media/video/cpia2/cpia2_v4l.c Alan Cox 2006-02-27  947 
buf->timestamp = cam->buffers[buf->index].timestamp;
ab33d507 drivers/media/video/cpia2/cpia2_v4l.c Alan Cox 2006-02-27  948 
buf->sequence = cam->buffers[buf->index].seq;
ab33d507 drivers/media/video/cpia2/cpia2_v4l.c Alan Cox 2006-02-27  949 
buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer;
ab33d507 drivers/media/video/cpia2/cpia2_v4l.c Alan Cox 2006-02-27  950 
buf->length = cam->frame_size;
2b719d7b drivers/media/video/cpia2/cpia2_v4l.c Sakari Ailus 2012-05-02 @951 
buf->reserved2 = 0;
ab33d507 drivers/media/video/cpia2/cpia2_v4l.c Alan Cox 2006-02-27  952 
buf->reserved = 0;
ab33d507 drivers/media/video/cpia2/cpia2_v4l.c Alan Cox 2006-02-27  953 
memset(>timecode, 0, sizeof(buf->timecode));
ab33d507 drivers/media/video/cpia2/cpia2_v4l.c Alan Cox 2006-02-27  954  

:: The code at line 951 was first introduced by commit
:: 2b719d7baf490e24ce7d817c6337b7c87fda84c1 [media] v4l: drop 
v4l2_buffer.input and V4L2_BUF_FLAG_INPUT

:: TO: Sakari Ailus <sakari.ai...@iki.fi>
:: CC: Mauro Carvalho Chehab <mche...@redhat.com>

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH 3/8] dt: bindings: Add a binding for referencing EEPROM from camera sensors

2017-06-18 Thread Rob Herring
On Wed, Jun 14, 2017 at 12:47:14PM +0300, Sakari Ailus wrote:
> Many camera sensor devices contain EEPROM chips that describe the
> properties of a given unit --- the data is specific to a given unit can
> thus is not stored e.g. in user space or the driver.
> 
> Some sensors embed the EEPROM chip and it can be accessed through the
> sensor's I2C interface. This property is to be used for devices where the
> EEPROM chip is accessed through a different I2C address than the sensor.
> 
> The intent is to later provide this information to the user space.
> 
> Signed-off-by: Sakari Ailus 
> Acked-by: Pavel Machek 
> Reviewed-by: Sebastian Reichel 
> ---
>  Documentation/devicetree/bindings/media/video-interfaces.txt | 3 +++
>  1 file changed, 3 insertions(+)

Acked-by: Rob Herring 


LINUX 4.11.6. Leadtek - USB2.0 Winfast DTV dongle does not initialize correctly

2017-06-18 Thread CIJOML CIJOMLovic
Hello,

after years of not using the dongle I wanted to use it. And I ended up
like this. Previously dongle worked correctly. It is not broken I
checked it in Windows.



[   22.050048] usb 3-1: new high-speed USB device number 3 using xhci_hcd
[   22.190321] usb 3-1: New USB device found, idVendor=0413, idProduct=6025
[   22.190323] usb 3-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[   23.218049] dvb-usb: found a 'Leadtek - USB2.0 Winfast DTV dongle'
in cold state, will try to load a firmware
[   23.218287] dvb-usb: downloading firmware from file
'dvb-usb-dibusb-6.0.0.8.fw'
[   23.235307] usbcore: registered new interface driver dvb_usb_dibusb_mc
[   23.237929] usb 3-1: USB disconnect, device number 3
[   23.237953] dvb-usb: generic DVB-USB module successfully
deinitialized and disconnected.
[   25.015530] usb 3-1: new high-speed USB device number 4 using xhci_hcd
[   25.164366] usb 3-1: New USB device found, idVendor=0413, idProduct=6026
[   25.164378] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[   25.164380] usb 3-1: Product: MOD3000
[   25.164380] usb 3-1: Manufacturer: STAE
[   25.165057] dvb-usb: found a 'Leadtek - USB2.0 Winfast DTV dongle'
in warm state.
[   25.165251] dvb-usb: will pass the complete MPEG2 transport stream
to the software demuxer.
[   25.169325] dvbdev: DVB: registering new adapter (Leadtek - USB2.0
Winfast DTV dongle)
[   25.169784] [ cut here ]
[   25.169791] WARNING: CPU: 3 PID: 29 at
/home/kernel/COD/linux/drivers/usb/core/hcd.c:1587
usb_hcd_map_urb_for_dma+0x37f/0x570
[   25.169791] transfer buffer not dma capable
[   25.169792] Modules linked in: dvb_usb_dibusb_mc
dvb_usb_dibusb_mc_common dvb_usb_dibusb_common dib3000mc
dibx000_common dvb_usb dvb_core rc_core ccm xt_CHECKSUM iptable_mangle
ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat
nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack libcrc32c
ipt_REJECT nf_reject_ipv4 xt_tcpudp bridge stp llc ebtable_filter
ebtables ip6table_filter ip6_tables iptable_filter ip_tables x_tables
rfcomm bnep intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp
crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc arc4
snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic
aesni_intel snd_hda_intel iwldvm aes_x86_64 snd_hda_codec crypto_simd
glue_helper snd_hda_core cryptd mac80211 snd_seq_midi snd_hwdep
uvcvideo videobuf2_vmalloc intel_cstate
[   25.169819]  intel_rapl_perf thinkpad_acpi snd_seq_midi_event
joydev input_leds videobuf2_memops snd_pcm serio_raw videobuf2_v4l2
snd_rawmidi videobuf2_core btusb iwlwifi videodev snd_seq cfg80211
btrtl media nvram mei_me btbcm btintel snd_seq_device bluetooth
lpc_ich snd_timer shpchp mei snd soundcore mac_hid kvm_intel kvm
irqbypass parport_pc sunrpc ppdev lp parport autofs4 btrfs xor
raid6_pq i915 i2c_algo_bit psmouse drm_kms_helper syscopyarea
sysfillrect sysimgblt fb_sys_fops ahci e1000e drm libahci sdhci_pci
sdhci ptp pps_core wmi video
[   25.169854] CPU: 3 PID: 29 Comm: kworker/3:0 Not tainted
4.11.6-041106-generic #201706170517
[   25.169855] Hardware name: LENOVO 2325CK9/2325CK9, BIOS G2ETA7WW
(2.67 ) 09/09/2016
[   25.169857] Workqueue: usb_hub_wq hub_event
[   25.169858] Call Trace:
[   25.169862]  dump_stack+0x63/0x81
[   25.169864]  __warn+0xcb/0xf0
[   25.169864]  warn_slowpath_fmt+0x5a/0x80
[   25.169866]  usb_hcd_map_urb_for_dma+0x37f/0x570
[   25.169867]  usb_hcd_submit_urb+0x35c/0xb90
[   25.169869]  ? del_timer_sync+0x48/0x50
[   25.169871]  ? schedule_timeout+0x184/0x310
[   25.169872]  ? del_timer_sync+0x50/0x50
[   25.169874]  usb_submit_urb.part.8+0x30b/0x530
[   25.169875]  ? wait_for_completion_timeout+0xb8/0x140
[   25.169876]  usb_submit_urb+0x62/0x70
[   25.169878]  usb_start_wait_urb+0x6e/0x170
[   25.169879]  usb_bulk_msg+0xbd/0x160
[   25.169882]  dvb_usb_generic_rw+0x15f/0x1e0 [dvb_usb]
[   25.169884]  dibusb_i2c_msg+0xcf/0x130 [dvb_usb_dibusb_common]
[   25.169886]  dibusb_i2c_xfer+0x13c/0x150 [dvb_usb_dibusb_common]
[   25.169887]  __i2c_transfer+0x115/0x3f0
[   25.169889]  ? dvb_usb_fe_sleep+0x60/0x60 [dvb_usb]
[   25.169890]  i2c_transfer+0x5c/0xc0
[   25.169892]  dib3000mc_read_word+0x9a/0x100 [dib3000mc]
[   25.169893]  dib3000mc_identify+0x17/0xc0 [dib3000mc]
[   25.169895]  ? dib3000mc_identify+0x17/0xc0 [dib3000mc]
[   25.169896]  dib3000mc_attach+0x6e/0x450 [dib3000mc]
[   25.169897]  dibusb_dib3000mc_frontend_attach+0x4c/0x160
[dvb_usb_dibusb_mc_common]
[   25.169899]  dvb_usb_adapter_frontend_init+0xdf/0x190 [dvb_usb]
[   25.169900]  dvb_usb_device_init+0x4ca/0x630 [dvb_usb]
[   25.169902]  dibusb_mc_probe+0x25/0x27 [dvb_usb_dibusb_mc]
[   25.169903]  usb_probe_interface+0x159/0x2d0
[   25.169905]  driver_probe_device+0x2bb/0x460
[   25.169906]  __device_attach_driver+0x8c/0x100
[   25.169908]  ? __driver_attach+0xf0/0xf0
[   25.169909]  bus_for_each_drv+0x67/0xb0
[   25.169910]  __device_attach+0xdd/0x160
[   25.169912]  device_initial_probe+0x13/0x20

cron job: media_tree daily build: ERRORS

2017-06-18 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:   Sun Jun 18 05:00:17 CEST 2017
media-tree git hash:acec3630155763c170c7ae6508cf973355464508
media_build git hash:   dbdc2495ec17a3e71d2ec56778eed10081bb718f
v4l-utils git hash: ce237eefc1f6dafafc0e1fe3a5fd9f075d3fd066
gcc version:i686-linux-gcc (GCC) 7.1.0
sparse version: v0.5.0-3553-g78b2ea6
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.9.0-164

linux-git-arm-at91: WARNINGS
linux-git-arm-davinci: WARNINGS
linux-git-arm-multi: WARNINGS
linux-git-arm-pxa: OK
linux-git-arm-stm32: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: WARNINGS
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.67-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: ERRORS
linux-3.17.8-i686: ERRORS
linux-3.18.7-i686: ERRORS
linux-3.19-i686: ERRORS
linux-4.0.9-i686: ERRORS
linux-4.1.33-i686: ERRORS
linux-4.2.8-i686: WARNINGS
linux-4.3.6-i686: WARNINGS
linux-4.4.22-i686: WARNINGS
linux-4.5.7-i686: WARNINGS
linux-4.6.7-i686: WARNINGS
linux-4.7.5-i686: WARNINGS
linux-4.8-i686: OK
linux-4.9.26-i686: OK
linux-4.10.14-i686: OK
linux-4.11-i686: OK
linux-4.12-rc1-i686: OK
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.67-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: ERRORS
linux-3.17.8-x86_64: ERRORS
linux-3.18.7-x86_64: ERRORS
linux-3.19-x86_64: ERRORS
linux-4.0.9-x86_64: ERRORS
linux-4.1.33-x86_64: ERRORS
linux-4.2.8-x86_64: WARNINGS
linux-4.3.6-x86_64: WARNINGS
linux-4.4.22-x86_64: WARNINGS
linux-4.5.7-x86_64: WARNINGS
linux-4.6.7-x86_64: WARNINGS
linux-4.7.5-x86_64: WARNINGS
linux-4.8-x86_64: WARNINGS
linux-4.9.26-x86_64: WARNINGS
linux-4.10.14-x86_64: WARNINGS
linux-4.11-x86_64: WARNINGS
linux-4.12-rc1-x86_64: WARNINGS
apps: WARNINGS
spec-git: OK
sparse: WARNINGS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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