summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c52
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c70
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c30
3 files changed, 91 insertions, 61 deletions
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
index 5cbcd72415..331803360f 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
+++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
@@ -26,7 +26,8 @@
26#include "panic.h" 26#include "panic.h"
27#include "ata-target.h" 27#include "ata-target.h"
28 28
29void ide_power_enable(bool on){ 29void ide_power_enable(bool on)
30{
30#if 0 31#if 0
31 IO_INTC_EINT1 &= ~INTR_EINT1_EXT2; 32 IO_INTC_EINT1 &= ~INTR_EINT1_EXT2;
32 if(on) 33 if(on)
@@ -37,13 +38,16 @@ void ide_power_enable(bool on){
37 else 38 else
38 IO_GIO_BITCLR0 = (1 << 14); 39 IO_GIO_BITCLR0 = (1 << 14);
39 IO_INTC_EINT1 |= INTR_EINT1_EXT2; 40 IO_INTC_EINT1 |= INTR_EINT1_EXT2;
40 return; 41 return;
42#else
43 (void)on;
41#endif 44#endif
42} 45}
43 46
44inline bool ide_powered(){ 47inline bool ide_powered()
48{
45#if 0 49#if 0
46 return (IO_GIO_BITSET0 & (1 << 14)); 50 return (IO_GIO_BITSET0 & (1 << 14));
47#else 51#else
48 return true; 52 return true;
49#endif 53#endif
@@ -52,31 +56,31 @@ inline bool ide_powered(){
52void ata_reset(void) 56void ata_reset(void)
53{ 57{
54/* Disabled until figured out what's wrong */ 58/* Disabled until figured out what's wrong */
55 IO_INTC_EINT1 &= ~INTR_EINT1_EXT2; //disable GIO2 interrupt 59 IO_INTC_EINT1 &= ~INTR_EINT1_EXT2; /*disable GIO2 interrupt */
56 if(!ide_powered()) 60 if(!ide_powered())
57 { 61 {
58 ide_power_enable(true); 62 ide_power_enable(true);
59 sleep(150); 63 sleep(150);
60 } 64 }
61 else 65 else
62 { 66 {
63 IO_GIO_BITSET0 = (1 << 5); 67 IO_GIO_BITSET0 = (1 << 5);
64 IO_GIO_BITCLR0 = (1 << 3); 68 IO_GIO_BITCLR0 = (1 << 3);
65 sleep(1); 69 sleep(1);
66 } 70 }
67 IO_GIO_BITCLR0 = (1 << 5); 71 IO_GIO_BITCLR0 = (1 << 5);
68 sleep(10); 72 sleep(10);
69 IO_GIO_BITSET0 = (1 << 3); 73 IO_GIO_BITSET0 = (1 << 3);
70 while(!(ATA_COMMAND & STATUS_RDY)) 74 while(!(ATA_COMMAND & STATUS_RDY))
71 sleep(10); 75 sleep(10);
72 IO_INTC_EINT1 |= INTR_EINT1_EXT2; //enable GIO2 interrupt 76 IO_INTC_EINT1 |= INTR_EINT1_EXT2; //enable GIO2 interrupt
73 return; 77 return;
74} 78}
75 79
76void ata_enable(bool on) 80void ata_enable(bool on)
77{ 81{
78 (void)on; 82 (void)on;
79 return; 83 return;
80} 84}
81 85
82bool ata_is_coldstart(void) 86bool ata_is_coldstart(void)
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c
index dec20ad72f..a96f9c4f5f 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c
+++ b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c
@@ -30,7 +30,14 @@
30 30
31/* Power and display status */ 31/* Power and display status */
32static bool display_on = true; /* Is the display turned on? */ 32static bool display_on = true; /* Is the display turned on? */
33static bool direct_fb_access = false; /* Does the DM320 has direct access to the FB? */ 33static bool direct_fb_access = false; /* Does the DM320 has direct access to
34 the FB? */
35
36/* Copies a rectangle from one framebuffer to another. Can be used in
37 single transfer mode with width = num pixels, and height = 1 which
38 allows a full-width rectangle to be copied more efficiently. */
39extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
40 int width, int height);
34 41
35int lcd_default_contrast(void) 42int lcd_default_contrast(void)
36{ 43{
@@ -46,17 +53,17 @@ void lcd_set_contrast(int val)
46 53
47void lcd_set_invert_display(bool yesno) { 54void lcd_set_invert_display(bool yesno) {
48 (void) yesno; 55 (void) yesno;
49 // TODO: 56 /* TODO: */
50} 57}
51 58
52void lcd_set_flip(bool yesno) { 59void lcd_set_flip(bool yesno) {
53 (void) yesno; 60 (void) yesno;
54 // TODO: 61 /* TODO: */
55} 62}
56 63
57 64
58/* LTV250QV panel functions */ 65/* LTV250QV panel functions */
59 66#ifdef ENABLE_DISPLAY_FUNCS
60static void lcd_write_reg(unsigned char reg, unsigned short val) 67static void lcd_write_reg(unsigned char reg, unsigned short val)
61{ 68{
62 unsigned char block[3]; 69 unsigned char block[3];
@@ -88,7 +95,7 @@ static void lcd_display_on(void)
88 IO_GIO_BITSET2 = (1 << 8); 95 IO_GIO_BITSET2 = (1 << 8);
89 sleep_ms(1); 96 sleep_ms(1);
90 97
91 //Init SPI here... 98 /*Init SPI here... */
92 sleep_ms(32); 99 sleep_ms(32);
93 100
94 IO_GIO_BITSET2 = (1 << 0); 101 IO_GIO_BITSET2 = (1 << 0);
@@ -98,7 +105,7 @@ static void lcd_display_on(void)
98 IO_GIO_BITSET2 = (1 << 4); 105 IO_GIO_BITSET2 = (1 << 4);
99 sleep_ms(5); 106 sleep_ms(5);
100 IO_GIO_BITCLR2 = (1 << 8); 107 IO_GIO_BITCLR2 = (1 << 8);
101 //TODO: figure out what OF does after this... 108 /*TODO: figure out what OF does after this... */
102 IO_GIO_BITSET2 = (1 << 8); 109 IO_GIO_BITSET2 = (1 << 8);
103 sleep_ms(1); 110 sleep_ms(1);
104 111
@@ -155,7 +162,7 @@ static void lcd_display_on(void)
155 lcd_write_reg(10, 0x111A); 162 lcd_write_reg(10, 0x111A);
156 sleep_ms(10); 163 sleep_ms(10);
157 164
158 //TODO: other stuff! 165 /*TODO: other stuff! */
159 166
160 /* tell that we're on now */ 167 /* tell that we're on now */
161 display_on = true; 168 display_on = true;
@@ -193,6 +200,7 @@ static void lcd_display_off(void)
193 IO_GIO_BITCLR2 |= (1 << 3); 200 IO_GIO_BITCLR2 |= (1 << 3);
194} 201}
195 202
203#endif /* ENABLE_DISPLAY_FUNCS */
196 204
197 205
198void lcd_enable(bool on) 206void lcd_enable(bool on)
@@ -202,13 +210,13 @@ void lcd_enable(bool on)
202 210
203 if (on) 211 if (on)
204 { 212 {
205 display_on = true; //TODO: remove me! 213 display_on = true; /*TODO: remove me! */
206 //lcd_display_on(); /* Turn on display */ 214 //lcd_display_on(); /* Turn on display */
207 lcd_update(); /* Resync display */ 215 lcd_update(); /* Resync display */
208 } 216 }
209 else 217 else
210 { 218 {
211 display_on = false; //TODO: remove me! 219 display_on = false; /*TODO: remove me! */
212 //lcd_display_off(); /* Turn off display */ 220 //lcd_display_off(); /* Turn off display */
213 } 221 }
214} 222}
@@ -268,17 +276,23 @@ void lcd_init_device(void)
268 IO_OSD_OSDWIN0XL = LCD_WIDTH; 276 IO_OSD_OSDWIN0XL = LCD_WIDTH;
269 IO_OSD_OSDWIN0YL = LCD_HEIGHT; 277 IO_OSD_OSDWIN0YL = LCD_HEIGHT;
270#if 0 278#if 0
271 //TODO: set LCD clock! 279 /*TODO: set LCD clock! */
272 IO_CLK_MOD1 &= ~0x18; // disable OSD clock and VENC clock 280 IO_CLK_MOD1 &= ~0x18; /* disable OSD clock and VENC clock */
273 IO_CLK_02DIV = 3; 281 IO_CLK_02DIV = 3;
274 IO_CLK_OSEL = (IO_CLK_OSEL & ~0xF00) | 0x400; // reset 'General purpose clock output (GIO26, GIO34)' and set to 'PLLIN clock' 282
275 IO_CLK_SEL1 = (IO_CLK_SEL1 | 7) | 0x1000; // set to 'GP clock output 2 (GIO26, GIO34)' and turn on 'VENC clock' 283 /* reset 'General purpose clock output (GIO26, GIO34)' and set to 'PLLIN
276 IO_CLK_MOD1 |= 0x18; // enable OSD clock and VENC clock 284 clock' */
285 IO_CLK_OSEL = (IO_CLK_OSEL & ~0xF00) | 0x400;
286
287 /* set to 'GP clock output 2 (GIO26, GIO34)' and turn on 'VENC clock' */
288 IO_CLK_SEL1 = (IO_CLK_SEL1 | 7) | 0x1000;
289 IO_CLK_MOD1 |= 0x18; /* enable OSD clock and VENC clock */
277 290
278 /* Set LCD values in OSD */ 291 /* Set LCD values in OSD */
279 IO_VID_ENC_VMOD = ( ( (IO_VID_ENC_VMOD & 0xFFFF8C00) | 0x14) | 0x2400 ); // disable NTSC/PAL encoder & set mode to RGB666 parallel 18 bit 292 /* disable NTSC/PAL encoder & set mode to RGB666 parallel 18 bit */
293 IO_VID_ENC_VMOD = ( ( (IO_VID_ENC_VMOD & 0xFFFF8C00) | 0x14) | 0x2400 );
280 IO_VID_ENC_VDCTL = ( ( (IO_VID_ENC_VDCTL & 0xFFFFCFE8) | 0x20) | 0x4000 ); 294 IO_VID_ENC_VDCTL = ( ( (IO_VID_ENC_VDCTL & 0xFFFFCFE8) | 0x20) | 0x4000 );
281 //TODO: finish this... 295 /* TODO: finish this... */
282#endif 296#endif
283} 297}
284 298
@@ -293,21 +307,21 @@ void lcd_update_rect(int x, int y, int width, int height)
293 register fb_data *dst, *src; 307 register fb_data *dst, *src;
294 308
295 if (!display_on || direct_fb_access) 309 if (!display_on || direct_fb_access)
296 return; 310 return;
297 311
298 if (x + width > LCD_WIDTH) 312 if (x + width > LCD_WIDTH)
299 width = LCD_WIDTH - x; /* Clip right */ 313 width = LCD_WIDTH - x; /* Clip right */
300 if (x < 0) 314 if (x < 0)
301 width += x, x = 0; /* Clip left */ 315 width += x, x = 0; /* Clip left */
302 if (width <= 0) 316 if (width <= 0)
303 return; /* nothing left to do */ 317 return; /* nothing left to do */
304 318
305 if (y + height > LCD_HEIGHT) 319 if (y + height > LCD_HEIGHT)
306 height = LCD_HEIGHT - y; /* Clip bottom */ 320 height = LCD_HEIGHT - y; /* Clip bottom */
307 if (y < 0) 321 if (y < 0)
308 height += y, y = 0; /* Clip top */ 322 height += y, y = 0; /* Clip top */
309 if (height <= 0) 323 if (height <= 0)
310 return; /* nothing left to do */ 324 return; /* nothing left to do */
311 325
312#if CONFIG_ORIENTATION == SCREEN_PORTAIT 326#if CONFIG_ORIENTATION == SCREEN_PORTAIT
313 dst = (fb_data *)FRAME + LCD_WIDTH*y + x; 327 dst = (fb_data *)FRAME + LCD_WIDTH*y + x;
@@ -348,10 +362,10 @@ This must be called after all other LCD functions that change the display. */
348void lcd_update(void) 362void lcd_update(void)
349{ 363{
350 if (!display_on || direct_fb_access) 364 if (!display_on || direct_fb_access)
351 return; 365 return;
352#if CONFIG_ORIENTATION == SCREEN_PORTAIT 366#if CONFIG_ORIENTATION == SCREEN_PORTAIT
353 lcd_copy_buffer_rect((fb_data *)FRAME, &lcd_framebuffer[0][0], 367 lcd_copy_buffer_rect((fb_data *)FRAME, &lcd_framebuffer[0][0],
354 LCD_WIDTH*LCD_HEIGHT, 1); 368 LCD_WIDTH*LCD_HEIGHT, 1);
355#else 369#else
356 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); 370 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
357#endif 371#endif
@@ -367,17 +381,17 @@ int stride);
367/* For the Gigabeat - show it rotated */ 381/* For the Gigabeat - show it rotated */
368/* So the LCD_WIDTH is now the height */ 382/* So the LCD_WIDTH is now the height */
369void lcd_blit_yuv(unsigned char * const src[3], 383void lcd_blit_yuv(unsigned char * const src[3],
370int src_x, int src_y, int stride, 384 int src_x, int src_y, int stride,
371int x, int y, int width, int height) 385 int x, int y, int width, int height)
372{ 386{
373 /* Caches for chroma data so it only need be recalculated every other 387 /* Caches for chroma data so it only need be recalculated every other
374 line */ 388 line */
375 unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */ 389 unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */
376 unsigned char const * yuv_src[3]; 390 unsigned char const * yuv_src[3];
377 off_t z; 391 off_t z;
378 392
379 if (!display_on || direct_fb_access) 393 if (!display_on || direct_fb_access)
380 return; 394 return;
381 395
382 /* Sorry, but width and height must be >= 2 or else */ 396 /* Sorry, but width and height must be >= 2 or else */
383 width &= ~1; 397 width &= ~1;
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c
index 35e6bd31fb..09d3cf7c67 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c
+++ b/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c
@@ -73,7 +73,10 @@
73#define BTN_HOLD 0x9F06 73#define BTN_HOLD 0x9F06
74#define BTN_UNHOLD 0xAF06 74#define BTN_UNHOLD 0xAF06
75/* TODO: other values 75/* TODO: other values
76First number is just pressing it, second is when you release it or keep it pressed a bit longer 76
77First number is just pressing it, second is when you release it or keep it
78pressed a bit longer
79
77On/Off = 0F00 && 0F01 80On/Off = 0F00 && 0F01
78Hold = 9F06 && AF06 81Hold = 9F06 && AF06
79Volume Up = 6F00 && 6F01 82Volume Up = 6F00 && 6F01
@@ -235,10 +238,14 @@ void GIO0(void)
235#ifdef BOOTLOADER 238#ifdef BOOTLOADER
236 lcd_set_foreground((sw ? LCD_RGBPACK(255,0,0) : LCD_RGBPACK(0,255,0) )); 239 lcd_set_foreground((sw ? LCD_RGBPACK(255,0,0) : LCD_RGBPACK(0,255,0) ));
237#endif 240#endif
238 snprintf(weergvn, sizeof(char)*10, "%x", (unsigned int)((msg[3] << 24) | (msg[2] << 16) | (msg[1] << 8) | msg[0])); 241 snprintf(weergvn, sizeof(char)*10, "%x",
239 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*10, LCD_HEIGHT-SYSFONT_HEIGHT*10, weergvn); 242 (unsigned int)((msg[3] << 24) |
243 (msg[2] << 16) | (msg[1] << 8) | msg[0]));
244 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*10, LCD_HEIGHT-SYSFONT_HEIGHT*10,
245 weergvn);
240 snprintf(weergvn, sizeof(char)*10, "%x", btn); 246 snprintf(weergvn, sizeof(char)*10, "%x", btn);
241 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*10, LCD_HEIGHT-SYSFONT_HEIGHT*7, weergvn); 247 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*10, LCD_HEIGHT-SYSFONT_HEIGHT*7,
248 weergvn);
242#ifdef BOOTLOADER 249#ifdef BOOTLOADER
243 lcd_set_foreground(LCD_BLACK); 250 lcd_set_foreground(LCD_BLACK);
244#endif 251#endif
@@ -249,7 +256,8 @@ void GIO0(void)
249 IO_INTC_IRQ1 = INTR_IRQ1_EXT0; 256 IO_INTC_IRQ1 = INTR_IRQ1_EXT0;
250} 257}
251 258
252void send_command_to_pic(unsigned char in, unsigned char* out, unsigned int length) 259void send_command_to_pic(unsigned char in, unsigned char* out,
260 unsigned int length)
253{ 261{
254 /* Disable GIO0 interrupt */ 262 /* Disable GIO0 interrupt */
255 IO_INTC_EINT1 &= ~INTR_EINT1_EXT0; 263 IO_INTC_EINT1 &= ~INTR_EINT1_EXT0;
@@ -280,13 +288,17 @@ bool headphones_inserted(void)
280 288
281void button_init_device(void) 289void button_init_device(void)
282{ 290{
283 /* TODO: I suppose GIO0 has to be set to input and enable interrupts on it? */ 291 /* TODO: I suppose GIO0 has to be set to input and enable interrupts on
292 it? */
284 /* Enable GIO0 interrupt */ 293 /* Enable GIO0 interrupt */
285 IO_INTC_EINT1 |= INTR_EINT1_EXT0; 294 IO_INTC_EINT1 |= INTR_EINT1_EXT0;
286 btn = nonbtn = pic_init_value = pic_init2_value = last_btn = hold_switch = 0; 295 btn = nonbtn = pic_init_value = pic_init2_value = last_btn = hold_switch =
296 0;
287 /* Initialize PIC */ 297 /* Initialize PIC */
288 send_command_to_pic(1, &pic_init_value, sizeof(pic_init_value)); 298 send_command_to_pic(1, (unsigned char *)&pic_init_value,
289 send_command_to_pic(2, &pic_init2_value, sizeof(pic_init2_value)); 299 sizeof(pic_init_value));
300 send_command_to_pic(2, (unsigned char *)&pic_init2_value,
301 sizeof(pic_init2_value));
290} 302}
291 303
292int get_debug_info(int choice) 304int get_debug_info(int choice)