1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <uapi/linux/screen_info.h>
7 #include <linux/bits.h>
10 * SCREEN_INFO_MAX_RESOURCES - maximum number of resources per screen_info
12 #define SCREEN_INFO_MAX_RESOURCES 3
17 static inline bool __screen_info_has_lfb(unsigned int type)
19 return (type == VIDEO_TYPE_VLFB) || (type == VIDEO_TYPE_EFI);
22 static inline u64 __screen_info_lfb_base(const struct screen_info *si)
24 u64 lfb_base = si->lfb_base;
26 if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE)
27 lfb_base |= (u64)si->ext_lfb_base << 32;
32 static inline void __screen_info_set_lfb_base(struct screen_info *si, u64 lfb_base)
34 si->lfb_base = lfb_base & GENMASK_ULL(31, 0);
35 si->ext_lfb_base = (lfb_base & GENMASK_ULL(63, 32)) >> 32;
38 si->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
40 si->capabilities &= ~VIDEO_CAPABILITY_64BIT_BASE;
43 static inline u64 __screen_info_lfb_size(const struct screen_info *si, unsigned int type)
45 u64 lfb_size = si->lfb_size;
47 if (type == VIDEO_TYPE_VLFB)
52 static inline bool __screen_info_vbe_mode_nonvga(const struct screen_info *si)
55 * VESA modes typically run on VGA hardware. Set bit 5 signals that this
56 * is not the case. Drivers can then not make use of VGA resources. See
57 * Sec 4.4 of the VBE 2.0 spec.
59 return si->vesa_attributes & BIT(5);
62 static inline unsigned int __screen_info_video_type(unsigned int type)
71 case VIDEO_TYPE_PICA_S3:
72 case VIDEO_TYPE_MIPS_G364:
76 case VIDEO_TYPE_SUNPCI:
86 * screen_info_video_type() - Decodes the video type from struct screen_info
87 * @si: an instance of struct screen_info
90 * A VIDEO_TYPE_ constant representing si's type of video display, or 0 otherwise.
92 static inline unsigned int screen_info_video_type(const struct screen_info *si)
96 // check if display output is on
97 if (!si->orig_video_isVGA)
100 // check for a known VIDEO_TYPE_ constant
101 type = __screen_info_video_type(si->orig_video_isVGA);
103 return si->orig_video_isVGA;
105 // check if text mode has been initialized
106 if (!si->orig_video_lines || !si->orig_video_cols)
110 if (si->orig_video_mode == 0x07) {
111 if ((si->orig_video_ega_bx & 0xff) != 0x10)
112 return VIDEO_TYPE_EGAM;
114 return VIDEO_TYPE_MDA;
117 // EGA/VGA, 16 colors
118 if ((si->orig_video_ega_bx & 0xff) != 0x10) {
119 if (si->orig_video_isVGA)
120 return VIDEO_TYPE_VGAC;
122 return VIDEO_TYPE_EGAC;
126 return VIDEO_TYPE_CGA;
129 ssize_t screen_info_resources(const struct screen_info *si, struct resource *r, size_t num);
131 #if defined(CONFIG_PCI)
132 void screen_info_apply_fixups(void);
133 struct pci_dev *screen_info_pci_dev(const struct screen_info *si);
135 static inline void screen_info_apply_fixups(void)
137 static inline struct pci_dev *screen_info_pci_dev(const struct screen_info *si)
143 extern struct screen_info screen_info;
145 #endif /* _SCREEN_INFO_H */