1/* s32a_d565_opaque.S
2**
3** Copyright 2009, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9**     http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18
19        .text
20        .align
21
22        .global s32a_d565_opaque_arm
23
24// void s32a_d565_opaque_arm(uint16_t*, uint32_t*, size_t)
25// r0: dst ptr
26// r1: src prt
27// r2: count
28
29s32a_d565_opaque_arm:
30    stmdb sp!, {r4, r5, r6, r7, lr}
31    subs r4, r2, #0
32    mov r7, r1
33    ble 1f
344:  ldr r1, [r7], #4 // r1=*src; src++
35    cmp r1, #0
36    mov lr, r1, lsr #24
37    beq 2f // get next src
38
39    cmp lr, #255 // 0xff
40    mov r2, r1, lsl #8
41    mov r6, r2
42    moveq r2, r1, lsr #5
43    andeq r3, r6, #63488 // 0xf800
44    andeq r2, r2, #2016 // 0x7e0
45    orreq r3, r3, r2
46    orreq r3, r3, r6, lsr #27
47    streqh r3, [r0], #2 // *dst = r3; dst++
48    beq 3f // go to count--
49
50    mov r3, r1, lsl #16
51    rsb ip, lr, #255 // 0xff
52    mov r5, r3, lsr #24
53    ldrh r3, [r0]    // r3 = *dst
54    mov lr, r6, lsr #24
55    and r6, r1, #255 // 0xff
56
57    mov r1, r3, lsr #5
58    and r2, r1, #63
59    smulbb r1, r2, ip
60    add r2, r1, #32
61    mov r1, r3, lsr #11
62    add r2, r2, r2, lsr #6
63
64    smulbb r1, r1, ip
65    add r2, r5, r2, lsr #6
66    add r1, r1, #16
67    and r3, r3, #31 // 0x1f
68    add r1, r1, r1, lsr #5
69
70    smulbb r3, r3, ip
71    add r1, r6, r1, lsr #5
72    mov ip, r2, lsr #2
73    add r3, r3, #16 // 0x10
74    mov r1, r1, lsr #3
75
76    add r3, r3, r3, lsr #5
77    mov r2, ip, lsl #5
78    add r3, lr, r3, lsr #5
79    orr ip, r2, r1, lsl #11
80    orr r1, ip, r3, lsr #3
81    strh r1, [r0]
82
832:  add r0, r0, #2  // dst++
843:  subs r4, r4, #1 // r4 = --count
85    bne 4b
86
871:  ldmia sp!, {r4, r5, r6, r7, pc}
88
89