Skip to content
Snippets Groups Projects
lcd.c 27.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • 			bmap += (padded_width - width);
    
    			fb -= byte_width + lcd_line_length;
    
    Mark Jackson's avatar
    Mark Jackson committed
    		}
    		break;
    
    Mark Jackson's avatar
    Mark Jackson committed
    #if defined(CONFIG_BMP_16BPP)
    	case 16:
    		for (i = 0; i < height; ++i) {
    			WATCHDOG_RESET();
    
    			for (j = 0; j < width; j++)
    				fb_put_word(&fb, &bmap);
    
    
    			bmap += (padded_width - width) * 2;
    
    			fb -= width * 2 + lcd_line_length;
    
    Mark Jackson's avatar
    Mark Jackson committed
    		}
    		break;
    #endif /* CONFIG_BMP_16BPP */
    
    #if defined(CONFIG_BMP_24BMP)
    	case 24:
    		for (i = 0; i < height; ++i) {
    			for (j = 0; j < width; j++) {
    				*(fb++) = *(bmap++);
    				*(fb++) = *(bmap++);
    				*(fb++) = *(bmap++);
    				*(fb++) = 0;
    			}
    			fb -= lcd_line_length + width * (bpix / 8);
    		}
    		break;
    #endif /* CONFIG_BMP_24BMP */
    
    #if defined(CONFIG_BMP_32BPP)
    	case 32:
    		for (i = 0; i < height; ++i) {
    			for (j = 0; j < width; j++) {
    				*(fb++) = *(bmap++);
    				*(fb++) = *(bmap++);
    				*(fb++) = *(bmap++);
    				*(fb++) = *(bmap++);
    			}
    
    			fb -= lcd_line_length + width * (bpix / 8);
    
    		}
    		break;
    #endif /* CONFIG_BMP_32BPP */
    
    Mark Jackson's avatar
    Mark Jackson committed
    	default:
    		break;
    	};
    
    static void *lcd_logo(void)
    
    {
    #ifdef CONFIG_SPLASH_SCREEN
    	char *s;
    	ulong addr;
    	static int do_splash = 1;
    
    	if (do_splash && (s = getenv("splashimage")) != NULL) {
    
    		addr = simple_strtoul (s, NULL, 16);
    
    		if (bmp_display(addr, x, y) == 0)
    
    			return (void *)lcd_base;
    
    Nikita Kiryanov's avatar
    Nikita Kiryanov committed
    	lcd_set_col(LCD_INFO_X / VIDEO_FONT_WIDTH);
    	lcd_set_row(LCD_INFO_Y / VIDEO_FONT_HEIGHT);
    
    	lcd_show_board_info();
    #endif /* CONFIG_LCD_INFO */
    
    Stelian Pop's avatar
    Stelian Pop committed
    
    
    #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
    
    	return (void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length);
    
    	return (void *)lcd_base;
    
    #endif /* CONFIG_LCD_LOGO && !defined(CONFIG_LCD_INFO_BELOW_LOGO) */
    
    #ifdef CONFIG_SPLASHIMAGE_GUARD
    static int on_splashimage(const char *name, const char *value, enum env_op op,
    	int flags)
    {
    	ulong addr;
    	int aligned;
    
    	if (op == env_op_delete)
    		return 0;
    
    	addr = simple_strtoul(value, NULL, 16);
    	/* See README.displaying-bmps */
    	aligned = (addr % 4 == 2);
    	if (!aligned) {
    		printf("Invalid splashimage value. Value must be 16 bit aligned, but not 32 bit aligned\n");
    		return -1;
    	}
    
    	return 0;
    }
    
    U_BOOT_ENV_CALLBACK(splashimage, on_splashimage);
    #endif
    
    
    void lcd_position_cursor(unsigned col, unsigned row)
    {
    
    	console_curr_col = min_t(short, col, console_cols - 1);
    	console_curr_row = min_t(short, row, console_rows - 1);
    
    }
    
    int lcd_get_pixel_width(void)
    {
    	return panel_info.vl_col;
    }
    
    int lcd_get_pixel_height(void)
    {
    	return panel_info.vl_row;
    }
    
    int lcd_get_screen_rows(void)
    {
    
    	return console_rows;
    
    }
    
    int lcd_get_screen_columns(void)
    {
    
    	return console_cols;
    
    
    #if defined(CONFIG_LCD_DT_SIMPLEFB)
    static int lcd_dt_simplefb_configure_node(void *blob, int off)
    {
    #if LCD_BPP == LCD_COLOR16
    
    	return fdt_setup_simplefb_node(blob, off, gd->fb_base,
    				       panel_info.vl_col, panel_info.vl_row,
    				       panel_info.vl_col * 2, "r5g6b5");
    
    #endif
    }
    
    int lcd_dt_simplefb_add_node(void *blob)
    {
    
    	static const char compat[] = "simple-framebuffer";
    	static const char disabled[] = "disabled";
    
    	int off, ret;
    
    	off = fdt_add_subnode(blob, 0, "framebuffer");
    	if (off < 0)
    		return -1;
    
    	ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled));
    	if (ret < 0)
    		return -1;
    
    	ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat));
    	if (ret < 0)
    		return -1;
    
    	return lcd_dt_simplefb_configure_node(blob, off);
    }
    
    int lcd_dt_simplefb_enable_existing_node(void *blob)
    {
    	int off;
    
    	off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
    	if (off < 0)
    		return -1;
    
    	return lcd_dt_simplefb_configure_node(blob, off);
    }
    #endif