summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iaudio/m5/lcd-as-m5.S
blob: 0ec98e45892f12b25f127eee80eae11152f1a6b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2007 by Jens Arnold
 *
 * All files in this archive are subject to the GNU General Public License.
 * See the file COPYING in the source tree root for full license agreement.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#include "config.h"
#include "cpu.h"

    .section    .icode,"ax",@progbits

    .align      2
    .global     lcd_write_command
    .type       lcd_write_command,@function

lcd_write_command:
    move.l  (4, %sp), %d0
    move.w  %d0, 0xf0008000
    rts
.wc_end:
    .size   lcd_write_command,.wc_end-lcd_write_command


    .align      2
    .global     lcd_write_command_ex
    .type       lcd_write_command_ex,@function

lcd_write_command_ex:
    lea.l   0xf0008000, %a0

    move.l  (4, %sp), %d0       /* Command */
    move.w  %d0, (%a0)+         /* Write to LCD, set A0 = 1 */

    move.l  (8, %sp), %d0       /* Data */
    cmp.l   #-1, %d0            /* -1? */
    beq.b   .last
    move.w  %d0, (%a0)          /* Write to LCD */

    move.l  (12, %sp), %d0      /* Data */
    cmp.l   #-1, %d0            /* -1? */
    beq.b   .last
    move.w  %d0, (%a0)          /* Write to LCD */

.last:
    rts
.wcex_end:
    .size   lcd_write_command_ex,.wcex_end-lcd_write_command_ex


    .align      2
    .global     lcd_write_data
    .type       lcd_write_data,@function

lcd_write_data:
    movem.l (4, %sp), %a0-%a1   /* Data pointer */
    move.l  %a1, %d0            /* Length */
    lea     0xf0008002, %a1

.loop:
    /* When running in IRAM, this loop takes 10 cycles plus the LCD write.
       The 10 cycles are necessary to follow the LCD timing specs
       at 140MHz */
    nop                         /* 3(0/0) */
    move.b  (%a0)+, %d1         /* 3(1/0) */
    move.w  %d1, (%a1)          /* 1(0/1) */
    subq.l  #1, %d0             /* 1(0/0) */
    bne     .loop               /* 2(0/0) */
    rts
.wd_end:
    .size   lcd_write_data,.wd_end-lcd_write_data


    .align      2
    .global     lcd_grey_data
    .type       lcd_grey_data,@function

lcd_grey_data:
    lea.l   (-9*4, %sp), %sp
    movem.l %d2-%d5/%a2-%a6, (%sp)  /* free some registers */
    movem.l (9*4+4, %sp), %a0-%a2   /* values, phases, length */
    lea.l   (%a1, %a2.l*4), %a2     /* end address */
    lea     0xf0008002, %a3     /* LCD data port */

    moveq.l #15, %d3
    add.l   %a1, %d3
    and.l   #0xfffffff0, %d3    /* first line bound */
    move.l  %a2, %d1
    and.l   #0xfffffff0, %d1    /* last line bound */
    cmp.l   %d3, %d1
    bls.w   .g_tloop            /* no lines to copy - jump to tail loop */
    cmp.l   %a1, %d0
    bls.s   .g_lloop            /* no head blocks - jump to line loop */

.g_hloop:
    move.l  (%a1), %d2          /* fetch 4 pixel phases */

    bclr.l  #31, %d2            /* Z = !(p0 & 0x80); p0 &= ~0x80; */
    seq.b   %d0                 /* %d0 = ........................00000000 */
    lsl.l   #2, %d0             /* %d0 = ......................00000000.. */
    bclr.l  #23, %d2            /* Z = !(p1 & 0x80); p1 &= ~0x80; */
    seq.b   %d0                 /* %d0 = ......................0011111111 */
    lsl.l   #2, %d0             /* %d0 = ....................0011111111.. */
    bclr.l  #15, %d2            /* Z = !(p2 & 0x80); p2 &= ~0x80; */
    seq.b   %d0                 /* %d0 = ....................001122222222 */
    lsl.l   #2, %d0             /* %d0 = ..................001122222222.. */
    bclr.l  #7, %d2             /* Z = !(p3 & 0x80); p3 &= ~0x80; */
    seq.b   %d0                 /* %d0 = ..................00112233333333 */
    lsr.l   #6, %d0             /* %d0 = ........................00112233 */
    move.w  %d0, (%a3)          /* write pixel block */
    
    add.l   (%a0)+, %d2         /* add 4 pixel values to the phases */
    move.l  %d2, (%a1)+         /* store new phases, advance pointer */

    cmp.l   %a1, %d3            /* go up to first line bound */
    bhi.s   .g_hloop
    
.g_lloop:
    movem.l (%a1), %d2-%d5
    
    bclr.l  #31, %d2
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #23, %d2
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #15, %d2
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #7, %d2
    seq.b   %d0
    lsr.l   #6, %d0
    move.w  %d0, (%a3)

    bclr.l  #31, %d3
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #23, %d3
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #15, %d3
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #7, %d3
    seq.b   %d0
    lsr.l   #6, %d0
    move.w  %d0, (%a3)
    
    bclr.l  #31, %d4
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #23, %d4
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #15, %d4
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #7, %d4
    seq.b   %d0
    lsr.l   #6, %d0
    move.w  %d0, (%a3)
    
    bclr.l  #31, %d5
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #23, %d5
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #15, %d5
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #7, %d5
    seq.b   %d0
    lsr.l   #6, %d0
    move.w  %d0, (%a3)
    
    movem.l (%a0), %d0/%a4-%a6
    lea.l   (16, %a0), %a0
    add.l   %d0, %d2
    add.l   %a4, %d3
    add.l   %a5, %d4
    add.l   %a6, %d5
    movem.l %d2-%d5, (%a1)
    lea.l   (16, %a1), %a1

    cmp.l   %a1, %d1            /* go up to last line bound */
    bhi.w   .g_lloop
    
    cmp.l   %a1, %a2
    bls.s   .g_no_tail

.g_tloop:
    move.l  (%a1), %d2

    bclr.l  #31, %d2
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #23, %d2
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #15, %d2
    seq.b   %d0
    lsl.l   #2, %d0
    bclr.l  #7, %d2
    seq.b   %d0
    lsr.l   #6, %d0
    move.w  %d0, (%a3)

    add.l   (%a0)+, %d2         /* go up to end address */
    move.l  %d2, (%a1)+

    cmp.l   %a1, %a2
    bhi.s   .g_tloop

.g_no_tail:
    movem.l (%sp), %d2-%d5/%a2-%a6  /* restore registers */
    lea.l   (9*4, %sp), %sp
    rts

.gd_end:
    .size   lcd_grey_data,.gd_end-lcd_grey_data