You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
5.6 KiB
150 lines
5.6 KiB
4 months ago
|
/*
|
||
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2016-2019. All rights reserved.
|
||
|
* Description: On behalf of a display device, hwcomposer is called for composition and sent for display
|
||
|
* Author: Hisilicon
|
||
|
* Created: 2019.12.02
|
||
|
*/
|
||
|
|
||
|
#ifndef HWC_IAPI_ADAPTER_H
|
||
|
#define HWC_IAPI_ADAPTER_H
|
||
|
|
||
|
#include <hardware/hwcomposer2.h>
|
||
|
#include <hardware/hardware.h>
|
||
|
#include <hardware/fb.h>
|
||
|
#include <vector>
|
||
|
|
||
|
#include "HWCCallbacks.h"
|
||
|
#include "HWCCommon.h"
|
||
|
#include "HWCLayer.h"
|
||
|
#include "uapi_disp.h"
|
||
|
|
||
|
namespace android {
|
||
|
using HWCHdmiCallback = void (*)(hwc2_display_t id, HWC2::Connection state);
|
||
|
class HWCIapiAdapter {
|
||
|
public:
|
||
|
static HWCIapiAdapter& GetInstance();
|
||
|
|
||
|
HWCIapiAdapter() {}
|
||
|
|
||
|
virtual ~HWCIapiAdapter() {}
|
||
|
|
||
|
HWCIapiAdapter(const HWCIapiAdapter&) = delete;
|
||
|
|
||
|
HWCIapiAdapter& operator=(const HWCIapiAdapter&) = delete;
|
||
|
|
||
|
// Whether the specified display is connected by HDMI or MPI
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual bool IsDisplayConnected(const int dislpay);
|
||
|
|
||
|
// Get the display image max width and height
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int GetHdmiMaxPara(const int displayId, float &maxWidth, float &maxHeight);
|
||
|
|
||
|
// Register callback for hdmi plug and unplug event
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int RegisterHdmiCallback(const int displayId, HWCHdmiCallback callback);
|
||
|
|
||
|
// Unregister callback for hdmi plug and unplug event
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int UnregisterHdmiCallback(const int displayId);
|
||
|
|
||
|
// Init the vo window
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int InitIapiModules();
|
||
|
|
||
|
// Deinit the vo window
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int DeInitIapiModules();
|
||
|
|
||
|
// Get the status of external display
|
||
|
// Implemented in UAPI_VERSION(1, 0), default return false
|
||
|
virtual int GetExternalDisplayStatus(uapi_disp_state *state);
|
||
|
|
||
|
// whether need to switch display
|
||
|
// Implemented in UAPI_VERSION(1, 0), default return false
|
||
|
virtual bool IsDisplaySwitched();
|
||
|
|
||
|
// Get fb device id following /proc/msp/gfbg[ID] by display id
|
||
|
// Implemented in UAPI_VERSION(1, 0), default return 0
|
||
|
virtual int GetFbDevId(const hwc2_display_t displayId) const;
|
||
|
|
||
|
// Update virtual screen
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual void UpdateVirtualScreen(const uint64_t displayId, const unsigned int width,
|
||
|
const unsigned int height) const;
|
||
|
|
||
|
// Set the vo window position for sideband video
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual void SetVoWindowPosition(const native_handle_t &sideband, const hwc_rect_t &hwcRect, int zorder,
|
||
|
int absZorder) const;
|
||
|
|
||
|
// Disalbe vo window for sideband video
|
||
|
virtual void DisableVoWindow(const native_handle_t &sideband) const;
|
||
|
|
||
|
// Open gfx2d device for gfx2d compose
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int OpenGfx2dAndInitCapability();
|
||
|
|
||
|
// Close gfx2d device
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int CloseGfx2d();
|
||
|
|
||
|
// Allocate necessary memory and memset it to be zero for gfx2d compose
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int PrepareGfx2dBasicArg(const int layerNumber);
|
||
|
|
||
|
// Prepare Source(Layer) info for gfx2d compose
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int PrepareGfx2dLayerArg(const HWCLayer &layer, const unsigned int i, const int fbWidht,
|
||
|
const int fbHeight, const bool isAsync);
|
||
|
|
||
|
// Prepare Dest(FrameBuffer) info for gfx2d compose
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int PrepareGfx2dDestArg(const int framebufferFd, const HWCBuffer &fbBuffer, const bool hwcCompress);
|
||
|
|
||
|
// Process sync or async gfx2d compose, valid release fence will be returned for async compose
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int Gfx2dCompose(int layerReleaseFence[], const int layerNumber, int &fbRealeaseFence,
|
||
|
const bool isAsync);
|
||
|
|
||
|
// free the memory allocated duing the prepare basic arg
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual void PostGfx2dCompose();
|
||
|
|
||
|
// present layer buffer directly
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int FreshDirect(const int framebufferFd, HWCBuffer &layerBuffer) const;
|
||
|
|
||
|
// Prepare framebuffer info and ready to fresh fb
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int FreshFb(const int framebufferFd, HWCBuffer &fbBuffer, const int composeType, const bool hwcCompress,
|
||
|
const bool discardFrame) const;
|
||
|
|
||
|
// Get Hdr info by HDMI iapi api
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int GetHdrInfo(const hwc2_display_t display, HdrCap &info) const;
|
||
|
|
||
|
// Get Vsync time(us) with blocking
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int64_t GetVsyncTime(const int framebufferFd, unsigned int &freshRate) const;
|
||
|
|
||
|
// Init display configs as well as active config
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual int InitDisplayConfigs(const hwc2_display_t display, DisplayConfigs &configs,
|
||
|
const framebuffer_device_t &device, unsigned int &active) const;
|
||
|
|
||
|
// Init display configs as well as active config
|
||
|
// Implemented in UAPI_VERSION(1, 0)
|
||
|
virtual bool IsSupportGfx2dCompose();
|
||
|
virtual bool CheckLayerNum(const size_t layerSize) const;
|
||
|
virtual bool CheckLayerSize(const unsigned int cropWidth, const unsigned int cropHeight,
|
||
|
const unsigned int dispWidth, const unsigned int dispHeight) const;
|
||
|
virtual bool CheckResizeNum(const int layerNum, const int videoLayerNum) const;
|
||
|
|
||
|
// set disp power state
|
||
|
virtual void SetDispPowerState(const int displayId, const HWC2::PowerMode mode) const;
|
||
|
};
|
||
|
} // namespace android
|
||
|
#endif // HWC_IAPI_ADAPTER_H
|
||
|
|