Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
51
6.8.4 Preparation
First step is to initialize the driver and setup the display:
/* Initialization of driver and display */
/* 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, &s_display));
If bShowDrawRects is set, we prepare an additional layer sComment. This layer represents a minimal colored layer:
only one bit is reserved for each color channel and for alpha. As the utility function utSurfCreateBuffer only supports
common color formats, we create our own function CreateCommentSurface.
static
MM_ERROR CreateCommentSurface(MML_GDC_SURFACE sComment)
{
MM_ERROR ret = MML_OK;
void
*vp;
vp = mmlGdcVideoAlloc( (BGR_WIDTH * BGR_HEIGHT * 4 / 8), 0, NULL);
if
(vp == NULL)
{
return
MML_ERR;
}
UTIL_SUCCESS(ret, mmlGdcSmResetSurfaceObject(sComment));
mmlGdcSmSetAttribute(sComment, MML_GDC_SURF_ATTR_WIDTH, BGR_WIDTH);
mmlGdcSmSetAttribute(sComment, MML_GDC_SURF_ATTR_HEIGHT, BGR_HEIGHT);
mmlGdcSmSetAttribute(sComment, MML_GDC_SURF_ATTR_BITPERPIXEL, 4);
mmlGdcSmSetAttribute(sComment, MML_GDC_SURF_ATTR_COLORBITS, 0x01010101);
mmlGdcSmSetAttribute(sComment, MML_GDC_SURF_ATTR_COLORSHIFT, 0x03020100);
mmlGdcSmSetAttribute(sComment, MML_GDC_SURF_ATTR_BASE_ADDRESS, (MM_U32)vp);
return
ret;
}
The background layer (the scale) will only be visible if bShowDrawRects is not set, to keep the example simple. As
this layer is not of interest for the tutorial, we just use a helper function DrawBgr() to draw several image sources in
our sBgr buffer.
/* Create a surface for background */
UTIL_SUCCESS(ret, mmlGdcSmResetSurfaceObject(&s_sBgr));
UTIL_SUCCESS(ret, utSurfCreateBuffer(&s_sBgr, BGR_WIDTH, BGR_HEIGHT,
MML_GDC_SURF_FORMAT_R5G6B5));