one more step toward HDMI support
getDisplayInfo() now returns proper information for HWC managed displays. hotplug is sitll not supported; so this is not fully correct as the information returned will be bogus if the HDMI screen is not plugged in. Bug: 7191563 Change-Id: If55d8e829fae0443571548155007f486cdf9bc9f
This commit is contained in:
parent
eba8c688f6
commit
1604f777d1
@ -187,7 +187,10 @@ HWComposer::HWComposer(
|
|||||||
mDisplayData[HWC_DISPLAY_PRIMARY].refresh);
|
mDisplayData[HWC_DISPLAY_PRIMARY].refresh);
|
||||||
}
|
}
|
||||||
} else if (mHwc) {
|
} else if (mHwc) {
|
||||||
queryDisplayProperties(HWC_DISPLAY_PRIMARY);
|
// here we're guaranteed to have at least HWC 1.1
|
||||||
|
for (size_t i =0 ; i<HWC_NUM_DISPLAY_TYPES ; i++) {
|
||||||
|
queryDisplayProperties(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needVSyncThread) {
|
if (needVSyncThread) {
|
||||||
@ -319,7 +322,8 @@ static const uint32_t DISPLAY_ATTRIBUTES[] = {
|
|||||||
#define ANDROID_DENSITY_TV 213
|
#define ANDROID_DENSITY_TV 213
|
||||||
#define ANDROID_DENSITY_XHIGH 320
|
#define ANDROID_DENSITY_XHIGH 320
|
||||||
|
|
||||||
void HWComposer::queryDisplayProperties(int disp) {
|
status_t HWComposer::queryDisplayProperties(int disp) {
|
||||||
|
|
||||||
LOG_ALWAYS_FATAL_IF(!mHwc || !hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1));
|
LOG_ALWAYS_FATAL_IF(!mHwc || !hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1));
|
||||||
|
|
||||||
// use zero as default value for unspecified attributes
|
// use zero as default value for unspecified attributes
|
||||||
@ -329,13 +333,13 @@ void HWComposer::queryDisplayProperties(int disp) {
|
|||||||
uint32_t config;
|
uint32_t config;
|
||||||
size_t numConfigs = 1;
|
size_t numConfigs = 1;
|
||||||
status_t err = mHwc->getDisplayConfigs(mHwc, disp, &config, &numConfigs);
|
status_t err = mHwc->getDisplayConfigs(mHwc, disp, &config, &numConfigs);
|
||||||
LOG_ALWAYS_FATAL_IF(err, "getDisplayAttributes failed (%s)", strerror(-err));
|
if (err != NO_ERROR) {
|
||||||
|
// this can happen if an unpluggable display is not connected
|
||||||
if (err == NO_ERROR) {
|
return err;
|
||||||
mHwc->getDisplayAttributes(mHwc, disp, config, DISPLAY_ATTRIBUTES,
|
|
||||||
values);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mHwc->getDisplayAttributes(mHwc, disp, config, DISPLAY_ATTRIBUTES, values);
|
||||||
|
|
||||||
int32_t w = 0, h = 0;
|
int32_t w = 0, h = 0;
|
||||||
for (size_t i = 0; i < NUM_DISPLAY_ATTRIBUTES - 1; i++) {
|
for (size_t i = 0; i < NUM_DISPLAY_ATTRIBUTES - 1; i++) {
|
||||||
switch (DISPLAY_ATTRIBUTES[i]) {
|
switch (DISPLAY_ATTRIBUTES[i]) {
|
||||||
@ -371,6 +375,7 @@ void HWComposer::queryDisplayProperties(int disp) {
|
|||||||
mDisplayData[disp].ydpi = ANDROID_DENSITY_TV;
|
mDisplayData[disp].ydpi = ANDROID_DENSITY_TV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t HWComposer::allocateDisplayId() {
|
int32_t HWComposer::allocateDisplayId() {
|
||||||
|
@ -274,7 +274,7 @@ private:
|
|||||||
inline void vsync(int disp, int64_t timestamp);
|
inline void vsync(int disp, int64_t timestamp);
|
||||||
inline void hotplug(int disp, int connected);
|
inline void hotplug(int disp, int connected);
|
||||||
|
|
||||||
void queryDisplayProperties(int disp);
|
status_t queryDisplayProperties(int disp);
|
||||||
|
|
||||||
status_t setFramebufferTarget(int32_t id,
|
status_t setFramebufferTarget(int32_t id,
|
||||||
const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buf);
|
const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buf);
|
||||||
|
@ -522,16 +522,21 @@ bool SurfaceFlinger::authenticateSurfaceTexture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
|
status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
|
||||||
// TODO: this is mostly here only for compatibility
|
int32_t type = BAD_VALUE;
|
||||||
// the display size is needed but the display metrics should come from elsewhere
|
for (int i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) {
|
||||||
if (display != mDefaultDisplays[ISurfaceComposer::eDisplayIdMain]) {
|
if (display == mDefaultDisplays[i]) {
|
||||||
// TODO: additional displays not yet supported
|
type = i;
|
||||||
return BAD_INDEX;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type < 0) {
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
const HWComposer& hwc(getHwComposer());
|
const HWComposer& hwc(getHwComposer());
|
||||||
float xdpi = hwc.getDpiX(HWC_DISPLAY_PRIMARY);
|
float xdpi = hwc.getDpiX(type);
|
||||||
float ydpi = hwc.getDpiY(HWC_DISPLAY_PRIMARY);
|
float ydpi = hwc.getDpiY(type);
|
||||||
|
|
||||||
// TODO: Not sure if display density should handled by SF any longer
|
// TODO: Not sure if display density should handled by SF any longer
|
||||||
class Density {
|
class Density {
|
||||||
@ -549,30 +554,39 @@ status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo*
|
|||||||
static int getBuildDensity() {
|
static int getBuildDensity() {
|
||||||
return getDensityFromProperty("ro.sf.lcd_density"); }
|
return getDensityFromProperty("ro.sf.lcd_density"); }
|
||||||
};
|
};
|
||||||
// The density of the device is provided by a build property
|
|
||||||
float density = Density::getBuildDensity() / 160.0f;
|
if (type == DisplayDevice::DISPLAY_PRIMARY) {
|
||||||
if (density == 0) {
|
// The density of the device is provided by a build property
|
||||||
// the build doesn't provide a density -- this is wrong!
|
float density = Density::getBuildDensity() / 160.0f;
|
||||||
// use xdpi instead
|
if (density == 0) {
|
||||||
ALOGE("ro.sf.lcd_density must be defined as a build property");
|
// the build doesn't provide a density -- this is wrong!
|
||||||
density = xdpi / 160.0f;
|
// use xdpi instead
|
||||||
}
|
ALOGE("ro.sf.lcd_density must be defined as a build property");
|
||||||
if (Density::getEmuDensity()) {
|
density = xdpi / 160.0f;
|
||||||
// if "qemu.sf.lcd_density" is specified, it overrides everything
|
}
|
||||||
xdpi = ydpi = density = Density::getEmuDensity();
|
if (Density::getEmuDensity()) {
|
||||||
density /= 160.0f;
|
// if "qemu.sf.lcd_density" is specified, it overrides everything
|
||||||
|
xdpi = ydpi = density = Density::getEmuDensity();
|
||||||
|
density /= 160.0f;
|
||||||
|
}
|
||||||
|
info->density = density;
|
||||||
|
|
||||||
|
// TODO: this needs to go away (currently needed only by webkit)
|
||||||
|
sp<const DisplayDevice> hw(getDefaultDisplayDevice());
|
||||||
|
info->orientation = hw->getOrientation();
|
||||||
|
getPixelFormatInfo(hw->getFormat(), &info->pixelFormatInfo);
|
||||||
|
} else {
|
||||||
|
// TODO: where should this value come from?
|
||||||
|
static const int TV_DENSITY = 213;
|
||||||
|
info->density = TV_DENSITY / 160.0f;
|
||||||
|
info->orientation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<const DisplayDevice> hw(getDefaultDisplayDevice());
|
info->w = hwc.getWidth(type);
|
||||||
info->w = hw->getWidth();
|
info->h = hwc.getHeight(type);
|
||||||
info->h = hw->getHeight();
|
|
||||||
info->xdpi = xdpi;
|
info->xdpi = xdpi;
|
||||||
info->ydpi = ydpi;
|
info->ydpi = ydpi;
|
||||||
info->fps = float(1e9 / hwc.getRefreshPeriod(HWC_DISPLAY_PRIMARY));
|
info->fps = float(1e9 / hwc.getRefreshPeriod(type));
|
||||||
info->density = density;
|
|
||||||
info->orientation = hw->getOrientation();
|
|
||||||
// TODO: this needs to go away (currently needed only by webkit)
|
|
||||||
getPixelFormatInfo(hw->getFormat(), &info->pixelFormatInfo);
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user