comparison chipsetsw/drivers/drv_app/r2d/r2d_geometry.s @ 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 .state32
4
5 .if (R2D_ASM = 1)
6
7 .include "r2d_asm_utils.inc"
8 .include "r2d_asm_configs.inc"
9
10
11 ; Main asm code (it is reflecting the C code of
12 ; r2d_blit_lcd_to_lcd)
13
14 .text
15
16
17
18 .global _r2d_blit_lb,_r2d_blit_la
19 .global _r2d_sb_down1,_r2d_sb_down2,_r2d_sa_up1,_r2d_sa_up2
20 .global _r2d_scb_down1,_r2d_scb_down2,_r2d_sca_up1,_r2d_sca_up2
21 .global _r2d_sdb_down1,_r2d_sdb_down2,_r2d_sda_up1,_r2d_sda_up2
22 .global _r2d_skip_color_proc_a
23 .global _r2d_end_ynb_color_dst_a
24 .global _r2d_skip_color_proc_b
25 .global _r2d_end_ynb_color_dst_b
26 .global _r2d_skip_color_dst_a
27 .global _r2d_skip_color_dst_b
28
29
30 .global _r2d_sconvcolb_down1,_r2d_econvcolb_down1
31 .global _r2d_sconvcolb_down2,_r2d_econvcolb_down2
32 .global _r2d_sconvcola_up1,_r2d_econvcola_up1
33 .global _r2d_sconvcola_up2,_r2d_econvcola_up2
34
35 .global _r2d_swb_down1,_r2d_swb_down2,_r2d_swa_up1,_r2d_swa_up2
36
37
38 ; Patch list for write_shift_pixel_down
39 .global _r2d_sft_dst_n_b_down1,_r2d_sft_dst_n_b_down2
40 .global _r2d_sft_srcb__b_down1,_r2d_sft_srcb__b_down2
41 .global _r2d_sft_dstc__b_down1,_r2d_sft_dstc__b_down2
42
43 .global _r2d_sft_src_c_b_down1,_r2d_sft_src_c_b_down2
44 .global _r2d_sft_b_c_b_down1,_r2d_sft_b_c_b_down2
45 .global _r2d_sft_dstb_c_b_down1,_r2d_sft_dstb_c_b_down2
46 .global _r2d_sft_d_c_b_down1,_r2d_sft_d_c_b_down2
47 .global _r2d_sft_dstc_c_b_down1,_r2d_sft_dstc_c_b_down2
48
49 ; Patch list for write_shift_pixel_up
50 .global _r2d_sft_dst_n_a_up1,_r2d_sft_dst_n_a_up2
51 .global _r2d_sft_srcb__a_up1,_r2d_sft_srcb__a_up2
52 .global _r2d_sft_dstc__a_up1,_r2d_sft_dstc__a_up2
53
54 .global _r2d_sft_src_c_a_up1,_r2d_sft_src_c_a_up2
55 .global _r2d_sft_b_c_a_up1,_r2d_sft_b_c_a_up2
56
57 ; Patch list fro shift_pixel_down
58 .global _r2d_sft_dst_n_downa,_r2d_sft_dst_n_downb,_r2d_sft_dst_n_downc
59 .global _r2d_sft_srcb_n_downa,_r2d_sft_srcb_n_downb,_r2d_sft_srcb_n_downc
60
61 .global _r2d_sft_src_c_downa,_r2d_sft_src_c_downb,_r2d_sft_src_c_downc
62
63 ; Patch list fro shift_pixel_up
64 .global _r2d_sft_dst_n_upa,_r2d_sft_dst_n_upb,_r2d_sft_dst_n_upc
65 .global _r2d_sft_srcb_n_upa,_r2d_sft_srcb_n_upb,_r2d_sft_srcb_n_upc
66
67 .global _r2d_sft_src_c_upa,_r2d_sft_src_c_upb,_r2d_sft_src_c_upc
68 .global _r2d_enda,_r2d_endb
69
70 .global _r2d_skip_load_src_a_up1,_r2d_skip_load_src_a_up2;
71 .global _r2d_skip_load_src_b_down1,_r2d_skip_load_src_b_down2;
72 .global _r2d_skip_shift_down_downa,_r2d_skip_shift_down_downb,_r2d_skip_shift_down_downc;
73 .global _r2d_skip_shift_up_upa,_r2d_skip_shift_up_upb,_r2d_skip_shift_up_upc;
74
75 .global _r2d_no_null_src_counter_a,_r2d_no_null_src_counter_b
76 .global _r2d_end_a_up2,_r2d_end_b_down2,_r2d_end_downa,_r2d_end_downb,_r2d_end_downc;
77 .global _r2d_end_upa,_r2d_end_upb,_r2d_end_upc;
78
79 .global _r2d_always_read_a_up1,_r2d_always_read_a_up2
80 .global _r2d_always_read_b_down1,_r2d_always_read_b_down2
81
82 .ref $r2d_blit_lcd_to_lcd
83
84 .endif
85
86 write_shift_pixel_down .macro label
87 ; Create free space for result
88 .if (R2D_PIXEL_DEPTH != 32)
89 _r2d_sft_dst_n_:label: MOV dstvalue,dstvalue, LSR #R2D_PIXEL_DEPTH
90 .else
91 _r2d_sft_dst_n_:label: MOV dstvalue,#0
92 .endif
93
94 ; Mask to extract pixel from src_current
95 _r2d_sft_src_c_:label: MOV calca,src_current,LSL #((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)
96 _r2d_always_read_:label: MOV src_current,src_current
97 _r2d_sft_b_c_:label: MOV calca,calca,LSR #((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)
98
99 ; Mask to extract pixel from dst_current
100 _r2d_sft_dstb_c_:label: MOV calcb,dst_current,LSL #((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)
101 _r2d_sft_d_c_:label: MOV calcb,calcb,LSR #((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)
102
103 ; Do foreground detection
104 _r2d_sd:label:
105 MOV calca,calca
106 MOV calca,calca
107 MOV calca,calca
108 _r2d_ed:label:
109
110 ; Get foreground/background colors if needed
111 _r2d_sc:label:
112 MOV calca,calca
113 MOV calca,calca
114 MOV calca,calca
115 _r2d_ec:label:
116
117 _r2d_sconvcol:label:
118 MOV calca,calca
119 MOV calca,calca
120 MOV calca,calca
121 _r2d_econvcol:label:
122
123 ; Compute drawing mode
124 _r2d_s:label:
125 MOV calca,calca
126 MOV calcb,calca
127 MOV calcb,calcb
128 _r2d_e:label:
129 _r2d_sft_dstc_c_:label: ORR dstvalue,dstvalue,calcb, LSL #((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)
130
131 _r2d_sw:label:
132 MOV dstvalue,dstvalue
133 _r2d_ew:label:
134
135 ; Read new data if needed
136 .if (R2D_PIXEL_DEPTH != 32)
137 _r2d_sft_srcb__:label: MOV src_current,src_current, LSR #R2D_PIXEL_DEPTH
138 _r2d_sft_dstc__:label: MOV dst_current,dst_current, LSR #R2D_PIXEL_DEPTH
139 .else
140 _r2d_sft_srcb__:label: MOV src_current,src_current,LSR #0
141 _r2d_sft_dstc__:label: MOV dst_current,dst_current,LSR #0
142 .endif
143
144 SUBS dstcounter,dstcounter,#1
145 MOVEQ dstcounter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
146 _r2d_skip_load_src_:label: MOV src_current,src_current
147 SUBS srccounter,srccounter,#1
148 BNE M1END?
149 MOV srccounter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
150 LDR src_current,[p_src_current,#4]!
151 M1END?
152 .endm
153
154 write_shift_pixel_up .macro label
155 .if (R2D_PIXEL_DEPTH != 32)
156 _r2d_sft_dst_n_:label: MOV dstvalue,dstvalue, LSL #R2D_PIXEL_DEPTH
157 .else
158 _r2d_sft_dst_n_:label: MOV dstvalue,#0
159 .endif
160
161 _r2d_sft_src_c_:label: MOV calca,src_current,LSR #((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)
162 _r2d_always_read_:label: MOV src_current,src_current
163 _r2d_sft_b_c_:label: MOV calcb,dst_current,LSR #((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)
164
165 ; Do foreground detection
166 _r2d_sd:label:
167 MOV calca,calca
168 MOV calca,calca
169 MOV calca,calca
170 _r2d_ed:label:
171
172 ; Get foreground/background colors if needed
173 _r2d_sc:label:
174 MOV calca,calca
175 MOV calca,calca
176 MOV calca,calca
177 _r2d_ec:label:
178
179 _r2d_sconvcol:label:
180 MOV calca,calca
181 MOV calca,calca
182 MOV calca,calca
183 _r2d_econvcol:label:
184
185 ; Compute drawing mode
186 _r2d_s:label:
187 MOV calca,calca
188 MOV calcb,calca
189 MOV calcb,calcb
190 _r2d_e:label:
191 ORR dstvalue,dstvalue,calcb
192
193 _r2d_sw:label:
194 MOV dstvalue,dstvalue
195 _r2d_ew:label:
196
197 .if (R2D_PIXEL_DEPTH != 32)
198 _r2d_sft_srcb__:label: MOV src_current,src_current, LSL #R2D_PIXEL_DEPTH
199 _r2d_sft_dstc__:label: MOV dst_current,dst_current, LSL #R2D_PIXEL_DEPTH
200 .else
201 _r2d_sft_srcb__:label: MOV src_current,src_current,LSL #0
202 _r2d_sft_dstc__:label: MOV dst_current,dst_current,LSL #0
203 .endif
204
205 SUBS dstcounter,dstcounter,#1
206 MOVEQ dstcounter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
207 _r2d_skip_load_src_:label: MOV src_current,src_current
208 SUBS srccounter,srccounter,#1
209 BNE M1END?
210 MOV srccounter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
211 LDR src_current,[p_src_current,#-4]!
212 M1END?
213 .endm
214
215 shift_pixel_down .macro arg,reg,label
216 _r2d_skip_shift_down_:label: MOV arg,arg
217
218 .if (R2D_PIXEL_DEPTH != 32)
219 _r2d_sft_dst_n_:label: MOV arg,arg, LSR #R2D_PIXEL_DEPTH
220 .else
221 _r2d_sft_dst_n_:label: MOV arg,#0
222 .endif
223
224 _r2d_sft_src_c_:label: ORR arg,arg,:reg:_current, LSL #((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)
225
226 .if (R2D_PIXEL_DEPTH != 32)
227 _r2d_sft_srcb_n_:label: MOV :reg:_current,:reg:_current, LSR #R2D_PIXEL_DEPTH
228 .else
229 _r2d_sft_srcb_n_:label: MOV :reg:_current,#0
230 .endif
231
232 SUBS :reg:counter,:reg:counter,#1
233 BNE M1END?
234 MOV :reg:counter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
235 LDR :reg:_current,[p_:reg:_current,#4]!
236 M1END?
237 .endm
238
239 shift_pixel_up .macro arg,reg,label
240 _r2d_skip_shift_up_:label: MOV arg,arg
241 .if (R2D_PIXEL_DEPTH != 32)
242 _r2d_sft_dst_n_:label: MOV arg,arg, LSL #R2D_PIXEL_DEPTH
243 .else
244 _r2d_sft_dst_n_:label: MOV arg,#0
245 .endif
246
247 _r2d_sft_src_c_:label: ORR arg,arg,:reg:_current, LSR #((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)
248
249 .if (R2D_PIXEL_DEPTH != 32)
250 _r2d_sft_srcb_n_:label: MOV :reg:_current,:reg:_current, LSL #R2D_PIXEL_DEPTH
251 .else
252 _r2d_sft_srcb_n_:label: MOV :reg:_current,#0
253 .endif
254
255
256 SUBS :reg:counter,:reg:counter,#1
257 BNE M1END?
258 MOV :reg:counter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
259 LDR :reg:_current,[p_:reg:_current,#-4]!
260 M1END?
261 .endm
262
263 .if (R2D_ASM = 1)
264
265 ;--------------------------------------
266 ;
267 ; v_direction == -1
268 ;
269
270 _r2d_blit_la
271 STMFD SP!, {R4,R5,R6,R7,R8,R9,R10,R11,R12,LR}
272 LDR dstvalue, [R0,#S_FRAME.dstvalue_ind]
273 LDR dst_current, [R0,#S_FRAME.dst_current_ind]
274 LDRH dstcounter, [R0,#S_FRAME.dstcounter_ind]
275 LDR src_current, [R0,#S_FRAME.src_current_ind]
276 LDRH ynb, [R0,#S_FRAME.ynb_ind]
277 LDR p_src_current, [R0,#S_FRAME.p_src_current_ind]
278 LDR p_dst_current, [R0,#S_FRAME.p_dst_current_ind]
279 LDR x, [R0,#S_FRAME.x_ind]
280 LDR y, [R0,#S_FRAME.y_ind]
281 LDRH current_dst_dy, [R0,#S_FRAME.current_dst_dy_ind]
282 LDRH current_src_dy, [R0,#S_FRAME.current_src_dy_ind]
283 LDRH dst_dy, [R0,#S_FRAME.dst_dy_ind]
284
285
286 ;-------------------------------------
287 ;
288 ; First while
289 ;
290 ; current_dst_dy != dst_dy
291 current_dst_a: CMP current_dst_dy,dst_dy
292 BEQ end_current_dst_a
293
294 shift_pixel_up dstvalue,dst,upa
295
296 _r2d_end_upa: SUB current_dst_dy,current_dst_dy,#1
297 SUB y,y,#1
298 B current_dst_a
299
300 end_current_dst_a:
301
302 ; Load srcounter(and overwrite dst_dy)
303 LDRH srccounter, [R0,#S_FRAME.srccounter_ind]
304
305 LDRH temp,[R0,#S_FRAME.src_dy_ind]
306 SUB current_src_dy,current_src_dy,temp
307
308 ;-------------------------------------
309 ;
310 ; Second while
311 ;
312 ; current_src_dy - src_dy != 0
313 current_src_a: CMP current_src_dy,#0
314 BEQ end_current_src_a
315
316 shift_pixel_up temp,src,upb
317
318 _r2d_end_upb: SUB current_src_dy,current_src_dy,#1
319 B current_src_a
320
321 end_current_src_a:
322
323 ;-------------------------------------
324 ;
325 ; Third while
326 ;
327 ; (ynb!=0)
328 _r2d_ynb_loop_a: TEQ ynb,#0
329 BEQ end_ynb_loop_a
330
331 write_shift_pixel_up a_up1 ; was a_up1
332
333 _r2d_no_null_src_counter_a:
334 SUB y,y,#1
335
336 ; When dst is color framebuffer, following instruction is replaced by
337 ; BL no_end_dst_counter_a so, to ynb_loop_a
338 _r2d_skip_color_proc_a: MOV y,y
339
340 CMP dstcounter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
341 BNE no_end_dst_counter_a
342
343 SUB ynb,ynb,#1
344 STR dstvalue,[p_dst_current],#-4
345
346 LDR dst_current,[p_dst_current]
347 MOV dstvalue,#0
348 MOV current_dst_dy,#((1<<R2D_PIXELS_PER_MEMORY_WORD)-1)
349
350 no_end_dst_counter_a: B _r2d_ynb_loop_a
351 _r2d_end_ynb_color_dst_a:SUB ynb,ynb,#1
352 B _r2d_ynb_loop_a
353
354 end_ynb_loop_a:
355 _r2d_skip_color_dst_a: MOV y,y
356
357 ADD current_dst_dy,current_dst_dy,#1
358 LDRH temp,[R0,#S_FRAME.end_dst_dy_ind]
359 SUB current_dst_dy,current_dst_dy,temp
360
361 ;-------------------------------------
362 ;
363 ; Fourth while
364 ;
365 ; current_dst_dy - end_dst_dy != 0
366 end_dst_loop_a: TEQ current_dst_dy,#0
367 BEQ end_end_dst_loop_a
368
369 write_shift_pixel_up a_up2
370
371 _r2d_end_a_up2: SUB current_dst_dy,current_dst_dy,#1
372 SUB y,y,#1
373 B end_dst_loop_a
374 end_end_dst_loop_a:
375 MOV temp,#0
376 CMP dstcounter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
377 MOVEQ temp,#1
378
379 ;-------------------------------------
380 ;
381 ; Last while
382 ;
383 ; dstcounter != (1<<R2D_PIXELS_PER_MEMORY_WORD)
384 dst_counter_loop_a: CMP dstcounter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
385 BEQ end_dst_counter_loop_a
386 shift_pixel_up dstvalue,dst,upc
387 _r2d_end_upc: SUB y,y,#1
388 B dst_counter_loop_a
389 end_dst_counter_loop_a:
390 CMP temp,#0
391 STREQ dstvalue,[p_dst_current,#4]!
392
393 CMP temp,#0
394 STRNE dstvalue,[p_dst_current]
395 _r2d_enda:
396 LDMFD SP!, {R4,R5,R6,R7,R8,R9,R10,R11,R12,LR}
397 MOV PC,LR
398
399
400 ;--------------------------------------
401 ;
402 ; v_direction != -1
403 ;
404 _r2d_blit_lb
405 STMFD SP!, {R4,R5,R6,R7,R8,R9,R10,R11,R12,LR}
406 LDR dstvalue, [R0,#S_FRAME.dstvalue_ind]
407 LDR dst_current, [R0,#S_FRAME.dst_current_ind]
408 LDRH dstcounter, [R0,#S_FRAME.dstcounter_ind]
409 LDR src_current, [R0,#S_FRAME.src_current_ind]
410 LDRH ynb, [R0,#S_FRAME.ynb_ind]
411 LDR p_src_current, [R0,#S_FRAME.p_src_current_ind]
412 LDR p_dst_current, [R0,#S_FRAME.p_dst_current_ind]
413 LDR x, [R0,#S_FRAME.x_ind]
414 LDR y, [R0,#S_FRAME.y_ind]
415 LDRH current_dst_dy, [R0,#S_FRAME.current_dst_dy_ind]
416 LDRH current_src_dy, [R0,#S_FRAME.current_src_dy_ind]
417 LDRH dst_dy, [R0,#S_FRAME.dst_dy_ind]
418
419
420 ;-------------------------------------
421 ;
422 ; First while
423 ;
424 ; current_dst_dy != dst_dy
425 current_dst_b: CMP current_dst_dy,dst_dy
426 BEQ end_current_dst_b
427
428 shift_pixel_down dstvalue,dst,downa
429
430 _r2d_end_downa: ADD current_dst_dy,current_dst_dy,#1
431 ADD y,y,#1
432 B current_dst_b
433
434 end_current_dst_b:
435
436 ; Load srcounter(and overwrite dst_dy)
437 LDRH srccounter, [R0,#S_FRAME.srccounter_ind]
438
439 LDRH temp,[R0,#S_FRAME.src_dy_ind]
440 SUB current_src_dy,current_src_dy,temp
441
442 ;-------------------------------------
443 ;
444 ; Second while
445 ;
446 ; current_src_dy - src_dy != 0
447 current_src_b: CMP current_src_dy,#0
448 BEQ end_current_src_b
449
450 shift_pixel_down temp,src,downb
451
452 _r2d_end_downb: ADD current_src_dy,current_src_dy,#1
453 B current_src_b
454
455 end_current_src_b:
456
457 ;-------------------------------------
458 ;
459 ; Third while
460 ;
461 ; (ynb!=0)
462 _r2d_ynb_loop_b: TEQ ynb,#0
463 BEQ end_ynb_loop_b
464
465 write_shift_pixel_down b_down1
466
467 _r2d_no_null_src_counter_b:
468 ADD y,y,#1
469
470 ; When dst is color framebuffer, following instruction is replaced by
471 ; BL no_end_dst_counter_a so, to ynb_loop_a
472 _r2d_skip_color_proc_b: MOV y,y
473
474 CMP dstcounter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
475 BNE no_end_dst_counter_b
476
477 SUB ynb,ynb,#1
478 STR dstvalue,[p_dst_current],#4
479
480 LDR dst_current,[p_dst_current]
481 MOV dstvalue,#0
482 MOV current_dst_dy,#0
483
484 no_end_dst_counter_b: B _r2d_ynb_loop_b
485 _r2d_end_ynb_color_dst_b: SUB ynb,ynb,#1
486 B _r2d_ynb_loop_b
487 end_ynb_loop_b:
488 _r2d_skip_color_dst_b: MOV y,y
489
490 SUB current_dst_dy,current_dst_dy,#1
491 LDRH temp,[R0,#S_FRAME.end_dst_dy_ind]
492 SUB current_dst_dy,current_dst_dy,temp
493
494 ;-------------------------------------
495 ;
496 ; Fourth while
497 ;
498 ; current_dst_dy - end_dst_dy != 0
499 end_dst_loop_b: TEQ current_dst_dy,#0
500 BEQ end_end_dst_loop_b
501
502 write_shift_pixel_down b_down2
503
504 _r2d_end_b_down2: ADD current_dst_dy,current_dst_dy,#1
505 ADD y,y,#1
506 B end_dst_loop_b
507 end_end_dst_loop_b:
508 MOV temp,#0
509 CMP dstcounter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
510 MOVEQ temp,#1
511
512 ;-------------------------------------
513 ;
514 ; Last while
515 ;
516 ; dstcounter != (1<<R2D_PIXELS_PER_MEMORY_WORD)
517 dst_counter_loop_b: CMP dstcounter,#(1<<R2D_PIXELS_PER_MEMORY_WORD)
518 BEQ end_dst_counter_loop_b
519 shift_pixel_down dstvalue,dst,downc
520 _r2d_end_downc: ADD y,y,#1
521 B dst_counter_loop_b
522 end_dst_counter_loop_b:
523 CMP temp,#0
524 STREQ dstvalue,[p_dst_current,#-4]!
525
526 CMP temp,#0
527 STRNE dstvalue,[p_dst_current]
528 _r2d_endb:
529 LDMFD SP!, {R4,R5,R6,R7,R8,R9,R10,R11,R12,LR}
530 MOV PC,LR
531
532 .endif
533
534 .end