summaryrefslogtreecommitdiff
path: root/firmware/target/arm/philips/hdd6330/lcd-hdd6330.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/philips/hdd6330/lcd-hdd6330.c')
-rw-r--r--firmware/target/arm/philips/hdd6330/lcd-hdd6330.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/firmware/target/arm/philips/hdd6330/lcd-hdd6330.c b/firmware/target/arm/philips/hdd6330/lcd-hdd6330.c
new file mode 100644
index 0000000000..3d9cb036f1
--- /dev/null
+++ b/firmware/target/arm/philips/hdd6330/lcd-hdd6330.c
@@ -0,0 +1,159 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 by Mark Arigo
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 ****************************************************************************/
21#include "config.h"
22#include "cpu.h"
23#include "lcd.h"
24#include "kernel.h"
25#include "system.h"
26
27/* Display status */
28static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
29
30/* wait for LCD */
31static inline void lcd_wait_write(void)
32{
33 int i = 0;
34 while (LCD2_PORT & LCD2_BUSY_MASK)
35 {
36 if (i < 2000)
37 i++;
38 else
39 LCD2_PORT &= ~LCD2_BUSY_MASK;
40 }
41}
42
43/* send LCD data */
44static void lcd_send_data(unsigned data)
45{
46 lcd_wait_write();
47 LCD2_PORT = LCD2_DATA_MASK | (data & 0xff);
48}
49
50/* send LCD command */
51static void lcd_send_cmd(unsigned cmd)
52{
53 lcd_wait_write();
54 LCD2_PORT = LCD2_CMD_MASK | (cmd & 0xff);
55 lcd_wait_write();
56}
57
58static inline void lcd_send_pixel(unsigned pixel)
59{
60 lcd_send_data(pixel >> 8);
61 lcd_send_data(pixel);
62}
63
64void lcd_init_device(void)
65{
66 /* init handled by the OF bootloader */
67}
68
69/*** hardware configuration ***/
70int lcd_default_contrast(void)
71{
72 return DEFAULT_CONTRAST_SETTING;
73}
74
75void lcd_set_contrast(int val)
76{
77 (void)val;
78}
79
80void lcd_set_invert_display(bool yesno)
81{
82 (void)yesno;
83}
84
85/* turn the display upside down (call lcd_update() afterwards) */
86void lcd_set_flip(bool yesno)
87{
88 (void)yesno;
89}
90
91void lcd_yuv_set_options(unsigned options)
92{
93 lcd_yuv_options = options;
94}
95
96/* Performance function to blit a YUV bitmap directly to the LCD */
97void lcd_blit_yuv(unsigned char * const src[3],
98 int src_x, int src_y, int stride,
99 int x, int y, int width, int height)
100{
101 (void)src;
102 (void)src_x;
103 (void)src_y;
104 (void)stride;
105 (void)x;
106 (void)y;
107 (void)width;
108 (void)height;
109}
110
111/* Update the display.
112 This must be called after all other LCD functions that change the display. */
113void lcd_update(void)
114{
115 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
116}
117
118/* Update a fraction of the display. */
119void lcd_update_rect(int x, int y, int width, int height)
120{
121 const fb_data *addr;
122
123 if (x + width >= LCD_WIDTH)
124 width = LCD_WIDTH - x;
125 if (y + height >= LCD_HEIGHT)
126 height = LCD_HEIGHT - y;
127
128 if ((width <= 0) || (height <= 0))
129 return; /* Nothing left to do. */
130
131 addr = &lcd_framebuffer[y][x];
132
133 lcd_send_cmd(0x01);
134 lcd_send_data(0x48);
135
136 lcd_send_cmd(0x05);
137 lcd_send_data(0x0f);
138
139 lcd_send_cmd(0x08);
140 lcd_send_data(y);
141
142 lcd_send_cmd(0x09);
143 lcd_send_data(y + height - 1);
144
145 lcd_send_cmd(0x0a);
146 lcd_send_data(x + 16);
147
148 lcd_send_cmd(0x0b);
149 lcd_send_data(x + width - 1 + 16);
150
151 lcd_send_cmd(0x06);
152 do {
153 int w = width;
154 do {
155 lcd_send_pixel(*addr++);
156 } while (--w > 0);
157 addr += LCD_WIDTH - width;
158 } while (--height > 0);
159}