aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/vimc
diff options
context:
space:
mode:
authorHelen Fornazier <helen.koike@collabora.com>2017-06-19 13:00:15 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-06-23 08:06:02 -0400
commit441c0db6e5a2f07f91b72e31a22a19180d28ebf5 (patch)
treecc401c10416395d2a6bf1284d90ac644fc116f5b /drivers/media/platform/vimc
parent288a22d45c631f5be5e1c8b83977a78841083d3c (diff)
[media] vimc: common: Add vimc_colorimetry_clamp
Colorimetry value will always be checked in the same way. Adding a helper macro for that Signed-off-by: Helen Koike <helen.koike@collabora.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/platform/vimc')
-rw-r--r--drivers/media/platform/vimc/vimc-common.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/media/platform/vimc/vimc-common.h b/drivers/media/platform/vimc/vimc-common.h
index 60ebde28f56b..43483eecb116 100644
--- a/drivers/media/platform/vimc/vimc-common.h
+++ b/drivers/media/platform/vimc/vimc-common.h
@@ -23,6 +23,32 @@
23#include <media/v4l2-device.h> 23#include <media/v4l2-device.h>
24 24
25/** 25/**
26 * struct vimc_colorimetry_clamp - Adjust colorimetry parameters
27 *
28 * @fmt: the pointer to struct v4l2_pix_format or
29 * struct v4l2_mbus_framefmt
30 *
31 * Entities must check if colorimetry given by the userspace is valid, if not
32 * then set them as DEFAULT
33 */
34#define vimc_colorimetry_clamp(fmt) \
35do { \
36 if ((fmt)->colorspace == V4L2_COLORSPACE_DEFAULT \
37 || (fmt)->colorspace > V4L2_COLORSPACE_DCI_P3) { \
38 (fmt)->colorspace = V4L2_COLORSPACE_DEFAULT; \
39 (fmt)->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; \
40 (fmt)->quantization = V4L2_QUANTIZATION_DEFAULT; \
41 (fmt)->xfer_func = V4L2_XFER_FUNC_DEFAULT; \
42 } \
43 if ((fmt)->ycbcr_enc > V4L2_YCBCR_ENC_SMPTE240M) \
44 (fmt)->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; \
45 if ((fmt)->quantization > V4L2_QUANTIZATION_LIM_RANGE) \
46 (fmt)->quantization = V4L2_QUANTIZATION_DEFAULT; \
47 if ((fmt)->xfer_func > V4L2_XFER_FUNC_SMPTE2084) \
48 (fmt)->xfer_func = V4L2_XFER_FUNC_DEFAULT; \
49} while (0)
50
51/**
26 * struct vimc_pix_map - maps media bus code with v4l2 pixel format 52 * struct vimc_pix_map - maps media bus code with v4l2 pixel format
27 * 53 *
28 * @code: media bus format code defined by MEDIA_BUS_FMT_* macros 54 * @code: media bus format code defined by MEDIA_BUS_FMT_* macros