]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.111/media-s5p-jpeg-check-for-fmt_ver_flag-when-doing-fmt.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.111 / media-s5p-jpeg-check-for-fmt_ver_flag-when-doing-fmt.patch
CommitLineData
04fd09d4
SL
1From 9cec4cd60dce0c1291e0af43a8b5363ab27f0949 Mon Sep 17 00:00:00 2001
2From: Pawe? Chmiel <pawel.mikolaj.chmiel@gmail.com>
3Date: Sat, 29 Dec 2018 10:46:01 -0500
4Subject: media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration
5
6[ Upstream commit 49710c32cd9d6626a77c9f5f978a5f58cb536b35 ]
7
8Previously when doing format enumeration, it was returning all
9 formats supported by driver, even if they're not supported by hw.
10Add missing check for fmt_ver_flag, so it'll be fixed and only those
11 supported by hw will be returned. Similar thing is already done
12 in s5p_jpeg_find_format.
13
14It was found by using v4l2-compliance tool and checking result
15 of VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS test
16and using v4l2-ctl to get list of all supported formats.
17
18Tested on s5pv210-galaxys (Samsung i9000 phone).
19
20Fixes: bb677f3ac434 ("[media] Exynos4 JPEG codec v4l2 driver")
21
22Signed-off-by: Pawe? Chmiel <pawel.mikolaj.chmiel@gmail.com>
23Reviewed-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
24[hverkuil-cisco@xs4all.nl: fix a few alignment issues]
25Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
26Signed-off-by: Sasha Levin <sashal@kernel.org>
27---
28 drivers/media/platform/s5p-jpeg/jpeg-core.c | 19 +++++++++++--------
29 1 file changed, 11 insertions(+), 8 deletions(-)
30
31diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
32index d7679e4585fd..4568e68e15fa 100644
33--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
34+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
35@@ -1293,13 +1293,16 @@ static int s5p_jpeg_querycap(struct file *file, void *priv,
36 return 0;
37 }
38
39-static int enum_fmt(struct s5p_jpeg_fmt *sjpeg_formats, int n,
40+static int enum_fmt(struct s5p_jpeg_ctx *ctx,
41+ struct s5p_jpeg_fmt *sjpeg_formats, int n,
42 struct v4l2_fmtdesc *f, u32 type)
43 {
44 int i, num = 0;
45+ unsigned int fmt_ver_flag = ctx->jpeg->variant->fmt_ver_flag;
46
47 for (i = 0; i < n; ++i) {
48- if (sjpeg_formats[i].flags & type) {
49+ if (sjpeg_formats[i].flags & type &&
50+ sjpeg_formats[i].flags & fmt_ver_flag) {
51 /* index-th format of type type found ? */
52 if (num == f->index)
53 break;
54@@ -1326,11 +1329,11 @@ static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
55 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
56
57 if (ctx->mode == S5P_JPEG_ENCODE)
58- return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f,
59+ return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f,
60 SJPEG_FMT_FLAG_ENC_CAPTURE);
61
62- return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f,
63- SJPEG_FMT_FLAG_DEC_CAPTURE);
64+ return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f,
65+ SJPEG_FMT_FLAG_DEC_CAPTURE);
66 }
67
68 static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
69@@ -1339,11 +1342,11 @@ static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
70 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
71
72 if (ctx->mode == S5P_JPEG_ENCODE)
73- return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f,
74+ return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f,
75 SJPEG_FMT_FLAG_ENC_OUTPUT);
76
77- return enum_fmt(sjpeg_formats, SJPEG_NUM_FORMATS, f,
78- SJPEG_FMT_FLAG_DEC_OUTPUT);
79+ return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f,
80+ SJPEG_FMT_FLAG_DEC_OUTPUT);
81 }
82
83 static struct s5p_jpeg_q_data *get_q_data(struct s5p_jpeg_ctx *ctx,
84--
852.19.1
86