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.
JPEG | Correspondence |
Width | >0(greater than 0) |
Height | >0(greater than 0) |
Color format | YCbCr444, YCbCr422, YCbCr420, YCbCr411 |
Bitmap | Correspondence |
Width | >0(greater than 0) |
Height | >0(greater than 0) |
Color format | YCbCr422 |
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
RGA/src/window_surfaces.c@13:1ee2176ef13f, 2017-04-24 (annotated)
- Committer:
- dkato
- Date:
- Mon Apr 24 08:16:23 2017 +0000
- Revision:
- 13:1ee2176ef13f
- Parent:
- 3:9f857750e4e9
Add "SetQuality()" to JCU.
; Bug fixes.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
1050186 | 3:9f857750e4e9 | 1 | /******************************************************************************* |
1050186 | 3:9f857750e4e9 | 2 | * DISCLAIMER |
1050186 | 3:9f857750e4e9 | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
1050186 | 3:9f857750e4e9 | 4 | * intended for use with Renesas products. No other uses are authorized. This |
1050186 | 3:9f857750e4e9 | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
1050186 | 3:9f857750e4e9 | 6 | * all applicable laws, including copyright laws. |
1050186 | 3:9f857750e4e9 | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
1050186 | 3:9f857750e4e9 | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
1050186 | 3:9f857750e4e9 | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
1050186 | 3:9f857750e4e9 | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
1050186 | 3:9f857750e4e9 | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
1050186 | 3:9f857750e4e9 | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
1050186 | 3:9f857750e4e9 | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
1050186 | 3:9f857750e4e9 | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
1050186 | 3:9f857750e4e9 | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
1050186 | 3:9f857750e4e9 | 16 | * Renesas reserves the right, without notice, to make changes to this software |
1050186 | 3:9f857750e4e9 | 17 | * and to discontinue the availability of this software. By using this software, |
1050186 | 3:9f857750e4e9 | 18 | * you agree to the additional terms and conditions found by accessing the |
1050186 | 3:9f857750e4e9 | 19 | * following link: |
1050186 | 3:9f857750e4e9 | 20 | * http://www.renesas.com/disclaimer |
1050186 | 3:9f857750e4e9 | 21 | * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved. |
1050186 | 3:9f857750e4e9 | 22 | *******************************************************************************/ |
1050186 | 3:9f857750e4e9 | 23 | /** |
1050186 | 3:9f857750e4e9 | 24 | * @file window_surfaces.c |
1050186 | 3:9f857750e4e9 | 25 | * @brief $Module: CLibCommon $ $PublicVersion: 1.00 $ (=CLIB_VERSION) |
1050186 | 3:9f857750e4e9 | 26 | * $Rev: 51 $ |
1050186 | 3:9f857750e4e9 | 27 | * $Date:: 2014-03-14 18:42:33 +0900#$ |
1050186 | 3:9f857750e4e9 | 28 | */ |
1050186 | 3:9f857750e4e9 | 29 | |
1050186 | 3:9f857750e4e9 | 30 | |
1050186 | 3:9f857750e4e9 | 31 | /****************************************************************************** |
1050186 | 3:9f857750e4e9 | 32 | Includes <System Includes> , "Project Includes" |
1050186 | 3:9f857750e4e9 | 33 | *******************************************************************************/ |
1050186 | 3:9f857750e4e9 | 34 | #include "r_typedefs.h" |
1050186 | 3:9f857750e4e9 | 35 | #include "lcd_panel.h" |
1050186 | 3:9f857750e4e9 | 36 | #include "r_ospl.h" |
1050186 | 3:9f857750e4e9 | 37 | #include "clib_registers.h" |
1050186 | 3:9f857750e4e9 | 38 | #include "clib_drivers.h" |
1050186 | 3:9f857750e4e9 | 39 | #include "clib_samples.h" |
1050186 | 3:9f857750e4e9 | 40 | #include "window_surfaces.h" |
1050186 | 3:9f857750e4e9 | 41 | #include "vsync.h" |
1050186 | 3:9f857750e4e9 | 42 | #include "window_surfaces_private.h" |
1050186 | 3:9f857750e4e9 | 43 | #include "RGA.h" |
1050186 | 3:9f857750e4e9 | 44 | #include "RGA_Port.h" |
1050186 | 3:9f857750e4e9 | 45 | #if USE_LCD |
1050186 | 3:9f857750e4e9 | 46 | #include "lcd_if.h" |
1050186 | 3:9f857750e4e9 | 47 | #endif |
1050186 | 3:9f857750e4e9 | 48 | #include <stdio.h> /* in R_WINDOW_SURFACES_DoMessageLoop */ |
1050186 | 3:9f857750e4e9 | 49 | |
1050186 | 3:9f857750e4e9 | 50 | |
1050186 | 3:9f857750e4e9 | 51 | /****************************************************************************** |
1050186 | 3:9f857750e4e9 | 52 | Typedef definitions |
1050186 | 3:9f857750e4e9 | 53 | ******************************************************************************/ |
1050186 | 3:9f857750e4e9 | 54 | |
1050186 | 3:9f857750e4e9 | 55 | /** |
1050186 | 3:9f857750e4e9 | 56 | * @typedef gs_frame_width_height_t |
1050186 | 3:9f857750e4e9 | 57 | * @brief gs_frame_width_height_t |
1050186 | 3:9f857750e4e9 | 58 | */ |
1050186 | 3:9f857750e4e9 | 59 | #ifdef IS_WINDOW_SURFACES_EX |
1050186 | 3:9f857750e4e9 | 60 | typedef struct st_gs_frame_width_height_t gs_frame_width_height_t; |
1050186 | 3:9f857750e4e9 | 61 | struct st_gs_frame_width_height_t { |
1050186 | 3:9f857750e4e9 | 62 | int_fast32_t Width; |
1050186 | 3:9f857750e4e9 | 63 | int_fast32_t Height; |
1050186 | 3:9f857750e4e9 | 64 | }; |
1050186 | 3:9f857750e4e9 | 65 | #endif |
1050186 | 3:9f857750e4e9 | 66 | |
1050186 | 3:9f857750e4e9 | 67 | |
1050186 | 3:9f857750e4e9 | 68 | /** |
1050186 | 3:9f857750e4e9 | 69 | * @typedef gs_rectangle_t |
1050186 | 3:9f857750e4e9 | 70 | * @brief gs_rectangle_t |
1050186 | 3:9f857750e4e9 | 71 | */ |
1050186 | 3:9f857750e4e9 | 72 | #ifdef IS_WINDOW_SURFACES_EX |
1050186 | 3:9f857750e4e9 | 73 | typedef struct st_gs_rectangle_t gs_rectangle_t; |
1050186 | 3:9f857750e4e9 | 74 | struct st_gs_rectangle_t { |
1050186 | 3:9f857750e4e9 | 75 | int_fast32_t Left; |
1050186 | 3:9f857750e4e9 | 76 | int_fast32_t Top; |
1050186 | 3:9f857750e4e9 | 77 | int_fast32_t Right; /* include right bound pixel */ |
1050186 | 3:9f857750e4e9 | 78 | int_fast32_t Bottom; /* include bottom bound pixel */ /* Top < Bottom */ |
1050186 | 3:9f857750e4e9 | 79 | }; |
1050186 | 3:9f857750e4e9 | 80 | #endif |
1050186 | 3:9f857750e4e9 | 81 | |
1050186 | 3:9f857750e4e9 | 82 | |
1050186 | 3:9f857750e4e9 | 83 | /****************************************************************************** |
1050186 | 3:9f857750e4e9 | 84 | Macro definitions |
1050186 | 3:9f857750e4e9 | 85 | ******************************************************************************/ |
1050186 | 3:9f857750e4e9 | 86 | |
1050186 | 3:9f857750e4e9 | 87 | /* GS_ : global static */ |
1050186 | 3:9f857750e4e9 | 88 | /* VDC5_CHANNEL_0 = LCD_VDC5_CH0_PANEL = ... */ |
1050186 | 3:9f857750e4e9 | 89 | /* VDC5_CHANNEL_1 = LCD_VDC5_CH1_PANEL = ... */ |
1050186 | 3:9f857750e4e9 | 90 | #if WINDOW_SURFACES_DEFAULT_CHANNEL |
1050186 | 3:9f857750e4e9 | 91 | #define GS_CHANNEL_n VDC5_CHANNEL_1 |
1050186 | 3:9f857750e4e9 | 92 | #define GS_LCD_CHn_SIG_FV LCD_CH1_SIG_FV |
1050186 | 3:9f857750e4e9 | 93 | #define GS_LCD_CHn_SIG_FH LCD_CH1_SIG_FH |
1050186 | 3:9f857750e4e9 | 94 | #define GS_LCD_CHn_DISP_VS LCD_CH1_DISP_VS |
1050186 | 3:9f857750e4e9 | 95 | #define GS_LCD_CHn_DISP_VW LCD_CH1_DISP_VW |
1050186 | 3:9f857750e4e9 | 96 | #define GS_LCD_CHn_DISP_HS LCD_CH1_DISP_HS |
1050186 | 3:9f857750e4e9 | 97 | #define GS_LCD_CHn_DISP_HW LCD_CH1_DISP_HW |
1050186 | 3:9f857750e4e9 | 98 | #define GS_LCD_CHn_TCON_HALF LCD_CH1_TCON_HALF |
1050186 | 3:9f857750e4e9 | 99 | #define GS_LCD_CHn_TCON_OFFSET LCD_CH1_TCON_OFFSET |
1050186 | 3:9f857750e4e9 | 100 | #define GS_LCD_CHn_OUT_EDGE LCD_CH1_OUT_EDGE |
1050186 | 3:9f857750e4e9 | 101 | #define GS_LCD_CHn_OUT_FORMAT LCD_CH1_OUT_FORMAT |
1050186 | 3:9f857750e4e9 | 102 | #define GS_LCD_CHn_PANEL_CLK LCD_CH1_PANEL_CLK |
1050186 | 3:9f857750e4e9 | 103 | #define GS_LCD_CHn_PANEL_CLK_DIV LCD_CH1_PANEL_CLK_DIV |
1050186 | 3:9f857750e4e9 | 104 | #define GS_DISPLAY_CH 1 /* 1 or 0 */ |
1050186 | 3:9f857750e4e9 | 105 | #else |
1050186 | 3:9f857750e4e9 | 106 | #define GS_CHANNEL_n VDC5_CHANNEL_0 |
1050186 | 3:9f857750e4e9 | 107 | #define GS_LCD_CHn_SIG_FV LCD_CH0_SIG_FV |
1050186 | 3:9f857750e4e9 | 108 | #define GS_LCD_CHn_SIG_FH LCD_CH0_SIG_FH |
1050186 | 3:9f857750e4e9 | 109 | #define GS_LCD_CHn_DISP_VS LCD_CH0_DISP_VS |
1050186 | 3:9f857750e4e9 | 110 | #define GS_LCD_CHn_DISP_VW LCD_CH0_DISP_VW |
1050186 | 3:9f857750e4e9 | 111 | #define GS_LCD_CHn_DISP_HS LCD_CH0_DISP_HS |
1050186 | 3:9f857750e4e9 | 112 | #define GS_LCD_CHn_DISP_HW LCD_CH0_DISP_HW |
1050186 | 3:9f857750e4e9 | 113 | #define GS_LCD_CHn_TCON_HALF LCD_CH0_TCON_HALF |
1050186 | 3:9f857750e4e9 | 114 | #define GS_LCD_CHn_TCON_OFFSET LCD_CH0_TCON_OFFSET |
1050186 | 3:9f857750e4e9 | 115 | #define GS_LCD_CHn_OUT_EDGE LCD_CH0_OUT_EDGE |
1050186 | 3:9f857750e4e9 | 116 | #define GS_LCD_CHn_OUT_FORMAT LCD_CH0_OUT_FORMAT |
1050186 | 3:9f857750e4e9 | 117 | #define GS_LCD_CHn_PANEL_CLK LCD_CH0_PANEL_CLK |
1050186 | 3:9f857750e4e9 | 118 | #define GS_LCD_CHn_PANEL_CLK_DIV LCD_CH0_PANEL_CLK_DIV |
1050186 | 3:9f857750e4e9 | 119 | #define GS_DISPLAY_CH 0 /* 1 or 0 */ |
1050186 | 3:9f857750e4e9 | 120 | #endif |
1050186 | 3:9f857750e4e9 | 121 | |
1050186 | 3:9f857750e4e9 | 122 | #if 1 |
1050186 | 3:9f857750e4e9 | 123 | #define GS_BUFFER_WIDTH 800 |
1050186 | 3:9f857750e4e9 | 124 | #define GS_BUFFER_HEIGHT 480 |
1050186 | 3:9f857750e4e9 | 125 | #else |
1050186 | 3:9f857750e4e9 | 126 | #define GS_BUFFER_WIDTH GS_LCD_CHn_DISP_HW |
1050186 | 3:9f857750e4e9 | 127 | #define GS_BUFFER_HEIGHT GS_LCD_CHn_DISP_VW |
1050186 | 3:9f857750e4e9 | 128 | #endif |
1050186 | 3:9f857750e4e9 | 129 | |
1050186 | 3:9f857750e4e9 | 130 | #define GS_MEASURE_GPU_LOAD 0 |
1050186 | 3:9f857750e4e9 | 131 | |
1050186 | 3:9f857750e4e9 | 132 | #define GS_DEFAULT_CLEAR_COLOR R_RGA_DEFAULT_CLEAR_COLOR |
1050186 | 3:9f857750e4e9 | 133 | |
1050186 | 3:9f857750e4e9 | 134 | #ifdef R_REE_INIT |
1050186 | 3:9f857750e4e9 | 135 | #define GRAPHICS_GetLvdsParam Graphics_GetLvdsParam |
1050186 | 3:9f857750e4e9 | 136 | #define GRAPHICS_SetLcdTconSettings Graphics_SetLcdTconSettings |
1050186 | 3:9f857750e4e9 | 137 | #define GRAPHICS_SetLcdPanel Graphics_SetLcdPanel |
1050186 | 3:9f857750e4e9 | 138 | #endif |
1050186 | 3:9f857750e4e9 | 139 | #ifdef RZ_A1L |
1050186 | 3:9f857750e4e9 | 140 | #define GRAPHICS_GetLvdsParam( ch ) NULL |
1050186 | 3:9f857750e4e9 | 141 | #define GRAPHICS_SetLcdTconSettings( ch, setting ) GRAPHICS_L_SetLcdTconSettings( setting ) |
1050186 | 3:9f857750e4e9 | 142 | #define GRAPHICS_SetLcdPanel( ch ) GRAPHICS_L_SetLcdPanel() |
1050186 | 3:9f857750e4e9 | 143 | #endif |
1050186 | 3:9f857750e4e9 | 144 | |
1050186 | 3:9f857750e4e9 | 145 | /** |
1050186 | 3:9f857750e4e9 | 146 | * @def GS_OFFSET_BYTE_NOT_SHOW |
1050186 | 3:9f857750e4e9 | 147 | * @brief GS_OFFSET_BYTE_NOT_SHOW |
1050186 | 3:9f857750e4e9 | 148 | */ |
1050186 | 3:9f857750e4e9 | 149 | enum { GS_OFFSET_BYTE_NOT_SHOW = -1 }; |
1050186 | 3:9f857750e4e9 | 150 | |
1050186 | 3:9f857750e4e9 | 151 | |
1050186 | 3:9f857750e4e9 | 152 | /****************************************************************************** |
1050186 | 3:9f857750e4e9 | 153 | Imported global variables and functions (from other files) |
1050186 | 3:9f857750e4e9 | 154 | ******************************************************************************/ |
1050186 | 3:9f857750e4e9 | 155 | |
1050186 | 3:9f857750e4e9 | 156 | /****************************************************************************** |
1050186 | 3:9f857750e4e9 | 157 | Exported global variables and functions (to be accessed by other files) |
1050186 | 3:9f857750e4e9 | 158 | ******************************************************************************/ |
1050186 | 3:9f857750e4e9 | 159 | |
1050186 | 3:9f857750e4e9 | 160 | /****************************************************************************** |
1050186 | 3:9f857750e4e9 | 161 | Private global variables and functions |
1050186 | 3:9f857750e4e9 | 162 | ******************************************************************************/ |
1050186 | 3:9f857750e4e9 | 163 | |
1050186 | 3:9f857750e4e9 | 164 | static errnum_t R_WINDOW_SURFACES_SwapBuffers_Sub( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 165 | int_fast32_t const layer_num ); |
1050186 | 3:9f857750e4e9 | 166 | |
1050186 | 3:9f857750e4e9 | 167 | #ifdef IS_WINDOW_SURFACES_EX |
1050186 | 3:9f857750e4e9 | 168 | errnum_t GS_ToInFrame( |
1050186 | 3:9f857750e4e9 | 169 | gs_frame_width_height_t *SourceFrameBuffer, |
1050186 | 3:9f857750e4e9 | 170 | gs_frame_width_height_t *DestinationFrameBuffer, |
1050186 | 3:9f857750e4e9 | 171 | gs_rectangle_t *SourceRect, |
1050186 | 3:9f857750e4e9 | 172 | gs_rectangle_t *DestinationRect ); |
1050186 | 3:9f857750e4e9 | 173 | #endif |
1050186 | 3:9f857750e4e9 | 174 | |
1050186 | 3:9f857750e4e9 | 175 | |
1050186 | 3:9f857750e4e9 | 176 | /** |
1050186 | 3:9f857750e4e9 | 177 | * @brief alloc_VRAM_stack_sub |
1050186 | 3:9f857750e4e9 | 178 | * |
1050186 | 3:9f857750e4e9 | 179 | * @param in_out_StackPointer in_out_StackPointer |
1050186 | 3:9f857750e4e9 | 180 | * @param OverOfVRAM OverOfVRAM |
1050186 | 3:9f857750e4e9 | 181 | * @param in_out_FrameBuffer in_out_FrameBuffer |
1050186 | 3:9f857750e4e9 | 182 | * @return Error code, 0=No error |
1050186 | 3:9f857750e4e9 | 183 | * |
1050186 | 3:9f857750e4e9 | 184 | * @par Description |
1050186 | 3:9f857750e4e9 | 185 | * - (input) - >stride, ->height, ->buffer_count |
1050186 | 3:9f857750e4e9 | 186 | * - (output) - >buffer_address[(all)] |
1050186 | 3:9f857750e4e9 | 187 | */ |
1050186 | 3:9f857750e4e9 | 188 | static errnum_t alloc_VRAM_stack_sub( uint8_t **const in_out_StackPointer, |
1050186 | 3:9f857750e4e9 | 189 | const uint8_t *const OverOfVRAM, |
1050186 | 3:9f857750e4e9 | 190 | frame_buffer_t *const in_out_FrameBuffer ); /* QAC-3450 */ |
1050186 | 3:9f857750e4e9 | 191 | static errnum_t alloc_VRAM_stack_sub( uint8_t **const in_out_StackPointer, |
1050186 | 3:9f857750e4e9 | 192 | const uint8_t *const OverOfVRAM, |
1050186 | 3:9f857750e4e9 | 193 | frame_buffer_t *const in_out_FrameBuffer ) |
1050186 | 3:9f857750e4e9 | 194 | { |
1050186 | 3:9f857750e4e9 | 195 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 196 | int_fast32_t size_1; |
1050186 | 3:9f857750e4e9 | 197 | int_fast32_t size_all; |
1050186 | 3:9f857750e4e9 | 198 | int_fast32_t buffer_num; |
1050186 | 3:9f857750e4e9 | 199 | uint8_t *stack_pointer; |
1050186 | 3:9f857750e4e9 | 200 | |
1050186 | 3:9f857750e4e9 | 201 | |
1050186 | 3:9f857750e4e9 | 202 | IF_DQ( in_out_StackPointer == NULL ) { |
1050186 | 3:9f857750e4e9 | 203 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 204 | goto fin; |
1050186 | 3:9f857750e4e9 | 205 | } |
1050186 | 3:9f857750e4e9 | 206 | IF_DQ( in_out_FrameBuffer == NULL ) { |
1050186 | 3:9f857750e4e9 | 207 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 208 | goto fin; |
1050186 | 3:9f857750e4e9 | 209 | } |
1050186 | 3:9f857750e4e9 | 210 | |
1050186 | 3:9f857750e4e9 | 211 | |
1050186 | 3:9f857750e4e9 | 212 | stack_pointer = *in_out_StackPointer; |
1050186 | 3:9f857750e4e9 | 213 | |
1050186 | 3:9f857750e4e9 | 214 | |
1050186 | 3:9f857750e4e9 | 215 | /* Set "size_1" */ |
1050186 | 3:9f857750e4e9 | 216 | size_1 = in_out_FrameBuffer->stride * in_out_FrameBuffer->height; |
1050186 | 3:9f857750e4e9 | 217 | size_1 = ( R_Ceil_64s( size_1 ) ); |
1050186 | 3:9f857750e4e9 | 218 | |
1050186 | 3:9f857750e4e9 | 219 | |
1050186 | 3:9f857750e4e9 | 220 | /* Set "size_all" */ |
1050186 | 3:9f857750e4e9 | 221 | size_all = in_out_FrameBuffer->buffer_count * size_1; |
1050186 | 3:9f857750e4e9 | 222 | |
1050186 | 3:9f857750e4e9 | 223 | |
1050186 | 3:9f857750e4e9 | 224 | /* Check */ |
1050186 | 3:9f857750e4e9 | 225 | /* ->MISRA 17.4 */ /* ->SEC R1.3.1 (1) */ |
1050186 | 3:9f857750e4e9 | 226 | IF ( (stack_pointer + size_all) > OverOfVRAM ) { |
1050186 | 3:9f857750e4e9 | 227 | in_out_FrameBuffer->buffer_count = 0; |
1050186 | 3:9f857750e4e9 | 228 | e=E_FEW_ARRAY; |
1050186 | 3:9f857750e4e9 | 229 | goto fin; |
1050186 | 3:9f857750e4e9 | 230 | } |
1050186 | 3:9f857750e4e9 | 231 | /* <-MISRA 17.4 */ /* <-SEC R1.3.1 (1) */ |
1050186 | 3:9f857750e4e9 | 232 | |
1050186 | 3:9f857750e4e9 | 233 | IF ( in_out_FrameBuffer->buffer_count > |
1050186 | 3:9f857750e4e9 | 234 | (int_fast32_t) R_COUNT_OF( in_out_FrameBuffer->buffer_address ) ) { |
1050186 | 3:9f857750e4e9 | 235 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 236 | goto fin; |
1050186 | 3:9f857750e4e9 | 237 | } |
1050186 | 3:9f857750e4e9 | 238 | |
1050186 | 3:9f857750e4e9 | 239 | |
1050186 | 3:9f857750e4e9 | 240 | /* Set "in_out_FrameBuffer->buffer_address" */ |
1050186 | 3:9f857750e4e9 | 241 | for ( buffer_num = 0; |
1050186 | 3:9f857750e4e9 | 242 | buffer_num < in_out_FrameBuffer->buffer_count; |
1050186 | 3:9f857750e4e9 | 243 | buffer_num += 1 ) { |
1050186 | 3:9f857750e4e9 | 244 | in_out_FrameBuffer->buffer_address[ buffer_num ] = stack_pointer; |
1050186 | 3:9f857750e4e9 | 245 | |
1050186 | 3:9f857750e4e9 | 246 | /* ->MISRA 17.4 */ /* ->SEC R1.3.1 (1) */ |
1050186 | 3:9f857750e4e9 | 247 | stack_pointer += size_1; /* MISRA 17.4: Bound check is done by "OverOfVRAM" */ |
1050186 | 3:9f857750e4e9 | 248 | /* <-MISRA 17.4 */ /* <-SEC R1.3.1 (1) */ |
1050186 | 3:9f857750e4e9 | 249 | } |
1050186 | 3:9f857750e4e9 | 250 | for ( /* buffer_num */; |
1050186 | 3:9f857750e4e9 | 251 | buffer_num < (int_fast32_t) R_COUNT_OF( in_out_FrameBuffer->buffer_address ); |
1050186 | 3:9f857750e4e9 | 252 | buffer_num += 1 ) { |
1050186 | 3:9f857750e4e9 | 253 | in_out_FrameBuffer->buffer_address[ buffer_num ] = NULL; |
1050186 | 3:9f857750e4e9 | 254 | } |
1050186 | 3:9f857750e4e9 | 255 | |
1050186 | 3:9f857750e4e9 | 256 | *in_out_StackPointer = stack_pointer; |
1050186 | 3:9f857750e4e9 | 257 | |
1050186 | 3:9f857750e4e9 | 258 | e=0; |
1050186 | 3:9f857750e4e9 | 259 | fin: |
1050186 | 3:9f857750e4e9 | 260 | return e; |
1050186 | 3:9f857750e4e9 | 261 | } |
1050186 | 3:9f857750e4e9 | 262 | |
1050186 | 3:9f857750e4e9 | 263 | |
1050186 | 3:9f857750e4e9 | 264 | /** |
1050186 | 3:9f857750e4e9 | 265 | * @brief free_VRAM_stack_sub |
1050186 | 3:9f857750e4e9 | 266 | * |
1050186 | 3:9f857750e4e9 | 267 | * @param in_out_StackPointer in_out_StackPointer |
1050186 | 3:9f857750e4e9 | 268 | * @param frame_buffer frame_buffer |
1050186 | 3:9f857750e4e9 | 269 | * @param StartOfVRAM StartOfVRAM |
1050186 | 3:9f857750e4e9 | 270 | * @return Error code, 0=No error |
1050186 | 3:9f857750e4e9 | 271 | * |
1050186 | 3:9f857750e4e9 | 272 | * @par Description |
1050186 | 3:9f857750e4e9 | 273 | * - If frame_buffer - >buffer_count == 0, do nothing. |
1050186 | 3:9f857750e4e9 | 274 | */ |
1050186 | 3:9f857750e4e9 | 275 | static errnum_t free_VRAM_stack_sub( uint8_t **const in_out_StackPointer, |
1050186 | 3:9f857750e4e9 | 276 | const frame_buffer_t *const frame_buffer, |
1050186 | 3:9f857750e4e9 | 277 | const uint8_t *const StartOfVRAM ); /* QAC-3450 */ |
1050186 | 3:9f857750e4e9 | 278 | static errnum_t free_VRAM_stack_sub( uint8_t **const in_out_StackPointer, |
1050186 | 3:9f857750e4e9 | 279 | const frame_buffer_t *const frame_buffer, |
1050186 | 3:9f857750e4e9 | 280 | const uint8_t *const StartOfVRAM ) |
1050186 | 3:9f857750e4e9 | 281 | { |
1050186 | 3:9f857750e4e9 | 282 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 283 | int_fast32_t size_1; |
1050186 | 3:9f857750e4e9 | 284 | int_fast32_t size_all; |
1050186 | 3:9f857750e4e9 | 285 | int_fast32_t buffer_num; |
1050186 | 3:9f857750e4e9 | 286 | uint8_t *next_stack_pointer; |
1050186 | 3:9f857750e4e9 | 287 | |
1050186 | 3:9f857750e4e9 | 288 | |
1050186 | 3:9f857750e4e9 | 289 | IF_DQ( frame_buffer == NULL ) { |
1050186 | 3:9f857750e4e9 | 290 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 291 | goto fin; |
1050186 | 3:9f857750e4e9 | 292 | } |
1050186 | 3:9f857750e4e9 | 293 | IF_DQ( in_out_StackPointer == NULL ) { |
1050186 | 3:9f857750e4e9 | 294 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 295 | goto fin; |
1050186 | 3:9f857750e4e9 | 296 | } |
1050186 | 3:9f857750e4e9 | 297 | |
1050186 | 3:9f857750e4e9 | 298 | |
1050186 | 3:9f857750e4e9 | 299 | /* Set "size_1" */ |
1050186 | 3:9f857750e4e9 | 300 | size_1 = frame_buffer->stride * frame_buffer->height; |
1050186 | 3:9f857750e4e9 | 301 | size_1 = ( R_Ceil_64s( size_1 ) ); |
1050186 | 3:9f857750e4e9 | 302 | R_STATIC_ASSERT( RGA_STACK_ADDRESS_ALIGNMENT == 64, "" ); /* check of ceil_xx */ |
1050186 | 3:9f857750e4e9 | 303 | |
1050186 | 3:9f857750e4e9 | 304 | |
1050186 | 3:9f857750e4e9 | 305 | /* Set "size_all" */ |
1050186 | 3:9f857750e4e9 | 306 | size_all = frame_buffer->buffer_count * size_1; |
1050186 | 3:9f857750e4e9 | 307 | |
1050186 | 3:9f857750e4e9 | 308 | |
1050186 | 3:9f857750e4e9 | 309 | /* Set "next_stack_pointer" */ |
1050186 | 3:9f857750e4e9 | 310 | /* ->MISRA 17.4 */ /* ->SEC R1.3.1 (1) */ |
1050186 | 3:9f857750e4e9 | 311 | next_stack_pointer = *in_out_StackPointer - size_all; |
1050186 | 3:9f857750e4e9 | 312 | /* MISRA 17.4: Bound check is done by "StartOfVRAM" */ |
1050186 | 3:9f857750e4e9 | 313 | /* <-MISRA 17.4 */ /* <-SEC R1.3.1 (1) */ |
1050186 | 3:9f857750e4e9 | 314 | |
1050186 | 3:9f857750e4e9 | 315 | |
1050186 | 3:9f857750e4e9 | 316 | /* Check */ |
1050186 | 3:9f857750e4e9 | 317 | IF ( next_stack_pointer < StartOfVRAM ) { |
1050186 | 3:9f857750e4e9 | 318 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 319 | goto fin; |
1050186 | 3:9f857750e4e9 | 320 | } |
1050186 | 3:9f857750e4e9 | 321 | |
1050186 | 3:9f857750e4e9 | 322 | IF ( frame_buffer->buffer_count > (int_fast32_t) R_COUNT_OF( frame_buffer->buffer_address ) ) { |
1050186 | 3:9f857750e4e9 | 323 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 324 | goto fin; |
1050186 | 3:9f857750e4e9 | 325 | } |
1050186 | 3:9f857750e4e9 | 326 | |
1050186 | 3:9f857750e4e9 | 327 | for ( buffer_num = frame_buffer->buffer_count - 1; buffer_num >= 0; buffer_num -= 1 ) { |
1050186 | 3:9f857750e4e9 | 328 | /* ->MISRA 17.4 */ /* ->SEC R1.3.1 (1) */ |
1050186 | 3:9f857750e4e9 | 329 | IF ( frame_buffer->buffer_address[ buffer_num ] != |
1050186 | 3:9f857750e4e9 | 330 | (next_stack_pointer + (size_1 * buffer_num)) ) { |
1050186 | 3:9f857750e4e9 | 331 | e=E_ACCESS_DENIED; |
1050186 | 3:9f857750e4e9 | 332 | goto fin; |
1050186 | 3:9f857750e4e9 | 333 | } |
1050186 | 3:9f857750e4e9 | 334 | /* MISRA 17.4: Bound check is done by "size_all" */ |
1050186 | 3:9f857750e4e9 | 335 | /* <-MISRA 17.4 */ /* <-SEC R1.3.1 (1) */ |
1050186 | 3:9f857750e4e9 | 336 | } |
1050186 | 3:9f857750e4e9 | 337 | |
1050186 | 3:9f857750e4e9 | 338 | |
1050186 | 3:9f857750e4e9 | 339 | /* Set "*in_out_StackPointer" */ |
1050186 | 3:9f857750e4e9 | 340 | *in_out_StackPointer = next_stack_pointer; |
1050186 | 3:9f857750e4e9 | 341 | |
1050186 | 3:9f857750e4e9 | 342 | e=0; |
1050186 | 3:9f857750e4e9 | 343 | fin: |
1050186 | 3:9f857750e4e9 | 344 | return e; |
1050186 | 3:9f857750e4e9 | 345 | } |
1050186 | 3:9f857750e4e9 | 346 | |
1050186 | 3:9f857750e4e9 | 347 | |
1050186 | 3:9f857750e4e9 | 348 | /*-------------------------------------------------------------------------*/ |
1050186 | 3:9f857750e4e9 | 349 | /* <<<< ### (window_surfaces_vdc5_layer_t) Class implement >>>> */ |
1050186 | 3:9f857750e4e9 | 350 | /*-------------------------------------------------------------------------*/ |
1050186 | 3:9f857750e4e9 | 351 | |
1050186 | 3:9f857750e4e9 | 352 | /** |
1050186 | 3:9f857750e4e9 | 353 | * @brief Initialize <window_surfaces_vdc5_layer_t> |
1050186 | 3:9f857750e4e9 | 354 | * |
1050186 | 3:9f857750e4e9 | 355 | * @param self window_surfaces_vdc5_layer_t |
1050186 | 3:9f857750e4e9 | 356 | * @param layer_num layer_num |
1050186 | 3:9f857750e4e9 | 357 | * @param graphics_layer_ID graphics_layer_ID |
1050186 | 3:9f857750e4e9 | 358 | * @return Error code, 0=No error |
1050186 | 3:9f857750e4e9 | 359 | */ |
1050186 | 3:9f857750e4e9 | 360 | static errnum_t window_surfaces_vdc5_layer_t__initialize( |
1050186 | 3:9f857750e4e9 | 361 | window_surfaces_vdc5_layer_t *const self, |
1050186 | 3:9f857750e4e9 | 362 | int_fast32_t const layer_num, |
1050186 | 3:9f857750e4e9 | 363 | vdc5_graphics_type_t const graphics_layer_ID ); /* QAC-3450 */ |
1050186 | 3:9f857750e4e9 | 364 | |
1050186 | 3:9f857750e4e9 | 365 | static errnum_t window_surfaces_vdc5_layer_t__initialize( |
1050186 | 3:9f857750e4e9 | 366 | window_surfaces_vdc5_layer_t *const self, |
1050186 | 3:9f857750e4e9 | 367 | int_fast32_t const layer_num, |
1050186 | 3:9f857750e4e9 | 368 | vdc5_graphics_type_t const graphics_layer_ID ) |
1050186 | 3:9f857750e4e9 | 369 | { |
1050186 | 3:9f857750e4e9 | 370 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 371 | |
1050186 | 3:9f857750e4e9 | 372 | IF_DQ( self == NULL ) { |
1050186 | 3:9f857750e4e9 | 373 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 374 | goto fin; |
1050186 | 3:9f857750e4e9 | 375 | } |
1050186 | 3:9f857750e4e9 | 376 | |
1050186 | 3:9f857750e4e9 | 377 | e= R_int_t_to_int8_t( layer_num, &self->layer_num ); |
1050186 | 3:9f857750e4e9 | 378 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 379 | goto fin; |
1050186 | 3:9f857750e4e9 | 380 | } |
1050186 | 3:9f857750e4e9 | 381 | |
1050186 | 3:9f857750e4e9 | 382 | self->graphics_layer_ID = graphics_layer_ID; |
1050186 | 3:9f857750e4e9 | 383 | |
1050186 | 3:9f857750e4e9 | 384 | self->is_data_control = false; |
1050186 | 3:9f857750e4e9 | 385 | |
1050186 | 3:9f857750e4e9 | 386 | self->layer_color = GS_DEFAULT_CLEAR_COLOR; |
1050186 | 3:9f857750e4e9 | 387 | |
1050186 | 3:9f857750e4e9 | 388 | switch ( graphics_layer_ID ) { |
1050186 | 3:9f857750e4e9 | 389 | case VDC5_GR_TYPE_GR0: |
1050186 | 3:9f857750e4e9 | 390 | self->data_control_ID = VDC5_LAYER_ID_0_RD; |
1050186 | 3:9f857750e4e9 | 391 | break; |
1050186 | 3:9f857750e4e9 | 392 | #ifndef RZ_A1L |
1050186 | 3:9f857750e4e9 | 393 | case VDC5_GR_TYPE_GR1: |
1050186 | 3:9f857750e4e9 | 394 | self->data_control_ID = VDC5_LAYER_ID_1_RD; |
1050186 | 3:9f857750e4e9 | 395 | break; |
1050186 | 3:9f857750e4e9 | 396 | #endif |
1050186 | 3:9f857750e4e9 | 397 | case VDC5_GR_TYPE_GR2: |
1050186 | 3:9f857750e4e9 | 398 | self->data_control_ID = VDC5_LAYER_ID_2_RD; |
1050186 | 3:9f857750e4e9 | 399 | break; |
1050186 | 3:9f857750e4e9 | 400 | case VDC5_GR_TYPE_GR3: |
1050186 | 3:9f857750e4e9 | 401 | self->data_control_ID = VDC5_LAYER_ID_3_RD; |
1050186 | 3:9f857750e4e9 | 402 | break; |
1050186 | 3:9f857750e4e9 | 403 | default: |
1050186 | 3:9f857750e4e9 | 404 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 405 | goto fin; /* Bad "graphics_layer_ID" */ |
1050186 | 3:9f857750e4e9 | 406 | } |
1050186 | 3:9f857750e4e9 | 407 | |
1050186 | 3:9f857750e4e9 | 408 | e=0; |
1050186 | 3:9f857750e4e9 | 409 | fin: |
1050186 | 3:9f857750e4e9 | 410 | return e; |
1050186 | 3:9f857750e4e9 | 411 | } |
1050186 | 3:9f857750e4e9 | 412 | |
1050186 | 3:9f857750e4e9 | 413 | |
1050186 | 3:9f857750e4e9 | 414 | |
1050186 | 3:9f857750e4e9 | 415 | /*-------------------------------------------------------------------------*/ |
1050186 | 3:9f857750e4e9 | 416 | /* <<<< ### (window_surfaces_t) Class implement >>>> */ |
1050186 | 3:9f857750e4e9 | 417 | /*-------------------------------------------------------------------------*/ |
1050186 | 3:9f857750e4e9 | 418 | |
1050186 | 3:9f857750e4e9 | 419 | /** |
1050186 | 3:9f857750e4e9 | 420 | * @brief Get <window_surfaces_vdc5_layer_t> |
1050186 | 3:9f857750e4e9 | 421 | * |
1050186 | 3:9f857750e4e9 | 422 | * @param self window_surfaces_t |
1050186 | 3:9f857750e4e9 | 423 | * @param in_LayerNum in_LayerNum |
1050186 | 3:9f857750e4e9 | 424 | * @param out_Layer out_Layer |
1050186 | 3:9f857750e4e9 | 425 | * @return Error code, 0=No error |
1050186 | 3:9f857750e4e9 | 426 | */ |
1050186 | 3:9f857750e4e9 | 427 | STATIC_INLINE errnum_t window_surfaces_t__get_layer( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 428 | int_fast32_t const in_LayerNum, |
1050186 | 3:9f857750e4e9 | 429 | window_surfaces_vdc5_layer_t **const out_Layer ); /* QAC-3450 */ |
1050186 | 3:9f857750e4e9 | 430 | /* ->MISRA 16.7 : "self" can not "const", because "out_Layer" is not "const" */ |
1050186 | 3:9f857750e4e9 | 431 | /* ->SEC M1.11.1 */ |
1050186 | 3:9f857750e4e9 | 432 | STATIC_INLINE errnum_t window_surfaces_t__get_layer( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 433 | int_fast32_t const in_LayerNum, |
1050186 | 3:9f857750e4e9 | 434 | window_surfaces_vdc5_layer_t **const out_Layer ) |
1050186 | 3:9f857750e4e9 | 435 | /* <-MISRA 16.7 */ /* <-SEC M1.11.1 */ |
1050186 | 3:9f857750e4e9 | 436 | { |
1050186 | 3:9f857750e4e9 | 437 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 438 | uint_fast32_t index; |
1050186 | 3:9f857750e4e9 | 439 | |
1050186 | 3:9f857750e4e9 | 440 | IF_DQ( self == NULL ) { |
1050186 | 3:9f857750e4e9 | 441 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 442 | goto fin; |
1050186 | 3:9f857750e4e9 | 443 | } |
1050186 | 3:9f857750e4e9 | 444 | IF_DQ( out_Layer == NULL ) { |
1050186 | 3:9f857750e4e9 | 445 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 446 | goto fin; |
1050186 | 3:9f857750e4e9 | 447 | } |
1050186 | 3:9f857750e4e9 | 448 | |
1050186 | 3:9f857750e4e9 | 449 | index = in_LayerNum - self->layer_num_min; |
1050186 | 3:9f857750e4e9 | 450 | |
1050186 | 3:9f857750e4e9 | 451 | IF ( index >= R_COUNT_OF( self->layers ) ) { |
1050186 | 3:9f857750e4e9 | 452 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 453 | goto fin; |
1050186 | 3:9f857750e4e9 | 454 | } |
1050186 | 3:9f857750e4e9 | 455 | |
1050186 | 3:9f857750e4e9 | 456 | *out_Layer = &self->layers[ index ]; |
1050186 | 3:9f857750e4e9 | 457 | |
1050186 | 3:9f857750e4e9 | 458 | e=0; |
1050186 | 3:9f857750e4e9 | 459 | fin: |
1050186 | 3:9f857750e4e9 | 460 | return e; |
1050186 | 3:9f857750e4e9 | 461 | } |
1050186 | 3:9f857750e4e9 | 462 | |
1050186 | 3:9f857750e4e9 | 463 | |
1050186 | 3:9f857750e4e9 | 464 | /** |
1050186 | 3:9f857750e4e9 | 465 | * @brief Get <window_surfaces_attribute_t> |
1050186 | 3:9f857750e4e9 | 466 | * |
1050186 | 3:9f857750e4e9 | 467 | * @param self window_surfaces_t |
1050186 | 3:9f857750e4e9 | 468 | * @param in_LayerNum in_LayerNum |
1050186 | 3:9f857750e4e9 | 469 | * @param out_Attribute out_Attribute |
1050186 | 3:9f857750e4e9 | 470 | * @return Error code, 0=No error |
1050186 | 3:9f857750e4e9 | 471 | */ |
1050186 | 3:9f857750e4e9 | 472 | #ifdef IS_WINDOW_SURFACES_EX |
1050186 | 3:9f857750e4e9 | 473 | STATIC_INLINE errnum_t window_surfaces_t__get_attribute( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 474 | int_fast32_t const in_LayerNum, |
1050186 | 3:9f857750e4e9 | 475 | window_surfaces_attribute_t **const out_Attribute ); /* QAC-3450 */ |
1050186 | 3:9f857750e4e9 | 476 | /* ->MISRA 16.7 : "self" can not "const", because "out_Attribute" is not "const" */ |
1050186 | 3:9f857750e4e9 | 477 | /* ->SEC M1.11.1 */ |
1050186 | 3:9f857750e4e9 | 478 | STATIC_INLINE errnum_t window_surfaces_t__get_attribute( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 479 | int_fast32_t const in_LayerNum, |
1050186 | 3:9f857750e4e9 | 480 | window_surfaces_attribute_t **const out_Attribute ) |
1050186 | 3:9f857750e4e9 | 481 | /* <-MISRA 16.7 */ /* <-SEC M1.11.1 */ |
1050186 | 3:9f857750e4e9 | 482 | { |
1050186 | 3:9f857750e4e9 | 483 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 484 | uint_fast32_t index; |
1050186 | 3:9f857750e4e9 | 485 | |
1050186 | 3:9f857750e4e9 | 486 | IF_DQ( self == NULL ) { |
1050186 | 3:9f857750e4e9 | 487 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 488 | goto fin; |
1050186 | 3:9f857750e4e9 | 489 | } |
1050186 | 3:9f857750e4e9 | 490 | IF_DQ( out_Attribute == NULL ) { |
1050186 | 3:9f857750e4e9 | 491 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 492 | goto fin; |
1050186 | 3:9f857750e4e9 | 493 | } |
1050186 | 3:9f857750e4e9 | 494 | |
1050186 | 3:9f857750e4e9 | 495 | index = in_LayerNum - self->layer_num_min; |
1050186 | 3:9f857750e4e9 | 496 | |
1050186 | 3:9f857750e4e9 | 497 | IF ( index >= R_COUNT_OF( self->layers ) ) { |
1050186 | 3:9f857750e4e9 | 498 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 499 | goto fin; |
1050186 | 3:9f857750e4e9 | 500 | } |
1050186 | 3:9f857750e4e9 | 501 | |
1050186 | 3:9f857750e4e9 | 502 | *out_Attribute = &self->attributes[ index ]; |
1050186 | 3:9f857750e4e9 | 503 | |
1050186 | 3:9f857750e4e9 | 504 | e=0; |
1050186 | 3:9f857750e4e9 | 505 | fin: |
1050186 | 3:9f857750e4e9 | 506 | return e; |
1050186 | 3:9f857750e4e9 | 507 | } |
1050186 | 3:9f857750e4e9 | 508 | #endif |
1050186 | 3:9f857750e4e9 | 509 | |
1050186 | 3:9f857750e4e9 | 510 | |
1050186 | 3:9f857750e4e9 | 511 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 512 | * Class: window_surfaces_t |
1050186 | 3:9f857750e4e9 | 513 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 514 | |
1050186 | 3:9f857750e4e9 | 515 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 516 | * Implement: R_WINDOW_SURFACES_InitConst |
1050186 | 3:9f857750e4e9 | 517 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 518 | |
1050186 | 3:9f857750e4e9 | 519 | static bool_t gs_window_surfaces_t_is_init = false; |
1050186 | 3:9f857750e4e9 | 520 | |
1050186 | 3:9f857750e4e9 | 521 | void R_WINDOW_SURFACES_InitConst( window_surfaces_t *const self ) |
1050186 | 3:9f857750e4e9 | 522 | { |
1050186 | 3:9f857750e4e9 | 523 | int_fast32_t i; |
1050186 | 3:9f857750e4e9 | 524 | |
1050186 | 3:9f857750e4e9 | 525 | IF_DQ( self == NULL ) { |
1050186 | 3:9f857750e4e9 | 526 | goto fin; |
1050186 | 3:9f857750e4e9 | 527 | } |
1050186 | 3:9f857750e4e9 | 528 | |
1050186 | 3:9f857750e4e9 | 529 | for ( i = 0; i < (ssize_t) R_COUNT_OF( self->frame_buffers ); i += 1 ) { |
1050186 | 3:9f857750e4e9 | 530 | self->frame_buffers[i].buffer_address[0] = NULL; |
1050186 | 3:9f857750e4e9 | 531 | } |
1050186 | 3:9f857750e4e9 | 532 | self->is_initialized = gs_window_surfaces_t_is_init; |
1050186 | 3:9f857750e4e9 | 533 | |
1050186 | 3:9f857750e4e9 | 534 | fin: |
1050186 | 3:9f857750e4e9 | 535 | return; |
1050186 | 3:9f857750e4e9 | 536 | } |
1050186 | 3:9f857750e4e9 | 537 | |
1050186 | 3:9f857750e4e9 | 538 | |
1050186 | 3:9f857750e4e9 | 539 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 540 | * Implement: R_WINDOW_SURFACES_Initialize |
1050186 | 3:9f857750e4e9 | 541 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 542 | |
1050186 | 3:9f857750e4e9 | 543 | static void vdc5_init_func( uint32_t user_num ); |
1050186 | 3:9f857750e4e9 | 544 | |
1050186 | 3:9f857750e4e9 | 545 | errnum_t R_WINDOW_SURFACES_Initialize( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 546 | window_surfaces_config_t *in_out_config ) |
1050186 | 3:9f857750e4e9 | 547 | { |
1050186 | 3:9f857750e4e9 | 548 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 549 | errnum_t ee; |
1050186 | 3:9f857750e4e9 | 550 | vdc5_error_t error_vdc; |
1050186 | 3:9f857750e4e9 | 551 | window_surfaces_config_t default_config; |
1050186 | 3:9f857750e4e9 | 552 | int_fast32_t layer_num; |
1050186 | 3:9f857750e4e9 | 553 | window_surfaces_vdc5_layer_t *main_layer[ R_COUNT_OF( self->frame_buffers ) ]; |
1050186 | 3:9f857750e4e9 | 554 | window_surfaces_vdc5_layer_t *back_layer; |
1050186 | 3:9f857750e4e9 | 555 | |
1050186 | 3:9f857750e4e9 | 556 | enum { num_2 = 2, num_4 = 4 }; |
1050186 | 3:9f857750e4e9 | 557 | |
1050186 | 3:9f857750e4e9 | 558 | |
1050186 | 3:9f857750e4e9 | 559 | IF_DQ( self == NULL ) { |
1050186 | 3:9f857750e4e9 | 560 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 561 | goto fin; |
1050186 | 3:9f857750e4e9 | 562 | } |
1050186 | 3:9f857750e4e9 | 563 | |
1050186 | 3:9f857750e4e9 | 564 | self->screen_channel = GS_CHANNEL_n; |
1050186 | 3:9f857750e4e9 | 565 | |
1050186 | 3:9f857750e4e9 | 566 | |
1050186 | 3:9f857750e4e9 | 567 | /* Set default configuration */ |
1050186 | 3:9f857750e4e9 | 568 | if ( in_out_config == NULL ) { |
1050186 | 3:9f857750e4e9 | 569 | in_out_config = &default_config; |
1050186 | 3:9f857750e4e9 | 570 | in_out_config->flags = 0; |
1050186 | 3:9f857750e4e9 | 571 | } |
1050186 | 3:9f857750e4e9 | 572 | |
1050186 | 3:9f857750e4e9 | 573 | if ( IS_BIT_NOT_SET( in_out_config->flags, F_WINDOW_SURFACES_PIXEL_FORMAT ) ) { |
1050186 | 3:9f857750e4e9 | 574 | in_out_config->pixel_format = PIXEL_FORMAT_ARGB8888; |
1050186 | 3:9f857750e4e9 | 575 | in_out_config->flags |= F_WINDOW_SURFACES_PIXEL_FORMAT; |
1050186 | 3:9f857750e4e9 | 576 | } |
1050186 | 3:9f857750e4e9 | 577 | |
1050186 | 3:9f857750e4e9 | 578 | |
1050186 | 3:9f857750e4e9 | 579 | if ( IS_BIT_NOT_SET( in_out_config->flags, F_WINDOW_SURFACES_LAYER_COUNT ) ) { |
1050186 | 3:9f857750e4e9 | 580 | in_out_config->layer_count = 1; |
1050186 | 3:9f857750e4e9 | 581 | in_out_config->flags |= F_WINDOW_SURFACES_LAYER_COUNT; |
1050186 | 3:9f857750e4e9 | 582 | } |
1050186 | 3:9f857750e4e9 | 583 | ASSERT_D( in_out_config->layer_count >= 1 && in_out_config->layer_count <= 2, |
1050186 | 3:9f857750e4e9 | 584 | e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 585 | |
1050186 | 3:9f857750e4e9 | 586 | |
1050186 | 3:9f857750e4e9 | 587 | if ( IS_BIT_NOT_SET( in_out_config->flags, F_WINDOW_SURFACES_BUFFER_HEIGHT ) ) { |
1050186 | 3:9f857750e4e9 | 588 | in_out_config->buffer_height = R_ToSigned( GS_BUFFER_HEIGHT ); |
1050186 | 3:9f857750e4e9 | 589 | in_out_config->flags |= F_WINDOW_SURFACES_BUFFER_HEIGHT; |
1050186 | 3:9f857750e4e9 | 590 | } |
1050186 | 3:9f857750e4e9 | 591 | |
1050186 | 3:9f857750e4e9 | 592 | |
1050186 | 3:9f857750e4e9 | 593 | if ( IS_BIT_NOT_SET( in_out_config->flags, F_WINDOW_SURFACES_BACKGROUND_COLOR ) ) { |
1050186 | 3:9f857750e4e9 | 594 | in_out_config->background_color = GS_DEFAULT_CLEAR_COLOR; |
1050186 | 3:9f857750e4e9 | 595 | in_out_config->flags |= F_WINDOW_SURFACES_BACKGROUND_COLOR; |
1050186 | 3:9f857750e4e9 | 596 | } |
1050186 | 3:9f857750e4e9 | 597 | |
1050186 | 3:9f857750e4e9 | 598 | |
1050186 | 3:9f857750e4e9 | 599 | if ( IS_BIT_NOT_SET( in_out_config->flags, F_WINDOW_SURFACES_BACKGROUND_FORMAT ) ) { |
1050186 | 3:9f857750e4e9 | 600 | in_out_config->background_format = BACKGROUND_FORMAT_SOLID_COLOR; |
1050186 | 3:9f857750e4e9 | 601 | in_out_config->flags |= F_WINDOW_SURFACES_BACKGROUND_FORMAT; |
1050186 | 3:9f857750e4e9 | 602 | } |
1050186 | 3:9f857750e4e9 | 603 | |
1050186 | 3:9f857750e4e9 | 604 | |
1050186 | 3:9f857750e4e9 | 605 | /* Set layers */ |
1050186 | 3:9f857750e4e9 | 606 | #ifndef RZ_A1L /* RZ/A1H */ |
1050186 | 3:9f857750e4e9 | 607 | self->layer_num_min = -1; |
1050186 | 3:9f857750e4e9 | 608 | self->layer_num_max = in_out_config->layer_count - 1; |
1050186 | 3:9f857750e4e9 | 609 | ASSERT_D( (ssize_t) R_COUNT_OF( self->layers ) >= self->layer_num_max - self->layer_num_min + 1, |
1050186 | 3:9f857750e4e9 | 610 | e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 611 | e= window_surfaces_vdc5_layer_t__initialize( &self->layers[0], -1, VDC5_GR_TYPE_GR0 ); |
1050186 | 3:9f857750e4e9 | 612 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 613 | goto fin; |
1050186 | 3:9f857750e4e9 | 614 | } |
1050186 | 3:9f857750e4e9 | 615 | e= window_surfaces_vdc5_layer_t__initialize( &self->layers[1], 0, VDC5_GR_TYPE_GR1 ); |
1050186 | 3:9f857750e4e9 | 616 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 617 | goto fin; |
1050186 | 3:9f857750e4e9 | 618 | } |
1050186 | 3:9f857750e4e9 | 619 | e= window_surfaces_vdc5_layer_t__initialize( &self->layers[2], 1, VDC5_GR_TYPE_GR2 ); |
1050186 | 3:9f857750e4e9 | 620 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 621 | goto fin; |
1050186 | 3:9f857750e4e9 | 622 | } |
1050186 | 3:9f857750e4e9 | 623 | #else |
1050186 | 3:9f857750e4e9 | 624 | if ( in_out_config->pixel_format != PIXEL_FORMAT_YUV422 ) { |
1050186 | 3:9f857750e4e9 | 625 | self->layer_num_min = -1; |
1050186 | 3:9f857750e4e9 | 626 | self->layer_num_max = in_out_config->layer_count - 1; |
1050186 | 3:9f857750e4e9 | 627 | ASSERT_D( R_COUNT_OF( self->layers ) >= self->layer_num_max - self->layer_num_min + 1, |
1050186 | 3:9f857750e4e9 | 628 | e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 629 | e= window_surfaces_vdc5_layer_t__initialize( &self->layers[0], -1, VDC5_GR_TYPE_GR0 ); |
1050186 | 3:9f857750e4e9 | 630 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 631 | goto fin; |
1050186 | 3:9f857750e4e9 | 632 | } |
1050186 | 3:9f857750e4e9 | 633 | e= window_surfaces_vdc5_layer_t__initialize( &self->layers[1], 0, VDC5_GR_TYPE_GR2 ); |
1050186 | 3:9f857750e4e9 | 634 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 635 | goto fin; |
1050186 | 3:9f857750e4e9 | 636 | } |
1050186 | 3:9f857750e4e9 | 637 | e= window_surfaces_vdc5_layer_t__initialize( &self->layers[2], 1, VDC5_GR_TYPE_GR3 ); |
1050186 | 3:9f857750e4e9 | 638 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 639 | goto fin; |
1050186 | 3:9f857750e4e9 | 640 | } |
1050186 | 3:9f857750e4e9 | 641 | } else { /* PIXEL_FORMAT_YUV422 */ |
1050186 | 3:9f857750e4e9 | 642 | self->layer_num_min = 0; |
1050186 | 3:9f857750e4e9 | 643 | self->layer_num_max = in_out_config->layer_count - 1; |
1050186 | 3:9f857750e4e9 | 644 | ASSERT_D( R_COUNT_OF( self->layers ) >= self->layer_num_max - self->layer_num_min + 1, |
1050186 | 3:9f857750e4e9 | 645 | e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 646 | e= window_surfaces_vdc5_layer_t__initialize( &self->layers[0], 0, VDC5_GR_TYPE_GR0 ); |
1050186 | 3:9f857750e4e9 | 647 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 648 | goto fin; |
1050186 | 3:9f857750e4e9 | 649 | } |
1050186 | 3:9f857750e4e9 | 650 | e= window_surfaces_vdc5_layer_t__initialize( &self->layers[1], 1, VDC5_GR_TYPE_GR2 ); |
1050186 | 3:9f857750e4e9 | 651 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 652 | goto fin; |
1050186 | 3:9f857750e4e9 | 653 | } |
1050186 | 3:9f857750e4e9 | 654 | } |
1050186 | 3:9f857750e4e9 | 655 | #endif |
1050186 | 3:9f857750e4e9 | 656 | |
1050186 | 3:9f857750e4e9 | 657 | |
1050186 | 3:9f857750e4e9 | 658 | /* Set "main_layer", "back_layer" */ |
1050186 | 3:9f857750e4e9 | 659 | for ( layer_num = 0; layer_num <= self->layer_num_max; layer_num += 1 ) { |
1050186 | 3:9f857750e4e9 | 660 | e= window_surfaces_t__get_layer( self, layer_num, &main_layer[ layer_num ] ); |
1050186 | 3:9f857750e4e9 | 661 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 662 | goto fin; |
1050186 | 3:9f857750e4e9 | 663 | } |
1050186 | 3:9f857750e4e9 | 664 | IF_DQ( main_layer[ layer_num ] == NULL ) { |
1050186 | 3:9f857750e4e9 | 665 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 666 | goto fin; |
1050186 | 3:9f857750e4e9 | 667 | } |
1050186 | 3:9f857750e4e9 | 668 | } |
1050186 | 3:9f857750e4e9 | 669 | |
1050186 | 3:9f857750e4e9 | 670 | self->background_format = in_out_config->background_format; |
1050186 | 3:9f857750e4e9 | 671 | if ( self->layer_num_min >= 0 ) { |
1050186 | 3:9f857750e4e9 | 672 | back_layer = NULL; |
1050186 | 3:9f857750e4e9 | 673 | self->background_frame_count = 0; |
1050186 | 3:9f857750e4e9 | 674 | } else { |
1050186 | 3:9f857750e4e9 | 675 | back_layer = NULL; |
1050186 | 3:9f857750e4e9 | 676 | /* NULL is for avoiding warning C417W of mbed cloud compiler */ |
1050186 | 3:9f857750e4e9 | 677 | e= window_surfaces_t__get_layer( self, -1, &back_layer ); |
1050186 | 3:9f857750e4e9 | 678 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 679 | goto fin; |
1050186 | 3:9f857750e4e9 | 680 | } |
1050186 | 3:9f857750e4e9 | 681 | IF_DQ( back_layer == NULL ) { |
1050186 | 3:9f857750e4e9 | 682 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 683 | goto fin; |
1050186 | 3:9f857750e4e9 | 684 | } |
1050186 | 3:9f857750e4e9 | 685 | |
1050186 | 3:9f857750e4e9 | 686 | if ( in_out_config->background_format != BACKGROUND_FORMAT_SOLID_COLOR ) { |
1050186 | 3:9f857750e4e9 | 687 | self->background_frame_count = 1; |
1050186 | 3:9f857750e4e9 | 688 | } else { |
1050186 | 3:9f857750e4e9 | 689 | self->background_frame_count = 0; |
1050186 | 3:9f857750e4e9 | 690 | } |
1050186 | 3:9f857750e4e9 | 691 | } |
1050186 | 3:9f857750e4e9 | 692 | |
1050186 | 3:9f857750e4e9 | 693 | |
1050186 | 3:9f857750e4e9 | 694 | { |
1050186 | 3:9f857750e4e9 | 695 | uint8_t *memory_address; |
1050186 | 3:9f857750e4e9 | 696 | size_t memory_size; |
1050186 | 3:9f857750e4e9 | 697 | |
1050186 | 3:9f857750e4e9 | 698 | |
1050186 | 3:9f857750e4e9 | 699 | /* Set "physical_address", ... */ |
1050186 | 3:9f857750e4e9 | 700 | e= R_Sample_GetBigMemory( &memory_address, &memory_size ); |
1050186 | 3:9f857750e4e9 | 701 | IF ( e != 0 ) { |
1050186 | 3:9f857750e4e9 | 702 | goto fin; |
1050186 | 3:9f857750e4e9 | 703 | } |
1050186 | 3:9f857750e4e9 | 704 | /* 64byte alignment */ |
1050186 | 3:9f857750e4e9 | 705 | ASSERT_R( R_Mod_64u( (uintptr_t) memory_address ) == 0, e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 706 | |
1050186 | 3:9f857750e4e9 | 707 | |
1050186 | 3:9f857750e4e9 | 708 | /* Set "self->start_of_VRAM", ... */ |
1050186 | 3:9f857750e4e9 | 709 | self->start_of_VRAM = memory_address; |
1050186 | 3:9f857750e4e9 | 710 | /* ->MISRA 17.4 */ /* ->SEC R1.3.1 (1) */ |
1050186 | 3:9f857750e4e9 | 711 | self->over_of_VRAM = self->start_of_VRAM + memory_size; /* MISRA 17.4: This is a bound */ |
1050186 | 3:9f857750e4e9 | 712 | /* <-MISRA 17.4 */ /* <-SEC R1.3.1 (1) */ |
1050186 | 3:9f857750e4e9 | 713 | self->stack_pointer_of_VRAM = self->start_of_VRAM; |
1050186 | 3:9f857750e4e9 | 714 | } |
1050186 | 3:9f857750e4e9 | 715 | |
1050186 | 3:9f857750e4e9 | 716 | |
1050186 | 3:9f857750e4e9 | 717 | for ( layer_num = -self->background_frame_count; layer_num <= self->layer_num_max; layer_num += 1 ) { |
1050186 | 3:9f857750e4e9 | 718 | frame_buffer_t *frame; |
1050186 | 3:9f857750e4e9 | 719 | window_surfaces_vdc5_layer_t *layer = main_layer[ layer_num ]; |
1050186 | 3:9f857750e4e9 | 720 | pixel_format_t pixel_format; |
1050186 | 3:9f857750e4e9 | 721 | |
1050186 | 3:9f857750e4e9 | 722 | e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, layer_num, &frame ); |
1050186 | 3:9f857750e4e9 | 723 | IF(e) { |
1050186 | 3:9f857750e4e9 | 724 | goto fin; |
1050186 | 3:9f857750e4e9 | 725 | } |
1050186 | 3:9f857750e4e9 | 726 | |
1050186 | 3:9f857750e4e9 | 727 | if ( layer_num <= -1 && in_out_config->background_format != BACKGROUND_FORMAT_SOLID_COLOR ) { |
1050186 | 3:9f857750e4e9 | 728 | pixel_format = PIXEL_FORMAT_YUV422; |
1050186 | 3:9f857750e4e9 | 729 | } else if ( layer_num >= 1 && in_out_config->pixel_format == PIXEL_FORMAT_YUV422 ) { |
1050186 | 3:9f857750e4e9 | 730 | pixel_format = PIXEL_FORMAT_ARGB4444; |
1050186 | 3:9f857750e4e9 | 731 | } else { |
1050186 | 3:9f857750e4e9 | 732 | pixel_format = in_out_config->pixel_format; |
1050186 | 3:9f857750e4e9 | 733 | } |
1050186 | 3:9f857750e4e9 | 734 | |
1050186 | 3:9f857750e4e9 | 735 | |
1050186 | 3:9f857750e4e9 | 736 | /* Set "self->frame_buffers" */ |
1050186 | 3:9f857750e4e9 | 737 | frame->buffer_count = num_2; |
1050186 | 3:9f857750e4e9 | 738 | frame->show_buffer_index = 0; |
1050186 | 3:9f857750e4e9 | 739 | frame->draw_buffer_index = 0; |
1050186 | 3:9f857750e4e9 | 740 | frame->width = R_ToSigned( GS_BUFFER_WIDTH ); |
1050186 | 3:9f857750e4e9 | 741 | frame->height = in_out_config->buffer_height; |
1050186 | 3:9f857750e4e9 | 742 | frame->pixel_format = pixel_format; |
1050186 | 3:9f857750e4e9 | 743 | frame->delegate = NULL; |
1050186 | 3:9f857750e4e9 | 744 | |
1050186 | 3:9f857750e4e9 | 745 | switch ( frame->pixel_format ) { |
1050186 | 3:9f857750e4e9 | 746 | case PIXEL_FORMAT_ARGB8888: |
1050186 | 3:9f857750e4e9 | 747 | frame->buffer_count = 1; |
1050186 | 3:9f857750e4e9 | 748 | frame->draw_buffer_index = 0; |
1050186 | 3:9f857750e4e9 | 749 | frame->byte_per_pixel = num_4; |
1050186 | 3:9f857750e4e9 | 750 | layer->vdc5_format = VDC5_GR_FORMAT_ARGB8888; |
1050186 | 3:9f857750e4e9 | 751 | break; |
1050186 | 3:9f857750e4e9 | 752 | |
1050186 | 3:9f857750e4e9 | 753 | case PIXEL_FORMAT_XRGB8888: |
1050186 | 3:9f857750e4e9 | 754 | frame->buffer_count = 1; |
1050186 | 3:9f857750e4e9 | 755 | frame->draw_buffer_index = 0; |
1050186 | 3:9f857750e4e9 | 756 | frame->byte_per_pixel = num_4; |
1050186 | 3:9f857750e4e9 | 757 | layer->vdc5_format = VDC5_GR_FORMAT_RGB888; |
1050186 | 3:9f857750e4e9 | 758 | break; |
1050186 | 3:9f857750e4e9 | 759 | |
1050186 | 3:9f857750e4e9 | 760 | case PIXEL_FORMAT_RGB565: |
1050186 | 3:9f857750e4e9 | 761 | frame->buffer_count = num_2; |
1050186 | 3:9f857750e4e9 | 762 | frame->draw_buffer_index = 1; |
1050186 | 3:9f857750e4e9 | 763 | frame->byte_per_pixel = num_2; |
1050186 | 3:9f857750e4e9 | 764 | layer->vdc5_format = VDC5_GR_FORMAT_RGB565; |
1050186 | 3:9f857750e4e9 | 765 | break; |
1050186 | 3:9f857750e4e9 | 766 | |
1050186 | 3:9f857750e4e9 | 767 | case PIXEL_FORMAT_ARGB1555: |
1050186 | 3:9f857750e4e9 | 768 | frame->buffer_count = num_2; |
1050186 | 3:9f857750e4e9 | 769 | frame->draw_buffer_index = 1; |
1050186 | 3:9f857750e4e9 | 770 | frame->byte_per_pixel = num_2; |
1050186 | 3:9f857750e4e9 | 771 | layer->vdc5_format = VDC5_GR_FORMAT_ARGB1555; |
1050186 | 3:9f857750e4e9 | 772 | break; |
1050186 | 3:9f857750e4e9 | 773 | |
1050186 | 3:9f857750e4e9 | 774 | case PIXEL_FORMAT_ARGB4444: |
1050186 | 3:9f857750e4e9 | 775 | frame->buffer_count = num_2; |
1050186 | 3:9f857750e4e9 | 776 | frame->draw_buffer_index = 1; |
1050186 | 3:9f857750e4e9 | 777 | frame->byte_per_pixel = num_2; |
1050186 | 3:9f857750e4e9 | 778 | layer->vdc5_format = VDC5_GR_FORMAT_ARGB4444; |
1050186 | 3:9f857750e4e9 | 779 | break; |
1050186 | 3:9f857750e4e9 | 780 | |
1050186 | 3:9f857750e4e9 | 781 | case PIXEL_FORMAT_YUV422: |
1050186 | 3:9f857750e4e9 | 782 | frame->buffer_count = num_2; |
1050186 | 3:9f857750e4e9 | 783 | frame->draw_buffer_index = 1; |
1050186 | 3:9f857750e4e9 | 784 | frame->byte_per_pixel = num_2; |
1050186 | 3:9f857750e4e9 | 785 | layer->vdc5_format = VDC5_GR_FORMAT_YCBCR422; |
1050186 | 3:9f857750e4e9 | 786 | break; |
1050186 | 3:9f857750e4e9 | 787 | |
1050186 | 3:9f857750e4e9 | 788 | case PIXEL_FORMAT_CLUT8: |
1050186 | 3:9f857750e4e9 | 789 | frame->buffer_count = 2; |
1050186 | 3:9f857750e4e9 | 790 | frame->draw_buffer_index = 1; |
1050186 | 3:9f857750e4e9 | 791 | frame->byte_per_pixel = R_RGA_BitPerPixelType_To_BytePerPixelType( 8 ); |
1050186 | 3:9f857750e4e9 | 792 | layer->vdc5_format = VDC5_GR_FORMAT_CLUT8; |
1050186 | 3:9f857750e4e9 | 793 | break; |
1050186 | 3:9f857750e4e9 | 794 | |
1050186 | 3:9f857750e4e9 | 795 | case PIXEL_FORMAT_CLUT4: |
1050186 | 3:9f857750e4e9 | 796 | frame->buffer_count = 2; |
1050186 | 3:9f857750e4e9 | 797 | frame->draw_buffer_index = 1; |
1050186 | 3:9f857750e4e9 | 798 | frame->byte_per_pixel = R_RGA_BitPerPixelType_To_BytePerPixelType( 4 ); |
1050186 | 3:9f857750e4e9 | 799 | layer->vdc5_format = VDC5_GR_FORMAT_CLUT4; |
1050186 | 3:9f857750e4e9 | 800 | break; |
1050186 | 3:9f857750e4e9 | 801 | |
1050186 | 3:9f857750e4e9 | 802 | case PIXEL_FORMAT_CLUT1: |
1050186 | 3:9f857750e4e9 | 803 | frame->buffer_count = 2; |
1050186 | 3:9f857750e4e9 | 804 | frame->draw_buffer_index = 1; |
1050186 | 3:9f857750e4e9 | 805 | frame->byte_per_pixel = R_RGA_BitPerPixelType_To_BytePerPixelType( 1 ); |
1050186 | 3:9f857750e4e9 | 806 | layer->vdc5_format = VDC5_GR_FORMAT_CLUT1; |
1050186 | 3:9f857750e4e9 | 807 | break; |
1050186 | 3:9f857750e4e9 | 808 | |
1050186 | 3:9f857750e4e9 | 809 | default: |
1050186 | 3:9f857750e4e9 | 810 | layer->vdc5_format = VDC5_GR_FORMAT_NUM; /* dummy data */ |
1050186 | 3:9f857750e4e9 | 811 | break; |
1050186 | 3:9f857750e4e9 | 812 | } |
1050186 | 3:9f857750e4e9 | 813 | if( R_BYTE_PER_PIXEL_IsInteger( frame->byte_per_pixel ) ) { |
1050186 | 3:9f857750e4e9 | 814 | frame->stride = frame->width * frame->byte_per_pixel; |
1050186 | 3:9f857750e4e9 | 815 | } else { |
1050186 | 3:9f857750e4e9 | 816 | frame->stride = R_Ceil_8s( frame->width * |
1050186 | 3:9f857750e4e9 | 817 | R_RGA_BytePerPixelType_To_BitPerPixelType( frame->byte_per_pixel ) ) / 8; |
1050186 | 3:9f857750e4e9 | 818 | frame->stride = R_Ceil_32s( frame->stride ); |
1050186 | 3:9f857750e4e9 | 819 | } |
1050186 | 3:9f857750e4e9 | 820 | e= alloc_VRAM_stack_sub( &self->stack_pointer_of_VRAM, |
1050186 | 3:9f857750e4e9 | 821 | self->over_of_VRAM, frame ); |
1050186 | 3:9f857750e4e9 | 822 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 823 | goto fin; |
1050186 | 3:9f857750e4e9 | 824 | } |
1050186 | 3:9f857750e4e9 | 825 | |
1050186 | 3:9f857750e4e9 | 826 | #ifndef R_OSPL_NDEBUG |
1050186 | 3:9f857750e4e9 | 827 | printf( "Screen %dx%dx%dx%d vdc5_format=%d stride=%d \n address[0]=0x%08X address[1]=0x%08X\n", |
1050186 | 3:9f857750e4e9 | 828 | frame->buffer_count, frame->width, frame->height, frame->byte_per_pixel, |
1050186 | 3:9f857750e4e9 | 829 | layer->vdc5_format, frame->stride, |
1050186 | 3:9f857750e4e9 | 830 | (uintptr_t) frame->buffer_address[0], (uintptr_t) frame->buffer_address[1] ); |
1050186 | 3:9f857750e4e9 | 831 | /* Cast of "uintptr_t" is for avoiding "format" warning of GNU_ARM */ |
1050186 | 3:9f857750e4e9 | 832 | #endif |
1050186 | 3:9f857750e4e9 | 833 | } |
1050186 | 3:9f857750e4e9 | 834 | |
1050186 | 3:9f857750e4e9 | 835 | |
1050186 | 3:9f857750e4e9 | 836 | if ( ! self->is_initialized ) { |
1050186 | 3:9f857750e4e9 | 837 | |
1050186 | 3:9f857750e4e9 | 838 | /* Call "R_VDC5_Initialize" */ |
1050186 | 3:9f857750e4e9 | 839 | { |
1050186 | 3:9f857750e4e9 | 840 | vdc5_init_t init; |
1050186 | 3:9f857750e4e9 | 841 | |
1050186 | 3:9f857750e4e9 | 842 | init.panel_icksel = GS_LCD_CHn_PANEL_CLK; |
1050186 | 3:9f857750e4e9 | 843 | init.panel_dcdr = GS_LCD_CHn_PANEL_CLK_DIV; |
1050186 | 3:9f857750e4e9 | 844 | init.lvds = GRAPHICS_GetLvdsParam( self->screen_channel ); |
1050186 | 3:9f857750e4e9 | 845 | |
1050186 | 3:9f857750e4e9 | 846 | error_vdc = R_VDC5_Initialize( self->screen_channel, &init, |
1050186 | 3:9f857750e4e9 | 847 | &vdc5_init_func, (uint32_t) self->screen_channel ); |
1050186 | 3:9f857750e4e9 | 848 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 849 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 850 | goto fin; |
1050186 | 3:9f857750e4e9 | 851 | } |
1050186 | 3:9f857750e4e9 | 852 | } |
1050186 | 3:9f857750e4e9 | 853 | |
1050186 | 3:9f857750e4e9 | 854 | |
1050186 | 3:9f857750e4e9 | 855 | /* Call "R_VDC5_SyncControl" */ |
1050186 | 3:9f857750e4e9 | 856 | { |
1050186 | 3:9f857750e4e9 | 857 | vdc5_sync_ctrl_t sync_ctrl; |
1050186 | 3:9f857750e4e9 | 858 | |
1050186 | 3:9f857750e4e9 | 859 | sync_ctrl.res_vs_sel = VDC5_ON; /* Free-running Vsync ON/OFF */ |
1050186 | 3:9f857750e4e9 | 860 | sync_ctrl.res_vs_in_sel = VDC5_RES_VS_IN_SEL_SC0; /* SC_RES_VS_IN_SEL */ |
1050186 | 3:9f857750e4e9 | 861 | sync_ctrl.res_fv = (uint16_t)GS_LCD_CHn_SIG_FV; /* Free-running Vsync period setting */ |
1050186 | 3:9f857750e4e9 | 862 | sync_ctrl.res_fh = (uint16_t)GS_LCD_CHn_SIG_FH; /* Hsync period setting */ |
1050186 | 3:9f857750e4e9 | 863 | sync_ctrl.res_vsdly = (uint16_t)0u; /* Vsync signal delay control */ |
1050186 | 3:9f857750e4e9 | 864 | /* Full-screen enable control */ |
1050186 | 3:9f857750e4e9 | 865 | sync_ctrl.res_f.vs = (uint16_t)GS_LCD_CHn_DISP_VS; |
1050186 | 3:9f857750e4e9 | 866 | sync_ctrl.res_f.vw = (uint16_t)GS_LCD_CHn_DISP_VW; |
1050186 | 3:9f857750e4e9 | 867 | sync_ctrl.res_f.hs = (uint16_t)GS_LCD_CHn_DISP_HS; |
1050186 | 3:9f857750e4e9 | 868 | sync_ctrl.res_f.hw = (uint16_t)GS_LCD_CHn_DISP_HW; |
1050186 | 3:9f857750e4e9 | 869 | sync_ctrl.vsync_cpmpe = NULL; /* Vsync signal compensation */ |
1050186 | 3:9f857750e4e9 | 870 | |
1050186 | 3:9f857750e4e9 | 871 | error_vdc = R_VDC5_SyncControl( self->screen_channel, &sync_ctrl ); |
1050186 | 3:9f857750e4e9 | 872 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 873 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 874 | goto fin; |
1050186 | 3:9f857750e4e9 | 875 | } |
1050186 | 3:9f857750e4e9 | 876 | } |
1050186 | 3:9f857750e4e9 | 877 | |
1050186 | 3:9f857750e4e9 | 878 | |
1050186 | 3:9f857750e4e9 | 879 | /* Call "R_VDC5_DisplayOutput" */ |
1050186 | 3:9f857750e4e9 | 880 | { |
1050186 | 3:9f857750e4e9 | 881 | vdc5_output_t output; |
1050186 | 3:9f857750e4e9 | 882 | argb8888_t background_color_; /* _ is for MISRA 5.6 */ |
1050186 | 3:9f857750e4e9 | 883 | |
1050186 | 3:9f857750e4e9 | 884 | /* ->QAC 3198 */ |
1050186 | 3:9f857750e4e9 | 885 | background_color_.Value = DUMMY_INITIAL_VALUE; /* for avoid ARMCC warning C4017W */ |
1050186 | 3:9f857750e4e9 | 886 | /* <-QAC 3198 */ |
1050186 | 3:9f857750e4e9 | 887 | background_color_.u.Alpha = 0; |
1050186 | 3:9f857750e4e9 | 888 | background_color_.u.Red = in_out_config->background_color.u.Red; |
1050186 | 3:9f857750e4e9 | 889 | background_color_.u.Green = in_out_config->background_color.u.Green; |
1050186 | 3:9f857750e4e9 | 890 | background_color_.u.Blue = in_out_config->background_color.u.Blue; |
1050186 | 3:9f857750e4e9 | 891 | |
1050186 | 3:9f857750e4e9 | 892 | |
1050186 | 3:9f857750e4e9 | 893 | output.tcon_half = (uint16_t)GS_LCD_CHn_TCON_HALF; /* TCON reference timing, 1/2fH timing */ |
1050186 | 3:9f857750e4e9 | 894 | output.tcon_offset = (uint16_t)GS_LCD_CHn_TCON_OFFSET;/* TCON reference timing, offset Hsync signal timing */ |
1050186 | 3:9f857750e4e9 | 895 | /* LCD TCON timing setting */ |
1050186 | 3:9f857750e4e9 | 896 | GRAPHICS_SetLcdTconSettings( self->screen_channel, output.outctrl ); |
1050186 | 3:9f857750e4e9 | 897 | output.outcnt_lcd_edge = GS_LCD_CHn_OUT_EDGE; /* Output phase control of LCD_DATA23 to LCD_DATA0 pin */ |
1050186 | 3:9f857750e4e9 | 898 | output.out_endian_on = VDC5_OFF; /* Bit endian change ON/OFF control */ |
1050186 | 3:9f857750e4e9 | 899 | output.out_swap_on = VDC5_OFF; /* B/R signal swap ON/OFF control */ |
1050186 | 3:9f857750e4e9 | 900 | output.out_format = GS_LCD_CHn_OUT_FORMAT; /* LCD output format select */ |
1050186 | 3:9f857750e4e9 | 901 | output.out_frq_sel = VDC5_LCD_PARALLEL_CLKFRQ_1; /* Clock frequency control */ |
1050186 | 3:9f857750e4e9 | 902 | output.out_dir_sel = VDC5_LCD_SERIAL_SCAN_FORWARD; /* Scan direction select */ |
1050186 | 3:9f857750e4e9 | 903 | output.out_phase = VDC5_LCD_SERIAL_CLKPHASE_0; /* Clock phase adjustment */ |
1050186 | 3:9f857750e4e9 | 904 | output.bg_color = background_color_.Value; |
1050186 | 3:9f857750e4e9 | 905 | |
1050186 | 3:9f857750e4e9 | 906 | error_vdc = R_VDC5_DisplayOutput( self->screen_channel, &output ); |
1050186 | 3:9f857750e4e9 | 907 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 908 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 909 | goto fin; |
1050186 | 3:9f857750e4e9 | 910 | } |
1050186 | 3:9f857750e4e9 | 911 | |
1050186 | 3:9f857750e4e9 | 912 | if ( back_layer != NULL ) { |
1050186 | 3:9f857750e4e9 | 913 | back_layer->layer_color = in_out_config->background_color; |
1050186 | 3:9f857750e4e9 | 914 | } |
1050186 | 3:9f857750e4e9 | 915 | } |
1050186 | 3:9f857750e4e9 | 916 | |
1050186 | 3:9f857750e4e9 | 917 | self->is_initialized = true; |
1050186 | 3:9f857750e4e9 | 918 | } |
1050186 | 3:9f857750e4e9 | 919 | |
1050186 | 3:9f857750e4e9 | 920 | |
1050186 | 3:9f857750e4e9 | 921 | /* Call "R_VDC5_ReadDataControl" */ |
1050186 | 3:9f857750e4e9 | 922 | { |
1050186 | 3:9f857750e4e9 | 923 | vdc5_read_t read; |
1050186 | 3:9f857750e4e9 | 924 | vdc5_width_read_fb_t read_area; |
1050186 | 3:9f857750e4e9 | 925 | |
1050186 | 3:9f857750e4e9 | 926 | |
1050186 | 3:9f857750e4e9 | 927 | for ( layer_num = 0; layer_num <= self->layer_num_max; layer_num += 1 ) { |
1050186 | 3:9f857750e4e9 | 928 | int_fast32_t bit_per_pixel; |
1050186 | 3:9f857750e4e9 | 929 | frame_buffer_t *frame; |
1050186 | 3:9f857750e4e9 | 930 | window_surfaces_vdc5_layer_t *layer = main_layer[ layer_num ]; |
1050186 | 3:9f857750e4e9 | 931 | |
1050186 | 3:9f857750e4e9 | 932 | e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, layer_num, &frame ); |
1050186 | 3:9f857750e4e9 | 933 | IF(e) { |
1050186 | 3:9f857750e4e9 | 934 | goto fin; |
1050186 | 3:9f857750e4e9 | 935 | } |
1050186 | 3:9f857750e4e9 | 936 | |
1050186 | 3:9f857750e4e9 | 937 | |
1050186 | 3:9f857750e4e9 | 938 | /* Read data parameter */ |
1050186 | 3:9f857750e4e9 | 939 | read.gr_ln_off_dir = VDC5_GR_LN_OFF_DIR_INC; /* Line offset address direction of the frame buffer */ |
1050186 | 3:9f857750e4e9 | 940 | read.gr_flm_sel = VDC5_GR_FLM_SEL_FLM_NUM; /* Selects a frame buffer address setting signal */ |
1050186 | 3:9f857750e4e9 | 941 | read.gr_imr_flm_inv = VDC5_OFF; /* Sets the frame buffer number for distortion correction */ |
1050186 | 3:9f857750e4e9 | 942 | read.gr_bst_md = VDC5_BST_MD_32BYTE; /* Frame buffer burst transfer mode */ |
1050186 | 3:9f857750e4e9 | 943 | /* ->QAC 0306 */ |
1050186 | 3:9f857750e4e9 | 944 | read.gr_base = (void *) frame->buffer_address[ frame->show_buffer_index ]; /* Frame buffer base address */ |
1050186 | 3:9f857750e4e9 | 945 | /* <-QAC 0306 */ |
1050186 | 3:9f857750e4e9 | 946 | read.gr_ln_off = (uint32_t) frame->stride; /* Frame buffer line offset address */ |
1050186 | 3:9f857750e4e9 | 947 | read.width_read_fb = NULL; /* width of the image read from frame buffer */ |
1050186 | 3:9f857750e4e9 | 948 | read.adj_sel = VDC5_OFF; /* Measures to decrease the influence |
1050186 | 3:9f857750e4e9 | 949 | by folding pixels/lines (ON/OFF) */ |
1050186 | 3:9f857750e4e9 | 950 | read.gr_format = layer->vdc5_format; /* Graphics format of the frame buffer read signal */ |
1050186 | 3:9f857750e4e9 | 951 | read.gr_ycc_swap = VDC5_GR_YCCSWAP_Y1CRY0CB; |
1050186 | 3:9f857750e4e9 | 952 | /* Controls swapping of data read from buffer in the YCbCr422 format */ |
1050186 | 3:9f857750e4e9 | 953 | |
1050186 | 3:9f857750e4e9 | 954 | bit_per_pixel = R_RGA_BytePerPixelType_To_BitPerPixelType( frame->byte_per_pixel ); |
1050186 | 3:9f857750e4e9 | 955 | if ( (bit_per_pixel == 32) || (frame->pixel_format == PIXEL_FORMAT_YCbCr422) ) { |
1050186 | 3:9f857750e4e9 | 956 | read.gr_rdswa = VDC5_WR_RD_WRSWA_32BIT; |
1050186 | 3:9f857750e4e9 | 957 | } else if ( bit_per_pixel == 16 ) { |
1050186 | 3:9f857750e4e9 | 958 | read.gr_rdswa = VDC5_WR_RD_WRSWA_32_16BIT; |
1050186 | 3:9f857750e4e9 | 959 | } else if ( bit_per_pixel <= 8 ) { |
1050186 | 3:9f857750e4e9 | 960 | read.gr_rdswa = VDC5_WR_RD_WRSWA_32_16_8BIT; |
1050186 | 3:9f857750e4e9 | 961 | } |
1050186 | 3:9f857750e4e9 | 962 | /* Display area */ |
1050186 | 3:9f857750e4e9 | 963 | read.gr_grc.hs = (uint16_t) GS_LCD_CHn_DISP_HS; |
1050186 | 3:9f857750e4e9 | 964 | read.gr_grc.hw = (uint16_t) GS_LCD_CHn_DISP_HW; |
1050186 | 3:9f857750e4e9 | 965 | read.gr_grc.vs = (uint16_t) GS_LCD_CHn_DISP_VS; |
1050186 | 3:9f857750e4e9 | 966 | if ( GS_BUFFER_HEIGHT < GS_LCD_CHn_DISP_VW ) { |
1050186 | 3:9f857750e4e9 | 967 | read.gr_grc.vw = (uint16_t) GS_BUFFER_HEIGHT; |
1050186 | 3:9f857750e4e9 | 968 | } else { |
1050186 | 3:9f857750e4e9 | 969 | read.gr_grc.vw = (uint16_t) GS_LCD_CHn_DISP_VW; |
1050186 | 3:9f857750e4e9 | 970 | } |
1050186 | 3:9f857750e4e9 | 971 | |
1050186 | 3:9f857750e4e9 | 972 | error_vdc = R_VDC5_ReadDataControl( self->screen_channel, layer->data_control_ID, &read ); |
1050186 | 3:9f857750e4e9 | 973 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 974 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 975 | goto fin; |
1050186 | 3:9f857750e4e9 | 976 | } |
1050186 | 3:9f857750e4e9 | 977 | layer->is_data_control = true; |
1050186 | 3:9f857750e4e9 | 978 | } |
1050186 | 3:9f857750e4e9 | 979 | |
1050186 | 3:9f857750e4e9 | 980 | if ( back_layer != NULL ) { |
1050186 | 3:9f857750e4e9 | 981 | if ( self->background_format == BACKGROUND_FORMAT_SOLID_COLOR ) { |
1050186 | 3:9f857750e4e9 | 982 | |
1050186 | 3:9f857750e4e9 | 983 | /* Set display area for back ground */ |
1050186 | 3:9f857750e4e9 | 984 | /* "read.gr_base", ... are ignored */ |
1050186 | 3:9f857750e4e9 | 985 | |
1050186 | 3:9f857750e4e9 | 986 | error_vdc = R_VDC5_ReadDataControl( self->screen_channel, back_layer->data_control_ID, &read ); |
1050186 | 3:9f857750e4e9 | 987 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 988 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 989 | goto fin; |
1050186 | 3:9f857750e4e9 | 990 | } |
1050186 | 3:9f857750e4e9 | 991 | } else { |
1050186 | 3:9f857750e4e9 | 992 | frame_buffer_t *frame; |
1050186 | 3:9f857750e4e9 | 993 | window_surfaces_vdc5_layer_t *layer = back_layer; |
1050186 | 3:9f857750e4e9 | 994 | |
1050186 | 3:9f857750e4e9 | 995 | e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, -1, &frame ); |
1050186 | 3:9f857750e4e9 | 996 | IF(e) { |
1050186 | 3:9f857750e4e9 | 997 | goto fin; |
1050186 | 3:9f857750e4e9 | 998 | } |
1050186 | 3:9f857750e4e9 | 999 | |
1050186 | 3:9f857750e4e9 | 1000 | |
1050186 | 3:9f857750e4e9 | 1001 | /* Read data parameter */ |
1050186 | 3:9f857750e4e9 | 1002 | read.gr_ln_off_dir = VDC5_GR_LN_OFF_DIR_INC; /* Line offset address direction of the frame buffer */ |
1050186 | 3:9f857750e4e9 | 1003 | read.gr_flm_sel = VDC5_GR_FLM_SEL_FLM_NUM; /* Selects a frame buffer address setting signal */ |
1050186 | 3:9f857750e4e9 | 1004 | read.gr_imr_flm_inv = VDC5_OFF; /* Sets the frame buffer number for distortion correction */ |
1050186 | 3:9f857750e4e9 | 1005 | read.gr_bst_md = VDC5_BST_MD_32BYTE; /* Frame buffer burst transfer mode */ |
1050186 | 3:9f857750e4e9 | 1006 | /* ->QAC 0306 */ |
1050186 | 3:9f857750e4e9 | 1007 | read.gr_base = (void *) frame->buffer_address[ frame->show_buffer_index ]; /* Frame buffer base address */ |
1050186 | 3:9f857750e4e9 | 1008 | /* <-QAC 0306 */ |
1050186 | 3:9f857750e4e9 | 1009 | read.gr_ln_off = (uint32_t) frame->stride; /* Frame buffer line offset address */ |
1050186 | 3:9f857750e4e9 | 1010 | read_area.in_hw = frame->width; |
1050186 | 3:9f857750e4e9 | 1011 | read_area.in_vw = frame->height / 2; |
1050186 | 3:9f857750e4e9 | 1012 | read.width_read_fb = &read_area; |
1050186 | 3:9f857750e4e9 | 1013 | read.adj_sel = VDC5_ON; |
1050186 | 3:9f857750e4e9 | 1014 | read.gr_format = layer->vdc5_format; /* Graphics format of the frame buffer read signal */ |
1050186 | 3:9f857750e4e9 | 1015 | read.gr_ycc_swap = VDC5_GR_YCCSWAP_CBY0CRY1; |
1050186 | 3:9f857750e4e9 | 1016 | /* Controls swapping of data read from buffer in the YCbCr422 format */ |
1050186 | 3:9f857750e4e9 | 1017 | read.gr_rdswa = VDC5_WR_RD_WRSWA_16BIT; |
1050186 | 3:9f857750e4e9 | 1018 | |
1050186 | 3:9f857750e4e9 | 1019 | /* Display area */ |
1050186 | 3:9f857750e4e9 | 1020 | read.gr_grc.hs = (uint16_t) GS_LCD_CHn_DISP_HS; |
1050186 | 3:9f857750e4e9 | 1021 | read.gr_grc.hw = (uint16_t) GS_LCD_CHn_DISP_HW; |
1050186 | 3:9f857750e4e9 | 1022 | read.gr_grc.vs = (uint16_t) GS_LCD_CHn_DISP_VS; |
1050186 | 3:9f857750e4e9 | 1023 | if ( GS_BUFFER_HEIGHT < GS_LCD_CHn_DISP_VW ) { |
1050186 | 3:9f857750e4e9 | 1024 | read.gr_grc.vw = (uint16_t) GS_BUFFER_HEIGHT; |
1050186 | 3:9f857750e4e9 | 1025 | } else { |
1050186 | 3:9f857750e4e9 | 1026 | read.gr_grc.vw = (uint16_t) GS_LCD_CHn_DISP_VW; |
1050186 | 3:9f857750e4e9 | 1027 | } |
1050186 | 3:9f857750e4e9 | 1028 | |
1050186 | 3:9f857750e4e9 | 1029 | error_vdc = R_VDC5_ReadDataControl( self->screen_channel, layer->data_control_ID, &read ); |
1050186 | 3:9f857750e4e9 | 1030 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1031 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1032 | goto fin; |
1050186 | 3:9f857750e4e9 | 1033 | } |
1050186 | 3:9f857750e4e9 | 1034 | } |
1050186 | 3:9f857750e4e9 | 1035 | back_layer->is_data_control = true; |
1050186 | 3:9f857750e4e9 | 1036 | } |
1050186 | 3:9f857750e4e9 | 1037 | } |
1050186 | 3:9f857750e4e9 | 1038 | |
1050186 | 3:9f857750e4e9 | 1039 | |
1050186 | 3:9f857750e4e9 | 1040 | /* Call "R_VDC5_AlphaBlending" for ARGB1555 */ |
1050186 | 3:9f857750e4e9 | 1041 | for ( layer_num = 0; layer_num <= self->layer_num_max; layer_num += 1 ) { |
1050186 | 3:9f857750e4e9 | 1042 | frame_buffer_t *frame; |
1050186 | 3:9f857750e4e9 | 1043 | |
1050186 | 3:9f857750e4e9 | 1044 | e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, layer_num, &frame ); |
1050186 | 3:9f857750e4e9 | 1045 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1046 | goto fin; |
1050186 | 3:9f857750e4e9 | 1047 | } |
1050186 | 3:9f857750e4e9 | 1048 | |
1050186 | 3:9f857750e4e9 | 1049 | if ( frame->pixel_format == PIXEL_FORMAT_ARGB1555 ) { |
1050186 | 3:9f857750e4e9 | 1050 | static vdc5_alpha_argb1555_t alpha_for_argb1555 = { 0x00, U8_255 }; |
1050186 | 3:9f857750e4e9 | 1051 | static vdc5_alpha_blending_t blend = { &alpha_for_argb1555, NULL }; |
1050186 | 3:9f857750e4e9 | 1052 | |
1050186 | 3:9f857750e4e9 | 1053 | error_vdc = R_VDC5_AlphaBlending( self->screen_channel, |
1050186 | 3:9f857750e4e9 | 1054 | main_layer[ layer_num ]->data_control_ID, |
1050186 | 3:9f857750e4e9 | 1055 | &blend ); |
1050186 | 3:9f857750e4e9 | 1056 | IF( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1057 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1058 | goto fin; |
1050186 | 3:9f857750e4e9 | 1059 | } |
1050186 | 3:9f857750e4e9 | 1060 | } |
1050186 | 3:9f857750e4e9 | 1061 | } |
1050186 | 3:9f857750e4e9 | 1062 | |
1050186 | 3:9f857750e4e9 | 1063 | |
1050186 | 3:9f857750e4e9 | 1064 | /* Call "R_V_SYNC_Initialize" */ |
1050186 | 3:9f857750e4e9 | 1065 | e= R_V_SYNC_Initialize( (int_fast32_t) self->screen_channel ); |
1050186 | 3:9f857750e4e9 | 1066 | IF ( e != 0 ) { |
1050186 | 3:9f857750e4e9 | 1067 | goto fin; |
1050186 | 3:9f857750e4e9 | 1068 | } |
1050186 | 3:9f857750e4e9 | 1069 | |
1050186 | 3:9f857750e4e9 | 1070 | |
1050186 | 3:9f857750e4e9 | 1071 | /* Wait for avoiding LCD filled white (LCD-KIT-B01) */ |
1050186 | 3:9f857750e4e9 | 1072 | e= R_OSPL_Delay( 80 ); |
1050186 | 3:9f857750e4e9 | 1073 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1074 | goto fin; |
1050186 | 3:9f857750e4e9 | 1075 | } |
1050186 | 3:9f857750e4e9 | 1076 | |
1050186 | 3:9f857750e4e9 | 1077 | |
1050186 | 3:9f857750e4e9 | 1078 | /* Set graphics display mode */ |
1050186 | 3:9f857750e4e9 | 1079 | { |
1050186 | 3:9f857750e4e9 | 1080 | vdc5_start_t start; |
1050186 | 3:9f857750e4e9 | 1081 | int_fast32_t i; |
1050186 | 3:9f857750e4e9 | 1082 | |
1050186 | 3:9f857750e4e9 | 1083 | for ( i = 0; i < (int_fast32_t) R_COUNT_OF( self->vdc5_disp_sel_array ); i += 1 ) { |
1050186 | 3:9f857750e4e9 | 1084 | self->vdc5_disp_sel_array[ i ] = VDC5_DISPSEL_LOWER; /* Reset */ |
1050186 | 3:9f857750e4e9 | 1085 | } |
1050186 | 3:9f857750e4e9 | 1086 | self->vdc5_disp_sel_array[ VDC5_GR_TYPE_GR0 ] = VDC5_DISPSEL_BACK; |
1050186 | 3:9f857750e4e9 | 1087 | |
1050186 | 3:9f857750e4e9 | 1088 | start.gr_disp_sel = self->vdc5_disp_sel_array; |
1050186 | 3:9f857750e4e9 | 1089 | error_vdc = R_VDC5_StartProcess( self->screen_channel, VDC5_LAYER_ID_ALL, &start ); |
1050186 | 3:9f857750e4e9 | 1090 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1091 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1092 | goto fin; |
1050186 | 3:9f857750e4e9 | 1093 | } |
1050186 | 3:9f857750e4e9 | 1094 | } |
1050186 | 3:9f857750e4e9 | 1095 | |
1050186 | 3:9f857750e4e9 | 1096 | #if USE_LCD |
1050186 | 3:9f857750e4e9 | 1097 | R_OSPL_Delay( 2*17 ); /* Synchronize to LCD */ |
1050186 | 3:9f857750e4e9 | 1098 | LCD_SetBacklight( 100 ); |
1050186 | 3:9f857750e4e9 | 1099 | #endif |
1050186 | 3:9f857750e4e9 | 1100 | |
1050186 | 3:9f857750e4e9 | 1101 | |
1050186 | 3:9f857750e4e9 | 1102 | /* Set "self->attributes" */ |
1050186 | 3:9f857750e4e9 | 1103 | for ( layer_num = self->layer_num_min; layer_num <= self->layer_num_max; layer_num += 1 ) { |
1050186 | 3:9f857750e4e9 | 1104 | window_surfaces_attribute_t *attribute = NULL; |
1050186 | 3:9f857750e4e9 | 1105 | /* NULL is for avoiding warning C417W of mbed cloud compiler */ |
1050186 | 3:9f857750e4e9 | 1106 | |
1050186 | 3:9f857750e4e9 | 1107 | e= window_surfaces_t__get_attribute( self, layer_num, &attribute ); |
1050186 | 3:9f857750e4e9 | 1108 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1109 | goto fin; |
1050186 | 3:9f857750e4e9 | 1110 | } |
1050186 | 3:9f857750e4e9 | 1111 | |
1050186 | 3:9f857750e4e9 | 1112 | attribute->X = 0; |
1050186 | 3:9f857750e4e9 | 1113 | attribute->Y = 0; |
1050186 | 3:9f857750e4e9 | 1114 | attribute->Width = R_ToSigned( GS_BUFFER_WIDTH ); |
1050186 | 3:9f857750e4e9 | 1115 | attribute->Height = in_out_config->buffer_height; |
1050186 | 3:9f857750e4e9 | 1116 | attribute->OffsetX = 0; |
1050186 | 3:9f857750e4e9 | 1117 | attribute->OffsetY = 0; |
1050186 | 3:9f857750e4e9 | 1118 | attribute->OffsetByte = 0; |
1050186 | 3:9f857750e4e9 | 1119 | } |
1050186 | 3:9f857750e4e9 | 1120 | |
1050186 | 3:9f857750e4e9 | 1121 | |
1050186 | 3:9f857750e4e9 | 1122 | e=0; |
1050186 | 3:9f857750e4e9 | 1123 | fin: |
1050186 | 3:9f857750e4e9 | 1124 | if ( e != 0 ) { |
1050186 | 3:9f857750e4e9 | 1125 | if ( self != NULL ) { |
1050186 | 3:9f857750e4e9 | 1126 | ee= R_WINDOW_SURFACES_Finalize( self, e ); |
1050186 | 3:9f857750e4e9 | 1127 | R_UNREFERENCED_VARIABLE( ee ); |
1050186 | 3:9f857750e4e9 | 1128 | } |
1050186 | 3:9f857750e4e9 | 1129 | } |
1050186 | 3:9f857750e4e9 | 1130 | return e; |
1050186 | 3:9f857750e4e9 | 1131 | } |
1050186 | 3:9f857750e4e9 | 1132 | |
1050186 | 3:9f857750e4e9 | 1133 | |
1050186 | 3:9f857750e4e9 | 1134 | /** |
1050186 | 3:9f857750e4e9 | 1135 | * @brief vdc5_init_func |
1050186 | 3:9f857750e4e9 | 1136 | * |
1050186 | 3:9f857750e4e9 | 1137 | * @param user_num channel |
1050186 | 3:9f857750e4e9 | 1138 | * @return None |
1050186 | 3:9f857750e4e9 | 1139 | */ |
1050186 | 3:9f857750e4e9 | 1140 | static void vdc5_init_func( uint32_t const user_num ) |
1050186 | 3:9f857750e4e9 | 1141 | { |
1050186 | 3:9f857750e4e9 | 1142 | vdc5_channel_t channel; |
1050186 | 3:9f857750e4e9 | 1143 | struct st_cpg *const reg_CPG = R_Get_CPG_Base(); |
1050186 | 3:9f857750e4e9 | 1144 | |
1050186 | 3:9f857750e4e9 | 1145 | IF_DQ( reg_CPG == NULL ) { |
1050186 | 3:9f857750e4e9 | 1146 | goto fin; |
1050186 | 3:9f857750e4e9 | 1147 | } |
1050186 | 3:9f857750e4e9 | 1148 | |
1050186 | 3:9f857750e4e9 | 1149 | channel = (vdc5_channel_t)user_num; |
1050186 | 3:9f857750e4e9 | 1150 | if (channel == VDC5_CHANNEL_0) { |
1050186 | 3:9f857750e4e9 | 1151 | /* Standby control register 9 (STBCR9) |
1050186 | 3:9f857750e4e9 | 1152 | b1 ------0-; MSTP91 : 0 : Video display controller channel 0 & LVDS enable */ |
1050186 | 3:9f857750e4e9 | 1153 | R_DRV_SET_REGISTER_BIT_FIELD( ®_CPG->STBCR9, STBCR9, MSTP91, false ); |
1050186 | 3:9f857750e4e9 | 1154 | } else { |
1050186 | 3:9f857750e4e9 | 1155 | /* Standby control register 9 (STBCR9) |
1050186 | 3:9f857750e4e9 | 1156 | b1 ------0-; MSTP91 : 0 : Video display controller channel 0 & LVDS enable |
1050186 | 3:9f857750e4e9 | 1157 | b0 -------0; MSTP90 : 0 : Video display controller channel 1 enable */ |
1050186 | 3:9f857750e4e9 | 1158 | R_DRV_SET_REGISTER_BIT_FIELD( ®_CPG->STBCR9, STBCR9, MSTP91, false ); |
1050186 | 3:9f857750e4e9 | 1159 | R_DRV_SET_REGISTER_BIT_FIELD( ®_CPG->STBCR9, STBCR9, MSTP90, false ); |
1050186 | 3:9f857750e4e9 | 1160 | } |
1050186 | 3:9f857750e4e9 | 1161 | GRAPHICS_SetLcdPanel(channel); |
1050186 | 3:9f857750e4e9 | 1162 | |
1050186 | 3:9f857750e4e9 | 1163 | fin: |
1050186 | 3:9f857750e4e9 | 1164 | return; |
1050186 | 3:9f857750e4e9 | 1165 | } |
1050186 | 3:9f857750e4e9 | 1166 | |
1050186 | 3:9f857750e4e9 | 1167 | |
1050186 | 3:9f857750e4e9 | 1168 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 1169 | * Implement: R_WINDOW_SURFACES_Finalize |
1050186 | 3:9f857750e4e9 | 1170 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 1171 | |
1050186 | 3:9f857750e4e9 | 1172 | static void vdc5_quit_func( uint32_t const user_num ); |
1050186 | 3:9f857750e4e9 | 1173 | |
1050186 | 3:9f857750e4e9 | 1174 | errnum_t R_WINDOW_SURFACES_Finalize( window_surfaces_t *const self, errnum_t e ) |
1050186 | 3:9f857750e4e9 | 1175 | { |
1050186 | 3:9f857750e4e9 | 1176 | vdc5_error_t error_vdc; |
1050186 | 3:9f857750e4e9 | 1177 | |
1050186 | 3:9f857750e4e9 | 1178 | IF_DQ( self == NULL ) { |
1050186 | 3:9f857750e4e9 | 1179 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1180 | goto fin; |
1050186 | 3:9f857750e4e9 | 1181 | } |
1050186 | 3:9f857750e4e9 | 1182 | |
1050186 | 3:9f857750e4e9 | 1183 | e= R_V_SYNC_Finalize( (int_fast32_t) self->screen_channel, e ); |
1050186 | 3:9f857750e4e9 | 1184 | |
1050186 | 3:9f857750e4e9 | 1185 | if ( ! self->is_initialized ) { |
1050186 | 3:9f857750e4e9 | 1186 | error_vdc = R_VDC5_Terminate( self->screen_channel, &vdc5_quit_func, |
1050186 | 3:9f857750e4e9 | 1187 | (uint32_t) self->screen_channel ); |
1050186 | 3:9f857750e4e9 | 1188 | IF ( (error_vdc != VDC5_OK) && (e == 0) ) { |
1050186 | 3:9f857750e4e9 | 1189 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1190 | } |
1050186 | 3:9f857750e4e9 | 1191 | } else { |
1050186 | 3:9f857750e4e9 | 1192 | int_fast32_t i; |
1050186 | 3:9f857750e4e9 | 1193 | |
1050186 | 3:9f857750e4e9 | 1194 | for ( i = -self->background_frame_count; i <= self->layer_num_max; i += 1 ) { |
1050186 | 3:9f857750e4e9 | 1195 | frame_buffer_t *frame; |
1050186 | 3:9f857750e4e9 | 1196 | errnum_t ee; |
1050186 | 3:9f857750e4e9 | 1197 | |
1050186 | 3:9f857750e4e9 | 1198 | ee= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, i, &frame ); |
1050186 | 3:9f857750e4e9 | 1199 | e= R_OSPL_MergeErrNum( e, ee ); |
1050186 | 3:9f857750e4e9 | 1200 | frame->buffer_address[0] = NULL; |
1050186 | 3:9f857750e4e9 | 1201 | } |
1050186 | 3:9f857750e4e9 | 1202 | |
1050186 | 3:9f857750e4e9 | 1203 | for ( i = self->layer_num_min; i <= self->layer_num_max; i += 1 ) { |
1050186 | 3:9f857750e4e9 | 1204 | window_surfaces_vdc5_layer_t *layer = NULL; |
1050186 | 3:9f857750e4e9 | 1205 | /* NULL is for avoiding warning C417W of mbed cloud compiler */ |
1050186 | 3:9f857750e4e9 | 1206 | errnum_t ee = window_surfaces_t__get_layer( self, i, &layer ); |
1050186 | 3:9f857750e4e9 | 1207 | |
1050186 | 3:9f857750e4e9 | 1208 | IF_DQ ( layer == NULL ) { |
1050186 | 3:9f857750e4e9 | 1209 | e=E_OTHERS; /* Same check as "ee" */ |
1050186 | 3:9f857750e4e9 | 1210 | goto fin; |
1050186 | 3:9f857750e4e9 | 1211 | } |
1050186 | 3:9f857750e4e9 | 1212 | |
1050186 | 3:9f857750e4e9 | 1213 | if ( (ee == 0) && (layer->is_data_control) ) { |
1050186 | 3:9f857750e4e9 | 1214 | error_vdc = R_VDC5_StopProcess( self->screen_channel, |
1050186 | 3:9f857750e4e9 | 1215 | layer->data_control_ID ); |
1050186 | 3:9f857750e4e9 | 1216 | IF ( (error_vdc != VDC5_OK) && (e == 0) ) { |
1050186 | 3:9f857750e4e9 | 1217 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1218 | } |
1050186 | 3:9f857750e4e9 | 1219 | error_vdc = R_VDC5_ReleaseDataControl( self->screen_channel, |
1050186 | 3:9f857750e4e9 | 1220 | layer->data_control_ID ); |
1050186 | 3:9f857750e4e9 | 1221 | layer->is_data_control = false; |
1050186 | 3:9f857750e4e9 | 1222 | IF ( (error_vdc != VDC5_OK) && (e == 0) ) { |
1050186 | 3:9f857750e4e9 | 1223 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1224 | } |
1050186 | 3:9f857750e4e9 | 1225 | } |
1050186 | 3:9f857750e4e9 | 1226 | } |
1050186 | 3:9f857750e4e9 | 1227 | |
1050186 | 3:9f857750e4e9 | 1228 | #define R_WINDOW_SURFACES_TERMINATE_VDC5 1 /* 0 or 1 */ |
1050186 | 3:9f857750e4e9 | 1229 | #if R_WINDOW_SURFACES_TERMINATE_VDC5 |
1050186 | 3:9f857750e4e9 | 1230 | self->is_initialized = false; |
1050186 | 3:9f857750e4e9 | 1231 | |
1050186 | 3:9f857750e4e9 | 1232 | error_vdc = R_VDC5_Terminate( self->screen_channel, &vdc5_quit_func, |
1050186 | 3:9f857750e4e9 | 1233 | (uint32_t) self->screen_channel ); |
1050186 | 3:9f857750e4e9 | 1234 | IF ( (error_vdc != VDC5_OK) && (e == 0) ) { |
1050186 | 3:9f857750e4e9 | 1235 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1236 | } |
1050186 | 3:9f857750e4e9 | 1237 | #endif |
1050186 | 3:9f857750e4e9 | 1238 | } |
1050186 | 3:9f857750e4e9 | 1239 | |
1050186 | 3:9f857750e4e9 | 1240 | gs_window_surfaces_t_is_init = self->is_initialized; |
1050186 | 3:9f857750e4e9 | 1241 | |
1050186 | 3:9f857750e4e9 | 1242 | fin: |
1050186 | 3:9f857750e4e9 | 1243 | return e; |
1050186 | 3:9f857750e4e9 | 1244 | } |
1050186 | 3:9f857750e4e9 | 1245 | |
1050186 | 3:9f857750e4e9 | 1246 | |
1050186 | 3:9f857750e4e9 | 1247 | /** |
1050186 | 3:9f857750e4e9 | 1248 | * @brief vdc5_quit_func |
1050186 | 3:9f857750e4e9 | 1249 | * |
1050186 | 3:9f857750e4e9 | 1250 | * @param user_num channel |
1050186 | 3:9f857750e4e9 | 1251 | * @return None |
1050186 | 3:9f857750e4e9 | 1252 | */ |
1050186 | 3:9f857750e4e9 | 1253 | static void vdc5_quit_func( uint32_t const user_num ) |
1050186 | 3:9f857750e4e9 | 1254 | { |
1050186 | 3:9f857750e4e9 | 1255 | vdc5_channel_t const channel = (vdc5_channel_t) user_num; |
1050186 | 3:9f857750e4e9 | 1256 | struct st_cpg *const reg_CPG = R_Get_CPG_Base(); |
1050186 | 3:9f857750e4e9 | 1257 | |
1050186 | 3:9f857750e4e9 | 1258 | IF_DQ( reg_CPG == NULL ) { |
1050186 | 3:9f857750e4e9 | 1259 | goto fin; |
1050186 | 3:9f857750e4e9 | 1260 | } |
1050186 | 3:9f857750e4e9 | 1261 | |
1050186 | 3:9f857750e4e9 | 1262 | if (channel == VDC5_CHANNEL_0) { |
1050186 | 3:9f857750e4e9 | 1263 | /* If LVDS should remain enabled, the following code should be removed. */ |
1050186 | 3:9f857750e4e9 | 1264 | R_DRV_SET_REGISTER_BIT_FIELD( ®_CPG->STBCR9, STBCR9, MSTP91, true ); |
1050186 | 3:9f857750e4e9 | 1265 | } else { |
1050186 | 3:9f857750e4e9 | 1266 | R_DRV_SET_REGISTER_BIT_FIELD( ®_CPG->STBCR9, STBCR9, MSTP90, true ); |
1050186 | 3:9f857750e4e9 | 1267 | } |
1050186 | 3:9f857750e4e9 | 1268 | |
1050186 | 3:9f857750e4e9 | 1269 | fin: |
1050186 | 3:9f857750e4e9 | 1270 | return; |
1050186 | 3:9f857750e4e9 | 1271 | } |
1050186 | 3:9f857750e4e9 | 1272 | |
1050186 | 3:9f857750e4e9 | 1273 | |
1050186 | 3:9f857750e4e9 | 1274 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 1275 | * Implement: R_WINDOW_SURFACES_GetLayerFrameBuffer |
1050186 | 3:9f857750e4e9 | 1276 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 1277 | errnum_t R_WINDOW_SURFACES_GetLayerFrameBuffer( const window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 1278 | int_fast32_t const layer_num, frame_buffer_t **const out_frame_buffer ) |
1050186 | 3:9f857750e4e9 | 1279 | { |
1050186 | 3:9f857750e4e9 | 1280 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 1281 | uint_fast32_t index; |
1050186 | 3:9f857750e4e9 | 1282 | |
1050186 | 3:9f857750e4e9 | 1283 | IF_DQ( out_frame_buffer == NULL ) { |
1050186 | 3:9f857750e4e9 | 1284 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1285 | goto fin; |
1050186 | 3:9f857750e4e9 | 1286 | } |
1050186 | 3:9f857750e4e9 | 1287 | IF_DQ( self == NULL ) { |
1050186 | 3:9f857750e4e9 | 1288 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1289 | goto fin; |
1050186 | 3:9f857750e4e9 | 1290 | } |
1050186 | 3:9f857750e4e9 | 1291 | |
1050186 | 3:9f857750e4e9 | 1292 | index = layer_num + self->background_frame_count; |
1050186 | 3:9f857750e4e9 | 1293 | IF ( index >= R_COUNT_OF( self->frame_buffers ) ) { |
1050186 | 3:9f857750e4e9 | 1294 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1295 | goto fin; |
1050186 | 3:9f857750e4e9 | 1296 | } |
1050186 | 3:9f857750e4e9 | 1297 | |
1050186 | 3:9f857750e4e9 | 1298 | *out_frame_buffer = (frame_buffer_t *) &self->frame_buffers[ index ]; |
1050186 | 3:9f857750e4e9 | 1299 | /* Cast is for const */ |
1050186 | 3:9f857750e4e9 | 1300 | |
1050186 | 3:9f857750e4e9 | 1301 | e=0; |
1050186 | 3:9f857750e4e9 | 1302 | fin: |
1050186 | 3:9f857750e4e9 | 1303 | return e; |
1050186 | 3:9f857750e4e9 | 1304 | } |
1050186 | 3:9f857750e4e9 | 1305 | |
1050186 | 3:9f857750e4e9 | 1306 | |
1050186 | 3:9f857750e4e9 | 1307 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 1308 | * Implement: R_WINDOW_SURFACES_SwapBuffers |
1050186 | 3:9f857750e4e9 | 1309 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 1310 | errnum_t R_WINDOW_SURFACES_SwapBuffers( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 1311 | int_fast32_t const layer_num, graphics_t *const context ) |
1050186 | 3:9f857750e4e9 | 1312 | { |
1050186 | 3:9f857750e4e9 | 1313 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 1314 | #if GS_MEASURE_GPU_LOAD |
1050186 | 3:9f857750e4e9 | 1315 | enum { interval = 60 }; |
1050186 | 3:9f857750e4e9 | 1316 | uint32_t idle_start_time; |
1050186 | 3:9f857750e4e9 | 1317 | uint32_t idle_end_time; |
1050186 | 3:9f857750e4e9 | 1318 | static uint32_t skip_count; |
1050186 | 3:9f857750e4e9 | 1319 | static uint32_t previous_idle_end_time; |
1050186 | 3:9f857750e4e9 | 1320 | r_ospl_ftimer_spec_t ts; |
1050186 | 3:9f857750e4e9 | 1321 | #endif |
1050186 | 3:9f857750e4e9 | 1322 | |
1050186 | 3:9f857750e4e9 | 1323 | |
1050186 | 3:9f857750e4e9 | 1324 | e= R_GRAPHICS_Finish( context ); |
1050186 | 3:9f857750e4e9 | 1325 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 1326 | goto fin; |
1050186 | 3:9f857750e4e9 | 1327 | } |
1050186 | 3:9f857750e4e9 | 1328 | |
1050186 | 3:9f857750e4e9 | 1329 | |
1050186 | 3:9f857750e4e9 | 1330 | #if GS_MEASURE_GPU_LOAD |
1050186 | 3:9f857750e4e9 | 1331 | e= R_OSPL_FTIMER_InitializeIfNot( &ts ); |
1050186 | 3:9f857750e4e9 | 1332 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1333 | goto fin; |
1050186 | 3:9f857750e4e9 | 1334 | } |
1050186 | 3:9f857750e4e9 | 1335 | idle_start_time = R_OSPL_FTIMER_Get(); |
1050186 | 3:9f857750e4e9 | 1336 | #endif |
1050186 | 3:9f857750e4e9 | 1337 | |
1050186 | 3:9f857750e4e9 | 1338 | |
1050186 | 3:9f857750e4e9 | 1339 | e= R_WINDOW_SURFACES_SwapBuffers_Sub( self, layer_num ); |
1050186 | 3:9f857750e4e9 | 1340 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 1341 | goto fin; |
1050186 | 3:9f857750e4e9 | 1342 | } |
1050186 | 3:9f857750e4e9 | 1343 | |
1050186 | 3:9f857750e4e9 | 1344 | |
1050186 | 3:9f857750e4e9 | 1345 | e= R_V_SYNC_Wait( self->screen_channel, 1, true ); |
1050186 | 3:9f857750e4e9 | 1346 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 1347 | goto fin; |
1050186 | 3:9f857750e4e9 | 1348 | } |
1050186 | 3:9f857750e4e9 | 1349 | |
1050186 | 3:9f857750e4e9 | 1350 | |
1050186 | 3:9f857750e4e9 | 1351 | #if GS_MEASURE_GPU_LOAD |
1050186 | 3:9f857750e4e9 | 1352 | idle_end_time = R_OSPL_FTIMER_Get(); |
1050186 | 3:9f857750e4e9 | 1353 | if ( previous_idle_end_time != 0 ) { /* Skip at first */ |
1050186 | 3:9f857750e4e9 | 1354 | skip_count += 1; |
1050186 | 3:9f857750e4e9 | 1355 | if ( skip_count >= interval ) { |
1050186 | 3:9f857750e4e9 | 1356 | printf( "GPU %d%% in %dmsec\n", |
1050186 | 3:9f857750e4e9 | 1357 | ( idle_start_time - previous_idle_end_time ) * 100 / |
1050186 | 3:9f857750e4e9 | 1358 | ( idle_end_time - previous_idle_end_time ), |
1050186 | 3:9f857750e4e9 | 1359 | R_OSPL_FTIMER_CountToTime( &ts, |
1050186 | 3:9f857750e4e9 | 1360 | idle_end_time - previous_idle_end_time ) ); |
1050186 | 3:9f857750e4e9 | 1361 | skip_count = 0; |
1050186 | 3:9f857750e4e9 | 1362 | |
1050186 | 3:9f857750e4e9 | 1363 | /* __heapstats( (__heapprt) fprintf, stdout ); */ |
1050186 | 3:9f857750e4e9 | 1364 | |
1050186 | 3:9f857750e4e9 | 1365 | /* R_DEBUG_BREAK(); */ /* This is for measuring CPU load */ |
1050186 | 3:9f857750e4e9 | 1366 | } |
1050186 | 3:9f857750e4e9 | 1367 | } |
1050186 | 3:9f857750e4e9 | 1368 | previous_idle_end_time = idle_end_time; |
1050186 | 3:9f857750e4e9 | 1369 | #endif |
1050186 | 3:9f857750e4e9 | 1370 | |
1050186 | 3:9f857750e4e9 | 1371 | |
1050186 | 3:9f857750e4e9 | 1372 | e=0; |
1050186 | 3:9f857750e4e9 | 1373 | fin: |
1050186 | 3:9f857750e4e9 | 1374 | return e; |
1050186 | 3:9f857750e4e9 | 1375 | } |
1050186 | 3:9f857750e4e9 | 1376 | |
1050186 | 3:9f857750e4e9 | 1377 | |
1050186 | 3:9f857750e4e9 | 1378 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 1379 | * Implement: R_WINDOW_SURFACES_SwapBuffersStart |
1050186 | 3:9f857750e4e9 | 1380 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 1381 | errnum_t R_WINDOW_SURFACES_SwapBuffersStart( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 1382 | int_fast32_t const layer_num, r_ospl_async_t *async ) |
1050186 | 3:9f857750e4e9 | 1383 | { |
1050186 | 3:9f857750e4e9 | 1384 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 1385 | |
1050186 | 3:9f857750e4e9 | 1386 | |
1050186 | 3:9f857750e4e9 | 1387 | e= R_WINDOW_SURFACES_SwapBuffers_Sub( self, layer_num ); |
1050186 | 3:9f857750e4e9 | 1388 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 1389 | goto fin; |
1050186 | 3:9f857750e4e9 | 1390 | } |
1050186 | 3:9f857750e4e9 | 1391 | |
1050186 | 3:9f857750e4e9 | 1392 | |
1050186 | 3:9f857750e4e9 | 1393 | e= R_V_SYNC_WaitStart( self->screen_channel, 1, true, async ); |
1050186 | 3:9f857750e4e9 | 1394 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 1395 | goto fin; |
1050186 | 3:9f857750e4e9 | 1396 | } |
1050186 | 3:9f857750e4e9 | 1397 | |
1050186 | 3:9f857750e4e9 | 1398 | e=0; |
1050186 | 3:9f857750e4e9 | 1399 | fin: |
1050186 | 3:9f857750e4e9 | 1400 | return e; |
1050186 | 3:9f857750e4e9 | 1401 | } |
1050186 | 3:9f857750e4e9 | 1402 | |
1050186 | 3:9f857750e4e9 | 1403 | |
1050186 | 3:9f857750e4e9 | 1404 | /** |
1050186 | 3:9f857750e4e9 | 1405 | * @brief Sub routine of <R_WINDOW_SURFACES_SwapBuffers> |
1050186 | 3:9f857750e4e9 | 1406 | * |
1050186 | 3:9f857750e4e9 | 1407 | * @param self window_surfaces_t |
1050186 | 3:9f857750e4e9 | 1408 | * @param layer_num layer_num |
1050186 | 3:9f857750e4e9 | 1409 | * @return Error code, 0=No error |
1050186 | 3:9f857750e4e9 | 1410 | */ |
1050186 | 3:9f857750e4e9 | 1411 | static errnum_t R_WINDOW_SURFACES_SwapBuffers_Sub( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 1412 | int_fast32_t const layer_num ) |
1050186 | 3:9f857750e4e9 | 1413 | { |
1050186 | 3:9f857750e4e9 | 1414 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 1415 | vdc5_error_t error_vdc; |
1050186 | 3:9f857750e4e9 | 1416 | frame_buffer_t *frame; |
1050186 | 3:9f857750e4e9 | 1417 | window_surfaces_vdc5_layer_t *layer = NULL; |
1050186 | 3:9f857750e4e9 | 1418 | /* NULL is for avoiding warning C417W of mbed cloud compiler */ |
1050186 | 3:9f857750e4e9 | 1419 | |
1050186 | 3:9f857750e4e9 | 1420 | |
1050186 | 3:9f857750e4e9 | 1421 | IF_DQ( self == NULL ) { |
1050186 | 3:9f857750e4e9 | 1422 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1423 | goto fin; |
1050186 | 3:9f857750e4e9 | 1424 | } |
1050186 | 3:9f857750e4e9 | 1425 | |
1050186 | 3:9f857750e4e9 | 1426 | e= window_surfaces_t__get_layer( self, layer_num, &layer ); |
1050186 | 3:9f857750e4e9 | 1427 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 1428 | goto fin; |
1050186 | 3:9f857750e4e9 | 1429 | } |
1050186 | 3:9f857750e4e9 | 1430 | IF_DQ( layer == NULL ) { |
1050186 | 3:9f857750e4e9 | 1431 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1432 | goto fin; |
1050186 | 3:9f857750e4e9 | 1433 | } |
1050186 | 3:9f857750e4e9 | 1434 | |
1050186 | 3:9f857750e4e9 | 1435 | |
1050186 | 3:9f857750e4e9 | 1436 | /* Swap buffer index */ |
1050186 | 3:9f857750e4e9 | 1437 | e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, layer_num, &frame ); |
1050186 | 3:9f857750e4e9 | 1438 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1439 | goto fin; |
1050186 | 3:9f857750e4e9 | 1440 | } |
1050186 | 3:9f857750e4e9 | 1441 | frame->show_buffer_index = frame->draw_buffer_index; |
1050186 | 3:9f857750e4e9 | 1442 | frame->draw_buffer_index += 1; |
1050186 | 3:9f857750e4e9 | 1443 | if ( frame->draw_buffer_index >= (int_t) frame->buffer_count ) { |
1050186 | 3:9f857750e4e9 | 1444 | frame->draw_buffer_index = 0; |
1050186 | 3:9f857750e4e9 | 1445 | } |
1050186 | 3:9f857750e4e9 | 1446 | |
1050186 | 3:9f857750e4e9 | 1447 | |
1050186 | 3:9f857750e4e9 | 1448 | /* Show the frame buffer */ |
1050186 | 3:9f857750e4e9 | 1449 | { |
1050186 | 3:9f857750e4e9 | 1450 | vdc5_read_chg_t config; |
1050186 | 3:9f857750e4e9 | 1451 | uintptr_t physical_address; |
1050186 | 3:9f857750e4e9 | 1452 | |
1050186 | 3:9f857750e4e9 | 1453 | window_surfaces_attribute_t *attribute = NULL; |
1050186 | 3:9f857750e4e9 | 1454 | /* NULL is for avoiding warning C417W of mbed cloud compiler */ |
1050186 | 3:9f857750e4e9 | 1455 | |
1050186 | 3:9f857750e4e9 | 1456 | e= R_OSPL_ToPhysicalAddress( frame->buffer_address[ frame->show_buffer_index ], |
1050186 | 3:9f857750e4e9 | 1457 | &physical_address ); |
1050186 | 3:9f857750e4e9 | 1458 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 1459 | goto fin; |
1050186 | 3:9f857750e4e9 | 1460 | } |
1050186 | 3:9f857750e4e9 | 1461 | |
1050186 | 3:9f857750e4e9 | 1462 | e= window_surfaces_t__get_attribute( self, layer_num, &attribute ); |
1050186 | 3:9f857750e4e9 | 1463 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1464 | goto fin; |
1050186 | 3:9f857750e4e9 | 1465 | } |
1050186 | 3:9f857750e4e9 | 1466 | |
1050186 | 3:9f857750e4e9 | 1467 | if ( attribute->OffsetByte != GS_OFFSET_BYTE_NOT_SHOW ) { |
1050186 | 3:9f857750e4e9 | 1468 | physical_address += attribute->OffsetByte; |
1050186 | 3:9f857750e4e9 | 1469 | |
1050186 | 3:9f857750e4e9 | 1470 | config.gr_base = (void *) physical_address; |
1050186 | 3:9f857750e4e9 | 1471 | config.width_read_fb = NULL; |
1050186 | 3:9f857750e4e9 | 1472 | config.gr_grc = NULL; |
1050186 | 3:9f857750e4e9 | 1473 | config.gr_disp_sel = NULL; |
1050186 | 3:9f857750e4e9 | 1474 | error_vdc = R_VDC5_ChangeReadProcess( self->screen_channel, layer->data_control_ID, &config ); |
1050186 | 3:9f857750e4e9 | 1475 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1476 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1477 | goto fin; |
1050186 | 3:9f857750e4e9 | 1478 | } |
1050186 | 3:9f857750e4e9 | 1479 | } |
1050186 | 3:9f857750e4e9 | 1480 | } |
1050186 | 3:9f857750e4e9 | 1481 | |
1050186 | 3:9f857750e4e9 | 1482 | |
1050186 | 3:9f857750e4e9 | 1483 | /* Show the layer */ |
1050186 | 3:9f857750e4e9 | 1484 | { |
1050186 | 3:9f857750e4e9 | 1485 | vdc5_gr_disp_sel_t new_value; |
1050186 | 3:9f857750e4e9 | 1486 | |
1050186 | 3:9f857750e4e9 | 1487 | if ( layer_num == 1 ) { |
1050186 | 3:9f857750e4e9 | 1488 | new_value = VDC5_DISPSEL_BLEND; |
1050186 | 3:9f857750e4e9 | 1489 | } else if ( layer_num == 0 ) { |
1050186 | 3:9f857750e4e9 | 1490 | frame_buffer_t *frame; |
1050186 | 3:9f857750e4e9 | 1491 | |
1050186 | 3:9f857750e4e9 | 1492 | e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, layer_num, &frame ); |
1050186 | 3:9f857750e4e9 | 1493 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1494 | goto fin; |
1050186 | 3:9f857750e4e9 | 1495 | } |
1050186 | 3:9f857750e4e9 | 1496 | |
1050186 | 3:9f857750e4e9 | 1497 | if ( frame->pixel_format == PIXEL_FORMAT_YUV422 ) { |
1050186 | 3:9f857750e4e9 | 1498 | new_value = VDC5_DISPSEL_CURRENT; |
1050186 | 3:9f857750e4e9 | 1499 | } else { |
1050186 | 3:9f857750e4e9 | 1500 | new_value = VDC5_DISPSEL_BLEND; |
1050186 | 3:9f857750e4e9 | 1501 | } |
1050186 | 3:9f857750e4e9 | 1502 | } else { |
1050186 | 3:9f857750e4e9 | 1503 | ASSERT_D( layer_num == -1, e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 1504 | |
1050186 | 3:9f857750e4e9 | 1505 | if ( self->background_format == BACKGROUND_FORMAT_SOLID_COLOR ) { |
1050186 | 3:9f857750e4e9 | 1506 | new_value = VDC5_DISPSEL_CURRENT; |
1050186 | 3:9f857750e4e9 | 1507 | } else { |
1050186 | 3:9f857750e4e9 | 1508 | new_value = VDC5_DISPSEL_LOWER; /* "*_LOWER" is "*_CURRENT" for resize */ |
1050186 | 3:9f857750e4e9 | 1509 | } |
1050186 | 3:9f857750e4e9 | 1510 | } |
1050186 | 3:9f857750e4e9 | 1511 | |
1050186 | 3:9f857750e4e9 | 1512 | if ( self->vdc5_disp_sel_array[ layer->graphics_layer_ID ] != new_value ) { |
1050186 | 3:9f857750e4e9 | 1513 | vdc5_start_t start; |
1050186 | 3:9f857750e4e9 | 1514 | |
1050186 | 3:9f857750e4e9 | 1515 | self->vdc5_disp_sel_array[ layer->graphics_layer_ID ] = new_value; |
1050186 | 3:9f857750e4e9 | 1516 | |
1050186 | 3:9f857750e4e9 | 1517 | start.gr_disp_sel = self->vdc5_disp_sel_array; |
1050186 | 3:9f857750e4e9 | 1518 | error_vdc = R_VDC5_StartProcess( self->screen_channel, VDC5_LAYER_ID_ALL, &start ); |
1050186 | 3:9f857750e4e9 | 1519 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1520 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1521 | goto fin; |
1050186 | 3:9f857750e4e9 | 1522 | } |
1050186 | 3:9f857750e4e9 | 1523 | } |
1050186 | 3:9f857750e4e9 | 1524 | } |
1050186 | 3:9f857750e4e9 | 1525 | |
1050186 | 3:9f857750e4e9 | 1526 | e=0; |
1050186 | 3:9f857750e4e9 | 1527 | fin: |
1050186 | 3:9f857750e4e9 | 1528 | return e; |
1050186 | 3:9f857750e4e9 | 1529 | } |
1050186 | 3:9f857750e4e9 | 1530 | |
1050186 | 3:9f857750e4e9 | 1531 | |
1050186 | 3:9f857750e4e9 | 1532 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 1533 | * Implement: R_WINDOW_SURFACES_WaitForVSync |
1050186 | 3:9f857750e4e9 | 1534 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 1535 | errnum_t R_WINDOW_SURFACES_WaitForVSync( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 1536 | int_fast32_t const swap_interval, bool_t const is_1_v_sync_at_minimum ) |
1050186 | 3:9f857750e4e9 | 1537 | { |
1050186 | 3:9f857750e4e9 | 1538 | return R_V_SYNC_Wait( self->screen_channel, swap_interval, is_1_v_sync_at_minimum ); |
1050186 | 3:9f857750e4e9 | 1539 | } |
1050186 | 3:9f857750e4e9 | 1540 | |
1050186 | 3:9f857750e4e9 | 1541 | |
1050186 | 3:9f857750e4e9 | 1542 | /** |
1050186 | 3:9f857750e4e9 | 1543 | * @brief R_WINDOW_SURFACES_AllocOffscreenStack |
1050186 | 3:9f857750e4e9 | 1544 | * |
1050186 | 3:9f857750e4e9 | 1545 | * @par Parameters |
1050186 | 3:9f857750e4e9 | 1546 | * None |
1050186 | 3:9f857750e4e9 | 1547 | * @return None. |
1050186 | 3:9f857750e4e9 | 1548 | */ |
1050186 | 3:9f857750e4e9 | 1549 | errnum_t R_WINDOW_SURFACES_AllocOffscreenStack( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 1550 | frame_buffer_t *const in_out_frame_buffer ) |
1050186 | 3:9f857750e4e9 | 1551 | { |
1050186 | 3:9f857750e4e9 | 1552 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 1553 | |
1050186 | 3:9f857750e4e9 | 1554 | IF_DQ( self == NULL ) { |
1050186 | 3:9f857750e4e9 | 1555 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1556 | goto fin; |
1050186 | 3:9f857750e4e9 | 1557 | } |
1050186 | 3:9f857750e4e9 | 1558 | |
1050186 | 3:9f857750e4e9 | 1559 | e= alloc_VRAM_stack_sub( &self->stack_pointer_of_VRAM, self->over_of_VRAM, |
1050186 | 3:9f857750e4e9 | 1560 | in_out_frame_buffer ); |
1050186 | 3:9f857750e4e9 | 1561 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 1562 | goto fin; |
1050186 | 3:9f857750e4e9 | 1563 | } |
1050186 | 3:9f857750e4e9 | 1564 | |
1050186 | 3:9f857750e4e9 | 1565 | e=0; |
1050186 | 3:9f857750e4e9 | 1566 | fin: |
1050186 | 3:9f857750e4e9 | 1567 | return e; |
1050186 | 3:9f857750e4e9 | 1568 | } |
1050186 | 3:9f857750e4e9 | 1569 | |
1050186 | 3:9f857750e4e9 | 1570 | |
1050186 | 3:9f857750e4e9 | 1571 | /** |
1050186 | 3:9f857750e4e9 | 1572 | * @brief R_WINDOW_SURFACES_FreeOffscreenStack |
1050186 | 3:9f857750e4e9 | 1573 | * |
1050186 | 3:9f857750e4e9 | 1574 | * @par Parameters |
1050186 | 3:9f857750e4e9 | 1575 | * None |
1050186 | 3:9f857750e4e9 | 1576 | * @return None. |
1050186 | 3:9f857750e4e9 | 1577 | */ |
1050186 | 3:9f857750e4e9 | 1578 | errnum_t R_WINDOW_SURFACES_FreeOffscreenStack( window_surfaces_t *const self, |
1050186 | 3:9f857750e4e9 | 1579 | const frame_buffer_t *const frame_buffer ) |
1050186 | 3:9f857750e4e9 | 1580 | { |
1050186 | 3:9f857750e4e9 | 1581 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 1582 | |
1050186 | 3:9f857750e4e9 | 1583 | IF_DQ( self == NULL ) { |
1050186 | 3:9f857750e4e9 | 1584 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1585 | goto fin; |
1050186 | 3:9f857750e4e9 | 1586 | } |
1050186 | 3:9f857750e4e9 | 1587 | |
1050186 | 3:9f857750e4e9 | 1588 | e= free_VRAM_stack_sub( &self->stack_pointer_of_VRAM, frame_buffer, |
1050186 | 3:9f857750e4e9 | 1589 | self->start_of_VRAM ); |
1050186 | 3:9f857750e4e9 | 1590 | IF(e!=0) { |
1050186 | 3:9f857750e4e9 | 1591 | goto fin; |
1050186 | 3:9f857750e4e9 | 1592 | } |
1050186 | 3:9f857750e4e9 | 1593 | |
1050186 | 3:9f857750e4e9 | 1594 | e=0; |
1050186 | 3:9f857750e4e9 | 1595 | fin: |
1050186 | 3:9f857750e4e9 | 1596 | return e; |
1050186 | 3:9f857750e4e9 | 1597 | } |
1050186 | 3:9f857750e4e9 | 1598 | |
1050186 | 3:9f857750e4e9 | 1599 | |
1050186 | 3:9f857750e4e9 | 1600 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 1601 | * Implement: R_WINDOW_SURFACES_DoMessageLoop |
1050186 | 3:9f857750e4e9 | 1602 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 1603 | errnum_t R_WINDOW_SURFACES_DoMessageLoop( window_surfaces_t *self ) |
1050186 | 3:9f857750e4e9 | 1604 | { |
1050186 | 3:9f857750e4e9 | 1605 | R_UNREFERENCED_VARIABLE( self ); |
1050186 | 3:9f857750e4e9 | 1606 | |
1050186 | 3:9f857750e4e9 | 1607 | R_OSPL_Delay( 2000 ); |
1050186 | 3:9f857750e4e9 | 1608 | |
1050186 | 3:9f857750e4e9 | 1609 | return 0; |
1050186 | 3:9f857750e4e9 | 1610 | } |
1050186 | 3:9f857750e4e9 | 1611 | |
1050186 | 3:9f857750e4e9 | 1612 | |
1050186 | 3:9f857750e4e9 | 1613 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 1614 | * Implement: R_WINDOW_SURFACES_AccessLayerAttributes |
1050186 | 3:9f857750e4e9 | 1615 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 1616 | errnum_t R_WINDOW_SURFACES_AccessLayerAttributes( window_surfaces_t *self, |
1050186 | 3:9f857750e4e9 | 1617 | layer_attributes_t *in_out_Attributes ) |
1050186 | 3:9f857750e4e9 | 1618 | { |
1050186 | 3:9f857750e4e9 | 1619 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 1620 | vdc5_error_t error_vdc; |
1050186 | 3:9f857750e4e9 | 1621 | window_surfaces_vdc5_layer_t *layer = NULL; |
1050186 | 3:9f857750e4e9 | 1622 | |
1050186 | 3:9f857750e4e9 | 1623 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_ID ) ) { |
1050186 | 3:9f857750e4e9 | 1624 | e= window_surfaces_t__get_layer( self, in_out_Attributes->id, &layer ); |
1050186 | 3:9f857750e4e9 | 1625 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1626 | goto fin; |
1050186 | 3:9f857750e4e9 | 1627 | } |
1050186 | 3:9f857750e4e9 | 1628 | } |
1050186 | 3:9f857750e4e9 | 1629 | |
1050186 | 3:9f857750e4e9 | 1630 | ASSERT_R( IS_ALL_BITS_NOT_SET( in_out_Attributes->access, ~ACCESS_ALL_MASK ), e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 1631 | |
1050186 | 3:9f857750e4e9 | 1632 | |
1050186 | 3:9f857750e4e9 | 1633 | if ( in_out_Attributes->flags & F_LAYER_LAYER_COLOR ) { |
1050186 | 3:9f857750e4e9 | 1634 | vdc5_output_t output; |
1050186 | 3:9f857750e4e9 | 1635 | vdc5_read_t read; |
1050186 | 3:9f857750e4e9 | 1636 | r8g8b8a8_t previous_layer_color = { {0,0,0,0} }; |
1050186 | 3:9f857750e4e9 | 1637 | /* Avoid Warning: C4017W: previous_layer_color may be used before being set */ |
1050186 | 3:9f857750e4e9 | 1638 | enum { necessary_flags = F_LAYER_ID }; |
1050186 | 3:9f857750e4e9 | 1639 | |
1050186 | 3:9f857750e4e9 | 1640 | |
1050186 | 3:9f857750e4e9 | 1641 | ASSERT_R( IS_ALL_BITS_SET( in_out_Attributes->flags, necessary_flags ), |
1050186 | 3:9f857750e4e9 | 1642 | e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 1643 | ASSERT_R( IS_ALL_BITS_NOT_SET( in_out_Attributes->access, ~(ACCESS_READ | ACCESS_WRITE) ), |
1050186 | 3:9f857750e4e9 | 1644 | e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 1645 | |
1050186 | 3:9f857750e4e9 | 1646 | |
1050186 | 3:9f857750e4e9 | 1647 | if ( IS_BIT_SET( in_out_Attributes->access, ACCESS_READ ) ) { |
1050186 | 3:9f857750e4e9 | 1648 | previous_layer_color = layer->layer_color; |
1050186 | 3:9f857750e4e9 | 1649 | } |
1050186 | 3:9f857750e4e9 | 1650 | |
1050186 | 3:9f857750e4e9 | 1651 | |
1050186 | 3:9f857750e4e9 | 1652 | if ( IS_BIT_SET( in_out_Attributes->access, ACCESS_WRITE ) ) { |
1050186 | 3:9f857750e4e9 | 1653 | |
1050186 | 3:9f857750e4e9 | 1654 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_LAYER_COLOR ) ) { |
1050186 | 3:9f857750e4e9 | 1655 | |
1050186 | 3:9f857750e4e9 | 1656 | /* Set "output.bg_color" to "R_VDC5_DisplayOutput" */ |
1050186 | 3:9f857750e4e9 | 1657 | output.tcon_half = (uint16_t)GS_LCD_CHn_TCON_HALF; /* TCON reference timing, 1/2fH timing */ |
1050186 | 3:9f857750e4e9 | 1658 | output.tcon_offset = (uint16_t)GS_LCD_CHn_TCON_OFFSET;/* TCON reference timing, offset Hsync signal timing */ |
1050186 | 3:9f857750e4e9 | 1659 | GRAPHICS_SetLcdTconSettings( self->screen_channel, output.outctrl ); |
1050186 | 3:9f857750e4e9 | 1660 | output.outcnt_lcd_edge = GS_LCD_CHn_OUT_EDGE; /* Output phase control of LCD_DATA23 to LCD_DATA0 pin */ |
1050186 | 3:9f857750e4e9 | 1661 | output.out_endian_on = VDC5_OFF; /* Bit endian change ON/OFF control */ |
1050186 | 3:9f857750e4e9 | 1662 | output.out_swap_on = VDC5_OFF; /* B/R signal swap ON/OFF control */ |
1050186 | 3:9f857750e4e9 | 1663 | output.out_format = GS_LCD_CHn_OUT_FORMAT; /* LCD output format select */ |
1050186 | 3:9f857750e4e9 | 1664 | output.out_frq_sel = VDC5_LCD_PARALLEL_CLKFRQ_1; /* Clock frequency control */ |
1050186 | 3:9f857750e4e9 | 1665 | output.out_dir_sel = VDC5_LCD_SERIAL_SCAN_FORWARD; /* Scan direction select */ |
1050186 | 3:9f857750e4e9 | 1666 | output.out_phase = VDC5_LCD_SERIAL_CLKPHASE_0; /* Clock phase adjustment */ |
1050186 | 3:9f857750e4e9 | 1667 | output.bg_color = |
1050186 | 3:9f857750e4e9 | 1668 | ( in_out_Attributes->layer_color.u.Red << 16 ) | |
1050186 | 3:9f857750e4e9 | 1669 | ( in_out_Attributes->layer_color.u.Green << 8 ) | |
1050186 | 3:9f857750e4e9 | 1670 | ( in_out_Attributes->layer_color.u.Blue << 0 ); /* 24-bit RGB color format */ |
1050186 | 3:9f857750e4e9 | 1671 | |
1050186 | 3:9f857750e4e9 | 1672 | error_vdc = R_VDC5_DisplayOutput( self->screen_channel, &output ); |
1050186 | 3:9f857750e4e9 | 1673 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1674 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1675 | goto fin; |
1050186 | 3:9f857750e4e9 | 1676 | } |
1050186 | 3:9f857750e4e9 | 1677 | |
1050186 | 3:9f857750e4e9 | 1678 | |
1050186 | 3:9f857750e4e9 | 1679 | /* Update ReadDataControl */ |
1050186 | 3:9f857750e4e9 | 1680 | |
1050186 | 3:9f857750e4e9 | 1681 | /* Release */ |
1050186 | 3:9f857750e4e9 | 1682 | if ( layer->is_data_control ) { |
1050186 | 3:9f857750e4e9 | 1683 | error_vdc = R_VDC5_StopProcess( self->screen_channel, layer->data_control_ID ); |
1050186 | 3:9f857750e4e9 | 1684 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1685 | R_NOOP(); |
1050186 | 3:9f857750e4e9 | 1686 | } |
1050186 | 3:9f857750e4e9 | 1687 | error_vdc = R_VDC5_ReleaseDataControl( self->screen_channel, layer->data_control_ID ); |
1050186 | 3:9f857750e4e9 | 1688 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1689 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1690 | goto fin; |
1050186 | 3:9f857750e4e9 | 1691 | } |
1050186 | 3:9f857750e4e9 | 1692 | layer->is_data_control = false; |
1050186 | 3:9f857750e4e9 | 1693 | } |
1050186 | 3:9f857750e4e9 | 1694 | |
1050186 | 3:9f857750e4e9 | 1695 | /* Read data parameter : These values are dummy */ |
1050186 | 3:9f857750e4e9 | 1696 | read.gr_ln_off_dir = VDC5_GR_LN_OFF_DIR_INC; /* Line offset address direction of the frame buffer */ |
1050186 | 3:9f857750e4e9 | 1697 | read.gr_flm_sel = VDC5_GR_FLM_SEL_FLM_NUM; /* Selects a frame buffer address setting signal */ |
1050186 | 3:9f857750e4e9 | 1698 | read.gr_imr_flm_inv = VDC5_OFF; /* Sets the frame buffer number for distortion correction */ |
1050186 | 3:9f857750e4e9 | 1699 | read.gr_bst_md = VDC5_BST_MD_32BYTE; /* Frame buffer burst transfer mode */ |
1050186 | 3:9f857750e4e9 | 1700 | read.gr_base = (void *) &read; /* Dummy, Frame buffer base address */ |
1050186 | 3:9f857750e4e9 | 1701 | read.gr_ln_off = 3200; /* Dummy, Frame buffer line offset address */ |
1050186 | 3:9f857750e4e9 | 1702 | read.width_read_fb = NULL; /* width of the image read from frame buffer */ |
1050186 | 3:9f857750e4e9 | 1703 | read.adj_sel = VDC5_OFF; /* Measures to decrease the influence |
1050186 | 3:9f857750e4e9 | 1704 | by folding pixels/lines (ON/OFF) */ |
1050186 | 3:9f857750e4e9 | 1705 | read.gr_format = VDC5_GR_FORMAT_RGB888; /* Graphics format of the frame buffer read signal */ |
1050186 | 3:9f857750e4e9 | 1706 | read.gr_ycc_swap = VDC5_GR_YCCSWAP_Y1CRY0CB; /* Controls swapping of data read from buffer |
1050186 | 3:9f857750e4e9 | 1707 | in the YCbCr422 format */ |
1050186 | 3:9f857750e4e9 | 1708 | read.gr_rdswa = VDC5_WR_RD_WRSWA_32BIT; /* for 32 bit format */ |
1050186 | 3:9f857750e4e9 | 1709 | |
1050186 | 3:9f857750e4e9 | 1710 | /* Set bakcground color area */ |
1050186 | 3:9f857750e4e9 | 1711 | read.gr_grc.hs = GS_LCD_CHn_DISP_HS; |
1050186 | 3:9f857750e4e9 | 1712 | read.gr_grc.hw = (uint16_t) GS_LCD_CHn_DISP_HW; |
1050186 | 3:9f857750e4e9 | 1713 | read.gr_grc.vs = GS_LCD_CHn_DISP_VS; |
1050186 | 3:9f857750e4e9 | 1714 | if ( GS_BUFFER_HEIGHT < GS_LCD_CHn_DISP_VW ) { |
1050186 | 3:9f857750e4e9 | 1715 | read.gr_grc.vw = (uint16_t) GS_BUFFER_HEIGHT; |
1050186 | 3:9f857750e4e9 | 1716 | } else { |
1050186 | 3:9f857750e4e9 | 1717 | read.gr_grc.vw = GS_LCD_CHn_DISP_VW; |
1050186 | 3:9f857750e4e9 | 1718 | } |
1050186 | 3:9f857750e4e9 | 1719 | |
1050186 | 3:9f857750e4e9 | 1720 | /* Start to read again */ |
1050186 | 3:9f857750e4e9 | 1721 | error_vdc = R_VDC5_ReadDataControl( self->screen_channel, layer->data_control_ID, &read ); |
1050186 | 3:9f857750e4e9 | 1722 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1723 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1724 | goto fin; |
1050186 | 3:9f857750e4e9 | 1725 | } |
1050186 | 3:9f857750e4e9 | 1726 | layer->is_data_control = true; |
1050186 | 3:9f857750e4e9 | 1727 | } |
1050186 | 3:9f857750e4e9 | 1728 | |
1050186 | 3:9f857750e4e9 | 1729 | |
1050186 | 3:9f857750e4e9 | 1730 | /* Set graphics display mode */ |
1050186 | 3:9f857750e4e9 | 1731 | { |
1050186 | 3:9f857750e4e9 | 1732 | vdc5_start_t start; |
1050186 | 3:9f857750e4e9 | 1733 | |
1050186 | 3:9f857750e4e9 | 1734 | start.gr_disp_sel = self->vdc5_disp_sel_array; |
1050186 | 3:9f857750e4e9 | 1735 | error_vdc = R_VDC5_StartProcess( self->screen_channel, VDC5_LAYER_ID_ALL, &start ); |
1050186 | 3:9f857750e4e9 | 1736 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1737 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1738 | goto fin; |
1050186 | 3:9f857750e4e9 | 1739 | } |
1050186 | 3:9f857750e4e9 | 1740 | } |
1050186 | 3:9f857750e4e9 | 1741 | } |
1050186 | 3:9f857750e4e9 | 1742 | |
1050186 | 3:9f857750e4e9 | 1743 | if ( IS_BIT_SET( in_out_Attributes->access, ACCESS_READ ) ) { |
1050186 | 3:9f857750e4e9 | 1744 | in_out_Attributes->layer_color = previous_layer_color; |
1050186 | 3:9f857750e4e9 | 1745 | } |
1050186 | 3:9f857750e4e9 | 1746 | } |
1050186 | 3:9f857750e4e9 | 1747 | |
1050186 | 3:9f857750e4e9 | 1748 | |
1050186 | 3:9f857750e4e9 | 1749 | /* Set window position */ |
1050186 | 3:9f857750e4e9 | 1750 | { |
1050186 | 3:9f857750e4e9 | 1751 | enum { flags_of_window_position = |
1050186 | 3:9f857750e4e9 | 1752 | F_LAYER_X | F_LAYER_Y | F_LAYER_WIDTH | F_LAYER_HEIGHT | |
1050186 | 3:9f857750e4e9 | 1753 | F_LAYER_OFFSET_X | F_LAYER_OFFSET_Y |
1050186 | 3:9f857750e4e9 | 1754 | }; |
1050186 | 3:9f857750e4e9 | 1755 | |
1050186 | 3:9f857750e4e9 | 1756 | if ( IS_ANY_BITS_SET( in_out_Attributes->flags, flags_of_window_position ) && |
1050186 | 3:9f857750e4e9 | 1757 | IS_BIT_SET( in_out_Attributes->access, ACCESS_WRITE ) ) { |
1050186 | 3:9f857750e4e9 | 1758 | vdc5_read_chg_t change; |
1050186 | 3:9f857750e4e9 | 1759 | vdc5_width_read_fb_t change_source_rectangle; |
1050186 | 3:9f857750e4e9 | 1760 | vdc5_period_rect_t change_destination_rectangle; |
1050186 | 3:9f857750e4e9 | 1761 | gs_frame_width_height_t source_frame; |
1050186 | 3:9f857750e4e9 | 1762 | gs_frame_width_height_t destination_frame; |
1050186 | 3:9f857750e4e9 | 1763 | gs_rectangle_t source_rectangle; |
1050186 | 3:9f857750e4e9 | 1764 | gs_rectangle_t destination_rectangle; |
1050186 | 3:9f857750e4e9 | 1765 | frame_buffer_t *frame; |
1050186 | 3:9f857750e4e9 | 1766 | bool_t is_interlace; |
1050186 | 3:9f857750e4e9 | 1767 | bool_t is_solid_color; |
1050186 | 3:9f857750e4e9 | 1768 | bool_t is_show = true; |
1050186 | 3:9f857750e4e9 | 1769 | window_surfaces_attribute_t *attribute = NULL; |
1050186 | 3:9f857750e4e9 | 1770 | /* NULL is for avoiding warning C417W of mbed cloud compiler */ |
1050186 | 3:9f857750e4e9 | 1771 | |
1050186 | 3:9f857750e4e9 | 1772 | |
1050186 | 3:9f857750e4e9 | 1773 | ASSERT_R( IS_ALL_BITS_SET( in_out_Attributes->flags, F_LAYER_ID ), e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 1774 | |
1050186 | 3:9f857750e4e9 | 1775 | e= window_surfaces_t__get_attribute( self, in_out_Attributes->id, &attribute ); |
1050186 | 3:9f857750e4e9 | 1776 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1777 | goto fin; |
1050186 | 3:9f857750e4e9 | 1778 | } |
1050186 | 3:9f857750e4e9 | 1779 | |
1050186 | 3:9f857750e4e9 | 1780 | is_interlace = ( self->background_format == BACKGROUND_FORMAT_VIDEO_INTERLACE && |
1050186 | 3:9f857750e4e9 | 1781 | in_out_Attributes->id == -1 ); |
1050186 | 3:9f857750e4e9 | 1782 | |
1050186 | 3:9f857750e4e9 | 1783 | is_solid_color = ( self->background_format == BACKGROUND_FORMAT_SOLID_COLOR && |
1050186 | 3:9f857750e4e9 | 1784 | in_out_Attributes->id == -1 ); |
1050186 | 3:9f857750e4e9 | 1785 | |
1050186 | 3:9f857750e4e9 | 1786 | change.gr_base = NULL; |
1050186 | 3:9f857750e4e9 | 1787 | change.width_read_fb = NULL; |
1050186 | 3:9f857750e4e9 | 1788 | change.gr_grc = NULL; |
1050186 | 3:9f857750e4e9 | 1789 | change.gr_disp_sel = NULL; |
1050186 | 3:9f857750e4e9 | 1790 | |
1050186 | 3:9f857750e4e9 | 1791 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_X ) ) { |
1050186 | 3:9f857750e4e9 | 1792 | attribute->X = in_out_Attributes->x; |
1050186 | 3:9f857750e4e9 | 1793 | change.gr_grc = &change_destination_rectangle; |
1050186 | 3:9f857750e4e9 | 1794 | } |
1050186 | 3:9f857750e4e9 | 1795 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_Y ) ) { |
1050186 | 3:9f857750e4e9 | 1796 | attribute->Y = in_out_Attributes->y; |
1050186 | 3:9f857750e4e9 | 1797 | change.gr_grc = &change_destination_rectangle; |
1050186 | 3:9f857750e4e9 | 1798 | } |
1050186 | 3:9f857750e4e9 | 1799 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_WIDTH ) ) { |
1050186 | 3:9f857750e4e9 | 1800 | attribute->Width = in_out_Attributes->width; |
1050186 | 3:9f857750e4e9 | 1801 | change.gr_grc = &change_destination_rectangle; |
1050186 | 3:9f857750e4e9 | 1802 | } |
1050186 | 3:9f857750e4e9 | 1803 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_HEIGHT ) ) { |
1050186 | 3:9f857750e4e9 | 1804 | attribute->Height = in_out_Attributes->height; |
1050186 | 3:9f857750e4e9 | 1805 | change.gr_grc = &change_destination_rectangle; |
1050186 | 3:9f857750e4e9 | 1806 | } |
1050186 | 3:9f857750e4e9 | 1807 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_OFFSET_X ) ) { |
1050186 | 3:9f857750e4e9 | 1808 | attribute->OffsetX = in_out_Attributes->offset_x; |
1050186 | 3:9f857750e4e9 | 1809 | change.gr_grc = &change_destination_rectangle; |
1050186 | 3:9f857750e4e9 | 1810 | } |
1050186 | 3:9f857750e4e9 | 1811 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_OFFSET_Y ) ) { |
1050186 | 3:9f857750e4e9 | 1812 | attribute->OffsetY = in_out_Attributes->offset_y; |
1050186 | 3:9f857750e4e9 | 1813 | change.gr_grc = &change_destination_rectangle; |
1050186 | 3:9f857750e4e9 | 1814 | } |
1050186 | 3:9f857750e4e9 | 1815 | |
1050186 | 3:9f857750e4e9 | 1816 | |
1050186 | 3:9f857750e4e9 | 1817 | /* Call "GS_ToInFrame" */ |
1050186 | 3:9f857750e4e9 | 1818 | if ( is_solid_color ) { |
1050186 | 3:9f857750e4e9 | 1819 | e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, 0, &frame ); |
1050186 | 3:9f857750e4e9 | 1820 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1821 | goto fin; |
1050186 | 3:9f857750e4e9 | 1822 | } |
1050186 | 3:9f857750e4e9 | 1823 | } else { |
1050186 | 3:9f857750e4e9 | 1824 | e= R_WINDOW_SURFACES_GetLayerFrameBuffer( self, in_out_Attributes->id, &frame ); |
1050186 | 3:9f857750e4e9 | 1825 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1826 | goto fin; |
1050186 | 3:9f857750e4e9 | 1827 | } |
1050186 | 3:9f857750e4e9 | 1828 | } |
1050186 | 3:9f857750e4e9 | 1829 | source_frame.Width = frame->width; |
1050186 | 3:9f857750e4e9 | 1830 | source_frame.Height = frame->height; |
1050186 | 3:9f857750e4e9 | 1831 | destination_frame.Width = frame->width; |
1050186 | 3:9f857750e4e9 | 1832 | destination_frame.Height = frame->height; |
1050186 | 3:9f857750e4e9 | 1833 | source_rectangle.Left = attribute->OffsetX; |
1050186 | 3:9f857750e4e9 | 1834 | source_rectangle.Top = attribute->OffsetY; |
1050186 | 3:9f857750e4e9 | 1835 | source_rectangle.Right = attribute->OffsetX + attribute->Width; |
1050186 | 3:9f857750e4e9 | 1836 | source_rectangle.Bottom = attribute->OffsetY + attribute->Height; |
1050186 | 3:9f857750e4e9 | 1837 | destination_rectangle.Left = attribute->X; |
1050186 | 3:9f857750e4e9 | 1838 | destination_rectangle.Top = attribute->Y; |
1050186 | 3:9f857750e4e9 | 1839 | destination_rectangle.Right = attribute->X + attribute->Width; |
1050186 | 3:9f857750e4e9 | 1840 | destination_rectangle.Bottom = attribute->Y + attribute->Height; |
1050186 | 3:9f857750e4e9 | 1841 | |
1050186 | 3:9f857750e4e9 | 1842 | e= GS_ToInFrame( &source_frame, &destination_frame, |
1050186 | 3:9f857750e4e9 | 1843 | &source_rectangle, &destination_rectangle ); |
1050186 | 3:9f857750e4e9 | 1844 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1845 | goto fin; |
1050186 | 3:9f857750e4e9 | 1846 | } |
1050186 | 3:9f857750e4e9 | 1847 | if ( source_rectangle.Left > source_rectangle.Right ) { |
1050186 | 3:9f857750e4e9 | 1848 | is_show = false; |
1050186 | 3:9f857750e4e9 | 1849 | } |
1050186 | 3:9f857750e4e9 | 1850 | |
1050186 | 3:9f857750e4e9 | 1851 | |
1050186 | 3:9f857750e4e9 | 1852 | /* Call "R_VDC5_ChangeReadProcess" */ |
1050186 | 3:9f857750e4e9 | 1853 | if ( is_show ) { |
1050186 | 3:9f857750e4e9 | 1854 | byte_t *source_address; |
1050186 | 3:9f857750e4e9 | 1855 | int_fast32_t offset_byte; |
1050186 | 3:9f857750e4e9 | 1856 | |
1050186 | 3:9f857750e4e9 | 1857 | ASSERT_R( ! is_solid_color, e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 1858 | |
1050186 | 3:9f857750e4e9 | 1859 | if ( is_interlace ) { |
1050186 | 3:9f857750e4e9 | 1860 | source_address = frame->buffer_address[0]; |
1050186 | 3:9f857750e4e9 | 1861 | offset_byte = ( source_rectangle.Top / 2 ) * frame->stride; |
1050186 | 3:9f857750e4e9 | 1862 | } else { |
1050186 | 3:9f857750e4e9 | 1863 | source_address = frame->buffer_address[ frame->show_buffer_index ]; |
1050186 | 3:9f857750e4e9 | 1864 | offset_byte = source_rectangle.Top * frame->stride; |
1050186 | 3:9f857750e4e9 | 1865 | } |
1050186 | 3:9f857750e4e9 | 1866 | offset_byte += source_rectangle.Left * frame->byte_per_pixel; |
1050186 | 3:9f857750e4e9 | 1867 | ASSERT_R( R_BYTE_PER_PIXEL_IsInteger( frame->byte_per_pixel ), |
1050186 | 3:9f857750e4e9 | 1868 | e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 1869 | attribute->OffsetByte = offset_byte; |
1050186 | 3:9f857750e4e9 | 1870 | |
1050186 | 3:9f857750e4e9 | 1871 | change.gr_base = source_address + attribute->OffsetByte; |
1050186 | 3:9f857750e4e9 | 1872 | } |
1050186 | 3:9f857750e4e9 | 1873 | if ( change.gr_grc != NULL ) { |
1050186 | 3:9f857750e4e9 | 1874 | change_destination_rectangle.hs = destination_rectangle.Left + GS_LCD_CHn_DISP_HS; |
1050186 | 3:9f857750e4e9 | 1875 | change_destination_rectangle.vs = destination_rectangle.Top + GS_LCD_CHn_DISP_VS; |
1050186 | 3:9f857750e4e9 | 1876 | change_destination_rectangle.hw = destination_rectangle.Right - destination_rectangle.Left + 1; |
1050186 | 3:9f857750e4e9 | 1877 | change_destination_rectangle.vw = destination_rectangle.Bottom - destination_rectangle.Top + 1; |
1050186 | 3:9f857750e4e9 | 1878 | |
1050186 | 3:9f857750e4e9 | 1879 | change.width_read_fb = &change_source_rectangle; |
1050186 | 3:9f857750e4e9 | 1880 | change_source_rectangle.in_hw = change_destination_rectangle.hw; |
1050186 | 3:9f857750e4e9 | 1881 | change_source_rectangle.in_vw = change_destination_rectangle.vw; |
1050186 | 3:9f857750e4e9 | 1882 | |
1050186 | 3:9f857750e4e9 | 1883 | if ( is_interlace ) { |
1050186 | 3:9f857750e4e9 | 1884 | change_source_rectangle.in_vw /= 2; |
1050186 | 3:9f857750e4e9 | 1885 | } |
1050186 | 3:9f857750e4e9 | 1886 | } |
1050186 | 3:9f857750e4e9 | 1887 | |
1050186 | 3:9f857750e4e9 | 1888 | if ( change_source_rectangle.in_hw < 3 || change_source_rectangle.in_vw == 0 ) { |
1050186 | 3:9f857750e4e9 | 1889 | is_show = false; |
1050186 | 3:9f857750e4e9 | 1890 | } |
1050186 | 3:9f857750e4e9 | 1891 | |
1050186 | 3:9f857750e4e9 | 1892 | if ( ! is_show ) { |
1050186 | 3:9f857750e4e9 | 1893 | change_destination_rectangle.hs = GS_LCD_CHn_DISP_HS - 2; /* out of visible */ |
1050186 | 3:9f857750e4e9 | 1894 | change_destination_rectangle.vs = GS_LCD_CHn_DISP_VS; |
1050186 | 3:9f857750e4e9 | 1895 | change_destination_rectangle.hw = 3; |
1050186 | 3:9f857750e4e9 | 1896 | change_destination_rectangle.vw = 1; |
1050186 | 3:9f857750e4e9 | 1897 | change_source_rectangle.in_hw = 3; |
1050186 | 3:9f857750e4e9 | 1898 | change_source_rectangle.in_vw = 1; |
1050186 | 3:9f857750e4e9 | 1899 | attribute->OffsetByte = GS_OFFSET_BYTE_NOT_SHOW; |
1050186 | 3:9f857750e4e9 | 1900 | } |
1050186 | 3:9f857750e4e9 | 1901 | |
1050186 | 3:9f857750e4e9 | 1902 | error_vdc = R_VDC5_ChangeReadProcess( |
1050186 | 3:9f857750e4e9 | 1903 | self->screen_channel, layer->data_control_ID, &change ); |
1050186 | 3:9f857750e4e9 | 1904 | IF ( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1905 | e = E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1906 | goto fin; |
1050186 | 3:9f857750e4e9 | 1907 | } |
1050186 | 3:9f857750e4e9 | 1908 | } |
1050186 | 3:9f857750e4e9 | 1909 | if ( IS_ANY_BITS_SET( in_out_Attributes->flags, flags_of_window_position ) && |
1050186 | 3:9f857750e4e9 | 1910 | IS_BIT_SET( in_out_Attributes->access, ACCESS_READ ) ) { |
1050186 | 3:9f857750e4e9 | 1911 | window_surfaces_attribute_t *attribute = NULL; |
1050186 | 3:9f857750e4e9 | 1912 | /* NULL is for avoiding warning C417W of mbed cloud compiler */ |
1050186 | 3:9f857750e4e9 | 1913 | |
1050186 | 3:9f857750e4e9 | 1914 | ASSERT_R( IS_ALL_BITS_SET( in_out_Attributes->flags, F_LAYER_ID ), e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 1915 | |
1050186 | 3:9f857750e4e9 | 1916 | e= window_surfaces_t__get_attribute( self, in_out_Attributes->id, &attribute ); |
1050186 | 3:9f857750e4e9 | 1917 | IF(e) { |
1050186 | 3:9f857750e4e9 | 1918 | goto fin; |
1050186 | 3:9f857750e4e9 | 1919 | } |
1050186 | 3:9f857750e4e9 | 1920 | |
1050186 | 3:9f857750e4e9 | 1921 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_X ) ) { |
1050186 | 3:9f857750e4e9 | 1922 | in_out_Attributes->x = attribute->X; |
1050186 | 3:9f857750e4e9 | 1923 | } |
1050186 | 3:9f857750e4e9 | 1924 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_Y ) ) { |
1050186 | 3:9f857750e4e9 | 1925 | in_out_Attributes->y = attribute->Y; |
1050186 | 3:9f857750e4e9 | 1926 | } |
1050186 | 3:9f857750e4e9 | 1927 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_WIDTH ) ) { |
1050186 | 3:9f857750e4e9 | 1928 | in_out_Attributes->width = attribute->Width; |
1050186 | 3:9f857750e4e9 | 1929 | } |
1050186 | 3:9f857750e4e9 | 1930 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_HEIGHT ) ) { |
1050186 | 3:9f857750e4e9 | 1931 | in_out_Attributes->height = attribute->Height; |
1050186 | 3:9f857750e4e9 | 1932 | } |
1050186 | 3:9f857750e4e9 | 1933 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_OFFSET_X ) ) { |
1050186 | 3:9f857750e4e9 | 1934 | in_out_Attributes->offset_x = attribute->OffsetX; |
1050186 | 3:9f857750e4e9 | 1935 | } |
1050186 | 3:9f857750e4e9 | 1936 | if ( IS_BIT_SET( in_out_Attributes->flags, F_LAYER_OFFSET_Y ) ) { |
1050186 | 3:9f857750e4e9 | 1937 | in_out_Attributes->offset_y = attribute->OffsetY; |
1050186 | 3:9f857750e4e9 | 1938 | } |
1050186 | 3:9f857750e4e9 | 1939 | } |
1050186 | 3:9f857750e4e9 | 1940 | } |
1050186 | 3:9f857750e4e9 | 1941 | |
1050186 | 3:9f857750e4e9 | 1942 | |
1050186 | 3:9f857750e4e9 | 1943 | /* Call "R_VDC5_CLUT" */ |
1050186 | 3:9f857750e4e9 | 1944 | { |
1050186 | 3:9f857750e4e9 | 1945 | enum { flags_of_CLUT = F_LAYER_CLUT | F_LAYER_CLUT_COUNT }; |
1050186 | 3:9f857750e4e9 | 1946 | |
1050186 | 3:9f857750e4e9 | 1947 | if ( IS_ANY_BITS_SET( in_out_Attributes->flags, flags_of_CLUT ) ) { |
1050186 | 3:9f857750e4e9 | 1948 | vdc5_clut_t clut_data; |
1050186 | 3:9f857750e4e9 | 1949 | enum { necessary_flags = flags_of_CLUT | F_LAYER_ID }; |
1050186 | 3:9f857750e4e9 | 1950 | |
1050186 | 3:9f857750e4e9 | 1951 | ASSERT_R( IS_ALL_BITS_SET( in_out_Attributes->flags, necessary_flags ), |
1050186 | 3:9f857750e4e9 | 1952 | e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 1953 | ASSERT_R( IS_ANY_BITS_NOT_SET( |
1050186 | 3:9f857750e4e9 | 1954 | in_out_Attributes->access, ~ (bit_flags_fast32_t) ACCESS_WRITE ), |
1050186 | 3:9f857750e4e9 | 1955 | e=E_OTHERS; goto fin ); |
1050186 | 3:9f857750e4e9 | 1956 | |
1050186 | 3:9f857750e4e9 | 1957 | clut_data.color_num = in_out_Attributes->CLUT_count; |
1050186 | 3:9f857750e4e9 | 1958 | clut_data.clut = (uint32_t *)( in_out_Attributes->CLUT ); |
1050186 | 3:9f857750e4e9 | 1959 | error_vdc = R_VDC5_CLUT( self->screen_channel, layer->data_control_ID, &clut_data ); |
1050186 | 3:9f857750e4e9 | 1960 | IF( error_vdc != VDC5_OK ) { |
1050186 | 3:9f857750e4e9 | 1961 | e=E_OTHERS; |
1050186 | 3:9f857750e4e9 | 1962 | goto fin; |
1050186 | 3:9f857750e4e9 | 1963 | } |
1050186 | 3:9f857750e4e9 | 1964 | } |
1050186 | 3:9f857750e4e9 | 1965 | } |
1050186 | 3:9f857750e4e9 | 1966 | |
1050186 | 3:9f857750e4e9 | 1967 | IF( IS_ANY_BITS_SET( in_out_Attributes->flags, |
1050186 | 3:9f857750e4e9 | 1968 | ~( F_LAYER_ID | F_LAYER_LAYER_COLOR | F_LAYER_CLUT_COUNT | F_LAYER_CLUT | |
1050186 | 3:9f857750e4e9 | 1969 | F_LAYER_X | F_LAYER_Y | F_LAYER_WIDTH | F_LAYER_HEIGHT | |
1050186 | 3:9f857750e4e9 | 1970 | F_LAYER_OFFSET_X | F_LAYER_OFFSET_Y ) ) ) { |
1050186 | 3:9f857750e4e9 | 1971 | e=E_LIMITATION; |
1050186 | 3:9f857750e4e9 | 1972 | goto fin; |
1050186 | 3:9f857750e4e9 | 1973 | } |
1050186 | 3:9f857750e4e9 | 1974 | |
1050186 | 3:9f857750e4e9 | 1975 | e=0; |
1050186 | 3:9f857750e4e9 | 1976 | fin: |
1050186 | 3:9f857750e4e9 | 1977 | return e; |
1050186 | 3:9f857750e4e9 | 1978 | } |
1050186 | 3:9f857750e4e9 | 1979 | |
1050186 | 3:9f857750e4e9 | 1980 | |
1050186 | 3:9f857750e4e9 | 1981 | /* Section: Global */ |
1050186 | 3:9f857750e4e9 | 1982 | /** |
1050186 | 3:9f857750e4e9 | 1983 | * @brief Put "SourceRect" and "DestinationRect" into the frame. |
1050186 | 3:9f857750e4e9 | 1984 | * |
1050186 | 3:9f857750e4e9 | 1985 | * @param SourceFrameBuffer gs_frame_width_height_t |
1050186 | 3:9f857750e4e9 | 1986 | * @param DestinationFrameBuffer gs_frame_width_height_t |
1050186 | 3:9f857750e4e9 | 1987 | * @param SourceRect gs_rectangle_t |
1050186 | 3:9f857750e4e9 | 1988 | * @param DestinationRect gs_rectangle_t |
1050186 | 3:9f857750e4e9 | 1989 | * @return Error Code. 0=No Error. |
1050186 | 3:9f857750e4e9 | 1990 | * |
1050186 | 3:9f857750e4e9 | 1991 | * @par Description |
1050186 | 3:9f857750e4e9 | 1992 | * - If out of frame then "SourceRect - >Left > SourceRect->Right". |
1050186 | 3:9f857750e4e9 | 1993 | */ |
1050186 | 3:9f857750e4e9 | 1994 | errnum_t GS_ToInFrame( |
1050186 | 3:9f857750e4e9 | 1995 | gs_frame_width_height_t *SourceFrameBuffer, |
1050186 | 3:9f857750e4e9 | 1996 | gs_frame_width_height_t *DestinationFrameBuffer, |
1050186 | 3:9f857750e4e9 | 1997 | gs_rectangle_t *SourceRect, |
1050186 | 3:9f857750e4e9 | 1998 | gs_rectangle_t *DestinationRect ) |
1050186 | 3:9f857750e4e9 | 1999 | { |
1050186 | 3:9f857750e4e9 | 2000 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 2001 | int src_top, src_bottom, dst_top, dst_bottom; /* top down coord */ |
1050186 | 3:9f857750e4e9 | 2002 | int diff; |
1050186 | 3:9f857750e4e9 | 2003 | |
1050186 | 3:9f857750e4e9 | 2004 | |
1050186 | 3:9f857750e4e9 | 2005 | /* fast culling by out of frame buffer horizontal */ |
1050186 | 3:9f857750e4e9 | 2006 | if ( SourceRect->Left >= SourceFrameBuffer->Width || |
1050186 | 3:9f857750e4e9 | 2007 | DestinationRect->Left >= DestinationFrameBuffer->Width || |
1050186 | 3:9f857750e4e9 | 2008 | SourceRect->Right < 0 || |
1050186 | 3:9f857750e4e9 | 2009 | DestinationRect->Right < 0 ) { |
1050186 | 3:9f857750e4e9 | 2010 | SourceRect->Right = SourceRect->Left - 1; /* out of frame */ |
1050186 | 3:9f857750e4e9 | 2011 | e = 0; |
1050186 | 3:9f857750e4e9 | 2012 | goto fin; |
1050186 | 3:9f857750e4e9 | 2013 | } |
1050186 | 3:9f857750e4e9 | 2014 | |
1050186 | 3:9f857750e4e9 | 2015 | |
1050186 | 3:9f857750e4e9 | 2016 | /* set "src_top", "src_bottom", "dst_top", "dst_bottom" */ |
1050186 | 3:9f857750e4e9 | 2017 | src_top = SourceRect->Top; |
1050186 | 3:9f857750e4e9 | 2018 | src_bottom = SourceRect->Bottom; |
1050186 | 3:9f857750e4e9 | 2019 | dst_top = DestinationRect->Top; |
1050186 | 3:9f857750e4e9 | 2020 | dst_bottom = DestinationRect->Bottom; |
1050186 | 3:9f857750e4e9 | 2021 | |
1050186 | 3:9f857750e4e9 | 2022 | |
1050186 | 3:9f857750e4e9 | 2023 | /* fast culling by out of frame buffer vertical */ |
1050186 | 3:9f857750e4e9 | 2024 | if ( src_top >= SourceFrameBuffer->Height || |
1050186 | 3:9f857750e4e9 | 2025 | dst_top >= DestinationFrameBuffer->Height || |
1050186 | 3:9f857750e4e9 | 2026 | src_bottom < 0 || |
1050186 | 3:9f857750e4e9 | 2027 | dst_bottom < 0 ) { |
1050186 | 3:9f857750e4e9 | 2028 | SourceRect->Right = SourceRect->Left - 1; /* out of frame */ |
1050186 | 3:9f857750e4e9 | 2029 | e = 0; |
1050186 | 3:9f857750e4e9 | 2030 | goto fin; |
1050186 | 3:9f857750e4e9 | 2031 | } |
1050186 | 3:9f857750e4e9 | 2032 | |
1050186 | 3:9f857750e4e9 | 2033 | |
1050186 | 3:9f857750e4e9 | 2034 | /* set top >= 0 */ |
1050186 | 3:9f857750e4e9 | 2035 | if ( src_top < 0 ) { |
1050186 | 3:9f857750e4e9 | 2036 | dst_top += - src_top; |
1050186 | 3:9f857750e4e9 | 2037 | src_top = 0; |
1050186 | 3:9f857750e4e9 | 2038 | } |
1050186 | 3:9f857750e4e9 | 2039 | |
1050186 | 3:9f857750e4e9 | 2040 | if ( dst_top < 0 ) { |
1050186 | 3:9f857750e4e9 | 2041 | src_top += - dst_top; |
1050186 | 3:9f857750e4e9 | 2042 | dst_top = 0; |
1050186 | 3:9f857750e4e9 | 2043 | } |
1050186 | 3:9f857750e4e9 | 2044 | |
1050186 | 3:9f857750e4e9 | 2045 | |
1050186 | 3:9f857750e4e9 | 2046 | /* set bottom < frame height */ |
1050186 | 3:9f857750e4e9 | 2047 | if ( src_bottom >= SourceFrameBuffer->Height ) { |
1050186 | 3:9f857750e4e9 | 2048 | diff = src_bottom - SourceFrameBuffer->Height + 1; |
1050186 | 3:9f857750e4e9 | 2049 | src_bottom -= diff; |
1050186 | 3:9f857750e4e9 | 2050 | dst_bottom -= diff; |
1050186 | 3:9f857750e4e9 | 2051 | } |
1050186 | 3:9f857750e4e9 | 2052 | |
1050186 | 3:9f857750e4e9 | 2053 | if ( dst_bottom >= DestinationFrameBuffer->Height ) { |
1050186 | 3:9f857750e4e9 | 2054 | diff = dst_bottom - DestinationFrameBuffer->Height + 1; |
1050186 | 3:9f857750e4e9 | 2055 | src_bottom -= diff; |
1050186 | 3:9f857750e4e9 | 2056 | dst_bottom -= diff; |
1050186 | 3:9f857750e4e9 | 2057 | } |
1050186 | 3:9f857750e4e9 | 2058 | |
1050186 | 3:9f857750e4e9 | 2059 | |
1050186 | 3:9f857750e4e9 | 2060 | /* culling by out of frame buffer vertical for modified top and bottom */ |
1050186 | 3:9f857750e4e9 | 2061 | if ( src_top < 0 || |
1050186 | 3:9f857750e4e9 | 2062 | dst_top < 0 || |
1050186 | 3:9f857750e4e9 | 2063 | src_bottom >= SourceFrameBuffer->Height || |
1050186 | 3:9f857750e4e9 | 2064 | dst_bottom >= DestinationFrameBuffer->Height ) { |
1050186 | 3:9f857750e4e9 | 2065 | SourceRect->Right = SourceRect->Left - 1; /* out of frame */ |
1050186 | 3:9f857750e4e9 | 2066 | e = 0; |
1050186 | 3:9f857750e4e9 | 2067 | goto fin; |
1050186 | 3:9f857750e4e9 | 2068 | } |
1050186 | 3:9f857750e4e9 | 2069 | |
1050186 | 3:9f857750e4e9 | 2070 | |
1050186 | 3:9f857750e4e9 | 2071 | /* return from "src_top", "src_bottom", "dst_top", "dst_bottom" */ |
1050186 | 3:9f857750e4e9 | 2072 | SourceRect->Top = src_top; |
1050186 | 3:9f857750e4e9 | 2073 | SourceRect->Bottom = src_bottom; |
1050186 | 3:9f857750e4e9 | 2074 | DestinationRect->Top = dst_top; |
1050186 | 3:9f857750e4e9 | 2075 | DestinationRect->Bottom = dst_bottom; |
1050186 | 3:9f857750e4e9 | 2076 | |
1050186 | 3:9f857750e4e9 | 2077 | |
1050186 | 3:9f857750e4e9 | 2078 | /* set left >= 0 */ |
1050186 | 3:9f857750e4e9 | 2079 | if ( SourceRect->Left < 0 ) { |
1050186 | 3:9f857750e4e9 | 2080 | DestinationRect->Left += - SourceRect->Left; |
1050186 | 3:9f857750e4e9 | 2081 | SourceRect->Left = 0; |
1050186 | 3:9f857750e4e9 | 2082 | } |
1050186 | 3:9f857750e4e9 | 2083 | |
1050186 | 3:9f857750e4e9 | 2084 | if ( DestinationRect->Left < 0 ) { |
1050186 | 3:9f857750e4e9 | 2085 | SourceRect->Left += - DestinationRect->Left; |
1050186 | 3:9f857750e4e9 | 2086 | DestinationRect->Left = 0; |
1050186 | 3:9f857750e4e9 | 2087 | } |
1050186 | 3:9f857750e4e9 | 2088 | |
1050186 | 3:9f857750e4e9 | 2089 | |
1050186 | 3:9f857750e4e9 | 2090 | /* set right < frame width */ |
1050186 | 3:9f857750e4e9 | 2091 | if ( SourceRect->Right >= SourceFrameBuffer->Width ) { |
1050186 | 3:9f857750e4e9 | 2092 | diff = SourceRect->Right - SourceFrameBuffer->Width + 1; |
1050186 | 3:9f857750e4e9 | 2093 | SourceRect->Right -= diff; |
1050186 | 3:9f857750e4e9 | 2094 | DestinationRect->Right -= diff; |
1050186 | 3:9f857750e4e9 | 2095 | } |
1050186 | 3:9f857750e4e9 | 2096 | |
1050186 | 3:9f857750e4e9 | 2097 | if ( DestinationRect->Right >= DestinationFrameBuffer->Width ) { |
1050186 | 3:9f857750e4e9 | 2098 | diff = DestinationRect->Right - DestinationFrameBuffer->Width + 1; |
1050186 | 3:9f857750e4e9 | 2099 | SourceRect->Right -= diff; |
1050186 | 3:9f857750e4e9 | 2100 | DestinationRect->Right -= diff; |
1050186 | 3:9f857750e4e9 | 2101 | } |
1050186 | 3:9f857750e4e9 | 2102 | |
1050186 | 3:9f857750e4e9 | 2103 | |
1050186 | 3:9f857750e4e9 | 2104 | /* culling by out of frame buffer horizontal for modified top and bottom */ |
1050186 | 3:9f857750e4e9 | 2105 | if ( SourceRect->Left >= SourceFrameBuffer->Width || |
1050186 | 3:9f857750e4e9 | 2106 | DestinationRect->Left >= DestinationFrameBuffer->Width || |
1050186 | 3:9f857750e4e9 | 2107 | SourceRect->Right < 0 || |
1050186 | 3:9f857750e4e9 | 2108 | DestinationRect->Right < 0 ) { |
1050186 | 3:9f857750e4e9 | 2109 | SourceRect->Right = SourceRect->Left - 1; /* out of frame */ |
1050186 | 3:9f857750e4e9 | 2110 | e = 0; |
1050186 | 3:9f857750e4e9 | 2111 | goto fin; |
1050186 | 3:9f857750e4e9 | 2112 | } |
1050186 | 3:9f857750e4e9 | 2113 | |
1050186 | 3:9f857750e4e9 | 2114 | e=0; |
1050186 | 3:9f857750e4e9 | 2115 | fin: |
1050186 | 3:9f857750e4e9 | 2116 | return e; |
1050186 | 3:9f857750e4e9 | 2117 | } |
1050186 | 3:9f857750e4e9 | 2118 | |
1050186 | 3:9f857750e4e9 | 2119 | |
1050186 | 3:9f857750e4e9 | 2120 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 2121 | * Class: vram_ex_stack_t |
1050186 | 3:9f857750e4e9 | 2122 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 2123 | |
1050186 | 3:9f857750e4e9 | 2124 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 2125 | * Implement: R_VRAM_EX_STACK_Initialize |
1050186 | 3:9f857750e4e9 | 2126 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 2127 | errnum_t R_VRAM_EX_STACK_Initialize( vram_ex_stack_t *self, void *NullConfig ) |
1050186 | 3:9f857750e4e9 | 2128 | { |
1050186 | 3:9f857750e4e9 | 2129 | errnum_t e; |
1050186 | 3:9f857750e4e9 | 2130 | uint8_t *address; |
1050186 | 3:9f857750e4e9 | 2131 | size_t size; |
1050186 | 3:9f857750e4e9 | 2132 | |
1050186 | 3:9f857750e4e9 | 2133 | R_UNREFERENCED_VARIABLE( NullConfig ); |
1050186 | 3:9f857750e4e9 | 2134 | |
1050186 | 3:9f857750e4e9 | 2135 | e= R_EXRAM_GetBigMemory( &address, &size ); |
1050186 | 3:9f857750e4e9 | 2136 | IF(e) { |
1050186 | 3:9f857750e4e9 | 2137 | goto fin; |
1050186 | 3:9f857750e4e9 | 2138 | } |
1050186 | 3:9f857750e4e9 | 2139 | |
1050186 | 3:9f857750e4e9 | 2140 | self->Start = address; |
1050186 | 3:9f857750e4e9 | 2141 | self->Over = address + size; |
1050186 | 3:9f857750e4e9 | 2142 | self->StackPointer = self->Start; |
1050186 | 3:9f857750e4e9 | 2143 | |
1050186 | 3:9f857750e4e9 | 2144 | e=0; |
1050186 | 3:9f857750e4e9 | 2145 | fin: |
1050186 | 3:9f857750e4e9 | 2146 | return e; |
1050186 | 3:9f857750e4e9 | 2147 | } |
1050186 | 3:9f857750e4e9 | 2148 | |
1050186 | 3:9f857750e4e9 | 2149 | |
1050186 | 3:9f857750e4e9 | 2150 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 2151 | * Implement: R_VRAM_EX_STACK_Alloc |
1050186 | 3:9f857750e4e9 | 2152 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 2153 | errnum_t R_VRAM_EX_STACK_Alloc( vram_ex_stack_t *self, frame_buffer_t *in_out_FrameBuffer ) |
1050186 | 3:9f857750e4e9 | 2154 | { |
1050186 | 3:9f857750e4e9 | 2155 | return alloc_VRAM_stack_sub( &self->StackPointer, self->Over, in_out_FrameBuffer ); |
1050186 | 3:9f857750e4e9 | 2156 | } |
1050186 | 3:9f857750e4e9 | 2157 | |
1050186 | 3:9f857750e4e9 | 2158 | |
1050186 | 3:9f857750e4e9 | 2159 | /*********************************************************************** |
1050186 | 3:9f857750e4e9 | 2160 | * Implement: R_VRAM_EX_STACK_Free |
1050186 | 3:9f857750e4e9 | 2161 | ************************************************************************/ |
1050186 | 3:9f857750e4e9 | 2162 | errnum_t R_VRAM_EX_STACK_Free( vram_ex_stack_t *self, frame_buffer_t *frame_buffer ) |
1050186 | 3:9f857750e4e9 | 2163 | { |
1050186 | 3:9f857750e4e9 | 2164 | return free_VRAM_stack_sub( &self->StackPointer, frame_buffer, self->Start ); |
1050186 | 3:9f857750e4e9 | 2165 | } |
1050186 | 3:9f857750e4e9 | 2166 | |
1050186 | 3:9f857750e4e9 | 2167 |