Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5640976img; Wed, 27 Mar 2019 12:15:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlsXfFCuoHTekBx9LB5h/NbMEhzXxUWtpEmPtpiJRCHXxB9amcT7r3zeO03tSVYlIrW+xk X-Received: by 2002:aa7:83ce:: with SMTP id j14mr9315022pfn.57.1553714132208; Wed, 27 Mar 2019 12:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714132; cv=none; d=google.com; s=arc-20160816; b=hbO3W5EKeSf4WYVCO9RUUreazOyJASBYyq8/Er2AJGzgPlRfHmx2+3liUWZsU44FwV pXTz5nq9cACwBXwEf0ADuFP9ud1xvZMI0K9Fhdv2kirWEamcLcwXLpsH/y8zjZAb67OL 2hKyc2sgPHU2bOErRboXzNaWiwZT4ZqiolBRnCYwnuP2unhtbo4C3Nn1WG8szZS+7vLE dXDnbOlJOJysv+dfvUHcEebIHf2X1u4a9+ioO/cBn8Xg9KK5gra/i/xDbsHaWkSuDAoD wZoojI2WlrYZh81OH3NrVPSj3yE+mz5irranNunBi1skUO0iDSU3TmC3PrMwt1q021/Q ywPA== 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=CmDmUI0zaB70sAFUMQtCBtinT8WfX6TTzLEUzsZCf0w=; b=Wip8DJeCtzD78wa8b92ihVGRxvCbc6vH5+055Pp6P6f1LK2PO8DIGUGh4/zVAvY6XS Z+BVNSv1lt0Mg+RUAmt8IeolRDha9BAaITGs4YTVC3Dn0cUUXRhfitQktcAhnzrfRHig C9nv80DB8f77ZI1rC9q9dwGybxFLyxMOQ30iMPXLmLsRk74+2qv4GQB22It9ytjWkch4 L4mwyvpsOGrlzAInDMc8MW8Lh40+Fh1buuKxGeh/kZnsHmJ1ssyhh0T74LOLCr6XWbgZ MfJIRSQNMYjOulfTyxLZ75sIu3xcy2+MuZGE8c4wtKYhIIk2mSyV7cSebW9GYwWsfKDK 1zcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uQU2VUvD; 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 m22si18695485pgv.562.2019.03.27.12.15.17; Wed, 27 Mar 2019 12:15:32 -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=uQU2VUvD; 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 S2388918AbfC0TOi (ORCPT + 99 others); Wed, 27 Mar 2019 15:14:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:51476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388612AbfC0SJj (ORCPT ); Wed, 27 Mar 2019 14:09:39 -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 38C462063F; Wed, 27 Mar 2019 18:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710178; bh=3JIVPaF6ykpQWFQ/deMi9kh+qkBKKuPJqPOVKoUv05Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uQU2VUvDtQTlFHYtNxkED0BKTqhjsSZk2mdFbpPDFSPOOiz+AIo8AXY7GjMKXtppL +payxHPpswW1ux5R2Fg6/aLVmFKgsVhj6LJPLSYCaCmz3XB4LIuvuCYyBKjEwyw3Q/ hHsY5wMcH3Y67BBh/BepyDjEg+ZQbVE5v+RZIjhY= 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 5.0 236/262] media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration Date: Wed, 27 Mar 2019 14:01:31 -0400 Message-Id: <20190327180158.10245-236-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-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 4b47d9f42117..370942b67d86 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1293,13 +1293,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; @@ -1326,11 +1329,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, @@ -1339,11 +1342,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