diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:43 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:43 -0800 |
commit | f013e1afd1e68af5e3b868c26a653bbfb39538f8 (patch) | |
tree | 7ad6c8fd9c7b55f4b4017171dec1cb760bbd26bf /libs/surfaceflinger/DisplayHardware | |
parent | e70cfafe580c6f2994c4827cd8a534aabf3eb05c (diff) | |
download | frameworks_base-f013e1afd1e68af5e3b868c26a653bbfb39538f8.zip frameworks_base-f013e1afd1e68af5e3b868c26a653bbfb39538f8.tar.gz frameworks_base-f013e1afd1e68af5e3b868c26a653bbfb39538f8.tar.bz2 |
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'libs/surfaceflinger/DisplayHardware')
3 files changed, 52 insertions, 24 deletions
diff --git a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp index 5dd9446..cd72179 100644 --- a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp +++ b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp @@ -19,6 +19,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <math.h> #include <GLES/egl.h> @@ -27,7 +28,9 @@ #include <ui/EGLDisplaySurface.h> #include "DisplayHardware/DisplayHardware.h" -#include "ui/BlitHardware.h" + +#include <hardware/copybit.h> +#include <hardware/overlay.h> using namespace android; @@ -91,19 +94,13 @@ DisplayHardware::~DisplayHardware() fini(); } -float DisplayHardware::getDpiX() const { return mDpiX; } -float DisplayHardware::getDpiY() const { return mDpiY; } -float DisplayHardware::getRefreshRate() const { return mRefreshRate; } - -int DisplayHardware::getWidth() const { - return mWidth; -} -int DisplayHardware::getHeight() const { - return mHeight; -} -PixelFormat DisplayHardware::getFormat() const { - return mFormat; -} +float DisplayHardware::getDpiX() const { return mDpiX; } +float DisplayHardware::getDpiY() const { return mDpiY; } +float DisplayHardware::getDensity() const { return mDensity; } +float DisplayHardware::getRefreshRate() const { return mRefreshRate; } +int DisplayHardware::getWidth() const { return mWidth; } +int DisplayHardware::getHeight() const { return mHeight; } +PixelFormat DisplayHardware::getFormat() const { return mFormat; } void DisplayHardware::init(uint32_t dpy) { @@ -195,6 +192,12 @@ void DisplayHardware::init(uint32_t dpy) mDpiY = 25.4f * float(value)/EGL_DISPLAY_SCALING; } mRefreshRate = 60.f; // TODO: get the real refresh rate + + // compute a "density" automatically as a scale factor from 160 dpi + // TODO: this value should be calculated a compile time based on the + // board. + mDensity = floorf((mDpiX>mDpiY ? mDpiX : mDpiY)*0.1f + 0.5f) * (10.0f/160.0f); + LOGI("density = %f", mDensity); /* * Create our OpenGL ES context @@ -237,8 +240,18 @@ void DisplayHardware::init(uint32_t dpy) mSurface = surface; mContext = context; mFormat = GGL_PIXEL_FORMAT_RGB_565; + + hw_module_t const* module; - mBlitEngine = copybit_init(); + mBlitEngine = NULL; + if (hw_get_module(COPYBIT_HARDWARE_MODULE_ID, &module) == 0) { + copybit_open(module, &mBlitEngine); + } + + mOverlayEngine = NULL; + if (hw_get_module(OVERLAY_HARDWARE_MODULE_ID, &module) == 0) { + overlay_open(module, &mOverlayEngine); + } } /* @@ -252,7 +265,8 @@ void DisplayHardware::fini() { eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglTerminate(mDisplay); - copybit_term(mBlitEngine); + copybit_close(mBlitEngine); + overlay_close(mOverlayEngine); } void DisplayHardware::releaseScreen() const diff --git a/libs/surfaceflinger/DisplayHardware/DisplayHardware.h b/libs/surfaceflinger/DisplayHardware/DisplayHardware.h index 299e236..de4a2cc 100644 --- a/libs/surfaceflinger/DisplayHardware/DisplayHardware.h +++ b/libs/surfaceflinger/DisplayHardware/DisplayHardware.h @@ -26,6 +26,8 @@ #include "DisplayHardware/DisplayHardwareBase.h" +struct overlay_device_t; +struct copybit_device_t; struct copybit_image_t; struct copybit_t; @@ -64,6 +66,7 @@ public: float getDpiX() const; float getDpiY() const; float getRefreshRate() const; + float getDensity() const; int getWidth() const; int getHeight() const; PixelFormat getFormat() const; @@ -74,7 +77,8 @@ public: void getDisplaySurface(copybit_image_t* img) const; void getDisplaySurface(GGLSurface* fb) const; EGLDisplay getEGLDisplay() const { return mDisplay; } - copybit_t* getBlitEngine() const { return mBlitEngine; } + copybit_device_t* getBlitEngine() const { return mBlitEngine; } + overlay_device_t* getOverlayEngine() const { return mOverlayEngine; } Rect bounds() const { return Rect(mWidth, mHeight); @@ -91,13 +95,15 @@ private: float mDpiX; float mDpiY; float mRefreshRate; + float mDensity; int mWidth; int mHeight; PixelFormat mFormat; uint32_t mFlags; mutable Region mDirty; sp<EGLDisplaySurface> mDisplaySurface; - copybit_t* mBlitEngine; + copybit_device_t* mBlitEngine; + overlay_device_t* mOverlayEngine; }; }; // namespace android diff --git a/libs/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp b/libs/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp index 90f6287..f75e5c2 100644 --- a/libs/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp +++ b/libs/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp @@ -49,8 +49,10 @@ // ---------------------------------------------------------------------------- namespace android { -static char const * const kSleepFileName = "/sys/android_power/wait_for_fb_sleep"; -static char const * const kWakeFileName = "/sys/android_power/wait_for_fb_wake"; +static char const * kSleepFileName = "/sys/power/wait_for_fb_sleep"; +static char const * kWakeFileName = "/sys/power/wait_for_fb_wake"; +static char const * const kOldSleepFileName = "/sys/android_power/wait_for_fb_sleep"; +static char const * const kOldWakeFileName = "/sys/android_power/wait_for_fb_wake"; // This dir exists if the framebuffer console is present, either built into // the kernel or loaded as a module. @@ -123,16 +125,22 @@ status_t DisplayHardwareBase::DisplayEventThread::releaseScreen() const status_t DisplayHardwareBase::DisplayEventThread::readyToRun() { if (access(kSleepFileName, R_OK) || access(kWakeFileName, R_OK)) { - LOGE("Couldn't open %s or %s", kSleepFileName, kWakeFileName); - return NO_INIT; + if (access(kOldSleepFileName, R_OK) || access(kOldWakeFileName, R_OK)) { + LOGE("Couldn't open %s or %s", kSleepFileName, kWakeFileName); + return NO_INIT; + } + kSleepFileName = kOldSleepFileName; + kWakeFileName = kOldWakeFileName; } return NO_ERROR; } status_t DisplayHardwareBase::DisplayEventThread::initCheck() const { - return (access(kSleepFileName, R_OK) == 0 && - access(kWakeFileName, R_OK) == 0 && + return (((access(kSleepFileName, R_OK) == 0 && + access(kWakeFileName, R_OK) == 0) || + (access(kOldSleepFileName, R_OK) == 0 && + access(kOldWakeFileName, R_OK) == 0)) && access(kFbconSysDir, F_OK) != 0) ? NO_ERROR : NO_INIT; } |