summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/lib/grey_core.c21
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/export/config-clip.h5
-rw-r--r--firmware/target/arm/as3525/sansa-clip/lcd-as-clip.S99
-rw-r--r--firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c30
5 files changed, 143 insertions, 13 deletions
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c
index 008104a04f..c4eb0fc080 100644
--- a/apps/plugins/lib/grey_core.c
+++ b/apps/plugins/lib/grey_core.c
@@ -207,6 +207,27 @@ static const unsigned char lcdlinear[256] = {
};
#define LCD_SCANRATE 51 /* Hz */
+#elif defined SANSA_CLIP /* NOT verified */
+static const unsigned char lcdlinear[256] = {
+ 0, 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, 234, 235, 236, 237, 238, 239,
+240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
+};
+#define LCD_SCANRATE 78 /* Hz */
+
#else /* not yet calibrated targets - generic linear mapping */
/* TODO: calibrate iFP7xx */
static const unsigned char lcdlinear[256] = {
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 47dcfe5c86..9b576d435a 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1068,6 +1068,7 @@ target/arm/pcm-telechips.c
#ifdef SANSA_CLIP
#ifndef SIMULATOR
target/arm/as3525/sansa-clip/lcd-ssd1303.c
+target/arm/as3525/sansa-clip/lcd-as-clip.S
target/arm/as3525/sansa-clip/button-clip.c
target/arm/as3525/sansa-clip/backlight-clip.c
target/arm/as3525/as3525-codec.c
diff --git a/firmware/export/config-clip.h b/firmware/export/config-clip.h
index 4266b59a7f..d54d4f3488 100644
--- a/firmware/export/config-clip.h
+++ b/firmware/export/config-clip.h
@@ -61,6 +61,9 @@
/* define this if you can flip your LCD */
#define HAVE_LCD_FLIP
+/* define this if you can invert the pixels */
+#define HAVE_LCD_INVERT
+
/* Define this if your LCD can set contrast */
#define HAVE_LCD_CONTRAST
@@ -68,7 +71,7 @@
#define MAX_CONTRAST_SETTING 50
#define DEFAULT_CONTRAST_SETTING 30
-/* #define IRAM_LCDFRAMEBUFFER IDATA_ATTR *//* put the lcd frame buffer in IRAM */
+#define IRAM_LCDFRAMEBUFFER IDATA_ATTR /* put the lcd frame buffer in IRAM */
#define CONFIG_KEYPAD SANSA_CLIP_PAD
diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-as-clip.S b/firmware/target/arm/as3525/sansa-clip/lcd-as-clip.S
new file mode 100644
index 0000000000..aab46861ba
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-clip/lcd-as-clip.S
@@ -0,0 +1,99 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 by Jens Arnold
+ *
+ * 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 "as3525.h"
+
+ .text
+ .align 2
+
+ .global lcd_grey_data
+ .type lcd_grey_data,%function
+
+/* A high performance function to write grey phase data to the display,
+ * one or multiple pixels.
+ *
+ * Arguments:
+ * r0 - pixel value data address
+ * r1 - pixel phase data address
+ * r2 - pixel block count
+ *
+ * Register usage:
+ * r3/r4 - current block of phases
+ * r5/r6 - current block of values
+ * r7 - lcd data accumulator
+ * r8 - phase signs mask
+ * lr - lcd bridge address
+ */
+
+lcd_grey_data:
+ stmfd sp!, {r4-r8, lr}
+ mov r8, #0x80
+ orr r8, r8, r8, lsl #8
+ orr r8, r8, r8, lsl #16
+
+ ldr lr, =GPIOA_BASE
+ mov r3, #(1<<5)
+ str r3, [lr, #(4*(1<<5))] @ set pin D/C# of LCD controller (data)
+
+ ldr lr, =DBOP_BASE
+
+.greyloop:
+ ldmia r1, {r3-r4} /* Fetch 8 pixel phases */
+ ldmia r0!, {r5-r6} /* Fetch 8 pixel values */
+
+ mov r7, #0xff
+ tst r3, #0x80
+ biceq r7, r7, #0x80
+ tst r3, #0x8000
+ biceq r7, r7, #0x40
+ tst r3, #0x800000
+ biceq r7, r7, #0x20
+ tst r3, #0x80000000
+ biceq r7, r7, #0x10
+ bic r3, r3, r8
+ add r3, r3, r5
+
+ tst r4, #0x80
+ biceq r7, r7, #0x08
+ tst r4, #0x8000
+ biceq r7, r7, #0x04
+ tst r4, #0x800000
+ biceq r7, r7, #0x02
+ tst r4, #0x80000000
+ biceq r7, r7, #0x01
+ bic r4, r4, r8
+ add r4, r4, r6
+
+ stmia r1!, {r3-r4}
+
+ orr r7, r7, r7, lsl #8 @ we set 15:13 to the MSb and 3:0 to the LSb
+ strh r7, [lr, #0x10] @ DBOP_DOUT
+
+1:
+ ldr r5, [lr, #0xC] @ DBOP_STAT
+ ands r5, r5, #(1<<10) @ wait until push fifo empties
+ beq 1b
+
+ subs r2, r2, #1
+ bne .greyloop
+
+ ldmfd sp!, {r4-r8, pc}
+ .size lcd_grey_data,.-lcd_grey_data
diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c
index f1e1c24b85..703b7e1307 100644
--- a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c
+++ b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c
@@ -88,6 +88,7 @@ void lcd_write_command(int byte)
GPIOA_PIN(5) = 0;
/* Write command */
+ /* Only bits 15:12 and 3:0 of DBOP_DOUT are meaningful */
DBOP_DOUT = (byte << 8) | byte;
/* While push fifo is not empty */
@@ -103,6 +104,7 @@ void lcd_write_data(const fb_data* p_bytes, int count)
while (count--)
{
/* Write pixels */
+ /* Only bits 15:12 and 3:0 of DBOP_DOUT are meaningful */
DBOP_DOUT = (*p_bytes << 8) | *p_bytes;
p_bytes++; /* next packed pixels */
@@ -266,26 +268,30 @@ void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
}
}
+/* Helper function for lcd_grey_phase_blit(). */
+void lcd_grey_data(unsigned char *values, unsigned char *phases, int count);
/* Performance function that works with an external buffer
note that by and bheight are in 8-pixel units! */
void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
int x, int by, int width, int bheight, int stride)
{
- /* TODO */
-
-#if 0
if(!display_on)
return;
-#endif
-
- (void)values;
- (void)phases;
- (void)x;
- (void)by;
- (void)width;
- (void)bheight;
- (void)stride;
+
+ stride <<= 3; /* 8 pixels per block */
+ /* Copy display bitmap to hardware */
+ while (bheight--)
+ {
+ lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf));
+ lcd_write_command (LCD_CNTL_HIGHCOL | (((x+2+xoffset)>>4) & 0xf));
+ lcd_write_command (LCD_CNTL_LOWCOL | ((x+2+xoffset) & 0xf));
+
+ lcd_grey_data(values, phases, width);
+
+ values += stride;
+ phases += stride;
+ }
}
/* Update the display.