Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp835304yba; Wed, 24 Apr 2019 10:21:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCrWOcUeuMuM9T2FGD+jRtuANF0kfMVPt+9DAjx+jYPUkmLzJF+m2Bpenk6nEAsAjQktBY X-Received: by 2002:a17:902:e709:: with SMTP id co9mr16309155plb.86.1556126491997; Wed, 24 Apr 2019 10:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556126491; cv=none; d=google.com; s=arc-20160816; b=u3ws7/m0Ls9rIhE+tOpwjzK5TPhYiZ0KBoLO4bArzxRX0nWy5PCBNCj85V5Ho49Ryy 5dkg92hTSxiMFymVQqTL6PGqU5mJ8zfOSJYUm7yFsKvrsNSW92HeEH6OGBk0GntHnfzX A7DQpT5NH393hE+MiQTrZ4O1wfMPGblkYJ8dl0cnrFXfHCvEISDSsPo942oRh9Tjqosh jRu7koQfpzwiYxL918lmCwM74BScjhGD+2Wls6igDq35fa6hVmIe6dqNCkSdzwBgB2W4 EE1rHGTpjJshuRVibpYOgSXahLVoeNBTRJcEgsh9TWO5uS6ZnqLNZZHV5rcXaXLOgx5g tsvg== 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=cnUJjbIle/4jVTEz9AaBWiocfyoU6/DQ81rEnvJ2GHw=; b=nTH0IYCY8SVuIZDNzBDsIU22ZBezOtNHTS36iGgzVtuf+VO0DGUAX+M9KFJhgMD3er LvSK/WcNWOFhzrqet2igqTiW6KmzJPkA2bWztLipDpTmG9MwsB7b7MysZrcok/w1YOJR 4mN0/35IfYW5shanKG14DVkJzBC4ajSg/6HbmUL1XbnhQ2a2CkoScvl81XxIgpvcqIHx CODiFMLQ5a/pgRxQj0a6bAbZLOSH2ZveNPa0gGvcHjMbfS2EfIOUd16DAzIl7VCAxWa7 VP7xc420qld3bwfN1aQZjkLsN+I6VYw+8zZXTiwtvpHDgsC6YYtS4yPXt+pywhKLfo5m 3Qow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BkJyIdvR; 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 a190si18448276pge.88.2019.04.24.10.21.16; Wed, 24 Apr 2019 10:21:31 -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=BkJyIdvR; 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 S2388821AbfDXRSW (ORCPT + 99 others); Wed, 24 Apr 2019 13:18:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:43342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388811AbfDXRSS (ORCPT ); Wed, 24 Apr 2019 13:18:18 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (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 BE64821909; Wed, 24 Apr 2019 17:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126297; bh=n8iI53Gw4QIIUCoRu3zzHQbqa6o7rzyUyasSVFimEg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BkJyIdvRHHptCQGSY0i2ybjf96D7wXcBBsoCoCBPtzCWXyqnfSvxPyF2JUVewrwET edeqHaqDl1NIAGMypiGvho4Fie8mCnIhJpZhbr8WwKwwAVLmUmmht1J0k0c+AToXSt IjqVD6vKEP8E3/1t1FoOPraSae863QuadEYsi4Ms= 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 4.4 063/168] media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration Date: Wed, 24 Apr 2019 19:08:27 +0200 Message-Id: <20190424170927.510822680@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170923.452349382@linuxfoundation.org> References: <20190424170923.452349382@linuxfoundation.org> User-Agent: quilt/0.66 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 [ 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 80c83bba7af3..0d981bbf38bc 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1262,13 +1262,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; @@ -1294,11 +1297,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, @@ -1307,11 +1310,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