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

Tiffany Lin tiffany.lin at mediatek.com
Tue Aug 25 01:39:04 EDT 2020


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 <tiffany.lin at mediatek.com>

> Signed-off-by: Alexandre Courbot <acourbot at chromium.org>
> ---
>  .../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 = &pdata->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;
>  	}
>  



More information about the Linux-mediatek mailing list