skin engine: Relax the AA load width/height checks
[maemo-rb.git] / bootloader / meizu_m3.c
blob5ecc92f369505b780f3a2fe7ee71c7c1fa10aca7
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 by Greg White
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <stdarg.h>
25 #include <string.h>
27 #include "config.h"
29 #include "inttypes.h"
30 #include "cpu.h"
31 #include "system.h"
32 #include "lcd.h"
33 #include "kernel.h"
34 #include "thread.h"
35 #include "storage.h"
36 #include "fat.h"
37 #include "disk.h"
38 #include "font.h"
39 #include "backlight.h"
40 #include "backlight-target.h"
41 #include "button.h"
42 #include "panic.h"
43 #include "power.h"
44 #include "file.h"
45 #include "common.h"
46 #include "rbunicode.h"
47 #include "usb.h"
48 #include "qt1106.h"
49 #include "bitmaps/rockboxlogo.h"
51 #include "i2c-s5l8700.h"
52 #include "dma-target.h"
53 #include "pcm.h"
54 #include "audiohw.h"
55 #include "rtc.h"
56 #include "time.h"
58 #define LONG_DELAY 200000
59 #define SHORT_DELAY 50000
60 #define PAUSE_DELAY 50000
62 static inline void delay(int duration)
64 volatile int i;
65 for(i=0;i<duration;i++);
69 void bl_debug(bool bit)
71 if (bit)
73 PDAT0 ^= (1 << 2); //Toggle backlight
74 delay(LONG_DELAY);
75 PDAT0 ^= (1 << 2); //Toggle backlight
76 delay(LONG_DELAY);
78 else
80 PDAT0 ^= (1 << 2); //Toggle backlight
81 delay(SHORT_DELAY);
82 PDAT0 ^= (1 << 2); //Toggle backlight
83 delay(SHORT_DELAY);
87 void bl_debug_count(unsigned int input)
89 unsigned int i;
90 delay(SHORT_DELAY*3);
91 for (i = 0; i < input; i++)
93 PDAT0 ^= (1 << 2); //Toggle backlight
94 delay(SHORT_DELAY);
95 PDAT0 ^= (1 << 2); //Toggle backlight
96 delay(2*SHORT_DELAY);
99 void bl_debug_int(unsigned int input,unsigned int count)
101 unsigned int i;
102 for (i = 0; i < count; i++)
104 bl_debug(input>>i & 1);
106 delay(SHORT_DELAY*6);
109 void post_mortem_stub(void)
113 void main(void)
115 char mystring[64];
116 int i;
117 unsigned short data = 0;
118 char write_data[2], read_data[16];
119 struct tm tm;
121 //Set backlight pin to output and enable
122 int oldval = PCON0;
123 PCON0 = ((oldval & ~(3 << 4)) | (1 << 4));
124 PDAT0 |= (1 << 2);
126 // Set codec reset pin inactive
127 PCON5 = (PCON5 & ~0xF) | 1;
128 PDAT5 &= ~(1 << 0);
130 //power on
131 // oldval = PCON1;
132 // PCON1 = ((oldval & ~(0xf << 12)) | (1 << 12));
133 // PDAT1|=(1<<3);
135 //Set PLAY to EINT4
136 oldval = PCON1;
137 PCON1 = ((oldval & ~(0xf << 16)) | (2 << 16));
139 //Set MENU to EINT0
140 oldval = PCON1;
141 PCON1 = (oldval & ~(0xf)) | 2;
143 // enable external interrupts
144 EINTPOL = 0x11;
145 INTMSK = 0x11;
146 EINTMSK = 0x11;
147 asm volatile("msr cpsr_c, #0x13\n\t"); // enable interrupts
149 system_init();
150 kernel_init();
152 backlight_init();
153 lcd_init();
154 lcd_update();
156 i2c_init();
158 init_qt1106();
160 /* Calibrate the lot */
161 qt1106_io(QT1106_MODE_FREE | QT1106_MOD_INF | QT1106_DI \
162 | QT1106_SLD_SLIDER | QT1106_CAL_WHEEL | QT1106_CAL_KEYS | QT1106_RES_256);
164 lcd_clear_display();
165 lcd_bitmap(rockboxlogo, 0, 30, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo);
166 lcd_update();
168 /* Set to maximum sensitivity */
169 qt1106_io(QT1106_CT | (0x00 << 8) );
171 while(true)
173 #if 1 /* enable this to see info about the slider touchpad */
174 qt1106_wait();
176 int slider = qt1106_io(QT1106_MODE_FREE | QT1106_MOD_INF \
177 | QT1106_DI | QT1106_SLD_SLIDER | QT1106_RES_256);
178 snprintf(mystring, 64, "%x %2.2x",(slider & 0x008000)>>15, slider&0xff);
179 lcd_puts(0,1,mystring);
180 _backlight_set_brightness((slider & 0xFF) >> 4);
183 if(slider & 0x008000)
184 bl_debug_count(((slider&0xff)) + 1);
186 #endif
188 #if 1 /* enable this to see info about the RTC */
189 rtc_read_datetime(&tm);
190 snprintf(mystring, 64, "%04d-%02d-%02d %02d:%02d:%02d",
191 tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
192 tm.tm_hour, tm.tm_min, tm.tm_sec);
193 lcd_puts(0, 10, mystring);
194 #endif
196 #if 1 /* enable this so see info about the UDA1380 codec */
197 memset(read_data, 0, sizeof(read_data));
198 for (i = 0; i < 7; i++) {
199 write_data[0] = i;
200 i2c_read(0x30, i, 2, read_data);
201 data = read_data[0] << 8 | read_data[1];
202 snprintf(mystring + 4 * i, 64, "%04X", data);
204 lcd_puts(0, 11, mystring);
205 #endif
207 #if 1 /* enable this to see info about IODMA channel 0 (PCM) */
208 snprintf(mystring, 64, "DMA: %08X %08X", (int)DMACADDR0, (int)DMACTCNT0);
209 lcd_puts(0, 12, mystring);
210 #endif
211 #if 1 /* enable this to see info about IIS */
212 snprintf(mystring, 64, "IIS: %08X", (int)I2SSTATUS);
213 lcd_puts(0, 13, mystring);
214 #endif
216 lcd_update();
219 //power off
220 PDAT1&=~(1<<3);