Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1021866yba; Thu, 4 Apr 2019 02:37:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqx65WB8UPXNrEzXjGngR6RQ0SeFD4bv4YR/R98Mfxwmcz0cHTOeB1K95qGny0lcvEffd9cq X-Received: by 2002:a65:50c2:: with SMTP id s2mr4618740pgp.112.1554370640372; Thu, 04 Apr 2019 02:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370640; cv=none; d=google.com; s=arc-20160816; b=q25iK8N5W94Fnsgiv9/3Fm9Dd0NwvvP1JYKktmyL3nA1pRLfZx3gARRKlMJYtn0jDz AQUHmKeuOcO2HnVCQcmCgwK1ydAugCC0jFgL0bAnGngZpNmwIofVAhG2J4dzgUCUEY57 QIO6PR6yoDvT/j95iHoH6PkU+s7iVynRiiNnKggyHYbXfk5Y2xRLaNQtQp0vZKIT1bPb FsCYRNYWhSBbvJf3YcV9oKZup13kYYPYfw6oQT/badWo44CQ+0UpbZPJ2qlIUG6VgVCT YU2PlYT5VczXWbYVUKCzX5qKlm2hDVI5hdZNcUXrtPx7ma3wgiBJ3Hk+zd6TAAlnDuN1 jD+g== 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=uuWG0ceoZjyOilTm0Cr2grmvGfLo1TNUm3evv6yHS0E=; b=AmfiDZhlhVgVfYg3vqTzTsfLZv4MRbeCdf+k9WNHuXd2ZEKDkEPedUKpGEQaeyrBAF inlz7OtPquwYlmS+EkA/2s/Es2oBLLiC7oxuD7z4/cdl7arSHX2+z4IfC99Dir1+oMKk k/L6dw/poCUENVsaf9/LRqgzbzZlWApLktVKBkVlF42awJDT3YAx4CoLFzdhLqG7nlHC rpdyv7tdnTC9yqoR10KU1nMkRUHRQDGfpfpd33F2nlmtkIuU3GYGqCmqCulZ1QGzLj8K Ng5IbvDZQ/PIaIqqEolOYTMbitVdr718zxTTmD46jGJyzLglOhimRb1SmarSUg/rSNif akRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CDTn3EqL; 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 j16si15617827pfa.197.2019.04.04.02.37.04; Thu, 04 Apr 2019 02:37:20 -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=CDTn3EqL; 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 S1732437AbfDDJeh (ORCPT + 99 others); Thu, 4 Apr 2019 05:34:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:45898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732448AbfDDJHH (ORCPT ); Thu, 4 Apr 2019 05:07:07 -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 99E292177E; Thu, 4 Apr 2019 09:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368826; bh=sM4XcSIWtBW4EWqe57Yv3bZQ5N62XO28uU0hSh0qt90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CDTn3EqL9QqLBLnLA9luaoW4JKsd0KqfjLx5B1px6ceK86rIoghvJ1bBk5IpqdBDk yFSqBTCZhvtVzO5jG6Sd0fqRXquEqfqfWwaAVGRNvACRrVe/btM5DVWSqT2dZH4m9i C/3N7d6P6pceyv0SM8CSGfgaTUWdC9RrR1IjwNqM= 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.19 168/187] media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration Date: Thu, 4 Apr 2019 10:48:25 +0200 Message-Id: <20190404084611.001891681@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@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 4.19-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 29daecf8de7d..350afaa29a62 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