summaryrefslogtreecommitdiff
Diffstat
-rw-r--r--hwc2/common/base/HwcFenceControl.cpp22
-rw-r--r--hwc2/common/base/HwcLayer.cpp61
-rw-r--r--hwc2/common/base/HwcLayer.h7
-rw-r--r--hwc2/common/base/Hwcomposer.cpp3
-rw-r--r--hwc2/common/composers/Composers.cpp16
-rw-r--r--hwc2/common/composers/Composers.h15
-rw-r--r--hwc2/common/composers/GE2DComposer.cpp33
-rw-r--r--hwc2/common/composers/GE2DComposer.h22
-rw-r--r--hwc2/common/devices/PhysicalDevice.cpp598
-rw-r--r--hwc2/common/devices/PrimaryDevice.cpp13
-rw-r--r--hwc2/common/devices/VirtualDevice.cpp14
-rw-r--r--hwc2/common/hdmi/DisplayHdmi.cpp853
-rw-r--r--hwc2/common/hdmi/DisplayHdmi.h202
-rw-r--r--hwc2/common/observers/SoftVsyncObserver.cpp18
-rw-r--r--hwc2/common/observers/SoftVsyncObserver.h3
-rw-r--r--hwc2/common/observers/UeventObserver.cpp2
-rw-r--r--hwc2/common/utils/AmVideo.cpp109
-rw-r--r--hwc2/common/utils/AmVinfo.cpp928
-rw-r--r--hwc2/common/utils/Utils.cpp89
-rw-r--r--hwc2/common/utils/Utils.h30
-rw-r--r--hwc2/include/AmVideo.h45
-rw-r--r--hwc2/include/AmVinfo.h221
-rw-r--r--hwc2/include/HwcFenceControl.h15
-rw-r--r--hwc2/include/IComposer.h16
-rw-r--r--hwc2/include/IComposerFactory.h16
-rw-r--r--hwc2/include/IDisplayDevice.h16
-rw-r--r--hwc2/include/PhysicalDevice.h33
-rw-r--r--hwc2/include/VirtualDevice.h1
-rw-r--r--hwc2/platforms/Android.mk6
-rw-r--r--tvp/LICENSE23
-rw-r--r--tvp/OmxUtil.cpp48
-rw-r--r--tvp/OmxUtil.h13
32 files changed, 2617 insertions, 874 deletions
diff --git a/hwc2/common/hdmi/DisplayHdmi.h b/hwc2/common/hdmi/DisplayHdmi.h
index 785b40b..284570b 100644
--- a/hwc2/common/hdmi/DisplayHdmi.h
+++ b/hwc2/common/hdmi/DisplayHdmi.h
@@ -1,8 +1,26 @@
+/*
+// Copyright (c) 2017 Amlogic
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+*/
+
#ifndef AML_DISPLAY_HDMI_H
#define AML_DISPLAY_HDMI_H
#include <gralloc_priv.h>
#include <utils/String8.h>
+#include <utils/Errors.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/time.h>
@@ -15,47 +33,66 @@
#include <hardware/hardware.h>
#include <hardware/hwcomposer.h>
#include <Hwcomposer.h>
-#include <SoftVsyncObserver.h>
#include <Utils.h>
#include <ISystemControlService.h>
#include <gui/SurfaceComposerClient.h>
+#include <AmVinfo.h>
-#include <vendor/amlogic/hardware/systemcontrol/1.0/ISystemControl.h>
-
-#define HWC_DISPLAY_MODE_LENGTH 32
+#define HDMI_FRAC_RATE_POLICY "/sys/class/amhdmitx/amhdmitx0/frac_rate_policy"
+#if PLATFORM_SDK_VERSION >= 26
+#include <vendor/amlogic/hardware/systemcontrol/1.0/ISystemControl.h>
using ::vendor::amlogic::hardware::systemcontrol::V1_0::ISystemControl;
using ::vendor::amlogic::hardware::systemcontrol::V1_0::Result;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::hardware::Return;
+#endif
namespace android {
namespace amlogic {
+// refresh rates.
+enum {
+ REFRESH_24kHZ = 24,
+ REFRESH_30kHZ = 30,
+ REFRESH_60kHZ = 60,
+ REFRESH_120kHZ = 120,
+ REFRESH_240kHZ = 240
+};
+
// display config
class DisplayConfig {
public:
- DisplayConfig(const char* dm,
- int rr,
- int w = 0,
- int h = 0,
- int dpix = 0,
- int dpiy = 0)
- : mRefreshRate(rr),
+ DisplayConfig(const std::string dm,
+ int rr,
+ int w = 0,
+ int h = 0,
+ int dpix = 0,
+ int dpiy = 0,
+ bool frac = false)
+ : mDisplayMode(dm),
+ mRefreshRate(rr),
mWidth(w),
mHeight(h),
mDpiX(dpix),
- mDpiY(dpiy)
- {
- memset(mDisplayMode, 0, HWC_DISPLAY_MODE_LENGTH);
- int length = strlen(dm);
- length = (length <= HWC_DISPLAY_MODE_LENGTH-1)?length:(HWC_DISPLAY_MODE_LENGTH-1);
- memcpy(mDisplayMode, dm, length);
- }
+ mDpiY(dpiy),
+ mFracRate(frac)
+ {}
public:
- char* getDisplayMode() const { return (char*)(&mDisplayMode[0]); };
- int getRefreshRate() const { return mRefreshRate; };
+ std::string getDisplayMode() const { return mDisplayMode; };
+ float getRefreshRate() const {
+ float actualRate = 0.0f;
+
+ if (mRefreshRate) {
+ if (mFracRate) {
+ actualRate = (mRefreshRate * 1000) / (float)1001;
+ } else {
+ actualRate = mRefreshRate;
+ }
+ }
+ return actualRate;
+ };
int getWidth() const { return mWidth; };
int getHeight() const { return mHeight; };
int getDpiX() const { return mDpiX; };
@@ -64,77 +101,112 @@ public:
mDpiX = dpix;
mDpiY = dpiy;
};
+ bool getFracRatePolicy() { return mFracRate; };
private:
- char mDisplayMode[HWC_DISPLAY_MODE_LENGTH];
+ std::string mDisplayMode;
int mRefreshRate;
int mWidth;
int mHeight;
int mDpiX;
int mDpiY;
+ bool mFracRate;
};
class DisplayHdmi {
public:
- DisplayHdmi(hwc2_display_t id);
+ DisplayHdmi();
~DisplayHdmi();
- void initialize();
+ void initialize(framebuffer_info_t& framebufferInfo);
void deinitialize();
- void reset();
- bool updateHotplug(bool connected, framebuffer_info_t * framebufferInfo,
- private_handle_t* framebufferHnd);
- int updateDisplayModeList();
- int updateActiveDisplayMode();
- int setDisplayMode(const char* displaymode);
- int updateDisplayConfigures();
- int updateActiveDisplayConfigure();
-
- int getDisplayConfigs(uint32_t* outNumConfigs, hwc2_config_t* outConfigs);
- int getDisplayAttribute(hwc2_config_t config, int32_t attribute, int32_t* outValue);
- int getActiveConfig(hwc2_config_t* outConfig);
- int setActiveConfig(int id);
- //int setPowerMode(int power) {return 0;};
+ bool updateHotplug(bool connected, framebuffer_info_t& framebufferInfo);
+ status_t setBestDisplayMode();
+
+ status_t getDisplayConfigs(uint32_t* outNumConfigs, hwc2_config_t* outConfigs);
+ status_t getDisplayAttribute(hwc2_config_t config, int32_t attribute, int32_t* outValue);
+ status_t getActiveConfig(hwc2_config_t* outConfig);
+ status_t getRealActiveConfig(hwc2_config_t* outConfig);
+ status_t setActiveConfig(int modeId);
+ // int setPowerMode(int power) {return 0;};
+ int getDisplayWorkMode() const { return mWorkMode; };
inline bool isConnected() {return mConnected;};
- int getActiveRefreshRate() {return mActiveRefreshRate;};
- bool calcMode2Config(const char *dispMode, int* refreshRate, int* width, int* height);
- bool readConfigFile(const char* configPath, std::vector<std::string>* supportDispModes);
- void setSurfaceFlingerActiveMode();
- void initModes();
+ bool chkPresent();
+
+ bool isSecure();
void dump(Dump& d);
+protected:
+ /* hdmi operations:
+ * TODO: need move all these operations to HAL.
+ */
+ auto getSystemControlService();
+ status_t readEdidList(std::vector<std::string> &edidlist);
+ status_t writeHdmiDispMode(std::string &dispmode);
+ status_t readHdmiDispMode(std::string &dispmode);
+ status_t readHdmiPhySize(framebuffer_info_t& fbInfo);
+ status_t readBestHdmiOutputMode(std::string &dispmode);
+
+ void switchRatePolicy(bool fracRatePolicy);
+ void reset();
+
+ // operations on mSupportDispModes
+ status_t clearSupportedConfigs();
+ status_t updateSupportedConfigs();
+ status_t updateDisplayAttributes(framebuffer_info_t& framebufferInfo);
+ status_t addSupportedConfig(std::string& mode);
+
+ // ensure the active mode equals the current displaymode.
+ status_t updateActiveConfig(std::string& activeMode);
+
+ status_t setDisplayMode(std::string& dispmode, bool policy = false);
+ bool isDispModeValid(std::string& dispmode);
+
+ bool readConfigFile(const char* configPath, std::vector<std::string>* supportDispModes);
+
+ status_t calcDefaultMode(framebuffer_info_t& framebufferInfo, std::string& defaultMode);
+ status_t buildSingleConfigList(std::string& defaultMode);
+
+ bool checkVinfo(framebuffer_info_t *fbInfo);
+
private:
- void initBinderService();
- struct SystemControlDeathRecipient : public android::hardware::hidl_death_recipient
- {
+ bool mConnected;
+
+#if PLATFORM_SDK_VERSION >= 26
+ struct SystemControlDeathRecipient : public android::hardware::hidl_death_recipient {
// hidl_death_recipient interface
virtual void serviceDied(uint64_t cookie,
- const ::android::wp<::android::hidl::base::V1_0::IBase>& who) override;
+ const ::android::wp<::android::hidl::base::V1_0::IBase>& who) override{};
};
-
- hwc2_display_t mDisplayId; //0-primary 1-external
- bool mConnected;
- bool mTrebleSystemControlEnable;
- sp<ISystemControlService> mSystemControlService;
- sp<ISystemControl> mTrebleSystemControl;
sp<SystemControlDeathRecipient> mDeathRecipient = nullptr;
- sp<SurfaceComposerClient> mComposerClient;
-
- //display outputmode as 4k20hz, 1080p60hz, panel. etc.
- std::vector<std::string> mAllModes;
- std::vector<std::string> mSupportDispModes;
- char mActiveDisplaymode[HWC_DISPLAY_MODE_LENGTH];
- int mActiveRefreshRate;
-
- std::vector<DisplayConfig*> mDisplayConfigs;
- hwc2_config_t mActiveDisplayConfigItem;
+#endif
- framebuffer_info_t *mFramebufferInfo;
- private_handle_t *mFramebufferHnd;
+ // configures variables.
+ hwc2_config_t mActiveConfigId; // for amlogic, it is vmode_e.
+ std::string mActiveConfigStr;
+ hwc2_config_t mRealActiveConfigId;
+ std::string mRealActiveConfigStr;
+ KeyedVector<int, DisplayConfig*> mSupportDispConfigs;
+
+ // physical size in mm.
+ int mPhyWidth;
+ int mPhyHeight;
+ // framebuffer size.
+ int mFbWidth;
+ int mFbHeight;
+
+ // work modes
+ enum {
+ REAL_ACTIVEMODE = 0,
+ LOGIC_ACTIVEMODE, // return the logic size which is framebuffer size.
+ NONE_ACTIVEMODE // no active mode list, always return a default config.
+ };
+ int mWorkMode;
+ // first boot up flag.
+ bool mFirstBootup;
};
-
} // namespace amlogic
} // namespace android