AccelerantHWInterface should no longer rely on GetModeList() being called before

working with it. The app_server would have crashed before if a graphics driver
could directly return a preferred display mode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22595 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-10-17 14:20:58 +00:00
parent 540fe7aef9
commit 89d522a443
@@ -404,13 +404,11 @@ AccelerantHWInterface::Shutdown()
Basically we try to set all modes as found in the mode list the driver Basically we try to set all modes as found in the mode list the driver
returned, but we start with the one that best fits the originally returned, but we start with the one that best fits the originally
desired mode. desired mode.
The mode list must have been retrieved already.
*/ */
status_t status_t
AccelerantHWInterface::_SetFallbackMode(display_mode& newMode) const AccelerantHWInterface::_SetFallbackMode(display_mode& newMode) const
{ {
if (fModeList == NULL)
return B_ERROR;
// At first, we search the closest display mode from the list of // At first, we search the closest display mode from the list of
// supported modes - if that fails, we just take one // supported modes - if that fails, we just take one
@@ -485,6 +483,12 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
if (!fInitialModeSwitch) if (!fInitialModeSwitch)
return status; return status;
if (fModeList == NULL) {
status = _UpdateModeList();
if (status < B_OK)
return status;
}
// If this is the initial mode switch, we try a number of fallback // If this is the initial mode switch, we try a number of fallback
// modes first, before we have to fail // modes first, before we have to fail
@@ -609,7 +613,7 @@ AccelerantHWInterface::_UpdateModeList()
ATRACE(("unable to get mode list\n")); ATRACE(("unable to get mode list\n"));
return B_ERROR; return B_ERROR;
} }
return B_OK; return B_OK;
} }
@@ -650,37 +654,41 @@ AccelerantHWInterface::GetFrameBufferConfig(frame_buffer_config& config)
status_t status_t
AccelerantHWInterface::GetModeList(display_mode** modes, uint32 *count) AccelerantHWInterface::GetModeList(display_mode** _modes, uint32 *_count)
{ {
AutoReadLocker _(this); AutoReadLocker _(this);
if (!count || !modes) if (_count == NULL || _modes == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
status_t ret = fModeList ? B_OK : _UpdateModeList(); status_t status = B_OK;
if (ret >= B_OK) { if (fModeList == NULL)
*modes = new(nothrow) display_mode[fModeCount]; status = _UpdateModeList();
if (*modes) {
*count = fModeCount; if (status >= B_OK) {
memcpy(*modes, fModeList, sizeof(display_mode) * fModeCount); *_modes = new(nothrow) display_mode[fModeCount];
if (*_modes) {
*_count = fModeCount;
memcpy(*_modes, fModeList, sizeof(display_mode) * fModeCount);
} else { } else {
*count = 0; *_count = 0;
ret = B_NO_MEMORY; status = B_NO_MEMORY;
} }
} }
return ret; return status;
} }
status_t status_t
AccelerantHWInterface::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high) AccelerantHWInterface::GetPixelClockLimits(display_mode *mode, uint32 *low,
uint32 *high)
{ {
AutoReadLocker _(this); AutoReadLocker _(this);
if (!mode || !low || !high) if (!mode || !low || !high)
return B_BAD_VALUE; return B_BAD_VALUE;
return fAccGetPixelClockLimits(mode, low, high); return fAccGetPixelClockLimits(mode, low, high);
} }
@@ -692,10 +700,10 @@ AccelerantHWInterface::GetTimingConstraints(display_timing_constraints *dtc)
if (!dtc) if (!dtc)
return B_BAD_VALUE; return B_BAD_VALUE;
if (fAccGetTimingConstraints) if (fAccGetTimingConstraints)
return fAccGetTimingConstraints(dtc); return fAccGetTimingConstraints(dtc);
return B_UNSUPPORTED; return B_UNSUPPORTED;
} }
@@ -740,14 +748,15 @@ AccelerantHWInterface::GetPreferredMode(display_mode* mode)
if (version != EDID_VERSION_1) if (version != EDID_VERSION_1)
return B_NOT_SUPPORTED; return B_NOT_SUPPORTED;
status = B_ERROR; if (fModeList == NULL)
_UpdateModeList();
// find preferred mode from EDID info // find preferred mode from EDID info
for (uint32 i = 0; i < EDID1_NUM_DETAILED_MONITOR_DESC; ++i) { for (uint32 i = 0; i < EDID1_NUM_DETAILED_MONITOR_DESC; ++i) {
if (info.detailed_monitor[i].monitor_desc_type != EDID1_IS_DETAILED_TIMING) if (info.detailed_monitor[i].monitor_desc_type != EDID1_IS_DETAILED_TIMING)
continue; continue;
// TODO: we could also just look for this mode in the most list // TODO: we could also just look for this mode in the mode list
// TODO: handle sync and flags correctly! // TODO: handle sync and flags correctly!
const edid1_detailed_timing& timing = info.detailed_monitor[i].data.detailed_timing; const edid1_detailed_timing& timing = info.detailed_monitor[i].data.detailed_timing;
mode->timing.pixel_clock = timing.pixel_clock * 10; mode->timing.pixel_clock = timing.pixel_clock * 10;
@@ -1235,9 +1244,6 @@ AccelerantHWInterface::MoveCursorTo(const float& x, const float& y)
RenderingBuffer * RenderingBuffer *
AccelerantHWInterface::FrontBuffer() const AccelerantHWInterface::FrontBuffer() const
{ {
if (!fModeList)
return NULL;
return fFrontBuffer; return fFrontBuffer;
} }
@@ -1245,9 +1251,6 @@ AccelerantHWInterface::FrontBuffer() const
RenderingBuffer * RenderingBuffer *
AccelerantHWInterface::BackBuffer() const AccelerantHWInterface::BackBuffer() const
{ {
if (!fModeList)
return NULL;
return fBackBuffer; return fBackBuffer;
} }