Home | History | Annotate | Download | only in include
      1 /*
      2 // Copyright(c)2014 IntelCorporation
      3 //
      4 // LicensedundertheApacheLicense,Version2.0(the"License");
      5 // youmaynotusethisfileexceptincompliancewiththeLicense.
      6 // YoumayobtainacopyoftheLicenseat
      7 //
      8 // http://www.apache.org/licenses/LICENSE-2.0
      9 //
     10 // Unlessrequiredbyapplicablelaworagreedtoinwriting,software
     11 // distributedundertheLicenseisdistributedonan"ASIS"BASIS,
     12 // WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
     13 // SeetheLicenseforthespecificlanguagegoverningpermissionsand
     14 // limitationsundertheLicense.
     15 */
     16 #ifndef PHYSICAL_DEVICE_H
     17 #define PHYSICAL_DEVICE_H
     18 
     19 #include <DisplayPlane.h>
     20 #include <IVsyncControl.h>
     21 #include <IBlankControl.h>
     22 #include <common/observers/VsyncEventObserver.h>
     23 #include <common/base/HwcLayerList.h>
     24 #include <common/base/Drm.h>
     25 #include <IDisplayDevice.h>
     26 
     27 namespace android {
     28 namespace intel {
     29 
     30 class Hwcomposer;
     31 
     32 // Base class for primary and external devices
     33 class PhysicalDevice : public IDisplayDevice {
     34 public:
     35     PhysicalDevice(uint32_t disp, uint32_t type, Hwcomposer& hwc, DisplayPlaneManager& dpm);
     36     virtual ~PhysicalDevice();
     37 public:
     38     virtual bool prePrepare(hwc_display_contents_1_t *display);
     39     virtual bool prepare(hwc_display_contents_1_t *display);
     40     virtual bool commit(hwc_display_contents_1_t *display, IDisplayContext *context);
     41 
     42     virtual bool vsyncControl(bool enabled);
     43     virtual bool blank(bool blank);
     44     virtual bool getDisplaySize(int *width, int *height);
     45     virtual bool getDisplayConfigs(uint32_t *configs,
     46                                        size_t *numConfigs);
     47     virtual bool getDisplayAttributes(uint32_t config,
     48                                           const uint32_t *attributes,
     49                                           int32_t *values);
     50     virtual bool compositionComplete();
     51 
     52     virtual bool setPowerMode(int mode);
     53     virtual int  getActiveConfig();
     54     virtual bool setActiveConfig(int index);
     55 
     56     // display config operations
     57     virtual void removeDisplayConfigs();
     58     virtual bool detectDisplayConfigs();
     59 
     60     // device related operations
     61     virtual bool initCheck() const { return mInitialized; }
     62     virtual bool initialize();
     63     virtual void deinitialize();
     64     virtual bool isConnected() const;
     65     virtual const char* getName() const;
     66     virtual int getType() const;
     67 
     68     //events
     69     virtual void onVsync(int64_t timestamp);
     70 
     71     virtual void dump(Dump& d);
     72 
     73 protected:
     74     void onGeometryChanged(hwc_display_contents_1_t *list);
     75     bool updateDisplayConfigs();
     76     virtual IVsyncControl* createVsyncControl() = 0;
     77     virtual IBlankControl* createBlankControl() = 0;
     78     friend class VsyncEventObserver;
     79 
     80 protected:
     81     uint32_t mDisp;
     82     uint32_t mType;
     83     const char *mName;
     84 
     85     Hwcomposer& mHwc;
     86     DisplayPlaneManager& mDisplayPlaneManager;
     87 
     88     // display configs
     89     Vector<DisplayConfig*> mDisplayConfigs;
     90     int mActiveDisplayConfig;
     91 
     92 
     93     IBlankControl *mBlankControl;
     94     VsyncEventObserver *mVsyncObserver;
     95 
     96     // layer list
     97     HwcLayerList *mLayerList;
     98     bool mConnected;
     99     bool mBlank;
    100 
    101     // lock
    102     Mutex mLock;
    103 
    104     // DPMS on (1) or off (0)
    105     int mDisplayState;
    106     bool mInitialized;
    107 };
    108 
    109 }
    110 }
    111 
    112 #endif /* PHYSICAL_DEVICE_H */
    113