Commit 644bdba7 authored by Pawe? Chmiel's avatar Pawe? Chmiel Committed by Greg Kroah-Hartman

media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration

[ Upstream commit 49710c32 ]

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: bb677f3a ("[media] Exynos4 JPEG codec v4l2 driver")
Signed-off-by: default avatarPawe? Chmiel <pawel.mikolaj.chmiel@gmail.com>
Reviewed-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
[hverkuil-cisco@xs4all.nl: fix a few alignment issues]
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 2230f5e2
...@@ -1293,13 +1293,16 @@ static int s5p_jpeg_querycap(struct file *file, void *priv, ...@@ -1293,13 +1293,16 @@ static int s5p_jpeg_querycap(struct file *file, void *priv,
return 0; 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) struct v4l2_fmtdesc *f, u32 type)
{ {
int i, num = 0; int i, num = 0;
unsigned int fmt_ver_flag = ctx->jpeg->variant->fmt_ver_flag;
for (i = 0; i < n; ++i) { 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 ? */ /* index-th format of type type found ? */
if (num == f->index) if (num == f->index)
break; break;
...@@ -1326,11 +1329,11 @@ static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv, ...@@ -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); struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
if (ctx->mode == S5P_JPEG_ENCODE) 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); 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); SJPEG_FMT_FLAG_DEC_CAPTURE);
} }
static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv, 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, ...@@ -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); struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
if (ctx->mode == S5P_JPEG_ENCODE) 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); 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); SJPEG_FMT_FLAG_DEC_OUTPUT);
} }
static struct s5p_jpeg_q_data *get_q_data(struct s5p_jpeg_ctx *ctx, static struct s5p_jpeg_q_data *get_q_data(struct s5p_jpeg_ctx *ctx,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment