Graphic.c 28 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5 6 7 8 9 10 11 12 13
#include "stdlib.h"
#include "string.h"
#include "r_typedefs.h"
#include "r_config_d1x.h"
#include "r_dev_api.h"
#include "r_ddb_api.h"
#include "r_cdi_api.h"
#include "r_wm_api.h"

#include "davehd_kernel_driver.h"
#include "davehd_kernel_bridge.h"
#include "davehd_os_libc.h"
#include "r_sys_davehd.h"
hu's avatar
hu committed
14
#include "jcua.h"
hu's avatar
hu committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49


//#include "wm.h"

#include "dr7f701441.dvf.h"
//#include "r_bsp_stdio_api.h"

#include "GPIO.h"
#include "SDRAM.h"
#include "Graphic.h"

// #include "jcua.h"
#include "loc_graphics.h"
#include "loc_graphics_data.h"

/* video selection registers */
#define   GFX_REG_VDCECTL                   (0xFFC0601CUL)

/* RSDS and other video output control register */
#define   GFX_REG_RSDSCFG                   (0xFFC06020UL)

/* OpenLDI interface */
#define   GFX_REG_OLDI0CR0                  (0xF2002000UL)
#define   GFX_REG_OLDI0CR1                  (0xF2002004UL)
#define   GFX_REG_OLDI0CTRCR                (0xF200200CUL)
#define   GFX_REG_OLDI0CHCR                 (0xF2002010UL)
#define   GFX_REG_OLDI0SKEWCTR              (0xF2002070UL)








hu's avatar
hu committed
50 51
static const r_dev_PinConfig_t g_stGfxVoPinCfgRGB888[] =
    /*  Port Pin Func      Dir      Feedback     Pull        OpenDrain   HiCurr   HiSpeed  InputType */
