summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/backlight.c12
-rw-r--r--firmware/mpeg.c32
2 files changed, 37 insertions, 7 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index e47a58adbf..db190226f0 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -24,6 +24,7 @@
24#include "i2c.h" 24#include "i2c.h"
25#include "debug.h" 25#include "debug.h"
26#include "rtc.h" 26#include "rtc.h"
27#include "usb.h"
27 28
28#define BACKLIGHT_ON 1 29#define BACKLIGHT_ON 1
29#define BACKLIGHT_OFF 2 30#define BACKLIGHT_OFF 2
@@ -55,6 +56,7 @@ void backlight_thread(void)
55#endif 56#endif
56 } 57 }
57 break; 58 break;
59
58 case BACKLIGHT_OFF: 60 case BACKLIGHT_OFF:
59#ifdef HAVE_RTC 61#ifdef HAVE_RTC
60 rtc_write(0x13, 0x00); 62 rtc_write(0x13, 0x00);
@@ -62,6 +64,16 @@ void backlight_thread(void)
62 PADR &= ~0x40; 64 PADR &= ~0x40;
63#endif 65#endif
64 break; 66 break;
67
68 case SYS_USB_CONNECTED:
69 /* Tell the USB thread that we are safe */
70 DEBUGF("backlight_thread got SYS_USB_CONNECTED\n");
71 usb_acknowledge(SYS_USB_CONNECTED_ACK);
72
73 /* Wait until the system reboots */
74 while(1)
75 yield();
76 break;
65 } 77 }
66 } 78 }
67} 79}
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index fb53585aef..815de997d5 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -25,6 +25,7 @@
25#include "debug.h" 25#include "debug.h"
26#include "kernel.h" 26#include "kernel.h"
27#include "thread.h" 27#include "thread.h"
28#include "usb.h"
28#include "panic.h" 29#include "panic.h"
29#include "file.h" 30#include "file.h"
30#include "mpeg.h" 31#include "mpeg.h"
@@ -471,6 +472,17 @@ struct mp3entry* mpeg_current_track(void)
471 return &(id3tags[0].id3); 472 return &(id3tags[0].id3);
472} 473}
473 474
475static void stop_playing(void)
476{
477 /* Stop the current stream */
478 playing = false;
479 filling = false;
480 if(mpeg_file >= 0)
481 close(mpeg_file);
482 mpeg_file = -1;
483 stop_dma();
484}
485
474static void mpeg_thread(void) 486static void mpeg_thread(void)
475{ 487{
476 struct event ev; 488 struct event ev;
@@ -526,13 +538,7 @@ static void mpeg_thread(void)
526 538
527 case MPEG_STOP: 539 case MPEG_STOP:
528 DEBUGF("MPEG_STOP\n"); 540 DEBUGF("MPEG_STOP\n");
529 /* Stop the current stream */ 541 stop_playing();
530 playing = false;
531 filling = false;
532 if(mpeg_file >= 0)
533 close(mpeg_file);
534 mpeg_file = -1;
535 stop_dma();
536 break; 542 break;
537 543
538 case MPEG_PAUSE: 544 case MPEG_PAUSE:
@@ -683,6 +689,18 @@ static void mpeg_thread(void)
683 yield(); /* To be safe */ 689 yield(); /* To be safe */
684 } 690 }
685 break; 691 break;
692
693 case SYS_USB_CONNECTED:
694 stop_playing();
695
696 /* Tell the USB thread that we are safe */
697 DEBUGF("mpeg_thread got SYS_USB_CONNECTED\n");
698 usb_acknowledge(SYS_USB_CONNECTED_ACK);
699
700 /* Wait until the system reboots */
701 while(1)
702 yield();
703 break;
686 } 704 }
687 } 705 }
688} 706}