blob: 2d24adfd410b04be8981c8b227a8d633aa790da3 [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.wang154f11d52023-04-14 07:56:49 +000022typedef enum _MESON_CONTENT_TYPE {
23 MESON_CONTENT_TYPE_Data = 0,
24 MESON_CONTENT_TYPE_Graphics,
25 MESON_CONTENT_TYPE_Photo,
26 MESON_CONTENT_TYPE_Cinema,
27 MESON_CONTENT_TYPE_Game,
28 MESON_CONTENT_TYPE_RESERVED
29} MESON_CONTENT_TYPE;
30
31/*HDCP transmission time divided into Type0&Type1 content*/
32typedef enum _ENUM_MESON_HDCP_Content_Type{
33 MESON_HDCP_Type0 = 0, //Type0 represents support for both 1.4 and 2.2
34 MESON_HDCP_Type1, //Type1 represents only support for 2.2
35 MESON_HDCP_Type_RESERVED
36} ENUM_MESON_HDCP_Content_Type;
37
limin.tian20df7d42023-02-10 10:05:52 +080038typedef enum {
39 MESON_DISCONNECTED = 0,
40 MESON_CONNECTED = 1,
41 MESON_UNKNOWNCONNECTION = 2
42} ENUM_MESON_CONN_CONNECTION;
43
44typedef struct _DisplayMode {
chen.wang154f11d52023-04-14 07:56:49 +000045 uint16_t w; //<--Number of horizontal pixels in the effective display area-->//
46 uint16_t h; //<--Number of vertical pixels in the effective display area-->//
47 uint32_t vrefresh; //<--Display refresh rate--->//
48 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 +080049 char name[DRM_DISPLAY_MODE_LEN];
50} DisplayMode;
51
52typedef enum _ENUM_MESON_HDR_MODE {
53 MESON_HDR10PLUS = 0,
54 MESON_DOLBYVISION_STD,
55 MESON_DOLBYVISION_LL,
56 MESON_HDR10_ST2084,
57 MESON_HDR10_TRADITIONAL,
58 MESON_HDR_HLG,
59 MESON_SDR
60} ENUM_MESON_HDR_MODE;
61
62typedef enum _ENUM_MESON_CONNECTOR_TYPE {
chen.wang1a175cb02023-08-10 08:39:05 +000063 MESON_CONNECTOR_HDMIA = 0,
limin.tian20df7d42023-02-10 10:05:52 +080064 MESON_CONNECTOR_HDMIB,
65 MESON_CONNECTOR_LVDS,
66 MESON_CONNECTOR_CVBS,
chen.wang1a175cb02023-08-10 08:39:05 +000067 MESON_CONNECTOR_DUMMY,
limin.tian20df7d42023-02-10 10:05:52 +080068 MESON_CONNECTOR_RESERVED
69} MESON_CONNECTOR_TYPE;
70
71typedef enum _ENUM_MESON_COLOR_SPACE {
72 MESON_COLOR_SPACE_RGB = 0,
73 MESON_COLOR_SPACE_YCBCR422,
74 MESON_COLOR_SPACE_YCBCR444,
75 MESON_COLOR_SPACE_YCBCR420,
76 MESON_COLOR_SPACE_RESERVED
77} ENUM_MESON_COLOR_SPACE;
78
79typedef enum _ENUM_MESON_HDCP_VERSION {
80 MESON_HDCP_14 = 0,
81 MESON_HDCP_22,
82 MESON_HDCP_RESERVED
83} ENUM_MESON_HDCP_VERSION;
84
85typedef enum _ENUM_MESON_HDR_POLICY {
86 MESON_HDR_POLICY_FOLLOW_SINK = 0,
87 MESON_HDR_POLICY_FOLLOW_SOURCE
88} ENUM_MESON_HDR_POLICY;
89
limin.tianfe2ab442023-03-06 08:40:15 +000090typedef enum _ENUM_MESON_HDCP_AUTH_STATUS {
91 MESON_AUTH_STATUS_FAIL = 0,
92 MESON_AUTH_STATUS_SUCCESS
93} ENUM_MESON_HDCPAUTH_STATUS;
94
chen.wang154f11d52023-04-14 07:56:49 +000095int meson_drm_setContentType(int drmFd, drmModeAtomicReq *req,
96 MESON_CONTENT_TYPE contentType, MESON_CONNECTOR_TYPE connType);
97
98int meson_drm_setVrrEnabled(int drmFd, drmModeAtomicReq *req,
99 uint32_t VrrEnable, MESON_CONNECTOR_TYPE connType);
100int meson_drm_getVrrEnabled( int drmFd, MESON_CONNECTOR_TYPE connType );
101
102
103int meson_drm_getActive( int drmFd, MESON_CONNECTOR_TYPE connType );
104
105int meson_drm_setActive(int drmFd, drmModeAtomicReq *req,
106 uint32_t active, MESON_CONNECTOR_TYPE connType);
107
108int meson_drm_getDvEnable( int drmFd, MESON_CONNECTOR_TYPE connType );
109int meson_drm_setDvEnable(int drmFd, drmModeAtomicReq *req,
110 uint32_t dvEnable, MESON_CONNECTOR_TYPE connType);
111
112MESON_CONTENT_TYPE meson_drm_getContentType(int drmFd, MESON_CONNECTOR_TYPE connType );
113
114
limin.tian20df7d42023-02-10 10:05:52 +0800115int meson_drm_changeMode(int drmFd, drmModeAtomicReq *req,
116 DisplayMode* modeInfo, MESON_CONNECTOR_TYPE connType);
117int meson_drm_getModeInfo(int drmFd, MESON_CONNECTOR_TYPE connType, DisplayMode* mode );
118
119ENUM_MESON_CONN_CONNECTION meson_drm_getConnectionStatus(int drmFd, MESON_CONNECTOR_TYPE connType);
120ENUM_MESON_HDR_MODE meson_drm_getHdrStatus(int drmFd, MESON_CONNECTOR_TYPE connType );
121ENUM_MESON_HDCP_VERSION meson_drm_getHdcpVersion(int drmFd, MESON_CONNECTOR_TYPE connType );
122ENUM_MESON_COLOR_SPACE meson_drm_getColorSpace(int drmFd, MESON_CONNECTOR_TYPE connType );
123int meson_drm_setColorSpace(int drmFd, drmModeAtomicReq *req,
124 ENUM_MESON_COLOR_SPACE colorSpace, MESON_CONNECTOR_TYPE connType);
125
126uint32_t meson_drm_getColorDepth(int drmFd, MESON_CONNECTOR_TYPE connType );
127int meson_drm_setColorDepth(int drmFd, drmModeAtomicReq *req,
128 uint32_t colorDepth, MESON_CONNECTOR_TYPE connType);
129
130ENUM_MESON_HDR_POLICY meson_drm_getHDRPolicy(int drmFd, MESON_CONNECTOR_TYPE connType );
131int meson_drm_setHDRPolicy(int drmFd, drmModeAtomicReq *req,
132 ENUM_MESON_HDR_POLICY hdrPolicy, MESON_CONNECTOR_TYPE connType);
133
limin.tianfe2ab442023-03-06 08:40:15 +0000134
135void meson_drm_getEDIDData(int drmFd, MESON_CONNECTOR_TYPE connType, int * data_Len, char **data );
136int meson_drm_setAVMute(int drmFd, drmModeAtomicReq *req,
137 bool mute, MESON_CONNECTOR_TYPE connType);
chen.wang154f11d52023-04-14 07:56:49 +0000138int meson_drm_getAVMute( int drmFd, MESON_CONNECTOR_TYPE connType );
139
limin.tianfe2ab442023-03-06 08:40:15 +0000140ENUM_MESON_HDCPAUTH_STATUS meson_drm_getHdcpAuthStatus( int drmFd, MESON_CONNECTOR_TYPE connType );
141int meson_drm_setHDCPEnable(int drmFd, drmModeAtomicReq *req,
142 bool enable, MESON_CONNECTOR_TYPE connType);
143
chen.wang154f11d52023-04-14 07:56:49 +0000144int meson_drm_getsupportedModesList(int drmFd, DisplayMode** modeInfo, int* modeCount );
145int meson_drm_getPreferredMode( DisplayMode* mode);
146
147int meson_drm_setHDCPContentType(int drmFd, drmModeAtomicReq *req,
148 ENUM_MESON_HDCP_Content_Type HDCPType, MESON_CONNECTOR_TYPE connType);
149ENUM_MESON_HDCP_Content_Type meson_drm_getHDCPContentType( int drmFd, MESON_CONNECTOR_TYPE connType );
150
151int meson_drm_getHdcpVer( int drmFd, MESON_CONNECTOR_TYPE connType );
152
153int meson_drm_getHdrCap( int drmFd, MESON_CONNECTOR_TYPE connType );
154int meson_drm_getDvCap( int drmFd, MESON_CONNECTOR_TYPE connType );
155
limin.tian20df7d42023-02-10 10:05:52 +0800156int meson_open_drm();
157void meson_close_drm(int drmFd);
158
159#if defined(__cplusplus)
160}
161#endif
162
163#endif