1 /* SPDX-License-Identifier: GPL-2.0-only */
5 #include <console/console.h>
7 #include <bootsplash.h>
12 void set_bootsplash(unsigned char *framebuffer
, unsigned int x_resolution
,
13 unsigned int y_resolution
, unsigned int bytes_per_line
,
14 unsigned int fb_resolution
)
16 if ((x_resolution
> INT_MAX
) || (y_resolution
) > INT_MAX
) {
17 printk(BIOS_ERR
, "Display resolution way too large.\n");
20 int xres
= x_resolution
, yres
= y_resolution
;
21 printk(BIOS_INFO
, "Setting up bootsplash in %dx%d@%d\n", x_resolution
, y_resolution
,
24 unsigned char *jpeg
= cbfs_map("bootsplash.jpg", &filesize
);
26 printk(BIOS_ERR
, "Could not find bootsplash.jpg\n");
30 unsigned int image_width
, image_height
;
31 const char *err
= jpeg_fetch_size(jpeg
, filesize
, &image_width
, &image_height
);
33 printk(BIOS_ERR
, "Could not parse bootsplash.jpg: %s\n", err
);
37 printk(BIOS_DEBUG
, "Bootsplash image resolution: %dx%d\n", image_width
, image_height
);
39 if (image_width
> xres
|| image_height
> yres
) {
40 printk(BIOS_NOTICE
, "Bootsplash image can't fit framebuffer.\n");
46 framebuffer
+= (yres
- image_height
) / 2 * bytes_per_line
47 + (xres
- image_width
) / 2 * (fb_resolution
/ 8);
49 err
= jpeg_decode(jpeg
, filesize
, framebuffer
, image_width
, image_height
,
50 bytes_per_line
, fb_resolution
);
53 printk(BIOS_ERR
, "Could not decode bootsplash.jpg: %s\n", err
);
56 printk(BIOS_INFO
, "Bootsplash loaded\n");