hu's avatar
hu committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
{
    /* VDCE0 Output 24bit parallel, HSync+VSync+DE */
    {44, 0,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out Data 23 */
    {44, 1,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 2,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 3,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 4,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 5,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 6,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 7,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 8,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 9,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 10, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 11, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out Data 12 */
    {45, 0,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out CLKP */
    {45, 1,  4u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out Tcon3 DE */
    {45, 2,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out Data 11 */
    {45, 3,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 4,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 5,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 6,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 7,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 8,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 9,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 10, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 11, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 12, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 13, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out Data 0 */
    {43, 0,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out TCON2 HS */
hu's avatar
hu committed
81
    /*   43, 0,  2u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1,  VDCE0 Out Tcon3 DE (shared on same pin as TCON2 HS) */
hu's avatar
hu committed
82
    {43, 1,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out TCON0 VS */
hu's avatar
hu committed
83

hu's avatar
hu committed
84
    /* delimiter - do not remove */
hu's avatar
hu committed
85
    {0u, R_DEV_PIN_LAST, 0u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO,   0u, 0u, 0u, R_DEV_PIN_CMOS1}
hu's avatar
hu committed
86 87
};

hu's avatar
hu committed
88 89
static const r_dev_PinConfig_t g_stGfxVoPinCfgRGB666[] =
    /*  Port Pin Func      Dir      Feedback     Pull        OpenDrain   HiCurr   HiSpeed  InputType */
hu's avatar
hu committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
{
    /* VDCE0 Output 18bit parallel, HSync+VSync+DE */
    {44, 6,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out Data 17 */
    {44, 7,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 8,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 9,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 10, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {44, 11, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out Data 12 */
    {45, 0,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out CLKP */
    {45, 1,  4u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out Tcon3 DE */
    {45, 2,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out Data 11 */
    {45, 3,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 4,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 5,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 6,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 7,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 8,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 9,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 10, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 11, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 12, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1},
    {45, 13, 1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out Data 0 */
    {43, 0,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out TCON2 HS */
hu's avatar
hu committed
113
    /*   43, 0,  2u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1,  VDCE0 Out Tcon3 DE (shared on same pin as TCON2 HS) */
hu's avatar
hu committed
114
    {43, 1,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 Out TCON0 VS */
hu's avatar
hu committed
115

hu's avatar
hu committed
116
    /* delimiter - do not remove */
hu's avatar
hu committed
117
    {0u, R_DEV_PIN_LAST, 0u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO,   0u, 0u, 0u, R_DEV_PIN_CMOS1}
hu's avatar
hu committed
118 119
};

hu's avatar
hu committed
120 121
static const r_dev_PinConfig_t g_stGfxVoPinCfgOpenLDI[] =
    /*  Port Pin Func      Dir      Feedback     Pull        OpenDrain   HiCurr   HiSpeed  InputType */
hu's avatar
hu committed
122 123 124 125 126 127 128 129 130 131 132 133 134 135
{
    /* VDCE0 Output 24bit OpenLDI */
    {45, 0,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 OpenLDI ch0_p (clk_p) */
    {45, 1,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 OpenLDI ch0_n (clk_n) */
    {45, 2,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 OpenLDI ch1_p */
    {45, 3,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 OpenLDI ch1_n */
    {45, 4,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 OpenLDI ch2_p */
    {45, 5,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 OpenLDI ch2_n */
    {45, 6,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 OpenLDI ch3_p */
    {45, 7,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 OpenLDI ch3_n */
    {45, 8,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 OpenLDI ch4_p */
    {45, 9,  1u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO, 0u, 0u, 1u, R_DEV_PIN_CMOS1}, /* VDCE0 OpenLDI ch4_n */

    /* delimiter - do not remove */
hu's avatar
hu committed
136
    {0u, R_DEV_PIN_LAST, 0u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO,   0u, 0u, 0u, R_DEV_PIN_CMOS1}
hu's avatar
hu committed
137 138
};

hu's avatar
hu committed
139 140
static const r_dev_PinConfig_t g_stGfxViPinCfgITU656[] =
    /*  Port Pin Func      Dir      Feedback     Pull        OpenDrain   HiCurr   HiSpeed  InputType */
hu's avatar
hu committed
141 142 143 144 145 146 147 148 149 150 151 152 153
{
    /* VDCE0 Input ITU on P42_[10:0] AF2_In; BT656 from CVBS source via SAA71xx video converter */
    {42, 0,  2u, R_DEV_PIN_IN,  0u, R_DEV_PIN_PULLNO, 0u, 0u, 0u, R_DEV_PIN_CMOS1}, /* VDCE1 In ITU DATA7 */
    {42, 1,  2u, R_DEV_PIN_IN,  0u, R_DEV_PIN_PULLNO, 0u, 0u, 0u, R_DEV_PIN_CMOS1},
    {42, 2,  2u, R_DEV_PIN_IN,  0u, R_DEV_PIN_PULLNO, 0u, 0u, 0u, R_DEV_PIN_CMOS1},
    {42, 3,  2u, R_DEV_PIN_IN,  0u, R_DEV_PIN_PULLNO, 0u, 0u, 0u, R_DEV_PIN_CMOS1},
    {42, 4,  2u, R_DEV_PIN_IN,  0u, R_DEV_PIN_PULLNO, 0u, 0u, 0u, R_DEV_PIN_CMOS1},
    {42, 5,  2u, R_DEV_PIN_IN,  0u, R_DEV_PIN_PULLNO, 0u, 0u, 0u, R_DEV_PIN_CMOS1},
    {42, 6,  2u, R_DEV_PIN_IN,  0u, R_DEV_PIN_PULLNO, 0u, 0u, 0u, R_DEV_PIN_CMOS1},
    {42, 7,  2u, R_DEV_PIN_IN,  0u, R_DEV_PIN_PULLNO, 0u, 0u, 0u, R_DEV_PIN_CMOS1}, /* VDCE1 In ITU DATA0 */
    {42, 8,  2u, R_DEV_PIN_IN,  0u, R_DEV_PIN_PULLNO, 0u, 0u, 0u, R_DEV_PIN_CMOS1}, /* VDCE1 In ITU CLK */
    {42, 9,  2u, R_DEV_PIN_IN,  0u, R_DEV_PIN_PULLNO, 0u, 0u, 0u, R_DEV_PIN_CMOS1}, /* VDCE1 In ITU HSYNC */
    {42, 10, 2u, R_DEV_PIN_IN,  0u, R_DEV_PIN_PULLNO, 0u, 0u, 0u, R_DEV_PIN_CMOS1}, /* VDCE1 In ITU VSYNC */
hu's avatar
hu committed
154

hu's avatar
hu committed
155
    /* delimiter - do not remove */
hu's avatar
hu committed
156
    {0u, R_DEV_PIN_LAST, 0u, R_DEV_PIN_OUT, 0u, R_DEV_PIN_PULLNO,   0u, 0u, 0u, R_DEV_PIN_CMOS1}
hu's avatar
hu committed
157 158 159 160 161
};




hu's avatar
hu committed
162
static const r_dev_PinConfig_t* g_pstGfxVoPinCfg[] =
hu's avatar
hu committed
163 164 165 166 167 168 169 170
{
    /* GFX_VO_NONE           */ NULL,
    /* GFX_VO_SINGLE_RGB888  */ g_stGfxVoPinCfgRGB888,
    /* GFX_VO_SINGLE_RGB666  */ g_stGfxVoPinCfgRGB666,
    /* GFX_VO_SINGLE_OPENLDI */ g_stGfxVoPinCfgOpenLDI,
};
#define   GFX_VO_PIN_CFG_NUM                (sizeof(g_pstGfxVoPinCfg) / sizeof(r_dev_PinConfig_t*))

hu's avatar
hu committed
171
static const r_dev_PinConfig_t* g_pstGfxViPinCfg[] =
hu's avatar
hu committed
172 173 174 175 176 177 178 179 180 181 182 183 184 185
{
    /* GFX_VI_NONE           */ NULL,
    /* GFX_VI_ITU656         */ g_stGfxViPinCfgITU656,
};
#define   GFX_VI_PIN_CFG_NUM                (sizeof(g_pstGfxViPinCfg) / sizeof(r_dev_PinConfig_t*))






/*r_cdi_Heap_t       g_stGfxVRAMheap;
r_cdi_Heap_t       g_stGfxlRAMheap;

hu's avatar
hu committed
186
#pragma alignvar(8)
hu's avatar
hu committed
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
uint8_t            g_u8GfxlRAMheapMem[GFX_CPU_HP_BLOCK_NB * GFX_CPU_HP_BLOCK_SIZE];

r_cdi_HpBlkIndex_t g_u16GfxlRAMheapIdxList[GFX_CPU_HP_BLOCK_NB];


uint32_t g_u32GfxVRAM0Addr;
uint32_t g_u32GfxVRAM0Size;

uint32_t g_u32VOWEImageBufferAddr;
uint32_t g_u32VOWEDisplayListAddr;
uint32_t g_u32GPUMemoryAddr;

static r_wm_Msg_t g_stGfxWMMsgQueue[GFX_WM_MSG_QUEUE_LEN];*/


uint32_t g_u32GfxVRAM0Addr;
uint32_t g_u32GfxVRAM0Size;

uint32_t g_u32VOWEImageBufferAddr;
uint32_t g_u32VOWEDisplayListAddr;
uint32_t g_u32GPUMemoryAddr;

static r_wm_Msg_t g_stGfxWMMsgQueue[GFX_WM_MSG_QUEUE_LEN];

r_cdi_Heap_t       g_stGfxIRAMheap;
r_cdi_Heap_t       g_stGfxVRAMheap;
r_cdi_Heap_t       g_stGfxSDRAMheap;

#pragma alignvar(128)
uint32_t g_u32GfxIRAMheapMem[GFX_HEAP_SIZE >> 2];

r_cdi_HpBlkIndex_t g_u16GfxVRAMheapIdxList[GFX_VID_HP_BLOCK_NB];


void Gfx_Init(uint8_t u8Mode)
{
    uint8_t  u8VoIndex;
    uint8_t  u8ViIndex;
    uint32_t u32RegVal;

    r_dev_ClkSelConfig_t stClkSelCfg;
    const r_dev_PinConfig_t*   pstGfxPinCfg;

    g_u32GfxVRAM0Addr = 0UL;
    g_u32GfxVRAM0Size = 0UL;

    g_u32VOWEImageBufferAddr = 0UL;
    g_u32VOWEDisplayListAddr = 0UL;
    g_u32GPUMemoryAddr = 0UL;

    u8VoIndex = u8Mode & 0x0FU;
    u8ViIndex = (u8Mode >> 4U) & 0x0FU;
    if ((u8VoIndex < GFX_VO_PIN_CFG_NUM) && (u8ViIndex < GFX_VI_PIN_CFG_NUM))
    {
        /* Disable the video output pixel clock */
        stClkSelCfg.Cks       = R_DEV_CKS_VDCE0CK;
        stClkSelCfg.SrcId     = R_DEV_CKS_SRC_DISABLED;
        stClkSelCfg.Div       = 0U;
        stClkSelCfg.StpReqMsk = 0U;
        R_DEV_ClkIdSet(&stClkSelCfg);

        stClkSelCfg.Cks       = R_DEV_CKS_VDCE1CK;
        R_DEV_ClkIdSet(&stClkSelCfg);

        u32RegVal = 0x00010000UL;

        /* Video output configuration */
        switch (u8Mode & 0x0FU)
        {
        case GFX_VO_SINGLE_RGB888 :
            R_DEV_WRITE_REG(32, GFX_REG_RSDSCFG, 0x00000000UL);       /* LVTTL output enabled */
            break;

        case GFX_VO_SINGLE_RGB666 :
            R_DEV_WRITE_REG(32, GFX_REG_RSDSCFG, 0x00000000UL);       /* LVTTL output enabled */
            break;

        case GFX_VO_SINGLE_OPENLDI :
            R_DEV_WRITE_REG(32, GFX_REG_RSDSCFG,      0x00000020UL);  /* Open LDI output enabled */
            R_DEV_WRITE_REG(32, GFX_REG_OLDI0CR1,     0x000003FFUL);  /* Set all channels to operating mode */
            R_DEV_WRITE_REG(32, GFX_REG_OLDI0CTRCR,   0x00000000UL);  /* Set CTRL0 to HSYNC, CTRL1 to VSYNC, CTRL2 to DE */
            R_DEV_WRITE_REG(32, GFX_REG_OLDI0CHCR,    0x00000000UL);  /* Set CH0 to output CH0, CH1 to CH1, CH2 to CH2, CH3 to CH3 */
            R_DEV_WRITE_REG(32, GFX_REG_OLDI0SKEWCTR, 0x00000000UL);  /* Set SKEW of all channels to 0ps */
            R_DEV_WRITE_REG(32, GFX_REG_OLDI0CR0,     0x00000403UL);  /* Activate outputs, Start Operation, Select Mode 4 */
            break;

        default :
            break;
        }

        /* Video input configuration */
        switch (u8Mode & 0xF0U)
        {
        case GFX_VI_ITU656 :
            break;

        default :
            break;
        }

        R_DEV_WRITE_REG(32, GFX_REG_VDCECTL, u32RegVal);

        /* Port pins configuration */
        pstGfxPinCfg = g_pstGfxVoPinCfg[u8VoIndex];
        if (pstGfxPinCfg != NULL)
        {
            R_DEV_PinInit(pstGfxPinCfg);
        }
    }
}

hu's avatar
hu committed
298

hu's avatar
hu committed
299 300 301 302 303 304 305 306 307 308 309

void Gfx_Sys_Start(void)
{
    uint32_t x;
    dhd_gpu_config_t stGpuConfig;
    dhd_gpu_call_data_t stGpuCall;
    dhd_uint32_t u32Ret;

    uint32_t u32Delay;

    /* Memory setup */
hu's avatar
hu committed
310 311 312 313 314
#if GFX_USE_INTERNAL_VRAM
    g_u32GfxVRAM0Addr = D1M1A_VRAM0;
    g_u32GfxVRAM0Size = D1M1A_VRAM0_SIZE + D1M1A_VRAM1_SIZE;
#else
    uint32_t u32SDRAMSize;
hu's avatar
hu committed
315

hu's avatar
hu committed
316 317 318 319 320 321 322 323 324 325 326 327 328 329
    u32SDRAMSize = Mem_SDRAM_Size();
    if (u32SDRAMSize <= GFX_VRAM_SIZE_IN_SDRAM)
    {
        g_u32GfxVRAM0Addr = D1M1A_SDRAM_BASE;
        g_u32GfxVRAM0Size = u32SDRAMSize;
    }
    else
    {
        g_u32GfxVRAM0Addr = D1M1A_SDRAM_BASE;
        g_u32GfxVRAM0Size = GFX_VRAM_SIZE_IN_SDRAM;
    }
#endif

#if GFX_USE_VOWE
hu's avatar
hu committed
330 331 332 333 334 335 336 337 338 339 340 341 342 343
    /* 1st is VOWE display list. We reserve space for two display lists. */
    /* Size is set to multiple of 1024 byte because VOWE image buffer has the alignment restriction. */
    if ( g_u32GfxVRAM0Size > (GFX_VOWE_DL_BUF_SIZE * 2u) )
    {
        g_u32VOWEImageBufferAddr = (g_u32GfxVRAM0Addr + g_u32GfxVRAM0Size) - (GFX_VOWE_DL_BUF_SIZE * 2u);
        g_u32GfxVRAM0Size -= GFX_VOWE_DL_BUF_SIZE * 2u;
        //R_BSP_STDIO_Printf("VOWE DL:  0x%08X / size %d\n", g_u32VOWEImageBufferAddr, GFX_VOWE_DL_BUF_SIZE * 2u);
    }
    else
    {
        //R_BSP_STDIO_Printf("Not enough memory space for VOWE display list! "
        //     "Please consider changing to Ringbuffer mode, to reduce the ringbuffer size or to reduce display resolution.\n");
        while (1U)
        {
hu's avatar
hu committed
344

hu's avatar
hu committed
345 346 347
        }
    }

hu's avatar
hu committed
348
    /* 2nd is VOWE image buffer.
hu's avatar
hu committed
349 350 351 352 353 354 355 356 357 358 359 360
       Start address must be multiple of 1024 byte in case of ring buffer mode.
       Size should be 2^n. */
    if ( g_u32GfxVRAM0Size > GFX_VOWE_WORK_BUFF_SIZE)
    {
        g_u32VOWEImageBufferAddr = (g_u32GfxVRAM0Addr + g_u32GfxVRAM0Size) - GFX_VOWE_WORK_BUFF_SIZE;
        g_u32GfxVRAM0Size -= GFX_VOWE_WORK_BUFF_SIZE;
        //R_BSP_STDIO_Printf("VOWE Buf: 0x%08X / size %d\n", g_u32VOWEImageBufferAddr, GFX_VOWE_WORK_BUFF_SIZE);
    }
    else
    {
        //R_BSP_STDIO_Printf("Not enough memory space for VOWE buffer! "
        //     "Please consider changing to Ringbuffer mode, to reduce the ringbuffer size or to reduce display resolution.\n");
hu's avatar
hu committed
361

hu's avatar
hu committed
362 363
        while (1U)
        {
hu's avatar
hu committed
364

hu's avatar
hu committed
365 366
        }
    }
hu's avatar
hu committed
367 368
#endif /* LOC_VOWE_ENABLE */

hu's avatar
hu committed
369 370 371 372 373 374 375 376 377 378 379 380 381
    /* 3rd is GPU2D. GPU is happy with almost any alignment, so it comes last.*/
    if ( g_u32GfxVRAM0Size > GFX_DHD_MEMORY_SIZE)
    {
        g_u32GPUMemoryAddr = (g_u32GfxVRAM0Addr + g_u32GfxVRAM0Size) - GFX_DHD_MEMORY_SIZE;
        g_u32GfxVRAM0Size -= GFX_DHD_MEMORY_SIZE;
        //R_BSP_STDIO_Printf("GPU2D:    0x%08X / size %d\n", g_u32GPUMemoryAddr, GFX_DHD_MEMORY_SIZE);
    }
    else
    {
        //R_BSP_STDIO_Printf("Not enough space for GPU memory! "
        //     "Please consider changing VOWE to Ringbuffer mode, to reduce the ringbuffer size or to reduce display resolution.\n");
        while (1U)
        {
hu's avatar
hu committed
382

hu's avatar
hu committed
383 384
        }
    }
hu's avatar
hu committed
385 386 387 388 389 390 391

    /*    x = R_CDI_InitHeapManager((uint32_t)g_u8GfxlRAMheapMem,
                                  &g_stGfxlRAMheap,
                                  g_u16GfxlRAMheapIdxList,
                                  GFX_CPU_HP_BLOCK_NB,
                                  GFX_CPU_HP_BLOCK_SIZE);
        if (x == 1)
hu's avatar
hu committed
392
        {
hu's avatar
hu committed
393 394 395 396
            while (1U)
            {

            }
hu's avatar
hu committed
397 398
        }

hu's avatar
hu committed
399 400 401 402 403 404
        x = R_CDI_InitHeapManager(g_u32GfxVRAM0Addr,
                                  &g_stGfxVRAMheap,
                                  0,
                                  g_u32GfxVRAM0Size / GFX_VID_HP_BLOCK_SIZE,
                                  GFX_VID_HP_BLOCK_SIZE);
        if (x == 1)
hu's avatar
hu committed
405
        {
hu's avatar
hu committed
406 407 408 409 410
            while (1U)
            {

            }
        }*/
hu's avatar
hu committed
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
    //R_BSP_STDIO_Printf("VRAM CDI: 0x%08X / size %d\n", g_u32GfxVRAM0Addr, g_u32GfxVRAM0Size);

    x = R_CDI_InitHeapManager((uint32_t)g_u32GfxIRAMheapMem,
                              &g_stGfxIRAMheap,
                              0,
                              GFX_CPU_HP_BLOCK_NB,
                              GFX_CPU_HP_BLOCK_SIZE);
    if (x == 1)
    {
        while (1U)
        {

        }
    }

    x = R_CDI_InitHeapManager((uint32_t)GFX_VID_FB_BASE,
                              &g_stGfxVRAMheap,
                              g_u16GfxVRAMheapIdxList, /* Example: Here we don't use the optional parameter HeapIdxList */
                              GFX_VID_HP_BLOCK_NB,
                              GFX_VID_HP_BLOCK_SIZE);
    if (x == 1)
    {
        while (1U)
        {

        }
    }

    x = R_CDI_InitHeapManager((uint32_t)GFX_SDRAM_FB_BASE,
                              &g_stGfxSDRAMheap,
                              0,                    /* Example: Here we don't use the optional parameter HeapIdxList */
                              GFX_SDRAM_HP_BLOCK_NB,
                              GFX_SDRAM_HP_BLOCK_SIZE);
    if (x == 1)
    {
        while (1U)
        {

        }
    }


    R_WM_DevInit(GFX_WM_UNIT, g_stGfxWMMsgQueue, GFX_WM_MSG_QUEUE_LEN, 0, &g_stGfxIRAMheap, &g_stGfxSDRAMheap);

    MCU_STBYB_LCD_OUT = 1U ;
    MCU_RSTB_LCD_OUT = 1U ;
hu's avatar
hu committed
457

hu's avatar
hu committed
458 459 460 461 462 463 464 465
    R_WM_ScreenTimingSetByName(GFX_WM_UNIT, (const int8_t*)GFX_DISPLAY_NAME);
    R_WM_ScreenColorFormatSet(GFX_WM_UNIT, (R_WM_OUTCOLORFMT_RGB888 | R_WM_OUTCOLORFMT_FLAG_SWAP_BR | R_WM_OUTCOLORFMT_FLAG_ENDIAN));
    R_WM_ScreenEnable(GFX_WM_UNIT);
    R_WM_ScreenBgColorSet(GFX_WM_UNIT, 0, 0, 0);
    R_WM_FrameEndMark(GFX_WM_UNIT, 0);
    R_WM_FrameWait(GFX_WM_UNIT, 0);

    R_SYS_DHD_IntCInit(GFX_DHD_UNIT);
hu's avatar
hu committed
466

hu's avatar
hu committed
467 468
    dhd_gpu_bridge_init_server();
    dhd_set_cpu_heap(&g_stGfxIRAMheap);
hu's avatar
hu committed
469

hu's avatar
hu committed
470
    memset(&stGpuConfig, 0, sizeof(stGpuConfig));
hu's avatar
hu committed
471

hu's avatar
hu committed
472 473 474 475 476 477 478 479 480 481
    stGpuConfig.m_sizeof                = sizeof(stGpuConfig);
    stGpuConfig.m_register_base_address = (void*)R_SYS_DHD_GetBaseAddr(0);
    stGpuConfig.m_vidmem_base_address   = GFX_DHD_BASE;
    stGpuConfig.m_vidmem_size           = GFX_DHD_MEMORY_SIZE;

    /* init device description */
    stGpuConfig.m_default_jobsize       = GFX_DHD_JOB_SIZE;
    stGpuConfig.m_default_jobcount      = GFX_DHD_JOB_COUNT;
    stGpuConfig.m_default_ringsize      = GFX_DHD_RING_SIZE;
    stGpuConfig.m_force_synchronous     = 1U;
hu's avatar
hu committed
482

hu's avatar
hu committed
483 484 485
    stGpuCall.m_init.m_instance         = dhd_gpu_prepare_instance(0);
    stGpuCall.m_init.m_config           = &stGpuConfig;
    u32Ret = dhd_gpu_call(0, E_DHD_CALL_INIT, &stGpuCall);
hu's avatar
hu committed
486

hu's avatar
hu committed
487 488
    while (u32Ret != E_DHD_OK)
    {
hu's avatar
hu committed
489

hu's avatar
hu committed
490
    }
hu's avatar
hu committed
491

hu's avatar
hu committed
492 493 494 495 496 497 498 499 500 501 502 503
    for (u32Delay = 0UL; u32Delay < 1000000UL; u32Delay++)
    {

    }

    D1530_EN_MCU_OUT = 1U ;  /* 1530EN = 1 */

    for (u32Delay = 0UL; u32Delay < 250000UL; u32Delay++)
    {

    }

hu's avatar
hu committed
504

hu's avatar
hu committed
505 506 507 508 509 510 511 512 513 514 515

    //stPinCfg.enGPIOPort = GPIO_PORT_GROUP_16;
    //stPinCfg.enGPIOPIN  = GPIO_PIN_8;
    //GPIO_Config(&stPinCfg);   /* BL PWM = 100% */



    loc_App((void *)SpriteHandler, (void *)&ScreenAttr);

}

hu's avatar
hu committed
516
#if 0
hu's avatar
hu committed
517 518 519 520 521 522 523 524 525 526 527 528 529
void Gfx_Sys_Start(void)
{
    uint32_t x;
    dhd_gpu_config_t stGpuConfig;
    dhd_gpu_call_data_t stGpuCall;
    dhd_uint32_t u32Ret;

    uint32_t u32Delay;





hu's avatar
hu committed
530

hu's avatar
hu committed
531 532 533 534

//LCD_BIAS_EN = 1U;
//LCD_RSTB = 1U;
//LCD_STDBYB = 1U;
hu's avatar
hu committed
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549
    /*
        GPIO_Config_st_t stPinCfg;
        stPinCfg.enGPIOPort = GPIO_PORT_GROUP_42;
        stPinCfg.enGPIOPIN  = GPIO_PIN_11;
        stPinCfg.enGPIODrive = GPIO_Drive_Fast;
        stPinCfg.enGPIOCharacter = GPIO_Char_CMOS1;
        stPinCfg.enGPIOPull = GPIO_PULL_NONE;
        stPinCfg.enGPIOOutputValue = GPIO_Level_High;
        stPinCfg.enGPIOMode = GPIO_MODE_PORT;
        stPinCfg.enGPIODir = GPIO_DIR_OUT;
        stPinCfg.enGPIOAltFun = GPIO_ALTER_FUN_1;
        GPIO_Config(&stPinCfg);
        */


hu's avatar
hu committed
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699

    /* Memory setup */
#if GFX_USE_INTERNAL_VRAM
    g_u32GfxVRAM0Addr = D1M1A_VRAM0;
    g_u32GfxVRAM0Size = D1M1A_VRAM0_SIZE + D1M1A_VRAM1_SIZE;
#else
    uint32_t u32SDRAMSize;

    u32SDRAMSize = Mem_SDRAM_Size();
    if (u32SDRAMSize <= GFX_VRAM_SIZE_IN_SDRAM)
    {
        g_u32GfxVRAM0Addr = D1M1A_SDRAM_BASE;
        g_u32GfxVRAM0Size = u32SDRAMSize;
    }
    else
    {
        g_u32GfxVRAM0Addr = D1M1A_SDRAM_BASE;
        g_u32GfxVRAM0Size = GFX_VRAM_SIZE_IN_SDRAM;
    }
#endif

#if GFX_USE_VOWE
    /* 1st is VOWE display list. We reserve space for two display lists. */
    /* Size is set to multiple of 1024 byte because VOWE image buffer has the alignment restriction. */
    if ( g_u32GfxVRAM0Size > (GFX_VOWE_DL_BUF_SIZE * 2u) )
    {
        g_u32VOWEImageBufferAddr = (g_u32GfxVRAM0Addr + g_u32GfxVRAM0Size) - (GFX_VOWE_DL_BUF_SIZE * 2u);
        g_u32GfxVRAM0Size -= GFX_VOWE_DL_BUF_SIZE * 2u;
        //R_BSP_STDIO_Printf("VOWE DL:  0x%08X / size %d\n", g_u32VOWEImageBufferAddr, GFX_VOWE_DL_BUF_SIZE * 2u);
    }
    else
    {
        //R_BSP_STDIO_Printf("Not enough memory space for VOWE display list! "
        //     "Please consider changing to Ringbuffer mode, to reduce the ringbuffer size or to reduce display resolution.\n");
        while (1U)
        {

        }
    }

    /* 2nd is VOWE image buffer.
       Start address must be multiple of 1024 byte in case of ring buffer mode.
       Size should be 2^n. */
    if ( g_u32GfxVRAM0Size > GFX_VOWE_WORK_BUFF_SIZE)
    {
        g_u32VOWEImageBufferAddr = (g_u32GfxVRAM0Addr + g_u32GfxVRAM0Size) - GFX_VOWE_WORK_BUFF_SIZE;
        g_u32GfxVRAM0Size -= GFX_VOWE_WORK_BUFF_SIZE;
        //R_BSP_STDIO_Printf("VOWE Buf: 0x%08X / size %d\n", g_u32VOWEImageBufferAddr, GFX_VOWE_WORK_BUFF_SIZE);
    }
    else
    {
        //R_BSP_STDIO_Printf("Not enough memory space for VOWE buffer! "
        //     "Please consider changing to Ringbuffer mode, to reduce the ringbuffer size or to reduce display resolution.\n");

        while (1U)
        {

        }
    }
#endif /* LOC_VOWE_ENABLE */

    /* 3rd is GPU2D. GPU is happy with almost any alignment, so it comes last.*/
    if ( g_u32GfxVRAM0Size > GFX_DHD_MEMORY_SIZE)
    {
        g_u32GPUMemoryAddr = (g_u32GfxVRAM0Addr + g_u32GfxVRAM0Size) - GFX_DHD_MEMORY_SIZE;
        g_u32GfxVRAM0Size -= GFX_DHD_MEMORY_SIZE;
        //R_BSP_STDIO_Printf("GPU2D:    0x%08X / size %d\n", g_u32GPUMemoryAddr, GFX_DHD_MEMORY_SIZE);
    }
    else
    {
        //R_BSP_STDIO_Printf("Not enough space for GPU memory! "
        //     "Please consider changing VOWE to Ringbuffer mode, to reduce the ringbuffer size or to reduce display resolution.\n");
        while (1U)
        {

        }
    }

    x = R_CDI_InitHeapManager((uint32_t)g_u32GfxIRAMheapMem,
                              &g_stGfxIRAMheap,
                              0,
                              GFX_CPU_HP_BLOCK_NB,
                              GFX_CPU_HP_BLOCK_SIZE);
    if (x == 1)
    {
        while (1U)
        {

        }
    }

    x = R_CDI_InitHeapManager((uint32_t)GFX_VID_FB_BASE,
                              &g_stGfxVRAMheap,
                              g_u16GfxVRAMheapIdxList, /* Example: Here we don't use the optional parameter HeapIdxList */
                              GFX_VID_HP_BLOCK_NB,
                              GFX_VID_HP_BLOCK_SIZE);
    if (x == 1)
    {
        while (1U)
        {

        }
    }

    x = R_CDI_InitHeapManager((uint32_t)GFX_SDRAM_FB_BASE,
                              &g_stGfxSDRAMheap,
                              0,                    /* Example: Here we don't use the optional parameter HeapIdxList */
                              GFX_SDRAM_HP_BLOCK_NB,
                              GFX_SDRAM_HP_BLOCK_SIZE);
    if (x == 1)
    {
        while (1U)
        {

        }
    }
    //R_BSP_STDIO_Printf("VRAM CDI: 0x%08X / size %d\n", g_u32GfxVRAM0Addr, g_u32GfxVRAM0Size);

    R_SYS_DHD_IntCInit(GFX_DHD_UNIT);

    dhd_gpu_bridge_init_server();
    dhd_set_cpu_heap(&g_stGfxIRAMheap);

    memset(&stGpuConfig, 0, sizeof(stGpuConfig));

    stGpuConfig.m_sizeof                = sizeof(stGpuConfig);
    stGpuConfig.m_register_base_address = (void*)R_SYS_DHD_GetBaseAddr(0);
    stGpuConfig.m_vidmem_base_address   = GFX_DHD_BASE;
    stGpuConfig.m_vidmem_size           = GFX_DHD_MEMORY_SIZE;

    /* init device description */
    stGpuConfig.m_default_jobsize       = GFX_DHD_JOB_SIZE;
    stGpuConfig.m_default_jobcount      = GFX_DHD_JOB_COUNT;
    stGpuConfig.m_default_ringsize      = GFX_DHD_RING_SIZE;
    stGpuConfig.m_force_synchronous     = 1U;

    stGpuCall.m_init.m_instance         = dhd_gpu_prepare_instance(0);
    stGpuCall.m_init.m_config           = &stGpuConfig;
    u32Ret = dhd_gpu_call(0, E_DHD_CALL_INIT, &stGpuCall);

    while (u32Ret != E_DHD_OK)
    {

    }

    for (u32Delay = 0UL; u32Delay < 250000UL; u32Delay++)
    {

    }

hu's avatar
hu committed
700

hu's avatar
hu committed
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751

    R_WM_DevInit(GFX_WM_UNIT, g_stGfxWMMsgQueue, GFX_WM_MSG_QUEUE_LEN, 0, &g_stGfxIRAMheap, &g_stGfxVRAMheap);

    R_WM_ScreenTimingSetByName(GFX_WM_UNIT, (const int8_t*)GFX_DISPLAY_NAME);
    R_WM_ScreenColorFormatSet(GFX_WM_UNIT, (R_WM_OUTCOLORFMT_RGB888 | R_WM_OUTCOLORFMT_FLAG_SWAP_BR));
    R_WM_ScreenEnable(GFX_WM_UNIT);
    R_WM_ScreenBgColorSet(GFX_WM_UNIT, 0, 0, 0);
    R_WM_FrameEndMark(GFX_WM_UNIT, 0);
    R_WM_FrameWait(GFX_WM_UNIT, 0);

    loc_App((void *)SpriteHandler, (void *)&ScreenAttr);
}
#endif
void Gfx_Sys_Stop(void)
{

}

r_wm_WinBuffer_t MainScreenBuffer[2];

void Gfx_Create_Window(r_wm_WinMode_t      enMode,
                       uint32_t            u32PosX,
                       uint32_t            u32PosY,
                       uint32_t            u32PosZ,
                       uint32_t            u32Width,
                       uint32_t            u32Height,
                       uint32_t            u32Pitch,
                       uint32_t            u32Bnumber,
                       r_wm_WinColorFmt_t  enColorFmt,
                       r_wm_Window_t*      pstWindow)
{
    uint8_t i = 0;

    memset(pstWindow, 0, sizeof(r_wm_Window_t));

    pstWindow->Mode      = enMode;
    pstWindow->Status    = R_WM_WINSTATUS_NOT_INITIALIZED;
    pstWindow->ColorFmt  = enColorFmt;
    pstWindow->Alpha     = 0xff;
    pstWindow->PosX      = u32PosX;
    pstWindow->PosY      = u32PosY;
    pstWindow->PosZ      = u32PosZ;
    pstWindow->Width     = u32Width;
    pstWindow->Height    = u32Height;
    pstWindow->Pitch     = u32Pitch;

    if (enMode == R_WM_WINMODE_FB)
    {
        pstWindow->Surface.Fb.BufNum    = u32Bnumber;
        pstWindow->Surface.Fb.Buffer    = MainScreenBuffer;
        pstWindow->Surface.Fb.BufMode   = R_WM_WINBUF_ALLOC_EXTERNAL;
hu's avatar
hu committed
752
        for (i = 0; i < u32Bnumber; i++)
hu's avatar
hu committed
753 754 755 756 757 758 759 760 761 762 763
        {
            //MainScreenBuffer[i].Data = R_CDI_Alloc(&g_stGfxSDRAMheap, u32Height * u32Pitch * 4);
            MainScreenBuffer[i].Data = R_CDI_Alloc(&g_stGfxVRAMheap, u32Height * u32Pitch * 4);
            MainScreenBuffer[i].Status = R_WM_WINBUF_FREE;
        }
    }

    R_WM_WindowCreate(GFX_WM_UNIT, pstWindow);
    R_WM_WindowEnable(GFX_WM_UNIT, pstWindow);
}

hu's avatar
hu committed
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779
void Loc_Display_Red(uint8_t ColorR, uint8_t ColorG, uint8_t ColorB)
{
    if (ColorR == 1 && ColorG == 1 && ColorB == 1)
    {
        JCUA_Enable_window();
        loc_Enable_Window_App();
    }
    else
    {
        loc_Disable_Window_App();
        JCUA_Disable_window();
        R_WM_ScreenBgColorSet(0, ColorR, ColorG, ColorB);
        R_WM_FrameEndMark(0, 0);
        R_WM_FrameWait(0, 0);
    }
}