[app/aboot]:Splash partition support for 1080 logo
Read the splash image from the splash partition and display
it on the screen.
Change-Id: I5d003406938cda26d3a6fbcdde7c617930c798f0
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 2f8aff1..79061f5 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -1880,33 +1880,123 @@
fastboot_okay("");
}
-void splash_screen ()
+static struct fbimage logo_header = {0};
+struct fbimage* splash_screen_flash();
+
+int splash_screen_check_header(struct fbimage *logo)
+{
+ if (memcmp(logo->header.magic, LOGO_IMG_MAGIC, 8))
+ return -1;
+ if (logo->header.width == 0 || logo->header.height == 0)
+ return -1;
+ return 0;
+}
+
+struct fbimage* splash_screen_flash()
{
struct ptentry *ptn;
struct ptable *ptable;
struct fbcon_config *fb_display = NULL;
+ struct fbimage *logo = &logo_header;
- if (!target_is_emmc_boot())
- {
- ptable = flash_get_ptable();
- if (ptable == NULL) {
- dprintf(CRITICAL, "ERROR: Partition table not found\n");
- return;
+
+ ptable = flash_get_ptable();
+ if (ptable == NULL) {
+ dprintf(CRITICAL, "ERROR: Partition table not found\n");
+ return NULL;
+ }
+ ptn = ptable_find(ptable, "splash");
+ if (ptn == NULL) {
+ dprintf(CRITICAL, "ERROR: splash Partition not found\n");
+ return NULL;
+ }
+
+ if (flash_read(ptn, 0,(unsigned int *) logo, sizeof(logo->header))) {
+ dprintf(CRITICAL, "ERROR: Cannot read boot image header\n");
+ return NULL;
+ }
+
+ if (splash_screen_check_header(logo)) {
+ dprintf(CRITICAL, "ERROR: Boot image header invalid\n");
+ return NULL;
+ }
+
+ fb_display = fbcon_display();
+ if (fb_display) {
+ uint8_t *base = (uint8_t *) fb_display->base;
+ if (logo->header.width != fb_display->width || logo->header.height != fb_display->height) {
+ base += LOGO_IMG_OFFSET;
}
- ptn = ptable_find(ptable, "splash");
- if (ptn == NULL) {
- dprintf(CRITICAL, "ERROR: No splash partition found\n");
- } else {
- fb_display = fbcon_display();
- if (fb_display) {
- if (flash_read(ptn, 0, fb_display->base,
- (fb_display->width * fb_display->height * fb_display->bpp/8))) {
- fbcon_clear();
- dprintf(CRITICAL, "ERROR: Cannot read splash image\n");
- }
- }
+ if (flash_read(ptn + sizeof(logo->header), 0,
+ base,
+ ((((logo->header.width * logo->header.height * fb_display->bpp/8) + 511) >> 9) << 9))) {
+ fbcon_clear();
+ dprintf(CRITICAL, "ERROR: Cannot read splash image\n");
+ return NULL;
}
+ logo->image = base;
+ }
+
+ return logo;
+}
+
+struct fbimage* splash_screen_mmc()
+{
+ int index = INVALID_PTN;
+ unsigned long long ptn = 0;
+ struct fbcon_config *fb_display = NULL;
+ struct fbimage *logo = &logo_header;
+
+ index = partition_get_index("splash");
+ if (index == 0) {
+ dprintf(CRITICAL, "ERROR: splash Partition table not found\n");
+ return NULL;
+ }
+
+ ptn = partition_get_offset(index);
+ if (ptn == 0) {
+ dprintf(CRITICAL, "ERROR: splash Partition invalid\n");
+ return NULL;
+ }
+
+ if (mmc_read(ptn, (unsigned int *) logo, sizeof(logo->header))) {
+ dprintf(CRITICAL, "ERROR: Cannot read splash image header\n");
+ return NULL;
+ }
+
+ if (splash_screen_check_header(logo)) {
+ dprintf(CRITICAL, "ERROR: Splash image header invalid\n");
+ return NULL;
+ }
+
+ fb_display = fbcon_display();
+ if (fb_display) {
+ uint8_t *base = (uint8_t *) fb_display->base;
+ if (logo->header.width != fb_display->width || logo->header.height != fb_display->height)
+ base += LOGO_IMG_OFFSET;
+
+ if (mmc_read(ptn + sizeof(logo->header),
+ base,
+ ((((logo->header.width * logo->header.height * fb_display->bpp/8) + 511) >> 9) << 9))) {
+ fbcon_clear();
+ dprintf(CRITICAL, "ERROR: Cannot read splash image\n");
+ return NULL;
+ }
+
+ logo->image = base;
+ }
+
+ return logo;
+}
+
+
+struct fbimage* fetch_image_from_partition()
+{
+ if (target_is_emmc_boot()) {
+ return splash_screen_mmc();
+ } else {
+ return splash_screen_flash();
}
}