Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5597758img; Wed, 27 Mar 2019 11:24:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXoJ578wI+PEXHuT4i2aApfcEr1fS64p+JXUabztULRfRjM1ZCQfyYSUOQl3P4Jacebqhd X-Received: by 2002:a63:158:: with SMTP id 85mr36240677pgb.351.1553711045523; Wed, 27 Mar 2019 11:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553711045; cv=none; d=google.com; s=arc-20160816; b=BsWrmcR6+AmUINH40Doz4XdoDYk10dufQQ7xzdCbB3lKS4QKO2eANx99ZQtmvpOaAE 1V2NiF3za0BaQRMwvxXsf4/G8zTbopq6O4NhLlyuLa0wqx4Qhx5Mr3MrCPu5TrfbXA0t cEEcSjY0t3TPQA4HxJnxXR4hDi4U0kesCdg4HwCmRb2EZNBTpkmG8gwk/zZHWg/K6Jq5 w3ZnXyfXwzU75dXCXVm0KB+eLKk4mbymgMUCW545Emi2iBOlCW0kQspkwLIiB/KPDchL VV/2IbIlmTRU7k0fpCb29acPzaWnEpbUIkKaTPxUXmNaxbGSYdl4dgOZiKe6U/33KuG3 /veg== 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=uD19H49ZyU7NO97nHt8OpzxN/qUIvyVGyX+QuqQQteo=; b=cC1CwOwfFZOgTs4A4t0WdpXHmUCZN60v575aPU+Aymj/wblF6oX7AsbzipM17SJ1Oa F2OOp/T2snleUPPujyASgxJAuDJQ5LEiiUKRqk673Scw1oDZIG6GC5fG7kH548OUITxp WJXmOBK5t9yhjMkLPPlUILSmatLakEk/nnmDq3VpYGecUvfy6BqBgqy2xAUrrzQP0gRf Us7Ymh01/zclpTOBMCA88qpZrbWzZRGhvw3jZ74WGl4wxBlo244d+tT/o8MVxQaHzDp5 23OceeibMH0E7J7WAGzL9yxAjdSq6Q2T2iar3ALD4a9eFRXEFv33FuvWQ1FKurmmqqJO EPug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=orfspICl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 145si18445033pga.532.2019.03.27.11.23.50; Wed, 27 Mar 2019 11:24:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=orfspICl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391420AbfC0SXG (ORCPT + 99 others); Wed, 27 Mar 2019 14:23:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:41340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391407AbfC0SXF (ORCPT ); Wed, 27 Mar 2019 14:23:05 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF8072147C; Wed, 27 Mar 2019 18:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710984; bh=eZsqNRtN7AcSby9VLPWL4CoNCTpAnqwEXDqEMG50gLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=orfspIClEptIN4qQvx78xLCX1ss07gokJlj5ojPxcWnODemwzARFfuz1D6+RIf8EV gs2u1ZthJu0RelugC2Ixmjgs6YfjEIih1v4p/7l7sftZjCgpixx56GPRVQGMplfFZp 9jOaqNRUhwVIn4TZd2TbvKJgd8BJgxzLOrStDfZs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pawe? Chmiel , Mauro Carvalho Chehab , Sasha Levin , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 78/87] media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration Date: Wed, 27 Mar 2019 14:20:31 -0400 Message-Id: <20190327182040.17444-78-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pawe? Chmiel [ Upstream commit 49710c32cd9d6626a77c9f5f978a5f58cb536b35 ] Previously when doing format enumeration, it was returning all formats supported by driver, even if they're not supported by hw. Add missing check for fmt_ver_flag, so it'll be fixed and only those supported by hw will be returned. Similar thing is already done in s5p_jpeg_find_format. It was found by using v4l2-compliance tool and checking result of VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS test and using v4l2-ctl to get list of all supported formats. Tested on s5pv210-galaxys (Samsung i9000 phone). Fixes: bb677f3ac434 ("[media] Exynos4 JPEG codec v4l2 driver") Signed-off-by: Pawe? Chmiel Reviewed-by: Jacek Anaszewski [hverkuil-cisco@xs4all.nl: fix a few alignment issues] Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 06e2b72d07ca..c89922fb42ce 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1264,13 +1264,16 @@ static int s5p_jpeg_querycap(struct file *file, void *priv, return 0; } -static int enum_fmt(struct s5p_jpeg_fmt *sjpeg_formats, int n, +static int enum_fmt(struct s5p_jpeg_ctx *ctx, + struct s5p_jpeg_fmt *sjpeg_formats, int n, struct v4l2_fmtdesc *f, u32 type) { int i, num = 0; + unsigned int fmt_ver_flag = ctx->jpeg->variant->fmt_ver_flag; for (i = 0; i < n; ++i) { - if (sjpeg_formats[i].flags & type) { + if (sjpeg_formats[i].flags & type && + sjpeg_formats[i].flags & fmt_ver_flag) { /* index-th format of type type found ? */ if (num == f->index) break; @@ -1297,11 +1300,11 @@ static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv, struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv); if (ctx->mode == S5P_JPEG_ENCODE) - return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f, + return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f, SJPEG_FMT_FLAG_ENC_CAPTURE); - return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f, - SJPEG_FMT_FLAG_DEC_CAPTURE); + return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f, + SJPEG_FMT_FLAG_DEC_CAPTURE); } static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv, @@ -1310,11 +1313,11 @@ static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv, struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv); if (ctx->mode == S5P_JPEG_ENCODE) - return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f, + return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f, SJPEG_FMT_FLAG_ENC_OUTPUT); - return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f, - SJPEG_FMT_FLAG_DEC_OUTPUT); + return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f, + SJPEG_FMT_FLAG_DEC_OUTPUT); } static struct s5p_jpeg_q_data *get_q_data(struct s5p_jpeg_ctx *ctx, -- 2.19.1