summaryrefslogtreecommitdiff
path: root/hwc2/common/hdmi/DisplayHdmi.h (plain)
blob: 2d2715059e640e764bd8c2a51795279a571f0801
1#ifndef AML_DISPLAY_HDMI_H
2#define AML_DISPLAY_HDMI_H
3
4#include <gralloc_priv.h>
5#include <utils/String8.h>
6#include <sys/ioctl.h>
7#include <sys/mman.h>
8#include <sys/time.h>
9#include <sys/types.h>
10#include <sys/resource.h>
11#include <linux/fb.h>
12#include <string>
13#include <vector>
14
15#include <hardware/hardware.h>
16#include <hardware/hwcomposer.h>
17#include <Hwcomposer.h>
18#include <SoftVsyncObserver.h>
19#include <Utils.h>
20#include <ISystemControlService.h>
21#include <gui/SurfaceComposerClient.h>
22
23#define HWC_DISPLAY_MODE_LENGTH 32
24
25namespace android {
26namespace amlogic {
27
28// display config
29class DisplayConfig {
30public:
31 DisplayConfig(const char* dm,
32 int rr,
33 int w = 0,
34 int h = 0,
35 int dpix = 0,
36 int dpiy = 0)
37 : mRefreshRate(rr),
38 mWidth(w),
39 mHeight(h),
40 mDpiX(dpix),
41 mDpiY(dpiy)
42 {
43 memset(mDisplayMode, 0, HWC_DISPLAY_MODE_LENGTH);
44 int length = strlen(dm);
45 length = (length <= HWC_DISPLAY_MODE_LENGTH-1)?length:(HWC_DISPLAY_MODE_LENGTH-1);
46 memcpy(mDisplayMode, dm, length);
47 }
48public:
49 char* getDisplayMode() const { return (char*)(&mDisplayMode[0]); };
50 int getRefreshRate() const { return mRefreshRate; };
51 int getWidth() const { return mWidth; };
52 int getHeight() const { return mHeight; };
53 int getDpiX() const { return mDpiX; };
54 int getDpiY() const { return mDpiY; };
55 void setDpi(int dpix, int dpiy) {
56 mDpiX = dpix;
57 mDpiY = dpiy;
58 };
59
60private:
61 char mDisplayMode[HWC_DISPLAY_MODE_LENGTH];
62 int mRefreshRate;
63 int mWidth;
64 int mHeight;
65 int mDpiX;
66 int mDpiY;
67};
68
69class DisplayHdmi {
70public:
71 DisplayHdmi(hwc2_display_t id);
72 ~DisplayHdmi();
73
74 void initialize();
75 void deinitialize();
76 void reset();
77 bool updateHotplug(bool connected, framebuffer_info_t * framebufferInfo,
78 private_handle_t* framebufferHnd);
79 int updateDisplayModeList();
80 int updateActiveDisplayMode();
81 int setDisplayMode(const char* displaymode);
82 int updateDisplayConfigures();
83 int updateActiveDisplayConfigure();
84
85 int getDisplayConfigs(uint32_t* outNumConfigs, hwc2_config_t* outConfigs);
86 int getDisplayAttribute(hwc2_config_t config, int32_t attribute, int32_t* outValue);
87 int getActiveConfig(hwc2_config_t* outConfig);
88 int setActiveConfig(int id);
89 //int setPowerMode(int power) {return 0;};
90
91 inline bool isConnected() {return mConnected;};
92 int getActiveRefreshRate() {return mActiveRefreshRate;};
93 bool calcMode2Config(const char *dispMode, int* refreshRate, int* width, int* height);
94 bool readConfigFile(const char* configPath, std::vector<std::string>* supportDispModes);
95 void setSurfaceFlingerActiveMode();
96 void initModes();
97
98 void dump(Dump& d);
99
100private:
101 hwc2_display_t mDisplayId; //0-primary 1-external
102 bool mConnected;
103 sp<ISystemControlService> mSystemControlService;
104 sp<SurfaceComposerClient> mComposerClient;
105
106 //display outputmode as 4k20hz, 1080p60hz, panel. etc.
107 std::vector<std::string> mAllModes;
108 std::vector<std::string> mSupportDispModes;
109 char mActiveDisplaymode[HWC_DISPLAY_MODE_LENGTH];
110 int mActiveRefreshRate;
111
112 std::vector<DisplayConfig*> mDisplayConfigs;
113 hwc2_config_t mActiveDisplayConfigItem;
114
115 framebuffer_info_t *mFramebufferInfo;
116 private_handle_t *mFramebufferHnd;
117};
118
119} // namespace amlogic
120} // namespace android
121
122#endif
123