Johanna Schander | db7a3ae | 2019-07-24 10:14:26 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2019 Johanna Schander <coreboot@mimoja.de> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | #include <cbfs.h> |
| 17 | #include <vbe.h> |
| 18 | #include <console/console.h> |
| 19 | #include <endian.h> |
| 20 | #include <bootsplash.h> |
Patrick Rudolph | 5ebe431 | 2019-09-26 08:47:40 +0200 | [diff] [blame] | 21 | #include <stdlib.h> |
Johanna Schander | db7a3ae | 2019-07-24 10:14:26 +0200 | [diff] [blame] | 22 | |
| 23 | #include "jpeg.h" |
| 24 | |
Johanna Schander | db7a3ae | 2019-07-24 10:14:26 +0200 | [diff] [blame] | 25 | |
| 26 | void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution, |
| 27 | unsigned int y_resolution, unsigned int fb_resolution) |
| 28 | { |
Johanna Schander | 7fc006f | 2019-07-28 08:48:36 +0200 | [diff] [blame] | 29 | printk(BIOS_INFO, "Setting up bootsplash in %dx%d@%d\n", x_resolution, y_resolution, |
| 30 | fb_resolution); |
Johanna Schander | db7a3ae | 2019-07-24 10:14:26 +0200 | [diff] [blame] | 31 | struct jpeg_decdata *decdata; |
| 32 | unsigned char *jpeg = |
| 33 | cbfs_boot_map_with_leak("bootsplash.jpg", CBFS_TYPE_BOOTSPLASH, NULL); |
| 34 | if (!jpeg) { |
| 35 | printk(BIOS_ERR, "Could not find bootsplash.jpg\n"); |
| 36 | return; |
| 37 | } |
| 38 | |
Johanna Schander | 7fc006f | 2019-07-28 08:48:36 +0200 | [diff] [blame] | 39 | int image_width, image_height; |
| 40 | jpeg_fetch_size(jpeg, &image_width, &image_height); |
| 41 | |
| 42 | printk(BIOS_DEBUG, "Bootsplash image resolution: %dx%d\n", image_width, image_height); |
| 43 | |
Johanna Schander | db7a3ae | 2019-07-24 10:14:26 +0200 | [diff] [blame] | 44 | decdata = malloc(sizeof(*decdata)); |
| 45 | int ret = jpeg_decode(jpeg, framebuffer, x_resolution, y_resolution, fb_resolution, |
| 46 | decdata); |
| 47 | if (ret != 0) { |
| 48 | printk(BIOS_ERR, "Bootsplash could not be decoded. jpeg_decode returned %d.\n", |
| 49 | ret); |
| 50 | return; |
| 51 | } |
| 52 | printk(BIOS_INFO, "Bootsplash loaded\n"); |
| 53 | } |