summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorMarkus Braun <markus.braun@krawel.de>2002-10-11 08:56:23 +0000
committerMarkus Braun <markus.braun@krawel.de>2002-10-11 08:56:23 +0000
commit88098be7e3f175129a8f9aa78c82206afa063694 (patch)
tree38349fdd85b92bd486a23249a46ff7fee663f77b /firmware
parent8232306d8007326be0f547844dc01dbb0d65de35 (diff)
downloadrockbox-88098be7e3f175129a8f9aa78c82206afa063694.tar.gz
rockbox-88098be7e3f175129a8f9aa78c82206afa063694.zip
Enable status bar in usb mode.
Moved usb_display_info() to screens.c Added functions queue_wait_w_tmo() and usb_wait_for_disconnect_w_tmo(). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2574 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/kernel.c19
-rw-r--r--firmware/kernel.h2
-rw-r--r--firmware/usb.c85
-rw-r--r--firmware/usb.h2
4 files changed, 43 insertions, 65 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c
index 6da8a1b057..2b4b09f52b 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -102,6 +102,25 @@ void queue_wait(struct event_queue *q, struct event *ev)
*ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
}
+void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks)
+{
+ unsigned int timeout = current_tick + ticks;
+
+ while(q->read == q->write && TIME_BEFORE( current_tick, timeout ))
+ {
+ switch_thread();
+ }
+
+ if(q->read != q->write)
+ {
+ *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
+ }
+ else
+ {
+ ev->id = SYS_TIMEOUT;
+ }
+}
+
void queue_post(struct event_queue *q, int id, void *data)
{
int wr;
diff --git a/firmware/kernel.h b/firmware/kernel.h
index ef287e5689..0f69f43ec0 100644
--- a/firmware/kernel.h
+++ b/firmware/kernel.h
@@ -37,6 +37,7 @@
#define SYS_USB_CONNECTED_ACK -2
#define SYS_USB_DISCONNECTED -3
#define SYS_USB_DISCONNECTED_ACK -4
+#define SYS_TIMEOUT -5
struct event
{
@@ -69,6 +70,7 @@ int tick_remove_task(void (*f)(void));
extern void queue_init(struct event_queue *q);
extern void queue_wait(struct event_queue *q, struct event *ev);
+extern void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks);
extern void queue_post(struct event_queue *q, int id, void *data);
extern bool queue_empty(struct event_queue* q);
extern int queue_broadcast(int id, void *data);
diff --git a/firmware/usb.c b/firmware/usb.c
index 962e373a67..64474c7b66 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -155,7 +155,6 @@ static void usb_thread(void)
#ifdef USB_REALLY_BRAVE
usb_slave_mode(true);
usb_state = USB_INSERTED;
- usb_display_info();
#else
system_reboot();
#endif
@@ -292,6 +291,27 @@ void usb_wait_for_disconnect(struct event_queue *q)
}
}
+int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks)
+{
+ struct event ev;
+
+ /* Don't return until we get SYS_USB_DISCONNECTED or SYS_TIMEOUT */
+ while(1)
+ {
+ queue_wait_w_tmo(q, &ev, ticks);
+ switch(ev.id)
+ {
+ case SYS_USB_DISCONNECTED:
+ usb_acknowledge(SYS_USB_DISCONNECTED_ACK);
+ return 0;
+ break;
+ case SYS_TIMEOUT:
+ return 1;
+ break;
+ }
+ }
+}
+
void usb_start_monitoring(void)
{
usb_monitor_enabled = true;
@@ -319,66 +339,3 @@ void usb_start_monitoring(void)
}
#endif
-
-#ifdef HAVE_LCD_BITMAP
-#define BMPHEIGHT_usb_logo 32
-#define BMPWIDTH_usb_logo 100
-static unsigned char usb_logo[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08,
- 0x04, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x81, 0x81, 0x81,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0xf1, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0,
- 0x00, 0x00, 0xe0, 0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x81, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0,
- 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x1c,
- 0x0c, 0x0e, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f,
- 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xf8, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x82, 0x7e, 0x00, 0xc0, 0x3e, 0x01,
- 0x70, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00, 0x07, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f,
- 0x0f, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f,
- 0x1f, 0x3f, 0x7b, 0xf3, 0xe3, 0xc3, 0x83, 0x83, 0x83, 0x83, 0xe3, 0xe3, 0xe3,
- 0xe3, 0xe3, 0xe3, 0x03, 0x03, 0x03, 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x02,
- 0xc0, 0x3e, 0x01, 0xe0, 0x9f, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0xf0, 0x0f, 0x80, 0x78, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x10, 0x20, 0x40, 0x40, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 0x81, 0x87, 0x87, 0x87,
- 0x87, 0x87, 0x87, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf0,
- 0x0f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00,
-};
-
-#endif
-void usb_display_info(void)
-{
- lcd_stop_scroll();
- lcd_clear_display();
-
-#ifdef HAVE_LCD_BITMAP
- /* lcd_bitmap() only supports 16 pixels height! */
- lcd_bitmap(usb_logo, 6, 16,
- BMPWIDTH_usb_logo, 8, false);
- lcd_bitmap(usb_logo+BMPWIDTH_usb_logo, 6, 24,
- BMPWIDTH_usb_logo, 8, false);
- lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*2, 6, 32,
- BMPWIDTH_usb_logo, 8, false);
- lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*3, 6, 40,
- BMPWIDTH_usb_logo, 8, false);
- lcd_update();
-#else
- lcd_puts(0, 0, "[USB Mode]");
- lcd_icon(ICON_PARAM, false);
- lcd_icon(ICON_AUDIO, false);
- lcd_icon(ICON_USB, true);
-#endif
-}
diff --git a/firmware/usb.h b/firmware/usb.h
index 455775c1d2..089b0f23e6 100644
--- a/firmware/usb.h
+++ b/firmware/usb.h
@@ -25,7 +25,7 @@ void usb_init(void);
void usb_start_monitoring(void);
void usb_acknowledge(int id);
void usb_wait_for_disconnect(struct event_queue *q);
-void usb_display_info(void);
+int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks);
bool usb_inserted(void);
#endif