Re: [PATCH 2/3] arm64: dts: mt8173: Separating mtk-vcodec-enc device node

2021-01-26 Thread Tiffany Lin
On Thu, 2021-01-21 at 14:18 +0800, Irui Wang wrote:
> There are two separate hardware encoder blocks inside MT8173.
> Split the current mtk-vcodec-enc node to match the hardware architecture.
> 
> Signed-off-by: Hsin-Yi Wang 
> Signed-off-by: Maoguang Meng 
> Signed-off-by: Irui Wang 
> 
Acked-by: Tiffany Lin 

> ---
>  arch/arm64/boot/dts/mediatek/mt8173.dtsi | 60 
>  1 file changed, 31 insertions(+), 29 deletions(-)
> 
> diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
> b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> index 7fa870e4386a..d667b296c512 100644
> --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> @@ -1459,13 +1459,10 @@
>   };
>  
>   vcodec_enc: vcodec@18002000 {
> - compatible = "mediatek,mt8173-vcodec-enc";
> - reg = <0 0x18002000 0 0x1000>,  /* VENC_SYS */
> -   <0 0x19002000 0 0x1000>;  /* VENC_LT_SYS */
> - interrupts = ,
> -  ;
> - mediatek,larb = <>,
> - <>;
> + compatible = "mediatek,mt8173-vcodec-avc-enc";
> + reg = <0 0x18002000 0 0x1000>;  /* VENC_SYS */
> + interrupts = ;
> + mediatek,larb = <>;
>   iommus = < M4U_PORT_VENC_RCPU>,
>< M4U_PORT_VENC_REC>,
>< M4U_PORT_VENC_BSDMA>,
> @@ -1476,29 +1473,12 @@
>< M4U_PORT_VENC_REF_LUMA>,
>< M4U_PORT_VENC_REF_CHROMA>,
>< M4U_PORT_VENC_NBM_RDMA>,
> -  < M4U_PORT_VENC_NBM_WDMA>,
> -  < M4U_PORT_VENC_RCPU_SET2>,
> -  < M4U_PORT_VENC_REC_FRM_SET2>,
> -  < M4U_PORT_VENC_BSDMA_SET2>,
> -  < M4U_PORT_VENC_SV_COMA_SET2>,
> -  < M4U_PORT_VENC_RD_COMA_SET2>,
> -  < M4U_PORT_VENC_CUR_LUMA_SET2>,
> -  < M4U_PORT_VENC_CUR_CHROMA_SET2>,
> -  < M4U_PORT_VENC_REF_LUMA_SET2>,
> -  < M4U_PORT_VENC_REC_CHROMA_SET2>;
> +  < M4U_PORT_VENC_NBM_WDMA>;
>   mediatek,vpu = <>;
> - clocks = < CLK_TOP_VENCPLL_D2>,
> -  < CLK_TOP_VENC_SEL>,
> -  < CLK_TOP_UNIVPLL1_D2>,
> -  < CLK_TOP_VENC_LT_SEL>;
> - clock-names = "venc_sel_src",
> -   "venc_sel",
> -   "venc_lt_sel_src",
> -   "venc_lt_sel";
> - assigned-clocks = < CLK_TOP_VENC_SEL>,
> -   < CLK_TOP_VENC_LT_SEL>;
> - assigned-clock-parents = < CLK_TOP_VCODECPLL>,
> -  < 
> CLK_TOP_VCODECPLL_370P5>;
> + clocks = < CLK_TOP_VENC_SEL>;
> + clock-names = "venc_sel";
> + assigned-clocks = < CLK_TOP_VENC_SEL>;
> + assigned-clock-parents = < CLK_TOP_VCODECPLL>;
>   };
>  
>   jpegdec: jpegdec@18004000 {
> @@ -1530,5 +1510,27 @@
>< CLK_VENCLT_CKE0>;
>   clock-names = "apb", "smi";
>   };
> +
> + vcodec_enc_lt: vcodec@19002000 {
> + compatible = "mediatek,mt8173-vcodec-vp8-enc";
> + reg =  <0 0x19002000 0 0x1000>; /* VENC_LT_SYS */
> + interrupts = ;
> + iommus = < M4U_PORT_VENC_RCPU_SET2>,
> +  < M4U_PORT_VENC_REC_FRM_SET2>,
> +  < M4U_PORT_VENC_BSDMA_SET2>,
> +  < M4U_PORT_VENC_SV_COMA_SET2>,
> +  < M4U_PORT_VENC_RD_COMA_SET2>,
> +  < M4U_PORT_VENC_CUR_LUMA_SET2>,
> +  < M4U_PORT_VENC_CUR_CHROMA_SET2>,
> +  < M4U_PORT_VENC_REF_LUMA_SET2>,
> +  < M4U_PORT_VENC_REC_CHROMA_SET2>;
> + mediatek,larb = <>;
> + mediatek,vpu = <>;
> + clocks = < CLK_TOP_VENC_LT_SEL>;
> + clock-names = "venc_lt_sel";
> + assigned-clocks = < CLK_TOP_VENC_LT_SEL>;
> + assigned-clock-parents =
> +  < CLK_TOP_VCODECPLL_370P5>;
> + };
>   };
>  };



Re: [PATCH 1/3] dt-bindings: media: mtk-vcodec: Separating mtk vcodec encoder node

2021-01-26 Thread Tiffany Lin
On Thu, 2021-01-21 at 14:18 +0800, Irui Wang wrote:
> Updates binding document since the avc and vp8 hardware encoder in
> MT8173 are now separated. Separate "mediatek,mt8173-vcodec-enc" to
> "mediatek,mt8173-vcodec-vp8-enc" and "mediatek,mt8173-vcodec-avc-enc".
> 
> Signed-off-by: Hsin-Yi Wang 
> Signed-off-by: Maoguang Meng 
> Signed-off-by: Irui Wang 
> 
Acked-by: Tiffany Lin 

