blob: f0d52e84c6e267390b9b56f514dad94d2d243419 [file] [log] [blame]
limin.tian20df7d42023-02-10 10:05:52 +08001/*
2 * Copyright (c) 2021 Amlogic, Inc. All rights reserved.
3 *
4 * This source code is subject to the terms and conditions defined in the
5 * file 'LICENSE' which is part of this source code package.
6 *
7 * Description:
8 */
limin.tian20df7d42023-02-10 10:05:52 +08009#ifndef MESON_DRM_SETTINGS_H_
10#define MESON_DRM_SETTINGS_H_
11#include <stdio.h>
12#include <stdint.h>
13#include <stdlib.h>
14#include <unistd.h>
15#include <stdbool.h>
16#include <xf86drmMode.h>
17#if defined(__cplusplus)
18extern "C" {
19#endif
20#define DRM_DISPLAY_MODE_LEN 32
21
chen.wang17a8264c2023-11-17 08:39:21 +000022typedef enum _ENUM_MESON_DRM_PROP_NAME {
23 ENUM_MESON_DRM_PROP_CONTENT_PROTECTION = 0,
24 ENUM_MESON_DRM_PROP_HDR_POLICY,
25 ENUM_MESON_DRM_PROP_HDMI_ENABLE,
26 ENUM_MESON_DRM_PROP_COLOR_SPACE,
27 ENUM_MESON_DRM_PROP_COLOR_DEPTH,
28 ENUM_MESON_DRM_PROP_HDCP_VERSION,
29 ENUM_MESON_DRM_PROP_DOLBY_VISION_ENABLE,
30 ENUM_MESON_DRM_PROP_ACTIVE,
31 ENUM_MESON_DRM_PROP_VRR_ENABLED,
32 ENUM_MESON_DRM_PROP_ASPECT_RATIO
33} ENUM_MESON_DRM_PROP_NAME;
34
chen.wang133a5c832023-07-12 04:23:36 +000035struct video_zpos {
36 unsigned int index;//<--Representing video index Index 0 corresponds to modifying video 0;Index 1 corresponds to modifying video 1-->//
37 unsigned int zpos; //<--Represents the zorder value set-->//
38 unsigned int flag; //<-- Make the settings effective Set flag equal to 1 to indicate effectiveness-->//
39};
40
chen.wang1c258d832023-10-18 09:28:25 +000041typedef enum _ENUM_MESON_ASPECTRATIO {
42 MESON_ASPECT_RATIO_AUTOMATIC =0,
43 MESON_ASPECT_RATIO_4_3,
44 MESON_ASPECT_RATIO_16_9,
45 MESON_ASPECT_RATIO_RESERVED
46} ENUM_MESON_ASPECT_RATIO;
47
chen.wang154f11d52023-04-14 07:56:49 +000048typedef enum _MESON_CONTENT_TYPE {
49 MESON_CONTENT_TYPE_Data = 0,
50 MESON_CONTENT_TYPE_Graphics,
51 MESON_CONTENT_TYPE_Photo,
52 MESON_CONTENT_TYPE_Cinema,
53 MESON_CONTENT_TYPE_Game,
54 MESON_CONTENT_TYPE_RESERVED
55} MESON_CONTENT_TYPE;
56
57/*HDCP transmission time divided into Type0&Type1 content*/
58typedef enum _ENUM_MESON_HDCP_Content_Type{
59 MESON_HDCP_Type0 = 0, //Type0 represents support for both 1.4 and 2.2
60 MESON_HDCP_Type1, //Type1 represents only support for 2.2
61 MESON_HDCP_Type_RESERVED
62} ENUM_MESON_HDCP_Content_Type;
63
limin.tian20df7d42023-02-10 10:05:52 +080064typedef enum {
65 MESON_DISCONNECTED = 0,
66 MESON_CONNECTED = 1,
67 MESON_UNKNOWNCONNECTION = 2
68} ENUM_MESON_CONN_CONNECTION;
69
70typedef struct _DisplayMode {
chen.wang154f11d52023-04-14 07:56:49 +000071 uint16_t w; //<--Number of horizontal pixels in the effective display area-->//
72 uint16_t h; //<--Number of vertical pixels in the effective display area-->//
73 uint32_t vrefresh; //<--Display refresh rate--->//
74 bool interlace; //<--Indicates which scanning form to choose, P represents progressive scanning, and i represents interlaced scanning; The default interlace value is 0 for P 1 for i-->//
limin.tian20df7d42023-02-10 10:05:52 +080075 char name[DRM_DISPLAY_MODE_LEN];
76} DisplayMode;
77
78typedef enum _ENUM_MESON_HDR_MODE {
79 MESON_HDR10PLUS = 0,
80 MESON_DOLBYVISION_STD,
81 MESON_DOLBYVISION_LL,
82 MESON_HDR10_ST2084,
83 MESON_HDR10_TRADITIONAL,
84 MESON_HDR_HLG,
85 MESON_SDR
86} ENUM_MESON_HDR_MODE;
87
88typedef enum _ENUM_MESON_CONNECTOR_TYPE {
chen.wang1a175cb02023-08-10 08:39:05 +000089 MESON_CONNECTOR_HDMIA = 0,
limin.tian20df7d42023-02-10 10:05:52 +080090 MESON_CONNECTOR_HDMIB,
91 MESON_CONNECTOR_LVDS,
92 MESON_CONNECTOR_CVBS,
chen.wang1a175cb02023-08-10 08:39:05 +000093 MESON_CONNECTOR_DUMMY,
limin.tian20df7d42023-02-10 10:05:52 +080094 MESON_CONNECTOR_RESERVED
95} MESON_CONNECTOR_TYPE;
96
97typedef enum _ENUM_MESON_COLOR_SPACE {
98 MESON_COLOR_SPACE_RGB = 0,
99 MESON_COLOR_SPACE_YCBCR422,
100 MESON_COLOR_SPACE_YCBCR444,
101 MESON_COLOR_SPACE_YCBCR420,
102 MESON_COLOR_SPACE_RESERVED
103} ENUM_MESON_COLOR_SPACE;
104
105typedef enum _ENUM_MESON_HDCP_VERSION {
106 MESON_HDCP_14 = 0,
107 MESON_HDCP_22,
108 MESON_HDCP_RESERVED
109} ENUM_MESON_HDCP_VERSION;
110
111typedef enum _ENUM_MESON_HDR_POLICY {
112 MESON_HDR_POLICY_FOLLOW_SINK = 0,
113 MESON_HDR_POLICY_FOLLOW_SOURCE
114} ENUM_MESON_HDR_POLICY;
115
limin.tianfe2ab442023-03-06 08:40:15 +0000116typedef enum _ENUM_MESON_HDCP_AUTH_STATUS {
117 MESON_AUTH_STATUS_FAIL = 0,
118 MESON_AUTH_STATUS_SUCCESS
119} ENUM_MESON_HDCPAUTH_STATUS;
120
chen.wang154f11d52023-04-14 07:56:49 +0000121int meson_drm_setContentType(int drmFd, drmModeAtomicReq *req,
122 MESON_CONTENT_TYPE contentType, MESON_CONNECTOR_TYPE connType);
123
124int meson_drm_setVrrEnabled(int drmFd, drmModeAtomicReq *req,
125 uint32_t VrrEnable, MESON_CONNECTOR_TYPE connType);
126int meson_drm_getVrrEnabled( int drmFd, MESON_CONNECTOR_TYPE connType );
127
128
129int meson_drm_getActive( int drmFd, MESON_CONNECTOR_TYPE connType );
130
131int meson_drm_setActive(int drmFd, drmModeAtomicReq *req,
132 uint32_t active, MESON_CONNECTOR_TYPE connType);
133
134int meson_drm_getDvEnable( int drmFd, MESON_CONNECTOR_TYPE connType );
135int meson_drm_setDvEnable(int drmFd, drmModeAtomicReq *req,
136 uint32_t dvEnable, MESON_CONNECTOR_TYPE connType);
137
138MESON_CONTENT_TYPE meson_drm_getContentType(int drmFd, MESON_CONNECTOR_TYPE connType );
139
140
limin.tian20df7d42023-02-10 10:05:52 +0800141int meson_drm_changeMode(int drmFd, drmModeAtomicReq *req,
142 DisplayMode* modeInfo, MESON_CONNECTOR_TYPE connType);
143int meson_drm_getModeInfo(int drmFd, MESON_CONNECTOR_TYPE connType, DisplayMode* mode );
144
145ENUM_MESON_CONN_CONNECTION meson_drm_getConnectionStatus(int drmFd, MESON_CONNECTOR_TYPE connType);
146ENUM_MESON_HDR_MODE meson_drm_getHdrStatus(int drmFd, MESON_CONNECTOR_TYPE connType );
147ENUM_MESON_HDCP_VERSION meson_drm_getHdcpVersion(int drmFd, MESON_CONNECTOR_TYPE connType );
148ENUM_MESON_COLOR_SPACE meson_drm_getColorSpace(int drmFd, MESON_CONNECTOR_TYPE connType );
149int meson_drm_setColorSpace(int drmFd, drmModeAtomicReq *req,
150 ENUM_MESON_COLOR_SPACE colorSpace, MESON_CONNECTOR_TYPE connType);
151
152uint32_t meson_drm_getColorDepth(int drmFd, MESON_CONNECTOR_TYPE connType );
153int meson_drm_setColorDepth(int drmFd, drmModeAtomicReq *req,
154 uint32_t colorDepth, MESON_CONNECTOR_TYPE connType);
155
156ENUM_MESON_HDR_POLICY meson_drm_getHDRPolicy(int drmFd, MESON_CONNECTOR_TYPE connType );
157int meson_drm_setHDRPolicy(int drmFd, drmModeAtomicReq *req,
158 ENUM_MESON_HDR_POLICY hdrPolicy, MESON_CONNECTOR_TYPE connType);
159
limin.tianfe2ab442023-03-06 08:40:15 +0000160
161void meson_drm_getEDIDData(int drmFd, MESON_CONNECTOR_TYPE connType, int * data_Len, char **data );
162int meson_drm_setAVMute(int drmFd, drmModeAtomicReq *req,
163 bool mute, MESON_CONNECTOR_TYPE connType);
chen.wang154f11d52023-04-14 07:56:49 +0000164int meson_drm_getAVMute( int drmFd, MESON_CONNECTOR_TYPE connType );
165
limin.tianfe2ab442023-03-06 08:40:15 +0000166ENUM_MESON_HDCPAUTH_STATUS meson_drm_getHdcpAuthStatus( int drmFd, MESON_CONNECTOR_TYPE connType );
167int meson_drm_setHDCPEnable(int drmFd, drmModeAtomicReq *req,
chen.wang17a8264c2023-11-17 08:39:21 +0000168 int enable, MESON_CONNECTOR_TYPE connType);
limin.tianfe2ab442023-03-06 08:40:15 +0000169
chen.wang13c3450e2023-08-01 11:07:11 +0000170int meson_drm_getsupportedModesList(int drmFd, DisplayMode** modeInfo, int* modeCount ,MESON_CONNECTOR_TYPE connType);
171int meson_drm_getPreferredMode( DisplayMode* mode, MESON_CONNECTOR_TYPE connType);
chen.wang154f11d52023-04-14 07:56:49 +0000172
173int meson_drm_setHDCPContentType(int drmFd, drmModeAtomicReq *req,
174 ENUM_MESON_HDCP_Content_Type HDCPType, MESON_CONNECTOR_TYPE connType);
175ENUM_MESON_HDCP_Content_Type meson_drm_getHDCPContentType( int drmFd, MESON_CONNECTOR_TYPE connType );
176
177int meson_drm_getHdcpVer( int drmFd, MESON_CONNECTOR_TYPE connType );
178
179int meson_drm_getHdrCap( int drmFd, MESON_CONNECTOR_TYPE connType );
180int meson_drm_getDvCap( int drmFd, MESON_CONNECTOR_TYPE connType );
chen.wang1c258d832023-10-18 09:28:25 +0000181int meson_drm_setVideoZorder(int drmFd, unsigned int index, unsigned int zorder, unsigned int flag);
182int meson_drm_setPlaneMute(int drmFd, unsigned int plane_type, unsigned int plane_mute);
183
184ENUM_MESON_ASPECT_RATIO meson_drm_getAspectRatioValue( int drmFd, MESON_CONNECTOR_TYPE connType );
185int meson_drm_setAspectRatioValue(int drmFd, drmModeAtomicReq *req,
186 ENUM_MESON_ASPECT_RATIO ASPECTRATIO, MESON_CONNECTOR_TYPE connType);
chen.wang17a8264c2023-11-17 08:39:21 +0000187
188int meson_drm_GetCrtcId(MESON_CONNECTOR_TYPE connType);
189int meson_drm_GetConnectorId(MESON_CONNECTOR_TYPE connType);
190char* meson_drm_GetPropName( ENUM_MESON_DRM_PROP_NAME enProp);
chen.wang154f11d52023-04-14 07:56:49 +0000191
limin.tian20df7d42023-02-10 10:05:52 +0800192int meson_open_drm();
193void meson_close_drm(int drmFd);
194
195#if defined(__cplusplus)
196}
197#endif
198
199#endif