comparison chipsetsw/drivers/drv_app/r2d/r2d_inits.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /**
2
3 @file: r2d_inits.c
4
5 @author Christophe Favergeon
6
7 @version 0.1
8
9 Purpose: Initializations routines for R2D
10
11 */
12
13 /*
14
15 Date Modification
16 ------------------------------------
17 03/05/2002 Create
18
19
20 (C) Copyright 2002 by Texas Instruments Incorporated, All Rights Reserved
21 */
22
23
24 #include "rv/general.h"
25
26 #include "rvm/rvm_gen.h"
27 #include "rvm/rvm_ext_priorities.h"
28 #include "rvm/rvm_use_id_list.h"
29
30 #include "r2d/r2d_pool_size.h" /* Stack & Memory Bank sizes definitions */
31
32 #include "r2d/r2d_config.h"
33 #include "r2d/r2d.h"
34 #include "r2d/r2d_i.h"
35 #include "r2d/r2d_env.h"
36 #include "r2d/r2d_independance_layer.h"
37 #include "r2d/r2d_messages.h"
38 #include "r2d/uwire.h"
39
40
41 #ifndef _WINDOWS
42 #ifndef _SIZE_T
43 #define _SIZE_T
44 typedef unsigned int size_t;
45 #endif
46 #endif
47
48 #ifndef _WINDOWS
49 void *memcpy(void *s1, const void *s2, register size_t n);
50 void *memmove(void *s1, const void *s2, size_t n);
51 #endif
52
53 extern T_R2D_ERROR r2d_font_init(void);
54 extern void r2d_font_clean(void);extern void r2d_core(UINT32 param);
55
56
57 /* global memory bank ID */
58 extern T_RVF_MB_ID r2d_mb_id;
59
60 /* Global standard graphical context */
61
62 extern T_R2D_GC_PTR r2d_g_lcd_gc;
63
64
65
66 #if (R2D_ASM == R2D_ON)
67 extern T_RVF_MUTEX * r2d_g_blit_mutex;
68 extern UINT32 r2d_g_old_foreground_pixelvalue;
69 extern UINT32 r2d_g_old_background_pixelvalue;
70 #endif
71
72 extern T_RVF_MUTEX * r2d_g_global_mutex;
73
74
75
76 #if (R2D_REFRESH == R2D_VERTICAL)
77 extern UINT32 r2d_lcd_memory_words[(((R2D_WIDTH*R2D_MWHEIGHT)+1)<<R2D_LONGSIZE_FACTOR)];
78 #else
79 extern UINT32 r2d_lcd_memory_words[(((R2D_MWWIDTH*R2D_HEIGHT)+1)<<R2D_LONGSIZE_FACTOR)];
80 #endif
81
82 extern INT16 r2d_update_ul_x,r2d_update_ul_y,r2d_update_br_x,r2d_update_br_y;
83
84 extern void r2d_reinit_update_region(void);
85
86 void (*IND_r2d_reinit_update_region)(void)=r2d_reinit_update_region;
87
88 extern T_R2D_FONT_DESCRIPTION *r2d_g_font_configuration;
89
90
91 #if (R2D_EMBEDDED_LCD == R2D_PC_COLOR_LCD)
92 #include "r2d/lcds/colorpc/r2d_task_init_i.c"
93 #endif
94
95 #if (R2D_EMBEDDED_LCD == R2D_PC_CSAMPLE)
96 #include "r2d/lcds/pc_csample/r2d_task_init_i.c"
97 #endif
98
99 #if (R2D_EMBEDDED_LCD == R2D_PC_DSAMPLE)
100 #include "r2d/lcds/pc_dsample/r2d_task_init_i.c"
101 #endif
102
103 #if (R2D_EMBEDDED_LCD == R2D_MIRRORED_LCD)
104 #include "r2d/lcds/simple/r2d_task_init_i.c"
105 #endif
106
107 #if (R2D_EMBEDDED_LCD == R2D_CUSTOMER_LCD)
108 #include "r2d/lcds/customer/r2d_task_init_i.c"
109 #endif
110
111 #if (R2D_EMBEDDED_LCD == R2D_HORIZONTAL_LCD)
112 #include "r2d/lcds/horizontal/r2d_task_init_i.c"
113 #endif
114
115 #if (R2D_EMBEDDED_LCD == R2D_SIMPLE_LCD)
116 #include "r2d/lcds/simple/r2d_task_init_i.c"
117 #endif
118
119 #if (R2D_EMBEDDED_LCD == R2D_BOARD_COLOR_LCD)
120 #include "r2d/lcds/colorboard/r2d_task_init_i.c"
121 #endif
122
123 #if (R2D_EMBEDDED_LCD == R2D_BOARD_DSAMPLE)
124 #include "r2d/lcds/d_sample/r2d_task_init_i.c"
125 #endif
126
127 #if (R2D_EMBEDDED_LCD == R2D_BOARD_BW_DSAMPLE)
128 #include "r2d/lcds/bw_d_sample/r2d_task_init_i.c"
129 #endif
130
131 UINT32 r2d_get_memory_bank_size()
132 {
133 return(R2D_MB_PRIM_SIZE);
134 }
135
136 #if ((!defined DEPENDENCY) && (R2D_MB_PRIM_SIZE != R2D_MB1_SIZE))
137 /* If the R2D Memory Bank sizes defined in rvf_pool_size.h differs from */
138 /* the one returned by the previous function, compilation is STOPPED. */
139 #error R2D Memory Bank size mismatch!
140 #endif
141
142
143
144 ////////////////////////////////////////
145 //
146 // Software entity initialization
147
148 // Allocate the LCD framebuffer and dithering matrix
149 // Clear the framebuffer to 0
150 // (Which does not mean intensity 0 since the meaning
151 // of 0 is dependent on the LCD).
152
153 static void r2d_lcd_init(void)
154 {
155 UINT16 length;
156 // UINT32 *p;
157 T_RVF_RET err;
158
159
160 R2D_MALLOC(r2d_mb_id,T_R2D_FRAMEBUFFER,sizeof(T_R2D_FRAMEBUFFER),r2d_g_framebuffer);
161
162 if (r2d_g_framebuffer !=NULL)
163 {
164 // length+1 is used instead of length because in the refresh loop
165 // one may need to read one word past the end of the real datas
166 #if (R2D_REFRESH==R2D_VERTICAL)
167 // Column is contiguous in memory
168 length=R2D_WIDTH*R2D_MWHEIGHT;
169 //R2D_MALLOC(r2d_mb_id,UINT32,((length+1)<<R2D_LONGSIZE_FACTOR),r2d_g_framebuffer->p_memory_words);
170 r2d_g_framebuffer->p_memory_words=r2d_lcd_memory_words;
171
172 // No deletion at the end since memory_word is NOT a dynamical object
173 r2d_g_framebuffer->refcount=-1;
174
175 // 0 is a special LCD kind : size of the framebuffer
176 // is hardcoded to quick pixel generation
177 r2d_g_framebuffer->kind=0;
178 r2d_g_framebuffer->p_frame_buffer_end=r2d_g_framebuffer->p_memory_words+length;
179 r2d_g_framebuffer->width=R2D_WIDTH;
180 r2d_g_framebuffer->height=R2D_HEIGHT;
181 #else
182 // Line is contiguous in memory
183 length=R2D_HEIGHT*R2D_MWWIDTH;
184 r2d_g_framebuffer->p_memory_words=r2d_lcd_memory_words;
185
186 r2d_g_framebuffer->refcount=-1;
187 // 0 is a special LCD kind : size of the framebuffer
188 // is hardcoded to quick pixel generation
189 r2d_g_framebuffer->kind=0;
190 r2d_g_framebuffer->p_frame_buffer_end=r2d_g_framebuffer->p_memory_words+length;
191 r2d_g_framebuffer->width=R2D_WIDTH;
192 r2d_g_framebuffer->height=R2D_HEIGHT;
193 #endif
194
195 R2D_MALLOC(r2d_mb_id,T_RVF_MUTEX,sizeof(T_RVF_MUTEX),r2d_g_framebuffer->mutex);
196 if (r2d_g_framebuffer->mutex!=NULL)
197 {
198 err=rvf_initialize_mutex(r2d_g_framebuffer->mutex);
199 if (err!=RVF_OK)
200 {
201 R2D_FREE(r2d_g_framebuffer->mutex);
202 R2D_FREE(r2d_g_framebuffer);
203 r2d_g_framebuffer=NULL;
204
205 }
206 }
207 else
208 {
209 R2D_FREE(r2d_g_framebuffer);
210 r2d_g_framebuffer=NULL;
211
212 }
213
214 }
215 IND_r2d_reinit_update_region();
216
217
218 }
219
220 T_RVM_RETURN r2d_cleanup(void)
221 {
222 /*
223 ** free all memory buffer previously allocated.
224 ** DO NOT SEND MESSAGES
225 */
226 r2d_refresh_task_kill();
227 #if (R2D_ASM == R2D_ON)
228 rvf_delete_mutex(r2d_g_blit_mutex);
229 R2D_FREE(r2d_g_blit_mutex);
230 #endif
231 rvf_delete_mutex(r2d_g_global_mutex);
232 R2D_FREE(r2d_g_global_mutex);
233 r2d_release_context(r2d_g_lcd_gc);
234 r2d_release_framebuffer(r2d_g_framebuffer);
235 R2D_FREE(r2d_g_dithering_matrix);
236 R2D_FREE(r2d_g_font_configuration);
237
238 return(RV_OK);
239 }
240
241
242
243 /******************************************************************************
244 * Function : xxx_init
245 *
246 * Description : This function is called by the RV manager to initialize the
247 * xxx SWE before creating the task and calling xxx_start.
248 *
249 * Parameters : None
250 *
251 * Return : T_RVM_RETURN
252 *
253 * History : 0.1 (20-August-2000)
254 *
255 *
256 ******************************************************************************/
257 T_RVM_RETURN r2d_initializations(void)
258 {
259 /*
260 ** Put local SWE initialization here
261 */
262
263 T_R2D_ERROR err;
264
265 r2d_lcd_init();
266 if (r2d_g_framebuffer==NULL)
267 goto r2d_init_error;
268
269 r2d_dithering_init();
270 if (r2d_g_dithering_matrix==NULL)
271 {
272 r2d_release_framebuffer(r2d_g_framebuffer);
273 goto r2d_init_error;
274 }
275
276 R2D_MALLOC(r2d_mb_id,T_R2D_FONT_DESCRIPTION,
277 sizeof(T_R2D_FONT_DESCRIPTION)*36,r2d_g_font_configuration);
278
279 if (r2d_g_font_configuration ==NULL)
280 {
281 r2d_release_framebuffer(r2d_g_framebuffer);
282 R2D_FREE(r2d_g_dithering_matrix);
283 goto r2d_init_error;
284 }
285
286 err=r2d_font_init();
287 if (err!=R2D_OK)
288 {
289 r2d_release_framebuffer(r2d_g_framebuffer);
290 R2D_FREE(r2d_g_dithering_matrix);
291 goto r2d_init_error;
292 }
293
294
295 r2d_g_default_font_framebuffer=r2d_g_font_configuration[R2D_MEDIUM_SYSTEM_NORMAL].framebuffer;
296 r2d_g_default_font_metrics=r2d_g_font_configuration[R2D_MEDIUM_SYSTEM_NORMAL].metrics;
297 r2d_g_default_font_table=r2d_g_font_configuration[R2D_MEDIUM_SYSTEM_NORMAL].table;
298
299 r2d_refresh_task_init();
300
301 r2d_g_lcd_gc=r2d_new_lcd_context(r2d_mb_id);
302 if (r2d_g_lcd_gc==NULL)
303 {
304 r2d_font_clean();
305 r2d_release_framebuffer(r2d_g_framebuffer);
306 R2D_FREE(r2d_g_dithering_matrix);
307 goto r2d_init_error;
308 }
309
310 r2d_g_event_was_sent=FALSE;
311 r2d_g_refresh_disabled=0;
312
313 #if (R2D_ASM == R2D_ON)
314
315 R2D_MALLOC(r2d_mb_id,T_RVF_MUTEX,sizeof(T_RVF_MUTEX),r2d_g_blit_mutex);
316 if (r2d_g_blit_mutex==NULL)
317 {
318 r2d_font_clean();
319 r2d_release_framebuffer(r2d_g_framebuffer);
320 R2D_FREE(r2d_g_dithering_matrix);
321 goto r2d_init_error;
322 }
323
324 err=rvf_initialize_mutex(r2d_g_blit_mutex);
325 if (err!=RVF_OK)
326 {
327 R2D_FREE(r2d_g_blit_mutex);
328 r2d_font_clean();
329 r2d_release_framebuffer(r2d_g_framebuffer);
330 R2D_FREE(r2d_g_dithering_matrix);
331 goto r2d_init_error;
332 }
333
334 // Mode of initial asm blit rect
335 r2d_g_old_mode=R2D_COPY_MODE;
336 r2d_g_old_use_foreground=FALSE;
337 r2d_g_old_srcdst=R2D_LCDLCD;
338 r2d_g_old_foreground_pixelvalue=((T_R2D_GC*)r2d_g_lcd_gc)->foreground_pixel_value;
339 r2d_g_old_background_pixelvalue=((T_R2D_GC*)r2d_g_lcd_gc)->background_pixel_value;
340
341 #endif
342
343 R2D_MALLOC(r2d_mb_id,T_RVF_MUTEX,sizeof(T_RVF_MUTEX),r2d_g_global_mutex);
344 if (r2d_g_global_mutex==NULL)
345 {
346 r2d_font_clean();
347 r2d_release_framebuffer(r2d_g_framebuffer);
348 R2D_FREE(r2d_g_dithering_matrix);
349 #if (R2D_ASM == R2D_ON)
350 rvf_delete_mutex(r2d_g_blit_mutex);
351 R2D_FREE(r2d_g_blit_mutex);
352 #endif
353 goto r2d_init_error;
354 }
355
356 err=rvf_initialize_mutex(r2d_g_global_mutex);
357 if (err!=RVF_OK)
358 {
359 R2D_FREE(r2d_g_global_mutex);
360 r2d_font_clean();
361 r2d_release_framebuffer(r2d_g_framebuffer);
362 R2D_FREE(r2d_g_dithering_matrix);
363 #if (R2D_ASM == R2D_ON)
364 rvf_delete_mutex(r2d_g_blit_mutex);
365 R2D_FREE(r2d_g_blit_mutex);
366 #endif
367 goto r2d_init_error;
368 }
369
370
371 return RV_OK;
372
373
374 r2d_init_error: return RV_MEMORY_ERR;
375 }
376