> ---
>  .../bindings/media/mediatek-vcodec.txt| 58 ++-
>  1 file changed, 31 insertions(+), 27 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt 
> b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> index 8217424fd4bd..f85276e629bf 100644
> --- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> +++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> @@ -4,7 +4,9 @@ Mediatek Video Codec is the video codec hw present in 
> Mediatek SoCs which
>  supports high resolution encoding and decoding functionalities.
>  
>  Required properties:
> -- compatible : "mediatek,mt8173-vcodec-enc" for MT8173 encoder
> +- compatible : must be one of the following string:
> +  "mediatek,mt8173-vcodec-vp8-enc" for mt8173 vp8 encoder.
> +  "mediatek,mt8173-vcodec-avc-enc" for mt8173 avc encoder.
>"mediatek,mt8183-vcodec-enc" for MT8183 encoder.
>"mediatek,mt8173-vcodec-dec" for MT8173 decoder.
>  - reg : Physical base address of the video codec registers and length of
> @@ -13,10 +15,11 @@ Required properties:
>  - mediatek,larb : must contain the local arbiters in the current Socs.
>  - clocks : list of clock specifiers, corresponding to entries in
>the clock-names property.
> -- clock-names: encoder must contain "venc_sel_src", "venc_sel",,
> -  "venc_lt_sel_src", "venc_lt_sel", decoder must contain "vcodecpll",
> -  "univpll_d2", "clk_cci400_sel", "vdec_sel", "vdecpll", "vencpll",
> -  "venc_lt_sel", "vdec_bus_clk_src".
> +- clock-names:
> +   avc venc must contain "venc_sel";
> +   vp8 venc must contain "venc_lt_sel";
> +   decoder  must contain "vcodecpll", "univpll_d2", "clk_cci400_sel",
> +   "vdec_sel", "vdecpll", "vencpll", "venc_lt_sel", "vdec_bus_clk_src".
>  - iommus : should point to the respective IOMMU block with master port as
>argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
>for details.
> @@ -80,14 +83,10 @@ vcodec_dec: vcodec@1600 {
>  assigned-clock-rates = <0>, <0>, <0>, <148200>, <8>;
>};
>  
> -  vcodec_enc: vcodec@18002000 {
> -compatible = "mediatek,mt8173-vcodec-enc";
> -reg = <0 0x18002000 0 0x1000>,/*VENC_SYS*/
> -  <0 0x19002000 0 0x1000>;/*VENC_LT_SYS*/
> -interrupts = ,
> -  ;
> -mediatek,larb = <>,
> - <>;
> +vcodec_enc: vcodec@18002000 {
> +compatible = "mediatek,mt8173-vcodec-avc-enc";
> +reg = <0 0x18002000 0 0x1000>;
> +interrupts = ;
>  iommus = < M4U_PORT_VENC_RCPU>,
>   < M4U_PORT_VENC_REC>,
>   < M4U_PORT_VENC_BSDMA>,
> @@ -98,8 +97,20 @@ vcodec_dec: vcodec@1600 {
>   < M4U_PORT_VENC_REF_LUMA>,
>   < M4U_PORT_VENC_REF_CHROMA>,
>   < M4U_PORT_VENC_NBM_RDMA>,
> - < M4U_PORT_VENC_NBM_WDMA>,
> - < M4U_PORT_VENC_RCPU_SET2>,
> + < M4U_PORT_VENC_NBM_WDMA>;
> +mediatek,larb = <>;
> +mediatek,vpu = <>;
> +clocks = < CLK_TOP_VENC_SEL>;
> +clock-names = "venc_sel";
> +assigned-clocks = < CLK_TOP_VENC_SEL>;
> +assigned-clock-parents = < CLK_TOP_VCODECPLL>;
> +  };
> +
> +vcodec_enc_lt: vcodec@19002000 {
> +compatible = "mediatek,mt8173-vcodec-vp8-enc";
> +reg =  <0 0x19002000 0 0x1000>;  /* VENC_LT_SYS */
> +interrupts = ;
> +iommus = < M4U_PORT_VENC_RCPU_SET2>,
>   < M4U_PORT_VENC_REC_FRM_SET2>,
>   < M4U_PORT_VENC_BSDMA_SET2>,
>   < M4U_PORT_VENC_SV_COMA_SET2>,
> @@ -108,17 +119,10 @@ vcodec_dec: vcodec@1600 {
>   < M4U_PORT_VENC_CUR_CHROMA_SET2>,
>   < M4U_PORT_VENC_REF_LUMA_SET2>,
>   < M4U_PORT_VENC_REC_CHROMA_SET2>;
> +mediatek,larb = <>;
>  mediatek,vpu = <>;
> -clocks = < CLK_TOP_VENCPLL_D2>,
> - < CLK_TOP_VENC_SEL>,
> - < CLK_TOP_UNIVPLL1_D2>,
> - < CLK_TOP_VENC_LT_SEL>;
> -clock-names = "venc_sel_src",
> -  "venc_sel",
> -  "venc_lt_sel_src",
> -  "venc_lt_sel";
> -assigned-clocks = < CLK_TOP_VENC_SEL>,
> -  < CLK_TOP_VENC_LT_SEL>;
> -assigned-clock-parents = < CLK_TOP_VENCPLL_D2>,
> - < CLK_TOP_UNIVPLL1_D2>;
> +clocks = < CLK_TOP_VENC_LT_SEL>;
> +clock-names = "venc_lt_sel";
> +assigned-clocks = < CLK_TOP_VENC_LT_SEL>;
> +assigned-clock-parents = < CLK_TOP_VCODECPLL_370P5>;
>};



Re: [PATCH 3/3] media: mtk-vcodec: Separating mtk encoder driver

2021-01-26 Thread Tiffany Lin
On Thu, 2021-01-21 at 14:18 +0800, Irui Wang wrote:
> MTK H264 Encoder(VENC_SYS) and VP8 Encoder(VENC_LT_SYS) are two
> independent hardware instance. They have their owner interrupt,
> register mapping, and special clocks.
> 
> This patch seperates them into two drivers:
> User Call "VIDIOC_QUERYCAP":
> H264 Encoder return driver name "mtk-vcodec-enc";
> VP8 Encoder return driver name "mtk-venc-vp8.
> 
> Signed-off-by: Hsin-Yi Wang 
> Signed-off-by: Maoguang Meng 
> Signed-off-by: Irui Wang 
> 
Acked-by: Tiffany Lin 

> ---
>  .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  10 +-
>  .../platform/mtk-vcodec/mtk_vcodec_enc.c  |  23 +++-
>  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  | 121 +++---
>  .../platform/mtk-vcodec/mtk_vcodec_enc_pm.c   |  40 +-
>  .../platform/mtk-vcodec/venc/venc_vp8_if.c|   4 +-
>  5 files changed, 82 insertions(+), 116 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> index 3dd010cba23e..1594edcc706d 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> @@ -19,6 +19,7 @@
>  #define MTK_VCODEC_DRV_NAME  "mtk_vcodec_drv"
>  #define MTK_VCODEC_DEC_NAME  "mtk-vcodec-dec"
>  #define MTK_VCODEC_ENC_NAME  "mtk-vcodec-enc"
> +#define MTK_VENC_VP8_NAME"mtk-venc-vp8"
>  #define MTK_PLATFORM_STR "platform:mt8173"
>  
>  #define MTK_VCODEC_MAX_PLANES3
> @@ -193,7 +194,6 @@ struct mtk_vcodec_pm {
>  
>   struct mtk_vcodec_clk   venc_clk;
>   struct device   *larbvenc;
> - struct device   *larbvenclt;
>   struct device   *dev;
>   struct mtk_vcodec_dev   *mtkdev;
>  };
> @@ -311,25 +311,27 @@ enum mtk_chip {
>   * @chip: chip this encoder is compatible with
>   *
>   * @uses_ext: whether the encoder uses the extended firmware messaging format
> - * @has_lt_irq: whether the encoder uses the LT irq
> + * @name: whether the encoder core is vp8
>   * @min_birate: minimum supported encoding bitrate
>   * @max_bitrate: maximum supported encoding bitrate
>   * @capture_formats: array of supported capture formats
>   * @num_capture_formats: number of entries in capture_formats
>   * @output_formats: array of supported output formats
>   * @num_output_formats: number of entries in output_formats
> + * @core_id: stand for h264 or vp8 encode index
>   */
>  struct mtk_vcodec_enc_pdata {
>   enum mtk_chip chip;
>  
>   bool uses_ext;
> - bool has_lt_irq;
> + const char *name;
>   unsigned long min_bitrate;
>   unsigned long max_bitrate;
>   const struct mtk_video_fmt *capture_formats;
>   size_t num_capture_formats;
>   const struct mtk_video_fmt *output_formats;
>   size_t num_output_formats;
> + int core_id;
>  };
>  
>  #define MTK_ENC_CTX_IS_EXT(ctx) ((ctx)->dev->venc_pdata->uses_ext)
> @@ -361,7 +363,6 @@ struct mtk_vcodec_enc_pdata {
>   *
>   * @dec_irq: decoder irq resource
>   * @enc_irq: h264 encoder irq resource
> - * @enc_lt_irq: vp8 encoder irq resource
>   *
>   * @dec_mutex: decoder hardware lock
>   * @enc_mutex: encoder hardware lock.
> @@ -397,7 +398,6 @@ struct mtk_vcodec_dev {
>  
>   int dec_irq;
>   int enc_irq;
> - int enc_lt_irq;
>  
>   struct mutex dec_mutex;
>   struct mutex enc_mutex;
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 21de1431cfcb..0da6871b4b39 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -9,6 +9,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "mtk_vcodec_drv.h"
>  #include "mtk_vcodec_enc.h"
> @@ -189,7 +190,10 @@ static int vidioc_enum_fmt_vid_out(struct file *file, 
> void *priv,
>  static int vidioc_venc_querycap(struct file *file, void *priv,
>   struct v4l2_capability *cap)
>  {
> - strscpy(cap->driver, MTK_VCODEC_ENC_NAME, sizeof(cap->driver));
> + const struct mtk_vcodec_enc_pdata *pdata =
> + fh_to_ctx(priv)->dev->venc_pdata;
> +
> + strscpy(cap->driver, pdata->name, sizeof(cap->driver));
>   strscpy(cap->bus_info, MTK_PLATFORM_STR, sizeof(cap->bus_info));
>   strscpy(cap->card, MTK_PLATFORM_STR, sizeof(cap->card));
>  
> @@ -797,7 +801,7 @@ static int vb2ops_venc_start_streaming(struct vb2_queue 
> *q, unsigned int count)
>

Re: [PATCH v4 17/17] media: mtk-vcodec: venc: fix invalid time per frame in S_PARM

2020-08-24 Thread Tiffany Lin
On Fri, 2020-08-21 at 19:36 +0900, Alexandre Courbot wrote:
> v4l2-compliance expects the driver to adjust the time per frame if it is
> invalid (numerator or denominator set to 0). Adjust it to the default
> value in these cases.
> 

Acked-by: Tiffany Lin 

> Signed-off-by: Alexandre Courbot 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 12 
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 09baac2dbc36..82b04714f750 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -200,14 +200,18 @@ static int vidioc_venc_s_parm(struct file *file, void 
> *priv,
> struct v4l2_streamparm *a)
>  {
>   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> + struct v4l2_fract *timeperframe = >parm.output.timeperframe;
>  
>   if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
>   return -EINVAL;
>  
> - ctx->enc_params.framerate_num =
> - a->parm.output.timeperframe.denominator;
> - ctx->enc_params.framerate_denom =
> - a->parm.output.timeperframe.numerator;
> + if (timeperframe->numerator == 0 || timeperframe->denominator == 0) {
> + timeperframe->numerator = MTK_DEFAULT_FRAMERATE_NUM;
> + timeperframe->denominator = MTK_DEFAULT_FRAMERATE_DENOM;
> + }
> +
> + ctx->enc_params.framerate_num = timeperframe->denominator;
> + ctx->enc_params.framerate_denom = timeperframe->numerator;
>   ctx->param_change |= MTK_ENCODE_PARAM_FRAMERATE;
>  
>   a->parm.output.capability = V4L2_CAP_TIMEPERFRAME;



Re: [PATCH v4 16/17] media: mtk-vcodec: venc: set default time per frame

2020-08-24 Thread Tiffany Lin
On Fri, 2020-08-21 at 19:36 +0900, Alexandre Courbot wrote:
> The time per frame was left initialized to 0/0, which make the driver
> fail v4l2-compliance, and also leaves it potentially exposed to doing a
> division by zero.
> 
Acked-by: Tiffany Lin 

> Signed-off-by: Alexandre Courbot 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 1b79185cf922..09baac2dbc36 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -24,6 +24,9 @@
>  #define DFT_CFG_HEIGHT   MTK_VENC_MIN_H
>  #define MTK_MAX_CTRLS_HINT   20
>  
> +#define MTK_DEFAULT_FRAMERATE_NUM 1001
> +#define MTK_DEFAULT_FRAMERATE_DENOM 3
> +
>  static void mtk_venc_worker(struct work_struct *work);
>  
>  static const struct v4l2_frmsize_stepwise mtk_venc_framesizes = {
> @@ -1197,6 +1200,8 @@ void mtk_vcodec_enc_set_default_params(struct 
> mtk_vcodec_ctx *ctx)
>   DFT_CFG_WIDTH * DFT_CFG_HEIGHT;
>   ctx->q_data[MTK_Q_DATA_DST].bytesperline[0] = 0;
>  
> + ctx->enc_params.framerate_num = MTK_DEFAULT_FRAMERATE_NUM;
> + ctx->enc_params.framerate_denom = MTK_DEFAULT_FRAMERATE_DENOM;
>  }
>  
>  int mtk_vcodec_enc_ctrls_setup(struct mtk_vcodec_ctx *ctx)



Re: [PATCH v4 15/17] media: mtk-vcodec: venc: support ENUM_FRAMESIZES on OUTPUT formats

2020-08-24 Thread Tiffany Lin
On Fri, 2020-08-21 at 19:36 +0900, Alexandre Courbot wrote:
> v4l2-compliance requires ENUM_FRAMESIZES to support OUTPUT formats.
> Reuse mtk_venc_find_format() to make sure both queues are considered
> when serving an ENUM_FRAMESIZES.
> 
Acked-by: Tiffany Lin 

> Signed-off-by: Alexandre Courbot 
> ---
>  .../platform/mtk-vcodec/mtk_vcodec_enc.c  | 71 +--
>  1 file changed, 33 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index f8d4fbe927f9..1b79185cf922 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -123,28 +123,44 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f,
>   return 0;
>  }
>  
> +static const struct mtk_video_fmt *mtk_venc_find_format(u32 fourcc,
> + const struct mtk_vcodec_enc_pdata *pdata)
> +{
> + const struct mtk_video_fmt *fmt;
> + unsigned int k;
> +
> + for (k = 0; k < pdata->num_capture_formats; k++) {
> + fmt = >capture_formats[k];
> + if (fmt->fourcc == fourcc)
> + return fmt;
> + }
> +
> + for (k = 0; k < pdata->num_output_formats; k++) {
> + fmt = >output_formats[k];
> + if (fmt->fourcc == fourcc)
> + return fmt;
> + }
> +
> + return NULL;
> +}
> +
>  static int vidioc_enum_framesizes(struct file *file, void *fh,
> struct v4l2_frmsizeenum *fsize)
>  {
> - const struct mtk_vcodec_enc_pdata *pdata =
> - fh_to_ctx(fh)->dev->venc_pdata;
> - int i = 0;
> + const struct mtk_video_fmt *fmt;
>  
>   if (fsize->index != 0)
>   return -EINVAL;
>  
> - for (i = 0; i < pdata->num_capture_formats; ++i) {
> - const struct mtk_video_fmt *fmt = >capture_formats[i];
> + fmt = mtk_venc_find_format(fsize->pixel_format,
> +fh_to_ctx(fh)->dev->venc_pdata);
> + if (!fmt)
> + return -EINVAL;
>  
> - if (fsize->pixel_format != fmt->fourcc)
> - continue;
> + fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
> + fsize->stepwise = mtk_venc_framesizes;
>  
> - fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
> - fsize->stepwise = mtk_venc_framesizes;
> - return 0;
> - }
> -
> - return -EINVAL;
> + return 0;
>  }
>  
>  static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
> @@ -222,27 +238,6 @@ static struct mtk_q_data *mtk_venc_get_q_data(struct 
> mtk_vcodec_ctx *ctx,
>   return >q_data[MTK_Q_DATA_DST];
>  }
>  
> -static const struct mtk_video_fmt *mtk_venc_find_format(struct v4l2_format 
> *f,
> - const struct mtk_vcodec_enc_pdata *pdata)
> -{
> - const struct mtk_video_fmt *fmt;
> - unsigned int k;
> -
> - for (k = 0; k < pdata->num_capture_formats; k++) {
> - fmt = >capture_formats[k];
> - if (fmt->fourcc == f->fmt.pix.pixelformat)
> - return fmt;
> - }
> -
> - for (k = 0; k < pdata->num_output_formats; k++) {
> - fmt = >output_formats[k];
> - if (fmt->fourcc == f->fmt.pix.pixelformat)
> - return fmt;
> - }
> -
> - return NULL;
> -}
> -
>  /* V4L2 specification suggests the driver corrects the format struct if any 
> of
>   * the dimensions is unsupported
>   */
> @@ -403,7 +398,7 @@ static int vidioc_venc_s_fmt_cap(struct file *file, void 
> *priv,
>   return -EINVAL;
>   }
>  
> - fmt = mtk_venc_find_format(f, pdata);
> + fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata);
>   if (!fmt) {
>   fmt = >dev->venc_pdata->capture_formats[0];
>   f->fmt.pix.pixelformat = fmt->fourcc;
> @@ -467,7 +462,7 @@ static int vidioc_venc_s_fmt_out(struct file *file, void 
> *priv,
>   return -EINVAL;
>   }
>  
> - fmt = mtk_venc_find_format(f, pdata);
> + fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata);
>   if (!fmt) {
>   fmt = >dev->venc_pdata->output_formats[0];
>   f->fmt.pix.pixelformat = fmt->fourcc;
> @@ -550,7 +545,7 @@ static int vidioc_try_fmt_vid_cap_mplane(struct file 
> *file, void *priv,
>   struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
>   const struct mtk_vcodec_enc_pdata *p

Re: [PATCH v4 14/17] media: mtk-vcodec: venc: use platform data for ENUM_FRAMESIZES

2020-08-24 Thread Tiffany Lin
On Fri, 2020-08-21 at 19:36 +0900, Alexandre Courbot wrote:
> vidioc_enum_framesizes() assumes that all encoders support H.264 and VP8,
> which is not necessarily true and requires to duplicate information about
> the supported codecs which is already stored in the platform data.
> 
> Fix this by referring to the platform data to find out whether a given
> format is supported. Since the supported sizes are all the same
> regardless of the format, we can then return a copy of a static value if
> the format is supported.
> 

Acked-by: Tiffany Lin 

> Signed-off-by: Alexandre Courbot 
> ---
>  .../platform/mtk-vcodec/mtk_vcodec_enc.c  | 24 ---
>  1 file changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 1a981d842c19..f8d4fbe927f9 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -26,17 +26,9 @@
>  
>  static void mtk_venc_worker(struct work_struct *work);
>  
> -static const struct mtk_codec_framesizes mtk_venc_framesizes[] = {
> - {
> - .fourcc = V4L2_PIX_FMT_H264,
> - .stepwise = { MTK_VENC_MIN_W, MTK_VENC_MAX_W, 16,
> -   MTK_VENC_MIN_H, MTK_VENC_MAX_H, 16 },
> - },
> - {
> - .fourcc = V4L2_PIX_FMT_VP8,
> - .stepwise = { MTK_VENC_MIN_W, MTK_VENC_MAX_W, 16,
> -   MTK_VENC_MIN_H, MTK_VENC_MAX_H, 16 },
> - },
> +static const struct v4l2_frmsize_stepwise mtk_venc_framesizes = {
> + MTK_VENC_MIN_W, MTK_VENC_MAX_W, 16,
> + MTK_VENC_MIN_H, MTK_VENC_MAX_H, 16,
>  };
>  
>  #define NUM_SUPPORTED_FRAMESIZE ARRAY_SIZE(mtk_venc_framesizes)
> @@ -134,17 +126,21 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f,
>  static int vidioc_enum_framesizes(struct file *file, void *fh,
> struct v4l2_frmsizeenum *fsize)
>  {
> + const struct mtk_vcodec_enc_pdata *pdata =
> + fh_to_ctx(fh)->dev->venc_pdata;
>   int i = 0;
>  
>   if (fsize->index != 0)
>   return -EINVAL;
>  
> - for (i = 0; i < NUM_SUPPORTED_FRAMESIZE; ++i) {
> - if (fsize->pixel_format != mtk_venc_framesizes[i].fourcc)
> + for (i = 0; i < pdata->num_capture_formats; ++i) {
> + const struct mtk_video_fmt *fmt = >capture_formats[i];
> +
> + if (fsize->pixel_format != fmt->fourcc)
>   continue;
>  
>   fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
> - fsize->stepwise = mtk_venc_framesizes[i].stepwise;
> + fsize->stepwise = mtk_venc_framesizes;
>   return 0;
>   }
>  



Re: [PATCH v2 12/18] media: mtk-vcodec: venc: set OUTPUT buffers field to V4L2_FIELD_NONE

2020-06-30 Thread Tiffany Lin
On Fri, 2020-06-26 at 17:04 +0900, Alexandre Courbot wrote:
> A default value of 0 means V4L2_FIELD_ANY, which is not correct.
> Reported by v4l2-compliance.
> 

Acked-by: Tiffany Lin 


> Signed-off-by: Alexandre Courbot 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index f833aee4a06f..1a981d842c19 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -893,8 +893,17 @@ static void vb2ops_venc_stop_streaming(struct vb2_queue 
> *q)
>   ctx->state = MTK_STATE_FREE;
>  }
>  
> +static int vb2ops_venc_buf_out_validate(struct vb2_buffer *vb)
> +{
> + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
> +
> + vbuf->field = V4L2_FIELD_NONE;
> + return 0;
> +}
> +
>  static const struct vb2_ops mtk_venc_vb2_ops = {
>   .queue_setup= vb2ops_venc_queue_setup,
> + .buf_out_validate   = vb2ops_venc_buf_out_validate,
>   .buf_prepare= vb2ops_venc_buf_prepare,
>   .buf_queue  = vb2ops_venc_buf_queue,
>   .wait_prepare   = vb2_ops_wait_prepare,



Re: [PATCH v2 11/18] media: mtk-vcodec: venc support MIN_OUTPUT_BUFFERS control

2020-06-30 Thread Tiffany Lin
On Fri, 2020-06-26 at 17:04 +0900, Alexandre Courbot wrote:
> This control is required by v4l2-compliance for encoders. A value of 1
> should be suitable for all scenarios.
> 
Acked-by: Tiffany Lin 

> Signed-off-by: Alexandre Courbot 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index f2ba19c32400..f833aee4a06f 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -1206,6 +1206,8 @@ int mtk_vcodec_enc_ctrls_setup(struct mtk_vcodec_ctx 
> *ctx)
>  
>   v4l2_ctrl_handler_init(handler, MTK_MAX_CTRLS_HINT);
>  
> + v4l2_ctrl_new_std(handler, ops, V4L2_CID_MIN_BUFFERS_FOR_OUTPUT,
> +   1, 1, 1, 1);
>   v4l2_ctrl_new_std(handler, ops, V4L2_CID_MPEG_VIDEO_BITRATE,
> ctx->dev->venc_pdata->min_bitrate,
> ctx->dev->venc_pdata->max_bitrate, 1, 400);



Re: [PATCH v2 10/18] Revert "media: mtk-vcodec: Remove extra area allocation in an input buffer on encoding"

2020-06-30 Thread Tiffany Lin
On Fri, 2020-06-26 at 17:04 +0900, Alexandre Courbot wrote:
> This reverts commit 81735ecb62f882853a37a8c157407ec4aed44fd0.
> 
> The hardware needs data to follow the previous alignment, so this extra
> space was not superfluous after all. Besides, this also made
> v4l2-compliance's G_FMT and S_FMT tests regress.
> 
Acked-by: Tiffany Lin 

> Signed-off-by: Alexandre Courbot 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 05743a745a11..f2ba19c32400 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -299,12 +299,14 @@ static int vidioc_try_fmt(struct v4l2_format *f,
>  
>   pix_fmt_mp->num_planes = fmt->num_planes;
>   pix_fmt_mp->plane_fmt[0].sizeimage =
> - pix_fmt_mp->width * pix_fmt_mp->height;
> + pix_fmt_mp->width * pix_fmt_mp->height +
> + ((ALIGN(pix_fmt_mp->width, 16) * 2) * 16);
>   pix_fmt_mp->plane_fmt[0].bytesperline = pix_fmt_mp->width;
>  
>   if (pix_fmt_mp->num_planes == 2) {
>   pix_fmt_mp->plane_fmt[1].sizeimage =
> - (pix_fmt_mp->width * pix_fmt_mp->height) / 2;
> + (pix_fmt_mp->width * pix_fmt_mp->height) / 2 +
> + (ALIGN(pix_fmt_mp->width, 16) * 16);
>   pix_fmt_mp->plane_fmt[2].sizeimage = 0;
>   pix_fmt_mp->plane_fmt[1].bytesperline =
>   pix_fmt_mp->width;
> @@ -312,7 +314,8 @@ static int vidioc_try_fmt(struct v4l2_format *f,
>   } else if (pix_fmt_mp->num_planes == 3) {
>   pix_fmt_mp->plane_fmt[1].sizeimage =
>   pix_fmt_mp->plane_fmt[2].sizeimage =
> - (pix_fmt_mp->width * pix_fmt_mp->height) / 4;
> + (pix_fmt_mp->width * pix_fmt_mp->height) / 4 +
> + ((ALIGN(pix_fmt_mp->width, 16) / 2) * 16);
>   pix_fmt_mp->plane_fmt[1].bytesperline =
>   pix_fmt_mp->plane_fmt[2].bytesperline =
>   pix_fmt_mp->width / 2;



Re: [PATCH v2 01/18] media: mtk-vcodec: abstract firmware interface

2020-06-30 Thread Tiffany Lin
On Fri, 2020-06-26 at 17:04 +0900, Alexandre Courbot wrote:
> From: Yunfei Dong 
> 
> MT8183's codec firwmare is run by a different remote processor from
> MT8173. While the firmware interface is basically the same, the way to
> invoke it differs. Abstract all firmware calls under a layer that will
> allow us to handle both firmware types transparently.
> 

Acked-by: Tiffany Lin 

> Signed-off-by: Yunfei Dong 
> [acourbot: refactor, cleanup and split]
> Co-developed-by: Alexandre Courbot 
> Signed-off-by: Alexandre Courbot 
> [pihsun: fix error path and add mtk_vcodec_fw_release]
> Signed-off-by: Pi-Hsun Shih 
> Reviewed-by: Tiffany Lin 
> ---
>  drivers/media/platform/mtk-vcodec/Makefile|   4 +-
>  .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  50 ++---
>  .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   |   1 -
>  .../platform/mtk-vcodec/mtk_vcodec_drv.h  |   5 +-
>  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  47 ++---
>  .../platform/mtk-vcodec/mtk_vcodec_enc_pm.c   |   2 -
>  .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 172 ++
>  .../media/platform/mtk-vcodec/mtk_vcodec_fw.h |  36 
>  .../platform/mtk-vcodec/mtk_vcodec_util.c |   1 -
>  .../platform/mtk-vcodec/vdec/vdec_h264_if.c   |   1 -
>  .../platform/mtk-vcodec/vdec/vdec_vp8_if.c|   1 -
>  .../platform/mtk-vcodec/vdec/vdec_vp9_if.c|   1 -
>  .../media/platform/mtk-vcodec/vdec_drv_base.h |   2 -
>  .../media/platform/mtk-vcodec/vdec_drv_if.c   |   1 -
>  .../media/platform/mtk-vcodec/vdec_vpu_if.c   |  12 +-
>  .../media/platform/mtk-vcodec/vdec_vpu_if.h   |  11 +-
>  .../platform/mtk-vcodec/venc/venc_h264_if.c   |  15 +-
>  .../platform/mtk-vcodec/venc/venc_vp8_if.c|   8 +-
>  .../media/platform/mtk-vcodec/venc_drv_if.c   |   1 -
>  .../media/platform/mtk-vcodec/venc_vpu_if.c   |  17 +-
>  .../media/platform/mtk-vcodec/venc_vpu_if.h   |   5 +-
>  21 files changed, 290 insertions(+), 103 deletions(-)
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h
> 
> diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
> b/drivers/media/platform/mtk-vcodec/Makefile
> index 37b94b555fa1..b8636119ed0a 100644
> --- a/drivers/media/platform/mtk-vcodec/Makefile
> +++ b/drivers/media/platform/mtk-vcodec/Makefile
> @@ -12,7 +12,7 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
>   vdec_vpu_if.o \
>   mtk_vcodec_dec.o \
>   mtk_vcodec_dec_pm.o \
> -
> + mtk_vcodec_fw.o
>  
>  mtk-vcodec-enc-y := venc/venc_vp8_if.o \
>   venc/venc_h264_if.o \
> @@ -25,5 +25,3 @@ mtk-vcodec-enc-y := venc/venc_vp8_if.o \
>  
>  mtk-vcodec-common-y := mtk_vcodec_intr.o \
>   mtk_vcodec_util.o\
> -
> -ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> index 97a1b6664c20..4f07a5fcce7f 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> @@ -20,7 +20,7 @@
>  #include "mtk_vcodec_dec_pm.h"
>  #include "mtk_vcodec_intr.h"
>  #include "mtk_vcodec_util.h"
> -#include "mtk_vpu.h"
> +#include "mtk_vcodec_fw.h"
>  
>  #define VDEC_HW_ACTIVE   0x10
>  #define VDEC_IRQ_CFG 0x11
> @@ -77,22 +77,6 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, 
> void *priv)
>   return IRQ_HANDLED;
>  }
>  
> -static void mtk_vcodec_dec_reset_handler(void *priv)
> -{
> - struct mtk_vcodec_dev *dev = priv;
> - struct mtk_vcodec_ctx *ctx;
> -
> - mtk_v4l2_err("Watchdog timeout!!");
> -
> - mutex_lock(>dev_mutex);
> - list_for_each_entry(ctx, >ctx_list, list) {
> - ctx->state = MTK_STATE_ABORT;
> - mtk_v4l2_debug(0, "[%d] Change to state MTK_STATE_ERROR",
> - ctx->id);
> - }
> - mutex_unlock(>dev_mutex);
> -}
> -
>  static int fops_vcodec_open(struct file *file)
>  {
>   struct mtk_vcodec_dev *dev = video_drvdata(file);
> @@ -144,21 +128,20 @@ static int fops_vcodec_open(struct file *file)
>   if (v4l2_fh_is_singular(>fh)) {
>   mtk_vcodec_dec_pw_on(>pm);
>   /*
> -  * vpu_load_firmware checks if it was loaded already and
> -  * does nothing in that case
> +  * Does nothing if firmware was already loaded.
>*/
> - ret = vpu_load_firmware(dev->vpu_plat_dev);
> + ret = mtk_vcodec_

Re: [PATCH v2 06/18] media: mtk-vcodec: venc: specify supported formats per-chip

2020-06-30 Thread Tiffany Lin
On Fri, 2020-06-26 at 17:04 +0900, Alexandre Courbot wrote:
> Different chips have different supported bitrate ranges. Move the list
> of supported formats to the platform data, and split the output and
> capture formats into two lists to make it easier to find the default
> format for each queue.
> 
Acked-by: Tiffany Lin 


> Signed-off-by: Alexandre Courbot 
> ---
>  .../platform/mtk-vcodec/mtk_vcodec_drv.h  |   8 ++
>  .../platform/mtk-vcodec/mtk_vcodec_enc.c  | 122 +++---
>  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  40 ++
>  3 files changed, 95 insertions(+), 75 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> index b8f913de8d80..59b4b750666b 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> @@ -313,6 +313,10 @@ enum mtk_chip {
>   * @has_lt_irq: whether the encoder uses the LT irq
>   * @min_birate: minimum supported encoding bitrate
>   * @max_bitrate: maximum supported encoding bitrate
> + * @capture_formats: array of supported capture formats
> + * @num_capture_formats: number of entries in capture_formats
> + * @output_formats: array of supported output formats
> + * @num_output_formats: number of entries in output_formats
>   */
>  struct mtk_vcodec_enc_pdata {
>   enum mtk_chip chip;
> @@ -321,6 +325,10 @@ struct mtk_vcodec_enc_pdata {
>   bool has_lt_irq;
>   unsigned long min_bitrate;
>   unsigned long max_bitrate;
> + const struct mtk_video_fmt *capture_formats;
> + size_t num_capture_formats;
> + const struct mtk_video_fmt *output_formats;
> + size_t num_output_formats;
>  };
>  
>  /**
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 50ba9da59153..05743a745a11 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -23,47 +23,9 @@
>  #define DFT_CFG_WIDTHMTK_VENC_MIN_W
>  #define DFT_CFG_HEIGHT   MTK_VENC_MIN_H
>  #define MTK_MAX_CTRLS_HINT   20
> -#define OUT_FMT_IDX  0
> -#define CAP_FMT_IDX  4
> -
>  
>  static void mtk_venc_worker(struct work_struct *work);
>  
> -static const struct mtk_video_fmt mtk_video_formats[] = {
> - {
> - .fourcc = V4L2_PIX_FMT_NV12M,
> - .type = MTK_FMT_FRAME,
> - .num_planes = 2,
> - },
> - {
> - .fourcc = V4L2_PIX_FMT_NV21M,
> - .type = MTK_FMT_FRAME,
> - .num_planes = 2,
> - },
> - {
> - .fourcc = V4L2_PIX_FMT_YUV420M,
> - .type = MTK_FMT_FRAME,
> - .num_planes = 3,
> - },
> - {
> - .fourcc = V4L2_PIX_FMT_YVU420M,
> - .type = MTK_FMT_FRAME,
> - .num_planes = 3,
> - },
> - {
> - .fourcc = V4L2_PIX_FMT_H264,
> - .type = MTK_FMT_ENC,
> - .num_planes = 1,
> - },
> - {
> - .fourcc = V4L2_PIX_FMT_VP8,
> - .type = MTK_FMT_ENC,
> - .num_planes = 1,
> - },
> -};
> -
> -#define NUM_FORMATS ARRAY_SIZE(mtk_video_formats)
> -
>  static const struct mtk_codec_framesizes mtk_venc_framesizes[] = {
>   {
>   .fourcc = V4L2_PIX_FMT_H264,
> @@ -156,27 +118,17 @@ static const struct v4l2_ctrl_ops 
> mtk_vcodec_enc_ctrl_ops = {
>   .s_ctrl = vidioc_venc_s_ctrl,
>  };
>  
> -static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, bool output_queue)
> +static int vidioc_enum_fmt(struct v4l2_fmtdesc *f,
> +const struct mtk_video_fmt *formats,
> +size_t num_formats)
>  {
> - const struct mtk_video_fmt *fmt;
> - int i, j = 0;
> + if (f->index >= num_formats)
> + return -EINVAL;
>  
> - for (i = 0; i < NUM_FORMATS; ++i) {
> - if (output_queue && mtk_video_formats[i].type != MTK_FMT_FRAME)
> - continue;
> - if (!output_queue && mtk_video_formats[i].type != MTK_FMT_ENC)
> - continue;
> + f->pixelformat = formats[f->index].fourcc;
> + memset(f->reserved, 0, sizeof(f->reserved));
>  
> - if (j == f->index) {
> - fmt = _video_formats[i];
> - f->pixelformat = fmt->fourcc;
> - memset(f->reserved, 0, sizeof(f->reserved));
> - return 0;
> - }
> - 

Re: [PATCH 02/10] media: mtk-vcodec: add SCP firmware ops

2020-06-24 Thread Tiffany Lin
On Tue, 2020-06-16 at 22:17 +0900, Alexandre Courbot wrote:
> On Mon, Jun 8, 2020 at 7:47 PM Tiffany Lin  wrote:
> >
> > On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> > > From: Yunfei Dong 
> > >
> > > Add support for communicating with the SCP firmware, which will be used
> > > by MT8183.
> > >


Acked-by: Tiffany Lin 

> > > Signed-off-by: Yunfei Dong 
> > > [acourbot: refactor, cleanup and split]
> > > Co-developed-by: Alexandre Courbot 
> > > Signed-off-by: Alexandre Courbot 
> > > ---
> > >  drivers/media/platform/Kconfig|  2 +
> > >  .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  3 +
> > >  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  3 +
> > >  .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 56 +++
> > >  .../media/platform/mtk-vcodec/mtk_vcodec_fw.h |  2 +
> > >  5 files changed, 66 insertions(+)
> > >
> > > diff --git a/drivers/media/platform/Kconfig 
> > > b/drivers/media/platform/Kconfig
> > > index c57ee78fa99d..9b11dd6b1ef3 100644
> > > --- a/drivers/media/platform/Kconfig
> > > +++ b/drivers/media/platform/Kconfig
> > > @@ -256,6 +256,8 @@ config VIDEO_MEDIATEK_VCODEC
> > >   select VIDEOBUF2_DMA_CONTIG
> > >   select V4L2_MEM2MEM_DEV
> > >   select VIDEO_MEDIATEK_VPU
> > > + select MTK_SCP
> > > + default n
> > >   help
> > >   Mediatek video codec driver provides HW capability to
> > >   encode and decode in a range of video formats
> > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
> > > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> > > index 4f07a5fcce7f..5b5765b98e57 100644
> > > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> > > @@ -225,6 +225,9 @@ static int mtk_vcodec_probe(struct platform_device 
> > > *pdev)
> > >   if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
> > > _phandle)) {
> > >   fw_type = VPU;
> > > + } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp",
> > > +  _phandle)) {
> > > + fw_type = SCP;
> > >   } else {
> > >   mtk_v4l2_err("Could not get vdec IPI device");
> > >   return -ENODEV;
> > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
> > > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> > > index 4340ea10afd0..42530cd01a30 100644
> > > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> > > @@ -233,6 +233,9 @@ static int mtk_vcodec_probe(struct platform_device 
> > > *pdev)
> > >   if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
> > > _phandle)) {
> > >   fw_type = VPU;
> > > + } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp",
> > > +  _phandle)) {
> > > + fw_type = SCP;
> > >   } else {
> > >   mtk_v4l2_err("Could not get venc IPI device");
> > >   return -ENODEV;
> > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c 
> > > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
> > > index 967bb100a990..f2a62ea62fc6 100644
> > > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
> > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
> > > @@ -19,6 +19,7 @@ struct mtk_vcodec_fw {
> > >   enum mtk_vcodec_fw_type type;
> > >   const struct mtk_vcodec_fw_ops *ops;
> > >   struct platform_device *pdev;
> > > + struct mtk_scp *scp;
> > >  };
> > >
> > >  static int mtk_vcodec_vpu_load_firmware(struct mtk_vcodec_fw *fw)
> > > @@ -71,6 +72,48 @@ static const struct mtk_vcodec_fw_ops 
> > > mtk_vcodec_vpu_msg = {
> > >   .ipi_send = mtk_vcodec_vpu_ipi_send,
> > >  };
> > >
> > > +static int mtk_vcodec_scp_load_firmware(struct mtk_vcodec_fw *fw)
> > > +{
> > > + return rproc_boot(scp_get_rproc(fw->scp));
> >
> >
> > Does rproc_boot a

Re: [PATCH 07/10] media: mtk-vcodec: venc: remove redundant code

2020-06-22 Thread Tiffany Lin
On Mon, 2020-06-22 at 22:10 +0900, Alexandre Courbot wrote:
> On Fri, Jun 19, 2020 at 3:59 PM Tiffany Lin  wrote:
> >
> > On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> > > vidioc_try_fmt() does clamp height and width when called on the OUTPUT
> > > queue, so clamping them prior to calling this function is redundant. Set
> > > the queue's parameters after calling vidioc_try_fmt() so we can use the
> > > values it computed.
> > >
> >
> > vidioc_try_fmt clamps height and width only when f->type ==
> > V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
> >
> > Does this cleanup pass v4l2 compliance test?
> 
> It doesn't result in more tests failing at least. :) But although I
> cannot test with a pristine upstream version, it seems like some tests
> are not passing to begin with. If you have different results with a
> true upstream I would like to hear about it. Otherwise I am willing to
> help with getting all the tests in the green.
> 
> Regarding this particular patch, you are right that we may end up
> writing an unclamped size in q_data. It's probably better to drop it
> for now.
> 
I did attach compliance tests results when I upstream first version.
It's how maintainer make sure all v4l2 driver implement interfaces the
same way.
And by doing this automatically instead review flow to make sure it meet
interfaces spec.


> > I recall compliance test will try different fmt and make sure driver
> > response enough information?
> >
> >
> > > Signed-off-by: Alexandre Courbot 
> > > ---
> > >  .../media/platform/mtk-vcodec/mtk_vcodec_enc.c   | 16 
> > >  1 file changed, 4 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> > > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > > index 05743a745a11..f0af78f112db 100644
> > > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > > @@ -449,7 +449,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, 
> > > void *priv,
> > >   struct mtk_q_data *q_data;
> > >   int ret, i;
> > >   const struct mtk_video_fmt *fmt;
> > > - struct v4l2_pix_format_mplane *pix_fmt_mp = >fmt.pix_mp;
> > >
> > >   vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
> > >   if (!vq) {
> > > @@ -474,20 +473,13 @@ static int vidioc_venc_s_fmt_out(struct file *file, 
> > > void *priv,
> > >   f->fmt.pix.pixelformat = fmt->fourcc;
> > >   }
> > >
> > > - pix_fmt_mp->height = clamp(pix_fmt_mp->height,
> > > - MTK_VENC_MIN_H,
> > > - MTK_VENC_MAX_H);
> > > - pix_fmt_mp->width = clamp(pix_fmt_mp->width,
> > > - MTK_VENC_MIN_W,
> > > - MTK_VENC_MAX_W);
> > > -
> > > - q_data->visible_width = f->fmt.pix_mp.width;
> > > - q_data->visible_height = f->fmt.pix_mp.height;
> > > - q_data->fmt = fmt;
> > > - ret = vidioc_try_fmt(f, q_data->fmt);
> > > + ret = vidioc_try_fmt(f, fmt);
> > >   if (ret)
> > >   return ret;
> > >
> > > + q_data->fmt = fmt;
> > > + q_data->visible_width = f->fmt.pix_mp.width;
> > > + q_data->visible_height = f->fmt.pix_mp.height;
> > >   q_data->coded_width = f->fmt.pix_mp.width;
> > >   q_data->coded_height = f->fmt.pix_mp.height;
> > >
> >



Re: [PATCH 06/10] media: mtk-vcodec: venc: specify supported formats per-chip

2020-06-22 Thread Tiffany Lin
On Mon, 2020-06-22 at 21:44 +0900, Alexandre Courbot wrote:
> On Fri, Jun 19, 2020 at 4:26 PM Tiffany Lin  wrote:
> >
> > On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> > > Different chips have different supported bitrate ranges. Move the list
> > > of supported formats to the platform data, and split the output and
> > > capture formats into two lists to make it easier to find the default
> > > format for each queue.
> > >
> >
> > Does this patch pass v4l2 compliance test?
> 
> This should not change the behavior towards userspace at all (it's
> just moving data around and making it more flexible), so the test
> results should not be affected either.
> 
I remember that passing compliance tests is required for upstream.
The tests try to make sure that all V4L2 driver implement interfaces in
the same way.
So user space applications could find/enumerate HW capability.



> >
> >
> > > Signed-off-by: Alexandre Courbot 
> > > ---
> > >  .../platform/mtk-vcodec/mtk_vcodec_drv.h  |   8 ++
> > >  .../platform/mtk-vcodec/mtk_vcodec_enc.c  | 122 +++---
> > >  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  40 ++
> > >  3 files changed, 95 insertions(+), 75 deletions(-)
> > >
> > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> > > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > > index b8f913de8d80..59b4b750666b 100644
> > > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > > @@ -313,6 +313,10 @@ enum mtk_chip {
> > >   * @has_lt_irq: whether the encoder uses the LT irq
> > >   * @min_birate: minimum supported encoding bitrate
> > >   * @max_bitrate: maximum supported encoding bitrate
> > > + * @capture_formats: array of supported capture formats
> > > + * @num_capture_formats: number of entries in capture_formats
> > > + * @output_formats: array of supported output formats
> > > + * @num_output_formats: number of entries in output_formats
> > >   */
> > >  struct mtk_vcodec_enc_pdata {
> > >   enum mtk_chip chip;
> > > @@ -321,6 +325,10 @@ struct mtk_vcodec_enc_pdata {
> > >   bool has_lt_irq;
> > >   unsigned long min_bitrate;
> > >   unsigned long max_bitrate;
> > > + const struct mtk_video_fmt *capture_formats;
> > > + size_t num_capture_formats;
> > > + const struct mtk_video_fmt *output_formats;
> > > + size_t num_output_formats;
> > >  };
> > >
> > >  /**
> > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> > > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > > index 50ba9da59153..05743a745a11 100644
> > > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > > @@ -23,47 +23,9 @@
> > >  #define DFT_CFG_WIDTHMTK_VENC_MIN_W
> > >  #define DFT_CFG_HEIGHT   MTK_VENC_MIN_H
> > >  #define MTK_MAX_CTRLS_HINT   20
> > > -#define OUT_FMT_IDX  0
> > > -#define CAP_FMT_IDX  4
> > > -
> > >
> > >  static void mtk_venc_worker(struct work_struct *work);
> > >
> > > -static const struct mtk_video_fmt mtk_video_formats[] = {
> > > - {
> > > - .fourcc = V4L2_PIX_FMT_NV12M,
> > > - .type = MTK_FMT_FRAME,
> > > - .num_planes = 2,
> > > - },
> > > - {
> > > - .fourcc = V4L2_PIX_FMT_NV21M,
> > > - .type = MTK_FMT_FRAME,
> > > - .num_planes = 2,
> > > - },
> > > - {
> > > - .fourcc = V4L2_PIX_FMT_YUV420M,
> > > - .type = MTK_FMT_FRAME,
> > > - .num_planes = 3,
> > > - },
> > > - {
> > > - .fourcc = V4L2_PIX_FMT_YVU420M,
> > > - .type = MTK_FMT_FRAME,
> > > - .num_planes = 3,
> > > - },
> > > - {
> > > - .fourcc = V4L2_PIX_FMT_H264,
> > > - .type = MTK_FMT_ENC,
> > > - .num_planes = 1,
> > > - },
> > > - {
> > > - .fourcc = V4L2_PIX_FMT_VP8,
> > > - .type = MTK_FMT_ENC,
> > > - .num_planes = 1,
> > > - },
> > > -};
> > > -
> > > -#defi

Re: [PATCH 06/10] media: mtk-vcodec: venc: specify supported formats per-chip

2020-06-19 Thread Tiffany Lin
On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> Different chips have different supported bitrate ranges. Move the list
> of supported formats to the platform data, and split the output and
> capture formats into two lists to make it easier to find the default
> format for each queue.
> 

Does this patch pass v4l2 compliance test?


> Signed-off-by: Alexandre Courbot 
> ---
>  .../platform/mtk-vcodec/mtk_vcodec_drv.h  |   8 ++
>  .../platform/mtk-vcodec/mtk_vcodec_enc.c  | 122 +++---
>  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  40 ++
>  3 files changed, 95 insertions(+), 75 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> index b8f913de8d80..59b4b750666b 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> @@ -313,6 +313,10 @@ enum mtk_chip {
>   * @has_lt_irq: whether the encoder uses the LT irq
>   * @min_birate: minimum supported encoding bitrate
>   * @max_bitrate: maximum supported encoding bitrate
> + * @capture_formats: array of supported capture formats
> + * @num_capture_formats: number of entries in capture_formats
> + * @output_formats: array of supported output formats
> + * @num_output_formats: number of entries in output_formats
>   */
>  struct mtk_vcodec_enc_pdata {
>   enum mtk_chip chip;
> @@ -321,6 +325,10 @@ struct mtk_vcodec_enc_pdata {
>   bool has_lt_irq;
>   unsigned long min_bitrate;
>   unsigned long max_bitrate;
> + const struct mtk_video_fmt *capture_formats;
> + size_t num_capture_formats;
> + const struct mtk_video_fmt *output_formats;
> + size_t num_output_formats;
>  };
>  
>  /**
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 50ba9da59153..05743a745a11 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -23,47 +23,9 @@
>  #define DFT_CFG_WIDTHMTK_VENC_MIN_W
>  #define DFT_CFG_HEIGHT   MTK_VENC_MIN_H
>  #define MTK_MAX_CTRLS_HINT   20
> -#define OUT_FMT_IDX  0
> -#define CAP_FMT_IDX  4
> -
>  
>  static void mtk_venc_worker(struct work_struct *work);
>  
> -static const struct mtk_video_fmt mtk_video_formats[] = {
> - {
> - .fourcc = V4L2_PIX_FMT_NV12M,
> - .type = MTK_FMT_FRAME,
> - .num_planes = 2,
> - },
> - {
> - .fourcc = V4L2_PIX_FMT_NV21M,
> - .type = MTK_FMT_FRAME,
> - .num_planes = 2,
> - },
> - {
> - .fourcc = V4L2_PIX_FMT_YUV420M,
> - .type = MTK_FMT_FRAME,
> - .num_planes = 3,
> - },
> - {
> - .fourcc = V4L2_PIX_FMT_YVU420M,
> - .type = MTK_FMT_FRAME,
> - .num_planes = 3,
> - },
> - {
> - .fourcc = V4L2_PIX_FMT_H264,
> - .type = MTK_FMT_ENC,
> - .num_planes = 1,
> - },
> - {
> - .fourcc = V4L2_PIX_FMT_VP8,
> - .type = MTK_FMT_ENC,
> - .num_planes = 1,
> - },
> -};
> -
> -#define NUM_FORMATS ARRAY_SIZE(mtk_video_formats)
> -
>  static const struct mtk_codec_framesizes mtk_venc_framesizes[] = {
>   {
>   .fourcc = V4L2_PIX_FMT_H264,
> @@ -156,27 +118,17 @@ static const struct v4l2_ctrl_ops 
> mtk_vcodec_enc_ctrl_ops = {
>   .s_ctrl = vidioc_venc_s_ctrl,
>  };
>  
> -static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, bool output_queue)
> +static int vidioc_enum_fmt(struct v4l2_fmtdesc *f,
> +const struct mtk_video_fmt *formats,
> +size_t num_formats)
>  {
> - const struct mtk_video_fmt *fmt;
> - int i, j = 0;
> + if (f->index >= num_formats)
> + return -EINVAL;
>  
> - for (i = 0; i < NUM_FORMATS; ++i) {
> - if (output_queue && mtk_video_formats[i].type != MTK_FMT_FRAME)
> - continue;
> - if (!output_queue && mtk_video_formats[i].type != MTK_FMT_ENC)
> - continue;
> + f->pixelformat = formats[f->index].fourcc;
> + memset(f->reserved, 0, sizeof(f->reserved));
>  
> - if (j == f->index) {
> - fmt = _video_formats[i];
> - f->pixelformat = fmt->fourcc;
> - memset(f->reserved, 0, sizeof(f->reserved));
> - return 0;
> - }
> - ++j;
> - }
> -
> - return -EINVAL;
> + return 0;
>  }
>  
>  static int vidioc_enum_framesizes(struct file *file, void *fh,
> @@ -202,13 +154,21 @@ static int vidioc_enum_framesizes(struct file *file, 
> void *fh,
>  static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
>  struct v4l2_fmtdesc *f)
>  {
> - return vidioc_enum_fmt(f, 

Re: [PATCH 09/10] media: dt-bindings: mtk-vcodec: specify SCP node

2020-06-19 Thread Tiffany Lin
On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> The mediatek codecs can use either the VPU or the SCP as their interface
> to firmware. Reflect this in the DT bindings.
> 
Acked-by: Tiffany Lin 


> Signed-off-by: Alexandre Courbot 
> ---
>  Documentation/devicetree/bindings/media/mediatek-vcodec.txt | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt 
> b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> index b6b5dde6abd8..7aef0a4fe207 100644
> --- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> +++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> @@ -19,7 +19,9 @@ Required properties:
>  - iommus : should point to the respective IOMMU block with master port as
>argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
>for details.
> -- mediatek,vpu : the node of video processor unit
> +One of the two following nodes:
> +- mediatek,vpu : the node of the video processor unit, if using VPU.
> +- mediatek,scp : the noode of the SCP unit, if using SCP.
>  
> 
>  Example:



Re: [PATCH 08/10] media: mtk-vcodec: add support for MT8183 encoder

2020-06-19 Thread Tiffany Lin
On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> From: Yunfei Dong 
> 
> Now that all the supporting blocks are present, enable encoder for
> MT8183.
> 

Acked-by: Tiffany Lin 


> Signed-off-by: Yunfei Dong 
> [acourbot: refactor, cleanup and split]
> Co-developed-by: Alexandre Courbot 
> Signed-off-by: Alexandre Courbot 
> ---
>  .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  1 +
>  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  | 22 +++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> index 59b4b750666b..a271611750ad 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> @@ -302,6 +302,7 @@ struct mtk_vcodec_ctx {
>  
>  enum mtk_chip {
>   MTK_MT8173,
> + MTK_MT8183,
>  };
>  
>  /**
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> index c8a4b85a81c4..b8fe408dd6c7 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> @@ -62,6 +62,14 @@ static const struct mtk_video_fmt 
> mtk_video_formats_capture_mt8173[] =  {
>   },
>  };
>  
> +static const struct mtk_video_fmt mtk_video_formats_capture_mt8183[] =  {
> + {
> + .fourcc = V4L2_PIX_FMT_H264,
> + .type = MTK_FMT_ENC,
> + .num_planes = 1,
> + },
> +};
> +
>  /* Wake up context wait_queue */
>  static void wake_up_ctx(struct mtk_vcodec_ctx *ctx, unsigned int reason)
>  {
> @@ -424,8 +432,22 @@ static const struct mtk_vcodec_enc_pdata mt8173_pdata = {
>   .max_bitrate = 400,
>  };
>  
> +static const struct mtk_vcodec_enc_pdata mt8183_pdata = {
> + .chip = MTK_MT8183,
> + .has_lt_irq = false,
> + .uses_ext = true,
> + .capture_formats = mtk_video_formats_capture_mt8183,
> + .num_capture_formats = ARRAY_SIZE(mtk_video_formats_capture_mt8183),
> + /* MT8183 supports the same output formats as MT8173 */
> + .output_formats = mtk_video_formats_output_mt8173,
> + .num_output_formats = ARRAY_SIZE(mtk_video_formats_output_mt8173),
> + .min_bitrate = 64,
> + .max_bitrate = 4000,
> +};
> +
>  static const struct of_device_id mtk_vcodec_enc_match[] = {
>   {.compatible = "mediatek,mt8173-vcodec-enc", .data = _pdata},
> + {.compatible = "mediatek,mt8183-vcodec-enc", .data = _pdata},
>   {},
>  };
>  MODULE_DEVICE_TABLE(of, mtk_vcodec_enc_match);



Re: [PATCH 07/10] media: mtk-vcodec: venc: remove redundant code

2020-06-19 Thread Tiffany Lin
On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> vidioc_try_fmt() does clamp height and width when called on the OUTPUT
> queue, so clamping them prior to calling this function is redundant. Set
> the queue's parameters after calling vidioc_try_fmt() so we can use the
> values it computed.
> 

vidioc_try_fmt clamps height and width only when f->type ==
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE

Does this cleanup pass v4l2 compliance test?
I recall compliance test will try different fmt and make sure driver
response enough information?


> Signed-off-by: Alexandre Courbot 
> ---
>  .../media/platform/mtk-vcodec/mtk_vcodec_enc.c   | 16 
>  1 file changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index 05743a745a11..f0af78f112db 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -449,7 +449,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void 
> *priv,
>   struct mtk_q_data *q_data;
>   int ret, i;
>   const struct mtk_video_fmt *fmt;
> - struct v4l2_pix_format_mplane *pix_fmt_mp = >fmt.pix_mp;
>  
>   vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
>   if (!vq) {
> @@ -474,20 +473,13 @@ static int vidioc_venc_s_fmt_out(struct file *file, 
> void *priv,
>   f->fmt.pix.pixelformat = fmt->fourcc;
>   }
>  
> - pix_fmt_mp->height = clamp(pix_fmt_mp->height,
> - MTK_VENC_MIN_H,
> - MTK_VENC_MAX_H);
> - pix_fmt_mp->width = clamp(pix_fmt_mp->width,
> - MTK_VENC_MIN_W,
> - MTK_VENC_MAX_W);
> -
> - q_data->visible_width = f->fmt.pix_mp.width;
> - q_data->visible_height = f->fmt.pix_mp.height;
> - q_data->fmt = fmt;
> - ret = vidioc_try_fmt(f, q_data->fmt);
> + ret = vidioc_try_fmt(f, fmt);
>   if (ret)
>   return ret;
>  
> + q_data->fmt = fmt;
> + q_data->visible_width = f->fmt.pix_mp.width;
> + q_data->visible_height = f->fmt.pix_mp.height;
>   q_data->coded_width = f->fmt.pix_mp.width;
>   q_data->coded_height = f->fmt.pix_mp.height;
>  



Re: [PATCH v4 01/17] media: dt-binding: mtk-vcodec: Separating mtk-vcodec encode node.

2020-06-16 Thread Tiffany Lin
On Wed, 2020-06-10 at 15:38 +0800, Tiffany Lin wrote:
> On Wed, 2020-06-10 at 15:46 +0900, Alexandre Courbot wrote:
> > On Wed, Jun 10, 2020 at 6:21 AM Rob Herring  wrote:
> > >
> > > On Sat, May 30, 2020 at 04:10:02PM +0800, Yong Wu wrote:
> > > > From: Maoguang Meng 
> > > >
> > > > Update binding document since the avc and vp8 hardware encoder in
> > > > mt8173 are now separated. Separate "mediatek,mt8173-vcodec-enc" to
> > > > "mediatek,mt8173-vcodec-vp8-enc" and "mediatek,mt8173-vcodec-avc-enc".
> > >
> > > The h/w suddenly split in 2? You are breaking compatibility. Up to the
> > > Mediatek maintainers to decide if that's okay, but you need to state you
> > > are breaking compatibility (here and in the driver) and why that is
> > > okay.
> > 
> > In my understanding there is no real hardware using the old bindings
> > at the moment, and the split is indeed a reflection of the actual
> > hardware layout. Tiffany, can you give your acked-by if this change is
> > ok with you?
> > 
> 
> In my opinion, there is no need to change mt8173 dts for driver to
> support mt8183.
> I saw another patch that already make change to have encoder driver
> support both mt8173 and mt8183.
> But they done a lot to prove h264 and vp8 encoder could work
> independently and parallel.
> In this case, I am ok with it because dts should be a reflection of the
> actual hardware.
> 
> 
> 
> > >
> > > >
> > > > This is a preparing patch for smi cleaning up "mediatek,larb".
> > > >
Acked-by: Tiffany Lin 


> > > > Signed-off-by: Maoguang Meng 
> > > > Signed-off-by: Hsin-Yi Wang 
> > > > Signed-off-by: Irui Wang 
> > > > Signed-off-by: Yong Wu 
> > > > ---
> > > >  .../devicetree/bindings/media/mediatek-vcodec.txt  | 58 
> > > > --
> > > >  1 file changed, 31 insertions(+), 27 deletions(-)
> > > >
> > > > diff --git 
> > > > a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt 
> > > > b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> > > > index 8093335..1023740 100644
> > > > --- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> > > > +++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> > > > @@ -4,7 +4,9 @@ Mediatek Video Codec is the video codec hw present in 
> > > > Mediatek SoCs which
> > > >  supports high resolution encoding and decoding functionalities.
> > > >
> > > >  Required properties:
> > > > -- compatible : "mediatek,mt8173-vcodec-enc" for MT8173 encoder
> > > > +- compatible : must be one of the following string:
> > > > +  "mediatek,mt8173-vcodec-vp8-enc" for mt8173 vp8 encoder.
> > > > +  "mediatek,mt8173-vcodec-avc-enc" for mt8173 avc encoder.
> > > >"mediatek,mt8183-vcodec-enc" for MT8183 encoder.
> > > >"mediatek,mt8173-vcodec-dec" for MT8173 decoder.
> > > >  - reg : Physical base address of the video codec registers and length 
> > > > of
> > > > @@ -13,10 +15,11 @@ Required properties:
> > > >  - mediatek,larb : must contain the local arbiters in the current Socs.
> > > >  - clocks : list of clock specifiers, corresponding to entries in
> > > >the clock-names property.
> > > > -- clock-names: encoder must contain "venc_sel_src", "venc_sel",,
> > > > -  "venc_lt_sel_src", "venc_lt_sel", decoder must contain "vcodecpll",
> > > > -  "univpll_d2", "clk_cci400_sel", "vdec_sel", "vdecpll", "vencpll",
> > > > -  "venc_lt_sel", "vdec_bus_clk_src".
> > > > +- clock-names:
> > > > +   avc venc must contain "venc_sel";
> > > > +   vp8 venc must contain "venc_lt_sel";
> > > > +   decoder  must contain "vcodecpll", "univpll_d2", "clk_cci400_sel",
> > > > +   "vdec_sel", "vdecpll", "vencpll", "venc_lt_sel", "vdec_bus_clk_src".
> > > >  - iommus : should point to the respective IOMMU block with master port 
> > > > as
> > > >argument, see 
> > > > Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
> > > >for 

Re: [PATCH 05/10] media: mtk-vcodec: venc: specify bitrate range per-chip

2020-06-16 Thread Tiffany Lin
On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> Different chips have different supported bitrate ranges. Move the min
> and max supported bitrates to the platform data.
> 

Acked-by: Tiffany Lin 

> Signed-off-by: Alexandre Courbot 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 4 
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 3 ++-
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 2 ++
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> index e7b155e7432e..b8f913de8d80 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> @@ -311,12 +311,16 @@ enum mtk_chip {
>   *
>   * @uses_ext: whether the encoder uses the extended firmware messaging format
>   * @has_lt_irq: whether the encoder uses the LT irq
> + * @min_birate: minimum supported encoding bitrate
> + * @max_bitrate: maximum supported encoding bitrate
>   */
>  struct mtk_vcodec_enc_pdata {
>   enum mtk_chip chip;
>  
>   bool uses_ext;
>   bool has_lt_irq;
> + unsigned long min_bitrate;
> + unsigned long max_bitrate;
>  };
>  
>  /**
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> index d469ff6464b2..50ba9da59153 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> @@ -1232,7 +1232,8 @@ int mtk_vcodec_enc_ctrls_setup(struct mtk_vcodec_ctx 
> *ctx)
>   v4l2_ctrl_handler_init(handler, MTK_MAX_CTRLS_HINT);
>  
>   v4l2_ctrl_new_std(handler, ops, V4L2_CID_MPEG_VIDEO_BITRATE,
> - 1, 400, 1, 400);
> +   ctx->dev->venc_pdata->min_bitrate,
> +   ctx->dev->venc_pdata->max_bitrate, 1, 400);
>   v4l2_ctrl_new_std(handler, ops, V4L2_CID_MPEG_VIDEO_B_FRAMES,
>   0, 2, 1, 0);
>   v4l2_ctrl_new_std(handler, ops, V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE,
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> index c1365209263e..221fa0303075 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> @@ -380,6 +380,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>  static const struct mtk_vcodec_enc_pdata mt8173_pdata = {
>   .chip = MTK_MT8173,
>   .has_lt_irq = true,
> + .min_bitrate = 1,
> + .max_bitrate = 400,
>  };
>  
>  static const struct of_device_id mtk_vcodec_enc_match[] = {



Re: [PATCH 04/10] media: mtk-vcodec: venc: handle firmware version field

2020-06-16 Thread Tiffany Lin
On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> Firmwares for encoders newer than MT8173 will include an ABI version
> number in their initialization ack message. Add the capacity to manage
> it and make initialization fail if the firmware ABI is of a version that
> we don't support.
> 
> For MT8173, this ABI version field is reserved and thus undefined ; thus
> ignore it on this chip. There should only be one firmware version available
> for it anyway.
> 

Acked-by: Tiffany Lin 

> Signed-off-by: Alexandre Courbot 
> ---
>  .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  8 ++
>  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  1 +
>  .../media/platform/mtk-vcodec/venc_ipi_msg.h  |  9 ---
>  .../media/platform/mtk-vcodec/venc_vpu_if.c   | 27 ---
>  4 files changed, 38 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> index 45c8adfc6a0c..e7b155e7432e 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> @@ -300,13 +300,21 @@ struct mtk_vcodec_ctx {
>  
>  };
>  
> +enum mtk_chip {
> + MTK_MT8173,
> +};
> +
>  /**
>   * struct mtk_vcodec_enc_pdata - compatible data for each IC
>   *
> + * @chip: chip this encoder is compatible with
> + *
>   * @uses_ext: whether the encoder uses the extended firmware messaging format
>   * @has_lt_irq: whether the encoder uses the LT irq
>   */
>  struct mtk_vcodec_enc_pdata {
> + enum mtk_chip chip;
> +
>   bool uses_ext;
>   bool has_lt_irq;
>  };
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> index 922bc8883811..c1365209263e 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> @@ -378,6 +378,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>  }
>  
>  static const struct mtk_vcodec_enc_pdata mt8173_pdata = {
> + .chip = MTK_MT8173,
>   .has_lt_irq = true,
>  };
>  
> diff --git a/drivers/media/platform/mtk-vcodec/venc_ipi_msg.h 
> b/drivers/media/platform/mtk-vcodec/venc_ipi_msg.h
> index 4cafbf92d9cd..31a3c76f7d0d 100644
> --- a/drivers/media/platform/mtk-vcodec/venc_ipi_msg.h
> +++ b/drivers/media/platform/mtk-vcodec/venc_ipi_msg.h
> @@ -131,16 +131,17 @@ struct venc_vpu_ipi_msg_common {
>   * @venc_inst:   AP encoder instance (struct 
> venc_vp8_inst/venc_h264_inst *)
>   * @vpu_inst_addr:   VPU encoder instance addr
>   *   (struct venc_vp8_vsi/venc_h264_vsi *)
> - * @reserved:reserved for future use. vpu is running in 32bit. 
> Without
> - *   this reserved field, if kernel run in 64bit. this struct size
> - *   will be different between kernel and vpu
> + * @venc_abi_version:ABI version of the firmware. Kernel can use it 
> to
> + *   ensure that it is compatible with the firmware.
> + *   For MT8173 the value of this field is undefined and
> + *   should not be used.
>   */
>  struct venc_vpu_ipi_msg_init {
>   uint32_t msg_id;
>   uint32_t status;
>   uint64_t venc_inst;
>   uint32_t vpu_inst_addr;
> - uint32_t reserved;
> + uint32_t venc_abi_version;
>  };
>  
>  /**
> diff --git a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c 
> b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
> index 6c77bf025172..472503701003 100644
> --- a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
> +++ b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
> @@ -4,6 +4,7 @@
>   * Author: PoChun Lin 
>   */
>  
> +#include "mtk_vcodec_drv.h"
>  #include "mtk_vcodec_fw.h"
>  #include "venc_ipi_msg.h"
>  #include "venc_vpu_if.h"
> @@ -15,6 +16,23 @@ static void handle_enc_init_msg(struct venc_vpu_inst *vpu, 
> const void *data)
>   vpu->inst_addr = msg->vpu_inst_addr;
>   vpu->vsi = mtk_vcodec_fw_map_dm_addr(vpu->ctx->dev->fw_handler,
>msg->vpu_inst_addr);
> +
> + /* Firmware version field value is unspecified on MT8173. */
> + if (vpu->ctx->dev->venc_pdata->chip == MTK_MT8173)
> + return;
> +
> + /* Check firmware version. */
> + mtk_vcodec_debug(vpu, "firmware version: 0x%x\n",
> +  msg->venc_abi_version);
> + switch (msg->venc_abi_version) {
> + case 1:
> + break;
> + default:
> 

Re: [PATCH v4 01/17] media: dt-binding: mtk-vcodec: Separating mtk-vcodec encode node.

2020-06-10 Thread Tiffany Lin
On Wed, 2020-06-10 at 15:46 +0900, Alexandre Courbot wrote:
> On Wed, Jun 10, 2020 at 6:21 AM Rob Herring  wrote:
> >
> > On Sat, May 30, 2020 at 04:10:02PM +0800, Yong Wu wrote:
> > > From: Maoguang Meng 
> > >
> > > Update binding document since the avc and vp8 hardware encoder in
> > > mt8173 are now separated. Separate "mediatek,mt8173-vcodec-enc" to
> > > "mediatek,mt8173-vcodec-vp8-enc" and "mediatek,mt8173-vcodec-avc-enc".
> >
> > The h/w suddenly split in 2? You are breaking compatibility. Up to the
> > Mediatek maintainers to decide if that's okay, but you need to state you
> > are breaking compatibility (here and in the driver) and why that is
> > okay.
> 
> In my understanding there is no real hardware using the old bindings
> at the moment, and the split is indeed a reflection of the actual
> hardware layout. Tiffany, can you give your acked-by if this change is
> ok with you?
> 

In my opinion, there is no need to change mt8173 dts for driver to
support mt8183.
I saw another patch that already make change to have encoder driver
support both mt8173 and mt8183.
But they done a lot to prove h264 and vp8 encoder could work
independently and parallel.
In this case, I am ok with it because dts should be a reflection of the
actual hardware.



> >
> > >
> > > This is a preparing patch for smi cleaning up "mediatek,larb".
> > >
> > > Signed-off-by: Maoguang Meng 
> > > Signed-off-by: Hsin-Yi Wang 
> > > Signed-off-by: Irui Wang 
> > > Signed-off-by: Yong Wu 
> > > ---
> > >  .../devicetree/bindings/media/mediatek-vcodec.txt  | 58 
> > > --
> > >  1 file changed, 31 insertions(+), 27 deletions(-)
> > >
> > > diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt 
> > > b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> > > index 8093335..1023740 100644
> > > --- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> > > +++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> > > @@ -4,7 +4,9 @@ Mediatek Video Codec is the video codec hw present in 
> > > Mediatek SoCs which
> > >  supports high resolution encoding and decoding functionalities.
> > >
> > >  Required properties:
> > > -- compatible : "mediatek,mt8173-vcodec-enc" for MT8173 encoder
> > > +- compatible : must be one of the following string:
> > > +  "mediatek,mt8173-vcodec-vp8-enc" for mt8173 vp8 encoder.
> > > +  "mediatek,mt8173-vcodec-avc-enc" for mt8173 avc encoder.
> > >"mediatek,mt8183-vcodec-enc" for MT8183 encoder.
> > >"mediatek,mt8173-vcodec-dec" for MT8173 decoder.
> > >  - reg : Physical base address of the video codec registers and length of
> > > @@ -13,10 +15,11 @@ Required properties:
> > >  - mediatek,larb : must contain the local arbiters in the current Socs.
> > >  - clocks : list of clock specifiers, corresponding to entries in
> > >the clock-names property.
> > > -- clock-names: encoder must contain "venc_sel_src", "venc_sel",,
> > > -  "venc_lt_sel_src", "venc_lt_sel", decoder must contain "vcodecpll",
> > > -  "univpll_d2", "clk_cci400_sel", "vdec_sel", "vdecpll", "vencpll",
> > > -  "venc_lt_sel", "vdec_bus_clk_src".
> > > +- clock-names:
> > > +   avc venc must contain "venc_sel";
> > > +   vp8 venc must contain "venc_lt_sel";
> > > +   decoder  must contain "vcodecpll", "univpll_d2", "clk_cci400_sel",
> > > +   "vdec_sel", "vdecpll", "vencpll", "venc_lt_sel", "vdec_bus_clk_src".
> > >  - iommus : should point to the respective IOMMU block with master port as
> > >argument, see 
> > > Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
> > >for details.
> > > @@ -80,14 +83,10 @@ vcodec_dec: vcodec@1600 {
> > >  assigned-clock-rates = <0>, <0>, <0>, <148200>, <8>;
> > >};
> > >
> > > -  vcodec_enc: vcodec@18002000 {
> > > -compatible = "mediatek,mt8173-vcodec-enc";
> > > -reg = <0 0x18002000 0 0x1000>,/*VENC_SYS*/
> > > -  <0 0x19002000 0 0x1000>;/*VENC_LT_SYS*/
> > > -interrupts = ,
> > > -  ;
> > > -mediatek,larb = <>,
> > > - <>;
> > > +vcodec_enc: vcodec@18002000 {
> > > +compatible = "mediatek,mt8173-vcodec-avc-enc";
> > > +reg = <0 0x18002000 0 0x1000>;
> > > +interrupts = ;
> > >  iommus = < M4U_PORT_VENC_RCPU>,
> > >   < M4U_PORT_VENC_REC>,
> > >   < M4U_PORT_VENC_BSDMA>,
> > > @@ -98,8 +97,20 @@ vcodec_dec: vcodec@1600 {
> > >   < M4U_PORT_VENC_REF_LUMA>,
> > >   < M4U_PORT_VENC_REF_CHROMA>,
> > >   < M4U_PORT_VENC_NBM_RDMA>,
> > > - < M4U_PORT_VENC_NBM_WDMA>,
> > > - < M4U_PORT_VENC_RCPU_SET2>,
> > > + < M4U_PORT_VENC_NBM_WDMA>;
> > > +mediatek,larb = <>;
> > > +mediatek,vpu = <>;
> > > +clocks = < CLK_TOP_VENC_SEL>;
> > > +clock-names = "venc_sel";
> > > +assigned-clocks = < CLK_TOP_VENC_SEL>;
> > > +assigned-clock-parents = < CLK_TOP_VCODECPLL>;
> > > +  };
> > > +
> > > +vcodec_enc_lt: 

Re: [PATCH 03/10] media: mtk-vcodec: venc: support SCP firmware

2020-06-10 Thread Tiffany Lin
On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> From: Yunfei Dong 
> 
> Support the new extended firmware used by MT8183's encoder.
> 

Acked-by: Tiffany Lin 

> Signed-off-by: Yunfei Dong 
> [acourbot: refactor, cleanup and split]
> Co-developed-by: Alexandre Courbot 
> Signed-off-by: Alexandre Courbot 
> ---
>  .../platform/mtk-vcodec/mtk_vcodec_drv.h  | 12 +++
>  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  | 34 ---
>  .../platform/mtk-vcodec/venc/venc_h264_if.c   | 65 +++--
>  .../platform/mtk-vcodec/venc/venc_vp8_if.c|  3 +-
>  .../media/platform/mtk-vcodec/venc_drv_if.h   |  6 ++
>  .../media/platform/mtk-vcodec/venc_ipi_msg.h  | 15 ++-
>  .../media/platform/mtk-vcodec/venc_vpu_if.c   | 97 +--
>  .../media/platform/mtk-vcodec/venc_vpu_if.h   |  3 +-
>  8 files changed, 181 insertions(+), 54 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> index e132c4ec463a..45c8adfc6a0c 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> @@ -300,6 +300,17 @@ struct mtk_vcodec_ctx {
>  
>  };
>  
> +/**
> + * struct mtk_vcodec_enc_pdata - compatible data for each IC
> + *
> + * @uses_ext: whether the encoder uses the extended firmware messaging format
> + * @has_lt_irq: whether the encoder uses the LT irq
> + */
> +struct mtk_vcodec_enc_pdata {
> + bool uses_ext;
> + bool has_lt_irq;
> +};
> +
>  /**
>   * struct mtk_vcodec_dev - driver data
>   * @v4l2_dev: V4L2 device to register video devices for.
> @@ -348,6 +359,7 @@ struct mtk_vcodec_dev {
>   spinlock_t irqlock;
>   struct mtk_vcodec_ctx *curr_ctx;
>   void __iomem *reg_base[NUM_MAX_VCODEC_REG_BASE];
> + const struct mtk_vcodec_enc_pdata *venc_pdata;
>  
>   struct mtk_vcodec_fw *fw_handler;
>  
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> index 42530cd01a30..922bc8883811 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> @@ -244,6 +244,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>   if (IS_ERR(dev->fw_handler))
>   return PTR_ERR(dev->fw_handler);
>  
> + dev->venc_pdata = of_device_get_match_data(>dev);
>   ret = mtk_vcodec_init_enc_pm(dev);
>   if (ret < 0) {
>   dev_err(>dev, "Failed to get mt vcodec clock source!");
> @@ -278,21 +279,24 @@ static int mtk_vcodec_probe(struct platform_device 
> *pdev)
>   ret = -EINVAL;
>   goto err_res;
>   }
> + disable_irq(dev->enc_irq);
>  
> - dev->enc_lt_irq = platform_get_irq(pdev, 1);
> - ret = devm_request_irq(>dev,
> -dev->enc_lt_irq, mtk_vcodec_enc_lt_irq_handler,
> -0, pdev->name, dev);
> - if (ret) {
> - dev_err(>dev,
> - "Failed to install dev->enc_lt_irq %d (%d)",
> - dev->enc_lt_irq, ret);
> - ret = -EINVAL;
> - goto err_res;
> + if (dev->venc_pdata->has_lt_irq) {
> + dev->enc_lt_irq = platform_get_irq(pdev, 1);
> + ret = devm_request_irq(>dev,
> +dev->enc_lt_irq,
> +mtk_vcodec_enc_lt_irq_handler,
> +0, pdev->name, dev);
> + if (ret) {
> + dev_err(>dev,
> + "Failed to install dev->enc_lt_irq %d (%d)",
> + dev->enc_lt_irq, ret);
> + ret = -EINVAL;
> + goto err_res;
> + }
> + disable_irq(dev->enc_lt_irq); /* VENC_LT */
>   }
>  
> - disable_irq(dev->enc_irq);
> - disable_irq(dev->enc_lt_irq); /* VENC_LT */
>   mutex_init(>enc_mutex);
>   mutex_init(>dev_mutex);
>   spin_lock_init(>irqlock);
> @@ -373,8 +377,12 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>   return ret;
>  }
>  
> +static const struct mtk_vcodec_enc_pdata mt8173_pdata = {
> + .has_lt_irq = true,
> +};
> +
>  static const struct of_device_id mtk_vcodec_enc_match[] = {
> - {.compatible = "mediatek,mt8173-vcodec-enc",},
> + {.compatible = "mediatek,mt8173-vcodec-enc", .data = _pdata},
>   {},

Re: [PATCH v4 09/17] media: mtk-vcodec: Get rid of mtk_smi_larb_get/put

2020-06-10 Thread Tiffany Lin
On Wed, 2020-06-10 at 13:47 +0800, CK Hu wrote:
> + Tiffany & Maoguang.
> 
> On Sat, 2020-05-30 at 16:10 +0800, Yong Wu wrote:
> > MediaTek IOMMU has already added the device_link between the consumer
> > and smi-larb device. If the vcodec device call the pm_runtime_get_sync,
> > the smi-larb's pm_runtime_get_sync also be called automatically.
> > 

Acked-by: Tiffany Lin 

> > CC: Tiffany Lin 
> > Signed-off-by: Yong Wu 
> > Reviewed-by: Evan Green 
> > ---
> >  .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  | 19 ---
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |  3 ---
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |  1 -
> >  .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c  | 27 
> > --
> >  4 files changed, 50 deletions(-)
> > 
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> > index 36dfe3f..1d7d14d 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> > @@ -8,14 +8,12 @@
> >  #include 
> >  #include 
> >  #include 
> > -#include 
> >  
> >  #include "mtk_vcodec_dec_pm.h"
> >  #include "mtk_vcodec_util.h"
> >  
> >  int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev)
> >  {
> > -   struct device_node *node;
> > struct platform_device *pdev;
> > struct mtk_vcodec_pm *pm;
> > struct mtk_vcodec_clk *dec_clk;
> > @@ -26,18 +24,7 @@ int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev)
> > pm = >pm;
> > pm->mtkdev = mtkdev;
> > dec_clk = >vdec_clk;
> > -   node = of_parse_phandle(pdev->dev.of_node, "mediatek,larb", 0);
> > -   if (!node) {
> > -   mtk_v4l2_err("of_parse_phandle mediatek,larb fail!");
> > -   return -1;
> > -   }
> >  
> > -   pdev = of_find_device_by_node(node);
> > -   of_node_put(node);
> > -   if (WARN_ON(!pdev)) {
> > -   return -1;
> > -   }
> > -   pm->larbvdec = >dev;
> > pdev = mtkdev->plat_dev;
> > pm->dev = >dev;
> >  
> > @@ -113,11 +100,6 @@ void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
> > }
> > }
> >  
> > -   ret = mtk_smi_larb_get(pm->larbvdec);
> > -   if (ret) {
> > -   mtk_v4l2_err("mtk_smi_larb_get larbvdec fail %d", ret);
> > -   goto error;
> > -   }
> > return;
> >  
> >  error:
> > @@ -130,7 +112,6 @@ void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm)
> > struct mtk_vcodec_clk *dec_clk = >vdec_clk;
> > int i = 0;
> >  
> > -   mtk_smi_larb_put(pm->larbvdec);
> > for (i = dec_clk->clk_num - 1; i >= 0; i--)
> > clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
> >  }
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > index 52d1ce1..7d3966a 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > @@ -190,10 +190,7 @@ struct mtk_vcodec_clk {
> >   */
> >  struct mtk_vcodec_pm {
> > struct mtk_vcodec_clk   vdec_clk;
> > -   struct device   *larbvdec;
> > -
> > struct mtk_vcodec_clk   venc_clk;
> > -   struct device   *larbvenc;
> > struct device   *dev;
> > struct mtk_vcodec_dev   *mtkdev;
> >  };
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > index 5301dca..18025f7 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > @@ -8,7 +8,6 @@
> >  #include 
> >  #include 
> >  #include 
> > -#include 
> >  #include 
> >  
> >  #include "mtk_vcodec_drv.h"
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
> > index 01c6a55..047919e 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
> > @@ -8,44 +8,25 @@
> >  #include 
> >  #include 
> >  #include 
> > -#include 
> >  
> >  #include "mtk_vcodec_enc_pm.h"
> >  #i

Re: [PATCH v4 08/17] media: mtk-vcodec: separate mtk-vcodec-enc node.

2020-06-10 Thread Tiffany Lin
On Wed, 2020-06-10 at 13:45 +0800, CK Hu wrote:
> + Tiffany & Maoguang.
> 
> 
> On Sat, 2020-05-30 at 16:10 +0800, Yong Wu wrote:
> > From: Maoguang Meng 
> > 
> > MTK H264 Encoder(VENC_SYS) and VP8 Encoder(VENC_LT_SYS) are two
> > independent hardware instance. They have their owner interrupt,
> > register mapping, and special clocks.
> > 
> > This patch seperates the two instance. This is a preparing patch for
> > adding device_link between the larbs and venc-device. It's mainly for
> > fixing the problem:
> > https://lkml.org/lkml/2019/9/3/316
> > 
> > User Call "VIDIOC_QUERYCAP":
> > H264 Encoder return driver name "mtk-vcodec-enc";
> > VP8 Encoder return driver name "mtk-venc-vp8.
> > 

Acked-by: Tiffany Lin 


> > Signed-off-by: Maoguang Meng 
> > Signed-off-by: Hsin-Yi Wang 
> > Signed-off-by: Irui Wang 
> > ---
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |  10 +-
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |  23 +++-
> >  .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 127 
> > +
> >  .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c  |  31 +
> >  .../media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h  |   1 -
> >  .../media/platform/mtk-vcodec/venc/venc_vp8_if.c   |   4 +-
> >  6 files changed, 80 insertions(+), 116 deletions(-)
> > 
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > index a2716117..52d1ce1 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> > @@ -19,6 +19,7 @@
> >  #define MTK_VCODEC_DRV_NAME"mtk_vcodec_drv"
> >  #define MTK_VCODEC_DEC_NAME"mtk-vcodec-dec"
> >  #define MTK_VCODEC_ENC_NAME"mtk-vcodec-enc"
> > +#define MTK_VENC_VP8_NAME  "mtk-venc-vp8"
> >  #define MTK_PLATFORM_STR   "platform:mt8173"
> >  
> >  #define MTK_VCODEC_MAX_PLANES  3
> > @@ -193,7 +194,6 @@ struct mtk_vcodec_pm {
> >  
> > struct mtk_vcodec_clk   venc_clk;
> > struct device   *larbvenc;
> > -   struct device   *larbvenclt;
> > struct device   *dev;
> > struct mtk_vcodec_dev   *mtkdev;
> >  };
> > @@ -311,25 +311,27 @@ enum mtk_chip {
> >   * @chip: chip this encoder is compatible with
> >   *
> >   * @uses_ext: whether the encoder uses the extended firmware messaging 
> > format
> > - * @has_lt_irq: whether the encoder uses the LT irq
> > + * @name: whether the encoder core is vp8
> >   * @min_birate: minimum supported encoding bitrate
> >   * @max_bitrate: maximum supported encoding bitrate
> >   * @capture_formats: array of supported capture formats
> >   * @num_capture_formats: number of entries in capture_formats
> >   * @output_formats: array of supported output formats
> >   * @num_output_formats: number of entries in output_formats
> > + * @core_id: stand for h264 or vp8 encode index
> >   */
> >  struct mtk_vcodec_enc_pdata {
> > enum mtk_chip chip;
> >  
> > bool uses_ext;
> > -   bool has_lt_irq;
> > +   const char *name;
> > unsigned long min_bitrate;
> > unsigned long max_bitrate;
> > const struct mtk_video_fmt *capture_formats;
> > size_t num_capture_formats;
> > const struct mtk_video_fmt *output_formats;
> > size_t num_output_formats;
> > +   int core_id;
> >  };
> >  
> >  /**
> > @@ -359,7 +361,6 @@ struct mtk_vcodec_enc_pdata {
> >   *
> >   * @dec_irq: decoder irq resource
> >   * @enc_irq: h264 encoder irq resource
> > - * @enc_lt_irq: vp8 encoder irq resource
> >   *
> >   * @dec_mutex: decoder hardware lock
> >   * @enc_mutex: encoder hardware lock.
> > @@ -395,7 +396,6 @@ struct mtk_vcodec_dev {
> >  
> > int dec_irq;
> > int enc_irq;
> > -   int enc_lt_irq;
> >  
> > struct mutex dec_mutex;
> > struct mutex enc_mutex;
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > index f0af78f..5301dca 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
> > @@ -9,6 +9,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  
> >  #include "mtk_vcodec_drv.h"
> >  #include "mtk_vcodec_enc.

Re: [PATCH 02/10] media: mtk-vcodec: add SCP firmware ops

2020-06-08 Thread Tiffany Lin
On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> From: Yunfei Dong 
> 
> Add support for communicating with the SCP firmware, which will be used
> by MT8183.
> 
> Signed-off-by: Yunfei Dong 
> [acourbot: refactor, cleanup and split]
> Co-developed-by: Alexandre Courbot 
> Signed-off-by: Alexandre Courbot 
> ---
>  drivers/media/platform/Kconfig|  2 +
>  .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  3 +
>  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  3 +
>  .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 56 +++
>  .../media/platform/mtk-vcodec/mtk_vcodec_fw.h |  2 +
>  5 files changed, 66 insertions(+)
> 
> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> index c57ee78fa99d..9b11dd6b1ef3 100644
> --- a/drivers/media/platform/Kconfig
> +++ b/drivers/media/platform/Kconfig
> @@ -256,6 +256,8 @@ config VIDEO_MEDIATEK_VCODEC
>   select VIDEOBUF2_DMA_CONTIG
>   select V4L2_MEM2MEM_DEV
>   select VIDEO_MEDIATEK_VPU
> + select MTK_SCP
> + default n
>   help
>   Mediatek video codec driver provides HW capability to
>   encode and decode in a range of video formats
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> index 4f07a5fcce7f..5b5765b98e57 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> @@ -225,6 +225,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>   if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
> _phandle)) {
>   fw_type = VPU;
> + } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp",
> +  _phandle)) {
> + fw_type = SCP;
>   } else {
>   mtk_v4l2_err("Could not get vdec IPI device");
>   return -ENODEV;
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> index 4340ea10afd0..42530cd01a30 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
> @@ -233,6 +233,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>   if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
> _phandle)) {
>   fw_type = VPU;
> + } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp",
> +  _phandle)) {
> + fw_type = SCP;
>   } else {
>   mtk_v4l2_err("Could not get venc IPI device");
>   return -ENODEV;
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
> index 967bb100a990..f2a62ea62fc6 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
> @@ -19,6 +19,7 @@ struct mtk_vcodec_fw {
>   enum mtk_vcodec_fw_type type;
>   const struct mtk_vcodec_fw_ops *ops;
>   struct platform_device *pdev;
> + struct mtk_scp *scp;
>  };
>  
>  static int mtk_vcodec_vpu_load_firmware(struct mtk_vcodec_fw *fw)
> @@ -71,6 +72,48 @@ static const struct mtk_vcodec_fw_ops mtk_vcodec_vpu_msg = 
> {
>   .ipi_send = mtk_vcodec_vpu_ipi_send,
>  };
>  
> +static int mtk_vcodec_scp_load_firmware(struct mtk_vcodec_fw *fw)
> +{
> + return rproc_boot(scp_get_rproc(fw->scp));


Does rproc_boot and scp_get_rproc depend on the other kernel module?
where are they defineded?

> +}
> +
> +static unsigned int mtk_vcodec_scp_get_vdec_capa(struct mtk_vcodec_fw *fw)
> +{
> + return scp_get_vdec_hw_capa(fw->scp);
> +}
> +
> +static unsigned int mtk_vcodec_scp_get_venc_capa(struct mtk_vcodec_fw *fw)
> +{
> + return scp_get_venc_hw_capa(fw->scp);
> +}
> +
> +static void *mtk_vcodec_vpu_scp_dm_addr(struct mtk_vcodec_fw *fw,
> + u32 dtcm_dmem_addr)
> +{
> + return scp_mapping_dm_addr(fw->scp, dtcm_dmem_addr);
> +}
> +
> +static int mtk_vcodec_scp_set_ipi_register(struct mtk_vcodec_fw *fw, int id,
> + mtk_vcodec_ipi_handler handler, const char *name, void *priv)
> +{
> + return scp_ipi_register(fw->scp, id, handler, priv);
> +}
> +
> +static int mtk_vcodec_scp_ipi_send(struct mtk_vcodec_fw *fw, int id, void 
> *buf,
> + unsigned int len, unsigned int wait)
> +{
> + return scp_ipi_send(fw->scp, id, buf, len, wait);
> +}
> +
> +static const struct mtk_vcodec_fw_ops mtk_vcodec_rproc_msg = {
> + .load_firmware = mtk_vcodec_scp_load_firmware,
> + .get_vdec_capa = mtk_vcodec_scp_get_vdec_capa,
> + .get_venc_capa = mtk_vcodec_scp_get_venc_capa,
> + .map_dm_addr = mtk_vcodec_vpu_scp_dm_addr,
> + .ipi_register = mtk_vcodec_scp_set_ipi_register,
> + .ipi_send = 

Re: [PATCH 01/10] media: mtk-vcodec: abstract firmware interface

2020-06-08 Thread Tiffany Lin
On Mon, 2020-06-08 at 18:16 +0800, Tiffany Lin wrote:
> On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> > From: Yunfei Dong 
> > 
> > MT8183's codec firwmare is run by a different remote processor from
> > MT8173. While the firmware interface is basically the same, the way to
> > invoke it differs. Abstract all firmware calls under a layer that will
> > allow us to handle both firmware types transparently.
> > 
> > Signed-off-by: Yunfei Dong 
> > [acourbot: refactor, cleanup and split]
> > Co-developed-by: Alexandre Courbot 
> > Signed-off-by: Alexandre Courbot 
> > [pihsun: fix error path and add mtk_vcodec_fw_release]
> > Signed-off-by: Pi-Hsun Shih 
> > ---
> >  drivers/media/platform/mtk-vcodec/Makefile|   4 +-
> >  .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  50 ++---
> >  .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   |   1 -
> >  .../platform/mtk-vcodec/mtk_vcodec_drv.h  |   5 +-
> >  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  47 ++---
> >  .../platform/mtk-vcodec/mtk_vcodec_enc_pm.c   |   2 -
> >  .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 172 ++
> >  .../media/platform/mtk-vcodec/mtk_vcodec_fw.h |  36 
> >  .../platform/mtk-vcodec/mtk_vcodec_util.c |   1 -
> >  .../platform/mtk-vcodec/vdec/vdec_h264_if.c   |   1 -
> >  .../platform/mtk-vcodec/vdec/vdec_vp8_if.c|   1 -
> >  .../platform/mtk-vcodec/vdec/vdec_vp9_if.c|   1 -
> >  .../media/platform/mtk-vcodec/vdec_drv_base.h |   2 -
> >  .../media/platform/mtk-vcodec/vdec_drv_if.c   |   1 -
> >  .../media/platform/mtk-vcodec/vdec_vpu_if.c   |  12 +-
> >  .../media/platform/mtk-vcodec/vdec_vpu_if.h   |  11 +-
> >  .../platform/mtk-vcodec/venc/venc_h264_if.c   |  15 +-
> >  .../platform/mtk-vcodec/venc/venc_vp8_if.c|   8 +-
> >  .../media/platform/mtk-vcodec/venc_drv_if.c   |   1 -
> >  .../media/platform/mtk-vcodec/venc_vpu_if.c   |  17 +-
> >  .../media/platform/mtk-vcodec/venc_vpu_if.h   |   5 +-
> >  21 files changed, 290 insertions(+), 103 deletions(-)
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
> >  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h
> > 
> > diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
> > b/drivers/media/platform/mtk-vcodec/Makefile
> > index 37b94b555fa1..b8636119ed0a 100644
> > --- a/drivers/media/platform/mtk-vcodec/Makefile
> > +++ b/drivers/media/platform/mtk-vcodec/Makefile
> > @@ -12,7 +12,7 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
> > vdec_vpu_if.o \
> > mtk_vcodec_dec.o \
> > mtk_vcodec_dec_pm.o \
> > -
> > +   mtk_vcodec_fw.o
> >  
> >  mtk-vcodec-enc-y := venc/venc_vp8_if.o \
> > venc/venc_h264_if.o \
> > @@ -25,5 +25,3 @@ mtk-vcodec-enc-y := venc/venc_vp8_if.o \
> >  
> >  mtk-vcodec-common-y := mtk_vcodec_intr.o \
> > mtk_vcodec_util.o\
> > -
> > -ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> > index 97a1b6664c20..4f07a5fcce7f 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> > @@ -20,7 +20,7 @@
> >  #include "mtk_vcodec_dec_pm.h"
> >  #include "mtk_vcodec_intr.h"
> >  #include "mtk_vcodec_util.h"
> > -#include "mtk_vpu.h"
> > +#include "mtk_vcodec_fw.h"
> >  
> >  #define VDEC_HW_ACTIVE 0x10
> >  #define VDEC_IRQ_CFG   0x11
> > @@ -77,22 +77,6 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, 
> > void *priv)
> > return IRQ_HANDLED;
> >  }
> >  
> > -static void mtk_vcodec_dec_reset_handler(void *priv)
> > -{
> > -   struct mtk_vcodec_dev *dev = priv;
> > -   struct mtk_vcodec_ctx *ctx;
> > -
> > -   mtk_v4l2_err("Watchdog timeout!!");
> > -
> > -   mutex_lock(>dev_mutex);
> > -   list_for_each_entry(ctx, >ctx_list, list) {
> > -   ctx->state = MTK_STATE_ABORT;
> > -   mtk_v4l2_debug(0, "[%d] Change to state MTK_STATE_ERROR",
> > -   ctx->id);
> > -   }
> > -   mutex_unlock(>dev_mutex);
> > -}
> > -
> 
> After using abstract firmware interface, how does driver process
> watchdog timeout?

I found it move to mtk_vcodec_fw.c and rename to
mtk_vcodec_rese

Re: [PATCH 01/10] media: mtk-vcodec: abstract firmware interface

2020-06-08 Thread Tiffany Lin
On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> From: Yunfei Dong 
> 
> MT8183's codec firwmare is run by a different remote processor from
> MT8173. While the firmware interface is basically the same, the way to
> invoke it differs. Abstract all firmware calls under a layer that will
> allow us to handle both firmware types transparently.
> 
> Signed-off-by: Yunfei Dong 
> [acourbot: refactor, cleanup and split]
> Co-developed-by: Alexandre Courbot 
> Signed-off-by: Alexandre Courbot 
> [pihsun: fix error path and add mtk_vcodec_fw_release]
> Signed-off-by: Pi-Hsun Shih 
> ---
>  drivers/media/platform/mtk-vcodec/Makefile|   4 +-
>  .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  50 ++---
>  .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   |   1 -
>  .../platform/mtk-vcodec/mtk_vcodec_drv.h  |   5 +-
>  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  47 ++---
>  .../platform/mtk-vcodec/mtk_vcodec_enc_pm.c   |   2 -
>  .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 172 ++
>  .../media/platform/mtk-vcodec/mtk_vcodec_fw.h |  36 
>  .../platform/mtk-vcodec/mtk_vcodec_util.c |   1 -
>  .../platform/mtk-vcodec/vdec/vdec_h264_if.c   |   1 -
>  .../platform/mtk-vcodec/vdec/vdec_vp8_if.c|   1 -
>  .../platform/mtk-vcodec/vdec/vdec_vp9_if.c|   1 -
>  .../media/platform/mtk-vcodec/vdec_drv_base.h |   2 -
>  .../media/platform/mtk-vcodec/vdec_drv_if.c   |   1 -
>  .../media/platform/mtk-vcodec/vdec_vpu_if.c   |  12 +-
>  .../media/platform/mtk-vcodec/vdec_vpu_if.h   |  11 +-
>  .../platform/mtk-vcodec/venc/venc_h264_if.c   |  15 +-
>  .../platform/mtk-vcodec/venc/venc_vp8_if.c|   8 +-
>  .../media/platform/mtk-vcodec/venc_drv_if.c   |   1 -
>  .../media/platform/mtk-vcodec/venc_vpu_if.c   |  17 +-
>  .../media/platform/mtk-vcodec/venc_vpu_if.h   |   5 +-
>  21 files changed, 290 insertions(+), 103 deletions(-)
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h
> 
> diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
> b/drivers/media/platform/mtk-vcodec/Makefile
> index 37b94b555fa1..b8636119ed0a 100644
> --- a/drivers/media/platform/mtk-vcodec/Makefile
> +++ b/drivers/media/platform/mtk-vcodec/Makefile
> @@ -12,7 +12,7 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
>   vdec_vpu_if.o \
>   mtk_vcodec_dec.o \
>   mtk_vcodec_dec_pm.o \
> -
> + mtk_vcodec_fw.o
>  
>  mtk-vcodec-enc-y := venc/venc_vp8_if.o \
>   venc/venc_h264_if.o \
> @@ -25,5 +25,3 @@ mtk-vcodec-enc-y := venc/venc_vp8_if.o \
>  
>  mtk-vcodec-common-y := mtk_vcodec_intr.o \
>   mtk_vcodec_util.o\
> -
> -ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> index 97a1b6664c20..4f07a5fcce7f 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> @@ -20,7 +20,7 @@
>  #include "mtk_vcodec_dec_pm.h"
>  #include "mtk_vcodec_intr.h"
>  #include "mtk_vcodec_util.h"
> -#include "mtk_vpu.h"
> +#include "mtk_vcodec_fw.h"
>  
>  #define VDEC_HW_ACTIVE   0x10
>  #define VDEC_IRQ_CFG 0x11
> @@ -77,22 +77,6 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, 
> void *priv)
>   return IRQ_HANDLED;
>  }
>  
> -static void mtk_vcodec_dec_reset_handler(void *priv)
> -{
> - struct mtk_vcodec_dev *dev = priv;
> - struct mtk_vcodec_ctx *ctx;
> -
> - mtk_v4l2_err("Watchdog timeout!!");
> -
> - mutex_lock(>dev_mutex);
> - list_for_each_entry(ctx, >ctx_list, list) {
> - ctx->state = MTK_STATE_ABORT;
> - mtk_v4l2_debug(0, "[%d] Change to state MTK_STATE_ERROR",
> - ctx->id);
> - }
> - mutex_unlock(>dev_mutex);
> -}
> -

After using abstract firmware interface, how does driver process
watchdog timeout?

>  static int fops_vcodec_open(struct file *file)
>  {
>   struct mtk_vcodec_dev *dev = video_drvdata(file);
> @@ -144,21 +128,20 @@ static int fops_vcodec_open(struct file *file)
>   if (v4l2_fh_is_singular(>fh)) {
>   mtk_vcodec_dec_pw_on(>pm);
>   /*
> -  * vpu_load_firmware checks if it was loaded already and
> -  * does nothing in that case
> +  * Does nothing if firmware was already loaded.
>*/
> - ret = vpu_load_firmware(dev->vpu_plat_dev);
> + ret = mtk_vcodec_fw_load_firmware(dev->fw_handler);
>   if (ret < 0) {
>   /*
>* Return 0 if downloading firmware successfully,
>* otherwise it is failed
>*/
> - mtk_v4l2_err("vpu_load_firmware failed!");
> + mtk_v4l2_err("failed to load firmware!");
>  

Re: [PATCH 01/10] media: mtk-vcodec: abstract firmware interface

2020-06-08 Thread Tiffany Lin
On Wed, 2020-05-20 at 17:27 +0900, Alexandre Courbot wrote:
> From: Yunfei Dong 
> 
> MT8183's codec firwmare is run by a different remote processor from
> MT8173. While the firmware interface is basically the same, the way to
> invoke it differs. Abstract all firmware calls under a layer that will
> allow us to handle both firmware types transparently.
> 
> Signed-off-by: Yunfei Dong 
> [acourbot: refactor, cleanup and split]
> Co-developed-by: Alexandre Courbot 
> Signed-off-by: Alexandre Courbot 
> [pihsun: fix error path and add mtk_vcodec_fw_release]
> Signed-off-by: Pi-Hsun Shih 
> ---
>  drivers/media/platform/mtk-vcodec/Makefile|   4 +-
>  .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  50 ++---
>  .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   |   1 -
>  .../platform/mtk-vcodec/mtk_vcodec_drv.h  |   5 +-
>  .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  47 ++---
>  .../platform/mtk-vcodec/mtk_vcodec_enc_pm.c   |   2 -
>  .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 172 ++
>  .../media/platform/mtk-vcodec/mtk_vcodec_fw.h |  36 
>  .../platform/mtk-vcodec/mtk_vcodec_util.c |   1 -
>  .../platform/mtk-vcodec/vdec/vdec_h264_if.c   |   1 -
>  .../platform/mtk-vcodec/vdec/vdec_vp8_if.c|   1 -
>  .../platform/mtk-vcodec/vdec/vdec_vp9_if.c|   1 -
>  .../media/platform/mtk-vcodec/vdec_drv_base.h |   2 -
>  .../media/platform/mtk-vcodec/vdec_drv_if.c   |   1 -
>  .../media/platform/mtk-vcodec/vdec_vpu_if.c   |  12 +-
>  .../media/platform/mtk-vcodec/vdec_vpu_if.h   |  11 +-
>  .../platform/mtk-vcodec/venc/venc_h264_if.c   |  15 +-
>  .../platform/mtk-vcodec/venc/venc_vp8_if.c|   8 +-
>  .../media/platform/mtk-vcodec/venc_drv_if.c   |   1 -
>  .../media/platform/mtk-vcodec/venc_vpu_if.c   |  17 +-
>  .../media/platform/mtk-vcodec/venc_vpu_if.h   |   5 +-
>  21 files changed, 290 insertions(+), 103 deletions(-)
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
>  create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h
> 
> diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
> b/drivers/media/platform/mtk-vcodec/Makefile
> index 37b94b555fa1..b8636119ed0a 100644
> --- a/drivers/media/platform/mtk-vcodec/Makefile
> +++ b/drivers/media/platform/mtk-vcodec/Makefile
> @@ -12,7 +12,7 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
>   vdec_vpu_if.o \
>   mtk_vcodec_dec.o \
>   mtk_vcodec_dec_pm.o \
> -
> + mtk_vcodec_fw.o
>  
>  mtk-vcodec-enc-y := venc/venc_vp8_if.o \
>   venc/venc_h264_if.o \
> @@ -25,5 +25,3 @@ mtk-vcodec-enc-y := venc/venc_vp8_if.o \
>  
>  mtk-vcodec-common-y := mtk_vcodec_intr.o \
>   mtk_vcodec_util.o\
> -
> -ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> index 97a1b6664c20..4f07a5fcce7f 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> @@ -20,7 +20,7 @@
>  #include "mtk_vcodec_dec_pm.h"
>  #include "mtk_vcodec_intr.h"
>  #include "mtk_vcodec_util.h"
> -#include "mtk_vpu.h"
> +#include "mtk_vcodec_fw.h"
>  
>  #define VDEC_HW_ACTIVE   0x10
>  #define VDEC_IRQ_CFG 0x11
> @@ -77,22 +77,6 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, 
> void *priv)
>   return IRQ_HANDLED;
>  }
>  
> -static void mtk_vcodec_dec_reset_handler(void *priv)
> -{
> - struct mtk_vcodec_dev *dev = priv;
> - struct mtk_vcodec_ctx *ctx;
> -
> - mtk_v4l2_err("Watchdog timeout!!");
> -
> - mutex_lock(>dev_mutex);
> - list_for_each_entry(ctx, >ctx_list, list) {
> - ctx->state = MTK_STATE_ABORT;
> - mtk_v4l2_debug(0, "[%d] Change to state MTK_STATE_ERROR",
> - ctx->id);
> - }
> - mutex_unlock(>dev_mutex);
> -}
> -

After adding abstract firmware interface,
how does driver process watchdog timeout?


>  static int fops_vcodec_open(struct file *file)
>  {
>   struct mtk_vcodec_dev *dev = video_drvdata(file);
> @@ -144,21 +128,20 @@ static int fops_vcodec_open(struct file *file)
>   if (v4l2_fh_is_singular(>fh)) {
>   mtk_vcodec_dec_pw_on(>pm);
>   /*
> -  * vpu_load_firmware checks if it was loaded already and
> -  * does nothing in that case
> +  * Does nothing if firmware was already loaded.
>*/
> - ret = vpu_load_firmware(dev->vpu_plat_dev);
> + ret = mtk_vcodec_fw_load_firmware(dev->fw_handler);
>   if (ret < 0) {
>   /*
>* Return 0 if downloading firmware successfully,
>* otherwise it is failed
>*/
> - mtk_v4l2_err("vpu_load_firmware failed!");
> + mtk_v4l2_err("failed to load firmware!");
>

Re: [PATCH v2] [media] mtk-vcodec: Show mtk driver error without DEBUG definition

2017-06-19 Thread Tiffany Lin
On Tue, 2017-05-30 at 18:53 +0900, Hirokazu Honda wrote:
> A driver error message is shown without DEBUG definition
> to find an error and debug easily.
> 
> Signed-off-by: Hirokazu Honda <hi...@chromium.org>
Acked-by: Tiffany Lin <tiffany@mediatek.com>

> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 20 +---
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> index 237e144c194f..06c254f5c171 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> @@ -32,6 +32,15 @@ extern int mtk_v4l2_dbg_level;
>  extern bool mtk_vcodec_dbg;
>  
> 
> +#define mtk_v4l2_err(fmt, args...)\
> + pr_err("[MTK_V4L2][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
> +##args)
> +
> +#define mtk_vcodec_err(h, fmt, args...)  
> \
> + pr_err("[MTK_VCODEC][ERROR][%d]: %s() " fmt "\n",   \
> +((struct mtk_vcodec_ctx *)h->ctx)->id, __func__, ##args)
> +
> +
>  #if defined(DEBUG)
>  
>  #define mtk_v4l2_debug(level, fmt, args...)   \
> @@ -41,11 +50,6 @@ extern bool mtk_vcodec_dbg;
>   level, __func__, __LINE__, ##args);  \
>   } while (0)
>  
> -#define mtk_v4l2_err(fmt, args...)\
> - pr_err("[MTK_V4L2][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
> -##args)
> -
> -
>  #define mtk_v4l2_debug_enter()  mtk_v4l2_debug(3, "+")
>  #define mtk_v4l2_debug_leave()  mtk_v4l2_debug(3, "-")
>  
> @@ -57,22 +61,16 @@ extern bool mtk_vcodec_dbg;
>   __func__, ##args);  \
>   } while (0)
>  
> -#define mtk_vcodec_err(h, fmt, args...)  
> \
> - pr_err("[MTK_VCODEC][ERROR][%d]: %s() " fmt "\n",   \
> -((struct mtk_vcodec_ctx *)h->ctx)->id, __func__, ##args)
> -
>  #define mtk_vcodec_debug_enter(h)  mtk_vcodec_debug(h, "+")
>  #define mtk_vcodec_debug_leave(h)  mtk_vcodec_debug(h, "-")
>  
>  #else
>  
>  #define mtk_v4l2_debug(level, fmt, args...) {}
> -#define mtk_v4l2_err(fmt, args...) {}
>  #define mtk_v4l2_debug_enter() {}
>  #define mtk_v4l2_debug_leave() {}
>  
>  #define mtk_vcodec_debug(h, fmt, args...) {}
> -#define mtk_vcodec_err(h, fmt, args...) {}
>  #define mtk_vcodec_debug_enter(h) {}
>  #define mtk_vcodec_debug_leave(h) {}
>  




Re: [PATCH v2] [media] mtk-vcodec: Show mtk driver error without DEBUG definition

2017-06-19 Thread Tiffany Lin
On Tue, 2017-05-30 at 18:53 +0900, Hirokazu Honda wrote:
> A driver error message is shown without DEBUG definition
> to find an error and debug easily.
> 
> Signed-off-by: Hirokazu Honda 
Acked-by: Tiffany Lin 

> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 20 +---
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> index 237e144c194f..06c254f5c171 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> @@ -32,6 +32,15 @@ extern int mtk_v4l2_dbg_level;
>  extern bool mtk_vcodec_dbg;
>  
> 
> +#define mtk_v4l2_err(fmt, args...)\
> + pr_err("[MTK_V4L2][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
> +##args)
> +
> +#define mtk_vcodec_err(h, fmt, args...)  
> \
> + pr_err("[MTK_VCODEC][ERROR][%d]: %s() " fmt "\n",   \
> +((struct mtk_vcodec_ctx *)h->ctx)->id, __func__, ##args)
> +
> +
>  #if defined(DEBUG)
>  
>  #define mtk_v4l2_debug(level, fmt, args...)   \
> @@ -41,11 +50,6 @@ extern bool mtk_vcodec_dbg;
>   level, __func__, __LINE__, ##args);  \
>   } while (0)
>  
> -#define mtk_v4l2_err(fmt, args...)\
> - pr_err("[MTK_V4L2][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
> -##args)
> -
> -
>  #define mtk_v4l2_debug_enter()  mtk_v4l2_debug(3, "+")
>  #define mtk_v4l2_debug_leave()  mtk_v4l2_debug(3, "-")
>  
> @@ -57,22 +61,16 @@ extern bool mtk_vcodec_dbg;
>   __func__, ##args);  \
>   } while (0)
>  
> -#define mtk_vcodec_err(h, fmt, args...)  
> \
> - pr_err("[MTK_VCODEC][ERROR][%d]: %s() " fmt "\n",   \
> -((struct mtk_vcodec_ctx *)h->ctx)->id, __func__, ##args)
> -
>  #define mtk_vcodec_debug_enter(h)  mtk_vcodec_debug(h, "+")
>  #define mtk_vcodec_debug_leave(h)  mtk_vcodec_debug(h, "-")
>  
>  #else
>  
>  #define mtk_v4l2_debug(level, fmt, args...) {}
> -#define mtk_v4l2_err(fmt, args...) {}
>  #define mtk_v4l2_debug_enter() {}
>  #define mtk_v4l2_debug_leave() {}
>  
>  #define mtk_vcodec_debug(h, fmt, args...) {}
> -#define mtk_vcodec_err(h, fmt, args...) {}
>  #define mtk_vcodec_debug_enter(h) {}
>  #define mtk_vcodec_debug_leave(h) {}
>  




Re: [PATCH] media: mtk-vcodec: remove informative log

2017-04-21 Thread Tiffany Lin
On Wed, 2017-04-19 at 07:56 -0300, Mauro Carvalho Chehab wrote:
> Em Wed, 5 Apr 2017 19:09:59 +0800
> Tiffany Lin <tiffany@mediatek.com> escreveu:
> 
> > On Wed, 2017-04-05 at 18:54 +0800, Minghsiu Tsai wrote:
> > > Driver is stable. Remove DEBUG definition from driver.
> > > 
> > > There are debug message in /var/log/messages if DEBUG is defined,
> > > such as:
> > > [MTK_V4L2] level=0 fops_vcodec_open(),170: decoder capability 0
> > > [MTK_V4L2] level=0 fops_vcodec_open(),177: 1600.vcodec decoder [0]
> > > [MTK_V4L2] level=0 fops_vcodec_release(),200: [0] decoder
> > > 
> > > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>  
> > Acked-by:Tiffany Lin <tiffany@mediatek.com>
> > 
> > > ---
> > >  drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 1 -
> > >  1 file changed, 1 deletion(-)
> > > 
> > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h 
> > > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> > > index 7d55975..1248083 100644
> > > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> > > @@ -31,7 +31,6 @@ struct mtk_vcodec_mem {
> > >  extern int mtk_v4l2_dbg_level;
> > >  extern bool mtk_vcodec_dbg;
> > >  
> > > -#define DEBUG1
> > >  
> > >  #if defined(DEBUG)
> > >
> 
> After this patch, building the Kernel with W=1 now shows warnings:
> 
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c: In function 
> 'mtk_vcodec_dec_pw_on':
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c:114:51: warning: 
> suggest braces around empty body in an 'if' statement [-Wempty-body]
>mtk_v4l2_err("pm_runtime_get_sync fail %d", ret);
>^
> 
> I wrote a patch fixing it, as this is really a trivial issue.
> 
> Yet, after that, this one still remains:
> 
> 
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c: In function 
> 'mtk_vdec_pic_info_update':
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c:284:6: warning: variable 
> 'ret' set but not used [-Wunused-but-set-variable]
>   int ret;
>   ^~~
> 


> 
> Shouldn't be mtk_vdec_pic_info_update() returning an error code?
> 
> 
> Also, IMHO, at least errors should be shown at dmesg.
> 
Got it. We will upstream patch to fix warning and add dmesg when error.


best regards,
Tiffany

> Thanks,
> Mauro




Re: [PATCH] media: mtk-vcodec: remove informative log

2017-04-21 Thread Tiffany Lin
On Wed, 2017-04-19 at 07:56 -0300, Mauro Carvalho Chehab wrote:
> Em Wed, 5 Apr 2017 19:09:59 +0800
> Tiffany Lin  escreveu:
> 
> > On Wed, 2017-04-05 at 18:54 +0800, Minghsiu Tsai wrote:
> > > Driver is stable. Remove DEBUG definition from driver.
> > > 
> > > There are debug message in /var/log/messages if DEBUG is defined,
> > > such as:
> > > [MTK_V4L2] level=0 fops_vcodec_open(),170: decoder capability 0
> > > [MTK_V4L2] level=0 fops_vcodec_open(),177: 1600.vcodec decoder [0]
> > > [MTK_V4L2] level=0 fops_vcodec_release(),200: [0] decoder
> > > 
> > > Signed-off-by: Minghsiu Tsai   
> > Acked-by:Tiffany Lin 
> > 
> > > ---
> > >  drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 1 -
> > >  1 file changed, 1 deletion(-)
> > > 
> > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h 
> > > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> > > index 7d55975..1248083 100644
> > > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> > > @@ -31,7 +31,6 @@ struct mtk_vcodec_mem {
> > >  extern int mtk_v4l2_dbg_level;
> > >  extern bool mtk_vcodec_dbg;
> > >  
> > > -#define DEBUG1
> > >  
> > >  #if defined(DEBUG)
> > >
> 
> After this patch, building the Kernel with W=1 now shows warnings:
> 
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c: In function 
> 'mtk_vcodec_dec_pw_on':
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c:114:51: warning: 
> suggest braces around empty body in an 'if' statement [-Wempty-body]
>mtk_v4l2_err("pm_runtime_get_sync fail %d", ret);
>^
> 
> I wrote a patch fixing it, as this is really a trivial issue.
> 
> Yet, after that, this one still remains:
> 
> 
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c: In function 
> 'mtk_vdec_pic_info_update':
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c:284:6: warning: variable 
> 'ret' set but not used [-Wunused-but-set-variable]
>   int ret;
>   ^~~
> 


> 
> Shouldn't be mtk_vdec_pic_info_update() returning an error code?
> 
> 
> Also, IMHO, at least errors should be shown at dmesg.
> 
Got it. We will upstream patch to fix warning and add dmesg when error.


best regards,
Tiffany

> Thanks,
> Mauro




Re: [PATCH] media: mtk-vcodec: remove informative log

2017-04-05 Thread Tiffany Lin
On Wed, 2017-04-05 at 18:54 +0800, Minghsiu Tsai wrote:
> Driver is stable. Remove DEBUG definition from driver.
> 
> There are debug message in /var/log/messages if DEBUG is defined,
> such as:
> [MTK_V4L2] level=0 fops_vcodec_open(),170: decoder capability 0
> [MTK_V4L2] level=0 fops_vcodec_open(),177: 1600.vcodec decoder [0]
> [MTK_V4L2] level=0 fops_vcodec_release(),200: [0] decoder
> 
> Signed-off-by: Minghsiu Tsai 
Acked-by:Tiffany Lin 

> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> index 7d55975..1248083 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> @@ -31,7 +31,6 @@ struct mtk_vcodec_mem {
>  extern int mtk_v4l2_dbg_level;
>  extern bool mtk_vcodec_dbg;
>  
> -#define DEBUG1
>  
>  #if defined(DEBUG)
>  




Re: [PATCH] media: mtk-vcodec: remove informative log

2017-04-05 Thread Tiffany Lin
On Wed, 2017-04-05 at 18:54 +0800, Minghsiu Tsai wrote:
> Driver is stable. Remove DEBUG definition from driver.
> 
> There are debug message in /var/log/messages if DEBUG is defined,
> such as:
> [MTK_V4L2] level=0 fops_vcodec_open(),170: decoder capability 0
> [MTK_V4L2] level=0 fops_vcodec_open(),177: 1600.vcodec decoder [0]
> [MTK_V4L2] level=0 fops_vcodec_release(),200: [0] decoder
> 
> Signed-off-by: Minghsiu Tsai 
Acked-by:Tiffany Lin 

> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> index 7d55975..1248083 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
> @@ -31,7 +31,6 @@ struct mtk_vcodec_mem {
>  extern int mtk_v4l2_dbg_level;
>  extern bool mtk_vcodec_dbg;
>  
> -#define DEBUG1
>  
>  #if defined(DEBUG)
>  




Re: [PATCH v3 1/1] mtk-vcodec: check the vp9 decoder buffer index from VPU.

2017-03-07 Thread Tiffany Lin
On Wed, 2017-03-08 at 11:40 +0800, Wu-Cheng Li wrote:
> From: Wu-Cheng Li <wuchen...@google.com>
> 
> VPU firmware has a bug and may return invalid buffer index for
> some vp9 videos. Check the buffer indexes before accessing the
> buffer.
> 

Acked-by: Tiffany Lin <tiffany@mediatek.com>

> Signed-off-by: Wu-Cheng Li <wuchen...@chromium.org>
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 33 
> +-
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |  2 ++
>  .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   | 26 +
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  2 ++
>  4 files changed, 56 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> index 502877a4b1df..a60b538686ea 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> @@ -420,6 +420,11 @@ static void mtk_vdec_worker(struct work_struct *work)
>   dst_buf->index,
>   ret, res_chg);
>   src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> + if (ret == -EIO) {
> + mutex_lock(>lock);
> + src_buf_info->error = true;
> + mutex_unlock(>lock);
> + }
>   v4l2_m2m_buf_done(_buf_info->vb, VB2_BUF_STATE_ERROR);
>   } else if (res_chg == false) {
>   /*
> @@ -1170,8 +1175,16 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer 
> *vb)
>*/
>  
>   src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
> - VB2_BUF_STATE_DONE);
> + if (ret == -EIO) {
> + mtk_v4l2_err("[%d] Unrecoverable error in 
> vdec_if_decode.",
> + ctx->id);
> + ctx->state = MTK_STATE_ABORT;
> + v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
> + VB2_BUF_STATE_ERROR);
> + } else {
> + v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
> + VB2_BUF_STATE_DONE);
> + }
>   mtk_v4l2_debug(ret ? 0 : 1,
>  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
> fail=%d, res_chg=%d",
>  ctx->id, src_buf->index,
> @@ -1216,16 +1229,22 @@ static void vb2ops_vdec_buf_finish(struct vb2_buffer 
> *vb)
>   struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
>   struct vb2_v4l2_buffer *vb2_v4l2;
>   struct mtk_video_dec_buf *buf;
> -
> - if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> - return;
> + bool buf_error;
>  
>   vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf);
>   buf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);
>   mutex_lock(>lock);
> - buf->queued_in_v4l2 = false;
> - buf->queued_in_vb2 = false;
> + if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
> + buf->queued_in_v4l2 = false;
> + buf->queued_in_vb2 = false;
> + }
> + buf_error = buf->error;
>   mutex_unlock(>lock);
> +
> + if (buf_error) {
> + mtk_v4l2_err("Unrecoverable error on buffer.");
> + ctx->state = MTK_STATE_ABORT;
> + }
>  }
>  
>  static int vb2ops_vdec_buf_init(struct vb2_buffer *vb)
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> index 362f5a85762e..dc4fc1df63c5 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> @@ -50,6 +50,7 @@ struct vdec_fb {
>   * @queued_in_v4l2:  Capture buffer is in v4l2 driver, but not in vb2
>   *   queue yet
>   * @lastframe:   Intput buffer is last buffer - EOS
> + * @error:   An unrecoverable error occurs on this buffer.
>   * @frame_buffer:Decode status, and buffer information of Capture buffer
>   *
>   * Note : These status information help us track and debug buffer state
> @@ -63,6 +64,7 @@ struct mtk_video_dec_buf {
>   boolqueued_in_vb2;
>   boolqueued_in_v4l2;
>   boollastframe;
> + boolerror;
>   struct vdec_fb  frame_buffer;
>  };
>  
> 

Re: [PATCH v3 1/1] mtk-vcodec: check the vp9 decoder buffer index from VPU.

2017-03-07 Thread Tiffany Lin
On Wed, 2017-03-08 at 11:40 +0800, Wu-Cheng Li wrote:
> From: Wu-Cheng Li 
> 
> VPU firmware has a bug and may return invalid buffer index for
> some vp9 videos. Check the buffer indexes before accessing the
> buffer.
> 

Acked-by: Tiffany Lin 

> Signed-off-by: Wu-Cheng Li 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 33 
> +-
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |  2 ++
>  .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   | 26 +
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  2 ++
>  4 files changed, 56 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> index 502877a4b1df..a60b538686ea 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> @@ -420,6 +420,11 @@ static void mtk_vdec_worker(struct work_struct *work)
>   dst_buf->index,
>   ret, res_chg);
>   src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> + if (ret == -EIO) {
> + mutex_lock(>lock);
> + src_buf_info->error = true;
> + mutex_unlock(>lock);
> + }
>   v4l2_m2m_buf_done(_buf_info->vb, VB2_BUF_STATE_ERROR);
>   } else if (res_chg == false) {
>   /*
> @@ -1170,8 +1175,16 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer 
> *vb)
>*/
>  
>   src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
> - VB2_BUF_STATE_DONE);
> + if (ret == -EIO) {
> + mtk_v4l2_err("[%d] Unrecoverable error in 
> vdec_if_decode.",
> + ctx->id);
> + ctx->state = MTK_STATE_ABORT;
> + v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
> + VB2_BUF_STATE_ERROR);
> + } else {
> + v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
> + VB2_BUF_STATE_DONE);
> + }
>   mtk_v4l2_debug(ret ? 0 : 1,
>  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
> fail=%d, res_chg=%d",
>  ctx->id, src_buf->index,
> @@ -1216,16 +1229,22 @@ static void vb2ops_vdec_buf_finish(struct vb2_buffer 
> *vb)
>   struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
>   struct vb2_v4l2_buffer *vb2_v4l2;
>   struct mtk_video_dec_buf *buf;
> -
> - if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> - return;
> + bool buf_error;
>  
>   vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf);
>   buf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);
>   mutex_lock(>lock);
> - buf->queued_in_v4l2 = false;
> - buf->queued_in_vb2 = false;
> + if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
> + buf->queued_in_v4l2 = false;
> + buf->queued_in_vb2 = false;
> + }
> + buf_error = buf->error;
>   mutex_unlock(>lock);
> +
> + if (buf_error) {
> + mtk_v4l2_err("Unrecoverable error on buffer.");
> + ctx->state = MTK_STATE_ABORT;
> + }
>  }
>  
>  static int vb2ops_vdec_buf_init(struct vb2_buffer *vb)
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> index 362f5a85762e..dc4fc1df63c5 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> @@ -50,6 +50,7 @@ struct vdec_fb {
>   * @queued_in_v4l2:  Capture buffer is in v4l2 driver, but not in vb2
>   *   queue yet
>   * @lastframe:   Intput buffer is last buffer - EOS
> + * @error:   An unrecoverable error occurs on this buffer.
>   * @frame_buffer:Decode status, and buffer information of Capture buffer
>   *
>   * Note : These status information help us track and debug buffer state
> @@ -63,6 +64,7 @@ struct mtk_video_dec_buf {
>   boolqueued_in_vb2;
>   boolqueued_in_v4l2;
>   boollastframe;
> + boolerror;
>   struct vdec_fb  frame_buffer;
>  };
>  
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
> b/drivers/media/platform

Re: [PATCH v2 1/1] mtk-vcodec: check the vp9 decoder buffer index from VPU.

2017-03-07 Thread Tiffany Lin
On Tue, 2017-03-07 at 22:42 +0800, Wu-Cheng Li wrote:
> From: Wu-Cheng Li 
> 
> VPU firmware has a bug and may return invalid buffer index for
> some vp9 videos. Check the buffer indexes before accessing the
> buffer.
> 
> Signed-off-by: Wu-Cheng Li 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 23 ++-
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |  2 ++
>  .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   | 26 
> ++
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  2 ++
>  4 files changed, 48 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> index 502877a4b1df..8a9285a84d47 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> @@ -420,6 +420,11 @@ static void mtk_vdec_worker(struct work_struct *work)
>   dst_buf->index,
>   ret, res_chg);
>   src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> + if (ret == -EIO) {
> + mutex_lock(>lock);
> + src_buf_info->error = true;
> + mutex_unlock(>lock);
> + }
>   v4l2_m2m_buf_done(_buf_info->vb, VB2_BUF_STATE_ERROR);
>   } else if (res_chg == false) {
>   /*
> @@ -1176,6 +1181,11 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer 
> *vb)
>  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
> fail=%d, res_chg=%d",
>  ctx->id, src_buf->index,
>  src_mem.size, ret, res_chg);
> + if (ret == -EIO) {
> + mtk_v4l2_err("[%d] Unrecoverable error in 
> vdec_if_decode.",
> + ctx->id);
> + ctx->state = MTK_STATE_ABORT;
> + }
Should we set buf status to VB2_BUF_STATE_ERROR in this case?

>   return;
>   }
>  
> @@ -1217,14 +1227,17 @@ static void vb2ops_vdec_buf_finish(struct vb2_buffer 
> *vb)
>   struct vb2_v4l2_buffer *vb2_v4l2;
>   struct mtk_video_dec_buf *buf;
>  
> - if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> - return;
> -
>   vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf);
>   buf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);
>   mutex_lock(>lock);
> - buf->queued_in_v4l2 = false;
> - buf->queued_in_vb2 = false;
> + if (buf->error) {
> + mtk_v4l2_err("Unrecoverable error on buffer.");
Remove mtk_v4l2_err out of mutex_lock/mutex_unlock?


best regards,
Tiffany
> + ctx->state = MTK_STATE_ABORT;
> + }
> + if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
> + buf->queued_in_v4l2 = false;
> + buf->queued_in_vb2 = false;
> + }
>   mutex_unlock(>lock);
>  }
>  
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> index 362f5a85762e..dc4fc1df63c5 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> @@ -50,6 +50,7 @@ struct vdec_fb {
>   * @queued_in_v4l2:  Capture buffer is in v4l2 driver, but not in vb2
>   *   queue yet
>   * @lastframe:   Intput buffer is last buffer - EOS
> + * @error:   An unrecoverable error occurs on this buffer.
>   * @frame_buffer:Decode status, and buffer information of Capture buffer
>   *
>   * Note : These status information help us track and debug buffer state
> @@ -63,6 +64,7 @@ struct mtk_video_dec_buf {
>   boolqueued_in_vb2;
>   boolqueued_in_v4l2;
>   boollastframe;
> + boolerror;
>   struct vdec_fb  frame_buffer;
>  };
>  
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
> b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> index e91a3b425b0c..5539b1853f16 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> @@ -718,6 +718,26 @@ static void get_free_fb(struct vdec_vp9_inst *inst, 
> struct vdec_fb **out_fb)
>   *out_fb = fb;
>  }
>  
> +static int validate_vsi_array_indexes(struct vdec_vp9_inst *inst,
> + struct vdec_vp9_vsi *vsi) {
> + if (vsi->sf_frm_idx >= VP9_MAX_FRM_BUF_NUM - 1) {
> + mtk_vcodec_err(inst, "Invalid vsi->sf_frm_idx=%u.",
> + vsi->sf_frm_idx);
> + return -EIO;
> + }
> + if (vsi->frm_to_show_idx >= VP9_MAX_FRM_BUF_NUM) {
> + mtk_vcodec_err(inst, "Invalid vsi->frm_to_show_idx=%u.",
> + vsi->frm_to_show_idx);
> + return -EIO;
> + }
> + if (vsi->new_fb_idx 

Re: [PATCH v2 1/1] mtk-vcodec: check the vp9 decoder buffer index from VPU.

2017-03-07 Thread Tiffany Lin
On Tue, 2017-03-07 at 22:42 +0800, Wu-Cheng Li wrote:
> From: Wu-Cheng Li 
> 
> VPU firmware has a bug and may return invalid buffer index for
> some vp9 videos. Check the buffer indexes before accessing the
> buffer.
> 
> Signed-off-by: Wu-Cheng Li 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 23 ++-
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |  2 ++
>  .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   | 26 
> ++
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  2 ++
>  4 files changed, 48 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> index 502877a4b1df..8a9285a84d47 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> @@ -420,6 +420,11 @@ static void mtk_vdec_worker(struct work_struct *work)
>   dst_buf->index,
>   ret, res_chg);
>   src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> + if (ret == -EIO) {
> + mutex_lock(>lock);
> + src_buf_info->error = true;
> + mutex_unlock(>lock);
> + }
>   v4l2_m2m_buf_done(_buf_info->vb, VB2_BUF_STATE_ERROR);
>   } else if (res_chg == false) {
>   /*
> @@ -1176,6 +1181,11 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer 
> *vb)
>  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
> fail=%d, res_chg=%d",
>  ctx->id, src_buf->index,
>  src_mem.size, ret, res_chg);
> + if (ret == -EIO) {
> + mtk_v4l2_err("[%d] Unrecoverable error in 
> vdec_if_decode.",
> + ctx->id);
> + ctx->state = MTK_STATE_ABORT;
> + }
Should we set buf status to VB2_BUF_STATE_ERROR in this case?

>   return;
>   }
>  
> @@ -1217,14 +1227,17 @@ static void vb2ops_vdec_buf_finish(struct vb2_buffer 
> *vb)
>   struct vb2_v4l2_buffer *vb2_v4l2;
>   struct mtk_video_dec_buf *buf;
>  
> - if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> - return;
> -
>   vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf);
>   buf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);
>   mutex_lock(>lock);
> - buf->queued_in_v4l2 = false;
> - buf->queued_in_vb2 = false;
> + if (buf->error) {
> + mtk_v4l2_err("Unrecoverable error on buffer.");
Remove mtk_v4l2_err out of mutex_lock/mutex_unlock?


best regards,
Tiffany
> + ctx->state = MTK_STATE_ABORT;
> + }
> + if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
> + buf->queued_in_v4l2 = false;
> + buf->queued_in_vb2 = false;
> + }
>   mutex_unlock(>lock);
>  }
>  
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> index 362f5a85762e..dc4fc1df63c5 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> @@ -50,6 +50,7 @@ struct vdec_fb {
>   * @queued_in_v4l2:  Capture buffer is in v4l2 driver, but not in vb2
>   *   queue yet
>   * @lastframe:   Intput buffer is last buffer - EOS
> + * @error:   An unrecoverable error occurs on this buffer.
>   * @frame_buffer:Decode status, and buffer information of Capture buffer
>   *
>   * Note : These status information help us track and debug buffer state
> @@ -63,6 +64,7 @@ struct mtk_video_dec_buf {
>   boolqueued_in_vb2;
>   boolqueued_in_v4l2;
>   boollastframe;
> + boolerror;
>   struct vdec_fb  frame_buffer;
>  };
>  
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
> b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> index e91a3b425b0c..5539b1853f16 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> @@ -718,6 +718,26 @@ static void get_free_fb(struct vdec_vp9_inst *inst, 
> struct vdec_fb **out_fb)
>   *out_fb = fb;
>  }
>  
> +static int validate_vsi_array_indexes(struct vdec_vp9_inst *inst,
> + struct vdec_vp9_vsi *vsi) {
> + if (vsi->sf_frm_idx >= VP9_MAX_FRM_BUF_NUM - 1) {
> + mtk_vcodec_err(inst, "Invalid vsi->sf_frm_idx=%u.",
> + vsi->sf_frm_idx);
> + return -EIO;
> + }
> + if (vsi->frm_to_show_idx >= VP9_MAX_FRM_BUF_NUM) {
> + mtk_vcodec_err(inst, "Invalid vsi->frm_to_show_idx=%u.",
> + vsi->frm_to_show_idx);
> + return -EIO;
> + }
> + if (vsi->new_fb_idx >= VP9_MAX_FRM_BUF_NUM) {
> + 

Re: [PATCH 1/1] mtk-vcodec: check the vp9 decoder buffer index from VPU.

2017-03-07 Thread Tiffany Lin
On Tue, 2017-03-07 at 14:03 +0800, Wu-Cheng Li wrote:
> From: Wu-Cheng Li 
> 
> VPU firmware has a bug and may return invalid buffer index for
> some vp9 videos. Check the buffer indexes before accessing the
> buffer.
> 
> Signed-off-by: Wu-Cheng Li 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |  6 +
>  .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   | 26 
> ++
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  2 ++
>  3 files changed, 34 insertions(+)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> index 502877a4b1df..7ebcf9e57ac7 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> @@ -1176,6 +1176,12 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer 
> *vb)
>  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
> fail=%d, res_chg=%d",
>  ctx->id, src_buf->index,
>  src_mem.size, ret, res_chg);
> +
> + if (ret == -EIO) {
> + mtk_v4l2_err("[%d] Unrecoverable error in 
> vdec_if_decode.",
> + ctx->id);
> + ctx->state = MTK_STATE_ABORT;
> + }
Could we use v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
VB2_BUF_STATE_ERROR); instead ctx->state = MTK_STATE_ABORT;
In this case, the behavior will be same as vdec_if_decode called in
mtk_vdec_worker.
And we could also get information about what output buffer make vpu
crash.

best regards,
Tiffany
>   return;
>   }
>  
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
> b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> index e91a3b425b0c..5539b1853f16 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> @@ -718,6 +718,26 @@ static void get_free_fb(struct vdec_vp9_inst *inst, 
> struct vdec_fb **out_fb)
>   *out_fb = fb;
>  }
>  
> +static int validate_vsi_array_indexes(struct vdec_vp9_inst *inst,
> + struct vdec_vp9_vsi *vsi) {
> + if (vsi->sf_frm_idx >= VP9_MAX_FRM_BUF_NUM - 1) {
> + mtk_vcodec_err(inst, "Invalid vsi->sf_frm_idx=%u.",
> + vsi->sf_frm_idx);
> + return -EIO;
> + }
> + if (vsi->frm_to_show_idx >= VP9_MAX_FRM_BUF_NUM) {
> + mtk_vcodec_err(inst, "Invalid vsi->frm_to_show_idx=%u.",
> + vsi->frm_to_show_idx);
> + return -EIO;
> + }
> + if (vsi->new_fb_idx >= VP9_MAX_FRM_BUF_NUM) {
> + mtk_vcodec_err(inst, "Invalid vsi->new_fb_idx=%u.",
> + vsi->new_fb_idx);
> + return -EIO;
> + }
> + return 0;
> +}
> +
>  static void vdec_vp9_deinit(unsigned long h_vdec)
>  {
>   struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec;
> @@ -834,6 +854,12 @@ static int vdec_vp9_decode(unsigned long h_vdec, struct 
> mtk_vcodec_mem *bs,
>   goto DECODE_ERROR;
>   }
>  
> + ret = validate_vsi_array_indexes(inst, vsi);
> + if (ret) {
> + mtk_vcodec_err(inst, "Invalid values from VPU.");
> + goto DECODE_ERROR;
> + }
> +
>   if (vsi->resolution_changed) {
>   if (!vp9_alloc_work_buf(inst)) {
>   ret = -EINVAL;
> diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h 
> b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h
> index db6b5205ffb1..ded1154481cd 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h
> +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h
> @@ -85,6 +85,8 @@ void vdec_if_deinit(struct mtk_vcodec_ctx *ctx);
>   * @res_chg  : [out] resolution change happens if current bs have different
>   *   picture width/height
>   * Note: To flush the decoder when reaching EOF, set input bitstream as NULL.
> + *
> + * Return: 0 on success. -EIO on unrecoverable error.
>   */
>  int vdec_if_decode(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_mem *bs,
>  struct vdec_fb *fb, bool *res_chg);




Re: [PATCH 1/1] mtk-vcodec: check the vp9 decoder buffer index from VPU.

2017-03-07 Thread Tiffany Lin
On Tue, 2017-03-07 at 14:03 +0800, Wu-Cheng Li wrote:
> From: Wu-Cheng Li 
> 
> VPU firmware has a bug and may return invalid buffer index for
> some vp9 videos. Check the buffer indexes before accessing the
> buffer.
> 
> Signed-off-by: Wu-Cheng Li 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |  6 +
>  .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   | 26 
> ++
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  2 ++
>  3 files changed, 34 insertions(+)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> index 502877a4b1df..7ebcf9e57ac7 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> @@ -1176,6 +1176,12 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer 
> *vb)
>  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
> fail=%d, res_chg=%d",
>  ctx->id, src_buf->index,
>  src_mem.size, ret, res_chg);
> +
> + if (ret == -EIO) {
> + mtk_v4l2_err("[%d] Unrecoverable error in 
> vdec_if_decode.",
> + ctx->id);
> + ctx->state = MTK_STATE_ABORT;
> + }
Could we use v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
VB2_BUF_STATE_ERROR); instead ctx->state = MTK_STATE_ABORT;
In this case, the behavior will be same as vdec_if_decode called in
mtk_vdec_worker.
And we could also get information about what output buffer make vpu
crash.

best regards,
Tiffany
>   return;
>   }
>  
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
> b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> index e91a3b425b0c..5539b1853f16 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
> @@ -718,6 +718,26 @@ static void get_free_fb(struct vdec_vp9_inst *inst, 
> struct vdec_fb **out_fb)
>   *out_fb = fb;
>  }
>  
> +static int validate_vsi_array_indexes(struct vdec_vp9_inst *inst,
> + struct vdec_vp9_vsi *vsi) {
> + if (vsi->sf_frm_idx >= VP9_MAX_FRM_BUF_NUM - 1) {
> + mtk_vcodec_err(inst, "Invalid vsi->sf_frm_idx=%u.",
> + vsi->sf_frm_idx);
> + return -EIO;
> + }
> + if (vsi->frm_to_show_idx >= VP9_MAX_FRM_BUF_NUM) {
> + mtk_vcodec_err(inst, "Invalid vsi->frm_to_show_idx=%u.",
> + vsi->frm_to_show_idx);
> + return -EIO;
> + }
> + if (vsi->new_fb_idx >= VP9_MAX_FRM_BUF_NUM) {
> + mtk_vcodec_err(inst, "Invalid vsi->new_fb_idx=%u.",
> + vsi->new_fb_idx);
> + return -EIO;
> + }
> + return 0;
> +}
> +
>  static void vdec_vp9_deinit(unsigned long h_vdec)
>  {
>   struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec;
> @@ -834,6 +854,12 @@ static int vdec_vp9_decode(unsigned long h_vdec, struct 
> mtk_vcodec_mem *bs,
>   goto DECODE_ERROR;
>   }
>  
> + ret = validate_vsi_array_indexes(inst, vsi);
> + if (ret) {
> + mtk_vcodec_err(inst, "Invalid values from VPU.");
> + goto DECODE_ERROR;
> + }
> +
>   if (vsi->resolution_changed) {
>   if (!vp9_alloc_work_buf(inst)) {
>   ret = -EINVAL;
> diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h 
> b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h
> index db6b5205ffb1..ded1154481cd 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h
> +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h
> @@ -85,6 +85,8 @@ void vdec_if_deinit(struct mtk_vcodec_ctx *ctx);
>   * @res_chg  : [out] resolution change happens if current bs have different
>   *   picture width/height
>   * Note: To flush the decoder when reaching EOF, set input bitstream as NULL.
> + *
> + * Return: 0 on success. -EIO on unrecoverable error.
>   */
>  int vdec_if_decode(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_mem *bs,
>  struct vdec_fb *fb, bool *res_chg);




Re: [PATCH v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-10-24 Thread Tiffany Lin
Hi Mauro,

On Mon, 2016-10-24 at 07:05 -0200, Mauro Carvalho Chehab wrote:
> Em Mon, 24 Oct 2016 11:22:08 +0800
> Tiffany Lin <tiffany@mediatek.com> escreveu:
> 
> > Hi Mauro,
> > 
> > On Fri, 2016-10-21 at 11:01 -0200, Mauro Carvalho Chehab wrote:
> > > Em Fri, 2 Sep 2016 20:19:54 +0800
> > > Tiffany Lin <tiffany@mediatek.com> escreveu:
> > >   
> > > > Add v4l2 layer decoder driver for MT8173
> > > > 
> > > > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>  
> > >   
> > > > +int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
> > > > +{
> > > > +   int ret = 0;
> > > > +
> > > > +   switch (fourcc) {
> > > > +   case V4L2_PIX_FMT_H264:
> > > > +   case V4L2_PIX_FMT_VP8:
> > > > +   default:
> > > > +   return -EINVAL;
> > > > +   }  
> > > 
> > > Did you ever test this driver? The above code will *always* return
> > > -EINVAL, with will cause vidioc_vdec_s_fmt() to always fail!
> > > 
> > > I suspect that what you wanted to do, instead, is:
> > > 
> > >   switch (fourcc) {
> > >   case V4L2_PIX_FMT_H264:
> > >   case V4L2_PIX_FMT_VP8:
> > >   break;
> > >   default:
> > >   return -EINVAL;
> > >   
> > 
> > The original idea here is that vp8 and h264 are added in later patches.
> > If get this patch without later patches, it should return -EINVAL.
> 
> I noticed your idea, but next time, don't add dead code like that.
> Reviewers check patch by patch at the order they're present at the
> patch series.
> 
> So, don't add something broken by purpose, assuming that it would
> be fixed later.
> 
Got it.
> > 
> > 
> > > Btw, this patch series has also several issues that were pointed by
> > > checkpatch. Please *always* run checkpatch when submitting your work.
> > > 
> > > You should take a look at the Kernel documentation about how to
> > > submit patches, at:
> > >   https://mchehab.fedorapeople.org/kernel_docs/process/index.html
> > > 
> > > PS.: this time, I fixed the checkpatch issues for you. So, let me know
> > > if the patch below is OK, and I'll merge it at media upstream,
> > > assuming that the other patches in this series are ok.
> > >   
> > 
> > I did run checkpatch, but I don't know why these issues missed.
> > probably I run checkpatch for all files not for patches.
> > I will take a look at the documentation and keep this in mind for future
> > upstream.
> > Appreciated for your help.
> 
> Checkpatch should be run patch by patch, as we expect that all patches
> will follow the coding style and will compile fine, without introducing
> warnings.
> 
> I do compile the Kernel for every single patch I merge.
> 
Got it. I will follow this.

best regards,
Tiffany

> Regards,
> Mauro




Re: [PATCH v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-10-24 Thread Tiffany Lin
Hi Mauro,

On Mon, 2016-10-24 at 07:05 -0200, Mauro Carvalho Chehab wrote:
> Em Mon, 24 Oct 2016 11:22:08 +0800
> Tiffany Lin  escreveu:
> 
> > Hi Mauro,
> > 
> > On Fri, 2016-10-21 at 11:01 -0200, Mauro Carvalho Chehab wrote:
> > > Em Fri, 2 Sep 2016 20:19:54 +0800
> > > Tiffany Lin  escreveu:
> > >   
> > > > Add v4l2 layer decoder driver for MT8173
> > > > 
> > > > Signed-off-by: Tiffany Lin   
> > >   
> > > > +int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
> > > > +{
> > > > +   int ret = 0;
> > > > +
> > > > +   switch (fourcc) {
> > > > +   case V4L2_PIX_FMT_H264:
> > > > +   case V4L2_PIX_FMT_VP8:
> > > > +   default:
> > > > +   return -EINVAL;
> > > > +   }  
> > > 
> > > Did you ever test this driver? The above code will *always* return
> > > -EINVAL, with will cause vidioc_vdec_s_fmt() to always fail!
> > > 
> > > I suspect that what you wanted to do, instead, is:
> > > 
> > >   switch (fourcc) {
> > >   case V4L2_PIX_FMT_H264:
> > >   case V4L2_PIX_FMT_VP8:
> > >   break;
> > >   default:
> > >   return -EINVAL;
> > >   
> > 
> > The original idea here is that vp8 and h264 are added in later patches.
> > If get this patch without later patches, it should return -EINVAL.
> 
> I noticed your idea, but next time, don't add dead code like that.
> Reviewers check patch by patch at the order they're present at the
> patch series.
> 
> So, don't add something broken by purpose, assuming that it would
> be fixed later.
> 
Got it.
> > 
> > 
> > > Btw, this patch series has also several issues that were pointed by
> > > checkpatch. Please *always* run checkpatch when submitting your work.
> > > 
> > > You should take a look at the Kernel documentation about how to
> > > submit patches, at:
> > >   https://mchehab.fedorapeople.org/kernel_docs/process/index.html
> > > 
> > > PS.: this time, I fixed the checkpatch issues for you. So, let me know
> > > if the patch below is OK, and I'll merge it at media upstream,
> > > assuming that the other patches in this series are ok.
> > >   
> > 
> > I did run checkpatch, but I don't know why these issues missed.
> > probably I run checkpatch for all files not for patches.
> > I will take a look at the documentation and keep this in mind for future
> > upstream.
> > Appreciated for your help.
> 
> Checkpatch should be run patch by patch, as we expect that all patches
> will follow the coding style and will compile fine, without introducing
> warnings.
> 
> I do compile the Kernel for every single patch I merge.
> 
Got it. I will follow this.

best regards,
Tiffany

> Regards,
> Mauro




Re: FW: [PATCH] mtk-vcodec: fix some smatch warnings

2016-10-23 Thread Tiffany Lin


> Fix this bug:
>   drivers/media/platform/mtk-vcodec/vdec_drv_if.c:38 vdec_if_init() info: 
> ignoring unreachable code.
> 
> With is indeed a real problem that prevents the driver to work!
> 
> While here, also remove an used var, as reported by smatch:
> 
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c: In function 
> 'mtk_vcodec_init_dec_pm':
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c:29:17: warning: 
> variable 'dev' set but not used [-Wunused-but-set-variable]
> struct device *dev;
>^~~
> 
> Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>

Acked-by: Tiffany Lin <tiffany@mediatek.com>
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c | 2 --
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.c   | 1 +
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> index 18182f5676d8..79ca03ac449c 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> @@ -26,14 +26,12 @@ int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev) 
>  {
>   struct device_node *node;
>   struct platform_device *pdev;
> - struct device *dev;
>   struct mtk_vcodec_pm *pm;
>   int ret = 0;
>  
>   pdev = mtkdev->plat_dev;
>   pm = >pm;
>   pm->mtkdev = mtkdev;
> - dev = >dev;
>   node = of_parse_phandle(pdev->dev.of_node, "mediatek,larb", 0);
>   if (!node) {
>   mtk_v4l2_err("of_parse_phandle mediatek,larb fail!"); diff 
> --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c 
> b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c
> index 3cb04ef45144..9813b2ffd5fa 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c
> @@ -31,6 +31,7 @@ int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int 
> fourcc)
>   switch (fourcc) {
>   case V4L2_PIX_FMT_H264:
>   case V4L2_PIX_FMT_VP8:
> + break;
>   default:
>   return -EINVAL;
>   }
> --
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in the 
> body of a message to majord...@vger.kernel.org More majordomo info at  
> http://vger.kernel.org/majordomo-info.html




Re: FW: [PATCH] mtk-vcodec: fix some smatch warnings

2016-10-23 Thread Tiffany Lin


> Fix this bug:
>   drivers/media/platform/mtk-vcodec/vdec_drv_if.c:38 vdec_if_init() info: 
> ignoring unreachable code.
> 
> With is indeed a real problem that prevents the driver to work!
> 
> While here, also remove an used var, as reported by smatch:
> 
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c: In function 
> 'mtk_vcodec_init_dec_pm':
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c:29:17: warning: 
> variable 'dev' set but not used [-Wunused-but-set-variable]
> struct device *dev;
>^~~
> 
> Signed-off-by: Mauro Carvalho Chehab 

Acked-by: Tiffany Lin 
> ---
>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c | 2 --
>  drivers/media/platform/mtk-vcodec/vdec_drv_if.c   | 1 +
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> index 18182f5676d8..79ca03ac449c 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
> @@ -26,14 +26,12 @@ int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev) 
>  {
>   struct device_node *node;
>   struct platform_device *pdev;
> - struct device *dev;
>   struct mtk_vcodec_pm *pm;
>   int ret = 0;
>  
>   pdev = mtkdev->plat_dev;
>   pm = >pm;
>   pm->mtkdev = mtkdev;
> - dev = >dev;
>   node = of_parse_phandle(pdev->dev.of_node, "mediatek,larb", 0);
>   if (!node) {
>   mtk_v4l2_err("of_parse_phandle mediatek,larb fail!"); diff 
> --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c 
> b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c
> index 3cb04ef45144..9813b2ffd5fa 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c
> @@ -31,6 +31,7 @@ int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int 
> fourcc)
>   switch (fourcc) {
>   case V4L2_PIX_FMT_H264:
>   case V4L2_PIX_FMT_VP8:
> + break;
>   default:
>   return -EINVAL;
>   }
> --
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in the 
> body of a message to majord...@vger.kernel.org More majordomo info at  
> http://vger.kernel.org/majordomo-info.html




Re: [PATCH v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-10-23 Thread Tiffany Lin
Hi Mauro,

On Fri, 2016-10-21 at 11:01 -0200, Mauro Carvalho Chehab wrote:
> Em Fri, 2 Sep 2016 20:19:54 +0800
> Tiffany Lin <tiffany@mediatek.com> escreveu:
> 
> > Add v4l2 layer decoder driver for MT8173
> > 
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> 
> > +int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
> > +{
> > +   int ret = 0;
> > +
> > +   switch (fourcc) {
> > +   case V4L2_PIX_FMT_H264:
> > +   case V4L2_PIX_FMT_VP8:
> > +   default:
> > +   return -EINVAL;
> > +   }
> 
> Did you ever test this driver? The above code will *always* return
> -EINVAL, with will cause vidioc_vdec_s_fmt() to always fail!
> 
> I suspect that what you wanted to do, instead, is:
> 
>   switch (fourcc) {
>   case V4L2_PIX_FMT_H264:
>   case V4L2_PIX_FMT_VP8:
>   break;
>   default:
>   return -EINVAL;
> 

The original idea here is that vp8 and h264 are added in later patches.
If get this patch without later patches, it should return -EINVAL.


> Btw, this patch series has also several issues that were pointed by
> checkpatch. Please *always* run checkpatch when submitting your work.
> 
> You should take a look at the Kernel documentation about how to
> submit patches, at:
>   https://mchehab.fedorapeople.org/kernel_docs/process/index.html
> 
> PS.: this time, I fixed the checkpatch issues for you. So, let me know
> if the patch below is OK, and I'll merge it at media upstream,
> assuming that the other patches in this series are ok.
> 

I did run checkpatch, but I don't know why these issues missed.
probably I run checkpatch for all files not for patches.
I will take a look at the documentation and keep this in mind for future
upstream.
Appreciated for your help.


best regards,
Tiffany



Re: [PATCH v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-10-23 Thread Tiffany Lin
Hi Mauro,

On Fri, 2016-10-21 at 11:01 -0200, Mauro Carvalho Chehab wrote:
> Em Fri, 2 Sep 2016 20:19:54 +0800
> Tiffany Lin  escreveu:
> 
> > Add v4l2 layer decoder driver for MT8173
> > 
> > Signed-off-by: Tiffany Lin 
> 
> > +int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
> > +{
> > +   int ret = 0;
> > +
> > +   switch (fourcc) {
> > +   case V4L2_PIX_FMT_H264:
> > +   case V4L2_PIX_FMT_VP8:
> > +   default:
> > +   return -EINVAL;
> > +   }
> 
> Did you ever test this driver? The above code will *always* return
> -EINVAL, with will cause vidioc_vdec_s_fmt() to always fail!
> 
> I suspect that what you wanted to do, instead, is:
> 
>   switch (fourcc) {
>   case V4L2_PIX_FMT_H264:
>   case V4L2_PIX_FMT_VP8:
>   break;
>   default:
>   return -EINVAL;
> 

The original idea here is that vp8 and h264 are added in later patches.
If get this patch without later patches, it should return -EINVAL.


> Btw, this patch series has also several issues that were pointed by
> checkpatch. Please *always* run checkpatch when submitting your work.
> 
> You should take a look at the Kernel documentation about how to
> submit patches, at:
>   https://mchehab.fedorapeople.org/kernel_docs/process/index.html
> 
> PS.: this time, I fixed the checkpatch issues for you. So, let me know
> if the patch below is OK, and I'll merge it at media upstream,
> assuming that the other patches in this series are ok.
> 

I did run checkpatch, but I don't know why these issues missed.
probably I run checkpatch for all files not for patches.
I will take a look at the documentation and keep this in mind for future
upstream.
Appreciated for your help.


best regards,
Tiffany



Re: [PATCH v2 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-18 Thread Tiffany Lin
Hi Hans,

On Wed, 2016-09-14 at 13:51 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> On 09/09/2016 05:48 PM, Tiffany Lin wrote:
> > Add V4L2_PIX_FMT_MT21C documentation
> > 
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> >  Documentation/media/uapi/v4l/pixfmt-reserved.rst |   10 ++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
> > b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > index 0dd2f7f..0989e99 100644
> > --- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > +++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > @@ -339,7 +339,17 @@ please make a proposal on the linux-media mailing list.
> >   array. Anything what's in between the UYVY lines is JPEG data and
> >   should be concatenated to form the JPEG stream.
> >  
> > +-  .. _V4L2-PIX-FMT-MT21C:
> >  
> > +   -  ``V4L2_PIX_FMT_MT21C``
> > +
> > +   -  'MT21C'
> > +
> > +   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
> > +  The compression is lossless.
> > +  It is an opaque intermediate format, and MDP HW could convert
> 
> Is it OK if I change this to:
> 
> " and the MDP hardware must be used to convert"
> 

Yes. It's better to make it more clear how to use MT21C.
Thanks for the help.

> > +  V4L2_PIX_FMT_MT21C to V4L2_PIX_FMT_NV12M,
> > +  V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
> 
> and here "and" should be replaced by "or".
> 
Yes. it should be "or". Sorry about that.


best regards,
Tiffany

> Regards,
> 
>   Hans
> 
> >  
> >  .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
> >  
> > 




Re: [PATCH v2 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-18 Thread Tiffany Lin
Hi Hans,

On Wed, 2016-09-14 at 13:51 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> On 09/09/2016 05:48 PM, Tiffany Lin wrote:
> > Add V4L2_PIX_FMT_MT21C documentation
> > 
> > Signed-off-by: Tiffany Lin 
> > ---
> >  Documentation/media/uapi/v4l/pixfmt-reserved.rst |   10 ++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
> > b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > index 0dd2f7f..0989e99 100644
> > --- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > +++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > @@ -339,7 +339,17 @@ please make a proposal on the linux-media mailing list.
> >   array. Anything what's in between the UYVY lines is JPEG data and
> >   should be concatenated to form the JPEG stream.
> >  
> > +-  .. _V4L2-PIX-FMT-MT21C:
> >  
> > +   -  ``V4L2_PIX_FMT_MT21C``
> > +
> > +   -  'MT21C'
> > +
> > +   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
> > +  The compression is lossless.
> > +  It is an opaque intermediate format, and MDP HW could convert
> 
> Is it OK if I change this to:
> 
> " and the MDP hardware must be used to convert"
> 

Yes. It's better to make it more clear how to use MT21C.
Thanks for the help.

> > +  V4L2_PIX_FMT_MT21C to V4L2_PIX_FMT_NV12M,
> > +  V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
> 
> and here "and" should be replaced by "or".
> 
Yes. it should be "or". Sorry about that.


best regards,
Tiffany

> Regards,
> 
>   Hans
> 
> >  
> >  .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
> >  
> > 




Re: [PATCH 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-13 Thread Tiffany Lin
Hi Hans,

On Thu, 2016-09-08 at 11:27 +0200, Hans Verkuil wrote:
> On 09/08/16 11:11, Tiffany Lin wrote:
> > Hi Hans,
> >
> > On Thu, 2016-09-08 at 09:21 +0200, Hans Verkuil wrote:
> >> Hi Tiffany,
> >>
> >> On 09/07/2016 08:56 AM, Tiffany Lin wrote:
> >>> This patch series add Mediatek compressed block format 
> >>> V4L2_PIX_FMT_MT21C, the
> >>> decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.
> >>>
> >>> User space applications could use MT8173 MDP driver to convert 
> >>> V4L2_PIX_FMT_MT21C to
> >>> V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
> >>>
> >>> MDP driver[1] is stand alone driver.
> >>>
> >>> Usage:
> >>> MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420
> >>> NV12M/NV21M/YUV420M/YVU420M -> mt8173 Encoder -> H264/VP8
> >>> H264/VP8/VP9 -> mtk8173 Decoder -> MT21C
> >>>
> >>> When encode with MT21 source, the pipeline will be:
> >>> MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8
> >>>
> >>> When playback, the pipeline will be:
> >>> H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM
> >>>
> >>> [1]https://patchwork.kernel.org/patch/9305329/
> >>>
> >>> Tiffany Lin (4):
> >>>   v4l: add Mediatek compressed video block format
> >>>   docs-rst: Add compressed video formats used on MT8173 codec driver
> >>>   vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
> >>>   arm64: dts: mediatek: Add Video Decoder for MT8173
> >>>
> >>>  Documentation/media/uapi/v4l/pixfmt-reserved.rst   |6 +++
> >>>  arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
> >>> 
> >>>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
> >>>  drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
> >>>  include/uapi/linux/videodev2.h |1 +
> >>>  5 files changed, 58 insertions(+), 1 deletion(-)
> >>>
> >>
> >> So basically the video decoder is useless without support for this format 
> >> and
> >> without the MDP driver, right?
> >>
> > Yes. It also require new vpu firmware.
> > Andrew will help release new vpu firmware include encode/decode/mdp
> > capability.
> 
> OK, then I'll park this until:
> 
> - the MT21C patch series is OK
> - the MDP patch series is OK
> - the new firmware is released
> 

> For the record: the decoder patch series is OK as far as I am concerned.
> It's in my mtkdec branch.
> 

Appreciated for your help.
We had upstream new MT21C, MDP and new VPU firmware.

MT21C patch series: https://patchwork.kernel.org/patch/9323883/
MDP patch series: https://patchwork.kernel.org/patch/9321343/
VPU firmware: https://patchwork.linuxtv.org/patch/36968/


best regards,
Tiffany



> Regards,
> 
>   Hans




Re: [PATCH 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-13 Thread Tiffany Lin
Hi Hans,

On Thu, 2016-09-08 at 11:27 +0200, Hans Verkuil wrote:
> On 09/08/16 11:11, Tiffany Lin wrote:
> > Hi Hans,
> >
> > On Thu, 2016-09-08 at 09:21 +0200, Hans Verkuil wrote:
> >> Hi Tiffany,
> >>
> >> On 09/07/2016 08:56 AM, Tiffany Lin wrote:
> >>> This patch series add Mediatek compressed block format 
> >>> V4L2_PIX_FMT_MT21C, the
> >>> decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.
> >>>
> >>> User space applications could use MT8173 MDP driver to convert 
> >>> V4L2_PIX_FMT_MT21C to
> >>> V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
> >>>
> >>> MDP driver[1] is stand alone driver.
> >>>
> >>> Usage:
> >>> MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420
> >>> NV12M/NV21M/YUV420M/YVU420M -> mt8173 Encoder -> H264/VP8
> >>> H264/VP8/VP9 -> mtk8173 Decoder -> MT21C
> >>>
> >>> When encode with MT21 source, the pipeline will be:
> >>> MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8
> >>>
> >>> When playback, the pipeline will be:
> >>> H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM
> >>>
> >>> [1]https://patchwork.kernel.org/patch/9305329/
> >>>
> >>> Tiffany Lin (4):
> >>>   v4l: add Mediatek compressed video block format
> >>>   docs-rst: Add compressed video formats used on MT8173 codec driver
> >>>   vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
> >>>   arm64: dts: mediatek: Add Video Decoder for MT8173
> >>>
> >>>  Documentation/media/uapi/v4l/pixfmt-reserved.rst   |6 +++
> >>>  arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
> >>> 
> >>>  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
> >>>  drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
> >>>  include/uapi/linux/videodev2.h |1 +
> >>>  5 files changed, 58 insertions(+), 1 deletion(-)
> >>>
> >>
> >> So basically the video decoder is useless without support for this format 
> >> and
> >> without the MDP driver, right?
> >>
> > Yes. It also require new vpu firmware.
> > Andrew will help release new vpu firmware include encode/decode/mdp
> > capability.
> 
> OK, then I'll park this until:
> 
> - the MT21C patch series is OK
> - the MDP patch series is OK
> - the new firmware is released
> 

> For the record: the decoder patch series is OK as far as I am concerned.
> It's in my mtkdec branch.
> 

Appreciated for your help.
We had upstream new MT21C, MDP and new VPU firmware.

MT21C patch series: https://patchwork.kernel.org/patch/9323883/
MDP patch series: https://patchwork.kernel.org/patch/9321343/
VPU firmware: https://patchwork.linuxtv.org/patch/36968/


best regards,
Tiffany



> Regards,
> 
>   Hans




[PATCH v2 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-09 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C documentation

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 Documentation/media/uapi/v4l/pixfmt-reserved.rst |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
index 0dd2f7f..0989e99 100644
--- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
@@ -339,7 +339,17 @@ please make a proposal on the linux-media mailing list.
  array. Anything what's in between the UYVY lines is JPEG data and
  should be concatenated to form the JPEG stream.
 
+-  .. _V4L2-PIX-FMT-MT21C:
 
+   -  ``V4L2_PIX_FMT_MT21C``
+
+   -  'MT21C'
+
+   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
+  The compression is lossless.
+  It is an opaque intermediate format, and MDP HW could convert
+  V4L2_PIX_FMT_MT21C to V4L2_PIX_FMT_NV12M,
+  V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
 
 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
 
-- 
1.7.9.5



[PATCH v2 3/4] vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder

2016-09-09 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C support

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 28a8453..fd3befc 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -25,7 +25,7 @@
 #include "mtk_vcodec_dec_pm.h"
 
 #define OUT_FMT_IDX0
-#define CAP_FMT_IDX0
+#define CAP_FMT_IDX3
 
 #define MTK_VDEC_MIN_W 64U
 #define MTK_VDEC_MIN_H 64U
@@ -48,6 +48,11 @@ static struct mtk_video_fmt mtk_video_formats[] = {
.type = MTK_FMT_DEC,
.num_planes = 1,
},
+   {
+   .fourcc = V4L2_PIX_FMT_MT21C,
+   .type = MTK_FMT_FRAME,
+   .num_planes = 2,
+   },
 };
 
 static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
-- 
1.7.9.5



[PATCH v2 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-09 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C documentation

Signed-off-by: Tiffany Lin 
---
 Documentation/media/uapi/v4l/pixfmt-reserved.rst |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
index 0dd2f7f..0989e99 100644
--- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
@@ -339,7 +339,17 @@ please make a proposal on the linux-media mailing list.
  array. Anything what's in between the UYVY lines is JPEG data and
  should be concatenated to form the JPEG stream.
 
+-  .. _V4L2-PIX-FMT-MT21C:
 
+   -  ``V4L2_PIX_FMT_MT21C``
+
+   -  'MT21C'
+
+   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
+  The compression is lossless.
+  It is an opaque intermediate format, and MDP HW could convert
+  V4L2_PIX_FMT_MT21C to V4L2_PIX_FMT_NV12M,
+  V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
 
 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
 
-- 
1.7.9.5



[PATCH v2 3/4] vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder

2016-09-09 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C support

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

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 28a8453..fd3befc 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -25,7 +25,7 @@
 #include "mtk_vcodec_dec_pm.h"
 
 #define OUT_FMT_IDX0
-#define CAP_FMT_IDX0
+#define CAP_FMT_IDX3
 
 #define MTK_VDEC_MIN_W 64U
 #define MTK_VDEC_MIN_H 64U
@@ -48,6 +48,11 @@ static struct mtk_video_fmt mtk_video_formats[] = {
.type = MTK_FMT_DEC,
.num_planes = 1,
},
+   {
+   .fourcc = V4L2_PIX_FMT_MT21C,
+   .type = MTK_FMT_FRAME,
+   .num_planes = 2,
+   },
 };
 
 static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
-- 
1.7.9.5



[PATCH v2 4/4] arm64: dts: mediatek: Add Video Decoder for MT8173

2016-09-09 Thread Tiffany Lin
Add video decoder node for MT8173

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   44 ++
 1 file changed, 44 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 10f638f..2872cd7 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -974,6 +974,50 @@
#clock-cells = <1>;
};
 
+   vcodec_dec: vcodec@1600 {
+   compatible = "mediatek,mt8173-vcodec-dec";
+   reg = <0 0x1600 0 0x100>,   /* VDEC_SYS */
+ <0 0x1602 0 0x1000>,  /* VDEC_MISC */
+ <0 0x16021000 0 0x800>,   /* VDEC_LD */
+ <0 0x16021800 0 0x800>,   /* VDEC_TOP */
+ <0 0x16022000 0 0x1000>,  /* VDEC_CM */
+ <0 0x16023000 0 0x1000>,  /* VDEC_AD */
+ <0 0x16024000 0 0x1000>,  /* VDEC_AV */
+ <0 0x16025000 0 0x1000>,  /* VDEC_PP */
+ <0 0x16026800 0 0x800>,   /* VDEC_HWD */
+ <0 0x16027000 0 0x800>,   /* VDEC_HWQ */
+ <0 0x16027800 0 0x800>,   /* VDEC_HWB */
+ <0 0x16028400 0 0x400>;   /* VDEC_HWG */
+   interrupts = ;
+   mediatek,larb = <>;
+   iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+< M4U_PORT_HW_VDEC_PP_EXT>,
+< M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+< M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+< M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+< M4U_PORT_HW_VDEC_UFO_EXT>,
+< M4U_PORT_HW_VDEC_VLD_EXT>,
+< M4U_PORT_HW_VDEC_VLD2_EXT>;
+   mediatek,vpu = <>;
+   power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+   clocks = < CLK_APMIXED_VCODECPLL>,
+< CLK_TOP_UNIVPLL_D2>,
+< CLK_TOP_CCI400_SEL>,
+< CLK_TOP_VDEC_SEL>,
+< CLK_TOP_VCODECPLL>,
+< CLK_APMIXED_VENCPLL>,
+< CLK_TOP_VENC_LT_SEL>,
+< CLK_TOP_VCODECPLL_370P5>;
+   clock-names = "vcodecpll",
+ "univpll_d2",
+ "clk_cci400_sel",
+ "vdec_sel",
+ "vdecpll",
+ "vencpll",
+ "venc_lt_sel",
+ "vdec_bus_clk_src";
+   };
+
larb1: larb@1601 {
compatible = "mediatek,mt8173-smi-larb";
reg = <0 0x1601 0 0x1000>;
-- 
1.7.9.5



[PATCH v2 4/4] arm64: dts: mediatek: Add Video Decoder for MT8173

2016-09-09 Thread Tiffany Lin
Add video decoder node for MT8173

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

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 10f638f..2872cd7 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -974,6 +974,50 @@
#clock-cells = <1>;
};
 
+   vcodec_dec: vcodec@1600 {
+   compatible = "mediatek,mt8173-vcodec-dec";
+   reg = <0 0x1600 0 0x100>,   /* VDEC_SYS */
+ <0 0x1602 0 0x1000>,  /* VDEC_MISC */
+ <0 0x16021000 0 0x800>,   /* VDEC_LD */
+ <0 0x16021800 0 0x800>,   /* VDEC_TOP */
+ <0 0x16022000 0 0x1000>,  /* VDEC_CM */
+ <0 0x16023000 0 0x1000>,  /* VDEC_AD */
+ <0 0x16024000 0 0x1000>,  /* VDEC_AV */
+ <0 0x16025000 0 0x1000>,  /* VDEC_PP */
+ <0 0x16026800 0 0x800>,   /* VDEC_HWD */
+ <0 0x16027000 0 0x800>,   /* VDEC_HWQ */
+ <0 0x16027800 0 0x800>,   /* VDEC_HWB */
+ <0 0x16028400 0 0x400>;   /* VDEC_HWG */
+   interrupts = ;
+   mediatek,larb = <>;
+   iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+< M4U_PORT_HW_VDEC_PP_EXT>,
+< M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+< M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+< M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+< M4U_PORT_HW_VDEC_UFO_EXT>,
+< M4U_PORT_HW_VDEC_VLD_EXT>,
+< M4U_PORT_HW_VDEC_VLD2_EXT>;
+   mediatek,vpu = <>;
+   power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+   clocks = < CLK_APMIXED_VCODECPLL>,
+< CLK_TOP_UNIVPLL_D2>,
+< CLK_TOP_CCI400_SEL>,
+< CLK_TOP_VDEC_SEL>,
+< CLK_TOP_VCODECPLL>,
+< CLK_APMIXED_VENCPLL>,
+< CLK_TOP_VENC_LT_SEL>,
+< CLK_TOP_VCODECPLL_370P5>;
+   clock-names = "vcodecpll",
+ "univpll_d2",
+ "clk_cci400_sel",
+ "vdec_sel",
+ "vdecpll",
+ "vencpll",
+ "venc_lt_sel",
+ "vdec_bus_clk_src";
+   };
+
larb1: larb@1601 {
compatible = "mediatek,mt8173-smi-larb";
reg = <0 0x1601 0 0x1000>;
-- 
1.7.9.5



[PATCH v2 1/4] v4l: add Mediatek compressed video block format

2016-09-09 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C format used on MT8173 driver.
It is compressed format and need MT8173 MDP driver to transfer to other
standard format.

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c |1 +
 include/uapi/linux/videodev2.h   |1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 2bd1581..1d45c58 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1288,6 +1288,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_JPGL: descr = "JPEG Lite"; break;
case V4L2_PIX_FMT_SE401:descr = "GSPCA SE401"; break;
case V4L2_PIX_FMT_S5C_UYVY_JPG: descr = "S5C73MX interleaved 
UYVY/JPEG"; break;
+   case V4L2_PIX_FMT_MT21C:descr = "Mediatek Compressed 
Format"; break;
default:
WARN(1, "Unknown pixelformat 0x%08x\n", 
fmt->pixelformat);
if (fmt->description[0])
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 43326c3..ddd0083 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -635,6 +635,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_Y8I  v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 
8-bit L/R interleaved */
 #define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 
12-bit L/R interleaved */
 #define V4L2_PIX_FMT_Z16  v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 
16-bit */
+#define V4L2_PIX_FMT_MT21Cv4l2_fourcc('M', 'T', '2', '1') /* Mediatek 
compressed block mode  */
 
 /* SDR formats - used only for Software Defined Radio devices */
 #define V4L2_SDR_FMT_CU8  v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
-- 
1.7.9.5



[PATCH v2 1/4] v4l: add Mediatek compressed video block format

2016-09-09 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C format used on MT8173 driver.
It is compressed format and need MT8173 MDP driver to transfer to other
standard format.

Signed-off-by: Tiffany Lin 
---
 drivers/media/v4l2-core/v4l2-ioctl.c |1 +
 include/uapi/linux/videodev2.h   |1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 2bd1581..1d45c58 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1288,6 +1288,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_JPGL: descr = "JPEG Lite"; break;
case V4L2_PIX_FMT_SE401:descr = "GSPCA SE401"; break;
case V4L2_PIX_FMT_S5C_UYVY_JPG: descr = "S5C73MX interleaved 
UYVY/JPEG"; break;
+   case V4L2_PIX_FMT_MT21C:descr = "Mediatek Compressed 
Format"; break;
default:
WARN(1, "Unknown pixelformat 0x%08x\n", 
fmt->pixelformat);
if (fmt->description[0])
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 43326c3..ddd0083 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -635,6 +635,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_Y8I  v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 
8-bit L/R interleaved */
 #define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 
12-bit L/R interleaved */
 #define V4L2_PIX_FMT_Z16  v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 
16-bit */
+#define V4L2_PIX_FMT_MT21Cv4l2_fourcc('M', 'T', '2', '1') /* Mediatek 
compressed block mode  */
 
 /* SDR formats - used only for Software Defined Radio devices */
 #define V4L2_SDR_FMT_CU8  v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
-- 
1.7.9.5



[PATCH v2 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-09 Thread Tiffany Lin
This patch series add Mediatek compressed block format V4L2_PIX_FMT_MT21C,
the decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.

User space applications could use MT8173 MDP driver to convert 
V4L2_PIX_FMT_MT21C
to V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
MDP driver[1] is stand alone driver.

Usage:
MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420 NV12M/NV21M/YUV420M/YVU420M -> 
mt8173 Encoder -> H264/VP8
H264/VP8/VP9 -> mtk8173 Decoder -> MT21C

When encode with MT21 source, the pipeline will be:
MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8

When playback, the pipeline will be:
H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM

[1]https://patchwork.kernel.org/patch/9305329/

---
v2: add more information for MT21C in docs-rst
---


Tiffany Lin (4):
  v4l: add Mediatek compressed video block format
  docs-rst: Add compressed video formats used on MT8173 codec driver
  vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
  arm64: dts: mediatek: Add Video Decoder for MT8173

 Documentation/media/uapi/v4l/pixfmt-reserved.rst   |   10 +
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
 drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
 include/uapi/linux/videodev2.h |1 +
 5 files changed, 62 insertions(+), 1 deletion(-)

-- 
1.7.9.5



[PATCH v2 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-09 Thread Tiffany Lin
This patch series add Mediatek compressed block format V4L2_PIX_FMT_MT21C,
the decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.

User space applications could use MT8173 MDP driver to convert 
V4L2_PIX_FMT_MT21C
to V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
MDP driver[1] is stand alone driver.

Usage:
MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420 NV12M/NV21M/YUV420M/YVU420M -> 
mt8173 Encoder -> H264/VP8
H264/VP8/VP9 -> mtk8173 Decoder -> MT21C

When encode with MT21 source, the pipeline will be:
MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8

When playback, the pipeline will be:
H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM

[1]https://patchwork.kernel.org/patch/9305329/

---
v2: add more information for MT21C in docs-rst
---


Tiffany Lin (4):
  v4l: add Mediatek compressed video block format
  docs-rst: Add compressed video formats used on MT8173 codec driver
  vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
  arm64: dts: mediatek: Add Video Decoder for MT8173

 Documentation/media/uapi/v4l/pixfmt-reserved.rst   |   10 +
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
 drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
 include/uapi/linux/videodev2.h |1 +
 5 files changed, 62 insertions(+), 1 deletion(-)

-- 
1.7.9.5



Re: [PATCH 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-08 Thread Tiffany Lin
Hi Hans,

On Thu, 2016-09-08 at 09:21 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> On 09/07/2016 08:56 AM, Tiffany Lin wrote:
> > This patch series add Mediatek compressed block format V4L2_PIX_FMT_MT21C, 
> > the
> > decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.
> > 
> > User space applications could use MT8173 MDP driver to convert 
> > V4L2_PIX_FMT_MT21C to
> > V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
> > 
> > MDP driver[1] is stand alone driver.
> > 
> > Usage:
> > MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420
> > NV12M/NV21M/YUV420M/YVU420M -> mt8173 Encoder -> H264/VP8
> > H264/VP8/VP9 -> mtk8173 Decoder -> MT21C
> > 
> > When encode with MT21 source, the pipeline will be:
> > MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8
> > 
> > When playback, the pipeline will be:
> > H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM
> > 
> > [1]https://patchwork.kernel.org/patch/9305329/
> > 
> > Tiffany Lin (4):
> >   v4l: add Mediatek compressed video block format
> >   docs-rst: Add compressed video formats used on MT8173 codec driver
> >   vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
> >   arm64: dts: mediatek: Add Video Decoder for MT8173
> > 
> >  Documentation/media/uapi/v4l/pixfmt-reserved.rst   |6 +++
> >  arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
> > 
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
> >  drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
> >  include/uapi/linux/videodev2.h |1 +
> >  5 files changed, 58 insertions(+), 1 deletion(-)
> > 
> 
> So basically the video decoder is useless without support for this format and
> without the MDP driver, right?
> 
Yes. It also require new vpu firmware.
Andrew will help release new vpu firmware include encode/decode/mdp
capability.

best regards,
Tiffany


> I'm wondering if I should hold off on merging the decoder driver until these 
> two
> are in. What is the timeline for v6 of the MDP driver?
> 
> If a v6 is posted early next week, then I have time to review and (assuming 
> it is
> OK) I can make a pull request for both this driver and the MDP driver.
> 
> If it takes longer, then there is a good chance that it will slip to 4.10. I 
> will
> have very little time in the period September 20 - October 14.
> 
> Regards,
> 
>   Hans




Re: [PATCH 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-08 Thread Tiffany Lin
Hi Hans,

On Thu, 2016-09-08 at 09:21 +0200, Hans Verkuil wrote:
> Hi Tiffany,
> 
> On 09/07/2016 08:56 AM, Tiffany Lin wrote:
> > This patch series add Mediatek compressed block format V4L2_PIX_FMT_MT21C, 
> > the
> > decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.
> > 
> > User space applications could use MT8173 MDP driver to convert 
> > V4L2_PIX_FMT_MT21C to
> > V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.
> > 
> > MDP driver[1] is stand alone driver.
> > 
> > Usage:
> > MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420
> > NV12M/NV21M/YUV420M/YVU420M -> mt8173 Encoder -> H264/VP8
> > H264/VP8/VP9 -> mtk8173 Decoder -> MT21C
> > 
> > When encode with MT21 source, the pipeline will be:
> > MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8
> > 
> > When playback, the pipeline will be:
> > H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM
> > 
> > [1]https://patchwork.kernel.org/patch/9305329/
> > 
> > Tiffany Lin (4):
> >   v4l: add Mediatek compressed video block format
> >   docs-rst: Add compressed video formats used on MT8173 codec driver
> >   vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
> >   arm64: dts: mediatek: Add Video Decoder for MT8173
> > 
> >  Documentation/media/uapi/v4l/pixfmt-reserved.rst   |6 +++
> >  arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
> > 
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
> >  drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
> >  include/uapi/linux/videodev2.h |1 +
> >  5 files changed, 58 insertions(+), 1 deletion(-)
> > 
> 
> So basically the video decoder is useless without support for this format and
> without the MDP driver, right?
> 
Yes. It also require new vpu firmware.
Andrew will help release new vpu firmware include encode/decode/mdp
capability.

best regards,
Tiffany


> I'm wondering if I should hold off on merging the decoder driver until these 
> two
> are in. What is the timeline for v6 of the MDP driver?
> 
> If a v6 is posted early next week, then I have time to review and (assuming 
> it is
> OK) I can make a pull request for both this driver and the MDP driver.
> 
> If it takes longer, then there is a good chance that it will slip to 4.10. I 
> will
> have very little time in the period September 20 - October 14.
> 
> Regards,
> 
>   Hans




Re: [PATCH 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-08 Thread Tiffany Lin
Hi Hans,

On Wed, 2016-09-07 at 11:23 +0200, Hans Verkuil wrote:
> On 09/07/16 08:56, Tiffany Lin wrote:
> > Add V4L2_PIX_FMT_MT21C documentation
> >
> > Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
> > ---
> >  Documentation/media/uapi/v4l/pixfmt-reserved.rst |6 ++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
> > b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > index 0dd2f7f..2e21fbc 100644
> > --- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > +++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > @@ -339,7 +339,13 @@ please make a proposal on the linux-media mailing list.
> >   array. Anything what's in between the UYVY lines is JPEG data and
> >   should be concatenated to form the JPEG stream.
> >
> > +-  .. _V4L2-PIX-FMT-MT21C:
> >
> > +   -  ``V4L2_PIX_FMT_MT21C``
> > +
> > +   -  'MT21C'
> > +
> > +   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
> 
> This really needs to be expanded.
> 
> Ideally this should reference the precise specification of this format if
> available.
> 

> It certainly should explain which HW blocks of the mediatek SoC use this
> format, it should explain that is it meant as an opaque intermediate format
> between those blocks.
> 

Yes. it is an opaque intermediate format.
VDEC HW only output MT21C format, and it need MDP HW to convert to other
standard format.

At first, we plan to put "convert MT21C to other standard format" in our
v4l2 decoder driver, actually in VPU firmware.
In this case, there is no need to expose MT21C format to user space.

But consider that MDP is a stand alone HW (interrupt, power, clk),
combine decode and format convert in one decode step impact performance.
VDEC HW and MDP HW could process different frame at same time.
MDP may also used by other modules to do format convert, not only VDEC.

That's why we need to expose MT21C to user space.
When user space application enumerate VDEC and display HW and found that
the format is not match.
It need to use MDP driver to do format convert.


> If you have some characteristics (i.e. is it lossy or lossless 
> compression, I
> presume it's lossless), then that will be useful to add as well.
> 
I will update this in next version.


best regards,
Tiffany

> We like to have as much information about formats as possible.
> 
> Regards,
> 
>   Hans
> 
> >
> >  .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
> >
> >




Re: [PATCH 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-08 Thread Tiffany Lin
Hi Hans,

On Wed, 2016-09-07 at 11:23 +0200, Hans Verkuil wrote:
> On 09/07/16 08:56, Tiffany Lin wrote:
> > Add V4L2_PIX_FMT_MT21C documentation
> >
> > Signed-off-by: Tiffany Lin 
> > ---
> >  Documentation/media/uapi/v4l/pixfmt-reserved.rst |6 ++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
> > b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > index 0dd2f7f..2e21fbc 100644
> > --- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > +++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
> > @@ -339,7 +339,13 @@ please make a proposal on the linux-media mailing list.
> >   array. Anything what's in between the UYVY lines is JPEG data and
> >   should be concatenated to form the JPEG stream.
> >
> > +-  .. _V4L2-PIX-FMT-MT21C:
> >
> > +   -  ``V4L2_PIX_FMT_MT21C``
> > +
> > +   -  'MT21C'
> > +
> > +   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
> 
> This really needs to be expanded.
> 
> Ideally this should reference the precise specification of this format if
> available.
> 

> It certainly should explain which HW blocks of the mediatek SoC use this
> format, it should explain that is it meant as an opaque intermediate format
> between those blocks.
> 

Yes. it is an opaque intermediate format.
VDEC HW only output MT21C format, and it need MDP HW to convert to other
standard format.

At first, we plan to put "convert MT21C to other standard format" in our
v4l2 decoder driver, actually in VPU firmware.
In this case, there is no need to expose MT21C format to user space.

But consider that MDP is a stand alone HW (interrupt, power, clk),
combine decode and format convert in one decode step impact performance.
VDEC HW and MDP HW could process different frame at same time.
MDP may also used by other modules to do format convert, not only VDEC.

That's why we need to expose MT21C to user space.
When user space application enumerate VDEC and display HW and found that
the format is not match.
It need to use MDP driver to do format convert.


> If you have some characteristics (i.e. is it lossy or lossless 
> compression, I
> presume it's lossless), then that will be useful to add as well.
> 
I will update this in next version.


best regards,
Tiffany

> We like to have as much information about formats as possible.
> 
> Regards,
> 
>   Hans
> 
> >
> >  .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
> >
> >




Re: [PATCH] [media] VPU: mediatek: fix null pointer dereference on pdev

2016-09-08 Thread Tiffany Lin
On Wed, 2016-09-07 at 18:10 +0100, Colin King wrote:
> From: Colin Ian King 
> 
> pdev is being null checked, however, prior to that it is being
> dereferenced by platform_get_drvdata.  Move the assignments of
> vpu and run to after the pdev null check to avoid a potential
> null pointer dereference.
> 

Reviewed-by:Tiffany Lin 

> Signed-off-by: Colin Ian King 
> ---
>  drivers/media/platform/mtk-vpu/mtk_vpu.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c 
> b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> index c9bf58c..43907a3 100644
> --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
> +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> @@ -523,9 +523,9 @@ static int load_requested_vpu(struct mtk_vpu *vpu,
>  
>  int vpu_load_firmware(struct platform_device *pdev)
>  {
> - struct mtk_vpu *vpu = platform_get_drvdata(pdev);
> + struct mtk_vpu *vpu;
>   struct device *dev = >dev;
> - struct vpu_run *run = >run;
> + struct vpu_run *run;
>   const struct firmware *vpu_fw = NULL;
>   int ret;
>  
> @@ -534,6 +534,9 @@ int vpu_load_firmware(struct platform_device *pdev)
>   return -EINVAL;
>   }
>  
> + vpu = platform_get_drvdata(pdev);
> + run = >run;
> +
>   mutex_lock(>vpu_mutex);
>   if (vpu->fw_loaded) {
>   mutex_unlock(>vpu_mutex);




Re: [PATCH] [media] VPU: mediatek: fix null pointer dereference on pdev

2016-09-08 Thread Tiffany Lin
On Wed, 2016-09-07 at 18:10 +0100, Colin King wrote:
> From: Colin Ian King 
> 
> pdev is being null checked, however, prior to that it is being
> dereferenced by platform_get_drvdata.  Move the assignments of
> vpu and run to after the pdev null check to avoid a potential
> null pointer dereference.
> 

Reviewed-by:Tiffany Lin 

> Signed-off-by: Colin Ian King 
> ---
>  drivers/media/platform/mtk-vpu/mtk_vpu.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c 
> b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> index c9bf58c..43907a3 100644
> --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
> +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> @@ -523,9 +523,9 @@ static int load_requested_vpu(struct mtk_vpu *vpu,
>  
>  int vpu_load_firmware(struct platform_device *pdev)
>  {
> - struct mtk_vpu *vpu = platform_get_drvdata(pdev);
> + struct mtk_vpu *vpu;
>   struct device *dev = >dev;
> - struct vpu_run *run = >run;
> + struct vpu_run *run;
>   const struct firmware *vpu_fw = NULL;
>   int ret;
>  
> @@ -534,6 +534,9 @@ int vpu_load_firmware(struct platform_device *pdev)
>   return -EINVAL;
>   }
>  
> + vpu = platform_get_drvdata(pdev);
> + run = >run;
> +
>   mutex_lock(>vpu_mutex);
>   if (vpu->fw_loaded) {
>   mutex_unlock(>vpu_mutex);




[PATCH v3] vcodec: mediatek: add Maintainers entry for Mediatek MT8173 vcodec drivers

2016-09-07 Thread Tiffany Lin
Add Tiffany Lin and Andrew-CT Chen as maintainers for
Mediatek MT8173 vcodec drivers

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
Signed-off-by: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
---
v3: Move MEDIATEK MEDIA DRIVER after MEDIATEK ETHERNET DRIVER to follow
alphabet sequence
v2: Rename MT8173 MEDIA DRIVER to MEDIATEK MEDIA DRIVER
---
 MAINTAINERS |9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a16a82..14a48cc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7597,6 +7597,15 @@ L:   net...@vger.kernel.org
 S: Maintained
 F: drivers/net/ethernet/mediatek/
 
+MEDIATEK MEDIA DRIVER
+M:     Tiffany Lin <tiffany@mediatek.com>
+M: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
+S: Supported
+F: drivers/media/platform/mtk-vcodec/
+F: drivers/media/platform/mtk-vpu/
+F: Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+F: Documentation/devicetree/bindings/media/mediatek-vpu.txt
+
 MEDIATEK MT7601U WIRELESS LAN DRIVER
 M: Jakub Kicinski <kubak...@wp.pl>
 L: linux-wirel...@vger.kernel.org
-- 
1.7.9.5



[PATCH v3] vcodec: mediatek: add Maintainers entry for Mediatek MT8173 vcodec drivers

2016-09-07 Thread Tiffany Lin
Add Tiffany Lin and Andrew-CT Chen as maintainers for
Mediatek MT8173 vcodec drivers

Signed-off-by: Tiffany Lin 
Signed-off-by: Andrew-CT Chen 
---
v3: Move MEDIATEK MEDIA DRIVER after MEDIATEK ETHERNET DRIVER to follow
alphabet sequence
v2: Rename MT8173 MEDIA DRIVER to MEDIATEK MEDIA DRIVER
---
 MAINTAINERS |9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a16a82..14a48cc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7597,6 +7597,15 @@ L:   net...@vger.kernel.org
 S: Maintained
 F: drivers/net/ethernet/mediatek/
 
+MEDIATEK MEDIA DRIVER
+M: Tiffany Lin 
+M: Andrew-CT Chen 
+S: Supported
+F: drivers/media/platform/mtk-vcodec/
+F: drivers/media/platform/mtk-vpu/
+F: Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+F: Documentation/devicetree/bindings/media/mediatek-vpu.txt
+
 MEDIATEK MT7601U WIRELESS LAN DRIVER
 M: Jakub Kicinski 
 L: linux-wirel...@vger.kernel.org
-- 
1.7.9.5



[PATCH 4/4] arm64: dts: mediatek: Add Video Decoder for MT8173

2016-09-07 Thread Tiffany Lin
Add video decoder node for MT8173

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   44 ++
 1 file changed, 44 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 10f638f..2872cd7 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -974,6 +974,50 @@
#clock-cells = <1>;
};
 
+   vcodec_dec: vcodec@1600 {
+   compatible = "mediatek,mt8173-vcodec-dec";
+   reg = <0 0x1600 0 0x100>,   /* VDEC_SYS */
+ <0 0x1602 0 0x1000>,  /* VDEC_MISC */
+ <0 0x16021000 0 0x800>,   /* VDEC_LD */
+ <0 0x16021800 0 0x800>,   /* VDEC_TOP */
+ <0 0x16022000 0 0x1000>,  /* VDEC_CM */
+ <0 0x16023000 0 0x1000>,  /* VDEC_AD */
+ <0 0x16024000 0 0x1000>,  /* VDEC_AV */
+ <0 0x16025000 0 0x1000>,  /* VDEC_PP */
+ <0 0x16026800 0 0x800>,   /* VDEC_HWD */
+ <0 0x16027000 0 0x800>,   /* VDEC_HWQ */
+ <0 0x16027800 0 0x800>,   /* VDEC_HWB */
+ <0 0x16028400 0 0x400>;   /* VDEC_HWG */
+   interrupts = ;
+   mediatek,larb = <>;
+   iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+< M4U_PORT_HW_VDEC_PP_EXT>,
+< M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+< M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+< M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+< M4U_PORT_HW_VDEC_UFO_EXT>,
+< M4U_PORT_HW_VDEC_VLD_EXT>,
+< M4U_PORT_HW_VDEC_VLD2_EXT>;
+   mediatek,vpu = <>;
+   power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+   clocks = < CLK_APMIXED_VCODECPLL>,
+< CLK_TOP_UNIVPLL_D2>,
+< CLK_TOP_CCI400_SEL>,
+< CLK_TOP_VDEC_SEL>,
+< CLK_TOP_VCODECPLL>,
+< CLK_APMIXED_VENCPLL>,
+< CLK_TOP_VENC_LT_SEL>,
+< CLK_TOP_VCODECPLL_370P5>;
+   clock-names = "vcodecpll",
+ "univpll_d2",
+ "clk_cci400_sel",
+ "vdec_sel",
+ "vdecpll",
+ "vencpll",
+ "venc_lt_sel",
+ "vdec_bus_clk_src";
+   };
+
larb1: larb@1601 {
compatible = "mediatek,mt8173-smi-larb";
reg = <0 0x1601 0 0x1000>;
-- 
1.7.9.5



[PATCH 4/4] arm64: dts: mediatek: Add Video Decoder for MT8173

2016-09-07 Thread Tiffany Lin
Add video decoder node for MT8173

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

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 10f638f..2872cd7 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -974,6 +974,50 @@
#clock-cells = <1>;
};
 
+   vcodec_dec: vcodec@1600 {
+   compatible = "mediatek,mt8173-vcodec-dec";
+   reg = <0 0x1600 0 0x100>,   /* VDEC_SYS */
+ <0 0x1602 0 0x1000>,  /* VDEC_MISC */
+ <0 0x16021000 0 0x800>,   /* VDEC_LD */
+ <0 0x16021800 0 0x800>,   /* VDEC_TOP */
+ <0 0x16022000 0 0x1000>,  /* VDEC_CM */
+ <0 0x16023000 0 0x1000>,  /* VDEC_AD */
+ <0 0x16024000 0 0x1000>,  /* VDEC_AV */
+ <0 0x16025000 0 0x1000>,  /* VDEC_PP */
+ <0 0x16026800 0 0x800>,   /* VDEC_HWD */
+ <0 0x16027000 0 0x800>,   /* VDEC_HWQ */
+ <0 0x16027800 0 0x800>,   /* VDEC_HWB */
+ <0 0x16028400 0 0x400>;   /* VDEC_HWG */
+   interrupts = ;
+   mediatek,larb = <>;
+   iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+< M4U_PORT_HW_VDEC_PP_EXT>,
+< M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+< M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+< M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+< M4U_PORT_HW_VDEC_UFO_EXT>,
+< M4U_PORT_HW_VDEC_VLD_EXT>,
+< M4U_PORT_HW_VDEC_VLD2_EXT>;
+   mediatek,vpu = <>;
+   power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+   clocks = < CLK_APMIXED_VCODECPLL>,
+< CLK_TOP_UNIVPLL_D2>,
+< CLK_TOP_CCI400_SEL>,
+< CLK_TOP_VDEC_SEL>,
+< CLK_TOP_VCODECPLL>,
+< CLK_APMIXED_VENCPLL>,
+< CLK_TOP_VENC_LT_SEL>,
+< CLK_TOP_VCODECPLL_370P5>;
+   clock-names = "vcodecpll",
+ "univpll_d2",
+ "clk_cci400_sel",
+ "vdec_sel",
+ "vdecpll",
+ "vencpll",
+ "venc_lt_sel",
+ "vdec_bus_clk_src";
+   };
+
larb1: larb@1601 {
compatible = "mediatek,mt8173-smi-larb";
reg = <0 0x1601 0 0x1000>;
-- 
1.7.9.5



[PATCH 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-07 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C documentation

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 Documentation/media/uapi/v4l/pixfmt-reserved.rst |6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
index 0dd2f7f..2e21fbc 100644
--- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
@@ -339,7 +339,13 @@ please make a proposal on the linux-media mailing list.
  array. Anything what's in between the UYVY lines is JPEG data and
  should be concatenated to form the JPEG stream.
 
+-  .. _V4L2-PIX-FMT-MT21C:
 
+   -  ``V4L2_PIX_FMT_MT21C``
+
+   -  'MT21C'
+
+   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
 
 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
 
-- 
1.7.9.5



[PATCH 1/4] v4l: add Mediatek compressed video block format

2016-09-07 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C format used on MT8173 driver.
It is compressed format and need MT8173 MDP driver to transfer to other
standard format.

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c |1 +
 include/uapi/linux/videodev2.h   |1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 2bd1581..1d45c58 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1288,6 +1288,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_JPGL: descr = "JPEG Lite"; break;
case V4L2_PIX_FMT_SE401:descr = "GSPCA SE401"; break;
case V4L2_PIX_FMT_S5C_UYVY_JPG: descr = "S5C73MX interleaved 
UYVY/JPEG"; break;
+   case V4L2_PIX_FMT_MT21C:descr = "Mediatek Compressed 
Format"; break;
default:
WARN(1, "Unknown pixelformat 0x%08x\n", 
fmt->pixelformat);
if (fmt->description[0])
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 43326c3..ddd0083 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -635,6 +635,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_Y8I  v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 
8-bit L/R interleaved */
 #define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 
12-bit L/R interleaved */
 #define V4L2_PIX_FMT_Z16  v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 
16-bit */
+#define V4L2_PIX_FMT_MT21Cv4l2_fourcc('M', 'T', '2', '1') /* Mediatek 
compressed block mode  */
 
 /* SDR formats - used only for Software Defined Radio devices */
 #define V4L2_SDR_FMT_CU8  v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
-- 
1.7.9.5



[PATCH 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-07 Thread Tiffany Lin
This patch series add Mediatek compressed block format V4L2_PIX_FMT_MT21C, the
decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.

User space applications could use MT8173 MDP driver to convert 
V4L2_PIX_FMT_MT21C to
V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.

MDP driver[1] is stand alone driver.

Usage:
MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420
NV12M/NV21M/YUV420M/YVU420M -> mt8173 Encoder -> H264/VP8
H264/VP8/VP9 -> mtk8173 Decoder -> MT21C

When encode with MT21 source, the pipeline will be:
MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8

When playback, the pipeline will be:
H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM

[1]https://patchwork.kernel.org/patch/9305329/

Tiffany Lin (4):
  v4l: add Mediatek compressed video block format
  docs-rst: Add compressed video formats used on MT8173 codec driver
  vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
  arm64: dts: mediatek: Add Video Decoder for MT8173

 Documentation/media/uapi/v4l/pixfmt-reserved.rst   |6 +++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
 drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
 include/uapi/linux/videodev2.h |1 +
 5 files changed, 58 insertions(+), 1 deletion(-)

-- 
1.7.9.5



[PATCH 2/4] docs-rst: Add compressed video formats used on MT8173 codec driver

2016-09-07 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C documentation

Signed-off-by: Tiffany Lin 
---
 Documentation/media/uapi/v4l/pixfmt-reserved.rst |6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/media/uapi/v4l/pixfmt-reserved.rst 
b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
index 0dd2f7f..2e21fbc 100644
--- a/Documentation/media/uapi/v4l/pixfmt-reserved.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-reserved.rst
@@ -339,7 +339,13 @@ please make a proposal on the linux-media mailing list.
  array. Anything what's in between the UYVY lines is JPEG data and
  should be concatenated to form the JPEG stream.
 
+-  .. _V4L2-PIX-FMT-MT21C:
 
+   -  ``V4L2_PIX_FMT_MT21C``
+
+   -  'MT21C'
+
+   -  Compressed two-planar YVU420 format used by Mediatek MT8173.
 
 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
 
-- 
1.7.9.5



[PATCH 1/4] v4l: add Mediatek compressed video block format

2016-09-07 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C format used on MT8173 driver.
It is compressed format and need MT8173 MDP driver to transfer to other
standard format.

Signed-off-by: Tiffany Lin 
---
 drivers/media/v4l2-core/v4l2-ioctl.c |1 +
 include/uapi/linux/videodev2.h   |1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 2bd1581..1d45c58 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1288,6 +1288,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_JPGL: descr = "JPEG Lite"; break;
case V4L2_PIX_FMT_SE401:descr = "GSPCA SE401"; break;
case V4L2_PIX_FMT_S5C_UYVY_JPG: descr = "S5C73MX interleaved 
UYVY/JPEG"; break;
+   case V4L2_PIX_FMT_MT21C:descr = "Mediatek Compressed 
Format"; break;
default:
WARN(1, "Unknown pixelformat 0x%08x\n", 
fmt->pixelformat);
if (fmt->description[0])
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 43326c3..ddd0083 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -635,6 +635,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_Y8I  v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 
8-bit L/R interleaved */
 #define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 
12-bit L/R interleaved */
 #define V4L2_PIX_FMT_Z16  v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 
16-bit */
+#define V4L2_PIX_FMT_MT21Cv4l2_fourcc('M', 'T', '2', '1') /* Mediatek 
compressed block mode  */
 
 /* SDR formats - used only for Software Defined Radio devices */
 #define V4L2_SDR_FMT_CU8  v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
-- 
1.7.9.5



[PATCH 0/4] Add V4L2_PIX_FMT_MT21C format for MT8173 codec driver

2016-09-07 Thread Tiffany Lin
This patch series add Mediatek compressed block format V4L2_PIX_FMT_MT21C, the
decoder driver will decoded bitstream to V4L2_PIX_FMT_MT21C format.

User space applications could use MT8173 MDP driver to convert 
V4L2_PIX_FMT_MT21C to
V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M and V4L2_PIX_FMT_YVU420.

MDP driver[1] is stand alone driver.

Usage:
MT21C -> MT8173 MDP -> NV12M/YUV420M/YVU420
NV12M/NV21M/YUV420M/YVU420M -> mt8173 Encoder -> H264/VP8
H264/VP8/VP9 -> mtk8173 Decoder -> MT21C

When encode with MT21 source, the pipeline will be:
MT21C -> MDP driver-> NV12M/NV21M/YUV420M/YVU420M -> Encoder -> H264/VP8

When playback, the pipeline will be:
H264/VP8/VP9 -> Decoder driver -> MT21C -> MDP Driver -> DRM

[1]https://patchwork.kernel.org/patch/9305329/

Tiffany Lin (4):
  v4l: add Mediatek compressed video block format
  docs-rst: Add compressed video formats used on MT8173 codec driver
  vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
  arm64: dts: mediatek: Add Video Decoder for MT8173

 Documentation/media/uapi/v4l/pixfmt-reserved.rst   |6 +++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   44 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 +++-
 drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
 include/uapi/linux/videodev2.h |1 +
 5 files changed, 58 insertions(+), 1 deletion(-)

-- 
1.7.9.5



[PATCH 3/4] vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder

2016-09-07 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C support

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 28a8453..fd3befc 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -25,7 +25,7 @@
 #include "mtk_vcodec_dec_pm.h"
 
 #define OUT_FMT_IDX0
-#define CAP_FMT_IDX0
+#define CAP_FMT_IDX3
 
 #define MTK_VDEC_MIN_W 64U
 #define MTK_VDEC_MIN_H 64U
@@ -48,6 +48,11 @@ static struct mtk_video_fmt mtk_video_formats[] = {
.type = MTK_FMT_DEC,
.num_planes = 1,
},
+   {
+   .fourcc = V4L2_PIX_FMT_MT21C,
+   .type = MTK_FMT_FRAME,
+   .num_planes = 2,
+   },
 };
 
 static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
-- 
1.7.9.5



[PATCH 3/4] vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder

2016-09-07 Thread Tiffany Lin
Add V4L2_PIX_FMT_MT21C support

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

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 28a8453..fd3befc 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -25,7 +25,7 @@
 #include "mtk_vcodec_dec_pm.h"
 
 #define OUT_FMT_IDX0
-#define CAP_FMT_IDX0
+#define CAP_FMT_IDX3
 
 #define MTK_VDEC_MIN_W 64U
 #define MTK_VDEC_MIN_H 64U
@@ -48,6 +48,11 @@ static struct mtk_video_fmt mtk_video_formats[] = {
.type = MTK_FMT_DEC,
.num_planes = 1,
},
+   {
+   .fourcc = V4L2_PIX_FMT_MT21C,
+   .type = MTK_FMT_FRAME,
+   .num_planes = 2,
+   },
 };
 
 static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
-- 
1.7.9.5



[PATCH v2] vcodec: mediatek: add Maintainers entry for Mediatek MT8173 vcodec drivers

2016-09-07 Thread Tiffany Lin
Add Tiffany Lin and Andrew-CT Chen as maintainers for
Mediatek MT8173 vcodec drivers

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
Signed-off-by: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
---
v2: Rename MT8173 MEDIA DRIVER to MEDIATEK MEDIA DRIVER
---
 MAINTAINERS |9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a16a82..96854c1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7590,6 +7590,15 @@ F:   include/uapi/linux/meye.h
 F: include/uapi/linux/ivtv*
 F: include/uapi/linux/uvcvideo.h
 
+MEDIATEK MEDIA DRIVER
+M:     Tiffany Lin <tiffany@mediatek.com>
+M: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
+S: Supported
+F: drivers/media/platform/mtk-vcodec/
+F: drivers/media/platform/mtk-vpu/
+F: Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+F: Documentation/devicetree/bindings/media/mediatek-vpu.txt
+
 MEDIATEK ETHERNET DRIVER
 M: Felix Fietkau <n...@openwrt.org>
 M: John Crispin <blo...@openwrt.org>
-- 
1.7.9.5



[PATCH v2] vcodec: mediatek: add Maintainers entry for Mediatek MT8173 vcodec drivers

2016-09-07 Thread Tiffany Lin
Add Tiffany Lin and Andrew-CT Chen as maintainers for
Mediatek MT8173 vcodec drivers

Signed-off-by: Tiffany Lin 
Signed-off-by: Andrew-CT Chen 
---
v2: Rename MT8173 MEDIA DRIVER to MEDIATEK MEDIA DRIVER
---
 MAINTAINERS |9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a16a82..96854c1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7590,6 +7590,15 @@ F:   include/uapi/linux/meye.h
 F: include/uapi/linux/ivtv*
 F: include/uapi/linux/uvcvideo.h
 
+MEDIATEK MEDIA DRIVER
+M: Tiffany Lin 
+M: Andrew-CT Chen 
+S: Supported
+F: drivers/media/platform/mtk-vcodec/
+F: drivers/media/platform/mtk-vpu/
+F: Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+F: Documentation/devicetree/bindings/media/mediatek-vpu.txt
+
 MEDIATEK ETHERNET DRIVER
 M: Felix Fietkau 
 M: John Crispin 
-- 
1.7.9.5



[PATCH] vcodec: mediatek: Fix decoder compiler/sparse warnings

2016-09-07 Thread Tiffany Lin
This patch fix decoder compiler/sparse warnings

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 .../media/platform/mtk-vcodec/vdec/vdec_h264_if.c  |7 ---
 .../media/platform/mtk-vcodec/vdec/vdec_vp8_if.c   |1 +
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   |4 ++--
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c|6 --
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
index 0353a47..57a842f 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
@@ -239,7 +239,7 @@ static void put_fb_to_free(struct vdec_h264_inst *inst, 
struct vdec_fb *fb)
mtk_vcodec_debug(inst, "[FB] put fb into free_list @(%p, %llx)",
 fb->base_y.va, (u64)fb->base_y.dma_addr);
 
-   list->fb_list[list->write_idx].vdec_fb_va = (u64)fb;
+   list->fb_list[list->write_idx].vdec_fb_va = (u64)(uintptr_t)fb;
list->write_idx = (list->write_idx == H264_MAX_FB_NUM - 1) ?
  0 : list->write_idx + 1;
list->count++;
@@ -350,7 +350,7 @@ static int vdec_h264_decode(unsigned long h_vdec, struct 
mtk_vcodec_mem *bs,
unsigned char *buf;
unsigned int buf_sz;
unsigned int data[2];
-   uint64_t vdec_fb_va = (u64)fb;
+   uint64_t vdec_fb_va = (u64)(uintptr_t)fb;
uint64_t y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
uint64_t c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
 
@@ -443,7 +443,8 @@ static void vdec_h264_get_fb(struct vdec_h264_inst *inst,
return;
}
 
-   fb = (struct vdec_fb *)list->fb_list[list->read_idx].vdec_fb_va;
+   fb = (struct vdec_fb *)
+   (uintptr_t)list->fb_list[list->read_idx].vdec_fb_va;
fb->status |= (disp_list ? FB_ST_DISPLAY : FB_ST_FREE);
 
*out_fb = fb;
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
index d4fce3e..054d4d1 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
@@ -13,6 +13,7 @@
  * GNU General Public License for more details.
  */
 
+#include 
 #include "../vdec_drv_if.h"
 #include "../mtk_vcodec_util.h"
 #include "../mtk_vcodec_dec.h"
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
index 60a7b00..ca3174d 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
@@ -475,7 +475,7 @@ static void vp9_swap_frm_bufs(struct vdec_vp9_inst *inst)
 */
if (frm_to_show->fb != NULL)
mtk_vcodec_err(inst,
-   "inst->cur_fb->base_y.size=%lx, 
frm_to_show->fb.base_y.size=%lx",
+   "inst->cur_fb->base_y.size=%zu, 
frm_to_show->fb.base_y.size=%zu",
inst->cur_fb->base_y.size,
frm_to_show->fb->base_y.size);
}
@@ -791,7 +791,7 @@ static int vdec_vp9_decode(unsigned long h_vdec, struct 
mtk_vcodec_mem *bs,
return -EINVAL;
}
 
-   mtk_vcodec_debug(inst, "Input BS Size = %ld", bs->size);
+   mtk_vcodec_debug(inst, "Input BS Size = %zu", bs->size);
 
while (1) {
struct vdec_fb *cur_fb = NULL;
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index 0798a6b..5a24c51 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -19,7 +19,8 @@
 
 static void handle_init_ack_msg(struct vdec_vpu_ipi_init_ack *msg)
 {
-   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)msg->ap_inst_addr;
+   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
+   (unsigned long)msg->ap_inst_addr;
 
mtk_vcodec_debug(vpu, "+ ap_inst_addr = 0x%llx", msg->ap_inst_addr);
 
@@ -38,7 +39,8 @@ static void handle_init_ack_msg(struct vdec_vpu_ipi_init_ack 
*msg)
 void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
 {
struct vdec_vpu_ipi_ack *msg = data;
-   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)msg->ap_inst_addr;
+   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
+   (unsigned long)msg->ap_inst_addr;
 
mtk_vcodec_debug(vpu, "+ id=%X", msg->msg_id);
 
-- 
1.7.9.5



[PATCH] vcodec: mediatek: Fix decoder compiler/sparse warnings

2016-09-07 Thread Tiffany Lin
This patch fix decoder compiler/sparse warnings

Signed-off-by: Tiffany Lin 
---
 .../media/platform/mtk-vcodec/vdec/vdec_h264_if.c  |7 ---
 .../media/platform/mtk-vcodec/vdec/vdec_vp8_if.c   |1 +
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   |4 ++--
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c|6 --
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
index 0353a47..57a842f 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
@@ -239,7 +239,7 @@ static void put_fb_to_free(struct vdec_h264_inst *inst, 
struct vdec_fb *fb)
mtk_vcodec_debug(inst, "[FB] put fb into free_list @(%p, %llx)",
 fb->base_y.va, (u64)fb->base_y.dma_addr);
 
-   list->fb_list[list->write_idx].vdec_fb_va = (u64)fb;
+   list->fb_list[list->write_idx].vdec_fb_va = (u64)(uintptr_t)fb;
list->write_idx = (list->write_idx == H264_MAX_FB_NUM - 1) ?
  0 : list->write_idx + 1;
list->count++;
@@ -350,7 +350,7 @@ static int vdec_h264_decode(unsigned long h_vdec, struct 
mtk_vcodec_mem *bs,
unsigned char *buf;
unsigned int buf_sz;
unsigned int data[2];
-   uint64_t vdec_fb_va = (u64)fb;
+   uint64_t vdec_fb_va = (u64)(uintptr_t)fb;
uint64_t y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
uint64_t c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
 
@@ -443,7 +443,8 @@ static void vdec_h264_get_fb(struct vdec_h264_inst *inst,
return;
}
 
-   fb = (struct vdec_fb *)list->fb_list[list->read_idx].vdec_fb_va;
+   fb = (struct vdec_fb *)
+   (uintptr_t)list->fb_list[list->read_idx].vdec_fb_va;
fb->status |= (disp_list ? FB_ST_DISPLAY : FB_ST_FREE);
 
*out_fb = fb;
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
index d4fce3e..054d4d1 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
@@ -13,6 +13,7 @@
  * GNU General Public License for more details.
  */
 
+#include 
 #include "../vdec_drv_if.h"
 #include "../mtk_vcodec_util.h"
 #include "../mtk_vcodec_dec.h"
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
index 60a7b00..ca3174d 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
@@ -475,7 +475,7 @@ static void vp9_swap_frm_bufs(struct vdec_vp9_inst *inst)
 */
if (frm_to_show->fb != NULL)
mtk_vcodec_err(inst,
-   "inst->cur_fb->base_y.size=%lx, 
frm_to_show->fb.base_y.size=%lx",
+   "inst->cur_fb->base_y.size=%zu, 
frm_to_show->fb.base_y.size=%zu",
inst->cur_fb->base_y.size,
frm_to_show->fb->base_y.size);
}
@@ -791,7 +791,7 @@ static int vdec_vp9_decode(unsigned long h_vdec, struct 
mtk_vcodec_mem *bs,
return -EINVAL;
}
 
-   mtk_vcodec_debug(inst, "Input BS Size = %ld", bs->size);
+   mtk_vcodec_debug(inst, "Input BS Size = %zu", bs->size);
 
while (1) {
struct vdec_fb *cur_fb = NULL;
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index 0798a6b..5a24c51 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -19,7 +19,8 @@
 
 static void handle_init_ack_msg(struct vdec_vpu_ipi_init_ack *msg)
 {
-   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)msg->ap_inst_addr;
+   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
+   (unsigned long)msg->ap_inst_addr;
 
mtk_vcodec_debug(vpu, "+ ap_inst_addr = 0x%llx", msg->ap_inst_addr);
 
@@ -38,7 +39,8 @@ static void handle_init_ack_msg(struct vdec_vpu_ipi_init_ack 
*msg)
 void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
 {
struct vdec_vpu_ipi_ack *msg = data;
-   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)msg->ap_inst_addr;
+   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
+   (unsigned long)msg->ap_inst_addr;
 
mtk_vcodec_debug(vpu, "+ id=%X", msg->msg_id);
 
-- 
1.7.9.5



Re: [PATCH] vcodec: mediatek: fix odd_ptr_err.cocci warnings

2016-09-06 Thread Tiffany Lin
On Tue, 2016-09-06 at 22:51 +0800, Julia Lawall wrote:
> PTR_ERR should access the value just tested by IS_ERR
> 
> Generated by: scripts/coccinelle/tests/odd_ptr_err.cocci
> 
> CC: Tiffany Lin <tiffany@mediatek.com>
> Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
> Signed-off-by: Fengguang Wu <fengguang...@intel.com>

Reviewed-by:Tiffany Lin <tiffany@mediatek.com>

> ---
> 
>  mtk_vcodec_dec_drv.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> @@ -255,7 +255,7 @@ static int mtk_vcodec_probe(struct platf
>   }
>   dev->reg_base[i] = devm_ioremap_resource(>dev, res);
>   if (IS_ERR((__force void *)dev->reg_base[i])) {
> - ret = PTR_ERR((__force void *)dev->reg_base);
> + ret = PTR_ERR((__force void *)dev->reg_base[i]);
>   goto err_res;
>   }
>   mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]);




Re: [PATCH] vcodec: mediatek: fix odd_ptr_err.cocci warnings

2016-09-06 Thread Tiffany Lin
On Tue, 2016-09-06 at 22:51 +0800, Julia Lawall wrote:
> PTR_ERR should access the value just tested by IS_ERR
> 
> Generated by: scripts/coccinelle/tests/odd_ptr_err.cocci
> 
> CC: Tiffany Lin 
> Signed-off-by: Julia Lawall 
> Signed-off-by: Fengguang Wu 

Reviewed-by:Tiffany Lin 

> ---
> 
>  mtk_vcodec_dec_drv.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> @@ -255,7 +255,7 @@ static int mtk_vcodec_probe(struct platf
>   }
>   dev->reg_base[i] = devm_ioremap_resource(>dev, res);
>   if (IS_ERR((__force void *)dev->reg_base[i])) {
> - ret = PTR_ERR((__force void *)dev->reg_base);
> + ret = PTR_ERR((__force void *)dev->reg_base[i]);
>   goto err_res;
>   }
>   mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]);




[PATCH] vcodec: mediatek: add Maintainers entry for Mediatek MT8173 vcodec drivers

2016-09-06 Thread Tiffany Lin
Add Tiffany Lin and Andrew-CT Chen as maintainers for
Mediatek MT8173 vcodec drivers

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
Signed-off-by: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
---
 MAINTAINERS |9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a16a82..ed830c7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7590,6 +7590,15 @@ F:   include/uapi/linux/meye.h
 F: include/uapi/linux/ivtv*
 F: include/uapi/linux/uvcvideo.h
 
+MT8173 MEDIA DRIVER
+M:     Tiffany Lin <tiffany@mediatek.com>
+M: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
+S: Supported
+F: drivers/media/platform/mtk-vcodec/
+F: drivers/media/platform/mtk-vpu/
+F: Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+F: Documentation/devicetree/bindings/media/mediatek-vpu.txt
+
 MEDIATEK ETHERNET DRIVER
 M: Felix Fietkau <n...@openwrt.org>
 M: John Crispin <blo...@openwrt.org>
-- 
1.7.9.5



[PATCH] vcodec: mediatek: add Maintainers entry for Mediatek MT8173 vcodec drivers

2016-09-06 Thread Tiffany Lin
Add Tiffany Lin and Andrew-CT Chen as maintainers for
Mediatek MT8173 vcodec drivers

Signed-off-by: Tiffany Lin 
Signed-off-by: Andrew-CT Chen 
---
 MAINTAINERS |9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a16a82..ed830c7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7590,6 +7590,15 @@ F:   include/uapi/linux/meye.h
 F: include/uapi/linux/ivtv*
 F: include/uapi/linux/uvcvideo.h
 
+MT8173 MEDIA DRIVER
+M: Tiffany Lin 
+M: Andrew-CT Chen 
+S: Supported
+F: drivers/media/platform/mtk-vcodec/
+F: drivers/media/platform/mtk-vpu/
+F: Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+F: Documentation/devicetree/bindings/media/mediatek-vpu.txt
+
 MEDIATEK ETHERNET DRIVER
 M: Felix Fietkau 
 M: John Crispin 
-- 
1.7.9.5



[PATCH] vcodec: mediatek: Add V4L2_CAP_TIMEPERFRAME capability setting

2016-09-05 Thread Tiffany Lin
This patch setting V4L2_CAP_TIMEPERFRAME capability in
vidioc_venc_s/g_parm functions

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index 34fd89c..d0c2b9a 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -243,6 +243,8 @@ static int vidioc_venc_s_parm(struct file *file, void *priv,
a->parm.output.timeperframe.numerator;
ctx->param_change |= MTK_ENCODE_PARAM_FRAMERATE;
 
+   a->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
+
return 0;
 }
 
@@ -254,6 +256,7 @@ static int vidioc_venc_g_parm(struct file *file, void *priv,
if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
return -EINVAL;
 
+   a->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
a->parm.output.timeperframe.denominator =
ctx->enc_params.framerate_num;
a->parm.output.timeperframe.numerator =
-- 
1.7.9.5



[PATCH] vcodec: mediatek: Add V4L2_CAP_TIMEPERFRAME capability setting

2016-09-05 Thread Tiffany Lin
This patch setting V4L2_CAP_TIMEPERFRAME capability in
vidioc_venc_s/g_parm functions

Signed-off-by: Tiffany Lin 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index 34fd89c..d0c2b9a 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -243,6 +243,8 @@ static int vidioc_venc_s_parm(struct file *file, void *priv,
a->parm.output.timeperframe.numerator;
ctx->param_change |= MTK_ENCODE_PARAM_FRAMERATE;
 
+   a->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
+
return 0;
 }
 
@@ -254,6 +256,7 @@ static int vidioc_venc_g_parm(struct file *file, void *priv,
if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
return -EINVAL;
 
+   a->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
a->parm.output.timeperframe.denominator =
ctx->enc_params.framerate_num;
a->parm.output.timeperframe.numerator =
-- 
1.7.9.5



Re: [PATCH v5 0/9] Add MT8173 Video Decoder Driver

2016-09-05 Thread Tiffany Lin
Hi Hans,

On Mon, 2016-09-05 at 13:26 +0200, Hans Verkuil wrote:
> On 09/05/2016 12:52 PM, Tiffany Lin wrote:
> > Hi Hans,
> > 
> > On Mon, 2016-09-05 at 12:09 +0200, Hans Verkuil wrote:
> >> On 09/05/2016 11:53 AM, Hans Verkuil wrote:
> >>> On 09/05/2016 11:50 AM, Tiffany Lin wrote:
> >>>> Hi Hans,
> >>>>
> >>>> On Mon, 2016-09-05 at 11:33 +0200, Hans Verkuil wrote:
> >>>>> On 09/02/2016 02:19 PM, Tiffany Lin wrote:
> >>>>>> ==
> >>>>>>  Introduction
> >>>>>> ==
> >>>>>>
> >>>>>> The purpose of this series is to add the driver for video codec hw 
> >>>>>> embedded in the Mediatek's MT8173 SoCs.
> >>>>>> Mediatek Video Codec is able to handle video decoding and encoding of 
> >>>>>> in a range of formats.
> >>>>>>
> >>>>>> This patch series rely on MTK VPU driver that have been merged in 
> >>>>>> v4.8-rc1.
> >>>>>> Mediatek Video Decoder driver rely on VPU driver to load, communicate 
> >>>>>> with VPU.
> >>>>>>
> >>>>>> Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK 
> >>>>>> SMI both have been merged in v4.6-rc1.
> >>>>>>
> >>>>>> [1]https://chromium-review.googlesource.com/#/c/245241/
> >>>>>
> >>>>> This patch series fails to apply to the media_tree master (patch 3/9). 
> >>>>> Can you rebase and repost?
> >>>>>
> >>>>> I'm ready to make a pull request for this, so I hope you can fix this 
> >>>>> soon.
> >>>>>
> >>>> I saw Encoder fix patches in fixes branch.
> >>>> This patch series is base on Encoder fix patches. 
> >>>>
> >>>> [media] vcodec:mediatek: Refine VP8 encoder driver
> >>>> [media] vcodec:mediatek: Refine H264 encoder driver
> >>>> [media] vcodec:mediatek: change H264 profile default to profile high
> >>>> [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2
> >>>> Encoder
> >>>> [media] vcodec:mediatek: Fix visible_height larger than coded_height
> >>>> issue in s_fmt_out
> >>>> [media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder
> >>>> [media] vcodec:mediatek:code refine for v4l2 Encoder driver
> >>>> [media] dvb_frontend: Use memdup_user() rather than duplicating its
> >>>> implementation
> >>>>
> >>>>
> >>>> If I do not rebase decoder patch series base on Encoder fix pathces.
> >>>> Then it will fail after Encoder fix patches merged.
> >>>>
> >>>> May I know what parent patch I need to rebase to to fix this issue?
> >>>
> >>> Ah, OK. I will retest placing this on top of those fixes. I forgot about 
> >>> the
> >>> pending fixes. I'll handle this.
> >>
> >> OK, that works much better when it is on top of the fixes.
> >>
> >> Only one thing is missing: an entry in the MAINTAINERS file. Strange that 
> >> that
> >> wasn't done for the encoder driver, we must have missed that. So can you 
> >> make a
> >> patch adding the en/decoder driver to this file? I'm ready to make the pull
> >> request once I have that.
> >>
> > Got it. I will check and update it.
> > 
> > I have a question about decoder device node.
> > In v5 decoder patch series, I do not add device node patch at end of
> > patch series.
> > I plain to put it in MT21C format patch series, is it ok?
> 
> What is the reason for not adding it in the decoder patch series?
> 

It is because our decoder HW only support MT21C format.


best regards,
Tiffany

> Regards,
> 
>   Hans




Re: [PATCH v5 0/9] Add MT8173 Video Decoder Driver

2016-09-05 Thread Tiffany Lin
Hi Hans,

On Mon, 2016-09-05 at 13:26 +0200, Hans Verkuil wrote:
> On 09/05/2016 12:52 PM, Tiffany Lin wrote:
> > Hi Hans,
> > 
> > On Mon, 2016-09-05 at 12:09 +0200, Hans Verkuil wrote:
> >> On 09/05/2016 11:53 AM, Hans Verkuil wrote:
> >>> On 09/05/2016 11:50 AM, Tiffany Lin wrote:
> >>>> Hi Hans,
> >>>>
> >>>> On Mon, 2016-09-05 at 11:33 +0200, Hans Verkuil wrote:
> >>>>> On 09/02/2016 02:19 PM, Tiffany Lin wrote:
> >>>>>> ==
> >>>>>>  Introduction
> >>>>>> ==
> >>>>>>
> >>>>>> The purpose of this series is to add the driver for video codec hw 
> >>>>>> embedded in the Mediatek's MT8173 SoCs.
> >>>>>> Mediatek Video Codec is able to handle video decoding and encoding of 
> >>>>>> in a range of formats.
> >>>>>>
> >>>>>> This patch series rely on MTK VPU driver that have been merged in 
> >>>>>> v4.8-rc1.
> >>>>>> Mediatek Video Decoder driver rely on VPU driver to load, communicate 
> >>>>>> with VPU.
> >>>>>>
> >>>>>> Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK 
> >>>>>> SMI both have been merged in v4.6-rc1.
> >>>>>>
> >>>>>> [1]https://chromium-review.googlesource.com/#/c/245241/
> >>>>>
> >>>>> This patch series fails to apply to the media_tree master (patch 3/9). 
> >>>>> Can you rebase and repost?
> >>>>>
> >>>>> I'm ready to make a pull request for this, so I hope you can fix this 
> >>>>> soon.
> >>>>>
> >>>> I saw Encoder fix patches in fixes branch.
> >>>> This patch series is base on Encoder fix patches. 
> >>>>
> >>>> [media] vcodec:mediatek: Refine VP8 encoder driver
> >>>> [media] vcodec:mediatek: Refine H264 encoder driver
> >>>> [media] vcodec:mediatek: change H264 profile default to profile high
> >>>> [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2
> >>>> Encoder
> >>>> [media] vcodec:mediatek: Fix visible_height larger than coded_height
> >>>> issue in s_fmt_out
> >>>> [media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder
> >>>> [media] vcodec:mediatek:code refine for v4l2 Encoder driver
> >>>> [media] dvb_frontend: Use memdup_user() rather than duplicating its
> >>>> implementation
> >>>>
> >>>>
> >>>> If I do not rebase decoder patch series base on Encoder fix pathces.
> >>>> Then it will fail after Encoder fix patches merged.
> >>>>
> >>>> May I know what parent patch I need to rebase to to fix this issue?
> >>>
> >>> Ah, OK. I will retest placing this on top of those fixes. I forgot about 
> >>> the
> >>> pending fixes. I'll handle this.
> >>
> >> OK, that works much better when it is on top of the fixes.
> >>
> >> Only one thing is missing: an entry in the MAINTAINERS file. Strange that 
> >> that
> >> wasn't done for the encoder driver, we must have missed that. So can you 
> >> make a
> >> patch adding the en/decoder driver to this file? I'm ready to make the pull
> >> request once I have that.
> >>
> > Got it. I will check and update it.
> > 
> > I have a question about decoder device node.
> > In v5 decoder patch series, I do not add device node patch at end of
> > patch series.
> > I plain to put it in MT21C format patch series, is it ok?
> 
> What is the reason for not adding it in the decoder patch series?
> 

It is because our decoder HW only support MT21C format.


best regards,
Tiffany

> Regards,
> 
>   Hans




Re: [PATCH v5 0/9] Add MT8173 Video Decoder Driver

2016-09-05 Thread Tiffany Lin
Hi Hans,

On Mon, 2016-09-05 at 12:09 +0200, Hans Verkuil wrote:
> On 09/05/2016 11:53 AM, Hans Verkuil wrote:
> > On 09/05/2016 11:50 AM, Tiffany Lin wrote:
> >> Hi Hans,
> >>
> >> On Mon, 2016-09-05 at 11:33 +0200, Hans Verkuil wrote:
> >>> On 09/02/2016 02:19 PM, Tiffany Lin wrote:
> >>>> ==
> >>>>  Introduction
> >>>> ==
> >>>>
> >>>> The purpose of this series is to add the driver for video codec hw 
> >>>> embedded in the Mediatek's MT8173 SoCs.
> >>>> Mediatek Video Codec is able to handle video decoding and encoding of in 
> >>>> a range of formats.
> >>>>
> >>>> This patch series rely on MTK VPU driver that have been merged in 
> >>>> v4.8-rc1.
> >>>> Mediatek Video Decoder driver rely on VPU driver to load, communicate 
> >>>> with VPU.
> >>>>
> >>>> Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK 
> >>>> SMI both have been merged in v4.6-rc1.
> >>>>
> >>>> [1]https://chromium-review.googlesource.com/#/c/245241/
> >>>
> >>> This patch series fails to apply to the media_tree master (patch 3/9). 
> >>> Can you rebase and repost?
> >>>
> >>> I'm ready to make a pull request for this, so I hope you can fix this 
> >>> soon.
> >>>
> >> I saw Encoder fix patches in fixes branch.
> >> This patch series is base on Encoder fix patches. 
> >>
> >> [media] vcodec:mediatek: Refine VP8 encoder driver
> >> [media] vcodec:mediatek: Refine H264 encoder driver
> >> [media] vcodec:mediatek: change H264 profile default to profile high
> >> [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2
> >> Encoder
> >> [media] vcodec:mediatek: Fix visible_height larger than coded_height
> >> issue in s_fmt_out
> >> [media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder
> >> [media] vcodec:mediatek:code refine for v4l2 Encoder driver
> >> [media] dvb_frontend: Use memdup_user() rather than duplicating its
> >> implementation
> >>
> >>
> >> If I do not rebase decoder patch series base on Encoder fix pathces.
> >> Then it will fail after Encoder fix patches merged.
> >>
> >> May I know what parent patch I need to rebase to to fix this issue?
> > 
> > Ah, OK. I will retest placing this on top of those fixes. I forgot about the
> > pending fixes. I'll handle this.
> 
> OK, that works much better when it is on top of the fixes.
> 
> Only one thing is missing: an entry in the MAINTAINERS file. Strange that that
> wasn't done for the encoder driver, we must have missed that. So can you make 
> a
> patch adding the en/decoder driver to this file? I'm ready to make the pull
> request once I have that.
> 
Got it. I will check and update it.

I have a question about decoder device node.
In v5 decoder patch series, I do not add device node patch at end of
patch series.
I plain to put it in MT21C format patch series, is it ok?


best regards,
Tiffany



> Regards,
> 
>   Hans




Re: [PATCH v5 0/9] Add MT8173 Video Decoder Driver

2016-09-05 Thread Tiffany Lin
Hi Hans,

On Mon, 2016-09-05 at 12:09 +0200, Hans Verkuil wrote:
> On 09/05/2016 11:53 AM, Hans Verkuil wrote:
> > On 09/05/2016 11:50 AM, Tiffany Lin wrote:
> >> Hi Hans,
> >>
> >> On Mon, 2016-09-05 at 11:33 +0200, Hans Verkuil wrote:
> >>> On 09/02/2016 02:19 PM, Tiffany Lin wrote:
> >>>> ==
> >>>>  Introduction
> >>>> ==
> >>>>
> >>>> The purpose of this series is to add the driver for video codec hw 
> >>>> embedded in the Mediatek's MT8173 SoCs.
> >>>> Mediatek Video Codec is able to handle video decoding and encoding of in 
> >>>> a range of formats.
> >>>>
> >>>> This patch series rely on MTK VPU driver that have been merged in 
> >>>> v4.8-rc1.
> >>>> Mediatek Video Decoder driver rely on VPU driver to load, communicate 
> >>>> with VPU.
> >>>>
> >>>> Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK 
> >>>> SMI both have been merged in v4.6-rc1.
> >>>>
> >>>> [1]https://chromium-review.googlesource.com/#/c/245241/
> >>>
> >>> This patch series fails to apply to the media_tree master (patch 3/9). 
> >>> Can you rebase and repost?
> >>>
> >>> I'm ready to make a pull request for this, so I hope you can fix this 
> >>> soon.
> >>>
> >> I saw Encoder fix patches in fixes branch.
> >> This patch series is base on Encoder fix patches. 
> >>
> >> [media] vcodec:mediatek: Refine VP8 encoder driver
> >> [media] vcodec:mediatek: Refine H264 encoder driver
> >> [media] vcodec:mediatek: change H264 profile default to profile high
> >> [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2
> >> Encoder
> >> [media] vcodec:mediatek: Fix visible_height larger than coded_height
> >> issue in s_fmt_out
> >> [media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder
> >> [media] vcodec:mediatek:code refine for v4l2 Encoder driver
> >> [media] dvb_frontend: Use memdup_user() rather than duplicating its
> >> implementation
> >>
> >>
> >> If I do not rebase decoder patch series base on Encoder fix pathces.
> >> Then it will fail after Encoder fix patches merged.
> >>
> >> May I know what parent patch I need to rebase to to fix this issue?
> > 
> > Ah, OK. I will retest placing this on top of those fixes. I forgot about the
> > pending fixes. I'll handle this.
> 
> OK, that works much better when it is on top of the fixes.
> 
> Only one thing is missing: an entry in the MAINTAINERS file. Strange that that
> wasn't done for the encoder driver, we must have missed that. So can you make 
> a
> patch adding the en/decoder driver to this file? I'm ready to make the pull
> request once I have that.
> 
Got it. I will check and update it.

I have a question about decoder device node.
In v5 decoder patch series, I do not add device node patch at end of
patch series.
I plain to put it in MT21C format patch series, is it ok?


best regards,
Tiffany



> Regards,
> 
>   Hans




Re: [PATCH v5 0/9] Add MT8173 Video Decoder Driver

2016-09-05 Thread Tiffany Lin
Hi Hans,

On Mon, 2016-09-05 at 11:33 +0200, Hans Verkuil wrote:
> On 09/02/2016 02:19 PM, Tiffany Lin wrote:
> > ==
> >  Introduction
> > ==
> > 
> > The purpose of this series is to add the driver for video codec hw embedded 
> > in the Mediatek's MT8173 SoCs.
> > Mediatek Video Codec is able to handle video decoding and encoding of in a 
> > range of formats.
> > 
> > This patch series rely on MTK VPU driver that have been merged in v4.8-rc1.
> > Mediatek Video Decoder driver rely on VPU driver to load, communicate with 
> > VPU.
> > 
> > Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI 
> > both have been merged in v4.6-rc1.
> > 
> > [1]https://chromium-review.googlesource.com/#/c/245241/
> 
> This patch series fails to apply to the media_tree master (patch 3/9). Can 
> you rebase and repost?
> 
> I'm ready to make a pull request for this, so I hope you can fix this soon.
> 
I saw Encoder fix patches in fixes branch.
This patch series is base on Encoder fix patches. 

[media] vcodec:mediatek: Refine VP8 encoder driver
[media] vcodec:mediatek: Refine H264 encoder driver
[media] vcodec:mediatek: change H264 profile default to profile high
[media] vcodec:mediatek: Add timestamp and timecode copy for V4L2
Encoder
[media] vcodec:mediatek: Fix visible_height larger than coded_height
issue in s_fmt_out
[media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder
[media] vcodec:mediatek:code refine for v4l2 Encoder driver
[media] dvb_frontend: Use memdup_user() rather than duplicating its
implementation


If I do not rebase decoder patch series base on Encoder fix pathces.
Then it will fail after Encoder fix patches merged.

May I know what parent patch I need to rebase to to fix this issue?


best regards,
Tiffany

> Thanks!
> 
>   Hans
> 
> > 
> > ==
> >  Device interface
> > ==
> > 
> > In principle the driver bases on v4l2 memory-to-memory framework:
> > it provides a single video node and each opened file handle gets its own 
> > private context with separate buffer queues. Each context consist of 2 
> > buffer 
> > queues: OUTPUT (for source buffers, i.e. bitstream) and CAPTURE (for 
> > destination buffers, i.e. decoded video frames).
> > OUTPUT and CAPTURE buffer could be MMAP or DMABUF memory type.
> > 
> > Change in v5:
> > 1. Merge wucheng's V4L2_PIX_FMT_VP9 series to this series
> >V4L: add VP9 format documentation
> >v4l2-ioctl: add VP9 format description.
> >videodev2.h: add V4L2_PIX_FMT_VP9 format.
> > 2. Remove V4L2_PIX_FMT_MT21C to another series
> > 
> > Change in v4:
> > 1.Change V4L2_PIX_FMT_MT21 to v4l2_PIX_FMT_MT21C
> > 2.Fix g/s_selection implementation
> > 3.Refine code according to review comments and pass V4l2-compliance test
> > 
> > -/bin/sh: v4l2: not found
> > # v4l2-compliance -d /dev/video0
> > v4l2-compliance SHA   : fc45cdc502065bc1dfb4ef9ceb9a822bb9877bce
> > 
> > Driver Info:
> > Driver name   : mtk-vcodec-dec
> > Card type : platform:mt8173
> > Bus info  : platform:mt8173
> > Driver version: 4.8.0
> > Capabilities  : 0x84204000
> > Video Memory-to-Memory Multiplanar
> > Streaming
> > Extended Pix Format
> > Device Capabilities
> > Device Caps   : 0x04204000
> > Video Memory-to-Memory Multiplanar
> > Streaming
> > Extended Pix Format
> > 
> > Compliance test for device /dev/video0 (not using libv4l2):
> > 
> > Required ioctls:
> > test VIDIOC_QUERYCAP: OK
> > 
> > Allow for multiple opens:
> > test second video open: OK
> > test VIDIOC_QUERYCAP: OK
> > test VIDIOC_G/S_PRIORITY: OK
> > test for unlimited opens: OK
> > 
> > Debug ioctls:
> > test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
> > test VIDIOC_LOG_STATUS: OK (Not Supported)
> > 
> > Input ioctls:
> > test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
> > test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> > test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
> > test VIDIOC_ENUMAUDIO: OK (Not Supported)
> > test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
> > test VIDIOC_G/S_AUDIO: OK (Not Supported)
> > Inputs: 0 Audio Inputs: 0 Tuners: 0
> > 
> > Output ioctls:
> > test V

Re: [PATCH v5 0/9] Add MT8173 Video Decoder Driver

2016-09-05 Thread Tiffany Lin
Hi Hans,

On Mon, 2016-09-05 at 11:33 +0200, Hans Verkuil wrote:
> On 09/02/2016 02:19 PM, Tiffany Lin wrote:
> > ==
> >  Introduction
> > ==
> > 
> > The purpose of this series is to add the driver for video codec hw embedded 
> > in the Mediatek's MT8173 SoCs.
> > Mediatek Video Codec is able to handle video decoding and encoding of in a 
> > range of formats.
> > 
> > This patch series rely on MTK VPU driver that have been merged in v4.8-rc1.
> > Mediatek Video Decoder driver rely on VPU driver to load, communicate with 
> > VPU.
> > 
> > Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI 
> > both have been merged in v4.6-rc1.
> > 
> > [1]https://chromium-review.googlesource.com/#/c/245241/
> 
> This patch series fails to apply to the media_tree master (patch 3/9). Can 
> you rebase and repost?
> 
> I'm ready to make a pull request for this, so I hope you can fix this soon.
> 
I saw Encoder fix patches in fixes branch.
This patch series is base on Encoder fix patches. 

[media] vcodec:mediatek: Refine VP8 encoder driver
[media] vcodec:mediatek: Refine H264 encoder driver
[media] vcodec:mediatek: change H264 profile default to profile high
[media] vcodec:mediatek: Add timestamp and timecode copy for V4L2
Encoder
[media] vcodec:mediatek: Fix visible_height larger than coded_height
issue in s_fmt_out
[media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder
[media] vcodec:mediatek:code refine for v4l2 Encoder driver
[media] dvb_frontend: Use memdup_user() rather than duplicating its
implementation


If I do not rebase decoder patch series base on Encoder fix pathces.
Then it will fail after Encoder fix patches merged.

May I know what parent patch I need to rebase to to fix this issue?


best regards,
Tiffany

> Thanks!
> 
>   Hans
> 
> > 
> > ==
> >  Device interface
> > ==
> > 
> > In principle the driver bases on v4l2 memory-to-memory framework:
> > it provides a single video node and each opened file handle gets its own 
> > private context with separate buffer queues. Each context consist of 2 
> > buffer 
> > queues: OUTPUT (for source buffers, i.e. bitstream) and CAPTURE (for 
> > destination buffers, i.e. decoded video frames).
> > OUTPUT and CAPTURE buffer could be MMAP or DMABUF memory type.
> > 
> > Change in v5:
> > 1. Merge wucheng's V4L2_PIX_FMT_VP9 series to this series
> >V4L: add VP9 format documentation
> >v4l2-ioctl: add VP9 format description.
> >videodev2.h: add V4L2_PIX_FMT_VP9 format.
> > 2. Remove V4L2_PIX_FMT_MT21C to another series
> > 
> > Change in v4:
> > 1.Change V4L2_PIX_FMT_MT21 to v4l2_PIX_FMT_MT21C
> > 2.Fix g/s_selection implementation
> > 3.Refine code according to review comments and pass V4l2-compliance test
> > 
> > -/bin/sh: v4l2: not found
> > # v4l2-compliance -d /dev/video0
> > v4l2-compliance SHA   : fc45cdc502065bc1dfb4ef9ceb9a822bb9877bce
> > 
> > Driver Info:
> > Driver name   : mtk-vcodec-dec
> > Card type : platform:mt8173
> > Bus info  : platform:mt8173
> > Driver version: 4.8.0
> > Capabilities  : 0x84204000
> > Video Memory-to-Memory Multiplanar
> > Streaming
> > Extended Pix Format
> > Device Capabilities
> > Device Caps   : 0x04204000
> > Video Memory-to-Memory Multiplanar
> > Streaming
> > Extended Pix Format
> > 
> > Compliance test for device /dev/video0 (not using libv4l2):
> > 
> > Required ioctls:
> > test VIDIOC_QUERYCAP: OK
> > 
> > Allow for multiple opens:
> > test second video open: OK
> > test VIDIOC_QUERYCAP: OK
> > test VIDIOC_G/S_PRIORITY: OK
> > test for unlimited opens: OK
> > 
> > Debug ioctls:
> > test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
> > test VIDIOC_LOG_STATUS: OK (Not Supported)
> > 
> > Input ioctls:
> > test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
> > test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> > test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
> > test VIDIOC_ENUMAUDIO: OK (Not Supported)
> > test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
> > test VIDIOC_G/S_AUDIO: OK (Not Supported)
> > Inputs: 0 Audio Inputs: 0 Tuners: 0
> > 
> > Output ioctls:
> > test V

[PATCH v5 8/9] Add documentation for V4L2_PIX_FMT_VP9.

2016-09-02 Thread Tiffany Lin
Add documentation for V4L2_PIX_FMT_VP9.

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
Signed-off-by: Wu-Cheng Li <wuchen...@chromium.org>
---
 Documentation/media/uapi/v4l/pixfmt-013.rst |8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/media/uapi/v4l/pixfmt-013.rst 
b/Documentation/media/uapi/v4l/pixfmt-013.rst
index bfef4f4..58e3ce6 100644
--- a/Documentation/media/uapi/v4l/pixfmt-013.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-013.rst
@@ -129,3 +129,11 @@ Compressed Formats
-  'VP80'
 
-  VP8 video elementary stream.
+
+-  .. _V4L2-PIX-FMT-VP9:
+
+   -  ``V4L2_PIX_FMT_VP9``
+
+   -  'VP90'
+
+   -  VP9 video elementary stream.
-- 
1.7.9.5



[PATCH v5 2/9] dt-bindings: Add a binding for Mediatek Video Decoder

2016-09-02 Thread Tiffany Lin
Add a DT binding documentation of Video Decoder for the
MT8173 SoC from Mediatek.

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
Acked-by: Rob Herring <r...@kernel.org>
---
 .../devicetree/bindings/media/mediatek-vcodec.txt  |   57 ++--
 1 file changed, 53 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt 
b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
index 59a47a5..46c15c5 100644
--- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
@@ -1,25 +1,74 @@
 Mediatek Video Codec
 
 Mediatek Video Codec is the video codec hw present in Mediatek SoCs which
-supports high resolution encoding functionalities.
+supports high resolution encoding and decoding functionalities.
 
 Required properties:
 - compatible : "mediatek,mt8173-vcodec-enc" for encoder
+  "mediatek,mt8173-vcodec-dec" for decoder.
 - reg : Physical base address of the video codec registers and length of
   memory mapped region.
 - interrupts : interrupt number to the cpu.
 - mediatek,larb : must contain the local arbiters in the current Socs.
 - clocks : list of clock specifiers, corresponding to entries in
   the clock-names property.
-- clock-names: encoder must contain "venc_sel_src", "venc_sel",
-- "venc_lt_sel_src", "venc_lt_sel".
+- clock-names: encoder must contain "venc_sel_src", "venc_sel",,
+  "venc_lt_sel_src", "venc_lt_sel", decoder must contain "vcodecpll",
+  "univpll_d2", "clk_cci400_sel", "vdec_sel", "vdecpll", "vencpll",
+  "venc_lt_sel", "vdec_bus_clk_src".
 - iommus : should point to the respective IOMMU block with master port as
   argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
   for details.
 - mediatek,vpu : the node of video processor unit
 
+
 Example:
-vcodec_enc: vcodec@0x18002000 {
+
+vcodec_dec: vcodec@1600 {
+compatible = "mediatek,mt8173-vcodec-dec";
+reg = <0 0x1600 0 0x100>,   /*VDEC_SYS*/
+  <0 0x1602 0 0x1000>,  /*VDEC_MISC*/
+  <0 0x16021000 0 0x800>,   /*VDEC_LD*/
+  <0 0x16021800 0 0x800>,   /*VDEC_TOP*/
+  <0 0x16022000 0 0x1000>,  /*VDEC_CM*/
+  <0 0x16023000 0 0x1000>,  /*VDEC_AD*/
+  <0 0x16024000 0 0x1000>,  /*VDEC_AV*/
+  <0 0x16025000 0 0x1000>,  /*VDEC_PP*/
+  <0 0x16026800 0 0x800>,   /*VP8_VD*/
+  <0 0x16027000 0 0x800>,   /*VP6_VD*/
+  <0 0x16027800 0 0x800>,   /*VP8_VL*/
+  <0 0x16028400 0 0x400>;   /*VP9_VD*/
+interrupts = ;
+mediatek,larb = <>;
+iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+ < M4U_PORT_HW_VDEC_PP_EXT>,
+ < M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+ < M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+ < M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+ < M4U_PORT_HW_VDEC_UFO_EXT>,
+ < M4U_PORT_HW_VDEC_VLD_EXT>,
+ < M4U_PORT_HW_VDEC_VLD2_EXT>;
+mediatek,vpu = <>;
+power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+clocks = < CLK_APMIXED_VCODECPLL>,
+ < CLK_TOP_UNIVPLL_D2>,
+ < CLK_TOP_CCI400_SEL>,
+ < CLK_TOP_VDEC_SEL>,
+ < CLK_TOP_VCODECPLL>,
+ < CLK_APMIXED_VENCPLL>,
+ < CLK_TOP_VENC_LT_SEL>,
+ < CLK_TOP_VCODECPLL_370P5>;
+clock-names = "vcodecpll",
+  "univpll_d2",
+  "clk_cci400_sel",
+  "vdec_sel",
+  "vdecpll",
+  "vencpll",
+  "venc_lt_sel",
+  "vdec_bus_clk_src";
+  };
+
+  vcodec_enc: vcodec@0x18002000 {
 compatible = "mediatek,mt8173-vcodec-enc";
 reg = <0 0x18002000 0 0x1000>,/*VENC_SYS*/
   <0 0x19002000 0 0x1000>;/*VENC_LT_SYS*/
-- 
1.7.9.5



[PATCH v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

2016-09-02 Thread Tiffany Lin
Add v4l2 layer decoder driver for MT8173

Signed-off-by: Tiffany Lin <tiffany@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/Makefile |   12 +-
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1433 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   88 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  394 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  205 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   62 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |8 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c|3 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c|   33 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h|5 +
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   55 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c|  112 ++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.h|  101 ++
 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |  103 ++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c|  168 +++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h|   96 ++
 17 files changed, 2884 insertions(+), 22 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_base.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index dc5cb00..b54e823 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -1,7 +1,13 @@
 
-
-obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-enc.o mtk-vcodec-common.o
-
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
+  mtk-vcodec-enc.o \
+  mtk-vcodec-common.o
+
+mtk-vcodec-dec-y := mtk_vcodec_dec_drv.o \
+   vdec_drv_if.o \
+   vdec_vpu_if.o \
+   mtk_vcodec_dec.o \
+   mtk_vcodec_dec_pm.o \
 
 
 mtk-vcodec-enc-y := venc/venc_vp8_if.o \
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
new file mode 100644
index 000..d634e61
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -0,0 +1,1433 @@
+/*
+* Copyright (c) 2016 MediaTek Inc.
+* Author: PC Chen <pc.c...@mediatek.com>
+*     Tiffany Lin <tiffany@mediatek.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.
+*
+* 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_dec.h"
+#include "mtk_vcodec_intr.h"
+#include "mtk_vcodec_util.h"
+#include "vdec_drv_if.h"
+#include "mtk_vcodec_dec_pm.h"
+
+#define OUT_FMT_IDX0
+#define CAP_FMT_IDX0
+
+#define MTK_VDEC_MIN_W 64U
+#define MTK_VDEC_MIN_H 64U
+#define DFT_CFG_WIDTH  MTK_VDEC_MIN_W
+#define DFT_CFG_HEIGHT MTK_VDEC_MIN_H
+
+static struct mtk_video_fmt mtk_video_formats[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_H264,
+   .type = MTK_FMT_DEC,
+   .num_planes = 1,
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_VP8,
+   .type = MTK_FMT_DEC,
+   .num_planes = 1,
+   },
+};
+
+static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_H264,
+   .stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
+   MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_VP8,
+   .stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
+   MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
+   },
+};
+
+#define NUM_SUPPORTED_FRAMESIZE ARRAY_SIZE(mtk_vdec_framesizes)
+#define NUM_FORMATS ARRAY_SIZE(mtk_video_formats)
+
+static struc

[PATCH v5 8/9] Add documentation for V4L2_PIX_FMT_VP9.

2016-09-02 Thread Tiffany Lin
Add documentation for V4L2_PIX_FMT_VP9.

Signed-off-by: Tiffany Lin 
Signed-off-by: Wu-Cheng Li 
---
 Documentation/media/uapi/v4l/pixfmt-013.rst |8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/media/uapi/v4l/pixfmt-013.rst 
b/Documentation/media/uapi/v4l/pixfmt-013.rst
index bfef4f4..58e3ce6 100644
--- a/Documentation/media/uapi/v4l/pixfmt-013.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-013.rst
@@ -129,3 +129,11 @@ Compressed Formats
-  'VP80'
 
-  VP8 video elementary stream.
+
+-  .. _V4L2-PIX-FMT-VP9:
+
+   -  ``V4L2_PIX_FMT_VP9``
+
+   -  'VP90'
+
+   -  VP9 video elementary stream.
-- 
1.7.9.5



  1   2   3   4   5   6   >