blob: 9497ec68ae9ac2da4704986ac2a9c7f1439eecc7 [file] [log] [blame]
Stefan Reinauer216fa462011-10-12 14:25:07 -07001/******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation
3 * Copyright (c) 2009 Pattrick Hueper <phueper@hueper.net>
4 * All rights reserved.
5 * This program and the accompanying materials
6 * are made available under the terms of the BSD License
7 * which accompanies this distribution, and is available at
8 * http://www.opensource.org/licenses/bsd-license.php
9 *
10 * Contributors:
11 * IBM Corporation - initial implementation
12 *****************************************************************************/
Ronald G. Minnichb2893a012013-04-23 10:59:11 -070013#ifndef VBE_H
14#define VBE_H
Stefan Reinauer216fa462011-10-12 14:25:07 -070015
Elyes HAOUAS0edf6a52019-10-26 18:41:47 +020016#include <stdint.h>
17
Stefan Reinauer216fa462011-10-12 14:25:07 -070018// these structs are for input from and output to OF
19typedef struct {
Elyes HAOUASa0fed372016-09-16 20:17:40 +020020 u8 display_type; // 0 = NONE, 1 = analog, 2 = digital
Stefan Reinauer216fa462011-10-12 14:25:07 -070021 u16 screen_width;
22 u16 screen_height;
Lee Leahy6a566d72017-03-07 17:45:12 -080023 u16 screen_linebytes; // bytes per line in framebuffer, may be more
24 // than screen_width
Ronald G. Minnich9518b562013-09-19 16:45:22 -070025 u8 color_depth; // color depth in bits per pixel
Stefan Reinauer216fa462011-10-12 14:25:07 -070026 u32 framebuffer_address;
27 u8 edid_block_zero[128];
Stefan Reinauer6a001132017-07-13 02:20:27 +020028} __packed screen_info_t;
Stefan Reinauer216fa462011-10-12 14:25:07 -070029
30typedef struct {
31 u8 signature[4];
32 u16 size_reserved;
33 u8 monitor_number;
34 u16 max_screen_width;
35 u8 color_depth;
Stefan Reinauer6a001132017-07-13 02:20:27 +020036} __packed screen_info_input_t;
Stefan Reinauer216fa462011-10-12 14:25:07 -070037
Stefan Reinauer216fa462011-10-12 14:25:07 -070038typedef struct {
39 u16 mode_attributes; // 00
40 u8 win_a_attributes; // 02
41 u8 win_b_attributes; // 03
42 u16 win_granularity; // 04
43 u16 win_size; // 06
44 u16 win_a_segment; // 08
45 u16 win_b_segment; // 0a
46 u32 win_func_ptr; // 0c
47 u16 bytes_per_scanline; // 10
48 u16 x_resolution; // 12
49 u16 y_resolution; // 14
50 u8 x_charsize; // 16
51 u8 y_charsize; // 17
52 u8 number_of_planes; // 18
53 u8 bits_per_pixel; // 19
54 u8 number_of_banks; // 20
55 u8 memory_model; // 21
56 u8 bank_size; // 22
57 u8 number_of_image_pages; // 23
58 u8 reserved_page;
59 u8 red_mask_size;
60 u8 red_mask_pos;
61 u8 green_mask_size;
62 u8 green_mask_pos;
63 u8 blue_mask_size;
64 u8 blue_mask_pos;
65 u8 reserved_mask_size;
66 u8 reserved_mask_pos;
67 u8 direct_color_mode_info;
68 u32 phys_base_ptr;
69 u32 offscreen_mem_offset;
70 u16 offscreen_mem_size;
71 u8 reserved[206];
Stefan Reinauer6a001132017-07-13 02:20:27 +020072} __packed vesa_mode_info_t;
Stefan Reinauer216fa462011-10-12 14:25:07 -070073
74typedef struct {
75 u16 video_mode;
76 union {
77 vesa_mode_info_t vesa;
78 u8 mode_info_block[256];
79 };
80 // our crap
81 //u16 attributes;
82 //u16 linebytes;
83 //u16 x_resolution;
84 //u16 y_resolution;
85 //u8 x_charsize;
86 //u8 y_charsize;
87 //u8 bits_per_pixel;
88 //u8 memory_model;
89 //u32 framebuffer_address;
90} vbe_mode_info_t;
91
92typedef struct {
93 u8 port_number; // i.e. monitor number
94 u8 edid_transfer_time;
95 u8 ddc_level;
96 u8 edid_block_zero[128];
97} vbe_ddc_info_t;
98
Stefan Reinauerc1efb902011-10-12 14:30:59 -070099#define VESA_GET_INFO 0x4f00
100#define VESA_GET_MODE_INFO 0x4f01
101#define VESA_SET_MODE 0x4f02
Stefan Reinauer216fa462011-10-12 14:25:07 -0700102
Ronald G. Minnichb2893a012013-04-23 10:59:11 -0700103void vbe_set_graphics(void);
104void vbe_textmode_console(void);
105
Johanna Schanderdb7a3ae2019-07-24 10:14:26 +0200106/**
107 * Returns the mode_info struct from the vbe context,
108 * if initialized. NULL on invalid mode_infos.
109 */
110const vbe_mode_info_t *vbe_mode_info(void);
111
Ronald G. Minnichb2893a012013-04-23 10:59:11 -0700112#endif // VBE_H