vglite_support.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright 2019 NXP
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #include "vglite_support.h"
  8. #include "fsl_clock.h"
  9. #include "vg_lite.h"
  10. #include "vg_lite_platform.h"
  11. #include "display_support.h"
  12. /*******************************************************************************
  13. * Definitions
  14. ******************************************************************************/
  15. #define MAX_CONTIGUOUS_SIZE 0x200000
  16. /*******************************************************************************
  17. * Prototypes
  18. ******************************************************************************/
  19. /*******************************************************************************
  20. * Variables
  21. ******************************************************************************/
  22. static uint32_t registerMemBase = 0x41800000;
  23. static uint32_t gpu_mem_base = 0x0;
  24. /*
  25. * In case custom VGLite memory parameters are used, the application needs to
  26. * allocate and publish the VGLite heap base, its size and the size of the
  27. * command buffer(s) using the following global variables:
  28. */
  29. extern void *vglite_heap_base;
  30. extern uint32_t vglite_heap_size;
  31. #if (CUSTOM_VGLITE_MEMORY_CONFIG == 0)
  32. /* VGLite driver heap */
  33. AT_NONCACHEABLE_SECTION_ALIGN(static uint8_t contiguous_mem[MAX_CONTIGUOUS_SIZE], FRAME_BUFFER_ALIGN);
  34. void *vglite_heap_base = &contiguous_mem;
  35. uint32_t vglite_heap_size = MAX_CONTIGUOUS_SIZE;
  36. #endif /* CUSTOM_VGLITE_MEMORY_CONFIG */
  37. /*******************************************************************************
  38. * Code
  39. ******************************************************************************/
  40. void GPU2D_IRQHandler(void)
  41. {
  42. vg_lite_IRQHandler();
  43. }
  44. static status_t BOARD_InitVGliteClock(void)
  45. {
  46. const clock_root_config_t gc355ClockConfig = {
  47. .clockOff = false,
  48. .mux = kCLOCK_GC355_ClockRoot_MuxVideoPllOut, /*!< 984MHz */
  49. .div = 2,
  50. };
  51. CLOCK_SetRootClock(kCLOCK_Root_Gc355, &gc355ClockConfig);
  52. CLOCK_GetRootClockFreq(kCLOCK_Root_Gc355);
  53. CLOCK_EnableClock(kCLOCK_Gpu2d);
  54. NVIC_SetPriority(GPU2D_IRQn, 3);
  55. EnableIRQ(GPU2D_IRQn);
  56. return kStatus_Success;
  57. }
  58. status_t BOARD_PrepareVGLiteController(void)
  59. {
  60. status_t status;
  61. status = BOARD_InitVGliteClock();
  62. if (kStatus_Success != status)
  63. {
  64. return status;
  65. }
  66. vg_lite_init_mem(registerMemBase, gpu_mem_base, vglite_heap_base, vglite_heap_size);
  67. return kStatus_Success;
  68. }