Re: [PATCH v7 6/8] [media] vcodec: mediatek: Add Mediatek VP8 Video Encoder Driver

2016-04-22 Thread kbuild test robot
Hi,

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

url:
https://github.com/0day-ci/linux/commits/Tiffany-Lin/Add-MT8173-Video-Encoder-Driver-and-VPU-Driver/20160422-123111
base:   git://linuxtv.org/media_tree.git master
config: i386-allyesconfig (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c: In function 
'vp8_enc_alloc_work_buf':
>> drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c:214:35: warning: format 
>> '%lx' expects argument of type 'long unsigned int', but argument 7 has type 
>> 'size_t {aka unsigned int}' [-Wformat=]
   drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c: In function 
'vp8_enc_compose_one_frame':
>> drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c:279:10: warning: format 
>> '%ld' expects argument of type 'long int', but argument 4 has type 'size_t 
>> {aka unsigned int}' [-Wformat=]
  mtk_vcodec_err(inst, "bitstream buf size is too small(%ld)",
 ^

vim +214 drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c

   208  tmp_va = vpu_mapping_dm_addr(inst->vpu_inst.dev,
   209   wb[i].vpua);
   210  memcpy(inst->work_bufs[i].va, tmp_va, 
wb[i].size);
   211  }
   212  wb[i].iova = inst->work_bufs[i].dma_addr;
   213  
 > 214  mtk_vcodec_debug(inst,
   215   "work_bufs[%d] 
va=0x%p,iova=0x%p,size=0x%lx",
   216   i, inst->work_bufs[i].va,
   217   (void *)inst->work_bufs[i].dma_addr,
   218   inst->work_bufs[i].size);
   219  }
   220  
   221  mtk_vcodec_debug_leave(inst);
   222  
   223  return ret;
   224  
   225  err_alloc:
   226  vp8_enc_free_work_buf(inst);
   227  
   228  return ret;
   229  }
   230  
   231  static unsigned int vp8_enc_wait_venc_done(struct venc_vp8_inst *inst)
   232  {
   233  unsigned int irq_status = 0;
   234  struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)inst->ctx;
   235  
   236  if (!mtk_vcodec_wait_for_done_ctx(ctx, MTK_INST_IRQ_RECEIVED,
   237WAIT_INTR_TIMEOUT_MS)) {
   238  irq_status = ctx->irq_status;
   239  mtk_vcodec_debug(inst, "isr return %x", irq_status);
   240  }
   241  return irq_status;
   242  }
   243  
   244  /*
   245   * Compose ac_tag, bitstream header and bitstream payload into
   246   * one bitstream buffer.
   247   */
   248  static int vp8_enc_compose_one_frame(struct venc_vp8_inst *inst,
   249   struct mtk_vcodec_mem *bs_buf,
   250   unsigned int *bs_size)
   251  {
   252  unsigned int not_key;
   253  u32 bs_frm_size;
   254  u32 bs_hdr_len;
   255  unsigned int ac_tag_size;
   256  u8 ac_tag[MAX_AC_TAG_SIZE];
   257  
   258  bs_frm_size = vp8_enc_read_reg(inst, VENC_BITSTREAM_FRAME_SIZE);
   259  bs_hdr_len = vp8_enc_read_reg(inst, VENC_BITSTREAM_HEADER_LEN);
   260  
   261  /* if a frame is key frame, not_key is 0 */
   262  not_key = !inst->vpu_inst.is_key_frm;
   263  *(u32 *)ac_tag = __cpu_to_le32((bs_hdr_len << 5) | 0x10 | 
not_key);
   264  /* key frame */
   265  if (not_key == 0) {
   266  ac_tag_size = MAX_AC_TAG_SIZE;
   267  ac_tag[3] = 0x9d;
   268  ac_tag[4] = 0x01;
   269  ac_tag[5] = 0x2a;
   270  ac_tag[6] = inst->vsi->config.pic_w;
   271  ac_tag[7] = inst->vsi->config.pic_w >> 8;
   272  ac_tag[8] = inst->vsi->config.pic_h;
   273  ac_tag[9] = inst->vsi->config.pic_h >> 8;
   274  } else {
   275  ac_tag_size = 3;
   276  }
   277  
   278  if (bs_buf->size < bs_hdr_len + bs_frm_size + ac_tag_size) {
 > 279  mtk_vcodec_err(inst, "bitstream buf size is too 
 > small(%ld)",
   280 bs_buf->size);
   281  return -EINVAL;
   282  }

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


.config.gz
Description: Binary data


Re: [PATCH v7 6/8] [media] vcodec: mediatek: Add Mediatek VP8 Video Encoder Driver

2016-04-21 Thread kbuild test robot
Hi,

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

url:
https://github.com/0day-ci/linux/commits/Tiffany-Lin/Add-MT8173-Video-Encoder-Driver-and-VPU-Driver/20160422-123111
base:   git://linuxtv.org/media_tree.git master
config: xtensa-allmodconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:13:0,
from include/linux/interrupt.h:5,
from 
drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c:17:
   drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c: In function 
'vp8_enc_alloc_work_buf':
>> drivers/media/platform/mtk-vcodec/venc/../mtk_vcodec_util.h:56:14: warning: 
>> format '%lx' expects argument of type 'long unsigned int', but argument 7 
>> has type 'size_t' [-Wformat=]
((struct mtk_vcodec_ctx *)h->ctx)->idx, \
 ^
   include/linux/printk.h:259:34: note: in definition of macro 'pr_info'
 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
 ^
   drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c:214:3: note: in 
expansion of macro 'mtk_vcodec_debug'
  mtk_vcodec_debug(inst,
  ^
   drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c: In function 
'vp8_enc_compose_one_frame':
>> drivers/media/platform/mtk-vcodec/venc/../mtk_vcodec_util.h:62:18: warning: 
>> format '%ld' expects argument of type 'long int', but argument 4 has type 
>> 'size_t' [-Wformat=]
((struct mtk_vcodec_ctx *)h->ctx)->idx, __func__, ##args)
 ^
   include/linux/printk.h:252:33: note: in definition of macro 'pr_err'
 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^
   drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c:279:3: note: in 
expansion of macro 'mtk_vcodec_err'
  mtk_vcodec_err(inst, "bitstream buf size is too small(%ld)",
  ^

vim +56 drivers/media/platform/mtk-vcodec/venc/../mtk_vcodec_util.h

67e5508b Tiffany Lin 2016-04-22  50  #define mtk_v4l2_debug_leave()  
mtk_v4l2_debug(3, "-")
67e5508b Tiffany Lin 2016-04-22  51  
67e5508b Tiffany Lin 2016-04-22  52  #define mtk_vcodec_debug(h, fmt, args...)  
\
67e5508b Tiffany Lin 2016-04-22  53 do {
\
67e5508b Tiffany Lin 2016-04-22  54 if (mtk_vcodec_dbg) 
\
67e5508b Tiffany Lin 2016-04-22  55 
pr_info("[MTK_VCODEC][%d]: %s() " fmt "\n", \
67e5508b Tiffany Lin 2016-04-22 @56 ((struct 
mtk_vcodec_ctx *)h->ctx)->idx, \
67e5508b Tiffany Lin 2016-04-22  57 __func__, 
##args);  \
67e5508b Tiffany Lin 2016-04-22  58 } while (0)
67e5508b Tiffany Lin 2016-04-22  59  
67e5508b Tiffany Lin 2016-04-22  60  #define mtk_vcodec_err(h, fmt, args...)
\
67e5508b Tiffany Lin 2016-04-22  61 pr_err("[MTK_VCODEC][ERROR][%d]: %s() " 
fmt "\n",   \
67e5508b Tiffany Lin 2016-04-22 @62((struct mtk_vcodec_ctx 
*)h->ctx)->idx, __func__, ##args)
67e5508b Tiffany Lin 2016-04-22  63  
67e5508b Tiffany Lin 2016-04-22  64  #define mtk_vcodec_debug_enter(h)  
mtk_vcodec_debug(h, "+")
67e5508b Tiffany Lin 2016-04-22  65  #define mtk_vcodec_debug_leave(h)  
mtk_vcodec_debug(h, "-")

:: The code at line 56 was first introduced by commit
:: 67e5508b437349a82c1a884f6abf3aaa434959e5 vcodec: mediatek: Add Mediatek 
V4L2 Video Encoder Driver

:: TO: Tiffany Lin 
:: CC: 0day robot 

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


.config.gz
Description: Binary data


[PATCH v7 6/8] [media] vcodec: mediatek: Add Mediatek VP8 Video Encoder Driver

2016-04-21 Thread Tiffany Lin
Add vp8 encoder driver for MT8173

Signed-off-by: PoChun Lin 
Signed-off-by: Tiffany Lin 

---
 drivers/media/platform/mtk-vcodec/Makefile |6 +-
 .../media/platform/mtk-vcodec/venc/venc_vp8_if.c   |  488 
 drivers/media/platform/mtk-vcodec/venc_drv_if.c|7 +-
 drivers/media/platform/mtk-vcodec/venc_vpu_if.c|  240 ++
 drivers/media/platform/mtk-vcodec/venc_vpu_if.h|   61 +++
 5 files changed, 800 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_vpu_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/venc_vpu_if.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index d04433be..bf73a45 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -1,12 +1,16 @@
 
+
 obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-enc.o mtk-vcodec-common.o
 
 
 
-mtk-vcodec-enc-y := mtk_vcodec_enc.o \
+mtk-vcodec-enc-y := venc/venc_vp8_if.o \
+   venc/venc_h264_if.o \
+   mtk_vcodec_enc.o \
mtk_vcodec_enc_drv.o \
mtk_vcodec_enc_pm.o \
venc_drv_if.o \
+   venc_vpu_if.o \
 
 mtk-vcodec-common-y := mtk_vcodec_intr.o \
mtk_vcodec_util.o\
diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c 
b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
new file mode 100644
index 000..5389841
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
@@ -0,0 +1,488 @@
+/*
+ * Copyright (c) 2016 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 "../mtk_vcodec_drv.h"
+#include "../mtk_vcodec_util.h"
+#include "../mtk_vcodec_intr.h"
+#include "../mtk_vcodec_enc.h"
+#include "../mtk_vcodec_enc_pm.h"
+#include "../venc_drv_base.h"
+#include "../venc_ipi_msg.h"
+#include "../venc_vpu_if.h"
+#include "mtk_vpu.h"
+
+#define VENC_BITSTREAM_FRAME_SIZE 0x0098
+#define VENC_BITSTREAM_HEADER_LEN 0x00e8
+
+/* This ac_tag is vp8 frame tag. */
+#define MAX_AC_TAG_SIZE 10
+
+/**
+ * enum venc_vp8_vpu_work_buf - vp8 encoder buffer index
+ */
+enum venc_vp8_vpu_work_buf {
+   VENC_VP8_VPU_WORK_BUF_LUMA,
+   VENC_VP8_VPU_WORK_BUF_LUMA2,
+   VENC_VP8_VPU_WORK_BUF_LUMA3,
+   VENC_VP8_VPU_WORK_BUF_CHROMA,
+   VENC_VP8_VPU_WORK_BUF_CHROMA2,
+   VENC_VP8_VPU_WORK_BUF_CHROMA3,
+   VENC_VP8_VPU_WORK_BUF_MV_INFO,
+   VENC_VP8_VPU_WORK_BUF_BS_HEADER,
+   VENC_VP8_VPU_WORK_BUF_PROB_BUF,
+   VENC_VP8_VPU_WORK_BUF_RC_INFO,
+   VENC_VP8_VPU_WORK_BUF_RC_CODE,
+   VENC_VP8_VPU_WORK_BUF_RC_CODE2,
+   VENC_VP8_VPU_WORK_BUF_RC_CODE3,
+   VENC_VP8_VPU_WORK_BUF_MAX,
+};
+
+/*
+ * struct venc_vp8_vpu_config - Structure for vp8 encoder configuration
+ * @input_fourcc: input fourcc
+ * @bitrate: target bitrate (in bps)
+ * @pic_w: picture width. Picture size is visible stream resolution, in pixels,
+ * to be used for display purposes; must be smaller or equal to buffer
+ * size.
+ * @pic_h: picture height
+ * @buf_w: buffer width (with 16 alignment). Buffer size is stream resolution
+ * in pixels aligned to hardware requirements.
+ * @buf_h: buffer height (with 16 alignment)
+ * @gop_size: group of picture size (key frame)
+ * @framerate: frame rate in fps
+ * @ts_mode: temporal scalability mode (0: disable, 1: enable)
+ *  support three temporal layers - 0: 7.5fps 1: 7.5fps 2: 15fps.
+ */
+struct venc_vp8_vpu_config {
+   u32 input_fourcc;
+   u32 bitrate;
+   u32 pic_w;
+   u32 pic_h;
+   u32 buf_w;
+   u32 buf_h;
+   u32 gop_size;
+   u32 framerate;
+   u32 ts_mode;
+};
+
+/*
+ * struct venc_vp8_vpu_buf -Structure for buffer information
+ * @align: buffer alignment (in bytes)
+ * @iova: IO virtual address
+ * @vpua: VPU side memory addr which is used by RC_CODE
+ * @size: buffer size (in bytes)
+ */
+struct venc_vp8_vpu_buf {
+   u32 align;
+   u32 iova;
+   u32 vpua;
+   u32 size;
+};
+
+/*
+ * struct venc_vp8_vsi - Structure for VPU driver control and info share
+ * This structure is allocated in VPU side and shared to AP side.
+ * @config: vp8 encoder configuration
+ * @work_bufs: working buffer information in VPU side
+ * The work_bufs here is for storing the 'size' info shared to AP side.
+ * The similar item in struct venc_vp8