xref: /OK3568_Linux_fs/external/gstreamer-rockchip/gst/rkximage/gstkmsutils.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* GStreamer
2  *
3  * Copyright (C) 2016 Igalia
4  *
5  * Authors:
6  *  Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
7  *  Javier Martin <javiermartin@by.com.es>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public
20  * License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  *
24  */
25 
26 #ifndef __GST_KMS_UTILS_H__
27 #define __GST_KMS_UTILS_H__
28 
29 #include <gst/video/video.h>
30 
31 G_BEGIN_DECLS
32 
33 #ifndef DRM_FORMAT_NV12_10
34 #define DRM_FORMAT_NV12_10 fourcc_code('N', 'A', '1', '2')
35 #endif
36 
37 #ifndef DRM_FORMAT_NV15
38 #define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5')
39 #endif
40 
41 #ifndef DRM_FORMAT_YUV420_8BIT
42 #define DRM_FORMAT_YUV420_8BIT fourcc_code('Y', 'U', '0', '8')
43 #endif
44 
45 #ifndef DRM_FORMAT_YUV420_10BIT
46 #define DRM_FORMAT_YUV420_10BIT fourcc_code('Y', 'U', '1', '0')
47 #endif
48 
49 #ifndef DRM_FORMAT_MOD_VENDOR_ARM
50 #define DRM_FORMAT_MOD_VENDOR_ARM 0x08
51 #endif
52 
53 #ifndef DRM_FORMAT_MOD_ARM_AFBC
54 #define DRM_FORMAT_MOD_ARM_AFBC(__afbc_mode) fourcc_mod_code(ARM, __afbc_mode)
55 #endif
56 
57 #ifndef AFBC_FORMAT_MOD_BLOCK_SIZE_16x16
58 #define AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 (1ULL)
59 #endif
60 
61 #ifndef AFBC_FORMAT_MOD_SPARSE
62 #define AFBC_FORMAT_MOD_SPARSE (((__u64)1) << 6)
63 #endif
64 
65 #define DRM_AFBC_MODIFIER \
66   (DRM_FORMAT_MOD_ARM_AFBC(AFBC_FORMAT_MOD_SPARSE) | \
67    DRM_FORMAT_MOD_ARM_AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16))
68 
69 #ifndef GST_VIDEO_FLAG_ARM_AFBC
70 #define GST_VIDEO_FLAG_ARM_AFBC (1UL << 31)
71 #define GST_VIDEO_INFO_SET_AFBC(i) \
72   GST_VIDEO_INFO_FLAG_SET (i, GST_VIDEO_FLAG_ARM_AFBC)
73 #define GST_VIDEO_INFO_UNSET_AFBC(i) \
74   GST_VIDEO_INFO_FLAG_UNSET (i, GST_VIDEO_FLAG_ARM_AFBC)
75 #define GST_VIDEO_INFO_IS_AFBC(i) \
76   GST_VIDEO_INFO_FLAG_IS_SET (i, GST_VIDEO_FLAG_ARM_AFBC)
77 #endif
78 
79 GstVideoFormat gst_video_format_from_drm (guint32 drmfmt);
80 guint32        gst_drm_format_from_video (GstVideoFormat fmt);
81 guint32        gst_drm_bpp_from_drm (guint32 drmfmt);
82 guint32        gst_drm_height_from_drm (guint32 drmfmt, guint32 height);
83 GstCaps *      gst_kms_sink_caps_template_fill (void);
84 void           gst_video_calculate_device_ratio (guint dev_width,
85 						 guint dev_height,
86 						 guint dev_width_mm,
87 						 guint dev_height_mm,
88 						 guint * dpy_par_n,
89 						 guint * dpy_par_d);
90 
91 G_END_DECLS
92 
93 #endif
94