From 84e4b425e6237cb026a6fe71025d89fa6359a685 Mon Sep 17 00:00:00 2001 From: Leonardo Graboski Veiga Date: Wed, 31 Aug 2016 15:05:51 -0300 Subject: tegra: lcd: video: add mem alloc for bmp colour conversion map While trying to display a BMP image by running the command 'bmp display
' the Colibri T30 was getting stuck (while on iMX6, iMX7 and Vybrid it worked). After investigation on what was going wrong, I noticed that the function 'lcd_set_cmap' should get a pointer address for the cmap variable, but the function returned 00000000. After further investigation, I noticed that this value should be held in the structure.member 'panel_info.cmap', which memory was being dynamically allocated in the function 'lcd_ctrl_init' of the file 'drivers/video/sandbox_sdl.c' (which was not being called). After copying the allocation to the same function in the file 'drivers/video/tegra.c', the command 'bmp display' didn't break anymore. The Colibri T20 module was working without the patch, as the module does have valid memory at the address 0, and of course it kept working after the patch now properly allocating memory for it. Signed-off-by: Leonardo Graboski Veiga Signed-off-by: Marcel Ziswiler --- drivers/video/tegra.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/video/tegra.c b/drivers/video/tegra.c index 5a5afb9413..c1f83b578f 100644 --- a/drivers/video/tegra.c +++ b/drivers/video/tegra.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -93,6 +94,17 @@ void lcd_ctrl_init(void *lcdbase) lcd_set_flush_dcache(config.cache_type & FDT_LCD_CACHE_FLUSH); debug("LCD frame buffer at %08X\n", disp_config->frame_buffer); + + /* + * Allocate memory to keep BMP colour conversion map. This is + required for 8-bit BMPs only (hence giving 256 colours). If malloc + fails - keep going, it is not even clear if displaying the bitmap + will be required on the way up. + */ + panel_info.cmap = malloc(256 * NBITS(panel_info.vl_bpix) / 8); + if (panel_info.cmap == NULL) { + printf("No memory available for panel_info.cmap!"); + } } ulong calc_fbsize(void) -- cgit v1.2.3