diff options
-rw-r--r-- | apps/plugins/doom/i_video.c | 2 | ||||
-rw-r--r-- | apps/plugins/lib/grey.h | 6 | ||||
-rw-r--r-- | apps/plugins/lib/grey_core.c | 21 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/stream_mgr.c | 2 | ||||
-rw-r--r-- | apps/plugins/test_fps.c | 2 | ||||
-rw-r--r-- | apps/plugins/zxbox/zxbox.c | 5 | ||||
-rw-r--r-- | firmware/target/arm/ipod/lcd-gray.c | 30 |
7 files changed, 52 insertions, 16 deletions
diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c index ce4b670583..2e98ce9f85 100644 --- a/apps/plugins/doom/i_video.c +++ b/apps/plugins/doom/i_video.c @@ -696,7 +696,7 @@ void I_InitGraphics(void) #ifndef HAVE_LCD_COLOR gbuf=malloc(GREYBUFSIZE); - grey_init(rb, gbuf, GREYBUFSIZE, 0, LCD_WIDTH, LCD_HEIGHT, NULL); + grey_init(rb, gbuf, GREYBUFSIZE, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL); /* switch on greyscale overlay */ grey_show(true); #endif diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h index 3f7be44522..95dca6beb6 100644 --- a/apps/plugins/lib/grey.h +++ b/apps/plugins/lib/grey.h @@ -45,8 +45,10 @@ #define GREY_INFO_STRUCT_IRAM struct _grey_info _grey_info IBSS_ATTR; /* Features you can request on library init (ORed together): */ -#define GREY_BUFFERED 0x0001 -#define GREY_RAWMAPPED 0x0002 +#define GREY_BUFFERED 0x0001 /* Use a chunky buffer */ +#define GREY_RAWMAPPED 0x0002 /* No gamma & LCD linearisation */ +#define GREY_ON_COP 0x0004 /* Run ISR on COP (PP targets) */ + /* TODO: only usable in conjunction with GREY_INFO_STRUCT_IRAM atm */ /* Library initialisation and release */ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c index 20c33a60f4..1326599574 100644 --- a/apps/plugins/lib/grey_core.c +++ b/apps/plugins/lib/grey_core.c @@ -495,11 +495,12 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, #endif plane_size = _GREY_MULUQ(width, height); -#ifdef CPU_COLDFIRE - plane_size += (-plane_size) & 0xf; /* All buffers should be line aligned */ +#if defined(CPU_COLDFIRE) /* Buffers should be line aligned */ \ + || defined(CPU_PP) && (NUM_CORES > 1) /* Buffers must be cache line aligned */ + plane_size += (-plane_size) & 0xf; buftaken = (-(long)gbuf) & 0xf; -#else - buftaken = (-(long)gbuf) & 3; /* All buffers must be long aligned. */ +#else /* Buffers must be 32 bit aligned. */ + buftaken = (-(long)gbuf) & 3; #endif gbuf += buftaken; @@ -509,6 +510,10 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, gbuf += plane_size; buftaken += plane_size; } +#if NUM_CORES > 1 /* Values and phases must be uncached when running on COP */ + if (features & GREY_ON_COP) + gbuf = UNCACHED_ADDR(gbuf); +#endif _grey_info.values = gbuf; gbuf += plane_size; _grey_info.phases = gbuf; @@ -602,8 +607,14 @@ void grey_show(bool enable) #ifdef NEED_BOOST _grey_info.rb->cpu_boost(true); #endif +#if NUM_CORES > 1 + _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, + 1, _timer_isr, + (_grey_info.flags & GREY_ON_COP) ? COP : CPU); +#else _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, 1, - _timer_isr IF_COP(, CPU)); + _timer_isr); +#endif #endif /* !SIMULATOR */ _grey_info.rb->screen_dump_set_hook(grey_screendump_hook); } diff --git a/apps/plugins/mpegplayer/stream_mgr.c b/apps/plugins/mpegplayer/stream_mgr.c index b962c5b993..778ed0df83 100644 --- a/apps/plugins/mpegplayer/stream_mgr.c +++ b/apps/plugins/mpegplayer/stream_mgr.c @@ -1005,7 +1005,7 @@ int stream_init(void) graymem = mem; #endif - success = grey_init(rb, graymem, memsize, GREY_BUFFERED, + success = grey_init(rb, graymem, memsize, GREY_BUFFERED|GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, &graysize); /* This can run on another processor - align size */ diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c index a312c13662..da61a4f348 100644 --- a/apps/plugins/test_fps.c +++ b/apps/plugins/test_fps.c @@ -286,7 +286,7 @@ static void time_greyscale(void) int fps, load; gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); - if (!grey_init(rb, gbuf, gbuf_size, 0, LCD_WIDTH, LCD_HEIGHT, NULL)) + if (!grey_init(rb, gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL)) { log_text("greylib: out of memory."); return; diff --git a/apps/plugins/zxbox/zxbox.c b/apps/plugins/zxbox/zxbox.c index 198aeecb37..3d94981ce5 100644 --- a/apps/plugins/zxbox/zxbox.c +++ b/apps/plugins/zxbox/zxbox.c @@ -74,9 +74,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) /* get the remainder of the plugin buffer */ gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); #ifdef USE_BUFFERED_GREY - grey_init(rb, gbuf, gbuf_size, GREY_BUFFERED, LCD_WIDTH, LCD_HEIGHT, NULL); + grey_init(rb, gbuf, gbuf_size, GREY_BUFFERED|GREY_ON_COP, LCD_WIDTH, + LCD_HEIGHT, NULL); #else - grey_init(rb, gbuf, gbuf_size, 0, LCD_WIDTH, LCD_HEIGHT, NULL); + grey_init(rb, gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL); #endif /* USE_BUFFERED_GREY */ /* switch on greyscale overlay */ grey_show(true); diff --git a/firmware/target/arm/ipod/lcd-gray.c b/firmware/target/arm/ipod/lcd-gray.c index 131b52da96..5cc219162c 100644 --- a/firmware/target/arm/ipod/lcd-gray.c +++ b/firmware/target/arm/ipod/lcd-gray.c @@ -53,6 +53,10 @@ /* The backlight makes the LCD appear negative on the 1st/2nd gen */ static bool lcd_inverted = false; static bool lcd_backlit = false; +#if NUM_CORES > 1 +/* invert_display() and the lcd_blit_* functions need to be corelocked */ +static struct corelock cl IBSS_ATTR; +#endif static void invert_display(void); #endif @@ -112,7 +116,9 @@ static void lcd_cmd_and_data(unsigned cmd, unsigned data) /* LCD init */ void lcd_init_device(void) { - +#if (NUM_CORES > 1) && defined(HAVE_BACKLIGHT_INVERSION) + corelock_init(&cl); +#endif #ifdef IPOD_MINI2G /* serial LCD hookup */ lcd_wait_write(); LCD1_CONTROL = 0x01730084; /* fastest setting */ @@ -167,7 +173,13 @@ static void invert_display(void) if (new_invert != last_invert) { int oldlevel = disable_irq_save(); +#if NUM_CORES > 1 + corelock_lock(&cl); lcd_cmd_and_data(R_DISPLAY_CONTROL, new_invert? 0x0017 : 0x0015); + corelock_unlock(&cl); +#else + lcd_cmd_and_data(R_DISPLAY_CONTROL, new_invert? 0x0017 : 0x0015); +#endif restore_irq(oldlevel); last_invert = new_invert; } @@ -254,14 +266,19 @@ void lcd_mono_data(const unsigned char *data, int count); void lcd_blit_mono(const unsigned char *data, int bx, int y, int bwidth, int height, int stride) { +#if (NUM_CORES > 1) && defined(HAVE_BACKLIGHT_INVERSION) + corelock_lock(&cl); +#endif while (height--) { lcd_cmd_and_data(R_RAM_ADDR_SET, (y++ << 5) + addr_offset - bx); lcd_prepare_cmd(R_RAM_DATA); - lcd_mono_data(data, bwidth); data += stride; } +#if (NUM_CORES > 1) && defined(HAVE_BACKLIGHT_INVERSION) + corelock_unlock(&cl); +#endif } /* Helper function for lcd_grey_phase_blit(). */ @@ -272,15 +289,20 @@ void lcd_grey_data(unsigned char *values, unsigned char *phases, int count); void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, int bx, int y, int bwidth, int height, int stride) { - while (height--) +#if (NUM_CORES > 1) && defined(HAVE_BACKLIGHT_INVERSION) + corelock_lock(&cl); +#endif + while (height--) { lcd_cmd_and_data(R_RAM_ADDR_SET, (y++ << 5) + addr_offset - bx); lcd_prepare_cmd(R_RAM_DATA); - lcd_grey_data(values, phases, bwidth); values += stride; phases += stride; } +#if (NUM_CORES > 1) && defined(HAVE_BACKLIGHT_INVERSION) + corelock_unlock(&cl); +#endif } void lcd_update_rect(int x, int y, int width, int height) |