Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
44
6.6.3 Code Description
We start with driver initialization and setup of the display. The macro UTIL_SUCCESS used in this example is a
simple error handling helper.
/* Initialize the driver */
UTIL_SUCCESS(ret, mmlGdcSysInitializeDriver(0));
UTIL_SUCCESS(ret, utMmanReset() );
/* Allocate some of VRAM for Instruction buffer for the command sequencer. Note, that mmlGdcVideoAlloc is an
application defined routine to manage the VRAM space.
The 2D core driver does not include any management of the VRAM. */
vInstrBuffer = mmlGdcVideoAlloc(fifo_size, 0, NULL);
UTIL_SUCCESS(ret, mmlGdcSysSetInstructionBuffer(vInstrBuffer, fifo_size));
/* Setup and enable the display */
UTIL_SUCCESS(ret, mmlGdcDispOpenDisplay(&dispParams, &display));
Reset the surfaces to apply default values.
UTIL_SUCCESS(ret, mmlGdcSmResetSurfaceObject(sFrame));
UTIL_SUCCESS(ret, mmlGdcSmResetSurfaceObject(sMap));
UTIL_SUCCESS(ret, mmlGdcSmResetSurfaceObject(sPosition));
UTIL_SUCCESS(ret, mmlGdcSmResetSurfaceObject(sArrow));
We load the surfaces for the example using a utility function. The utility function sets all the related properties
including compression parameter.
/* First we load the the map surface with 1024 * 1024 pixel resolution.
Of course we will read only a part if we use it as layer in this example. */
UTIL_SUCCESS(ret, utSurfLoadBitmap(sMap, map2d, MM_FALSE));
/* Now we load the blue frame surface. Please note that this surface is run length encoded. */
UTIL_SUCCESS(ret, utSurfLoadBitmap(sFrame, frame, MM_FALSE));
/* Next we load a position indicator bitmap */
UTIL_SUCCESS(ret, utSurfLoadBitmap(sPosition, position, MM_FALSE));
/* Finally we load the arrow bitmaps (1 bpp and 2 bpp alpha channel) */
UTIL_SUCCESS(ret, utSurfLoadBitmap(sArrow, arrow, MM_FALSE));
Additional we have to create 4 windows:
/* create 4 windows for the layer */
//sMap
winprop.topLeftX = 0;
winprop.topLeftY = 0;
winprop.width = dispParams.xResolution;
// horizontal display resolution
winprop.height = dispParams.yResolution;
// vertical display resolution
winprop.features = MML_GDC_DISP_FEATURE_DECODE; /
* We do not need decode.
However it ensures the driver uses this fetch and not the multilayer fetch.
Other way: just open this window as the last one. */