display: Remove framebuffer HAL usage
This patch removes the usage of the framebuffer HAL which is
deprecated in JB MR1 onwards. The code is left for compatibility
such as conformance tests but it is unused for normal display
usage.
Change-Id: If98133bdaa759cdc41d4503ff695b225ee43cb6f
Conflicts:
libhwcomposer/hwc_utils.cpp
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 30555fa..540040a 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -25,10 +25,9 @@
#include <cutils/atomic.h>
#include <EGL/egl.h>
#include <utils/Trace.h>
-
+#include <sys/ioctl.h>
#include <overlay.h>
#include <overlayRotator.h>
-#include <fb_priv.h>
#include <mdp_version.h>
#include "hwc_utils.h"
#include "hwc_video.h"
@@ -122,6 +121,17 @@
}
}
+static int display_commit(hwc_context_t *ctx, int dpy) {
+ struct mdp_display_commit commit_info;
+ memset(&commit_info, 0, sizeof(struct mdp_display_commit));
+ commit_info.flags = MDP_DISPLAY_COMMIT_OVERLAY;
+ if(ioctl(ctx->dpyAttr[dpy].fd, MSMFB_DISPLAY_COMMIT, &commit_info) == -1) {
+ ALOGE("%s: MSMFB_DISPLAY_COMMIT for primary failed", __FUNCTION__);
+ return -errno;
+ }
+ return 0;
+}
+
static int hwc_prepare_primary(hwc_composer_device_1 *dev,
hwc_display_contents_1_t *list) {
hwc_context_t* ctx = (hwc_context_t*)(dev);
@@ -217,8 +227,6 @@
{
int ret = 0;
hwc_context_t* ctx = (hwc_context_t*)(dev);
- private_module_t* m = reinterpret_cast<private_module_t*>(
- ctx->mFbDev->common.module);
pthread_mutex_lock(&ctx->vstate.lock);
switch(event) {
case HWC_EVENT_VSYNC:
@@ -243,8 +251,7 @@
{
ATRACE_CALL();
hwc_context_t* ctx = (hwc_context_t*)(dev);
- private_module_t* m = reinterpret_cast<private_module_t*>(
- ctx->mFbDev->common.module);
+
Locker::Autolock _l(ctx->mBlankLock);
int ret = 0;
ALOGD("%s: %s display: %d", __FUNCTION__,
@@ -255,13 +262,13 @@
ctx->mOverlay->configBegin();
ctx->mOverlay->configDone();
ctx->mRotMgr->clear();
- ret = ioctl(m->framebuffer->fd, FBIOBLANK, FB_BLANK_POWERDOWN);
+ ret = ioctl(ctx->dpyAttr[dpy].fd, FBIOBLANK,FB_BLANK_POWERDOWN);
if(ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected == true) {
// Surfaceflinger does not send Blank/unblank event to hwc
// for virtual display, handle it explicitly when blank for
// primary is invoked, so that any pipes unset get committed
- if (!ctx->mExtDisplay->post()) {
+ if (display_commit(ctx, HWC_DISPLAY_VIRTUAL) < 0) {
ret = -1;
ALOGE("%s:post failed for virtual display !!",
__FUNCTION__);
@@ -270,7 +277,7 @@
}
}
} else {
- ret = ioctl(m->framebuffer->fd, FBIOBLANK, FB_BLANK_UNBLANK);
+ ret = ioctl(ctx->dpyAttr[dpy].fd, FBIOBLANK, FB_BLANK_UNBLANK);
if(ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected == true) {
ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isActive = !blank;
}
@@ -278,12 +285,11 @@
break;
case HWC_DISPLAY_EXTERNAL:
if(blank) {
- // External post commits the changes to display
- // Call this on blank, so that any pipe unsets gets committed
- if (!ctx->mExtDisplay->post()) {
+ // call external framebuffer commit on blank,
+ // so that any pipe unsets gets committed
+ if (display_commit(ctx, dpy) < 0) {
ret = -1;
- ALOGE("%s:post failed for external display !! ",
- __FUNCTION__);
+ ALOGE("%s:post failed for external display !! ", __FUNCTION__);
}
} else {
}
@@ -311,8 +317,6 @@
int param, int* value)
{
hwc_context_t* ctx = (hwc_context_t*)(dev);
- private_module_t* m = reinterpret_cast<private_module_t*>(
- ctx->mFbDev->common.module);
int supported = HWC_DISPLAY_PRIMARY_BIT;
switch (param) {
@@ -320,10 +324,6 @@
// Not supported for now
value[0] = 0;
break;
- case HWC_VSYNC_PERIOD: //Not used for hwc > 1.1
- value[0] = m->fps;
- ALOGI("fps: %d", value[0]);
- break;
case HWC_DISPLAY_TYPES_SUPPORTED:
if(ctx->mMDP.hasOverlay)
supported |= HWC_DISPLAY_EXTERNAL_BIT;
@@ -336,6 +336,7 @@
}
+
static int hwc_set_primary(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
ATRACE_CALL();
int ret = 0;
@@ -375,9 +376,10 @@
}
}
}
- if (ctx->mFbDev->post(ctx->mFbDev, fbLayer->handle)) {
- ALOGE("%s: ctx->mFbDev->post fail!", __FUNCTION__);
- ret = -1;
+
+ if (display_commit(ctx, dpy) < 0) {
+ ALOGE("%s: display commit fail!", __FUNCTION__);
+ return -1;
}
}
@@ -425,9 +427,10 @@
ret = -1;
}
}
- if (!ctx->mExtDisplay->post()) {
- ALOGE("%s: ctx->mExtDisplay->post fail!", __FUNCTION__);
- ret = -1;
+
+ if (display_commit(ctx, dpy) < 0) {
+ ALOGE("%s: display commit fail!", __FUNCTION__);
+ return -1;
}
}
diff --git a/libhwcomposer/hwc_fbupdate.cpp b/libhwcomposer/hwc_fbupdate.cpp
index e79523d..f7fce09 100644
--- a/libhwcomposer/hwc_fbupdate.cpp
+++ b/libhwcomposer/hwc_fbupdate.cpp
@@ -20,7 +20,6 @@
#define DEBUG_FBUPDATE 0
#include <gralloc_priv.h>
-#include <fb_priv.h>
#include "hwc_fbupdate.h"
namespace qhwc {
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 11f7dc5..496dc21 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -23,7 +23,6 @@
#include <EGL/egl.h>
#include <cutils/properties.h>
#include <gralloc_priv.h>
-#include <fb_priv.h>
#include <overlay.h>
#include <overlayRotator.h>
#include "hwc_utils.h"
@@ -46,25 +45,59 @@
namespace qhwc {
-// Opens Framebuffer device
-static void openFramebufferDevice(hwc_context_t *ctx)
+static int openFramebufferDevice(hwc_context_t *ctx)
{
- hw_module_t const *module;
- if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
- framebuffer_open(module, &(ctx->mFbDev));
- private_module_t* m = reinterpret_cast<private_module_t*>(
- ctx->mFbDev->common.module);
- //xres, yres may not be 32 aligned
- ctx->dpyAttr[HWC_DISPLAY_PRIMARY].stride = m->finfo.line_length /
- (m->info.xres/8);
- ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres = m->info.xres;
- ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres = m->info.yres;
- ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xdpi = ctx->mFbDev->xdpi;
- ctx->dpyAttr[HWC_DISPLAY_PRIMARY].ydpi = ctx->mFbDev->ydpi;
- ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period =
- 1000000000l / ctx->mFbDev->fps;
- ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd = openFb(HWC_DISPLAY_PRIMARY);
+ struct fb_fix_screeninfo finfo;
+ struct fb_var_screeninfo info;
+
+ int fb_fd = openFb(HWC_DISPLAY_PRIMARY);
+
+ if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &info) == -1)
+ return -errno;
+
+ if (int(info.width) <= 0 || int(info.height) <= 0) {
+ // the driver doesn't return that information
+ // default to 160 dpi
+ info.width = ((info.xres * 25.4f)/160.0f + 0.5f);
+ info.height = ((info.yres * 25.4f)/160.0f + 0.5f);
}
+
+ float xdpi = (info.xres * 25.4f) / info.width;
+ float ydpi = (info.yres * 25.4f) / info.height;
+
+#ifdef MSMFB_METADATA_GET
+ struct msmfb_metadata metadata;
+ memset(&metadata, 0 , sizeof(metadata));
+ metadata.op = metadata_op_frame_rate;
+
+ if (ioctl(fb_fd, MSMFB_METADATA_GET, &metadata) == -1) {
+ ALOGE("Error retrieving panel frame rate");
+ return -errno;
+ }
+
+ float fps = metadata.data.panel_frame_rate;
+#else
+ //XXX: Remove reserved field usage on all baselines
+ //The reserved[3] field is used to store FPS by the driver.
+ float fps = info.reserved[3] & 0xFF;
+#endif
+
+ if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &finfo) == -1)
+ return -errno;
+
+ if (finfo.smem_len <= 0)
+ return -errno;
+
+ ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd = fb_fd;
+ //xres, yres may not be 32 aligned
+ ctx->dpyAttr[HWC_DISPLAY_PRIMARY].stride = finfo.line_length /(info.xres/8);
+ ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres = info.xres;
+ ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres = info.yres;
+ ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xdpi = xdpi;
+ ctx->dpyAttr[HWC_DISPLAY_PRIMARY].ydpi = ydpi;
+ ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period = 1000000000l / fps;
+
+ return 0;
}
void initContext(hwc_context_t *ctx)
@@ -143,9 +176,7 @@
}
}
- if(ctx->mFbDev) {
- framebuffer_close(ctx->mFbDev);
- ctx->mFbDev = NULL;
+ if(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd) {
close(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd);
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd = -1;
}
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index 67745f4..7221c13 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -29,6 +29,7 @@
#include <utils/String8.h>
#include "qdMetaData.h"
#include <overlayUtils.h>
+#include <linux/fb.h>
#define ALIGN_TO(x, align) (((x) + ((align)-1)) & ~((align)-1))
#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
@@ -44,7 +45,6 @@
//Fwrd decls
struct hwc_context_t;
-struct framebuffer_device_t;
namespace ovutils = overlay::utils;
@@ -262,8 +262,6 @@
struct hwc_context_t {
hwc_composer_device_1_t device;
const hwc_procs_t* proc;
- //Framebuffer device
- framebuffer_device_t *mFbDev;
//CopyBit objects
qhwc::CopyBit *mCopyBit[MAX_DISPLAYS];