2010-04-26 21:40:16 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
2010-10-22 12:28:43 +00:00
|
|
|
* $Id$
|
2010-04-26 21:40:16 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Marcin Bukat
|
2010-04-30 14:13:52 +00:00
|
|
|
* based on lcd-as-m3.S by Jens Arnold
|
2010-04-26 21:40:16 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define LCD_BASE_ADDRESS 0xf0000000
|
|
|
|
|
|
|
|
.section .icode,"ax",@progbits
|
|
|
|
|
|
|
|
.align 2
|
|
|
|
.global lcd_write_command
|
|
|
|
.type lcd_write_command,@function
|
|
|
|
|
|
|
|
lcd_write_command:
|
|
|
|
move.l (4, %sp), %d0
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d0, LCD_BASE_ADDRESS /* transfers 1 byte to LCD */
|
|
|
|
|
2010-04-26 21:40:16 +00:00
|
|
|
rts
|
|
|
|
.wc_end:
|
|
|
|
.size lcd_write_command,.wc_end-lcd_write_command
|
|
|
|
|
|
|
|
|
|
|
|
.align 2
|
|
|
|
.global lcd_write_command_e
|
|
|
|
.type lcd_write_command_e,@function
|
|
|
|
|
|
|
|
lcd_write_command_e:
|
|
|
|
lea.l LCD_BASE_ADDRESS, %a0
|
|
|
|
move.l (4, %sp), %d0 /* Command */
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d0, (%a0)
|
2010-04-26 21:40:16 +00:00
|
|
|
move.l (8, %sp), %d0 /* Data */
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d0, (%a0) /* Write to LCD */
|
2010-04-26 21:40:16 +00:00
|
|
|
|
|
|
|
rts
|
|
|
|
.wce_end:
|
|
|
|
.size lcd_write_command_e,.wce_end-lcd_write_command_e
|
|
|
|
|
|
|
|
|
|
|
|
.align 2
|
|
|
|
.global lcd_write_data
|
|
|
|
.type lcd_write_data,@function
|
|
|
|
|
|
|
|
/* PIXELFORMAT = VERTICAL_INTERLEAVED
|
|
|
|
* this means that data is packed verticaly in 8 pixels columns
|
|
|
|
* first byte is lsb of 2bit color in column
|
|
|
|
* second byte is msb of 2bit color in column
|
|
|
|
* so one word of data equals 8 pixels i 2bits color depth packed
|
|
|
|
* verticaly
|
|
|
|
*/
|
|
|
|
lcd_write_data:
|
|
|
|
movem.l (4, %sp), %a0 /* Data pointer */
|
|
|
|
move.l (8, %sp), %d0 /* Length i in words */
|
2010-05-17 12:34:59 +00:00
|
|
|
lea.l LCD_BASE_ADDRESS+2, %a1 /* LCD data port address */
|
2010-04-26 21:40:16 +00:00
|
|
|
|
|
|
|
btst #0, %d0 /* longwords multiply? */
|
2010-05-17 12:34:59 +00:00
|
|
|
jeq .l_write
|
2010-04-26 21:40:16 +00:00
|
|
|
|
|
|
|
.w_write:
|
|
|
|
move.w (%a0)+, %d1 /* load data 3 cycles*/
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d1, (%a1) /* first byte 1 cycle*/
|
2010-04-26 21:40:16 +00:00
|
|
|
lsr.l #8, %d1 /* load second byte 1 cycle*/
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d1, (%a1) /* transfer 1 cycle*/
|
2010-04-26 21:40:16 +00:00
|
|
|
subq.l #1, %d0 /* decrement counter 1 cycle*/
|
2010-05-17 12:34:59 +00:00
|
|
|
jeq .write_end
|
2010-04-26 21:40:16 +00:00
|
|
|
|
|
|
|
.l_write:
|
|
|
|
move.l (%a0)+, %d1 /* load data 2 cycles*/
|
|
|
|
swap %d1 /* 1 cycle */
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d1, (%a1) /* first byte 1 cycle*/
|
2010-04-26 21:40:16 +00:00
|
|
|
lsr.l #8, %d1 /* 1 cycle */
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d1, (%a1) /* second byte 1 cycle*/
|
2010-04-26 21:40:16 +00:00
|
|
|
lsr.l #8, %d1 /* 1 cycle */
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d1, (%a1) /* third byte 1 cycle*/
|
2010-04-26 21:40:16 +00:00
|
|
|
lsr.l #8, %d1 /* 1 cycle */
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d1, (%a1) /* forth byte 1 cycle*/
|
2010-04-26 21:40:16 +00:00
|
|
|
subq.l #2, %d0 /* decrement counter 1 cycle*/
|
2010-05-17 12:34:59 +00:00
|
|
|
bne.s .l_write
|
2010-04-26 21:40:16 +00:00
|
|
|
|
|
|
|
.write_end:
|
|
|
|
rts
|
2010-04-30 14:13:52 +00:00
|
|
|
.wd_end:
|
2010-04-26 21:40:16 +00:00
|
|
|
.size lcd_write_data,.wd_end-lcd_write_data
|
|
|
|
|
2010-04-30 14:13:52 +00:00
|
|
|
.global lcd_mono_data
|
|
|
|
.type lcd_mono_data, @function
|
|
|
|
|
|
|
|
lcd_mono_data:
|
|
|
|
move.l (4, %sp), %a0 /* p_bytes */
|
|
|
|
move.l (8, %sp), %d0 /* count */
|
|
|
|
lea.l LCD_BASE_ADDRESS+2, %a1 /* LCD data port address */
|
|
|
|
|
|
|
|
.md_loop:
|
|
|
|
move.b (%a0)+, %d1
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d1, (%a1) /* byte transfers */
|
|
|
|
move.b %d1, (%a1)
|
2010-04-30 14:13:52 +00:00
|
|
|
subq.l #1, %d0
|
|
|
|
bne.s .md_loop
|
2010-07-16 07:24:08 +00:00
|
|
|
|
2010-04-30 14:13:52 +00:00
|
|
|
rts
|
|
|
|
.md_end:
|
|
|
|
.size lcd_mono_data,.md_end-lcd_mono_data
|
|
|
|
|
|
|
|
.global lcd_grey_data
|
|
|
|
.type lcd_grey_data,@function
|
|
|
|
|
|
|
|
lcd_grey_data:
|
2010-07-16 07:08:39 +00:00
|
|
|
lea.l (-11*4, %sp), %sp
|
|
|
|
movem.l %d2-%d7/%a2-%a6, (%sp) /* save some registers */
|
|
|
|
movem.l (11*4+4, %sp), %a0-%a2 /* values, phases, length */
|
2010-04-30 14:13:52 +00:00
|
|
|
add.l %a2, %a2
|
|
|
|
lea.l (%a1, %a2.l*4), %a2 /* end address */
|
|
|
|
lea.l LCD_BASE_ADDRESS+2, %a3 /* LCD data port address */
|
2010-06-11 19:53:17 +00:00
|
|
|
moveq.l #24, %d4 /* shift count */
|
|
|
|
move.l #0x204081, %d5 /* bit shuffle factor */
|
|
|
|
|
2010-07-16 07:08:39 +00:00
|
|
|
moveq.l #8, %d2
|
2010-06-15 10:41:43 +00:00
|
|
|
add.l %a1, %d2
|
|
|
|
and.l #0xfffffff0, %d2 /* first line bound */
|
|
|
|
cmp.l %d2, %a2 /* end address lower than first line bound? */
|
|
|
|
bhs.s 1f
|
|
|
|
move.l %a2, %d2 /* -> adjust end address of head loop */
|
|
|
|
1:
|
|
|
|
cmp.l %a1, %d2
|
2010-07-16 07:08:39 +00:00
|
|
|
bls.s .g_hend
|
2010-06-15 10:41:43 +00:00
|
|
|
|
2010-07-16 07:08:39 +00:00
|
|
|
/* process head pixels */
|
2010-06-11 19:53:17 +00:00
|
|
|
movem.l (%a1), %d0-%d1 /* fetch 8 pixel phases */
|
|
|
|
|
|
|
|
move.l %d0, %d2
|
|
|
|
and.l #0x80808080, %d2 /* %d2 = 0.......1.......2.......3....... */
|
2010-07-16 07:08:39 +00:00
|
|
|
eor.l %d2, %d0
|
2010-06-11 19:53:17 +00:00
|
|
|
add.l (%a0)+, %d0 /* add values to first 4 phases */
|
|
|
|
|
|
|
|
move.l %d1, %d3
|
|
|
|
and.l #0x80808080, %d3 /* %d3 = 4.......5.......6.......7....... */
|
|
|
|
eor.l %d3, %d1
|
|
|
|
add.l (%a0)+, %d1 /* add values to second 4 phases */
|
|
|
|
|
|
|
|
lsr.l #4, %d3 /* %d3 = ....4.......5.......6.......7... */
|
|
|
|
or.l %d3, %d2 /* %d2 = 0...4...1...5...2...6...3...7... */
|
|
|
|
mulu.l %d5, %d2 /* %d2 = 01234567123.567.23..67..3...7... */
|
|
|
|
not.l %d2 /* negate bits */
|
|
|
|
lsr.l %d4, %d2 /* %d2 = ........................01234567 */
|
|
|
|
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d2, (%a3) /* transfer first LCD byte */
|
2010-06-11 19:53:17 +00:00
|
|
|
|
|
|
|
movem.l %d0-%d1, (%a1) /* store 8 new pixel phases */
|
|
|
|
addq.l #8, %a1
|
2010-04-30 14:13:52 +00:00
|
|
|
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d2, (%a3) /* transfer second LCD byte */
|
2010-06-15 10:41:43 +00:00
|
|
|
|
2010-07-16 07:08:39 +00:00
|
|
|
.g_hend:
|
2010-06-15 10:41:43 +00:00
|
|
|
cmp.l %a1, %a2
|
2010-07-16 07:08:39 +00:00
|
|
|
bls.w .g_tend
|
|
|
|
subq.l #8, %a2
|
2010-06-15 10:41:43 +00:00
|
|
|
cmp.l %a1, %a2
|
2010-07-16 07:08:39 +00:00
|
|
|
bls.s .g_lend
|
2010-06-15 10:41:43 +00:00
|
|
|
|
|
|
|
.g_line_loop:
|
2010-07-16 07:08:39 +00:00
|
|
|
/* loop that utilizes line transfers */
|
2010-06-15 10:41:43 +00:00
|
|
|
movem.l (%a1), %d0-%d3 /* fetch 2 * 8 pixels phases */
|
|
|
|
|
|
|
|
move.l %d0, %d6
|
|
|
|
and.l #0x80808080, %d6 /* %d6 = 0.......1.......2.......3....... */
|
|
|
|
eor.l %d6, %d0
|
|
|
|
|
|
|
|
move.l %d1, %d7
|
|
|
|
and.l #0x80808080, %d7 /* %d7 = 4.......5.......6.......7....... */
|
|
|
|
eor.l %d7, %d1
|
|
|
|
|
|
|
|
lsr.l #4, %d7 /* %d7 = ....4.......5.......6.......7... */
|
|
|
|
or.l %d7, %d6 /* %d6 = 0...4...1...5...2...6...3...7... */
|
|
|
|
mulu.l %d5, %d6 /* %d6 = 01234567123.567.23..67..3...7... */
|
|
|
|
not.l %d6 /* negate bits */
|
|
|
|
lsr.l %d4, %d6 /* %d6 = ........................01234567 */
|
|
|
|
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d6, (%a3) /* transfer first LCD byte */
|
2010-07-16 07:08:39 +00:00
|
|
|
|
|
|
|
movem.l (%a0), %d7/%a4-%a6 /* fetch 2 * 8 pixel values */
|
|
|
|
lea.l (16, %a0), %a0
|
|
|
|
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d6, (%a3) /* transfer second LCD byte */
|
2010-06-15 10:41:43 +00:00
|
|
|
|
2010-07-16 07:08:39 +00:00
|
|
|
add.l %d7, %d0
|
|
|
|
add.l %a4, %d1
|
|
|
|
|
2010-06-15 10:41:43 +00:00
|
|
|
move.l %d2, %d6
|
|
|
|
and.l #0x80808080, %d6 /* %d6 = 0.......1.......2.......3....... */
|
|
|
|
eor.l %d6, %d2
|
|
|
|
|
|
|
|
move.l %d3, %d7
|
|
|
|
and.l #0x80808080, %d7 /* %d7 = 4.......5.......6.......7....... */
|
|
|
|
eor.l %d7, %d3
|
|
|
|
|
|
|
|
lsr.l #4, %d7 /* %d7 = ....4.......5.......6.......7... */
|
|
|
|
or.l %d7, %d6 /* %d6 = 0...4...1...5...2...6...3...7... */
|
|
|
|
mulu.l %d5, %d6 /* %d6 = 01234567123.567.23..67..3...7... */
|
|
|
|
not.l %d6 /* negate bits */
|
|
|
|
lsr.l %d4, %d6 /* %d6 = ........................01234567 */
|
|
|
|
|
2010-07-16 07:08:39 +00:00
|
|
|
add.l %a5, %d2
|
|
|
|
add.l %a6, %d3
|
|
|
|
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d6, (%a3) /* transfer first LCD byte */
|
2010-06-15 10:41:43 +00:00
|
|
|
|
|
|
|
movem.l %d0-%d3, (%a1) /* store 2 * 8 new pixel phases */
|
|
|
|
lea.l (16, %a1), %a1 /* advance pointer */
|
|
|
|
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d6, (%a3) /* transfer second LCD byte */
|
2010-07-16 07:08:39 +00:00
|
|
|
|
2010-04-30 14:13:52 +00:00
|
|
|
cmp.l %a2, %a1
|
2010-06-15 10:41:43 +00:00
|
|
|
bls.s .g_line_loop
|
|
|
|
|
2010-07-16 07:08:39 +00:00
|
|
|
.g_lend:
|
|
|
|
addq.l #8, %a2
|
2010-06-15 10:41:43 +00:00
|
|
|
cmp.l %a1, %a2
|
2010-07-16 07:08:39 +00:00
|
|
|
bls.s .g_tend
|
|
|
|
|
|
|
|
/* process tail pixels */
|
|
|
|
movem.l (%a1), %d0-%d1 /* fetch 8 pixel phases */
|
|
|
|
|
|
|
|
move.l %d0, %d2
|
|
|
|
and.l #0x80808080, %d2 /* %d2 = 0.......1.......2.......3....... */
|
|
|
|
eor.l %d2, %d0
|
|
|
|
add.l (%a0)+, %d0 /* add values to first 4 phases */
|
|
|
|
|
|
|
|
move.l %d1, %d3
|
|
|
|
and.l #0x80808080, %d3 /* %d3 = 4.......5.......6.......7....... */
|
|
|
|
eor.l %d3, %d1
|
|
|
|
add.l (%a0)+, %d1 /* add values to second 4 phases */
|
|
|
|
|
|
|
|
lsr.l #4, %d3 /* %d3 = ....4.......5.......6.......7... */
|
|
|
|
or.l %d3, %d2 /* %d2 = 0...4...1...5...2...6...3...7... */
|
|
|
|
mulu.l %d5, %d2 /* %d2 = 01234567123.567.23..67..3...7... */
|
|
|
|
not.l %d2 /* negate bits */
|
|
|
|
lsr.l %d4, %d2 /* %d2 = ........................01234567 */
|
|
|
|
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d2, (%a3) /* transfer first LCD byte */
|
2010-07-16 07:08:39 +00:00
|
|
|
|
|
|
|
movem.l %d0-%d1, (%a1) /* store 8 new pixel phases */
|
|
|
|
/* addq.l #8, %a1 not needed anymore */
|
|
|
|
|
2010-07-16 07:24:08 +00:00
|
|
|
move.b %d2, (%a3) /* transfer second LCD byte */
|
2010-04-30 14:13:52 +00:00
|
|
|
|
2010-07-16 07:08:39 +00:00
|
|
|
.g_tend:
|
|
|
|
movem.l (%sp), %d2-%d7/%a2-%a6
|
|
|
|
lea.l (11*4, %sp), %sp
|
2010-04-30 14:13:52 +00:00
|
|
|
rts
|
|
|
|
.grey_end:
|
|
|
|
.size lcd_grey_data,.grey_end-lcd_grey_data
|