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