blob: 0eb94dc81280c51a0977881554af963a1882206b [file] [log] [blame]
Angel Pons118a9c72020-04-02 23:48:34 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +02002
3#include <cbfs.h>
4#include <vbe.h>
5#include <console/console.h>
6#include <endian.h>
7#include <bootsplash.h>
Patrick Rudolph5ebe4312019-09-26 08:47:40 +02008#include <stdlib.h>
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +02009
10#include "jpeg.h"
11
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +020012
13void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution,
14 unsigned int y_resolution, unsigned int fb_resolution)
15{
Johanna Schander7fc006f2019-07-28 08:48:36 +020016 printk(BIOS_INFO, "Setting up bootsplash in %dx%d@%d\n", x_resolution, y_resolution,
17 fb_resolution);
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +020018 struct jpeg_decdata *decdata;
Julius Werner834b3ec2020-03-04 16:52:08 -080019 unsigned char *jpeg = cbfs_map("bootsplash.jpg", NULL);
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +020020 if (!jpeg) {
21 printk(BIOS_ERR, "Could not find bootsplash.jpg\n");
22 return;
23 }
24
Johanna Schander7fc006f2019-07-28 08:48:36 +020025 int image_width, image_height;
26 jpeg_fetch_size(jpeg, &image_width, &image_height);
27
28 printk(BIOS_DEBUG, "Bootsplash image resolution: %dx%d\n", image_width, image_height);
29
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +020030 decdata = malloc(sizeof(*decdata));
31 int ret = jpeg_decode(jpeg, framebuffer, x_resolution, y_resolution, fb_resolution,
32 decdata);
Julius Werner834b3ec2020-03-04 16:52:08 -080033 cbfs_unmap(jpeg);
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +020034 if (ret != 0) {
35 printk(BIOS_ERR, "Bootsplash could not be decoded. jpeg_decode returned %d.\n",
36 ret);
37 return;
38 }
39 printk(BIOS_INFO, "Bootsplash loaded\n");
40}