blob: a67d54d532df5ede11444b677fe0c2e858bb5600 [file] [log] [blame]
Angel Pons118a9c72020-04-02 23:48:34 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +02003
4#include <cbfs.h>
5#include <vbe.h>
6#include <console/console.h>
7#include <endian.h>
8#include <bootsplash.h>
Patrick Rudolph5ebe4312019-09-26 08:47:40 +02009#include <stdlib.h>
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +020010
11#include "jpeg.h"
12
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +020013
14void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution,
15 unsigned int y_resolution, unsigned int fb_resolution)
16{
Johanna Schander7fc006f2019-07-28 08:48:36 +020017 printk(BIOS_INFO, "Setting up bootsplash in %dx%d@%d\n", x_resolution, y_resolution,
18 fb_resolution);
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +020019 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 Schander7fc006f2019-07-28 08:48:36 +020027 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 Schanderdb7a3ae2019-07-24 10:14:26 +020032 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}