STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
GUIDRV_Lin_Private.h
Go to the documentation of this file.
1 /*********************************************************************
2 * SEGGER Microcontroller GmbH & Co. KG *
3 * Solutions for real time microcontroller applications *
4 **********************************************************************
5 * *
6 * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG *
7 * *
8 * Internet: www.segger.com Support: support@segger.com *
9 * *
10 **********************************************************************
11 
12 ** emWin V5.28 - Graphical user interface for embedded applications **
13 All Intellectual Property rights in the Software belongs to SEGGER.
14 emWin is protected by international copyright laws. Knowledge of the
15 source code may not be used to write a similar product. This file may
16 only be used in accordance with the following terms:
17 
18 The software has been licensed to STMicroelectronics International
19 N.V. a Dutch company with a Swiss branch and its headquarters in Plan-
20 les-Ouates, Geneva, 39 Chemin du Champ des Filles, Switzerland for the
21 purposes of creating libraries for ARM Cortex-M-based 32-bit microcon_
22 troller products commercialized by Licensee only, sublicensed and dis_
23 tributed under the terms and conditions of the End User License Agree_
24 ment supplied by STMicroelectronics International N.V.
25 Full source code is available at: www.segger.com
26 
27 We appreciate your understanding and fairness.
28 ----------------------------------------------------------------------
29 File : GUIDRV_Lin_Private.h
30 Purpose : Common definitions and common code for all LIN-drivers
31 ---------------------------END-OF-HEADER------------------------------
32 */
33 
34 #ifndef GUIDRV_LIN_PRIVATE_H
35 #define GUIDRV_LIN_PRIVATE_H
36 
37 #include <string.h>
38 
39 #if defined(__cplusplus)
40 extern "C" { /* Make sure we have C-declarations in C++ programs */
41 #endif
42 
43 /*********************************************************************
44 *
45 * Common definitions for all variants of the LIN driver
46 *
47 **********************************************************************
48 */
49 #if defined(WIN32) && !defined(GUIDRV_SLAYER)
50  //
51  // Simulation prototypes
52  //
53  U16 SIM_Lin_ReadMem16 (unsigned int Off);
54  U32 SIM_Lin_ReadMem32 (unsigned int Off);
55  U8 SIM_Lin_ReadMem08p (U8 * p);
56  U32 SIM_Lin_ReadMem32p (U32 * p);
57  void SIM_Lin_WriteMem16 (unsigned int Off, U16 Data);
58  void SIM_Lin_WriteMem32 (unsigned int Off, U32 Data);
59  void SIM_Lin_WriteMem08p(U8 * p, U8 Data);
60  void SIM_Lin_WriteMem16p(U16 * p, U16 Data);
61  void SIM_Lin_WriteMem32p(U32 * p, U32 Data);
62  void SIM_Lin_memcpy (void * pDst, const void * pSrc, int Len);
63  void SIM_Lin_memset (void * pDst, U8 Value, U32 Len);
64  void SIM_Lin_SetVRAMAddr(int LayerIndex, void * pVRAM);
65  void SIM_Lin_SetVRAMSize(int LayerIndex, int vxSize, int vySize, int xSize, int ySize);
66  void SIM_Lin_CopyBuffer (int IndexSrc, int IndexDst);
67  void SIM_Lin_ShowBuffer (int Index);
68  //
69  // Access macro definition for internal simulation
70  //
71  #define LCD_READ_MEM16(VRAMAddr, Off) SIM_Lin_ReadMem16(Off)
72  #define LCD_READ_MEM32(VRAMAddr, Off) SIM_Lin_ReadMem32(Off)
73  #define LCD_READ_MEM08P(p) SIM_Lin_ReadMem08p(p)
74  #define LCD_READ_MEM32P(p) SIM_Lin_ReadMem32p(p)
75  #define LCD_WRITE_MEM16(VRAMAddr, Off, Data) SIM_Lin_WriteMem16(Off, Data)
76  #define LCD_WRITE_MEM32(VRAMAddr, Off, Data) SIM_Lin_WriteMem32(Off, Data)
77  #define LCD_WRITE_MEM08P(p, Data) SIM_Lin_WriteMem08p(p, Data)
78  #define LCD_WRITE_MEM16P(p, Data) SIM_Lin_WriteMem16p(p, Data)
79  #define LCD_WRITE_MEM32P(p, Data) SIM_Lin_WriteMem32p(p, Data)
80  #undef GUI_MEMCPY
81  #define GUI_MEMCPY(pDst, pSrc, Len) SIM_Lin_memcpy(pDst, pSrc, Len)
82  #undef GUI_MEMSET
83  #define GUI_MEMSET(pDst, Value, Len) SIM_Lin_memset(pDst, Value, Len)
84 #else
85  //
86  // Access macro definition for hardware
87  //
88  #define LCD_READ_MEM16(VRAMAddr, Off) (*((U16 *)VRAMAddr + (U32)Off))
89  #define LCD_READ_MEM32(VRAMAddr, Off) (*((U32 *)VRAMAddr + (U32)Off))
90  #define LCD_READ_MEM08P(p) (*((U8 *)p))
91  #define LCD_READ_MEM32P(p) (*((U32 *)p))
92  #define LCD_WRITE_MEM16(VRAMAddr, Off, Data) *((U16 *)VRAMAddr + (U32)Off) = Data
93  #define LCD_WRITE_MEM32(VRAMAddr, Off, Data) *((U32 *)VRAMAddr + (U32)Off) = Data
94  #define LCD_WRITE_MEM08P(p, Data) *((U8 *)p) = Data
95  #define LCD_WRITE_MEM16P(p, Data) *((U16 *)p) = Data
96  #define LCD_WRITE_MEM32P(p, Data) *((U32 *)p) = Data
97 #endif
98 
99 #define WRITE_MEM16(VRAMAddr, Off, Data) LCD_WRITE_MEM16(VRAMAddr, Off, Data)
100 #define WRITE_MEM32(VRAMAddr, Off, Data) LCD_WRITE_MEM32(VRAMAddr, Off, Data)
101 #define READ_MEM08P(p) LCD_READ_MEM08P(p)
102 #define READ_MEM16(VRAMAddr, Off) LCD_READ_MEM16(VRAMAddr, Off)
103 #define READ_MEM32(VRAMAddr, Off) LCD_READ_MEM32(VRAMAddr, Off)
104 #define READ_MEM32P(p) LCD_READ_MEM32P(p)
105 #define WRITE_MEM08P(p, Data) LCD_WRITE_MEM08P(p, Data)
106 #define WRITE_MEM16P(p, Data) LCD_WRITE_MEM16P(p, Data)
107 #define WRITE_MEM32P(p, Data) LCD_WRITE_MEM32P(p, Data)
108 
109 #define OFF2PTR08(VRAMAddr, Off) (U8 *)((U8 *)VRAMAddr + (Off ))
110 #define OFF2PTR16(VRAMAddr, Off) (U16 *)((U8 *)VRAMAddr + (Off << 1))
111 #define OFF2PTR32(VRAMAddr, Off) (U32 *)((U8 *)VRAMAddr + (Off << 2))
112 
113 //
114 // Definition of default members for DRIVER_CONTEXT structure
115 //
116 #define DEFAULT_CONTEXT_MEMBERS \
117  U32 VRAMAddr; \
118  U32 BaseAddr; \
119  int BufferIndex; \
120  int xSize, ySize; \
121  int vxSize, vySize; \
122  int vxSizePhys; \
123  int xPos, yPos; \
124  int Alpha; \
125  int IsVisible; \
126  void (* pfFillRect) (int /* LayerIndex */, \
127  int /* x0 */, \
128  int /* y0 */, \
129  int /* x1 */, \
130  int /* y1 */, \
131  U32 /* PixelIndex */); \
132  void (* pfCopyBuffer)(int /* LayerIndex */, \
133  int /* IndexSrc */, \
134  int /* IndexDst */); \
135  void (* pfDrawBMP1) (int /* LayerIndex */, \
136  int /* x */, \
137  int /* y */, \
138  U8 const * /* p */, \
139  int /* Diff */, \
140  int /* xSize */, \
141  int /* ySize */, \
142  int /* BytesPerLine */, \
143  const LCD_PIXELINDEX * /* pTrans */); \
144  void (* pfDrawBMP8) (int /* LayerIndex */, \
145  int /* x */, \
146  int /* y */, \
147  U8 const * /* p */, \
148  int /* xSize */, \
149  int /* ySize */, \
150  int /* BytesPerLine */, \
151  const LCD_PIXELINDEX * /* pTrans */); \
152  void (* pfCopyRect) (int /* LayerIndex */, \
153  int /* x0 */, \
154  int /* y0 */, \
155  int /* x1 */, \
156  int /* y1 */, \
157  int /* xSize */, \
158  int /* ySize */);
159 
160 #ifndef PRIVATE_CONTEXT_MEMBERS
161  #define PRIVATE_CONTEXT_MEMBERS
162 #endif
163 
164 //
165 // Definition of default function management for _GetDevFunc()
166 //
167 #define DEFAULT_MANAGEMENT_GETDEVFUNC() \
168  case LCD_DEVFUNC_SET_VRAM_ADDR: \
169  return (void (*)(void))_SetVRAMAddr; \
170  case LCD_DEVFUNC_SET_VSIZE: \
171  return (void (*)(void))_SetVSize; \
172  case LCD_DEVFUNC_SET_SIZE: \
173  return (void (*)(void))_SetSize; \
174  case LCD_DEVFUNC_SETPOS: \
175  return (void (*)(void))_SetPos; \
176  case LCD_DEVFUNC_GETPOS: \
177  return (void (*)(void))_GetPos; \
178  case LCD_DEVFUNC_SETALPHA: \
179  return (void (*)(void))_SetAlpha; \
180  case LCD_DEVFUNC_SETVIS: \
181  return (void (*)(void))_SetVis; \
182  case LCD_DEVFUNC_INIT: \
183  return (void (*)(void))_Init; \
184  case LCD_DEVFUNC_ON: \
185  return (void (*)(void))_On; \
186  case LCD_DEVFUNC_OFF: \
187  return (void (*)(void))_Off; \
188  case LCD_DEVFUNC_ALPHAMODE: \
189  return (void (*)(void))_SetAlphaMode; \
190  case LCD_DEVFUNC_CHROMAMODE: \
191  return (void (*)(void))_SetChromaMode; \
192  case LCD_DEVFUNC_CHROMA: \
193  return (void (*)(void))_SetChroma; \
194  case LCD_DEVFUNC_COPYBUFFER: \
195  return (void (*)(void))_CopyBuffer; \
196  case LCD_DEVFUNC_SHOWBUFFER: \
197  return (void (*)(void))_ShowBuffer; \
198  case LCD_DEVFUNC_SETFUNC: \
199  return (void (*)(void))_SetDevFunc; \
200  case LCD_DEVFUNC_FILLRECT: \
201  return (void (*)(void))((DRIVER_CONTEXT *)(*ppDevice)->u.pContext)->pfFillRect; \
202  case LCD_DEVFUNC_DRAWBMP_1BPP: \
203  return (void (*)(void))((DRIVER_CONTEXT *)(*ppDevice)->u.pContext)->pfDrawBMP1; \
204  case LCD_DEVFUNC_DRAWBMP_8BPP: \
205  return (void (*)(void))((DRIVER_CONTEXT *)(*ppDevice)->u.pContext)->pfDrawBMP8; \
206  case LCD_DEVFUNC_COPYRECT: \
207  return (void (*)(void))((DRIVER_CONTEXT *)(*ppDevice)->u.pContext)->pfCopyRect;
208 
209 //
210 // Definition of private function management for _GetDevFunc()
211 //
212 #ifndef PRIVATE_MANAGEMENT_GETDEVFUNC
213  #define PRIVATE_MANAGEMENT_GETDEVFUNC()
214 #endif
215 
216 //
217 // Definition of default function management for _SetDevFunc()
218 //
219 #define DEFAULT_MANAGEMENT_SETDEVFUNC() \
220  case LCD_DEVFUNC_FILLRECT: \
221  pContext->pfFillRect = (void (*)(int LayerIndex, int x0, int y0, int x1, int y1, U32 PixelIndex))pFunc; \
222  break; \
223  case LCD_DEVFUNC_COPYBUFFER: \
224  pContext->pfCopyBuffer = (void (*)(int LayerIndex, int IndexSrc, int IndexDst))pFunc; \
225  break; \
226  case LCD_DEVFUNC_DRAWBMP_1BPP: \
227  pContext->pfDrawBMP1 = (void (*)(int LayerIndex, int x, int y, U8 const * p, int Diff, int xSize, int ySize, int BytesPerLine, const LCD_PIXELINDEX * pTrans))pFunc; \
228  break; \
229  case LCD_DEVFUNC_DRAWBMP_8BPP: \
230  pContext->pfDrawBMP8 = (void (*)(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine, const LCD_PIXELINDEX * pTrans))pFunc; \
231  break; \
232  case LCD_DEVFUNC_COPYRECT: \
233  pContext->pfCopyRect = (void (*)(int LayerIndex, int x0, int y0, int x1, int y1, int xSize, int ySize))pFunc; \
234  break;
235 
236 //
237 // Definition of private function management for _GetDevFunc()
238 //
239 #ifndef PRIVATE_MANAGEMENT_SETDEVFUNC
240  #define PRIVATE_MANAGEMENT_SETDEVFUNC()
241 #endif
242 
243 //
244 // Endian related definitions
245 //
246 #ifndef LCD_MIRROR
247  #define LCD_MIRROR 0
248 #endif
249 
250 #if (LCD_MIRROR == 2)
251 #define MIRROR(x) x = ((x & 0x000000ffUL) << 8) \
252  | ((x & 0x0000ff00UL) >> 8) \
253  | ((x & 0x00ff0000UL) << 8) \
254  | ((x & 0xff000000UL) >> 8)
255 #else
256 #define MIRROR(x) x = ((x & 0x000000ffUL) << 24) \
257  | ((x & 0x0000ff00UL) << 8) \
258  | ((x & 0x00ff0000UL) >> 8) \
259  | ((x & 0xff000000UL) >> 24)
260 #endif
261 
262 /*********************************************************************
263 *
264 * Types
265 *
266 **********************************************************************
267 */
268 //
269 // DRIVER_CONTEXT structure consisting of default and private members
270 //
271 typedef struct {
275 
276 /*********************************************************************
277 *
278 * Static code (common for all)
279 *
280 **********************************************************************
281 */
282 /*********************************************************************
283 *
284 * _InitOnce
285 *
286 * Purpose:
287 * Allocates a fixed block for the context of the driver
288 *
289 * Return value:
290 * 0 on success, 1 on error
291 */
292 static int _InitOnce(GUI_DEVICE * pDevice) {
293  if (pDevice->u.pContext == NULL) {
294  pDevice->u.pContext = GUI_ALLOC_GetFixedBlock(sizeof(DRIVER_CONTEXT));
295  GUI__memset((U8 *)pDevice->u.pContext, 0, sizeof(DRIVER_CONTEXT));
296  }
297  return pDevice->u.pContext ? 0 : 1;
298 }
299 
300 /*********************************************************************
301 *
302 * _GetRect
303 *
304 * Purpose:
305 * Returns the display size.
306 */
307 static void _GetRect(GUI_DEVICE * pDevice, LCD_RECT * pRect) {
308  DRIVER_CONTEXT * pContext;
309 
310  pContext = (DRIVER_CONTEXT *)pDevice->u.pContext;
311  pRect->x0 = 0;
312  pRect->y0 = 0;
313  pRect->x1 = pContext->vxSize - 1;
314  pRect->y1 = pContext->vySize - 1;
315 }
316 
317 /*********************************************************************
318 *
319 * _SetPos
320 *
321 * Purpose:
322 * Sets the position of the given layer by sending a LCD_X_SETPOS command to LCD_X_DisplayDriver()
323 * (Requires special hardware support.)
324 */
325 static void _SetPos(GUI_DEVICE * pDevice, int xPos, int yPos) {
326  DRIVER_CONTEXT * pContext;
327  LCD_X_SETPOS_INFO Data = {0};
328 
329  _InitOnce(pDevice);
330  if (pDevice->u.pContext) {
331  pContext = (DRIVER_CONTEXT *)pDevice->u.pContext;
332  pContext->xPos = xPos;
333  pContext->yPos = yPos;
334  Data.xPos = xPos;
335  Data.yPos = yPos;
336  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETPOS, (void *)&Data);
337  }
338 }
339 
340 /*********************************************************************
341 *
342 * _GetPos
343 *
344 * Purpose:
345 * Returns the position of the given layer.
346 */
347 static void _GetPos(GUI_DEVICE * pDevice, int * pxPos, int * pyPos) {
348  DRIVER_CONTEXT * pContext;
349 
350  _InitOnce(pDevice);
351  if (pDevice->u.pContext) {
352  pContext = (DRIVER_CONTEXT *)pDevice->u.pContext;
353  *pxPos = pContext->xPos;
354  *pyPos = pContext->yPos;
355  }
356 }
357 
358 /*********************************************************************
359 *
360 * _SetAlpha
361 *
362 * Purpose:
363 * Sets the alpha value of the given layer by sending a LCD_X_SETALPHA command to LCD_X_DisplayDriver()
364 * (Requires special hardware support.)
365 */
366 static void _SetAlpha(GUI_DEVICE * pDevice, int Alpha) {
367  DRIVER_CONTEXT * pContext;
368  LCD_X_SETALPHA_INFO Data = {0};
369 
370  _InitOnce(pDevice);
371  if (pDevice->u.pContext) {
372  pContext = (DRIVER_CONTEXT *)pDevice->u.pContext;
373  pContext->Alpha = Alpha;
374  Data.Alpha = Alpha;
375  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETALPHA, (void *)&Data);
376  }
377 }
378 
379 /*********************************************************************
380 *
381 * _SetVis
382 *
383 * Purpose:
384 * Sets the visibility of the given layer by sending a LCD_X_SETVIS command to LCD_X_DisplayDriver()
385 * (Requires special hardware support.)
386 */
387 static void _SetVis(GUI_DEVICE * pDevice, int OnOff) {
388  DRIVER_CONTEXT * pContext;
389  LCD_X_SETVIS_INFO Data = {0};
390 
391  _InitOnce(pDevice);
392  if (pDevice->u.pContext) {
393  pContext = (DRIVER_CONTEXT *)pDevice->u.pContext;
394  pContext->IsVisible = OnOff;
395  Data.OnOff = OnOff;
396  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETVIS, (void *)&Data);
397  }
398 }
399 
400 /*********************************************************************
401 *
402 * _Init
403 *
404 * Purpose:
405 * Called during the initialization process of emWin.
406 */
407 static int _Init(GUI_DEVICE * pDevice) {
408  int r;
409 
410  r = _InitOnce(pDevice);
412  return r;
413 }
414 
415 /*********************************************************************
416 *
417 * _On
418 *
419 * Purpose:
420 * Sends a LCD_X_ON command to LCD_X_DisplayDriver().
421 */
422 static void _On (GUI_DEVICE * pDevice) {
424 }
425 
426 /*********************************************************************
427 *
428 * _Off
429 *
430 * Purpose:
431 * Sends a LCD_X_OFF command to LCD_X_DisplayDriver().
432 */
433 static void _Off (GUI_DEVICE * pDevice) {
435 }
436 
437 /*********************************************************************
438 *
439 * _SetAlphaMode
440 *
441 * Purpose:
442 * Sets the alpha mode of the given layer by sending a LCD_X_SETALPHAMODE command to LCD_X_DisplayDriver()
443 * (Requires special hardware support.)
444 */
445 static void _SetAlphaMode(GUI_DEVICE * pDevice, int AlphaMode) {
446  LCD_X_SETALPHAMODE_INFO Data = {0};
447 
448  Data.AlphaMode = AlphaMode;
449  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETALPHAMODE, (void *)&Data);
450 }
451 
452 /*********************************************************************
453 *
454 * _SetChromaMode
455 *
456 * Purpose:
457 * Sets the chroma mode of the given layer by sending a LCD_X_SETCHROMAMODE command to LCD_X_DisplayDriver()
458 * (Requires special hardware support.)
459 */
460 static void _SetChromaMode(GUI_DEVICE * pDevice, int ChromaMode) {
461  LCD_X_SETCHROMAMODE_INFO Data = {0};
462 
463  Data.ChromaMode = ChromaMode;
464  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETCHROMAMODE, (void *)&Data);
465 }
466 
467 /*********************************************************************
468 *
469 * _SetChroma
470 *
471 * Purpose:
472 * Sets the chroma values of the given layer by sending a LCD_X_SETCHROMA command to LCD_X_DisplayDriver()
473 * (Requires special hardware support.)
474 */
475 static void _SetChroma(GUI_DEVICE * pDevice, LCD_COLOR ChromaMin, LCD_COLOR ChromaMax) {
476  LCD_X_SETCHROMA_INFO Data = {0};
477 
478  Data.ChromaMin = ChromaMin;
479  Data.ChromaMax = ChromaMax;
480  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETCHROMA, (void *)&Data);
481 }
482 
483 /*********************************************************************
484 *
485 * _CopyBuffer
486 *
487 * Purpose:
488 * Copies the source buffer to the destination buffer and routes
489 * further drawing operations to the destination buffer.
490 *
491 * (Required for using multiple buffers)
492 */
493 static void _CopyBuffer(GUI_DEVICE * pDevice, int IndexSrc, int IndexDst) {
494  DRIVER_CONTEXT * pContext;
495  #if (!defined(WIN32) | defined(GUIDRV_SLAYER))
496  U32 AddrSrc, AddrDst;
497  I32 BufferSize;
498  int BitsPerPixel;
499  #endif
500 
501  _InitOnce(pDevice);
502  if (pDevice->u.pContext) {
503  pContext = (DRIVER_CONTEXT *)pDevice->u.pContext;
504  if (IndexSrc != IndexDst) {
505  #if defined(WIN32) && !defined(GUIDRV_SLAYER)
506  SIM_Lin_CopyBuffer(IndexSrc, IndexDst);
507  #else
508  BitsPerPixel = pDevice->pDeviceAPI->pfGetDevProp(pDevice, LCD_DEVCAP_BITSPERPIXEL);
509  BufferSize = (((U32)pContext->xSize * pContext->ySize * BitsPerPixel) >> 3);
510  AddrSrc = pContext->BaseAddr + BufferSize * IndexSrc;
511  AddrDst = pContext->BaseAddr + BufferSize * IndexDst;
512  if (pContext->pfCopyBuffer) {
513  //
514  // Use custom callback function for copy operation
515  //
516  pContext->pfCopyBuffer(pDevice->LayerIndex, IndexSrc, IndexDst);
517  } else {
518  //
519  // Calculate pointers for copy operation
520  //
521  GUI_MEMCPY((void *)AddrDst, (void *)AddrSrc, BufferSize);
522  }
523  //
524  // Set destination buffer as target for further drawing operations
525  //
526  pContext->VRAMAddr = AddrDst;
527  #endif
528  }
529  }
530 }
531 
532 /*********************************************************************
533 *
534 * _ShowBuffer
535 *
536 * Purpose:
537 * Sends a LCD_X_SHOWBUFFER command to LCD_X_DisplayDriver() to make the given buffer visible.
538 *
539 * (Required for using multiple buffers)
540 */
541 static void _ShowBuffer(GUI_DEVICE * pDevice, int Index) {
542  LCD_X_SHOWBUFFER_INFO Data = {0};
543 
544  _InitOnce(pDevice);
545  if (pDevice->u.pContext) {
546  #if defined(WIN32) && !defined(GUIDRV_SLAYER)
547  SIM_Lin_ShowBuffer(Index);
548  #else
549  Data.Index = Index;
550  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SHOWBUFFER, (void *)&Data);
551  #endif
552  }
553 }
554 
555 /*********************************************************************
556 *
557 * _SetOrg
558 *
559 * Purpose:
560 * Calls the driver callback function with the display origin to be set
561 */
562 static void _SetOrg(GUI_DEVICE * pDevice, int x, int y) {
563  #if (!defined(WIN32) | defined(GUIDRV_SLAYER))
564  DRIVER_CONTEXT * pContext;
565  int Orientation;
566  #endif
567  LCD_X_SETORG_INFO Data = {0};
568 
569  #if defined(WIN32) && !defined(GUIDRV_SLAYER)
570  LCDSIM_SetOrg(x, y, pDevice->LayerIndex);
571  #else
572  pContext = (DRIVER_CONTEXT *)pDevice->u.pContext;
573  Orientation = LCD_GetMirrorXEx(pDevice->LayerIndex) * GUI_MIRROR_X;
574  Orientation |= LCD_GetMirrorYEx(pDevice->LayerIndex) * GUI_MIRROR_Y;
575  Orientation |= LCD_GetSwapXYEx (pDevice->LayerIndex) * GUI_SWAP_XY;
576  switch (Orientation) {
577  case 0:
578  Data.xPos = x;
579  Data.yPos = y;
580  break;
581  case GUI_MIRROR_X:
582  Data.xPos = pContext->vxSize - pContext->xSize - x;
583  Data.yPos = y;
584  break;
585  case GUI_MIRROR_Y:
586  Data.xPos = x;
587  Data.yPos = pContext->vySize - pContext->ySize - y;
588  break;
589  case GUI_MIRROR_X | GUI_MIRROR_Y:
590  Data.xPos = pContext->vxSize - pContext->xSize - x;
591  Data.yPos = pContext->vySize - pContext->ySize - y;
592  break;
593  case GUI_SWAP_XY:
594  Data.xPos = y;
595  Data.yPos = x;
596  break;
597  case GUI_SWAP_XY | GUI_MIRROR_X:
598  Data.xPos = pContext->vySize - pContext->ySize - y;
599  Data.yPos = x;
600  break;
601  case GUI_SWAP_XY | GUI_MIRROR_Y:
602  Data.xPos = y;
603  Data.yPos = pContext->vxSize - pContext->xSize - x;
604  break;
606  Data.xPos = pContext->vySize - pContext->ySize - y;
607  Data.yPos = pContext->vxSize - pContext->xSize - x;
608  break;
609  }
610  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETORG, (void *)&Data);
611  #endif
612 }
613 
614 /*********************************************************************
615 *
616 * _SetVRAMAddr
617 */
618 static void _SetVRAMAddr(GUI_DEVICE * pDevice, void * pVRAM) {
619  DRIVER_CONTEXT * pContext;
620  LCD_X_SETVRAMADDR_INFO Data = {0};
621 
622  _InitOnce(pDevice);
623  if (pDevice->u.pContext) {
624  pContext = (DRIVER_CONTEXT *)pDevice->u.pContext;
625  pContext->VRAMAddr = pContext->BaseAddr = (U32)pVRAM;
626  Data.pVRAM = pVRAM;
627  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETVRAMADDR, (void *)&Data);
628  }
629  #if defined(WIN32) && !defined(GUIDRV_SLAYER)
630  SIM_Lin_SetVRAMAddr(pDevice->LayerIndex, pVRAM);
631  #endif
632 }
633 
634 /*********************************************************************
635 *
636 * _SetVSize
637 */
638 static void _SetVSize(GUI_DEVICE * pDevice, int xSize, int ySize) {
639  DRIVER_CONTEXT * pContext;
640  #if defined(WIN32) && !defined(GUIDRV_SLAYER)
641  int NumBuffers;
642  #endif
643 
644  _InitOnce(pDevice);
645  if (pDevice->u.pContext) {
646  #if defined(WIN32) && !defined(GUIDRV_SLAYER)
647  NumBuffers = GUI_MULTIBUF_GetNumBuffers();
648  #endif
649  pContext = (DRIVER_CONTEXT *)pDevice->u.pContext;
650  if (LCD_GetSwapXYEx(pDevice->LayerIndex)) {
651  #if defined(WIN32) && !defined(GUIDRV_SLAYER)
652  pContext->vxSize = xSize * NumBuffers;
653  #else
654  pContext->vxSize = xSize;
655  #endif
656  pContext->vySize = ySize;
657  pContext->vxSizePhys = ySize;
658  } else {
659  pContext->vxSize = xSize;
660  #if defined(WIN32) && !defined(GUIDRV_SLAYER)
661  pContext->vySize = ySize * NumBuffers;
662  #else
663  pContext->vySize = ySize;
664  #endif
665  pContext->vxSizePhys = xSize;
666  }
667  }
668  #if defined(WIN32) && !defined(GUIDRV_SLAYER)
669  SIM_Lin_SetVRAMSize(pDevice->LayerIndex, pContext->vxSize, pContext->vySize, pContext->xSize, pContext->ySize);
670  #endif
671 }
672 
673 /*********************************************************************
674 *
675 * _SetSize
676 */
677 static void _SetSize(GUI_DEVICE * pDevice, int xSize, int ySize) {
678  DRIVER_CONTEXT * pContext;
679  LCD_X_SETSIZE_INFO Data = {0};
680 
681  _InitOnce(pDevice);
682  if (pDevice->u.pContext) {
683  pContext = (DRIVER_CONTEXT *)pDevice->u.pContext;
684  if (pContext->vxSizePhys == 0) {
685  if (LCD_GetSwapXYEx(pDevice->LayerIndex)) {
686  pContext->vxSizePhys = ySize;
687  } else {
688  pContext->vxSizePhys = xSize;
689  }
690  }
691  pContext->xSize = xSize;
692  pContext->ySize = ySize;
693  Data.xSize = xSize;
694  Data.ySize = ySize;
695  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETSIZE, (void *)&Data);
696  }
697 }
698 
699 #if defined(__cplusplus)
700 }
701 #endif
702 
703 #endif /* GUIDRV_LIN_PRIVATE_H */
704 
705 /*************************** End of file ****************************/
#define LCD_X_SETSIZE
Definition: LCD.h:520
int LCD_GetMirrorYEx(int LayerIndex)
int LCD_GetSwapXYEx(int LayerIndex)
#define U32
Definition: Global.h:50
#define LCD_DEVCAP_BITSPERPIXEL
Definition: LCD.h:346
#define PRIVATE_CONTEXT_MEMBERS
#define LCD_X_SETPOS
Definition: LCD.h:521
Definition: LCD.h:102
#define LCD_X_ON
Definition: LCD.h:518
if(LCD_Lock==DISABLE)
Definition: lcd_log.c:249
#define LCD_X_SETVIS
Definition: LCD.h:522
LCD_COLOR ChromaMax
Definition: LCD.h:503
#define LCD_X_SHOWBUFFER
Definition: LCD.h:527
union GUI_DEVICE::@32 u
#define GUI_MEMCPY(pDest, pSrc, NumBytes)
#define LCD_X_INITCONTROLLER
Definition: LCD.h:514
#define LCD_X_SETCHROMA
Definition: LCD.h:526
void * pContext
Definition: GUI.h:179
I16 y0
Definition: LCD.h:102
#define LCD_X_SETALPHA
Definition: LCD.h:523
#define LCD_X_OFF
Definition: LCD.h:519
#define NULL
Definition: usbd_def.h:53
I32(* pfGetDevProp)(GUI_DEVICE *pDevice, int Index)
Definition: GUI.h:116
int LayerIndex
Definition: GUI.h:187
I16 y1
Definition: LCD.h:102
#define GUI_MIRROR_X
Definition: GUI.h:1968
U32 LCD_COLOR
Definition: LCD.h:95
#define LCD_X_SETCHROMAMODE
Definition: LCD.h:525
#define LCD_X_SETVRAMADDR
Definition: LCD.h:515
void GUI__memset(U8 *p, U8 Fill, int NumBytes)
#define LCD_X_SETORG
Definition: LCD.h:516
int GUI_MULTIBUF_GetNumBuffers(void)
#define GUI_MIRROR_Y
Definition: GUI.h:1969
#define GUI_SWAP_XY
Definition: GUI.h:1970
void * GUI_ALLOC_GetFixedBlock(GUI_ALLOC_DATATYPE Size)
#define DEFAULT_CONTEXT_MEMBERS
struct DRIVER_CONTEXT DRIVER_CONTEXT
I16 x1
Definition: LCD.h:102
int LCD_GetMirrorXEx(int LayerIndex)
#define LCD_X_SETALPHAMODE
Definition: LCD.h:524
#define U16
Definition: Global.h:47
I16 x0
Definition: LCD.h:102
LCD_COLOR ChromaMin
Definition: LCD.h:502
#define I32
Definition: Global.h:59
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void *pData)
This function is called by the display driver for several purposes. To support the according task the...
Definition: LCDConf.c:857
const GUI_DEVICE_API * pDeviceAPI
Definition: GUI.h:184
void LCDSIM_SetOrg(int x, int y, int LayerIndex)
#define U8
Definition: Global.h:44