limin.tian | 20df7d4 | 2023-02-10 10:05:52 +0800 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 9 | |
| 10 | #ifndef MESON_DRM_SETTINGS_H_ |
| 11 | #define MESON_DRM_SETTINGS_H_ |
| 12 | #include <stdio.h> |
| 13 | #include <stdint.h> |
| 14 | #include <stdlib.h> |
| 15 | #include <unistd.h> |
| 16 | #include <stdbool.h> |
| 17 | #include <xf86drmMode.h> |
| 18 | #if defined(__cplusplus) |
| 19 | extern "C" { |
| 20 | #endif |
| 21 | #define DRM_DISPLAY_MODE_LEN 32 |
| 22 | |
| 23 | typedef enum { |
| 24 | MESON_DISCONNECTED = 0, |
| 25 | MESON_CONNECTED = 1, |
| 26 | MESON_UNKNOWNCONNECTION = 2 |
| 27 | } ENUM_MESON_CONN_CONNECTION; |
| 28 | |
| 29 | typedef struct _DisplayMode { |
| 30 | uint16_t w; |
| 31 | uint16_t h; |
| 32 | uint32_t vrefresh; |
| 33 | bool interlace; |
| 34 | char name[DRM_DISPLAY_MODE_LEN]; |
| 35 | } DisplayMode; |
| 36 | |
| 37 | typedef enum _ENUM_MESON_HDR_MODE { |
| 38 | MESON_HDR10PLUS = 0, |
| 39 | MESON_DOLBYVISION_STD, |
| 40 | MESON_DOLBYVISION_LL, |
| 41 | MESON_HDR10_ST2084, |
| 42 | MESON_HDR10_TRADITIONAL, |
| 43 | MESON_HDR_HLG, |
| 44 | MESON_SDR |
| 45 | } ENUM_MESON_HDR_MODE; |
| 46 | |
| 47 | typedef enum _ENUM_MESON_CONNECTOR_TYPE { |
| 48 | MESON_CONNECTOR_HDMIA = 0, |
| 49 | MESON_CONNECTOR_HDMIB, |
| 50 | MESON_CONNECTOR_LVDS, |
| 51 | MESON_CONNECTOR_CVBS, |
| 52 | MESON_CONNECTOR_RESERVED |
| 53 | } MESON_CONNECTOR_TYPE; |
| 54 | |
| 55 | typedef enum _ENUM_MESON_COLOR_SPACE { |
| 56 | MESON_COLOR_SPACE_RGB = 0, |
| 57 | MESON_COLOR_SPACE_YCBCR422, |
| 58 | MESON_COLOR_SPACE_YCBCR444, |
| 59 | MESON_COLOR_SPACE_YCBCR420, |
| 60 | MESON_COLOR_SPACE_RESERVED |
| 61 | } ENUM_MESON_COLOR_SPACE; |
| 62 | |
| 63 | typedef enum _ENUM_MESON_HDCP_VERSION { |
| 64 | MESON_HDCP_14 = 0, |
| 65 | MESON_HDCP_22, |
| 66 | MESON_HDCP_RESERVED |
| 67 | } ENUM_MESON_HDCP_VERSION; |
| 68 | |
| 69 | typedef enum _ENUM_MESON_HDR_POLICY { |
| 70 | MESON_HDR_POLICY_FOLLOW_SINK = 0, |
| 71 | MESON_HDR_POLICY_FOLLOW_SOURCE |
| 72 | } ENUM_MESON_HDR_POLICY; |
| 73 | |
| 74 | int meson_drm_changeMode(int drmFd, drmModeAtomicReq *req, |
| 75 | DisplayMode* modeInfo, MESON_CONNECTOR_TYPE connType); |
| 76 | int meson_drm_getModeInfo(int drmFd, MESON_CONNECTOR_TYPE connType, DisplayMode* mode ); |
| 77 | |
| 78 | ENUM_MESON_CONN_CONNECTION meson_drm_getConnectionStatus(int drmFd, MESON_CONNECTOR_TYPE connType); |
| 79 | ENUM_MESON_HDR_MODE meson_drm_getHdrStatus(int drmFd, MESON_CONNECTOR_TYPE connType ); |
| 80 | ENUM_MESON_HDCP_VERSION meson_drm_getHdcpVersion(int drmFd, MESON_CONNECTOR_TYPE connType ); |
| 81 | ENUM_MESON_COLOR_SPACE meson_drm_getColorSpace(int drmFd, MESON_CONNECTOR_TYPE connType ); |
| 82 | int meson_drm_setColorSpace(int drmFd, drmModeAtomicReq *req, |
| 83 | ENUM_MESON_COLOR_SPACE colorSpace, MESON_CONNECTOR_TYPE connType); |
| 84 | |
| 85 | uint32_t meson_drm_getColorDepth(int drmFd, MESON_CONNECTOR_TYPE connType ); |
| 86 | int meson_drm_setColorDepth(int drmFd, drmModeAtomicReq *req, |
| 87 | uint32_t colorDepth, MESON_CONNECTOR_TYPE connType); |
| 88 | |
| 89 | ENUM_MESON_HDR_POLICY meson_drm_getHDRPolicy(int drmFd, MESON_CONNECTOR_TYPE connType ); |
| 90 | int meson_drm_setHDRPolicy(int drmFd, drmModeAtomicReq *req, |
| 91 | ENUM_MESON_HDR_POLICY hdrPolicy, MESON_CONNECTOR_TYPE connType); |
| 92 | |
| 93 | int meson_open_drm(); |
| 94 | void meson_close_drm(int drmFd); |
| 95 | |
| 96 | #if defined(__cplusplus) |
| 97 | } |
| 98 | #endif |
| 99 | |
| 100 | #endif |