blob: 8364afa0b9bc3f96b123b5cbd7acd46b852adeb6 [file] [log] [blame]
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +02001/*
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 Rudolph5ebe4312019-09-26 08:47:40 +020021#include <stdlib.h>
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +020022
23#include "jpeg.h"
24
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +020025
26void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution,
27 unsigned int y_resolution, unsigned int fb_resolution)
28{
Johanna Schander7fc006f2019-07-28 08:48:36 +020029 printk(BIOS_INFO, "Setting up bootsplash in %dx%d@%d\n", x_resolution, y_resolution,
30 fb_resolution);
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +020031 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 Schander7fc006f2019-07-28 08:48:36 +020039 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 Schanderdb7a3ae2019-07-24 10:14:26 +020044 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}