From 302937e586ea44ed72e0485ef9e6732027ea9164 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 5 Jan 2012 23:00:14 +0000 Subject: Coldfire: Fix alpha bitmap drawing from messing up the emac status register. It failed to restore macsr to the expected default (FRAC/SAT) which caused DSP functions like tone control filter calculation to fail (resulting in noise). The FFT plugin was also affected. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31589 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/lcd-16bit-common.c | 13 ++++++++++++- firmware/target/coldfire/iaudio/x5/lcd-x5.c | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c index 2e5ce208b0..467d9f32a6 100644 --- a/firmware/drivers/lcd-16bit-common.c +++ b/firmware/drivers/lcd-16bit-common.c @@ -606,6 +606,7 @@ void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, int heig #define ALPHA_COLOR_PIXEL_PER_WORD (32 >> ALPHA_COLOR_FONT_DEPTH) #ifdef CPU_ARM #define BLEND_INIT do {} while (0) +#define BLEND_FINISH do {} while(0) #define BLEND_START(acc, color, alpha) \ asm volatile("mul %0, %1, %2" : "=&r" (acc) : "r" (color), "r" (alpha)) #define BLEND_CONT(acc, color, alpha) \ @@ -613,13 +614,18 @@ void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, int heig #define BLEND_OUT(acc) do {} while (0) #elif defined(CPU_COLDFIRE) #define ALPHA_BITMAP_READ_WORDS -#define BLEND_INIT coldfire_set_macsr(EMAC_UNSIGNED) +#define BLEND_INIT \ + unsigned long _macsr = coldfire_get_macsr(); \ + coldfire_set_macsr(EMAC_UNSIGNED) +#define BLEND_FINISH \ + coldfire_set_macsr(_macsr) #define BLEND_START(acc, color, alpha) \ asm volatile("mac.l %0, %1, %%acc0" :: "%d" (color), "d" (alpha)) #define BLEND_CONT BLEND_START #define BLEND_OUT(acc) asm volatile("movclr.l %%acc0, %0" : "=d" (acc)) #else #define BLEND_INIT do {} while (0) +#define BLEND_FINISH do {} while(0) #define BLEND_START(acc, color, alpha) ((acc) = (color) * (alpha)) #define BLEND_CONT(acc, color, alpha) ((acc) += (color) * (alpha)) #define BLEND_OUT(acc) do {} while (0) @@ -701,7 +707,10 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, /* nothing to draw? */ if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) + { + BLEND_FINISH; return; + } /* clip image in viewport in screen */ if (x < 0) @@ -908,6 +917,8 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, } #endif } while (--row); + + BLEND_FINISH; } /* Draw a full native bitmap */ diff --git a/firmware/target/coldfire/iaudio/x5/lcd-x5.c b/firmware/target/coldfire/iaudio/x5/lcd-x5.c index e1504b6e98..19b0725ce4 100644 --- a/firmware/target/coldfire/iaudio/x5/lcd-x5.c +++ b/firmware/target/coldfire/iaudio/x5/lcd-x5.c @@ -451,7 +451,9 @@ void lcd_blit_yuv(unsigned char * const src[3], vsrc = src[2] + (src_y * stride >> 2) + (src_x >> 1); ysrc_max = ysrc + height * stride; + unsigned long macsr = coldfire_get_macsr(); coldfire_set_macsr(EMAC_SATURATE); + do { lcd_write_reg(R_HORIZ_RAM_ADDR_POS, ((y + y_offset + 1) << 8) | (y + y_offset)); @@ -470,6 +472,8 @@ void lcd_blit_yuv(unsigned char * const src[3], vsrc += stride >> 1; } while (ysrc < ysrc_max); + + coldfire_set_macsr(macsr); } /* lcd_yuv_blit */ -- cgit v1.2.3