/src/barebox/include/fb.h
Line | Count | Source |
1 | | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | | #ifndef __FB_H |
3 | | #define __FB_H |
4 | | |
5 | | #include <ioctl.h> |
6 | | #include <param.h> |
7 | | #include <driver.h> |
8 | | #include <linux/bitops.h> |
9 | | |
10 | | #define FB_VISUAL_TRUECOLOR 2 /* True color */ |
11 | | #define FB_VISUAL_PSEUDOCOLOR 3 /* Pseudo color (like atari) */ |
12 | | #define FB_VISUAL_DIRECTCOLOR 4 /* Direct color */ |
13 | | #define FB_VISUAL_STATIC_PSEUDOCOLOR 5 /* Pseudo color readonly */ |
14 | | |
15 | 0 | #define FB_SYNC_HOR_HIGH_ACT 1 /* horizontal sync high active */ |
16 | 0 | #define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */ |
17 | | #define FB_SYNC_EXT 4 /* external sync */ |
18 | | #define FB_SYNC_COMP_HIGH_ACT 8 /* composite sync high active */ |
19 | | #define FB_SYNC_BROADCAST 16 /* broadcast video timings */ |
20 | | /* vtotal = 144d/288n/576i => PAL */ |
21 | | /* vtotal = 121d/242n/484i => NTSC */ |
22 | | #define FB_SYNC_ON_GREEN 32 /* sync on green */ |
23 | | |
24 | | #define FB_VMODE_NONINTERLACED 0 /* non interlaced */ |
25 | 0 | #define FB_VMODE_INTERLACED 1 /* interlaced */ |
26 | 0 | #define FB_VMODE_DOUBLE 2 /* double scan */ |
27 | | #define FB_VMODE_ODD_FLD_FIRST 4 /* interlaced: top line first */ |
28 | | #define FB_VMODE_MASK 255 |
29 | | |
30 | | #define FB_VMODE_YWRAP 256 /* ywrap instead of panning */ |
31 | | #define FB_VMODE_SMOOTH_XPAN 512 /* smooth xpan possible (internally used) */ |
32 | | #define FB_VMODE_CONUPDATE 512 /* don't update x/yoffset */ |
33 | | |
34 | | typedef struct { |
35 | | u32 ps; |
36 | | } picoseconds_t; |
37 | | |
38 | 0 | #define PICOS2KHZ(a) (1000000000UL/(a).ps) |
39 | 0 | #define KHZ2PICOS(a) ((picoseconds_t){1000000000UL/(a)}) |
40 | | |
41 | | enum display_flags { |
42 | | DISPLAY_FLAGS_HSYNC_LOW = BIT(0), |
43 | | DISPLAY_FLAGS_HSYNC_HIGH = BIT(1), |
44 | | DISPLAY_FLAGS_VSYNC_LOW = BIT(2), |
45 | | DISPLAY_FLAGS_VSYNC_HIGH = BIT(3), |
46 | | |
47 | | /* data enable flag */ |
48 | | DISPLAY_FLAGS_DE_LOW = BIT(4), |
49 | | DISPLAY_FLAGS_DE_HIGH = BIT(5), |
50 | | /* drive data on pos. edge */ |
51 | | DISPLAY_FLAGS_PIXDATA_POSEDGE = BIT(6), |
52 | | /* drive data on neg. edge */ |
53 | | DISPLAY_FLAGS_PIXDATA_NEGEDGE = BIT(7), |
54 | | DISPLAY_FLAGS_INTERLACED = BIT(8), |
55 | | DISPLAY_FLAGS_DOUBLESCAN = BIT(9), |
56 | | DISPLAY_FLAGS_DOUBLECLK = BIT(10), |
57 | | /* drive sync on pos. edge */ |
58 | | DISPLAY_FLAGS_SYNC_POSEDGE = BIT(11), |
59 | | /* drive sync on neg. edge */ |
60 | | DISPLAY_FLAGS_SYNC_NEGEDGE = BIT(12), |
61 | | }; |
62 | | |
63 | | struct fb_videomode { |
64 | | const char *name; /* optional */ |
65 | | u32 refresh; /* optional */ |
66 | | u32 xres; |
67 | | u32 yres; |
68 | | picoseconds_t pixclock; |
69 | | u32 left_margin; |
70 | | u32 right_margin; |
71 | | u32 upper_margin; |
72 | | u32 lower_margin; |
73 | | u32 hsync_len; |
74 | | u32 vsync_len; |
75 | | u32 sync; |
76 | | u32 vmode; |
77 | | u32 display_flags; |
78 | | }; |
79 | | |
80 | | static inline ulong fb_videomode_get_pixclock_hz(const struct fb_videomode *mode) |
81 | 0 | { |
82 | 0 | return mode->pixclock.ps ? PICOS2KHZ(mode->pixclock) * 1000UL : 0; |
83 | 0 | } Unexecuted instantiation: fb.c:fb_videomode_get_pixclock_hz Unexecuted instantiation: mode-helpers.c:fb_videomode_get_pixclock_hz Unexecuted instantiation: of_display_timing.c:fb_videomode_get_pixclock_hz Unexecuted instantiation: fbconsole.c:fb_videomode_get_pixclock_hz Unexecuted instantiation: bfetch.c:fb_videomode_get_pixclock_hz Unexecuted instantiation: splash.c:fb_videomode_get_pixclock_hz Unexecuted instantiation: fbtest.c:fb_videomode_get_pixclock_hz Unexecuted instantiation: bmp.c:fb_videomode_get_pixclock_hz Unexecuted instantiation: image_renderer.c:fb_videomode_get_pixclock_hz Unexecuted instantiation: graphic_utils.c:fb_videomode_get_pixclock_hz Unexecuted instantiation: 2d-primitives.c:fb_videomode_get_pixclock_hz Unexecuted instantiation: board.c:fb_videomode_get_pixclock_hz |
84 | | |
85 | | static inline void fb_videomode_set_pixclock_hz(struct fb_videomode *mode, |
86 | | ulong rate) |
87 | 0 | { |
88 | 0 | mode->pixclock = rate ? KHZ2PICOS(rate / 1000UL) : (picoseconds_t){0}; |
89 | 0 | } Unexecuted instantiation: fb.c:fb_videomode_set_pixclock_hz Unexecuted instantiation: mode-helpers.c:fb_videomode_set_pixclock_hz Unexecuted instantiation: of_display_timing.c:fb_videomode_set_pixclock_hz Unexecuted instantiation: fbconsole.c:fb_videomode_set_pixclock_hz Unexecuted instantiation: bfetch.c:fb_videomode_set_pixclock_hz Unexecuted instantiation: splash.c:fb_videomode_set_pixclock_hz Unexecuted instantiation: fbtest.c:fb_videomode_set_pixclock_hz Unexecuted instantiation: bmp.c:fb_videomode_set_pixclock_hz Unexecuted instantiation: image_renderer.c:fb_videomode_set_pixclock_hz Unexecuted instantiation: graphic_utils.c:fb_videomode_set_pixclock_hz Unexecuted instantiation: 2d-primitives.c:fb_videomode_set_pixclock_hz Unexecuted instantiation: board.c:fb_videomode_set_pixclock_hz |
90 | | |
91 | | /* Interpretation of offset for color fields: All offsets are from the right, |
92 | | * inside a "pixel" value, which is exactly 'bits_per_pixel' wide (means: you |
93 | | * can use the offset as right argument to <<). A pixel afterwards is a bit |
94 | | * stream and is written to video memory as that unmodified. |
95 | | * |
96 | | * For pseudocolor: offset and length should be the same for all color |
97 | | * components. Offset specifies the position of the least significant bit |
98 | | * of the pallette index in a pixel value. Length indicates the number |
99 | | * of available palette entries (i.e. # of entries = 1 << length). |
100 | | */ |
101 | | struct fb_bitfield { |
102 | | u32 offset; /* beginning of bitfield */ |
103 | | u32 length; /* length of bitfield */ |
104 | | u32 msb_right; /* != 0 : Most significant bit is */ |
105 | | /* right */ |
106 | | }; |
107 | | |
108 | | struct fb_info; |
109 | | |
110 | | struct fb_rect { |
111 | | u32 x1; |
112 | | u32 y1; |
113 | | u32 x2; |
114 | | u32 y2; |
115 | | }; |
116 | | |
117 | | static inline int fb_rect_width(const struct fb_rect *r) |
118 | 0 | { |
119 | 0 | return r->x2 - r->x1; |
120 | 0 | } Unexecuted instantiation: fb.c:fb_rect_width Unexecuted instantiation: mode-helpers.c:fb_rect_width Unexecuted instantiation: of_display_timing.c:fb_rect_width Unexecuted instantiation: fbconsole.c:fb_rect_width Unexecuted instantiation: bfetch.c:fb_rect_width Unexecuted instantiation: splash.c:fb_rect_width Unexecuted instantiation: fbtest.c:fb_rect_width Unexecuted instantiation: bmp.c:fb_rect_width Unexecuted instantiation: image_renderer.c:fb_rect_width Unexecuted instantiation: graphic_utils.c:fb_rect_width Unexecuted instantiation: 2d-primitives.c:fb_rect_width Unexecuted instantiation: board.c:fb_rect_width |
121 | | |
122 | | static inline int fb_rect_height(const struct fb_rect *r) |
123 | 0 | { |
124 | 0 | return r->y2 - r->y1; |
125 | 0 | } Unexecuted instantiation: fb.c:fb_rect_height Unexecuted instantiation: mode-helpers.c:fb_rect_height Unexecuted instantiation: of_display_timing.c:fb_rect_height Unexecuted instantiation: fbconsole.c:fb_rect_height Unexecuted instantiation: bfetch.c:fb_rect_height Unexecuted instantiation: splash.c:fb_rect_height Unexecuted instantiation: fbtest.c:fb_rect_height Unexecuted instantiation: bmp.c:fb_rect_height Unexecuted instantiation: image_renderer.c:fb_rect_height Unexecuted instantiation: graphic_utils.c:fb_rect_height Unexecuted instantiation: 2d-primitives.c:fb_rect_height Unexecuted instantiation: board.c:fb_rect_height |
126 | | |
127 | | struct fb_ops { |
128 | | /* set color register */ |
129 | | int (*fb_setcolreg)(unsigned regno, unsigned red, unsigned green, |
130 | | unsigned blue, unsigned transp, struct fb_info *info); |
131 | | void (*fb_enable)(struct fb_info *info); |
132 | | void (*fb_disable)(struct fb_info *info); |
133 | | int (*fb_activate_var)(struct fb_info *info); |
134 | | void (*fb_damage)(struct fb_info *info, const struct fb_rect *rect); |
135 | | void (*fb_flush)(struct fb_info *info); |
136 | | }; |
137 | | |
138 | | /* |
139 | | * This describes all timing settings a display provides. |
140 | | * The native_mode is the default setting for this display. |
141 | | * Drivers that can handle multiple videomodes should work with this struct and |
142 | | * convert each entry to the desired end result. |
143 | | */ |
144 | | struct display_timings { |
145 | | unsigned int native_mode; |
146 | | |
147 | | unsigned int num_modes; |
148 | | struct fb_videomode *modes; |
149 | | void *edid; |
150 | | }; |
151 | | |
152 | | struct i2c_adapter; |
153 | | |
154 | | struct fb_info { |
155 | | struct fb_videomode *mode; |
156 | | struct display_timings modes; |
157 | | |
158 | | int current_mode; |
159 | | |
160 | | void *edid_data; |
161 | | struct i2c_adapter *edid_i2c_adapter; |
162 | | struct display_timings edid_modes; |
163 | | |
164 | | struct fb_ops *fbops; |
165 | | struct device dev; /* This is this fb device */ |
166 | | |
167 | | void *screen_base; |
168 | | void *screen_base_shadow; |
169 | | unsigned long screen_size; |
170 | | |
171 | | void *priv; |
172 | | |
173 | | struct cdev cdev; |
174 | | |
175 | | u32 xres; /* visible resolution */ |
176 | | u32 yres; |
177 | | u32 bits_per_pixel; /* guess what */ |
178 | | u32 line_length; /* length of a line in bytes */ |
179 | | |
180 | | u32 grayscale; /* != 0 Graylevels instead of colors */ |
181 | | |
182 | | struct fb_bitfield red; /* bitfield in fb mem if true color, */ |
183 | | struct fb_bitfield green; /* else only length is significant */ |
184 | | struct fb_bitfield blue; |
185 | | struct fb_bitfield transp; /* transparency */ |
186 | | |
187 | | int enabled; |
188 | | int p_enable; |
189 | | int register_simplefb; /* enum simplefb_mode */ |
190 | | int shadowfb; |
191 | | |
192 | | struct fb_info *base_plane; |
193 | | int n_overlays; |
194 | | }; |
195 | | |
196 | | int of_get_display_timing(const struct device_node *np, const char *name, |
197 | | struct fb_videomode *mode); |
198 | | struct display_timings *of_get_display_timings(struct device_node *np); |
199 | | void display_timings_release(struct display_timings *); |
200 | | |
201 | | int register_framebuffer(struct fb_info *info); |
202 | | |
203 | | int fb_enable(struct fb_info *info); |
204 | | int fb_disable(struct fb_info *info); |
205 | | void fb_damage(struct fb_info *info, struct fb_rect *rect); |
206 | | void fb_flush(struct fb_info *info); |
207 | | |
208 | 0 | #define FBIOGET_SCREENINFO _IOR('F', 1, loff_t) |
209 | 0 | #define FBIO_ENABLE _IO('F', 2) |
210 | 0 | #define FBIO_DISABLE _IO('F', 3) |
211 | | |
212 | | extern struct bus_type fb_bus; |
213 | | |
214 | | /* fb internal functions */ |
215 | | |
216 | | int fb_register_simplefb(struct fb_info *info); |
217 | | |
218 | | int edid_to_display_timings(struct display_timings *, unsigned char *edid); |
219 | | void *edid_read_i2c(struct i2c_adapter *adapter); |
220 | | void fb_edid_add_modes(struct fb_info *info); |
221 | | void fb_of_reserve_add_fixup(struct fb_info *info); |
222 | | |
223 | | int register_fbconsole(struct fb_info *fb); |
224 | | void *fb_get_screen_base(struct fb_info *info); |
225 | | |
226 | | extern struct class fb_class; |
227 | | |
228 | | #endif /* __FB_H */ |