xref: /OK3568_Linux_fs/u-boot/common/splash.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (C) 2013, Boundary Devices <info@boundarydevices.com>
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * See file CREDITS for list of people who contributed to this
5*4882a593Smuzhiyun  * project.
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * This program is free software; you can redistribute it and/or
8*4882a593Smuzhiyun  * modify it under the terms of the GNU General Public License as
9*4882a593Smuzhiyun  * published by the Free Software Foundation; either version 2 of
10*4882a593Smuzhiyun  * the License, or (at your option) any later version.
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  * This program is distributed in the hope that it will be useful,
13*4882a593Smuzhiyun  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14*4882a593Smuzhiyun  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
15*4882a593Smuzhiyun  * GNU General Public License for more details.
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  * You should have received a copy of the GNU General Public License
18*4882a593Smuzhiyun  * along with this program; if not, write to the Free Software
19*4882a593Smuzhiyun  * Foundation, Inc., http://www.fsf.org/about/contact/
20*4882a593Smuzhiyun  *
21*4882a593Smuzhiyun  */
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun #include <common.h>
24*4882a593Smuzhiyun #include <splash.h>
25*4882a593Smuzhiyun #include <lcd.h>
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun static struct splash_location default_splash_locations[] = {
28*4882a593Smuzhiyun 	{
29*4882a593Smuzhiyun 		.name = "sf",
30*4882a593Smuzhiyun 		.storage = SPLASH_STORAGE_SF,
31*4882a593Smuzhiyun 		.flags = SPLASH_STORAGE_RAW,
32*4882a593Smuzhiyun 		.offset = 0x0,
33*4882a593Smuzhiyun 	},
34*4882a593Smuzhiyun 	{
35*4882a593Smuzhiyun 		.name = "mmc_fs",
36*4882a593Smuzhiyun 		.storage = SPLASH_STORAGE_MMC,
37*4882a593Smuzhiyun 		.flags = SPLASH_STORAGE_FS,
38*4882a593Smuzhiyun 		.devpart = "0:1",
39*4882a593Smuzhiyun 	},
40*4882a593Smuzhiyun 	{
41*4882a593Smuzhiyun 		.name = "usb_fs",
42*4882a593Smuzhiyun 		.storage = SPLASH_STORAGE_USB,
43*4882a593Smuzhiyun 		.flags = SPLASH_STORAGE_FS,
44*4882a593Smuzhiyun 		.devpart = "0:1",
45*4882a593Smuzhiyun 	},
46*4882a593Smuzhiyun 	{
47*4882a593Smuzhiyun 		.name = "sata_fs",
48*4882a593Smuzhiyun 		.storage = SPLASH_STORAGE_SATA,
49*4882a593Smuzhiyun 		.flags = SPLASH_STORAGE_FS,
50*4882a593Smuzhiyun 		.devpart = "0:1",
51*4882a593Smuzhiyun 	},
52*4882a593Smuzhiyun };
53*4882a593Smuzhiyun 
splash_screen_prepare(void)54*4882a593Smuzhiyun __weak int splash_screen_prepare(void)
55*4882a593Smuzhiyun {
56*4882a593Smuzhiyun 	return splash_source_load(default_splash_locations,
57*4882a593Smuzhiyun 				  ARRAY_SIZE(default_splash_locations));
58*4882a593Smuzhiyun }
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun #ifdef CONFIG_SPLASH_SCREEN_ALIGN
splash_get_pos(int * x,int * y)61*4882a593Smuzhiyun void splash_get_pos(int *x, int *y)
62*4882a593Smuzhiyun {
63*4882a593Smuzhiyun 	char *s = env_get("splashpos");
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun 	if (!s)
66*4882a593Smuzhiyun 		return;
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun 	if (s[0] == 'm')
69*4882a593Smuzhiyun 		*x = BMP_ALIGN_CENTER;
70*4882a593Smuzhiyun 	else
71*4882a593Smuzhiyun 		*x = simple_strtol(s, NULL, 0);
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun 	s = strchr(s + 1, ',');
74*4882a593Smuzhiyun 	if (s != NULL) {
75*4882a593Smuzhiyun 		if (s[1] == 'm')
76*4882a593Smuzhiyun 			*y = BMP_ALIGN_CENTER;
77*4882a593Smuzhiyun 		else
78*4882a593Smuzhiyun 			*y = simple_strtol(s + 1, NULL, 0);
79*4882a593Smuzhiyun 	}
80*4882a593Smuzhiyun }
81*4882a593Smuzhiyun #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun #if defined(CONFIG_SPLASH_SCREEN) && defined(CONFIG_LCD)
lcd_splash(ulong addr)84*4882a593Smuzhiyun int lcd_splash(ulong addr)
85*4882a593Smuzhiyun {
86*4882a593Smuzhiyun 	int x = 0, y = 0, ret;
87*4882a593Smuzhiyun 
88*4882a593Smuzhiyun 	ret = splash_screen_prepare();
89*4882a593Smuzhiyun 	if (ret)
90*4882a593Smuzhiyun 		return ret;
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun 	splash_get_pos(&x, &y);
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun 	return bmp_display(addr, x, y);
95*4882a593Smuzhiyun }
96*4882a593Smuzhiyun #endif
97