Skip to content

Commit

Permalink
hwc: Update to new API
Browse files Browse the repository at this point in the history
* Updates HWC to use the Jellybean MR1 API
* Remove qcom_ui which was using parts of the old API

Change-Id: I663363547b193d2318aae88f2256a9baed1e3d4b
  • Loading branch information
naseer authored and Iliyan Malchev committed Aug 14, 2012
1 parent b90d091 commit 5b6708a
Show file tree
Hide file tree
Showing 16 changed files with 165 additions and 1,324 deletions.
116 changes: 69 additions & 47 deletions libhwcomposer/hwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ hwc_module_t HAL_MODULE_INFO_SYM = {
/*
* Save callback functions registered to HWC
*/
static void hwc_registerProcs(struct hwc_composer_device* dev,
static void hwc_registerProcs(struct hwc_composer_device_1* dev,
hwc_procs_t const* procs)
{
hwc_context_t* ctx = (hwc_context_t*)(dev);
Expand All @@ -72,7 +72,8 @@ static void hwc_registerProcs(struct hwc_composer_device* dev,
ctx->device.reserved_proc[0] = (void*)procs;
}

static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list)
static int hwc_prepare(hwc_composer_device_1 *dev, size_t numDisplays,
hwc_display_contents_1_t** displays)
{
hwc_context_t* ctx = (hwc_context_t*)(dev);
ctx->overlayInUse = false;
Expand All @@ -81,40 +82,46 @@ static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list)
ctx->qbuf->unlockAllPrevious();
return 0;

if (LIKELY(list)) {
//reset for this draw round
VideoOverlay::reset();
ExtOnly::reset();

getLayerStats(ctx, list);
if(VideoOverlay::prepare(ctx, list)) {
ctx->overlayInUse = true;
//Nothing here
} else if(ExtOnly::prepare(ctx, list)) {
ctx->overlayInUse = true;
} else if(UIMirrorOverlay::prepare(ctx, list)) {
ctx->overlayInUse = true;
} else if(MDPComp::configure(dev, list)) {
ctx->overlayInUse = true;
} else if (0) {
//Other features
ctx->overlayInUse = true;
} else { // Else set this flag to false, otherwise video cases
// fail in non-overlay targets.
ctx->overlayInUse = false;
for (uint32_t i = 0; i <numDisplays; i++) {
hwc_display_contents_1_t* list = displays[i];
ctx->dpys[i] = list->dpy;
//XXX: Actually handle the multiple displays
if (LIKELY(list)) {
//reset for this draw round
VideoOverlay::reset();
ExtOnly::reset();

getLayerStats(ctx, list);
if(VideoOverlay::prepare(ctx, list)) {
ctx->overlayInUse = true;
//Nothing here
} else if(ExtOnly::prepare(ctx, list)) {
ctx->overlayInUse = true;
} else if(UIMirrorOverlay::prepare(ctx, list)) {
ctx->overlayInUse = true;
} else if(MDPComp::configure(dev, list)) {
ctx->overlayInUse = true;
} else if (0) {
//Other features
ctx->overlayInUse = true;
} else { // Else set this flag to false, otherwise video cases
// fail in non-overlay targets.
ctx->overlayInUse = false;
}
}
}

return 0;
}

static int hwc_eventControl(struct hwc_composer_device* dev,
static int hwc_eventControl(struct hwc_composer_device_1* dev, int dpy,
int event, int enabled)
{
int ret = 0;
hwc_context_t* ctx = (hwc_context_t*)(dev);
private_module_t* m = reinterpret_cast<private_module_t*>(
ctx->mFbDev->common.module);
//XXX: Handle dpy
switch(event) {
case HWC_EVENT_VSYNC:
if(ioctl(m->framebuffer->fd, MSMFB_OVERLAY_VSYNC_CTRL, &enabled) < 0)
Expand All @@ -130,7 +137,18 @@ static int hwc_eventControl(struct hwc_composer_device* dev,
return ret;
}

static int hwc_query(struct hwc_composer_device* dev,
static int hwc_blank(struct hwc_composer_device_1* dev, int dpy, int blank)
{
//XXX: Handle based on dpy
if(blank) {
hwc_context_t* ctx = (hwc_context_t*)(dev);
ctx->mOverlay->setState(ovutils::OV_CLOSED);
ctx->qbuf->unlockAllPrevious();
}
return 0;
}

static int hwc_query(struct hwc_composer_device_1* dev,
int param, int* value)
{
hwc_context_t* ctx = (hwc_context_t*)(dev);
Expand All @@ -153,29 +171,32 @@ static int hwc_query(struct hwc_composer_device* dev,

}

static int hwc_set(hwc_composer_device_t *dev,
hwc_display_t dpy,
hwc_surface_t sur,
hwc_layer_list_t* list)
static int hwc_set(hwc_composer_device_1 *dev,
size_t numDisplays,
hwc_display_contents_1_t** displays)
{
int ret = 0;
hwc_context_t* ctx = (hwc_context_t*)(dev);
if (LIKELY(list)) {
VideoOverlay::draw(ctx, list);
ExtOnly::draw(ctx, list);
MDPComp::draw(ctx, list);
EGLBoolean sucess = eglSwapBuffers((EGLDisplay)dpy, (EGLSurface)sur);
UIMirrorOverlay::draw(ctx);
if(ctx->mExtDisplay->getExternalDisplay())
ctx->mExtDisplay->commit();
} else {
ctx->mOverlay->setState(ovutils::OV_CLOSED);
ctx->qbuf->unlockAllPrevious();
}

if(!ctx->overlayInUse)
ctx->mOverlay->setState(ovutils::OV_CLOSED);
for (uint32_t i = 0; i <numDisplays; i++) {
hwc_display_contents_1_t* list = displays[i];
//XXX: Actually handle the multiple displays
if (LIKELY(list)) {
VideoOverlay::draw(ctx, list);
ExtOnly::draw(ctx, list);
MDPComp::draw(ctx, list);
EGLBoolean success = eglSwapBuffers((EGLDisplay)list->dpy,
(EGLSurface)list->sur);
UIMirrorOverlay::draw(ctx);
if(ctx->mExtDisplay->getExternalDisplay())
ctx->mExtDisplay->commit();
} else {
ctx->mOverlay->setState(ovutils::OV_CLOSED);
ctx->qbuf->unlockAllPrevious();
}

if(!ctx->overlayInUse)
ctx->mOverlay->setState(ovutils::OV_CLOSED);
}
return ret;
}

Expand Down Expand Up @@ -205,13 +226,14 @@ static int hwc_device_open(const struct hw_module_t* module, const char* name,
initContext(dev);

//Setup HWC methods
hwc_methods_t *methods;
methods = (hwc_methods_t *)malloc(sizeof(*methods));
hwc_methods_1_t *methods;
methods = (hwc_methods_1_t *) malloc(sizeof(*methods));
memset(methods, 0, sizeof(*methods));
methods->eventControl = hwc_eventControl;
methods->blank = hwc_blank;

dev->device.common.tag = HARDWARE_DEVICE_TAG;
dev->device.common.version = HWC_DEVICE_API_VERSION_0_3;
dev->device.common.version = HWC_DEVICE_API_VERSION_1_0;
dev->device.common.module = const_cast<hw_module_t*>(module);
dev->device.common.close = hwc_device_close;
dev->device.prepare = hwc_prepare;
Expand Down
14 changes: 7 additions & 7 deletions libhwcomposer/hwc_copybit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ bool CopyBit::canUseCopybitForYUV(hwc_context_t *ctx) {
return true;
}

bool CopyBit::canUseCopybitForRGB(hwc_context_t *ctx, hwc_layer_list_t *list) {
bool CopyBit::canUseCopybitForRGB(hwc_context_t *ctx, hwc_display_contents_1_t *list) {
int compositionType =
qdutils::QCCompositionType::getInstance().getCompositionType();

Expand Down Expand Up @@ -154,7 +154,7 @@ bool CopyBit::canUseCopybitForRGB(hwc_context_t *ctx, hwc_layer_list_t *list) {
return false;
}

unsigned int CopyBit::getRGBRenderingArea(const hwc_layer_list_t *list) {
unsigned int CopyBit::getRGBRenderingArea(const hwc_display_contents_1_t *list) {
//Calculates total rendering area for RGB layers
unsigned int renderArea = 0;
unsigned int w=0, h=0;
Expand All @@ -170,7 +170,7 @@ unsigned int CopyBit::getRGBRenderingArea(const hwc_layer_list_t *list) {
return renderArea;
}

bool CopyBit::prepare(hwc_context_t *ctx, hwc_layer_list_t *list) {
bool CopyBit::prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list) {

int compositionType =
qdutils::QCCompositionType::getInstance().getCompositionType();
Expand Down Expand Up @@ -209,7 +209,7 @@ bool CopyBit::prepare(hwc_context_t *ctx, hwc_layer_list_t *list) {
return true;
}

bool CopyBit::draw(hwc_context_t *ctx, hwc_layer_list_t *list, EGLDisplay dpy,
bool CopyBit::draw(hwc_context_t *ctx, hwc_display_contents_1_t *list, EGLDisplay dpy,
EGLSurface sur){
// draw layers marked for COPYBIT
int retVal = true;
Expand All @@ -228,7 +228,7 @@ bool CopyBit::draw(hwc_context_t *ctx, hwc_layer_list_t *list, EGLDisplay dpy,
return true;
}

int CopyBit::drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_t *layer,
int CopyBit::drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_1_t *layer,
EGLDisplay dpy,
EGLSurface surface,
functype_eglGetRenderBufferANDROID& LINK_eglGetRenderBufferANDROID,
Expand Down Expand Up @@ -459,7 +459,7 @@ int CopyBit::drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_t *layer,
return err;
}

void CopyBit::getLayerResolution(const hwc_layer_t* layer,
void CopyBit::getLayerResolution(const hwc_layer_1_t* layer,
unsigned int& width, unsigned int& height)
{
hwc_rect_t displayFrame = layer->displayFrame;
Expand All @@ -468,7 +468,7 @@ void CopyBit::getLayerResolution(const hwc_layer_t* layer,
height = displayFrame.bottom - displayFrame.top;
}

bool CopyBit::validateParams(hwc_context_t *ctx, const hwc_layer_list_t *list) {
bool CopyBit::validateParams(hwc_context_t *ctx, const hwc_display_contents_1_t *list) {
//Validate parameters
if (!ctx) {
ALOGE("%s:Invalid HWC context", __FUNCTION__);
Expand Down
16 changes: 8 additions & 8 deletions libhwcomposer/hwc_copybit.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,28 @@ typedef EGLSurface (*functype_eglGetCurrentSurface)(EGLint readdraw);
class CopyBit {
public:
//Sets up members and prepares copybit if conditions are met
static bool prepare(hwc_context_t *ctx, hwc_layer_list_t *list);
static bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
//Draws layer if the layer is set for copybit in prepare
static bool draw(hwc_context_t *ctx, hwc_layer_list_t *list, EGLDisplay dpy,
static bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list, EGLDisplay dpy,
EGLSurface sur);
//Receives data from hwc
static void setStats(int yuvCount, int yuvLayerIndex, bool isYuvLayerSkip);

static void updateEglHandles(void*);
static int drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_t *layer,
static int drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_1_t *layer,
EGLDisplay dpy, EGLSurface surface,
functype_eglGetRenderBufferANDROID& LINK_eglGetRenderBufferANDROID,
functype_eglGetCurrentSurface LINK_eglGetCurrentSurface);
static bool canUseCopybitForYUV (hwc_context_t *ctx);
static bool canUseCopybitForRGB (hwc_context_t *ctx,
hwc_layer_list_t *list);
hwc_display_contents_1_t *list);
static bool validateParams (hwc_context_t *ctx,
const hwc_layer_list_t *list);
const hwc_display_contents_1_t *list);
static void closeEglLib();
static void openEglLibAndGethandle();
private:
//Marks layer flags if this feature is used
static void markFlags(hwc_layer_t *layer);
static void markFlags(hwc_layer_1_t *layer);
//returns yuv count
static int getYuvCount();

Expand All @@ -78,9 +78,9 @@ class CopyBit {
static functype_eglGetRenderBufferANDROID LINK_eglGetRenderBufferANDROID;
static functype_eglGetCurrentSurface LINK_eglGetCurrentSurface;

static unsigned int getRGBRenderingArea (const hwc_layer_list_t *list);
static unsigned int getRGBRenderingArea (const hwc_display_contents_1_t *list);

static void getLayerResolution(const hwc_layer_t* layer,
static void getLayerResolution(const hwc_layer_1_t* layer,
unsigned int &width, unsigned int& height);
};

Expand Down
10 changes: 5 additions & 5 deletions libhwcomposer/hwc_extonly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool ExtOnly::sIsExtBlock = false;
bool ExtOnly::sIsModeOn = false;

//Cache stats, figure out the state, config overlay
bool ExtOnly::prepare(hwc_context_t *ctx, hwc_layer_list_t *list) {
bool ExtOnly::prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list) {
sIsModeOn = false;
if(!ctx->mMDP.hasOverlay) {
ALOGD_IF(EXTONLY_DEBUG,"%s, this hw doesnt support overlay",
Expand All @@ -44,7 +44,7 @@ bool ExtOnly::prepare(hwc_context_t *ctx, hwc_layer_list_t *list) {
chooseState(ctx);
//if the state chosen above is CLOSED, skip this block.
if(sState != ovutils::OV_CLOSED) {
hwc_layer_t *extLayer = &list->hwLayers[sExtIndex];
hwc_layer_1_t *extLayer = &list->hwLayers[sExtIndex];
if(configure(ctx, extLayer)) {
markFlags(extLayer);
sIsModeOn = true;
Expand Down Expand Up @@ -75,7 +75,7 @@ void ExtOnly::chooseState(hwc_context_t *ctx) {
ovutils::getStateString(sState));
}

void ExtOnly::markFlags(hwc_layer_t *layer) {
void ExtOnly::markFlags(hwc_layer_1_t *layer) {
switch(sState) {
case ovutils::OV_DUAL_DISP:
layer->compositionType = HWC_OVERLAY;
Expand All @@ -85,7 +85,7 @@ void ExtOnly::markFlags(hwc_layer_t *layer) {
}
}

bool ExtOnly::configure(hwc_context_t *ctx, hwc_layer_t *layer) {
bool ExtOnly::configure(hwc_context_t *ctx, hwc_layer_1_t *layer) {

overlay::Overlay& ov = *(ctx->mOverlay);
ov.setState(sState);
Expand Down Expand Up @@ -121,7 +121,7 @@ bool ExtOnly::configure(hwc_context_t *ctx, hwc_layer_t *layer) {
return true;
}

bool ExtOnly::draw(hwc_context_t *ctx, hwc_layer_list_t *list)
bool ExtOnly::draw(hwc_context_t *ctx, hwc_display_contents_1_t *list)
{
if(!sIsModeOn || sExtIndex == -1) {
return true;
Expand Down
8 changes: 4 additions & 4 deletions libhwcomposer/hwc_extonly.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ namespace qhwc {
class ExtOnly {
public:
//Sets up members and prepares overlay if conditions are met
static bool prepare(hwc_context_t *ctx, hwc_layer_list_t *list);
static bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
//Draws layer if this feature is on
static bool draw(hwc_context_t *ctx, hwc_layer_list_t *list);
static bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
//Receives data from hwc
static void setStats(int extCount, int extIndex, bool isExtBlock);
//resets values
Expand All @@ -39,9 +39,9 @@ class ExtOnly {
//Choose an appropriate overlay state based on conditions
static void chooseState(hwc_context_t *ctx);
//Configures overlay
static bool configure(hwc_context_t *ctx, hwc_layer_t *layer);
static bool configure(hwc_context_t *ctx, hwc_layer_1_t *layer);
//Marks layer flags if this feature is used
static void markFlags(hwc_layer_t *layer);
static void markFlags(hwc_layer_1_t *layer);
//returns ext-only count
static int getExtCount();

Expand Down
Loading

0 comments on commit 5b6708a

Please sign in to comment.