Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp745140ybh; Sun, 12 Jul 2020 23:10:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/gzm7fWhTDt9B9ohqUF1MMwD16UJ8ls+upHEnoJoMBbatjNqV6/PjBXDqH7NvFRI2x0cG X-Received: by 2002:a17:906:da19:: with SMTP id fi25mr71554605ejb.369.1594620649650; Sun, 12 Jul 2020 23:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594620649; cv=none; d=google.com; s=arc-20160816; b=uzkcUWgoxDa8uCMTq/7IK3aU5gzaj1ojCyPol1GcHaLvjf3gMia2paqeUIG1JR6Or/ LsNhb2bswKs+dsLHEmyHNehiVYr64nKVI95Wi1Mr3/2kA2V7CyA5kCbSG1lMph/eTcQj ov34jS5ginM+OnzMs3KpntP9w7EQnWMcRiy2pvL9ZGyO73pEH1c+FM9vXb+ApWEnjfll WqQCq6NDxtqL5PzPuk8fS8/3nq0MYL2i8m63F+tjhVabs/vnXV0Rqd8kMSBzONvlH+4C mtBduZtiOTp2aBZYxuYH99W7EUGuk+8pKn6Cl7rqAce2nW2/ZT+E3Wyjf2nTNEQRjOle eJqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sxvr8s/NHxCkyhh7PIH9LpOL4fHeYb/Kvpdz2+ATe9s=; b=FeksDzXb21YAi4YWIAMWpH+1Jad/pJUY/klIXATjhKoonLAwF+798xoDtEGTd33kYW EZmi4FBGDpJZDqWQomwXPcsx0HzNno6eM63Ze++jxCrbqh28n7TqcFnU+rZ5XhoRRD8Y r/ney4re3RNN/QFLYEBGqhFaIrvi4IpHq/vrWuc7ngwX+nBf1j2nDLM+LH6IM/tnWvdh 6DXuhxw/RS4w3Z2QEudp2VPkGgPCdMt+KoV48IDsXHexGdYSomZz/2ld6DYoK7Yl3bYT CstUoeXd78vAAACdJvFixzaaPHh+wfpaefAgGJyPe4O9Y9qE5H2JBeT/9ZLDmHlHfN8z JDMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DWWH+FXO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si8544545ejq.299.2020.07.12.23.10.26; Sun, 12 Jul 2020 23:10:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DWWH+FXO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729339AbgGMGJw (ORCPT + 99 others); Mon, 13 Jul 2020 02:09:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729357AbgGMGJv (ORCPT ); Mon, 13 Jul 2020 02:09:51 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E4AAC061794 for ; Sun, 12 Jul 2020 23:09:51 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id t15so5712835pjq.5 for ; Sun, 12 Jul 2020 23:09:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sxvr8s/NHxCkyhh7PIH9LpOL4fHeYb/Kvpdz2+ATe9s=; b=DWWH+FXOvXKdSMxYAHRFSmEYh3PV0xpioqdjOti4quFB7TjJPSOs64lXwfgZ3w/22p iQvFr1Hvz5zYvoC+gumOr5SDq6P8PBLUtH6DbD3aOc0zZmxIjlmWwZYH/gvi/zBDcp0H VKu4Ac5dYDLg/07yrOoa+taF1ne5GilW7mTAU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sxvr8s/NHxCkyhh7PIH9LpOL4fHeYb/Kvpdz2+ATe9s=; b=jneVyLEcCix9pLKrI2aFBwu6wdo/fGr/mDN9KzasNQa0P9LT1GFgVB9ef8KHUPbQti BAZdI1nvOTsulmFH5/zL+W7dJlMDF10Pjmrn94fJXM3rGhKiXWwc/Cs2Qm+KvIQL/3T8 0zl+m5C25YC4vxnFyNQCGVwdRQJMamM+CAi9+CKWDr5be+a882H6BNGZg15uzUKLmv2n ME6055RiQeYG9R3YEaoLBKn8zUFm+hoJOa5fJSaueUcwNgSdU2aKUtwffo01fk66A3ot Ju5MR3FU9xg3sWq1Fju7ANwrdiBBqKjXjx8HH1qIo2BxTqJLPLoAygr/4ghnnWUx2olH ay3Q== X-Gm-Message-State: AOAM531OIP0KOQGquFHDC3dkk054aN/ALPcEoK1bmxqVi1JzUxWjjriT qH6yyyIk8vfdWhEELahtVWeidw== X-Received: by 2002:a17:90a:e511:: with SMTP id t17mr19326850pjy.87.1594620590700; Sun, 12 Jul 2020 23:09:50 -0700 (PDT) Received: from acourbot.tok.corp.google.com ([2401:fa00:8f:203:eeb1:d7ff:fe57:b7e5]) by smtp.gmail.com with ESMTPSA id c134sm13134934pfc.115.2020.07.12.23.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:09:50 -0700 (PDT) From: Alexandre Courbot To: Tiffany Lin , Andrew-CT Chen , Hans Verkuil , Yunfei Dong , Maoguang Meng Cc: linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Courbot Subject: [PATCH v3 13/16] media: mtk-vcodec: venc: use platform data for ENUM_FRAMESIZES Date: Mon, 13 Jul 2020 15:08:39 +0900 Message-Id: <20200713060842.471356-14-acourbot@chromium.org> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog In-Reply-To: <20200713060842.471356-1-acourbot@chromium.org> References: <20200713060842.471356-1-acourbot@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 = &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; } -- 2.27.0.383.g050319c2ae-goog