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 unsigned int __screen_info_video_type(unsigned int type)
61 case VIDEO_TYPE_PICA_S3:
62 case VIDEO_TYPE_MIPS_G364:
66 case VIDEO_TYPE_SUNPCI:
76 * screen_info_video_type() - Decodes the video type from struct screen_info
77 * @si: an instance of struct screen_info
80 * A VIDEO_TYPE_ constant representing si's type of video display, or 0 otherwise.
82 static inline unsigned int screen_info_video_type(const struct screen_info *si)
86 // check if display output is on
87 if (!si->orig_video_isVGA)
90 // check for a known VIDEO_TYPE_ constant
91 type = __screen_info_video_type(si->orig_video_isVGA);
93 return si->orig_video_isVGA;
95 // check if text mode has been initialized
96 if (!si->orig_video_lines || !si->orig_video_cols)
100 if (si->orig_video_mode == 0x07) {
101 if ((si->orig_video_ega_bx & 0xff) != 0x10)
102 return VIDEO_TYPE_EGAM;
104 return VIDEO_TYPE_MDA;
107 // EGA/VGA, 16 colors
108 if ((si->orig_video_ega_bx & 0xff) != 0x10) {
109 if (si->orig_video_isVGA)
110 return VIDEO_TYPE_VGAC;
112 return VIDEO_TYPE_EGAC;
116 return VIDEO_TYPE_CGA;
119 ssize_t screen_info_resources(const struct screen_info *si, struct resource *r, size_t num);
121 #if defined(CONFIG_PCI)
122 void screen_info_apply_fixups(void);
123 struct pci_dev *screen_info_pci_dev(const struct screen_info *si);
125 static inline void screen_info_apply_fixups(void)
127 static inline struct pci_dev *screen_info_pci_dev(const struct screen_info *si)
133 extern struct screen_info screen_info;
135 #endif /* _SCREEN_INFO_H */