Lcd companion boards support (VKLCD50RTA & VKLCD70RT)
Embed:
(wiki syntax)
Show/hide line numbers
RGA_Callback.c
Go to the documentation of this file.
00001 /******************************************************************************* 00002 * DISCLAIMER 00003 * This software is supplied by Renesas Electronics Corporation and is only 00004 * intended for use with Renesas products. No other uses are authorized. This 00005 * software is owned by Renesas Electronics Corporation and is protected under 00006 * all applicable laws, including copyright laws. 00007 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING 00008 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT 00009 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 00010 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. 00011 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS 00012 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE 00013 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR 00014 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE 00015 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 00016 * Renesas reserves the right, without notice, to make changes to this software 00017 * and to discontinue the availability of this software. By using this software, 00018 * you agree to the additional terms and conditions found by accessing the 00019 * following link: 00020 * http://www.renesas.com/disclaimer 00021 * Copyright (C) 2013 - 2014 Renesas Electronics Corporation. All rights reserved. 00022 *******************************************************************************/ 00023 /** 00024 * @file RGA_Callback.c 00025 * @brief $Module: RGA $ $PublicVersion: 1.20 $ (=RGA_VERSION) 00026 * $Rev: $ 00027 * $Date:: $ 00028 */ 00029 00030 #include <string.h> 00031 #include "RGA.h" 00032 #include "RGA_Callback_private.h " 00033 #include "clib_drivers.h " 00034 00035 00036 00037 /** gs_WorkBufferMemory */ 00038 static uint8_t *gs_WorkBufferMemory; 00039 static size_t gs_WorkBufferMemory_Size; 00040 static uint8_t *gs_WorkBufferB_Memory; 00041 static size_t gs_WorkBufferB_Memory_Size; 00042 00043 00044 /** 00045 * @struct GraphicsDefaultSubClass 00046 * @brief GraphicsDefaultSubClass 00047 */ 00048 typedef struct _GraphicsDefaultSubClass GraphicsDefaultSubClass; 00049 struct _GraphicsDefaultSubClass { 00050 uint8_t *WorkBufferMemory; 00051 size_t work_buffer_size; 00052 bool_t IsUsedWorkBuffer; 00053 uint8_t *WorkBufferB_Memory; 00054 size_t work_buffer_b_size; 00055 bool_t IsUsedWorkBufferB; 00056 }; 00057 00058 00059 /* Section: Global */ 00060 /** gs_GraphicsDefaultSub */ 00061 static GraphicsDefaultSubClass gs_GraphicsDefaultSub = { 00062 NULL, /* WorkBufferMemory */ 00063 0, /* work_buffer_size */ 00064 false, /* IsUsedWorkBuffer */ 00065 NULL, /* WorkBufferB_Memory */ 00066 0, /* work_buffer_b_size */ 00067 false, /* IsUsedWorkBufferB */ 00068 }; 00069 00070 00071 00072 /** 00073 * @brief R_GRAPHICS_STATIC_OnInitializeDefault 00074 * 00075 * @par Parameters 00076 * None 00077 * @return None. 00078 */ 00079 errnum_t R_GRAPHICS_STATIC_OnInitializeDefault( graphics_t *self, graphics_config_t *in_out_Config, 00080 void **out_CalleeDefined ) 00081 { 00082 enum { work_buffer_flags = 00083 F_GRAPHICS_WORK_BUFFER_ADDRESS | 00084 F_GRAPHICS_WORK_BUFFER_SIZE | 00085 F_GRAPHICS_MAX_WIDTH_OF_FRAME_BUFFER | 00086 F_GRAPHICS_MAX_HEIGHT_OF_FRAME_BUFFER 00087 //F_GRAPHICS_IS_FAST_MANUAL_FLUSH 00088 }; 00089 00090 enum { work_buffer_B_flags = 00091 F_GRAPHICS_WORK_BUFFER_B_ADDRESS | 00092 F_GRAPHICS_WORK_BUFFER_B_SIZE 00093 }; 00094 00095 static r_ospl_c_lock_t gs_c_lock_object; 00096 00097 errnum_t e; 00098 00099 GraphicsDefaultSubClass *sub = &gs_GraphicsDefaultSub; 00100 00101 R_UNREFERENCED_VARIABLE_2( self, out_CalleeDefined ); 00102 00103 R_MEMORY_SECTION_GetMemory_RGA_WorkBuffer( &gs_WorkBufferMemory, &gs_WorkBufferMemory_Size, 00104 &gs_WorkBufferB_Memory, &gs_WorkBufferB_Memory_Size ); 00105 00106 00107 /* Set default configuration */ 00108 00109 /* Use work buffer */ 00110 if ( IS_ANY_BITS_NOT_SET( in_out_Config->flags, work_buffer_flags ) ) { 00111 ASSERT_R( IS_ALL_BITS_NOT_SET( in_out_Config->flags, work_buffer_flags ), e=E_OTHERS; goto fin ); 00112 ASSERT_R( ! sub->IsUsedWorkBuffer, e=E_OTHERS; goto fin ); 00113 00114 #if RGA_WORK_BUFFER_ADDRESS_ALIGNMENT == 64 /* Check of "R_Ceil_64u" */ 00115 sub->WorkBufferMemory = (uint8_t *) R_Ceil_64u( (uintptr_t) gs_WorkBufferMemory ); 00116 #elif RGA_WORK_BUFFER_ADDRESS_ALIGNMENT == 4 /* Check of "R_Ceil_4u" */ 00117 sub->WorkBufferMemory = (uint8_t *) R_Ceil_4u( (uintptr_t) gs_WorkBufferMemory ); 00118 #else 00119 #error 00120 #endif 00121 sub->work_buffer_size = gs_WorkBufferMemory_Size - ( sub->WorkBufferMemory - gs_WorkBufferMemory ); 00122 00123 in_out_Config->flags |= work_buffer_flags; 00124 in_out_Config->work_buffer_address = sub->WorkBufferMemory; 00125 in_out_Config->work_buffer_size = sub->work_buffer_size; 00126 in_out_Config->max_width_of_frame_buffer = MAX_WIDTH_OF_FRAME_BUFFER; 00127 in_out_Config->max_height_of_frame_buffer = MAX_HEIGHT_OF_FRAME_BUFFER; 00128 //in_out_Config->is_fast_manual_flush = true; 00129 sub->IsUsedWorkBuffer = true; 00130 } 00131 00132 /* Use work buffer B */ 00133 if ( IS_ANY_BITS_NOT_SET( in_out_Config->flags, work_buffer_B_flags ) ) { 00134 ASSERT_R( IS_ALL_BITS_NOT_SET( in_out_Config->flags, work_buffer_B_flags ), e=E_OTHERS; goto fin ); 00135 ASSERT_R( ! sub->IsUsedWorkBufferB, e=E_OTHERS; goto fin ); 00136 00137 #if RGA_WORK_BUFFER_B_ADDRESS_ALIGNMENT == 32 /* Check of "R_Ceil_32u" */ 00138 sub->WorkBufferB_Memory = (uint8_t *) R_Ceil_32u( (uintptr_t) gs_WorkBufferB_Memory ); 00139 #elif RGA_WORK_BUFFER_B_ADDRESS_ALIGNMENT == 4 /* Check of "R_Ceil_4u" */ 00140 sub->WorkBufferB_Memory = (uint8_t *) R_Ceil_4u( (uintptr_t) gs_WorkBufferB_Memory ); 00141 #else 00142 #error 00143 #endif 00144 sub->work_buffer_b_size = gs_WorkBufferB_Memory_Size - ( sub->WorkBufferB_Memory - gs_WorkBufferB_Memory ); 00145 00146 in_out_Config->flags |= work_buffer_B_flags; 00147 in_out_Config->work_buffer_b_address = sub->WorkBufferB_Memory; 00148 in_out_Config->work_buffer_b_size = sub->work_buffer_b_size; 00149 00150 sub->IsUsedWorkBufferB = true; 00151 } 00152 00153 #ifdef WORK_SIZE_FOR_LIB_PNG 00154 in_out_Config->flags |= F_GRAPHICS_WORK_SIZE_FOR_LIBPNG; 00155 in_out_Config->work_size_for_libPNG = WORK_SIZE_FOR_LIB_PNG; 00156 #endif 00157 00158 R_OSPL_MEMORY_Flush( R_OSPL_FLUSH_WRITEBACK_INVALIDATE ); 00159 /* Avoid write back by initialization to global variables of buffers */ 00160 00161 /* Lock object */ 00162 in_out_Config->flags |= F_GRAPHICS_LOCK_OBJECT; 00163 in_out_Config->lock_object = &gs_c_lock_object; 00164 00165 e=0; 00166 fin: 00167 return e; 00168 } 00169 00170 00171 00172 /** 00173 * @brief R_GRAPHICS_STATIC_OnFinalizeDefault 00174 * 00175 * @par Parameters 00176 * None 00177 * @return None. 00178 */ 00179 errnum_t R_GRAPHICS_STATIC_OnFinalizeDefault( graphics_t *self, void *CalleeDefined, errnum_t e ) 00180 { 00181 GraphicsDefaultSubClass *sub = &gs_GraphicsDefaultSub; 00182 00183 R_UNREFERENCED_VARIABLE_2( self, CalleeDefined ); 00184 sub->IsUsedWorkBuffer = false; 00185 sub->IsUsedWorkBufferB = false; 00186 return e; 00187 } 00188 00189 00190 /** 00191 * @brief drawCLUTImage 00192 * 00193 * @par Parameters 00194 * None 00195 * @return None. 00196 */ 00197 errnum_t drawCLUTImage( uint8_t *SrcAddress, const graphics_image_t *image, frame_buffer_t *frame ) 00198 { 00199 errnum_t e; 00200 int_t image_w; 00201 int i; 00202 uint32_t ImageWidthPoint; 00203 uint8_t *DestAddress; 00204 graphics_image_properties_t image_prop; 00205 00206 DestAddress = frame->buffer_address[ frame->draw_buffer_index ]; 00207 00208 switch( frame->pixel_format ) { 00209 case PIXEL_FORMAT_CLUT8: 00210 ImageWidthPoint = 1; 00211 break; 00212 case PIXEL_FORMAT_CLUT4: 00213 ImageWidthPoint = 2; 00214 break; 00215 case PIXEL_FORMAT_CLUT1: 00216 ImageWidthPoint = 8; 00217 break; 00218 default: 00219 /* never comes here */ 00220 ImageWidthPoint = 1; 00221 break; 00222 } 00223 00224 e = R_GRAPHICS_IMAGE_GetProperties( image, &image_prop ); 00225 IF(e)goto fin; 00226 ASSERT_R( image_prop.pixelFormat == frame->pixel_format , e=E_NOT_SUPPORTED_PIXEL_FORMAT; goto fin ); 00227 ASSERT_R( ( image->width % ImageWidthPoint ) == 0 , e=E_OTHERS; goto fin ); 00228 ASSERT_R( image->width <= frame->width , e=E_OTHERS; goto fin ); 00229 ASSERT_R( image->height <= frame->height , e=E_OTHERS; goto fin ); 00230 ASSERT_R( frame->stride % 32 == 0 , e=E_OTHERS; goto fin ); 00231 00232 image_w = image_prop.width; 00233 switch( frame->pixel_format ) { 00234 case PIXEL_FORMAT_CLUT8: 00235 SrcAddress += sizeof( uint32_t ) * 256; 00236 break; 00237 case PIXEL_FORMAT_CLUT4: 00238 image_w = image_w / 2; 00239 SrcAddress += sizeof( uint32_t ) * 16; 00240 break; 00241 case PIXEL_FORMAT_CLUT1: 00242 image_w = image_w / 8; 00243 SrcAddress += sizeof( uint32_t ) * 2; 00244 break; 00245 default: 00246 e=E_OTHERS; 00247 goto fin; 00248 } 00249 for( i = 0; i < image->height ; i++ ) { 00250 memcpy(( void *) DestAddress, ( void *)SrcAddress, (size_t)image_w ); 00251 DestAddress += frame->stride; 00252 SrcAddress += image_w; 00253 } 00254 e = 0; 00255 fin: 00256 return e; 00257 } 00258 00259 00260
Generated on Tue Jul 12 2022 14:32:45 by
1.7.2