Graphics framework for GR-PEACH. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Dependents:   ImageZoomInout_Sample ImageRotaion_Sample ImageScroll_Sample GR-PEACH_LCD_4_3inch_Save_to_USB ... more

License

When you use this library, we judge you have agreed to the following contents.

https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Note

If you import the GraphicsFramework library, please import GR-PEACH_video library and R_BSP library together.



JPEG Converter

The JPEG Converter driver implements encode and decode functionality which uses the JCU of the RZ/A Series.

Hello World!

Import programJCU_HelloWorld

Hello World for JCU(JPEG Codec Unit). JCU is JPEG codec unit of RZ/A1. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

API

Import library

Data Structures

struct bitmap_buff_info_t
Bitmap data setting struct. More...
struct encode_options_t
Encode option setting. More...

Public Types

enum jpeg_conv_error_t {
JPEG_CONV_OK = 0, JPEG_CONV_JCU_ERR = -1, JPEG_CONV_FORMA_ERR = -2, JPEG_CONV_PARAM_ERR = -3,
JPEG_CONV_BUSY = -4, JPEG_CONV_PARAM_RANGE_ERR = -7
}

Error codes.

More...
enum wr_rd_swa_t {
WR_RD_WRSWA_NON = 0, WR_RD_WRSWA_8BIT = 1, WR_RD_WRSWA_16BIT = 2, WR_RD_WRSWA_16_8BIT = 3,
WR_RD_WRSWA_32BIT = 4, WR_RD_WRSWA_32_8BIT = 5, WR_RD_WRSWA_32_16BIT = 6, WR_RD_WRSWA_32_16_8BIT = 7
}

Write/Read image pixcel frame buffer swap setting.

More...
enum wr_rd_format_t { WR_RD_YCbCr422 = 0x00, WR_RD_ARGB8888 = 0x01, WR_RD_RGB565 = 0x02 }

Write/Read image pixcel format selects.

More...
enum sub_sampling_t { SUB_SAMPLING_1_1 = 0x00, SUB_SAMPLING_1_2 = 0x01, SUB_SAMPLING_1_4 = 0x02, SUB_SAMPLING_1_8 = 0x03 }

Thinning output image selects.

More...
enum cbcr_offset_t { CBCR_OFFSET_0 = 0x00, CBCR_OFFSET_128 = 0x01 }

Cb/Cr range selects for decode.

More...

Public Member Functions

JPEG_Converter ()
Constructor method of JPEG converter(encode/decode)
virtual ~JPEG_Converter ()
Destructor method of JPEG converter(encode/decode)
JPEG_Converter::jpeg_conv_error_t decode (void *pJpegBuff, bitmap_buff_info_t *psOutputBuff)
Decode JPEG to rinear data.
JPEG_Converter::jpeg_conv_error_t decode (void *pJpegBuff, bitmap_buff_info_t *psOutputBuff, decode_options_t *pOptions)
JPEG data decode to bitmap.
JPEG_Converter::jpeg_conv_error_t encode ( bitmap_buff_info_t *psInputBuff, void *pJpegBuff, size_t *pEncodeSize)
Encode rinear data to JPEG.
JPEG_Converter::jpeg_conv_error_t encode ( bitmap_buff_info_t *psInputBuff, void *pJpegBuff, size_t *pEncodeSize, encode_options_t *pOptions)
Bitmap data encode to JPEG.
JPEG_Converter::jpeg_conv_error_t SetQuality (const uint8_t qual)
Set encode quality.

Correspondence file

A correspondence file of JPEG Converter is as the following table.

JPEGCorrespondence
Width>0(greater than 0)
Height>0(greater than 0)
Color formatYCbCr444, YCbCr422, YCbCr420, YCbCr411
BitmapCorrespondence
Width>0(greater than 0)
Height>0(greater than 0)
Color formatYCbCr422

Notice

You run JPEG converter once destruction each time.

You set whether these JPEG files aren't input, or it check error setting decode(set in "flag" = true). The JPEG file which becomes correspondence outside will be the following condition.

  • File besides the above-mentioned correspondence file.
  • As information in the JPEG file, WIDTH or HEIGHT is larger than output buffer setting.

Buffer area is used encode/decode, set 8 bytes align and non-cash memory area. The output buffer when decoding, is made beyond the size decided in the size of the JPEG file, the format, setting of thinning out. You make output buffer for decode/encode to enough big size in order to stock this result. JPEG Converter, if you do not particularly perform specified, does not check size against the output data at the time of encoding and decoding. You set the output buffer so that there is no effect of corruption by the output data.

Color format

Color format in case to be converted from Bitmap to JPEG is either ARGB8888 or RGB555, YCbCr422. Color format of the If you want to convert from JPEG file to Bitmap file is YCbCr422. You correct "alpha(member of decode_options_t)" of setting and "output_cb_cr_offset(member of decode_options_t)" according to color format when decoding.

  • example
    decode to ARGB8888(WR_RD_ARGB8888 set in format member of bitmap_buff_info_t)
    alpha = 0x01-0xFF
    output_cb_cr_offset = CBCR_OFFSET_0

    decode to YCbCr422(WR_RD_YCbCr422 set in format member of bitmap_buff_info_t)
    alpha = 0
    output_cb_cr_offset = CBCR_OFFSET_0 or CBCR_OFFSET_128

    decode to RGB565(WR_RD_RGB565 set in format member of bitmap_buff_info_t)
    alpha = 0
    output_cb_cr_offset = CBCR_OFFSET_0

Decode/encode settings are optional

If omitted encode/decode settings, it will work with the following settings.
[Decode option setting (member of decode_options_t)]

  • Vertical sub sampling is thinning output image to 1/1.
  • Horizontal sub sampling is thinning output image to 1/1.
  • Output data of Cb/Cr range is -128 to 127.
  • Output data of swap in 8-bit units: 2-1-4-3-6-5-8-7.
  • Alpha value of 0.
  • JPEG format correspondence outside error check.
  • It decode in a synchronous function.

[Encode option setting (member of encode_options_t)]

  • DRI value is 0.
  • Encoding JPEG file start width offset is 0.
  • Encoding JPEG file start height offset is 0.
  • Input data of Cb/Cr range of input data is -128 to 127.
  • Input data swap in 8-bit units: 2-1-4-3-6-5-8-7.
  • It don't check encode size.
  • Quantization Y use default table(Quality75).
  • Quantization C use default table(Quality75).
  • Huffman Y DC use default table.
  • Huffman C DC use default table.
  • Huffman Y AC use default table.
  • Huffman C AC use default table.
  • It encode in a synchronous function.

Synchronous/asynchronous switching

Decoding and encoding setting to operate asynchronously by setting a callback function(decode_options_t and encode_options_t).

Quality

Quality changes are possible. If you want to change the Quality, please specify the table made of Quality you want to change the address of the setting. If you do not want to change the Quality, it will operate at Quality75.

RGA

The RGA library implements fast drawing functionality which uses the RGA of the RZ/A Series.
Supporting compiler is ARMCC, GCC ARM and IAR.

Hello World!

Import programRGA_HelloWorld

Hello World for RGA(Renesas Graphics Architecture). RGA is the Graphics Library of RZ/A1. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Files at this revision

API Documentation at this revision

Comitter:
1050186
Date:
Wed Jan 20 02:35:17 2016 +0000
Parent:
2:f3c5d5e6e5ef
Child:
4:7a761c1499fe
Commit message:
Add RGA library

Changed in this revision

RGA/RGA.h Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/inc/ncg_debug.h Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/inc/ncg_defs.h Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/inc/ncg_memory.h Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/inc/ncg_register.h Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/inc/ncg_state.h Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/inc/ncg_time.h Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/inc/ncg_vg.h Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/inc/ncg_vg_isr.h Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/src/ncg_memory.c Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/src/ncg_register.c Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/src/ncg_state.c Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/src/ncg_vg.c Show annotated file Show diff for this revision Revisions of this file
RGA/RGPNCG/src/ncg_vg_isr.c Show annotated file Show diff for this revision Revisions of this file
RGA/inc/RGA_API.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/RGA_API_typedef.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/RGA_Config.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/RGA_Cpp.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/RGA_Port.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/RGA_Port_inline.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/RGA_Port_typedef.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/RGA_raw_image.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/RGA_raw_image_typedef.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/frame_buffer.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/frame_buffer_typedef.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/video_input.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/video_input.hpp Show annotated file Show diff for this revision Revisions of this file
RGA/inc/video_input_typedef.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/vsync.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/vsync_pl.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/vsync_typedef.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/window_surfaces.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/window_surfaces.hpp Show annotated file Show diff for this revision Revisions of this file
RGA/inc/window_surfaces_ex.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/window_surfaces_ex_typedef.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/window_surfaces_inline.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/window_surfaces_private.h Show annotated file Show diff for this revision Revisions of this file
RGA/inc/window_surfaces_typedef.h Show annotated file Show diff for this revision Revisions of this file
RGA/libPNG_Zip.ar Show annotated file Show diff for this revision Revisions of this file
RGA/libRGA.ar Show annotated file Show diff for this revision Revisions of this file
RGA/libRGAH.ar Show annotated file Show diff for this revision Revisions of this file
RGA/porting/RGA_Callback.c Show annotated file Show diff for this revision Revisions of this file
RGA/porting/RGA_Callback_WorkBuf.c Show annotated file Show diff for this revision Revisions of this file
RGA/porting/RGA_Callback_private.h Show annotated file Show diff for this revision Revisions of this file
RGA/porting/RGA_VRAM.c Show annotated file Show diff for this revision Revisions of this file
RGA/porting/RGA_VRAM_EX.c Show annotated file Show diff for this revision Revisions of this file
RGA/porting/vsync_pl.c Show annotated file Show diff for this revision Revisions of this file
RGA/src/video_input.c Show annotated file Show diff for this revision Revisions of this file
RGA/src/video_input_cpp.cpp Show annotated file Show diff for this revision Revisions of this file
RGA/src/vsync.c Show annotated file Show diff for this revision Revisions of this file
RGA/src/window_surfaces.c Show annotated file Show diff for this revision Revisions of this file
RGA/src/window_surfaces_cpp.cpp Show annotated file Show diff for this revision Revisions of this file
common/inc/clib_drivers.h Show annotated file Show diff for this revision Revisions of this file
common/inc/clib_drivers_config.h Show annotated file Show diff for this revision Revisions of this file
common/inc/clib_drivers_inline.h Show annotated file Show diff for this revision Revisions of this file
common/inc/clib_drivers_typedef.h Show annotated file Show diff for this revision Revisions of this file
common/inc/clib_samples.h Show annotated file Show diff for this revision Revisions of this file
common/inc/clib_samples_private.h Show annotated file Show diff for this revision Revisions of this file
common/src/clib_drivers.c Show annotated file Show diff for this revision Revisions of this file
common/src/clib_samples.c Show annotated file Show diff for this revision Revisions of this file
config/Project_Config.h Show annotated file Show diff for this revision Revisions of this file
config/Project_Config_Sub.h Show annotated file Show diff for this revision Revisions of this file
ospl/inc/r_ospl.h Show annotated file Show diff for this revision Revisions of this file
ospl/inc/r_ospl_test.h Show diff for this revision Revisions of this file
ospl/inc/r_ospl_typedef.h Show annotated file Show diff for this revision Revisions of this file
ospl/porting/TOOLCHAIN_GCC/r_ospl_os_less_asm.s Show annotated file Show diff for this revision Revisions of this file
ospl/porting/inline_body.c Show annotated file Show diff for this revision Revisions of this file
ospl/porting/r_ospl_debug.c Show annotated file Show diff for this revision Revisions of this file
ospl/porting/r_ospl_memory.c Show annotated file Show diff for this revision Revisions of this file
ospl/porting/r_ospl_unrecoverable.c Show annotated file Show diff for this revision Revisions of this file
ospl/src/r_ospl.c Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGA.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,78 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/******************************************************************************
+* $FileName: RGA.h $
+* $Module: RGA $ $PublicVersion: 1.20 $ (=RGA_VERSION)
+* $Rev: $
+* $Date::                           $
+* Description:
+******************************************************************************/
+
+
+/* This is MAIN header file */
+
+#ifndef  RGA_H
+#define  RGA_H
+
+#include  "Project_Config.h"
+
+
+#ifdef _MSC_VER
+	#include  "PC/RGA_Sub_PC.h"
+	#include  "sub/bitblt_alpha.h"
+	#include  "PC/RGA_PC.h"
+#endif
+#ifdef _SH
+	#include  "SH7269/RGA_Sub_SH7269.h"
+	#include  "sub/bitblt_alpha.h"
+	#include  "SH7269/RGA_SH.h"
+#endif
+#ifdef R_ARM
+	#include  "r_ospl.h"
+	#include  "r_typedefs.h"
+	#include  "RGA_Port.h"
+#endif
+
+#include  "RGA_API.h"
+#ifdef  __cplusplus
+	#include  "RGA_Cpp.h"
+#endif
+
+
+/* Sample window surfaces library */
+#ifdef _MSC_VER
+	#include  <PC/RGA_SampleLib_RZ_A1H.h>
+#endif
+#ifdef _SH
+	#include  <SH7269/RGA_SampleLib_RZ_A1H.h>
+#endif
+#ifdef R_ARM
+	#include  "RGA_raw_image.h"
+	#include  "window_surfaces.h"
+	#include  "RGA_Port.h"
+#endif
+
+
+#endif  /* RGA_H */
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/inc/ncg_debug.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,81 @@
+/******************************************************************************
+* Copyright(c) 2010-2012 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : NCG debug header.
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2010.10.08
+*          - Created the initial code.
+*          2012.08.21
+*          - Added debugging messase function.
+*          2012.08.22
+*          - Updated coding format.
+*          - Added debug macro.
+*            - NCG_DEBUG_MAKE_MSG
+*            - NCG_DEBUG_PRINT_MSG
+*          2013.01.08
+*            - Fixed release code.
+*
+*******************************************************************************/
+
+#ifndef NCG_DEBUG_H
+#define NCG_DEBUG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*-----------------------------------------------------------------------------------*/
+#ifdef NCG_DEBUG
+/*-----------------------------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NCG_ASSERT(EXPR)                            if (!(EXPR)) { NCGSYS_Abort(__FILE__, __LINE__, #EXPR); }
+
+#define NCG_DEBUG_MAKE_MSG_START( buff, format )    sprintf( (buff), format
+#define NCG_DEBUG_MAKE_MSG_PARAMETER( param )           , (param)
+#define NCG_DEBUG_MAKE_MSG_END(  )                  )
+#define NCG_DEBUG_PRINT_MSG( msg )                  printf( msg )
+
+#ifdef NCG_DEBUG_API_LOG
+
+#define NCG_DEBUG_PRINT_STRING( msg )               printf( "%s%s", (msg), NCG_CRLF )
+
+#else /* #ifdef NCG_DEBUG_API_LOG */
+
+#define NCG_DEBUG_PRINT_STRING( msg )               /* No process */
+
+#endif /* #ifdef NCG_DEBUG_API_LOG */
+
+#define NCG_DEBUG_MSG_BUFFER_SIZE                   512
+
+#define NCG_CRLF                                    "\n"
+
+extern void NCGSYS_Abort(const NCGchar *filename, NCGint32 line, const NCGchar *condition);
+
+extern char NCG_G_MASSAGE_BUFF[NCG_DEBUG_MSG_BUFFER_SIZE];
+
+/*-----------------------------------------------------------------------------------*/
+#else   /* NCG_DEBUG */
+/*-----------------------------------------------------------------------------------*/
+
+#define NCG_ASSERT(EXPR)                                /* No process */
+#define NCG_DEBUG_MAKE_MSG_START( buff, format )        /* No process */
+#define NCG_DEBUG_MAKE_MSG_PARAMETER( param )           /* No process */
+#define NCG_DEBUG_MAKE_MSG_END(  )                      /* No process */
+#define NCG_DEBUG_PRINT_MSG( msg )                      /* No process */
+
+#define NCG_DEBUG_PRINT_STRING( msg )                   /* No process */
+
+/*-----------------------------------------------------------------------------------*/
+#endif  /* NCG_DEBUG */
+/*-----------------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NCG_DEBUG_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/inc/ncg_defs.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,113 @@
+/******************************************************************************
+* Copyright(c) 2010-2012 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : NCG Type Definitions.
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2010.10.08
+*          - Created the initial code.
+*          2011.03.04
+*          - Added the type of NCGfp.
+*          2012.08.22
+*          - Updated coding format.
+*          2012.11.14
+*          - Added the definition for Multi-Display.
+*             NCGDU_CH1
+*             NCGDU_CH2
+*          - Modified the type of NCGISRfp to NCGDUISRfp and NCGVGISRfp.
+*
+*******************************************************************************/
+
+#ifndef NCG_DEFS_H
+#define NCG_DEFS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef __cplusplus
+#define NCG_NULL    0
+#else
+#define NCG_NULL    ((void *)0)
+#endif
+
+#define NCG_FALSE   0
+#define NCG_TRUE    1
+
+#define NCG_UINT32_MAX (0xffffffffU)
+
+#define NCG_TIMEOUT_INFINITE NCG_UINT32_MAX
+#define NCG_INVALID_TLSINDEX NCG_UINT32_MAX
+
+/* Display chanel */
+#define NCGDU_CH1                   (0x00000001U)
+#define NCGDU_CH2                   (0x00000002U)
+
+
+#if !defined(NCG_UNREFERENCED_PARAMETER)
+#define NCG_UNREFERENCED_PARAMETER   R_UNREFERENCED_VARIABLE
+#endif
+
+/*
+ *  Error codes
+ */
+
+#define NCG_FIRST_ERROR (-255)
+enum
+{
+    NCG_no_err = 0,
+    NCG_err_unknown                 = NCG_FIRST_ERROR,
+    NCG_err_not_implemented         = NCG_FIRST_ERROR+ 1,
+    NCG_err_bad_parameter           = NCG_FIRST_ERROR+ 2,
+    NCG_err_no_host_mem             = NCG_FIRST_ERROR+ 3,
+    NCG_err_lost_host_mem           = NCG_FIRST_ERROR+ 4,
+    NCG_err_no_frame_mem            = NCG_FIRST_ERROR+ 5,
+    NCG_err_lost_frame_mem          = NCG_FIRST_ERROR+ 6,
+    NCG_err_already_created         = NCG_FIRST_ERROR+ 7,
+    NCG_err_isr_management_failed   = NCG_FIRST_ERROR+ 8,
+    NCG_err_wait_timeout            = NCG_FIRST_ERROR+ 9,
+    NCG_err_device_in_use           = NCG_FIRST_ERROR+10,
+    NCG_err_not_found               = NCG_FIRST_ERROR+11,
+    NCG_err_invalid_handle          = NCG_FIRST_ERROR+12,
+    NCG_err_resource_exceeded       = NCG_FIRST_ERROR+13,
+    NCG_last_err                    = NCG_FIRST_ERROR+14,
+};
+
+
+/*
+ *  NCG data type definitions
+ */
+
+typedef void                    NCGvoid;
+typedef unsigned int            NCGenum;
+typedef unsigned int            NCGboolean;
+typedef unsigned int            NCGbitfield;
+
+typedef char                    NCGchar;
+typedef signed char             NCGint8;
+typedef short                   NCGint16;
+typedef int                     NCGint32;
+typedef long long               NCGint64;
+typedef unsigned char           NCGuint8;
+typedef unsigned short          NCGuint16;
+typedef unsigned int            NCGuint32;
+typedef unsigned long long      NCGuint64;
+typedef float                   NCGfloat32;
+typedef double                  NCGfloat64;
+
+typedef int                     NCGsizei;
+typedef float                   NCGclampf;
+typedef long                    NCGfixed;
+
+typedef NCGuint32 (*NCGDUISRfp)(NCGbitfield uiDisplay);
+typedef NCGuint32 (*NCGVGISRfp)(void);
+typedef NCGvoid (*NCGfp)(NCGvoid *);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NCG_DEFS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/inc/ncg_memory.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,55 @@
+/******************************************************************************
+* Copyright(c) 2012 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : Sample code of NCG memory operation functions header.
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2013.06.25
+*          - Changed for RGAH
+*          2013.01.08
+*          - Created new code.
+*
+******************************************************************************/
+
+#ifndef NCG_MEMORY_H
+#define NCG_MEMORY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*=============================================================================
+ * Definitions
+ */
+
+
+/*=============================================================================
+ *  Structures
+ */
+
+
+/*=============================================================================
+ *  Function prototyping
+ */
+
+/*
+ * Host memory management
+ */
+
+NCGvoid
+NCGSYS_PurgeCPUOperandCache (
+    void
+);
+
+NCGuint32
+NCGSYS_CPUVAddrToSysPAddr (
+    NCGuint32   ui32CPUAddr
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NCG_MEMORY_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/inc/ncg_register.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,66 @@
+/******************************************************************************
+* Copyright(c) 2010-2012 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : NCG register read/write header.
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2010.10.08
+*          - Created the initial code.
+*          2012.08.22
+*          - Updated coding format.
+*
+*******************************************************************************/
+
+#ifndef NCG_REGISTER_H
+#define NCG_REGISTER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*=============================================================================
+ * Definitions
+ */
+
+
+/*=============================================================================
+ *  Structures
+ */
+
+
+/*=============================================================================
+ *  Function prototyping
+ */
+
+/*
+ *  Register read/write
+ */
+NCGuint32
+NCGSYS_ReadReg (
+    NCGuint32   ui32RegBase,
+    NCGuint32   ui32Offset
+);
+
+NCGvoid
+NCGSYS_WriteReg (
+    NCGuint32   ui32RegBase,
+    NCGuint32   ui32Offset,
+    NCGuint32   ui32Value
+);
+
+NCGuint32
+NCGSYS_ModifyReg (
+    NCGuint32   ui32RegBase,
+    NCGuint32   ui32Offset,
+    NCGuint32   ui32Mask,
+    NCGuint32   ui32Value
+);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NCG_REGISTER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/inc/ncg_state.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,109 @@
+/******************************************************************************
+* Copyright(c) 2010-2012 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : NCG state variable control functions header.
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2010.10.08
+*          - Created the initial code.
+*          2012.08.22
+*          - Updated coding format.
+*
+*******************************************************************************/
+
+#ifndef NCG_STATE_H
+#define NCG_STATE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*=============================================================================
+ * Definitions
+ */
+
+/*
+ *  Mode Flags
+ */
+
+#define NCGSYS_STATE_CALL_MASK       (0x00000003U)
+#define NCGSYS_STATE_CALL_NORMAL     (0x00000000U)
+#define NCGSYS_STATE_CALL_INTERRUPT  (0x00000001U)
+#define NCGSYS_STATE_CALL_CALLBACK   (0x00000002U)
+
+#define NCGSYS_STATE_WAIT_MASK       (0x00000004U)
+#define NCGSYS_STATE_WAIT_OR         (0x00000004U)
+#define NCGSYS_STATE_WAIT_AND        (0x00000000U)
+
+#define NCGSYS_STATE_SET_MASK        (0x00000018U)
+#define NCGSYS_STATE_SET_AND         (0x00000000U)
+#define NCGSYS_STATE_SET_OR          (0x00000008U)
+#define NCGSYS_STATE_SET_SET         (0x00000010U)
+
+#define NCGSYS_STATE_OR             NCGSYS_STATE_SET_OR
+#define NCGSYS_STATE_SET            NCGSYS_STATE_SET_SET
+#define NCGSYS_STATE_CLEAR          NCGSYS_STATE_SET_AND
+
+
+/*=============================================================================
+ *  Structures
+ */
+
+
+/*=============================================================================
+ *  Function prototyping
+ */
+
+/*
+ *  State control
+ */
+
+NCGint32
+NCGSYS_CreateState (
+    NCGvoid     **ppObj,
+    NCGuint32   ui32StateID
+);
+
+NCGint32
+NCGSYS_DestroyState (
+    NCGvoid     *pObj
+);
+
+NCGint32
+NCGSYS_SetState (
+    NCGvoid     *pObj,
+    NCGuint32   ui32State,
+    NCGuint32   ui32Flags
+);
+
+NCGuint32
+NCGSYS_GetState (
+    NCGvoid     *pObj,
+    NCGuint32   ui32Flags
+);
+
+NCGint32
+NCGSYS_WaitState (
+    NCGvoid     *pObj,
+    NCGuint32   ui32State,
+    NCGuint32   ui32Flags,
+    NCGuint32   ui32Timeout
+);
+
+NCGvoid
+NCGSYS_SetStateEventValue (
+    NCGvoid    *pObj,
+    NCGuint32   ui32EventValue
+);
+
+NCGvoid *
+NCGSYS_GetLastCreatedState(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NCG_STATE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/inc/ncg_time.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,64 @@
+/******************************************************************************
+* Copyright(c) 2010-2012 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : NCG time and delay control functions header.
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2010.10.08
+*          - Created the initial code.
+*          2012.08.22
+*          - Updated coding format.
+*
+*******************************************************************************/
+
+#ifndef NCG_TIME_H
+#define NCG_TIME_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*=============================================================================
+ * Definitions
+ */
+
+
+/*=============================================================================
+ *  Structures
+ */
+
+
+/*=============================================================================
+ *  Function prototyping
+ */
+
+/*
+ *  Delay control
+ */
+NCGint32
+NCGSYS_Sleep (
+    NCGuint32   ui32MilliSeconds
+);
+
+/*
+ *  Time acquisition
+ */
+
+NCGint32
+NCGSYS_StartTickCount (
+    void
+);
+
+NCGuint32
+NCGSYS_GetTickCount (
+    void
+);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NCG_TIME_H__ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/inc/ncg_vg.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,72 @@
+/******************************************************************************
+* Copyright(c) 2010-2013 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : R-GPVG Functions header
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2011.01.12
+*          - Created the initial code.
+*          2012.08.22
+*          - Updated coding format.
+*          2013.05.13
+*          - Added function of initialization.
+*          - Added function of finalization.
+*
+*******************************************************************************/
+
+#ifndef NCG_VG_H
+#define NCG_VG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "ncg_defs.h"
+/*=============================================================================
+ * Definitions
+ */
+
+/* VGINFO */
+typedef struct VGINFO_TAG {
+    NCGuint32   ui32Flags;
+} NCGVGINFO, * PNCGVGINFO;
+
+/* RGPINFO */
+typedef struct RGPINFO_TAG {
+    NCGuint32   ui32WorkBufferStride;       /* Work Buffer Stride */
+    NCGuint32   ui32WorkBufferHeight;       /* Work Buffer Height */
+    NCGuint32   ui32StreamBuffer0Size;      /* Stream Buffer 0 Size */
+    NCGuint32   ui32StreamBuffer1Size;      /* Stream Buffer 1 Size */
+    NCGuint32   ui32DisplayListBufferSize;  /* Display List Buffer Size */
+} NCGRGPINFO, * PNCGRGPINFO;
+
+
+/*=============================================================================
+ *  Structures
+ */
+
+
+/*=============================================================================
+ *  Function prototyping
+ */
+
+/*
+ *  VG initialization / finalization
+ */
+NCGvoid
+NCGVG_Init (
+    PNCGVGINFO      pVGInfo
+);
+
+NCGvoid
+NCGVG_DeInit (
+    PNCGVGINFO      pVGInfo
+);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NCG_VG_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/inc/ncg_vg_isr.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,68 @@
+/******************************************************************************
+* Copyright(c) 2010-2013 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : NCG R-GPVG interrupt handling functions header.
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2010.10.08
+*          - Created the initial code.
+*          2012.08.22
+*          - Updated coding format.
+*          2013.01.08
+*          - Applied to R-GPVG2 for Aragon.
+*          2013.02.21
+*          - Modified the value of NCGVG_INT_LEVEL.
+*
+*******************************************************************************/
+
+#ifndef NCG_VG_ISR_H
+#define NCG_VG_ISR_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*=============================================================================
+ * Definitions
+ */
+
+#define NCGVG_INT0_VECT     (130)
+#define NCGVG_INT1_VECT     (131)
+#define NCGVG_INT2_VECT     (132)
+#define NCGVG_INT3_VECT     (133)
+
+#define NCGVG_INT_LEVEL     (5)               /* interrupt level */
+
+
+/*=============================================================================
+ *  Structures
+ */
+
+
+/*=============================================================================
+ *  Function prototyping
+ */
+
+/*
+ * VG interrupt handling
+ */
+
+NCGint32
+NCGVG_Attach_ISR (
+    NCGVGISRfp pfnInterrupt
+);
+
+NCGint32
+NCGVG_Detach_ISR (
+    NCGVGISRfp pfnInterrupt
+);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NCG_VG_ISR_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/src/ncg_memory.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,53 @@
+/******************************************************************************
+* Copyright(c) 2010-2012 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : NCG memory operation functions.
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2013.06.25
+*          - Changed for RGAH
+*          2010.10.08
+*          - Created the initial code.
+*          2012.08.23
+*          - Created the initial code.
+*          2014.12.22
+*          - Applied to OSPL and RGA.
+*
+*******************************************************************************/
+
+/*=============================================================================
+ * Includes
+ */
+
+#include "Project_Config.h"
+#include "ncg_defs.h"
+#include "ncg_memory.h"
+
+#ifdef  RGAH_VERSION
+
+/*=============================================================================
+ * Internal definitions
+ */
+
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGSYS_CPUVAddrToSysPAddr
+ FUNCTION   : Get the system physical address of the given host memory block.
+ PARAMETERS : ui32CPUAddr  : [IN ] The address of the host memory area.
+ RETURN     : Phy.
+------------------------------------------------------------------------------*/
+NCGuint32
+NCGSYS_CPUVAddrToSysPAddr (
+    NCGuint32   ui32CPUAddr )
+{
+    NCGuint32   ui32Ret_addr;
+
+    ui32Ret_addr = ui32CPUAddr;
+
+    return ui32Ret_addr;
+}
+
+
+#endif
+/* -- end of file -- */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/src/ncg_register.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,85 @@
+/******************************************************************************
+* Copyright (c) 2010-2012 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : NCG register read/write Functions
+*
+* author : Renesas Electronics Corporation.
+*
+* history: 2013.06.25
+*          - Changed for RGAH
+*          2010.10.08
+*          - Created the initial code.
+*          2012.08.22
+*          - Updated coding format.
+*          2014.12.22
+*          - Applied to OSPL and RGA.
+*
+*******************************************************************************/
+
+/*=============================================================================
+ * Includes
+ */
+
+#include "Project_Config.h"
+#include "ncg_defs.h"
+#include "ncg_register.h"
+
+#ifdef  RGAH_VERSION
+
+/*=============================================================================
+ * Internal definitions
+ */
+
+
+/*=============================================================================
+ *  Prototyping of internal functions
+ */
+
+
+/*=============================================================================
+ *  Private global variables and functions
+ */
+
+
+/*=============================================================================
+ *  Global Function
+ */
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGSYS_ReadReg
+ FUNCTION   : Read a hardware register.
+ PARAMETERS : ui32RegBase : [IN ] Base address.
+              ui32Offset  : [IN ] Address offset.
+ RETURN     : Register value.
+------------------------------------------------------------------------------*/
+NCGuint32
+NCGSYS_ReadReg (
+    NCGuint32       ui32RegBase,
+    NCGuint32       ui32Offset )
+{
+    NCGuint32 ui32RegVal;
+
+    ui32RegVal = *(((volatile NCGuint32 *)ui32RegBase) + (ui32Offset>>2));
+
+    return ui32RegVal;
+}
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGSYS_WriteReg
+ FUNCTION   : Write a hardware register.
+ PARAMETERS : ui32RegBase : [IN ] Base address.
+              ui32Offset  : [IN ] Address offset.
+              ui32Value   : [IN ] Register value.
+ RETURN     : None.
+------------------------------------------------------------------------------*/
+NCGvoid
+NCGSYS_WriteReg (
+    NCGuint32       ui32RegBase,
+    NCGuint32       ui32Offset,
+    NCGuint32       ui32Value )
+{
+    *(((volatile NCGuint32 *)ui32RegBase) + (ui32Offset>>2)) = ui32Value;
+}
+
+#endif
+/* -- end of file -- */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/src/ncg_state.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,499 @@
+/******************************************************************************
+* Copyright(c) 2010-2012 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : NCG State variable control functions.
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2010.10.08
+*          - Created the initial code.
+*          2013.05.20
+*          - Applied to CMSIS-RTOS RTX.
+*          2014.12.10
+*          - Applied to OSPL and RGA.
+*
+*******************************************************************************/
+
+/*=============================================================================
+ * Includes
+ */
+#include "Project_Config.h"
+#include "r_ospl.h"
+
+#include    "ncg_defs.h"
+#include    "ncg_debug.h"
+#include    "ncg_state.h"
+
+#ifdef  RGAH_VERSION
+
+/*=============================================================================
+ * Internal definitions
+ */
+
+#define     NCG_MAX_STATE_OBJECTS   (1U)
+#define     NCG_MAX_THREAD_ID       (1U)
+
+struct NCG_STATE_T {
+    r_ospl_thread_id_t  id[NCG_MAX_THREAD_ID];
+    NCGboolean      bInUse;
+    int32_t         flgbit;
+    NCGuint32       ui32State;
+} ;
+
+
+/*=============================================================================
+ *  Prototyping of internal functions
+ */
+
+static NCGint32 ncg_init_states( void ) ;
+static NCGuint32 ncg_state_search( NCGvoid *pObj );
+
+
+/*=============================================================================
+ *  Private global variables and functions
+ */
+
+volatile static struct NCG_STATE_T tStates[NCG_MAX_STATE_OBJECTS];
+
+static NCGboolean ncg_state_initialized = NCG_FALSE ;
+static struct NCG_STATE_T *ncg_last_created_state;
+
+
+/*=============================================================================
+ *  Global Function
+ */
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGSYS_CreateState
+ FUNCTION   : Create a state control object.
+ PARAMETERS : ppObj       : [OUT] The pointer to the created state control object.
+              ui32StateID : [IN ] The identifier of the state variable.
+ RETURN     : Error code of the NCG.
+------------------------------------------------------------------------------*/
+NCGint32
+NCGSYS_CreateState(
+    NCGvoid         **ppObj,
+    NCGuint32       ui32StateID )
+{
+    struct NCG_STATE_T  *p_state;
+    NCGuint32           state_idx;
+    NCGuint32           thread_idx;
+
+    NCG_DEBUG_PRINT_STRING( "[LOG] NCGSYS_CreateState" );
+
+    NCG_UNREFERENCED_PARAMETER(ui32StateID);
+
+    if( ppObj == NCG_NULL ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_CreateState(1) invalid ppObj.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return NCG_err_invalid_handle ;
+    }
+
+    if( ncg_state_initialized == NCG_FALSE ) {
+        ncg_init_states();
+    }
+
+    p_state = NULL;
+    for ( state_idx = 0 ; state_idx < NCG_MAX_STATE_OBJECTS ; state_idx++ ) {
+        if ( tStates[state_idx].bInUse == NCG_FALSE ) {
+            p_state = (struct NCG_STATE_T *)&tStates[state_idx];
+            break ;
+        }
+    }
+    if ( p_state == NULL ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_CreateState(2) Object over flow.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return NCG_err_resource_exceeded ;
+    }
+
+    /* set initial value */
+    for ( thread_idx = 1U ; thread_idx < NCG_MAX_THREAD_ID ; thread_idx++ ) {
+        p_state->id[thread_idx] = NULL;
+    }
+    p_state->id[0]     = R_OSPL_THREAD_GetCurrentId();    /* [0] is current thread id */
+    p_state->bInUse    = NCG_TRUE ;
+    p_state->ui32State = 0U ;
+
+    *ppObj = ( NCGvoid *)p_state ;
+    ncg_last_created_state = p_state;
+
+    return NCG_no_err ;
+}
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGSYS_DestroyState
+ FUNCTION   : Destroy the given state control object.
+ PARAMETERS : pObj : [IN ] The pointer to the state control object.
+ RETURN     : Error code of the NCG.
+------------------------------------------------------------------------------*/
+NCGint32
+NCGSYS_DestroyState(
+    NCGvoid *pObj )
+{
+    volatile struct NCG_STATE_T *p_state;
+    NCGuint32                   state_idx;
+    NCGuint32                   thread_idx;
+    NCGboolean bDestroyFlg ;
+
+    NCG_DEBUG_PRINT_STRING( "[LOG] NCGSYS_DestroyState" );
+
+    p_state = (struct NCG_STATE_T *)pObj;
+    if( p_state == NCG_NULL ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_DestroyState(1) Failed: pObj is NULL.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return NCG_err_invalid_handle ;
+    }
+
+    state_idx = ncg_state_search( pObj );
+    if ( state_idx >= NCG_MAX_STATE_OBJECTS ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_DestroyState(2) Failed: pObj is not found.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return NCG_err_not_found ;
+    }
+
+    if( p_state->bInUse == NCG_FALSE ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_DestroyState(3) Failed: pObj is not used.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return NCG_err_bad_parameter ;
+    }
+
+    /* clear status parameters */
+    for ( thread_idx = 0 ; thread_idx < NCG_MAX_THREAD_ID ; thread_idx++ ) {
+        p_state->id[thread_idx] = NULL;
+    }
+    p_state->bInUse    = NCG_FALSE;
+    p_state->ui32State = 0U;
+
+    bDestroyFlg = NCG_TRUE ;
+    for ( state_idx = 0 ; state_idx < NCG_MAX_STATE_OBJECTS ; state_idx++ ) {
+        if ( tStates[state_idx].bInUse != NCG_FALSE ) {
+            bDestroyFlg = NCG_FALSE ;
+            break ;
+        }
+    }
+    if ( bDestroyFlg != NCG_FALSE ) {
+        ncg_state_initialized = NCG_FALSE ;
+    }
+    return NCG_no_err ;
+}
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGSYS_SetState
+ FUNCTION   : Set the state control object into the given state.
+ PARAMETERS : pObj      : [IN ] The pointer to the state control object.
+              ui32State : [IN ] The state value to set.
+              ui32Flags : [IN ] Flags.
+ RETURN     : Error code of the NCG.
+------------------------------------------------------------------------------*/
+NCGint32
+NCGSYS_SetState(
+    NCGvoid         *pObj,
+    NCGuint32       ui32State,
+    NCGuint32       ui32Flags )
+{
+    volatile struct NCG_STATE_T *p_state = (volatile struct NCG_STATE_T *)pObj ;
+
+    NCGuint32                   uiSetMask;
+    NCGuint32                   thread_idx;
+
+    NCG_DEBUG_PRINT_STRING( "[LOG] NCGSYS_SetState" );
+
+    if( pObj == NCG_NULL ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_SetState(1) Failed:pObj is NULL.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return NCG_err_unknown ;
+    }
+
+    if ( ncg_state_search( pObj ) >= NCG_MAX_STATE_OBJECTS ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_SetState(2) Failed: pObj is not found.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return NCG_err_not_found ;
+    }
+
+    p_state = (volatile struct NCG_STATE_T *)pObj;
+    if ( p_state->bInUse == NCG_FALSE ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_SetState(3) Failed: pObj is not used.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return NCG_err_bad_parameter ;
+    }
+
+    uiSetMask = ui32Flags & NCGSYS_STATE_SET_MASK;
+    switch( uiSetMask ) {
+        case NCGSYS_STATE_SET_AND :
+            p_state->ui32State &= ui32State ;
+            break ;
+
+        case NCGSYS_STATE_SET_OR :
+            p_state->ui32State |= ui32State ;
+            break ;
+
+        case NCGSYS_STATE_SET_SET :
+            p_state->ui32State = ui32State ;
+            break ;
+
+        default :
+            NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_SetState(5) Failed:ui32Flags (0x%08x).%s" )
+            NCG_DEBUG_MAKE_MSG_PARAMETER( ui32Flags )
+            NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+            NCG_DEBUG_MAKE_MSG_END();
+            NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+            return NCG_err_bad_parameter ;
+    }
+
+    if ( uiSetMask == NCGSYS_STATE_SET_AND ) {
+        for ( thread_idx = 0 ; thread_idx < NCG_MAX_THREAD_ID ; thread_idx++ ) {
+            if ( p_state->id[thread_idx] != NULL ) {
+                r_ospl_thread_id_t  thread = p_state->id[thread_idx];  /* ICCARM Pa082 : volatile's order */
+                R_OSPL_EVENT_Clear( thread, p_state->flgbit );
+            }
+        }
+    } else {
+        for ( thread_idx = 0 ; thread_idx < NCG_MAX_THREAD_ID ; thread_idx++ ) {
+            if ( p_state->id[thread_idx] != NULL ) {
+                r_ospl_thread_id_t  thread = p_state->id[thread_idx];  /* ICCARM Pa082 : volatile's order */
+                R_OSPL_EVENT_Set( thread, p_state->flgbit );
+            }
+        }
+    }
+
+    return NCG_no_err ;
+}
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGSYS_GetState
+ FUNCTION   : Get the current state value from the state control object.
+ PARAMETERS : pObj       : [IN ] The pointer to the state control object.
+              ui32Flags  : [IN ] Flags.
+ RETURN     : Error code of the NCG.
+------------------------------------------------------------------------------*/
+NCGuint32
+NCGSYS_GetState(
+    NCGvoid         *pObj,
+    NCGuint32       ui32Flags )
+{
+    volatile struct NCG_STATE_T *p_state;
+
+    NCG_DEBUG_PRINT_STRING( "[LOG] NCGSYS_GetState" );
+
+    NCG_UNREFERENCED_PARAMETER(ui32Flags);
+
+    if ( pObj == NCG_NULL ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_GetState(1) Failed: pObj.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return (NCGuint32)NCG_err_unknown ;
+    }
+
+    if ( ncg_state_search( pObj ) >= NCG_MAX_STATE_OBJECTS ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_GetState(2) Failed: pObj is not found.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return (NCGuint32)NCG_err_not_found ;
+    }
+
+    p_state = (volatile struct NCG_STATE_T *)pObj;
+    if( p_state->bInUse == NCG_FALSE ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_GetState(3) Failed: pObj is not used.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return (NCGuint32)NCG_err_bad_parameter ;
+    }
+    return ( NCGuint32 )p_state->ui32State ;
+}
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGSYS_WaitState
+ FUNCTION   : Wait for the state control object to be in the given state.
+ PARAMETERS : pObj        : [IN ] The pointer to the state control object.
+              ui32State   : [IN ] The state value to wait for.
+              ui32Flags   : [IN ] Flags.
+              ui32Timeout : [IN ] Timeout value in milli seconds.
+ RETURN     : Error code of the NCG.
+------------------------------------------------------------------------------*/
+NCGint32
+NCGSYS_WaitState(
+    NCGvoid         *pObj,
+    NCGuint32       ui32State,
+    NCGuint32       ui32Flags,
+    NCGuint32       ui32Timeout )
+{
+    volatile struct NCG_STATE_T     *p_state;
+    NCGuint32                       wait_mode;
+    NCGuint32                       thread_idx;
+    NCGint32                        func_ret;
+    uint32_t                        time_out;
+    errnum_t                        e;
+
+
+    NCG_DEBUG_PRINT_STRING( "[LOG] NCGSYS_WaitState" );
+
+    p_state    = (volatile struct NCG_STATE_T *)pObj;
+    wait_mode = (ui32Flags & NCGSYS_STATE_WAIT_MASK);
+
+    if ( p_state == NCG_NULL ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_WaitState(1) Failed: pObj is NULL.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return NCG_err_unknown ;
+    }
+    if ( p_state->bInUse == NCG_FALSE ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_WaitState(2) Failed: pObj.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return NCG_err_unknown ;
+    }
+    if (( ui32Timeout != NCG_TIMEOUT_INFINITE ) && ( ui32Timeout > 0x7fffffffU )) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGSYS_WaitState(3) Failed: ui32Timeout.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        return NCG_err_unknown ;
+    }
+
+    if ( ui32Timeout == NCG_TIMEOUT_INFINITE ) {
+        time_out = R_OSPL_INFINITE;
+    } else {
+        time_out = ui32Timeout;
+    }
+
+    for ( thread_idx = 0 ; thread_idx < NCG_MAX_THREAD_ID ; thread_idx++ ) {
+        if ( p_state->id[thread_idx] == R_OSPL_THREAD_GetCurrentId() ) {
+            break;
+        }
+        if ( p_state->id[thread_idx] == NULL ) {
+            /* add thread ID */
+            p_state->id[thread_idx] = R_OSPL_THREAD_GetCurrentId();
+            break;
+        }
+    }
+
+    while (1) {
+        if ( wait_mode == NCGSYS_STATE_WAIT_OR ) {
+            if ( (p_state->ui32State & ui32State) != 0 ) {
+                func_ret = NCG_no_err;
+                break;
+            }
+        } else {
+            /* wait_mode == NCGSYS_STATE_WAIT_AND */
+            if ( (p_state->ui32State & ui32State) == ui32State ) {
+                func_ret = NCG_no_err;
+                break;
+            }
+        }
+        e = R_OSPL_EVENT_Wait( p_state->flgbit, NULL, time_out );
+        IF ( e != 0 ) {
+            func_ret = NCG_err_unknown;
+            break;
+        }
+    }
+
+    for ( thread_idx = 1 ; thread_idx < NCG_MAX_THREAD_ID ; thread_idx++ ) {
+        p_state->id[thread_idx] = NULL;
+    }
+
+    return func_ret;
+}
+
+
+/*=============================================================================
+ *  Internal functions
+ */
+
+/*----------------------------------------------------------------------------
+ NAME       : ncg_init_states
+ FUNCTION   : Initialize global variable in NCG state.
+ PARAMETERS : None.
+ RETURN     : None.
+------------------------------------------------------------------------------*/
+static NCGint32
+ncg_init_states( void )
+{
+    NCGuint32   i ;
+    NCGuint32   thread_idx;
+
+    for( i = 0 ; i < NCG_MAX_STATE_OBJECTS ; i++ ) {
+        for ( thread_idx = 0 ; thread_idx < NCG_MAX_THREAD_ID ; thread_idx++ ) {
+            tStates[i].id[thread_idx] = NULL;
+        }
+        tStates[i].bInUse    = NCG_FALSE ;
+        tStates[i].flgbit    = (int32_t)(1 << i) ;
+        tStates[ i ].ui32State = 0U ;
+    }
+    ncg_state_initialized = NCG_TRUE ;
+
+    return NCG_no_err;
+}
+
+/*----------------------------------------------------------------------------
+ NAME       : ncg_state_search
+ FUNCTION   : Search status object.
+ PARAMETERS : pObj :[IN ] Handle to the status object.
+ RETURN     : Index of the status object.
+------------------------------------------------------------------------------*/
+static NCGuint32 ncg_state_search(
+    NCGvoid     *pObj
+)
+{
+    NCGuint32               state_idx;
+
+    for ( state_idx = 0U ; state_idx < NCG_MAX_STATE_OBJECTS ; state_idx++ ) {
+        if ( pObj == &tStates[state_idx] ) {
+            break;
+        }
+    }
+
+    return state_idx;
+}
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGSYS_SetStateEventValue
+ FUNCTION   : Set the value of thread attached event.
+ PARAMETERS : pObj           : [IN ] The pointer to the state control object.
+              ui32EventValue : [IN ] The value of thread attached event.
+ RETURN     : None.
+------------------------------------------------------------------------------*/
+NCGvoid
+NCGSYS_SetStateEventValue(
+    NCGvoid         *pObj,
+    NCGuint32       ui32EventValue )
+{
+    volatile struct NCG_STATE_T *p_state = (volatile struct NCG_STATE_T *)pObj ;
+
+    p_state->flgbit = ui32EventValue;
+}
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGSYS_GetLastCreatedState
+ FUNCTION   : GetLastCreatedState.
+ PARAMETERS : None.
+ RETURN     : LastCreatedState.
+------------------------------------------------------------------------------*/
+NCGvoid *
+NCGSYS_GetLastCreatedState(void)
+{
+    return  (NCGvoid *) ncg_last_created_state;
+}
+
+#endif
+/* -- end of file -- */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/src/ncg_vg.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,161 @@
+/******************************************************************************
+* Copyright(c) 2010-2014 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : R-GPVG control functions.
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2011.01.20
+*          - Created the initial code.
+*          2012.08.22
+*          - Added return value to "NCGVG_InitResourceSize"
+*          2013.05.13
+*          - Added function of initialization.
+*          - Added function of finalization.
+*          2013.06.10
+*          - Applied to new VDC5 driver (Version 0.03.0046).
+*          2013.11.07
+*          - Modified value of NCG_VG_SBO1_SIZE to (4U) from (0U).
+*          2014.02.13
+*          - Modified the value of definitions.
+*              NCG_VG_WB_STRIDE
+*              NCG_VG_WB_HEIGHT
+*              NCG_VG_SBO0_SIZE
+*              NCG_VG_DLB_SIZE
+*          2014.03.25
+*          - Modified NCGVG_Init() and NCGVG_DeInit().
+*          2014.05.16
+*          - Modified NCGVG_Init() and NCGVG_DeInit().
+*          2014.12.22
+*          - Applied to OSPL and RGA.
+*
+*******************************************************************************/
+
+/*=============================================================================
+ * Includes
+ */
+
+#include "Project_Config.h"
+#include "ncg_defs.h"
+#include "ncg_debug.h"
+#include "r_ospl.h"
+
+#include "ncg_vg.h"
+
+/* Depending on the build environment */
+#include "r_typedefs.h"
+
+#include "iodefine.h"
+#include "iobitmasks/cpg_iobitmask.h"
+
+#ifdef  RGAH_VERSION
+
+/*=============================================================================
+ * Internal definitions
+ */
+
+/* TODO:
+    Please change these parameters in accordance with your system.
+ */
+#define NCG_VG_WB_STRIDE    (256U)
+#define NCG_VG_WB_HEIGHT    (480U)
+
+#define NCG_VG_SBO0_SIZE    (16384U)
+#define NCG_VG_SBO1_SIZE    (4U)
+#define NCG_VG_DLB_SIZE     (5120U)
+
+/*=============================================================================
+ *  Prototyping of internal functions
+ */
+
+
+/*=============================================================================
+ *  Private global variables and functions
+ */
+
+
+/*=============================================================================
+ *  Global Function
+ */
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGVG_Init
+ FUNCTION   : Initialize R-GPVG.
+ PARAMETERS : pVGInfo : [IN ] The pointer to the initialization information struct.
+ RETURN     : None.
+------------------------------------------------------------------------------*/
+NCGvoid
+NCGVG_Init (
+    PNCGVGINFO pVGInfo)
+{
+    /* Depending on the build environment */
+    volatile uint8_t    reg_value;
+
+    NCG_UNREFERENCED_PARAMETER( pVGInfo );
+
+    NCG_DEBUG_PRINT_STRING( "[LOG] NCGVG_Init" );
+
+    reg_value = CPG.STBCR10;
+    if ( CPG.STBCR10 & CPG_STBCR10_MSTP100 ) {
+        /* Standby control register 10 (STBCR10) : 0 : R-GPVG enable */
+        CPG.STBCR10 &= ~CPG_STBCR10_MSTP100;
+        /* dummy read */
+        reg_value = CPG.STBCR10;
+
+        if ( CPG.STBREQ2 & CPG_STBREQ2_STBRQ20 ) {
+            CPG.SWRSTCR3 |=  CPG_SWRSTCR3_SRST32;
+            /* dummy read */
+            reg_value = CPG.SWRSTCR3;
+
+            CPG.SWRSTCR3 &= ~CPG_SWRSTCR3_SRST32;
+            /* dummy read */
+            reg_value = CPG.SWRSTCR3;
+
+            CPG.STBREQ2 &= ~CPG_STBREQ2_STBRQ20;
+            /* dummy read */
+            reg_value = CPG.STBREQ2;
+            while ( (CPG.STBACK2 & CPG_STBACK2_STBAK20) != 0  ) ;
+        }
+    }
+
+    NCG_UNREFERENCED_PARAMETER( reg_value );  /* Avoid warning of "unused-but-set-variable" of GCC_ARM */
+
+    return ;
+}
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGVG_DeInit
+ FUNCTION   : Finalize R-GPVG.
+ PARAMETERS : pVGInfo : [IN ] The pointer to the finalization information struct.
+ RETURN     : None.
+------------------------------------------------------------------------------*/
+NCGvoid
+NCGVG_DeInit (
+    PNCGVGINFO      pVGInfo )
+{
+    /* Depending on the build environment */
+    volatile uint8_t    reg_value;
+
+    NCG_UNREFERENCED_PARAMETER(pVGInfo);
+
+    NCG_DEBUG_PRINT_STRING( "[LOG] NCGVG_DeInit" );
+
+    if ( (CPG.STBCR10 & CPG_STBCR10_MSTP100) != CPG_STBCR10_MSTP100 ) {
+        CPG.STBREQ2 |= CPG_STBREQ2_STBRQ20;
+        /* dummy read */
+        reg_value = CPG.STBREQ2;
+        while ( (CPG.STBACK2 & CPG_STBACK2_STBAK20) == 0  ) ;
+
+        /* Standby control register 10 (STBCR10) : 0 : R-GPVG disable */
+        CPG.STBCR10 |= CPG_STBCR10_MSTP100;
+        /* dummy read */
+        reg_value = CPG.STBCR10;
+    }
+
+    NCG_UNREFERENCED_PARAMETER( reg_value );  /* Avoid warning of "unused-but-set-variable" of GCC_ARM */
+
+    return ;
+}
+
+#endif
+/* -- end of file -- */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/RGPNCG/src/ncg_vg_isr.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,357 @@
+/******************************************************************************
+* Copyright(c) 2010-2015 Renesas Electronics Corporation. All rights reserved.
+*
+* brief  : R-GPVG control functions
+*
+* author : Renesas Electronics Corporation
+*
+* history: 2010.10.08
+*          - Created the initial code.
+*          2011.03.07
+*          - Fixed bug : NCGVG_Detach_ISR / [R-GPVG_common_P_033]
+*          2012.08.22
+*          - Moved definition to "ncg_vg_isr.h".
+*            - RGPVG_INT_LEVEL
+*          - Moved definition to "ncg_register.h".
+*            - RTIP_VG_BASE
+*            - VG_REG_VG_ISR
+*          2012.08.22
+*          - Added error message in the debug mode.
+*          - Update all comments
+*          2013.02.21
+*          - Modified the argument of the NCGVG_RGPVG_ISR.
+*          - Modified the call to R_INTC_RegistIntFunc function
+*            by NCGVG_Attach_ISR.
+*          2014.12.22
+*          - Applied to OSPL and RGA.
+*
+*******************************************************************************/
+
+
+/*=============================================================================
+ * Includes
+ */
+
+#include "Project_Config.h"
+#include    "ncg_defs.h"
+#include    "ncg_debug.h"
+#include    "ncg_vg_isr.h"
+#include    "RGA.h"
+
+/* Depending on the build environment */
+#include    "r_typedefs.h"
+#include    "r_ospl.h"
+
+#ifdef  RGAH_VERSION
+
+/*=============================================================================
+ * Internal definitions
+ */
+
+
+/*=============================================================================
+ *  Prototyping of internal functions
+ */
+static void NCGVG_RGPVG_ISR(void) ;
+static void NCGVG_RGPVG_ISR_0(void) ;
+static void NCGVG_RGPVG_ISR_1(void) ;
+static void NCGVG_RGPVG_ISR_2(void) ;
+static void NCGVG_RGPVG_ISR_3(void) ;
+
+
+/*=============================================================================
+ *  Private global variables and functions
+ */
+static NCGboolean NCGVG_ISR_Initialized  = NCG_FALSE ;
+static NCGVGISRfp NCGVG_pRGPVG_Interrupt = NCG_NULL ;
+
+
+/*=============================================================================
+ *  Global Function
+ */
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGVG_Attach_ISR
+ FUNCTION   : Attach the function pointer of OpenVG ISR.
+ PARAMETERS : pfnInterrupt : [IN ] The pointer to the function of OpenVG ISR.
+ RETURN     : Error code of the NCG.
+------------------------------------------------------------------------------*/
+NCGint32
+NCGVG_Attach_ISR(
+    NCGVGISRfp      pfnInterrupt )
+{
+    NCGint32        rc_val = NCG_no_err;
+    bsp_int_err_t   eb;
+    errnum_t        e;
+
+    NCG_DEBUG_PRINT_STRING( "[LOG] NCGVG_Attach_ISR" );
+
+    NCG_ASSERT(pfnInterrupt != NCG_NULL);
+
+    if( NCGVG_ISR_Initialized != NCG_FALSE ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGVG_Attach_ISR(1) Initialized.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        rc_val = NCG_err_isr_management_failed ;
+    } else {
+        NCGVG_ISR_Initialized  = NCG_TRUE ;
+        NCGVG_pRGPVG_Interrupt = pfnInterrupt ;
+
+        /* Regist function */
+        eb= R_BSP_InterruptWrite( BSP_INT_SRC_INT0, NCGVG_RGPVG_ISR_0 );
+        IF ( eb != BSP_INT_SUCCESS ) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+        eb= R_BSP_InterruptWrite( BSP_INT_SRC_INT1, NCGVG_RGPVG_ISR_1 );
+        IF ( eb != BSP_INT_SUCCESS ) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+        eb= R_BSP_InterruptWrite( BSP_INT_SRC_INT2, NCGVG_RGPVG_ISR_2 );
+        IF ( eb != BSP_INT_SUCCESS ) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+        eb= R_BSP_InterruptWrite( BSP_INT_SRC_INT3, NCGVG_RGPVG_ISR_3 );
+        IF ( eb != BSP_INT_SUCCESS ) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+
+        /* set priority */
+        e= R_OSPL_SetInterruptPriority( BSP_INT_SRC_INT0, NCGVG_INT_LEVEL );
+        IF(e) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+        e= R_OSPL_SetInterruptPriority( BSP_INT_SRC_INT1, NCGVG_INT_LEVEL );
+        IF(e) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+        e= R_OSPL_SetInterruptPriority( BSP_INT_SRC_INT2, NCGVG_INT_LEVEL );
+        IF(e) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+        e= R_OSPL_SetInterruptPriority( BSP_INT_SRC_INT3, NCGVG_INT_LEVEL );
+        IF(e) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+
+        /* Enable interrupt from Renesas OpenVG library */
+        eb= R_BSP_InterruptControl( BSP_INT_SRC_INT0, BSP_INT_CMD_INTERRUPT_ENABLE, FIT_NO_PTR );
+        IF ( eb != BSP_INT_SUCCESS ) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+        eb= R_BSP_InterruptControl( BSP_INT_SRC_INT1, BSP_INT_CMD_INTERRUPT_ENABLE, FIT_NO_PTR );
+        IF ( eb != BSP_INT_SUCCESS ) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+        eb= R_BSP_InterruptControl( BSP_INT_SRC_INT2, BSP_INT_CMD_INTERRUPT_ENABLE, FIT_NO_PTR );
+        IF ( eb != BSP_INT_SUCCESS ) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+        eb= R_BSP_InterruptControl( BSP_INT_SRC_INT3, BSP_INT_CMD_INTERRUPT_ENABLE, FIT_NO_PTR );
+        IF ( eb != BSP_INT_SUCCESS ) {
+            rc_val = NCG_err_isr_management_failed;
+            goto fin;
+        }
+    }
+
+fin:
+    return rc_val;
+}
+
+
+/*----------------------------------------------------------------------------
+ NAME       : NCGVG_Detach_ISR
+ FUNCTION   : Detach the function pointer of OpenVG ISR.
+ PARAMETERS : pfnInterrupt : [IN ] The pointer to the function of OpenVG ISR.
+ RETURN     : Error code of the NCG.
+------------------------------------------------------------------------------*/
+NCGint32
+NCGVG_Detach_ISR(
+    NCGVGISRfp      pfnInterrupt )
+{
+    NCGint32        rc_val = NCG_no_err;
+    bsp_int_err_t   eb;
+
+    NCG_DEBUG_PRINT_STRING( "[LOG] NCGVG_Detach_ISR" );
+
+    NCG_ASSERT(pfnInterrupt != NCG_NULL);
+
+    if ( NCGVG_ISR_Initialized == NCG_FALSE ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGVG_Detach_ISR(1) Not initialized.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        rc_val = NCG_err_isr_management_failed;
+    } else {
+        NCGVG_ISR_Initialized = NCG_FALSE ;
+
+        if( pfnInterrupt == NCGVG_pRGPVG_Interrupt ) {
+            /* Disable interrupt from Renesas OpenVG library */
+            eb= R_BSP_InterruptControl( BSP_INT_SRC_INT3, BSP_INT_CMD_INTERRUPT_DISABLE, FIT_NO_PTR );
+            IF ( eb != BSP_INT_SUCCESS ) {
+                rc_val = NCG_err_isr_management_failed;
+                goto fin;
+            }
+            eb= R_BSP_InterruptControl( BSP_INT_SRC_INT2, BSP_INT_CMD_INTERRUPT_DISABLE, FIT_NO_PTR );
+            IF ( eb != BSP_INT_SUCCESS ) {
+                rc_val = NCG_err_isr_management_failed;
+                goto fin;
+            }
+            eb= R_BSP_InterruptControl( BSP_INT_SRC_INT1, BSP_INT_CMD_INTERRUPT_DISABLE, FIT_NO_PTR );
+            IF ( eb != BSP_INT_SUCCESS ) {
+                rc_val = NCG_err_isr_management_failed;
+                goto fin;
+            }
+            eb= R_BSP_InterruptControl( BSP_INT_SRC_INT0, BSP_INT_CMD_INTERRUPT_DISABLE, FIT_NO_PTR );
+            IF ( eb != BSP_INT_SUCCESS ) {
+                rc_val = NCG_err_isr_management_failed;
+                goto fin;
+            }
+
+            /* Unregist function */
+            eb= R_BSP_InterruptWrite( BSP_INT_SRC_INT3, FIT_NO_FUNC );
+            IF ( eb != BSP_INT_SUCCESS ) {
+                rc_val = NCG_err_isr_management_failed;
+                goto fin;
+            }
+            eb= R_BSP_InterruptWrite( BSP_INT_SRC_INT2, FIT_NO_FUNC );
+            IF ( eb != BSP_INT_SUCCESS ) {
+                rc_val = NCG_err_isr_management_failed;
+                goto fin;
+            }
+            eb= R_BSP_InterruptWrite( BSP_INT_SRC_INT1, FIT_NO_FUNC );
+            IF ( eb != BSP_INT_SUCCESS ) {
+                rc_val = NCG_err_isr_management_failed;
+                goto fin;
+            }
+            eb= R_BSP_InterruptWrite( BSP_INT_SRC_INT0, FIT_NO_FUNC );
+            IF ( eb != BSP_INT_SUCCESS ) {
+                rc_val = NCG_err_isr_management_failed;
+                goto fin;
+            }
+
+            NCGVG_pRGPVG_Interrupt = NCG_NULL ;
+        } else {
+            NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGVG_Detach_ISR(2) Miss match function pointer.%s" )
+            NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+            NCG_DEBUG_MAKE_MSG_END();
+            NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+            rc_val = NCG_err_isr_management_failed;
+        }
+    }
+
+fin:
+    return rc_val;
+}
+
+
+/*=============================================================================
+ *  Internal functions
+ */
+
+/*-----------------------------------------------------------------------------
+ NAME       : NCGVG_RGPVG_ISR
+ FUNCTION   : The Interrrupt from OpenVG.
+ PARAMETERS :
+ RETURN     : None.
+-----------------------------------------------------------------------------*/
+static void NCGVG_RGPVG_ISR(void)
+{
+    NCGuint32 ret ;
+    errnum_t  e;
+
+    NCG_DEBUG_PRINT_STRING( "[LOG] NCGVG_RGPVG_ISR" );
+
+    if( NCGVG_pRGPVG_Interrupt == NCG_NULL ) {
+        NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][INFO]NCGVG_RGPVG_ISR Not initialized.%s" )
+        NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+        NCG_DEBUG_MAKE_MSG_END();
+        NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+    } else {
+        ret = NCGVG_pRGPVG_Interrupt() ;
+        if ( ret != 0 ) {
+            NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGVG_RGPVG_ISR(0x%08x)%s" )
+            NCG_DEBUG_MAKE_MSG_PARAMETER( ret )
+            NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+            NCG_DEBUG_MAKE_MSG_END();
+            NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        }
+
+        e= R_GRAPHICS_OnInterrupting();
+        if ( e != 0 ) {
+            NCG_DEBUG_MAKE_MSG_START( NCG_G_MASSAGE_BUFF, "[NCG][ERROR]NCGVG_RGPVG_ISR(e=0x%08x)%s" )
+            NCG_DEBUG_MAKE_MSG_PARAMETER( e )
+            NCG_DEBUG_MAKE_MSG_PARAMETER( NCG_CRLF )
+            NCG_DEBUG_MAKE_MSG_END();
+            NCG_DEBUG_PRINT_MSG( NCG_G_MASSAGE_BUFF );
+        }
+    }
+
+    return ;
+}
+
+/*-----------------------------------------------------------------------------
+ NAME       : NCGVG_RGPVG_ISR_0
+ FUNCTION   : The Interrrupt from OpenVG.
+ PARAMETERS :
+ RETURN     : None.
+-----------------------------------------------------------------------------*/
+static void NCGVG_RGPVG_ISR_0(void)
+{
+    NCGVG_RGPVG_ISR();
+
+    GIC_EndInterrupt( BSP_INT_SRC_INT0 );
+}
+
+/*-----------------------------------------------------------------------------
+ NAME       : NCGVG_RGPVG_ISR_1
+ FUNCTION   : The Interrrupt from OpenVG.
+ PARAMETERS :
+ RETURN     : None.
+-----------------------------------------------------------------------------*/
+static void NCGVG_RGPVG_ISR_1(void)
+{
+    NCGVG_RGPVG_ISR();
+
+    GIC_EndInterrupt( BSP_INT_SRC_INT1 );
+}
+
+/*-----------------------------------------------------------------------------
+ NAME       : NCGVG_RGPVG_ISR_2
+ FUNCTION   : The Interrrupt from OpenVG.
+ PARAMETERS :
+ RETURN     : None.
+-----------------------------------------------------------------------------*/
+static void NCGVG_RGPVG_ISR_2(void)
+{
+    NCGVG_RGPVG_ISR();
+
+    GIC_EndInterrupt( BSP_INT_SRC_INT2 );
+}
+
+/*-----------------------------------------------------------------------------
+ NAME       : NCGVG_RGPVG_ISR_3
+ FUNCTION   : The Interrrupt from OpenVG.
+ PARAMETERS :
+ RETURN     : None.
+-----------------------------------------------------------------------------*/
+static void NCGVG_RGPVG_ISR_3(void)
+{
+    NCGVG_RGPVG_ISR();
+
+    GIC_EndInterrupt( BSP_INT_SRC_INT3 );
+}
+
+#endif
+/* -- end of file -- */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/RGA_API.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,222 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  RGA_API.h
+* @brief   $Module: RGA $ $PublicVersion: 1.20 $ (=RGA_VERSION)
+* $Rev: $
+* $Date::                           $
+*/
+
+#ifndef  RGA_API_H
+#define  RGA_API_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "RGA_API_typedef.h"
+#include  "frame_buffer_typedef.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+
+/***********************************************************************
+* Functions: R_RGA
+************************************************************************/
+bool_t  R_RGA_IsSupportedPixelFormatForRGAH( pixel_format_t pixel_format );
+
+
+/***********************************************************************
+* Class: graphics_image_t
+************************************************************************/
+errnum_t  R_GRAPHICS_IMAGE_InitR8G8B8A8(
+    graphics_image_t *self, void *ImageDataArray, size_t ImageDataArraySize,
+    int_fast32_t width, int_fast32_t height );
+errnum_t  R_GRAPHICS_IMAGE_InitSameSizeR8G8B8A8(
+    graphics_image_t *self, void *ImageDataArray, size_t ImageDataArraySize,
+    graphics_image_t *SameSizeImage );
+errnum_t  R_GRAPHICS_IMAGE_InitCopyFrameBufferR8G8B8A8(
+    graphics_image_t *self, void *ImageDataArray, size_t ImageDataArraySize,
+    graphics_t *Context, int_fast32_t MinX,  int_fast32_t MinY,  int_fast32_t width,  int_fast32_t height );
+errnum_t  R_GRAPHICS_IMAGE_InitByShareFrameBuffer( graphics_image_t *self, frame_buffer_t *frame_buffer );
+errnum_t  R_GRAPHICS_IMAGE_GetProperties( const graphics_image_t *self, graphics_image_properties_t *out_Properties );
+errnum_t  R_GRAPHICS_IMAGE_GetImageFormat( const graphics_image_t *self, pixel_format_t *out_Format );
+
+
+/***********************************************************************
+* Class: graphics_pattern_t
+************************************************************************/
+errnum_t  R_GRAPHICS_PATTERN_Initialize( graphics_pattern_t *self,
+        const graphics_image_t *image,  repetition_t repetition,  graphics_t *Context );
+
+
+/***********************************************************************
+* Class: graphics_t
+************************************************************************/
+void      R_GRAPHICS_InitConst( graphics_t *self );
+errnum_t  R_GRAPHICS_Initialize( graphics_t *self, graphics_config_t *Config );
+errnum_t  R_GRAPHICS_Finalize( graphics_t *self, errnum_t e );
+
+errnum_t  R_GRAPHICS_SetFrameBuffer( graphics_t *self, frame_buffer_t *frame_buffer );
+errnum_t  R_GRAPHICS_GetFrameBuffer( graphics_t *self, frame_buffer_t **out_frame_buffer );
+errnum_t  R_GRAPHICS_Finish( graphics_t *self );
+errnum_t  R_GRAPHICS_FinishStart( graphics_t *self, r_ospl_async_t *Async );
+errnum_t  R_GRAPHICS_GetAsyncStatus( graphics_t *self, const graphics_async_status_t **out_Status );
+errnum_t  R_GRAPHICS_OnInterrupting(void);
+
+errnum_t  R_GRAPHICS_Save( graphics_t *self, graphics_status_t *out_Status );
+errnum_t  R_GRAPHICS_Restore( graphics_t *self, graphics_status_t *Status, errnum_t e );
+
+errnum_t  R_GRAPHICS_ResetMatrix( graphics_t *self );
+errnum_t  R_GRAPHICS_SetMatrix_2x3( graphics_t *self,  graphics_matrix_float_t sx,  graphics_matrix_float_t ky,
+                                    graphics_matrix_float_t kx,  graphics_matrix_float_t sy,  graphics_matrix_float_t tx,  graphics_matrix_float_t ty );
+errnum_t  R_GRAPHICS_SetMatrix_3x3( graphics_t *self,  graphics_matrix_float_t *Matrix );
+errnum_t  R_GRAPHICS_GetMatrix_3x3( graphics_t *self,  graphics_matrix_float_t *out_Matrix );
+errnum_t  R_GRAPHICS_TranslateMatrixI( graphics_t *self, int_fast32_t tx, int_fast32_t ty );
+errnum_t  R_GRAPHICS_TranslateMatrix( graphics_t *self, graphics_matrix_float_t tx, graphics_matrix_float_t ty );
+errnum_t  R_GRAPHICS_ScaleMatrix( graphics_t *self, graphics_matrix_float_t sx, graphics_matrix_float_t sy );
+errnum_t  R_GRAPHICS_RotateMatrixDegree( graphics_t *self, graphics_matrix_float_t degree );
+errnum_t  R_GRAPHICS_ShearMatrix( graphics_t *self, graphics_matrix_float_t shx, graphics_matrix_float_t shy );
+errnum_t  R_GRAPHICS_TransformMatrix( graphics_t *self,  graphics_matrix_float_t sx,  graphics_matrix_float_t ky,
+                                      graphics_matrix_float_t kx,  graphics_matrix_float_t sy,  graphics_matrix_float_t tx,  graphics_matrix_float_t ty );
+errnum_t  R_GRAPHICS_MultiplyMatrix( graphics_t *self,  graphics_matrix_float_t *Matrix );
+errnum_t  R_GRAPHICS_GetProjectiveMatrix(
+    graphics_matrix_float_t SourceTopLeftX,           graphics_matrix_float_t SourceTopLeftY,
+    graphics_matrix_float_t SourceTopRightX,          graphics_matrix_float_t SourceTopRightY,
+    graphics_matrix_float_t SourceBottomLeftX,        graphics_matrix_float_t SourceBottomLeftY,
+    graphics_matrix_float_t SourceBottomRightX,       graphics_matrix_float_t SourceBottomRightY,
+    graphics_matrix_float_t DestinationTopLeftX,      graphics_matrix_float_t DestinationTopLeftY,
+    graphics_matrix_float_t DestinationTopRightX,     graphics_matrix_float_t DestinationTopRightY,
+    graphics_matrix_float_t DestinationBottomLeftX,   graphics_matrix_float_t DestinationBottomLeftY,
+    graphics_matrix_float_t DestinationBottomRightX,  graphics_matrix_float_t DestinationBottomRightY,
+    graphics_matrix_float_t *out_Matrix );
+
+errnum_t  R_GRAPHICS_SetBackgroundColor( graphics_t *self, r8g8b8a8_t Color );
+errnum_t  R_GRAPHICS_GetBackgroundColor( graphics_t *self, r8g8b8a8_t *out_Color );
+errnum_t  R_GRAPHICS_GetClearColor( graphics_t *self, r8g8b8a8_t *out_Color );
+errnum_t  R_GRAPHICS_Clear( graphics_t *self,
+                            int_fast32_t MinX, int_fast32_t MinY, int_fast32_t width, int_fast32_t height );
+
+errnum_t  R_GRAPHICS_DrawImage( graphics_t *self,  const graphics_image_t *image,
+                                int_fast32_t MinX,  int_fast32_t MinY );
+errnum_t  R_GRAPHICS_DrawImageResized( graphics_t *self,  const graphics_image_t *image,
+                                       int_fast32_t MinX,  int_fast32_t MinY,  int_fast32_t width,  int_fast32_t height );
+errnum_t  R_GRAPHICS_DrawImageChild( graphics_t *self,  const graphics_image_t *image,
+                                     int_fast32_t SourceMinX,        int_fast32_t SourceMinY,
+                                     int_fast32_t SourceWidth,       int_fast32_t SourceHeight,
+                                     int_fast32_t DestinationMinX,   int_fast32_t DestinationMinY,
+                                     int_fast32_t DestinationWidth,  int_fast32_t DestinationHeight );
+
+errnum_t  R_GRAPHICS_FillRect( graphics_t *self,  int_fast32_t MinX,  int_fast32_t MinY,
+                               int_fast32_t width,  int_fast32_t height );
+errnum_t  R_GRAPHICS_SetFillColor( graphics_t *self, r8g8b8a8_t Color );
+errnum_t  R_GRAPHICS_SetFillPattern( graphics_t *self, graphics_pattern_t *Pattern );
+
+errnum_t  R_GRAPHICS_StrokeRect( graphics_t *self,  int_fast32_t MinX,  int_fast32_t MinY,
+                                 int_fast32_t width,  int_fast32_t height );
+errnum_t  R_GRAPHICS_SetStrokeColor( graphics_t *self, r8g8b8a8_t Color );
+
+errnum_t  R_GRAPHICS_BeginPath( graphics_t *self );
+errnum_t  R_GRAPHICS_Rect( graphics_t *self,  int_t MinX,  int_t MinY,
+                           int_t width,  int_t height );
+errnum_t  R_GRAPHICS_Cilp( graphics_t *self );
+
+errnum_t  R_GRAPHICS_SetGlobalAlpha( graphics_t *self, uint8_t AlphaValue );
+errnum_t  R_GRAPHICS_GetGlobalAlpha( graphics_t *self, uint8_t *out_AlphaValue );
+errnum_t  R_GRAPHICS_SetGlobalCompositeOperation( graphics_t *self,
+        graphics_composite_operation_t CompositeOperation );
+errnum_t  R_GRAPHICS_GetGlobalCompositeOperation( graphics_t *self,
+        graphics_composite_operation_t *out_CompositeOperation );
+
+errnum_t  R_GRAPHICS_SetQualityFlags( graphics_t *self,
+                                      graphics_quality_flags_t Qualities );
+errnum_t  R_GRAPHICS_GetQualityFlags( graphics_t *self,
+                                      graphics_quality_flags_t *out_Qualities );
+
+
+/***********************************************************************
+* Class: graphics_static_t
+************************************************************************/
+graphics_static_t  *get_graphics_static(void);
+errnum_t  R_GRAPHICS_STATIC_GetVersion( uint32_t *out_Version );
+errnum_t  R_GRAPHICS_STATIC_OnInitializeDefault( graphics_t *self, graphics_config_t *in_out_Config,
+        void **out_CalleeDefined );
+errnum_t  R_GRAPHICS_STATIC_OnFinalizeDefault( graphics_t *self, void *CalleeDefined, errnum_t e );
+errnum_t  R_GRAPHICS_STATIC_SetOnInitialize(
+    R_GRAPHICS_OnInitialize_FuncType CallbackFunction );
+errnum_t  R_GRAPHICS_STATIC_SetOnFinalize(
+    R_GRAPHICS_OnFinalize_FuncType CallbackFunction );
+
+
+/***********************************************************************
+* Class: RGA_SHS
+*    Synchronize hardware and software rendering
+************************************************************************/
+errnum_t  R_GRAPHICS_BeginSoftwareRendering( graphics_t *self );
+errnum_t  R_GRAPHICS_BeginSoftwareRendering2( graphics_t *self );
+errnum_t  R_GRAPHICS_BeginSoftwareRenderingA( graphics_t *self, void *Address );
+errnum_t  R_GRAPHICS_EndSoftwareRendering( graphics_t *self );
+errnum_t  R_GRAPHICS_EndRenderingInFin( graphics_t *self, errnum_t e );
+
+
+/***********************************************************************
+* Class: animation_timing_function_t
+************************************************************************/
+errnum_t  R_Get_AnimationTimingFunction( char_t *TimingName,
+        animation_timing_function_t **out_Timing );
+
+float32_t  R_ANIMATION_TIMING_FUNCTION_GetValue( animation_timing_function_t *self,
+        float32_t ClampTime, float32_t ValueOfPreviousKeyFrame, float32_t ValueOfNextKeyFrame );
+
+
+/***********************************************************************
+* Functions: Self_Test_for_Package
+************************************************************************/
+errnum_t  R_RGA_CheckStructSize( size_t SizeOf_GraphicsClass, size_t SizeOf_GraphicsStatusClass,
+                                 size_t Zero );
+
+
+#ifdef  __cplusplus
+}  /* extern "C" */
+#endif
+
+#endif  /* RGA_API_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/RGA_API_typedef.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,323 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2015 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  RGA_API_typedef.h
+* @brief   $Module: RGA $ $PublicVersion: 1.20 $ (=RGA_VERSION)
+* $Rev: $
+* $Date::                           $
+*/
+
+#ifndef  RGA_API_TYPEDEF_H
+#define  RGA_API_TYPEDEF_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "Project_Config.h"
+#include  "r_ospl_typedef.h"
+#include  "locking_typedef.h"
+#include  "clib_drivers_typedef.h"
+#include  "frame_buffer_typedef.h"
+#include  "RGA_raw_image_typedef.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/**
+* @enum   graphics_quality_flag_t
+* @brief  graphics_quality_flag_t
+*/
+typedef enum {
+    /* Set to "ON" */
+    GRAPHICS_RENDERING_QUALITY_ANTIALIASED     = 0x0001,
+    GRAPHICS_IMAGE_QUALITY_ANTIALIASED         = 0x0002,
+
+    /* Set to "OFF" */
+    GRAPHICS_RENDERING_QUALITY_NONANTIALIASED  = GRAPHICS_RENDERING_QUALITY_ANTIALIASED << 16,
+    GRAPHICS_IMAGE_QUALITY_NONANTIALIASED      = GRAPHICS_IMAGE_QUALITY_ANTIALIASED << 16
+}
+        graphics_quality_flag_t;
+
+
+/**
+* @enum   graphics_jpeg_decoder_t
+* @brief  graphics_jpeg_decoder_t
+*/
+typedef enum {
+    GRAPHICS_JPEG_DECODER_NONE = 0,
+    GRAPHICS_JPEG_DECODER_HARD = 1
+} graphics_jpeg_decoder_t;
+
+
+/**
+* @typedef  graphics_quality_flags_t
+* @brief  graphics_quality_flags_t
+*/
+typedef bit_flags_fast32_t /*<graphics_quality_flag_t>*/  graphics_quality_flags_t;
+
+
+/**
+* @struct  graphics_config_t
+* @brief  graphics_config_t
+*/
+typedef struct _GraphicsConfigClass  graphics_config_t;
+struct _GraphicsConfigClass {
+    bit_flags32_t    flags;
+    frame_buffer_t  *frame_buffer;  /* F_GRAPHICS_FRAME_BUFFER */
+
+    /* for RGAH/RGAS hardware renderer */
+    void   *work_buffer_address;         /* F_GRAPHICS_WORK_BUFFER_ADDRESS */
+    size_t  work_buffer_size;            /* F_GRAPHICS_WORK_BUFFER_SIZE */
+    int_fast32_t  max_width_of_frame_buffer;   /* F_GRAPHICS_MAX_WIDTH_OF_FRAME_BUFFER */
+    int_fast32_t  max_height_of_frame_buffer;  /* F_GRAPHICS_MAX_HEIGHT_OF_FRAME_BUFFER */
+
+    /* for any */
+    graphics_quality_flags_t  quality_flags;         /* F_GRAPHICS_QUALITY_FLAGS */
+    r8g8b8a8_t                background_color;      /* F_GRAPHICS_BACK_GROUND_COLOR */
+    bool_t                    is_fast_manual_flush;  /* F_GRAPHICS_IS_FAST_MANUAL_FLUSH */
+
+    /* work buffer B */
+    void   *work_buffer_b_address;       /* F_GRAPHICS_WORK_BUFFER_B_ADDRESS */
+    size_t  work_buffer_b_size;          /* F_GRAPHICS_WORK_BUFFER_B_SIZE */
+
+    /* JPEG */
+    graphics_jpeg_decoder_t  jpeg_decoder;  /* F_GRAPHICS_JPEG_DECODER */
+
+    /* PNG */
+    size_t  work_size_for_libPNG;  /* F_GRAPHICS_WORK_SIZE_FOR_LIBPNG */
+
+    /* Asynchronous call */
+    bit_flags32_t  internal_event_value;  /* F_GRAPHICS_INTERNAL_EVENT_VALUE : 16bit */
+
+    /* Thread safe */
+    BSP_CFG_USER_LOCKING_TYPE  *lock_object;  /* F_GRAPHICS_LOCK_OBJECT */
+
+    /* for RGAS */
+    int_fast32_t  channel_of_DMAC_1;      /* F_GRAPHICS_CHANNEL_OF_DMAC_1 */
+    int_fast32_t  channel_of_DMAC_2;      /* F_GRAPHICS_CHANNEL_OF_DMAC_2 */
+    int_fast32_t  event_value_of_DMAC_1;  /* F_GRAPHICS_EVENT_VALUE_OF_DMAC_1 */
+    int_fast32_t  event_value_of_DMAC_2;  /* F_GRAPHICS_EVENT_VALUE_OF_DMAC_2 */
+};
+enum {
+    F_GRAPHICS_FRAME_BUFFER               = 0x0001,
+    F_GRAPHICS_WORK_BUFFER_ADDRESS        = 0x0002,
+    F_GRAPHICS_WORK_BUFFER_SIZE           = 0x0004,
+    F_GRAPHICS_MAX_HEIGHT_OF_FRAME_BUFFER = 0x0008,
+    F_GRAPHICS_MAX_WIDTH_OF_FRAME_BUFFER  = 0x0080,
+    F_GRAPHICS_QUALITY_FLAGS              = 0x0010,
+    F_GRAPHICS_BACK_GROUND_COLOR          = 0x0020,
+    F_GRAPHICS_IS_FAST_MANUAL_FLUSH       = 0x0040,
+    F_GRAPHICS_WORK_BUFFER_B_ADDRESS      = 0x0100,
+    F_GRAPHICS_WORK_BUFFER_B_SIZE         = 0x0200,
+    F_GRAPHICS_JPEG_DECODER               = 0x1000,
+    F_GRAPHICS_WORK_SIZE_FOR_LIBPNG       = 0x8000,
+    F_GRAPHICS_INTERNAL_EVENT_VALUE       = 0x2000,
+    F_GRAPHICS_LOCK_OBJECT                = 0x4000,
+    F_GRAPHICS_CHANNEL_OF_DMAC_1          = 0x0400,
+    F_GRAPHICS_CHANNEL_OF_DMAC_2          = 0x0800,
+    F_GRAPHICS_EVENT_VALUE_OF_DMAC_1    = 0x040000,
+    F_GRAPHICS_EVENT_VALUE_OF_DMAC_2    = 0x080000
+};
+
+
+/**
+* @typedef  graphics_matrix_float_t
+* @brief  graphics_matrix_float_t
+*/
+typedef  float  graphics_matrix_float_t;
+
+
+/**
+* @struct  graphics_matrix3x3_t
+* @brief  graphics_matrix3x3_t
+*/
+typedef union {
+    graphics_matrix_float_t   xy[3][3];  /* [x][y] */
+    graphics_matrix_float_t   array[9];  /* { sx, shy, w0, shx, sy, w1, tx, ty, w2 } */
+} graphics_matrix3x3_t;
+
+
+/**
+* @struct  graphics_image_properties_t
+* @brief  graphics_image_properties_t
+*/
+#if  IS_SUPPORT_SAME_TYPEDEF  || ! defined( graphics_image_properties_t )
+typedef struct _GraphicsImagePropertiesClass  graphics_image_properties_t;
+#define         graphics_image_properties_t   graphics_image_properties_t
+#endif
+struct _GraphicsImagePropertiesClass {
+    int_fast32_t     width;
+    int_fast32_t     height;
+    uint8_t         *data;    /* NULL, if pixelFormat != PIXEL_FORMAT_R8G8B8A8 */
+    void            *pixels;  /* Same as "data" but not NULL */
+    pixel_format_t   pixelFormat;
+    uint32_t        *CLUT;
+    int_fast32_t     CLUT_count;
+};
+
+
+/**
+* @enum   repetition_t
+* @brief  repetition_t
+*/
+typedef enum st_repetition_t {
+    GRAPHICS_REPEAT = 1
+} repetition_t;
+
+
+/**
+* @struct  graphics_pattern_t
+* @brief  graphics_pattern_t
+*/
+typedef struct st_graphics_pattern_t  graphics_pattern_t;
+struct st_graphics_pattern_t {
+    graphics_image_t *image;
+    repetition_t      repetition;
+};
+
+
+/**
+* @enum   graphics_composite_operation_t
+* @brief  graphics_composite_operation_t
+*/
+typedef enum st_graphics_composite_operation_t {
+    GRAPHICS_SOURCE_OVER = 1,
+    GRAPHICS_DESTINATION_OUT = 7,
+    GRAPHICS_COPY = 0
+} graphics_composite_operation_t;
+
+
+/**
+* @struct  graphics_status_t
+* @brief  graphics_status_t
+*/
+typedef struct st_graphics_status_t  graphics_status_t;
+struct st_graphics_status_t {
+    uint8_t  __Members[0x30];
+};
+
+
+/**
+* @struct  graphics_hard_status_t
+* @brief  graphics_hard_status_t
+*/
+#ifdef  RGAH_VERSION
+typedef struct st_graphics_hard_status_t  graphics_hard_status_t;
+struct st_graphics_hard_status_t {
+    volatile bool_t  IsRenderingCompleted;
+};
+#endif
+
+
+/**
+* @struct  graphics_async_status_t
+* @brief  graphics_async_status_t
+*/
+typedef struct st_graphics_async_status_t  graphics_async_status_t;
+struct st_graphics_async_status_t {
+    volatile r_ospl_async_state_t  State;
+    r_ospl_async_t *volatile       Async;
+    BSP_CFG_USER_LOCKING_TYPE     *CLock;
+    r_ospl_thread_id_t             LockedThread;
+#ifdef  RGAH_VERSION
+    const graphics_hard_status_t  *Hardware;
+#endif
+};
+
+
+/**
+* @struct  graphics_t
+* @brief  graphics_t
+*/
+#if  IS_SUPPORT_SAME_TYPEDEF  || ! defined( graphics_t )
+typedef struct st_graphics_t  graphics_t;
+#endif
+struct st_graphics_t {
+    uint8_t  __Members[0x118];
+};
+
+
+/**
+* @brief   R_GRAPHICS_OnInitialize_FuncType
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+typedef  errnum_t  (*R_GRAPHICS_OnInitialize_FuncType)(
+    graphics_t *self, graphics_config_t *in_out_Config, void **out_CalleeDefined );
+
+/**
+* @brief   R_GRAPHICS_OnFinalize_FuncType
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+typedef  errnum_t  (*R_GRAPHICS_OnFinalize_FuncType)(
+    graphics_t *self, void *CalleeDefined, errnum_t e );
+
+
+/**
+* @struct  graphics_static_t
+* @brief  graphics_static_t
+*/
+typedef struct st_graphics_static_t  graphics_static_t;
+struct st_graphics_static_t {
+    R_GRAPHICS_OnInitialize_FuncType  OnInitialize;
+    R_GRAPHICS_OnFinalize_FuncType    OnFinalize;
+    graphics_t                       *Contexts[1];
+};
+
+
+/**
+* @struct  animation_timing_function_t
+* @brief  animation_timing_function_t
+*/
+typedef struct _CSS_animation_timing_function_Class  animation_timing_function_t;
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+
+#ifdef  __cplusplus
+}  /* extern "C" */
+#endif
+
+#endif  /* RGA_API_TYPEDEF_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/RGA_Config.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,154 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  RGA_Config.h
+* @brief   $Module: RGA $ $PublicVersion: 1.20 $ (=RGA_VERSION)
+* $Rev: $
+* $Date::                           $
+*/
+
+
+/* This file is included from "Project_Config.h" */
+
+
+#ifndef  RGA_CONFIG_H
+#define  RGA_CONFIG_H
+
+
+/**
+* @def  RGA_VERSION
+* @brief  RGA_VERSION
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  RGA_VERSION  120
+
+
+/**
+* @def  RGA_VERSION_STRING
+* @brief  RGA_VERSION_STRING
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  RGA_VERSION_STRING  "1.20"
+
+
+/**
+* @def  GSCE_VERSION
+* @brief  GSCE_VERSION
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  GSCE_VERSION  402
+
+
+/**
+* @def  RGAH_VERSION
+* @brief  RGAH_VERSION
+* @par Parameters
+*    None
+* @return  None.
+*/
+/**
+* @def  RGAS_VERSION
+* @brief  RGAS_VERSION
+* @par Parameters
+*    None
+* @return  None.
+*/
+
+#ifdef R_ARM
+#define  IS_RGAH_ARM_VERSION
+/* #define  IS_RGAS_ARM_VERSION */
+#endif
+
+#ifdef _SH
+#define  IS_RGAH_SH_VERSION
+/* #define  IS_RGAS_SH_VERSION */
+#endif
+
+#ifdef _MSC_VER
+/* #define  IS_RGAH_PC_VERSION */
+#define  IS_RGAS_PC_VERSION
+#endif
+
+#if defined( IS_RGAH_ARM_VERSION ) || defined( IS_RGAH_SH_VERSION ) || defined( IS_RGAH_PC_VERSION )
+#define  RGAH_VERSION  103
+#endif
+
+#if defined( IS_RGAS_ARM_VERSION ) || defined( IS_RGAS_SH_VERSION ) || defined( IS_RGAS_PC_VERSION )
+#define  RGAS_VERSION  203
+#endif
+
+#undef  IS_RGAS_ARM_VERSION
+#undef  IS_RGAH_ARM_VERSION
+#undef  IS_RGAS_SH_VERSION
+#undef  IS_RGAH_SH_VERSION
+#undef  IS_RGAS_PC_VERSION
+#undef  IS_RGAH_PC_VERSION
+/* Use "R_ARM" or "RGAH_VERSION" */
+
+
+/**
+* @def  IS_WINDOW_SURFACES_EX
+* @brief  define or not define
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  IS_WINDOW_SURFACES_EX
+
+
+/***********************************************************************
+* Macros: RGA_LIMITATION_*
+*    0 or 1
+************************************************************************/
+#ifdef  RGAH_VERSION
+#define  RGA_LIMITATION_01_MATRIXED_IMAGE_STRIDE  1
+#define  RGA_LIMITATION_02_XRGB8888_BLEND         0
+#define  RGA_LIMITATION_03_INIT_BMP               1
+#define  RGA_LIMITATION_04_AYNCHRONOOUS_JCU       1
+#define  RGA_LIMITATION_06_COLOR_LITTLE_ERROR     1
+#define  RGA_LIMITATION_07_DRAWIMAGE_VERTEX_ERR   1
+#define  RGA_LIMITATION_08_OPTIMIZATION_ERR       0
+#define  RGA_LIMITATION_09_RGAH_BITBLT_CLIP       1
+#define  RGA_LIMITATION_11_SOURCE_FLUSH_B         0
+#else
+#define  RGA_LIMITATION_01_MATRIXED_IMAGE_STRIDE  0
+#define  RGA_LIMITATION_02_XRGB8888_BLEND         0
+#define  RGA_LIMITATION_03_INIT_BMP               0
+#define  RGA_LIMITATION_04_AYNCHRONOOUS_JCU       1
+#define  RGA_LIMITATION_06_COLOR_LITTLE_ERROR     0
+#define  RGA_LIMITATION_07_DRAWIMAGE_VERTEX_ERR   1
+#define  RGA_LIMITATION_08_OPTIMIZATION_ERR       0
+#define  RGA_LIMITATION_09_RGAH_BITBLT_CLIP       0
+#define  RGA_LIMITATION_11_SOURCE_FLUSH_B         0
+#endif
+
+
+#endif  /* __RGA_CONFIG_H */
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/RGA_Cpp.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,516 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  RGA_Cpp.h
+* @brief   $Module: RGA $ $PublicVersion: 1.20 $ (=RGA_VERSION)
+* $Rev: $
+* $Date::                           $
+*/
+
+#ifndef  RGA_CPP_H
+#define  RGA_CPP_H
+
+#ifndef __cplusplus
+#error C++ only
+#endif
+
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "RGA.h"
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+typedef float  graphics_matrix_float_t;
+typedef double graphics_matrix_other_float_t;
+
+
+/***********************************************************************
+* Class: ObjectHandleClass
+************************************************************************/
+class  ObjectHandleClass
+{
+public:
+    void  *Entity;
+
+    ObjectHandleClass() {
+        this->Entity = NULL;
+    }
+};
+
+bool_t  operator == ( ObjectHandleClass Left, ObjectHandleClass Right );
+
+
+/** undefined */
+#define  undefined  get_undefined()
+extern ObjectHandleClass  get_undefined();
+
+
+/***********************************************************************
+* Class: saveList_st
+************************************************************************/
+struct saveList_st {
+    saveList_st       *beforePoint;
+    graphics_status_t  saveData;
+};
+
+
+/***********************************************************************
+* Class: Canvas2D_ImageEntityClass
+************************************************************************/
+class Canvas2D_ImageEntityClass
+{
+public:
+    graphics_image_t  *C_Image;
+    bool_t               isImageDataComposition;
+
+    Canvas2D_ImageEntityClass( bool_t composition ) {
+        this->C_Image = NULL;
+        this->isImageDataComposition = composition;
+    }
+};
+
+
+/***********************************************************************
+* Class: Canvas2D_ImageClass
+************************************************************************/
+class  Canvas2D_ImageClass
+{
+public:
+    Canvas2D_ImageEntityClass  *Entity;
+
+    Canvas2D_ImageClass() {
+        this->Entity = NULL;
+    }
+
+    operator ObjectHandleClass () {
+        return  *(ObjectHandleClass *) this;
+    }
+
+    Canvas2D_ImageClass &operator = ( ObjectHandleClass Right ) {
+        this->Entity = (Canvas2D_ImageEntityClass *) Right.Entity;
+        return  *this;
+    }
+
+
+    void  set_imageClass( graphics_image_t *imageClass );
+    inline void  operator= ( graphics_image_t *imageClass ) {
+        this->set_imageClass( imageClass );
+    }
+
+    inline operator graphics_image_t *() {
+        return  this->Entity->C_Image;
+    }
+
+
+    void destroy();
+
+
+    /* "width" property */
+    class  widthProperty
+    {
+    public:
+        inline operator int_t() {
+            graphics_image_properties_t  prop;
+            errnum_t e;
+            Canvas2D_ImageClass  *parent = (Canvas2D_ImageClass *)(
+                                               (char *) this - offsetof( Canvas2D_ImageClass, width ) );
+            e = R_GRAPHICS_IMAGE_GetProperties( parent->Entity->C_Image, &prop );
+            if( e ) {
+                R_OSPL_SetErrNum( e );
+                prop.width = 0;
+            }
+            return  prop.width;
+        }
+    } width;
+
+    /* "height" property */
+    class  heightProperty
+    {
+    public:
+        inline operator int_t() {
+            graphics_image_properties_t  prop;
+            errnum_t e;
+            Canvas2D_ImageClass  *parent = (Canvas2D_ImageClass *)(
+                                               (char *) this - offsetof( Canvas2D_ImageClass, height ) );
+            e = R_GRAPHICS_IMAGE_GetProperties( parent->Entity->C_Image, &prop );
+            if( e ) {
+                R_OSPL_SetErrNum( e );
+                prop.height = 0;
+            }
+            return  prop.height;
+        }
+    } height;
+
+    /* "data" property */
+    class  dataProperty
+    {
+    public:
+        inline operator uint8_t *() {
+            graphics_image_properties_t  prop;
+            errnum_t e;
+            Canvas2D_ImageClass  *parent = (Canvas2D_ImageClass *)(
+                                               (char *) this - offsetof( Canvas2D_ImageClass, data ) );
+            e = R_GRAPHICS_IMAGE_GetProperties( parent->Entity->C_Image, &prop );
+            if( e ) {
+                R_OSPL_SetErrNum( e );
+                prop.data = NULL;
+            }
+            return  prop.data;
+        }
+
+        inline operator r8g8b8a8_t *() {
+            return  (r8g8b8a8_t *)(uint8_t *) *this;
+        }
+
+        inline operator void *() {
+            return  (void *)(uint8_t *) *this;
+        }
+
+        inline uint8_t  &operator[]( int Index ) {
+            return  ( (uint8_t *) *this )[ Index ];
+        }
+
+        inline uint8_t  *operator+( int Index ) {
+            return  ( (uint8_t *) *this ) + Index;
+        }
+    } data;
+
+    /* "src" property */
+    class  srcProperty
+    {
+    public:
+        inline void  operator= ( const graphics_image_t *imageClass ) {
+            Canvas2D_ImageClass  *parent = (Canvas2D_ImageClass *)(
+                                               (char *) this - offsetof( Canvas2D_ImageClass, src ) );
+
+            parent->set_imageClass( (graphics_image_t *)imageClass );
+        }
+        inline operator graphics_image_t *() {
+            graphics_image_t *outData = NULL;
+            Canvas2D_ImageClass  *parent = (Canvas2D_ImageClass *)(
+                                               (char *) this - offsetof( Canvas2D_ImageClass, src ) );
+
+            if( parent->Entity != NULL ) {
+                outData = parent->Entity->C_Image;
+            }
+            return outData;
+        }
+    } src;
+};
+
+
+/***********************************************************************
+* Class: Canvas2D_PatternClass
+************************************************************************/
+class  Canvas2D_PatternClass
+{
+public:
+    graphics_pattern_t  *Entity;
+
+    Canvas2D_PatternClass() {
+        this->Entity = NULL;
+    }
+
+    operator ObjectHandleClass () {
+        return  *(ObjectHandleClass *) this;
+    }
+
+    Canvas2D_PatternClass &operator = ( ObjectHandleClass Right ) {
+        this->Entity = (graphics_pattern_t *) Right.Entity;
+        return  *this;
+    }
+
+    void destroy();
+};
+
+
+/***********************************************************************
+* Class: Canvas2D_ContextEntityClass
+************************************************************************/
+class Canvas2D_ContextEntityClass
+{
+public:
+    graphics_t  *C_Graphics;
+    saveList_st    *LastSavePoint;
+
+    Canvas2D_ContextEntityClass() {
+        this->C_Graphics = NULL;
+        this->LastSavePoint = NULL;
+    }
+};
+
+
+/***********************************************************************
+* Class: Canvas2D_ContextClass
+************************************************************************/
+class  Canvas2D_ContextClass
+{
+public:
+    Canvas2D_ContextEntityClass  *Entity;
+
+    Canvas2D_ContextClass() {
+        this->Entity = NULL;
+    }
+
+    operator ObjectHandleClass () {
+        return  *(ObjectHandleClass *) this;
+    }
+
+    Canvas2D_ContextClass &operator = ( ObjectHandleClass Right ) {
+        this->Entity = (Canvas2D_ContextEntityClass *) Right.Entity;
+        return  *this;
+    }
+
+    void  destroy();
+    void  clearRect( int x, int y, int w, int h );
+    void  save();
+    void  restore();
+    void  drawImage( const graphics_image_t *image, int_t minX, int_t minY );
+    void  drawImage( const graphics_image_t *image, int_t minX, int_t minY , int_t width, int_t height );
+    void  drawImage( const graphics_image_t *image, int_t srcMinX,  int_t srcMinY,  int_t srcWidth,   int_t srcHeight,
+                     int_t destMinx, int_t destMinY, int_t destWidth , int_t destHeight );
+    Canvas2D_ImageClass  createImageData( Canvas2D_ImageClass image );
+    Canvas2D_ImageClass  createImageData( int_t width, int_t height );
+    Canvas2D_ImageClass  getImageData( int_t minX, int_t minY, int_t width, int_t height );
+    void  putImageData( Canvas2D_ImageClass imageData, int_t minX, int_t minY );
+    void  putImageData ( Canvas2D_ImageClass imageData, int_t minX, int_t minY, int_t dirtyX, int_t dirtyY, int_t dirtyWidth, int_t dirtyHeight );
+    void  fillRect( int x, int y, int w, int h );
+    Canvas2D_PatternClass  createPattern( const graphics_image_t *image, const char *repetition );
+    void  beginPath();
+    void  rect( int_t minX, int_t minY, int_t width, int_t height );
+    void  clip();
+
+    void  setTransform( graphics_matrix_float_t sx,  graphics_matrix_float_t ky,
+                        graphics_matrix_float_t kx,  graphics_matrix_float_t sy,
+                        graphics_matrix_float_t tx,  graphics_matrix_float_t ty );
+    void  setTransform( graphics_matrix_other_float_t sx,  graphics_matrix_other_float_t ky,
+                        graphics_matrix_other_float_t kx,  graphics_matrix_other_float_t sy,
+                        graphics_matrix_other_float_t tx,  graphics_matrix_other_float_t ty ) {
+        setTransform( (graphics_matrix_float_t) sx,  (graphics_matrix_float_t) ky,
+                      (graphics_matrix_float_t) kx,  (graphics_matrix_float_t) sy,
+                      (graphics_matrix_float_t) tx,  (graphics_matrix_float_t) ty );
+    }
+    void  setTransform( int_t sx,  int_t ky, int_t kx,  int_t sy, int_t tx,  int_t ty ) {
+        setTransform( (graphics_matrix_float_t) sx,  (graphics_matrix_float_t) ky,
+                      (graphics_matrix_float_t) kx,  (graphics_matrix_float_t) sy,
+                      (graphics_matrix_float_t) tx,  (graphics_matrix_float_t) ty );
+    }
+
+    void  translate( graphics_matrix_float_t tx, graphics_matrix_float_t ty );
+    void  translate( graphics_matrix_other_float_t tx, graphics_matrix_other_float_t ty ) {
+        translate( (graphics_matrix_float_t) tx, (graphics_matrix_float_t) ty );
+    }
+    void  translate( graphics_matrix_float_t tx, graphics_matrix_other_float_t ty ) {
+        translate( tx, (graphics_matrix_float_t) ty );
+    }
+    void  translate( graphics_matrix_other_float_t tx, graphics_matrix_float_t ty ) {
+        translate( (graphics_matrix_float_t) tx, ty );
+    }
+    void  translate( int_t tx, int_t ty ) {
+        translate( (graphics_matrix_float_t) tx, (graphics_matrix_float_t) ty );
+    }
+
+    void  scale( graphics_matrix_float_t sx, graphics_matrix_float_t sy );
+    void  scale( graphics_matrix_other_float_t sx, graphics_matrix_other_float_t sy ) {
+        scale( (graphics_matrix_float_t) sx, (graphics_matrix_float_t) sy );
+    }
+    void  scale( graphics_matrix_float_t sx, graphics_matrix_other_float_t sy ) {
+        scale( sx, (graphics_matrix_float_t) sy );
+    }
+    void  scale( graphics_matrix_other_float_t sx, graphics_matrix_float_t sy ) {
+        scale( (graphics_matrix_float_t) sx, sy );
+    }
+    void  scale( int_t sx, int_t sy ) {
+        scale( (graphics_matrix_float_t) sx, (graphics_matrix_float_t) sy );
+    }
+
+    void  rotate( graphics_matrix_float_t angle );
+    void  rotate( graphics_matrix_other_float_t angle ) {
+        rotate( (graphics_matrix_float_t) angle );
+    }
+
+    void  transform( graphics_matrix_float_t sx,  graphics_matrix_float_t ky,
+                     graphics_matrix_float_t kx,  graphics_matrix_float_t sy,
+                     graphics_matrix_float_t tx,  graphics_matrix_float_t ty );
+    void  transform( graphics_matrix_other_float_t sx,  graphics_matrix_other_float_t ky,
+                     graphics_matrix_other_float_t kx,  graphics_matrix_other_float_t sy,
+                     graphics_matrix_other_float_t tx,  graphics_matrix_other_float_t ty ) {
+        transform( (graphics_matrix_float_t) sx,  (graphics_matrix_float_t) ky,
+                   (graphics_matrix_float_t) kx,  (graphics_matrix_float_t) sy,
+                   (graphics_matrix_float_t) tx,  (graphics_matrix_float_t) ty );
+    }
+    void  transform( int_t sx,  int_t ky,  int_t kx,  int_t sy,  int_t tx,  int_t ty ) {
+        transform( (graphics_matrix_float_t) sx,  (graphics_matrix_float_t) ky,
+                   (graphics_matrix_float_t) kx,  (graphics_matrix_float_t) sy,
+                   (graphics_matrix_float_t) tx,  (graphics_matrix_float_t) ty );
+    }
+
+
+    /* "fillStyle" property */
+    void  Set_fillStyle( const char *Color );
+    void  Set_fillStyle( r8g8b8a8_t Color );
+    void  Set_fillStylePattern( const Canvas2D_PatternClass Pattern );
+#if 0
+    void  Set_fillStyleGradient( const Canvas2D_GradientClass Gradient );
+#endif
+    class  fillStyleProperty
+    {
+    public:
+        inline void  operator= ( const char *Color ) {
+            Canvas2D_ContextClass  *parent = (Canvas2D_ContextClass *)(
+                                                 (char *) this - offsetof( Canvas2D_ContextClass, fillStyle ) );
+
+            parent->Set_fillStyle( Color );
+        }
+        inline void  operator= ( r8g8b8a8_t Color ) {
+            Canvas2D_ContextClass  *parent = (Canvas2D_ContextClass *)(
+                                                 (char *) this - offsetof( Canvas2D_ContextClass, fillStyle ) );
+
+            parent->Set_fillStyle( Color );
+        }
+        inline void  operator= ( const Canvas2D_PatternClass Pattern ) {
+            Canvas2D_ContextClass  *parent = (Canvas2D_ContextClass *)(
+                                                 (char *) this - offsetof( Canvas2D_ContextClass, fillStyle ) );
+
+            parent->Set_fillStylePattern( Pattern );
+        }
+#if 0
+        inline void  operator= ( const Canvas2D_GradientClass Gradient ) {
+            Canvas2D_ContextClass  *parent = (Canvas2D_ContextClass *)(
+                                                 (char *) this - offsetof( Canvas2D_ContextClass, fillStyle ) );
+
+            parent->Set_fillStyleGradient( Gradient );
+        }
+#endif
+    } fillStyle;
+
+
+    /* "c_LanguageContext" property */
+    class  c_LanguageContextProperty
+    {
+        inline graphics_t  *get_c_LanguageContext() {
+            Canvas2D_ContextClass  *parent = (Canvas2D_ContextClass *)(
+                                                 (char *) this - offsetof( Canvas2D_ContextClass, c_LanguageContext ) );
+
+            return  parent->Entity->C_Graphics;
+        }
+    public:
+
+        inline operator graphics_t *() {
+            return  get_c_LanguageContext();
+        }
+        inline graphics_t *operator->() {
+            return  get_c_LanguageContext();
+        }
+    } c_LanguageContext;
+
+
+    /* "globalAlpha" property */
+    void set_globalAlpha( const float32_t alpha );
+    float32_t get_globalAlpha();
+    class  globalAlphaProperty
+    {
+    public:
+        inline void  operator= ( const float32_t alpha ) {
+            Canvas2D_ContextClass  *parent = (Canvas2D_ContextClass *)(
+                                                 (char *) this - offsetof( Canvas2D_ContextClass, globalAlpha ) );
+
+            parent->set_globalAlpha( alpha );
+        }
+        inline void  operator= ( const float64_t alpha ) {
+            Canvas2D_ContextClass  *parent = (Canvas2D_ContextClass *)(
+                                                 (char *) this - offsetof( Canvas2D_ContextClass, globalAlpha ) );
+
+            parent->set_globalAlpha( (float32_t) alpha );
+        }
+        inline operator float32_t() {
+            Canvas2D_ContextClass  *parent = (Canvas2D_ContextClass *)(
+                                                 (char *) this - offsetof( Canvas2D_ContextClass, globalAlpha ) );
+
+            return parent->get_globalAlpha();
+        }
+    } globalAlpha;
+
+
+    /* "globalCompositeOperation" property */
+    void set_globalCompositeOperation( const char *operation );
+    char *get_globalCompositeOperation();
+    class  globalCompositeOperationProperty
+    {
+    public:
+        inline void  operator= ( const char *operation ) {
+            Canvas2D_ContextClass  *parent = (Canvas2D_ContextClass *)(
+                                                 (char *) this - offsetof( Canvas2D_ContextClass, globalCompositeOperation ) );
+
+            parent->set_globalCompositeOperation( operation );
+        }
+        inline operator char *() {
+            Canvas2D_ContextClass  *parent = (Canvas2D_ContextClass *)(
+                                                 (char *) this - offsetof( Canvas2D_ContextClass, globalCompositeOperation ) );
+
+            return parent->get_globalCompositeOperation();
+        }
+    } globalCompositeOperation;
+
+};
+
+
+/***********************************************************************
+* Class: Canvas2D_ContextConfigClass
+************************************************************************/
+struct  Canvas2D_ContextConfigClass {
+    frame_buffer_t  *frame_buffer;
+    bool_t           is_fast_manual_flush;
+
+    Canvas2D_ContextConfigClass() {
+        frame_buffer = NULL;
+        is_fast_manual_flush = false;
+    }
+};
+
+
+/***********************************************************************
+* Functions: Canvas2D_Constructers
+************************************************************************/
+Canvas2D_ContextClass  R_RGA_New_Canvas2D_ContextClass( frame_buffer_t *frame_buffer );
+Canvas2D_ContextClass  R_RGA_New_Canvas2D_ContextClass( Canvas2D_ContextConfigClass &in_out_Config );
+Canvas2D_ImageClass  R_RGA_New_Canvas2D_ImageClass();
+
+#endif  // RGA_CPP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/RGA_Port.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,134 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/******************************************************************************
+* $FileName: RGA_Port.h $
+* $Module: RGA $ $PublicVersion: 1.03 $ (=RGA_VERSION)
+* $Rev: $
+* $Date::                           $
+* Description:
+******************************************************************************/
+
+#ifndef  RGA_PORT_H
+#define  RGA_PORT_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "RGA_API_typedef.h"
+#include  "RGA_Port_typedef.h"
+#include  "clib_drivers_typedef.h"  /* "R_CEIL_8U" in "R_RGA_CalcWorkBufferSize" */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+/* in RGA_Port_typedef.h */
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+/* in RGA_Port_typedef.h */
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+/* in RGA_Port_typedef.h */
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+errnum_t  drawCLUTImage( uint8_t *SrcAddress, const graphics_image_t *image, frame_buffer_t *frame );
+
+
+/***********************************************************************
+* Class: vram_ex_stack_t
+************************************************************************/
+errnum_t  R_VRAM_EX_STACK_Initialize( vram_ex_stack_t *self, void *NullConfig );
+errnum_t  R_VRAM_EX_STACK_Alloc( vram_ex_stack_t *self, frame_buffer_t *in_out_FrameBuffer );
+errnum_t  R_VRAM_EX_STACK_Free( vram_ex_stack_t *self, frame_buffer_t *frame_buffer );
+
+
+/* Section: Global */
+/**
+* @brief   Calculate size of hardware work buffer
+*
+* @param   max_height_of_frame_buffer int
+* @return  size of hardware work buffer
+*/
+#ifdef  RGAH_VERSION
+
+#define  R_RGA_CalcWorkBufferSize( max_height_of_frame_buffer ) \
+	( (size_t)( RGA_WORK_BUFFER_MAX_DISPLAY_LIST + \
+		RGA_WORK_BUFFER_STRIDE * R_CEIL_8U( max_height_of_frame_buffer ) * 4 * 2 ) )
+R_STATIC_ASSERT_GLOBAL( RGA_WORK_BUFFER_HEIGHT_ALIGNMENT == 8, "" );  /* check of R_CEIL_8U */
+
+#endif
+
+
+/**
+* @brief   Calculate size of hardware work buffer
+*
+* @param   max_width_of_frame_buffer int
+* @param   max_height_of_frame_buffer int
+* @return  size of hardware work buffer
+*/
+#ifdef  RGAH_VERSION
+
+#define  R_RGA_CalcWorkBufferSize2( max_width_of_frame_buffer, max_height_of_frame_buffer ) \
+	R_RGA_CalcWorkBufferSize( max_height_of_frame_buffer )
+#else
+
+#define  R_RGA_CalcWorkBufferSize2( max_width_of_frame_buffer, max_height_of_frame_buffer ) \
+	( (size_t)( (max_width_of_frame_buffer) * RGA_WORK_BUFFER_DMAC_LM_WIDTH_BYTE + \
+		(max_height_of_frame_buffer) * RGA_WORK_BUFFER_DMAC_LM_HEIGHT_BYTE ) )
+#endif
+
+
+/**
+* @brief   Calculate size of hardware work buffer B
+*
+* @param   MaxWidthOfJPEG int
+* @param   MaxHeightOfJPEG int
+* @param   MaxBytePerPixelOfFrameBuffer int
+* @return  size of hardware work buffer B
+*/
+#define  R_RGA_CalcWorkBufferB_Size( MaxWidthOfJPEG, MaxHeightOfJPEG, MaxBytePerPixelOfFrameBuffer ) \
+	( R_CEIL_16U( MaxWidthOfJPEG ) * R_CEIL_16U( MaxHeightOfJPEG ) * (MaxBytePerPixelOfFrameBuffer) )
+R_STATIC_ASSERT_GLOBAL( RGA_JPEG_MAX_WIDTH_ALIGNMENT  == 16, "" );  /* check of R_CEIL_16U */
+R_STATIC_ASSERT_GLOBAL( RGA_JPEG_MAX_HEIGHT_ALIGNMENT == 16, "" );  /* check of R_CEIL_16U */
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+/* Inline Functions */
+#include  "RGA_Port_inline.h"
+
+#endif  /* RGA_PORT_H */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/RGA_Port_inline.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,445 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/******************************************************************************
+* $FileName: RGA_Port_inline.h $
+* $Module: RGA $ $PublicVersion: 1.03 $ (=RGA_VERSION)
+* $Rev: $
+* $Date::                           $
+* Description:
+******************************************************************************/
+
+
+/* This file is included from "RGA_Port.h" */
+
+
+#ifndef  RGA_PORT_INLINE_H
+#define  RGA_PORT_INLINE_H
+#ifndef  NOT_DEFINE_INLINE_FUNCTION
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "clib_drivers.h"
+#include  "frame_buffer.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+/* in RGA_Port_typedef.h */
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+/* in RGA_Port_typedef.h */
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+/* in RGA_Port_typedef.h */
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+
+/**
+* @brief   SwapEndian to 2Byte
+*
+* @param   in_out_2byteVariable Address to 2 byte
+* @return  None
+*/
+INLINE void  SwapEndian2Byte( void *in_out_2byteVariable )
+{
+    byte_t   buffer[2];
+    byte_t  *data = (byte_t *) in_out_2byteVariable;
+
+    buffer[0] = data[0];
+    buffer[1] = data[1];
+
+    data[0] = buffer[1];
+    data[1] = buffer[0];
+}
+
+
+/**
+* @brief   SwapEndian to 4Byte
+*
+* @param   in_out_2byteVariable Address to 4 byte
+* @return  None
+*/
+INLINE void  SwapEndian4Byte( void *in_out_4byteVariable )
+{
+    byte_t   buffer[4];
+    byte_t  *data = (byte_t *) in_out_4byteVariable;
+
+    buffer[0] = data[0];
+    buffer[1] = data[1];
+    buffer[2] = data[2];
+    buffer[3] = data[3];
+
+    data[0] = buffer[3];
+    data[1] = buffer[2];
+    data[2] = buffer[1];
+    data[3] = buffer[0];
+}
+
+
+/**
+* @brief   Sets the value to the address not aligned 4byte
+*
+* @param   out_Variable <uint32_not_aligned_t>
+* @param   Value Set value
+* @return  None
+*/
+INLINE void  uint32_not_aligned_t_set( uint32_not_aligned_t *out_Variable,  uint32_t Value )
+{
+#if BYTE_ENDIAN == BYTE_LITTLE_ENDIAN
+    out_Variable->byte[0] = (byte_t)( ( Value & 0x000000FF ) );
+    out_Variable->byte[1] = (byte_t)( ( Value & 0x0000FF00 ) >>  8 );
+    out_Variable->byte[2] = (byte_t)( ( Value & 0x00FF0000 ) >> 16 );
+    out_Variable->byte[3] = (byte_t)( ( Value & 0xFF000000 ) >> 24 );
+#else
+    out_Variable->byte[0] = (byte_t)( ( Value & 0xFF000000 ) >> 24 );
+    out_Variable->byte[1] = (byte_t)( ( Value & 0x00FF0000 ) >> 16 );
+    out_Variable->byte[2] = (byte_t)( ( Value & 0x0000FF00 ) >>  8 );
+    out_Variable->byte[3] = (byte_t)( ( Value & 0x000000FF ) );
+#endif
+}
+
+
+/***********************************************************************
+* Class: byte_per_pixel_t
+************************************************************************/
+
+
+/**
+* @brief   R_RGA_BitPerPixelType_To_BytePerPixelType
+*
+* @param   BitPerPixel Input
+* @return  byte_per_pixel_t
+*/
+INLINE byte_per_pixel_t  R_RGA_BitPerPixelType_To_BytePerPixelType( int_fast32_t BitPerPixel )
+{
+    if ( R_Mod_8s( BitPerPixel ) == 0 )  {
+        return  (byte_per_pixel_t)( (uint_fast32_t) BitPerPixel / 8 );
+    } else                                 {
+        return  BitPerPixel << R_BYTE_PER_PIXEL_SHIFT;
+    }
+}
+
+
+/**
+* @brief   R_RGA_BytePerPixelType_To_BitPerPixelType
+*
+* @param   BytePerPixel byte_per_pixel_t
+* @return  BitPerPixel
+*/
+INLINE int_fast32_t  R_RGA_BytePerPixelType_To_BitPerPixelType( byte_per_pixel_t  BytePerPixel )
+{
+    return  ( ( BytePerPixel & R_BYTE_PER_PIXEL_MASK ) * 8 ) |
+            ( BytePerPixel >> R_BYTE_PER_PIXEL_SHIFT );
+}
+
+
+/**
+* @brief   R_BYTE_PER_PIXEL_IsInteger
+*
+* @param   BytePerPixel byte_per_pixel_t
+* @return  Whether "BytePerPixel" is integer type.
+*/
+INLINE bool_t  R_BYTE_PER_PIXEL_IsInteger( byte_per_pixel_t BytePerPixel )
+{
+    return  ( BytePerPixel & R_BYTE_PER_PIXEL_MASK ) != 0;
+}
+
+
+/* Section: Global */
+/**
+* @brief   argb8888_t_to_rgb565_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE  rgb565_t  argb8888_t_to_rgb565_t( argb8888_t Color )
+{
+    rgb565_t  ret = {0};
+    /* Warning: C4017W: ret may be used before being set */
+    /* This warning is not correct */
+
+    ret.Value = (uint16_t)(
+                    ( ( Color.Value & 0x00F80000 ) >> 8 ) |
+                    ( ( Color.Value & 0x0000FC00 ) >> 5 ) |
+                    ( ( Color.Value & 0x000000F8 ) >> 3 ) );
+
+    return  ret;
+}
+
+
+/**
+* @brief   argb8888_t_to_argb1555_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE  argb1555_t  argb8888_t_to_argb1555_t( argb8888_t Color )
+{
+    argb1555_t  ret = {0};
+    /* Warning: C4017W: ret may be used before being set */
+    /* This warning is not correct */
+
+    ret.Value = (uint16_t)(
+                    ( ( Color.Value & 0x80000000 ) >> 16 ) |  /* A */
+                    ( ( Color.Value & 0x00F80000 ) >>  9 ) |  /* R */
+                    ( ( Color.Value & 0x0000F800 ) >>  6 ) |  /* G */
+                    ( ( Color.Value & 0x000000F8 ) >>  3 ) ); /* B */
+
+    return  ret;
+}
+
+
+/**
+* @brief   argb8888_t_to_argb4444_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE  argb4444_t  argb8888_t_to_argb4444_t( argb8888_t Color )
+{
+    argb4444_t  ret = {0};
+    /* Warning: C4017W: ret may be used before being set */
+    /* This warning is not correct */
+
+    ret.Value = (uint16_t)(
+                    ( ( Color.Value & 0xF0000000 ) >> 16 ) |
+                    ( ( Color.Value & 0x00F00000 ) >> 12 ) |
+                    ( ( Color.Value & 0x0000F000 ) >>  8 ) |
+                    ( ( Color.Value & 0x000000F0 ) >>  4 ) );
+
+    return  ret;
+}
+
+
+/**
+* @brief   argb8888_t_to_r8g8b8a8_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE  r8g8b8a8_t  argb8888_t_to_r8g8b8a8_t( argb8888_t Color )
+{
+    r8g8b8a8_t  ret;
+    ret.Value = 0;  /* Avoid Warning: C4017W: ret may be used before being set */
+
+    ret.u.Red   = Color.u.Red;
+    ret.u.Green = Color.u.Green;
+    ret.u.Blue  = Color.u.Blue;
+    ret.u.Alpha = Color.u.Alpha;
+
+    return  ret;
+}
+
+
+/**
+* @brief   rgb565_t_to_argb8888_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE  argb8888_t  rgb565_t_to_argb8888_t( rgb565_t Color )
+{
+    argb8888_t  ret;
+
+    ret.Value = 0xFF000000 | /* A */
+                ( ( Color.Value & 0xF800 ) << 8 ) | ( ( Color.Value & 0xE000 ) << 3 ) |  /* R */
+                ( ( Color.Value & 0x07E0 ) << 5 ) | ( ( Color.Value & 0x0600 ) >> 1 ) |  /* G */
+                ( ( Color.Value & 0x001F ) << 3 ) | ( ( Color.Value & 0x001C ) >> 2 );   /* B */
+
+    return  ret;
+}
+
+
+/**
+* @brief   argb1555_t_to_argb8888_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE  argb8888_t  argb1555_t_to_argb8888_t( argb1555_t Color )
+{
+    argb8888_t  ret;
+
+    ret.Value =
+        ( ( Color.Value & 0x7C00 ) << 9 ) | ( ( Color.Value & 0x7000 ) << 4 ) |  /* R */
+        ( ( Color.Value & 0x03E0 ) << 6 ) | ( ( Color.Value & 0x0380 ) << 1 ) |  /* G */
+        ( ( Color.Value & 0x001F ) << 3 ) | ( ( Color.Value & 0x001C ) >> 2 );   /* B */
+
+    if ( Color.u.Alpha ) {
+        ret.Value |= 0xFF000000;    /* A */
+    }
+
+    return  ret;
+}
+
+
+/**
+* @brief   argb4444_t_to_argb8888_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE  argb8888_t  argb4444_t_to_argb8888_t( argb4444_t Color )
+{
+    argb8888_t  ret;
+
+    ret.Value =
+        ( ( Color.Value & 0xF000 ) << 16 ) | ( ( Color.Value & 0xF000 ) << 12 ) |  /* A */
+        ( ( Color.Value & 0x0F00 ) << 12 ) | ( ( Color.Value & 0x0F00 ) <<  8 ) |  /* R */
+        ( ( Color.Value & 0x00F0 ) <<  8 ) | ( ( Color.Value & 0x00F0 ) <<  4 ) |  /* G */
+        ( ( Color.Value & 0x000F ) <<  4 ) | ( ( Color.Value & 0x000F )       );   /* B */
+
+    return  ret;
+}
+
+
+/**
+* @brief   rgba8888_t_to_rgb565_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE rgb565_t  rgba8888_t_to_rgb565_t( rgba8888_t Color )
+{
+    rgb565_t  ret;
+
+    ret.Value = (uint16_t) (
+                    ( ( Color.Value & 0xF8000000 ) >> 16 ) |  /* R */
+                    ( ( Color.Value & 0x00FC0000 ) >> 13 ) |  /* G */
+                    ( ( Color.Value & 0x0000F800 ) >> 11 ) ); /* B */
+
+    return  ret;
+}
+
+
+/**
+* @brief   rgba8888_t_to_argb1555_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE argb1555_t  rgba8888_t_to_argb1555_t( rgba8888_t Color )
+{
+    argb1555_t  ret;
+
+    ret.Value = (uint16_t) (
+                    ( ( Color.Value & 0xF8000000 ) >> 17 ) |  /* R */
+                    ( ( Color.Value & 0x00F80000 ) >> 14 ) |  /* G */
+                    ( ( Color.Value & 0x0000F800 ) >> 11 ) |  /* B */
+                    ( ( Color.Value & 0x00000080 ) <<  8 ) ); /* A */
+
+    return  ret;
+}
+
+
+/**
+* @brief   rgba8888_t_to_argb4444_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE argb4444_t  rgba8888_t_to_argb4444_t( rgba8888_t Color )
+{
+    argb4444_t  ret;
+
+    ret.Value = (uint16_t) (
+                    ( ( Color.Value & 0xF0000000 ) >> 20 ) |  /* R */
+                    ( ( Color.Value & 0x00F00000 ) >> 16 ) |  /* G */
+                    ( ( Color.Value & 0x0000F000 ) >> 12 ) |  /* B */
+                    ( ( Color.Value & 0x000000F0 ) <<  8 ) ); /* A */
+
+    return  ret;
+}
+
+
+/**
+* @brief   r8g8b8a8_t_to_argb8888_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE  argb8888_t  r8g8b8a8_t_to_argb8888_t( r8g8b8a8_t Color )
+{
+    argb8888_t  ret;
+
+    ret.Value =
+        ( Color.u.Alpha << 24 ) |
+        ( Color.u.Red   << 16 ) |
+        ( Color.u.Green <<  8 ) |
+        ( Color.u.Blue );
+
+    return  ret;
+}
+
+
+/**
+* @brief   rgba8888_t_to_argb8888_t
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE argb8888_t  rgba8888_t_to_argb8888_t( rgba8888_t Color )
+{
+    argb8888_t  ret;
+
+    ret.Value = (
+                    ( ( Color.Value & 0xFF000000 ) >>  8 ) |  /* R */
+                    ( ( Color.Value & 0x00FF0000 ) >>  8 ) |  /* G */
+                    ( ( Color.Value & 0x0000FF00 ) >>  8 ) |  /* B */
+                    ( ( Color.Value & 0x000000FF ) << 24 ) ); /* A */
+
+    return  ret;
+}
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif  /* NOT_DEFINE_INLINE_FUNCTION */
+#endif  /* RGA_PORT_INLINE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/RGA_Port_typedef.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,192 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  RGA_Port_typedef.h
+* @brief   $Module: RGA $ $PublicVersion: 1.20 $ (=RGA_VERSION)
+* $Rev: $
+* $Date::                           $
+*/
+
+#ifndef  RGA_PORT_TYPEDEF_H
+#define  RGA_PORT_TYPEDEF_H
+
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "r_ospl_typedef.h"
+#include  "clib_drivers.h"  /* ceil_8 */
+#include  "RGA_Port_typedef.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/**
+* @struct  uint16_not_aligned_t
+* @brief  uint16_not_aligned_t
+*/
+#pragma pack (push,1)
+/* uint16_not_aligned_t* variable raises warning, when it was passed to uint16_t* argument. */
+typedef struct _uint16_not_aligned_t {
+    uint8_t  byte[2];
+} uint16_not_aligned_t;
+#pragma pack (pop)
+
+
+/**
+* @struct  uint32_not_aligned_t
+* @brief  uint32_not_aligned_t
+*/
+#pragma pack (push,1)
+/* uint32_not_aligned_t* variable raises warning, when it was passed to uint32_t* argument. */
+typedef struct _uint32_not_aligned_t {
+    uint8_t  byte[4];
+} uint32_not_aligned_t;
+#pragma pack (pop)
+
+
+/**
+* @struct  BITMAPFILEHEADER
+* @brief  BITMAPFILEHEADER
+*/
+#pragma pack (push,1)
+typedef struct tagBITMAPFILEHEADER {
+    uint16_t  bfType;
+    uint32_t  bfSize;
+    uint16_t  bfReserved1;
+    uint16_t  bfReserved2;
+    uint32_t  bfOffBits;
+} BITMAPFILEHEADER;
+#pragma pack (pop)
+
+
+/**
+* @struct  BITMAPINFOHEADER
+* @brief  BITMAPINFOHEADER
+*/
+#pragma pack (push,1)
+typedef struct tagBITMAPINFOHEADER {
+    uint32_t  biSize;
+    int32_t   biWidth;
+    int32_t   biHeight;
+    uint16_t  biPlanes;
+    uint16_t  biBitCount;
+    uint32_t  biCompression;
+    uint32_t  biSizeImage;
+    int32_t   biXPelsPerMeter;
+    int32_t   biYPelsPerMeter;
+    uint32_t  biClrUsed;
+    uint32_t  biClrImportant;
+} BITMAPINFOHEADER;
+#pragma pack (pop)
+
+
+/**
+* @def  BI_BITFIELDS
+* @brief  BI_BITFIELDS
+*/
+enum { BI_BITFIELDS = 3 };
+
+
+/**
+* @struct  vram_ex_stack_t
+* @brief  vram_ex_stack_t
+*/
+typedef struct _vram_ex_stack_t  vram_ex_stack_t;
+struct _vram_ex_stack_t {
+    uint8_t  *Start;
+    uint8_t  *Over;
+    uint8_t  *StackPointer;
+};
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+#ifdef  RGAH_VERSION
+#define  RGA_FRAME_BUFFER_ADDRESS_ALIGNMENT   32  /* byte */
+#define  RGA_SOURCE_IMAGE_STRIDE_ALIGNMENT    32  /* byte */
+#define  RGA_DESTINATION_STRIDE_ALIGNMENT     32  /* byte */
+#define  RGA_JPEG_ADDRESS_ALIGNMENT            8  /* byte */
+#define  RGA_JPEG_MAX_WIDTH_ALIGNMENT         16  /* pixel. Max of width_of_MCU */
+#define  RGA_JPEG_MAX_HEIGHT_ALIGNMENT        16  /* pixel. Max of height_of_MCU */
+#define  RGA_VDC5_BUFFER_ADDRESS_ALIGNMENT    64  /* byte */
+#define  RGA_WORK_BUFFER_MAX_DISPLAY_LIST    184  /* Constant value */
+#define  RGA_WORK_BUFFER_STRIDE               64  /* Constant value. This is not width of frame buffer */
+#define  RGA_WORK_BUFFER_ADDRESS_ALIGNMENT    64  /* byte */
+#define  RGA_WORK_BUFFER_HEIGHT_ALIGNMENT      8  /* pixel */
+#define  RGA_WORK_BUFFER_B_ADDRESS_ALIGNMENT  32  /* byte */
+/* RGA_WORK_BUFFER_B_ADDRESS_ALIGNMENT : RGA_RGAH_initBmp_ForSourceImage( colorBuffer ) */
+#endif
+#ifdef  RGAS_VERSION
+#define  RGA_FRAME_BUFFER_ADDRESS_ALIGNMENT    4  /* byte */
+#define  RGA_SOURCE_IMAGE_STRIDE_ALIGNMENT     4  /* byte */
+#define  RGA_DESTINATION_STRIDE_ALIGNMENT      4  /* byte */
+#define  RGA_JPEG_ADDRESS_ALIGNMENT            4  /* byte */
+#define  RGA_JPEG_MAX_WIDTH_ALIGNMENT         16  /* pixel. Max of width_of_MCU */
+#define  RGA_JPEG_MAX_HEIGHT_ALIGNMENT        16  /* pixel. Max of height_of_MCU */
+#define  RGA_WORK_BUFFER_ADDRESS_ALIGNMENT     4  /* byte */
+#define  RGA_WORK_BUFFER_B_ADDRESS_ALIGNMENT   4  /* byte */
+#endif
+#define  RGA_VDC5_BUFFER_ADDRESS_ALIGNMENT    64  /* byte */
+
+#define  RGA_MAX_WORK_SIZE_FOR_LIB_PNG_DEFAULT   0x40000 /* byte */ /* "work_size_for_libPNG" */
+
+#define  RGA_WORK_BUFFER_DMAC_LM_WIDTH_BYTE    4  /* byte */
+#define  RGA_WORK_BUFFER_DMAC_LM_HEIGHT_BYTE  32  /* byte */
+
+/**
+* @def  R_RGA_DEFAULT_CLEAR_COLOR
+* @brief  R_RGA_DEFAULT_CLEAR_COLOR
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  R_RGA_DEFAULT_CLEAR_COLOR  R_RGA_Get_R8G8B8A8( 255, 255, 255, 255 )
+
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+/* in RGA_Port_typedef.h */
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif  /* RGA_PORT_TYPEDEF_H */
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/RGA_raw_image.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  RGA_raw_image.h
+* @brief   $Module: RGA_Image $ $PublicVersion: 0.91 $ (=RGA_IMAGE_VERSION)
+* $Rev: 38 $
+* $Date:: 2014-03-18 16:14:45 +0900#$
+*/
+
+#ifndef  RGA_RAW_IMAGE_H
+#define  RGA_RAW_IMAGE_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "RGA_raw_image_typedef.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+/* In "RGA_raw_image_typedef.h" */
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+/* In "RGA_raw_image_typedef.h" */
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+/* In "RGA_raw_image_typedef.h" */
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/RGA_raw_image_typedef.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,109 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  RGA_raw_image_typedef.h
+* @brief   $Module: RGA_Image $ $PublicVersion: 0.91 $ (=RGA_IMAGE_VERSION)
+* $Rev: 38 $
+* $Date:: 2014-03-18 16:14:45 +0900#$
+*/
+
+#ifndef  RGA_RAW_IMAGE_TYPEDEF_H
+#define  RGA_RAW_IMAGE_TYPEDEF_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/**
+* @struct  graphics_image_t
+* @brief  Raw image format of RGA and ImagePackager.
+*/
+typedef struct st_graphics_image_t  graphics_image_t;
+struct st_graphics_image_t {
+
+    /** flags */
+    uint32_t    flags;
+
+    /** offset_to_image */
+    uint32_t    offset_to_image;
+
+    /** offset_to_alpha */
+    uint32_t    offset_to_alpha;
+
+    /** width */
+    uint16_t    width;
+
+    /** height */
+    uint16_t    height;
+
+    /** type */
+    uint8_t     type;
+
+    /** type2 */
+    uint8_t     type2;
+
+    /** color */
+    uint32_t    color;
+};
+
+enum { /* graphics_image_t::flags */
+    F_T_IMAGE_INF_RAW_MASK    = 0x01,
+    F_T_IMAGE_INF_RAW_ADDRESS = 0x00,  /* T_IMAGE_INF::image and Alpha are pointers */
+    F_T_IMAGE_INF_RAW_OFFSET  = 0x01,  /* T_IMAGE_INF::image and Alpha are offsets */
+
+    F_T_IMAGE_INF_PREMULTIPLIED_ALPHA  = 0x04,  /* Premultiplied alpha */
+
+    F_T_IMAGE_INF_LINE_OFFSET = 0x08,  /* Color member variable is line offset */
+
+    F_T_IMAGE_INF_USED_MASK = 0x0000000F
+};
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+/* In "RGA_raw_image.h" */
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/frame_buffer.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,66 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  frame_buffer.h
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 38 $
+* $Date:: 2014-03-18 16:14:45 +0900#$
+*/
+
+#ifndef  FRAME_BUFFER_H
+#define  FRAME_BUFFER_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "frame_buffer_typedef.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+/* In "frame_buffer_typedef.h" */
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+/* In "frame_buffer_typedef.h" */
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+/* In "frame_buffer_typedef.h" */
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/frame_buffer_typedef.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,457 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  frame_buffer_typedef.h
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 38 $
+* $Date:: 2014-03-18 16:14:45 +0900#$
+*/
+
+#ifndef  FRAME_BUFFER_TYPEDEF_H
+#define  FRAME_BUFFER_TYPEDEF_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "Project_Config.h"
+#include  <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/**
+* @typedef  byte_per_pixel_t
+* @brief  This can have shift value, if byte per pixel is less than 1
+*/
+typedef int  byte_per_pixel_t;
+#ifdef  IS_WINDOW_SURFACES_EX
+enum {
+    R_BYTE_PER_PIXEL_MASK  = 0xFF,  /*[R_BYTE_PER_PIXEL_MASK]*/
+    R_BYTE_PER_PIXEL_SHIFT = 8      /*[R_BYTE_PER_PIXEL_SHIFT]*/
+};
+#endif
+
+
+/**
+* @typedef  frame_buffer_delegate_t
+* @brief  This is user defined variable. Library does not access it.
+*/
+typedef void  frame_buffer_delegate_t;
+enum { /* int_fast32_t */  frame_buffer_t_max_buffer_count = 3 };
+
+
+/**
+* @enum   pixel_format_t
+* @brief  pixel_format_t
+*
+*    - PIXEL_FORMAT_UNKNOWN - 0,              0x00
+*    - PIXEL_FORMAT_ARGB8888 - 1,              0x01
+*    - PIXEL_FORMAT_RGB565 - 3,              0x03
+*    - PIXEL_FORMAT_ARGB4444 - 5,              0x05
+*    - PIXEL_FORMAT_A8 - 11,              0x0B
+*    - PIXEL_FORMAT_A4 - 14,              0x0E
+*    - PIXEL_FORMAT_A1 - 13,              0x0D
+*    - PIXEL_FORMAT_RGB888 - 15,              0x0F
+*    - PIXEL_FORMAT_R8G8B8A8 - 6 | (1 << 4),   0x16
+*    - PIXEL_FORMAT_XRGB8888 - 0 | (1 << 6),   0x40
+*    - PIXEL_FORMAT_ARGB1555 - 4 | (1 << 6),   0x10002
+*    - PIXEL_FORMAT_YCbCr422 - 2 | (1 << 16),  0x10002
+*    - PIXEL_FORMAT_YUV422 - 2 | (1 << 16),  0x10002
+*    - PIXEL_FORMAT_YUV422_GRAY_SCALE_IS_0x80 - 2 | (1 << 16),  0x10002
+*    - PIXEL_FORMAT_JPEG - 12 | (2 << 8),    0x20C
+*    - PIXEL_FORMAT_PNG - 12 | (3 << 8),    0x30C
+*    - PIXEL_FORMAT_GIF - 12 | (4 << 8),    0x40C
+*    - PIXEL_FORMAT_CLUT1 - 12 | (1 << 12),  0x100C
+*    - PIXEL_FORMAT_CLUT4 - 12 | (4 << 12),  0x400C
+*    - PIXEL_FORMAT_CLUT8 - 12 | (8 << 12)   0x800C
+*/
+enum _pixel_format_t {
+    PIXEL_FORMAT_UNKNOWN  =  0,
+    PIXEL_FORMAT_ARGB8888 =  1,
+    PIXEL_FORMAT_RGB565   =  3,
+    PIXEL_FORMAT_ARGB4444 =  5,
+    PIXEL_FORMAT_A8       = 11,
+    PIXEL_FORMAT_A4       = 14,
+    PIXEL_FORMAT_A1       = 13,
+    PIXEL_FORMAT_RGB888   = 15,
+    PIXEL_FORMAT_R8G8B8A8 =  6 | (1 << 4),
+    PIXEL_FORMAT_XRGB8888 =  0 | (1 << 6),
+    PIXEL_FORMAT_ARGB1555 =  4 | (1 << 6),
+    PIXEL_FORMAT_YCbCr422 =  2 | (1 << 16),
+    PIXEL_FORMAT_YUV422   =  2 | (1 << 16),
+    PIXEL_FORMAT_YUV422_GRAY_SCALE_IS_0x80  = 2 | (1 << 16),
+    PIXEL_FORMAT_JPEG     = 12 | (2 << 8),
+    PIXEL_FORMAT_PNG      = 12 | (3 << 8),
+    PIXEL_FORMAT_GIF      = 12 | (4 << 8),
+    PIXEL_FORMAT_CLUT1    = 12 | (1 << 12),
+    PIXEL_FORMAT_CLUT4    = 12 | (4 << 12),
+    PIXEL_FORMAT_CLUT8    = 12 | (8 << 12)
+};
+typedef enum _pixel_format_t  pixel_format_t;
+
+
+/**
+* @struct  frame_buffer_t
+* @brief  frame_buffer_t
+*/
+typedef struct st_frame_buffer_t  frame_buffer_t;
+struct st_frame_buffer_t {
+
+    /** Cached address, [2] is Reserved */
+    uint8_t          *buffer_address[ frame_buffer_t_max_buffer_count ];
+
+    /** max is 2 */
+    int_fast32_t      buffer_count;
+
+    /** Index of "buffer_address" */
+    int_fast32_t      show_buffer_index;
+
+    /** Index of "buffer_address" */
+    int_fast32_t      draw_buffer_index;
+
+    /** width */
+    int_fast32_t      width;
+
+    /** check Stride and PixelFormat */
+    byte_per_pixel_t  byte_per_pixel;
+
+    /** byte to next bottom line */
+    int_fast32_t      stride;
+
+    /** height */
+    int_fast32_t      height;
+
+    /** pixel_format */
+    pixel_format_t    pixel_format;
+
+    /** delegate */
+    frame_buffer_delegate_t  *delegate;
+};
+
+
+/**
+* @struct  r8g8b8a8_t
+* @brief  One of color type
+*/
+#define  r8g8b8a8_t  r8g8b8a8_t
+typedef union st_r8g8b8a8_t  r8g8b8a8_t;
+union st_r8g8b8a8_t {
+    struct {
+#if  BIT_FIELD_ENDIAN == BIT_FIELD_LITTLE_ENDIAN
+
+        /** u */
+        uint8_t  Red;
+
+        /** u */
+        uint8_t  Green;
+
+        /** u */
+        uint8_t  Blue;
+
+        /** u */
+        uint8_t  Alpha;
+#else
+        uint8_t  Alpha;
+        uint8_t  Blue;
+        uint8_t  Green;
+        uint8_t  Red;
+#endif
+    } u;  /* 1st member "u" can be used by initializer */
+
+    /** Value */
+    uint32_t  Value;  /* This is depend on CPU endian. Use only copy or compare */
+};
+
+
+/**
+* @struct  argb8888_t
+* @brief  One of color type
+*/
+#define        argb8888_t  argb8888_t
+typedef union _ARGB8888Type  argb8888_t;
+union _ARGB8888Type {
+    uint32_t  Value;  /* CPU Endian. Not frame buffer endian */
+    struct {
+#if BYTE_ENDIAN == BYTE_LITTLE_ENDIAN
+
+        /** Blue is Value & 0x000000FF */
+        uint8_t  Blue;
+
+        /** u */
+        uint8_t  Green;
+
+        /** u */
+        uint8_t  Red;
+
+        /** u */
+        uint8_t  Alpha;
+#else
+        uint8_t  Alpha;
+        uint8_t  Red;
+        uint8_t  Green;
+        uint8_t  Blue;   /* Blue is Value & 0x000000FF */
+#endif
+    } u;
+};
+
+
+/**
+* @struct  xrgb8888_t
+* @brief  One of color type
+*/
+#define        xrgb8888_t  xrgb8888_t
+typedef union _XRGB8888Type  xrgb8888_t;
+union _XRGB8888Type {
+    uint32_t  Value;  /* CPU Endian. Not frame buffer endian */
+    struct {
+#if BYTE_ENDIAN == BYTE_LITTLE_ENDIAN
+
+        /** Blue is Value & 0x000000FF */
+        uint8_t  Blue;
+
+        /** u */
+        uint8_t  Green;
+
+        /** u */
+        uint8_t  Red;
+
+        /** u */
+        uint8_t  X;      /* zero */
+#else
+        uint8_t  X;      /* zero */
+        uint8_t  Red;
+        uint8_t  Green;
+        uint8_t  Blue;   /* Blue is Value & 0x000000FF */
+#endif
+    } u;
+};
+
+
+/**
+* @struct  rgb565_t
+* @brief  One of color type
+*/
+#define        rgb565_t  rgb565_t
+typedef union _RGB565Type  rgb565_t;
+union _RGB565Type {
+    uint16_t  Value;  /* CPU Endian. Not frame buffer endian */
+    struct {
+#if  BIT_FIELD_ENDIAN == BIT_FIELD_LITTLE_ENDIAN
+
+        /** Blue is at LSB */
+        unsigned  Blue  : 5;
+
+        /** u */
+        unsigned  Green : 6;
+
+        /** u */
+        unsigned  Red   : 5;
+#else
+        unsigned  Red   : 5;
+        unsigned  Green : 6;
+        unsigned  Blue  : 5;  /* Blue is at LSB */
+#endif
+    } u;
+};
+
+
+/**
+* @struct  argb1555_t
+* @brief  One of color type
+*/
+#define        argb1555_t  argb1555_t
+typedef union _ARGB1555Type  argb1555_t;
+union _ARGB1555Type {
+    uint16_t  Value;  /* CPU Endian. Not frame buffer endian */
+    struct {
+#if  BIT_FIELD_ENDIAN == BIT_FIELD_LITTLE_ENDIAN
+
+        /** Blue is at LSB */
+        unsigned  Blue  : 5;
+
+        /** u */
+        unsigned  Green : 5;
+
+        /** u */
+        unsigned  Red   : 5;
+
+        /** u */
+        unsigned  Alpha : 1;
+#else
+        unsigned  Alpha : 1;
+        unsigned  Red   : 5;
+        unsigned  Green : 5;
+        unsigned  Blue  : 5;  /* Blue is at LSB */
+#endif
+    } u;
+};
+
+
+/**
+* @struct  argb4444_t
+* @brief  One of color type
+*/
+#define        argb4444_t  argb4444_t
+typedef union _ARGB4444Type  argb4444_t;
+union _ARGB4444Type {
+    uint16_t  Value;  /* CPU Endian. Not frame buffer endian */
+    struct {
+#if  BIT_FIELD_ENDIAN == BIT_FIELD_LITTLE_ENDIAN
+
+        /** Blue is at LSB */
+        unsigned  Blue  : 4;
+
+        /** u */
+        unsigned  Green : 4;
+
+        /** u */
+        unsigned  Red   : 4;
+
+        /** u */
+        unsigned  Alpha : 4;
+#else
+        unsigned  Alpha : 4;
+        unsigned  Red   : 4;
+        unsigned  Green : 4;
+        unsigned  Blue  : 4;  /* Blue is at LSB */
+#endif
+    } u;
+};
+
+
+/**
+* @struct  rgba8888_t
+* @brief  One of color type
+*/
+#define        rgba8888_t  rgba8888_t
+typedef union _RGBA8888Type  rgba8888_t;
+union _RGBA8888Type {
+    uint32_t  Value;  /* CPU Endian. Not frame buffer endian */
+    struct {
+#if  BIT_FIELD_ENDIAN == BIT_FIELD_LITTLE_ENDIAN
+
+        /** Alpha is at LSB */
+        unsigned  Alpha : 8;
+
+        /** u */
+        unsigned  Blue  : 8;
+
+        /** u */
+        unsigned  Green : 8;
+
+        /** u */
+        unsigned  Red   : 8;
+#else
+        unsigned  Red   : 8;
+        unsigned  Green : 8;
+        unsigned  Blue  : 8;
+        unsigned  Alpha : 8;  /* Alpha is at LSB */
+#endif
+    } u;
+};
+
+
+/**
+* @struct  y_cb_cr_422_t
+* @brief  Same as <yuv422_t>
+*/
+/**
+* @struct  yuv422_t
+* @brief  One of color type
+*/
+#define          y_cb_cr_422_t  y_cb_cr_422_t
+typedef union st_y_cb_cr_422_t  y_cb_cr_422_t;
+#define          yuv422_t       yuv422_t
+typedef union st_y_cb_cr_422_t  yuv422_t;
+union st_y_cb_cr_422_t {
+    struct {
+        /** U */
+        uint8_t  Cb_01;
+
+        /** u */
+        uint8_t  Y_0;
+
+        /** V */
+        uint8_t  Cr_01;
+
+        /** u */
+        uint8_t  Y_1;
+
+    } u;  /* 1st member "u" can be used by initializer */
+
+    struct {
+        /** uu */
+        uint8_t  U_01;
+
+        /** uu */
+        uint8_t  Y_0;
+
+        /** uu */
+        uint8_t  V_01;
+
+        /** uu */
+        uint8_t  Y_1;
+    } uu;
+
+    uint32_t  Value;
+};
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/* Section: Global */
+/**
+* @enum   E_CATEGORY_PIXEL_FORMAT
+* @brief  E_CATEGORY_PIXEL_FORMAT
+*
+*    - E_NOT_SUPPORTED_PIXEL_FORMAT - E_CATEGORY_PIXEL_FORMAT | 0x01
+*/
+#ifndef  E_CATEGORY_PIXEL_FORMAT
+#define  E_CATEGORY_PIXEL_FORMAT  E_CATEGORY_PIXEL_FORMAT
+enum {   E_CATEGORY_PIXEL_FORMAT = 0x00009400 };
+#endif
+enum { E_NOT_SUPPORTED_PIXEL_FORMAT  = E_CATEGORY_PIXEL_FORMAT | 0x01 }; /* 0x9401 = 37889 */
+
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+/* In "frame_buffer.h" */
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/video_input.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,103 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  video_input.h
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+* - Description: V-Sync porting layer
+*/
+
+#ifndef  VIDEO_INPUT_H
+#define  VIDEO_INPUT_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "video_input_typedef.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+/* In "video_input_typedef.h" */
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+/* In "video_input_typedef.h" */
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+/* In "video_input_typedef.h" */
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+
+/**
+* @brief   R_VIDEO_INPUT_InitConst
+*
+* @param   self video_input_t
+* @return  None
+*/
+void  R_VIDEO_INPUT_InitConst( video_input_t *const  self );
+
+
+/**
+* @brief   R_VIDEO_INPUT_Initialize
+*
+* @param   self video_input_t
+* @param   in_out_Config Configuration
+* @return  Error Code. 0=No Error.
+*
+* @par Description
+*    "R_WINDOW_SURFACES_SwapBuffers" must be called after calling this
+*    function for showing video layer.
+*    Set "window_surfaces_config_t::background_mode" = "BACKGROUND_MODE_VIDEO_INTERLACE"
+*/
+errnum_t  R_VIDEO_INPUT_Initialize( video_input_t *const  self,
+                                    video_input_config_t *in_out_Config );
+
+
+/**
+* @brief   R_VIDEO_INPUT_Finalize
+*
+* @param   self video_input_t
+* @param   e Errors that have occurred. No error = 0
+* @return  Error code or e, 0 = successful and input e=0
+*/
+errnum_t  R_VIDEO_INPUT_Finalize( video_input_t *const  self, errnum_t e );
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/video_input.hpp	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,116 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  video_input.hpp
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+* - Description: Video Input for mbed style C++ API
+*/
+
+#ifndef  VIDEO_INPUT_HPP
+#define  VIDEO_INPUT_HPP
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "r_ospl_typedef.h"
+#include  "video_input_typedef.h"
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+class  VideoInputConfig;
+
+
+/***********************************************************************
+* Class: VideoInput
+*    mbed style C++ version of <video_input_t>
+************************************************************************/
+class  VideoInput {
+public:
+	/**
+* @brief   VideoInput
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	VideoInput();
+	~VideoInput();
+
+	/**
+* @brief   initialize
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	errnum_t  initialize( VideoInputConfig& in_out_Config );
+
+	/**
+* @brief   destroy
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	void  destroy();
+
+private:
+	video_input_t*  _self;
+};
+
+
+/***********************************************************************
+* Class: VideoInputConfig
+*    mbed style C++ version of <video_input_config_t>
+************************************************************************/
+class  VideoInputConfig : public video_input_config_t {
+public:
+	/**
+* @brief   VideoInputConfig
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	VideoInputConfig();
+};
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/video_input_typedef.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,190 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  video_input_typedef.h
+* @brief   $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+*/
+
+#ifndef  VIDEO_INPUT_TYPEDEF_H
+#define  VIDEO_INPUT_TYPEDEF_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "r_vdc5.h"
+#include  "r_vdec.h"
+#include  "frame_buffer_typedef.h"
+#include  "r_ospl_typedef.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/***********************************************************************
+* Macros: INTERRUPT_FUNCTION_TYPE
+*    INTERRUPT_FUNCTION_TYPE
+*
+*    : INTERRUPT_FUNCTION_TYPE_OS_RTX  - RTX
+*    : INTERRUPT_FUNCTION_TYPE_OS_LESS - OS less
+************************************************************************/
+#if R_OSPL_IS_PREEMPTION
+#define  INTERRUPT_FUNCTION_TYPE  INTERRUPT_FUNCTION_TYPE_OS_RTX
+#else
+#define  INTERRUPT_FUNCTION_TYPE  INTERRUPT_FUNCTION_TYPE_OS_LESS
+#endif
+#define  INTERRUPT_FUNCTION_TYPE_OS_LESS  0
+#define  INTERRUPT_FUNCTION_TYPE_OS_RTX   1
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/**
+* @enum   video_input_channel_enum_t
+* @brief  Special integer value
+*
+*    - VIDEO_INPUT_NOT_DISPLAY - 0xFF
+*/
+enum st_video_input_channel_enum_t {
+    VIDEO_INPUT_NOT_DISPLAY = 0xFF
+};
+typedef enum st_video_input_channel_enum_t  video_input_channel_enum_t;
+/* "typedef" must be after "enum". Because GCC_ARM raises an error */
+
+
+/**
+* @struct  video_input_t
+* @brief  video_input_t
+*
+* @par Description
+*    Member variables can not be accessed by user.
+*/
+typedef struct st_video_input_t  video_input_t;
+struct st_video_input_t {
+
+    /*-----------------------------------------------------------*/
+    /* Group: Cannel */
+
+    /** video_input_channel */
+    vdc5_channel_t      video_input_channel;
+
+    /** video_input_select */
+    vdec_adc_vinsel_t   video_input_select;
+
+    /** is_data_control */
+    bool_t              is_data_control;
+
+    /** data_control_ID */
+    vdc5_layer_id_t     data_control_ID;
+
+
+    /*-----------------------------------------------------------*/
+    /* Group: Interrupt */
+
+    /** is_vsync_interrupt_registered */
+    bool_t              is_vsync_interrupt_registered[3];
+
+    /** interrupt_for_VDC5 */
+    vdc5_int_t          interrupt_for_VDC5;
+
+    /** interrupt_ID */
+    bsp_int_src_t       interrupt_ID;
+
+    /** interrupt_vector */
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+    bsp_int_cb_t        interrupt_vector;
+#endif
+
+
+    /*-----------------------------------------------------------*/
+    /* Group: Buffer */
+
+    /** frame_buffer */
+    frame_buffer_t      frame_buffer;
+
+    /** captured_buffer_index */
+    int_fast32_t        captured_buffer_index;
+
+    /** captured_count */
+    int_fast32_t        captured_count;
+
+    /** captured_async */
+    r_ospl_async_t     *captured_async;
+};
+
+
+/**
+* @struct  video_input_config_t
+* @brief  Parameters of <R_VIDEO_INPUT_Initialize>
+*/
+typedef struct st_video_input_config_t  video_input_config_t;
+struct st_video_input_config_t {
+
+    /** 0 | VIDEO_INPUT_CONFIG_T_layer_ID | ... */
+    bit_flags_fast32_t  flags;
+
+
+    /** 0=ch0.VIN1, 1=ch1.VIN1, 2=ch0.VIN2, 3=ch1.VIN2 */
+    int_fast32_t        video_input_channel_num;
+
+    /** 0, 1 or VIDEO_INPUT_NOT_DISPLAY */
+    int_fast32_t        display_channel_num;
+
+    /** -1 or VIDEO_INPUT_NOT_DISPLAY */
+    int_fast32_t        display_layer_num;
+
+    /** frame_buffer */
+    frame_buffer_t     *frame_buffer;
+
+    /** captured_async */
+    r_ospl_async_t     *captured_async;
+};
+/* video_input_config_t::flags */
+#define  VIDEO_INPUT_CONFIG_T_VIDEO_INPUT_CHANNEL_NUM  0x0001
+#define  VIDEO_INPUT_CONFIG_T_DISPLAY_CHANNEL_NUM      0x0002
+#define  VIDEO_INPUT_CONFIG_T_DISPLAY_LAYER_NUM        0x0004
+#define  VIDEO_INPUT_CONFIG_T_FRAME_BUFFER             0x0008
+#define  VIDEO_INPUT_CONFIG_T_CAPTURED_ASYNC           0x0010
+
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+/* In "video_input.h" */
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/vsync.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,138 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  vsync.h
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 38 $
+* $Date:: 2014-03-18 16:14:45 +0900#$
+*/
+
+#ifndef  VSYNC_H
+#define  VSYNC_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "r_typedefs.h"
+#include  "vsync_typedef.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+/* In "vsync_typedef.h" */
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+/* In "vsync_typedef.h" */
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+/* In "vsync_typedef.h" */
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+/**
+* @brief   Initialize V-Sync object of specified channel number
+*
+* @param   ChannelNum ChannelNum
+* @return  Error Code. 0=No Error.
+*/
+errnum_t  R_V_SYNC_Initialize( int_fast32_t const  ChannelNum );
+
+
+/**
+* @brief   R_V_SYNC_Finalize
+*
+* @param   ChannelNum ChannelNum
+* @param   e Errors that have occurred. No error = 0
+* @return  Error code or e, 0 = successful and input e=0
+*/
+errnum_t  R_V_SYNC_Finalize( int_fast32_t const  ChannelNum,  errnum_t e );
+
+
+/**
+* @brief   Wait for V-Sync
+*
+* @param   ChannelNum ChannelNum
+* @param   SwapInterval If 1=60fps Then 2=30fps, 3=20fps
+* @param   Is1VSyncAtMinimum false = It is possible to return soon
+* @return  Error Code. 0=No Error.
+*/
+errnum_t  R_V_SYNC_Wait( int_fast32_t const  ChannelNum,
+                         int_fast32_t const  SwapInterval,  bool_t const  Is1VSyncAtMinimum );
+
+
+/**
+* @brief   Asynchronous function of <R_V_SYNC_Wait>
+*
+* @param   ChannelNum ChannelNum
+* @param   SwapInterval If 1=60fps Then 2=30fps, 3=20fps
+* @param   Is1VSyncAtMinimum false = It is possible to set event soon
+* @param   Async r_ospl_async_t
+* @return  Error Code. 0=No Error.
+*/
+errnum_t  R_V_SYNC_WaitStart( int_fast32_t const  ChannelNum,
+                              int_fast32_t const  SwapInterval,  bool_t const  Is1VSyncAtMinimum,
+                              r_ospl_async_t *const  Async );
+
+
+/**
+* @brief   Receive interrupt information.
+*
+* @param   InterruptSource r_ospl_interrupt_t
+* @return  Error Code. 0=No Error.
+*/
+errnum_t  R_V_SYNC_OnInterrupting( const r_ospl_interrupt_t *const  InterruptSource );
+
+
+/**
+* @brief   Get <r_v_sync_async_status_t>
+*
+* @param   ChannelNum ChannelNum
+* @param   out_Status AsyncStatus
+* @return  Error Code. 0=No Error.
+*/
+errnum_t  R_V_SYNC_GetAsyncStatus( int_fast32_t const  ChannelNum,
+                                   const r_v_sync_async_status_t **const  out_Status );
+
+
+/* Following functions can not be called from Application. */
+void      R_V_SYNC_EnableInterrupt( int_fast32_t const  ChannelNum );
+bool_t    R_V_SYNC_DisableInterrupt( int_fast32_t const  ChannelNum );
+/* It is not necessary: R_V_SYNC_FinalizeAsync(), R_V_SYNC_OnInterrupted() */
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/vsync_pl.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,139 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  vsync_pl.h
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 38 $
+* $Date:: 2014-03-18 16:14:45 +0900#$
+* - Description: V-Sync porting layer
+*/
+
+#ifndef  WINDOW_SURFACES_PL_H
+#define  WINDOW_SURFACES_PL_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "r_ospl_typedef.h"
+#include  "vsync_typedef.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+
+    /******************************************************************************
+    Typedef definitions
+    ******************************************************************************/
+
+    /******************************************************************************
+    Macro definitions
+    ******************************************************************************/
+
+    /******************************************************************************
+    Variable Externs
+    ******************************************************************************/
+
+    /******************************************************************************
+    Functions Prototypes
+    ******************************************************************************/
+
+
+    /**
+    * @brief   Set default <r_ospl_async_t>
+    *
+    * @param   in_out_Async Async parameters
+    * @param   AsyncType r_ospl_async_type_t
+    * @return  None
+    */
+    void  R_V_SYNC_SetDefaultAsync( r_ospl_async_t *const  in_out_Async,  r_ospl_async_type_t AsyncType );
+
+
+    /**
+    * @brief   Called from <R_V_SYNC_Initialize>
+    *
+    * @param   ChannelNum ChannelNum parameters
+    * @return  Error Code. 0=No Error.
+    */
+    errnum_t  R_V_SYNC_OnInitialize( int_fast32_t const  ChannelNum );
+
+
+    /**
+    * @brief   Called from <R_V_SYNC_Finalize>
+    *
+    * @param   ChannelNum ChannelNum parameters
+    * @return  Error Code. 0=No Error.
+    */
+    errnum_t  R_V_SYNC_OnFinalize( int_fast32_t const  ChannelNum,  errnum_t e );
+
+
+    /**
+    * @brief   Send <r_ospl_caller_t> to porting layer
+    *
+    * @param   ChannelNum ChannelNum parameters
+    * @param   Caller r_ospl_caller_t
+    * @return  Error Code. 0=No Error.
+    */
+    errnum_t  R_V_SYNC_SetInterruptCallbackCaller( int_fast32_t const  ChannelNum,
+            const r_ospl_caller_t *const  Caller );
+
+
+    /**
+    * @brief   Enable interrupt lines
+    *
+    * @param   ChannelNum ChannelNum parameters
+    * @param   Enables <r_v_sync_interrupt_lines_t>. 1=Enable, 0=NotChange
+    * @return  Error Code. 0=No Error.
+    */
+    void   R_V_SYNC_OnEnableInterrupt( int_fast32_t const  ChannelNum,
+                                       r_v_sync_interrupt_lines_t const  Enables );
+
+
+    /**
+    * @brief   Disable interrupt lines
+    *
+    * @param   ChannelNum ChannelNum parameters
+    * @param   Disables <r_v_sync_interrupt_lines_t>. 1=Disable, 0=NotChange
+    * @return  Error Code. 0=No Error.
+    */
+    void      R_V_SYNC_OnDisableInterrupt( int_fast32_t const  ChannelNum,
+                                           r_v_sync_interrupt_lines_t const  Disables );
+
+
+    /**
+    * @brief   Default interrupt callback function
+    *
+    * @param   InterruptSource r_ospl_interrupt_t
+    * @param   Caller r_ospl_caller_t
+    * @return  Error Code. 0=No Error.
+    */
+    errnum_t  R_V_SYNC_OnInterruptDefault( const r_ospl_interrupt_t *const  InterruptSource,
+                                           const r_ospl_caller_t *const  Caller );
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/vsync_typedef.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  vsync_typedef.h
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 38 $
+* $Date:: 2014-03-18 16:14:45 +0900#$
+*/
+
+#ifndef  VSYNC_TYPEDEF_H
+#define  VSYNC_TYPEDEF_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "r_typedefs.h"
+#include  "r_ospl_typedef.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/**
+* @typedef  r_v_sync_interrupt_line_t
+* @brief  r_v_sync_interrupt_line_t
+*/
+typedef uint_fast32_t  r_v_sync_interrupt_line_t;
+#define  R_V_SYNC_INTERRUPT_LINE_V_LINE  0x00000001u
+
+
+/**
+* @typedef  r_v_sync_interrupt_lines_t
+* @brief  r_v_sync_interrupt_lines_t
+*/
+typedef bit_flags_fast32_t /*<r_v_sync_interrupt_line_t>*/  r_v_sync_interrupt_lines_t;
+
+
+/**
+* @def  R_V_SYNC_INTERRUPT_LINE_ALL
+* @brief  All bits of <r_v_sync_interrupt_lines_t>
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  R_V_SYNC_INTERRUPT_LINE_ALL  ( R_V_SYNC_INTERRUPT_LINE_V_LINE )
+
+
+/**
+* @typedef  r_v_sync_async_status_t
+* @brief  r_v_sync_async_status_t
+*/
+typedef struct st_r_ospl_async_status_t  r_v_sync_async_status_t;
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/**
+* @def  R_V_SYNC_CHANNEL_COUNT
+* @brief  VDC5 channel count
+* @par Parameters
+*    None
+* @return  None.
+*/
+enum { R_V_SYNC_CHANNEL_COUNT = 2 };
+
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+/* In "vsync.h" */
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/window_surfaces.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,185 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/******************************************************************************
+* $FileName: window_surfaces.h $
+* $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+* Description: Sample API
+*******************************************************************************/
+
+#ifndef  WINDOW_SURFACES_H
+#define  WINDOW_SURFACES_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "clib_drivers_typedef.h"
+#include  "window_surfaces_typedef.h"
+#include  "r_multi_compiler_typedef.h"
+#include  "window_surfaces_inline.h"
+#ifdef  IS_WINDOW_SURFACES_EX
+#include  "window_surfaces_ex.h"
+#include  "RGA_API_typedef.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+/* In "frame_buffer_typedef.h" */
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+/* In "frame_buffer_typedef.h" */
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+/* In "frame_buffer_typedef.h" */
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+/**
+* @brief   R_WINDOW_SURFACES_InitConst
+*
+* @param   self window_surfaces_t
+* @return  None
+*/
+void      R_WINDOW_SURFACES_InitConst( window_surfaces_t *const  self );
+
+
+/**
+* @brief   R_WINDOW_SURFACES_Initialize
+*
+* @param   self window_surfaces_t
+* @param   in_out_config window_surfaces_config_t
+* @return  Error code, 0=No error
+*/
+errnum_t  R_WINDOW_SURFACES_Initialize( window_surfaces_t *const  self,
+                                        window_surfaces_config_t *in_out_config );
+
+
+/**
+* @brief   R_WINDOW_SURFACES_Finalize
+*
+* @param   self window_surfaces_t
+* @param   e Errors that have occurred. No error = 0
+* @return  Error code or e, 0 = successful and input e=0
+*/
+errnum_t  R_WINDOW_SURFACES_Finalize( window_surfaces_t *const  self, errnum_t e );
+
+
+/**
+* @brief   Get <frame_buffer_t>* of specified layer number
+*
+* @param   self window_surfaces_t
+* @param   layer_num layer_num
+* @param   out_frame_buffer out_frame_buffer
+* @return  Error code, 0=No error
+*/
+errnum_t  R_WINDOW_SURFACES_GetLayerFrameBuffer( const window_surfaces_t *const  self,
+        int_fast32_t const  layer_num,  frame_buffer_t **const  out_frame_buffer );
+
+
+/**
+* @brief   R_WINDOW_SURFACES_SwapBuffers
+*
+* @param   self window_surfaces_t
+* @param   layer_num layer_num
+* @param   context Graphics context or NULL
+* @return  Error code, 0=No error
+*/
+#ifdef  IS_WINDOW_SURFACES_EX
+errnum_t  R_WINDOW_SURFACES_SwapBuffers( window_surfaces_t *const  self,
+        int_fast32_t const  layer_num,  graphics_t *const  context );
+#else
+errnum_t  R_WINDOW_SURFACES_SwapBuffers( window_surfaces_t *const  self,
+        int_fast32_t const  layer_num,  const void *const  null_context );
+#endif
+
+
+/**
+* @brief   Asynchronous function of <R_WINDOW_SURFACES_SwapBuffers>
+*
+* @param   self window_surfaces_t
+* @param   layer_num layer_num
+* @param   async r_ospl_async_t
+* @return  Error code, 0=No error
+*/
+errnum_t  R_WINDOW_SURFACES_SwapBuffersStart( window_surfaces_t *const  self,
+        int_fast32_t const  layer_num,  r_ospl_async_t *async );
+
+
+/**
+* @brief   Wait for V-Sync
+*
+* @param   swap_interval If 1=60fps Then 2=30fps, 3=20fps
+* @param   is_1_v_sync_at_minimum false = It is possible to return soon
+* @return  Error Code. 0=No Error.
+*/
+errnum_t  R_WINDOW_SURFACES_WaitForVSync( window_surfaces_t *const  self,
+        int_fast32_t const  swap_interval,  bool_t const  is_1_v_sync_at_minimum );
+
+
+/**
+* @brief   Allocate offscreen from stack
+*
+* @param   self window_surfaces_t
+* @param   in_out_frame_buffer frame_buffer_t
+* @return  Error code, 0=No error
+*
+* @par Description
+*    - (input) - >stride, ->height, ->buffer_count
+*    - (output) - >buffer_address[(all)]
+*/
+errnum_t  R_WINDOW_SURFACES_AllocOffscreenStack( window_surfaces_t *const  self,
+        frame_buffer_t *const  in_out_frame_buffer );
+
+
+/**
+* @brief   Free offscreen to stack
+*
+* @param   self window_surfaces_t
+* @param   frame_buffer frame_buffer_t
+* @return  Error code, 0=No error
+*
+* @par Description
+*    - If frame_buffer - >buffer_count == 0, do nothing.
+*/
+errnum_t  R_WINDOW_SURFACES_FreeOffscreenStack( window_surfaces_t *const  self,
+        const frame_buffer_t *const  frame_buffer );
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/window_surfaces.hpp	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,218 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2014 - 2015 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  window_surfaces.hpp
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.20 $ (=CLIB_VERSION)
+* $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+* - Description: Window Surfaces for mbed style C++ API
+*/
+
+#ifndef  WINDOW_SURFACES_HPP
+#define  WINDOW_SURFACES_HPP
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "r_ospl_typedef.h"
+#include  "window_surfaces_typedef.h"
+#include  "RGA.h"
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+class  WindowSurfacesConfigClass;
+#ifdef  IS_WINDOW_SURFACES_EX
+class  GraphicsClass;
+class  LayerAttributes;
+#endif
+
+
+/***********************************************************************
+* Class: WindowSurfacesClass
+*    mbed style C++ version of <window_surfaces_t>
+************************************************************************/
+class  WindowSurfacesClass {
+public:
+	/**
+* @brief   WindowSurfacesClass
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	WindowSurfacesClass();
+	~WindowSurfacesClass();
+
+	/**
+* @brief   initialize
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	errnum_t  initialize( WindowSurfacesConfigClass& in_out_config );
+
+	/**
+* @brief   destroy
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	void  destroy();
+
+	/**
+* @brief   get_layer_frame_buffer
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	errnum_t  get_layer_frame_buffer( int_fast32_t const  layer_num,  frame_buffer_t** const  out_frame_buffer );
+
+	/**
+* @brief   swap_buffers
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	#ifdef  IS_WINDOW_SURFACES_EX
+	errnum_t  swap_buffers( int_fast32_t const  layer_num,  Canvas2D_ContextClass&  context );
+	#else
+	errnum_t  swap_buffers( int_fast32_t const  layer_num,  const void* const  null_context );
+	#endif
+
+	/**
+* @brief   swap_buffers_start
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	errnum_t  swap_buffers_start( int_fast32_t const  layer_num,  r_ospl_async_t* async );
+
+	/**
+* @brief   wait_for_v_sync
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	errnum_t  wait_for_v_sync( int_fast32_t const  swap_interval,  bool_t const  is_1_v_sync_at_minimum );
+
+	/**
+* @brief   alloc_offscreen_stack
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	errnum_t  alloc_offscreen_stack( frame_buffer_t* const  in_out_frame_buffer );
+
+	/**
+* @brief   free_offscreen_stack
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	errnum_t  free_offscreen_stack( const frame_buffer_t* const  frame_buffer );
+
+#ifdef  IS_WINDOW_SURFACES_EX
+	/**
+* @brief   do_message_loop
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	errnum_t  do_message_loop();
+
+	/**
+* @brief   access_layer_attributes
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	errnum_t  access_layer_attributes( LayerAttributes& in_out_Attributes );
+#endif
+
+private:
+	window_surfaces_t*  _self;
+};
+
+
+/***********************************************************************
+* Class: WindowSurfacesConfigClass
+*    mbed style C++ version of <window_surfaces_config_t>
+************************************************************************/
+class  WindowSurfacesConfigClass : public window_surfaces_config_t {
+public:
+	/**
+* @brief   WindowSurfacesConfigClass
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	WindowSurfacesConfigClass();
+};
+
+
+/***********************************************************************
+* Class: LayerAttributes
+*    mbed style C++ version of <layer_attributes_t>
+************************************************************************/
+#ifdef  IS_WINDOW_SURFACES_EX
+class  LayerAttributes : public layer_attributes_t {
+public:
+	/**
+* @brief   LayerAttributes
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+	LayerAttributes();
+};
+#endif
+
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+#endif  /* WINDOW_SURFACES_HPP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/window_surfaces_ex.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,133 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  window_surfaces_ex.h
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+*/
+#ifndef  WINDOW_SURFACES_EX_H
+#define  WINDOW_SURFACES_EX_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "window_surfaces_ex_typedef.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+/* In "frame_buffer_typedef.h" */
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+/* In "frame_buffer_typedef.h" */
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+/* In "frame_buffer_typedef.h" */
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+
+/***********************************************************************
+* Class: window_surfaces_t
+*    Extra methods of <window_surfaces_t>
+************************************************************************/
+
+/**
+* @brief   Emulate message loop function.
+*
+* @param   self window_surfaces_t
+* @return  Error code, 0=No error
+*/
+errnum_t  R_WINDOW_SURFACES_DoMessageLoop( window_surfaces_t *self );
+
+
+/**
+* @brief   Set or get by <layer_attributes_t>
+*
+* @param   self window_surfaces_t
+* @param   in_out_Attributes <layer_attributes_t>
+* @return  Error code, 0=No error
+*/
+errnum_t  R_WINDOW_SURFACES_AccessLayerAttributes( window_surfaces_t *self,
+        layer_attributes_t *in_out_Attributes );
+
+
+/***********************************************************************
+* Class: vram_ex_stack_t
+*    VRAM stack in external RAM
+************************************************************************/
+
+/**
+* @brief   R_VRAM_EX_STACK_Initialize
+*
+* @param   self vram_ex_stack_t
+* @param   NullConfig NULL
+* @return  Error Code. 0=No Error.
+*/
+errnum_t  R_VRAM_EX_STACK_Initialize( vram_ex_stack_t *self, void *NullConfig );
+
+
+/**
+* @brief   Allocate VRAM from external RAM
+*
+* @param   self vram_ex_stack_t
+* @param   in_out_FrameBuffer frame_buffer_t
+* @return  Error code, 0=No error
+*
+* @par Description
+*    - (input) - >stride, ->height, ->buffer_count
+*    - (output) - >buffer_address[(all)]
+*/
+errnum_t  R_VRAM_EX_STACK_Alloc( vram_ex_stack_t *self, frame_buffer_t *in_out_FrameBuffer );
+
+
+/**
+* @brief   Free VRAM to external RAM
+*
+* @param   self vram_ex_stack_t
+* @param   frame_buffer frame_buffer_t
+* @return  Error code, 0=No error
+*
+* @par Description
+*    - If frame_buffer - >buffer_count == 0, do nothing.
+*/
+errnum_t  R_VRAM_EX_STACK_Free( vram_ex_stack_t *self, frame_buffer_t *frame_buffer );
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/window_surfaces_ex_typedef.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,189 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  window_surfaces_ex_typedef.h
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+*/
+
+#ifndef  WINDOW_SURFACES_EX_TYPEDEF_H
+#define  WINDOW_SURFACES_EX_TYPEDEF_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+
+/**
+* @struct  window_surfaces_attribute_t
+* @brief  Type of <window_surfaces_t>::attributes.
+*/
+typedef  struct st_window_surfaces_attribute_t  window_surfaces_attribute_t;
+struct st_window_surfaces_attribute_t {
+
+    /** X */
+    int_fast32_t  X;
+
+    /** Y */
+    int_fast32_t  Y;
+
+    /** Width */
+    int_fast32_t  Width;
+
+    /** Height */
+    int_fast32_t  Height;
+
+    /** OffsetX */
+    int_fast32_t  OffsetX;
+
+    /** OffsetY */
+    int_fast32_t  OffsetY;
+
+    /** OffsetByte */
+    int_fast32_t  OffsetByte;
+};
+
+
+/* Section: Global */
+/**
+* @enum   access_t
+* @brief  access_t
+*    - ACCESS_READ - 1
+*    - ACCESS_WRITE - 2
+*    - ACCESS_READ_WRITE - 3
+*    - ACCESS_PLUS - 4
+*/
+enum st_access_t {
+    ACCESS_READ  = 1,
+    ACCESS_WRITE = 2,
+    ACCESS_READ_WRITE = ( 1 | 2 ),
+    ACCESS_PLUS  = 4,
+
+    ACCESS_ALL_MASK = ACCESS_READ | ACCESS_WRITE | ACCESS_READ_WRITE | ACCESS_PLUS
+};
+typedef  enum st_access_t  access_t;
+
+
+/**
+* @struct  layer_attributes_t
+* @brief  Parameters of <R_WINDOW_SURFACES_AccessLayerAttributes>.
+*/
+typedef  struct st_layer_attributes_t  layer_attributes_t;
+struct st_layer_attributes_t {
+
+    /** access */
+    access_t      access;
+
+    /** 0 | F_LAYER_IS_SHOW | ... */
+    bit_flags_fast32_t  flags;
+
+    /** id */
+    int_fast32_t  id;
+
+    /** priority */
+    int_fast32_t  priority;
+
+    /** is_show */
+    bool_t        is_show;
+
+    /** is_color_key */
+    bool_t        is_color_key;
+
+    /** color_key */
+    r8g8b8a8_t    color_key;
+
+    /** layer_color */
+    r8g8b8a8_t    layer_color;
+
+    /** x */
+    int_fast32_t  x;
+
+    /** y */
+    int_fast32_t  y;
+
+    /** width */
+    int_fast32_t  width;
+
+    /** height */
+    int_fast32_t  height;
+
+    /** offset_x */
+    int_fast32_t  offset_x;
+
+    /** offset_y */
+    int_fast32_t  offset_y;
+
+    /** CLUT (Color Look Up Table) */
+    uint32_t     *CLUT;
+
+    /** CLUT (Color Look Up Table) count */
+    int_fast32_t  CLUT_count;
+};
+
+enum {
+    F_LAYER_ID           = 0x0001,
+    F_LAYER_PRIORITY     = 0x0002,
+    F_LAYER_IS_SHOW      = 0x0004,
+    F_LAYER_IS_COLOR_KEY = 0x0008,
+    F_LAYER_COLOR_KEY    = 0x0010,
+    F_LAYER_LAYER_COLOR  = 0x0020,
+    F_LAYER_X            = 0x0040,
+    F_LAYER_Y            = 0x0080,
+    F_LAYER_WIDTH        = 0x0100,
+    F_LAYER_HEIGHT       = 0x0200,
+    F_LAYER_OFFSET_X     = 0x0400,
+    F_LAYER_OFFSET_Y     = 0x0800,
+    F_LAYER_CLUT         = 0x1000,
+    F_LAYER_CLUT_COUNT   = 0x2000
+};
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+/* In "window_surfaces_ex.h" */
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/window_surfaces_inline.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  window_surfaces_inline.h
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+*/
+
+
+/* This file is included from "window_surfaces.h" */
+
+
+#ifndef  WINDOW_SURFACES_INLINE_H
+#define  WINDOW_SURFACES_INLINE_H
+#ifndef  NOT_DEFINE_INLINE_FUNCTION
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  <stdint.h>
+#include  "clib_drivers_typedef.h"
+#include  "frame_buffer_typedef.h"
+#include  "r_multi_compiler_typedef.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+
+/**
+* @brief   Get color
+*
+* @param   Red Red.
+* @param   Green Green.
+* @param   Blue Blue.
+* @param   Alpha Alpha.
+* @return  Color code as "r8g8b8a8_t"
+*/
+INLINE r8g8b8a8_t  R_RGA_Get_R8G8B8A8( int_fast32_t const  Red,
+                                       int_fast32_t const  Green,
+                                       int_fast32_t const  Blue,
+                                       int_fast32_t const  Alpha )
+{
+    r8g8b8a8_t  color_;  /* _ is for MISRA 5.6 */
+
+    /* ->QAC 3198 */
+    color_.Value = DUMMY_INITIAL_VALUE;  /* for avoid ARMCC warning C4017W */
+    /* <-QAC 3198 */
+    color_.u.Red   = (uint8_t) Red;
+    color_.u.Green = (uint8_t) Green;
+    color_.u.Blue  = (uint8_t) Blue;
+    color_.u.Alpha = (uint8_t) Alpha;
+
+    return  color_;
+}
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif  /* NOT_DEFINE_INLINE_FUNCTION */
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/window_surfaces_private.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,70 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/******************************************************************************
+* $FileName: window_surfaces_private.h $
+* $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+* Description  : Sample API
+*******************************************************************************/
+
+#ifndef  WINDOW_SURFACES_PRIVATE_H
+#define  WINDOW_SURFACES_PRIVATE_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "RGA_Port_typedef.h"
+#include  "r_ospl_typedef.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+#define  RGA_STACK_ADDRESS_ALIGNMENT  64
+R_STATIC_ASSERT_GLOBAL( RGA_STACK_ADDRESS_ALIGNMENT >= RGA_SOURCE_IMAGE_STRIDE_ALIGNMENT, "" );
+R_STATIC_ASSERT_GLOBAL( RGA_STACK_ADDRESS_ALIGNMENT >= RGA_VDC5_BUFFER_ADDRESS_ALIGNMENT, "" );
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+errnum_t  R_EXRAM_GetBigMemory( void * /*<type**>*/ out_Address, size_t *out_Size );
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* WINDOW_SURFACES_PRIVATE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/inc/window_surfaces_typedef.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,228 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  window_surfaces_typedef.h
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+*/
+
+#ifndef  WINDOW_SURFACES_TYPEDEF_H
+#define  WINDOW_SURFACES_TYPEDEF_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "Project_Config.h"
+#include  "r_vdc5.h"
+#include  "frame_buffer_typedef.h"
+#include  "RGA_Port_typedef.h"
+#ifdef  IS_WINDOW_SURFACES_EX
+#include  "window_surfaces_ex_typedef.h"
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/**
+* @enum   background_format_t
+* @brief  background_format_t
+*
+*    - BACKGROUND_FORMAT_SOLID_COLOR - 0
+*    - BACKGROUND_FORMAT_VIDEO_INTERLACE - 1
+*/
+enum st_background_format_t {
+    BACKGROUND_FORMAT_SOLID_COLOR,
+    BACKGROUND_FORMAT_VIDEO_INTERLACE
+};
+typedef enum st_background_format_t  background_format_t;
+/* "typedef" must be after "enum". Because GCC_ARM raises an error */
+
+
+/**
+* @struct  window_surfaces_vdc5_layer_t
+* @brief  VDC5 layer
+*/
+typedef struct st_window_surfaces_vdc5_layer_t  window_surfaces_vdc5_layer_t;
+struct st_window_surfaces_vdc5_layer_t {
+
+    /*-----------------------------------------------------------*/
+    /* Group: Layer */
+
+    /** layer_num */
+    int8_t  layer_num;
+
+    /** graphics_layer_ID */
+    vdc5_graphics_type_t  graphics_layer_ID;
+
+
+    /*-----------------------------------------------------------*/
+    /* Group: Data Control */
+
+    /** is_data_control */
+    bool_t  is_data_control;
+
+    /** data_control_ID */
+    vdc5_layer_id_t  data_control_ID;
+
+
+    /*-----------------------------------------------------------*/
+    /* Group: Color Format */
+
+    /** vdc5_format */
+    vdc5_gr_format_t  vdc5_format;
+
+    /** layer_color */
+    r8g8b8a8_t  layer_color;
+};
+
+
+/**
+* @struct  window_surfaces_t
+* @brief  window_surfaces_t
+*/
+typedef struct st_window_surfaces_t  window_surfaces_t;
+#define   WINDOW_SURFACES_T_MAX_LAYERS_COUNT   3
+
+struct st_window_surfaces_t {
+    /** Index is 0 .. (layer_num_max + background_frame_count) */
+    frame_buffer_t  frame_buffers[ WINDOW_SURFACES_T_MAX_LAYERS_COUNT ];
+
+    /** screen_channel */
+    vdc5_channel_t  screen_channel;
+
+    /** layer_num_min */
+    int8_t  layer_num_min;
+
+    /** layer_num_max */
+    int8_t  layer_num_max;
+
+    /** layers */
+    window_surfaces_vdc5_layer_t  layers[ WINDOW_SURFACES_T_MAX_LAYERS_COUNT ];
+
+    /** attributes */
+#ifdef  IS_WINDOW_SURFACES_EX
+    window_surfaces_attribute_t   attributes[ WINDOW_SURFACES_T_MAX_LAYERS_COUNT ];
+#endif
+
+    /** vdc5_disp_sel_array */
+    vdc5_gr_disp_sel_t   vdc5_disp_sel_array[ VDC5_GR_TYPE_NUM ];
+
+    /** background_format */
+    background_format_t  background_format;
+
+    /** background_frame_count */
+    int_fast32_t   background_frame_count;
+
+
+    /*-----------------------------------------------------------*/
+    /* Group: VRAM */
+
+    /** start_of_VRAM */
+    uint8_t  *start_of_VRAM;
+
+    /** over_of_VRAM */
+    uint8_t  *over_of_VRAM;
+
+    /** stack_pointer_of_VRAM */
+    uint8_t  *stack_pointer_of_VRAM;
+
+
+    /*-----------------------------------------------------------*/
+    /* Group: State */
+
+    /** is_initialized */
+    bool_t  is_initialized;  /* For reduce loading */
+};
+
+
+/**
+* @struct  window_surfaces_config_t
+* @brief  window_surfaces_config_t
+*/
+typedef struct st_window_surfaces_config_t  window_surfaces_config_t;
+struct st_window_surfaces_config_t {
+    /** 0 | F_WINDOW_SURFACES_PIXEL_FORMAT | ... */
+    bit_flags_fast32_t  flags;
+
+    /** pixel_format */
+    pixel_format_t  pixel_format;
+
+    /** layer_count */
+    int_fast32_t  layer_count;
+
+    /** buffer_height */
+    int_fast32_t  buffer_height;
+
+    /** background_color */
+    r8g8b8a8_t  background_color;
+
+    /** background_format */
+    background_format_t  background_format;
+};
+enum  /* "window_surfaces_config_t::flags" */
+{
+    F_WINDOW_SURFACES_PIXEL_FORMAT      = 0x08,
+    F_WINDOW_SURFACES_LAYER_COUNT       = 0x20,
+#define  F_WINDOW_SURFACES_BACKGROUND_COLOR    0x40u
+    F_WINDOW_SURFACES_BUFFER_HEIGHT     = 0x80,
+    F_WINDOW_SURFACES_BACKGROUND_FORMAT = 0x100
+};
+
+
+/***********************************************************************
+* Section: Global
+************************************************************************/
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/**
+* @def  WINDOW_SURFACES_DEFAULT_CHANNEL
+* @brief  0 or 1
+*/
+#define  WINDOW_SURFACES_DEFAULT_CHANNEL  0
+
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+/* In "frame_buffer.h" */
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
Binary file RGA/libPNG_Zip.ar has changed
Binary file RGA/libRGA.ar has changed
Binary file RGA/libRGAH.ar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/porting/RGA_Callback.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,258 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  RGA_Callback.c
+* @brief   $Module: RGA $ $PublicVersion: 1.20 $ (=RGA_VERSION)
+* $Rev: $
+* $Date::                           $
+*/
+
+#include  <string.h>
+#include  "RGA.h"
+#include  "RGA_Callback_private.h"
+#include  "clib_drivers.h"
+
+
+
+/** gs_WorkBufferMemory */
+static uint8_t  *gs_WorkBufferMemory;
+static size_t    gs_WorkBufferMemory_Size;
+static uint8_t  *gs_WorkBufferB_Memory;
+static size_t    gs_WorkBufferB_Memory_Size;
+
+
+/**
+* @struct  GraphicsDefaultSubClass
+* @brief  GraphicsDefaultSubClass
+*/
+typedef struct _GraphicsDefaultSubClass  GraphicsDefaultSubClass;
+struct _GraphicsDefaultSubClass {
+    uint8_t  *WorkBufferMemory;
+    size_t    work_buffer_size;
+    bool_t    IsUsedWorkBuffer;
+    uint8_t  *WorkBufferB_Memory;
+    size_t    work_buffer_b_size;
+    bool_t    IsUsedWorkBufferB;
+};
+
+
+/* Section: Global */
+/** gs_GraphicsDefaultSub */
+static  GraphicsDefaultSubClass  gs_GraphicsDefaultSub = {
+    NULL,      /* WorkBufferMemory */
+    0,         /* work_buffer_size */
+    false,     /* IsUsedWorkBuffer */
+    NULL,      /* WorkBufferB_Memory */
+    0,         /* work_buffer_b_size */
+    false,     /* IsUsedWorkBufferB */
+};
+
+
+
+/**
+* @brief   R_GRAPHICS_STATIC_OnInitializeDefault
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+errnum_t  R_GRAPHICS_STATIC_OnInitializeDefault( graphics_t *self, graphics_config_t *in_out_Config,
+        void **out_CalleeDefined )
+{
+    enum { work_buffer_flags =
+               F_GRAPHICS_WORK_BUFFER_ADDRESS |
+               F_GRAPHICS_WORK_BUFFER_SIZE |
+               F_GRAPHICS_MAX_WIDTH_OF_FRAME_BUFFER |
+               F_GRAPHICS_MAX_HEIGHT_OF_FRAME_BUFFER
+         };
+
+    enum { work_buffer_B_flags =
+               F_GRAPHICS_WORK_BUFFER_B_ADDRESS |
+               F_GRAPHICS_WORK_BUFFER_B_SIZE
+         };
+
+    static r_ospl_c_lock_t  gs_c_lock_object;
+
+    errnum_t  e;
+
+    GraphicsDefaultSubClass  *sub = &gs_GraphicsDefaultSub;
+
+    R_UNREFERENCED_VARIABLE_2( self, out_CalleeDefined );
+
+    R_MEMORY_SECTION_GetMemory_RGA_WorkBuffer( &gs_WorkBufferMemory, &gs_WorkBufferMemory_Size,
+            &gs_WorkBufferB_Memory, &gs_WorkBufferB_Memory_Size );
+
+
+    /* Set default configuration */
+
+    /* Use work buffer */
+    if ( IS_ANY_BITS_NOT_SET( in_out_Config->flags, work_buffer_flags ) ) {
+        ASSERT_R( IS_ALL_BITS_NOT_SET( in_out_Config->flags, work_buffer_flags ),  e=E_OTHERS; goto fin );
+        ASSERT_R( ! sub->IsUsedWorkBuffer,  e=E_OTHERS; goto fin );
+
+#if  RGA_WORK_BUFFER_ADDRESS_ALIGNMENT == 64  /* Check of "R_Ceil_64u" */
+        sub->WorkBufferMemory = (uint8_t *) R_Ceil_64u( (uintptr_t) gs_WorkBufferMemory );
+#elif  RGA_WORK_BUFFER_ADDRESS_ALIGNMENT == 4  /* Check of "R_Ceil_4u" */
+        sub->WorkBufferMemory = (uint8_t *) R_Ceil_4u( (uintptr_t) gs_WorkBufferMemory );
+#else
+#error
+#endif
+        sub->work_buffer_size = gs_WorkBufferMemory_Size - ( sub->WorkBufferMemory - gs_WorkBufferMemory );
+
+        in_out_Config->flags |= work_buffer_flags;
+        in_out_Config->work_buffer_address = sub->WorkBufferMemory;
+        in_out_Config->work_buffer_size    = sub->work_buffer_size;
+        in_out_Config->max_width_of_frame_buffer = MAX_WIDTH_OF_FRAME_BUFFER;
+        in_out_Config->max_height_of_frame_buffer = MAX_HEIGHT_OF_FRAME_BUFFER;
+
+        sub->IsUsedWorkBuffer = true;
+    }
+
+    /* Use work buffer B */
+    if ( IS_ANY_BITS_NOT_SET( in_out_Config->flags, work_buffer_B_flags ) ) {
+        ASSERT_R( IS_ALL_BITS_NOT_SET( in_out_Config->flags, work_buffer_B_flags ),  e=E_OTHERS; goto fin );
+        ASSERT_R( ! sub->IsUsedWorkBufferB,  e=E_OTHERS; goto fin );
+
+#if  RGA_WORK_BUFFER_B_ADDRESS_ALIGNMENT == 32  /* Check of "R_Ceil_32u" */
+        sub->WorkBufferB_Memory = (uint8_t *) R_Ceil_32u( (uintptr_t) gs_WorkBufferB_Memory );
+#elif  RGA_WORK_BUFFER_B_ADDRESS_ALIGNMENT == 4  /* Check of "R_Ceil_4u" */
+        sub->WorkBufferB_Memory = (uint8_t *) R_Ceil_4u( (uintptr_t) gs_WorkBufferB_Memory );
+#else
+#error
+#endif
+        sub->work_buffer_b_size = gs_WorkBufferB_Memory_Size - ( sub->WorkBufferB_Memory - gs_WorkBufferB_Memory );
+
+        in_out_Config->flags |= work_buffer_B_flags;
+        in_out_Config->work_buffer_b_address = sub->WorkBufferB_Memory;
+        in_out_Config->work_buffer_b_size    = sub->work_buffer_b_size;
+
+        sub->IsUsedWorkBufferB = true;
+    }
+
+#ifdef  WORK_SIZE_FOR_LIB_PNG
+    in_out_Config->flags |= F_GRAPHICS_WORK_SIZE_FOR_LIBPNG;
+    in_out_Config->work_size_for_libPNG = WORK_SIZE_FOR_LIB_PNG;
+#endif
+
+    R_OSPL_MEMORY_Flush( R_OSPL_FLUSH_WRITEBACK_INVALIDATE );
+    /* Avoid write back by initialization to global variables of buffers */
+
+    /* Lock object */
+    in_out_Config->flags |= F_GRAPHICS_LOCK_OBJECT;
+    in_out_Config->lock_object = &gs_c_lock_object;
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+
+/**
+* @brief   R_GRAPHICS_STATIC_OnFinalizeDefault
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+errnum_t  R_GRAPHICS_STATIC_OnFinalizeDefault( graphics_t *self, void *CalleeDefined, errnum_t e )
+{
+    GraphicsDefaultSubClass  *sub = &gs_GraphicsDefaultSub;
+
+    R_UNREFERENCED_VARIABLE_2( self, CalleeDefined );
+    sub->IsUsedWorkBuffer  = false;
+    sub->IsUsedWorkBufferB = false;
+    return  e;
+}
+
+
+/**
+* @brief   drawCLUTImage
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+errnum_t drawCLUTImage( uint8_t *SrcAddress, const graphics_image_t *image, frame_buffer_t *frame )
+{
+    errnum_t e;
+    int_t image_w;
+    int i;
+    uint32_t ImageWidthPoint;
+    uint8_t *DestAddress;
+    graphics_image_properties_t  image_prop;
+
+    DestAddress = frame->buffer_address[ frame->draw_buffer_index ];
+
+    switch( frame->pixel_format ) {
+        case PIXEL_FORMAT_CLUT8:
+            ImageWidthPoint = 1;
+            break;
+        case PIXEL_FORMAT_CLUT4:
+            ImageWidthPoint = 2;
+            break;
+        case PIXEL_FORMAT_CLUT1:
+            ImageWidthPoint = 8;
+            break;
+        default:
+            /* never comes here */
+            ImageWidthPoint = 1;
+            break;
+    }
+
+    e = R_GRAPHICS_IMAGE_GetProperties( image, &image_prop );
+    IF(e)goto fin;
+    ASSERT_R( image_prop.pixelFormat == frame->pixel_format , e=E_NOT_SUPPORTED_PIXEL_FORMAT; goto fin );
+    ASSERT_R( ( image->width % ImageWidthPoint ) == 0 , e=E_OTHERS; goto fin );
+    ASSERT_R( image->width <= frame->width , e=E_OTHERS; goto fin );
+    ASSERT_R( image->height <= frame->height , e=E_OTHERS; goto fin );
+    ASSERT_R( frame->stride % 32 == 0 , e=E_OTHERS; goto fin );
+
+    image_w = image_prop.width;
+    switch( frame->pixel_format ) {
+        case PIXEL_FORMAT_CLUT8:
+            SrcAddress += sizeof( uint32_t ) * 256;
+            break;
+        case PIXEL_FORMAT_CLUT4:
+            image_w = image_w / 2;
+            SrcAddress += sizeof( uint32_t ) * 16;
+            break;
+        case PIXEL_FORMAT_CLUT1:
+            image_w = image_w / 8;
+            SrcAddress += sizeof( uint32_t ) * 2;
+            break;
+        default:
+            e=E_OTHERS;
+            goto fin;
+    }
+    for( i = 0; i < image->height ; i++ ) {
+        memcpy(( void *) DestAddress, ( void *)SrcAddress, (size_t)image_w );
+        DestAddress += frame->stride;
+        SrcAddress += image_w;
+    }
+    e = 0;
+fin:
+    return e;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/porting/RGA_Callback_WorkBuf.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,69 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2015 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  RGA_Callback_WorkBuf.c
+* @brief   $Module: RGA $ $PublicVersion: 1.20 $ (=RGA_VERSION)
+* $Rev: $
+* $Date::                           $
+*/
+
+#include  <string.h>
+#include  "RGA.h"
+#include  "RGA_Callback_private.h"
+
+
+/** gs_WorkBufferMemory */
+
+/* <MapSection attribute="Uncachable"/> */
+/* .WORK_SECTION1 is for only R_REE_INIT. This is ignored in other environments. */
+R_OSPL_ALIGNMENT( RGA_WORK_BUFFER_ADDRESS_ALIGNMENT,
+                  R_OSPL_SECTION_FOR_ZERO_INIT( "NC_BSS",
+                          static uint8_t  gs_WorkBufferMemory[ WORK_BUFFER_SIZE ] ));
+
+
+/** gs_WorkBufferB_Memory */
+
+R_OSPL_ALIGNMENT( RGA_WORK_BUFFER_B_ADDRESS_ALIGNMENT,
+                  static uint8_t  gs_WorkBufferB_Memory[ WORK_BUFFER_B_SIZE ] );
+
+
+/**
+* @brief   Get Memory of RGA WorkBuffer
+*
+* @param   out_WorkBufferAddress uint8_t*
+* @param   out_WorkBufferSize size_t
+* @param   out_WorkBufferB_Address uint8_t*
+* @param   out_WorkBufferB_Size size_t
+* @return  None
+*/
+void  R_MEMORY_SECTION_GetMemory_RGA_WorkBuffer(
+    uint8_t **out_WorkBufferAddress,  size_t *out_WorkBufferSize,
+    uint8_t **out_WorkBufferB_Address,  size_t *out_WorkBufferB_Size )
+{
+    *out_WorkBufferAddress = gs_WorkBufferMemory;
+    *out_WorkBufferSize = sizeof( gs_WorkBufferMemory );
+    *out_WorkBufferB_Address = gs_WorkBufferB_Memory;
+    *out_WorkBufferB_Size = sizeof( gs_WorkBufferB_Memory );
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/porting/RGA_Callback_private.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,58 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2015 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  RGA_Callback_private.h
+* @brief   $Module: RGA $ $PublicVersion: 1.20 $ (=RGA_VERSION)
+* $Rev: $
+* $Date::                           $
+*/
+
+#include  "r_typedefs.h"
+#include  "RGA_Port_typedef.h"
+
+#ifdef  RZ_A1L  /* Reduce working buffer size for LibPNG */
+#define  WORK_SIZE_FOR_LIB_PNG   0x10000
+#endif
+
+enum {
+    MAX_WIDTH_OF_FRAME_BUFFER  = 800,
+    MAX_HEIGHT_OF_FRAME_BUFFER = 480,
+
+    WORK_BUFFER_SIZE = R_RGA_CalcWorkBufferSize2(
+                           MAX_WIDTH_OF_FRAME_BUFFER, MAX_HEIGHT_OF_FRAME_BUFFER ),
+
+#ifdef  WORK_SIZE_FOR_LIB_PNG
+    WORK_BUFFER_B_SIZE = R_RGA_CalcWorkBufferB_Size(
+                             MAX_WIDTH_OF_FRAME_BUFFER, MAX_HEIGHT_OF_FRAME_BUFFER, 4 ) +
+                         WORK_SIZE_FOR_LIB_PNG
+#else
+    WORK_BUFFER_B_SIZE = R_RGA_CalcWorkBufferB_Size(
+                             MAX_WIDTH_OF_FRAME_BUFFER, MAX_HEIGHT_OF_FRAME_BUFFER, 4 ) +
+                         RGA_MAX_WORK_SIZE_FOR_LIB_PNG_DEFAULT
+#endif
+};
+
+void  R_MEMORY_SECTION_GetMemory_RGA_WorkBuffer(
+    uint8_t **out_WorkBufferAddress,  size_t *out_WorkBufferSize,
+    uint8_t **out_WorkBufferB_Address,  size_t *out_WorkBufferB_Size );
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/porting/RGA_VRAM.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,74 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/*******************************************************************************
+* $FileName: RGA_VRAM.c $
+* $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 40 $
+* $Date:: 2013-12-18 20:02:45 +0900#$
+* Description : Sample functions
+*******************************************************************************/
+
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "Project_Config.h"
+#include  "r_typedefs.h"
+#include  "r_ospl.h"
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Imported global variables and functions (from other files)
+******************************************************************************/
+
+/******************************************************************************
+Exported global variables and functions (to be accessed by other files)
+******************************************************************************/
+
+/******************************************************************************
+Private global variables and functions
+******************************************************************************/
+
+#if ! IS_VDC_SAMPLE_VRAM_USED
+
+/* <MapSection attribute="Uncached"/> */
+R_OSPL_SECTION_FOR_ZERO_INIT( "VRAM",
+                              static uint8_t gs_FrameBufferMemory[ 0x00300000 ] );
+
+void  R_MEMORY_SECTION_GetMemory_ClibSamplesC( uint8_t **out_Address,  size_t *out_Size )
+{
+    *out_Address = gs_FrameBufferMemory;
+    *out_Size = sizeof( gs_FrameBufferMemory );
+}
+
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/porting/RGA_VRAM_EX.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  RGA_VRAM_EX.c
+* @brief   External VRAM Area
+*
+* $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 51 $
+* $Date:: 2014-03-14 18:42:33 +0900#$
+*/
+
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "Project_Config.h"
+#include  "r_typedefs.h"
+#include  "window_surfaces_private.h"
+#include  "r_ospl.h"
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Imported global variables and functions (from other files)
+******************************************************************************/
+
+/******************************************************************************
+Exported global variables and functions (to be accessed by other files)
+******************************************************************************/
+
+/******************************************************************************
+Private global variables and functions
+******************************************************************************/
+
+/** gs_VRAM_Ex */
+/* <MapSection attribute="SDRAM_Cached"/> */
+R_OSPL_ALIGNMENT( RGA_STACK_ADDRESS_ALIGNMENT,
+                  R_OSPL_SECTION_FOR_ZERO_INIT( "VRAM_EX",
+                          static uint8_t gs_VRAM_Ex[ 0x00500000 ] ));
+
+
+/**
+* @brief   R_EXRAM_GetBigMemory
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+errnum_t  R_EXRAM_GetBigMemory( void * /*<type**>*/ out_Address,  size_t *out_Size )
+{
+    *(void **) out_Address = gs_VRAM_Ex;
+    *out_Size = sizeof( gs_VRAM_Ex );
+    return  0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/porting/vsync_pl.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,412 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  vsync_pl.c
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 44 $
+* $Date:: 2013-12-20 11:20:00 +0900#$
+*/
+
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+*******************************************************************************/
+#include  "r_ospl.h"
+#include  "r_vdc5.h"
+#include  "vsync.h"
+#include  "vsync_pl.h"
+
+#if ! R_OSPL_IS_PREEMPTION
+#include  "dev_drv.h"
+#endif
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+typedef void (* gs_rtx_interrupt_t )(void);  /* RTX */
+typedef void (* gs_cint_interrupt_t )( uint32_t int_sense );  /* OS less INTC */
+typedef void (* gs_vdc_interrupt_t )( vdc5_int_type_t int_type );
+
+typedef struct st_r_v_sync_pl_channel_t  r_v_sync_pl_channel_t;
+struct st_r_v_sync_pl_channel_t {
+    const r_ospl_caller_t             *InterruptCallbackCaller;
+    bool_t                             IsVDC5_Callback;
+};
+
+static r_v_sync_pl_channel_t  gs_v_sync_pl_channel[ R_V_SYNC_CHANNEL_COUNT ];
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/**
+* @def  GS_VSYNC_INTERRUPT_PRIORITY
+* @brief  GS_VSYNC_INTERRUPT_PRIORITY
+* @par Parameters
+*    None
+* @return  None.
+*/
+enum { GS_VSYNC_INTERRUPT_PRIORITY = 7 };
+
+
+/**
+* @def  GS_INTERRUPT_FUNCTION_TYPE
+* @brief  GS_INTERRUPT_FUNCTION_TYPE
+* @par Parameters
+*    None
+* @return  None.
+*
+*    - 0 : RTX
+*    - 1 : INTC
+*/
+#if R_OSPL_IS_PREEMPTION
+#define  GS_INTERRUPT_FUNCTION_TYPE  0
+#else
+#define  GS_INTERRUPT_FUNCTION_TYPE  1
+#endif
+
+
+/**
+* @typedef  gs_interrupt_t
+* @brief  Interrupt callback function type
+*/
+#if  GS_INTERRUPT_FUNCTION_TYPE == 0
+#define  gs_interrupt_t  gs_rtx_interrupt_t
+#else
+#define  gs_interrupt_t  gs_cint_interrupt_t
+#endif
+
+
+/******************************************************************************
+Imported global variables and functions (from other files)
+******************************************************************************/
+
+/******************************************************************************
+Exported global variables and functions (to be accessed by other files)
+******************************************************************************/
+
+/******************************************************************************
+Private global variables and functions
+******************************************************************************/
+static void  R_V_SYNC_IRQ_HandlerN( int_fast32_t const  ChannelNum );
+static void  R_V_SYNC_IRQ_Handler0( vdc5_int_type_t const  int_type );
+static void  R_V_SYNC_IRQ_Handler1( vdc5_int_type_t const  int_type );
+#if  GS_INTERRUPT_FUNCTION_TYPE != 1
+static gs_cint_interrupt_t  gs_cint_vdc5_interrupt_handler[2];
+static void  R_V_SYNC_IRQ_HandlerRoot0(void);
+static void  R_V_SYNC_IRQ_HandlerRoot1(void);
+#endif
+
+
+/** Table of interrupt line to channel number */
+static const r_ospl_interrupt_t  gs_array_of_i_context[ R_V_SYNC_CHANNEL_COUNT ] = {
+    { BSP_INT_SRC_GR3_VLINE0,  0 },
+    { BSP_INT_SRC_GR3_VLINE1,  1 }
+};
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_SetDefaultAsync
+************************************************************************/
+void  R_V_SYNC_SetDefaultAsync( r_ospl_async_t *const  Async,  r_ospl_async_type_t AsyncType )
+{
+    R_UNREFERENCED_VARIABLE( AsyncType );
+
+    IF_DQ( Async == NULL ) {
+        goto fin;
+    }
+
+    if ( IS_BIT_NOT_SET( Async->Flags, R_F_OSPL_A_Thread ) ) {
+        Async->A_Thread = NULL;
+    }
+
+    if ( IS_BIT_NOT_SET( Async->Flags, R_F_OSPL_A_EventValue ) ) {
+        Async->A_EventValue = R_OSPL_A_FLAG;
+    }
+
+    if ( IS_BIT_NOT_SET( Async->Flags, R_F_OSPL_I_Thread ) ) {
+        Async->I_Thread = NULL;
+    }
+
+    if ( IS_BIT_NOT_SET( Async->Flags, R_F_OSPL_I_EventValue ) ) {
+        Async->I_EventValue = R_OSPL_I_FLAG;
+    }
+
+    if ( IS_BIT_NOT_SET( Async->Flags, R_F_OSPL_InterruptCallback ) ) {
+        Async->InterruptCallback = (r_ospl_callback_t)&( R_V_SYNC_OnInterruptDefault );
+    }
+    /* MISRA 16.9 */
+
+    Async->Flags = R_F_OSPL_A_Thread | R_F_OSPL_A_EventValue |
+                   R_F_OSPL_I_Thread | R_F_OSPL_I_EventValue |
+                   R_F_OSPL_InterruptCallback | R_F_OSPL_Delegate;
+
+fin:
+    return;
+}
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_OnInitialize
+************************************************************************/
+errnum_t  R_V_SYNC_OnInitialize( int_fast32_t const  ChannelNum )
+{
+#if GS_INTERRUPT_FUNCTION_TYPE == 1
+    bsp_int_cb_t    handler;
+#endif
+    errnum_t       e;
+    vdc5_error_t   er;
+    bsp_int_err_t  eb;
+    bsp_int_src_t  int_id;
+    vdc5_int_t     interrupt;
+    r_v_sync_pl_channel_t *const     self = &gs_v_sync_pl_channel[ ChannelNum ];
+    const r_ospl_interrupt_t *const  i_context = &gs_array_of_i_context[ ChannelNum ];
+
+    /*[gs_IRQHandlers]*/
+    static const gs_vdc_interrupt_t  gs_IRQHandlers[ R_V_SYNC_CHANNEL_COUNT ] = {
+        &( R_V_SYNC_IRQ_Handler0 ), /* MISRA 16.9 */
+        &( R_V_SYNC_IRQ_Handler1 )
+    };
+
+#if  GS_INTERRUPT_FUNCTION_TYPE != 1
+    /*[gs_IRQHandlerRoots]*/
+    static const gs_interrupt_t  gs_IRQHandlerRoots[ R_V_SYNC_CHANNEL_COUNT ] = {
+        &( R_V_SYNC_IRQ_HandlerRoot0 ), /* MISRA 16.9 */
+        &( R_V_SYNC_IRQ_HandlerRoot1 )
+    };
+#endif
+
+
+    IF ( (ChannelNum < 0) || (ChannelNum >= R_V_SYNC_CHANNEL_COUNT) ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    self->InterruptCallbackCaller = NULL;
+
+    int_id  = i_context->IRQ_Num;
+#if GS_INTERRUPT_FUNCTION_TYPE == 1
+    handler = R_VDC5_GetISR( (vdc5_channel_t) ChannelNum, VDC5_INT_TYPE_VLINE );
+    eb= R_BSP_InterruptWrite( int_id, handler );
+#else
+    gs_cint_vdc5_interrupt_handler[ChannelNum] = R_VDC5_GetISR(
+                (vdc5_channel_t) ChannelNum, VDC5_INT_TYPE_VLINE );
+    eb= R_BSP_InterruptWrite( int_id, gs_IRQHandlerRoots[ChannelNum] );
+#endif
+    IF ( eb != BSP_INT_SUCCESS ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    e= R_OSPL_SetInterruptPriority( int_id, GS_VSYNC_INTERRUPT_PRIORITY );
+    IF ( e != 0 ) {
+        goto fin;
+    }
+
+    interrupt.type     = VDC5_INT_TYPE_VLINE;
+    interrupt.callback = gs_IRQHandlers[ ChannelNum ];
+    interrupt.line_num = (uint16_t) 0;
+
+    er = R_VDC5_CallbackISR( (vdc5_channel_t) ChannelNum, &interrupt );
+    IF ( er != VDC5_OK ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    self->IsVDC5_Callback = true;
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_OnFinalize
+************************************************************************/
+errnum_t  R_V_SYNC_OnFinalize( int_fast32_t const  ChannelNum,  errnum_t e )
+{
+    r_v_sync_pl_channel_t *const  self = &gs_v_sync_pl_channel[ ChannelNum ];
+
+    if ( (ChannelNum >= 0) && (ChannelNum < R_V_SYNC_CHANNEL_COUNT) ) {
+        if ( IS( self->IsVDC5_Callback ) ) {
+            vdc5_error_t  er;
+            vdc5_int_t    interrupt;
+
+            interrupt.type     = VDC5_INT_TYPE_VLINE;
+            interrupt.callback = NULL;
+            interrupt.line_num = (uint16_t) 0;
+
+            er = R_VDC5_CallbackISR( (vdc5_channel_t) ChannelNum, &interrupt );
+            IF ( (er != VDC5_OK) && (e == 0) ) {
+                e=E_OTHERS;
+            }
+
+            self->IsVDC5_Callback = false;
+        }
+    }
+
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_SetInterruptCallbackCaller
+************************************************************************/
+errnum_t  R_V_SYNC_SetInterruptCallbackCaller( int_fast32_t const  ChannelNum,
+        const r_ospl_caller_t *const  Caller )
+{
+    r_v_sync_pl_channel_t *const  self = &gs_v_sync_pl_channel[ ChannelNum ];
+
+    self->InterruptCallbackCaller = Caller;
+
+    return  0;
+}
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_OnEnableInterrupt
+************************************************************************/
+void  R_V_SYNC_OnEnableInterrupt( int_fast32_t const  ChannelNum,
+                                  r_v_sync_interrupt_lines_t const  Enables )
+{
+    bsp_int_err_t  eb;
+
+    if ( IS_BIT_SET( Enables, R_V_SYNC_INTERRUPT_LINE_V_LINE ) ) {
+        bsp_int_src_t const  num_of_IRQ = gs_array_of_i_context[ ChannelNum ].IRQ_Num;
+
+        eb= R_BSP_InterruptControl( num_of_IRQ, BSP_INT_CMD_INTERRUPT_ENABLE, FIT_NO_PTR );
+        ASSERT_D( eb == 0,  R_NOOP() );
+        R_UNREFERENCED_VARIABLE( eb ); /* for Release configuration */
+    }
+}
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_OnDisableInterrupt
+************************************************************************/
+void  R_V_SYNC_OnDisableInterrupt( int_fast32_t const  ChannelNum,
+                                   r_v_sync_interrupt_lines_t const  Disables1 )
+{
+    bsp_int_err_t  eb;
+
+    if ( IS_BIT_SET( Disables1, R_V_SYNC_INTERRUPT_LINE_V_LINE ) ) {
+        bsp_int_src_t const  num_of_IRQ = gs_array_of_i_context[ ChannelNum ].IRQ_Num;
+
+        eb= R_BSP_InterruptControl( num_of_IRQ, BSP_INT_CMD_INTERRUPT_DISABLE, FIT_NO_PTR );
+        ASSERT_D( eb == 0,  R_NOOP() );
+        R_UNREFERENCED_VARIABLE( eb ); /* for Release configuration */
+    }
+}
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_OnInterruptDefault
+************************************************************************/
+errnum_t  R_V_SYNC_OnInterruptDefault( const r_ospl_interrupt_t *const  InterruptSource,
+                                       const r_ospl_caller_t *const  Caller )
+{
+    R_UNREFERENCED_VARIABLE( Caller );
+
+    return  R_V_SYNC_OnInterrupting( InterruptSource );
+}
+
+
+/**
+* @brief   Interrupt service routine for all channels
+*
+* @param   ChannelNum ChannelNum
+* @return  None
+*/
+static void  R_V_SYNC_IRQ_HandlerN( int_fast32_t const  ChannelNum )
+{
+    r_v_sync_pl_channel_t *const     self = &gs_v_sync_pl_channel[ ChannelNum ];
+    const r_ospl_interrupt_t *const  i_context = &gs_array_of_i_context[ ChannelNum ];
+
+    /* V-Sync interrupt always be enabled. Because clear interrupt status */
+
+    if ( self->InterruptCallbackCaller != NULL ) {
+        R_OSPL_CallInterruptCallback( self->InterruptCallbackCaller, i_context );
+    }
+}
+
+
+/**
+* @brief   Interrupt service routine for INTC channel 0
+*
+* @param   int_type ignored
+* @return  None
+*/
+static void  R_V_SYNC_IRQ_Handler0( vdc5_int_type_t const  int_type )
+{
+    R_UNREFERENCED_VARIABLE( int_type );
+    R_V_SYNC_IRQ_HandlerN( 0 );
+}
+
+
+/**
+* @brief   Interrupt service routine for INTC channel 1
+*
+* @param   int_type ignored
+* @return  None
+*/
+static void  R_V_SYNC_IRQ_Handler1( vdc5_int_type_t const  int_type )
+{
+    R_UNREFERENCED_VARIABLE( int_type );
+    R_V_SYNC_IRQ_HandlerN( 1 );
+}
+
+
+/**
+* @brief   Interrupt service routine for RTX channel 0
+*
+* @par Parameters
+*    None
+* @return  None
+*/
+#if GS_INTERRUPT_FUNCTION_TYPE != 1
+static void  R_V_SYNC_IRQ_HandlerRoot0(void)
+{
+    gs_cint_vdc5_interrupt_handler[0]( 0 );
+    GIC_EndInterrupt( BSP_INT_SRC_GR3_VLINE0 );
+}
+#endif
+
+
+/**
+* @brief   Interrupt service routine for RTX channel 1
+*
+* @par Parameters
+*    None
+* @return  None
+*/
+#if GS_INTERRUPT_FUNCTION_TYPE != 1
+static void  R_V_SYNC_IRQ_HandlerRoot1(void)
+{
+    gs_cint_vdc5_interrupt_handler[1]( 0 );
+    GIC_EndInterrupt( BSP_INT_SRC_GR3_VLINE0 );
+}
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/src/video_input.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,905 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2014 - 2015 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  video_input.c
+* @brief   $Rev: 51 $
+* $Date:: 2014-03-14 18:42:33 +0900#$
+*/
+
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+*******************************************************************************/
+#include  "r_typedefs.h"
+#include  "r_ospl.h"
+#include  "video_input.h"
+#include  "video_decoder.h"
+#include  "window_surfaces_typedef.h"  /* WINDOW_SURFACES_DEFAULT_CHANNEL */
+#ifndef R_OSPL_NDEBUG
+#include  <stdio.h>
+#endif
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/**
+* @typedef  video_input_vdc5_layer_t
+* @brief  video_input_vdc5_layer_t
+*/
+typedef struct st_video_input_vdc5_layer_t  video_input_vdc5_layer_t;
+struct st_video_input_vdc5_layer_t {
+    bool_t                is_data_control;
+    vdc5_layer_id_t       data_control_ID;
+};
+
+
+/**
+* @typedef  vdc5_int_cb_t
+* @brief  vdc5_int_cb_t
+*/
+typedef  void (* vdc5_int_cb_t )( const uint32_t );
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+#define VSYNC_1_2_FH_TIMING  (858u) /* Vsync signal 1/2fH phase timing */
+#define VSYNC_1_4_FH_TIMING  (429u) /* Vsync signal 1/4fH phase timing */
+
+#define     IMGCAP_SIZE_NTSC_HS         (122u * 2u)
+#define     IMGCAP_SIZE_NTSC_HW         (720u * 2u)
+#define     IMGCAP_SIZE_NTSC_VS         (16u)
+#define     IMGCAP_SIZE_NTSC_VW         (480u/2u)
+
+#define     IMGCAP_SIZE_PAL_HS          (132u * 2u)
+#define     IMGCAP_SIZE_PAL_HW          (720u * 2u)
+#define     IMGCAP_SIZE_PAL_VS          (19u)
+#define     IMGCAP_SIZE_PAL_VW          (560u/2u)
+
+#define     VIDEO_FORMAT                (VDC5_RES_MD_YCBCR422)
+
+
+/******************************************************************************
+Imported global variables and functions (from other files)
+******************************************************************************/
+
+/******************************************************************************
+Exported global variables and functions (to be accessed by other files)
+******************************************************************************/
+
+/******************************************************************************
+Private global variables and functions
+******************************************************************************/
+
+static void  R_VIDEO_INPUT_OnVideoInVSync( vdc5_channel_t  video_input_channel,  vdc5_int_type_t int_type );
+static void  R_VIDEO_INPUT_OnVideoInVSync_Ch0( vdc5_int_type_t int_type );
+static void  R_VIDEO_INPUT_OnVideoInVSync_Ch1( vdc5_int_type_t int_type );
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+static void  InterruptCallbackVector_S0_VI_VSYNC0(void);
+static void  InterruptCallbackVector_S0_VI_VSYNC1(void);
+static void  InterruptCallbackVector_S1_VI_VSYNC0(void);
+static void  InterruptCallbackVector_S1_VI_VSYNC1(void);
+vdc5_int_cb_t  gs_VDC5_ISR_S0_VI_VSYNC0;
+vdc5_int_cb_t  gs_VDC5_ISR_S0_VI_VSYNC1;
+vdc5_int_cb_t  gs_VDC5_ISR_S1_VI_VSYNC0;
+vdc5_int_cb_t  gs_VDC5_ISR_S1_VI_VSYNC1;
+#endif
+
+static video_input_t  *gs_InterruptToSelf[ 2 /* video_input_channel */ ][ 2 /* data_control_ID */ ];
+
+static errnum_t  R_VIDEO_INPUT_STATIC_AttachSelfToInterrupt(
+    vdc5_channel_t  in_video_input_channel,  vdc5_layer_id_t  in_data_control_ID,
+    video_input_t  *in_self );
+static errnum_t  R_VIDEO_INPUT_STATIC_DetachSelfFromInterrupt(
+    vdc5_channel_t  in_video_input_channel,  vdc5_layer_id_t  in_data_control_ID,
+    video_input_t  *in_self );
+static errnum_t  R_VIDEO_INPUT_STATIC_GetSelfPointer(
+    vdc5_channel_t  in_video_input_channel,  vdc5_layer_id_t  in_data_control_ID,
+    video_input_t ***  out_self_pp );
+static errnum_t  R_VIDEO_INPUT_STATIC_GetSelfFromInterrupt(
+    vdc5_channel_t  in_video_input_channel,  vdc5_int_type_t  in_interrupt,
+    video_input_t  **out_self );
+
+
+/**
+* @brief   Initializes by constant data.
+*
+* @param   self video_input_t.
+* @return  None.
+*/
+void  R_VIDEO_INPUT_InitConst( video_input_t *const  self )
+{
+    self->is_data_control = false;
+    self->is_vsync_interrupt_registered[0] = false;
+    self->is_vsync_interrupt_registered[1] = false;
+    self->is_vsync_interrupt_registered[2] = false;
+}
+
+
+/***********************************************************************
+* Implement: R_VIDEO_INPUT_Initialize
+************************************************************************/
+errnum_t  R_VIDEO_INPUT_Initialize( video_input_t *const  self,
+                                    video_input_config_t *in_out_Config )
+{
+    errnum_t         e;
+    vdc5_error_t     e_vdc5;
+#ifdef  IS_MBED_USED
+    vdec_error_t     e_vdec;
+#endif
+    vdc5_write_t     writing_config;
+    frame_buffer_t  *frame;
+    uintptr_t        frame_physical_address[ R_COUNT_OF( frame->buffer_address ) ];
+
+
+    /* Initialize by constant */
+    ASSERT_R( ! self->is_data_control,  e=E_STATE; goto fin );
+    ASSERT_R( ! self->is_vsync_interrupt_registered[0],  e=E_STATE; goto fin );
+    ASSERT_R( ! self->is_vsync_interrupt_registered[1],  e=E_STATE; goto fin );
+    ASSERT_R( ! self->is_vsync_interrupt_registered[2],  e=E_STATE; goto fin );
+    self->captured_count = 0;
+
+
+    /* Check necessary flags */
+    {
+        enum { necessary_flags =
+                   VIDEO_INPUT_CONFIG_T_FRAME_BUFFER
+             };
+
+        ASSERT_R( IS_ALL_BITS_SET( in_out_Config->flags, necessary_flags ),
+                  e=E_OTHERS; goto fin );
+    }
+
+
+    /* Set "frame" */
+    {
+        int_fast32_t  i;
+
+        frame = in_out_Config->frame_buffer;
+        ASSERT_R( frame->buffer_count == 2,  e=E_OTHERS; goto fin );
+        self->frame_buffer = *frame;
+
+        for ( i = 0;  i < frame->buffer_count;  i += 1 ) {
+            e= R_OSPL_ToPhysicalAddress( frame->buffer_address[ i ],
+                                         &frame_physical_address[ i ] );
+            IF(e!=0) {
+                goto fin;
+            }
+        }
+    }
+
+
+    /* Set default "in_out_Config->video_input_channel_num" */
+    if ( IS_BIT_NOT_SET( in_out_Config->flags, VIDEO_INPUT_CONFIG_T_VIDEO_INPUT_CHANNEL_NUM ) ) {
+        in_out_Config->video_input_channel_num = WINDOW_SURFACES_DEFAULT_CHANNEL;
+    }
+
+
+    /* Set from "in_out_Config->video_input_channel_num" */
+    switch ( in_out_Config->video_input_channel_num ) {
+        case  0:
+            self->video_input_channel = VDC5_CHANNEL_0;
+            self->video_input_select = VDEC_ADC_VINSEL_VIN1;
+            break;
+        case  1:
+            self->video_input_channel = VDC5_CHANNEL_1;
+            self->video_input_select = VDEC_ADC_VINSEL_VIN1;
+            break;
+        case  2:
+            self->video_input_channel = VDC5_CHANNEL_0;
+            self->video_input_select = VDEC_ADC_VINSEL_VIN2;
+            break;
+        case  3:
+            self->video_input_channel = VDC5_CHANNEL_1;
+            self->video_input_select = VDEC_ADC_VINSEL_VIN2;
+            break;
+        default:
+            ASSERT_R( false,  e=E_OTHERS; goto fin );
+    }
+
+
+    /* Set default "in_out_Config->display_channel_num" */
+    if ( IS_BIT_NOT_SET( in_out_Config->flags, VIDEO_INPUT_CONFIG_T_DISPLAY_CHANNEL_NUM ) ) {
+        if ( IS_BIT_NOT_SET( in_out_Config->flags, VIDEO_INPUT_CONFIG_T_DISPLAY_LAYER_NUM ) ) {
+            in_out_Config->display_channel_num = VIDEO_INPUT_NOT_DISPLAY;
+        } else {
+            in_out_Config->display_channel_num = WINDOW_SURFACES_DEFAULT_CHANNEL;
+        }
+    }
+
+
+    /* Set default "in_out_Config->display_layer_num" */
+    if ( IS_BIT_NOT_SET( in_out_Config->flags, VIDEO_INPUT_CONFIG_T_DISPLAY_LAYER_NUM ) ) {
+        if ( in_out_Config->display_channel_num == VIDEO_INPUT_NOT_DISPLAY ) {
+            in_out_Config->display_layer_num = VIDEO_INPUT_NOT_DISPLAY;
+        } else {
+            in_out_Config->display_layer_num = -1;
+        }
+    }
+    ASSERT_D( in_out_Config->display_layer_num == VIDEO_INPUT_NOT_DISPLAY  ||
+              in_out_Config->display_layer_num <= -1,  e=E_OTHERS; goto fin );
+    ASSERT_D(
+        ( in_out_Config->display_channel_num == VIDEO_INPUT_NOT_DISPLAY  &&
+          in_out_Config->display_layer_num   == VIDEO_INPUT_NOT_DISPLAY ) ||
+        ( in_out_Config->display_channel_num != VIDEO_INPUT_NOT_DISPLAY  &&
+          in_out_Config->display_layer_num   != VIDEO_INPUT_NOT_DISPLAY ),
+        e=E_OTHERS; goto fin );
+
+
+    /* Set "self->data_control_ID" : No care of "display_layer_num" */
+    if ( in_out_Config->display_channel_num == 0 ) {
+        if ( self->video_input_channel == 0 ) {
+            self->data_control_ID = VDC5_LAYER_ID_0_WR;
+        } else {
+            self->data_control_ID = VDC5_LAYER_ID_1_WR;
+        }
+    } else if ( in_out_Config->display_channel_num == 1 ) {
+        if ( self->video_input_channel == 0 ) {
+            self->data_control_ID = VDC5_LAYER_ID_1_WR;
+        } else {
+            self->data_control_ID = VDC5_LAYER_ID_0_WR;
+        }
+    } else {
+        ASSERT_D( in_out_Config->display_channel_num == VIDEO_INPUT_NOT_DISPLAY,
+                  e=E_OTHERS; goto fin );
+
+        self->data_control_ID = VDC5_LAYER_ID_0_WR;
+    }
+
+
+    /* Set "self->captured_async" */
+    self->captured_async = NULL;
+    if ( IS_BIT_SET( in_out_Config->flags, VIDEO_INPUT_CONFIG_T_CAPTURED_ASYNC ) ) {
+        self->captured_async = in_out_Config->captured_async;
+    }
+
+
+    /* From GRPDRV_Init() */
+    {
+        vdc5_input_t      input;
+
+        /* Input parameter */
+        input.inp_sel   = VDC5_INPUT_SEL_VDEC;           /* Input select */
+        input.inp_fh50  = (uint16_t)VSYNC_1_2_FH_TIMING; /* Vsync signal 1/2fH phase timing */
+        input.inp_fh25  = (uint16_t)VSYNC_1_4_FH_TIMING; /* Vsync signal 1/4fH phase timing */
+        input.dly       = NULL;                          /* Sync signal delay adjustment */
+        input.ext_sig   = NULL;                          /* External input signal */
+        e_vdc5 = R_VDC5_VideoInput( self->video_input_channel, &input );
+        IF ( e_vdc5 != VDC5_OK ) {
+            e=E_OTHERS;
+            goto fin;
+        }
+    }
+
+
+    /* ... */
+    {
+        vdec_channel_t           vdec_channel;  /* video decoder channel */
+#ifdef  IS_MBED_USED
+        graphics_col_sys_t       color_system = GRPH_COL_SYS_NTSC_358;
+#else
+        graphics_col_sys_t       color_system;
+#endif
+        vdc5_scalingdown_rot_t  *writing_scale = &writing_config.scalingdown_rot;
+
+
+        /* From SetVideoDecoder() */
+
+        if ( self->video_input_channel == VDC5_CHANNEL_0 ) {
+            vdec_channel = VDEC_CHANNEL_0;
+        } else {
+            ASSERT_R( self->video_input_channel == VDC5_CHANNEL_1,  e=E_OTHERS; goto fin );
+            vdec_channel = VDEC_CHANNEL_1;
+        }
+#ifdef  IS_MBED_USED
+        e_vdec = GRAPHICS_VideoDecoderInit( self->video_input_select, vdec_channel, color_system );
+        IF ( e_vdec != VDEC_OK ) {
+            e=E_OTHERS;
+            goto fin;
+        }
+#else
+        color_system = GRAPHICS_VideoDecoderInit( self->video_input_select, vdec_channel );
+        if ( color_system == GRPH_COL_SYS_UNKNOWN ) {
+            color_system = GRPH_COL_SYS_NTSC_358;
+        }
+#endif
+
+
+        /* From GRPDRV_VideoCreateNonDispSurface() */
+
+        /* Image area to be captured */
+#if  VIDEO_FORMAT_TYPE == VIDEO_FORMAT_TYPE_NTSC
+        ASSERT_R( (color_system == GRPH_COL_SYS_NTSC_358) ||
+                  (color_system == GRPH_COL_SYS_NTSC_443),
+                  e=E_OTHERS; goto fin );
+
+        writing_scale->res.vs = (uint16_t)( IMGCAP_SIZE_NTSC_VS - 1 );
+        writing_scale->res.vw = (uint16_t)IMGCAP_SIZE_NTSC_VW;
+        writing_scale->res.hs = (uint16_t)IMGCAP_SIZE_NTSC_HS;
+        writing_scale->res.hw = (uint16_t)IMGCAP_SIZE_NTSC_HW;
+        /* v = vertical, h = horizontal, s = start, w = width */
+#elif  VIDEO_FORMAT_TYPE == VIDEO_FORMAT_TYPE_PAL
+        ASSERT_R( (color_system != GRPH_COL_SYS_NTSC_358) &&
+                  (color_system != GRPH_COL_SYS_NTSC_443),
+                  e=E_OTHERS; goto fin );
+
+        writing_scale->res.vs = (uint16_t)( IMGCAP_SIZE_PAL_VS - 1 );
+        writing_scale->res.vw = (uint16_t)IMGCAP_SIZE_PAL_VW;
+        writing_scale->res.hs = (uint16_t)IMGCAP_SIZE_PAL_HS;
+        writing_scale->res.hw = (uint16_t)IMGCAP_SIZE_PAL_HW;
+#else
+#error
+#endif
+
+
+        /* Write data parameter */
+        writing_scale->res_pfil_sel = VDC5_ON;
+        /* Prefilter mode select for brightness signals (on/off) */
+
+        writing_scale->res_out_vw   = frame->height / 2;
+        /* Number of valid lines in vertical direction */
+        /* output by scaling-down control block */
+
+        writing_scale->res_out_hw   = frame->width;
+        /* Number of valid horizontal pixels */
+        /* output by scaling-down control block */
+
+        writing_scale->adj_sel      = VDC5_ON;
+        /* Measures to decrease the influence */
+        /* by lack of last-input line (on/off) */
+
+        writing_scale->res_ds_wr_md = VDC5_WR_MD_NORMAL;
+        /* Frame buffer writing mode */
+    }
+
+
+    /* From GRPDRV_VideoCreateNonDispSurface() */
+    {
+        writing_config.res_wrswa     = VDC5_WR_RD_WRSWA_16BIT;
+        /* Frame buffer swap setting */
+
+        writing_config.res_md        = VIDEO_FORMAT;
+        /* Frame buffer video-signal writing format */
+
+        writing_config.res_bst_md    = VDC5_BST_MD_32BYTE;
+        /* Transfer burst length for frame buffer */
+
+        writing_config.res_inter     = VDC5_RES_INTER_INTERLACE;
+        /* Field operating mode select */
+
+        writing_config.res_fs_rate   = VDC5_RES_FS_RATE_PER1;
+        /* Writing rate */
+
+        writing_config.res_fld_sel   = VDC5_RES_FLD_SEL_TOP;
+        /* Write field select */
+
+        writing_config.res_dth_on    = VDC5_ON;
+        /* Dither correction on/off */
+
+        writing_config.base          = (void *) frame_physical_address[0];
+        /* Frame buffer base address */
+
+        writing_config.ln_off        = frame->stride;
+        /* Frame buffer line offset address [byte] */
+
+        writing_config.flm_num       = (uint32_t)( frame->buffer_count - 1u );
+        /* Number of frames of buffer (res_flm_num + 1) */
+
+        writing_config.flm_off       = frame_physical_address[1] - frame_physical_address[0];
+
+        writing_config.btm_base      = NULL;
+        /* Frame buffer base address for bottom */
+
+
+        e_vdc5 = R_VDC5_WriteDataControl( self->video_input_channel,
+                                          self->data_control_ID,  &writing_config );
+        IF ( e_vdc5 != VDC5_OK ) {
+            e=E_OTHERS;
+            goto fin;
+        }
+
+        self->is_data_control = true;
+    }
+
+
+    {
+        vdc5_start_t  start;
+
+        e_vdc5 = R_VDC5_StartProcess( self->video_input_channel, self->data_control_ID, &start );
+        IF ( e_vdc5 != VDC5_OK ) {
+            e = E_OTHERS;
+            goto fin;
+        }
+
+        /* This module does not call "R_VDC5_StartProcess" function for reading (showing). */
+    }
+
+
+    {
+        vdc5_int_t     *config = &self->interrupt_for_VDC5;
+        bsp_int_err_t   ret_b;
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+        vdc5_int_cb_t  *p_VDC5_ISR;
+#endif
+
+        e= R_VIDEO_INPUT_STATIC_AttachSelfToInterrupt(
+               self->video_input_channel, self->data_control_ID, self );
+        IF(e) {
+            goto fin;
+        }
+
+        self->is_vsync_interrupt_registered[2] = true;
+
+
+        if ( self->data_control_ID == VDC5_LAYER_ID_0_WR ) {
+            config->type = VDC5_INT_TYPE_S0_VI_VSYNC;
+        } else {
+            config->type = VDC5_INT_TYPE_S1_VI_VSYNC;
+        }
+        if ( self->video_input_channel == 0 ) {
+            config->callback = R_VIDEO_INPUT_OnVideoInVSync_Ch0;
+
+            if ( self->data_control_ID == VDC5_LAYER_ID_0_WR ) {
+                self->interrupt_ID = BSP_INT_SRC_S0_VI_VSYNC0;
+
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+                p_VDC5_ISR = &gs_VDC5_ISR_S0_VI_VSYNC0;
+                self->interrupt_vector = InterruptCallbackVector_S0_VI_VSYNC0;
+#endif
+            } else {
+                self->interrupt_ID = BSP_INT_SRC_S1_VI_VSYNC0;
+
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+                p_VDC5_ISR = &gs_VDC5_ISR_S1_VI_VSYNC0;
+                self->interrupt_vector = InterruptCallbackVector_S1_VI_VSYNC0;
+#endif
+            }
+        } else {
+            config->callback = R_VIDEO_INPUT_OnVideoInVSync_Ch1;
+
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+            if ( self->data_control_ID == VDC5_LAYER_ID_0_WR ) {
+                self->interrupt_ID = BSP_INT_SRC_S0_VI_VSYNC1;
+
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+                p_VDC5_ISR = &gs_VDC5_ISR_S0_VI_VSYNC1;
+                self->interrupt_vector = InterruptCallbackVector_S0_VI_VSYNC1;
+#endif
+            } else {
+                self->interrupt_ID = BSP_INT_SRC_S1_VI_VSYNC1;
+
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+                p_VDC5_ISR = &gs_VDC5_ISR_S1_VI_VSYNC1;
+                self->interrupt_vector = InterruptCallbackVector_S1_VI_VSYNC1;
+#endif
+            }
+#endif
+        }
+        config->line_num = 0;
+
+        e_vdc5 = R_VDC5_CallbackISR( self->video_input_channel, config );
+        IF ( e_vdc5 != VDC5_OK ) {
+            e=E_OTHERS;
+            goto fin;
+        }
+
+        self->is_vsync_interrupt_registered[1] = true;
+
+
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_LESS
+        {
+            vdc5_int_cb_t  a_VDC5_ISR;
+
+            a_VDC5_ISR = R_VDC5_GetISR( self->video_input_channel, config->type );
+            ret_b = R_BSP_InterruptWrite( self->interrupt_ID, a_VDC5_ISR );
+            IF ( ret_b != BSP_INT_SUCCESS ) {
+                e=E_OTHERS;
+                goto fin;
+            }
+        }
+#else
+        *p_VDC5_ISR = R_VDC5_GetISR( self->video_input_channel, config->type );
+        ret_b = R_BSP_InterruptWrite( self->interrupt_ID, self->interrupt_vector );
+        IF ( ret_b != BSP_INT_SUCCESS ) {
+            e=E_OTHERS;
+            goto fin;
+        }
+#endif
+
+        self->is_vsync_interrupt_registered[0] = true;
+    }
+
+
+#ifndef R_OSPL_NDEBUG
+    printf( "VideoInput %dx%dx%dx%d stride=%d \n address[0]=0x%08X address[1]=0x%08X\n",
+            frame->buffer_count, frame->width, frame->height, frame->byte_per_pixel,
+            frame->stride,
+            (uintptr_t) frame->buffer_address[0],
+            (uintptr_t) frame->buffer_address[1] );
+    /* Cast of "uintptr_t" is for avoiding "format" warning of GNU_ARM */
+#endif
+
+
+    e=0;
+fin:
+    if ( e != 0 ) {
+        e= R_VIDEO_INPUT_Finalize( self, e );
+    }
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_VIDEO_INPUT_Finalize
+************************************************************************/
+errnum_t  R_VIDEO_INPUT_Finalize( video_input_t *const  self, errnum_t e )
+{
+    errnum_t       ee;
+    vdc5_error_t   e_vdc5;
+    bsp_int_err_t  ret_b;
+
+    if ( self->is_vsync_interrupt_registered[0] ) {
+        ret_b = R_BSP_InterruptWrite( self->interrupt_ID, FIT_NO_FUNC );
+        IF ( ret_b != BSP_INT_SUCCESS ) {
+            e= R_OSPL_MergeErrNum( e, E_OTHERS );
+        }
+
+        self->is_vsync_interrupt_registered[0] = false;
+    }
+
+
+    if ( self->is_vsync_interrupt_registered[1] ) {
+        vdc5_int_t  *config = &self->interrupt_for_VDC5;
+
+        config->callback = NULL;
+        config->line_num = 0;
+
+        e_vdc5 = R_VDC5_CallbackISR( self->video_input_channel, config );
+        IF ( e_vdc5 != VDC5_OK ) {
+            e= R_OSPL_MergeErrNum( e, E_OTHERS );
+        }
+
+        config->type = VDC5_INT_TYPE_NUM;  /* Not Used interrupt type */
+
+        self->is_vsync_interrupt_registered[1] = false;
+    }
+
+
+    if ( self->is_vsync_interrupt_registered[2] ) {
+        ee= R_VIDEO_INPUT_STATIC_DetachSelfFromInterrupt(
+                self->video_input_channel, self->data_control_ID, self );
+        e= R_OSPL_MergeErrNum( e, ee );
+
+        self->is_vsync_interrupt_registered[2] = false;
+    }
+
+
+    if ( self->is_data_control ) {
+        e_vdc5 = R_VDC5_StopProcess( self->video_input_channel,
+                                     self->data_control_ID );
+        IF ( e_vdc5 != VDC5_OK ) {
+            e= R_OSPL_MergeErrNum( e, E_OTHERS );
+        }
+
+        e_vdc5 = R_VDC5_ReleaseDataControl( self->video_input_channel,
+                                            self->data_control_ID );
+        IF ( e_vdc5 != VDC5_OK ) {
+            e= R_OSPL_MergeErrNum( e, E_OTHERS );
+        }
+
+        self->is_data_control = false;
+    }
+
+    return  e;
+}
+
+
+/**
+* @brief   Video input V-Sync interrupt handler.
+*
+* @param   channel_num channel_num.
+* @param   int_type vdc5_int_type_t.
+* @return  None.
+*/
+static void  R_VIDEO_INPUT_OnVideoInVSync( vdc5_channel_t  video_input_channel,  vdc5_int_type_t int_type )
+{
+    errnum_t        e;
+    video_input_t  *self = NULL;
+    /* NULL is for avoiding warning C4017W of mbed cloud compiler */
+
+    e= R_VIDEO_INPUT_STATIC_GetSelfFromInterrupt( video_input_channel,  int_type,  &self );
+    IF(e) {
+        R_NOOP();
+    }
+    else if (
+        int_type == VDC5_INT_TYPE_S0_VI_VSYNC  ||
+        int_type == VDC5_INT_TYPE_S1_VI_VSYNC  ||
+        int_type == VDC5_INT_TYPE_S0_WLINE  ||
+        int_type == VDC5_INT_TYPE_S1_WLINE ) {
+        if ( IS_BIT_SET( VDC51.SC0_SCL1_WR7, 0x00000001u ) ) {
+            self->captured_buffer_index = 0;
+        } else {
+            self->captured_buffer_index = 1;
+        }
+
+        self->captured_count += 1;
+
+        if ( self->captured_async != NULL ) {
+            R_OSPL_EVENT_Set(
+                self->captured_async->A_Thread,
+                self->captured_async->A_EventValue );
+        }
+    }
+
+    R_DEBUG_BREAK_IF_ERROR();
+}
+
+
+/**
+* @brief   R_VIDEO_INPUT_OnVideoInVSync_Ch0
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+static void  R_VIDEO_INPUT_OnVideoInVSync_Ch0( vdc5_int_type_t int_type )
+{
+    R_VIDEO_INPUT_OnVideoInVSync( VDC5_CHANNEL_0, int_type );
+}
+
+
+/**
+* @brief   R_VIDEO_INPUT_OnVideoInVSync_Ch1
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+static void  R_VIDEO_INPUT_OnVideoInVSync_Ch1( vdc5_int_type_t int_type )
+{
+    R_VIDEO_INPUT_OnVideoInVSync( VDC5_CHANNEL_1, int_type );
+}
+
+
+/**
+* @brief   InterruptCallbackVector_S0_VI_VSYNC0
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+static void  InterruptCallbackVector_S0_VI_VSYNC0(void)
+{
+    gs_VDC5_ISR_S0_VI_VSYNC0(0);
+    GIC_EndInterrupt( BSP_INT_SRC_S0_VI_VSYNC0 );
+}
+#endif
+
+
+/**
+* @brief   InterruptCallbackVector_S0_VI_VSYNC1
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+static void  InterruptCallbackVector_S0_VI_VSYNC1(void)
+{
+    gs_VDC5_ISR_S0_VI_VSYNC1(0);
+    GIC_EndInterrupt( BSP_INT_SRC_S0_VI_VSYNC1 );
+}
+#endif
+
+
+/**
+* @brief   InterruptCallbackVector_S1_VI_VSYNC0
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+static void  InterruptCallbackVector_S1_VI_VSYNC0(void)
+{
+    gs_VDC5_ISR_S1_VI_VSYNC0(0);
+    GIC_EndInterrupt( BSP_INT_SRC_S1_VI_VSYNC0 );
+}
+#endif
+
+
+/**
+* @brief   InterruptCallbackVector_S1_VI_VSYNC1
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+#if INTERRUPT_FUNCTION_TYPE == INTERRUPT_FUNCTION_TYPE_OS_RTX
+static void  InterruptCallbackVector_S1_VI_VSYNC1(void)
+{
+    gs_VDC5_ISR_S1_VI_VSYNC1(0);
+    GIC_EndInterrupt( BSP_INT_SRC_S1_VI_VSYNC1 );
+}
+#endif
+
+
+/**
+* @brief   R_VIDEO_INPUT_STATIC_AttachSelfToInterrupt
+*
+* @param   in_video_input_channel vdc5_channel_t.
+* @param   in_data_control_ID vdc5_layer_id_t.
+* @param   in_self video_input_t*
+* @return  Error Code. 0=No Error.
+*/
+static errnum_t  R_VIDEO_INPUT_STATIC_AttachSelfToInterrupt(
+    vdc5_channel_t  in_video_input_channel,  vdc5_layer_id_t  in_data_control_ID,
+    video_input_t  *in_self )
+{
+    errnum_t         e;
+    video_input_t  **self_pp = NULL;
+    /* NULL is for avoiding warning C4017W of mbed cloud compiler */
+
+    e= R_VIDEO_INPUT_STATIC_GetSelfPointer(
+           in_video_input_channel,  in_data_control_ID,
+           &self_pp );
+    IF(e) {
+        goto fin;
+    }
+
+    ASSERT_R( *self_pp == NULL,  e=E_OTHERS; goto fin );
+
+    *self_pp = in_self;
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/**
+* @brief   R_VIDEO_INPUT_STATIC_DetachSelfFromInterrupt
+*
+* @param   in_video_input_channel vdc5_channel_t.
+* @param   in_data_control_ID vdc5_layer_id_t.
+* @param   in_self video_input_t*
+* @return  Error Code. 0=No Error.
+*/
+static errnum_t  R_VIDEO_INPUT_STATIC_DetachSelfFromInterrupt(
+    vdc5_channel_t  in_video_input_channel,  vdc5_layer_id_t  in_data_control_ID,
+    video_input_t  *in_self )
+{
+    errnum_t         e;
+    video_input_t  **self_pp = NULL;
+    /* NULL is for avoiding warning C4017W of mbed cloud compiler */
+
+    e= R_VIDEO_INPUT_STATIC_GetSelfPointer(
+           in_video_input_channel,  in_data_control_ID,
+           &self_pp );
+    IF(e) {
+        goto fin;
+    }
+
+    ASSERT_R( *self_pp == in_self,  e=E_OTHERS; goto fin );
+
+    *self_pp = NULL;
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/**
+* @brief   R_VIDEO_INPUT_STATIC_GetSelfFromInterrupt
+*
+* @param   in_interrupt vdc5_int_type_t.
+* @param   in_self video_input_t*
+* @return  Error Code. 0=No Error.
+*/
+static errnum_t  R_VIDEO_INPUT_STATIC_GetSelfFromInterrupt(
+    vdc5_channel_t  in_video_input_channel,  vdc5_int_type_t  in_interrupt,
+    video_input_t  **out_self )
+{
+    errnum_t         e;
+    vdc5_layer_id_t  data_control_ID = VDC5_LAYER_ID_0_WR;
+    /* VDC5_LAYER_ID_0_WR is for avoiding warning C4017W of mbed cloud compiler */
+    video_input_t  **self_pp = NULL;
+    /* NULL is for avoiding warning C4017W of mbed cloud compiler */
+
+
+    switch ( in_interrupt ) {
+        case  VDC5_INT_TYPE_S0_VI_VSYNC:
+            data_control_ID = VDC5_LAYER_ID_0_WR;
+            break;
+
+        case  VDC5_INT_TYPE_S1_VI_VSYNC:
+            data_control_ID = VDC5_LAYER_ID_1_WR;
+            break;
+
+        default:
+            ASSERT_R( false,  e=E_OTHERS;  goto fin );
+    }
+
+
+    e= R_VIDEO_INPUT_STATIC_GetSelfPointer(
+           in_video_input_channel,  data_control_ID,  &self_pp );
+    IF(e) {
+        goto fin;
+    }
+
+    *out_self = *self_pp;
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/**
+* @brief   R_VIDEO_INPUT_STATIC_GetSelfPointer
+*
+* @param   in_video_input_channel vdc5_channel_t.
+* @param   in_data_control_ID vdc5_layer_id_t.
+* @param   out_self_pp video_input_t*
+* @return  Error Code. 0=No Error.
+*/
+static errnum_t  R_VIDEO_INPUT_STATIC_GetSelfPointer(
+    vdc5_channel_t  in_video_input_channel,  vdc5_layer_id_t  in_data_control_ID,
+    video_input_t ***  out_self_pp )
+{
+    errnum_t      e;
+    int_fast32_t  video_input_index;
+    int_fast32_t  data_control_index;
+
+
+    if ( in_video_input_channel == VDC5_CHANNEL_0 ) {
+        video_input_index = 0;
+    } else {
+        ASSERT_D( in_video_input_channel == VDC5_CHANNEL_1,  e=E_OTHERS; goto fin );
+
+        video_input_index = 1;
+    }
+
+    if ( in_data_control_ID == VDC5_LAYER_ID_0_WR ) {
+        data_control_index = 0;
+    } else {
+        ASSERT_D( in_data_control_ID == VDC5_LAYER_ID_1_WR,  e=E_OTHERS; goto fin );
+
+        data_control_index = 1;
+    }
+
+    *out_self_pp = &gs_InterruptToSelf[ video_input_index ][ data_control_index ];
+
+    e=0;
+#ifndef  R_OSPL_NDEBUG
+fin:
+#endif
+    return  e;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/src/video_input_cpp.cpp	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,146 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2014 - 2015 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  video_input_cpp.cpp
+* @brief   $Rev: 51 $
+* $Date:: 2014-03-14 18:42:33 +0900#$
+*/
+
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+*******************************************************************************/
+#include  "video_input.hpp"
+#include  "video_input.h"
+#include  "r_ospl.h"
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+#define  GS_DEFAULT_INT_VALUE  -1
+
+
+/******************************************************************************
+Imported global variables and functions (from other files)
+******************************************************************************/
+
+/******************************************************************************
+Exported global variables and functions (to be accessed by other files)
+******************************************************************************/
+
+/******************************************************************************
+Private global variables and functions
+******************************************************************************/
+
+/***********************************************************************
+* ClassImplement: VideoInput
+************************************************************************/
+
+/***********************************************************************
+* Implement: VideoInput
+************************************************************************/
+VideoInput::VideoInput()
+{
+    this->_self = NULL;
+}
+
+
+/***********************************************************************
+* Implement: ~VideoInput
+************************************************************************/
+VideoInput::~VideoInput()
+{
+    this->destroy();
+}
+
+
+/***********************************************************************
+* Implement: initialize
+************************************************************************/
+errnum_t  VideoInput::initialize( VideoInputConfig &in_out_config )
+{
+    this->_self = new  video_input_t;
+    ASSERT_R( this->_self != NULL,  return  E_FEW_MEMORY );
+
+    in_out_config.flags =
+        VIDEO_INPUT_CONFIG_T_VIDEO_INPUT_CHANNEL_NUM |
+        VIDEO_INPUT_CONFIG_T_DISPLAY_CHANNEL_NUM |
+        VIDEO_INPUT_CONFIG_T_DISPLAY_LAYER_NUM |
+        VIDEO_INPUT_CONFIG_T_FRAME_BUFFER |
+        VIDEO_INPUT_CONFIG_T_CAPTURED_ASYNC;
+
+    if ( in_out_config.video_input_channel_num == GS_DEFAULT_INT_VALUE ) {
+        in_out_config.flags &= ~VIDEO_INPUT_CONFIG_T_VIDEO_INPUT_CHANNEL_NUM;
+    }
+    if ( in_out_config.display_channel_num == GS_DEFAULT_INT_VALUE ) {
+        in_out_config.flags &= ~VIDEO_INPUT_CONFIG_T_DISPLAY_CHANNEL_NUM;
+    }
+    if ( in_out_config.display_layer_num == GS_DEFAULT_INT_VALUE ) {
+        in_out_config.flags &= ~VIDEO_INPUT_CONFIG_T_DISPLAY_LAYER_NUM;
+    }
+    if ( in_out_config.frame_buffer == NULL ) {
+        in_out_config.flags &= ~VIDEO_INPUT_CONFIG_T_FRAME_BUFFER;
+    }
+    if ( in_out_config.captured_async == NULL ) {
+        in_out_config.flags &= ~VIDEO_INPUT_CONFIG_T_CAPTURED_ASYNC;
+    }
+
+    return  R_VIDEO_INPUT_Initialize( this->_self,  (video_input_config_t *) &in_out_config );
+}
+
+
+/***********************************************************************
+* Implement: destroy
+************************************************************************/
+void  VideoInput::destroy()
+{
+    if ( this->_self != NULL ) {
+        errnum_t  e = R_VIDEO_INPUT_Finalize( this->_self,  0 );
+        ASSERT_R( e == 0,  R_NOOP() );
+    }
+}
+
+
+/***********************************************************************
+* ClassImplement: VideoInputConfig
+************************************************************************/
+
+/***********************************************************************
+* Implement: VideoInputConfig
+************************************************************************/
+VideoInputConfig::VideoInputConfig()
+{
+    this->flags = 0;
+    this->video_input_channel_num = GS_DEFAULT_INT_VALUE;
+    this->display_channel_num = GS_DEFAULT_INT_VALUE;
+    this->display_layer_num = GS_DEFAULT_INT_VALUE;
+    this->frame_buffer = NULL;
+    this->captured_async = NULL;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/src/vsync.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,543 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  vsync.c
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: $
+* $Date::                           $
+*/
+
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "vsync.h"
+#include  "vsync_pl.h"
+#include  "r_ospl.h"
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/**
+* @struct  r_v_sync_i_lock_t
+* @brief  I-Lock
+*/
+typedef struct st_r_v_sync_i_lock_t  r_v_sync_i_lock_t;
+struct st_r_v_sync_i_lock_t {
+    /** is_lock */
+    bool_t  is_lock;
+
+    /** channel_num */
+    int_fast32_t  channel_num;
+};
+
+
+/**
+* @struct  r_v_sync_channel_t
+* @brief  V-Sync context
+*/
+typedef struct st_r_v_sync_channel_t  r_v_sync_channel_t;
+struct st_r_v_sync_channel_t {
+    /*-----------------------------------------------------------*/
+    /* Group: Count */
+
+    /** VSync_FrameCount */
+    volatile int_fast32_t  VSync_FrameCount;
+
+    /** VSync_PreviousFrameCount */
+    volatile int_fast32_t  VSync_PreviousFrameCount;
+
+    /** VSync_TargetCount */
+    volatile int_fast32_t  VSync_TargetCount;
+
+
+    /*-----------------------------------------------------------*/
+    /* Group: Interrupt */
+
+    /** AsyncStatus */
+    r_v_sync_async_status_t  AsyncStatus;
+
+    /** InterruptCallbackCaller */
+    r_ospl_caller_t    InterruptCallbackCaller;
+
+    /** InterruptFlag */
+    r_ospl_flag32_t    InterruptFlag;
+
+    /** IsEnabledInterrupt */
+    bool_t             IsEnabledInterrupt;
+
+    /** InterruptEnables */
+    r_ospl_flag32_t    InterruptEnables;
+
+    /** I_Lock */
+    r_v_sync_i_lock_t  I_Lock;
+};
+
+
+/* Section: Global */
+/** V-Sync context */
+static r_v_sync_channel_t  gs_v_sync_channel[ R_V_SYNC_CHANNEL_COUNT ];
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Imported global variables and functions (from other files)
+******************************************************************************/
+
+/******************************************************************************
+Exported global variables and functions (to be accessed by other files)
+******************************************************************************/
+
+/******************************************************************************
+Private global variables and functions
+******************************************************************************/
+
+static void   R_V_SYNC_I_LOCK_Reset( r_v_sync_i_lock_t *const  self );
+static bool_t R_V_SYNC_I_LOCK_Lock( r_v_sync_i_lock_t *const  self );
+static void   R_V_SYNC_I_LOCK_Unlock( r_v_sync_i_lock_t *const  self );
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_Initialize
+************************************************************************/
+errnum_t  R_V_SYNC_Initialize( int_fast32_t const  ChannelNum )
+{
+    errnum_t  e;
+    r_v_sync_channel_t *const  self = &gs_v_sync_channel[ ChannelNum ];
+
+    IF ( (ChannelNum < 0) || (ChannelNum >= R_V_SYNC_CHANNEL_COUNT) ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    self->I_Lock.channel_num = ChannelNum;
+    R_V_SYNC_I_LOCK_Reset( &self->I_Lock );
+
+    ASSERT_R( self->AsyncStatus.State == R_OSPL_UNINITIALIZED,  e=E_STATE; goto fin );
+    R_OSPL_FLAG32_InitConst( &self->AsyncStatus.InterruptFlags );
+    R_OSPL_FLAG32_InitConst( &self->AsyncStatus.CancelFlags );
+
+    e= R_V_SYNC_OnInitialize( ChannelNum );
+    IF(e!=0) {
+        goto fin;
+    }
+
+    self->IsEnabledInterrupt = true;
+    R_OSPL_FLAG32_InitConst( &self->InterruptEnables );
+    self->AsyncStatus.State = R_OSPL_RUNNABLE;
+
+    R_OSPL_FLAG32_Set( &self->InterruptEnables, R_V_SYNC_INTERRUPT_LINE_V_LINE );
+    /* V-Sync interrupt always be enabled. Because clear interrupt status */
+
+    e=0;
+fin:
+    if ( e != 0 ) {
+        e= R_V_SYNC_Finalize( ChannelNum, e );
+        R_UNREFERENCED_VARIABLE( e );
+    }
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_Finalize
+************************************************************************/
+errnum_t  R_V_SYNC_Finalize( int_fast32_t const  ChannelNum,  errnum_t e )
+{
+    bool_t                     was_enabled; /* = false; */ /* QAC 3197 */
+    r_v_sync_channel_t *const  self = &gs_v_sync_channel[ ChannelNum ];
+
+    was_enabled = R_V_SYNC_I_LOCK_Lock( &self->I_Lock );
+
+    if ( ! ( (ChannelNum < 0) || (ChannelNum >= R_V_SYNC_CHANNEL_COUNT) ) ) {
+        if ( self->AsyncStatus.State != R_OSPL_UNINITIALIZED ) {
+            R_OSPL_FLAG32_Clear( &self->InterruptEnables, R_V_SYNC_INTERRUPT_LINE_V_LINE );
+
+            R_OSPL_FLAG32_Set( &self->AsyncStatus.CancelFlags,
+                               R_OSPL_CANNEL_REQUEST | R_OSPL_CANNELING | R_OSPL_CANNELED |
+                               R_OSPL_FINALIZE_REQUEST | R_OSPL_FINALIZING );
+
+            e= R_V_SYNC_OnFinalize( ChannelNum, e );
+
+            R_OSPL_FLAG32_Set( &self->AsyncStatus.CancelFlags, R_OSPL_FINALIZED );
+            R_OSPL_FLAG32_Clear( &self->AsyncStatus.CancelFlags, R_OSPL_FLAG32_ALL_BITS );
+            self->AsyncStatus.State = R_OSPL_UNINITIALIZED;
+        }
+    }
+
+    if ( IS( was_enabled ) ) {
+        R_V_SYNC_I_LOCK_Unlock( &self->I_Lock );
+    }
+    R_V_SYNC_I_LOCK_Reset( &self->I_Lock );
+
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_Wait
+************************************************************************/
+errnum_t  R_V_SYNC_Wait( int_fast32_t const  ChannelNum,
+                         int_fast32_t const  SwapInterval,  bool_t const  Is1VSyncAtMinimum )
+{
+    errnum_t        e;
+    r_ospl_async_t  async;
+    bit_flags32_t   got_flags;
+
+    async.Flags = R_F_OSPL_A_Thread;
+    async.A_Thread = R_OSPL_THREAD_GetCurrentId();
+
+    e= R_V_SYNC_WaitStart( ChannelNum, SwapInterval, Is1VSyncAtMinimum, &async );
+    IF(e!=0) {
+        goto fin;
+    }
+
+    e= R_OSPL_EVENT_Wait( async.A_EventValue, &got_flags, R_OSPL_INFINITE );
+    IF(e!=0) {
+        goto fin;
+    }
+
+    e= async.ReturnValue;
+    IF(e!=0) {
+        goto fin;
+    }
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_WaitStart
+************************************************************************/
+errnum_t  R_V_SYNC_WaitStart( int_fast32_t const  ChannelNum,
+                              int_fast32_t const  SwapInterval,  bool_t const  Is1VSyncAtMinimum,
+                              r_ospl_async_t *const  Async )
+{
+    errnum_t                   e;
+    bool_t                     was_enabled = false;
+    int_fast32_t               target_count;
+    int_fast32_t               operand1;
+    int_fast32_t               operand2;
+    r_v_sync_channel_t *const  self = &gs_v_sync_channel[ ChannelNum ];
+
+    IF ( (ChannelNum < 0) || (ChannelNum >= R_V_SYNC_CHANNEL_COUNT) ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+    IF ( Async == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    R_V_SYNC_SetDefaultAsync( Async, R_OSPL_ASYNC_TYPE_NORMAL );
+    Async->ReturnValue = 0;
+    ASSERT_R( Async->I_Thread == NULL,  e=E_OTHERS; goto fin );
+
+    was_enabled = R_V_SYNC_I_LOCK_Lock( &self->I_Lock );
+
+    ASSERT_R( self->AsyncStatus.State == R_OSPL_RUNNABLE, e=E_STATE; goto fin );
+
+
+    /* Set "self->VSync_TargetCount" */
+    target_count = self->VSync_PreviousFrameCount + SwapInterval;
+    if ( (Is1VSyncAtMinimum) && (target_count < (self->VSync_FrameCount + 1)) ) {
+        target_count = self->VSync_FrameCount + 1;
+    }
+    self->VSync_TargetCount = target_count;
+
+
+    /* If already target count */
+    operand1 = self->VSync_TargetCount;  /* SEC R3.6.2 */
+    operand2 = self->VSync_FrameCount;   /* SEC R3.6.2 */
+    if ( (operand1 - operand2) <= 0 ) {
+        operand1 = self->VSync_FrameCount;  /* SEC R3.6.2 */
+        self->VSync_PreviousFrameCount = operand1;
+
+        /* Set application event */
+        R_OSPL_EVENT_Set( Async->A_Thread, Async->A_EventValue );
+    } else {
+        /* Change state to waiting */
+        self->AsyncStatus.State = R_OSPL_RUNNING;
+
+        /* Clear application event */
+        R_OSPL_EVENT_Clear( Async->A_Thread, Async->A_EventValue );
+
+        /* Attach "Async" to interrupt */
+        /* ->MISRA 11.4 : Not too big "enum" is same bit count as "int" */ /* ->SEC R2.7.1 */
+        R_OSPL_CALLER_Initialize( &self->InterruptCallbackCaller,
+                                  Async, (volatile int_t *) &self->AsyncStatus.State, R_OSPL_INTERRUPTING, NULL, NULL );
+        /* <-MISRA 11.4 */ /* <-SEC R2.7.1 */
+        e= R_V_SYNC_SetInterruptCallbackCaller( ChannelNum,
+                                                &self->InterruptCallbackCaller );
+        IF(e!=0) {
+            goto fin;
+        }
+    }
+
+    e=0;
+fin:
+    if ( IS( was_enabled ) ) {
+        R_V_SYNC_I_LOCK_Unlock( &self->I_Lock );
+    }
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_OnInterrupting
+************************************************************************/
+errnum_t  R_V_SYNC_OnInterrupting( const r_ospl_interrupt_t *const  InterruptSource )
+{
+    errnum_t      e;
+    bool_t        was_enabled  = false;
+    int_fast32_t  operand1;
+    int_fast32_t  operand2;
+    int_fast32_t  channel_num_;
+    r_v_sync_channel_t  *self;
+    r_ospl_async_t      *notify_async = NULL;
+
+    IF_DQ( InterruptSource == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    channel_num_ = InterruptSource->ChannelNum;
+    self = &gs_v_sync_channel[ channel_num_ ];
+
+    if ( self->AsyncStatus.State != R_OSPL_INTERRUPTING ) {
+        e=0;
+        goto fin;
+    }
+
+    self->AsyncStatus.State = R_OSPL_INTERRUPTED;
+
+
+    /* Operate like R_V_SYNC_OnInterrupted() */
+    was_enabled = R_V_SYNC_I_LOCK_Lock( &self->I_Lock );
+
+    self->VSync_FrameCount += 1;
+
+
+    operand1 = self->VSync_TargetCount;  /* SEC R3.6.2 */
+    operand2 = self->VSync_FrameCount;   /* SEC R3.6.2 */
+    if ( (operand1 - operand2) <= 0 ) {
+        operand1 = self->VSync_FrameCount;  /* SEC R3.6.2 */
+        self->VSync_PreviousFrameCount = operand1;
+
+        e= R_V_SYNC_SetInterruptCallbackCaller( channel_num_, NULL );
+
+        self->AsyncStatus.State = R_OSPL_RUNNABLE;
+        notify_async = self->InterruptCallbackCaller.Async;
+    } else {
+        self->AsyncStatus.State = R_OSPL_RUNNING;
+    }
+
+
+    e=0;
+fin:
+    if ( IS( was_enabled ) ) {
+        /* ->QAC 3353 : "self" is always assigned, if "was_enabled" is true */
+        IF_DQ( self == NULL ) {}  /* QAC 3353 raises SEC R3.2.2 */
+        else {
+            R_V_SYNC_I_LOCK_Unlock( &self->I_Lock );
+        }
+        /* <-QAC 3353 */
+        /* This is for disabling interrupt by R_V_SYNC_I_LOCK_Disable() */
+    }
+
+    if ( notify_async != NULL ) {
+        R_OSPL_EVENT_Set( notify_async->A_Thread, notify_async->A_EventValue );
+    }
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_V_SYNC_GetAsyncStatus
+************************************************************************/
+errnum_t  R_V_SYNC_GetAsyncStatus( int_fast32_t const  ChannelNum,
+                                   const r_v_sync_async_status_t **const  out_Status )
+{
+    errnum_t  e;
+    r_v_sync_channel_t *const  self = &gs_v_sync_channel[ ChannelNum ];
+
+    IF_DQ( out_Status == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+    IF ( (ChannelNum < 0) || (ChannelNum >= R_V_SYNC_CHANNEL_COUNT) ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    *out_Status = &self->AsyncStatus;
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/**
+* @brief   Enable interrupt API
+*
+* @param   ChannelNum ChannelNum
+* @return  None
+*/
+void  R_V_SYNC_EnableInterrupt( int_fast32_t const  ChannelNum )
+{
+    errnum_t  e;
+    r_v_sync_channel_t *const  self = &gs_v_sync_channel[ ChannelNum ];
+
+    IF ( (ChannelNum < 0) || (ChannelNum >= R_V_SYNC_CHANNEL_COUNT) ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    R_V_SYNC_OnEnableInterrupt( ChannelNum, self->InterruptEnables.Flags );
+    self->IsEnabledInterrupt = true;
+
+    e=0;
+fin:
+    R_UNREFERENCED_VARIABLE( e );
+}
+
+
+/**
+* @brief   Disable interrupt API
+*
+* @param   ChannelNum ChannelNum
+* @return  None
+*/
+bool_t  R_V_SYNC_DisableInterrupt( int_fast32_t const  ChannelNum )
+{
+    errnum_t  e;
+    bool_t    was_interrupted = false;
+    r_v_sync_channel_t *const  self = &gs_v_sync_channel[ ChannelNum ];
+
+    IF ( (ChannelNum < 0) || (ChannelNum >= R_V_SYNC_CHANNEL_COUNT) ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    was_interrupted = self->IsEnabledInterrupt;
+    self->IsEnabledInterrupt = false;
+
+    R_V_SYNC_OnDisableInterrupt( ChannelNum, self->InterruptEnables.Flags );
+
+    e=0;
+fin:
+    R_UNREFERENCED_VARIABLE( e );
+    return  was_interrupted;
+}
+
+
+/**
+* @brief   Reset I-Lock (Interrupt Lock)
+*
+* @param   self r_v_sync_i_lock_t
+* @return  None
+*/
+static void  R_V_SYNC_I_LOCK_Reset( r_v_sync_i_lock_t *const  self )
+{
+    IF_DQ( self == NULL ) {
+        goto fin;
+    }
+
+    self->is_lock = false;
+    R_V_SYNC_OnDisableInterrupt( self->channel_num, R_V_SYNC_INTERRUPT_LINE_ALL );
+
+fin:
+    return;
+}
+
+
+/**
+* @brief   Lock
+*
+* @param   self r_v_sync_i_lock_t
+* @return  Was interrupt enabled
+*/
+static bool_t  R_V_SYNC_I_LOCK_Lock( r_v_sync_i_lock_t *const  self )
+{
+    bool_t  is_locked;
+    bool_t  was_all_enabled; /* = false; */ /* QAC 3197 */
+    bool_t  b;
+
+    IF_DQ( self == NULL ) {
+        is_locked = true;
+        goto fin;
+    }
+
+    was_all_enabled = R_OSPL_DisableAllInterrupt();
+
+    is_locked = self->is_lock;
+    if ( ! is_locked ) {
+        b= R_V_SYNC_DisableInterrupt( self->channel_num );
+        R_UNREFERENCED_VARIABLE( b );  /* QAC 3200 : This is not error information */
+        self->is_lock = true;
+    }
+
+    if ( IS( was_all_enabled ) ) {
+        R_OSPL_EnableAllInterrupt();
+    }
+
+fin:
+    return  ! is_locked;
+}
+
+
+/**
+* @brief   Unlock
+*
+* @param   self r_v_sync_i_lock_t
+* @return  None
+*/
+static void  R_V_SYNC_I_LOCK_Unlock( r_v_sync_i_lock_t *const  self )
+{
+    bool_t  was_all_enabled; /* = false; */ /* QAC 3197 */
+
+    IF_DQ( self == NULL ) {
+        goto fin;
+    }
+
+    was_all_enabled = R_OSPL_DisableAllInterrupt();
+
+    R_V_SYNC_EnableInterrupt( self->channel_num );
+    self->is_lock = false;
+
+    if ( IS( was_all_enabled ) ) {
+        R_OSPL_EnableAllInterrupt();
+    }
+fin:
+    return;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/src/window_surfaces.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,2167 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  window_surfaces.c
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 51 $
+* $Date:: 2014-03-14 18:42:33 +0900#$
+*/
+
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+*******************************************************************************/
+#include  "r_typedefs.h"
+#include  "lcd_panel.h"
+#include  "r_ospl.h"
+#include  "clib_registers.h"
+#include  "clib_drivers.h"
+#include  "clib_samples.h"
+#include  "window_surfaces.h"
+#include  "vsync.h"
+#include  "window_surfaces_private.h"
+#include  "RGA.h"
+#include  "RGA_Port.h"
+#if  USE_LCD
+#include  "lcd_if.h"
+#endif
+#include  <stdio.h>  /* in R_WINDOW_SURFACES_DoMessageLoop */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/**
+* @typedef  gs_frame_width_height_t
+* @brief  gs_frame_width_height_t
+*/
+#ifdef  IS_WINDOW_SURFACES_EX
+typedef struct st_gs_frame_width_height_t  gs_frame_width_height_t;
+struct st_gs_frame_width_height_t {
+    int_fast32_t  Width;
+    int_fast32_t  Height;
+};
+#endif
+
+
+/**
+* @typedef  gs_rectangle_t
+* @brief  gs_rectangle_t
+*/
+#ifdef  IS_WINDOW_SURFACES_EX
+typedef struct st_gs_rectangle_t  gs_rectangle_t;
+struct st_gs_rectangle_t {
+    int_fast32_t  Left;
+    int_fast32_t  Top;
+    int_fast32_t  Right;   /* include right  bound pixel */
+    int_fast32_t  Bottom;  /* include bottom bound pixel */ /* Top < Bottom */
+};
+#endif
+
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/* GS_ : global static */
+/* VDC5_CHANNEL_0 = LCD_VDC5_CH0_PANEL = ... */
+/* VDC5_CHANNEL_1 = LCD_VDC5_CH1_PANEL = ... */
+#if WINDOW_SURFACES_DEFAULT_CHANNEL
+#define   GS_CHANNEL_n              VDC5_CHANNEL_1
+#define   GS_LCD_CHn_SIG_FV         LCD_CH1_SIG_FV
+#define   GS_LCD_CHn_SIG_FH         LCD_CH1_SIG_FH
+#define   GS_LCD_CHn_DISP_VS        LCD_CH1_DISP_VS
+#define   GS_LCD_CHn_DISP_VW        LCD_CH1_DISP_VW
+#define   GS_LCD_CHn_DISP_HS        LCD_CH1_DISP_HS
+#define   GS_LCD_CHn_DISP_HW        LCD_CH1_DISP_HW
+#define   GS_LCD_CHn_TCON_HALF      LCD_CH1_TCON_HALF
+#define   GS_LCD_CHn_TCON_OFFSET    LCD_CH1_TCON_OFFSET
+#define   GS_LCD_CHn_OUT_EDGE       LCD_CH1_OUT_EDGE
+#define   GS_LCD_CHn_OUT_FORMAT     LCD_CH1_OUT_FORMAT
+#define   GS_LCD_CHn_PANEL_CLK      LCD_CH1_PANEL_CLK
+#define   GS_LCD_CHn_PANEL_CLK_DIV  LCD_CH1_PANEL_CLK_DIV
+#define   GS_DISPLAY_CH             1   /* 1 or 0 */
+#else
+#define   GS_CHANNEL_n              VDC5_CHANNEL_0
+#define   GS_LCD_CHn_SIG_FV         LCD_CH0_SIG_FV
+#define   GS_LCD_CHn_SIG_FH         LCD_CH0_SIG_FH
+#define   GS_LCD_CHn_DISP_VS        LCD_CH0_DISP_VS
+#define   GS_LCD_CHn_DISP_VW        LCD_CH0_DISP_VW
+#define   GS_LCD_CHn_DISP_HS        LCD_CH0_DISP_HS
+#define   GS_LCD_CHn_DISP_HW        LCD_CH0_DISP_HW
+#define   GS_LCD_CHn_TCON_HALF      LCD_CH0_TCON_HALF
+#define   GS_LCD_CHn_TCON_OFFSET    LCD_CH0_TCON_OFFSET
+#define   GS_LCD_CHn_OUT_EDGE       LCD_CH0_OUT_EDGE
+#define   GS_LCD_CHn_OUT_FORMAT     LCD_CH0_OUT_FORMAT
+#define   GS_LCD_CHn_PANEL_CLK      LCD_CH0_PANEL_CLK
+#define   GS_LCD_CHn_PANEL_CLK_DIV  LCD_CH0_PANEL_CLK_DIV
+#define   GS_DISPLAY_CH             0   /* 1 or 0 */
+#endif
+
+#if  1
+#define   GS_BUFFER_WIDTH           800
+#define   GS_BUFFER_HEIGHT          480
+#else
+#define   GS_BUFFER_WIDTH           GS_LCD_CHn_DISP_HW
+#define   GS_BUFFER_HEIGHT          GS_LCD_CHn_DISP_VW
+#endif
+
+#define   GS_MEASURE_GPU_LOAD       0
+
+#define  GS_DEFAULT_CLEAR_COLOR  R_RGA_DEFAULT_CLEAR_COLOR
+
+#ifdef  R_REE_INIT
+#define  GRAPHICS_GetLvdsParam        Graphics_GetLvdsParam
+#define  GRAPHICS_SetLcdTconSettings  Graphics_SetLcdTconSettings
+#define  GRAPHICS_SetLcdPanel         Graphics_SetLcdPanel
+#endif
+#ifdef  RZ_A1L
+#define  GRAPHICS_GetLvdsParam( ch )                 NULL
+#define  GRAPHICS_SetLcdTconSettings( ch, setting )  GRAPHICS_L_SetLcdTconSettings( setting )
+#define  GRAPHICS_SetLcdPanel( ch )                  GRAPHICS_L_SetLcdPanel()
+#endif
+
+/**
+* @def  GS_OFFSET_BYTE_NOT_SHOW
+* @brief  GS_OFFSET_BYTE_NOT_SHOW
+*/
+enum { GS_OFFSET_BYTE_NOT_SHOW = -1 };
+
+
+/******************************************************************************
+Imported global variables and functions (from other files)
+******************************************************************************/
+
+/******************************************************************************
+Exported global variables and functions (to be accessed by other files)
+******************************************************************************/
+
+/******************************************************************************
+Private global variables and functions
+******************************************************************************/
+
+static errnum_t  R_WINDOW_SURFACES_SwapBuffers_Sub( window_surfaces_t *const  self,
+        int_fast32_t const  layer_num );
+
+#ifdef  IS_WINDOW_SURFACES_EX
+errnum_t  GS_ToInFrame(
+    gs_frame_width_height_t *SourceFrameBuffer,
+    gs_frame_width_height_t *DestinationFrameBuffer,
+    gs_rectangle_t *SourceRect,
+    gs_rectangle_t *DestinationRect );
+#endif
+
+
+/**
+* @brief   alloc_VRAM_stack_sub
+*
+* @param   in_out_StackPointer in_out_StackPointer
+* @param   OverOfVRAM OverOfVRAM
+* @param   in_out_FrameBuffer in_out_FrameBuffer
+* @return  Error code, 0=No error
+*
+* @par Description
+*    - (input) - >stride, ->height, ->buffer_count
+*    - (output) - >buffer_address[(all)]
+*/
+static errnum_t  alloc_VRAM_stack_sub( uint8_t **const  in_out_StackPointer,
+                                       const uint8_t *const  OverOfVRAM,
+                                       frame_buffer_t *const  in_out_FrameBuffer ); /* QAC-3450 */
+static errnum_t  alloc_VRAM_stack_sub( uint8_t **const  in_out_StackPointer,
+                                       const uint8_t *const  OverOfVRAM,
+                                       frame_buffer_t *const  in_out_FrameBuffer )
+{
+    errnum_t      e;
+    int_fast32_t  size_1;
+    int_fast32_t  size_all;
+    int_fast32_t  buffer_num;
+    uint8_t      *stack_pointer;
+
+
+    IF_DQ( in_out_StackPointer == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+    IF_DQ( in_out_FrameBuffer == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+
+    stack_pointer = *in_out_StackPointer;
+
+
+    /* Set "size_1" */
+    size_1 = in_out_FrameBuffer->stride * in_out_FrameBuffer->height;
+    size_1 = ( R_Ceil_64s( size_1 ) );
+
+
+    /* Set "size_all" */
+    size_all = in_out_FrameBuffer->buffer_count * size_1;
+
+
+    /* Check */
+    /* ->MISRA 17.4 */ /* ->SEC R1.3.1 (1) */
+    IF ( (stack_pointer + size_all) > OverOfVRAM ) {
+        in_out_FrameBuffer->buffer_count = 0;
+        e=E_FEW_ARRAY;
+        goto fin;
+    }
+    /* <-MISRA 17.4 */ /* <-SEC R1.3.1 (1) */
+
+    IF ( in_out_FrameBuffer->buffer_count >
+         (int_fast32_t) R_COUNT_OF( in_out_FrameBuffer->buffer_address ) ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+
+    /* Set "in_out_FrameBuffer->buffer_address" */
+    for ( buffer_num = 0;
+            buffer_num < in_out_FrameBuffer->buffer_count;
+            buffer_num += 1 ) {
+        in_out_FrameBuffer->buffer_address[ buffer_num ] = stack_pointer;
+
+        /* ->MISRA 17.4 */ /* ->SEC R1.3.1 (1) */
+        stack_pointer += size_1;  /* MISRA 17.4: Bound check is done by "OverOfVRAM" */
+        /* <-MISRA 17.4 */ /* <-SEC R1.3.1 (1) */
+    }
+    for ( /* buffer_num */;
+                          buffer_num < (int_fast32_t) R_COUNT_OF( in_out_FrameBuffer->buffer_address );
+                          buffer_num += 1 ) {
+        in_out_FrameBuffer->buffer_address[ buffer_num ] = NULL;
+    }
+
+    *in_out_StackPointer = stack_pointer;
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/**
+* @brief   free_VRAM_stack_sub
+*
+* @param   in_out_StackPointer in_out_StackPointer
+* @param   frame_buffer frame_buffer
+* @param   StartOfVRAM StartOfVRAM
+* @return  Error code, 0=No error
+*
+* @par Description
+*    - If frame_buffer - >buffer_count == 0, do nothing.
+*/
+static errnum_t  free_VRAM_stack_sub( uint8_t **const  in_out_StackPointer,
+                                      const frame_buffer_t *const  frame_buffer,
+                                      const uint8_t *const  StartOfVRAM ); /* QAC-3450 */
+static errnum_t  free_VRAM_stack_sub( uint8_t **const  in_out_StackPointer,
+                                      const frame_buffer_t *const  frame_buffer,
+                                      const uint8_t *const  StartOfVRAM )
+{
+    errnum_t      e;
+    int_fast32_t  size_1;
+    int_fast32_t  size_all;
+    int_fast32_t  buffer_num;
+    uint8_t      *next_stack_pointer;
+
+
+    IF_DQ( frame_buffer == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+    IF_DQ( in_out_StackPointer == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+
+    /* Set "size_1" */
+    size_1 = frame_buffer->stride * frame_buffer->height;
+    size_1 = ( R_Ceil_64s( size_1 ) );
+    R_STATIC_ASSERT( RGA_STACK_ADDRESS_ALIGNMENT == 64, "" );  /* check of ceil_xx */
+
+
+    /* Set "size_all" */
+    size_all = frame_buffer->buffer_count * size_1;
+
+
+    /* Set "next_stack_pointer" */
+    /* ->MISRA 17.4 */ /* ->SEC R1.3.1 (1) */
+    next_stack_pointer = *in_out_StackPointer - size_all;
+    /* MISRA 17.4: Bound check is done by "StartOfVRAM" */
+    /* <-MISRA 17.4 */ /* <-SEC R1.3.1 (1) */
+
+
+    /* Check */
+    IF ( next_stack_pointer < StartOfVRAM ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    IF ( frame_buffer->buffer_count > (int_fast32_t) R_COUNT_OF( frame_buffer->buffer_address ) ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    for ( buffer_num = frame_buffer->buffer_count - 1;  buffer_num >= 0;  buffer_num -= 1 ) {
+        /* ->MISRA 17.4 */ /* ->SEC R1.3.1 (1) */
+        IF ( frame_buffer->buffer_address[ buffer_num ] !=
+             (next_stack_pointer + (size_1 * buffer_num)) ) {
+            e=E_ACCESS_DENIED;
+            goto fin;
+        }
+        /* MISRA 17.4: Bound check is done by "size_all" */
+        /* <-MISRA 17.4 */ /* <-SEC R1.3.1 (1) */
+    }
+
+
+    /* Set "*in_out_StackPointer" */
+    *in_out_StackPointer = next_stack_pointer;
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/*-------------------------------------------------------------------------*/
+/* <<<< ### (window_surfaces_vdc5_layer_t) Class implement >>>> */
+/*-------------------------------------------------------------------------*/
+
+/**
+* @brief   Initialize <window_surfaces_vdc5_layer_t>
+*
+* @param   self window_surfaces_vdc5_layer_t
+* @param   layer_num layer_num
+* @param   graphics_layer_ID graphics_layer_ID
+* @return  Error code, 0=No error
+*/
+static errnum_t  window_surfaces_vdc5_layer_t__initialize(
+    window_surfaces_vdc5_layer_t *const  self,
+    int_fast32_t const  layer_num,
+    vdc5_graphics_type_t const  graphics_layer_ID ); /* QAC-3450 */
+
+static errnum_t  window_surfaces_vdc5_layer_t__initialize(
+    window_surfaces_vdc5_layer_t *const  self,
+    int_fast32_t const  layer_num,
+    vdc5_graphics_type_t const  graphics_layer_ID )
+{
+    errnum_t  e;
+
+    IF_DQ( self == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    e= R_int_t_to_int8_t( layer_num, &self->layer_num );
+    IF(e!=0) {
+        goto fin;
+    }
+
+    self->graphics_layer_ID = graphics_layer_ID;
+
+    self->is_data_control = false;
+
+    self->layer_color = GS_DEFAULT_CLEAR_COLOR;
+
+    switch ( graphics_layer_ID ) {
+        case  VDC5_GR_TYPE_GR0:
+            self->data_control_ID = VDC5_LAYER_ID_0_RD;
+            break;
+#ifndef  RZ_A1L
+        case  VDC5_GR_TYPE_GR1:
+            self->data_control_ID = VDC5_LAYER_ID_1_RD;
+            break;
+#endif
+        case  VDC5_GR_TYPE_GR2:
+            self->data_control_ID = VDC5_LAYER_ID_2_RD;
+            break;
+        case  VDC5_GR_TYPE_GR3:
+            self->data_control_ID = VDC5_LAYER_ID_3_RD;
+            break;
+        default:
+            e=E_OTHERS;
+            goto fin; /* Bad "graphics_layer_ID" */
+    }
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+
+/*-------------------------------------------------------------------------*/
+/* <<<< ### (window_surfaces_t) Class implement >>>> */
+/*-------------------------------------------------------------------------*/
+
+/**
+* @brief   Get <window_surfaces_vdc5_layer_t>
+*
+* @param   self window_surfaces_t
+* @param   in_LayerNum in_LayerNum
+* @param   out_Layer out_Layer
+* @return  Error code, 0=No error
+*/
+STATIC_INLINE errnum_t  window_surfaces_t__get_layer( window_surfaces_t *const  self,
+        int_fast32_t const  in_LayerNum,
+        window_surfaces_vdc5_layer_t **const  out_Layer );  /* QAC-3450 */
+/* ->MISRA 16.7 : "self" can not "const", because "out_Layer" is not "const" */
+/* ->SEC M1.11.1 */
+STATIC_INLINE errnum_t  window_surfaces_t__get_layer( window_surfaces_t *const  self,
+        int_fast32_t const  in_LayerNum,
+        window_surfaces_vdc5_layer_t **const  out_Layer )
+/* <-MISRA 16.7 */ /* <-SEC M1.11.1 */
+{
+    errnum_t       e;
+    uint_fast32_t  index;
+
+    IF_DQ( self == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+    IF_DQ( out_Layer == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    index = in_LayerNum - self->layer_num_min;
+
+    IF ( index >= R_COUNT_OF( self->layers ) ) {
+        e = E_OTHERS;
+        goto fin;
+    }
+
+    *out_Layer = &self->layers[ index ];
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/**
+* @brief   Get <window_surfaces_attribute_t>
+*
+* @param   self window_surfaces_t
+* @param   in_LayerNum in_LayerNum
+* @param   out_Attribute out_Attribute
+* @return  Error code, 0=No error
+*/
+#ifdef  IS_WINDOW_SURFACES_EX
+STATIC_INLINE errnum_t  window_surfaces_t__get_attribute( window_surfaces_t *const  self,
+        int_fast32_t const  in_LayerNum,
+        window_surfaces_attribute_t **const  out_Attribute );  /* QAC-3450 */
+/* ->MISRA 16.7 : "self" can not "const", because "out_Attribute" is not "const" */
+/* ->SEC M1.11.1 */
+STATIC_INLINE errnum_t  window_surfaces_t__get_attribute( window_surfaces_t *const  self,
+        int_fast32_t const  in_LayerNum,
+        window_surfaces_attribute_t **const  out_Attribute )
+/* <-MISRA 16.7 */ /* <-SEC M1.11.1 */
+{
+    errnum_t       e;
+    uint_fast32_t  index;
+
+    IF_DQ( self == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+    IF_DQ( out_Attribute == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    index = in_LayerNum - self->layer_num_min;
+
+    IF ( index >= R_COUNT_OF( self->layers ) ) {
+        e = E_OTHERS;
+        goto fin;
+    }
+
+    *out_Attribute = &self->attributes[ index ];
+
+    e=0;
+fin:
+    return  e;
+}
+#endif
+
+
+/***********************************************************************
+* Class: window_surfaces_t
+************************************************************************/
+
+/***********************************************************************
+* Implement: R_WINDOW_SURFACES_InitConst
+************************************************************************/
+
+static bool_t  gs_window_surfaces_t_is_init = false;
+
+void  R_WINDOW_SURFACES_InitConst( window_surfaces_t *const  self )
+{
+    int_fast32_t  i;
+
+    IF_DQ( self == NULL ) {
+        goto fin;
+    }
+
+    for ( i = 0;  i < (ssize_t) R_COUNT_OF( self->frame_buffers );  i += 1 ) {
+        self->frame_buffers[i].buffer_address[0] = NULL;
+    }
+    self->is_initialized = gs_window_surfaces_t_is_init;
+
+fin:
+    return;
+}
+
+
+/***********************************************************************
+* Implement: R_WINDOW_SURFACES_Initialize
+************************************************************************/
+
+static void  vdc5_init_func( uint32_t user_num );
+
+errnum_t  R_WINDOW_SURFACES_Initialize( window_surfaces_t *const  self,
+                                        window_surfaces_config_t  *in_out_config )
+{
+    errnum_t                  e;
+    errnum_t                  ee;
+    vdc5_error_t              error_vdc;
+    window_surfaces_config_t  default_config;
+    int_fast32_t              layer_num;
+    window_surfaces_vdc5_layer_t  *main_layer[ R_COUNT_OF( self->frame_buffers ) ];
+    window_surfaces_vdc5_layer_t  *back_layer;
+
+    enum { num_2 = 2,  num_4 = 4 };
+
+
+    IF_DQ( self == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    self->screen_channel = GS_CHANNEL_n;
+
+
+    /* Set default configuration */
+    if ( in_out_config == NULL ) {
+        in_out_config = &default_config;
+        in_out_config->flags = 0;
+    }
+
+    if ( IS_BIT_NOT_SET( in_out_config->flags, F_WINDOW_SURFACES_PIXEL_FORMAT ) ) {
+        in_out_config->pixel_format = PIXEL_FORMAT_ARGB8888;
+        in_out_config->flags |= F_WINDOW_SURFACES_PIXEL_FORMAT;
+    }
+
+
+    if ( IS_BIT_NOT_SET( in_out_config->flags, F_WINDOW_SURFACES_LAYER_COUNT ) ) {
+        in_out_config->layer_count = 1;
+        in_out_config->flags |= F_WINDOW_SURFACES_LAYER_COUNT;
+    }
+    ASSERT_D( in_out_config->layer_count >= 1  &&  in_out_config->layer_count <= 2,
+              e=E_OTHERS; goto fin );
+
+
+    if ( IS_BIT_NOT_SET( in_out_config->flags, F_WINDOW_SURFACES_BUFFER_HEIGHT ) ) {
+        in_out_config->buffer_height = R_ToSigned( GS_BUFFER_HEIGHT );
+        in_out_config->flags |= F_WINDOW_SURFACES_BUFFER_HEIGHT;
+    }
+
+
+    if ( IS_BIT_NOT_SET( in_out_config->flags, F_WINDOW_SURFACES_BACKGROUND_COLOR ) ) {
+        in_out_config->background_color = GS_DEFAULT_CLEAR_COLOR;
+        in_out_config->flags |= F_WINDOW_SURFACES_BACKGROUND_COLOR;
+    }
+
+
+    if ( IS_BIT_NOT_SET( in_out_config->flags, F_WINDOW_SURFACES_BACKGROUND_FORMAT ) ) {
+        in_out_config->background_format = BACKGROUND_FORMAT_SOLID_COLOR;
+        in_out_config->flags |= F_WINDOW_SURFACES_BACKGROUND_FORMAT;
+    }
+
+
+    /* Set layers */
+#ifndef  RZ_A1L  /* RZ/A1H */
+    self->layer_num_min = -1;
+    self->layer_num_max =  in_out_config->layer_count - 1;
+    ASSERT_D( (ssize_t) R_COUNT_OF( self->layers ) >= self->layer_num_max - self->layer_num_min + 1,
+              e=E_OTHERS; goto fin );
+    e= window_surfaces_vdc5_layer_t__initialize( &self->layers[0], -1, VDC5_GR_TYPE_GR0 );
+    IF(e!=0) {
+        goto fin;
+    }
+    e= window_surfaces_vdc5_layer_t__initialize( &self->layers[1],  0, VDC5_GR_TYPE_GR1 );
+    IF(e!=0) {
+        goto fin;
+    }
+    e= window_surfaces_vdc5_layer_t__initialize( &self->layers[2],  1, VDC5_GR_TYPE_GR2 );
+    IF(e!=0) {
+        goto fin;
+    }
+#else
+    if ( in_out_config->pixel_format != PIXEL_FORMAT_YUV422 ) {
+        self->layer_num_min = -1;
+        self->layer_num_max =  in_out_config->layer_count - 1;
+        ASSERT_D( R_COUNT_OF( self->layers ) >= self->layer_num_max - self->layer_num_min + 1,
+                  e=E_OTHERS; goto fin );
+        e= window_surfaces_vdc5_layer_t__initialize( &self->layers[0], -1, VDC5_GR_TYPE_GR0 );
+        IF(e!=0) {
+            goto fin;
+        }
+        e= window_surfaces_vdc5_layer_t__initialize( &self->layers[1],  0, VDC5_GR_TYPE_GR2 );
+        IF(e!=0) {
+            goto fin;
+        }
+        e= window_surfaces_vdc5_layer_t__initialize( &self->layers[2],  1, VDC5_GR_TYPE_GR3 );
+        IF(e!=0) {
+            goto fin;
+        }
+    } else { /* PIXEL_FORMAT_YUV422 */
+        self->layer_num_min = 0;
+        self->layer_num_max = in_out_config->layer_count - 1;
+        ASSERT_D( R_COUNT_OF( self->layers ) >= self->layer_num_max - self->layer_num_min + 1,
+                  e=E_OTHERS; goto fin );
+        e= window_surfaces_vdc5_layer_t__initialize( &self->layers[0],  0, VDC5_GR_TYPE_GR0 );
+        IF(e!=0) {
+            goto fin;
+        }
+        e= window_surfaces_vdc5_layer_t__initialize( &self->layers[1],  1, VDC5_GR_TYPE_GR2 );
+        IF(e!=0) {
+            goto fin;
+        }
+    }
+#endif
+
+
+    /* Set "main_layer", "back_layer" */
+    for ( layer_num = 0;  layer_num <= self->layer_num_max;  layer_num += 1 ) {
+        e= window_surfaces_t__get_layer( self,  layer_num,  &main_layer[ layer_num ] );
+        IF(e!=0) {
+            goto fin;
+        }
+        IF_DQ( main_layer[ layer_num ] == NULL ) {
+            e=E_OTHERS;
+            goto fin;
+        }
+    }
+
+    self->background_format = in_out_config->background_format;
+    if ( self->layer_num_min >= 0 ) {
+        back_layer = NULL;
+        self->background_frame_count = 0;
+    } else {
+        back_layer = NULL;
+        /* NULL is for avoiding warning C417W of mbed cloud compiler */
+        e= window_surfaces_t__get_layer( self, -1, &back_layer );
+        IF(e!=0) {
+            goto fin;
+        }
+        IF_DQ( back_layer == NULL ) {
+            e=E_OTHERS;
+            goto fin;
+        }
+
+        if ( in_out_config->background_format != BACKGROUND_FORMAT_SOLID_COLOR ) {
+            self->background_frame_count = 1;
+        } else {
+            self->background_frame_count = 0;
+        }
+    }
+
+
+    {
+        uint8_t   *memory_address;
+        size_t     memory_size;
+
+
+        /* Set "physical_address", ... */
+        e= R_Sample_GetBigMemory( &memory_address,  &memory_size );
+        IF ( e != 0 ) {
+            goto fin;
+        }
+        /* 64byte alignment */
+        ASSERT_R( R_Mod_64u( (uintptr_t) memory_address ) == 0,  e=E_OTHERS; goto fin );
+
+
+        /* Set "self->start_of_VRAM", ... */
+        self->start_of_VRAM = memory_address;
+        /* ->MISRA 17.4 */ /* ->SEC R1.3.1 (1) */
+        self->over_of_VRAM  = self->start_of_VRAM + memory_size;  /* MISRA 17.4: This is a bound */
+        /* <-MISRA 17.4 */ /* <-SEC R1.3.1 (1) */
+        self->stack_pointer_of_VRAM = self->start_of_VRAM;
+    }
+
+
+    for ( layer_num = -self->background_frame_count;  layer_num <= self->layer_num_max;  layer_num += 1 ) {
+        frame_buffer_t  *frame;
+        window_surfaces_vdc5_layer_t  *layer = main_layer[ layer_num ];
+        pixel_format_t  pixel_format;
+
+        e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, layer_num, &frame );
+        IF(e) {
+            goto fin;
+        }
+
+        if ( layer_num <= -1  &&  in_out_config->background_format != BACKGROUND_FORMAT_SOLID_COLOR ) {
+            pixel_format = PIXEL_FORMAT_YUV422;
+        } else if ( layer_num >= 1  &&  in_out_config->pixel_format == PIXEL_FORMAT_YUV422 ) {
+            pixel_format = PIXEL_FORMAT_ARGB4444;
+        } else {
+            pixel_format = in_out_config->pixel_format;
+        }
+
+
+        /* Set "self->frame_buffers" */
+        frame->buffer_count      = num_2;
+        frame->show_buffer_index = 0;
+        frame->draw_buffer_index = 0;
+        frame->width             = R_ToSigned( GS_BUFFER_WIDTH );
+        frame->height            = in_out_config->buffer_height;
+        frame->pixel_format      = pixel_format;
+        frame->delegate          = NULL;
+
+        switch ( frame->pixel_format ) {
+            case PIXEL_FORMAT_ARGB8888:
+                frame->buffer_count      = 1;
+                frame->draw_buffer_index = 0;
+                frame->byte_per_pixel    = num_4;
+                layer->vdc5_format = VDC5_GR_FORMAT_ARGB8888;
+                break;
+
+            case PIXEL_FORMAT_XRGB8888:
+                frame->buffer_count      = 1;
+                frame->draw_buffer_index = 0;
+                frame->byte_per_pixel    = num_4;
+                layer->vdc5_format = VDC5_GR_FORMAT_RGB888;
+                break;
+
+            case PIXEL_FORMAT_RGB565:
+                frame->buffer_count      = num_2;
+                frame->draw_buffer_index = 1;
+                frame->byte_per_pixel    = num_2;
+                layer->vdc5_format = VDC5_GR_FORMAT_RGB565;
+                break;
+
+            case PIXEL_FORMAT_ARGB1555:
+                frame->buffer_count      = num_2;
+                frame->draw_buffer_index = 1;
+                frame->byte_per_pixel    = num_2;
+                layer->vdc5_format = VDC5_GR_FORMAT_ARGB1555;
+                break;
+
+            case PIXEL_FORMAT_ARGB4444:
+                frame->buffer_count      = num_2;
+                frame->draw_buffer_index = 1;
+                frame->byte_per_pixel    = num_2;
+                layer->vdc5_format = VDC5_GR_FORMAT_ARGB4444;
+                break;
+
+            case PIXEL_FORMAT_YUV422:
+                frame->buffer_count      = num_2;
+                frame->draw_buffer_index = 1;
+                frame->byte_per_pixel    = num_2;
+                layer->vdc5_format = VDC5_GR_FORMAT_YCBCR422;
+                break;
+
+            case PIXEL_FORMAT_CLUT8:
+                frame->buffer_count      = 2;
+                frame->draw_buffer_index = 1;
+                frame->byte_per_pixel    = R_RGA_BitPerPixelType_To_BytePerPixelType( 8 );
+                layer->vdc5_format = VDC5_GR_FORMAT_CLUT8;
+                break;
+
+            case PIXEL_FORMAT_CLUT4:
+                frame->buffer_count      = 2;
+                frame->draw_buffer_index = 1;
+                frame->byte_per_pixel    = R_RGA_BitPerPixelType_To_BytePerPixelType( 4 );
+                layer->vdc5_format = VDC5_GR_FORMAT_CLUT4;
+                break;
+
+            case PIXEL_FORMAT_CLUT1:
+                frame->buffer_count      = 2;
+                frame->draw_buffer_index = 1;
+                frame->byte_per_pixel    = R_RGA_BitPerPixelType_To_BytePerPixelType( 1 );
+                layer->vdc5_format = VDC5_GR_FORMAT_CLUT1;
+                break;
+
+            default:
+                layer->vdc5_format = VDC5_GR_FORMAT_NUM;  /* dummy data */
+                break;
+        }
+        if( R_BYTE_PER_PIXEL_IsInteger( frame->byte_per_pixel ) ) {
+            frame->stride = frame->width * frame->byte_per_pixel;
+        } else {
+            frame->stride = R_Ceil_8s( frame->width *
+                                       R_RGA_BytePerPixelType_To_BitPerPixelType( frame->byte_per_pixel ) ) / 8;
+            frame->stride = R_Ceil_32s( frame->stride );
+        }
+        e= alloc_VRAM_stack_sub( &self->stack_pointer_of_VRAM,
+                                 self->over_of_VRAM, frame );
+        IF(e!=0) {
+            goto fin;
+        }
+
+#ifndef R_OSPL_NDEBUG
+        printf( "Screen %dx%dx%dx%d vdc5_format=%d stride=%d \n address[0]=0x%08X address[1]=0x%08X\n",
+                frame->buffer_count, frame->width, frame->height, frame->byte_per_pixel,
+                layer->vdc5_format, frame->stride,
+                (uintptr_t) frame->buffer_address[0], (uintptr_t) frame->buffer_address[1] );
+        /* Cast of "uintptr_t" is for avoiding "format" warning of GNU_ARM */
+#endif
+    }
+
+
+    if ( ! self->is_initialized ) {
+
+        /* Call "R_VDC5_Initialize" */
+        {
+            vdc5_init_t  init;
+
+            init.panel_icksel = GS_LCD_CHn_PANEL_CLK;
+            init.panel_dcdr   = GS_LCD_CHn_PANEL_CLK_DIV;
+            init.lvds = GRAPHICS_GetLvdsParam( self->screen_channel );
+
+            error_vdc = R_VDC5_Initialize( self->screen_channel, &init,
+                                           &vdc5_init_func, (uint32_t) self->screen_channel );
+            IF ( error_vdc != VDC5_OK ) {
+                e = E_OTHERS;
+                goto fin;
+            }
+        }
+
+
+        /* Call "R_VDC5_SyncControl" */
+        {
+            vdc5_sync_ctrl_t  sync_ctrl;
+
+            sync_ctrl.res_vs_sel    = VDC5_ON;                      /* Free-running Vsync ON/OFF */
+            sync_ctrl.res_vs_in_sel = VDC5_RES_VS_IN_SEL_SC0;       /* SC_RES_VS_IN_SEL */
+            sync_ctrl.res_fv        = (uint16_t)GS_LCD_CHn_SIG_FV;     /* Free-running Vsync period setting */
+            sync_ctrl.res_fh        = (uint16_t)GS_LCD_CHn_SIG_FH;     /* Hsync period setting */
+            sync_ctrl.res_vsdly     = (uint16_t)0u;                 /* Vsync signal delay control */
+            /* Full-screen enable control */
+            sync_ctrl.res_f.vs      = (uint16_t)GS_LCD_CHn_DISP_VS;
+            sync_ctrl.res_f.vw      = (uint16_t)GS_LCD_CHn_DISP_VW;
+            sync_ctrl.res_f.hs      = (uint16_t)GS_LCD_CHn_DISP_HS;
+            sync_ctrl.res_f.hw      = (uint16_t)GS_LCD_CHn_DISP_HW;
+            sync_ctrl.vsync_cpmpe   = NULL;                         /* Vsync signal compensation */
+
+            error_vdc = R_VDC5_SyncControl( self->screen_channel, &sync_ctrl );
+            IF ( error_vdc != VDC5_OK ) {
+                e = E_OTHERS;
+                goto fin;
+            }
+        }
+
+
+        /* Call "R_VDC5_DisplayOutput" */
+        {
+            vdc5_output_t  output;
+            argb8888_t     background_color_;  /* _ is for MISRA 5.6 */
+
+            /* ->QAC 3198 */
+            background_color_.Value = DUMMY_INITIAL_VALUE;  /* for avoid ARMCC warning C4017W */
+            /* <-QAC 3198 */
+            background_color_.u.Alpha = 0;
+            background_color_.u.Red   = in_out_config->background_color.u.Red;
+            background_color_.u.Green = in_out_config->background_color.u.Green;
+            background_color_.u.Blue  = in_out_config->background_color.u.Blue;
+
+
+            output.tcon_half        = (uint16_t)GS_LCD_CHn_TCON_HALF;  /* TCON reference timing, 1/2fH timing */
+            output.tcon_offset      = (uint16_t)GS_LCD_CHn_TCON_OFFSET;/* TCON reference timing, offset Hsync signal timing */
+            /* LCD TCON timing setting */
+            GRAPHICS_SetLcdTconSettings( self->screen_channel, output.outctrl );
+            output.outcnt_lcd_edge  = GS_LCD_CHn_OUT_EDGE;          /* Output phase control of LCD_DATA23 to LCD_DATA0 pin */
+            output.out_endian_on    = VDC5_OFF;                     /* Bit endian change ON/OFF control */
+            output.out_swap_on      = VDC5_OFF;                     /* B/R signal swap ON/OFF control */
+            output.out_format       = GS_LCD_CHn_OUT_FORMAT;        /* LCD output format select */
+            output.out_frq_sel      = VDC5_LCD_PARALLEL_CLKFRQ_1;   /* Clock frequency control */
+            output.out_dir_sel      = VDC5_LCD_SERIAL_SCAN_FORWARD; /* Scan direction select */
+            output.out_phase        = VDC5_LCD_SERIAL_CLKPHASE_0;   /* Clock phase adjustment */
+            output.bg_color         = background_color_.Value;
+
+            error_vdc = R_VDC5_DisplayOutput( self->screen_channel, &output );
+            IF ( error_vdc != VDC5_OK ) {
+                e = E_OTHERS;
+                goto fin;
+            }
+
+            if ( back_layer != NULL ) {
+                back_layer->layer_color = in_out_config->background_color;
+            }
+        }
+
+        self->is_initialized = true;
+    }
+
+
+    /* Call "R_VDC5_ReadDataControl" */
+    {
+        vdc5_read_t           read;
+        vdc5_width_read_fb_t  read_area;
+
+
+        for ( layer_num = 0;  layer_num <= self->layer_num_max;  layer_num += 1 ) {
+            int_fast32_t     bit_per_pixel;
+            frame_buffer_t  *frame;
+            window_surfaces_vdc5_layer_t  *layer = main_layer[ layer_num ];
+
+            e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, layer_num, &frame );
+            IF(e) {
+                goto fin;
+            }
+
+
+            /* Read data parameter */
+            read.gr_ln_off_dir  = VDC5_GR_LN_OFF_DIR_INC;   /* Line offset address direction of the frame buffer */
+            read.gr_flm_sel = VDC5_GR_FLM_SEL_FLM_NUM;  /* Selects a frame buffer address setting signal */
+            read.gr_imr_flm_inv = VDC5_OFF;                 /* Sets the frame buffer number for distortion correction */
+            read.gr_bst_md      = VDC5_BST_MD_32BYTE;       /* Frame buffer burst transfer mode */
+            /* ->QAC 0306 */
+            read.gr_base        = (void *) frame->buffer_address[ frame->show_buffer_index ]; /* Frame buffer base address */
+            /* <-QAC 0306 */
+            read.gr_ln_off      = (uint32_t) frame->stride; /* Frame buffer line offset address */
+            read.width_read_fb = NULL;             /* width of the image read from frame buffer */
+            read.adj_sel = VDC5_OFF;                /* Measures to decrease the influence
+		                                                   by folding pixels/lines (ON/OFF) */
+            read.gr_format      = layer->vdc5_format;       /* Graphics format of the frame buffer read signal */
+            read.gr_ycc_swap = VDC5_GR_YCCSWAP_Y1CRY0CB;
+            /* Controls swapping of data read from buffer in the YCbCr422 format */
+
+            bit_per_pixel = R_RGA_BytePerPixelType_To_BitPerPixelType( frame->byte_per_pixel );
+            if ( (bit_per_pixel == 32) || (frame->pixel_format == PIXEL_FORMAT_YCbCr422) ) {
+                read.gr_rdswa = VDC5_WR_RD_WRSWA_32BIT;
+            } else if ( bit_per_pixel == 16 ) {
+                read.gr_rdswa = VDC5_WR_RD_WRSWA_32_16BIT;
+            } else if ( bit_per_pixel <= 8 ) {
+                read.gr_rdswa = VDC5_WR_RD_WRSWA_32_16_8BIT;
+            }
+            /* Display area */
+            read.gr_grc.hs      = (uint16_t) GS_LCD_CHn_DISP_HS;
+            read.gr_grc.hw      = (uint16_t) GS_LCD_CHn_DISP_HW;
+            read.gr_grc.vs      = (uint16_t) GS_LCD_CHn_DISP_VS;
+            if ( GS_BUFFER_HEIGHT < GS_LCD_CHn_DISP_VW ) {
+                read.gr_grc.vw      = (uint16_t) GS_BUFFER_HEIGHT;
+            } else {
+                read.gr_grc.vw      = (uint16_t) GS_LCD_CHn_DISP_VW;
+            }
+
+            error_vdc = R_VDC5_ReadDataControl( self->screen_channel, layer->data_control_ID, &read );
+            IF ( error_vdc != VDC5_OK ) {
+                e = E_OTHERS;
+                goto fin;
+            }
+            layer->is_data_control = true;
+        }
+
+        if ( back_layer != NULL ) {
+            if ( self->background_format == BACKGROUND_FORMAT_SOLID_COLOR ) {
+
+                /* Set display area for back ground */
+                /* "read.gr_base", ... are ignored */
+
+                error_vdc = R_VDC5_ReadDataControl( self->screen_channel, back_layer->data_control_ID, &read );
+                IF ( error_vdc != VDC5_OK ) {
+                    e = E_OTHERS;
+                    goto fin;
+                }
+            } else {
+                frame_buffer_t                *frame;
+                window_surfaces_vdc5_layer_t  *layer = back_layer;
+
+                e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, -1, &frame );
+                IF(e) {
+                    goto fin;
+                }
+
+
+                /* Read data parameter */
+                read.gr_ln_off_dir  = VDC5_GR_LN_OFF_DIR_INC;   /* Line offset address direction of the frame buffer */
+                read.gr_flm_sel     = VDC5_GR_FLM_SEL_FLM_NUM;  /* Selects a frame buffer address setting signal */
+                read.gr_imr_flm_inv = VDC5_OFF;                 /* Sets the frame buffer number for distortion correction */
+                read.gr_bst_md      = VDC5_BST_MD_32BYTE;       /* Frame buffer burst transfer mode */
+                /* ->QAC 0306 */
+                read.gr_base        = (void *) frame->buffer_address[ frame->show_buffer_index ]; /* Frame buffer base address */
+                /* <-QAC 0306 */
+                read.gr_ln_off      = (uint32_t) frame->stride; /* Frame buffer line offset address */
+                read_area.in_hw     = frame->width;
+                read_area.in_vw     = frame->height / 2;
+                read.width_read_fb  = &read_area;
+                read.adj_sel        = VDC5_ON;
+                read.gr_format      = layer->vdc5_format;       /* Graphics format of the frame buffer read signal */
+                read.gr_ycc_swap    = VDC5_GR_YCCSWAP_CBY0CRY1;
+                /* Controls swapping of data read from buffer in the YCbCr422 format */
+                read.gr_rdswa = VDC5_WR_RD_WRSWA_16BIT;
+
+                /* Display area */
+                read.gr_grc.hs      = (uint16_t) GS_LCD_CHn_DISP_HS;
+                read.gr_grc.hw      = (uint16_t) GS_LCD_CHn_DISP_HW;
+                read.gr_grc.vs      = (uint16_t) GS_LCD_CHn_DISP_VS;
+                if ( GS_BUFFER_HEIGHT < GS_LCD_CHn_DISP_VW ) {
+                    read.gr_grc.vw = (uint16_t) GS_BUFFER_HEIGHT;
+                } else {
+                    read.gr_grc.vw = (uint16_t) GS_LCD_CHn_DISP_VW;
+                }
+
+                error_vdc = R_VDC5_ReadDataControl( self->screen_channel, layer->data_control_ID, &read );
+                IF ( error_vdc != VDC5_OK ) {
+                    e = E_OTHERS;
+                    goto fin;
+                }
+            }
+            back_layer->is_data_control = true;
+        }
+    }
+
+
+    /* Call "R_VDC5_AlphaBlending" for ARGB1555 */
+    for ( layer_num = 0;  layer_num <= self->layer_num_max;  layer_num += 1 ) {
+        frame_buffer_t  *frame;
+
+        e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, layer_num, &frame );
+        IF(e) {
+            goto fin;
+        }
+
+        if ( frame->pixel_format == PIXEL_FORMAT_ARGB1555 ) {
+            static vdc5_alpha_argb1555_t  alpha_for_argb1555 = { 0x00, U8_255 };
+            static vdc5_alpha_blending_t  blend = { &alpha_for_argb1555, NULL };
+
+            error_vdc = R_VDC5_AlphaBlending( self->screen_channel,
+                                              main_layer[ layer_num ]->data_control_ID,
+                                              &blend );
+            IF( error_vdc != VDC5_OK ) {
+                e=E_OTHERS;
+                goto fin;
+            }
+        }
+    }
+
+
+    /* Call "R_V_SYNC_Initialize" */
+    e= R_V_SYNC_Initialize( (int_fast32_t) self->screen_channel );
+    IF ( e != 0 ) {
+        goto fin;
+    }
+
+
+    /* Wait for avoiding LCD filled white (LCD-KIT-B01) */
+    e= R_OSPL_Delay( 80 );
+    IF(e) {
+        goto fin;
+    }
+
+
+    /* Set graphics display mode */
+    {
+        vdc5_start_t  start;
+        int_fast32_t  i;
+
+        for ( i = 0;  i < (int_fast32_t) R_COUNT_OF( self->vdc5_disp_sel_array );  i += 1 ) {
+            self->vdc5_disp_sel_array[ i ] = VDC5_DISPSEL_LOWER;  /* Reset */
+        }
+        self->vdc5_disp_sel_array[ VDC5_GR_TYPE_GR0 ] = VDC5_DISPSEL_BACK;
+
+        start.gr_disp_sel = self->vdc5_disp_sel_array;
+        error_vdc = R_VDC5_StartProcess( self->screen_channel, VDC5_LAYER_ID_ALL, &start );
+        IF ( error_vdc != VDC5_OK ) {
+            e = E_OTHERS;
+            goto fin;
+        }
+    }
+
+#if  USE_LCD
+    R_OSPL_Delay( 2*17 );  /* Synchronize to LCD */
+    LCD_SetBacklight( 100 );
+#endif
+
+
+    /* Set "self->attributes" */
+    for ( layer_num = self->layer_num_min;  layer_num <=  self->layer_num_max;  layer_num += 1 ) {
+        window_surfaces_attribute_t  *attribute = NULL;
+        /* NULL is for avoiding warning C417W of mbed cloud compiler */
+
+        e= window_surfaces_t__get_attribute( self, layer_num, &attribute );
+        IF(e) {
+            goto fin;
+        }
+
+        attribute->X = 0;
+        attribute->Y = 0;
+        attribute->Width  = R_ToSigned( GS_BUFFER_WIDTH );
+        attribute->Height = in_out_config->buffer_height;
+        attribute->OffsetX = 0;
+        attribute->OffsetY = 0;
+        attribute->OffsetByte = 0;
+    }
+
+
+    e=0;
+fin:
+    if ( e != 0 ) {
+        if ( self != NULL ) {
+            ee= R_WINDOW_SURFACES_Finalize( self, e );
+            R_UNREFERENCED_VARIABLE( ee );
+        }
+    }
+    return  e;
+}
+
+
+/**
+* @brief   vdc5_init_func
+*
+* @param   user_num channel
+* @return  None
+*/
+static void  vdc5_init_func( uint32_t const  user_num )
+{
+    vdc5_channel_t        channel;
+    struct st_cpg *const  reg_CPG = R_Get_CPG_Base();
+
+    IF_DQ( reg_CPG == NULL ) {
+        goto fin;
+    }
+
+    channel = (vdc5_channel_t)user_num;
+    if (channel == VDC5_CHANNEL_0) {
+        /* Standby control register 9 (STBCR9)
+        	b1      ------0-;  MSTP91 : 0 : Video display controller channel 0 & LVDS enable */
+        R_DRV_SET_REGISTER_BIT_FIELD( &reg_CPG->STBCR9, STBCR9, MSTP91, false );
+    } else {
+        /* Standby control register 9 (STBCR9)
+        	b1      ------0-;  MSTP91 : 0 : Video display controller channel 0 & LVDS enable
+        	b0      -------0;  MSTP90 : 0 : Video display controller channel 1 enable */
+        R_DRV_SET_REGISTER_BIT_FIELD( &reg_CPG->STBCR9, STBCR9, MSTP91, false );
+        R_DRV_SET_REGISTER_BIT_FIELD( &reg_CPG->STBCR9, STBCR9, MSTP90, false );
+    }
+    GRAPHICS_SetLcdPanel(channel);
+
+fin:
+    return;
+}
+
+
+/***********************************************************************
+* Implement: R_WINDOW_SURFACES_Finalize
+************************************************************************/
+
+static void  vdc5_quit_func( uint32_t const  user_num );
+
+errnum_t  R_WINDOW_SURFACES_Finalize( window_surfaces_t *const  self,  errnum_t e )
+{
+    vdc5_error_t  error_vdc;
+
+    IF_DQ( self == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    e= R_V_SYNC_Finalize( (int_fast32_t) self->screen_channel, e );
+
+    if ( ! self->is_initialized ) {
+        error_vdc = R_VDC5_Terminate( self->screen_channel, &vdc5_quit_func,
+                                      (uint32_t) self->screen_channel );
+        IF ( (error_vdc != VDC5_OK) && (e == 0) ) {
+            e = E_OTHERS;
+        }
+    } else {
+        int_fast32_t  i;
+
+        for ( i = -self->background_frame_count;  i <= self->layer_num_max;  i += 1 ) {
+            frame_buffer_t  *frame;
+            errnum_t         ee;
+
+            ee= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, i, &frame );
+            e= R_OSPL_MergeErrNum( e, ee );
+            frame->buffer_address[0] = NULL;
+        }
+
+        for ( i = self->layer_num_min;  i <=  self->layer_num_max;  i += 1 ) {
+            window_surfaces_vdc5_layer_t  *layer = NULL;
+            /* NULL is for avoiding warning C417W of mbed cloud compiler */
+            errnum_t  ee = window_surfaces_t__get_layer( self, i, &layer );
+
+            IF_DQ ( layer == NULL ) {
+                e=E_OTHERS;    /* Same check as "ee" */
+                goto fin;
+            }
+
+            if ( (ee == 0) && (layer->is_data_control) ) {
+                error_vdc = R_VDC5_StopProcess( self->screen_channel,
+                                                layer->data_control_ID );
+                IF ( (error_vdc != VDC5_OK) && (e == 0) ) {
+                    e = E_OTHERS;
+                }
+                error_vdc = R_VDC5_ReleaseDataControl( self->screen_channel,
+                                                       layer->data_control_ID );
+                layer->is_data_control = false;
+                IF ( (error_vdc != VDC5_OK) && (e == 0) ) {
+                    e = E_OTHERS;
+                }
+            }
+        }
+
+#define  R_WINDOW_SURFACES_TERMINATE_VDC5  1  /* 0 or 1 */
+#if      R_WINDOW_SURFACES_TERMINATE_VDC5
+        self->is_initialized = false;
+
+        error_vdc = R_VDC5_Terminate( self->screen_channel, &vdc5_quit_func,
+                                      (uint32_t) self->screen_channel );
+        IF ( (error_vdc != VDC5_OK) && (e == 0) ) {
+            e = E_OTHERS;
+        }
+#endif
+    }
+
+    gs_window_surfaces_t_is_init = self->is_initialized;
+
+fin:
+    return  e;
+}
+
+
+/**
+* @brief   vdc5_quit_func
+*
+* @param   user_num channel
+* @return  None
+*/
+static void  vdc5_quit_func( uint32_t const  user_num )
+{
+    vdc5_channel_t const  channel = (vdc5_channel_t) user_num;
+    struct st_cpg *const  reg_CPG = R_Get_CPG_Base();
+
+    IF_DQ( reg_CPG == NULL ) {
+        goto fin;
+    }
+
+    if (channel == VDC5_CHANNEL_0) {
+        /* If LVDS should remain enabled, the following code should be removed. */
+        R_DRV_SET_REGISTER_BIT_FIELD( &reg_CPG->STBCR9, STBCR9, MSTP91, true );
+    } else {
+        R_DRV_SET_REGISTER_BIT_FIELD( &reg_CPG->STBCR9, STBCR9, MSTP90, true );
+    }
+
+fin:
+    return;
+}
+
+
+/***********************************************************************
+* Implement: R_WINDOW_SURFACES_GetLayerFrameBuffer
+************************************************************************/
+errnum_t  R_WINDOW_SURFACES_GetLayerFrameBuffer( const window_surfaces_t *const  self,
+        int_fast32_t const  layer_num,  frame_buffer_t **const  out_frame_buffer )
+{
+    errnum_t       e;
+    uint_fast32_t  index;
+
+    IF_DQ( out_frame_buffer == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+    IF_DQ( self == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    index = layer_num + self->background_frame_count;
+    IF ( index >= R_COUNT_OF( self->frame_buffers ) ) {
+        e = E_OTHERS;
+        goto fin;
+    }
+
+    *out_frame_buffer = (frame_buffer_t *) &self->frame_buffers[ index ];
+    /* Cast is for const */
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_WINDOW_SURFACES_SwapBuffers
+************************************************************************/
+errnum_t  R_WINDOW_SURFACES_SwapBuffers( window_surfaces_t *const  self,
+        int_fast32_t const  layer_num,  graphics_t *const  context )
+{
+    errnum_t  e;
+#if GS_MEASURE_GPU_LOAD
+    enum {                interval = 60 };
+    uint32_t              idle_start_time;
+    uint32_t              idle_end_time;
+    static  uint32_t      skip_count;
+    static  uint32_t      previous_idle_end_time;
+    r_ospl_ftimer_spec_t  ts;
+#endif
+
+
+    e= R_GRAPHICS_Finish( context );
+    IF(e!=0) {
+        goto fin;
+    }
+
+
+#if GS_MEASURE_GPU_LOAD
+    e= R_OSPL_FTIMER_InitializeIfNot( &ts );
+    IF(e) {
+        goto fin;
+    }
+    idle_start_time = R_OSPL_FTIMER_Get();
+#endif
+
+
+    e= R_WINDOW_SURFACES_SwapBuffers_Sub( self, layer_num );
+    IF(e!=0) {
+        goto fin;
+    }
+
+
+    e= R_V_SYNC_Wait( self->screen_channel, 1, true );
+    IF(e!=0) {
+        goto fin;
+    }
+
+
+#if GS_MEASURE_GPU_LOAD
+    idle_end_time = R_OSPL_FTIMER_Get();
+    if ( previous_idle_end_time != 0 ) {  /* Skip at first */
+        skip_count += 1;
+        if ( skip_count >= interval ) {
+            printf( "GPU %d%% in %dmsec\n",
+                    ( idle_start_time - previous_idle_end_time ) * 100 /
+                    ( idle_end_time   - previous_idle_end_time ),
+                    R_OSPL_FTIMER_CountToTime( &ts,
+                                               idle_end_time - previous_idle_end_time ) );
+            skip_count = 0;
+
+            /* __heapstats( (__heapprt) fprintf, stdout ); */
+
+            /* R_DEBUG_BREAK(); */ /* This is for measuring CPU load */
+        }
+    }
+    previous_idle_end_time = idle_end_time;
+#endif
+
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_WINDOW_SURFACES_SwapBuffersStart
+************************************************************************/
+errnum_t  R_WINDOW_SURFACES_SwapBuffersStart( window_surfaces_t *const  self,
+        int_fast32_t const  layer_num,  r_ospl_async_t *async )
+{
+    errnum_t  e;
+
+
+    e= R_WINDOW_SURFACES_SwapBuffers_Sub( self, layer_num );
+    IF(e!=0) {
+        goto fin;
+    }
+
+
+    e= R_V_SYNC_WaitStart( self->screen_channel, 1, true, async );
+    IF(e!=0) {
+        goto fin;
+    }
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/**
+* @brief   Sub routine of <R_WINDOW_SURFACES_SwapBuffers>
+*
+* @param   self window_surfaces_t
+* @param   layer_num layer_num
+* @return  Error code, 0=No error
+*/
+static errnum_t  R_WINDOW_SURFACES_SwapBuffers_Sub( window_surfaces_t *const  self,
+        int_fast32_t const  layer_num )
+{
+    errnum_t         e;
+    vdc5_error_t     error_vdc;
+    frame_buffer_t  *frame;
+    window_surfaces_vdc5_layer_t  *layer = NULL;
+    /* NULL is for avoiding warning C417W of mbed cloud compiler */
+
+
+    IF_DQ( self == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    e= window_surfaces_t__get_layer( self, layer_num, &layer );
+    IF(e!=0) {
+        goto fin;
+    }
+    IF_DQ( layer == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+
+    /* Swap buffer index */
+    e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, layer_num, &frame );
+    IF(e) {
+        goto fin;
+    }
+    frame->show_buffer_index = frame->draw_buffer_index;
+    frame->draw_buffer_index += 1;
+    if ( frame->draw_buffer_index >= (int_t) frame->buffer_count ) {
+        frame->draw_buffer_index = 0;
+    }
+
+
+    /* Show the frame buffer */
+    {
+        vdc5_read_chg_t  config;
+        uintptr_t        physical_address;
+
+        window_surfaces_attribute_t   *attribute = NULL;
+        /* NULL is for avoiding warning C417W of mbed cloud compiler */
+
+        e= R_OSPL_ToPhysicalAddress( frame->buffer_address[ frame->show_buffer_index ],
+                                     &physical_address );
+        IF(e!=0) {
+            goto fin;
+        }
+
+        e= window_surfaces_t__get_attribute( self, layer_num, &attribute );
+        IF(e) {
+            goto fin;
+        }
+
+        if ( attribute->OffsetByte != GS_OFFSET_BYTE_NOT_SHOW ) {
+            physical_address += attribute->OffsetByte;
+
+            config.gr_base        = (void *) physical_address;
+            config.width_read_fb  = NULL;
+            config.gr_grc         = NULL;
+            config.gr_disp_sel    = NULL;
+            error_vdc = R_VDC5_ChangeReadProcess( self->screen_channel, layer->data_control_ID, &config );
+            IF ( error_vdc != VDC5_OK ) {
+                e=E_OTHERS;
+                goto  fin;
+            }
+        }
+    }
+
+
+    /* Show the layer */
+    {
+        vdc5_gr_disp_sel_t  new_value;
+
+        if ( layer_num == 1 ) {
+            new_value = VDC5_DISPSEL_BLEND;
+        } else if ( layer_num == 0 ) {
+            frame_buffer_t  *frame;
+
+            e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, layer_num, &frame );
+            IF(e) {
+                goto fin;
+            }
+
+            if ( frame->pixel_format == PIXEL_FORMAT_YUV422 ) {
+                new_value = VDC5_DISPSEL_CURRENT;
+            } else {
+                new_value = VDC5_DISPSEL_BLEND;
+            }
+        } else {
+            ASSERT_D( layer_num == -1,  e=E_OTHERS; goto fin );
+
+            if ( self->background_format == BACKGROUND_FORMAT_SOLID_COLOR ) {
+                new_value = VDC5_DISPSEL_CURRENT;
+            } else {
+                new_value = VDC5_DISPSEL_LOWER;  /* "*_LOWER" is "*_CURRENT" for resize */
+            }
+        }
+
+        if ( self->vdc5_disp_sel_array[ layer->graphics_layer_ID ] != new_value ) {
+            vdc5_start_t  start;
+
+            self->vdc5_disp_sel_array[ layer->graphics_layer_ID ] = new_value;
+
+            start.gr_disp_sel = self->vdc5_disp_sel_array;
+            error_vdc = R_VDC5_StartProcess( self->screen_channel, VDC5_LAYER_ID_ALL, &start );
+            IF ( error_vdc != VDC5_OK ) {
+                e = E_OTHERS;
+                goto fin;
+            }
+        }
+    }
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_WINDOW_SURFACES_WaitForVSync
+************************************************************************/
+errnum_t  R_WINDOW_SURFACES_WaitForVSync( window_surfaces_t *const  self,
+        int_fast32_t const  swap_interval,  bool_t const  is_1_v_sync_at_minimum )
+{
+    return  R_V_SYNC_Wait( self->screen_channel, swap_interval, is_1_v_sync_at_minimum );
+}
+
+
+/**
+* @brief   R_WINDOW_SURFACES_AllocOffscreenStack
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+errnum_t  R_WINDOW_SURFACES_AllocOffscreenStack( window_surfaces_t *const  self,
+        frame_buffer_t *const  in_out_frame_buffer )
+{
+    errnum_t  e;
+
+    IF_DQ( self == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    e= alloc_VRAM_stack_sub( &self->stack_pointer_of_VRAM,  self->over_of_VRAM,
+                             in_out_frame_buffer );
+    IF(e!=0) {
+        goto fin;
+    }
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/**
+* @brief   R_WINDOW_SURFACES_FreeOffscreenStack
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+errnum_t  R_WINDOW_SURFACES_FreeOffscreenStack( window_surfaces_t *const  self,
+        const frame_buffer_t *const  frame_buffer )
+{
+    errnum_t  e;
+
+    IF_DQ( self == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    e= free_VRAM_stack_sub( &self->stack_pointer_of_VRAM, frame_buffer,
+                            self->start_of_VRAM );
+    IF(e!=0) {
+        goto fin;
+    }
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_WINDOW_SURFACES_DoMessageLoop
+************************************************************************/
+errnum_t  R_WINDOW_SURFACES_DoMessageLoop( window_surfaces_t *self )
+{
+    R_UNREFERENCED_VARIABLE( self );
+
+    R_OSPL_Delay( 2000 );
+
+    return  0;
+}
+
+
+/***********************************************************************
+* Implement: R_WINDOW_SURFACES_AccessLayerAttributes
+************************************************************************/
+errnum_t  R_WINDOW_SURFACES_AccessLayerAttributes( window_surfaces_t *self,
+        layer_attributes_t *in_out_Attributes )
+{
+    errnum_t         e;
+    vdc5_error_t     error_vdc;
+    window_surfaces_vdc5_layer_t  *layer = NULL;
+
+    if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_ID ) ) {
+        e= window_surfaces_t__get_layer( self, in_out_Attributes->id, &layer );
+        IF(e) {
+            goto fin;
+        }
+    }
+
+    ASSERT_R( IS_ALL_BITS_NOT_SET( in_out_Attributes->access, ~ACCESS_ALL_MASK ),  e=E_OTHERS; goto fin );
+
+
+    if ( in_out_Attributes->flags & F_LAYER_LAYER_COLOR ) {
+        vdc5_output_t  output;
+        vdc5_read_t    read;
+        r8g8b8a8_t     previous_layer_color = { {0,0,0,0} };
+        /* Avoid Warning: C4017W: previous_layer_color may be used before being set */
+        enum { necessary_flags = F_LAYER_ID };
+
+
+        ASSERT_R( IS_ALL_BITS_SET( in_out_Attributes->flags, necessary_flags ),
+                  e=E_OTHERS; goto fin );
+        ASSERT_R( IS_ALL_BITS_NOT_SET( in_out_Attributes->access, ~(ACCESS_READ | ACCESS_WRITE) ),
+                  e=E_OTHERS; goto fin );
+
+
+        if ( IS_BIT_SET( in_out_Attributes->access, ACCESS_READ ) ) {
+            previous_layer_color = layer->layer_color;
+        }
+
+
+        if ( IS_BIT_SET( in_out_Attributes->access, ACCESS_WRITE ) ) {
+
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_LAYER_COLOR ) ) {
+
+                /* Set "output.bg_color" to "R_VDC5_DisplayOutput" */
+                output.tcon_half        = (uint16_t)GS_LCD_CHn_TCON_HALF;  /* TCON reference timing, 1/2fH timing */
+                output.tcon_offset      = (uint16_t)GS_LCD_CHn_TCON_OFFSET;/* TCON reference timing, offset Hsync signal timing */
+                GRAPHICS_SetLcdTconSettings( self->screen_channel, output.outctrl );
+                output.outcnt_lcd_edge  = GS_LCD_CHn_OUT_EDGE;          /* Output phase control of LCD_DATA23 to LCD_DATA0 pin */
+                output.out_endian_on    = VDC5_OFF;                     /* Bit endian change ON/OFF control */
+                output.out_swap_on      = VDC5_OFF;                     /* B/R signal swap ON/OFF control */
+                output.out_format       = GS_LCD_CHn_OUT_FORMAT;        /* LCD output format select */
+                output.out_frq_sel      = VDC5_LCD_PARALLEL_CLKFRQ_1;   /* Clock frequency control */
+                output.out_dir_sel      = VDC5_LCD_SERIAL_SCAN_FORWARD; /* Scan direction select */
+                output.out_phase        = VDC5_LCD_SERIAL_CLKPHASE_0;   /* Clock phase adjustment */
+                output.bg_color         =
+                    ( in_out_Attributes->layer_color.u.Red << 16 ) |
+                    ( in_out_Attributes->layer_color.u.Green << 8 ) |
+                    ( in_out_Attributes->layer_color.u.Blue << 0 );  /* 24-bit RGB color format */
+
+                error_vdc = R_VDC5_DisplayOutput( self->screen_channel, &output );
+                IF ( error_vdc != VDC5_OK ) {
+                    e = E_OTHERS;
+                    goto fin;
+                }
+
+
+                /* Update ReadDataControl */
+
+                /* Release */
+                if ( layer->is_data_control ) {
+                    error_vdc = R_VDC5_StopProcess( self->screen_channel, layer->data_control_ID );
+                    IF ( error_vdc != VDC5_OK ) {
+                        R_NOOP();
+                    }
+                    error_vdc = R_VDC5_ReleaseDataControl( self->screen_channel, layer->data_control_ID );
+                    IF ( error_vdc != VDC5_OK ) {
+                        e=E_OTHERS;
+                        goto fin;
+                    }
+                    layer->is_data_control = false;
+                }
+
+                /* Read data parameter : These values are dummy */
+                read.gr_ln_off_dir  = VDC5_GR_LN_OFF_DIR_INC;   /* Line offset address direction of the frame buffer */
+                read.gr_flm_sel     = VDC5_GR_FLM_SEL_FLM_NUM;  /* Selects a frame buffer address setting signal */
+                read.gr_imr_flm_inv = VDC5_OFF;                 /* Sets the frame buffer number for distortion correction */
+                read.gr_bst_md      = VDC5_BST_MD_32BYTE;       /* Frame buffer burst transfer mode */
+                read.gr_base        = (void *) &read;           /* Dummy, Frame buffer base address */
+                read.gr_ln_off      = 3200;                     /* Dummy, Frame buffer line offset address */
+                read.width_read_fb  = NULL;                     /* width of the image read from frame buffer */
+                read.adj_sel        = VDC5_OFF;                 /* Measures to decrease the influence
+				                                                   by folding pixels/lines (ON/OFF) */
+                read.gr_format      = VDC5_GR_FORMAT_RGB888;    /* Graphics format of the frame buffer read signal */
+                read.gr_ycc_swap    = VDC5_GR_YCCSWAP_Y1CRY0CB; /* Controls swapping of data read from buffer
+				                                                   in the YCbCr422 format */
+                read.gr_rdswa       = VDC5_WR_RD_WRSWA_32BIT;   /* for 32 bit format */
+
+                /* Set bakcground color area */
+                read.gr_grc.hs      = GS_LCD_CHn_DISP_HS;
+                read.gr_grc.hw      = (uint16_t) GS_LCD_CHn_DISP_HW;
+                read.gr_grc.vs      = GS_LCD_CHn_DISP_VS;
+                if ( GS_BUFFER_HEIGHT < GS_LCD_CHn_DISP_VW ) {
+                    read.gr_grc.vw      = (uint16_t) GS_BUFFER_HEIGHT;
+                } else {
+                    read.gr_grc.vw      = GS_LCD_CHn_DISP_VW;
+                }
+
+                /* Start to read again */
+                error_vdc = R_VDC5_ReadDataControl( self->screen_channel, layer->data_control_ID, &read );
+                IF ( error_vdc != VDC5_OK ) {
+                    e = E_OTHERS;
+                    goto fin;
+                }
+                layer->is_data_control = true;
+            }
+
+
+            /* Set graphics display mode */
+            {
+                vdc5_start_t  start;
+
+                start.gr_disp_sel = self->vdc5_disp_sel_array;
+                error_vdc = R_VDC5_StartProcess( self->screen_channel, VDC5_LAYER_ID_ALL, &start );
+                IF ( error_vdc != VDC5_OK ) {
+                    e = E_OTHERS;
+                    goto fin;
+                }
+            }
+        }
+
+        if ( IS_BIT_SET( in_out_Attributes->access, ACCESS_READ ) ) {
+            in_out_Attributes->layer_color = previous_layer_color;
+        }
+    }
+
+
+    /* Set window position */
+    {
+        enum { flags_of_window_position =
+                   F_LAYER_X | F_LAYER_Y | F_LAYER_WIDTH | F_LAYER_HEIGHT |
+                   F_LAYER_OFFSET_X | F_LAYER_OFFSET_Y
+             };
+
+        if ( IS_ANY_BITS_SET( in_out_Attributes->flags, flags_of_window_position )  &&
+                IS_BIT_SET( in_out_Attributes->access, ACCESS_WRITE ) ) {
+            vdc5_read_chg_t          change;
+            vdc5_width_read_fb_t     change_source_rectangle;
+            vdc5_period_rect_t       change_destination_rectangle;
+            gs_frame_width_height_t  source_frame;
+            gs_frame_width_height_t  destination_frame;
+            gs_rectangle_t           source_rectangle;
+            gs_rectangle_t           destination_rectangle;
+            frame_buffer_t          *frame;
+            bool_t                   is_interlace;
+            bool_t                   is_solid_color;
+            bool_t                   is_show = true;
+            window_surfaces_attribute_t  *attribute = NULL;
+            /* NULL is for avoiding warning C417W of mbed cloud compiler */
+
+
+            ASSERT_R( IS_ALL_BITS_SET( in_out_Attributes->flags, F_LAYER_ID ), e=E_OTHERS; goto fin );
+
+            e= window_surfaces_t__get_attribute( self, in_out_Attributes->id, &attribute );
+            IF(e) {
+                goto fin;
+            }
+
+            is_interlace = ( self->background_format == BACKGROUND_FORMAT_VIDEO_INTERLACE  &&
+                             in_out_Attributes->id == -1 );
+
+            is_solid_color = ( self->background_format == BACKGROUND_FORMAT_SOLID_COLOR  &&
+                               in_out_Attributes->id == -1 );
+
+            change.gr_base = NULL;
+            change.width_read_fb = NULL;
+            change.gr_grc = NULL;
+            change.gr_disp_sel = NULL;
+
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_X ) ) {
+                attribute->X = in_out_Attributes->x;
+                change.gr_grc = &change_destination_rectangle;
+            }
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_Y ) ) {
+                attribute->Y = in_out_Attributes->y;
+                change.gr_grc = &change_destination_rectangle;
+            }
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_WIDTH ) ) {
+                attribute->Width = in_out_Attributes->width;
+                change.gr_grc = &change_destination_rectangle;
+            }
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_HEIGHT ) ) {
+                attribute->Height = in_out_Attributes->height;
+                change.gr_grc = &change_destination_rectangle;
+            }
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_OFFSET_X ) ) {
+                attribute->OffsetX = in_out_Attributes->offset_x;
+                change.gr_grc = &change_destination_rectangle;
+            }
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_OFFSET_Y ) ) {
+                attribute->OffsetY = in_out_Attributes->offset_y;
+                change.gr_grc = &change_destination_rectangle;
+            }
+
+
+            /* Call "GS_ToInFrame" */
+            if ( is_solid_color ) {
+                e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, 0, &frame );
+                IF(e) {
+                    goto fin;
+                }
+            } else {
+                e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, in_out_Attributes->id, &frame );
+                IF(e) {
+                    goto fin;
+                }
+            }
+            source_frame.Width  = frame->width;
+            source_frame.Height = frame->height;
+            destination_frame.Width  = frame->width;
+            destination_frame.Height = frame->height;
+            source_rectangle.Left   = attribute->OffsetX;
+            source_rectangle.Top    = attribute->OffsetY;
+            source_rectangle.Right  = attribute->OffsetX + attribute->Width;
+            source_rectangle.Bottom = attribute->OffsetY + attribute->Height;
+            destination_rectangle.Left   = attribute->X;
+            destination_rectangle.Top    = attribute->Y;
+            destination_rectangle.Right  = attribute->X + attribute->Width;
+            destination_rectangle.Bottom = attribute->Y + attribute->Height;
+
+            e= GS_ToInFrame( &source_frame, &destination_frame,
+                             &source_rectangle, &destination_rectangle );
+            IF(e) {
+                goto fin;
+            }
+            if ( source_rectangle.Left > source_rectangle.Right ) {
+                is_show = false;
+            }
+
+
+            /* Call "R_VDC5_ChangeReadProcess" */
+            if ( is_show ) {
+                byte_t       *source_address;
+                int_fast32_t  offset_byte;
+
+                ASSERT_R( ! is_solid_color,  e=E_OTHERS; goto fin );
+
+                if ( is_interlace ) {
+                    source_address = frame->buffer_address[0];
+                    offset_byte = ( source_rectangle.Top / 2 ) * frame->stride;
+                } else {
+                    source_address = frame->buffer_address[ frame->show_buffer_index ];
+                    offset_byte = source_rectangle.Top * frame->stride;
+                }
+                offset_byte += source_rectangle.Left * frame->byte_per_pixel;
+                ASSERT_R( R_BYTE_PER_PIXEL_IsInteger( frame->byte_per_pixel ),
+                          e=E_OTHERS; goto fin );
+                attribute->OffsetByte = offset_byte;
+
+                change.gr_base = source_address + attribute->OffsetByte;
+            }
+            if ( change.gr_grc != NULL ) {
+                change_destination_rectangle.hs = destination_rectangle.Left + GS_LCD_CHn_DISP_HS;
+                change_destination_rectangle.vs = destination_rectangle.Top  + GS_LCD_CHn_DISP_VS;
+                change_destination_rectangle.hw = destination_rectangle.Right - destination_rectangle.Left + 1;
+                change_destination_rectangle.vw = destination_rectangle.Bottom - destination_rectangle.Top + 1;
+
+                change.width_read_fb = &change_source_rectangle;
+                change_source_rectangle.in_hw = change_destination_rectangle.hw;
+                change_source_rectangle.in_vw = change_destination_rectangle.vw;
+
+                if ( is_interlace ) {
+                    change_source_rectangle.in_vw /= 2;
+                }
+            }
+
+            if ( change_source_rectangle.in_hw < 3  ||  change_source_rectangle.in_vw == 0 ) {
+                is_show = false;
+            }
+
+            if ( ! is_show ) {
+                change_destination_rectangle.hs = GS_LCD_CHn_DISP_HS - 2;  /* out of visible */
+                change_destination_rectangle.vs = GS_LCD_CHn_DISP_VS;
+                change_destination_rectangle.hw = 3;
+                change_destination_rectangle.vw = 1;
+                change_source_rectangle.in_hw = 3;
+                change_source_rectangle.in_vw = 1;
+                attribute->OffsetByte = GS_OFFSET_BYTE_NOT_SHOW;
+            }
+
+            error_vdc = R_VDC5_ChangeReadProcess(
+                            self->screen_channel, layer->data_control_ID, &change );
+            IF ( error_vdc != VDC5_OK ) {
+                e = E_OTHERS;
+                goto fin;
+            }
+        }
+        if ( IS_ANY_BITS_SET( in_out_Attributes->flags, flags_of_window_position )  &&
+                IS_BIT_SET( in_out_Attributes->access, ACCESS_READ ) ) {
+            window_surfaces_attribute_t  *attribute = NULL;
+            /* NULL is for avoiding warning C417W of mbed cloud compiler */
+
+            ASSERT_R( IS_ALL_BITS_SET( in_out_Attributes->flags, F_LAYER_ID ), e=E_OTHERS; goto fin );
+
+            e= window_surfaces_t__get_attribute( self, in_out_Attributes->id, &attribute );
+            IF(e) {
+                goto fin;
+            }
+
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_X ) ) {
+                in_out_Attributes->x = attribute->X;
+            }
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_Y ) ) {
+                in_out_Attributes->y = attribute->Y;
+            }
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_WIDTH ) ) {
+                in_out_Attributes->width = attribute->Width;
+            }
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_HEIGHT ) ) {
+                in_out_Attributes->height = attribute->Height;
+            }
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_OFFSET_X ) ) {
+                in_out_Attributes->offset_x = attribute->OffsetX;
+            }
+            if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_OFFSET_Y ) ) {
+                in_out_Attributes->offset_y = attribute->OffsetY;
+            }
+        }
+    }
+
+
+    /* Call "R_VDC5_CLUT" */
+    {
+        enum { flags_of_CLUT = F_LAYER_CLUT | F_LAYER_CLUT_COUNT };
+
+        if ( IS_ANY_BITS_SET( in_out_Attributes->flags, flags_of_CLUT ) ) {
+            vdc5_clut_t  clut_data;
+            enum { necessary_flags = flags_of_CLUT | F_LAYER_ID };
+
+            ASSERT_R( IS_ALL_BITS_SET( in_out_Attributes->flags, necessary_flags ),
+                      e=E_OTHERS; goto fin );
+            ASSERT_R( IS_ANY_BITS_NOT_SET(
+                          in_out_Attributes->access,  ~ (bit_flags_fast32_t) ACCESS_WRITE ),
+                      e=E_OTHERS; goto fin );
+
+            clut_data.color_num = in_out_Attributes->CLUT_count;
+            clut_data.clut = (uint32_t *)( in_out_Attributes->CLUT );
+            error_vdc = R_VDC5_CLUT( self->screen_channel, layer->data_control_ID, &clut_data );
+            IF( error_vdc != VDC5_OK ) {
+                e=E_OTHERS;
+                goto fin;
+            }
+        }
+    }
+
+    IF( IS_ANY_BITS_SET( in_out_Attributes->flags,
+                         ~( F_LAYER_ID | F_LAYER_LAYER_COLOR | F_LAYER_CLUT_COUNT | F_LAYER_CLUT |
+                            F_LAYER_X | F_LAYER_Y | F_LAYER_WIDTH | F_LAYER_HEIGHT |
+                            F_LAYER_OFFSET_X | F_LAYER_OFFSET_Y ) ) ) {
+        e=E_LIMITATION;
+        goto fin;
+    }
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/* Section: Global */
+/**
+* @brief   Put "SourceRect" and "DestinationRect" into the frame.
+*
+* @param   SourceFrameBuffer gs_frame_width_height_t
+* @param   DestinationFrameBuffer gs_frame_width_height_t
+* @param   SourceRect gs_rectangle_t
+* @param   DestinationRect gs_rectangle_t
+* @return  Error Code. 0=No Error.
+*
+* @par Description
+*    - If out of frame then "SourceRect - >Left > SourceRect->Right".
+*/
+errnum_t  GS_ToInFrame(
+    gs_frame_width_height_t *SourceFrameBuffer,
+    gs_frame_width_height_t *DestinationFrameBuffer,
+    gs_rectangle_t *SourceRect,
+    gs_rectangle_t *DestinationRect )
+{
+    errnum_t  e;
+    int  src_top,  src_bottom,  dst_top,  dst_bottom;  /* top down coord */
+    int  diff;
+
+
+    /* fast culling by out of frame buffer horizontal */
+    if (      SourceRect->Left >= SourceFrameBuffer->Width ||
+              DestinationRect->Left >= DestinationFrameBuffer->Width ||
+              SourceRect->Right < 0 ||
+              DestinationRect->Right < 0 ) {
+        SourceRect->Right = SourceRect->Left - 1;  /* out of frame */
+        e = 0;
+        goto fin;
+    }
+
+
+    /* set "src_top", "src_bottom", "dst_top", "dst_bottom" */
+    src_top    = SourceRect->Top;
+    src_bottom = SourceRect->Bottom;
+    dst_top    = DestinationRect->Top;
+    dst_bottom = DestinationRect->Bottom;
+
+
+    /* fast culling by out of frame buffer vertical */
+    if ( src_top >= SourceFrameBuffer->Height ||
+            dst_top >= DestinationFrameBuffer->Height ||
+            src_bottom < 0 ||
+            dst_bottom < 0 ) {
+        SourceRect->Right = SourceRect->Left - 1;  /* out of frame */
+        e = 0;
+        goto fin;
+    }
+
+
+    /* set top >= 0 */
+    if ( src_top < 0 ) {
+        dst_top += - src_top;
+        src_top = 0;
+    }
+
+    if ( dst_top < 0 ) {
+        src_top += - dst_top;
+        dst_top = 0;
+    }
+
+
+    /* set bottom < frame height */
+    if ( src_bottom >= SourceFrameBuffer->Height ) {
+        diff = src_bottom - SourceFrameBuffer->Height + 1;
+        src_bottom -= diff;
+        dst_bottom -= diff;
+    }
+
+    if ( dst_bottom >= DestinationFrameBuffer->Height ) {
+        diff = dst_bottom - DestinationFrameBuffer->Height + 1;
+        src_bottom -= diff;
+        dst_bottom -= diff;
+    }
+
+
+    /* culling by out of frame buffer vertical for modified top and bottom */
+    if ( src_top < 0 ||
+            dst_top < 0 ||
+            src_bottom >= SourceFrameBuffer->Height ||
+            dst_bottom >= DestinationFrameBuffer->Height ) {
+        SourceRect->Right = SourceRect->Left - 1;  /* out of frame */
+        e = 0;
+        goto fin;
+    }
+
+
+    /* return from "src_top", "src_bottom", "dst_top", "dst_bottom" */
+    SourceRect->Top    = src_top;
+    SourceRect->Bottom = src_bottom;
+    DestinationRect->Top    = dst_top;
+    DestinationRect->Bottom = dst_bottom;
+
+
+    /* set left >= 0 */
+    if ( SourceRect->Left < 0 ) {
+        DestinationRect->Left += - SourceRect->Left;
+        SourceRect->Left = 0;
+    }
+
+    if ( DestinationRect->Left < 0 ) {
+        SourceRect->Left += - DestinationRect->Left;
+        DestinationRect->Left = 0;
+    }
+
+
+    /* set right < frame width */
+    if ( SourceRect->Right >= SourceFrameBuffer->Width ) {
+        diff = SourceRect->Right - SourceFrameBuffer->Width + 1;
+        SourceRect->Right      -= diff;
+        DestinationRect->Right -= diff;
+    }
+
+    if ( DestinationRect->Right >= DestinationFrameBuffer->Width ) {
+        diff = DestinationRect->Right - DestinationFrameBuffer->Width + 1;
+        SourceRect->Right      -= diff;
+        DestinationRect->Right -= diff;
+    }
+
+
+    /* culling by out of frame buffer horizontal for modified top and bottom */
+    if (      SourceRect->Left >= SourceFrameBuffer->Width ||
+              DestinationRect->Left >= DestinationFrameBuffer->Width ||
+              SourceRect->Right < 0 ||
+              DestinationRect->Right < 0 ) {
+        SourceRect->Right = SourceRect->Left - 1;  /* out of frame */
+        e = 0;
+        goto fin;
+    }
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/***********************************************************************
+* Class: vram_ex_stack_t
+************************************************************************/
+
+/***********************************************************************
+* Implement: R_VRAM_EX_STACK_Initialize
+************************************************************************/
+errnum_t  R_VRAM_EX_STACK_Initialize( vram_ex_stack_t *self, void *NullConfig )
+{
+    errnum_t  e;
+    uint8_t  *address;
+    size_t    size;
+
+    R_UNREFERENCED_VARIABLE( NullConfig );
+
+    e= R_EXRAM_GetBigMemory( &address, &size );
+    IF(e) {
+        goto fin;
+    }
+
+    self->Start = address;
+    self->Over  = address + size;
+    self->StackPointer = self->Start;
+
+    e=0;
+fin:
+    return  e;
+}
+
+
+/***********************************************************************
+* Implement: R_VRAM_EX_STACK_Alloc
+************************************************************************/
+errnum_t  R_VRAM_EX_STACK_Alloc( vram_ex_stack_t *self, frame_buffer_t *in_out_FrameBuffer )
+{
+    return  alloc_VRAM_stack_sub( &self->StackPointer, self->Over, in_out_FrameBuffer );
+}
+
+
+/***********************************************************************
+* Implement: R_VRAM_EX_STACK_Free
+************************************************************************/
+errnum_t  R_VRAM_EX_STACK_Free( vram_ex_stack_t *self, frame_buffer_t *frame_buffer )
+{
+    return  free_VRAM_stack_sub( &self->StackPointer, frame_buffer, self->Start );
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGA/src/window_surfaces_cpp.cpp	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,299 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2014 - 2015 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  window_surfaces_cpp.cpp
+* @brief   $Module: CLibCommon $ $PublicVersion: 1.20 $ (=CLIB_VERSION)
+* $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+* - Description: Window Surfaces for mbed style C++ API
+*/
+
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+*******************************************************************************/
+#include  "window_surfaces.hpp"
+#include  "window_surfaces.h"
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+#define  GS_DEFAULT_INT_VALUE  0x7FFFFFFF
+#define  GS_DEFAULT_HEIGHT  -1
+#define  GS_DEFAULT_CLEAR_COLOR  0x00000100
+
+
+/******************************************************************************
+Imported global variables and functions (from other files)
+******************************************************************************/
+
+/******************************************************************************
+Exported global variables and functions (to be accessed by other files)
+******************************************************************************/
+
+/******************************************************************************
+Private global variables and functions
+******************************************************************************/
+
+
+/***********************************************************************
+* ClassImplement: WindowSurfacesClass
+************************************************************************/
+
+/***********************************************************************
+* Implement: WindowSurfacesClass
+************************************************************************/
+WindowSurfacesClass::WindowSurfacesClass()
+{
+    this->_self = NULL;
+}
+
+
+/***********************************************************************
+* Implement: ~WindowSurfacesClass
+************************************************************************/
+WindowSurfacesClass::~WindowSurfacesClass()
+{
+    this->destroy();
+}
+
+
+/***********************************************************************
+* Implement: initialize
+************************************************************************/
+errnum_t  WindowSurfacesClass::initialize( WindowSurfacesConfigClass &in_out_config )
+{
+    this->_self = new  window_surfaces_t;
+    ASSERT_R( this->_self != NULL,  return  E_FEW_MEMORY );
+
+    in_out_config.flags =
+        F_WINDOW_SURFACES_PIXEL_FORMAT |
+        F_WINDOW_SURFACES_LAYER_COUNT |
+        F_WINDOW_SURFACES_BACKGROUND_COLOR |
+        F_WINDOW_SURFACES_BUFFER_HEIGHT;
+
+    if ( in_out_config.buffer_height == GS_DEFAULT_HEIGHT ) {
+        in_out_config.flags &= ~F_WINDOW_SURFACES_BUFFER_HEIGHT;
+    }
+    if ( in_out_config.background_color.Value == GS_DEFAULT_CLEAR_COLOR ) {
+        in_out_config.flags &= ~F_WINDOW_SURFACES_BACKGROUND_COLOR;
+    }
+
+    R_WINDOW_SURFACES_InitConst( this->_self );
+
+    return  R_WINDOW_SURFACES_Initialize( this->_self,
+                                          (window_surfaces_config_t *) &in_out_config );
+}
+
+
+/***********************************************************************
+* Implement: destroy
+************************************************************************/
+void  WindowSurfacesClass::destroy()
+{
+    if ( this->_self != NULL ) {
+        errnum_t  e = R_WINDOW_SURFACES_Finalize( this->_self,  0 );
+        ASSERT_R( e == 0,  R_NOOP() );
+    }
+}
+
+
+/***********************************************************************
+* Implement: get_layer_frame_buffer
+************************************************************************/
+errnum_t  WindowSurfacesClass::get_layer_frame_buffer( int_fast32_t const  layer_num,  frame_buffer_t **const  out_frame_buffer )
+{
+    return  R_WINDOW_SURFACES_GetLayerFrameBuffer( this->_self,  layer_num,  out_frame_buffer );
+}
+
+
+/***********************************************************************
+* Implement: swap_buffers
+************************************************************************/
+#ifdef  IS_WINDOW_SURFACES_EX
+errnum_t  WindowSurfacesClass::swap_buffers( int_fast32_t const  layer_num,  Canvas2D_ContextClass  &context )
+{
+    return  R_WINDOW_SURFACES_SwapBuffers( this->_self,  layer_num,  context.c_LanguageContext );
+}
+#else
+errnum_t  WindowSurfacesClass::swap_buffers( int_fast32_t const  layer_num,  const void *const  null_context )
+{
+    return  R_WINDOW_SURFACES_SwapBuffers( this->_self,  layer_num,  null_context );
+}
+#endif
+
+
+/***********************************************************************
+* Implement: swap_buffers_start
+************************************************************************/
+errnum_t  WindowSurfacesClass::swap_buffers_start( int_fast32_t const  layer_num,  r_ospl_async_t *async )
+{
+    return  R_WINDOW_SURFACES_SwapBuffersStart( this->_self,  layer_num,  async );
+}
+
+
+/***********************************************************************
+* Implement: wait_for_v_sync
+************************************************************************/
+errnum_t  WindowSurfacesClass::wait_for_v_sync( int_fast32_t const  swap_interval,  bool_t const  is_1_v_sync_at_minimum )
+{
+    return  R_WINDOW_SURFACES_WaitForVSync( this->_self,  swap_interval,  is_1_v_sync_at_minimum );
+}
+
+
+/***********************************************************************
+* Implement: alloc_offscreen_stack
+************************************************************************/
+errnum_t  WindowSurfacesClass::alloc_offscreen_stack( frame_buffer_t *const  in_out_frame_buffer )
+{
+    return  R_WINDOW_SURFACES_AllocOffscreenStack( this->_self,  in_out_frame_buffer );
+}
+
+
+/***********************************************************************
+* Implement: free_offscreen_stack
+************************************************************************/
+errnum_t  WindowSurfacesClass::free_offscreen_stack( const frame_buffer_t *const  frame_buffer )
+{
+    return  R_WINDOW_SURFACES_FreeOffscreenStack( this->_self,  frame_buffer );
+}
+
+
+/***********************************************************************
+* Implement: do_message_loop
+************************************************************************/
+#ifdef  IS_WINDOW_SURFACES_EX
+errnum_t  WindowSurfacesClass::do_message_loop()
+{
+    return  R_WINDOW_SURFACES_DoMessageLoop( this->_self );
+}
+#endif
+
+
+/***********************************************************************
+* Implement: access_layer_attributes
+************************************************************************/
+#ifdef  IS_WINDOW_SURFACES_EX
+errnum_t  WindowSurfacesClass::access_layer_attributes( LayerAttributes &in_out_Attributes )
+{
+    in_out_Attributes.flags =
+        F_LAYER_ID |
+        F_LAYER_PRIORITY |
+        F_LAYER_X |
+        F_LAYER_Y |
+        F_LAYER_WIDTH |
+        F_LAYER_HEIGHT |
+        F_LAYER_OFFSET_X |
+        F_LAYER_OFFSET_Y |
+        F_LAYER_CLUT |
+        F_LAYER_CLUT_COUNT;
+
+    if ( in_out_Attributes.id == GS_DEFAULT_INT_VALUE ) {
+        in_out_Attributes.flags &= ~F_LAYER_ID;
+    }
+    if ( in_out_Attributes.priority == GS_DEFAULT_INT_VALUE ) {
+        in_out_Attributes.flags &= ~F_LAYER_PRIORITY;
+    }
+    if ( in_out_Attributes.x == GS_DEFAULT_INT_VALUE ) {
+        in_out_Attributes.flags &= ~F_LAYER_X;
+    }
+    if ( in_out_Attributes.y == GS_DEFAULT_INT_VALUE ) {
+        in_out_Attributes.flags &= ~F_LAYER_Y;
+    }
+    if ( in_out_Attributes.width == GS_DEFAULT_INT_VALUE ) {
+        in_out_Attributes.flags &= ~F_LAYER_WIDTH;
+    }
+    if ( in_out_Attributes.height == GS_DEFAULT_INT_VALUE ) {
+        in_out_Attributes.flags &= ~F_LAYER_HEIGHT;
+    }
+    if ( in_out_Attributes.offset_x == GS_DEFAULT_INT_VALUE ) {
+        in_out_Attributes.flags &= ~F_LAYER_OFFSET_X;
+    }
+    if ( in_out_Attributes.offset_y == GS_DEFAULT_INT_VALUE ) {
+        in_out_Attributes.flags &= ~F_LAYER_OFFSET_Y;
+    }
+    if ( in_out_Attributes.CLUT == NULL ) {
+        in_out_Attributes.flags &= ~F_LAYER_CLUT;
+    }
+    if ( in_out_Attributes.CLUT_count == 0 ) {
+        in_out_Attributes.flags &= ~F_LAYER_CLUT_COUNT;
+    }
+
+    return  R_WINDOW_SURFACES_AccessLayerAttributes( this->_self,
+            (layer_attributes_t *) &in_out_Attributes );
+}
+#endif
+
+
+/***********************************************************************
+* ClassImplement: WindowSurfacesConfigClass
+************************************************************************/
+
+/***********************************************************************
+* Implement: WindowSurfacesConfigClass
+************************************************************************/
+WindowSurfacesConfigClass::WindowSurfacesConfigClass()
+{
+    this->flags = 0;
+    this->pixel_format = PIXEL_FORMAT_ARGB8888;
+    this->layer_count = 1;
+    this->buffer_height = GS_DEFAULT_HEIGHT;
+    this->background_color.Value = GS_DEFAULT_CLEAR_COLOR;
+}
+
+
+/***********************************************************************
+* ClassImplement: LayerAttributes
+************************************************************************/
+
+/***********************************************************************
+* Implement: LayerAttributes
+************************************************************************/
+#ifdef  IS_WINDOW_SURFACES_EX
+LayerAttributes::LayerAttributes()
+{
+    this->access = ACCESS_READ;
+    this->flags = 0;
+    this->id       = GS_DEFAULT_INT_VALUE;
+    this->priority = GS_DEFAULT_INT_VALUE;
+    this->is_show = false;
+    this->is_color_key = false;
+    this->color_key.Value = GS_DEFAULT_CLEAR_COLOR;
+    this->layer_color.Value = 0;
+    this->x        = GS_DEFAULT_INT_VALUE;
+    this->y        = GS_DEFAULT_INT_VALUE;
+    this->width    = GS_DEFAULT_INT_VALUE;
+    this->height   = GS_DEFAULT_INT_VALUE;
+    this->offset_x = GS_DEFAULT_INT_VALUE;
+    this->offset_y = GS_DEFAULT_INT_VALUE;
+    this->CLUT     = NULL;
+    this->CLUT_count = 0;
+}
+#endif
+
+
--- a/common/inc/clib_drivers.h	Thu Dec 03 07:55:42 2015 +0000
+++ b/common/inc/clib_drivers.h	Wed Jan 20 02:35:17 2016 +0000
@@ -68,451 +68,13 @@
 errnum_t  R_int32_t_to_int8_t( int32_t input, int8_t *output );
 
 
-
-/*-------------------------------------------------------------------------*/
-/* <<<< ### Inline Functions >>>> */
-/*-------------------------------------------------------------------------*/
-
-/**
-* @brief   Cast with range check
-*
-* @param   input Input value
-* @param   output Output value
-* @return  Error Code. 0=No Error.
-*/
-INLINE errnum_t  R_int_t_to_int8_t( int_t input, int8_t *output )
-{
-    return  R_int32_t_to_int8_t( input, output );
-}
-
-
-/**
-* @brief   Fast mod operation
-*
-* @param   value Left operand
-* @return  value % N
-*
-* @par Description
-* - This is shared description of
-*   R_Mod_2s, R_Mod_4s, R_Mod_8s, R_Mod_16s, R_Mod_32s, R_Mod_64s,
-*   R_Mod_2u, R_Mod_4u, R_Mod_8u, R_Mod_16u, R_Mod_32u, R_Mod_64u.
-* - Porting layer of fast % operator.
-* - MISRA & IPA SEC confirmed version.
-* - Minus value is expected 2's complement.
-* - Not same C99 % operator.
-*   - Sample: R_Mod_4s( - 7 ) == +1.  Sample: -7 % 4 == -3
-*/
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Mod_2s( int_fast32_t const  value )
-{
-    enum { mask = 1 };
-    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
-}
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Mod_4s( int_fast32_t const  value )
-{
-    enum { mask = 3 };
-    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
-}
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Mod_8s( int_fast32_t const  value )
-{
-    enum { mask = 7 };
-    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
-}
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Mod_16s( int_fast32_t const  value )
-{
-    enum { mask = 15 };
-    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
-}
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Mod_32s( int_fast32_t const  value )
-{
-    enum { mask = 31 };
-    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
-}
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Mod_64s( int_fast32_t const  value )
-{
-    enum { mask = 63 };
-    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
-}
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Mod_2u( uint_fast32_t const  value )
-{
-    return  ((value) & 1u);
-}
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Mod_4u( uint_fast32_t const  value )
-{
-    return  ((value) & 3u);
-}
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Mod_8u( uint_fast32_t const  value )
-{
-    return  ((value) & 7u);
-}
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Mod_16u( uint_fast32_t const  value )
-{
-    return  ((value) & 15u);
-}
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Mod_32u( uint_fast32_t const  value )
-{
-    return  ((value) & 31u);
-}
-
-
-/**
-* @brief   Fast mod operation. See <R_Mod_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Mod_64u( uint_fast32_t const  value )
-{
-    return  ((value) & 63u);
-}
-
-
-/**
-* @brief   Fast ceil operation
-*
-* @param   value Left operand
-* @return  Ceil( value / N )
-*
-* @par Description
-* - This is shared description of
-*   R_Ceil_2s, R_Ceil_4s, R_Ceil_8s, R_Ceil_16s, R_Ceil_32s, R_Ceil_64s,
-*   R_Ceil_2u, R_Ceil_4u, R_Ceil_8u, R_Ceil_16u, R_Ceil_32u, R_Ceil_64u.
-* - Porting layer of fast ceil operation.
-* - Function version is confirmed with MISRA & IPA SEC.
-*/
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Ceil_2s( int_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 1;
-    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
-}
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Ceil_4s( int_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 3;
-    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
-}
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Ceil_8s( int_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 7;
-    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
-}
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Ceil_16s( int_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 15;
-    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
-}
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Ceil_32s( int_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 31;
-    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
-}
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE int_fast32_t  R_Ceil_64s( int_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 63;
-    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
-}
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Ceil_2u( uint_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 1;
-    return  (((value)+mask)&~mask);
-}
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Ceil_4u( uint_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 3;
-    return  (((value)+mask)&~mask);
-}
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Ceil_8u( uint_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 7;
-    return  (((value)+mask)&~mask);
-}
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Ceil_16u( uint_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 15;
-    return  (((value)+mask)&~mask);
-}
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Ceil_32u( uint_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 31;
-    return  (((value)+mask)&~mask);
-}
-
-
-/**
-* @brief   Fast ceil operation. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-INLINE uint_fast32_t  R_Ceil_64u( uint_fast32_t const  value )
-{
-    static const uint_fast32_t  mask = 63;
-    return  (((value)+mask)&~mask);
-}
-
-
-/**
-* @brief   Fast ceil operation. Macro version. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-#define  R_CEIL_2U( value )   (((value)+1)&~1)
-
-
-/**
-* @brief   Fast ceil operation. Macro version. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-#define  R_CEIL_4U( value )   (((value)+3)&~3)
-
-
-/**
-* @brief   Fast ceil operation. Macro version. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-#define  R_CEIL_8U( value )   (((value)+7)&~7)
-
-
-/**
-* @brief   Fast ceil operation. Macro version. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-#define  R_CEIL_16U( value )  (((value)+15)&~15)
-
-
-/**
-* @brief   Fast ceil operation. Macro version. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-#define  R_CEIL_32U( value )  (((value)+31)&~31)
-
-
-/**
-* @brief   Fast ceil operation. Macro version. See <R_Ceil_N>.
-*
-* @par Parameters
-*    None
-* @return  None.
-*/
-#define  R_CEIL_64U( value )  (((value)+63)&~63)
-
-
 #ifdef __cplusplus
 }  /* extern "C" */
 #endif /* __cplusplus */
 
+/* Inline Functions */
+#include  "clib_drivers_inline.h"
+
 #endif  /* CLIB_DRIVERS_H */
 
 
--- a/common/inc/clib_drivers_config.h	Thu Dec 03 07:55:42 2015 +0000
+++ b/common/inc/clib_drivers_config.h	Wed Jan 20 02:35:17 2016 +0000
@@ -60,14 +60,14 @@
 
 
 /**
-* @def  lib_static
-* @brief  Public library is complied by set "lib_static" static.
+* @def  LIB_STATIC
+* @brief  Public library is complied by set "LIB_STATIC" static.
 * @par Parameters
 *    None
 * @return  None.
 */
-#ifndef lib_static
-#define lib_static
+#ifndef LIB_STATIC
+#define LIB_STATIC
 #endif
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/inc/clib_drivers_inline.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,446 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2013 - 2015 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**
+* @file  clib_drivers_inline.h
+* @brief   $Module: CLibCommon $ $PublicVersion: 0.90 $ (=CLIB_VERSION)
+* $Rev: 30 $
+* $Date:: 2014-02-13 21:21:47 +0900#$
+* - Description: Common code for drivers and more.
+*/
+
+#ifndef  CLIB_DRIVERS_INLINE_H
+#define  CLIB_DRIVERS_INLINE_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+/* in clib_drivers_typedef.h */
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+/* in clib_drivers_typedef.h */
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+/* in clib_drivers_typedef.h */
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+
+/**
+* @brief   Cast with range check
+*
+* @param   input Input value
+* @param   output Output value
+* @return  Error Code. 0=No Error.
+*/
+INLINE errnum_t  R_int_t_to_int8_t( int_t input, int8_t *output )
+{
+    return  R_int32_t_to_int8_t( input, output );
+}
+
+
+/**
+* @brief   Fast mod operation
+*
+* @param   value Left operand
+* @return  value % N
+*
+* @par Description
+* - This is shared description of
+*   R_Mod_2s, R_Mod_4s, R_Mod_8s, R_Mod_16s, R_Mod_32s, R_Mod_64s,
+*   R_Mod_2u, R_Mod_4u, R_Mod_8u, R_Mod_16u, R_Mod_32u, R_Mod_64u.
+* - Porting layer of fast % operator.
+* - MISRA & IPA SEC confirmed version.
+* - Minus value is expected 2's complement.
+* - Not same C99 % operator.
+*   - Sample: R_Mod_4s( - 7 ) == +1.  Sample: -7 % 4 == -3
+*/
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Mod_2s( int_fast32_t const  value )
+{
+    enum { mask = 1 };
+    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
+}
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Mod_4s( int_fast32_t const  value )
+{
+    enum { mask = 3 };
+    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
+}
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Mod_8s( int_fast32_t const  value )
+{
+    enum { mask = 7 };
+    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
+}
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Mod_16s( int_fast32_t const  value )
+{
+    enum { mask = 15 };
+    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
+}
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Mod_32s( int_fast32_t const  value )
+{
+    enum { mask = 31 };
+    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
+}
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Mod_64s( int_fast32_t const  value )
+{
+    enum { mask = 63 };
+    return  ((int_fast32_t)((uint_fast32_t)(value) & mask));
+}
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Mod_2u( uint_fast32_t const  value )
+{
+    return  ((value) & 1u);
+}
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Mod_4u( uint_fast32_t const  value )
+{
+    return  ((value) & 3u);
+}
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Mod_8u( uint_fast32_t const  value )
+{
+    return  ((value) & 7u);
+}
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Mod_16u( uint_fast32_t const  value )
+{
+    return  ((value) & 15u);
+}
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Mod_32u( uint_fast32_t const  value )
+{
+    return  ((value) & 31u);
+}
+
+
+/**
+* @brief   Fast mod operation. See <R_Mod_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Mod_64u( uint_fast32_t const  value )
+{
+    return  ((value) & 63u);
+}
+
+
+/**
+* @brief   Fast ceil operation
+*
+* @param   value Left operand
+* @return  Ceil( value / N )
+*
+* @par Description
+* - This is shared description of
+*   R_Ceil_2s, R_Ceil_4s, R_Ceil_8s, R_Ceil_16s, R_Ceil_32s, R_Ceil_64s,
+*   R_Ceil_2u, R_Ceil_4u, R_Ceil_8u, R_Ceil_16u, R_Ceil_32u, R_Ceil_64u.
+* - Porting layer of fast ceil operation.
+* - Function version is confirmed with MISRA & IPA SEC.
+*/
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Ceil_2s( int_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 1;
+    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
+}
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Ceil_4s( int_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 3;
+    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
+}
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Ceil_8s( int_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 7;
+    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
+}
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Ceil_16s( int_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 15;
+    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
+}
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Ceil_32s( int_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 31;
+    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
+}
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE int_fast32_t  R_Ceil_64s( int_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 63;
+    return  ((int_fast32_t)((uint_fast32_t)((value)+mask)&~mask));
+}
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Ceil_2u( uint_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 1;
+    return  (((value)+mask)&~mask);
+}
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Ceil_4u( uint_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 3;
+    return  (((value)+mask)&~mask);
+}
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Ceil_8u( uint_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 7;
+    return  (((value)+mask)&~mask);
+}
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Ceil_16u( uint_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 15;
+    return  (((value)+mask)&~mask);
+}
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Ceil_32u( uint_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 31;
+    return  (((value)+mask)&~mask);
+}
+
+
+/**
+* @brief   Fast ceil operation. See <R_Ceil_N>.
+*
+* @par Parameters
+*    None
+* @return  None.
+*/
+INLINE uint_fast32_t  R_Ceil_64u( uint_fast32_t const  value )
+{
+    static const uint_fast32_t  mask = 63;
+    return  (((value)+mask)&~mask);
+}
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif  /* CLIB_DRIVERS_INLINE_H */
+
+
+
--- a/common/inc/clib_drivers_typedef.h	Thu Dec 03 07:55:42 2015 +0000
+++ b/common/inc/clib_drivers_typedef.h	Wed Jan 20 02:35:17 2016 +0000
@@ -66,6 +66,19 @@
 typedef  unsigned char   bool8_t;
 
 
+/**
+* @typedef  IntBoxType
+* @brief  IntBoxType
+*/
+typedef struct st_IntBoxType  IntBoxType;
+struct st_IntBoxType {
+    int  MinX;
+    int  MinY;
+    int  Width;
+    int  Height;
+};
+
+
 /******************************************************************************
 Macro definitions
 ******************************************************************************/
@@ -117,6 +130,66 @@
 #define  U8_255   255
 
 
+/**
+* @def  R_CEIL_2U
+* @brief  Fast ceil operation. Macro version. See <R_Ceil_N>.
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  R_CEIL_2U( value )   (((value)+1)&~1)
+
+
+/**
+* @def  R_CEIL_4U
+* @brief  Fast ceil operation. Macro version. See <R_Ceil_N>.
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  R_CEIL_4U( value )   (((value)+3)&~3)
+
+
+/**
+* @def  R_CEIL_8U
+* @brief  Fast ceil operation. Macro version. See <R_Ceil_N>.
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  R_CEIL_8U( value )   (((value)+7)&~7)
+
+
+/**
+* @def  R_CEIL_16U
+* @brief  Fast ceil operation. Macro version. See <R_Ceil_N>.
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  R_CEIL_16U( value )  (((value)+15)&~15)
+
+
+/**
+* @def  R_CEIL_32U
+* @brief  Fast ceil operation. Macro version. See <R_Ceil_N>.
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  R_CEIL_32U( value )  (((value)+31)&~31)
+
+
+/**
+* @def  R_CEIL_64U
+* @brief  Fast ceil operation. Macro version. See <R_Ceil_N>.
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  R_CEIL_64U( value )  (((value)+63)&~63)
+
+
 /******************************************************************************
 Variable Externs
 ******************************************************************************/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/inc/clib_samples.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,77 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/******************************************************************************
+* $FileName: clib_samples.h $
+* $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 40 $
+* $Date:: 2014-03-20 18:46:41 +0900#$
+* Description: Sample API
+*******************************************************************************/
+
+
+#ifndef  CLIB_SAMLES_H
+#define  CLIB_SAMLES_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include  "r_ospl_typedef.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+
+    /******************************************************************************
+    Typedef definitions
+    ******************************************************************************/
+    /* In "clib_samples_typedef.h" */
+
+    /******************************************************************************
+    Macro definitions
+    ******************************************************************************/
+    /* In "clib_samples_typedef.h" */
+
+    /******************************************************************************
+    Variable Externs
+    ******************************************************************************/
+    /* In "clib_samples_typedef.h" */
+
+    /******************************************************************************
+    Functions Prototypes
+    ******************************************************************************/
+
+    errnum_t  R_Sample_GetBigMemory( uint8_t **const  out_Address,  size_t *const  out_Size );
+
+#if IS_VDC_SAMPLE_VRAM_USED
+    errnum_t  R_Sample_GetBigMemory_FromVDC_Sample( void * /*<type**>*/ out_Address, size_t *out_Size );
+#endif
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif /* __cplusplus */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/inc/clib_samples_private.h	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,56 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/******************************************************************************
+* $FileName: window_surfaces.h $
+* $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 47 $
+* $Date:: 2014-01-06 18:18:48 +0900#$
+* Description  : Sample API
+*******************************************************************************/
+
+#ifndef  CLIB_SAMPLES_PRIVATE_H
+#define  CLIB_SAMPLES_PRIVATE_H
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Variable Externs
+******************************************************************************/
+
+/******************************************************************************
+Functions Prototypes
+******************************************************************************/
+
+void  R_MEMORY_SECTION_GetMemory_ClibSamplesC( uint8_t **out_Address,  size_t *out_Size );
+
+#endif
--- a/common/src/clib_drivers.c	Thu Dec 03 07:55:42 2015 +0000
+++ b/common/src/clib_drivers.c	Wed Jan 20 02:35:17 2016 +0000
@@ -84,3 +84,86 @@
 }
 
 
+/**
+* @brief   Cast with range check
+*
+* @param   input Input value
+* @param   output Output value
+* @return  Error Code. 0=No Error.
+*/
+errnum_t  R_int32_t_to_int16_t( int32_t input, int16_t *output )
+{
+    IF ( input < -32768  ||  input > 32767 ) {
+        return  E_OTHERS;
+    }
+
+    *output = (int16_t) input;
+    return  0;
+}
+
+
+/**
+* @brief   Cast with range check
+*
+* @param   input Input value
+* @param   output Output value
+* @return  Error Code. 0=No Error.
+*/
+errnum_t  R_int32_t_to_uint8_t( int32_t input, uint8_t *output )
+{
+    IF ( input < 0  ||  input > 255 ) {
+        return  E_OTHERS;
+    }
+
+    *output = (uint8_t) input;
+    return  0;
+}
+
+
+/**
+* @brief   Returns whether specified value has 1 bit only 1.
+*
+* @param   Value Input value
+* @return  Returns whether specified value has 1 bit only 1.
+*/
+bool_t  Is1bitOnlyInt( uint32_t Value )
+{
+    if ( (Value & 0x0000FFFF) == 0 ) {
+        Value >>= 16;
+    }
+    if ( (Value & 0x000000FF) == 0 ) {
+        Value >>=  8;
+    }
+    if ( (Value & 0x0000000F) == 0 ) {
+        Value >>=  4;
+    }
+    if ( (Value & 0x00000003) == 0 ) {
+        Value >>=  2;
+    }
+    if ( (Value & 0x00000001) == 0 ) {
+        Value >>=  1;
+    }
+    return  ( Value == 1 );
+}
+
+
+/**
+* @brief   Get whether 2 "IntBoxType"s are same area.
+*
+* @param   in_BoxA A box
+* @param   in_BoxB Other box
+* @param   out_IsSame Whether 2 "IntBoxType"s are same area.
+* @return  Error Code. 0=No Error.
+*/
+errnum_t  IntBoxType_isSame( const IntBoxType *in_BoxA, const IntBoxType *in_BoxB, bool_t *out_IsSame )
+{
+    *out_IsSame = (
+                      in_BoxA->MinX   == in_BoxB->MinX  &&
+                      in_BoxA->MinY   == in_BoxB->MinY  &&
+                      in_BoxA->Width  == in_BoxB->Width  &&
+                      in_BoxA->Height == in_BoxB->Height );
+
+    return  0;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/clib_samples.c	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,104 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/******************************************************************************
+* $FileName: clib_samples.c $
+* $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION)
+* $Rev: 52 $
+* $Date:: 2014-03-20 18:41:05 +0900#$
+* Description: Sample functions
+*******************************************************************************/
+
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+*******************************************************************************/
+#include  "Project_Config.h"
+#include  "r_typedefs.h"
+#include  "r_ospl.h"
+#include  "clib_samples.h"
+#if ! IS_VDC_SAMPLE_VRAM_USED
+#include  "clib_samples_private.h"
+#endif
+
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+
+/******************************************************************************
+Imported global variables and functions (from other files)
+******************************************************************************/
+
+/******************************************************************************
+Exported global variables and functions (to be accessed by other files)
+******************************************************************************/
+
+/******************************************************************************
+Private global variables and functions
+******************************************************************************/
+
+/******************************************************************************
+* Function Name: [R_Sample_GetBigMemory]
+* Description  :
+* Arguments    :
+* Return Value : Error code, 0=No error
+******************************************************************************/
+errnum_t  R_Sample_GetBigMemory( uint8_t **const  out_Address,  size_t *const  out_Size )
+{
+#if IS_VDC_SAMPLE_VRAM_USED
+    errnum_t          e;
+    static uint8_t   *address;
+    static size_t     memory_size;
+
+    IF_DQ( out_Address == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+    IF_DQ( out_Size    == NULL ) {
+        e=E_OTHERS;
+        goto fin;
+    }
+
+    if ( address == NULL ) {
+        e= R_Sample_GetBigMemory_FromVDC_Sample( &address, &memory_size );
+        IF(e!=0) {
+            goto fin;
+        }
+    }
+    *out_Address = address;
+    *out_Size    = memory_size;
+
+    e=0;
+fin:
+    return  e;
+#else
+    R_MEMORY_SECTION_GetMemory_ClibSamplesC( out_Address, out_Size );
+    return  0;
+#endif
+}
+
+
--- a/config/Project_Config.h	Thu Dec 03 07:55:42 2015 +0000
+++ b/config/Project_Config.h	Wed Jan 20 02:35:17 2016 +0000
@@ -37,8 +37,11 @@
 
 /* This file must be included at first of source file */
 /* Include configuration header files of drivers and applications */
+/* The #include parameter must be not depended on include path for other projects */
 #include  "Project_Config_Sub.h"
 #include  "../ospl/inc/r_ospl_config.h"
+#include  "../common/inc/clib_drivers_config.h"
+#include  "../RGA/inc/RGA_Config.h"
 
 
 #ifdef __cplusplus
--- a/config/Project_Config_Sub.h	Thu Dec 03 07:55:42 2015 +0000
+++ b/config/Project_Config_Sub.h	Wed Jan 20 02:35:17 2016 +0000
@@ -98,6 +98,16 @@
 #define  IS_VDC_SAMPLE_VRAM_USED  0
 
 
+/**
+* @def  R_ARM
+* @brief  ARM core = 1, otherwise = not define
+* @par Parameters
+*    None
+* @return  None.
+*/
+#define  R_ARM  1
+
+
 /******************************************************************************
 Variable Externs
 ******************************************************************************/
--- a/ospl/inc/r_ospl.h	Thu Dec 03 07:55:42 2015 +0000
+++ b/ospl/inc/r_ospl.h	Wed Jan 20 02:35:17 2016 +0000
@@ -1017,6 +1017,8 @@
 *
 * @par Description
 *    This function must be modified by MMU setting.
+*    If "E_ACCESS_DENIED" error was raised, you may know the variable by
+*    looking at value of "Address" argument and map file.
 */
 errnum_t  R_OSPL_ToCachedAddress( const volatile void *const  Address, void *const  out_CachedAddress );
 
@@ -1030,6 +1032,8 @@
 *
 * @par Description
 *    This function must be modified by MMU setting.
+*    If "E_ACCESS_DENIED" error was raised, you may know the variable by
+*    looking at value of "Address" argument and map file.
 */
 errnum_t  R_OSPL_ToUncachedAddress( const volatile void *const  Address, void *const  out_UncachedAddress );
 
--- a/ospl/inc/r_ospl_test.h	Thu Dec 03 07:55:42 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*******************************************************************************
-* DISCLAIMER
-* This software is supplied by Renesas Electronics Corporation and is only
-* intended for use with Renesas products. No other uses are authorized. This
-* software is owned by Renesas Electronics Corporation and is protected under
-* all applicable laws, including copyright laws.
-* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
-* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
-* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
-* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
-* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
-* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
-* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
-* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
-* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-* Renesas reserves the right, without notice, to make changes to this software
-* and to discontinue the availability of this software. By using this software,
-* you agree to the additional terms and conditions found by accessing the
-* following link:
-* http://www.renesas.com/disclaimer
-* Copyright (C) 2012 - 2015 Renesas Electronics Corporation. All rights reserved.
-*******************************************************************************/
-/**
-* @file  r_ospl_test.h
-* @brief   Test support functions
-*
-* $Module: OSPL $ $PublicVersion: 0.90 $ (=R_OSPL_VERSION)
-* $Rev: 35 $
-* $Date:: 2014-04-15 21:38:18 +0900#$
-*/
-
-#ifndef R_OSPL_TEST_H
-#define R_OSPL_TEST_H
-
-
-/******************************************************************************
-Includes   <System Includes> , "Project Includes"
-******************************************************************************/
-#include  "Project_Config.h"
-
-#ifdef R_OSPL_TEST_CODE
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-/******************************************************************************
-Typedef definitions
-******************************************************************************/
-
-/**
-* @enum   r_ospl_axi_envronment_t
-* @brief  r_ospl_axi_envronment_t
-*
-*    - R_OSPL_AXI_L2CACHED - 0
-*    - R_OSPL_AXI_L2STRONGLY - 1
-*/
-typedef enum st_r_ospl_axi_envronment_t  r_ospl_axi_envronment_t;
-enum st_r_ospl_axi_envronment_t {
-    R_OSPL_AXI_L2CACHED,
-    R_OSPL_AXI_L2STRONGLY
-};
-
-
-/******************************************************************************
-Macro definitions
-******************************************************************************/
-
-/******************************************************************************
-Variable Externs
-******************************************************************************/
-
-/******************************************************************************
-Functions Prototypes
-******************************************************************************/
-
-/**
-* @brief   R_OSPL_AXI_SetEnvironment
-*
-* @param   Environment <r_ospl_axi_envronment_t>
-* @return  Error Code. 0=No Error.
-*/
-errnum_t  R_OSPL_AXI_SetEnvironment( r_ospl_axi_envronment_t Environment );
-
-
-/***********************************************************************
-* End of File:
-************************************************************************/
-#ifdef __cplusplus
-}  /* extern "C" */
-#endif /* __cplusplus */
-
-#endif /* R_OSPL_TEST_CODE */
-#endif /* R_OSPL_TEST_H */
-
--- a/ospl/inc/r_ospl_typedef.h	Thu Dec 03 07:55:42 2015 +0000
+++ b/ospl/inc/r_ospl_typedef.h	Wed Jan 20 02:35:17 2016 +0000
@@ -107,6 +107,15 @@
 typedef uint8_t        byte_t;
 
 
+/**
+* @typedef  ssize_t
+* @brief  Signed size type. This is a POSIX specification.
+*/
+#if ! defined( __GNUC__ )  ||  defined( __CC_ARM )
+typedef int  ssize_t;
+#endif
+
+
 /***********************************************************************
 * Section: Global
 ************************************************************************/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ospl/porting/TOOLCHAIN_GCC/r_ospl_os_less_asm.s	Wed Jan 20 02:35:17 2016 +0000
@@ -0,0 +1,140 @@
+;/*******************************************************************************
+;* DISCLAIMER
+;* This software is supplied by Renesas Electronics Corporation and is only
+;* intended for use with Renesas products. No other uses are authorized. This
+;* software is owned by Renesas Electronics Corporation and is protected under
+;* all applicable laws, including copyright laws.
+;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+;* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+;* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+;* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+;* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+;* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+;* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+;* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+;* Renesas reserves the right, without notice, to make changes to this software
+;* and to discontinue the availability of this software. By using this software,
+;* you agree to the additional terms and conditions found by accessing the
+;* following link:
+;* http://www.renesas.com/disclaimer
+;* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
+;*******************************************************************************/
+;/*******************************************************************************
+;* $FileName: r_ospl_os_less_asm.s $
+;* $Module: OSPL $ $PublicVersion: 0.83 $ (=R_OSPL_VERSION)
+;* $Rev: 35 $
+;* $Date:: 2014-04-15 21:38:18 +0900#$
+;* Description : OS Porting Layer API
+;******************************************************************************/
+
+
+@   PRESERVE8
+	.section  .text @, CODE, READONLY
+
+
+;/******************************************************************************
+;* Function Name: [R_OSPL_MEMORY_Flush_Sub]
+;* Description  :
+;* Arguments    : None
+;* Return Value : None
+;******************************************************************************/
+
+	.global  R_OSPL_MEMORY_Flush_Sub
+
+R_OSPL_MEMORY_Flush_Sub:
+
+	PUSH    {r4-r7}
+
+	MRC     p15, 1, r7, c0, c0, 1   ;// r7 = p15(CLIDR);  // [r4] CLIDR(LoC) * 2  // LoC: level of coherency
+	MOV     r4, r7, LSR #23         ;// r4 = r7 >> 23;    //   :
+	ANDS    r4, r4, #0xE            ;// r4 &= 0xE;        //   :
+	BEQ     Fin                     ;// if ( r4 == 0 ) goto Fin;  // if LoC == 0, no need to clean
+
+	MOV     r3, #0                  ;// for ( r3 = 0;  r3 < r4;  r3 += 2 ) { // [r3]: current_cache_level * 2
+Loop1:
+	ADD     r2, r3, r3, LSR #1      ;// r2 = r3 + (r3 >> 1);  // r2 = current_cache_level * 3
+	MOV     r0, r7, LSR r2          ;// r0 = (r7 >> r2);  // r0 = CLIDR(Ctype#)
+	AND     r0, r0, #7              ;// r0 &= 7;          //  :
+	CMP     r0, #2                  ;// if ( r0 < 2 ) goto Continue1;
+	BLT     Continue1               ;//  :        // If no cache or only instruction cache at this level
+
+	MCR     p15, 2, r3, c0, c0, 0   ;// p15(CSSELR) = r3;    // CSSELR: Cache Size Selection Register
+	ISB                             ;// Guarantee MCR operation
+	MRC     p15, 1, r0, c0, c0, 0   ;// r0 = p15(CCSIDR);    // CCSIDR: Cache Size ID Registers
+	AND     r6, r0, #7              ;// r6 = r0 & 7;         // CCSIDR(LineSize): log2(cache_line_byte)-4
+	ADD     r6, r6, #4              ;// r6 += 4;             // [r6] log2(cache_line_byte)
+	LDR     r7, =0x3FF              ;// r7 = 0x3FF;          // [r7] CCSIDR(Associativity): associativity_value - 1
+	AND     r7, r7, r0, LSR #3      ;// r7 = r7 & r0 >> 3;   //   :
+	CLZ     r5, r7                  ;// r5 = CLZ( r7 );      // [r5] log2(WaySize), if exponential 2
+	LDR     r2, =0x7FFF             ;// r2 = 0x7FFF;         // CCSIDR(NumSets) : max number of the index size - 1
+	AND     r2, r2, r0, LSR #13     ;// r2 = r2 & r0 >> 13;  //  :
+	                                ;// for ( /*r2*/;   r2 >= 0;  r2 -= 1 ) {  // [r2] Set number
+Loop2:
+	MOV     r1, r7                  ;// for ( r1 = r7;  r1 >= 0;  r1 -= 1 ) {  // [r1] Way number
+Loop3:
+	ORR     r0, r3, r1, LSL r5      ;//     r0 = r3 | (r1 << r5)
+	ORR     r0, r0, r2, LSL r6      ;//             | (r2 << r6);
+	MCR     p15, 0, r0, c7, c14, 2  ;//     p15(DCCISW) = r0;  // Clean(WriteBack) and Invalidate
+	SUBS    r1, r1, #1              ;// }  /* End of r1 loop */
+	BGE     Loop3                   ;//  :
+	SUBS    r2, r2, #1              ;// }  /* End of r2 loop */
+	BGE     Loop2                   ;//  :
+Continue1:
+	ADD     r3, r3, #2              ;// }  /* End of r3 loop */
+	CMP     r4, r3                  ;//  :
+	BGT     Loop1                   ;//  :
+
+Fin:
+	DSB
+	POP    {r4-r7}
+	BX     lr
+
+
+;/******************************************************************************
+;* Function Name: [R_OSPL_MEMORY_GetCacheLineSize]
+;* Description  :
+;* Arguments    : None
+;* Return Value : None
+;******************************************************************************/
+
+	.global  R_OSPL_MEMORY_GetCacheLineSize
+
+R_OSPL_MEMORY_GetCacheLineSize:
+
+	MRC     p15, 1, r0, c0, c0, 0   ;// r0 = p15(CCSIDR);    // CCSIDR: Cache Size ID Registers
+	AND     r0, r0, #7              ;// r0 = r0 & 7;         // CCSIDR.LineSize: log2(cache_line_byte)-4
+	ADD     r0, r0, #4              ;// r0 += 4;             //
+	MOV     r1, #1                  ;// r0 = 1 << r0;        // [r0] cache_line_byte
+	MOV     r0, r1, LSL r0          ;//    :
+
+	BX     lr
+
+
+;/******************************************************************************
+;* Function Name: [R_OSPL_MEMORY_RangeFlush_Sub]
+;* Description  :
+;* Arguments    : r0: Start address
+;*              : r1: Over address (Last + 1)
+;*              : r2: Cache line size
+;* Return Value : None
+;******************************************************************************/
+
+	.global  R_OSPL_MEMORY_RangeFlush_Sub
+
+R_OSPL_MEMORY_RangeFlush_Sub:
+
+Loop:
+	CMP     r0, r1                  ;// for ( r0 = r0;  r0 < r1;  r0 += r2 ) {
+	BGE     Fin2                    ;//  :
+	MCR     p15, 0, r0, c7, c6, 1   ;//     p15(DCIMVAC) = r0;  // Invalidate
+	ADD     r0, r0, r2              ;// }
+	B       Loop                    ;//  :
+Fin2:
+	DSB
+	BX     lr
+
+	.END
+
+
+
--- a/ospl/porting/inline_body.c	Thu Dec 03 07:55:42 2015 +0000
+++ b/ospl/porting/inline_body.c	Wed Jan 20 02:35:17 2016 +0000
@@ -30,4 +30,10 @@
 */
 
 #define  R_OSPL_MAKE_INLINE_BODY
+#include  "Project_Config.h"
 #include  "r_ospl.h"
+#include  "iodefine.h" /* for inline function in "clib_registers.h" */
+#include  "clib_registers.h"
+#include  "clib_drivers.h"
+#include  "window_surfaces.h"
+#include  "RGA_Port.h"
--- a/ospl/porting/r_ospl_debug.c	Thu Dec 03 07:55:42 2015 +0000
+++ b/ospl/porting/r_ospl_debug.c	Wed Jan 20 02:35:17 2016 +0000
@@ -119,8 +119,9 @@
 
     if ( self->Address != NULL ) {
         if ( IS( self->IsPrintf ) ) {
-            r= printf( "Debug_watch( %d ): 0x%08X\n", in_IndexNum, *self->Address );
+            r= printf( "Debug_watch( %d ): 0x%08X\n", in_IndexNum, (uintptr_t) *self->Address );
             R_UNREFERENCED_VARIABLE( r ); /* QAC 3200 : This is not error information */
+            /* Cast of "uintptr_t" is for avoiding "format" warning of GNU_ARM */
         }
         if ( *self->Address == self->BreakValue ) {
             R_DEBUG_BREAK();
--- a/ospl/porting/r_ospl_memory.c	Thu Dec 03 07:55:42 2015 +0000
+++ b/ospl/porting/r_ospl_memory.c	Wed Jan 20 02:35:17 2016 +0000
@@ -177,7 +177,7 @@
     }
     else if ( address < LRAM_END ) {
         e = 0;
-    } else IF ( address < (uintptr_t)&Image$$RW_DATA_NC$$Base ) {
+    } else IF ( address < UNUSED_UNCACHED_LRAM_START ) {
         e = E_ACCESS_DENIED;
     }
     else if ( address < UNCACHED_LRAM_END ) {
@@ -222,7 +222,7 @@
     errnum_t  e;
 #if  IS_MBED_USED
     uintptr_t  address = (uintptr_t) in_Address;
-    uintptr_t  nc_base = (uintptr_t) &Image$$RW_DATA_NC$$Base;
+    uintptr_t  nc_base = UNUSED_UNCACHED_LRAM_START;
     const uintptr_t  uncached_from_cached = UNUSED_UNCACHED_LRAM_START - LRAM_START;
 #else
     uintptr_t const  address = (uintptr_t) in_Address;
--- a/ospl/porting/r_ospl_unrecoverable.c	Thu Dec 03 07:55:42 2015 +0000
+++ b/ospl/porting/r_ospl_unrecoverable.c	Wed Jan 20 02:35:17 2016 +0000
@@ -34,9 +34,6 @@
 Includes   <System Includes> , "Project Includes"
 ******************************************************************************/
 #include  "r_ospl.h"
-#ifdef  R_OSPL_TEST_CODE
-#include  "Test/T_OSPL.h"
-#endif
 
 
 /******************************************************************************
@@ -72,12 +69,7 @@
 
     was_all_enabled = R_OSPL_DisableAllInterrupt();
 
-#ifdef  R_OSPL_TEST_CODE
-    TEST_CODE_CallbackFromTestCode( R_OSPL_RaiseUnrecoverable );
-    is_loop = false;
-#else
     R_DebugBreak( NULL, e );
-#endif
 
     while ( IS( is_loop ) ) {
         /* Infinite Loop. Set "is_loop" by the debugger */
--- a/ospl/src/r_ospl.c	Thu Dec 03 07:55:42 2015 +0000
+++ b/ospl/src/r_ospl.c	Wed Jan 20 02:35:17 2016 +0000
@@ -1097,7 +1097,7 @@
     printf( "    .Count = %d\n", self->Count );
     for ( so_index = 0;  so_index < self->Count;  so_index += 1 ) {
         printf( "    .Area[%d].Key, Index = 0x%08X, %d\n",
-                so_index,  array[ so_index ].Key,  array[ so_index ].Index );
+                so_index,  (uintptr_t) array[ so_index ].Key,  array[ so_index ].Index );
     }
     printf( "    .FirstFreeIndex = %d\n", self->FirstFreeIndex );
     for ( index = 0;  index < self->MaxCount;  index += 1 ) {
@@ -1177,7 +1177,10 @@
 
     *self->PointerToState = self->StateValueOfOnInterrupting;
 
-    e= async->InterruptCallback( InterruptSource, self );
+
+
+    e= async->InterruptCallback( InterruptSource, self );  /* Main of callback */
+
 
 
     if ( e != 0 ) {
@@ -1210,7 +1213,18 @@
     gs_nested_interrupt_level -= 1;
 
     if ( gs_nested_interrupt_level == 0 ) {
+        if ( gs_master != NULL ) {
+            current_thread = gs_master->CurrentThread;
+            gs_master->CurrentThread = NULL;
+        }
+
+
         R_DEBUG_BREAK_IF_ERROR();
+
+
+        if ( gs_master != NULL ) {
+            gs_master->CurrentThread = current_thread;
+        }
     }
 #endif
     R_UNREFERENCED_VARIABLE( e );