SDL/DISPMANX: Updated class member names, configure script and asociated files and docs to conform to fingolfin's corrections.

This commit is contained in:
vanfanel 2015-07-22 13:00:45 +02:00
parent 6320a008ec
commit b706ca36f1
5 changed files with 106 additions and 116 deletions

View file

@ -20,7 +20,7 @@
* *
*/ */
//Needed for Raspberry Pi header incussion // Needed for Raspberry Pi header inclusion
#define FORBIDDEN_SYMBOL_ALLOW_ALL #define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "common/scummsys.h" #include "common/scummsys.h"
@ -34,12 +34,12 @@
#include <bcm_host.h> #include <bcm_host.h>
struct dispvarsStruct { struct dispvarsStruct {
DISPMANX_DISPLAY_HANDLE_T display; DISPMANX_DISPLAY_HANDLE_T display;
DISPMANX_UPDATE_HANDLE_T update; DISPMANX_UPDATE_HANDLE_T update;
DISPMANX_ELEMENT_HANDLE_T element; DISPMANX_ELEMENT_HANDLE_T element;
VC_IMAGE_TYPE_T pixFormat; VC_IMAGE_TYPE_T pixFormat;
VC_DISPMANX_ALPHA_T alpha; VC_DISPMANX_ALPHA_T alpha;
VC_RECT_T bmpRect; VC_RECT_T bmpRect;
VC_RECT_T srcRect; VC_RECT_T srcRect;
@ -52,13 +52,13 @@ struct dispvarsStruct {
bool aspectRatioCorrection; bool aspectRatioCorrection;
void *pixmem; void *pixmem;
int numpages; int numpages;
struct dispmanxPage *pages; dispmanxPage *pages;
struct dispmanxPage *currentPage; dispmanxPage *currentPage;
int pageflipPending; int pageflipPending;
pthread_cond_t vsyncCondition; pthread_cond_t vsyncCondition;
pthread_mutex_t vsyncCondMutex; pthread_mutex_t vsyncCondMutex;
pthread_mutex_t pendingMutex; pthread_mutex_t pendingMutex;
SDL_Surface *fscreen; SDL_Surface *fscreen;
@ -71,31 +71,31 @@ struct dispmanxPage {
// isolating the access to it's "used" flag. // isolating the access to it's "used" flag.
pthread_mutex_t pageUsedMutex; pthread_mutex_t pageUsedMutex;
// This field will allow us to access the // This field will allow us to access the
// main dispvars struct, for the vsync cb. // main dispvars struct, for the vsync cb.
struct dispvarsStruct *dispvars; struct dispvarsStruct *dispvars;
}; };
DispmanXSdlGraphicsManager::DispmanXSdlGraphicsManager(SdlEventSource *sdlEventSource) DispmanXSdlGraphicsManager::DispmanXSdlGraphicsManager(SdlEventSource *sdlEventSource)
: SurfaceSdlGraphicsManager(sdlEventSource) { : SurfaceSdlGraphicsManager(sdlEventSource) {
_dispvars = new(dispvarsStruct); _dispvars = new(dispvarsStruct);
DispmanXInit(); dispmanXInit();
} }
DispmanXSdlGraphicsManager::~DispmanXSdlGraphicsManager() { DispmanXSdlGraphicsManager::~DispmanXSdlGraphicsManager() {
DispmanXVideoQuit(); dispmanXVideoQuit();
delete(_dispvars); delete(_dispvars);
} }
void DispmanXSdlGraphicsManager::DispmanXInit() { void DispmanXSdlGraphicsManager::dispmanXInit() {
_dispvars->screen = 0; _dispvars->screen = 0;
_dispvars->vcImagePtr = 0; _dispvars->vcImagePtr = 0;
_dispvars->numpages = 3; _dispvars->numpages = 3;
_dispvars->pages = (struct dispmanxPage *)calloc(_dispvars->numpages, sizeof(struct dispmanxPage)); _dispvars->pages = (struct dispmanxPage *)calloc(_dispvars->numpages, sizeof(struct dispmanxPage));
_dispvars->pageflipPending = 0; _dispvars->pageflipPending = 0;
_dispvars->currentPage = NULL; _dispvars->currentPage = NULL;
_dispvars->pixFormat = VC_IMAGE_RGB565; _dispvars->pixFormat = VC_IMAGE_RGB565;
/* Transparency disabled */ /* Transparency disabled */
_dispvars->alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS; _dispvars->alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS;
_dispvars->alpha.opacity = 255; _dispvars->alpha.opacity = 255;
@ -104,20 +104,20 @@ void DispmanXSdlGraphicsManager::DispmanXInit() {
// Init each page's variables // Init each page's variables
for (int i = 0; i < _dispvars->numpages; i++) { for (int i = 0; i < _dispvars->numpages; i++) {
_dispvars->pages[i].used = false; _dispvars->pages[i].used = false;
_dispvars->pages[i].dispvars = _dispvars; _dispvars->pages[i].dispvars = _dispvars;
_dispvars->pages[i].resource = 0; _dispvars->pages[i].resource = 0;
pthread_mutex_init(&_dispvars->pages[i].pageUsedMutex, NULL); pthread_mutex_init(&_dispvars->pages[i].pageUsedMutex, NULL);
} }
// Initialize the other mutex and condition variables // Initialize the other mutex and condition variables
pthread_cond_init(&_dispvars->vsyncCondition, NULL); pthread_cond_init(&_dispvars->vsyncCondition, NULL);
pthread_mutex_init(&_dispvars->pendingMutex, NULL); pthread_mutex_init(&_dispvars->pendingMutex, NULL);
pthread_mutex_init(&_dispvars->vsyncCondMutex, NULL); pthread_mutex_init(&_dispvars->vsyncCondMutex, NULL);
// Before we call any vc_* function, we need to call this one. // Before we call any vc_* function, we need to call this one.
bcm_host_init(); bcm_host_init();
_dispvars->display = vc_dispmanx_display_open(_dispvars->screen); _dispvars->display = vc_dispmanx_display_open(_dispvars->screen);
graphics_get_display_size(_dispvars->display, &_dispvars->dispmanxWidth, &_dispvars->dispmanxHeight); graphics_get_display_size(_dispvars->display, &_dispvars->dispmanxWidth, &_dispvars->dispmanxHeight);
@ -125,24 +125,24 @@ void DispmanXSdlGraphicsManager::DispmanXInit() {
_dispvars->fscreen = NULL; _dispvars->fscreen = NULL;
} }
void DispmanXSdlGraphicsManager::DispmanXSetup(int srcWidth, int srcHeight) { void DispmanXSdlGraphicsManager::dispmanXSetup(int srcWidth, int srcHeight) {
unsigned int dstWidth, dstHeight, dstXpos, dstYpos; unsigned int dstWidth, dstHeight, dstXpos, dstYpos;
// If we have an element, we have to free it along with it's resources. // If we have an element, we have to free it along with it's resources.
if (_dispvars->element) { if (_dispvars->element) {
DispmanXFreeResources(); dispmanXFreeResources();
} }
// We do this for 2 bytes per pixel which is default on the Rpi. // We do this for 2 bytes per pixel which is default on the Rpi.
_dispvars->pitch = srcWidth * 2; _dispvars->pitch = srcWidth * 2;
if (_dispvars->aspectRatioCorrection) { if (_dispvars->aspectRatioCorrection) {
float aspect = ((float)srcWidth / (float)srcHeight); float aspect = ((float)srcWidth / (float)srcHeight);
dstWidth = _dispvars->dispmanxHeight * aspect; dstWidth = _dispvars->dispmanxHeight * aspect;
} else { } else {
dstWidth = _dispvars->dispmanxWidth; dstWidth = _dispvars->dispmanxWidth;
} }
dstHeight = _dispvars->dispmanxHeight; dstHeight = _dispvars->dispmanxHeight;
// If we obtain a scaled image width that is bigger than the physical screen width, // If we obtain a scaled image width that is bigger than the physical screen width,
// then we keep the physical screen width as our maximun width. // then we keep the physical screen width as our maximun width.
if (dstWidth > _dispvars->dispmanxWidth) { if (dstWidth > _dispvars->dispmanxWidth) {
@ -155,11 +155,11 @@ void DispmanXSdlGraphicsManager::DispmanXSetup(int srcWidth, int srcHeight) {
// Remember we have to transfer the whole bitmap even if we would have // Remember we have to transfer the whole bitmap even if we would have
// interest in a part of it! Blitting is done by the GPU. // interest in a part of it! Blitting is done by the GPU.
vc_dispmanx_rect_set(&_dispvars->dstRect, dstXpos, dstYpos, dstWidth, dstHeight); vc_dispmanx_rect_set(&_dispvars->dstRect, dstXpos, dstYpos, dstWidth, dstHeight);
vc_dispmanx_rect_set(&_dispvars->bmpRect, 0, 0, srcWidth, srcHeight); vc_dispmanx_rect_set(&_dispvars->bmpRect, 0, 0, srcWidth, srcHeight);
vc_dispmanx_rect_set(&_dispvars->srcRect, 0, 0, srcWidth << 16, srcHeight << 16); vc_dispmanx_rect_set(&_dispvars->srcRect, 0, 0, srcWidth << 16, srcHeight << 16);
for (int i = 0; i < _dispvars->numpages; i++) { for (int i = 0; i < _dispvars->numpages; i++) {
_dispvars->pages[i].resource = vc_dispmanx_resource_create(_dispvars->pixFormat, _dispvars->pages[i].resource = vc_dispmanx_resource_create(_dispvars->pixFormat,
srcWidth, srcHeight, &(_dispvars->vcImagePtr)); srcWidth, srcHeight, &(_dispvars->vcImagePtr));
} }
@ -167,20 +167,20 @@ void DispmanXSdlGraphicsManager::DispmanXSetup(int srcWidth, int srcHeight) {
_dispvars->update = vc_dispmanx_update_start(0); _dispvars->update = vc_dispmanx_update_start(0);
_dispvars->element = vc_dispmanx_element_add( _dispvars->element = vc_dispmanx_element_add(
_dispvars->update,_dispvars->display, 0, _dispvars->update,_dispvars->display, 0,
&_dispvars->dstRect, 0, &_dispvars->dstRect, 0,
&_dispvars->srcRect, DISPMANX_PROTECTION_NONE, &_dispvars->srcRect, DISPMANX_PROTECTION_NONE,
&_dispvars->alpha, 0, (DISPMANX_TRANSFORM_T)0); &_dispvars->alpha, 0, (DISPMANX_TRANSFORM_T)0);
vc_dispmanx_update_submit_sync(_dispvars->update); vc_dispmanx_update_submit_sync(_dispvars->update);
} }
void DispmanXVSyncCallback (DISPMANX_UPDATE_HANDLE_T u, void *arg) { void dispmanXVSyncCallback (DISPMANX_UPDATE_HANDLE_T u, void *arg) {
struct dispmanxPage *page = (struct dispmanxPage*)arg; struct dispmanxPage *page = (struct dispmanxPage*)arg;
struct dispvarsStruct *dispvars = page->dispvars; struct dispvarsStruct *dispvars = page->dispvars;
// Marking the page as free must be done before the signaling // Marking the page as free must be done before the signaling
// so when the update function continues (it won't continue until we signal) // so when the update function continues (it won't continue until we signal)
// we can chose this page as free. // we can chose this page as free.
if (dispvars->currentPage) { if (dispvars->currentPage) {
pthread_mutex_lock(&dispvars->currentPage->pageUsedMutex); pthread_mutex_lock(&dispvars->currentPage->pageUsedMutex);
@ -195,46 +195,46 @@ void DispmanXVSyncCallback (DISPMANX_UPDATE_HANDLE_T u, void *arg) {
// caused this callback becomes the visible one // caused this callback becomes the visible one
dispvars->currentPage = page; dispvars->currentPage = page;
// These two things must be isolated "atomically" to avoid getting // These two things must be isolated "atomically" to avoid getting
// a false positive in the pending_mutex test in update function. // a false positive in the pending_mutex test in update function.
pthread_mutex_lock(&dispvars->pendingMutex); pthread_mutex_lock(&dispvars->pendingMutex);
dispvars->pageflipPending--; dispvars->pageflipPending--;
pthread_cond_signal(&dispvars->vsyncCondition); pthread_cond_signal(&dispvars->vsyncCondition);
pthread_mutex_unlock(&dispvars->pendingMutex); pthread_mutex_unlock(&dispvars->pendingMutex);
} }
void DispmanXSdlGraphicsManager::DispmanXUpdate() { void DispmanXSdlGraphicsManager::dispmanXUpdate() {
// Wait until last issued flip completes to get a free page. Also, // Wait until last issued flip completes to get a free page. Also,
// dispmanx doesn't support issuing more than one pageflip. // dispmanx doesn't support issuing more than one pageflip.
pthread_mutex_lock(&_dispvars->pendingMutex); pthread_mutex_lock(&_dispvars->pendingMutex);
if (_dispvars->pageflipPending > 0) { if (_dispvars->pageflipPending > 0) {
pthread_cond_wait(&_dispvars->vsyncCondition, &_dispvars->pendingMutex); pthread_cond_wait(&_dispvars->vsyncCondition, &_dispvars->pendingMutex);
} }
pthread_mutex_unlock(&_dispvars->pendingMutex); pthread_mutex_unlock(&_dispvars->pendingMutex);
struct dispmanxPage *page = DispmanXGetFreePage(); struct dispmanxPage *page = dispmanXGetFreePage();
// Frame blitting // Frame blitting
vc_dispmanx_resource_write_data(page->resource, _dispvars->pixFormat, vc_dispmanx_resource_write_data(page->resource, _dispvars->pixFormat,
_dispvars->pitch, _dispvars->pixmem, &_dispvars->bmpRect); _dispvars->pitch, _dispvars->pixmem, &_dispvars->bmpRect);
// Issue a page flip at the next vblank interval (will be done at vsync anyway). // Issue a page flip at the next vblank interval (will be done at vsync anyway).
_dispvars->update = vc_dispmanx_update_start(0); _dispvars->update = vc_dispmanx_update_start(0);
vc_dispmanx_element_change_source(_dispvars->update, _dispvars->element, vc_dispmanx_element_change_source(_dispvars->update, _dispvars->element,
page->resource); page->resource);
vc_dispmanx_update_submit(_dispvars->update, &DispmanXVSyncCallback, page); vc_dispmanx_update_submit(_dispvars->update, &dispmanXVSyncCallback, page);
pthread_mutex_lock(&_dispvars->pendingMutex); pthread_mutex_lock(&_dispvars->pendingMutex);
_dispvars->pageflipPending++; _dispvars->pageflipPending++;
pthread_mutex_unlock(&_dispvars->pendingMutex); pthread_mutex_unlock(&_dispvars->pendingMutex);
} }
struct dispmanxPage *DispmanXSdlGraphicsManager::DispmanXGetFreePage(void) { struct dispmanxPage *DispmanXSdlGraphicsManager::dispmanXGetFreePage(void) {
struct dispmanxPage *page = NULL; struct dispmanxPage *page = NULL;
while (!page) while (!page)
@ -265,8 +265,8 @@ struct dispmanxPage *DispmanXSdlGraphicsManager::DispmanXGetFreePage(void) {
return page; return page;
} }
void DispmanXSdlGraphicsManager::DispmanXFreeResources(void) { void DispmanXSdlGraphicsManager::dispmanXFreeResources(void) {
// What if we run into the vsync cb code after freeing the resources? // What if we run into the vsync cb code after freeing the resources?
pthread_mutex_lock(&_dispvars->pendingMutex); pthread_mutex_lock(&_dispvars->pendingMutex);
if (_dispvars->pageflipPending > 0) if (_dispvars->pageflipPending > 0)
{ {
@ -274,7 +274,7 @@ void DispmanXSdlGraphicsManager::DispmanXFreeResources(void) {
} }
pthread_mutex_unlock(&_dispvars->pendingMutex); pthread_mutex_unlock(&_dispvars->pendingMutex);
for (int i = 0; i < _dispvars->numpages; i++) { for (int i = 0; i < _dispvars->numpages; i++) {
vc_dispmanx_resource_delete(_dispvars->pages[i].resource); vc_dispmanx_resource_delete(_dispvars->pages[i].resource);
_dispvars->pages[i].resource = 0; _dispvars->pages[i].resource = 0;
_dispvars->pages[i].used = false; _dispvars->pages[i].used = false;
@ -282,37 +282,37 @@ void DispmanXSdlGraphicsManager::DispmanXFreeResources(void) {
_dispvars->update = vc_dispmanx_update_start(0); _dispvars->update = vc_dispmanx_update_start(0);
vc_dispmanx_element_remove(_dispvars->update, _dispvars->element); vc_dispmanx_element_remove(_dispvars->update, _dispvars->element);
vc_dispmanx_update_submit_sync(_dispvars->update); vc_dispmanx_update_submit_sync(_dispvars->update);
// We use this on the setup function to know if we have to free resources and element. // We use this on the setup function to know if we have to free resources and element.
_dispvars->element = 0; _dispvars->element = 0;
} }
void DispmanXSdlGraphicsManager::DispmanXVideoQuit() { void DispmanXSdlGraphicsManager::dispmanXVideoQuit() {
// This also waits for pending flips to complete, that's needed before // This also waits for pending flips to complete, that's needed before
// we destroy the mutexes and condition. // we destroy the mutexes and condition.
DispmanXFreeResources(); dispmanXFreeResources();
// Destroy the mutexes and conditions // Destroy the mutexes and conditions
for (int i = 0; i < _dispvars->numpages; i++) { for (int i = 0; i < _dispvars->numpages; i++) {
pthread_mutex_destroy(&_dispvars->pages[i].pageUsedMutex); pthread_mutex_destroy(&_dispvars->pages[i].pageUsedMutex);
} }
pthread_mutex_destroy(&_dispvars->pendingMutex); pthread_mutex_destroy(&_dispvars->pendingMutex);
pthread_mutex_destroy(&_dispvars->vsyncCondMutex); pthread_mutex_destroy(&_dispvars->vsyncCondMutex);
pthread_cond_destroy(&_dispvars->vsyncCondition); pthread_cond_destroy(&_dispvars->vsyncCondition);
free(_dispvars->pages); free(_dispvars->pages);
// Close display and deinit // Close display and deinit
vc_dispmanx_display_close(_dispvars->display); vc_dispmanx_display_close(_dispvars->display);
bcm_host_deinit(); bcm_host_deinit();
} }
bool DispmanXSdlGraphicsManager::loadGFXMode() { bool DispmanXSdlGraphicsManager::loadGFXMode() {
_forceFull = true; _forceFull = true;
// In DispmanX, we manage aspect ratio correction, so for scummvm it's always disabled. // In dispmanX, we manage aspect ratio correction, so for scummvm it's always disabled.
_videoMode.aspectRatioCorrection = false; _videoMode.aspectRatioCorrection = false;
_videoMode.overlayWidth = _videoMode.screenWidth; _videoMode.overlayWidth = _videoMode.screenWidth;
_videoMode.overlayHeight = _videoMode.screenHeight; _videoMode.overlayHeight = _videoMode.screenHeight;
_videoMode.hardwareWidth = _videoMode.screenWidth; _videoMode.hardwareWidth = _videoMode.screenWidth;
@ -332,7 +332,7 @@ bool DispmanXSdlGraphicsManager::loadGFXMode() {
error("allocating _screen failed"); error("allocating _screen failed");
// Avoid having SDL_SRCALPHA set even if we supplied an alpha-channel in the format. // Avoid having SDL_SRCALPHA set even if we supplied an alpha-channel in the format.
SDL_SetAlpha(_screen, 0, 255); SDL_SetAlpha(_screen, 0, 255);
// We set our own default palette to all black. // We set our own default palette to all black.
SDL_SetColors(_screen, _currentPalette, 0, 256); SDL_SetColors(_screen, _currentPalette, 0, 256);
@ -340,23 +340,23 @@ bool DispmanXSdlGraphicsManager::loadGFXMode() {
// Create the surface that contains the scaled graphics in 16 bit mode // Create the surface that contains the scaled graphics in 16 bit mode
// //
DispmanXSetup(_videoMode.screenWidth, _videoMode.screenHeight); dispmanXSetup(_videoMode.screenWidth, _videoMode.screenHeight);
_hwscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.hardwareWidth, _videoMode.hardwareHeight, 16, _hwscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.hardwareWidth, _videoMode.hardwareHeight, 16,
0, 0, 0, 0); 0, 0, 0, 0);
// This is just so SDL 1.x input is initialized. Only once! // This is just so SDL 1.x input is initialized. Only once!
if (_dispvars->fscreen == NULL) if (_dispvars->fscreen == NULL)
_dispvars->fscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 16, SDL_FULLSCREEN); _dispvars->fscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 16, SDL_FULLSCREEN);
if (_hwscreen == NULL) { if (_hwscreen == NULL) {
// Don't use error here because we don't have access to the debug console // Don't use error here because we don't have access to the debug console
warning("Allocating surface for DispmanX rendering _hwscreen failed"); warning("Allocating surface for dispmanX rendering _hwscreen failed");
g_system->quit(); g_system->quit();
} }
// We render to dispmanx resources from _hwscreen pixels array // We render to dispmanx resources from _hwscreen pixels array
_dispvars->pixmem = _hwscreen->pixels; _dispvars->pixmem = _hwscreen->pixels;
_overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth, _videoMode.overlayHeight, _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth, _videoMode.overlayHeight,
16, 16,
_hwscreen->format->Rmask, _hwscreen->format->Rmask,
@ -401,7 +401,7 @@ bool DispmanXSdlGraphicsManager::loadGFXMode() {
void DispmanXSdlGraphicsManager::clearOverlay() { void DispmanXSdlGraphicsManager::clearOverlay() {
//assert(_transactionMode == kTransactionNone); //assert(_transactionMode == kTransactionNone);
Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
if (!_overlayVisible) if (!_overlayVisible)
@ -436,7 +436,7 @@ void DispmanXSdlGraphicsManager::internUpdateScreen() {
(_mouseNeedsRedraw && _mouseBackup.y <= _currentShakePos)) { (_mouseNeedsRedraw && _mouseBackup.y <= _currentShakePos)) {
SDL_Rect blackrect = {0, 0, (Uint16)(_videoMode.screenWidth * _videoMode.scaleFactor), (Uint16)(_newShakePos * _videoMode.scaleFactor)}; SDL_Rect blackrect = {0, 0, (Uint16)(_videoMode.screenWidth * _videoMode.scaleFactor), (Uint16)(_newShakePos * _videoMode.scaleFactor)};
if (_videoMode.aspectRatioCorrection && !_overlayVisible) if (_dispvars->aspectRatioCorrection && !_overlayVisible)
blackrect.h = real2Aspect(blackrect.h - 1) + 1; blackrect.h = real2Aspect(blackrect.h - 1) + 1;
SDL_FillRect(_hwscreen, &blackrect, 0); SDL_FillRect(_hwscreen, &blackrect, 0);
@ -535,7 +535,7 @@ void DispmanXSdlGraphicsManager::internUpdateScreen() {
// Finally, blit all our changes to the screen // Finally, blit all our changes to the screen
if (!_displayDisabled) { if (!_displayDisabled) {
SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList);
DispmanXUpdate(); dispmanXUpdate();
} }
} }
@ -548,9 +548,7 @@ bool DispmanXSdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) {
// Ctrl-Alt-a toggles aspect ratio correction // Ctrl-Alt-a toggles aspect ratio correction
if (key == 'a') { if (key == 'a') {
beginGFXTransaction(); setFeatureState(OSystem::kFeatureAspectRatioCorrection, !_dispvars->aspectRatioCorrection);
setFeatureState(OSystem::kFeatureAspectRatioCorrection, !_dispvars->aspectRatioCorrection);
endGFXTransaction();
#ifdef USE_OSD #ifdef USE_OSD
char buffer[128]; char buffer[128];
if (_dispvars->aspectRatioCorrection) if (_dispvars->aspectRatioCorrection)
@ -574,11 +572,11 @@ void DispmanXSdlGraphicsManager::setAspectRatioCorrection(bool enable) {
Common::StackLock lock(_graphicsMutex); Common::StackLock lock(_graphicsMutex);
// We simply take note on what's the aspect ratio correction activation state. // We simply take note on what's the aspect ratio correction activation state.
_dispvars->aspectRatioCorrection = enable; _dispvars->aspectRatioCorrection = enable;
// If we have a videomode setup already, call DispmanXSetup() again so aspect ratio // If we have a videomode setup already, call dispmanXSetup() again so aspect ratio
// correction activation/deactivation works from the menu. // correction activation/deactivation works from the menu.
if (_oldVideoMode.setup && _dispvars->aspectRatioCorrection == enable) { if (_oldVideoMode.setup && _dispvars->aspectRatioCorrection == enable) {
DispmanXSetup(_videoMode.screenWidth, _videoMode.screenHeight); dispmanXSetup(_videoMode.screenWidth, _videoMode.screenHeight);
} }
} }

View file

@ -31,22 +31,22 @@ struct dispmanxPage;
class DispmanXSdlGraphicsManager : public SurfaceSdlGraphicsManager { class DispmanXSdlGraphicsManager : public SurfaceSdlGraphicsManager {
public: public:
DispmanXSdlGraphicsManager(SdlEventSource *sdlEventSource); DispmanXSdlGraphicsManager(SdlEventSource *sdlEventSource);
~DispmanXSdlGraphicsManager(); ~DispmanXSdlGraphicsManager();
bool loadGFXMode(); bool loadGFXMode();
void internUpdateScreen(); void internUpdateScreen();
bool handleScalerHotkeys(Common::KeyCode key); bool handleScalerHotkeys(Common::KeyCode key);
void setFullscreenMode(bool enable); void setFullscreenMode(bool enable);
void setAspectRatioCorrection(bool enable); void setAspectRatioCorrection(bool enable);
void clearOverlay(); void clearOverlay();
protected: protected:
// Raspberry Pi Dispmanx API // Raspberry Pi Dispmanx API
void DispmanXSetup(int width, int height); void dispmanXSetup(int width, int height);
void DispmanXInit(); void dispmanXInit();
void DispmanXUpdate(); void dispmanXUpdate();
struct dispmanxPage *DispmanXGetFreePage(); dispmanxPage *dispmanXGetFreePage();
void DispmanXFreeResources(); void dispmanXFreeResources();
void DispmanXVideoQuit(); void dispmanXVideoQuit();
struct dispvarsStruct *_dispvars; dispvarsStruct *_dispvars;
}; };
#endif /* BACKENDS_GRAPHICS_SDL_DISPMANX_H */ #endif /* BACKENDS_GRAPHICS_SDL_DISPMANX_H */

View file

@ -127,6 +127,11 @@ MODULE_OBJS += \
mixer/sdl13/sdl13-mixer.o mixer/sdl13/sdl13-mixer.o
endif endif
ifdef RASPBERRYPI
MODULE_OBJS += \
graphics/dispmanxsdl/dispmanxsdl-graphics.o
endif
ifeq ($(BACKEND),tizen) ifeq ($(BACKEND),tizen)
MODULE_OBJS += \ MODULE_OBJS += \
timer/tizen/timer.o timer/tizen/timer.o
@ -193,11 +198,6 @@ MODULE_OBJS += \
timer/psp/timer.o timer/psp/timer.o
endif endif
ifeq ($(BACKEND),raspberrypi)
MODULE_OBJS += \
graphics/dispmanxsdl/dispmanxsdl-graphics.o
endif
ifeq ($(BACKEND),samsungtv) ifeq ($(BACKEND),samsungtv)
MODULE_OBJS += \ MODULE_OBJS += \
events/samsungtvsdl/samsungtvsdl-events.o \ events/samsungtvsdl/samsungtvsdl-events.o \

View file

@ -8,7 +8,7 @@ This version of ScummVM is specially tailored to use DispmanX, the native 2D
API on the Raspberry Pi. The idea is that scaling and drawing on a double API on the Raspberry Pi. The idea is that scaling and drawing on a double
buffer with a non-blocking vsync wait is all done using the on-board VideoCore buffer with a non-blocking vsync wait is all done using the on-board VideoCore
hardware, thus using only a small fraction of the CPU ScummVM uses when ran hardware, thus using only a small fraction of the CPU ScummVM uses when ran
on a clunky, software-scaled and desynced X11 enviroment using the X11 API. on a clunky, software-scaled and desynced X11 environment using the X11 API.
Thus, running this version under an X11 session is not supported. Thus, running this version under an X11 session is not supported.
Requirements Requirements
@ -77,7 +77,7 @@ Local compilation would simply consist of the "standard" GNU/Linux building proc
cd <sources_dir> cd <sources_dir>
./configure ./configure --backend=raspberrypi -disable-debug --enable-release ./configure --backend=raspberrypi -disable-debug --enable-release
--enable-optimizations --disable-mt32emu --disable-flac --disable-mad --disable-vorbis --enable-optimizations --disable-mt32emu --disable-flac --disable-mad --disable-vorbis
--disable-tremor --disable-fluidsynth --disable-taskbar --disable-timidity --disable-alsa --disable-tremor --disable-fluidsynth --disable-taskbar --disable-timidity --disable-alsa
@ -86,7 +86,7 @@ make
¡¡It will be an SLOW process, taking several hours to complete, unless you ¡¡It will be an SLOW process, taking several hours to complete, unless you
are running distcc against a fast compilation server!! are running distcc against a fast compilation server!!
2) If we wandt to build by cross-compiling on a GNU/Linux X86-based computer, 2) If we want to build by cross-compiling on a GNU/Linux X86-based computer,
we can find concise instructions for this can be found on the ScummVM wiki: we can find concise instructions for this can be found on the ScummVM wiki:
http://wiki.scummvm.org/index.php/Compiling_ScummVM/RPI http://wiki.scummvm.org/index.php/Compiling_ScummVM/RPI

44
configure vendored
View file

@ -1052,9 +1052,9 @@ for ac_option in $@; do
--disable-libunity) _libunity=no ;; --disable-libunity) _libunity=no ;;
--enable-opengl) _opengl=yes ;; --enable-opengl) _opengl=yes ;;
--disable-opengl) _opengl=no ;; --disable-opengl) _opengl=no ;;
--enable-dispmanx) _dispmanx=yes ;; --enable-dispmanx) _dispmanx=yes ;;
--disable-dispmanx) _dispmanx=no ;; --disable-dispmanx) _dispmanx=no ;;
--enable-bink) _bink=yes ;; --enable-bink) _bink=yes ;;
--disable-bink) _bink=no ;; --disable-bink) _bink=no ;;
--enable-verbose-build) _verbose_build=yes ;; --enable-verbose-build) _verbose_build=yes ;;
--enable-plugins) _dynamic_modules=yes ;; --enable-plugins) _dynamic_modules=yes ;;
@ -1304,7 +1304,6 @@ raspberrypi)
_host_os=linux _host_os=linux
_host_cpu=arm _host_cpu=arm
_host_alias=arm-linux-gnueabihf _host_alias=arm-linux-gnueabihf
_backend=raspberrypi
;; ;;
caanoo) caanoo)
_host_os=gph-linux _host_os=gph-linux
@ -2549,6 +2548,17 @@ if test -n "$_host"; then
_seq_midi=no _seq_midi=no
_port_mk="backends/platform/dingux/dingux.mk" _port_mk="backends/platform/dingux/dingux.mk"
;; ;;
raspberrypi)
# We should have setup raspberrypi-sdl-config with modified prefix as part of
# the cross-building enviroment.
_savegame_timestamp=no
_eventrec=no
_build_scalers=no
_build_hq_scalers=no
# It makes no sense to have both GL and dispmanx rendering support.
_opengl=no
_opengles=no
;;
dreamcast) dreamcast)
DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER" DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER"
DEFINES="$DEFINES -DDISABLE_TEXT_CONSOLE" DEFINES="$DEFINES -DDISABLE_TEXT_CONSOLE"
@ -2993,6 +3003,8 @@ case $_backend in
LIBS="$LIBS -Wl,-Map,mapfile.txt" LIBS="$LIBS -Wl,-Map,mapfile.txt"
;; ;;
raspberrypi) raspberrypi)
LIBS="$LIBS -L$RPI_ROOT/usr/lib"
LIBS="$LIBS -L$RPI_ROOT/usr/lib/arm-linux-gnueabihf"
;; ;;
samsungtv) samsungtv)
DEFINES="$DEFINES -DSAMSUNGTV" DEFINES="$DEFINES -DSAMSUNGTV"
@ -3129,23 +3141,6 @@ case $_backend in
;; ;;
esac esac
#
# In raspberry Pi, we don't use find_sdlconfig since we could be crosscompiling, but still we use SDL
#
case $_backend in
raspberrypi)
INCLUDES="$INCLUDES -I$RPI_ROOTDIR/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT"
LIBS="$LIBS -L$RPI_ROOTDIR/usr/lib -L$RPI_ROOTDIR/usr/lib/arm-linux-gnueabihf -lSDL"
DEFINES="$DEFINES -DSDL_BACKEND"
add_line_to_config_mk "SDL_BACKEND = 1"
_16bit=yes
_savegame_timestamp=no
_eventrec=no
_build_scalers=no
_build_hq_scalers=no
;;
esac
# #
# Determine whether host is POSIX compliant, or at least POSIX # Determine whether host is POSIX compliant, or at least POSIX
# compatible enough to support our POSIX code (including dlsym(), # compatible enough to support our POSIX code (including dlsym(),
@ -4083,8 +4078,8 @@ define_in_config_if_yes "$_opengles" "USE_GLES"
if test "$_dispmanx" = "yes" ; then if test "$_dispmanx" = "yes" ; then
echocheck "DispmanX graphics" echocheck "DispmanX graphics"
_use_dispmanx=no _use_dispmanx=no
DISPMANX_CXXFLAGS="-I$RPI_ROOTDIR/opt/vc/include -I$RPI_ROOTDIR/opt/vc/include/interface/vmcs_host/linux/ -I$RPI_ROOTDIR/opt/vc/include/interface/vcos/pthreads -mfpu=vfp -mfloat-abi=hard -I$RPI_ROOTDIR/opt/rpi_root/usr/include/SDL" DISPMANX_CXXFLAGS="-I$RPI_ROOT/opt/vc/include -I$RPI_ROOT/opt/vc/include/interface/vmcs_host/linux/ -I$RPI_ROOT/opt/vc/include/interface/vcos/pthreads -I$RPI_ROOT/opt/rpi_root/usr/include/SDL"
DISPMANX_LIBS="--sysroot=$RPI_ROOTDIR -L$RPI_ROOTDIR/usr/lib -L$RPI_ROOTDIR/opt/vc/lib -lbcm_host -lvcos -lvchiq_arm" DISPMANX_LIBS="--sysroot=$RPI_ROOT -L$RPI_ROOT/usr/lib -L$RPI_ROOT/opt/vc/lib -lbcm_host -lvcos -lvchiq_arm"
cat > $TMPC << EOF cat > $TMPC << EOF
#include <bcm_host.h> #include <bcm_host.h>
@ -4096,11 +4091,8 @@ EOF
if test "$_use_dispmanx" = "yes"; then if test "$_use_dispmanx" = "yes"; then
CXXFLAGS="$CXXFLAGS $DISPMANX_CXXFLAGS" CXXFLAGS="$CXXFLAGS $DISPMANX_CXXFLAGS"
LIBS="$LIBS $DISPMANX_LIBS" LIBS="$LIBS $DISPMANX_LIBS"
MODULES="$MODULES backends/platform/sdl"
DEFINES="$DEFINES -DRASPBERRYPI" DEFINES="$DEFINES -DRASPBERRYPI"
add_line_to_config_mk 'RASPBERRYPI = 1' add_line_to_config_mk 'RASPBERRYPI = 1'
_opengl=no
_opengles=no
echo $_use_dispmanx echo $_use_dispmanx
fi fi
fi fi