summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c')
-rw-r--r--firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c111
1 files changed, 4 insertions, 107 deletions
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c
index 308b4297c2..ad417663fe 100644
--- a/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c
+++ b/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c
@@ -30,18 +30,7 @@
30#include "lcd-target.h" 30#include "lcd-target.h"
31#include "avr-sansaconnect.h" 31#include "avr-sansaconnect.h"
32 32
33/* Copies a rectangle from one framebuffer to another. Can be used in 33extern bool lcd_on; /* lcd-memframe.c */
34 single transfer mode with width = num pixels, and height = 1 which
35 allows a full-width rectangle to be copied more efficiently. */
36extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
37 int width, int height);
38
39static bool lcd_on = true;
40
41bool lcd_active(void)
42{
43 return lcd_on;
44}
45 34
46#if defined(HAVE_LCD_SLEEP) 35#if defined(HAVE_LCD_SLEEP)
47void lcd_sleep(void) 36void lcd_sleep(void)
@@ -49,6 +38,7 @@ void lcd_sleep(void)
49 if (lcd_on) 38 if (lcd_on)
50 { 39 {
51 lcd_on = false; 40 lcd_on = false;
41
52 avr_hid_lcm_sleep(); 42 avr_hid_lcm_sleep();
53 sleep(HZ/20); 43 sleep(HZ/20);
54 44
@@ -67,6 +57,7 @@ void lcd_awake(void)
67 if (!lcd_on) 57 if (!lcd_on)
68 { 58 {
69 lcd_on = true; 59 lcd_on = true;
60
70 /* enable video encoder clock */ 61 /* enable video encoder clock */
71 bitset16(&IO_CLK_MOD1, CLK_MOD1_VENC); 62 bitset16(&IO_CLK_MOD1, CLK_MOD1_VENC);
72 63
@@ -159,56 +150,7 @@ void lcd_init_device(void)
159 /* Enable Video Encoder - RGB666, custom timing */ 150 /* Enable Video Encoder - RGB666, custom timing */
160 IO_VID_ENC_VMOD = 0x2011; 151 IO_VID_ENC_VMOD = 0x2011;
161 avr_hid_lcm_wake(); 152 avr_hid_lcm_wake();
162} 153 lcd_on = true;
163
164/* Update a fraction of the display. */
165void lcd_update_rect(int x, int y, int width, int height)
166 __attribute__ ((section(".icode")));
167void lcd_update_rect(int x, int y, int width, int height)
168{
169 register fb_data *dst, *src;
170
171 if (!lcd_on)
172 return;
173
174 if ((width | height) < 0)
175 return; /* Nothing left to do */
176
177 if (x + width > LCD_WIDTH)
178 width = LCD_WIDTH - x; /* Clip right */
179 if (x < 0)
180 width += x, x = 0; /* Clip left */
181
182 if (y + height > LCD_HEIGHT)
183 height = LCD_HEIGHT - y; /* Clip bottom */
184 if (y < 0)
185 height += y, y = 0; /* Clip top */
186
187 dst = FRAME + LCD_WIDTH*y + x;
188 src = &lcd_framebuffer[y][x];
189
190 /* Copy part of the Rockbox framebuffer to the second framebuffer */
191 if (width < LCD_WIDTH)
192 {
193 /* Not full width - do line-by-line */
194 lcd_copy_buffer_rect(dst, src, width, height);
195 }
196 else
197 {
198 /* Full width - copy as one line */
199 lcd_copy_buffer_rect(dst, src, LCD_WIDTH*height, 1);
200 }
201}
202
203/* Update the display.
204 This must be called after all other LCD functions that change the display. */
205void lcd_update(void) __attribute__ ((section(".icode")));
206void lcd_update(void)
207{
208 if (!lcd_on)
209 return;
210
211 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
212} 154}
213 155
214void lcd_set_contrast(int val) { 156void lcd_set_contrast(int val) {
@@ -225,48 +167,3 @@ void lcd_set_flip(bool yesno) {
225 (void) yesno; 167 (void) yesno;
226 // TODO: 168 // TODO:
227} 169}
228
229/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
230extern void lcd_write_yuv420_lines(fb_data *dst,
231 unsigned char chroma_buf[LCD_HEIGHT/2*3],
232 unsigned char const * const src[3],
233 int width, int stride);
234
235/* Performance function to blit a YUV bitmap directly to the LCD */
236void lcd_blit_yuv(unsigned char * const src[3],
237 int src_x, int src_y, int stride,
238 int x, int y, int width, int height)
239{
240 /* Caches for chroma data so it only need be recalculated every other
241 line */
242 unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */
243 unsigned char const * yuv_src[3];
244 off_t z;
245
246 if (!lcd_on)
247 return;
248
249 /* Sorry, but width and height must be >= 2 or else */
250 width &= ~1;
251 height >>= 1;
252
253 fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + (LCD_WIDTH - y) - 1;
254
255 z = stride*src_y;
256 yuv_src[0] = src[0] + z + src_x;
257 yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
258 yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
259
260 do
261 {
262 lcd_write_yuv420_lines(dst, chroma_buf, yuv_src, width,
263 stride);
264
265 yuv_src[0] += stride << 1; /* Skip down two luma lines */
266 yuv_src[1] += stride >> 1; /* Skip down one chroma line */
267 yuv_src[2] += stride >> 1;
268 dst -= 2;
269 }
270 while (--height > 0);
271}
272