Prepare v2023.10
[platform/kernel/u-boot.git] / include / vesa.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /******************************************************************************
3  * Copyright (c) 2004, 2008 IBM Corporation
4  * Copyright (c) 2009 Pattrick Hueper <phueper@hueper.net>
5  * All rights reserved.
6  *
7  * Contributors:
8  *     IBM Corporation - initial implementation
9  *****************************************************************************/
10 #ifndef _VESA_H
11 #define _VESA_H
12
13 /* these structs are for input from and output to OF */
14 struct __packed vesa_screen_info {
15         u8 display_type;        /* 0=NONE, 1= analog, 2=digital */
16         u16 screen_width;
17         u16 screen_height;
18         /* bytes per line in framebuffer, may be more than screen_width */
19         u16 screen_linebytes;
20         u8 color_depth; /* color depth in bits per pixel */
21         u32 framebuffer_address;
22         u8 edid_block_zero[128];
23 };
24
25 struct __packed vesa_screen_info_input {
26         u8 signature[4];
27         u16 size_reserved;
28         u8 monitor_number;
29         u16 max_screen_width;
30         u8 color_depth;
31 };
32
33 /*
34  * These structs only store the required subset of fields  in Vesa BIOS
35  * Extensions
36  */
37 struct __packed vesa_bios_ext_info {
38         char signature[4];
39         u16 version;
40         u32 oem_string_ptr;
41         u32 capabilities;
42         u32 modes_ptr;
43         u16 total_memory;
44         u16 oem_version;
45         u32 vendor_name_ptr;
46         u32 product_name_ptr;
47         u32 product_rev_ptr;
48 };
49
50 struct __packed vesa_mode_info {
51         u16 mode_attributes;    /* 00 */
52         u8 win_a_attributes;    /* 02 */
53         u8 win_b_attributes;    /* 03 */
54         u16 win_granularity;    /* 04 */
55         u16 win_size;           /* 06 */
56         u16 win_a_segment;      /* 08 */
57         u16 win_b_segment;      /* 0a */
58         u32 win_func_ptr;       /* 0c */
59         u16 bytes_per_scanline; /* 10 */
60         u16 x_resolution;       /* 12 */
61         u16 y_resolution;       /* 14 */
62         u8 x_charsize;          /* 16 */
63         u8 y_charsize;          /* 17 */
64         u8 number_of_planes;    /* 18 */
65         u8 bits_per_pixel;      /* 19 */
66         u8 number_of_banks;     /* 20 */
67         u8 memory_model;        /* 21 */
68         u8 bank_size;           /* 22 */
69         u8 number_of_image_pages; /* 23 */
70         u8 reserved_page;
71         u8 red_mask_size;
72         u8 red_mask_pos;
73         u8 green_mask_size;
74         u8 green_mask_pos;
75         u8 blue_mask_size;
76         u8 blue_mask_pos;
77         u8 reserved_mask_size;
78         u8 reserved_mask_pos;
79         u8 direct_color_mode_info;
80         u32 phys_base_ptr;
81         u32 offscreen_mem_offset;
82         u16 offscreen_mem_size;
83         u8 reserved[206];
84 };
85
86 struct vesa_state {
87         u16 video_mode;
88         bool valid;
89         union {
90                 struct vesa_mode_info vesa;
91                 u8 mode_info_block[256];
92         };
93 };
94
95 struct vesa_ddc_info {
96         u8 port_number; /* i.e. monitor number */
97         u8 edid_transfer_time;
98         u8 ddc_level;
99         u8 edid_block_zero[128];
100 };
101
102 #define VESA_GET_INFO           0x4f00
103 #define VESA_GET_MODE_INFO      0x4f01
104 #define VESA_SET_MODE           0x4f02
105 #define VESA_GET_CUR_MODE       0x4f03
106
107 extern struct vesa_state mode_info;
108
109 struct video_priv;
110 struct video_uc_plat;
111
112 /**
113  * vesa_setup_video_priv() - Set up a video device using VESA information
114  *
115  * The vesa struct is used by various x86 drivers, so this is a common function
116  * to use it to set up the video.
117  *
118  * @vesa: Vesa information to use (vesa->phys_base_ptr is ignored)
119  * @fb: Frame buffer address (since vesa->phys_base_ptr is only 32 bits)
120  * @uc_priv: Video device's uclass-private information
121  * @plat: Video devices's uclass-private platform data
122  * Returns: 0 if OK, -ENXIO if the x resolution is 0, -EEPROTONOSUPPORT if the
123  * pixel format is not supported
124  */
125 int vesa_setup_video_priv(struct vesa_mode_info *vesa, u64 fb,
126                           struct video_priv *uc_priv,
127                           struct video_uc_plat *plat);
128 int vesa_setup_video(struct udevice *dev, int (*int15_handler)(void));
129
130 #endif