Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1010620yba; Thu, 4 Apr 2019 02:21:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6LalMBKadP5shGpdsNkPrG6ULNpNsx+j9XC543KSKeW4ExspiUAHZeJvGLGtS3ojx71x4 X-Received: by 2002:a17:902:e091:: with SMTP id cb17mr5366583plb.222.1554369703234; Thu, 04 Apr 2019 02:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554369703; cv=none; d=google.com; s=arc-20160816; b=LefQsndVB6SU19SMCoJCCLvLM9DwHGP4Y5IG9V10AZLzs4MNsJyr2/WevtlnML9Nv3 N4PdVf6nZBf2HJn0FGIG6Ko2YVA7HjGkHoVUiXWggSjKUTcop2xXLWZvLh2wuCAv2tVH h1YXBuZD68vTjnaKGpIp7bZTLMg4M/JLrbrnPSNOzZQJLkzT7AnD4OBMC82celNvFdFV BA0Y381PJqhpbJAbwzt9Hm6l/EXqKpvlgErgxnDZyuViSJlZqAcQQ2RPsKY4XUPN/NQZ 0aZi98QswwAF+ztGgvVhSrakUYX3Jjtvn3gmYAKfjch+AXhYdwLPmPg6mOkhx2lOJn4d n0vg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=L7uKG5h9owG4mxYcMSUF7P8C1RcJ5xQxq7Aeuiaiyoo=; b=m29FyiHx8y6pGli7/J5X0Snw7pVPDlM4WDy6NDbEaADt6VoQfTi890jpnlFRjqsCHv 3vVE8DRQ0He5mwZT+UcFC8mTmhg5+QVKnehloEEhpDtbxb8q5hFre3MezEn6Gln+Iww1 8vtXFfxO3HPvq7sHqr3jF9x+I/xgYB6m2JbxqoK5i8RPWx5zs3KfnXkfqBnc36OVHYOo DYpoPjk1win/VfdB824Q89YWUPlybUgeOZ/nAjEp72o9+FWgDVI+VxvX2TaLizI/6TnJ AZc6//Y1mgMGahMyw/PuVVEEFSyxXuvl3g0C9BHdVISFcqVFx9mMr+3ILbZEK0+2Mizs GDqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="UnXoH2L/"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t186si15582876pgd.221.2019.04.04.02.21.28; Thu, 04 Apr 2019 02:21:43 -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="UnXoH2L/"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388219AbfDDJRb (ORCPT + 99 others); Thu, 4 Apr 2019 05:17:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:59156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388199AbfDDJRa (ORCPT ); Thu, 4 Apr 2019 05:17:30 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC1522075E; Thu, 4 Apr 2019 09:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554369449; bh=7clfelsx/a9DPBTTdJnqiZL6xa5GWYfRDrKvGLTp6Xk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UnXoH2L//FMESVAPkaEg80YxqPV0h6u5AfIqhfL92XlfW5jNrI/ABCtY/uNlAH4WI R0pCLY1gsQEXtGK7E9H7KYuZXLbqb+NDu0hvjubIh9gt1keT40DobfD1rohXD4gBM1 dLdLyXBfPX5hbm2Lg6iqcCl2h+IcAD5VSKw9Ptdc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pawe? Chmiel , Jacek Anaszewski , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.0 220/246] media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration Date: Thu, 4 Apr 2019 10:48:40 +0200 Message-Id: <20190404084626.903565438@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084619.236418459@linuxfoundation.org> References: <20190404084619.236418459@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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