diff options
| author | Benjamin Pujol <benjamin.pujol@intel.com> | 2015-04-01 07:32:18 +0200 |
|---|---|---|
| committer | Heather Lee Wilson <hwilson@google.com> | 2015-04-09 12:10:36 -0700 |
| commit | 8b0063f7f46289983bd1bf9ca61662b4a2ddf5b6 (patch) | |
| tree | 2a97a83a92c17f81dc0deaf7dd5ee7b21ad92693 /merrifield/include | |
| parent | b4201ddf6cb717a9df706bd8d290b3d792acd6a9 (diff) | |
| download | android_hardware_intel_img_hwcomposer-8b0063f7f46289983bd1bf9ca61662b4a2ddf5b6.tar.gz android_hardware_intel_img_hwcomposer-8b0063f7f46289983bd1bf9ca61662b4a2ddf5b6.tar.bz2 android_hardware_intel_img_hwcomposer-8b0063f7f46289983bd1bf9ca61662b4a2ddf5b6.zip | |
First hwcomposer code drop for marvin
Issued from Intel internal commit : 58771d
Change-Id: I8437d663e3b9baa0164517c0ece83b77b5864e8f
Signed-off-by: Benjamin Pujol <benjamin.pujol@intel.com>
Signed-off-by: Victor Tasayco Loarte <victorx.tasayco.loarte@intel.com>
Signed-off-by: Guilhem IMBERTON <guilhem.imberton@intel.com>
Diffstat (limited to 'merrifield/include')
24 files changed, 2022 insertions, 0 deletions
diff --git a/merrifield/include/BufferManager.h b/merrifield/include/BufferManager.h new file mode 100644 index 0000000..ccc8eaa --- /dev/null +++ b/merrifield/include/BufferManager.h @@ -0,0 +1,89 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 BUFFERMANAGER_H_ +#define BUFFERMANAGER_H_ + +#include <Dump.h> +#include <DataBuffer.h> +#include <BufferMapper.h> +#include <BufferCache.h> +#include <utils/Mutex.h> + +namespace android { +namespace intel { + +// Gralloc Buffer Manager +class BufferManager { +public: + BufferManager(); + virtual ~BufferManager(); + + bool initCheck() const; + virtual bool initialize(); + virtual void deinitialize(); + + // dump interface + void dump(Dump& d); + + // lockDataBuffer and unlockDataBuffer must be used in serial + // nested calling of them will cause a deadlock + DataBuffer* lockDataBuffer(buffer_handle_t handle); + void unlockDataBuffer(DataBuffer *buffer); + + // get and put interfaces are deprecated + // use lockDataBuffer and unlockDataBuffer instead + DataBuffer* get(buffer_handle_t handle); + void put(DataBuffer *buffer); + + // map/unmap a data buffer into/from display memory + BufferMapper* map(DataBuffer& buffer); + void unmap(BufferMapper *mapper); + + // frame buffer management + //return 0 if allocation fails + virtual buffer_handle_t allocFrameBuffer(int width, int height, int *stride); + virtual void freeFrameBuffer(buffer_handle_t fbHandle); + + buffer_handle_t allocGrallocBuffer(uint32_t width, uint32_t height, uint32_t format, uint32_t usage); + void freeGrallocBuffer(buffer_handle_t handle); + virtual bool blit(buffer_handle_t srcHandle, buffer_handle_t destHandle, + const crop_t& destRect, bool filter, bool async) = 0; +protected: + virtual DataBuffer* createDataBuffer(gralloc_module_t *module, + buffer_handle_t handle) = 0; + virtual BufferMapper* createBufferMapper(gralloc_module_t *module, + DataBuffer& buffer) = 0; + + gralloc_module_t *mGrallocModule; +private: + enum { + // make the buffer pool large enough + DEFAULT_BUFFER_POOL_SIZE = 128, + }; + + alloc_device_t *mAllocDev; + KeyedVector<buffer_handle_t, BufferMapper*> mFrameBuffers; + BufferCache *mBufferPool; + DataBuffer *mDataBuffer; + Mutex mDataBufferLock; + Mutex mLock; + bool mInitialized; +}; + +} // namespace intel +} // namespace android + +#endif /* BUFFERMANAGER_H_ */ diff --git a/merrifield/include/BufferMapper.h b/merrifield/include/BufferMapper.h new file mode 100644 index 0000000..7a4ceaf --- /dev/null +++ b/merrifield/include/BufferMapper.h @@ -0,0 +1,68 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 BUFFERMAPPER_H__ +#define BUFFERMAPPER_H__ + +#include <DataBuffer.h> + +namespace android { +namespace intel { + +class BufferMapper : public DataBuffer { +public: + BufferMapper(DataBuffer& buffer) + : DataBuffer(buffer), + mRefCount(0) + { + } + virtual ~BufferMapper() {} +public: + int incRef() + { + mRefCount++; + return mRefCount; + } + int decRef() + { + mRefCount--; + return mRefCount; + } + + int getRef() const + { + return mRefCount; + } + + // map the given buffer into both DC & CPU MMU + virtual bool map() = 0; + // unmap the give buffer from both DC & CPU MMU + virtual bool unmap() = 0; + + // return gtt page offset + virtual uint32_t getGttOffsetInPage(int subIndex) const = 0; + virtual void* getCpuAddress(int subIndex) const = 0; + virtual uint32_t getSize(int subIndex) const = 0; + virtual buffer_handle_t getKHandle(int subIndex) = 0; + virtual buffer_handle_t getFbHandle(int subIndex) = 0; + virtual void putFbHandle() = 0; +private: + int mRefCount; +}; + +} // namespace intel +} // namespace android + +#endif /* BUFFERMAPPER_H__ */ diff --git a/merrifield/include/DataBuffer.h b/merrifield/include/DataBuffer.h new file mode 100644 index 0000000..a4a6d84 --- /dev/null +++ b/merrifield/include/DataBuffer.h @@ -0,0 +1,114 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 DATABUFFER_H__ +#define DATABUFFER_H__ + +#include <hardware/hwcomposer.h> + +namespace android { +namespace intel { + +typedef struct crop { + // align with android, using 'int' here + int x; + int y; + int w; + int h; +} crop_t; + +typedef struct stride { + union { + struct { + uint32_t stride; + } rgb; + struct { + uint32_t yStride; + uint32_t uvStride; + } yuv; + }; +}stride_t; + +class DataBuffer { +public: + enum { + FORMAT_INVALID = 0xffffffff, + }; +public: + DataBuffer(buffer_handle_t handle) + { + initBuffer(handle); + } + virtual ~DataBuffer() {} + +public: + virtual void resetBuffer(buffer_handle_t handle) { + // nothing to reset, just do initialization + initBuffer(handle); + } + + buffer_handle_t getHandle() const { return mHandle; } + + void setStride(stride_t& stride) { mStride = stride; } + stride_t& getStride() { return mStride; } + + void setWidth(uint32_t width) { mWidth = width; } + uint32_t getWidth() const { return mWidth; } + + void setHeight(uint32_t height) { mHeight = height; } + uint32_t getHeight() const { return mHeight; } + + void setCrop(int x, int y, int w, int h) { + mCrop.x = x; mCrop.y = y; mCrop.w = w; mCrop.h = h; } + crop_t& getCrop() { return mCrop; } + + void setFormat(uint32_t format) { mFormat = format; } + uint32_t getFormat() const { return mFormat; } + + uint64_t getKey() const { return mKey; } + + void setIsCompression(bool isCompressed) { mIsCompression = isCompressed; } + bool isCompression() { return mIsCompression; } + +private: + void initBuffer(buffer_handle_t handle) { + mHandle = handle; + mFormat = 0; + mWidth = 0; + mHeight = 0; + mKey = (uint64_t)handle; + memset(&mStride, 0, sizeof(stride_t)); + memset(&mCrop, 0, sizeof(crop_t)); + } +protected: + buffer_handle_t mHandle; + stride_t mStride; + crop_t mCrop; + uint32_t mFormat; + uint32_t mWidth; + uint32_t mHeight; + uint64_t mKey; + bool mIsCompression; +}; + +static inline uint32_t align_to(uint32_t arg, uint32_t align) +{ + return ((arg + (align - 1)) & (~(align - 1))); +} + +} // namespace intel +} // namespace android + +#endif /* DATABUFFER_H__ */ diff --git a/merrifield/include/DisplayPlane.h b/merrifield/include/DisplayPlane.h new file mode 100644 index 0000000..250d485 --- /dev/null +++ b/merrifield/include/DisplayPlane.h @@ -0,0 +1,154 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 DISPLAYPLANE_H_ +#define DISPLAYPLANE_H_ + +#include <utils/KeyedVector.h> +#include <BufferMapper.h> +#include <Drm.h> + +namespace android { +namespace intel { + +typedef struct { + // align with android, using 'int' here + int x; + int y; + int w; + int h; +} PlanePosition; + +enum { + // support up to 4 overlays + MAX_OVERLAY_COUNT = 4, + MAX_SPRITE_COUNT = 4, +}; + +enum { + // in version 1.3, HWC_FRAMEBUFFER_TARGET is defined as 3 + HWC_FORCE_FRAMEBUFFER = 255, +}; + +class ZOrderConfig; + +class DisplayPlane { +public: + // plane type + enum { + PLANE_SPRITE = 0, + PLANE_OVERLAY, + PLANE_PRIMARY, + PLANE_CURSOR, + PLANE_MAX, + }; + + enum { + // one more than android's back buffer count to allow more space + // to do map/unmap, as plane reallocation may unmap on-screen layer. + // each plane will cache the latest MIN_DATA_BUFFER_COUNT buffers + // in case that these buffers are still in-using by display device + // other buffers will be released on cache invalidation + MIN_DATA_BUFFER_COUNT = 4, + }; + +protected: + enum { + PLANE_POSITION_CHANGED = 0x00000001UL, + PLANE_BUFFER_CHANGED = 0x00000002UL, + PLANE_SOURCE_CROP_CHANGED = 0x00000004UL, + PLANE_TRANSFORM_CHANGED = 0x00000008UL, + }; +public: + DisplayPlane(int index, int type, int disp); + virtual ~DisplayPlane(); +public: + virtual int getIndex() const { return mIndex; } + virtual int getType() const { return mType; } + virtual bool initCheck() const { return mInitialized; } + + // data destination + virtual void setPosition(int x, int y, int w, int h); + virtual void setSourceCrop(int x, int y, int w, int h); + virtual void setTransform(int transform); + virtual void setPlaneAlpha(uint8_t alpha, uint32_t blending); + + // data source + virtual bool setDataBuffer(buffer_handle_t handle); + + virtual void invalidateBufferCache(); + + // display device + virtual bool assignToDevice(int disp); + + // hardware operations + virtual bool flip(void *ctx); + virtual void postFlip(); + + virtual bool reset(); + virtual bool enable() = 0; + virtual bool disable() = 0; + virtual bool isDisabled() = 0; + + // set z order config + virtual void setZOrderConfig(ZOrderConfig& config, + void *nativeConfig) = 0; + + virtual void setZOrder(int zorder); + virtual int getZOrder() const; + + virtual void* getContext() const = 0; + + virtual bool initialize(uint32_t bufferCount); + virtual void deinitialize(); + +protected: + virtual void checkPosition(int& x, int& y, int& w, int& h); + virtual bool setDataBuffer(BufferMapper& mapper) = 0; +private: + inline BufferMapper* mapBuffer(DataBuffer *buffer); + + inline int findActiveBuffer(BufferMapper *mapper); + void updateActiveBuffers(BufferMapper *mapper); + void invalidateActiveBuffers(); +protected: + int mIndex; + int mType; + int mZOrder; + int mDevice; + bool mInitialized; + + // cached data buffers + KeyedVector<uint64_t, BufferMapper*> mDataBuffers; + // holding the most recent buffers + Vector<BufferMapper*> mActiveBuffers; + int mCacheCapacity; + + PlanePosition mPosition; + crop_t mSrcCrop; + bool mIsProtectedBuffer; + int mTransform; + uint8_t mPlaneAlpha; + uint32_t mBlending; + buffer_handle_t mCurrentDataBuffer; + uint32_t mUpdateMasks; + drmModeModeInfo mModeInfo; + int mPanelOrientation; +}; + +} // namespace intel +} // namespace android + +#endif /* DISPLAYPLANE_H_ */ diff --git a/merrifield/include/DisplayPlaneManager.h b/merrifield/include/DisplayPlaneManager.h new file mode 100644 index 0000000..1c55d9f --- /dev/null +++ b/merrifield/include/DisplayPlaneManager.h @@ -0,0 +1,112 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 DISPLAYPLANEMANAGER_H_ +#define DISPLAYPLANEMANAGER_H_ + +#include <Dump.h> +#include <DisplayPlane.h> +#include <HwcLayer.h> +#include <utils/Vector.h> + +namespace android { +namespace intel { + +struct ZOrderLayer +{ + ZOrderLayer() { + memset(this, 0, sizeof(ZOrderLayer)); + } + + inline bool operator<(const ZOrderLayer& rhs) const { + return zorder < rhs.zorder; + } + + int planeType; + int zorder; + DisplayPlane *plane; + HwcLayer *hwcLayer; +}; + +class ZOrderConfig : public SortedVector<ZOrderLayer*> { +public: + ZOrderConfig() {} + + int do_compare(const void* lhs, const void* rhs) const { + const ZOrderLayer *l = *(ZOrderLayer**)lhs; + const ZOrderLayer *r = *(ZOrderLayer**)rhs; + + // sorted from z order 0 to n + return l->zorder - r->zorder; + } +}; + + +class DisplayPlaneManager { +public: + DisplayPlaneManager(); + virtual ~DisplayPlaneManager(); + +public: + virtual bool initialize(); + virtual void deinitialize(); + + virtual bool isValidZOrder(int dsp, ZOrderConfig& config) = 0; + virtual bool assignPlanes(int dsp, ZOrderConfig& config) = 0; + // TODO: remove this API + virtual void* getZOrderConfig() const = 0; + virtual int getFreePlanes(int dsp, int type); + virtual void reclaimPlane(int dsp, DisplayPlane& plane); + virtual void disableReclaimedPlanes(); + virtual bool isOverlayPlanesDisabled(); + // dump interface + virtual void dump(Dump& d); + +protected: + // plane allocation & free + int getPlane(uint32_t& mask); + int getPlane(uint32_t& mask, int index); + DisplayPlane* getPlane(int type, int index); + DisplayPlane* getAnyPlane(int type); + void putPlane(int index, uint32_t& mask); + void putPlane(int dsp, DisplayPlane& plane); + bool isFreePlane(int type, int index); + virtual DisplayPlane* allocPlane(int index, int type) = 0; + +protected: + int mPlaneCount[DisplayPlane::PLANE_MAX]; + int mTotalPlaneCount; + int mPrimaryPlaneCount; + int mSpritePlaneCount; + int mOverlayPlaneCount; + int mCursorPlaneCount; + + Vector<DisplayPlane*> mPlanes[DisplayPlane::PLANE_MAX]; + + // Bitmap of free planes. Bit0 - plane A, bit 1 - plane B, etc. + uint32_t mFreePlanes[DisplayPlane::PLANE_MAX]; + uint32_t mReclaimedPlanes[DisplayPlane::PLANE_MAX]; + + bool mInitialized; + +enum { + DEFAULT_PRIMARY_PLANE_COUNT = 3 +}; +}; + +} // namespace intel +} // namespace android + +#endif /* DISPLAYPLANEMANAGER_H_ */ diff --git a/merrifield/include/DisplayQuery.h b/merrifield/include/DisplayQuery.h new file mode 100644 index 0000000..185a25d --- /dev/null +++ b/merrifield/include/DisplayQuery.h @@ -0,0 +1,33 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 DISPLAY_QUERY_H +#define DISPLAY_QUERY_H + +namespace android { +namespace intel { + +class DisplayQuery +{ +public: + static bool isVideoFormat(uint32_t format); + static int getOverlayLumaStrideAlignment(uint32_t format); + static uint32_t queryNV12Format(); +}; + +} // namespace intel +} // namespace android + +#endif /*DISPLAY_QUERY_H*/ diff --git a/merrifield/include/DrmConfig.h b/merrifield/include/DrmConfig.h new file mode 100644 index 0000000..23ab889 --- /dev/null +++ b/merrifield/include/DrmConfig.h @@ -0,0 +1,44 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 DRM_CONFIG_H +#define DRM_CONFIG_H + +namespace android { +namespace intel { + +#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \ + ((__u32)(c) << 16) | ((__u32)(d) << 24)) +#define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */ + +class DrmConfig +{ +public: + static const char* getDrmPath(); + static uint32_t getDrmConnector(int device); + static uint32_t getDrmEncoder(int device); + static uint32_t getFrameBufferFormat(); + static uint32_t getFrameBufferDepth(); + static uint32_t getFrameBufferBpp(); + static const char* getUeventEnvelope(); + static const char* getHotplugString(); + static const char* getRepeatedFrameString(); + static uint32_t convertHalFormatToDrmFormat(uint32_t halFormat); +}; + +} // namespace intel +} // namespace android + +#endif /*DRM_CONFIG_H*/ diff --git a/merrifield/include/ExternalDevice.h b/merrifield/include/ExternalDevice.h new file mode 100644 index 0000000..ba22167 --- /dev/null +++ b/merrifield/include/ExternalDevice.h @@ -0,0 +1,65 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 EXTERNAL_DEVICE_H +#define EXTERNAL_DEVICE_H + +#include <PhysicalDevice.h> +#include <IHdcpControl.h> +#include <SimpleThread.h> + +namespace android { +namespace intel { + + +class ExternalDevice : public PhysicalDevice { + +public: + ExternalDevice(Hwcomposer& hwc, DeviceControlFactory* controlFactory); + virtual ~ExternalDevice(); +public: + virtual bool initialize(); + virtual void deinitialize(); + virtual bool setDrmMode(drmModeModeInfo& value); + virtual void setRefreshRate(int hz); + virtual int getActiveConfig(); + virtual bool setActiveConfig(int index); + int getRefreshRate(); + +private: + static void HdcpLinkStatusListener(bool success, void *userData); + void HdcpLinkStatusListener(bool success); + void setDrmMode(); +protected: + IHdcpControl *mHdcpControl; + +private: + static void hotplugEventListener(void *data); + void hotplugListener(); + +private: + Condition mAbortModeSettingCond; + drmModeModeInfo mPendingDrmMode; + bool mHotplugEventPending; + int mExpectedRefreshRate; + +private: + DECLARE_THREAD(ModeSettingThread, ExternalDevice); +}; + +} +} + +#endif /* EXTERNAL_DEVICE_H */ diff --git a/merrifield/include/GraphicBuffer.h b/merrifield/include/GraphicBuffer.h new file mode 100644 index 0000000..65320d8 --- /dev/null +++ b/merrifield/include/GraphicBuffer.h @@ -0,0 +1,57 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 GRAPHIC_BUFFER_H +#define GRAPHIC_BUFFER_H + +#include <DataBuffer.h> + + +namespace android { +namespace intel { + +class GraphicBuffer : public DataBuffer { +public: + enum { + USAGE_INVALID = 0xffffffff, + }; + +public: + GraphicBuffer(buffer_handle_t handle); + virtual ~GraphicBuffer() {} + + virtual void resetBuffer(buffer_handle_t handle); + + uint32_t getUsage() const { return mUsage; } + uint32_t getBpp() const { return mBpp; } + + static bool isProtectedUsage(uint32_t usage); + static bool isProtectedBuffer(GraphicBuffer *buffer); + + static bool isCompressionUsage(uint32_t usage); + static bool isCompressionBuffer(GraphicBuffer *buffer); + +private: + void initBuffer(buffer_handle_t handle); + +protected: + uint32_t mUsage; + uint32_t mBpp; +}; + +} // namespace intel +} // namespace android + +#endif /* GRAPHIC_BUFFER_H */ diff --git a/merrifield/include/Hwcomposer.h b/merrifield/include/Hwcomposer.h new file mode 100644 index 0000000..17e5365 --- /dev/null +++ b/merrifield/include/Hwcomposer.h @@ -0,0 +1,136 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 HWCOMPOSER_H +#define HWCOMPOSER_H + +#include <EGL/egl.h> +#include <hardware/hwcomposer.h> +#include <utils/Vector.h> + +#include <IDisplayDevice.h> +#include <BufferManager.h> +#include <IDisplayContext.h> +#include <Drm.h> +#include <DisplayPlaneManager.h> +#include <DisplayAnalyzer.h> +#include <VsyncManager.h> +#include <MultiDisplayObserver.h> +#include <UeventObserver.h> +#include <IPlatFactory.h> + + +namespace android { +namespace intel { + +class Hwcomposer : public hwc_composer_device_1_t { +public: + virtual ~Hwcomposer(); +public: + // callbacks implementation + virtual bool prepare(size_t numDisplays, + hwc_display_contents_1_t** displays); + virtual bool commit(size_t numDisplays, + hwc_display_contents_1_t** displays); + virtual bool vsyncControl(int disp, int enabled); + virtual bool release(); + virtual bool dump(char *buff, int buff_len, int *cur_len); + virtual void registerProcs(hwc_procs_t const *procs); + + virtual bool blank(int disp, int blank); + virtual bool getDisplayConfigs(int disp, + uint32_t *configs, + size_t *numConfigs); + virtual bool getDisplayAttributes(int disp, + uint32_t config, + const uint32_t *attributes, + int32_t *values); + virtual bool compositionComplete(int disp); + + virtual bool setPowerMode(int disp, int mode); + virtual int getActiveConfig(int disp); + virtual bool setActiveConfig(int disp, int index); + virtual bool setCursorPositionAsync(int disp, int x, int y); + + // callbacks + virtual void vsync(int disp, int64_t timestamp); + virtual void hotplug(int disp, bool connected); + virtual void invalidate(); + + virtual bool initCheck() const; + virtual bool initialize(); + virtual void deinitialize(); + + +public: + Drm* getDrm(); + DisplayPlaneManager* getPlaneManager(); + BufferManager* getBufferManager(); + IDisplayContext* getDisplayContext(); + DisplayAnalyzer* getDisplayAnalyzer(); + VsyncManager* getVsyncManager(); + MultiDisplayObserver* getMultiDisplayObserver(); + IDisplayDevice* getDisplayDevice(int disp); + UeventObserver* getUeventObserver(); + IPlatFactory* getPlatFactory() {return mPlatFactory;} +protected: + Hwcomposer(IPlatFactory *factory); + +public: + static Hwcomposer& getInstance() { + Hwcomposer *instance = sInstance; + if (instance == 0) { + instance = createHwcomposer(); + sInstance = instance; + } + return *sInstance; + } + static void releaseInstance() { + delete sInstance; + sInstance = NULL; + } + // Need to be implemented + static Hwcomposer* createHwcomposer(); + + +private: + hwc_procs_t const *mProcs; + Drm *mDrm; + + // plugin through set + IPlatFactory *mPlatFactory; + VsyncManager *mVsyncManager; + DisplayAnalyzer *mDisplayAnalyzer; + MultiDisplayObserver *mMultiDisplayObserver; + UeventObserver *mUeventObserver; + + // created from IPlatFactory + DisplayPlaneManager *mPlaneManager; + BufferManager *mBufferManager; + IDisplayContext *mDisplayContext; + + Vector<IDisplayDevice*> mDisplayDevices; + + bool mInitialized; + + + + static Hwcomposer *sInstance; +}; + +} // namespace intel +} + +#endif /*HW_COMPOSER_H*/ diff --git a/merrifield/include/IBlankControl.h b/merrifield/include/IBlankControl.h new file mode 100644 index 0000000..7051ce1 --- /dev/null +++ b/merrifield/include/IBlankControl.h @@ -0,0 +1,33 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 IBLANKCONTROL_H_ +#define IBLANKCONTROL_H_ + +namespace android { +namespace intel { + +class IBlankControl { +public: + IBlankControl() {} + virtual ~IBlankControl() {} +public: + virtual bool blank(int disp, bool blank) = 0; +}; + +} // namespace intel +} // namespace android + +#endif /* IBLANKCONTROL_H_ */ diff --git a/merrifield/include/IDisplayContext.h b/merrifield/include/IDisplayContext.h new file mode 100644 index 0000000..7767856 --- /dev/null +++ b/merrifield/include/IDisplayContext.h @@ -0,0 +1,43 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 IDISPLAY_CONTEXT_H +#define IDISPLAY_CONTEXT_H + +#include <hardware/hwcomposer.h> + +namespace android { +namespace intel { + +class HwcLayerList; + +class IDisplayContext { +public: + IDisplayContext() {} + virtual ~IDisplayContext() {} +public: + virtual bool initialize() = 0; + virtual void deinitialize() = 0; + virtual bool commitBegin(size_t numDisplays, hwc_display_contents_1_t **displays) = 0; + virtual bool commitContents(hwc_display_contents_1_t *display, HwcLayerList *layerList) = 0; + virtual bool commitEnd(size_t numDisplays, hwc_display_contents_1_t **displays) = 0; + virtual bool compositionComplete() = 0; + virtual bool setCursorPosition(int disp, int x, int y) = 0; +}; + +} +} + +#endif /* IDISPLAY_CONTEXT_H */ diff --git a/merrifield/include/IDisplayDevice.h b/merrifield/include/IDisplayDevice.h new file mode 100644 index 0000000..d9a6ac2 --- /dev/null +++ b/merrifield/include/IDisplayDevice.h @@ -0,0 +1,107 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 IDISPLAY_DEVICE_H +#define IDISPLAY_DEVICE_H + +#include <Dump.h> +#include <IDisplayContext.h> +#include <DisplayPlane.h> + +namespace android { +namespace intel { + +// display config +class DisplayConfig { +public: + DisplayConfig(int rr, int w, int h, int dpix, int dpiy) + : mRefreshRate(rr), + mWidth(w), + mHeight(h), + mDpiX(dpix), + mDpiY(dpiy) + {} +public: + int getRefreshRate() const { return mRefreshRate; } + int getWidth() const { return mWidth; } + int getHeight() const { return mHeight; } + int getDpiX() const { return mDpiX; } + int getDpiY() const { return mDpiY; } +private: + int mRefreshRate; + int mWidth; + int mHeight; + int mDpiX; + int mDpiY; +}; + + +// display device interface +class IDisplayDevice { +public: + // display device type + enum { + DEVICE_PRIMARY = HWC_DISPLAY_PRIMARY, + DEVICE_EXTERNAL = HWC_DISPLAY_EXTERNAL, +#ifdef INTEL_WIDI_MERRIFIELD + DEVICE_VIRTUAL = HWC_DISPLAY_VIRTUAL, +#endif + DEVICE_COUNT, + }; + enum { + DEVICE_DISCONNECTED = 0, + DEVICE_CONNECTED, + }; + enum { + DEVICE_DISPLAY_OFF = 0, + DEVICE_DISPLAY_ON, + DEVICE_DISPLAY_STANDBY, + }; +public: + IDisplayDevice() {} + virtual ~IDisplayDevice() {} +public: + virtual bool prePrepare(hwc_display_contents_1_t *display) = 0; + virtual bool prepare(hwc_display_contents_1_t *display) = 0; + virtual bool commit(hwc_display_contents_1_t *display, + IDisplayContext *context) = 0; + + virtual bool vsyncControl(bool enabled) = 0; + virtual bool blank(bool blank) = 0; + virtual bool getDisplaySize(int *width, int *height) = 0; + virtual bool getDisplayConfigs(uint32_t *configs, + size_t *numConfigs) = 0; + virtual bool getDisplayAttributes(uint32_t config, + const uint32_t *attributes, + int32_t *values) = 0; + virtual bool compositionComplete() = 0; + + virtual bool setPowerMode(int mode) = 0; + virtual int getActiveConfig() = 0; + virtual bool setActiveConfig(int index) = 0; + + virtual bool initialize() = 0; + virtual void deinitialize() = 0; + virtual bool isConnected() const = 0; + virtual const char* getName() const = 0; + virtual int getType() const = 0; + virtual void onVsync(int64_t timestamp) = 0; + virtual void dump(Dump& d) = 0; +}; + +} +} + +#endif /* IDISPLAY_DEVICE_H */ diff --git a/merrifield/include/IHdcpControl.h b/merrifield/include/IHdcpControl.h new file mode 100644 index 0000000..31a3bfd --- /dev/null +++ b/merrifield/include/IHdcpControl.h @@ -0,0 +1,38 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 IHDCP_CONTROL_H +#define IHDCP_CONTROL_H + +namespace android { +namespace intel { + +typedef void (*HdcpStatusCallback)(bool success, void *userData); + +class IHdcpControl { +public: + IHdcpControl() {} + virtual ~IHdcpControl() {} +public: + virtual bool startHdcp() = 0; + virtual bool startHdcpAsync(HdcpStatusCallback cb, void *userData) = 0; + virtual bool stopHdcp() = 0; +}; + +} // namespace intel +} // namespace android + + +#endif /* IHDCP_CONTROL_H */ diff --git a/merrifield/include/IPlatFactory.h b/merrifield/include/IPlatFactory.h new file mode 100644 index 0000000..71f3fe7 --- /dev/null +++ b/merrifield/include/IPlatFactory.h @@ -0,0 +1,45 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 IPLATFORM_FACTORY_H_ +#define IPLATFORM_FACTORY_H_ + + +#include <IDisplayDevice.h> +#include <BufferManager.h> +#include <IDisplayContext.h> +#include <DisplayPlaneManager.h> +#include <IVideoPayloadManager.h> + + +namespace android { +namespace intel { + + +class IPlatFactory { + +public: + virtual ~IPlatFactory() {}; +public: + virtual DisplayPlaneManager* createDisplayPlaneManager() = 0; + virtual BufferManager* createBufferManager() = 0; + virtual IDisplayDevice* createDisplayDevice(int disp) = 0; + virtual IDisplayContext* createDisplayContext() = 0; + virtual IVideoPayloadManager* createVideoPayloadManager() = 0; +}; +} // namespace intel +} // namespace android + +#endif /* DATABUFFER_H__ */ diff --git a/merrifield/include/IPrepareListener.h b/merrifield/include/IPrepareListener.h new file mode 100644 index 0000000..57dbba8 --- /dev/null +++ b/merrifield/include/IPrepareListener.h @@ -0,0 +1,33 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 IPREPARE_LISTENER_H +#define IPREPARE_LISTENER_H + +namespace android { +namespace intel { + +class IPrepareListener { +public: + IPrepareListener() {} + virtual ~IPrepareListener() {} +public: + virtual void onProtectedLayerStart(int disp) = 0; +}; + +} // namespace intel +} // namespace android + +#endif /* IPREPARE_LISTENER_H */ diff --git a/merrifield/include/IVideoPayloadManager.h b/merrifield/include/IVideoPayloadManager.h new file mode 100644 index 0000000..3aa0fc6 --- /dev/null +++ b/merrifield/include/IVideoPayloadManager.h @@ -0,0 +1,62 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 IVIDEO_PAYLOAD_MANAGER_H +#define IVIDEO_PAYLOAD_MANAGER_H + +#include <hardware/hwcomposer.h> + +namespace android { +namespace intel { + +class BufferMapper; + +class IVideoPayloadManager { +public: + IVideoPayloadManager() {} + virtual ~IVideoPayloadManager() {} + +public: + struct Buffer { + buffer_handle_t khandle; + uint16_t width; + uint16_t height; + uint16_t bufWidth; + uint16_t bufHeight; + uint16_t lumaStride; + uint16_t chromaUStride; + uint16_t chromaVStride; + uint16_t offsetX; + uint16_t offsetY; + bool tiled; + }; + struct MetaData { + uint32_t format; + uint32_t transform; + int64_t timestamp; + Buffer normalBuffer; + Buffer scalingBuffer; + Buffer rotationBuffer; + }; + +public: + virtual bool getMetaData(BufferMapper *mapper, MetaData *metadata) = 0; + virtual bool setRenderStatus(BufferMapper *mapper, bool renderStatus) = 0; +}; + +} // namespace intel +} // namespace android + +#endif /* IVIDEO_PAYLOAD_MANAGER_H */ diff --git a/merrifield/include/IVsyncControl.h b/merrifield/include/IVsyncControl.h new file mode 100644 index 0000000..5edc77b --- /dev/null +++ b/merrifield/include/IVsyncControl.h @@ -0,0 +1,37 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 IVSYNCCONTROL_H_ +#define IVSYNCCONTROL_H_ + +namespace android { +namespace intel { + +class IVsyncControl { +public: + IVsyncControl() {}; + virtual ~IVsyncControl() {}; +public: + virtual bool initialize() = 0; + virtual void deinitialize() = 0; + virtual bool control(int disp, bool enabled) = 0; + virtual bool wait(int disp, int64_t& timestamp) = 0; +}; + +} // namespace intel +} // namespace android + + +#endif /* IVSYNCCONTROL_H_ */ diff --git a/merrifield/include/PhysicalDevice.h b/merrifield/include/PhysicalDevice.h new file mode 100644 index 0000000..9bbb90d --- /dev/null +++ b/merrifield/include/PhysicalDevice.h @@ -0,0 +1,125 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 PHYSICAL_DEVICE_H +#define PHYSICAL_DEVICE_H + +#include <DisplayPlane.h> +#include <IVsyncControl.h> +#include <IBlankControl.h> +#include <IPrepareListener.h> +#include <VsyncEventObserver.h> +#include <HwcLayerList.h> +#include <Drm.h> +#include <IDisplayDevice.h> + +namespace android { +namespace intel { + +class IHdcpControl; + +class DeviceControlFactory { +public: + virtual ~DeviceControlFactory(){} +public: + virtual IVsyncControl* createVsyncControl() = 0; + virtual IBlankControl* createBlankControl() = 0; + virtual IHdcpControl* createHdcpControl() = 0; +}; + +class Hwcomposer; + +// Base class for primary and external devices +class PhysicalDevice : public IDisplayDevice { +public: + PhysicalDevice(uint32_t type, Hwcomposer& hwc, DeviceControlFactory* controlFactory); + virtual ~PhysicalDevice(); +public: + virtual bool prePrepare(hwc_display_contents_1_t *display); + virtual bool prepare(hwc_display_contents_1_t *display); + virtual bool commit(hwc_display_contents_1_t *display, IDisplayContext *context); + + virtual bool vsyncControl(bool enabled); + virtual bool blank(bool blank); + virtual bool getDisplaySize(int *width, int *height); + virtual bool getDisplayConfigs(uint32_t *configs, + size_t *numConfigs); + virtual bool getDisplayAttributes(uint32_t config, + const uint32_t *attributes, + int32_t *values); + virtual bool compositionComplete(); + + virtual bool setPowerMode(int mode); + virtual int getActiveConfig(); + virtual bool setActiveConfig(int index); + + // display config operations + virtual void removeDisplayConfigs(); + virtual bool detectDisplayConfigs(); + + // device related operations + virtual bool initCheck() const { return mInitialized; } + virtual bool initialize(); + virtual void deinitialize(); + virtual bool isConnected() const; + virtual const char* getName() const; + virtual int getType() const; + + //events + virtual void onVsync(int64_t timestamp); + + virtual void dump(Dump& d); + +protected: + void onGeometryChanged(hwc_display_contents_1_t *list); + bool updateDisplayConfigs(); + IVsyncControl* createVsyncControl() {return mControlFactory->createVsyncControl();} + friend class VsyncEventObserver; + +protected: + uint32_t mType; + const char *mName; + + Hwcomposer& mHwc; + + // display configs + Vector<DisplayConfig*> mDisplayConfigs; + int mActiveDisplayConfig; + + + IBlankControl *mBlankControl; + VsyncEventObserver *mVsyncObserver; + + DeviceControlFactory *mControlFactory; + + // layer list + HwcLayerList *mLayerList; + bool mConnected; + bool mBlank; + + // lock + Mutex mLock; + + // DPMS on (1) or off (0) + int mDisplayState; + bool mInitialized; +}; + + + +} +} + +#endif /* PHYSICAL_DEVICE_H */ diff --git a/merrifield/include/PlaneCapabilities.h b/merrifield/include/PlaneCapabilities.h new file mode 100644 index 0000000..0962fda --- /dev/null +++ b/merrifield/include/PlaneCapabilities.h @@ -0,0 +1,38 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 PLANE_CAPABILITIES_H +#define PLANE_CAPABILITIES_H + +#include <DataBuffer.h> + +namespace android { +namespace intel { + +class HwcLayer; +class PlaneCapabilities +{ +public: + static bool isFormatSupported(int planeType, HwcLayer *hwcLayer); + static bool isSizeSupported(int planeType, HwcLayer *hwcLayer); + static bool isBlendingSupported(int planeType, HwcLayer *hwcLayer); + static bool isScalingSupported(int planeType, HwcLayer *hwcLayer); + static bool isTransformSupported(int planeType, HwcLayer *hwcLayer); +}; + +} // namespace intel +} // namespace android + +#endif /*PLANE_CAPABILITIES_H*/ diff --git a/merrifield/include/PrimaryDevice.h b/merrifield/include/PrimaryDevice.h new file mode 100644 index 0000000..6354193 --- /dev/null +++ b/merrifield/include/PrimaryDevice.h @@ -0,0 +1,47 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 PRIMARY_DEVICE_H +#define PRIMARY_DEVICE_H + +#include <DisplayPlane.h> +#include <IVsyncControl.h> +#include <IBlankControl.h> +#include <VsyncEventObserver.h> +#include <HwcLayerList.h> +#include <PhysicalDevice.h> + +namespace android { +namespace intel { + + +class PrimaryDevice : public PhysicalDevice { +public: + PrimaryDevice(Hwcomposer& hwc, DeviceControlFactory* controlFactory); + virtual ~PrimaryDevice(); +public: + virtual bool initialize(); + virtual void deinitialize(); + + bool blank(bool blank); +private: + static void repeatedFrameEventListener(void *data); + void repeatedFrameListener(); +}; + +} +} + +#endif /* PRIMARY_DEVICE_H */ diff --git a/merrifield/include/UeventObserver.h b/merrifield/include/UeventObserver.h new file mode 100755 index 0000000..b1ca781 --- /dev/null +++ b/merrifield/include/UeventObserver.h @@ -0,0 +1,64 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 UEVENT_OBSERVER_H +#define UEVENT_OBSERVER_H + +#include <utils/KeyedVector.h> +#include <utils/String8.h> +#include <SimpleThread.h> + +namespace android { +namespace intel { + +typedef void (*UeventListenerFunc)(void *data); + +class UeventObserver +{ +public: + UeventObserver(); + virtual ~UeventObserver(); + +public: + bool initialize(); + void deinitialize(); + void start(); + void registerListener(const char *event, UeventListenerFunc func, void *data); + +private: + DECLARE_THREAD(UeventObserverThread, UeventObserver); + void onUevent(); + +private: + enum { + UEVENT_MSG_LEN = 4096, + }; + + char mUeventMessage[UEVENT_MSG_LEN]; + int mUeventFd; + int mExitRDFd; + int mExitWDFd; + struct UeventListener { + UeventListenerFunc func; + void *data; + }; + KeyedVector<String8, UeventListener*> mListeners; +}; + +} // namespace intel +} // namespace android + +#endif + diff --git a/merrifield/include/VirtualDevice.h b/merrifield/include/VirtualDevice.h new file mode 100755 index 0000000..2af3c6b --- /dev/null +++ b/merrifield/include/VirtualDevice.h @@ -0,0 +1,221 @@ +/* +// Copyright (c) 2014 Intel Corporation +// +// 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 VIRTUAL_DEVICE_H +#define VIRTUAL_DEVICE_H + +#include <IDisplayDevice.h> +#include <SimpleThread.h> +#include <IVideoPayloadManager.h> +#include <utils/Condition.h> +#include <utils/Mutex.h> +#include <utils/Vector.h> + +#include "IFrameServer.h" + +#include <va/va.h> +#include <va/va_vpp.h> + +namespace android { +namespace intel { + +class Hwcomposer; +class DisplayPlaneManager; +class IVideoPayloadManager; +class SoftVsyncObserver; + +class VirtualDevice : public IDisplayDevice, public BnFrameServer { +protected: + class VAMappedHandle; + class VAMappedHandleObject; + struct CachedBuffer : public android::RefBase { + CachedBuffer(BufferManager *mgr, buffer_handle_t handle); + ~CachedBuffer(); + BufferManager *manager; + BufferMapper *mapper; + VAMappedHandle *vaMappedHandle; + buffer_handle_t cachedKhandle; + }; + struct HeldDecoderBuffer : public android::RefBase { + HeldDecoderBuffer(const sp<VirtualDevice>& vd, const android::sp<CachedBuffer>& cachedBuffer); + virtual ~HeldDecoderBuffer(); + android::sp<VirtualDevice> vd; + android::sp<CachedBuffer> cachedBuffer; + }; + struct Configuration { + sp<IFrameTypeChangeListener> typeChangeListener; + sp<IFrameListener> frameListener; + FrameProcessingPolicy policy; + bool frameServerActive; + bool extendedModeEnabled; + bool forceNotifyFrameType; + bool forceNotifyBufferInfo; + }; + class BufferList { + public: + BufferList(VirtualDevice& vd, const char* name, uint32_t limit, uint32_t format, uint32_t usage); + buffer_handle_t get(uint32_t width, uint32_t height, sp<RefBase>* heldBuffer); + void clear(); + private: + struct HeldBuffer; + VirtualDevice& mVd; + const char* mName; + android::List<buffer_handle_t> mAvailableBuffers; + const uint32_t mLimit; + const uint32_t mFormat; + const uint32_t mUsage; + uint32_t mBuffersToCreate; + uint32_t mWidth; + uint32_t mHeight; + }; + struct Task; + struct RenderTask; + struct ComposeTask; + struct EnableVspTask; + struct DisableVspTask; + struct BlitTask; + struct FrameTypeChangedTask; + struct BufferInfoChangedTask; + struct OnFrameReadyTask; + + Mutex mConfigLock; + Configuration mCurrentConfig; + Configuration mNextConfig; + ssize_t mRgbLayer; + ssize_t mYuvLayer; + bool mProtectedMode; + + buffer_handle_t mExtLastKhandle; + int64_t mExtLastTimestamp; + + int64_t mRenderTimestamp; + + Mutex mTaskLock; // for task queue and buffer lists + BufferList mCscBuffers; + BufferList mRgbUpscaleBuffers; + DECLARE_THREAD(WidiBlitThread, VirtualDevice); + Condition mRequestQueued; + Condition mRequestDequeued; + Vector< sp<Task> > mTasks; + + // fence info + int mSyncTimelineFd; + unsigned mNextSyncPoint; + bool mExpectAcquireFences; + + FrameInfo mLastInputFrameInfo; + FrameInfo mLastOutputFrameInfo; + + int32_t mVideoFramerate; + + android::KeyedVector<buffer_handle_t, android::sp<CachedBuffer> > mMappedBufferCache; + android::Mutex mHeldBuffersLock; + android::KeyedVector<buffer_handle_t, android::sp<android::RefBase> > mHeldBuffers; + + // VSP + bool mVspInUse; + bool mVspEnabled; + uint32_t mVspWidth; + uint32_t mVspHeight; + VADisplay va_dpy; + VAConfigID va_config; + VAContextID va_context; + VASurfaceID va_blank_yuv_in; + VASurfaceID va_blank_rgb_in; + android::KeyedVector<buffer_handle_t, android::sp<VAMappedHandleObject> > mVaMapCache; + + bool mVspUpscale; + bool mDebugVspClear; + bool mDebugVspDump; + uint32_t mDebugCounter; + +private: + android::sp<CachedBuffer> getMappedBuffer(buffer_handle_t handle); + + bool sendToWidi(hwc_display_contents_1_t *display); + bool queueCompose(hwc_display_contents_1_t *display); + bool queueColorConvert(hwc_display_contents_1_t *display); + bool handleExtendedMode(hwc_display_contents_1_t *display); + + void queueFrameTypeInfo(const FrameInfo& inputFrameInfo); + void queueBufferInfo(const FrameInfo& outputFrameInfo); + + void colorSwap(buffer_handle_t src, buffer_handle_t dest, uint32_t pixelCount); + void vspPrepare(uint32_t width, uint32_t height); + void vspEnable(uint32_t width, uint32_t height); + void vspDisable(); + void vspCompose(VASurfaceID videoIn, VASurfaceID rgbIn, VASurfaceID videoOut, + const VARectangle* surface_region, const VARectangle* output_region); + + bool getFrameOfSize(uint32_t width, uint32_t height, const IVideoPayloadManager::MetaData& metadata, IVideoPayloadManager::Buffer& info); + void setMaxDecodeResolution(uint32_t width, uint32_t height); + +public: + VirtualDevice(Hwcomposer& hwc); + virtual ~VirtualDevice(); + bool isFrameServerActive() const; + +public: + virtual bool prePrepare(hwc_display_contents_1_t *display); + virtual bool prepare(hwc_display_contents_1_t *display); + virtual bool commit(hwc_display_contents_1_t *display, + IDisplayContext *context); + + virtual bool vsyncControl(bool enabled); + virtual bool blank(bool blank); + virtual bool getDisplaySize(int *width, int *height); + virtual bool getDisplayConfigs(uint32_t *configs, + size_t *numConfigs); + virtual bool getDisplayAttributes(uint32_t config, + const uint32_t *attributes, + int32_t *values); + virtual bool compositionComplete(); + virtual bool initialize(); + virtual void deinitialize(); + virtual bool isConnected() const; + virtual const char* getName() const; + virtual int getType() const; + virtual void onVsync(int64_t timestamp); + virtual void dump(Dump& d); + + // IFrameServer methods + virtual android::status_t start(sp<IFrameTypeChangeListener> frameTypeChangeListener); + virtual android::status_t stop(bool isConnected); + /* TODO: 64-bit - this handle of size 32-bit is a problem for 64-bit */ + virtual android::status_t notifyBufferReturned(int handle); + virtual android::status_t setResolution(const FrameProcessingPolicy& policy, android::sp<IFrameListener> listener); + virtual bool setPowerMode(int mode); + virtual int getActiveConfig(); + virtual bool setActiveConfig(int index); + +protected: + bool mInitialized; + Hwcomposer& mHwc; + IVideoPayloadManager *mPayloadManager; + SoftVsyncObserver *mVsyncObserver; + uint32_t mOrigContentWidth; + uint32_t mOrigContentHeight; + bool mFirstVideoFrame; + bool mLastConnectionStatus; + uint32_t mCachedBufferCapcity; + uint32_t mDecWidth; + uint32_t mDecHeight; + bool mIsForceCloneMode; +}; + +} +} + +#endif /* VIRTUAL_DEVICE_H */ diff --git a/merrifield/include/pvr/hal/hal_public.h b/merrifield/include/pvr/hal/hal_public.h new file mode 100644 index 0000000..9cd6db2 --- /dev/null +++ b/merrifield/include/pvr/hal/hal_public.h @@ -0,0 +1,257 @@ +/* Copyright (c) Imagination Technologies Ltd. + * + * The contents of this file are subject to the MIT license as set out below. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef HAL_PUBLIC_H +#define HAL_PUBLIC_H + +/* Authors of third party hardware composer (HWC) modules will need to include + * this header to access functionality in the gralloc HAL. + */ + +#define PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC + +#include <hardware/gralloc.h> +#include <hardware/hwcomposer.h> + +#define ALIGN(x,a) (((x) + (a) - 1L) & ~((a) - 1L)) +#define HW_ALIGN 32 +#define CAMERA_ALIGN 64 + +/** YV12 specific (to handle different alignment) ****************************/ + +/* We must align YV12 to a multiple of 32bytes as NEON optimizations + * in stagefright require the YV12 planes to be 128bit aligned. + * while display controller requires 64 bytes alignement + */ +#define YV12_ALIGN 128 + +#define HAL_PIXEL_FORMAT_BGRX_8888 0x101 // Keep consistent with android_utils.h +enum { + HAL_PIXEL_FORMAT_NV12 = 0x3231564E, // YCrCb 4:2:0 SP + HAL_PIXEL_FORMAT_NV21 = 0x3132564E, // YCrCb 4:2:0 SP + HAL_PIXEL_FORMAT_I420 = 0x30323449, + HAL_PIXEL_FORMAT_YUY2 = 0x32595559, + HAL_PIXEL_FORMAT_UYVY = 0x59565955, + + // Intel video decode formats + HAL_PIXEL_FORMAT_NV12_VED = 0x7FA00E00, //OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar + HAL_PIXEL_FORMAT_NV12_VEDT = 0x7FA00F00, //OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled + + HAL_PIXEL_FORMAT_YCbCr_422_P = 0x12, // IYUV + HAL_PIXEL_FORMAT_YCbCr_420_P = 0x13, // YUV9 + HAL_PIXEL_FORMAT_YCbCr_420_I = 0x15, + + HAL_PIXEL_FORMAT_INTEL_UYVY = 0x107, + HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x108, + HAL_PIXEL_FORMAT_ZSL = 0x109, +}; + +/* This can be tuned down as appropriate for the SOC. + * + * IMG formats are usually a single sub-alloc. + * Some OEM video formats are two sub-allocs (Y, UV planes). + * Future OEM video formats might be three sub-allocs (Y, U, V planes). + */ +#define MAX_SUB_ALLOCS 3 + + +/* This defines the maximum server sync objects used per allocation. */ + +/* Note: It's unfortunate that we have to change the handle size dependent + * on a build option, but we have no choice because 'fd' fields must all + * be utilized so they are valid to be dup'ed, and we don't need some of + * the extra fds in a native_fence_sync build. + */ +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) +#define MAX_SRV_SYNC_OBJS 2 +#else +#define MAX_SRV_SYNC_OBJS 4 +#endif + +typedef struct +{ + native_handle_t base; + + /* These fields can be sent cross process. They are also valid + * to duplicate within the same process. + * + * A table is stored within psPrivateData on gralloc_module_t (this + * is obviously per-process) which maps stamps to a mapped + * PVRSRV_MEMDESC in that process. Each map entry has a lock + * count associated with it, satisfying the requirements of the + * Android API. This also prevents us from leaking maps/allocations. + * + * This table has entries inserted either by alloc() + * (alloc_device_t) or map() (gralloc_module_t). Entries are removed + * by free() (alloc_device_t) and unmap() (gralloc_module_t). + */ + +#define IMG_NATIVE_HANDLE_NUMFDS (MAX_SRV_SYNC_OBJS + MAX_SUB_ALLOCS) + /* The `syncfd' field is used to export PVRSRV_CLIENT_SYNC_PRIM to + * another process. Its producer/consumer rules should match the + * PVRSRV_MEMDESC handles, except that there is only one sync + * per N memdesc objects. + * + * This should be listed before `fd' because it is not variable + * width. The problem with variable width is that in the case we + * export framebuffer allocations, we may want to patch some of + * the fds to (unused) ints, so we can't leave gaps. + */ + int aiSyncFD[MAX_SRV_SYNC_OBJS]; + + /* The `fd' field is used to "export" a meminfo to another process. + * Therefore, it is allocated by alloc_device_t, and consumed by + * gralloc_module_t. + */ + int fd[MAX_SUB_ALLOCS]; + +#define IMG_NATIVE_HANDLE_NUMINTS ((sizeof(unsigned long long) / sizeof(int)) + 5) + /* A KERNEL unique identifier for any exported kernel meminfo. Each + * exported kernel meminfo will have a unique stamp, but note that in + * userspace, several meminfos across multiple processes could have + * the same stamp. As the native_handle can be dup(2)'d, there could be + * multiple handles with the same stamp but different file descriptors. + */ + unsigned long long ui64Stamp; + + /* This is used for buffer usage validation when locking a buffer, + * and also in WSEGL (for the composition bypass feature). + */ + int usage; + + /* In order to do efficient cache flushes we need the buffer dimensions + * and format. These are available on the ANativeWindowBuffer, + * but the platform doesn't pass them down to the graphics HAL. + * + * These fields are also used in the composition bypass. In this + * capacity, these are the "real" values for the backing allocation. + */ + int iWidth; + int iHeight; + int iFormat; + unsigned int uiBpp; +} +__attribute__((aligned(sizeof(int)),packed)) IMG_native_handle_t; + +typedef struct +{ + int l, t, w, h; +} +IMG_write_lock_rect_t; + +/* Keep this in sync with SGX */ +typedef int (*IMG_buffer_format_compute_params_pfn)( + unsigned int uiPlane, int *piWidth, int *piHeight, int *piStride, + int *piVStride, unsigned long *pulPlaneOffset); + +#define IMG_BFF_YUV (1 << 0) +#define IMG_BFF_UVCbCrORDERING (1 << 1) +#define IMG_BFF_CPU_CLEAR (1 << 2) +#define IMG_BFF_DONT_GPU_CLEAR (1 << 3) +#define IMG_BFF_PARTIAL_ALLOC (1 << 4) +#define IMG_BFF_NEVER_COMPRESS (1 << 5) + +/* Keep this in sync with SGX */ +typedef struct IMG_buffer_format_public_t +{ + /* Buffer formats are returned as a linked list */ + struct IMG_buffer_format_public_t *psNext; + + /* HAL_PIXEL_FORMAT_... enumerant */ + int iHalPixelFormat; + + /* IMG_PIXFMT_... enumerant */ + int iIMGPixelFormat; + + /* Friendly name for format */ + const char *const szName; + + /* Bits (not bytes) per pixel */ + unsigned int uiBpp; + + /* Supported HW usage bits. If this is GRALLOC_USAGE_HW_MASK, all usages + * are supported. Used for HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. + */ + int iSupportedUsage; + + /* Allocation description flags */ + unsigned int uiFlags; + + /* Utility function for adjusting YUV per-plane parameters */ + IMG_buffer_format_compute_params_pfn pfnComputeParams; +} +IMG_buffer_format_public_t; + +typedef struct +{ + /* The original hwc layer */ + hwc_layer_1_t *psLayer; + + /* Custom data for the display engine */ + unsigned long custom; +} +IMG_hwc_layer_t; + +typedef struct IMG_display_device_public_t { + int (*post)(struct IMG_display_device_public_t *dev, IMG_hwc_layer_t *layers, + int num_layers, int *releaseFenceFd); +} IMG_display_device_public_t; + +typedef struct IMG_gralloc_module_public_t +{ + gralloc_module_t base; + IMG_display_device_public_t *psDisplayDevice; + + /* Gets the head of the linked list of all registered formats */ + const IMG_buffer_format_public_t *(*GetBufferFormats)(void); + + /* Functionality before this point should be in sync with SGX. + * After this point will be different. + */ + + /* Custom-blit components in lieu of overlay hardware */ + int (*Blit)(struct IMG_gralloc_module_public_t const *module, + buffer_handle_t src, buffer_handle_t dest, + int w, int h, int x, int y, + int filter, + int transform, + int async); + + int (*Blit3)(struct IMG_gralloc_module_public_t const *module, + unsigned long long ui64SrcStamp, int iSrcWidth, + int iSrcHeight, int iSrcFormat, int eSrcRotation, + buffer_handle_t dest, int eDestRotation); + + /* Walk the above list and return only the specified format */ + const IMG_buffer_format_public_t *(*GetBufferFormat)(int iFormat); +/* intel hwc extension */ + int (*getCpuAddress)(struct IMG_gralloc_module_public_t const *module, + buffer_handle_t handle, + void **virt, uint32_t *size); + int (*putCpuAddress)(struct IMG_gralloc_module_public_t const *module, + buffer_handle_t handle); + IMG_display_device_public_t *(*getDisplayDevice)(struct IMG_gralloc_module_public_t *module); +} +IMG_gralloc_module_public_t; + +#endif /* HAL_PUBLIC_H */ |
