FS#11335 by me: make ARM assembly functions thumb-friendly
[kugel-rb.git] / firmware / target / arm / as3525 / sansa-clip / lcd-as-clip.S
blob431dc62da0a560fa536ba27c95cc27a7f1db662f
1 /***************************************************************************
2  *             __________               __   ___.
3  *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4  *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5  *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6  *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7  *                     \/            \/     \/    \/            \/
8  * $Id$
9  *
10  * Copyright (C) 2008 by Jens Arnold
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18  * KIND, either express or implied.
19  *
20  ****************************************************************************/
22 #include "config.h"
23 #include "as3525.h"
25     .text
26     .align      2
28     .global     lcd_grey_data
29     .type       lcd_grey_data,%function
31 /* A high performance function to write grey phase data to the display,
32  * one or multiple pixels.
33  *
34  * Arguments:
35  *   r0 - pixel value data address
36  *   r1 - pixel phase data address
37  *   r2 - pixel block count
38  *
39  * Register usage:
40  *   r3/r4 - current block of phases
41  *   r5/r6 - current block of values
42  *   r7 - lcd data accumulator
43  *   r12 - phase signs mask
44  *   lr - lcd bridge address
45  */
47 lcd_grey_data:
48     stmfd   sp!, {r4-r7, lr}
49     mov     r12, #0x80
50     orr     r12, r12, r12, lsl #8
51     orr     r12, r12, r12, lsl #16
53     ldr     lr, =GPIOA_BASE
54     mov     r3, #(1<<5)
55     str     r3, [lr, #(4*(1<<5))] @ set pin D/C# of LCD controller (data)
57     ldr     lr, =DBOP_BASE
59 .greyloop:
61     ldmia   r1, {r3-r4}
62     
63     and     r5, r12, r3         @ r5 = 3.......2.......1.......0.......
64     and     r6, r12, r4         @ r6 = 7.......6.......5.......4.......
65     orr     r5, r5, r6, lsr #4  @ r5 = 3...7...2...6...1...5...0...4...
66     orr     r5, r5, r5, lsr #9  @ r5 = 3...7...23..67..12..56..01..45..
67     orr     r5, r5, r5, lsr #9  @ r5 = 3...7...23..67..123.567.012.456.
68     orr     r5, r5, r5, lsr #9  @ r5 = 3...7...23..67..123.567.01234567
69     and     r5, r5, #0xff
70     orr     r5, r5, r5, lsl #8  @ post processing for clipv1 LCD */
72     ldmia   r0!, {r6-r7}
73     bic     r3, r3, r12
74     add     r3, r3, r6
75     bic     r4, r4, r12
76     add     r4, r4, r7
77     stmia   r1!, {r3-r4}
79     strh    r5, [lr, #0x10]     @ DBOP_DOUT
82     ldr     r6, [lr, #0xC]      @ DBOP_STAT
83     ands    r6, r6, #(1<<6)     @ wait until push fifo is full
84     bne     1b
86     subs    r2, r2, #1
87     bne     .greyloop
90     ldr     r5, [lr, #0xC]      @ DBOP_STAT
91     ands    r5, r5, #(1<<10)    @ wait until push fifo empties
92     beq     1b
94     ldmpc   regs=r4-r7
95     .size   lcd_grey_data,.-lcd_grey_data