blob: 959f543cf9ff3e7fa0f53f2af587a398100a9b53 [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.wang133a5c832023-07-12 04:23:36 +000022struct video_zpos {
23 unsigned int index;//<--Representing video index Index 0 corresponds to modifying video 0;Index 1 corresponds to modifying video 1-->//
24 unsigned int zpos; //<--Represents the zorder value set-->//
25 unsigned int flag; //<-- Make the settings effective Set flag equal to 1 to indicate effectiveness-->//
26};
27
chen.wang1c258d832023-10-18 09:28:25 +000028typedef enum _ENUM_MESON_ASPECTRATIO {
29 MESON_ASPECT_RATIO_AUTOMATIC =0,
30 MESON_ASPECT_RATIO_4_3,
31 MESON_ASPECT_RATIO_16_9,
32 MESON_ASPECT_RATIO_RESERVED
33} ENUM_MESON_ASPECT_RATIO;
34
chen.wang154f11d52023-04-14 07:56:49 +000035typedef enum _MESON_CONTENT_TYPE {
36 MESON_CONTENT_TYPE_Data = 0,
37 MESON_CONTENT_TYPE_Graphics,
38 MESON_CONTENT_TYPE_Photo,
39 MESON_CONTENT_TYPE_Cinema,
40 MESON_CONTENT_TYPE_Game,
41 MESON_CONTENT_TYPE_RESERVED
42} MESON_CONTENT_TYPE;
43
44/*HDCP transmission time divided into Type0&Type1 content*/
45typedef enum _ENUM_MESON_HDCP_Content_Type{
46 MESON_HDCP_Type0 = 0, //Type0 represents support for both 1.4 and 2.2
47 MESON_HDCP_Type1, //Type1 represents only support for 2.2
48 MESON_HDCP_Type_RESERVED
49} ENUM_MESON_HDCP_Content_Type;
50
limin.tian20df7d42023-02-10 10:05:52 +080051typedef enum {
52 MESON_DISCONNECTED = 0,
53 MESON_CONNECTED = 1,
54 MESON_UNKNOWNCONNECTION = 2
55} ENUM_MESON_CONN_CONNECTION;
56
57typedef struct _DisplayMode {
chen.wang154f11d52023-04-14 07:56:49 +000058 uint16_t w; //<--Number of horizontal pixels in the effective display area-->//
59 uint16_t h; //<--Number of vertical pixels in the effective display area-->//
60 uint32_t vrefresh; //<--Display refresh rate--->//
61 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 +080062 char name[DRM_DISPLAY_MODE_LEN];
63} DisplayMode;
64
65typedef enum _ENUM_MESON_HDR_MODE {
66 MESON_HDR10PLUS = 0,
67 MESON_DOLBYVISION_STD,
68 MESON_DOLBYVISION_LL,
69 MESON_HDR10_ST2084,
70 MESON_HDR10_TRADITIONAL,
71 MESON_HDR_HLG,
72 MESON_SDR
73} ENUM_MESON_HDR_MODE;
74
75typedef enum _ENUM_MESON_CONNECTOR_TYPE {
chen.wang1a175cb02023-08-10 08:39:05 +000076 MESON_CONNECTOR_HDMIA = 0,
limin.tian20df7d42023-02-10 10:05:52 +080077 MESON_CONNECTOR_HDMIB,
78 MESON_CONNECTOR_LVDS,
79 MESON_CONNECTOR_CVBS,
chen.wang1a175cb02023-08-10 08:39:05 +000080 MESON_CONNECTOR_DUMMY,
limin.tian20df7d42023-02-10 10:05:52 +080081 MESON_CONNECTOR_RESERVED
82} MESON_CONNECTOR_TYPE;
83
84typedef enum _ENUM_MESON_COLOR_SPACE {
85 MESON_COLOR_SPACE_RGB = 0,
86 MESON_COLOR_SPACE_YCBCR422,
87 MESON_COLOR_SPACE_YCBCR444,
88 MESON_COLOR_SPACE_YCBCR420,
89 MESON_COLOR_SPACE_RESERVED
90} ENUM_MESON_COLOR_SPACE;
91
92typedef enum _ENUM_MESON_HDCP_VERSION {
93 MESON_HDCP_14 = 0,
94 MESON_HDCP_22,
95 MESON_HDCP_RESERVED
96} ENUM_MESON_HDCP_VERSION;
97
98typedef enum _ENUM_MESON_HDR_POLICY {
99 MESON_HDR_POLICY_FOLLOW_SINK = 0,
100 MESON_HDR_POLICY_FOLLOW_SOURCE
101} ENUM_MESON_HDR_POLICY;
102
limin.tianfe2ab442023-03-06 08:40:15 +0000103typedef enum _ENUM_MESON_HDCP_AUTH_STATUS {
104 MESON_AUTH_STATUS_FAIL = 0,
105 MESON_AUTH_STATUS_SUCCESS
106} ENUM_MESON_HDCPAUTH_STATUS;
107
chen.wang154f11d52023-04-14 07:56:49 +0000108int meson_drm_setContentType(int drmFd, drmModeAtomicReq *req,
109 MESON_CONTENT_TYPE contentType, MESON_CONNECTOR_TYPE connType);
110
111int meson_drm_setVrrEnabled(int drmFd, drmModeAtomicReq *req,
112 uint32_t VrrEnable, MESON_CONNECTOR_TYPE connType);
113int meson_drm_getVrrEnabled( int drmFd, MESON_CONNECTOR_TYPE connType );
114
115
116int meson_drm_getActive( int drmFd, MESON_CONNECTOR_TYPE connType );
117
118int meson_drm_setActive(int drmFd, drmModeAtomicReq *req,
119 uint32_t active, MESON_CONNECTOR_TYPE connType);
120
121int meson_drm_getDvEnable( int drmFd, MESON_CONNECTOR_TYPE connType );
122int meson_drm_setDvEnable(int drmFd, drmModeAtomicReq *req,
123 uint32_t dvEnable, MESON_CONNECTOR_TYPE connType);
124
125MESON_CONTENT_TYPE meson_drm_getContentType(int drmFd, MESON_CONNECTOR_TYPE connType );
126
127
limin.tian20df7d42023-02-10 10:05:52 +0800128int meson_drm_changeMode(int drmFd, drmModeAtomicReq *req,
129 DisplayMode* modeInfo, MESON_CONNECTOR_TYPE connType);
130int meson_drm_getModeInfo(int drmFd, MESON_CONNECTOR_TYPE connType, DisplayMode* mode );
131
132ENUM_MESON_CONN_CONNECTION meson_drm_getConnectionStatus(int drmFd, MESON_CONNECTOR_TYPE connType);
133ENUM_MESON_HDR_MODE meson_drm_getHdrStatus(int drmFd, MESON_CONNECTOR_TYPE connType );
134ENUM_MESON_HDCP_VERSION meson_drm_getHdcpVersion(int drmFd, MESON_CONNECTOR_TYPE connType );
135ENUM_MESON_COLOR_SPACE meson_drm_getColorSpace(int drmFd, MESON_CONNECTOR_TYPE connType );
136int meson_drm_setColorSpace(int drmFd, drmModeAtomicReq *req,
137 ENUM_MESON_COLOR_SPACE colorSpace, MESON_CONNECTOR_TYPE connType);
138
139uint32_t meson_drm_getColorDepth(int drmFd, MESON_CONNECTOR_TYPE connType );
140int meson_drm_setColorDepth(int drmFd, drmModeAtomicReq *req,
141 uint32_t colorDepth, MESON_CONNECTOR_TYPE connType);
142
143ENUM_MESON_HDR_POLICY meson_drm_getHDRPolicy(int drmFd, MESON_CONNECTOR_TYPE connType );
144int meson_drm_setHDRPolicy(int drmFd, drmModeAtomicReq *req,
145 ENUM_MESON_HDR_POLICY hdrPolicy, MESON_CONNECTOR_TYPE connType);
146
limin.tianfe2ab442023-03-06 08:40:15 +0000147
148void meson_drm_getEDIDData(int drmFd, MESON_CONNECTOR_TYPE connType, int * data_Len, char **data );
149int meson_drm_setAVMute(int drmFd, drmModeAtomicReq *req,
150 bool mute, MESON_CONNECTOR_TYPE connType);
chen.wang154f11d52023-04-14 07:56:49 +0000151int meson_drm_getAVMute( int drmFd, MESON_CONNECTOR_TYPE connType );
152
limin.tianfe2ab442023-03-06 08:40:15 +0000153ENUM_MESON_HDCPAUTH_STATUS meson_drm_getHdcpAuthStatus( int drmFd, MESON_CONNECTOR_TYPE connType );
154int meson_drm_setHDCPEnable(int drmFd, drmModeAtomicReq *req,
155 bool enable, MESON_CONNECTOR_TYPE connType);
156
chen.wang13c3450e2023-08-01 11:07:11 +0000157int meson_drm_getsupportedModesList(int drmFd, DisplayMode** modeInfo, int* modeCount ,MESON_CONNECTOR_TYPE connType);
158int meson_drm_getPreferredMode( DisplayMode* mode, MESON_CONNECTOR_TYPE connType);
chen.wang154f11d52023-04-14 07:56:49 +0000159
160int meson_drm_setHDCPContentType(int drmFd, drmModeAtomicReq *req,
161 ENUM_MESON_HDCP_Content_Type HDCPType, MESON_CONNECTOR_TYPE connType);
162ENUM_MESON_HDCP_Content_Type meson_drm_getHDCPContentType( int drmFd, MESON_CONNECTOR_TYPE connType );
163
164int meson_drm_getHdcpVer( int drmFd, MESON_CONNECTOR_TYPE connType );
165
166int meson_drm_getHdrCap( int drmFd, MESON_CONNECTOR_TYPE connType );
167int meson_drm_getDvCap( int drmFd, MESON_CONNECTOR_TYPE connType );
chen.wang1c258d832023-10-18 09:28:25 +0000168int meson_drm_setVideoZorder(int drmFd, unsigned int index, unsigned int zorder, unsigned int flag);
169int meson_drm_setPlaneMute(int drmFd, unsigned int plane_type, unsigned int plane_mute);
170
171ENUM_MESON_ASPECT_RATIO meson_drm_getAspectRatioValue( int drmFd, MESON_CONNECTOR_TYPE connType );
172int meson_drm_setAspectRatioValue(int drmFd, drmModeAtomicReq *req,
173 ENUM_MESON_ASPECT_RATIO ASPECTRATIO, MESON_CONNECTOR_TYPE connType);
chen.wang154f11d52023-04-14 07:56:49 +0000174
limin.tian20df7d42023-02-10 10:05:52 +0800175int meson_open_drm();
176void meson_close_drm(int drmFd);
177
178#if defined(__cplusplus)
179}
180#endif
181
182#endif