Commit b245168c authored by Jacek Anaszewski's avatar Jacek Anaszewski Committed by Mauro Carvalho Chehab

[media] s5p-jpeg: Add fmt_ver_flag field to the s5p_jpeg_variant structure

Simplify the code by adding fmt_ver_flag field
to the s5p_jpeg_variant structure which allows
to avoid "if" statement in the s5p_jpeg_find_format
function.
Signed-off-by: default avatarJacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent b9684a60
...@@ -959,7 +959,7 @@ static int s5p_jpeg_g_fmt(struct file *file, void *priv, struct v4l2_format *f) ...@@ -959,7 +959,7 @@ static int s5p_jpeg_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
static struct s5p_jpeg_fmt *s5p_jpeg_find_format(struct s5p_jpeg_ctx *ctx, static struct s5p_jpeg_fmt *s5p_jpeg_find_format(struct s5p_jpeg_ctx *ctx,
u32 pixelformat, unsigned int fmt_type) u32 pixelformat, unsigned int fmt_type)
{ {
unsigned int k, fmt_flag, ver_flag; unsigned int k, fmt_flag;
if (ctx->mode == S5P_JPEG_ENCODE) if (ctx->mode == S5P_JPEG_ENCODE)
fmt_flag = (fmt_type == FMT_TYPE_OUTPUT) ? fmt_flag = (fmt_type == FMT_TYPE_OUTPUT) ?
...@@ -970,16 +970,11 @@ static struct s5p_jpeg_fmt *s5p_jpeg_find_format(struct s5p_jpeg_ctx *ctx, ...@@ -970,16 +970,11 @@ static struct s5p_jpeg_fmt *s5p_jpeg_find_format(struct s5p_jpeg_ctx *ctx,
SJPEG_FMT_FLAG_DEC_OUTPUT : SJPEG_FMT_FLAG_DEC_OUTPUT :
SJPEG_FMT_FLAG_DEC_CAPTURE; SJPEG_FMT_FLAG_DEC_CAPTURE;
if (ctx->jpeg->variant->version == SJPEG_S5P)
ver_flag = SJPEG_FMT_FLAG_S5P;
else
ver_flag = SJPEG_FMT_FLAG_EXYNOS4;
for (k = 0; k < ARRAY_SIZE(sjpeg_formats); k++) { for (k = 0; k < ARRAY_SIZE(sjpeg_formats); k++) {
struct s5p_jpeg_fmt *fmt = &sjpeg_formats[k]; struct s5p_jpeg_fmt *fmt = &sjpeg_formats[k];
if (fmt->fourcc == pixelformat && if (fmt->fourcc == pixelformat &&
fmt->flags & fmt_flag && fmt->flags & fmt_flag &&
fmt->flags & ver_flag) { fmt->flags & ctx->jpeg->variant->fmt_ver_flag) {
return fmt; return fmt;
} }
} }
...@@ -2104,11 +2099,13 @@ static const struct dev_pm_ops s5p_jpeg_pm_ops = { ...@@ -2104,11 +2099,13 @@ static const struct dev_pm_ops s5p_jpeg_pm_ops = {
static struct s5p_jpeg_variant s5p_jpeg_drvdata = { static struct s5p_jpeg_variant s5p_jpeg_drvdata = {
.version = SJPEG_S5P, .version = SJPEG_S5P,
.jpeg_irq = s5p_jpeg_irq, .jpeg_irq = s5p_jpeg_irq,
.fmt_ver_flag = SJPEG_FMT_FLAG_S5P,
}; };
static struct s5p_jpeg_variant exynos4_jpeg_drvdata = { static struct s5p_jpeg_variant exynos4_jpeg_drvdata = {
.version = SJPEG_EXYNOS4, .version = SJPEG_EXYNOS4,
.jpeg_irq = exynos4_jpeg_irq, .jpeg_irq = exynos4_jpeg_irq,
.fmt_ver_flag = SJPEG_FMT_FLAG_EXYNOS4,
}; };
static const struct of_device_id samsung_jpeg_match[] = { static const struct of_device_id samsung_jpeg_match[] = {
......
...@@ -118,6 +118,7 @@ struct s5p_jpeg { ...@@ -118,6 +118,7 @@ struct s5p_jpeg {
struct s5p_jpeg_variant { struct s5p_jpeg_variant {
unsigned int version; unsigned int version;
unsigned int fmt_ver_flag;
irqreturn_t (*jpeg_irq)(int irq, void *priv); irqreturn_t (*jpeg_irq)(int irq, void *priv);
}; };
......
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