From patchwork Sat Dec 29 15:46:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Chmiel?= X-Patchwork-Id: 10744925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23EFA746 for ; Sat, 29 Dec 2018 15:46:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F1C42899F for ; Sat, 29 Dec 2018 15:46:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2ED028AA8; Sat, 29 Dec 2018 15:46:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7173B2899F for ; Sat, 29 Dec 2018 15:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=PRxthxxTqhRMdTvB208I9AiWY4RzwXVcfGc1qALwyHY=; b=r398kbp8XfpfBp PbQmixKSJkoDzveve7gUvmD7CzIleI0/CPIYXbdlz9drp7D+gR3TDLoeT/nJ2Ta4nfts/bTv1OS4x 8SsoYAulrOpnkjIeLm8ZI4JMoIPYLkyGjUlvNbpf6m/k3x/wLVubyOLxD50pDlsvQzTLPR0lrV2iI Hwtbos2/xwAyxKD3FtXEc+WMq4LGYqbuKLfhKYbjuAiZeclZnFrB9bVW5xrKgdEbAYP6VRTr1Yq80 WJqJ3vcIFCq4NtdXmIAAQqMx/AxaIP0q7RfdDGUxbUdh4CWmTF+R1zAtWdrd1RMqLZVga4hX40wSr YlEyyVWSYI103KE+tPJg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gdGom-0007gy-5k; Sat, 29 Dec 2018 15:46:28 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gdGoi-0007em-W1 for linux-arm-kernel@lists.infradead.org; Sat, 29 Dec 2018 15:46:26 +0000 Received: by mail-lf1-x144.google.com with SMTP id v5so16189790lfe.7 for ; Sat, 29 Dec 2018 07:46:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HJ2D6S+BDoyT03ZFRm8ignD7WKbmeioqnKEpSljjok8=; b=FHh3A4frWZa9R5ZnhGNKmr+YDMPmuGTRRHei39/mQ11mNUSL3H0I0EE6w/ZIQAWcii Q0wAbv9SwgcHvnYBDORQ9xW7CYdKE6eSm1x0C2k6/EBgPw7OcjUwI2A520e0XK2NZSRg uk5Hy+/N8iJOCYa/Fw3br9EBCW8JSiT+0qgcI9HDt0DaOQfG5B+jXgTM+cSsC7/+obi4 Xx+8vXEyZAQZEEe+yvq5WqhenrY5CdWBR4DgTZQPlB7iTBDcMJQg/a6mN8WXC0TTG1V9 h3PTcdLSUOzfjr+Li/k5eJr97dxjFk0BH31rcw+Dq/Vh50xrCTu3pGdnB8kx6rwyJxz6 ZWhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HJ2D6S+BDoyT03ZFRm8ignD7WKbmeioqnKEpSljjok8=; b=WIEGTuCAQs/O9rJ6eEHlR3Qm440tfH+9jJRQu79HjwXDQLVKVdiB8yKfthkj9k88Yx bQxYGN7e8W0pXVCYgqZ2l2a6JKt22NDjPJNAWagpbekPWsdUKCzbJqqc+ag+evpxxLgu oPdwbF3nVz4qxQ4k3w/Rx8/8NHFgo7uk+qSNcuQ24RgUsK/eQJtkZsz0yCST5Q6AUCA1 OCOXCbMvoLuQ2JEoJWL5lpyd04q7imLLvsNpsMh01AB8Sl/gsv+Wa326rAVGPFl9Klw7 3G+QZfpWj4gJd6wCIoZhixJSvEvYQESsrwuRFgY4ySlfiAX8h334tbTterzXICONrqCz u2pw== X-Gm-Message-State: AA+aEWZpJoEZDs/FG99FREmudqVkf15eIsrwhoEJgGPZb5/Bg6ClPXNX RV748+ikSlriaTrwfKJ4Vpc= X-Google-Smtp-Source: AFSGD/WXaxorWkt/A8rmcraHPQ/UJpJ10nGCFUq8X/6Uvvj4axZdkmEjvuPZ6N8fDU5IkDOfVxOcaA== X-Received: by 2002:a19:200b:: with SMTP id g11mr15577555lfg.58.1546098372092; Sat, 29 Dec 2018 07:46:12 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:59d9:2ac4:8755:7a21]) by smtp.googlemail.com with ESMTPSA id d19-v6sm9106105ljc.37.2018.12.29.07.46.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Dec 2018 07:46:11 -0800 (PST) From: =?utf-8?q?Pawe=C5=82_Chmiel?= To: andrzej.p@samsung.com Subject: [PATCH] media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration Date: Sat, 29 Dec 2018 16:46:01 +0100 Message-Id: <20181229154602.25693-1-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181229_074625_036973_4AD71AFA X-CRM114-Status: GOOD ( 14.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, =?utf-8?q?Pawe=C5=82_Chmiel?= , linux-kernel@vger.kernel.org, jacek.anaszewski@gmail.com, mchehab@kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 3f9000b70385..232b75cf209f 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,10 +1329,10 @@ 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, + return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f, SJPEG_FMT_FLAG_DEC_CAPTURE); } @@ -1339,10 +1342,10 @@ 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, + return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f, SJPEG_FMT_FLAG_DEC_OUTPUT); }