summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-04-04 19:38:46 +0000
committerJens Arnold <amiconn@rockbox.org>2008-04-04 19:38:46 +0000
commitac9b92716a11cf7699f6ce9668b1ca5cd4171cf9 (patch)
treeb327ea00d2320464d5022b63690032ec31b55f47
parent3183b9e534eba4ca07ffaa68895e63177b5d8761 (diff)
downloadrockbox-ac9b92716a11cf7699f6ce9668b1ca5cd4171cf9.tar.gz
rockbox-ac9b92716a11cf7699f6ce9668b1ca5cd4171cf9.zip
Allow to select the core for running the user timer on portalplayer targets. * Incompatible plugin API change -> sorted API.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16965 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.c4
-rw-r--r--apps/plugin.h8
-rw-r--r--apps/plugins/alpine_cdc.c4
-rw-r--r--apps/plugins/doom/i_system.c2
-rw-r--r--apps/plugins/lib/grey_core.c2
-rw-r--r--apps/plugins/metronome.c2
-rw-r--r--apps/plugins/test_scanrate.c3
-rw-r--r--apps/plugins/video.c6
-rw-r--r--firmware/backlight.c5
-rw-r--r--firmware/export/timer.h3
-rw-r--r--firmware/timer.c19
11 files changed, 36 insertions, 22 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 7c3fab1079..66e3d634df 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -144,6 +144,7 @@ static const struct plugin_api rockbox_api = {
144#if CONFIG_CHARGING 144#if CONFIG_CHARGING
145 backlight_set_timeout_plugged, 145 backlight_set_timeout_plugged,
146#endif 146#endif
147 is_backlight_on,
147 gui_syncsplash, 148 gui_syncsplash,
148 149
149#ifdef HAVE_REMOTE_LCD 150#ifdef HAVE_REMOTE_LCD
@@ -477,7 +478,7 @@ static const struct plugin_api rockbox_api = {
477# endif 478# endif
478#endif 479#endif
479#ifdef HAVE_USB_POWER 480#ifdef HAVE_USB_POWER
480 usb_powered, 481 usb_powered,
481#endif 482#endif
482 483
483 /* misc */ 484 /* misc */
@@ -576,7 +577,6 @@ static const struct plugin_api rockbox_api = {
576 /* new stuff at the end, sort into place next time 577 /* new stuff at the end, sort into place next time
577 the API gets incompatible */ 578 the API gets incompatible */
578 579
579 is_backlight_on,
580}; 580};
581 581
582int plugin_load(const char* plugin, void* parameter) 582int plugin_load(const char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index cfbd3e72af..c638688753 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -120,12 +120,12 @@
120#define PLUGIN_MAGIC 0x526F634B /* RocK */ 120#define PLUGIN_MAGIC 0x526F634B /* RocK */
121 121
122/* increase this every time the api struct changes */ 122/* increase this every time the api struct changes */
123#define PLUGIN_API_VERSION 106 123#define PLUGIN_API_VERSION 107
124 124
125/* update this to latest version if a change to the api struct breaks 125/* update this to latest version if a change to the api struct breaks
126 backwards compatibility (and please take the opportunity to sort in any 126 backwards compatibility (and please take the opportunity to sort in any
127 new function which are "waiting" at the end of the function table) */ 127 new function which are "waiting" at the end of the function table) */
128#define PLUGIN_MIN_API_VERSION 105 128#define PLUGIN_MIN_API_VERSION 107
129 129
130/* plugin return codes */ 130/* plugin return codes */
131enum plugin_status { 131enum plugin_status {
@@ -235,6 +235,7 @@ struct plugin_api {
235#if CONFIG_CHARGING 235#if CONFIG_CHARGING
236 void (*backlight_set_timeout_plugged)(int index); 236 void (*backlight_set_timeout_plugged)(int index);
237#endif 237#endif
238 bool (*is_backlight_on)(bool ignore_always_off);
238 void (*splash)(int ticks, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3); 239 void (*splash)(int ticks, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
239 240
240#ifdef HAVE_REMOTE_LCD 241#ifdef HAVE_REMOTE_LCD
@@ -394,7 +395,7 @@ struct plugin_api {
394#endif 395#endif
395 bool (*timer_register)(int reg_prio, void (*unregister_callback)(void), 396 bool (*timer_register)(int reg_prio, void (*unregister_callback)(void),
396 long cycles, int int_prio, 397 long cycles, int int_prio,
397 void (*timer_callback)(void)); 398 void (*timer_callback)(void) IF_COP(, int core));
398 void (*timer_unregister)(void); 399 void (*timer_unregister)(void);
399 bool (*timer_set_period)(long count); 400 bool (*timer_set_period)(long count);
400 401
@@ -722,7 +723,6 @@ struct plugin_api {
722 /* new stuff at the end, sort into place next time 723 /* new stuff at the end, sort into place next time
723 the API gets incompatible */ 724 the API gets incompatible */
724 725
725 bool (*is_backlight_on)(bool ignore_always_off);
726}; 726};
727 727
728/* plugin header */ 728/* plugin header */
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c
index 919ce181f6..f781509e80 100644
--- a/apps/plugins/alpine_cdc.c
+++ b/apps/plugins/alpine_cdc.c
@@ -231,11 +231,11 @@ void timer_set_mode(int mode)
231 231
232 if (mode == TM_RX_TIMEOUT) 232 if (mode == TM_RX_TIMEOUT)
233 { 233 {
234 rb->timer_register(1, NULL, gTimer.timeout, 11, timer4_isr); 234 rb->timer_register(1, NULL, gTimer.timeout, 11, timer4_isr IF_COP(, CPU));
235 } 235 }
236 else if (mode == TM_TRANSMIT) 236 else if (mode == TM_TRANSMIT)
237 { 237 {
238 rb->timer_register(1, NULL, gTimer.transmit, 14, timer4_isr); 238 rb->timer_register(1, NULL, gTimer.transmit, 14, timer4_isr IF_COP(, CPU));
239 } 239 }
240 else 240 else
241 { 241 {
diff --git a/apps/plugins/doom/i_system.c b/apps/plugins/doom/i_system.c
index 4a22743405..09a61808fd 100644
--- a/apps/plugins/doom/i_system.c
+++ b/apps/plugins/doom/i_system.c
@@ -109,7 +109,7 @@ int I_GetTime (void)
109void I_Init (void) 109void I_Init (void)
110{ 110{
111#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE) 111#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE)
112 rb->timer_register(1, NULL, TIMER_FREQ/TICRATE, 1, doomtime); 112 rb->timer_register(1, NULL, TIMER_FREQ/TICRATE, 1, doomtime IF_COP(, CPU));
113#endif 113#endif
114 I_InitSound(); 114 I_InitSound();
115} 115}
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c
index 5125d77432..20c33a60f4 100644
--- a/apps/plugins/lib/grey_core.c
+++ b/apps/plugins/lib/grey_core.c
@@ -603,7 +603,7 @@ void grey_show(bool enable)
603 _grey_info.rb->cpu_boost(true); 603 _grey_info.rb->cpu_boost(true);
604#endif 604#endif
605 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, 1, 605 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, 1,
606 _timer_isr); 606 _timer_isr IF_COP(, CPU));
607#endif /* !SIMULATOR */ 607#endif /* !SIMULATOR */
608 _grey_info.rb->screen_dump_set_hook(grey_screendump_hook); 608 _grey_info.rb->screen_dump_set_hook(grey_screendump_hook);
609 } 609 }
diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c
index 571e085b51..d05e881f4f 100644
--- a/apps/plugins/metronome.c
+++ b/apps/plugins/metronome.c
@@ -322,7 +322,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
322#endif /* CONFIG_CODEC != SWCODEC */ 322#endif /* CONFIG_CODEC != SWCODEC */
323 323
324 calc_period(); 324 calc_period();
325 rb->timer_register(1, NULL, TIMER_FREQ/1024, 1, timer_callback); 325 rb->timer_register(1, NULL, TIMER_FREQ/1024, 1, timer_callback IF_COP(, CPU));
326 326
327 draw_display(); 327 draw_display();
328 328
diff --git a/apps/plugins/test_scanrate.c b/apps/plugins/test_scanrate.c
index aabc623d9f..e88ac99a0f 100644
--- a/apps/plugins/test_scanrate.c
+++ b/apps/plugins/test_scanrate.c
@@ -150,7 +150,8 @@ int plugin_main(void)
150 rb->cpu_boost(true); 150 rb->cpu_boost(true);
151#endif 151#endif
152 /* The actual frequency is twice the displayed value */ 152 /* The actual frequency is twice the displayed value */
153 rb->timer_register(1, NULL, TIMER_FREQ * 5 / scan_rate, 1, timer_isr); 153 rb->timer_register(1, NULL, TIMER_FREQ * 5 / scan_rate, 1,
154 timer_isr IF_COP(, CPU));
154 155
155 while (!done) 156 while (!done)
156 { 157 {
diff --git a/apps/plugins/video.c b/apps/plugins/video.c
index fa1646d112..3e7e53aec8 100644
--- a/apps/plugins/video.c
+++ b/apps/plugins/video.c
@@ -540,9 +540,11 @@ int SeekTo(int fd, int nPos)
540 gPlay.bVideoUnderrun = false; 540 gPlay.bVideoUnderrun = false;
541 /* start display interrupt */ 541 /* start display interrupt */
542#if FREQ == 12000000 /* Ondio speed kludge */ 542#if FREQ == 12000000 /* Ondio speed kludge */
543 rb->timer_register(1, NULL, gPlay.nFrameTimeAdjusted, 1, timer4_isr); 543 rb->timer_register(1, NULL, gPlay.nFrameTimeAdjusted, 1,
544 timer4_isr IF_COP(, CPU));
544#else 545#else
545 rb->timer_register(1, NULL, gFileHdr.video_frametime, 1, timer4_isr); 546 rb->timer_register(1, NULL, gFileHdr.video_frametime, 1,
547 timer4_isr IF_COP(, CPU));
546#endif 548#endif
547 } 549 }
548 550
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 4126b82a2c..a09521de9a 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -289,7 +289,8 @@ static void backlight_dim(int value)
289 if (bl_timer_active) 289 if (bl_timer_active)
290 return ; 290 return ;
291 291
292 if (timer_register(0, backlight_release_timer, 2, 0, backlight_isr)) 292 if (timer_register(0, backlight_release_timer, 2, 0, backlight_isr
293 IF_COP(, CPU)))
293 { 294 {
294#ifdef _BACKLIGHT_FADE_BOOST 295#ifdef _BACKLIGHT_FADE_BOOST
295 /* Prevent cpu frequency changes while dimming. */ 296 /* Prevent cpu frequency changes while dimming. */
@@ -813,7 +814,7 @@ void remote_backlight_on(void) {}
813void remote_backlight_off(void) {} 814void remote_backlight_off(void) {}
814void remote_backlight_set_timeout(int value) {(void)value;} 815void remote_backlight_set_timeout(int value) {(void)value;}
815 816
816bool is_remote_backlight_on(bool ignore_always_off) 817bool is_remote_backlight_on(bool ignore_always_off)
817{ 818{
818 (void)ignore_always_off; 819 (void)ignore_always_off;
819 return true; 820 return true;
diff --git a/firmware/export/timer.h b/firmware/export/timer.h
index 21995ef459..08bf7b13e4 100644
--- a/firmware/export/timer.h
+++ b/firmware/export/timer.h
@@ -39,7 +39,8 @@
39 #define TIMER_FREQ CPU_FREQ 39 #define TIMER_FREQ CPU_FREQ
40#endif 40#endif
41bool timer_register(int reg_prio, void (*unregister_callback)(void), 41bool timer_register(int reg_prio, void (*unregister_callback)(void),
42 long cycles, int int_prio, void (*timer_callback)(void)); 42 long cycles, int int_prio, void (*timer_callback)(void)
43 IF_COP(,int core));
43bool timer_set_period(long cycles); 44bool timer_set_period(long cycles);
44#ifdef CPU_COLDFIRE 45#ifdef CPU_COLDFIRE
45void timers_adjust_prescale(int multiplier, bool enable_irq); 46void timers_adjust_prescale(int multiplier, bool enable_irq);
diff --git a/firmware/timer.c b/firmware/timer.c
index d15ba64443..23df271220 100644
--- a/firmware/timer.c
+++ b/firmware/timer.c
@@ -25,12 +25,12 @@
25#include "logf.h" 25#include "logf.h"
26 26
27static int timer_prio = -1; 27static int timer_prio = -1;
28void (*pfn_timer)(void) = NULL; /* timer callback */ 28void NOCACHEBSS_ATTR (*pfn_timer)(void) = NULL; /* timer callback */
29void (*pfn_unregister)(void) = NULL; /* unregister callback */ 29void NOCACHEBSS_ATTR (*pfn_unregister)(void) = NULL; /* unregister callback */
30#ifdef CPU_COLDFIRE 30#ifdef CPU_COLDFIRE
31static int base_prescale; 31static int base_prescale;
32#elif defined CPU_PP || CONFIG_CPU == PNX0101 32#elif defined CPU_PP || CONFIG_CPU == PNX0101
33static long cycles_new = 0; 33static long NOCACHEBSS_ATTR cycles_new = 0;
34#endif 34#endif
35 35
36/* interrupt handler */ 36/* interrupt handler */
@@ -201,6 +201,8 @@ static bool timer_set(long cycles, bool start)
201 pfn_unregister(); 201 pfn_unregister();
202 pfn_unregister = NULL; 202 pfn_unregister = NULL;
203 } 203 }
204 CPU_INT_CLR = TIMER2_MASK;
205 COP_INT_CLR = TIMER2_MASK;
204 } 206 }
205 if (start || (cycles_new == -1)) /* within isr, cycles_new is "locked" */ 207 if (start || (cycles_new == -1)) /* within isr, cycles_new is "locked" */
206 TIMER2_CFG = 0xc0000000 | (cycles - 1); /* enable timer */ 208 TIMER2_CFG = 0xc0000000 | (cycles - 1); /* enable timer */
@@ -236,7 +238,8 @@ void timers_adjust_prescale(int multiplier, bool enable_irq)
236 238
237/* Register a user timer, called every <cycles> TIMER_FREQ cycles */ 239/* Register a user timer, called every <cycles> TIMER_FREQ cycles */
238bool timer_register(int reg_prio, void (*unregister_callback)(void), 240bool timer_register(int reg_prio, void (*unregister_callback)(void),
239 long cycles, int int_prio, void (*timer_callback)(void)) 241 long cycles, int int_prio, void (*timer_callback)(void)
242 IF_COP(, int core))
240{ 243{
241 if (reg_prio <= timer_prio || cycles == 0) 244 if (reg_prio <= timer_prio || cycles == 0)
242 return false; 245 return false;
@@ -264,7 +267,12 @@ bool timer_register(int reg_prio, void (*unregister_callback)(void),
264 return true; 267 return true;
265#elif defined(CPU_PP) 268#elif defined(CPU_PP)
266 /* unmask interrupt source */ 269 /* unmask interrupt source */
267 CPU_INT_EN = TIMER2_MASK; 270#if NUM_CORES > 1
271 if (core == COP)
272 COP_INT_EN = TIMER2_MASK;
273 else
274#endif
275 CPU_INT_EN = TIMER2_MASK;
268 return true; 276 return true;
269#elif CONFIG_CPU == PNX0101 277#elif CONFIG_CPU == PNX0101
270 irq_set_int_handler(IRQ_TIMER1, TIMER1_ISR); 278 irq_set_int_handler(IRQ_TIMER1, TIMER1_ISR);
@@ -301,6 +309,7 @@ void timer_unregister(void)
301#elif defined(CPU_PP) 309#elif defined(CPU_PP)
302 TIMER2_CFG = 0; /* stop timer 2 */ 310 TIMER2_CFG = 0; /* stop timer 2 */
303 CPU_INT_CLR = TIMER2_MASK; 311 CPU_INT_CLR = TIMER2_MASK;
312 COP_INT_CLR = TIMER2_MASK;
304#elif CONFIG_CPU == PNX0101 313#elif CONFIG_CPU == PNX0101
305 TIMER1.ctrl &= ~0x80; /* disable timer 1 */ 314 TIMER1.ctrl &= ~0x80; /* disable timer 1 */
306 irq_disable_int(IRQ_TIMER1); 315 irq_disable_int(IRQ_TIMER1);