2 * coreboot Framebuffer driver.
4 * Copyright (C) 2011 The Chromium OS authors
6 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/sysinfo.h>
13 #include "videomodes.h"
20 static void save_vesa_mode(void)
22 struct vesa_mode_info
*vesa
= &mode_info
.vesa
;
23 struct cb_framebuffer
*fb
= lib_sysinfo
.framebuffer
;
25 vesa
->x_resolution
= fb
->x_resolution
;
26 vesa
->y_resolution
= fb
->y_resolution
;
27 vesa
->bits_per_pixel
= fb
->bits_per_pixel
;
28 vesa
->bytes_per_scanline
= fb
->bytes_per_line
;
29 vesa
->phys_base_ptr
= fb
->physical_address
;
30 vesa
->red_mask_size
= fb
->red_mask_size
;
31 vesa
->red_mask_pos
= fb
->red_mask_pos
;
32 vesa
->green_mask_size
= fb
->green_mask_size
;
33 vesa
->green_mask_pos
= fb
->green_mask_pos
;
34 vesa
->blue_mask_size
= fb
->blue_mask_size
;
35 vesa
->blue_mask_pos
= fb
->blue_mask_pos
;
36 vesa
->reserved_mask_size
= fb
->reserved_mask_size
;
37 vesa
->reserved_mask_pos
= fb
->reserved_mask_pos
;
40 static int parse_coreboot_table_fb(GraphicDevice
*gdev
)
42 struct cb_framebuffer
*fb
= lib_sysinfo
.framebuffer
;
44 /* If there is no framebuffer structure, bail out and keep
45 * running on the serial console.
50 gdev
->winSizeX
= fb
->x_resolution
;
51 gdev
->winSizeY
= fb
->y_resolution
;
53 gdev
->plnSizeX
= fb
->x_resolution
;
54 gdev
->plnSizeY
= fb
->y_resolution
;
56 gdev
->gdfBytesPP
= fb
->bits_per_pixel
/ 8;
58 switch (fb
->bits_per_pixel
) {
60 gdev
->gdfIndex
= GDF_32BIT_X888RGB
;
63 gdev
->gdfIndex
= GDF_16BIT_565RGB
;
66 gdev
->gdfIndex
= GDF__8BIT_INDEX
;
70 gdev
->isaBase
= CONFIG_SYS_ISA_IO_BASE_ADDRESS
;
71 gdev
->pciBase
= (unsigned int)fb
->physical_address
;
73 gdev
->frameAdrs
= (unsigned int)fb
->physical_address
;
74 gdev
->memSize
= fb
->bytes_per_line
* fb
->y_resolution
;
76 gdev
->vprBase
= (unsigned int)fb
->physical_address
;
77 gdev
->cprBase
= (unsigned int)fb
->physical_address
;
82 void *video_hw_init(void)
84 GraphicDevice
*gdev
= &ctfb
;
89 if (!parse_coreboot_table_fb(gdev
)) {
90 printf("No video mode configured in coreboot!\n");
94 bits_per_pixel
= gdev
->gdfBytesPP
* 8;
96 /* fill in Graphic device struct */
97 sprintf(gdev
->modeIdent
, "%dx%dx%d", gdev
->winSizeX
, gdev
->winSizeY
,
99 printf("%s\n", gdev
->modeIdent
);
101 memset((void *)gdev
->pciBase
, 0,
102 gdev
->winSizeX
* gdev
->winSizeY
* gdev
->gdfBytesPP
);
104 /* Initialize vesa_mode_info structure */