aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2015-04-28 07:49:09 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-06-05 10:45:45 -0400
commit74fdcb2ee1786a92584e89c91006e449813527ce (patch)
tree7463ad10b2bfb97ccba2197cd797464417ac1ce9 /include/uapi/linux
parentaf8a819a2513df4be461c6a29e3bdee6e23cf3be (diff)
[media] videodev2.h: add support for transfer functions
In the past the transfer function was implied by the colorspace. However, it is an independent entity in its own right. Add support for explicitly choosing the transfer function. This change will allow us to represent linear RGB (as is used by openGL), and it will make it easier to work with decoded video material since most codecs store the transfer function as a separate property as well. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'include/uapi/linux')
-rw-r--r--include/uapi/linux/v4l2-mediabus.h4
-rw-r--r--include/uapi/linux/videodev2.h41
2 files changed, 43 insertions, 2 deletions
diff --git a/include/uapi/linux/v4l2-mediabus.h b/include/uapi/linux/v4l2-mediabus.h
index 26db20647e6f..9cac6325cc7e 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -24,6 +24,7 @@
24 * @colorspace: colorspace of the data (from enum v4l2_colorspace) 24 * @colorspace: colorspace of the data (from enum v4l2_colorspace)
25 * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding) 25 * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
26 * @quantization: quantization of the data (from enum v4l2_quantization) 26 * @quantization: quantization of the data (from enum v4l2_quantization)
27 * @xfer_func: transfer function of the data (from enum v4l2_xfer_func)
27 */ 28 */
28struct v4l2_mbus_framefmt { 29struct v4l2_mbus_framefmt {
29 __u32 width; 30 __u32 width;
@@ -33,7 +34,8 @@ struct v4l2_mbus_framefmt {
33 __u32 colorspace; 34 __u32 colorspace;
34 __u16 ycbcr_enc; 35 __u16 ycbcr_enc;
35 __u16 quantization; 36 __u16 quantization;
36 __u32 reserved[6]; 37 __u16 xfer_func;
38 __u16 reserved[11];
37}; 39};
38 40
39#ifndef __KERNEL__ 41#ifndef __KERNEL__
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 003a91292a4f..3d5fc72d53a7 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -240,6 +240,42 @@ enum v4l2_colorspace {
240 ((is_sdtv) ? V4L2_COLORSPACE_SMPTE170M : \ 240 ((is_sdtv) ? V4L2_COLORSPACE_SMPTE170M : \
241 ((is_hdtv) ? V4L2_COLORSPACE_REC709 : V4L2_COLORSPACE_SRGB)) 241 ((is_hdtv) ? V4L2_COLORSPACE_REC709 : V4L2_COLORSPACE_SRGB))
242 242
243enum v4l2_xfer_func {
244 /*
245 * Mapping of V4L2_XFER_FUNC_DEFAULT to actual transfer functions
246 * for the various colorspaces:
247 *
248 * V4L2_COLORSPACE_SMPTE170M, V4L2_COLORSPACE_470_SYSTEM_M,
249 * V4L2_COLORSPACE_470_SYSTEM_BG, V4L2_COLORSPACE_REC709 and
250 * V4L2_COLORSPACE_BT2020: V4L2_XFER_FUNC_709
251 *
252 * V4L2_COLORSPACE_SRGB, V4L2_COLORSPACE_JPEG: V4L2_XFER_FUNC_SRGB
253 *
254 * V4L2_COLORSPACE_ADOBERGB: V4L2_XFER_FUNC_ADOBERGB
255 *
256 * V4L2_COLORSPACE_SMPTE240M: V4L2_XFER_FUNC_SMPTE240M
257 *
258 * V4L2_COLORSPACE_RAW: V4L2_XFER_FUNC_NONE
259 */
260 V4L2_XFER_FUNC_DEFAULT = 0,
261 V4L2_XFER_FUNC_709 = 1,
262 V4L2_XFER_FUNC_SRGB = 2,
263 V4L2_XFER_FUNC_ADOBERGB = 3,
264 V4L2_XFER_FUNC_SMPTE240M = 4,
265 V4L2_XFER_FUNC_NONE = 5,
266};
267
268/*
269 * Determine how XFER_FUNC_DEFAULT should map to a proper transfer function.
270 * This depends on the colorspace.
271 */
272#define V4L2_MAP_XFER_FUNC_DEFAULT(colsp) \
273 ((colsp) == V4L2_XFER_FUNC_ADOBERGB ? V4L2_XFER_FUNC_ADOBERGB : \
274 ((colsp) == V4L2_COLORSPACE_SMPTE240M ? V4L2_XFER_FUNC_SMPTE240M : \
275 ((colsp) == V4L2_COLORSPACE_RAW ? V4L2_XFER_FUNC_NONE : \
276 ((colsp) == V4L2_COLORSPACE_SRGB || (colsp) == V4L2_COLORSPACE_JPEG ? \
277 V4L2_XFER_FUNC_SRGB : V4L2_XFER_FUNC_709))))
278
243enum v4l2_ycbcr_encoding { 279enum v4l2_ycbcr_encoding {
244 /* 280 /*
245 * Mapping of V4L2_YCBCR_ENC_DEFAULT to actual encodings for the 281 * Mapping of V4L2_YCBCR_ENC_DEFAULT to actual encodings for the
@@ -409,6 +445,7 @@ struct v4l2_pix_format {
409 __u32 flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */ 445 __u32 flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */
410 __u32 ycbcr_enc; /* enum v4l2_ycbcr_encoding */ 446 __u32 ycbcr_enc; /* enum v4l2_ycbcr_encoding */
411 __u32 quantization; /* enum v4l2_quantization */ 447 __u32 quantization; /* enum v4l2_quantization */
448 __u32 xfer_func; /* enum v4l2_xfer_func */
412}; 449};
413 450
414/* Pixel format FOURCC depth Description */ 451/* Pixel format FOURCC depth Description */
@@ -1907,6 +1944,7 @@ struct v4l2_plane_pix_format {
1907 * @flags: format flags (V4L2_PIX_FMT_FLAG_*) 1944 * @flags: format flags (V4L2_PIX_FMT_FLAG_*)
1908 * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding 1945 * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding
1909 * @quantization: enum v4l2_quantization, colorspace quantization 1946 * @quantization: enum v4l2_quantization, colorspace quantization
1947 * @xfer_func: enum v4l2_xfer_func, colorspace transfer function
1910 */ 1948 */
1911struct v4l2_pix_format_mplane { 1949struct v4l2_pix_format_mplane {
1912 __u32 width; 1950 __u32 width;
@@ -1920,7 +1958,8 @@ struct v4l2_pix_format_mplane {
1920 __u8 flags; 1958 __u8 flags;
1921 __u8 ycbcr_enc; 1959 __u8 ycbcr_enc;
1922 __u8 quantization; 1960 __u8 quantization;
1923 __u8 reserved[8]; 1961 __u8 xfer_func;
1962 __u8 reserved[7];
1924} __attribute__ ((packed)); 1963} __attribute__ ((packed));
1925 1964
1926/** 1965/**