Angel Pons | 118a9c7 | 2020-04-02 23:48:34 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Johanna Schander | db7a3ae | 2019-07-24 10:14:26 +0200 | [diff] [blame] | 3 | |
| 4 | #include <cbfs.h> |
| 5 | #include <vbe.h> |
| 6 | #include <console/console.h> |
| 7 | #include <endian.h> |
| 8 | #include <bootsplash.h> |
Patrick Rudolph | 5ebe431 | 2019-09-26 08:47:40 +0200 | [diff] [blame] | 9 | #include <stdlib.h> |
Johanna Schander | db7a3ae | 2019-07-24 10:14:26 +0200 | [diff] [blame] | 10 | |
| 11 | #include "jpeg.h" |
| 12 | |
Johanna Schander | db7a3ae | 2019-07-24 10:14:26 +0200 | [diff] [blame] | 13 | |
| 14 | void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution, |
| 15 | unsigned int y_resolution, unsigned int fb_resolution) |
| 16 | { |
Johanna Schander | 7fc006f | 2019-07-28 08:48:36 +0200 | [diff] [blame] | 17 | printk(BIOS_INFO, "Setting up bootsplash in %dx%d@%d\n", x_resolution, y_resolution, |
| 18 | fb_resolution); |
Johanna Schander | db7a3ae | 2019-07-24 10:14:26 +0200 | [diff] [blame] | 19 | struct jpeg_decdata *decdata; |
| 20 | unsigned char *jpeg = |
| 21 | cbfs_boot_map_with_leak("bootsplash.jpg", CBFS_TYPE_BOOTSPLASH, NULL); |
| 22 | if (!jpeg) { |
| 23 | printk(BIOS_ERR, "Could not find bootsplash.jpg\n"); |
| 24 | return; |
| 25 | } |
| 26 | |
Johanna Schander | 7fc006f | 2019-07-28 08:48:36 +0200 | [diff] [blame] | 27 | int image_width, image_height; |
| 28 | jpeg_fetch_size(jpeg, &image_width, &image_height); |
| 29 | |
| 30 | printk(BIOS_DEBUG, "Bootsplash image resolution: %dx%d\n", image_width, image_height); |
| 31 | |
Johanna Schander | db7a3ae | 2019-07-24 10:14:26 +0200 | [diff] [blame] | 32 | decdata = malloc(sizeof(*decdata)); |
| 33 | int ret = jpeg_decode(jpeg, framebuffer, x_resolution, y_resolution, fb_resolution, |
| 34 | decdata); |
| 35 | if (ret != 0) { |
| 36 | printk(BIOS_ERR, "Bootsplash could not be decoded. jpeg_decode returned %d.\n", |
| 37 | ret); |
| 38 | return; |
| 39 | } |
| 40 | printk(BIOS_INFO, "Bootsplash loaded\n"); |
| 41 | } |