diff options
author | Jackie Li <yaodong.li@intel.com> | 2014-01-01 17:02:52 -0800 |
---|---|---|
committer | buildslave <buildslave@buildbot.tl.intel.com> | 2014-01-03 07:12:52 +0000 |
commit | f6d5b36e320f093f08855d64fa3d565eacae3c4b (patch) | |
tree | 143d021d915fdc0ff1c60d1b565cb24c6f4016a1 | |
parent | 177b44e0661a92d06f8f37c51e59af86423f7a95 (diff) | |
download | hwcomposer-f6d5b36e320f093f08855d64fa3d565eacae3c4b.tar.gz |
hwc: updated hwcomposer to support ANN.
BZ: 161970
This is part of a set of patches to enable Moorefield graphics.
Change-Id: Ica32c38871f86bca68c34c7e54e9db2c6b7d4f56
Signed-off-by: Jackie Li <yaodong.li@intel.com>
33 files changed, 4078 insertions, 58 deletions
@@ -20,7 +20,7 @@ ifeq ($(INTEL_HWC_MERRIFIELD),true) include $(LOCAL_PATH)/platforms/merrifield/Android.mk endif - - - +ifeq ($(INTEL_HWC_MOOREFIELD),true) +include $(LOCAL_PATH)/platforms/merrifield_plus/Android.mk +endif diff --git a/common/base/HwcLayerList.cpp b/common/base/HwcLayerList.cpp index 904644f..7f04b92 100644 --- a/common/base/HwcLayerList.cpp +++ b/common/base/HwcLayerList.cpp @@ -111,7 +111,6 @@ bool HwcLayer::attachPlane(DisplayPlane* plane, int device) // z order = layer's index + 1 // reserve z order 0 for frame buffer target layer plane->setZOrder(mIndex + 1); - plane->assignToDevice(device); mPlane = plane; return true; } @@ -226,7 +225,7 @@ uint32_t HwcLayer::getPriority() const return mPriority; } -bool HwcLayer::update(hwc_layer_1_t *layer) +bool HwcLayer::update(hwc_layer_1_t *layer, int dsp) { // update layer mLayer = layer; @@ -243,6 +242,7 @@ bool HwcLayer::update(hwc_layer_1_t *layer) layer->sourceCropf.right - layer->sourceCropf.left, layer->sourceCropf.bottom - layer->sourceCropf.top); mPlane->setTransform(layer->transform); + mPlane->assignToDevice(dsp); bool ret = mPlane->setDataBuffer((uint32_t)layer->handle); if (ret == true) { return true; @@ -531,7 +531,7 @@ void HwcLayerList::deinitialize() if (hwcLayer) { DisplayPlane *plane = hwcLayer->detachPlane(); if (plane) - mDisplayPlaneManager.reclaimPlane(*plane); + mDisplayPlaneManager.reclaimPlane(mDisplayIndex, *plane); } // delete HWC layer delete hwcLayer; @@ -596,7 +596,7 @@ void HwcLayerList::assignPlanes() // assign overlay planes for (size_t idx = 0; idx < mOverlayCandidates.size(); idx++) { // break if no free overlay - if (!mDisplayPlaneManager.hasFreeOverlay()) { + if (!mDisplayPlaneManager.hasFreeOverlay(mDisplayIndex)) { VTRACE("no free overlay available"); break; } @@ -610,7 +610,7 @@ void HwcLayerList::assignPlanes() } if (!hwcLayer->attachPlane(plane, mDisplayIndex)) { WTRACE("failed to attach plane"); - mDisplayPlaneManager.reclaimPlane(*plane); + mDisplayPlaneManager.reclaimPlane(mDisplayIndex, *plane); continue; } @@ -621,27 +621,27 @@ void HwcLayerList::assignPlanes() for (size_t idx = 0; idx < mSpriteCandidates.size(); idx++) { // break if no free sprite - if (!mDisplayPlaneManager.hasFreeSprite()) { + if (!mDisplayPlaneManager.hasFreeSprite(mDisplayIndex)) { VTRACE("no free sprite available"); break; } HwcLayer *hwcLayer = mSpriteCandidates.itemAt(idx); - DisplayPlane *plane = mDisplayPlaneManager.getSpritePlane(); + DisplayPlane *plane = mDisplayPlaneManager.getSpritePlane(mDisplayIndex); if (!plane) { ETRACE("sprite plane is null"); break; } if (!plane->enable()) { ETRACE("sprite plane is not ready"); - mDisplayPlaneManager.putPlane(*plane); + mDisplayPlaneManager.putPlane(mDisplayIndex, *plane); continue; } // attach plane to hwc layer if (!hwcLayer->attachPlane(plane, mDisplayIndex)) { WTRACE("failed to attach plane"); - mDisplayPlaneManager.reclaimPlane(*plane); + mDisplayPlaneManager.reclaimPlane(mDisplayIndex, *plane); continue; } mFBLayers.remove(hwcLayer); @@ -715,7 +715,7 @@ void HwcLayerList::adjustAssignment() if (!next) { VTRACE("reclaimed plane type %d, index %d", plane->getType(), plane->getIndex()); - mDisplayPlaneManager.reclaimPlane(*plane); + mDisplayPlaneManager.reclaimPlane(mDisplayIndex, *plane); return; } @@ -794,7 +794,7 @@ bool HwcLayerList::updateZOrderConfig() // attach primary to frame buffer target if (!usePrimaryAsFramebufferTarget(primaryPlane)) { VTRACE("primary is unused"); - mDisplayPlaneManager.reclaimPlane(*primaryPlane); + mDisplayPlaneManager.reclaimPlane(mDisplayIndex, *primaryPlane); return setupZOrderConfig(); } @@ -837,7 +837,7 @@ bool HwcLayerList::usePrimaryAsSprite(DisplayPlane *primaryPlane) // attach primary to layer if (!layer->attachPlane(primaryPlane, mDisplayIndex)) { WTRACE("failed to attach plane"); - mDisplayPlaneManager.reclaimPlane(*primaryPlane); + mDisplayPlaneManager.reclaimPlane(mDisplayIndex, *primaryPlane); return false; } // set the layer type to overlay @@ -863,7 +863,7 @@ void HwcLayerList::detachPrimary() if (primaryPlane) { framebufferTarget->detachPlane(); // reclaim primary plane - mDisplayPlaneManager.reclaimPlane(*primaryPlane); + mDisplayPlaneManager.reclaimPlane(mDisplayIndex, *primaryPlane); return; } @@ -883,7 +883,7 @@ void HwcLayerList::detachPrimary() // add it to fb layer list mFBLayers.add(hwcLayer); // reclaim primary plane - mDisplayPlaneManager.reclaimPlane(*plane); + mDisplayPlaneManager.reclaimPlane(mDisplayIndex, *plane); break; } } @@ -1041,6 +1041,9 @@ bool HwcLayerList::setupZOrderConfig() zorderConfig.setCapacity(mOverlayLayers.size() + 1); + // setup display device which this zorder config belongs to + zorderConfig.setDisplayDevice(mDisplayIndex); + // add all planes in overlay layer list for (size_t i = 0; i < mOverlayLayers.size(); i++) { layer = mOverlayLayers.itemAt(i); @@ -1120,7 +1123,7 @@ bool HwcLayerList::update(hwc_display_contents_1_t *list) continue; } - ret = hwcLayer->update(&list->hwLayers[i]); + ret = hwcLayer->update(&list->hwLayers[i], mDisplayIndex); if (ret == false) { // layer update failed, fall back to ST and revisit all plane // assignment diff --git a/common/base/HwcLayerList.h b/common/base/HwcLayerList.h index 2c810ed..3ee82cd 100644 --- a/common/base/HwcLayerList.h +++ b/common/base/HwcLayerList.h @@ -88,7 +88,7 @@ public: void setPriority(uint32_t priority); uint32_t getPriority() const; - bool update(hwc_layer_1_t *layer); + bool update(hwc_layer_1_t *layer, int dsp); void postFlip(); bool isUpdated(); diff --git a/common/planes/DisplayPlaneManager.cpp b/common/planes/DisplayPlaneManager.cpp index 3cdc467..7d91d76 100644 --- a/common/planes/DisplayPlaneManager.cpp +++ b/common/planes/DisplayPlaneManager.cpp @@ -190,8 +190,7 @@ DisplayPlane* DisplayPlaneManager::getPlane(int type, int dsp) } // try to get free plane from reclaimed planes - if (type == DisplayPlane::PLANE_PRIMARY || - type == DisplayPlane::PLANE_OVERLAY) + if (type == DisplayPlane::PLANE_PRIMARY) // primary planes are attached to specific displays freePlaneIndex = getPlane(mReclaimedPlanes[type], dsp); else @@ -202,8 +201,7 @@ DisplayPlane* DisplayPlaneManager::getPlane(int type, int dsp) return mPlanes[type].itemAt(freePlaneIndex); // failed to get a free plane from reclaimed planes, try it on free planes - if (type == DisplayPlane::PLANE_PRIMARY || - type == DisplayPlane::PLANE_OVERLAY) + if (type == DisplayPlane::PLANE_PRIMARY) freePlaneIndex = getPlane(mFreePlanes[type], dsp); else freePlaneIndex = getPlane(mFreePlanes[type]); @@ -212,18 +210,11 @@ DisplayPlane* DisplayPlaneManager::getPlane(int type, int dsp) if (freePlaneIndex >= 0) return mPlanes[type].itemAt(freePlaneIndex); - // Check the free overlay again if one pipe needs two overlays - if (type == DisplayPlane::PLANE_OVERLAY) { - freePlaneIndex = getPlane(mFreePlanes[type]); - if (freePlaneIndex >= 0) - return mPlanes[type].itemAt(freePlaneIndex); - } - VTRACE("failed to get a plane, type %d", type); return 0; } -void DisplayPlaneManager::putPlane(DisplayPlane& plane) +void DisplayPlaneManager::putPlane(int dsp, DisplayPlane& plane) { int index; int type; @@ -266,7 +257,7 @@ bool DisplayPlaneManager::hasFreePlanes(int type, int dsp) return freePlanes ? true : false; } -DisplayPlane* DisplayPlaneManager::getSpritePlane() +DisplayPlane* DisplayPlaneManager::getSpritePlane(int dsp) { return getPlane((int)DisplayPlane::PLANE_SPRITE); } @@ -281,12 +272,12 @@ DisplayPlane* DisplayPlaneManager::getPrimaryPlane(int dsp) return getPlane((int)DisplayPlane::PLANE_PRIMARY, dsp); } -bool DisplayPlaneManager::hasFreeSprite() +bool DisplayPlaneManager::hasFreeSprite(int dsp) { return hasFreePlanes((int)DisplayPlane::PLANE_SPRITE); } -bool DisplayPlaneManager::hasFreeOverlay() +bool DisplayPlaneManager::hasFreeOverlay(int dsp) { return hasFreePlanes((int)DisplayPlane::PLANE_OVERLAY); } @@ -296,7 +287,7 @@ bool DisplayPlaneManager::hasFreePrimary(int dsp) return hasFreePlanes((int)DisplayPlane::PLANE_PRIMARY, dsp); } -void DisplayPlaneManager::reclaimPlane(DisplayPlane& plane) +void DisplayPlaneManager::reclaimPlane(int dsp, DisplayPlane& plane) { RETURN_VOID_IF_NOT_INIT(); diff --git a/include/DisplayPlaneManager.h b/include/DisplayPlaneManager.h index 610e2bb..cf4fa61 100644 --- a/include/DisplayPlaneManager.h +++ b/include/DisplayPlaneManager.h @@ -37,6 +37,9 @@ namespace intel { class ZOrderConfig : public SortedVector<DisplayPlane*> { public: + ZOrderConfig() + : mDisplayDevice(0) { } + int do_compare(const void* lhs, const void* rhs) const { const DisplayPlane *l = *(DisplayPlane**)lhs; const DisplayPlane *r = *(DisplayPlane**)rhs; @@ -44,6 +47,11 @@ public: // sorted from z order 0 to n return l->getZOrder() - r->getZOrder(); } + + void setDisplayDevice(int dsp) { mDisplayDevice = dsp; } + int getDisplayDevice() const { return mDisplayDevice; } +private: + int mDisplayDevice; }; class DisplayPlaneManager { @@ -62,34 +70,34 @@ public: virtual void deinitialize(); // plane allocation & free - DisplayPlane* getSpritePlane(); - DisplayPlane* getOverlayPlane(int dsp); - DisplayPlane* getPrimaryPlane(int dsp); - void putPlane(DisplayPlane& plane); + virtual DisplayPlane* getSpritePlane(int dsp); + virtual DisplayPlane* getOverlayPlane(int dsp); + virtual DisplayPlane* getPrimaryPlane(int dsp); + virtual void putPlane(int dsp, DisplayPlane& plane); - bool hasFreeSprite(); - bool hasFreeOverlay(); - bool hasFreePrimary(int dsp); + virtual bool hasFreeSprite(int dsp); + virtual bool hasFreeOverlay(int dsp); + virtual bool hasFreePrimary(int dsp); - void reclaimPlane(DisplayPlane& plane); - void disableReclaimedPlanes(); - void disableOverlayPlanes(); + virtual void reclaimPlane(int dsp, DisplayPlane& plane); + virtual void disableReclaimedPlanes(); + virtual void disableOverlayPlanes(); // z order config - bool setZOrderConfig(ZOrderConfig& zorderConfig); - void* getZOrderConfig() const; + virtual bool setZOrderConfig(ZOrderConfig& zorderConfig); + virtual void* getZOrderConfig() const; // dump interface - void dump(Dump& d); + virtual void dump(Dump& d); -private: +protected: int getPlane(uint32_t& mask); int getPlane(uint32_t& mask, int index); void putPlane(int index, uint32_t& mask); inline DisplayPlane* getPlane(int type, int dsp = 0); inline bool hasFreePlanes(int type, int dsp = 0); -protected: + // sub-classes need implement follow functions virtual bool detect(int& spriteCount, int& overlayCount, @@ -97,7 +105,7 @@ protected: virtual DisplayPlane* allocPlane(int index, int type) = 0; virtual bool isValidZOrderConfig(ZOrderConfig& zorderConfig) = 0; virtual void* getNativeZOrderConfig() = 0; -private: +protected: int mPlaneCount[DisplayPlane::PLANE_MAX]; int mTotalPlaneCount; @@ -108,7 +116,7 @@ private: uint32_t mReclaimedPlanes[DisplayPlane::PLANE_MAX]; void *mNativeZOrderConfig; -protected: + bool mInitialized; }; diff --git a/ips/anniedale/AnnDisplayContext.cpp b/ips/anniedale/AnnDisplayContext.cpp new file mode 100644 index 0000000..4803600 --- /dev/null +++ b/ips/anniedale/AnnDisplayContext.cpp @@ -0,0 +1,212 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#include <HwcTrace.h> +#include <Hwcomposer.h> +#include <DisplayPlane.h> +#include <IDisplayDevice.h> +#include <HwcLayerList.h> +#include <anniedale/AnnDisplayContext.h> + + +namespace android { +namespace intel { + +AnnDisplayContext::AnnDisplayContext() + : mIMGDisplayDevice(0), + mInitialized(false), + mCount(0) +{ + CTRACE(); +} + +AnnDisplayContext::~AnnDisplayContext() +{ + WARN_IF_NOT_DEINIT(); +} + +bool AnnDisplayContext::initialize() +{ + CTRACE(); + + // open frame buffer device + hw_module_t const* module; + int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); + if (err) { + ETRACE("failed to load gralloc module, error = %d", err); + return false; + } + + // init IMG display device + mIMGDisplayDevice = (((IMG_gralloc_module_public_t *)module)->psDisplayDevice); + if (!mIMGDisplayDevice) { + ETRACE("failed to get display device"); + return false; + } + + mCount = 0; + mInitialized = true; + return true; +} + +bool AnnDisplayContext::commitBegin(size_t numDisplays, hwc_display_contents_1_t **displays) +{ + RETURN_FALSE_IF_NOT_INIT(); + mCount = 0; + return true; +} + +bool AnnDisplayContext::commitContents(hwc_display_contents_1_t *display, HwcLayerList *layerList) +{ + bool ret; + + RETURN_FALSE_IF_NOT_INIT(); + + if (!display || !layerList) { + ETRACE("invalid parameters"); + return false; + } + + IMG_hwc_layer_t *imgLayerList = (IMG_hwc_layer_t*)mImgLayers; + + for (size_t i = 0; i < display->numHwLayers; i++) { + if (mCount >= MAXIMUM_LAYER_NUMBER) { + ETRACE("layer count exceeds the limit"); + return false; + } + + // check layer parameters + if (!display->hwLayers[i].handle) { + close(display->hwLayers[i].acquireFenceFd); + continue; + } + + DisplayPlane* plane = layerList->getPlane(i); + if (!plane) { + close(display->hwLayers[i].acquireFenceFd); + continue; + } + + ret = plane->flip(NULL); + if (ret == false) { + VTRACE("failed to flip plane %d", i); + close(display->hwLayers[i].acquireFenceFd); + continue; + } + + IMG_hwc_layer_t *imgLayer = &imgLayerList[mCount++]; + // update IMG layer + imgLayer->psLayer = &display->hwLayers[i]; + imgLayer->custom = (uint32_t)plane->getContext(); + struct intel_dc_plane_ctx *ctx = + (struct intel_dc_plane_ctx *)imgLayer->custom; + + // update z order + memset(&ctx->zorder, 0, sizeof(ctx->zorder)); + + VTRACE("count %d, handle %#x, trans %#x, blending %#x" + " sourceCrop %f,%f - %fx%f, dst %d,%d - %dx%d, custom %#x" + " plane (type = %d, idx = %d), zorder %d", + mCount, + (uint32_t)imgLayer->psLayer->handle, + imgLayer->psLayer->transform, + imgLayer->psLayer->blending, + imgLayer->psLayer->sourceCropf.left, + imgLayer->psLayer->sourceCropf.top, + imgLayer->psLayer->sourceCropf.right - imgLayer->psLayer->sourceCropf.left, + imgLayer->psLayer->sourceCropf.bottom - imgLayer->psLayer->sourceCropf.top, + imgLayer->psLayer->displayFrame.left, + imgLayer->psLayer->displayFrame.top, + imgLayer->psLayer->displayFrame.right - imgLayer->psLayer->displayFrame.left, + imgLayer->psLayer->displayFrame.bottom - imgLayer->psLayer->displayFrame.top, + imgLayer->custom, + plane->getType(), + plane->getIndex(), + plane->getZOrder()); + } + + layerList->postFlip(); + return true; +} + +bool AnnDisplayContext::commitEnd(size_t numDisplays, hwc_display_contents_1_t **displays) +{ + int releaseFenceFd = -1; + + VTRACE("count = %d", mCount); + + // nothing need to be submitted + if (!mCount) + return true; + + if (mIMGDisplayDevice) { + int err = mIMGDisplayDevice->post(mIMGDisplayDevice, + mImgLayers, + mCount, + &releaseFenceFd); + if (err) { + ETRACE("post failed, err = %d", err); + return false; + } + } + + // update release fence + for (size_t i = 0; i < numDisplays; i++) { + if (!displays[i]) { + continue; + } + + for (size_t j = 0; j < displays[i]->numHwLayers; j++) { + displays[i]->hwLayers[j].releaseFenceFd = dup(releaseFenceFd); + VTRACE("handle %#x, acquiredFD %d, releaseFD %d", + (uint32_t)displays[i]->hwLayers[j].handle, + displays[i]->hwLayers[j].acquireFenceFd, + displays[i]->hwLayers[j].releaseFenceFd); + } + } + + // close original release fence fd + close(releaseFenceFd); + return true; +} + +bool AnnDisplayContext::compositionComplete() +{ + return true; +} + +void AnnDisplayContext::deinitialize() +{ + mIMGDisplayDevice = 0; + + mCount = 0; + mInitialized = false; +} + + +} // namespace intel +} // namespace android diff --git a/ips/anniedale/AnnDisplayContext.h b/ips/anniedale/AnnDisplayContext.h new file mode 100644 index 0000000..73caf53 --- /dev/null +++ b/ips/anniedale/AnnDisplayContext.h @@ -0,0 +1,62 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef ANN_DISPLAY_CONTEXT_H +#define ANN_DISPLAY_CONTEXT_H + +#include <IDisplayContext.h> +#include <hal_public.h> + +namespace android { +namespace intel { + +class AnnDisplayContext : public IDisplayContext { +public: + AnnDisplayContext(); + virtual ~AnnDisplayContext(); +public: + bool initialize(); + void deinitialize(); + bool commitBegin(size_t numDisplays, hwc_display_contents_1_t **displays); + bool commitContents(hwc_display_contents_1_t *display, HwcLayerList* layerList); + bool commitEnd(size_t numDisplays, hwc_display_contents_1_t **displays); + bool compositionComplete(); + +private: + enum { + MAXIMUM_LAYER_NUMBER = 20, + }; + IMG_display_device_public_t *mIMGDisplayDevice; + IMG_hwc_layer_t mImgLayers[MAXIMUM_LAYER_NUMBER]; + bool mInitialized; + int mCount; +}; + +} // namespace intel +} // namespace android + +#endif /* ANN_DISPLAY_CONTEXT_H */ diff --git a/ips/anniedale/AnnDisplayPlane.cpp b/ips/anniedale/AnnDisplayPlane.cpp new file mode 100644 index 0000000..92c2e20 --- /dev/null +++ b/ips/anniedale/AnnDisplayPlane.cpp @@ -0,0 +1,176 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#include <HwcTrace.h> +#include <Hwcomposer.h> +#include <BufferManager.h> +#include <anniedale/AnnGrallocBuffer.h> +#include <anniedale/AnnDisplayPlane.h> +#include <common/PixelFormat.h> + +namespace android { +namespace intel { + +#define RETURN_VOID_IF_NO_REAL_PLANE() \ + do { \ + if (!mRealPlane) { \ + VTRACE("No real plane set"); \ + return; \ + } \ + } while(0) + +#define RETURN_FALSE_IF_NO_REAL_PLANE() \ + do { \ + if (!mRealPlane) { \ + VTRACE("No real plane set"); \ + return false; \ + } \ + } while(0) + +AnnDisplayPlane::AnnDisplayPlane(int index, int type, int disp) + : DisplayPlane(index, type, disp), + mRealPlane(0) +{ + +} + +AnnDisplayPlane::~AnnDisplayPlane() +{ + mRealPlane = NULL; +} + +void AnnDisplayPlane::setPosition(int x, int y, int w, int h) +{ + RETURN_VOID_IF_NO_REAL_PLANE(); + + mRealPlane->setPosition(x, y, w, h); +} + +void AnnDisplayPlane::setSourceCrop(int x, int y, int w, int h) +{ + RETURN_VOID_IF_NO_REAL_PLANE(); + + mRealPlane->setSourceCrop(x, y, w, h); +} + +void AnnDisplayPlane::setTransform(int transform) +{ + RETURN_VOID_IF_NO_REAL_PLANE(); + + mRealPlane->setTransform(transform); +} + +bool AnnDisplayPlane::setDataBuffer(uint32_t handle) +{ + RETURN_FALSE_IF_NO_REAL_PLANE(); + + return mRealPlane->setDataBuffer(handle); +} + +void AnnDisplayPlane::invalidateBufferCache() +{ + RETURN_VOID_IF_NO_REAL_PLANE(); + + mRealPlane->invalidateBufferCache(); +} + +bool AnnDisplayPlane::assignToDevice(int disp) +{ + RETURN_FALSE_IF_NO_REAL_PLANE(); + + return mRealPlane->assignToDevice(disp); +} + +bool AnnDisplayPlane::flip(void *ctx) +{ + RETURN_FALSE_IF_NO_REAL_PLANE(); + + return mRealPlane->flip(ctx); +} + +bool AnnDisplayPlane::reset() +{ + RETURN_FALSE_IF_NO_REAL_PLANE(); + + return mRealPlane->reset(); +} + +bool AnnDisplayPlane::enable() +{ + return true; +} + +bool AnnDisplayPlane::disable() +{ + RETURN_FALSE_IF_NO_REAL_PLANE(); + + return mRealPlane->disable(); +} + +void* AnnDisplayPlane::getContext() const +{ + if (!mRealPlane) { + WTRACE("No real plane"); + return NULL; + } + + return mRealPlane->getContext(); +} + +bool AnnDisplayPlane::initialize(uint32_t bufferCount) +{ + return true; +} + +void AnnDisplayPlane::deinitialize() +{ + +} + +void AnnDisplayPlane::setZOrderConfig(ZOrderConfig& config, + void *nativeConfig) +{ + +} + +void AnnDisplayPlane::setRealPlane(DisplayPlane *plane) +{ + mRealPlane = plane; +} + +DisplayPlane* AnnDisplayPlane::getRealPlane() const +{ + return mRealPlane; +} + +bool AnnDisplayPlane::setDataBuffer(BufferMapper& mapper) +{ + return false; +} + +} // namespace intel +} // namespace android diff --git a/ips/anniedale/AnnDisplayPlane.h b/ips/anniedale/AnnDisplayPlane.h new file mode 100644 index 0000000..73cf2ad --- /dev/null +++ b/ips/anniedale/AnnDisplayPlane.h @@ -0,0 +1,82 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef ANN_DISPLAY_PLANE_H +#define ANN_DISPLAY_PLANE_H + +#include <utils/KeyedVector.h> +#include <hal_public.h> +#include <Hwcomposer.h> +#include <BufferCache.h> +#include <DisplayPlane.h> + +namespace android { +namespace intel { + +class AnnDisplayPlane : public DisplayPlane { +public: + AnnDisplayPlane(int index, int type, int disp); + virtual ~AnnDisplayPlane(); +public: + // data destination + void setPosition(int x, int y, int w, int h); + void setSourceCrop(int x, int y, int w, int h); + void setTransform(int transform); + + // data source + bool setDataBuffer(uint32_t handle); + + void invalidateBufferCache(); + + // display device + bool assignToDevice(int disp); + + // hardware operations + bool flip(void *ctx); + + bool reset(); + bool enable(); + bool disable(); + + void* getContext() const; + + bool initialize(uint32_t bufferCount); + void deinitialize(); + void setZOrderConfig(ZOrderConfig& config, void *nativeConfig); + + void setRealPlane(DisplayPlane *plane); + DisplayPlane* getRealPlane() const; +protected: + bool setDataBuffer(BufferMapper& mapper); +private: + DisplayPlane *mRealPlane; +}; + +} // namespace intel +} // namespace android + +#endif /* ANN_DISPLAY_PLANE_H */ diff --git a/ips/anniedale/AnnDisplayQuery.cpp b/ips/anniedale/AnnDisplayQuery.cpp new file mode 100644 index 0000000..01e40bf --- /dev/null +++ b/ips/anniedale/AnnDisplayQuery.cpp @@ -0,0 +1,70 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + */ + +#include <HwcTrace.h> +#include <DisplayPlane.h> +#include <hal_public.h> +#include <OMX_IVCommon.h> +#include <DisplayQuery.h> + + +namespace android { +namespace intel { + +bool DisplayQuery::isVideoFormat(uint32_t format) +{ + switch (format) { + case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar: + case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled: + return true; + default: + return false; + } +} + +int DisplayQuery::getOverlayLumaStrideAlignment(uint32_t format) +{ + // both luma and chroma stride need to be 64-byte aligned for overlay + switch (format) { + case HAL_PIXEL_FORMAT_YV12: + case HAL_PIXEL_FORMAT_I420: + // for these two formats, chroma stride is calculated as half of luma stride + // so luma stride needs to be 128-byte aligned. + return 128; + default: + return 64; + } +} + +uint32_t DisplayQuery::queryNV12Format() +{ + return HAL_PIXEL_FORMAT_NV12; +} + +} // namespace intel +} // namespace android + diff --git a/ips/anniedale/AnnGrallocBuffer.cpp b/ips/anniedale/AnnGrallocBuffer.cpp new file mode 100644 index 0000000..b50ae48 --- /dev/null +++ b/ips/anniedale/AnnGrallocBuffer.cpp @@ -0,0 +1,74 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#include <HwcTrace.h> +#include <anniedale/AnnGrallocBuffer.h> + +namespace android { +namespace intel { + +AnnGrallocBuffer::AnnGrallocBuffer(uint32_t handle) + :GrallocBufferBase(handle) +{ + initBuffer(handle); +} + +AnnGrallocBuffer::~AnnGrallocBuffer() +{ +} + +void AnnGrallocBuffer::resetBuffer(uint32_t handle) +{ + GrallocBufferBase::resetBuffer(handle); + initBuffer(handle); +} + +void AnnGrallocBuffer::initBuffer(uint32_t handle) +{ + AnnIMGGrallocBuffer *grallocHandle = (AnnIMGGrallocBuffer *)handle; + + CTRACE(); + + if (!grallocHandle) { + ETRACE("gralloc handle is null"); + return; + } + + mFormat = grallocHandle->iFormat; + mWidth = grallocHandle->iWidth; + mHeight = grallocHandle->iHeight; + mUsage = grallocHandle->usage; + mKey = grallocHandle->ui64Stamp; + mBpp = grallocHandle->uiBpp; + + // stride can only be initialized after format is set + initStride(); +} + + +} +} diff --git a/ips/anniedale/AnnGrallocBuffer.h b/ips/anniedale/AnnGrallocBuffer.h new file mode 100644 index 0000000..8c61e1a --- /dev/null +++ b/ips/anniedale/AnnGrallocBuffer.h @@ -0,0 +1,56 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef ANN_GRALLOC_BUFFER_H +#define ANN_GRALLOC_BUFFER_H + +#include <DataBuffer.h> +#include <hal_public.h> +#include <common/GrallocSubBuffer.h> +#include <common/GrallocBufferBase.h> + +namespace android { +namespace intel { + +typedef IMG_native_handle_t AnnIMGGrallocBuffer; + +class AnnGrallocBuffer : public GrallocBufferBase { +public: + AnnGrallocBuffer(uint32_t handle); + virtual ~AnnGrallocBuffer(); + + void resetBuffer(uint32_t handle); + +private: + void initBuffer(uint32_t handle); +}; + +} // namespace intel +} // namespace android + + +#endif /* ANN_GRALLOC_BUFFER_H */ diff --git a/ips/anniedale/AnnGrallocBufferMapper.cpp b/ips/anniedale/AnnGrallocBufferMapper.cpp new file mode 100644 index 0000000..3b08c5b --- /dev/null +++ b/ips/anniedale/AnnGrallocBufferMapper.cpp @@ -0,0 +1,257 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#include <HwcTrace.h> +#include <Drm.h> +#include <Hwcomposer.h> +#include <anniedale/AnnGrallocBufferMapper.h> +#include <common/WsbmWrapper.h> + +namespace android { +namespace intel { + +AnnGrallocBufferMapper::AnnGrallocBufferMapper(IMG_gralloc_module_public_t& module, + DataBuffer& buffer) + : GrallocBufferMapperBase(buffer), + mIMGGrallocModule(module), + mBufferObject(0) +{ + CTRACE(); +} + +AnnGrallocBufferMapper::~AnnGrallocBufferMapper() +{ + CTRACE(); +} + +bool AnnGrallocBufferMapper::gttMap(void *vaddr, + uint32_t size, + uint32_t gttAlign, + int *offset) +{ + struct psb_gtt_mapping_arg arg; + bool ret; + + ATRACE("vaddr = %p, size = %d", vaddr, size); + + if (!vaddr || !size || !offset) { + VTRACE("invalid parameters"); + return false; + } + + arg.type = PSB_GTT_MAP_TYPE_VIRTUAL; + arg.page_align = gttAlign; + arg.vaddr = (uint32_t)vaddr; + arg.size = size; + + Drm *drm = Hwcomposer::getInstance().getDrm(); + ret = drm->writeReadIoctl(DRM_PSB_GTT_MAP, &arg, sizeof(arg)); + if (ret == false) { + ETRACE("gtt mapping failed"); + return false; + } + + VTRACE("offset = %#x", arg.offset_pages); + *offset = arg.offset_pages; + return true; +} + +bool AnnGrallocBufferMapper::gttUnmap(void *vaddr) +{ + struct psb_gtt_mapping_arg arg; + bool ret; + + ATRACE("vaddr = %p", vaddr); + + if (!vaddr) { + ETRACE("invalid parameter"); + return false; + } + + arg.type = PSB_GTT_MAP_TYPE_VIRTUAL; + arg.vaddr = (uint32_t)vaddr; + + Drm *drm = Hwcomposer::getInstance().getDrm(); + ret = drm->writeIoctl(DRM_PSB_GTT_UNMAP, &arg, sizeof(arg)); + if (ret == false) { + ETRACE("gtt unmapping failed"); + return false; + } + + return true; +} + +bool AnnGrallocBufferMapper::map() +{ + void *vaddr[SUB_BUFFER_MAX]; + uint32_t size[SUB_BUFFER_MAX]; + int gttOffsetInPage = 0; + bool ret; + int err; + int i; + + CTRACE(); + // get virtual address + err = mIMGGrallocModule.getCpuAddress(&mIMGGrallocModule, + (buffer_handle_t)getHandle(), + vaddr, + size); + if (err) { + ETRACE("failed to map. err = %d", err); + return false; + } + + for (i = 0; i < SUB_BUFFER_MAX; i++) { + // skip gtt mapping for empty sub buffers + if (!vaddr[i] || !size[i]) + continue; + + // map to gtt + ret = gttMap(vaddr[i], size[i], 0, >tOffsetInPage); + if (!ret) { + VTRACE("failed to map %d into gtt", i); + break; + } + + mCpuAddress[i] = vaddr[i]; + mSize[i] = size[i]; + mGttOffsetInPage[i] = gttOffsetInPage; + // TODO: set kernel handle + mKHandle[i] = 0; + } + + if (i == SUB_BUFFER_MAX) { + return true; + } + + // error handling + for (i = 0; i < SUB_BUFFER_MAX; i++) { + if (mCpuAddress[i]) { + gttUnmap(mCpuAddress[i]); + } + } + + err = mIMGGrallocModule.putCpuAddress(&mIMGGrallocModule, + (buffer_handle_t)getHandle()); + return false; +} + +bool AnnGrallocBufferMapper::unmap() +{ + int i; + int err; + + CTRACE(); + + for (i = 0; i < SUB_BUFFER_MAX; i++) { + if (mCpuAddress[i]) + gttUnmap(mCpuAddress[i]); + + mGttOffsetInPage[i] = 0; + mCpuAddress[i] = 0; + mSize[i] = 0; + } + + err = mIMGGrallocModule.putCpuAddress(&mIMGGrallocModule, + (buffer_handle_t)getHandle()); + if (err) { + ETRACE("failed to unmap. err = %d", err); + } + return err; +} + +uint32_t AnnGrallocBufferMapper::getKHandle(int subIndex) +{ + uint32_t ret = GrallocBufferMapperBase::getKHandle(subIndex); + if (subIndex == 0 && ret == 0) { + if (mapKhandle()) + return mKHandle[subIndex]; + } + + return ret; +} + +bool AnnGrallocBufferMapper::mapKhandle() +{ + // TODO: this is a complete hack and temporary workaround + // need support from DDK to map khandle + void *wsbmBufferObject = 0; + int ret = psbWsbmWrapTTMBuffer2(mHandle, &wsbmBufferObject); + if (ret != 0) { + ETRACE("Wrap ttm buffer failed!"); + return false; + } + + ret = psbWsbmCreateFromUB(wsbmBufferObject, mWidth * mHeight, mCpuAddress[0]); + if (ret != 0) { + ETRACE("Creat from UB failed!"); + return false; + } + + mKHandle[0] = psbWsbmGetKBufHandle(wsbmBufferObject); + psbWsbmUnReference(wsbmBufferObject); + return true; +} + +uint32_t AnnGrallocBufferMapper::getFbHandle(int subIndex) +{ + void *vaddr[SUB_BUFFER_MAX]; + uint32_t size[SUB_BUFFER_MAX]; + int err; + + CTRACE(); + + if (subIndex < 0 || subIndex >= SUB_BUFFER_MAX) { + return 0; + } + + // get virtual address + err = mIMGGrallocModule.getCpuAddress(&mIMGGrallocModule, + (buffer_handle_t)getHandle(), + vaddr, + size); + if (err) { + ETRACE("failed to map. err = %d", err); + return 0; + } + + return (uint32_t)vaddr[subIndex]; +} + +void AnnGrallocBufferMapper::putFbHandle() +{ + int err = mIMGGrallocModule.putCpuAddress(&mIMGGrallocModule, + (buffer_handle_t)getHandle()); + if (err) { + ETRACE("failed to unmap. err = %d", err); + } + return; + +} + +} // namespace intel +} // namespace android diff --git a/ips/anniedale/AnnGrallocBufferMapper.h b/ips/anniedale/AnnGrallocBufferMapper.h new file mode 100644 index 0000000..7c0a6dc --- /dev/null +++ b/ips/anniedale/AnnGrallocBufferMapper.h @@ -0,0 +1,63 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef ANN_GRALLOC_BUFFER_MAPPER_H +#define ANN_GRALLOC_BUFFER_MAPPER_H + +#include <BufferMapper.h> +#include <hal_public.h> +#include <common/GrallocBufferMapperBase.h> +#include <anniedale/AnnGrallocBuffer.h> + +namespace android { +namespace intel { + +class AnnGrallocBufferMapper : public GrallocBufferMapperBase { +public: + AnnGrallocBufferMapper(IMG_gralloc_module_public_t& module, + DataBuffer& buffer); + virtual ~AnnGrallocBufferMapper(); +public: + bool map(); + bool unmap(); + uint32_t getKHandle(int subIndex); + uint32_t getFbHandle(int subIndex); + void putFbHandle(); +private: + bool gttMap(void *vaddr, uint32_t size, uint32_t gttAlign, int *offset); + bool gttUnmap(void *vaddr); + bool mapKhandle(); + +private: + IMG_gralloc_module_public_t& mIMGGrallocModule; + void* mBufferObject; +}; + +} // namespace intel +} // namespace android + +#endif /* ANN_GRALLOC_BUFFER_MAPPER_H */ diff --git a/ips/anniedale/AnnOverlayPlane.cpp b/ips/anniedale/AnnOverlayPlane.cpp new file mode 100644 index 0000000..3374e92 --- /dev/null +++ b/ips/anniedale/AnnOverlayPlane.cpp @@ -0,0 +1,1081 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ + +#include <math.h> +#include <HwcTrace.h> +#include <Drm.h> +#include <Hwcomposer.h> +#include <PhysicalDevice.h> +#include <common/TTMBufferMapper.h> +#include <common/GrallocSubBuffer.h> +#include <DisplayQuery.h> +#include <anniedale/AnnOverlayPlane.h> + +// FIXME: remove it +#include <OMX_IVCommon.h> + +namespace android { +namespace intel { + +AnnOverlayPlane::AnnOverlayPlane(int index, int disp) + : DisplayPlane(index, PLANE_OVERLAY, disp), + mCurrent(0), + mWsbm(0), + mPipeConfig(0), + mDisablePending(false), + mDisablePendingDevice(0), + mDisablePendingCount(0), + mRotationConfig(0), + mZOrderConfig(0) +{ + CTRACE(); + for (int i = 0; i < OVERLAY_BACK_BUFFER_COUNT; i++) { + mBackBuffer[i] = 0; + } +} + +AnnOverlayPlane::~AnnOverlayPlane() +{ + CTRACE(); +} + +bool AnnOverlayPlane::initialize(uint32_t bufferCount) +{ + Drm *drm = Hwcomposer::getInstance().getDrm(); + CTRACE(); + + // NOTE: use overlay's data buffer count for the overlay plane + if (bufferCount < OVERLAY_DATA_BUFFER_COUNT) { + ITRACE("override overlay buffer count from %d to %d", + bufferCount, OVERLAY_DATA_BUFFER_COUNT); + bufferCount = OVERLAY_DATA_BUFFER_COUNT; + } + if (!DisplayPlane::initialize(bufferCount)) { + DEINIT_AND_RETURN_FALSE("failed to initialize display plane"); + } + + // init wsbm + mWsbm = new Wsbm(drm->getDrmFd()); + if (!mWsbm || !mWsbm->initialize()) { + DEINIT_AND_RETURN_FALSE("failed to create wsbm"); + } + + // create overlay back buffer + for (int i = 0; i < OVERLAY_BACK_BUFFER_COUNT; i++) { + mBackBuffer[i] = createBackBuffer(); + if (!mBackBuffer[i]) { + DEINIT_AND_RETURN_FALSE("failed to create overlay back buffer"); + } + // reset back buffer + resetBackBuffer(i); + } + + // disable overlay when created + flush(PLANE_DISABLE); + + // overlay by default is in "disabled" status + mDisablePending = false; + mDisablePendingDevice = 0; + mDisablePendingCount = 0; + return true; +} + +void AnnOverlayPlane::deinitialize() +{ + + // delete back buffer + for (int i = 0; i < OVERLAY_BACK_BUFFER_COUNT; i++) { + if (mBackBuffer[i]) { + deleteBackBuffer(i); + } + } + DEINIT_AND_DELETE_OBJ(mWsbm); + + DisplayPlane::deinitialize(); +} + +bool AnnOverlayPlane::setDataBuffer(uint32_t handle) +{ + if (mDisablePending) { + if (isFlushed() || mDisablePendingCount >= OVERLAY_DISABLING_COUNT_MAX) { + mDisablePending = false; + mDisablePendingDevice = 0; + mDisablePendingCount = 0; + enable(); + } else { + mDisablePendingCount++; + WTRACE("overlay %d disabling on device %d is still pending, count: %d", + mIndex, mDisablePendingDevice, mDisablePendingCount); + return false; + } + } + + return DisplayPlane::setDataBuffer(handle); +} + +void AnnOverlayPlane::invalidateBufferCache() +{ + // clear plane buffer cache + DisplayPlane::invalidateBufferCache(); +} + +bool AnnOverlayPlane::assignToDevice(int disp) +{ + uint32_t pipeConfig = 0; + + RETURN_FALSE_IF_NOT_INIT(); + VTRACE("overlay %d assigned to disp %d", mIndex, disp); + + switch (disp) { + case IDisplayDevice::DEVICE_EXTERNAL: + pipeConfig = (0x2 << 6); + break; + case IDisplayDevice::DEVICE_PRIMARY: + default: + pipeConfig = 0; + break; + } + + // if pipe switching happened, then disable overlay first + if (mPipeConfig != pipeConfig) { + DTRACE("overlay %d switched from %d to %d", mIndex, mDevice, disp); + disable(); + } + + mPipeConfig = pipeConfig; + mDevice = disp; + + if (!mDisablePending) { + enable(); + } + + return true; +} + +void AnnOverlayPlane::setZOrderConfig(ZOrderConfig& zorderConfig, + void *nativeConfig) +{ + int slot = (int)nativeConfig; + + CTRACE(); + + switch (slot) { + case 0: + mZOrderConfig = 0; + break; + case 1: + mZOrderConfig = (1 << 8); + break; + case 2: + mZOrderConfig = (2 << 8); + break; + case 3: + mZOrderConfig = (3 << 8); + break; + default: + ETRACE("Invalid overlay plane zorder %d", slot); + return; + } +} + +bool AnnOverlayPlane::reset() +{ + RETURN_FALSE_IF_NOT_INIT(); + + if (mDisablePending) { + if (isFlushed() || mDisablePendingCount >= OVERLAY_DISABLING_COUNT_MAX) { + mDisablePending = false; + mDisablePendingDevice = 0; + mDisablePendingCount = 0; + } else { + mDisablePendingCount++; + WTRACE("overlay %d disabling is still pending on device %d, count %d", + mIndex, mDisablePendingDevice, mDisablePendingCount); + return false; + } + } + + DisplayPlane::reset(); + + // reset back buffers + for (int i = 0; i < OVERLAY_BACK_BUFFER_COUNT; i++) { + resetBackBuffer(i); + } + + return true; +} + +bool AnnOverlayPlane::enable() +{ + RETURN_FALSE_IF_NOT_INIT(); + OverlayBackBufferBlk *backBuffer = mBackBuffer[mCurrent]->buf; + if (!backBuffer) + return false; + + if (mContext.ctx.ov_ctx.ovadd & (0x1 << 15)) + return true; + + mContext.ctx.ov_ctx.ovadd |= (0x1 << 15); + + // flush + flush(PLANE_ENABLE); + return true; +} + +bool AnnOverlayPlane::disable() +{ + RETURN_FALSE_IF_NOT_INIT(); + + for (int i = 0; i < OVERLAY_BACK_BUFFER_COUNT; i++) { + OverlayBackBufferBlk *backBuffer = mBackBuffer[i]->buf; + if (!backBuffer) + continue; + + if (!(mContext.ctx.ov_ctx.ovadd & (0x1 << 15))) + continue; + + mContext.ctx.ov_ctx.ovadd &= ~(0x1 << 15); + + mContext.ctx.ov_ctx.ovadd &= ~(0x300); + + mContext.ctx.ov_ctx.ovadd |= mPipeConfig; + } + + if (mDisablePending) { + WTRACE("overlay %d disabling is still pending on device %d, skip disabling", + mIndex, mDisablePendingDevice); + return true; + } + + // flush + flush(PLANE_DISABLE); + + // "disable" is asynchronous and needs at least one vsync to complete + mDisablePending = true; + mDisablePendingDevice = mDevice; + mDisablePendingCount = 0; + return true; +} + +OverlayBackBuffer* AnnOverlayPlane::createBackBuffer() +{ + CTRACE(); + + // create back buffer + OverlayBackBuffer *backBuffer = (OverlayBackBuffer *)malloc(sizeof(OverlayBackBuffer)); + if (!backBuffer) { + ETRACE("failed to allocate back buffer"); + return 0; + } + + + int size = sizeof(OverlayBackBufferBlk); + int alignment = 64 * 1024; + void *wsbmBufferObject = 0; + bool ret = mWsbm->allocateTTMBuffer(size, alignment, &wsbmBufferObject); + if (ret == false) { + ETRACE("failed to allocate TTM buffer"); + return 0; + } + + void *virtAddr = mWsbm->getCPUAddress(wsbmBufferObject); + uint32_t gttOffsetInPage = mWsbm->getGttOffset(wsbmBufferObject); + + backBuffer->buf = (OverlayBackBufferBlk *)virtAddr; + backBuffer->gttOffsetInPage = gttOffsetInPage; + backBuffer->bufObject = (uint32_t)wsbmBufferObject; + + VTRACE("cpu %p, gtt %d", virtAddr, gttOffsetInPage); + + return backBuffer; +} + +void AnnOverlayPlane::deleteBackBuffer(int buf) +{ + if (!mBackBuffer[buf]) + return; + + void *wsbmBufferObject = (void *)mBackBuffer[buf]->bufObject; + bool ret = mWsbm->destroyTTMBuffer(wsbmBufferObject); + if (ret == false) { + WTRACE("failed to destroy TTM buffer"); + } + // free back buffer + free(mBackBuffer[buf]); + mBackBuffer[buf] = 0; +} + +void AnnOverlayPlane::resetBackBuffer(int buf) +{ + CTRACE(); + + if (!mBackBuffer[buf] || !mBackBuffer[buf]->buf) + return; + + OverlayBackBufferBlk *backBuffer = mBackBuffer[buf]->buf; + + memset(backBuffer, 0, sizeof(OverlayBackBufferBlk)); + + // reset overlay + backBuffer->OCLRC0 = (OVERLAY_INIT_CONTRAST << 18) | + (OVERLAY_INIT_BRIGHTNESS & 0xff); + backBuffer->OCLRC1 = OVERLAY_INIT_SATURATION; + backBuffer->DCLRKV = OVERLAY_INIT_COLORKEY; + backBuffer->DCLRKM = OVERLAY_INIT_COLORKEYMASK; + backBuffer->OCONFIG = 0; + backBuffer->OCONFIG |= (0x1 << 27); + // use 3 line buffers + backBuffer->OCONFIG |= 0x1; + backBuffer->SCHRKEN &= ~(0x7 << 24); + backBuffer->SCHRKEN |= 0xff; +} + +void AnnOverlayPlane::checkPosition(int& x, int& y, int& w, int& h) +{ + Drm *drm = Hwcomposer::getInstance().getDrm(); + drmModeModeInfo modeInfo; + if (!drm->getModeInfo(mDevice, modeInfo)) { + ETRACE("failed to get mode info"); + return; + } + drmModeModeInfoPtr mode = &modeInfo; + + if (x < 0) + x = 0; + if (y < 0) + y = 0; + if ((x + w) > mode->hdisplay) + w = mode->hdisplay - x; + if ((y + h) > mode->vdisplay) + h = mode->vdisplay - y; +} + +bool AnnOverlayPlane::bufferOffsetSetup(BufferMapper& mapper) +{ + CTRACE(); + + OverlayBackBufferBlk *backBuffer = mBackBuffer[mCurrent]->buf; + if (!backBuffer) { + ETRACE("invalid back buffer"); + return false; + } + + uint32_t format = mapper.getFormat(); + uint32_t gttOffsetInBytes = (mapper.getGttOffsetInPage(0) << 12); + uint32_t yStride = mapper.getStride().yuv.yStride; + uint32_t uvStride = mapper.getStride().yuv.uvStride; + uint32_t w = mapper.getWidth(); + uint32_t h = mapper.getHeight(); + uint32_t srcX= mapper.getCrop().x; + uint32_t srcY= mapper.getCrop().y; + uint32_t ySurface, uSurface, vSurface; + uint32_t yTileOffsetX, yTileOffsetY; + uint32_t uTileOffsetX, uTileOffsetY; + uint32_t vTileOffsetX, vTileOffsetY; + + // clear original format setting + backBuffer->OCMD &= ~(0xf << 10); + backBuffer->OCMD &= ~OVERLAY_MEMORY_LAYOUT_TILED; + + // Y/U/V plane must be 4k bytes aligned. + ySurface = gttOffsetInBytes; + if (mIsProtectedBuffer) { + // temporary workaround until vsync event logic is corrected. + // it seems that overlay buffer update and renderring can be overlapped, + // as such encryption bit may be cleared during HW rendering + ySurface |= 0x01; + } + + switch(format) { + case HAL_PIXEL_FORMAT_YV12: // YV12 + vSurface = ySurface + yStride * h; + uSurface = vSurface + uvStride * (h / 2); + yTileOffsetX = srcX; + yTileOffsetY = srcY; + uTileOffsetX = srcX / 2; + uTileOffsetY = srcY / 2; + vTileOffsetX = uTileOffsetX; + vTileOffsetY = uTileOffsetY; + backBuffer->OCMD |= OVERLAY_FORMAT_PLANAR_YUV420; + break; + case HAL_PIXEL_FORMAT_I420: // I420 + uSurface = ySurface + yStride * h; + vSurface = uSurface + uvStride * (h / 2); + yTileOffsetX = srcX; + yTileOffsetY = srcY; + uTileOffsetX = srcX / 2; + uTileOffsetY = srcY / 2; + vTileOffsetX = uTileOffsetX; + vTileOffsetY = uTileOffsetY; + backBuffer->OCMD |= OVERLAY_FORMAT_PLANAR_YUV420; + break; + case HAL_PIXEL_FORMAT_NV12: // NV12 + uSurface = ySurface + yStride * align_to(h, 32); + vSurface = ySurface + yStride * align_to(h, 32); + yTileOffsetX = srcX; + yTileOffsetY = srcY; + uTileOffsetX = srcX / 2; + uTileOffsetY = srcY / 2; + vTileOffsetX = uTileOffsetX; + vTileOffsetY = uTileOffsetY; + backBuffer->OCMD |= OVERLAY_FORMAT_PLANAR_NV12_2; + break; + // NOTE: this is the decoded video format, align the height to 32B + //as it's defined by video driver + case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar: // NV12 + uSurface = ySurface + yStride * align_to(h, 32); + vSurface = ySurface + yStride * align_to(h, 32); + yTileOffsetX = srcX; + yTileOffsetY = srcY; + uTileOffsetX = srcX / 2; + uTileOffsetY = srcY / 2; + vTileOffsetX = uTileOffsetX; + vTileOffsetY = uTileOffsetY; + backBuffer->OCMD |= OVERLAY_FORMAT_PLANAR_NV12_2; + break; + case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled: //NV12_tiled + uSurface = ySurface + yStride * align_to(h, 32); + vSurface = ySurface + yStride * align_to(h, 32); + yTileOffsetX = srcX; + yTileOffsetY = srcY; + uTileOffsetX = srcX / 2; + uTileOffsetY = srcY / 2; + vTileOffsetX = uTileOffsetX; + vTileOffsetY = uTileOffsetY; + backBuffer->OCMD |= OVERLAY_FORMAT_PLANAR_NV12_2; + backBuffer->OCMD |= OVERLAY_MEMORY_LAYOUT_TILED; + break; + case HAL_PIXEL_FORMAT_YUY2: // YUY2 + uSurface = ySurface; + vSurface = ySurface; + yTileOffsetX = srcX; + yTileOffsetY = srcY; + uTileOffsetX = yTileOffsetX; + uTileOffsetY = yTileOffsetY; + vTileOffsetX = yTileOffsetX; + vTileOffsetY = yTileOffsetY; + backBuffer->OCMD |= OVERLAY_FORMAT_PACKED_YUV422; + backBuffer->OCMD |= OVERLAY_PACKED_ORDER_YUY2; + break; + case HAL_PIXEL_FORMAT_UYVY: // UYVY + uSurface = ySurface; + vSurface = ySurface; + yTileOffsetX = srcX; + yTileOffsetY = srcY; + uTileOffsetX = yTileOffsetX; + uTileOffsetY = yTileOffsetY; + vTileOffsetX = yTileOffsetX; + vTileOffsetY = yTileOffsetY; + backBuffer->OCMD |= OVERLAY_FORMAT_PACKED_YUV422; + backBuffer->OCMD |= OVERLAY_PACKED_ORDER_UYVY; + break; + default: + ETRACE("unsupported format %d", format); + return false; + } + + backBuffer->OSTART_0Y = ySurface; + backBuffer->OSTART_0U = uSurface; + backBuffer->OSTART_0V = vSurface; + backBuffer->OBUF_0Y = srcY * yStride + srcX; + backBuffer->OBUF_0V = (srcY / 2) * uvStride + srcX; + backBuffer->OBUF_0U = (srcY / 2) * uvStride + srcX; + backBuffer->OTILEOFF_0Y = yTileOffsetY << 16 | yTileOffsetX; + backBuffer->OTILEOFF_0U = uTileOffsetY << 16 | uTileOffsetX; + backBuffer->OTILEOFF_0V = vTileOffsetY << 16 | vTileOffsetX; + + VTRACE("done. offset (%d, %d, %d)", + backBuffer->OBUF_0Y, + backBuffer->OBUF_0U, + backBuffer->OBUF_0V); + + return true; +} + +uint32_t AnnOverlayPlane::calculateSWidthSW(uint32_t offset, uint32_t width) +{ + ATRACE("offset = %d, width = %d", offset, width); + + uint32_t swidth = ((offset + width + 0x3F) >> 6) - (offset >> 6); + + swidth <<= 1; + swidth -= 1; + + return swidth; +} + +bool AnnOverlayPlane::coordinateSetup(BufferMapper& mapper) +{ + CTRACE(); + + OverlayBackBufferBlk *backBuffer = mBackBuffer[mCurrent]->buf; + if (!backBuffer) { + ETRACE("invalid back buffer"); + return false; + } + + uint32_t swidthy = 0; + uint32_t swidthuv = 0; + uint32_t format = mapper.getFormat(); + uint32_t width = mapper.getCrop().w; + uint32_t height = mapper.getCrop().h; + uint32_t yStride = mapper.getStride().yuv.yStride; + uint32_t uvStride = mapper.getStride().yuv.uvStride; + uint32_t offsety = backBuffer->OBUF_0Y; + uint32_t offsetu = backBuffer->OBUF_0U; + + switch (format) { + case HAL_PIXEL_FORMAT_YV12: // YV12 + case HAL_PIXEL_FORMAT_I420: // I420 + case HAL_PIXEL_FORMAT_NV12: // NV12 + case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar: // NV12 + case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled: // NV12_tiled + break; + case HAL_PIXEL_FORMAT_YUY2: // YUY2 + case HAL_PIXEL_FORMAT_UYVY: // UYVY + width <<= 1; + break; + default: + ETRACE("unsupported format %d", format); + return false; + } + + if (width <= 0 || height <= 0) { + ETRACE("invalid src dim"); + return false; + } + + if (yStride <=0 && uvStride <= 0) { + ETRACE("invalid source stride"); + return false; + } + + backBuffer->SWIDTH = width | ((width / 2) << 16); + swidthy = calculateSWidthSW(offsety, width); + swidthuv = calculateSWidthSW(offsetu, width / 2); + backBuffer->SWIDTHSW = (swidthy << 2) | (swidthuv << 18); + backBuffer->SHEIGHT = height | ((height / 2) << 16); + backBuffer->OSTRIDE = (yStride & (~0x3f)) | ((uvStride & (~0x3f)) << 16); + + XTRACE(); + + return true; +} + +bool AnnOverlayPlane::setCoeffRegs(double *coeff, int mantSize, + coeffPtr pCoeff, int pos) +{ + int maxVal, icoeff, res; + int sign; + double c; + + sign = 0; + maxVal = 1 << mantSize; + c = *coeff; + if (c < 0.0) { + sign = 1; + c = -c; + } + + res = 12 - mantSize; + if ((icoeff = (int)(c * 4 * maxVal + 0.5)) < maxVal) { + pCoeff[pos].exponent = 3; + pCoeff[pos].mantissa = icoeff << res; + *coeff = (double)icoeff / (double)(4 * maxVal); + } else if ((icoeff = (int)(c * 2 * maxVal + 0.5)) < maxVal) { + pCoeff[pos].exponent = 2; + pCoeff[pos].mantissa = icoeff << res; + *coeff = (double)icoeff / (double)(2 * maxVal); + } else if ((icoeff = (int)(c * maxVal + 0.5)) < maxVal) { + pCoeff[pos].exponent = 1; + pCoeff[pos].mantissa = icoeff << res; + *coeff = (double)icoeff / (double)(maxVal); + } else if ((icoeff = (int)(c * maxVal * 0.5 + 0.5)) < maxVal) { + pCoeff[pos].exponent = 0; + pCoeff[pos].mantissa = icoeff << res; + *coeff = (double)icoeff / (double)(maxVal / 2); + } else { + // Coeff out of range + return false; + } + + pCoeff[pos].sign = sign; + if (sign) + *coeff = -(*coeff); + return true; +} + +void AnnOverlayPlane::updateCoeff(int taps, double fCutoff, + bool isHoriz, bool isY, + coeffPtr pCoeff) +{ + int i, j, j1, num, pos, mantSize; + double pi = 3.1415926535, val, sinc, window, sum; + double rawCoeff[MAX_TAPS * 32], coeffs[N_PHASES][MAX_TAPS]; + double diff; + int tapAdjust[MAX_TAPS], tap2Fix; + bool isVertAndUV; + + if (isHoriz) + mantSize = 7; + else + mantSize = 6; + + isVertAndUV = !isHoriz && !isY; + num = taps * 16; + for (i = 0; i < num * 2; i++) { + val = (1.0 / fCutoff) * taps * pi * (i - num) / (2 * num); + if (val == 0.0) + sinc = 1.0; + else + sinc = sin(val) / val; + + // Hamming window + window = (0.54 - 0.46 * cos(2 * i * pi / (2 * num - 1))); + rawCoeff[i] = sinc * window; + } + + for (i = 0; i < N_PHASES; i++) { + // Normalise the coefficients + sum = 0.0; + for (j = 0; j < taps; j++) { + pos = i + j * 32; + sum += rawCoeff[pos]; + } + for (j = 0; j < taps; j++) { + pos = i + j * 32; + coeffs[i][j] = rawCoeff[pos] / sum; + } + + // Set the register values + for (j = 0; j < taps; j++) { + pos = j + i * taps; + if ((j == (taps - 1) / 2) && !isVertAndUV) + setCoeffRegs(&coeffs[i][j], mantSize + 2, pCoeff, pos); + else + setCoeffRegs(&coeffs[i][j], mantSize, pCoeff, pos); + } + + tapAdjust[0] = (taps - 1) / 2; + for (j = 1, j1 = 1; j <= tapAdjust[0]; j++, j1++) { + tapAdjust[j1] = tapAdjust[0] - j; + tapAdjust[++j1] = tapAdjust[0] + j; + } + + // Adjust the coefficients + sum = 0.0; + for (j = 0; j < taps; j++) + sum += coeffs[i][j]; + if (sum != 1.0) { + for (j1 = 0; j1 < taps; j1++) { + tap2Fix = tapAdjust[j1]; + diff = 1.0 - sum; + coeffs[i][tap2Fix] += diff; + pos = tap2Fix + i * taps; + if ((tap2Fix == (taps - 1) / 2) && !isVertAndUV) + setCoeffRegs(&coeffs[i][tap2Fix], mantSize + 2, pCoeff, pos); + else + setCoeffRegs(&coeffs[i][tap2Fix], mantSize, pCoeff, pos); + + sum = 0.0; + for (j = 0; j < taps; j++) + sum += coeffs[i][j]; + if (sum == 1.0) + break; + } + } + } +} + +bool AnnOverlayPlane::scalingSetup(BufferMapper& mapper) +{ + int xscaleInt, xscaleFract, yscaleInt, yscaleFract; + int xscaleIntUV, xscaleFractUV; + int yscaleIntUV, yscaleFractUV; + // UV is half the size of Y -- YUV420 + int uvratio = 2; + uint32_t newval; + coeffRec xcoeffY[N_HORIZ_Y_TAPS * N_PHASES]; + coeffRec xcoeffUV[N_HORIZ_UV_TAPS * N_PHASES]; + coeffRec ycoeffY[N_VERT_Y_TAPS * N_PHASES]; + coeffRec ycoeffUV[N_VERT_UV_TAPS * N_PHASES]; + int i, j, pos; + bool scaleChanged = false; + int x, y, w, h; + + OverlayBackBufferBlk *backBuffer = mBackBuffer[mCurrent]->buf; + if (!backBuffer) { + ETRACE("invalid back buffer"); + return false; + } + + x = mPosition.x; + y = mPosition.y; + w = mPosition.w; + h = mPosition.h; + + // check position + checkPosition(x, y, w, h); + VTRACE("final position (%d, %d, %d, %d)", x, y, w, h); + + if ((w <= 0) || (h <= 0)) { + ETRACE("invalid dst width/height"); + return false; + } + + // setup dst position + backBuffer->DWINPOS = (y << 16) | x; + backBuffer->DWINSZ = (h << 16) | w; + + uint32_t srcWidth = mapper.getCrop().w; + uint32_t srcHeight = mapper.getCrop().h; + uint32_t dstWidth = w; + uint32_t dstHeight = h; + + VTRACE("src (%dx%d), dst (%dx%d), transform %d", + srcWidth, srcHeight, + dstWidth, dstHeight, + mTransform); + + // switch destination width/height for scale factor calculation + // for 90/270 transformation + if ((mTransform == DisplayPlane::PLANE_TRANSFORM_90) || + (mTransform == DisplayPlane::PLANE_TRANSFORM_270)) { + uint32_t tmp = srcHeight; + srcHeight = srcWidth; + srcWidth = tmp; + } + + // Y down-scale factor as a multiple of 4096 + if (srcWidth == dstWidth && srcHeight == dstHeight) { + xscaleFract = (1 << 12); + yscaleFract = (1 << 12); + } else { + xscaleFract = ((srcWidth - 1) << 12) / dstWidth; + yscaleFract = ((srcHeight - 1) << 12) / dstHeight; + } + + // Calculate the UV scaling factor + xscaleFractUV = xscaleFract / uvratio; + yscaleFractUV = yscaleFract / uvratio; + + + // To keep the relative Y and UV ratios exact, round the Y scales + // to a multiple of the Y/UV ratio. + xscaleFract = xscaleFractUV * uvratio; + yscaleFract = yscaleFractUV * uvratio; + + // Integer (un-multiplied) values + xscaleInt = xscaleFract >> 12; + yscaleInt = yscaleFract >> 12; + + xscaleIntUV = xscaleFractUV >> 12; + yscaleIntUV = yscaleFractUV >> 12; + + // Check scaling ratio + if (xscaleInt > INTEL_OVERLAY_MAX_SCALING_RATIO) { + ETRACE("xscaleInt > %d", INTEL_OVERLAY_MAX_SCALING_RATIO); + return false; + } + + // shouldn't get here + if (xscaleIntUV > INTEL_OVERLAY_MAX_SCALING_RATIO) { + ETRACE("xscaleIntUV > %d", INTEL_OVERLAY_MAX_SCALING_RATIO); + return false; + } + + newval = (xscaleInt << 15) | + ((xscaleFract & 0xFFF) << 3) | ((yscaleFract & 0xFFF) << 20); + if (newval != backBuffer->YRGBSCALE) { + scaleChanged = true; + backBuffer->YRGBSCALE = newval; + } + + newval = (xscaleIntUV << 15) | ((xscaleFractUV & 0xFFF) << 3) | + ((yscaleFractUV & 0xFFF) << 20); + if (newval != backBuffer->UVSCALE) { + scaleChanged = true; + backBuffer->UVSCALE = newval; + } + + newval = yscaleInt << 16 | yscaleIntUV; + if (newval != backBuffer->UVSCALEV) { + scaleChanged = true; + backBuffer->UVSCALEV = newval; + } + + // Recalculate coefficients if the scaling changed + // Only Horizontal coefficients so far. + if (scaleChanged) { + double fHCutoffY; + double fHCutoffUV; + double fVCutoffY; + double fVCutoffUV; + + fHCutoffY = xscaleFract / 4096.0; + fHCutoffUV = xscaleFractUV / 4096.0; + fVCutoffY = yscaleFract / 4096.0; + fVCutoffUV = yscaleFractUV / 4096.0; + + // Limit to between 1.0 and 3.0 + if (fHCutoffY < MIN_CUTOFF_FREQ) + fHCutoffY = MIN_CUTOFF_FREQ; + if (fHCutoffY > MAX_CUTOFF_FREQ) + fHCutoffY = MAX_CUTOFF_FREQ; + if (fHCutoffUV < MIN_CUTOFF_FREQ) + fHCutoffUV = MIN_CUTOFF_FREQ; + if (fHCutoffUV > MAX_CUTOFF_FREQ) + fHCutoffUV = MAX_CUTOFF_FREQ; + + if (fVCutoffY < MIN_CUTOFF_FREQ) + fVCutoffY = MIN_CUTOFF_FREQ; + if (fVCutoffY > MAX_CUTOFF_FREQ) + fVCutoffY = MAX_CUTOFF_FREQ; + if (fVCutoffUV < MIN_CUTOFF_FREQ) + fVCutoffUV = MIN_CUTOFF_FREQ; + if (fVCutoffUV > MAX_CUTOFF_FREQ) + fVCutoffUV = MAX_CUTOFF_FREQ; + + updateCoeff(N_HORIZ_Y_TAPS, fHCutoffY, true, true, xcoeffY); + updateCoeff(N_HORIZ_UV_TAPS, fHCutoffUV, true, false, xcoeffUV); + updateCoeff(N_VERT_Y_TAPS, fVCutoffY, false, true, ycoeffY); + updateCoeff(N_VERT_UV_TAPS, fVCutoffUV, false, false, ycoeffUV); + + for (i = 0; i < N_PHASES; i++) { + for (j = 0; j < N_HORIZ_Y_TAPS; j++) { + pos = i * N_HORIZ_Y_TAPS + j; + backBuffer->Y_HCOEFS[pos] = + (xcoeffY[pos].sign << 15 | + xcoeffY[pos].exponent << 12 | + xcoeffY[pos].mantissa); + } + } + for (i = 0; i < N_PHASES; i++) { + for (j = 0; j < N_HORIZ_UV_TAPS; j++) { + pos = i * N_HORIZ_UV_TAPS + j; + backBuffer->UV_HCOEFS[pos] = + (xcoeffUV[pos].sign << 15 | + xcoeffUV[pos].exponent << 12 | + xcoeffUV[pos].mantissa); + } + } + + for (i = 0; i < N_PHASES; i++) { + for (j = 0; j < N_VERT_Y_TAPS; j++) { + pos = i * N_VERT_Y_TAPS + j; + backBuffer->Y_VCOEFS[pos] = + (ycoeffY[pos].sign << 15 | + ycoeffY[pos].exponent << 12 | + ycoeffY[pos].mantissa); + } + } + for (i = 0; i < N_PHASES; i++) { + for (j = 0; j < N_VERT_UV_TAPS; j++) { + pos = i * N_VERT_UV_TAPS + j; + backBuffer->UV_VCOEFS[pos] = + (ycoeffUV[pos].sign << 15 | + ycoeffUV[pos].exponent << 12 | + ycoeffUV[pos].mantissa); + } + } + } + + XTRACE(); + return true; +} + +bool AnnOverlayPlane::setDataBuffer(BufferMapper& grallocMapper) +{ + BufferMapper *mapper; + bool ret; + + RETURN_FALSE_IF_NOT_INIT(); + + // get gralloc mapper + mapper = &grallocMapper; + + OverlayBackBufferBlk *backBuffer = mBackBuffer[mCurrent]->buf; + if (!backBuffer) { + ETRACE("invalid back buffer"); + return false; + } + + ret = bufferOffsetSetup(*mapper); + if (ret == false) { + ETRACE("failed to set up buffer offsets"); + return false; + } + + ret = coordinateSetup(*mapper); + if (ret == false) { + ETRACE("failed to set up overlay coordinates"); + return false; + } + + ret = scalingSetup(*mapper); + if (ret == false) { + ETRACE("failed to set up scaling parameters"); + return false; + } + + return true; +} + +void AnnOverlayPlane::setTransform(int transform) +{ + RETURN_VOID_IF_NOT_INIT(); + + DisplayPlane::setTransform(transform); + + // setup transform config + switch (mTransform) { + case PLANE_TRANSFORM_90: + mRotationConfig = (0x1 << 10); + break; + case PLANE_TRANSFORM_180: + mRotationConfig = (0x2 << 10); + break; + case PLANE_TRANSFORM_270: + mRotationConfig = (0x3 << 10); + break; + case PLANE_TRANSFORM_0: + default: + mRotationConfig = 0; + break; + } +} + +bool AnnOverlayPlane::flip(void *ctx) +{ + uint32_t ovadd = 0; + + RETURN_FALSE_IF_NOT_INIT(); + + if (!DisplayPlane::flip(ctx)) + return false; + + // update back buffer address + ovadd = (mBackBuffer[mCurrent]->gttOffsetInPage << 12); + + // enable rotation mode and setup rotation config + if (mIndex == 0 && mTransform) { + ovadd |= (1 << 12); + ovadd |= mRotationConfig; + } + + // setup z-order config + ovadd |= mZOrderConfig; + + // load coefficients + ovadd |= 0x1; + + // enable overlay + ovadd |= (1 << 15); + + mContext.type = DC_OVERLAY_PLANE; + mContext.ctx.ov_ctx.ovadd = ovadd; + mContext.ctx.ov_ctx.index = mIndex; + mContext.ctx.ov_ctx.pipe = mPipeConfig; + + // move to next back buffer + mCurrent = (mCurrent + 1) % OVERLAY_BACK_BUFFER_COUNT; + + VTRACE("ovadd = %#x, index = %d, device = %d", + mContext.ctx.ov_ctx.ovadd, + mIndex, + mDevice); + + return true; +} + +void* AnnOverlayPlane::getContext() const +{ + CTRACE(); + return (void *)&mContext; +} + +bool AnnOverlayPlane::flush(uint32_t flags) +{ + RETURN_FALSE_IF_NOT_INIT(); + ATRACE("flags = %#x, type = %d, index = %d", flags, mType, mIndex); + + if (!(flags & PLANE_ENABLE) && !(flags & PLANE_DISABLE)) + return false; + + struct drm_psb_register_rw_arg arg; + memset(&arg, 0, sizeof(struct drm_psb_register_rw_arg)); + + if (flags & PLANE_DISABLE) + arg.plane_disable_mask = 1; + else if (flags & PLANE_ENABLE) + arg.plane_enable_mask = 1; + + arg.plane.type = DC_OVERLAY_PLANE; + arg.plane.index = mIndex; + arg.plane.ctx = mContext.ctx.ov_ctx.ovadd; + + // issue ioctl + Drm *drm = Hwcomposer::getInstance().getDrm(); + bool ret = drm->writeReadIoctl(DRM_PSB_REGISTER_RW, &arg, sizeof(arg)); + if (ret == false) { + WTRACE("overlay update failed with error code %d", ret); + return false; + } + + return true; +} + +bool AnnOverlayPlane::isFlushed() +{ + RETURN_FALSE_IF_NOT_INIT(); + + struct drm_psb_register_rw_arg arg; + memset(&arg, 0, sizeof(struct drm_psb_register_rw_arg)); + + arg.overlay_read_mask = OVSTATUS_REGRBIT_OVR_UPDT; + arg.plane.type = DC_OVERLAY_PLANE; + arg.plane.index = mIndex; + // pass the pipe index to check its enabled status + // now we can pass the device id directly since + // their values are just equal + arg.plane.ctx = mDisablePendingDevice; + + Drm *drm = Hwcomposer::getInstance().getDrm(); + bool ret = drm->writeReadIoctl(DRM_PSB_REGISTER_RW, &arg, sizeof(arg)); + if (ret == false) { + WTRACE("overlay read failed with error code %d", ret); + return false; + } + + DTRACE("overlay %d flush status %s on device %d, current device %d", + mIndex, arg.plane.ctx ? "DONE" : "PENDING", mDisablePendingDevice, mDevice); + return arg.plane.ctx == 1; +} + +} // namespace intel +} // namespace android diff --git a/ips/anniedale/AnnOverlayPlane.h b/ips/anniedale/AnnOverlayPlane.h new file mode 100644 index 0000000..23286cb --- /dev/null +++ b/ips/anniedale/AnnOverlayPlane.h @@ -0,0 +1,136 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef ANN_OVERLAY_PLANE_H +#define ANN_OVERLAY_PLANE_H + +#include <utils/KeyedVector.h> +#include <hal_public.h> +#include <DisplayPlane.h> +#include <BufferMapper.h> +#include <common/Wsbm.h> +#include <common/OverlayHardware.h> +#include <common/VideoPayloadBuffer.h> + +namespace android { +namespace intel { + +typedef struct { + OverlayBackBufferBlk *buf; + uint32_t gttOffsetInPage; + uint32_t bufObject; +} OverlayBackBuffer; + +class AnnOverlayPlane : public DisplayPlane { +public: + AnnOverlayPlane(int index, int disp); + virtual ~AnnOverlayPlane(); + + virtual bool setDataBuffer(uint32_t handle); + + virtual void invalidateBufferCache(); + + virtual void setTransform(int transform); + virtual bool assignToDevice(int disp); + + virtual void setZOrderConfig(ZOrderConfig& config, void *nativeConfig); + + // plane operations + virtual bool flip(void *ctx) ; + virtual bool reset(); + virtual bool enable(); + virtual bool disable(); + + virtual void* getContext() const; + virtual bool initialize(uint32_t bufferCount); + virtual void deinitialize(); + +protected: + // generic overlay register flush + virtual bool flush(uint32_t flags); + virtual bool isFlushed(); + virtual bool setDataBuffer(BufferMapper& mapper); + virtual bool bufferOffsetSetup(BufferMapper& mapper); + virtual uint32_t calculateSWidthSW(uint32_t offset, uint32_t width); + virtual bool coordinateSetup(BufferMapper& mapper); + virtual bool setCoeffRegs(double *coeff, int mantSize, + coeffPtr pCoeff, int pos); + virtual void updateCoeff(int taps, double fCutoff, + bool isHoriz, bool isY, + coeffPtr pCoeff); + virtual bool scalingSetup(BufferMapper& mapper); + virtual void checkPosition(int& x, int& y, int& w, int& h); + +protected: + // back buffer operations + virtual OverlayBackBuffer* createBackBuffer(); + virtual void deleteBackBuffer(int buf); + virtual void resetBackBuffer(int buf); +protected: + // flush flags + enum { + PLANE_ENABLE = 0x00000001UL, + PLANE_DISABLE = 0x00000002UL, + UPDATE_COEF = 0x00000004UL, + }; + + enum { + OVERLAY_BACK_BUFFER_COUNT = 3, + OVERLAY_DATA_BUFFER_COUNT = 10, + }; + + // overlay back buffer + OverlayBackBuffer *mBackBuffer[OVERLAY_BACK_BUFFER_COUNT]; + int mCurrent; + + // wsbm + Wsbm *mWsbm; + // pipe config + uint32_t mPipeConfig; + + // variables for asynchronous overlay disabling + enum { + // maximum wait count before aborting overlay disabling + OVERLAY_DISABLING_COUNT_MAX = 60, + }; + bool mDisablePending; + bool mDisablePendingDevice; + int mDisablePendingCount; + + // rotation config + uint32_t mRotationConfig; + // z order config + uint32_t mZOrderConfig; + // hardware context + struct intel_dc_plane_ctx mContext; +}; + +} // namespace intel +} // namespace android + +#endif /* ANN_OVERLAY_PLANE_H */ + diff --git a/ips/anniedale/AnnRGBPlane.cpp b/ips/anniedale/AnnRGBPlane.cpp new file mode 100644 index 0000000..2da11b4 --- /dev/null +++ b/ips/anniedale/AnnRGBPlane.cpp @@ -0,0 +1,261 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#include <HwcTrace.h> +#include <Hwcomposer.h> +#include <BufferManager.h> +#include <anniedale/AnnRGBPlane.h> +#include <anniedale/AnnGrallocBuffer.h> +#include <common/PixelFormat.h> + +namespace android { +namespace intel { + +AnnRGBPlane::AnnRGBPlane(int index, int type, int disp) + : DisplayPlane(index, type, disp) +{ + CTRACE(); + memset(&mContext, 0, sizeof(mContext)); + + mZOrder = index; + if (type == PLANE_SPRITE) + mZOrder |= 0x8; +} + +AnnRGBPlane::~AnnRGBPlane() +{ + CTRACE(); +} + +bool AnnRGBPlane::enable() +{ + return enablePlane(true); +} + +bool AnnRGBPlane::disable() +{ + return enablePlane(false); +} + +void* AnnRGBPlane::getContext() const +{ + CTRACE(); + return (void *)&mContext; +} + +void AnnRGBPlane::setZOrderConfig(ZOrderConfig& config, void *nativeConfig) +{ + CTRACE(); +} + +bool AnnRGBPlane::assignToDevice(int disp) +{ + CTRACE(); + return false; +} + +void AnnRGBPlane::setZOrder(int zorder) +{ + CTRACE(); +} + +bool AnnRGBPlane::setDataBuffer(uint32_t handle) +{ + if (!handle) { + setFramebufferTarget(handle); + return true; + } + + AnnGrallocBuffer tmpBuf(handle); + uint32_t usage; + bool ret; + + ATRACE("handle = %#x", handle); + + usage = tmpBuf.getUsage(); + if (GRALLOC_USAGE_HW_FB & usage) { + setFramebufferTarget(handle); + return true; + } + + // use primary as a sprite + ret = DisplayPlane::setDataBuffer(handle); + if (ret == false) { + ETRACE("failed to set data buffer"); + return ret; + } + + return true; +} + +bool AnnRGBPlane::setDataBuffer(BufferMapper& mapper) +{ + int bpp; + int srcX, srcY; + int dstX, dstY, dstW, dstH; + uint32_t spriteFormat; + uint32_t stride; + uint32_t linoff; + + CTRACE(); + + // setup plane position + dstX = mPosition.x; + dstY = mPosition.y; + dstW = mPosition.w; + dstH = mPosition.h; + + checkPosition(dstX, dstY, dstW, dstH); + + // setup plane format + if (!PixelFormat::convertFormat(mapper.getFormat(), spriteFormat, bpp)) { + ETRACE("unsupported format %#x", mapper.getFormat()); + return false; + } + + // setup stride and source buffer crop + srcX = mapper.getCrop().x; + srcY = mapper.getCrop().y; + stride = mapper.getStride().rgb.stride; + linoff = srcY * stride + srcX * bpp; + + // unlikely happen, but still we need make sure linoff is valid + if (linoff > (stride * mapper.getHeight())) { + ETRACE("invalid source crop"); + return false; + } + + // update context + if (mType == PLANE_SPRITE) + mContext.type = DC_SPRITE_PLANE; + else + mContext.type = DC_PRIMARY_PLANE; + + mContext.ctx.sp_ctx.index = mIndex; + mContext.ctx.sp_ctx.pipe = mDevice; + mContext.ctx.sp_ctx.cntr = spriteFormat | 0x80000000; + mContext.ctx.sp_ctx.cntr |= (0x1 << 23); + mContext.ctx.sp_ctx.linoff = linoff; + mContext.ctx.sp_ctx.stride = stride; + mContext.ctx.sp_ctx.surf = mapper.getGttOffsetInPage(0) << 12; + mContext.ctx.sp_ctx.pos = (dstY & 0xfff) << 16 | (dstX & 0xfff); + mContext.ctx.sp_ctx.size = + ((dstH - 1) & 0xfff) << 16 | ((dstW - 1) & 0xfff); + mContext.ctx.sp_ctx.update_mask = SPRITE_UPDATE_ALL; + + VTRACE("type = %d, index = %d, cntr = %#x, linoff = %#x, stride = %#x," + "surf = %#x, pos = %#x, size = %#x", mType, mIndex, + mContext.ctx.sp_ctx.cntr, + mContext.ctx.sp_ctx.linoff, + mContext.ctx.sp_ctx.stride, + mContext.ctx.sp_ctx.surf, + mContext.ctx.sp_ctx.pos, + mContext.ctx.sp_ctx.size); + return true; +} + +bool AnnRGBPlane::enablePlane(bool enabled) +{ + RETURN_FALSE_IF_NOT_INIT(); + + struct drm_psb_register_rw_arg arg; + memset(&arg, 0, sizeof(struct drm_psb_register_rw_arg)); + if (enabled) { + arg.plane_enable_mask = 1; + } else { + arg.plane_disable_mask = 1; + } + + if (mType == PLANE_SPRITE) + arg.plane.type = DC_SPRITE_PLANE; + else + arg.plane.type = DC_PRIMARY_PLANE; + + arg.plane.index = mIndex; + arg.plane.ctx = 0; + + // issue ioctl + Drm *drm = Hwcomposer::getInstance().getDrm(); + bool ret = drm->writeReadIoctl(DRM_PSB_REGISTER_RW, &arg, sizeof(arg)); + if (ret == false) { + WTRACE("plane enabling (%d) failed with error code %d", enabled, ret); + return false; + } + + return true; + +} + +void AnnRGBPlane::setFramebufferTarget(uint32_t handle) +{ + CTRACE(); + + // do not need to update the buffer handle + if (mCurrentDataBuffer != handle) + mUpdateMasks |= PLANE_BUFFER_CHANGED; + else + mUpdateMasks &= ~PLANE_BUFFER_CHANGED; + + // if no update then do Not need set data buffer + if (!mUpdateMasks) + return; + + // don't need to map data buffer for primary plane + if (mType == PLANE_SPRITE) + mContext.type = DC_SPRITE_PLANE; + else + mContext.type = DC_PRIMARY_PLANE; + + // FIXME: use sprite context for sprite plane + mContext.ctx.prim_ctx.update_mask = SPRITE_UPDATE_ALL; + mContext.ctx.prim_ctx.index = mIndex; + mContext.ctx.prim_ctx.pipe = mDevice; + mContext.ctx.prim_ctx.linoff = 0; + mContext.ctx.prim_ctx.stride = align_to((4 * align_to(mPosition.w, 32)), 64); + mContext.ctx.prim_ctx.pos = 0; + mContext.ctx.prim_ctx.size = + ((mPosition.h - 1) & 0xfff) << 16 | ((mPosition.w - 1) & 0xfff); + mContext.ctx.prim_ctx.surf = 0; + + mContext.ctx.prim_ctx.cntr = PixelFormat::PLANE_PIXEL_FORMAT_BGRA8888; + mContext.ctx.prim_ctx.cntr |= (0x1 << 23); + mContext.ctx.prim_ctx.cntr |= 0x80000000; + + VTRACE("type = %d, index = %d, cntr = %#x, linoff = %#x, stride = %#x," + "surf = %#x, pos = %#x, size = %#x", mType, mIndex, + mContext.ctx.prim_ctx.cntr, + mContext.ctx.prim_ctx.linoff, + mContext.ctx.prim_ctx.stride, + mContext.ctx.prim_ctx.surf, + mContext.ctx.prim_ctx.pos, + mContext.ctx.prim_ctx.size); + + mCurrentDataBuffer = handle; +} + +} // namespace intel +} // namespace android diff --git a/ips/anniedale/AnnRGBPlane.h b/ips/anniedale/AnnRGBPlane.h new file mode 100644 index 0000000..ef885c8 --- /dev/null +++ b/ips/anniedale/AnnRGBPlane.h @@ -0,0 +1,70 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef ANN_RGB_PLANE_H +#define ANN_RGB_PLANE_H + +#include <utils/KeyedVector.h> +#include <hal_public.h> +#include <Hwcomposer.h> +#include <BufferCache.h> +#include <DisplayPlane.h> + +#include <linux/psb_drm.h> + +namespace android { +namespace intel { + +class AnnRGBPlane : public DisplayPlane { +public: + AnnRGBPlane(int index, int type, int disp); + virtual ~AnnRGBPlane(); +public: + // hardware operations + bool enable(); + bool disable(); + + void* getContext() const; + void setZOrderConfig(ZOrderConfig& config, void *nativeConfig); + bool assignToDevice(int disp); + + void setZOrder(int zorder); + + bool setDataBuffer(uint32_t handle); +protected: + bool setDataBuffer(BufferMapper& mapper); + bool enablePlane(bool enabled); +private: + void setFramebufferTarget(uint32_t handle); +protected: + struct intel_dc_plane_ctx mContext; +}; + +} // namespace intel +} // namespace android + +#endif /* ANN_RGB_PLANE_H */ diff --git a/ips/common/PlaneCapabilities.cpp b/ips/common/PlaneCapabilities.cpp index 0ed8b89..6fc4420 100644 --- a/ips/common/PlaneCapabilities.cpp +++ b/ips/common/PlaneCapabilities.cpp @@ -58,7 +58,6 @@ bool PlaneCapabilities::isFormatSupported(int planeType, uint32_t format, uint32 } } else if (planeType == DisplayPlane::PLANE_OVERLAY) { switch (format) { - case HAL_PIXEL_FORMAT_YV12: case HAL_PIXEL_FORMAT_I420: case HAL_PIXEL_FORMAT_NV12: case HAL_PIXEL_FORMAT_YUY2: @@ -68,6 +67,7 @@ bool PlaneCapabilities::isFormatSupported(int planeType, uint32_t format, uint32 WTRACE("180 degree rotation is not supported yet"); } return trans ? false : true; + case HAL_PIXEL_FORMAT_YV12: case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar: case OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled: return true; diff --git a/ips/tangier/TngDisplayContext.cpp b/ips/tangier/TngDisplayContext.cpp index 215db96..0f8db51 100644 --- a/ips/tangier/TngDisplayContext.cpp +++ b/ips/tangier/TngDisplayContext.cpp @@ -130,15 +130,15 @@ bool TngDisplayContext::commitContents(hwc_display_contents_1_t *display, HwcLay memcpy(&ctx->zorder, pm->getZOrderConfig(), sizeof(ctx->zorder)); VTRACE("count %d, handle %#x, trans %#x, blending %#x" - " sourceCrop %d,%d - %dx%d, dst %d,%d - %dx%d, custom %#x", + " sourceCrop %f,%f - %fx%f, dst %d,%d - %dx%d, custom %#x", mCount, (uint32_t)imgLayer->psLayer->handle, imgLayer->psLayer->transform, imgLayer->psLayer->blending, - imgLayer->psLayer->sourceCrop.left, - imgLayer->psLayer->sourceCrop.top, - imgLayer->psLayer->sourceCrop.right - imgLayer->psLayer->sourceCrop.left, - imgLayer->psLayer->sourceCrop.bottom - imgLayer->psLayer->sourceCrop.top, + imgLayer->psLayer->sourceCropf.left, + imgLayer->psLayer->sourceCropf.top, + imgLayer->psLayer->sourceCropf.right - imgLayer->psLayer->sourceCropf.left, + imgLayer->psLayer->sourceCropf.bottom - imgLayer->psLayer->sourceCropf.top, imgLayer->psLayer->displayFrame.left, imgLayer->psLayer->displayFrame.top, imgLayer->psLayer->displayFrame.right - imgLayer->psLayer->displayFrame.left, diff --git a/platforms/merrifield_plus/Android.mk b/platforms/merrifield_plus/Android.mk new file mode 100644 index 0000000..e1ce99b --- /dev/null +++ b/platforms/merrifield_plus/Android.mk @@ -0,0 +1,131 @@ +# Copyright (C) 2008 The Android Open Source Project +# +# 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. + +LOCAL_PATH := $(call my-dir) + +# HAL module implemenation, not prelinked and stored in +# hw/<OVERLAY_HARDWARE_MODULE_ID>.<ro.product.board>.so +include $(CLEAR_VARS) + +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw +LOCAL_SHARED_LIBRARIES := liblog libcutils libdrm \ + libwsbm libutils libhardware \ + libva libva-tpi libva-android +LOCAL_SRC_FILES := \ + ../../common/base/Drm.cpp \ + ../../common/base/HwcLayerList.cpp \ + ../../common/base/Hwcomposer.cpp \ + ../../common/base/HwcModule.cpp \ + ../../common/base/DisplayAnalyzer.cpp \ + ../../common/base/VsyncManager.cpp \ + ../../common/buffers/BufferCache.cpp \ + ../../common/buffers/GraphicBuffer.cpp \ + ../../common/buffers/BufferManager.cpp \ + ../../common/devices/PhysicalDevice.cpp \ + ../../common/devices/PrimaryDevice.cpp \ + ../../common/devices/ExternalDevice.cpp \ + ../../common/observers/HotplugEventObserver.cpp \ + ../../common/observers/VsyncEventObserver.cpp \ + ../../common/observers/SoftVsyncObserver.cpp \ + ../../common/observers/MultiDisplayObserver.cpp \ + ../../common/planes/DisplayPlane.cpp \ + ../../common/planes/DisplayPlaneManager.cpp \ + ../../common/utils/Dump.cpp + + +LOCAL_SRC_FILES += \ + ../../ips/common/BlankControl.cpp \ + ../../ips/common/HotplugControl.cpp \ + ../../ips/common/HdcpControl.cpp \ + ../../ips/common/DrmControl.cpp \ + ../../ips/common/VsyncControl.cpp \ + ../../ips/common/PrepareListener.cpp \ + ../../ips/common/OverlayPlaneBase.cpp \ + ../../ips/common/SpritePlaneBase.cpp \ + ../../ips/common/PixelFormat.cpp \ + ../../ips/common/PlaneCapabilities.cpp \ + ../../ips/common/GrallocBufferBase.cpp \ + ../../ips/common/GrallocBufferMapperBase.cpp \ + ../../ips/common/TTMBufferMapper.cpp \ + ../../ips/common/DrmConfig.cpp \ + ../../ips/common/VideoPayloadManager.cpp \ + ../../ips/common/Wsbm.cpp \ + ../../ips/common/WsbmWrapper.c \ + ../../ips/common/RotationBufferProvider.cpp + +LOCAL_SRC_FILES += \ + ../../ips/anniedale/AnnGrallocBuffer.cpp \ + ../../ips/anniedale/AnnGrallocBufferMapper.cpp \ + ../../ips/anniedale/AnnOverlayPlane.cpp \ + ../../ips/anniedale/AnnDisplayPlane.cpp \ + ../../ips/anniedale/AnnRGBPlane.cpp \ + ../../ips/anniedale/AnnDisplayQuery.cpp \ + ../../ips/anniedale/AnnDisplayContext.cpp + + +LOCAL_SRC_FILES += \ + PlatfBufferManager.cpp \ + PlatfPrimaryDevice.cpp \ + PlatfExternalDevice.cpp \ + PlatfDisplayPlaneManager.cpp \ + PlatfHwcomposer.cpp + + +LOCAL_C_INCLUDES := $(addprefix $(LOCAL_PATH)/../../../, $(SGX_INCLUDES)) \ + frameworks/native/include/media/openmax \ + frameworks/native/opengl/include \ + hardware/libhardware_legacy/include/hardware_legacy \ + vendor/intel/hardware/PRIVATE/rgx/rogue/android/graphicshal \ + vendor/intel/hardware/PRIVATE/rgx/rogue/include/ \ + vendor/intel/hardware/PRIVATE/widi/libhwcwidi/ \ + $(TARGET_OUT_HEADERS)/drm \ + $(TARGET_OUT_HEADERS)/libdrm \ + $(TARGET_OUT_HEADERS)/libdrm/shared-core \ + $(TARGET_OUT_HEADERS)/libwsbm/wsbm \ + $(TARGET_OUT_HEADERS)/libttm \ + $(TARGET_OUT_HEADERS)/libva + +LOCAL_C_INCLUDES += $(LOCAL_PATH) \ + $(LOCAL_PATH)/../../include \ + $(LOCAL_PATH)/../../common/base \ + $(LOCAL_PATH)/../../common/buffers \ + $(LOCAL_PATH)/../../common/devices \ + $(LOCAL_PATH)/../../common/observers \ + $(LOCAL_PATH)/../../common/planes \ + $(LOCAL_PATH)/../../common/utils \ + $(LOCAL_PATH)/../../ips/ \ + $(LOCAL_PATH)/ + + +LOCAL_MODULE_TAGS := eng +LOCAL_MODULE := hwcomposer.$(TARGET_DEVICE) +LOCAL_CFLAGS:= -DLINUX + +#$(error local path is: $(LOCAL_C_INCLUDES)) +ifeq ($(INTEL_WIDI_MERRIFIELD), true) +LOCAL_SRC_FILES += \ + ../../common/devices/VirtualDevice.cpp \ + PlatfVirtualDevice.cpp + + LOCAL_SHARED_LIBRARIES += libhwcwidi libbinder + LOCAL_CFLAGS += -DINTEL_WIDI_MERRIFIELD +endif + +ifeq ($(TARGET_HAS_MULTIPLE_DISPLAY),true) + LOCAL_SHARED_LIBRARIES += libmultidisplay libbinder + LOCAL_CFLAGS += -DTARGET_HAS_MULTIPLE_DISPLAY +endif +include $(BUILD_SHARED_LIBRARY) + diff --git a/platforms/merrifield_plus/PlatfBufferManager.cpp b/platforms/merrifield_plus/PlatfBufferManager.cpp new file mode 100644 index 0000000..a962324 --- /dev/null +++ b/platforms/merrifield_plus/PlatfBufferManager.cpp @@ -0,0 +1,89 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#include <HwcTrace.h> +#include <PlatfBufferManager.h> +#include <anniedale/AnnGrallocBuffer.h> +#include <anniedale/AnnGrallocBufferMapper.h> + +namespace android { +namespace intel { + +PlatfBufferManager::PlatfBufferManager() + : BufferManager() +{ + +} + +PlatfBufferManager::~PlatfBufferManager() +{ + +} + +bool PlatfBufferManager::initialize() +{ + return BufferManager::initialize(); +} + +void PlatfBufferManager::deinitialize() +{ + BufferManager::deinitialize(); +} + +DataBuffer* PlatfBufferManager::createDataBuffer(gralloc_module_t *module, + uint32_t handle) +{ + return new AnnGrallocBuffer(handle); +} + +BufferMapper* PlatfBufferManager::createBufferMapper(gralloc_module_t *module, + DataBuffer& buffer) +{ + if (!module) + return 0; + + return new AnnGrallocBufferMapper(*(IMG_gralloc_module_public_t*)module, + buffer); +} + +bool PlatfBufferManager::convertRGBToNV12(uint32_t rgbHandle, uint32_t yuvHandle, + crop_t& srcCrop, uint32_t async) + +{ + IMG_gralloc_module_public_t *imgGrallocModule = (IMG_gralloc_module_public_t *) mGrallocModule; + if (imgGrallocModule->Blit(imgGrallocModule, (buffer_handle_t)rgbHandle, + (buffer_handle_t)yuvHandle, + srcCrop.w, srcCrop.h, srcCrop.x, + srcCrop.y, async)) { + ETRACE("Blit failed"); + return false; + } + return true; +} + +} // namespace intel +} // namespace android diff --git a/platforms/merrifield_plus/PlatfBufferManager.h b/platforms/merrifield_plus/PlatfBufferManager.h new file mode 100644 index 0000000..29b2c3a --- /dev/null +++ b/platforms/merrifield_plus/PlatfBufferManager.h @@ -0,0 +1,55 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef PLATF_BUFFER_MANAGER_H +#define PLATF_BUFFER_MANAGER_H + +#include <BufferManager.h> + +namespace android { +namespace intel { + +class PlatfBufferManager : public BufferManager { +public: + PlatfBufferManager(); + virtual ~PlatfBufferManager(); + +public: + bool initialize(); + void deinitialize(); + +protected: + DataBuffer* createDataBuffer(gralloc_module_t *module, uint32_t handle); + BufferMapper* createBufferMapper(gralloc_module_t *module, + DataBuffer& buffer); + bool convertRGBToNV12(uint32_t rgbHandle, uint32_t yuvHandle, + crop_t& srcCrop, uint32_t async); +}; + +} +} +#endif /* PLATF_BUFFER_MANAGER_H */ diff --git a/platforms/merrifield_plus/PlatfDisplayPlaneManager.cpp b/platforms/merrifield_plus/PlatfDisplayPlaneManager.cpp new file mode 100644 index 0000000..ec23a3b --- /dev/null +++ b/platforms/merrifield_plus/PlatfDisplayPlaneManager.cpp @@ -0,0 +1,537 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#include <HwcTrace.h> +#include <PlatfDisplayPlaneManager.h> +#include <anniedale/AnnRGBPlane.h> +#include <anniedale/AnnDisplayPlane.h> +#include <anniedale/AnnOverlayPlane.h> + +namespace android { +namespace intel { + +// hardware z order configs +static const uint32_t PRIMARY_ZORDER_CONFIG[2][4] = { + {1 << 0, 1 << 3, 1 << 4, 1 << 5}, + {1 << 0, 1 << 0, 1 << 0, 1 << 0}, +}; + +static const uint32_t EXTERNAL_ZORDER_CONFIG[2][4] = { + {1 << 1, (1 << 1) | (1 << 3), (1 << 1) | (1 << 3), 1 << 3}, + {1 << 1, 1 << 1, 1 << 1, 1 << 1}, +}; + +PlatfDisplayPlaneManager::PlatfDisplayPlaneManager() + : DisplayPlaneManager(), + mExtraSpriteCount(EXTRA_SPRITE_COUNT), + mExtraSprites(), + mFreeExtraSprites(0), + mReclaimedExtraSprites(0) +{ + CTRACE(); + memset(&mZorder, 1, sizeof(mZorder)); + + for (int i = 0; i < REAL_PLANE_MAX; i++) { + mFreeRealPlanes[i] = 0; + mReclaimedRealPlanes[i] = 0; + mRealPlaneCounts[i] = 0; + } +} + +PlatfDisplayPlaneManager::~PlatfDisplayPlaneManager() +{ + +} + +bool PlatfDisplayPlaneManager::initialize() +{ + bool ret; + int i; + + ret = DisplayPlaneManager::initialize(); + if (ret == false) { + ETRACE("failed to initialize DisplayPlaneManager"); + return false; + } + + // init extra sprites + mFreeExtraSprites = ((1 << mExtraSpriteCount) - 1); + mExtraSprites.setCapacity(mExtraSpriteCount); + + // init free real planes; + mRealPlaneCounts[REAL_PLANE_SPRITE] = + PRIMARY_COUNT + SPRITE_COUNT + EXTRA_SPRITE_COUNT; + mRealPlaneCounts[REAL_PLANE_OVERLAY] = OVERLAY_COUNT; + + // allocate and reset extra sprites + for (i = 0; i < mExtraSpriteCount; i++) { + // allocate extra sprites, plane indexes start from SPRITE_COUNT + DisplayPlane* plane = allocPlane((SPRITE_COUNT + i), + DisplayPlane::PLANE_SPRITE); + if (!plane) { + ETRACE("failed to allocate extra sprite %d", (SPRITE_COUNT + i)); + DEINIT_AND_RETURN_FALSE(); + } + // reset plane + plane->reset(); + mExtraSprites.push_back(plane); + } + + // create real planes + for (i = 0; i < REAL_PLANE_MAX; i++) { + mFreeRealPlanes[i] = ((1 << mRealPlaneCounts[i]) - 1); + mRealPlanes[i].setCapacity(mRealPlaneCounts[i]); + } + + for (i = 0; i < PRIMARY_COUNT; i++) { + DisplayPlane *plane = new AnnRGBPlane(i, DisplayPlane::PLANE_PRIMARY, i); + if (!plane->initialize(DisplayPlane::MIN_DATA_BUFFER_COUNT)) { + ETRACE("failed to initialize primary plane %d", i); + DEINIT_AND_RETURN_FALSE(); + } + mRealPlanes[REAL_PLANE_SPRITE].push_back(plane); + } + + for (i = 0; i < SPRITE_COUNT + EXTRA_SPRITE_COUNT; i++) { + DisplayPlane *plane = new AnnRGBPlane(i, DisplayPlane::PLANE_SPRITE, 0); + if (!plane->initialize(DisplayPlane::MIN_DATA_BUFFER_COUNT)) { + ETRACE("failed to initialize sprite plane %d", i); + DEINIT_AND_RETURN_FALSE(); + } + mRealPlanes[REAL_PLANE_SPRITE].push_back(plane); + } + + for (i = 0; i < OVERLAY_COUNT; i++) { + DisplayPlane *plane = new AnnOverlayPlane(i, 0); + if (!plane->initialize(DisplayPlane::MIN_DATA_BUFFER_COUNT)) { + ETRACE("failed to initialize overlay plane %d", i); + DEINIT_AND_RETURN_FALSE(); + } + mRealPlanes[REAL_PLANE_OVERLAY].push_back(plane); + } + + return true; +} + +void PlatfDisplayPlaneManager::deinitialize() +{ + for (size_t i = 0; i < mExtraSprites.size(); i++) { + // reset plane + DisplayPlane *plane = mExtraSprites.itemAt(i); + plane->reset(); + DEINIT_AND_DELETE_OBJ(plane); + } + mExtraSprites.clear(); + + DisplayPlaneManager::deinitialize(); +} + +DisplayPlane* PlatfDisplayPlaneManager::getSpritePlane(int dsp) +{ + DisplayPlane *plane = DisplayPlaneManager::getSpritePlane(dsp); + if (plane) { + VTRACE("Get sprite plane"); + return plane; + } + + if (dsp != IDisplayDevice::DEVICE_PRIMARY) { + return NULL; + } + + // for primary display we have extra sprites + int freePlaneIndex = -1; + + freePlaneIndex = getPlane(mReclaimedExtraSprites); + if (freePlaneIndex >= 0) { + VTRACE("Get extra sprite plane on reclaimed plane list"); + return mExtraSprites.itemAt(freePlaneIndex); + } + + freePlaneIndex = getPlane(mFreeExtraSprites); + if (freePlaneIndex >= 0) { + VTRACE("Get extra sprite plane on free plane list"); + return mExtraSprites.itemAt(freePlaneIndex); + } + + VTRACE("failed to get extra sprite"); + + return NULL; +} + +void PlatfDisplayPlaneManager::putPlane(int dsp, DisplayPlane& plane) +{ + int index; + int type; + + RETURN_VOID_IF_NOT_INIT(); + + index = plane.getIndex(); + type = plane.getType(); + + if (type != DisplayPlane::PLANE_SPRITE || index < SPRITE_COUNT) { + DisplayPlaneManager::putPlane(dsp, plane); + return; + } + + if (dsp != IDisplayDevice::DEVICE_PRIMARY) + WTRACE("putting a plane which doesn't belong to device %d", dsp); + + // put it back into free extra sprites + index -= SPRITE_COUNT; + DisplayPlaneManager::putPlane(index, mFreeExtraSprites); +} + +bool PlatfDisplayPlaneManager::hasFreeSprite(int dsp) +{ + bool ret = DisplayPlaneManager::hasFreeSprite(dsp); + if (ret == true) { + VTRACE("DisplayPlaneManager has free sprite"); + return ret; + } + + if (dsp != IDisplayDevice::DEVICE_PRIMARY) { + return false; + } + + // extra sprites is available for primary device + uint32_t freePlanes = (mFreeExtraSprites | mReclaimedExtraSprites); + return freePlanes ? true : false; +} + +void PlatfDisplayPlaneManager::reclaimPlane(int dsp, DisplayPlane& plane) +{ + AnnDisplayPlane *annPlane; + int index; + int type; + + RETURN_VOID_IF_NOT_INIT(); + + index = plane.getIndex(); + type = plane.getType(); + + // reclaim real plane + annPlane = reinterpret_cast<AnnDisplayPlane *>(&plane); + reclaimRealPlane(annPlane->getRealPlane()); + + // clear this slot + annPlane->setRealPlane(0); + + if (type != DisplayPlane::PLANE_SPRITE || index < SPRITE_COUNT) { + DisplayPlaneManager::reclaimPlane(dsp, plane); + return; + } + + if (dsp != IDisplayDevice::DEVICE_PRIMARY) + WTRACE("reclaiming a plane which doesn't belong to device %d", dsp); + + index -= SPRITE_COUNT; + DisplayPlaneManager::putPlane(index, mReclaimedExtraSprites); +} + +void PlatfDisplayPlaneManager::disableReclaimedPlanes() +{ + int i, j; + bool ret; + + RETURN_VOID_IF_NOT_INIT(); + + // merge into free bitmap + for (i = 0; i < DisplayPlane::PLANE_MAX; i++) { + // disable reclaimed planes + if (mReclaimedPlanes[i]) { + mFreePlanes[i] |= mReclaimedPlanes[i]; + mReclaimedPlanes[i] = 0; + } + } + + if (mReclaimedExtraSprites) { + mFreeExtraSprites |= mReclaimedExtraSprites; + mReclaimedExtraSprites = 0; + } + + // disable reclaimed real planes + disableReclaimedRealPlanes(); +} + +bool PlatfDisplayPlaneManager::setZOrderConfig(ZOrderConfig& zorderConfig) +{ + AnnDisplayPlane *annPlane; + + RETURN_FALSE_IF_NOT_INIT(); + + if (!zorderConfig.size()) { + WTRACE("No zorder config, should NOT happen"); + return false; + } + + if (!isValidZOrderConfig(zorderConfig)) { + VTRACE("Invalid z order config"); + return false; + } + + for (size_t i = 0; i < zorderConfig.size(); i++) { + DisplayPlane *plane = zorderConfig.itemAt(i); + if (!plane) { + ETRACE("no plane found in zorder config"); + return false; + } + + // reclaim plane's existing realPlane + annPlane = reinterpret_cast<AnnDisplayPlane*>(plane); + if (annPlane->getRealPlane()) { + reclaimRealPlane(annPlane->getRealPlane()); + } + + DisplayPlane *realPlane = getRealPlane(zorderConfig.getDisplayDevice(), + plane->getType(), i); + if (!realPlane) { + ETRACE("failed to get real plane"); + return false; + } + + realPlane->setZOrderConfig(zorderConfig, (void *)i); + + // TODO: check enable failure + realPlane->enable(); + + annPlane->setRealPlane(realPlane); + } + + VTRACE("dump start:"); + for (size_t i = 0; i < zorderConfig.size(); i++) { + DisplayPlane *plane = zorderConfig.itemAt(i); + AnnDisplayPlane *annPlane = reinterpret_cast<AnnDisplayPlane*>(plane); + DisplayPlane *realPlane = annPlane->getRealPlane(); + VTRACE("slot %d, plane (type = %d, idx = %d)", i, realPlane->getType(), realPlane->getIndex()); + } + VTRACE("dump end!"); + return true; +} + +bool PlatfDisplayPlaneManager::detect(int&spriteCount, + int& overlayCount, + int& primaryCount) +{ + CTRACE(); + + spriteCount = SPRITE_COUNT; + overlayCount = OVERLAY_COUNT; + primaryCount = PRIMARY_COUNT; + + return true; +} + +DisplayPlane* PlatfDisplayPlaneManager::allocPlane(int index, int type) +{ + DisplayPlane *plane = 0; + ATRACE("index = %d, type = %d", index, type); + + switch (type) { + case DisplayPlane::PLANE_PRIMARY: + plane = new AnnDisplayPlane(index, DisplayPlane::PLANE_PRIMARY, index); + break; + case DisplayPlane::PLANE_SPRITE: + plane = new AnnDisplayPlane(index, DisplayPlane::PLANE_SPRITE, 0); + break; + case DisplayPlane::PLANE_OVERLAY: + plane = new AnnDisplayPlane(index, DisplayPlane::PLANE_OVERLAY, 0); + break; + default: + ETRACE("unsupported type %d", type); + break; + } + + if (plane && !plane->initialize(DisplayPlane::MIN_DATA_BUFFER_COUNT)) { + ETRACE("failed to initialize plane."); + DEINIT_AND_DELETE_OBJ(plane); + } + + return plane; +} + +bool PlatfDisplayPlaneManager::isValidZOrderConfig(ZOrderConfig& config) +{ + // check whether it's a supported z order config + if (!config.size() || config.size() > 4) { + ETRACE("Invalid z order config. size %d", config.size()); + return false; + } + + return true; +} + +void* PlatfDisplayPlaneManager::getNativeZOrderConfig() +{ + return &mZorder; +} + +DisplayPlane* PlatfDisplayPlaneManager::getRealPlane(int dsp, + int type, int slot) +{ + uint32_t *reclaimedRealPlanes; + uint32_t *freeRealPlanes; + uint32_t possiblePlanes; + int realType; + int index; + + RETURN_NULL_IF_NOT_INIT(); + + if (dsp < 0 || dsp > IDisplayDevice::DEVICE_EXTERNAL) { + ETRACE("Invalid display device %d", dsp); + return 0; + } + + if (type < 0 || type >= DisplayPlane::PLANE_MAX) { + ETRACE("Invalid plane type %d", type); + return 0; + } + + switch (type) { + case DisplayPlane::PLANE_OVERLAY: + realType = REAL_PLANE_OVERLAY; + break; + case DisplayPlane::PLANE_PRIMARY: + case DisplayPlane::PLANE_SPRITE: + realType = REAL_PLANE_SPRITE; + break; + default: + ETRACE("Invalid plane type %d", type); + return 0; + } + + // get the possible plane candidates for this slot + switch (dsp) { + case IDisplayDevice::DEVICE_PRIMARY: + possiblePlanes = PRIMARY_ZORDER_CONFIG[realType][slot]; + break; + case IDisplayDevice::DEVICE_EXTERNAL: + possiblePlanes = EXTERNAL_ZORDER_CONFIG[realType][slot]; + break; + default: + ETRACE("Unsupported display device %d", dsp); + return 0; + } + + reclaimedRealPlanes = &mReclaimedRealPlanes[realType]; + freeRealPlanes = &mFreeRealPlanes[realType]; + + // allocate plane for this slot following an order from bottom to top + for (index = 0; index < 32; index++) { + int bit = (1 << index); + if (!(possiblePlanes & bit)) + continue; + + // try to get it from reclaimed planes + if (*reclaimedRealPlanes & bit) { + // got plane from reclaimed planes + VTRACE("acquired plane (type = %d) for slot %d on reclaimed planes " + "real index %d", type, slot, index); + *reclaimedRealPlanes &= ~bit; + return mRealPlanes[realType].itemAt(index); + } + + // try to get it from free planes + if (*freeRealPlanes & bit) { + VTRACE("acquired plane (type = %d) for slot %d on free planes " + "real index %d", type, slot, index); + *freeRealPlanes &= ~bit; + return mRealPlanes[realType].itemAt(index); + } + } + + WTRACE("failed to acquire plane (type = %d) for slot %d", type, slot); + return 0; +} + +void PlatfDisplayPlaneManager::reclaimRealPlane(DisplayPlane *plane) +{ + uint32_t *reclaimedRealPlanes; + int index; + int type, realType; + + RETURN_VOID_IF_NOT_INIT(); + + if (!plane) { + VTRACE("Invalid plane"); + return; + } + + index = plane->getIndex(); + type = plane->getType(); + + switch (type) { + case DisplayPlane::PLANE_OVERLAY: + realType = REAL_PLANE_OVERLAY; + break; + case DisplayPlane::PLANE_PRIMARY: + realType = REAL_PLANE_SPRITE; + break; + case DisplayPlane::PLANE_SPRITE: + index += PRIMARY_COUNT; + realType = REAL_PLANE_SPRITE; + break; + default: + ETRACE("Invalid plane type %d", type); + return; + } + + reclaimedRealPlanes = &mReclaimedRealPlanes[realType]; + *reclaimedRealPlanes |= (1 << index); + + VTRACE("reclaimed real plane type %d, index %d", type, index); +} + +void PlatfDisplayPlaneManager::disableReclaimedRealPlanes() +{ + uint32_t i, j; + + RETURN_VOID_IF_NOT_INIT(); + + for (i = 0; i < REAL_PLANE_MAX; i++) { + if (mReclaimedRealPlanes[i]) { + for (j = 0; j < mRealPlaneCounts[i]; j++) { + int bit = (1 << j); + + if (mReclaimedRealPlanes[i] & bit) { + DisplayPlane* plane = mRealPlanes[i].itemAt(j); + // disable plane first + plane->disable(); + // reset plane + plane->reset(); + } + } + + // merge into free bitmap + mFreeRealPlanes[i] |= mReclaimedRealPlanes[i]; + mReclaimedRealPlanes[i] = 0; + } + } +} + +} // namespace intel +} // namespace android + diff --git a/platforms/merrifield_plus/PlatfDisplayPlaneManager.h b/platforms/merrifield_plus/PlatfDisplayPlaneManager.h new file mode 100644 index 0000000..5cb323e --- /dev/null +++ b/platforms/merrifield_plus/PlatfDisplayPlaneManager.h @@ -0,0 +1,95 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef PLATF_DISPLAY_PLANE_MANAGER_H +#define PLATF_DISPLAY_PLANE_MANAGER_H + +#include <DisplayPlaneManager.h> +#include <linux/psb_drm.h> + +namespace android { +namespace intel { + +class PlatfDisplayPlaneManager : public DisplayPlaneManager { + enum { + SPRITE_COUNT = 1, + OVERLAY_COUNT = 2, + PRIMARY_COUNT = 3, + EXTRA_SPRITE_COUNT = 2, + }; +private: + enum { + REAL_PLANE_SPRITE = 0, + REAL_PLANE_OVERLAY, + REAL_PLANE_MAX, + }; +public: + PlatfDisplayPlaneManager(); + virtual ~PlatfDisplayPlaneManager(); + + bool initialize(); + void deinitialize(); + // override get sprite plane + DisplayPlane* getSpritePlane(int dsp); + // override put plane + void putPlane(int dsp, DisplayPlane& plane); + // override has free sprite + bool hasFreeSprite(int dsp); + // override reclaim plane + void reclaimPlane(int dsp, DisplayPlane& plane); + // override disable reclaimed planes + void disableReclaimedPlanes(); + // override + bool setZOrderConfig(ZOrderConfig& zorderConfig); +protected: + bool detect(int&spriteCount, int& overlayCount, int& primaryCount); + DisplayPlane* allocPlane(int index, int type); + bool isValidZOrderConfig(ZOrderConfig& zorderConfig); + void* getNativeZOrderConfig(); +private: + DisplayPlane* getRealPlane(int dsp, int type, int slot); + void reclaimRealPlane(DisplayPlane *plane); + void disableReclaimedRealPlanes(); +private: + int mExtraSpriteCount; + Vector<DisplayPlane*> mExtraSprites; + uint32_t mFreeExtraSprites; + uint32_t mReclaimedExtraSprites; + + uint32_t mFreeRealPlanes[REAL_PLANE_MAX]; + uint32_t mReclaimedRealPlanes[REAL_PLANE_MAX]; + uint32_t mRealPlaneCounts[REAL_PLANE_MAX]; + Vector<DisplayPlane*> mRealPlanes[REAL_PLANE_MAX]; + + struct intel_dc_plane_zorder mZorder; +}; + +} // namespace intel +} // namespace android + + +#endif /* PLATF_DISPLAY_PLANE_MANAGER_H */ diff --git a/platforms/merrifield_plus/PlatfExternalDevice.cpp b/platforms/merrifield_plus/PlatfExternalDevice.cpp new file mode 100644 index 0000000..a57d1e9 --- /dev/null +++ b/platforms/merrifield_plus/PlatfExternalDevice.cpp @@ -0,0 +1,80 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#include <HwcTrace.h> +#include <PlatfExternalDevice.h> +#include <common/VsyncControl.h> +#include <common/BlankControl.h> +#include <common/HotplugControl.h> +#include <common/HdcpControl.h> +#include <common/PrepareListener.h> + + +namespace android { +namespace intel { + +PlatfExternalDevice::PlatfExternalDevice(Hwcomposer& hwc, + DisplayPlaneManager& dpm) + : ExternalDevice(hwc, dpm) +{ + CTRACE(); +} + +PlatfExternalDevice::~PlatfExternalDevice() +{ + CTRACE(); +} + +IVsyncControl* PlatfExternalDevice::createVsyncControl() +{ + return new VsyncControl(); +} + +IBlankControl* PlatfExternalDevice::createBlankControl() +{ + return new BlankControl(); +} + +IPrepareListener* PlatfExternalDevice::createPrepareListener() +{ + return new PrepareListener(); +} + +IHotplugControl* PlatfExternalDevice::createHotplugControl() +{ + return new HotplugControl(); +} + +IHdcpControl* PlatfExternalDevice::createHdcpControl() +{ + return new HdcpControl(); +} + +} // namespace intel +} // namespace android + + diff --git a/platforms/merrifield_plus/PlatfExternalDevice.h b/platforms/merrifield_plus/PlatfExternalDevice.h new file mode 100644 index 0000000..4182a29 --- /dev/null +++ b/platforms/merrifield_plus/PlatfExternalDevice.h @@ -0,0 +1,53 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef PLATF_EXTERNAL_DEVICE_H +#define PLATF_EXTERNAL_DEVICE_H + +#include <hal_public.h> +#include <ExternalDevice.h> + +namespace android { +namespace intel { + +class PlatfExternalDevice : public ExternalDevice { +public: + PlatfExternalDevice(Hwcomposer& hwc, + DisplayPlaneManager& dpm); + virtual ~PlatfExternalDevice(); + +protected: + IVsyncControl* createVsyncControl(); + IBlankControl* createBlankControl(); + IPrepareListener* createPrepareListener(); + IHotplugControl* createHotplugControl(); + IHdcpControl* createHdcpControl(); +}; + +} +} +#endif /* PLATF_EXTERNAL_DEVICE_H */ diff --git a/platforms/merrifield_plus/PlatfHwcomposer.cpp b/platforms/merrifield_plus/PlatfHwcomposer.cpp new file mode 100644 index 0000000..b9e078f --- /dev/null +++ b/platforms/merrifield_plus/PlatfHwcomposer.cpp @@ -0,0 +1,100 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#include <hal_public.h> +#include <HwcTrace.h> +#include <anniedale/AnnDisplayContext.h> +#include <PlatfDisplayPlaneManager.h> +#include <PlatfBufferManager.h> +#include <IDisplayDevice.h> +#include <PlatfPrimaryDevice.h> +#include <PlatfExternalDevice.h> +#include <PlatfVirtualDevice.h> +#include <PlatfHwcomposer.h> + + + +namespace android { +namespace intel { + +PlatfHwcomposer::PlatfHwcomposer() + : Hwcomposer() +{ + CTRACE(); +} + +PlatfHwcomposer::~PlatfHwcomposer() +{ + CTRACE(); +} + +DisplayPlaneManager* PlatfHwcomposer::createDisplayPlaneManager() +{ + CTRACE(); + return (new PlatfDisplayPlaneManager()); +} + +BufferManager* PlatfHwcomposer::createBufferManager() +{ + CTRACE(); + return (new PlatfBufferManager()); +} + +IDisplayDevice* PlatfHwcomposer::createDisplayDevice(int disp, + DisplayPlaneManager& dpm) +{ + CTRACE(); + + switch (disp) { + case IDisplayDevice::DEVICE_PRIMARY: + return new PlatfPrimaryDevice(*this, dpm); + case IDisplayDevice::DEVICE_EXTERNAL: + return new PlatfExternalDevice(*this, dpm); +#ifdef INTEL_WIDI_MERRIFIELD + case IDisplayDevice::DEVICE_VIRTUAL: + return new PlatfVirtualDevice(*this, dpm); +#endif + default: + ETRACE("invalid display device %d", disp); + return NULL; + } +} + +IDisplayContext* PlatfHwcomposer::createDisplayContext() +{ + CTRACE(); + return new AnnDisplayContext(); +} + +Hwcomposer* Hwcomposer::createHwcomposer() +{ + CTRACE(); + return new PlatfHwcomposer(); +} + +} //namespace intel +} //namespace android diff --git a/platforms/merrifield_plus/PlatfHwcomposer.h b/platforms/merrifield_plus/PlatfHwcomposer.h new file mode 100644 index 0000000..b24ab9e --- /dev/null +++ b/platforms/merrifield_plus/PlatfHwcomposer.h @@ -0,0 +1,52 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef PLATF_HWCOMPOSER_H +#define PLATF_HWCOMPOSER_H + +#include <hal_public.h> +#include <Hwcomposer.h> + +namespace android { +namespace intel { + +class PlatfHwcomposer : public Hwcomposer { +public: + PlatfHwcomposer(); + virtual ~PlatfHwcomposer(); + +protected: + DisplayPlaneManager* createDisplayPlaneManager(); + BufferManager* createBufferManager(); + IDisplayDevice* createDisplayDevice(int disp, DisplayPlaneManager& dpm); + IDisplayContext* createDisplayContext(); +}; + +} //namespace intel +} //namespace android + +#endif /* PLATF_HWCOMPOSER_H */ diff --git a/platforms/merrifield_plus/PlatfPrimaryDevice.cpp b/platforms/merrifield_plus/PlatfPrimaryDevice.cpp new file mode 100644 index 0000000..cb82bc6 --- /dev/null +++ b/platforms/merrifield_plus/PlatfPrimaryDevice.cpp @@ -0,0 +1,68 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#include <HwcTrace.h> +#include <PlatfPrimaryDevice.h> +#include <common/VsyncControl.h> +#include <common/BlankControl.h> +#include <common/PrepareListener.h> + + +namespace android { +namespace intel { + +PlatfPrimaryDevice::PlatfPrimaryDevice(Hwcomposer& hwc, + DisplayPlaneManager& dpm) + : PrimaryDevice(hwc, dpm) +{ + CTRACE(); +} + +PlatfPrimaryDevice::~PlatfPrimaryDevice() +{ + CTRACE(); +} + +IVsyncControl* PlatfPrimaryDevice::createVsyncControl() +{ + return new VsyncControl(); +} + +IBlankControl* PlatfPrimaryDevice::createBlankControl() +{ + return new BlankControl(); +} + +IPrepareListener* PlatfPrimaryDevice::createPrepareListener() +{ + return new PrepareListener(); +} + +} // namespace intel +} // namespace android + + diff --git a/platforms/merrifield_plus/PlatfPrimaryDevice.h b/platforms/merrifield_plus/PlatfPrimaryDevice.h new file mode 100644 index 0000000..b564f4c --- /dev/null +++ b/platforms/merrifield_plus/PlatfPrimaryDevice.h @@ -0,0 +1,51 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef PLATF_PRIMARY_DEVICE_H +#define PLATF_PRIMARY_DEVICE_H + +#include <hal_public.h> +#include <PrimaryDevice.h> + +namespace android { +namespace intel { + +class PlatfPrimaryDevice : public PrimaryDevice { +public: + PlatfPrimaryDevice(Hwcomposer& hwc, + DisplayPlaneManager& dpm); + virtual ~PlatfPrimaryDevice(); + +protected: + IVsyncControl* createVsyncControl(); + IBlankControl* createBlankControl(); + IPrepareListener* createPrepareListener(); +}; + +} +} +#endif /* PLATF_PRIMARY_DEVICE_H */ diff --git a/platforms/merrifield_plus/PlatfVirtualDevice.cpp b/platforms/merrifield_plus/PlatfVirtualDevice.cpp new file mode 100644 index 0000000..a6ac4cb --- /dev/null +++ b/platforms/merrifield_plus/PlatfVirtualDevice.cpp @@ -0,0 +1,58 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#include <HwcTrace.h> +#include <Hwcomposer.h> +#include <DisplayPlaneManager.h> +#include <PlatfVirtualDevice.h> +#include <common/VideoPayloadManager.h> + +namespace android { +namespace intel { + +PlatfVirtualDevice::PlatfVirtualDevice(Hwcomposer& hwc, + DisplayPlaneManager& dpm) + : VirtualDevice(hwc, dpm) +{ + CTRACE(); +} + +PlatfVirtualDevice::~PlatfVirtualDevice() +{ + CTRACE(); +} + +IVideoPayloadManager* PlatfVirtualDevice::createVideoPayloadManager() +{ + return new VideoPayloadManager(); +} + + +} // namespace intel +} // namespace android + + diff --git a/platforms/merrifield_plus/PlatfVirtualDevice.h b/platforms/merrifield_plus/PlatfVirtualDevice.h new file mode 100644 index 0000000..63ec7f9 --- /dev/null +++ b/platforms/merrifield_plus/PlatfVirtualDevice.h @@ -0,0 +1,49 @@ +/* + * Copyright © 2012 Intel Corporation + * All rights reserved. + * + * 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 (including the next + * paragraph) 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. + * + * Authors: + * Jackie Li <yaodong.li@intel.com> + * + */ +#ifndef PLATF_VIRTUAL_DEVICE_H +#define PLATF_VIRTUAL_DEVICE_H + +#include <hal_public.h> +#include <VirtualDevice.h> + +namespace android { +namespace intel { + +class IVideoPayloadManager; + +class PlatfVirtualDevice : public VirtualDevice { +public: + PlatfVirtualDevice(Hwcomposer& hwc, + DisplayPlaneManager& dpm); + virtual ~PlatfVirtualDevice(); + virtual IVideoPayloadManager* createVideoPayloadManager(); +}; + +} +} +#endif /* PLATF_VIRTUAL_DEVICE_H */ |