]>
Commit | Line | Data |
---|---|---|
17c40ad9 SR |
1 | /* |
2 | * coreboot Framebuffer driver. | |
3 | * | |
4 | * Copyright (C) 2011 The Chromium OS authors | |
5 | * | |
1a459660 | 6 | * SPDX-License-Identifier: GPL-2.0+ |
17c40ad9 SR |
7 | */ |
8 | ||
9 | #include <common.h> | |
10 | #include <asm/arch/tables.h> | |
11 | #include <asm/arch/sysinfo.h> | |
153e1dda | 12 | #include <vbe.h> |
17c40ad9 SR |
13 | #include <video_fb.h> |
14 | #include "videomodes.h" | |
15 | ||
16 | /* | |
17 | * The Graphic Device | |
18 | */ | |
19 | GraphicDevice ctfb; | |
20 | ||
153e1dda BM |
21 | static void save_vesa_mode(void) |
22 | { | |
23 | struct vesa_mode_info *vesa = &mode_info.vesa; | |
24 | struct cb_framebuffer *fb = lib_sysinfo.framebuffer; | |
25 | ||
26 | vesa->x_resolution = fb->x_resolution; | |
27 | vesa->y_resolution = fb->y_resolution; | |
28 | vesa->bits_per_pixel = fb->bits_per_pixel; | |
29 | vesa->bytes_per_scanline = fb->bytes_per_line; | |
30 | vesa->phys_base_ptr = fb->physical_address; | |
31 | vesa->red_mask_size = fb->red_mask_size; | |
32 | vesa->red_mask_pos = fb->red_mask_pos; | |
33 | vesa->green_mask_size = fb->green_mask_size; | |
34 | vesa->green_mask_pos = fb->green_mask_pos; | |
35 | vesa->blue_mask_size = fb->blue_mask_size; | |
36 | vesa->blue_mask_pos = fb->blue_mask_pos; | |
37 | vesa->reserved_mask_size = fb->reserved_mask_size; | |
38 | vesa->reserved_mask_pos = fb->reserved_mask_pos; | |
39 | } | |
40 | ||
17c40ad9 SR |
41 | static int parse_coreboot_table_fb(GraphicDevice *gdev) |
42 | { | |
43 | struct cb_framebuffer *fb = lib_sysinfo.framebuffer; | |
44 | ||
45 | /* If there is no framebuffer structure, bail out and keep | |
46 | * running on the serial console. | |
47 | */ | |
48 | if (!fb) | |
49 | return 0; | |
50 | ||
51 | gdev->winSizeX = fb->x_resolution; | |
52 | gdev->winSizeY = fb->y_resolution; | |
53 | ||
54 | gdev->plnSizeX = fb->x_resolution; | |
55 | gdev->plnSizeY = fb->y_resolution; | |
56 | ||
57 | gdev->gdfBytesPP = fb->bits_per_pixel / 8; | |
58 | ||
59 | switch (fb->bits_per_pixel) { | |
60 | case 24: | |
61 | gdev->gdfIndex = GDF_32BIT_X888RGB; | |
62 | break; | |
63 | case 16: | |
64 | gdev->gdfIndex = GDF_16BIT_565RGB; | |
65 | break; | |
66 | default: | |
67 | gdev->gdfIndex = GDF__8BIT_INDEX; | |
68 | break; | |
69 | } | |
70 | ||
71 | gdev->isaBase = CONFIG_SYS_ISA_IO_BASE_ADDRESS; | |
72 | gdev->pciBase = (unsigned int)fb->physical_address; | |
73 | ||
74 | gdev->frameAdrs = (unsigned int)fb->physical_address; | |
75 | gdev->memSize = fb->bytes_per_line * fb->y_resolution; | |
76 | ||
77 | gdev->vprBase = (unsigned int)fb->physical_address; | |
78 | gdev->cprBase = (unsigned int)fb->physical_address; | |
79 | ||
80 | return 1; | |
81 | } | |
82 | ||
83 | void *video_hw_init(void) | |
84 | { | |
85 | GraphicDevice *gdev = &ctfb; | |
86 | int bits_per_pixel; | |
87 | ||
88 | printf("Video: "); | |
89 | ||
90 | if (!parse_coreboot_table_fb(gdev)) { | |
91 | printf("No video mode configured in coreboot!\n"); | |
92 | return NULL; | |
93 | } | |
94 | ||
95 | bits_per_pixel = gdev->gdfBytesPP * 8; | |
96 | ||
97 | /* fill in Graphic device struct */ | |
98 | sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY, | |
99 | bits_per_pixel); | |
100 | printf("%s\n", gdev->modeIdent); | |
101 | ||
102 | memset((void *)gdev->pciBase, 0, | |
103 | gdev->winSizeX * gdev->winSizeY * gdev->gdfBytesPP); | |
104 | ||
153e1dda BM |
105 | /* Initialize vesa_mode_info structure */ |
106 | save_vesa_mode(); | |
107 | ||
17c40ad9 SR |
108 | return (void *)gdev; |
109 | } |