printf: Remove unused 'bprintf'
[drm/drm-misc.git] / include / linux / screen_info.h
blob6a4a3cec4638be31d6a15379185629d1b41c1843
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _SCREEN_INFO_H
3 #define _SCREEN_INFO_H
5 #include <uapi/linux/screen_info.h>
7 #include <linux/bits.h>
9 /**
10 * SCREEN_INFO_MAX_RESOURCES - maximum number of resources per screen_info
12 #define SCREEN_INFO_MAX_RESOURCES 3
14 struct pci_dev;
15 struct resource;
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;
29 return lfb_base;
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;
37 if (si->ext_lfb_base)
38 si->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
39 else
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)
48 lfb_size <<= 16;
49 return lfb_size;
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)
64 switch (type) {
65 case VIDEO_TYPE_MDA:
66 case VIDEO_TYPE_CGA:
67 case VIDEO_TYPE_EGAM:
68 case VIDEO_TYPE_EGAC:
69 case VIDEO_TYPE_VGAC:
70 case VIDEO_TYPE_VLFB:
71 case VIDEO_TYPE_PICA_S3:
72 case VIDEO_TYPE_MIPS_G364:
73 case VIDEO_TYPE_SGI:
74 case VIDEO_TYPE_TGAC:
75 case VIDEO_TYPE_SUN:
76 case VIDEO_TYPE_SUNPCI:
77 case VIDEO_TYPE_PMAC:
78 case VIDEO_TYPE_EFI:
79 return type;
80 default:
81 return 0;
85 /**
86 * screen_info_video_type() - Decodes the video type from struct screen_info
87 * @si: an instance of struct screen_info
89 * Returns:
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)
94 unsigned int type;
96 // check if display output is on
97 if (!si->orig_video_isVGA)
98 return 0;
100 // check for a known VIDEO_TYPE_ constant
101 type = __screen_info_video_type(si->orig_video_isVGA);
102 if (type)
103 return si->orig_video_isVGA;
105 // check if text mode has been initialized
106 if (!si->orig_video_lines || !si->orig_video_cols)
107 return 0;
109 // 80x25 text, mono
110 if (si->orig_video_mode == 0x07) {
111 if ((si->orig_video_ega_bx & 0xff) != 0x10)
112 return VIDEO_TYPE_EGAM;
113 else
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;
121 else
122 return VIDEO_TYPE_EGAC;
125 // the rest...
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);
134 #else
135 static inline void screen_info_apply_fixups(void)
137 static inline struct pci_dev *screen_info_pci_dev(const struct screen_info *si)
139 return NULL;
141 #endif
143 extern struct screen_info screen_info;
145 #endif /* _SCREEN_INFO_H */