Commit a085aa1f2737baf60d322296f02c066ee3c6a53e
Committed by
Anatolij Gustschin
1 parent
889808da9b
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
dm: video: Add basic ANSI escape sequence support
Really just the subset that is needed by efi_console. Perhaps more will be added later, for example color support would be useful to implement efi_cout_set_attribute(). Signed-off-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Showing 5 changed files with 135 additions and 3 deletions Inline Diff
drivers/video/Kconfig
1 | # | 1 | # |
2 | # Video configuration | 2 | # Video configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Graphics support" | 5 | menu "Graphics support" |
6 | 6 | ||
7 | config DM_VIDEO | 7 | config DM_VIDEO |
8 | bool "Enable driver model support for LCD/video" | 8 | bool "Enable driver model support for LCD/video" |
9 | depends on DM | 9 | depends on DM |
10 | help | 10 | help |
11 | This enables driver model for LCD and video devices. These support | 11 | This enables driver model for LCD and video devices. These support |
12 | a bitmap display of various sizes and depths which can be drawn on | 12 | a bitmap display of various sizes and depths which can be drawn on |
13 | to display a command-line console or splash screen. Enabling this | 13 | to display a command-line console or splash screen. Enabling this |
14 | option compiles in the video uclass and routes all LCD/video access | 14 | option compiles in the video uclass and routes all LCD/video access |
15 | through this. | 15 | through this. |
16 | 16 | ||
17 | config BACKLIGHT_PWM | 17 | config BACKLIGHT_PWM |
18 | bool "Generic PWM based Backlight Driver" | 18 | bool "Generic PWM based Backlight Driver" |
19 | depends on DM_VIDEO && DM_PWM | 19 | depends on DM_VIDEO && DM_PWM |
20 | default y | 20 | default y |
21 | help | 21 | help |
22 | If you have a LCD backlight adjustable by PWM, say Y to enable | 22 | If you have a LCD backlight adjustable by PWM, say Y to enable |
23 | this driver. | 23 | this driver. |
24 | This driver can be use with "simple-panel" and | 24 | This driver can be use with "simple-panel" and |
25 | it understands the standard device tree | 25 | it understands the standard device tree |
26 | (leds/backlight/pwm-backlight.txt) | 26 | (leds/backlight/pwm-backlight.txt) |
27 | 27 | ||
28 | config BACKLIGHT_GPIO | 28 | config BACKLIGHT_GPIO |
29 | bool "Generic GPIO based Backlight Driver" | 29 | bool "Generic GPIO based Backlight Driver" |
30 | depends on DM_VIDEO | 30 | depends on DM_VIDEO |
31 | help | 31 | help |
32 | If you have a LCD backlight adjustable by GPIO, say Y to enable | 32 | If you have a LCD backlight adjustable by GPIO, say Y to enable |
33 | this driver. | 33 | this driver. |
34 | This driver can be used with "simple-panel" and | 34 | This driver can be used with "simple-panel" and |
35 | it understands the standard device tree | 35 | it understands the standard device tree |
36 | (leds/backlight/gpio-backlight.txt) | 36 | (leds/backlight/gpio-backlight.txt) |
37 | 37 | ||
38 | config VIDEO_BPP8 | 38 | config VIDEO_BPP8 |
39 | bool "Support 8-bit-per-pixel displays" | 39 | bool "Support 8-bit-per-pixel displays" |
40 | depends on DM_VIDEO | 40 | depends on DM_VIDEO |
41 | default y if DM_VIDEO | 41 | default y if DM_VIDEO |
42 | help | 42 | help |
43 | Support drawing text and bitmaps onto a 8-bit-per-pixel display. | 43 | Support drawing text and bitmaps onto a 8-bit-per-pixel display. |
44 | Enabling this will include code to support this display. Without | 44 | Enabling this will include code to support this display. Without |
45 | this option, such displays will not be supported and console output | 45 | this option, such displays will not be supported and console output |
46 | will be empty. | 46 | will be empty. |
47 | 47 | ||
48 | config VIDEO_BPP16 | 48 | config VIDEO_BPP16 |
49 | bool "Support 16-bit-per-pixel displays" | 49 | bool "Support 16-bit-per-pixel displays" |
50 | depends on DM_VIDEO | 50 | depends on DM_VIDEO |
51 | default y if DM_VIDEO | 51 | default y if DM_VIDEO |
52 | help | 52 | help |
53 | Support drawing text and bitmaps onto a 16-bit-per-pixel display. | 53 | Support drawing text and bitmaps onto a 16-bit-per-pixel display. |
54 | Enabling this will include code to support this display. Without | 54 | Enabling this will include code to support this display. Without |
55 | this option, such displays will not be supported and console output | 55 | this option, such displays will not be supported and console output |
56 | will be empty. | 56 | will be empty. |
57 | 57 | ||
58 | config VIDEO_BPP32 | 58 | config VIDEO_BPP32 |
59 | bool "Support 32-bit-per-pixel displays" | 59 | bool "Support 32-bit-per-pixel displays" |
60 | depends on DM_VIDEO | 60 | depends on DM_VIDEO |
61 | default y if DM_VIDEO | 61 | default y if DM_VIDEO |
62 | help | 62 | help |
63 | Support drawing text and bitmaps onto a 32-bit-per-pixel display. | 63 | Support drawing text and bitmaps onto a 32-bit-per-pixel display. |
64 | Enabling this will include code to support this display. Without | 64 | Enabling this will include code to support this display. Without |
65 | this option, such displays will not be supported and console output | 65 | this option, such displays will not be supported and console output |
66 | will be empty. | 66 | will be empty. |
67 | 67 | ||
68 | config VIDEO_ANSI | ||
69 | bool "Support ANSI escape sequences in video console" | ||
70 | depends on DM_VIDEO | ||
71 | default y if DM_VIDEO | ||
72 | help | ||
73 | Enable ANSI escape sequence decoding for a more fully functional | ||
74 | console. | ||
75 | |||
68 | config CONSOLE_NORMAL | 76 | config CONSOLE_NORMAL |
69 | bool "Support a simple text console" | 77 | bool "Support a simple text console" |
70 | depends on DM_VIDEO | 78 | depends on DM_VIDEO |
71 | default y if DM_VIDEO | 79 | default y if DM_VIDEO |
72 | help | 80 | help |
73 | Support drawing text on the frame buffer console so that it can be | 81 | Support drawing text on the frame buffer console so that it can be |
74 | used as a console. Rotation is not supported by this driver (see | 82 | used as a console. Rotation is not supported by this driver (see |
75 | CONFIG_CONSOLE_ROTATION for that). A built-in 8x16 font is used | 83 | CONFIG_CONSOLE_ROTATION for that). A built-in 8x16 font is used |
76 | for the display. | 84 | for the display. |
77 | 85 | ||
78 | config CONSOLE_ROTATION | 86 | config CONSOLE_ROTATION |
79 | bool "Support rotated displays" | 87 | bool "Support rotated displays" |
80 | depends on DM_VIDEO | 88 | depends on DM_VIDEO |
81 | help | 89 | help |
82 | Sometimes, for example if the display is mounted in portrait | 90 | Sometimes, for example if the display is mounted in portrait |
83 | mode or even if it's mounted landscape but rotated by 180degree, | 91 | mode or even if it's mounted landscape but rotated by 180degree, |
84 | we need to rotate our content of the display relative to the | 92 | we need to rotate our content of the display relative to the |
85 | framebuffer, so that user can read the messages which are | 93 | framebuffer, so that user can read the messages which are |
86 | printed out. Enable this option to include a text driver which can | 94 | printed out. Enable this option to include a text driver which can |
87 | support this. The rotation is set by the 'rot' parameter in | 95 | support this. The rotation is set by the 'rot' parameter in |
88 | struct video_priv: 0=unrotated, 1=90 degrees clockwise, 2=180 | 96 | struct video_priv: 0=unrotated, 1=90 degrees clockwise, 2=180 |
89 | degrees, 3=270 degrees. | 97 | degrees, 3=270 degrees. |
90 | 98 | ||
91 | config CONSOLE_TRUETYPE | 99 | config CONSOLE_TRUETYPE |
92 | bool "Support a console that uses TrueType fonts" | 100 | bool "Support a console that uses TrueType fonts" |
93 | depends on DM_VIDEO | 101 | depends on DM_VIDEO |
94 | help | 102 | help |
95 | TrueTrype fonts can provide outline-drawing capability rather than | 103 | TrueTrype fonts can provide outline-drawing capability rather than |
96 | needing to provide a bitmap for each font and size that is needed. | 104 | needing to provide a bitmap for each font and size that is needed. |
97 | With this option you can adjust the text size and use a variety of | 105 | With this option you can adjust the text size and use a variety of |
98 | fonts. Note that this is noticeably slower than with normal console. | 106 | fonts. Note that this is noticeably slower than with normal console. |
99 | 107 | ||
100 | config CONSOLE_TRUETYPE_SIZE | 108 | config CONSOLE_TRUETYPE_SIZE |
101 | int "TrueType font size" | 109 | int "TrueType font size" |
102 | depends on CONSOLE_TRUETYPE | 110 | depends on CONSOLE_TRUETYPE |
103 | default 18 | 111 | default 18 |
104 | help | 112 | help |
105 | This sets the font size for the console. The size is measured in | 113 | This sets the font size for the console. The size is measured in |
106 | pixels and is the nominal height of a character. Note that fonts | 114 | pixels and is the nominal height of a character. Note that fonts |
107 | are commonly measured in 'points', being 1/72 inch (about 3.52mm). | 115 | are commonly measured in 'points', being 1/72 inch (about 3.52mm). |
108 | However that measurement depends on the size of your display and | 116 | However that measurement depends on the size of your display and |
109 | there is no standard display density. At present there is not a | 117 | there is no standard display density. At present there is not a |
110 | method to select the display's physical size, which would allow | 118 | method to select the display's physical size, which would allow |
111 | U-Boot to calculate the correct font size. | 119 | U-Boot to calculate the correct font size. |
112 | 120 | ||
113 | config SYS_WHITE_ON_BLACK | 121 | config SYS_WHITE_ON_BLACK |
114 | bool "Display console as white on a black background" | 122 | bool "Display console as white on a black background" |
115 | default y if ARCH_AT91 || ARCH_EXYNOS || ARCH_ROCKCHIP || TEGRA || X86 | 123 | default y if ARCH_AT91 || ARCH_EXYNOS || ARCH_ROCKCHIP || TEGRA || X86 |
116 | help | 124 | help |
117 | Normally the display is black on a white background, Enable this | 125 | Normally the display is black on a white background, Enable this |
118 | option to invert this, i.e. white on a black background. This can be | 126 | option to invert this, i.e. white on a black background. This can be |
119 | better in low-light situations or to reduce eye strain in some | 127 | better in low-light situations or to reduce eye strain in some |
120 | cases. | 128 | cases. |
121 | 129 | ||
122 | config NO_FB_CLEAR | 130 | config NO_FB_CLEAR |
123 | bool "Skip framebuffer clear" | 131 | bool "Skip framebuffer clear" |
124 | help | 132 | help |
125 | If firmware (whatever loads u-boot) has already put a splash image | 133 | If firmware (whatever loads u-boot) has already put a splash image |
126 | on screen, you might want to preserve it until whatever u-boot | 134 | on screen, you might want to preserve it until whatever u-boot |
127 | loads takes over the screen. This, for example, can be used to | 135 | loads takes over the screen. This, for example, can be used to |
128 | keep splash image on screen until grub graphical boot menu starts. | 136 | keep splash image on screen until grub graphical boot menu starts. |
129 | 137 | ||
130 | source "drivers/video/fonts/Kconfig" | 138 | source "drivers/video/fonts/Kconfig" |
131 | 139 | ||
132 | config VIDCONSOLE_AS_LCD | 140 | config VIDCONSOLE_AS_LCD |
133 | bool "Use 'vidconsole' when 'lcd' is seen in stdout" | 141 | bool "Use 'vidconsole' when 'lcd' is seen in stdout" |
134 | depends on DM_VIDEO | 142 | depends on DM_VIDEO |
135 | help | 143 | help |
136 | This is a work-around for boards which have 'lcd' in their stdout | 144 | This is a work-around for boards which have 'lcd' in their stdout |
137 | environment variable, but have moved to use driver model for video. | 145 | environment variable, but have moved to use driver model for video. |
138 | In this case the console will no-longer work. While it is possible | 146 | In this case the console will no-longer work. While it is possible |
139 | to update the environment, the breakage may be confusing for users. | 147 | to update the environment, the breakage may be confusing for users. |
140 | This option will be removed around the end of 2016. | 148 | This option will be removed around the end of 2016. |
141 | 149 | ||
142 | config VIDEO_COREBOOT | 150 | config VIDEO_COREBOOT |
143 | bool "Enable coreboot framebuffer driver support" | 151 | bool "Enable coreboot framebuffer driver support" |
144 | depends on X86 && SYS_COREBOOT | 152 | depends on X86 && SYS_COREBOOT |
145 | help | 153 | help |
146 | Turn on this option to enable a framebuffer driver when U-Boot is | 154 | Turn on this option to enable a framebuffer driver when U-Boot is |
147 | loaded by coreboot where the graphics device is configured by | 155 | loaded by coreboot where the graphics device is configured by |
148 | coreboot already. This can in principle be used with any platform | 156 | coreboot already. This can in principle be used with any platform |
149 | that coreboot supports. | 157 | that coreboot supports. |
150 | 158 | ||
151 | config VIDEO_VESA | 159 | config VIDEO_VESA |
152 | bool "Enable VESA video driver support" | 160 | bool "Enable VESA video driver support" |
153 | default n | 161 | default n |
154 | help | 162 | help |
155 | Turn on this option to enable a very simple driver which uses vesa | 163 | Turn on this option to enable a very simple driver which uses vesa |
156 | to discover the video mode and then provides a frame buffer for use | 164 | to discover the video mode and then provides a frame buffer for use |
157 | by U-Boot. This can in principle be used with any platform that | 165 | by U-Boot. This can in principle be used with any platform that |
158 | supports PCI and video cards that support VESA BIOS Extension (VBE). | 166 | supports PCI and video cards that support VESA BIOS Extension (VBE). |
159 | 167 | ||
160 | config FRAMEBUFFER_SET_VESA_MODE | 168 | config FRAMEBUFFER_SET_VESA_MODE |
161 | bool "Set framebuffer graphics resolution" | 169 | bool "Set framebuffer graphics resolution" |
162 | depends on VIDEO_VESA || VIDEO_BROADWELL_IGD | 170 | depends on VIDEO_VESA || VIDEO_BROADWELL_IGD |
163 | help | 171 | help |
164 | Set VESA/native framebuffer mode (needed for bootsplash and graphical | 172 | Set VESA/native framebuffer mode (needed for bootsplash and graphical |
165 | framebuffer console) | 173 | framebuffer console) |
166 | 174 | ||
167 | choice | 175 | choice |
168 | prompt "framebuffer graphics resolution" | 176 | prompt "framebuffer graphics resolution" |
169 | default FRAMEBUFFER_VESA_MODE_117 | 177 | default FRAMEBUFFER_VESA_MODE_117 |
170 | depends on FRAMEBUFFER_SET_VESA_MODE | 178 | depends on FRAMEBUFFER_SET_VESA_MODE |
171 | help | 179 | help |
172 | This option sets the resolution used for the U-Boot framebuffer (and | 180 | This option sets the resolution used for the U-Boot framebuffer (and |
173 | bootsplash screen). | 181 | bootsplash screen). |
174 | 182 | ||
175 | config FRAMEBUFFER_VESA_MODE_100 | 183 | config FRAMEBUFFER_VESA_MODE_100 |
176 | bool "640x400 256-color" | 184 | bool "640x400 256-color" |
177 | 185 | ||
178 | config FRAMEBUFFER_VESA_MODE_101 | 186 | config FRAMEBUFFER_VESA_MODE_101 |
179 | bool "640x480 256-color" | 187 | bool "640x480 256-color" |
180 | 188 | ||
181 | config FRAMEBUFFER_VESA_MODE_102 | 189 | config FRAMEBUFFER_VESA_MODE_102 |
182 | bool "800x600 16-color" | 190 | bool "800x600 16-color" |
183 | 191 | ||
184 | config FRAMEBUFFER_VESA_MODE_103 | 192 | config FRAMEBUFFER_VESA_MODE_103 |
185 | bool "800x600 256-color" | 193 | bool "800x600 256-color" |
186 | 194 | ||
187 | config FRAMEBUFFER_VESA_MODE_104 | 195 | config FRAMEBUFFER_VESA_MODE_104 |
188 | bool "1024x768 16-color" | 196 | bool "1024x768 16-color" |
189 | 197 | ||
190 | config FRAMEBUFFER_VESA_MODE_105 | 198 | config FRAMEBUFFER_VESA_MODE_105 |
191 | bool "1024x768 256-color" | 199 | bool "1024x768 256-color" |
192 | 200 | ||
193 | config FRAMEBUFFER_VESA_MODE_106 | 201 | config FRAMEBUFFER_VESA_MODE_106 |
194 | bool "1280x1024 16-color" | 202 | bool "1280x1024 16-color" |
195 | 203 | ||
196 | config FRAMEBUFFER_VESA_MODE_107 | 204 | config FRAMEBUFFER_VESA_MODE_107 |
197 | bool "1280x1024 256-color" | 205 | bool "1280x1024 256-color" |
198 | 206 | ||
199 | config FRAMEBUFFER_VESA_MODE_108 | 207 | config FRAMEBUFFER_VESA_MODE_108 |
200 | bool "80x60 text" | 208 | bool "80x60 text" |
201 | 209 | ||
202 | config FRAMEBUFFER_VESA_MODE_109 | 210 | config FRAMEBUFFER_VESA_MODE_109 |
203 | bool "132x25 text" | 211 | bool "132x25 text" |
204 | 212 | ||
205 | config FRAMEBUFFER_VESA_MODE_10A | 213 | config FRAMEBUFFER_VESA_MODE_10A |
206 | bool "132x43 text" | 214 | bool "132x43 text" |
207 | 215 | ||
208 | config FRAMEBUFFER_VESA_MODE_10B | 216 | config FRAMEBUFFER_VESA_MODE_10B |
209 | bool "132x50 text" | 217 | bool "132x50 text" |
210 | 218 | ||
211 | config FRAMEBUFFER_VESA_MODE_10C | 219 | config FRAMEBUFFER_VESA_MODE_10C |
212 | bool "132x60 text" | 220 | bool "132x60 text" |
213 | 221 | ||
214 | config FRAMEBUFFER_VESA_MODE_10D | 222 | config FRAMEBUFFER_VESA_MODE_10D |
215 | bool "320x200 32k-color (1:5:5:5)" | 223 | bool "320x200 32k-color (1:5:5:5)" |
216 | 224 | ||
217 | config FRAMEBUFFER_VESA_MODE_10E | 225 | config FRAMEBUFFER_VESA_MODE_10E |
218 | bool "320x200 64k-color (5:6:5)" | 226 | bool "320x200 64k-color (5:6:5)" |
219 | 227 | ||
220 | config FRAMEBUFFER_VESA_MODE_10F | 228 | config FRAMEBUFFER_VESA_MODE_10F |
221 | bool "320x200 16.8M-color (8:8:8)" | 229 | bool "320x200 16.8M-color (8:8:8)" |
222 | 230 | ||
223 | config FRAMEBUFFER_VESA_MODE_110 | 231 | config FRAMEBUFFER_VESA_MODE_110 |
224 | bool "640x480 32k-color (1:5:5:5)" | 232 | bool "640x480 32k-color (1:5:5:5)" |
225 | 233 | ||
226 | config FRAMEBUFFER_VESA_MODE_111 | 234 | config FRAMEBUFFER_VESA_MODE_111 |
227 | bool "640x480 64k-color (5:6:5)" | 235 | bool "640x480 64k-color (5:6:5)" |
228 | 236 | ||
229 | config FRAMEBUFFER_VESA_MODE_112 | 237 | config FRAMEBUFFER_VESA_MODE_112 |
230 | bool "640x480 16.8M-color (8:8:8)" | 238 | bool "640x480 16.8M-color (8:8:8)" |
231 | 239 | ||
232 | config FRAMEBUFFER_VESA_MODE_113 | 240 | config FRAMEBUFFER_VESA_MODE_113 |
233 | bool "800x600 32k-color (1:5:5:5)" | 241 | bool "800x600 32k-color (1:5:5:5)" |
234 | 242 | ||
235 | config FRAMEBUFFER_VESA_MODE_114 | 243 | config FRAMEBUFFER_VESA_MODE_114 |
236 | bool "800x600 64k-color (5:6:5)" | 244 | bool "800x600 64k-color (5:6:5)" |
237 | 245 | ||
238 | config FRAMEBUFFER_VESA_MODE_115 | 246 | config FRAMEBUFFER_VESA_MODE_115 |
239 | bool "800x600 16.8M-color (8:8:8)" | 247 | bool "800x600 16.8M-color (8:8:8)" |
240 | 248 | ||
241 | config FRAMEBUFFER_VESA_MODE_116 | 249 | config FRAMEBUFFER_VESA_MODE_116 |
242 | bool "1024x768 32k-color (1:5:5:5)" | 250 | bool "1024x768 32k-color (1:5:5:5)" |
243 | 251 | ||
244 | config FRAMEBUFFER_VESA_MODE_117 | 252 | config FRAMEBUFFER_VESA_MODE_117 |
245 | bool "1024x768 64k-color (5:6:5)" | 253 | bool "1024x768 64k-color (5:6:5)" |
246 | 254 | ||
247 | config FRAMEBUFFER_VESA_MODE_118 | 255 | config FRAMEBUFFER_VESA_MODE_118 |
248 | bool "1024x768 16.8M-color (8:8:8)" | 256 | bool "1024x768 16.8M-color (8:8:8)" |
249 | 257 | ||
250 | config FRAMEBUFFER_VESA_MODE_119 | 258 | config FRAMEBUFFER_VESA_MODE_119 |
251 | bool "1280x1024 32k-color (1:5:5:5)" | 259 | bool "1280x1024 32k-color (1:5:5:5)" |
252 | 260 | ||
253 | config FRAMEBUFFER_VESA_MODE_11A | 261 | config FRAMEBUFFER_VESA_MODE_11A |
254 | bool "1280x1024 64k-color (5:6:5)" | 262 | bool "1280x1024 64k-color (5:6:5)" |
255 | 263 | ||
256 | config FRAMEBUFFER_VESA_MODE_11B | 264 | config FRAMEBUFFER_VESA_MODE_11B |
257 | bool "1280x1024 16.8M-color (8:8:8)" | 265 | bool "1280x1024 16.8M-color (8:8:8)" |
258 | 266 | ||
259 | config FRAMEBUFFER_VESA_MODE_USER | 267 | config FRAMEBUFFER_VESA_MODE_USER |
260 | bool "Manually select VESA mode" | 268 | bool "Manually select VESA mode" |
261 | 269 | ||
262 | endchoice | 270 | endchoice |
263 | 271 | ||
264 | # Map the config names to an integer (KB). | 272 | # Map the config names to an integer (KB). |
265 | config FRAMEBUFFER_VESA_MODE | 273 | config FRAMEBUFFER_VESA_MODE |
266 | prompt "VESA mode" if FRAMEBUFFER_VESA_MODE_USER | 274 | prompt "VESA mode" if FRAMEBUFFER_VESA_MODE_USER |
267 | hex | 275 | hex |
268 | default 0x100 if FRAMEBUFFER_VESA_MODE_100 | 276 | default 0x100 if FRAMEBUFFER_VESA_MODE_100 |
269 | default 0x101 if FRAMEBUFFER_VESA_MODE_101 | 277 | default 0x101 if FRAMEBUFFER_VESA_MODE_101 |
270 | default 0x102 if FRAMEBUFFER_VESA_MODE_102 | 278 | default 0x102 if FRAMEBUFFER_VESA_MODE_102 |
271 | default 0x103 if FRAMEBUFFER_VESA_MODE_103 | 279 | default 0x103 if FRAMEBUFFER_VESA_MODE_103 |
272 | default 0x104 if FRAMEBUFFER_VESA_MODE_104 | 280 | default 0x104 if FRAMEBUFFER_VESA_MODE_104 |
273 | default 0x105 if FRAMEBUFFER_VESA_MODE_105 | 281 | default 0x105 if FRAMEBUFFER_VESA_MODE_105 |
274 | default 0x106 if FRAMEBUFFER_VESA_MODE_106 | 282 | default 0x106 if FRAMEBUFFER_VESA_MODE_106 |
275 | default 0x107 if FRAMEBUFFER_VESA_MODE_107 | 283 | default 0x107 if FRAMEBUFFER_VESA_MODE_107 |
276 | default 0x108 if FRAMEBUFFER_VESA_MODE_108 | 284 | default 0x108 if FRAMEBUFFER_VESA_MODE_108 |
277 | default 0x109 if FRAMEBUFFER_VESA_MODE_109 | 285 | default 0x109 if FRAMEBUFFER_VESA_MODE_109 |
278 | default 0x10A if FRAMEBUFFER_VESA_MODE_10A | 286 | default 0x10A if FRAMEBUFFER_VESA_MODE_10A |
279 | default 0x10B if FRAMEBUFFER_VESA_MODE_10B | 287 | default 0x10B if FRAMEBUFFER_VESA_MODE_10B |
280 | default 0x10C if FRAMEBUFFER_VESA_MODE_10C | 288 | default 0x10C if FRAMEBUFFER_VESA_MODE_10C |
281 | default 0x10D if FRAMEBUFFER_VESA_MODE_10D | 289 | default 0x10D if FRAMEBUFFER_VESA_MODE_10D |
282 | default 0x10E if FRAMEBUFFER_VESA_MODE_10E | 290 | default 0x10E if FRAMEBUFFER_VESA_MODE_10E |
283 | default 0x10F if FRAMEBUFFER_VESA_MODE_10F | 291 | default 0x10F if FRAMEBUFFER_VESA_MODE_10F |
284 | default 0x110 if FRAMEBUFFER_VESA_MODE_110 | 292 | default 0x110 if FRAMEBUFFER_VESA_MODE_110 |
285 | default 0x111 if FRAMEBUFFER_VESA_MODE_111 | 293 | default 0x111 if FRAMEBUFFER_VESA_MODE_111 |
286 | default 0x112 if FRAMEBUFFER_VESA_MODE_112 | 294 | default 0x112 if FRAMEBUFFER_VESA_MODE_112 |
287 | default 0x113 if FRAMEBUFFER_VESA_MODE_113 | 295 | default 0x113 if FRAMEBUFFER_VESA_MODE_113 |
288 | default 0x114 if FRAMEBUFFER_VESA_MODE_114 | 296 | default 0x114 if FRAMEBUFFER_VESA_MODE_114 |
289 | default 0x115 if FRAMEBUFFER_VESA_MODE_115 | 297 | default 0x115 if FRAMEBUFFER_VESA_MODE_115 |
290 | default 0x116 if FRAMEBUFFER_VESA_MODE_116 | 298 | default 0x116 if FRAMEBUFFER_VESA_MODE_116 |
291 | default 0x117 if FRAMEBUFFER_VESA_MODE_117 | 299 | default 0x117 if FRAMEBUFFER_VESA_MODE_117 |
292 | default 0x118 if FRAMEBUFFER_VESA_MODE_118 | 300 | default 0x118 if FRAMEBUFFER_VESA_MODE_118 |
293 | default 0x119 if FRAMEBUFFER_VESA_MODE_119 | 301 | default 0x119 if FRAMEBUFFER_VESA_MODE_119 |
294 | default 0x11A if FRAMEBUFFER_VESA_MODE_11A | 302 | default 0x11A if FRAMEBUFFER_VESA_MODE_11A |
295 | default 0x11B if FRAMEBUFFER_VESA_MODE_11B | 303 | default 0x11B if FRAMEBUFFER_VESA_MODE_11B |
296 | default 0x117 if FRAMEBUFFER_VESA_MODE_USER | 304 | default 0x117 if FRAMEBUFFER_VESA_MODE_USER |
297 | 305 | ||
298 | config VIDEO_LCD_ANX9804 | 306 | config VIDEO_LCD_ANX9804 |
299 | bool "ANX9804 bridge chip" | 307 | bool "ANX9804 bridge chip" |
300 | default n | 308 | default n |
301 | ---help--- | 309 | ---help--- |
302 | Support for the ANX9804 bridge chip, which can take pixel data coming | 310 | Support for the ANX9804 bridge chip, which can take pixel data coming |
303 | from a parallel LCD interface and translate it on the fy into a DP | 311 | from a parallel LCD interface and translate it on the fy into a DP |
304 | interface for driving eDP TFT displays. It uses I2C for configuration. | 312 | interface for driving eDP TFT displays. It uses I2C for configuration. |
305 | 313 | ||
306 | config VIDEO_LCD_SSD2828 | 314 | config VIDEO_LCD_SSD2828 |
307 | bool "SSD2828 bridge chip" | 315 | bool "SSD2828 bridge chip" |
308 | default n | 316 | default n |
309 | ---help--- | 317 | ---help--- |
310 | Support for the SSD2828 bridge chip, which can take pixel data coming | 318 | Support for the SSD2828 bridge chip, which can take pixel data coming |
311 | from a parallel LCD interface and translate it on the fly into MIPI DSI | 319 | from a parallel LCD interface and translate it on the fly into MIPI DSI |
312 | interface for driving a MIPI compatible LCD panel. It uses SPI for | 320 | interface for driving a MIPI compatible LCD panel. It uses SPI for |
313 | configuration. | 321 | configuration. |
314 | 322 | ||
315 | config VIDEO_LCD_SSD2828_TX_CLK | 323 | config VIDEO_LCD_SSD2828_TX_CLK |
316 | int "SSD2828 TX_CLK frequency (in MHz)" | 324 | int "SSD2828 TX_CLK frequency (in MHz)" |
317 | depends on VIDEO_LCD_SSD2828 | 325 | depends on VIDEO_LCD_SSD2828 |
318 | default 0 | 326 | default 0 |
319 | ---help--- | 327 | ---help--- |
320 | The frequency of the crystal, which is clocking SSD2828. It may be | 328 | The frequency of the crystal, which is clocking SSD2828. It may be |
321 | anything in the 8MHz-30MHz range and the exact value should be | 329 | anything in the 8MHz-30MHz range and the exact value should be |
322 | retrieved from the board schematics. Or in the case of Allwinner | 330 | retrieved from the board schematics. Or in the case of Allwinner |
323 | hardware, it can be usually found as 'lcd_xtal_freq' variable in | 331 | hardware, it can be usually found as 'lcd_xtal_freq' variable in |
324 | FEX files. It can be also set to 0 for selecting PCLK from the | 332 | FEX files. It can be also set to 0 for selecting PCLK from the |
325 | parallel LCD interface instead of TX_CLK as the PLL clock source. | 333 | parallel LCD interface instead of TX_CLK as the PLL clock source. |
326 | 334 | ||
327 | config VIDEO_LCD_SSD2828_RESET | 335 | config VIDEO_LCD_SSD2828_RESET |
328 | string "RESET pin of SSD2828" | 336 | string "RESET pin of SSD2828" |
329 | depends on VIDEO_LCD_SSD2828 | 337 | depends on VIDEO_LCD_SSD2828 |
330 | default "" | 338 | default "" |
331 | ---help--- | 339 | ---help--- |
332 | The reset pin of SSD2828 chip. This takes a string in the format | 340 | The reset pin of SSD2828 chip. This takes a string in the format |
333 | understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H. | 341 | understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H. |
334 | 342 | ||
335 | config VIDEO_LCD_HITACHI_TX18D42VM | 343 | config VIDEO_LCD_HITACHI_TX18D42VM |
336 | bool "Hitachi tx18d42vm LVDS LCD panel support" | 344 | bool "Hitachi tx18d42vm LVDS LCD panel support" |
337 | depends on VIDEO | 345 | depends on VIDEO |
338 | default n | 346 | default n |
339 | ---help--- | 347 | ---help--- |
340 | Support for Hitachi tx18d42vm LVDS LCD panels, these panels have a | 348 | Support for Hitachi tx18d42vm LVDS LCD panels, these panels have a |
341 | lcd controller which needs to be initialized over SPI, once that is | 349 | lcd controller which needs to be initialized over SPI, once that is |
342 | done they work like a regular LVDS panel. | 350 | done they work like a regular LVDS panel. |
343 | 351 | ||
344 | config VIDEO_LCD_SPI_CS | 352 | config VIDEO_LCD_SPI_CS |
345 | string "SPI CS pin for LCD related config job" | 353 | string "SPI CS pin for LCD related config job" |
346 | depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM | 354 | depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM |
347 | default "" | 355 | default "" |
348 | ---help--- | 356 | ---help--- |
349 | This is one of the SPI communication pins, involved in setting up a | 357 | This is one of the SPI communication pins, involved in setting up a |
350 | working LCD configuration. The exact role of SPI may differ for | 358 | working LCD configuration. The exact role of SPI may differ for |
351 | different hardware setups. The option takes a string in the format | 359 | different hardware setups. The option takes a string in the format |
352 | understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H. | 360 | understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H. |
353 | 361 | ||
354 | config VIDEO_LCD_SPI_SCLK | 362 | config VIDEO_LCD_SPI_SCLK |
355 | string "SPI SCLK pin for LCD related config job" | 363 | string "SPI SCLK pin for LCD related config job" |
356 | depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM | 364 | depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM |
357 | default "" | 365 | default "" |
358 | ---help--- | 366 | ---help--- |
359 | This is one of the SPI communication pins, involved in setting up a | 367 | This is one of the SPI communication pins, involved in setting up a |
360 | working LCD configuration. The exact role of SPI may differ for | 368 | working LCD configuration. The exact role of SPI may differ for |
361 | different hardware setups. The option takes a string in the format | 369 | different hardware setups. The option takes a string in the format |
362 | understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H. | 370 | understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H. |
363 | 371 | ||
364 | config VIDEO_LCD_SPI_MOSI | 372 | config VIDEO_LCD_SPI_MOSI |
365 | string "SPI MOSI pin for LCD related config job" | 373 | string "SPI MOSI pin for LCD related config job" |
366 | depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM | 374 | depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM |
367 | default "" | 375 | default "" |
368 | ---help--- | 376 | ---help--- |
369 | This is one of the SPI communication pins, involved in setting up a | 377 | This is one of the SPI communication pins, involved in setting up a |
370 | working LCD configuration. The exact role of SPI may differ for | 378 | working LCD configuration. The exact role of SPI may differ for |
371 | different hardware setups. The option takes a string in the format | 379 | different hardware setups. The option takes a string in the format |
372 | understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H. | 380 | understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H. |
373 | 381 | ||
374 | config VIDEO_LCD_SPI_MISO | 382 | config VIDEO_LCD_SPI_MISO |
375 | string "SPI MISO pin for LCD related config job (optional)" | 383 | string "SPI MISO pin for LCD related config job (optional)" |
376 | depends on VIDEO_LCD_SSD2828 | 384 | depends on VIDEO_LCD_SSD2828 |
377 | default "" | 385 | default "" |
378 | ---help--- | 386 | ---help--- |
379 | This is one of the SPI communication pins, involved in setting up a | 387 | This is one of the SPI communication pins, involved in setting up a |
380 | working LCD configuration. The exact role of SPI may differ for | 388 | working LCD configuration. The exact role of SPI may differ for |
381 | different hardware setups. If wired up, this pin may provide additional | 389 | different hardware setups. If wired up, this pin may provide additional |
382 | useful functionality. Such as bi-directional communication with the | 390 | useful functionality. Such as bi-directional communication with the |
383 | hardware and LCD panel id retrieval (if the panel can report it). The | 391 | hardware and LCD panel id retrieval (if the panel can report it). The |
384 | option takes a string in the format understood by 'name_to_gpio' | 392 | option takes a string in the format understood by 'name_to_gpio' |
385 | function, e.g. PH1 for pin 1 of port H. | 393 | function, e.g. PH1 for pin 1 of port H. |
386 | 394 | ||
387 | config VIDEO_MVEBU | 395 | config VIDEO_MVEBU |
388 | bool "Armada XP LCD controller" | 396 | bool "Armada XP LCD controller" |
389 | default n | 397 | default n |
390 | ---help--- | 398 | ---help--- |
391 | Support for the LCD controller integrated in the Marvell | 399 | Support for the LCD controller integrated in the Marvell |
392 | Armada XP SoC. | 400 | Armada XP SoC. |
393 | 401 | ||
394 | config I2C_EDID | 402 | config I2C_EDID |
395 | bool "Enable EDID library" | 403 | bool "Enable EDID library" |
396 | depends on DM_I2C | 404 | depends on DM_I2C |
397 | default n | 405 | default n |
398 | help | 406 | help |
399 | This enables library for accessing EDID data from an LCD panel. | 407 | This enables library for accessing EDID data from an LCD panel. |
400 | 408 | ||
401 | config DISPLAY | 409 | config DISPLAY |
402 | bool "Enable Display support" | 410 | bool "Enable Display support" |
403 | depends on DM | 411 | depends on DM |
404 | default n | 412 | default n |
405 | select I2C_EDID | 413 | select I2C_EDID |
406 | help | 414 | help |
407 | This supports drivers that provide a display, such as eDP (Embedded | 415 | This supports drivers that provide a display, such as eDP (Embedded |
408 | DisplayPort) and HDMI (High Definition Multimedia Interface). | 416 | DisplayPort) and HDMI (High Definition Multimedia Interface). |
409 | The devices provide a simple interface to start up the display, | 417 | The devices provide a simple interface to start up the display, |
410 | read display information and enable it. | 418 | read display information and enable it. |
411 | 419 | ||
412 | config ATMEL_HLCD | 420 | config ATMEL_HLCD |
413 | bool "Enable ATMEL video support using HLCDC" | 421 | bool "Enable ATMEL video support using HLCDC" |
414 | depends on DM_VIDEO | 422 | depends on DM_VIDEO |
415 | help | 423 | help |
416 | HLCDC supports video output to an attached LCD panel. | 424 | HLCDC supports video output to an attached LCD panel. |
417 | 425 | ||
418 | config VIDEO_BROADWELL_IGD | 426 | config VIDEO_BROADWELL_IGD |
419 | bool "Enable Intel Broadwell integrated graphics device" | 427 | bool "Enable Intel Broadwell integrated graphics device" |
420 | depends on X86 | 428 | depends on X86 |
421 | help | 429 | help |
422 | This enables support for integrated graphics on Intel broadwell | 430 | This enables support for integrated graphics on Intel broadwell |
423 | devices. Initialisation is mostly performed by a VGA boot ROM, with | 431 | devices. Initialisation is mostly performed by a VGA boot ROM, with |
424 | some setup handled by U-Boot itself. The graphics adaptor works as | 432 | some setup handled by U-Boot itself. The graphics adaptor works as |
425 | a VESA device and supports LCD panels, eDP and LVDS outputs. | 433 | a VESA device and supports LCD panels, eDP and LVDS outputs. |
426 | Configuration of most aspects of device operation is performed using | 434 | Configuration of most aspects of device operation is performed using |
427 | a special tool which configures the VGA ROM, but the graphics | 435 | a special tool which configures the VGA ROM, but the graphics |
428 | resolution can be selected in U-Boot. | 436 | resolution can be selected in U-Boot. |
429 | 437 | ||
430 | config VIDEO_IVYBRIDGE_IGD | 438 | config VIDEO_IVYBRIDGE_IGD |
431 | bool "Enable Intel Ivybridge integration graphics support" | 439 | bool "Enable Intel Ivybridge integration graphics support" |
432 | depends on X86 | 440 | depends on X86 |
433 | help | 441 | help |
434 | This enables support for integrated graphics on Intel ivybridge | 442 | This enables support for integrated graphics on Intel ivybridge |
435 | devices. Initialisation is mostly performed by a VGA boot ROM, with | 443 | devices. Initialisation is mostly performed by a VGA boot ROM, with |
436 | some setup handled by U-Boot itself. The graphics adaptor works as | 444 | some setup handled by U-Boot itself. The graphics adaptor works as |
437 | a VESA device and supports LCD panels, eDP and LVDS outputs. | 445 | a VESA device and supports LCD panels, eDP and LVDS outputs. |
438 | Configuration of most aspects of device operation is performed using | 446 | Configuration of most aspects of device operation is performed using |
439 | a special tool which configures the VGA ROM, but the graphics | 447 | a special tool which configures the VGA ROM, but the graphics |
440 | resolution can be selected in U-Boot. | 448 | resolution can be selected in U-Boot. |
441 | 449 | ||
442 | config VIDEO_FSL_DCU_FB | 450 | config VIDEO_FSL_DCU_FB |
443 | bool "Enable Freescale Display Control Unit" | 451 | bool "Enable Freescale Display Control Unit" |
444 | depends on VIDEO | 452 | depends on VIDEO |
445 | help | 453 | help |
446 | This enables support for Freescale Display Control Unit (DCU4) | 454 | This enables support for Freescale Display Control Unit (DCU4) |
447 | module found on Freescale Vybrid and QorIQ family of SoCs. | 455 | module found on Freescale Vybrid and QorIQ family of SoCs. |
448 | 456 | ||
449 | config VIDEO_FSL_DCU_MAX_FB_SIZE_MB | 457 | config VIDEO_FSL_DCU_MAX_FB_SIZE_MB |
450 | int "Freescale DCU framebuffer size" | 458 | int "Freescale DCU framebuffer size" |
451 | depends on VIDEO_FSL_DCU_FB | 459 | depends on VIDEO_FSL_DCU_FB |
452 | default 4194304 | 460 | default 4194304 |
453 | help | 461 | help |
454 | Set maximum framebuffer size to be used for Freescale Display | 462 | Set maximum framebuffer size to be used for Freescale Display |
455 | Controller Unit (DCU4). | 463 | Controller Unit (DCU4). |
456 | 464 | ||
457 | source "drivers/video/rockchip/Kconfig" | 465 | source "drivers/video/rockchip/Kconfig" |
458 | 466 | ||
459 | config VIDEO_SANDBOX_SDL | 467 | config VIDEO_SANDBOX_SDL |
460 | bool "Enable sandbox video console using SDL" | 468 | bool "Enable sandbox video console using SDL" |
461 | depends on SANDBOX | 469 | depends on SANDBOX |
462 | help | 470 | help |
463 | When using sandbox you can enable an emulated LCD display which | 471 | When using sandbox you can enable an emulated LCD display which |
464 | appears as an SDL (Simple DirectMedia Layer) window. This is a | 472 | appears as an SDL (Simple DirectMedia Layer) window. This is a |
465 | console device and can display stdout output. Within U-Boot is is | 473 | console device and can display stdout output. Within U-Boot is is |
466 | a normal bitmap display and can display images as well as text. | 474 | a normal bitmap display and can display images as well as text. |
467 | 475 | ||
468 | source "drivers/video/stm32/Kconfig" | 476 | source "drivers/video/stm32/Kconfig" |
469 | 477 | ||
470 | config VIDEO_TEGRA20 | 478 | config VIDEO_TEGRA20 |
471 | bool "Enable LCD support on Tegra20" | 479 | bool "Enable LCD support on Tegra20" |
472 | depends on OF_CONTROL | 480 | depends on OF_CONTROL |
473 | help | 481 | help |
474 | Tegra20 supports video output to an attached LCD panel as well as | 482 | Tegra20 supports video output to an attached LCD panel as well as |
475 | other options such as HDMI. Only the LCD is supported in U-Boot. | 483 | other options such as HDMI. Only the LCD is supported in U-Boot. |
476 | This option enables this support which can be used on devices which | 484 | This option enables this support which can be used on devices which |
477 | have an LCD display connected. | 485 | have an LCD display connected. |
478 | 486 | ||
479 | config VIDEO_TEGRA124 | 487 | config VIDEO_TEGRA124 |
480 | bool "Enable video support on Tegra124" | 488 | bool "Enable video support on Tegra124" |
481 | depends on DM_VIDEO | 489 | depends on DM_VIDEO |
482 | help | 490 | help |
483 | Tegra124 supports many video output options including eDP and | 491 | Tegra124 supports many video output options including eDP and |
484 | HDMI. At present only eDP is supported by U-Boot. This option | 492 | HDMI. At present only eDP is supported by U-Boot. This option |
485 | enables this support which can be used on devices which | 493 | enables this support which can be used on devices which |
486 | have an eDP display connected. | 494 | have an eDP display connected. |
487 | 495 | ||
488 | source "drivers/video/bridge/Kconfig" | 496 | source "drivers/video/bridge/Kconfig" |
489 | 497 | ||
490 | config VIDEO | 498 | config VIDEO |
491 | bool "Enable legacy video support" | 499 | bool "Enable legacy video support" |
492 | depends on !DM_VIDEO | 500 | depends on !DM_VIDEO |
493 | help | 501 | help |
494 | Define this for video support, without using driver model. Some | 502 | Define this for video support, without using driver model. Some |
495 | drivers use this because they are not yet converted to driver | 503 | drivers use this because they are not yet converted to driver |
496 | model. Video drivers typically provide a colour text console and | 504 | model. Video drivers typically provide a colour text console and |
497 | cursor. | 505 | cursor. |
498 | 506 | ||
499 | config VIDEO_IPUV3 | 507 | config VIDEO_IPUV3 |
500 | bool "i.MX IPUv3 Core video support" | 508 | bool "i.MX IPUv3 Core video support" |
501 | depends on VIDEO && MX6 | 509 | depends on VIDEO && MX6 |
502 | help | 510 | help |
503 | This enables framebuffer driver for i.MX processors working | 511 | This enables framebuffer driver for i.MX processors working |
504 | on the IPUv3(Image Processing Unit) internal graphic processor. | 512 | on the IPUv3(Image Processing Unit) internal graphic processor. |
505 | 513 | ||
506 | config CFB_CONSOLE | 514 | config CFB_CONSOLE |
507 | bool "Enable colour frame buffer console" | 515 | bool "Enable colour frame buffer console" |
508 | depends on VIDEO | 516 | depends on VIDEO |
509 | default y if VIDEO | 517 | default y if VIDEO |
510 | help | 518 | help |
511 | Enables the colour frame buffer driver. This supports colour | 519 | Enables the colour frame buffer driver. This supports colour |
512 | output on a bitmap display from an in-memory frame buffer. | 520 | output on a bitmap display from an in-memory frame buffer. |
513 | Several colour devices are supported along with various options to | 521 | Several colour devices are supported along with various options to |
514 | adjust the supported features. The driver is implemented in | 522 | adjust the supported features. The driver is implemented in |
515 | cfb_console.c | 523 | cfb_console.c |
516 | 524 | ||
517 | The following defines are needed (cf. smiLynxEM, i8042) | 525 | The following defines are needed (cf. smiLynxEM, i8042) |
518 | VIDEO_FB_LITTLE_ENDIAN graphic memory organisation | 526 | VIDEO_FB_LITTLE_ENDIAN graphic memory organisation |
519 | (default big endian) | 527 | (default big endian) |
520 | VIDEO_HW_RECTFILL graphic chip supports | 528 | VIDEO_HW_RECTFILL graphic chip supports |
521 | rectangle fill (cf. smiLynxEM) | 529 | rectangle fill (cf. smiLynxEM) |
522 | VIDEO_HW_BITBLT graphic chip supports | 530 | VIDEO_HW_BITBLT graphic chip supports |
523 | bit-blit (cf. smiLynxEM) | 531 | bit-blit (cf. smiLynxEM) |
524 | VIDEO_VISIBLE_COLS visible pixel columns (cols=pitch) | 532 | VIDEO_VISIBLE_COLS visible pixel columns (cols=pitch) |
525 | VIDEO_VISIBLE_ROWS visible pixel rows | 533 | VIDEO_VISIBLE_ROWS visible pixel rows |
526 | VIDEO_PIXEL_SIZE bytes per pixel | 534 | VIDEO_PIXEL_SIZE bytes per pixel |
527 | VIDEO_DATA_FORMAT graphic data format | 535 | VIDEO_DATA_FORMAT graphic data format |
528 | (0-5, cf. cfb_console.c) | 536 | (0-5, cf. cfb_console.c) |
529 | VIDEO_FB_ADRS framebuffer address | 537 | VIDEO_FB_ADRS framebuffer address |
530 | VIDEO_KBD_INIT_FCT keyboard int fct (i.e. rx51_kp_init()) | 538 | VIDEO_KBD_INIT_FCT keyboard int fct (i.e. rx51_kp_init()) |
531 | VIDEO_TSTC_FCT test char fct (i.e. rx51_kp_tstc) | 539 | VIDEO_TSTC_FCT test char fct (i.e. rx51_kp_tstc) |
532 | VIDEO_GETC_FCT get char fct (i.e. rx51_kp_getc) | 540 | VIDEO_GETC_FCT get char fct (i.e. rx51_kp_getc) |
533 | CONFIG_VIDEO_LOGO display Linux logo in upper left corner | 541 | CONFIG_VIDEO_LOGO display Linux logo in upper left corner |
534 | CONFIG_VIDEO_BMP_LOGO use bmp_logo.h instead of linux_logo.h | 542 | CONFIG_VIDEO_BMP_LOGO use bmp_logo.h instead of linux_logo.h |
535 | for logo. Requires CONFIG_VIDEO_LOGO | 543 | for logo. Requires CONFIG_VIDEO_LOGO |
536 | CONFIG_CONSOLE_EXTRA_INFO | 544 | CONFIG_CONSOLE_EXTRA_INFO |
537 | additional board info beside | 545 | additional board info beside |
538 | the logo | 546 | the logo |
539 | CONFIG_HIDE_LOGO_VERSION | 547 | CONFIG_HIDE_LOGO_VERSION |
540 | do not display bootloader | 548 | do not display bootloader |
541 | version string | 549 | version string |
542 | 550 | ||
543 | When CONFIG_CFB_CONSOLE is defined, the video console is the | 551 | When CONFIG_CFB_CONSOLE is defined, the video console is the |
544 | default console. The serial console can be forced by setting the | 552 | default console. The serial console can be forced by setting the |
545 | environment 'console=serial'. | 553 | environment 'console=serial'. |
546 | 554 | ||
547 | config CFB_CONSOLE_ANSI | 555 | config CFB_CONSOLE_ANSI |
548 | bool "Support ANSI escape sequences" | 556 | bool "Support ANSI escape sequences" |
549 | depends on CFB_CONSOLE | 557 | depends on CFB_CONSOLE |
550 | help | 558 | help |
551 | This allows the colour buffer frame buffer driver to support | 559 | This allows the colour buffer frame buffer driver to support |
552 | a limited number of ANSI escape sequences (cursor control, | 560 | a limited number of ANSI escape sequences (cursor control, |
553 | erase functions and limited graphics rendition control). Normal | 561 | erase functions and limited graphics rendition control). Normal |
554 | output from U-Boot will pass through this filter. | 562 | output from U-Boot will pass through this filter. |
555 | 563 | ||
556 | config VGA_AS_SINGLE_DEVICE | 564 | config VGA_AS_SINGLE_DEVICE |
557 | bool "Set the video as an output-only device" | 565 | bool "Set the video as an output-only device" |
558 | depends on CFB_CONSOLE | 566 | depends on CFB_CONSOLE |
559 | default y | 567 | default y |
560 | help | 568 | help |
561 | If enable the framebuffer device will be initialized as an | 569 | If enable the framebuffer device will be initialized as an |
562 | output-only device. The Keyboard driver will not be set up. This | 570 | output-only device. The Keyboard driver will not be set up. This |
563 | may be used if you have no keyboard device, or more than one | 571 | may be used if you have no keyboard device, or more than one |
564 | (USB Keyboard, AT Keyboard). | 572 | (USB Keyboard, AT Keyboard). |
565 | 573 | ||
566 | config VIDEO_SW_CURSOR | 574 | config VIDEO_SW_CURSOR |
567 | bool "Enable a software cursor" | 575 | bool "Enable a software cursor" |
568 | depends on CFB_CONSOLE | 576 | depends on CFB_CONSOLE |
569 | default y if CFB_CONSOLE | 577 | default y if CFB_CONSOLE |
570 | help | 578 | help |
571 | This draws a cursor after the last character. No blinking is | 579 | This draws a cursor after the last character. No blinking is |
572 | provided. This makes it possible to see the current cursor | 580 | provided. This makes it possible to see the current cursor |
573 | position when entering text on the console. It is recommended to | 581 | position when entering text on the console. It is recommended to |
574 | enable this. | 582 | enable this. |
575 | 583 | ||
576 | config CONSOLE_EXTRA_INFO | 584 | config CONSOLE_EXTRA_INFO |
577 | bool "Display additional board information" | 585 | bool "Display additional board information" |
578 | depends on CFB_CONSOLE | 586 | depends on CFB_CONSOLE |
579 | help | 587 | help |
580 | Display additional board information strings that normally go to | 588 | Display additional board information strings that normally go to |
581 | the serial port. When this option is enabled, a board-specific | 589 | the serial port. When this option is enabled, a board-specific |
582 | function video_get_info_str() is called to get the string for | 590 | function video_get_info_str() is called to get the string for |
583 | each line of the display. The function should return the string, | 591 | each line of the display. The function should return the string, |
584 | which can be empty if there is nothing to display for that line. | 592 | which can be empty if there is nothing to display for that line. |
585 | 593 | ||
586 | config CONSOLE_SCROLL_LINES | 594 | config CONSOLE_SCROLL_LINES |
587 | int "Number of lines to scroll the console by" | 595 | int "Number of lines to scroll the console by" |
588 | depends on CFB_CONSOLE || DM_VIDEO || LCD | 596 | depends on CFB_CONSOLE || DM_VIDEO || LCD |
589 | default 1 | 597 | default 1 |
590 | help | 598 | help |
591 | When the console need to be scrolled, this is the number of | 599 | When the console need to be scrolled, this is the number of |
592 | lines to scroll by. It defaults to 1. Increasing this makes the | 600 | lines to scroll by. It defaults to 1. Increasing this makes the |
593 | console jump but can help speed up operation when scrolling | 601 | console jump but can help speed up operation when scrolling |
594 | is slow. | 602 | is slow. |
595 | 603 | ||
596 | config SYS_CONSOLE_BG_COL | 604 | config SYS_CONSOLE_BG_COL |
597 | hex "Background colour" | 605 | hex "Background colour" |
598 | depends on CFB_CONSOLE | 606 | depends on CFB_CONSOLE |
599 | default 0x00 | 607 | default 0x00 |
600 | help | 608 | help |
601 | Defines the background colour for the console. The value is from | 609 | Defines the background colour for the console. The value is from |
602 | 0x00 to 0xff and the meaning depends on the graphics card. | 610 | 0x00 to 0xff and the meaning depends on the graphics card. |
603 | Typically, 0x00 means black and 0xff means white. Do not set | 611 | Typically, 0x00 means black and 0xff means white. Do not set |
604 | the background and foreground to the same colour or you will see | 612 | the background and foreground to the same colour or you will see |
605 | nothing. | 613 | nothing. |
606 | 614 | ||
607 | config SYS_CONSOLE_FG_COL | 615 | config SYS_CONSOLE_FG_COL |
608 | hex "Foreground colour" | 616 | hex "Foreground colour" |
609 | depends on CFB_CONSOLE | 617 | depends on CFB_CONSOLE |
610 | default 0xa0 | 618 | default 0xa0 |
611 | help | 619 | help |
612 | Defines the foreground colour for the console. The value is from | 620 | Defines the foreground colour for the console. The value is from |
613 | 0x00 to 0xff and the meaning depends on the graphics card. | 621 | 0x00 to 0xff and the meaning depends on the graphics card. |
614 | Typically, 0x00 means black and 0xff means white. Do not set | 622 | Typically, 0x00 means black and 0xff means white. Do not set |
615 | the background and foreground to the same colour or you will see | 623 | the background and foreground to the same colour or you will see |
616 | nothing. | 624 | nothing. |
617 | 625 | ||
618 | config LCD | 626 | config LCD |
619 | bool "Enable legacy LCD support" | 627 | bool "Enable legacy LCD support" |
620 | help | 628 | help |
621 | Define this to enable LCD support (for output to LCD display). | 629 | Define this to enable LCD support (for output to LCD display). |
622 | You will also need to select an LCD driver using an additional | 630 | You will also need to select an LCD driver using an additional |
623 | CONFIG option. See the README for details. Drives which have been | 631 | CONFIG option. See the README for details. Drives which have been |
624 | converted to driver model will instead used CONFIG_DM_VIDEO. | 632 | converted to driver model will instead used CONFIG_DM_VIDEO. |
625 | 633 | ||
626 | config VIDEO_DW_HDMI | 634 | config VIDEO_DW_HDMI |
627 | bool | 635 | bool |
628 | help | 636 | help |
629 | Enables the common driver code for the Designware HDMI TX | 637 | Enables the common driver code for the Designware HDMI TX |
630 | block found in SoCs from various vendors. | 638 | block found in SoCs from various vendors. |
631 | As this does not provide any functionality by itself (but | 639 | As this does not provide any functionality by itself (but |
632 | rather requires a SoC-specific glue driver to call it), it | 640 | rather requires a SoC-specific glue driver to call it), it |
633 | can not be enabled from the configuration menu. | 641 | can not be enabled from the configuration menu. |
634 | 642 | ||
635 | config VIDEO_SIMPLE | 643 | config VIDEO_SIMPLE |
636 | bool "Simple display driver for preconfigured display" | 644 | bool "Simple display driver for preconfigured display" |
637 | help | 645 | help |
638 | Enables a simple generic display driver which utilizes the | 646 | Enables a simple generic display driver which utilizes the |
639 | simple-framebuffer devicetree bindings. | 647 | simple-framebuffer devicetree bindings. |
640 | 648 | ||
641 | This driver assumes that the display hardware has been initialized | 649 | This driver assumes that the display hardware has been initialized |
642 | before u-boot starts, and u-boot will simply render to the pre- | 650 | before u-boot starts, and u-boot will simply render to the pre- |
643 | allocated frame buffer surface. | 651 | allocated frame buffer surface. |
644 | 652 | ||
645 | endmenu | 653 | endmenu |
646 | 654 |
drivers/video/vidconsole-uclass.c
1 | /* | 1 | /* |
2 | * Copyright (c) 2015 Google, Inc | 2 | * Copyright (c) 2015 Google, Inc |
3 | * (C) Copyright 2001-2015 | 3 | * (C) Copyright 2001-2015 |
4 | * DENX Software Engineering -- wd@denx.de | 4 | * DENX Software Engineering -- wd@denx.de |
5 | * Compulab Ltd - http://compulab.co.il/ | 5 | * Compulab Ltd - http://compulab.co.il/ |
6 | * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com | 6 | * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com |
7 | * | 7 | * |
8 | * SPDX-License-Identifier: GPL-2.0+ | 8 | * SPDX-License-Identifier: GPL-2.0+ |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <common.h> | 11 | #include <common.h> |
12 | #include <linux/ctype.h> | ||
12 | #include <dm.h> | 13 | #include <dm.h> |
13 | #include <video.h> | 14 | #include <video.h> |
14 | #include <video_console.h> | 15 | #include <video_console.h> |
15 | #include <video_font.h> /* Get font data, width and height */ | 16 | #include <video_font.h> /* Get font data, width and height */ |
16 | 17 | ||
17 | /* By default we scroll by a single line */ | 18 | /* By default we scroll by a single line */ |
18 | #ifndef CONFIG_CONSOLE_SCROLL_LINES | 19 | #ifndef CONFIG_CONSOLE_SCROLL_LINES |
19 | #define CONFIG_CONSOLE_SCROLL_LINES 1 | 20 | #define CONFIG_CONSOLE_SCROLL_LINES 1 |
20 | #endif | 21 | #endif |
21 | 22 | ||
22 | int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch) | 23 | int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch) |
23 | { | 24 | { |
24 | struct vidconsole_ops *ops = vidconsole_get_ops(dev); | 25 | struct vidconsole_ops *ops = vidconsole_get_ops(dev); |
25 | 26 | ||
26 | if (!ops->putc_xy) | 27 | if (!ops->putc_xy) |
27 | return -ENOSYS; | 28 | return -ENOSYS; |
28 | return ops->putc_xy(dev, x, y, ch); | 29 | return ops->putc_xy(dev, x, y, ch); |
29 | } | 30 | } |
30 | 31 | ||
31 | int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc, | 32 | int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc, |
32 | uint count) | 33 | uint count) |
33 | { | 34 | { |
34 | struct vidconsole_ops *ops = vidconsole_get_ops(dev); | 35 | struct vidconsole_ops *ops = vidconsole_get_ops(dev); |
35 | 36 | ||
36 | if (!ops->move_rows) | 37 | if (!ops->move_rows) |
37 | return -ENOSYS; | 38 | return -ENOSYS; |
38 | return ops->move_rows(dev, rowdst, rowsrc, count); | 39 | return ops->move_rows(dev, rowdst, rowsrc, count); |
39 | } | 40 | } |
40 | 41 | ||
41 | int vidconsole_set_row(struct udevice *dev, uint row, int clr) | 42 | int vidconsole_set_row(struct udevice *dev, uint row, int clr) |
42 | { | 43 | { |
43 | struct vidconsole_ops *ops = vidconsole_get_ops(dev); | 44 | struct vidconsole_ops *ops = vidconsole_get_ops(dev); |
44 | 45 | ||
45 | if (!ops->set_row) | 46 | if (!ops->set_row) |
46 | return -ENOSYS; | 47 | return -ENOSYS; |
47 | return ops->set_row(dev, row, clr); | 48 | return ops->set_row(dev, row, clr); |
48 | } | 49 | } |
49 | 50 | ||
50 | static int vidconsole_entry_start(struct udevice *dev) | 51 | static int vidconsole_entry_start(struct udevice *dev) |
51 | { | 52 | { |
52 | struct vidconsole_ops *ops = vidconsole_get_ops(dev); | 53 | struct vidconsole_ops *ops = vidconsole_get_ops(dev); |
53 | 54 | ||
54 | if (!ops->entry_start) | 55 | if (!ops->entry_start) |
55 | return -ENOSYS; | 56 | return -ENOSYS; |
56 | return ops->entry_start(dev); | 57 | return ops->entry_start(dev); |
57 | } | 58 | } |
58 | 59 | ||
59 | /* Move backwards one space */ | 60 | /* Move backwards one space */ |
60 | static int vidconsole_back(struct udevice *dev) | 61 | static int vidconsole_back(struct udevice *dev) |
61 | { | 62 | { |
62 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); | 63 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); |
63 | struct vidconsole_ops *ops = vidconsole_get_ops(dev); | 64 | struct vidconsole_ops *ops = vidconsole_get_ops(dev); |
64 | int ret; | 65 | int ret; |
65 | 66 | ||
66 | if (ops->backspace) { | 67 | if (ops->backspace) { |
67 | ret = ops->backspace(dev); | 68 | ret = ops->backspace(dev); |
68 | if (ret != -ENOSYS) | 69 | if (ret != -ENOSYS) |
69 | return ret; | 70 | return ret; |
70 | } | 71 | } |
71 | 72 | ||
72 | priv->xcur_frac -= VID_TO_POS(priv->x_charsize); | 73 | priv->xcur_frac -= VID_TO_POS(priv->x_charsize); |
73 | if (priv->xcur_frac < priv->xstart_frac) { | 74 | if (priv->xcur_frac < priv->xstart_frac) { |
74 | priv->xcur_frac = (priv->cols - 1) * | 75 | priv->xcur_frac = (priv->cols - 1) * |
75 | VID_TO_POS(priv->x_charsize); | 76 | VID_TO_POS(priv->x_charsize); |
76 | priv->ycur -= priv->y_charsize; | 77 | priv->ycur -= priv->y_charsize; |
77 | if (priv->ycur < 0) | 78 | if (priv->ycur < 0) |
78 | priv->ycur = 0; | 79 | priv->ycur = 0; |
79 | } | 80 | } |
80 | video_sync(dev->parent); | 81 | video_sync(dev->parent); |
81 | 82 | ||
82 | return 0; | 83 | return 0; |
83 | } | 84 | } |
84 | 85 | ||
85 | /* Move to a newline, scrolling the display if necessary */ | 86 | /* Move to a newline, scrolling the display if necessary */ |
86 | static void vidconsole_newline(struct udevice *dev) | 87 | static void vidconsole_newline(struct udevice *dev) |
87 | { | 88 | { |
88 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); | 89 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); |
89 | struct udevice *vid_dev = dev->parent; | 90 | struct udevice *vid_dev = dev->parent; |
90 | struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev); | 91 | struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev); |
91 | const int rows = CONFIG_CONSOLE_SCROLL_LINES; | 92 | const int rows = CONFIG_CONSOLE_SCROLL_LINES; |
92 | int i; | 93 | int i; |
93 | 94 | ||
94 | priv->xcur_frac = priv->xstart_frac; | 95 | priv->xcur_frac = priv->xstart_frac; |
95 | priv->ycur += priv->y_charsize; | 96 | priv->ycur += priv->y_charsize; |
96 | 97 | ||
97 | /* Check if we need to scroll the terminal */ | 98 | /* Check if we need to scroll the terminal */ |
98 | if ((priv->ycur + priv->y_charsize) / priv->y_charsize > priv->rows) { | 99 | if ((priv->ycur + priv->y_charsize) / priv->y_charsize > priv->rows) { |
99 | vidconsole_move_rows(dev, 0, rows, priv->rows - rows); | 100 | vidconsole_move_rows(dev, 0, rows, priv->rows - rows); |
100 | for (i = 0; i < rows; i++) | 101 | for (i = 0; i < rows; i++) |
101 | vidconsole_set_row(dev, priv->rows - i - 1, | 102 | vidconsole_set_row(dev, priv->rows - i - 1, |
102 | vid_priv->colour_bg); | 103 | vid_priv->colour_bg); |
103 | priv->ycur -= rows * priv->y_charsize; | 104 | priv->ycur -= rows * priv->y_charsize; |
104 | } | 105 | } |
105 | priv->last_ch = 0; | 106 | priv->last_ch = 0; |
106 | 107 | ||
107 | video_sync(dev->parent); | 108 | video_sync(dev->parent); |
108 | } | 109 | } |
109 | 110 | ||
111 | static char *parsenum(char *s, int *num) | ||
112 | { | ||
113 | char *end; | ||
114 | *num = simple_strtol(s, &end, 10); | ||
115 | return end; | ||
116 | } | ||
117 | |||
118 | /* | ||
119 | * Process a character while accumulating an escape string. Chars are | ||
120 | * accumulated into escape_buf until the end of escape sequence is | ||
121 | * found, at which point the sequence is parsed and processed. | ||
122 | */ | ||
123 | static void vidconsole_escape_char(struct udevice *dev, char ch) | ||
124 | { | ||
125 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); | ||
126 | |||
127 | if (!IS_ENABLED(CONFIG_VIDEO_ANSI)) | ||
128 | goto error; | ||
129 | |||
130 | /* Sanity checking for bogus ESC sequences: */ | ||
131 | if (priv->escape_len >= sizeof(priv->escape_buf)) | ||
132 | goto error; | ||
133 | if (priv->escape_len == 0 && ch != '[') | ||
134 | goto error; | ||
135 | |||
136 | priv->escape_buf[priv->escape_len++] = ch; | ||
137 | |||
138 | /* | ||
139 | * Escape sequences are terminated by a letter, so keep | ||
140 | * accumulating until we get one: | ||
141 | */ | ||
142 | if (!isalpha(ch)) | ||
143 | return; | ||
144 | |||
145 | /* | ||
146 | * clear escape mode first, otherwise things will get highly | ||
147 | * surprising if you hit any debug prints that come back to | ||
148 | * this console. | ||
149 | */ | ||
150 | priv->escape = 0; | ||
151 | |||
152 | switch (ch) { | ||
153 | case 'H': | ||
154 | case 'f': { | ||
155 | int row, col; | ||
156 | char *s = priv->escape_buf; | ||
157 | |||
158 | /* | ||
159 | * Set cursor position: [%d;%df or [%d;%dH | ||
160 | */ | ||
161 | s++; /* [ */ | ||
162 | s = parsenum(s, &row); | ||
163 | s++; /* ; */ | ||
164 | s = parsenum(s, &col); | ||
165 | |||
166 | priv->ycur = row * priv->y_charsize; | ||
167 | priv->xcur_frac = priv->xstart_frac + | ||
168 | VID_TO_POS(col * priv->x_charsize); | ||
169 | |||
170 | break; | ||
171 | } | ||
172 | case 'J': { | ||
173 | int mode; | ||
174 | |||
175 | /* | ||
176 | * Clear part/all screen: | ||
177 | * [J or [0J - clear screen from cursor down | ||
178 | * [1J - clear screen from cursor up | ||
179 | * [2J - clear entire screen | ||
180 | * | ||
181 | * TODO we really only handle entire-screen case, others | ||
182 | * probably require some additions to video-uclass (and | ||
183 | * are not really needed yet by efi_console) | ||
184 | */ | ||
185 | parsenum(priv->escape_buf + 1, &mode); | ||
186 | |||
187 | if (mode == 2) { | ||
188 | video_clear(dev->parent); | ||
189 | video_sync(dev->parent); | ||
190 | priv->ycur = 0; | ||
191 | priv->xcur_frac = priv->xstart_frac; | ||
192 | } else { | ||
193 | debug("unsupported clear mode: %d\n", mode); | ||
194 | } | ||
195 | break; | ||
196 | } | ||
197 | default: | ||
198 | debug("unrecognized escape sequence: %*s\n", | ||
199 | priv->escape_len, priv->escape_buf); | ||
200 | } | ||
201 | |||
202 | return; | ||
203 | |||
204 | error: | ||
205 | /* something went wrong, just revert to normal mode: */ | ||
206 | priv->escape = 0; | ||
207 | } | ||
208 | |||
110 | int vidconsole_put_char(struct udevice *dev, char ch) | 209 | int vidconsole_put_char(struct udevice *dev, char ch) |
111 | { | 210 | { |
112 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); | 211 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); |
113 | int ret; | 212 | int ret; |
114 | 213 | ||
214 | if (priv->escape) { | ||
215 | vidconsole_escape_char(dev, ch); | ||
216 | return 0; | ||
217 | } | ||
218 | |||
115 | switch (ch) { | 219 | switch (ch) { |
220 | case '\x1b': | ||
221 | priv->escape_len = 0; | ||
222 | priv->escape = 1; | ||
223 | break; | ||
116 | case '\a': | 224 | case '\a': |
117 | /* beep */ | 225 | /* beep */ |
118 | break; | 226 | break; |
119 | case '\r': | 227 | case '\r': |
120 | priv->xcur_frac = priv->xstart_frac; | 228 | priv->xcur_frac = priv->xstart_frac; |
121 | break; | 229 | break; |
122 | case '\n': | 230 | case '\n': |
123 | vidconsole_newline(dev); | 231 | vidconsole_newline(dev); |
124 | vidconsole_entry_start(dev); | 232 | vidconsole_entry_start(dev); |
125 | break; | 233 | break; |
126 | case '\t': /* Tab (8 chars alignment) */ | 234 | case '\t': /* Tab (8 chars alignment) */ |
127 | priv->xcur_frac = ((priv->xcur_frac / priv->tab_width_frac) | 235 | priv->xcur_frac = ((priv->xcur_frac / priv->tab_width_frac) |
128 | + 1) * priv->tab_width_frac; | 236 | + 1) * priv->tab_width_frac; |
129 | 237 | ||
130 | if (priv->xcur_frac >= priv->xsize_frac) | 238 | if (priv->xcur_frac >= priv->xsize_frac) |
131 | vidconsole_newline(dev); | 239 | vidconsole_newline(dev); |
132 | break; | 240 | break; |
133 | case '\b': | 241 | case '\b': |
134 | vidconsole_back(dev); | 242 | vidconsole_back(dev); |
135 | priv->last_ch = 0; | 243 | priv->last_ch = 0; |
136 | break; | 244 | break; |
137 | default: | 245 | default: |
138 | /* | 246 | /* |
139 | * Failure of this function normally indicates an unsupported | 247 | * Failure of this function normally indicates an unsupported |
140 | * colour depth. Check this and return an error to help with | 248 | * colour depth. Check this and return an error to help with |
141 | * diagnosis. | 249 | * diagnosis. |
142 | */ | 250 | */ |
143 | ret = vidconsole_putc_xy(dev, priv->xcur_frac, priv->ycur, ch); | 251 | ret = vidconsole_putc_xy(dev, priv->xcur_frac, priv->ycur, ch); |
144 | if (ret == -EAGAIN) { | 252 | if (ret == -EAGAIN) { |
145 | vidconsole_newline(dev); | 253 | vidconsole_newline(dev); |
146 | ret = vidconsole_putc_xy(dev, priv->xcur_frac, | 254 | ret = vidconsole_putc_xy(dev, priv->xcur_frac, |
147 | priv->ycur, ch); | 255 | priv->ycur, ch); |
148 | } | 256 | } |
149 | if (ret < 0) | 257 | if (ret < 0) |
150 | return ret; | 258 | return ret; |
151 | priv->xcur_frac += ret; | 259 | priv->xcur_frac += ret; |
152 | priv->last_ch = ch; | 260 | priv->last_ch = ch; |
153 | if (priv->xcur_frac >= priv->xsize_frac) | 261 | if (priv->xcur_frac >= priv->xsize_frac) |
154 | vidconsole_newline(dev); | 262 | vidconsole_newline(dev); |
155 | break; | 263 | break; |
156 | } | 264 | } |
157 | 265 | ||
158 | return 0; | 266 | return 0; |
159 | } | 267 | } |
160 | 268 | ||
161 | static void vidconsole_putc(struct stdio_dev *sdev, const char ch) | 269 | static void vidconsole_putc(struct stdio_dev *sdev, const char ch) |
162 | { | 270 | { |
163 | struct udevice *dev = sdev->priv; | 271 | struct udevice *dev = sdev->priv; |
164 | 272 | ||
165 | vidconsole_put_char(dev, ch); | 273 | vidconsole_put_char(dev, ch); |
166 | video_sync(dev->parent); | 274 | video_sync(dev->parent); |
167 | } | 275 | } |
168 | 276 | ||
169 | static void vidconsole_puts(struct stdio_dev *sdev, const char *s) | 277 | static void vidconsole_puts(struct stdio_dev *sdev, const char *s) |
170 | { | 278 | { |
171 | struct udevice *dev = sdev->priv; | 279 | struct udevice *dev = sdev->priv; |
172 | 280 | ||
173 | while (*s) | 281 | while (*s) |
174 | vidconsole_put_char(dev, *s++); | 282 | vidconsole_put_char(dev, *s++); |
175 | video_sync(dev->parent); | 283 | video_sync(dev->parent); |
176 | } | 284 | } |
177 | 285 | ||
178 | /* Set up the number of rows and colours (rotated drivers override this) */ | 286 | /* Set up the number of rows and colours (rotated drivers override this) */ |
179 | static int vidconsole_pre_probe(struct udevice *dev) | 287 | static int vidconsole_pre_probe(struct udevice *dev) |
180 | { | 288 | { |
181 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); | 289 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); |
182 | struct udevice *vid = dev->parent; | 290 | struct udevice *vid = dev->parent; |
183 | struct video_priv *vid_priv = dev_get_uclass_priv(vid); | 291 | struct video_priv *vid_priv = dev_get_uclass_priv(vid); |
184 | 292 | ||
185 | priv->xsize_frac = VID_TO_POS(vid_priv->xsize); | 293 | priv->xsize_frac = VID_TO_POS(vid_priv->xsize); |
186 | 294 | ||
187 | return 0; | 295 | return 0; |
188 | } | 296 | } |
189 | 297 | ||
190 | /* Register the device with stdio */ | 298 | /* Register the device with stdio */ |
191 | static int vidconsole_post_probe(struct udevice *dev) | 299 | static int vidconsole_post_probe(struct udevice *dev) |
192 | { | 300 | { |
193 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); | 301 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); |
194 | struct stdio_dev *sdev = &priv->sdev; | 302 | struct stdio_dev *sdev = &priv->sdev; |
195 | 303 | ||
196 | if (!priv->tab_width_frac) | 304 | if (!priv->tab_width_frac) |
197 | priv->tab_width_frac = VID_TO_POS(priv->x_charsize) * 8; | 305 | priv->tab_width_frac = VID_TO_POS(priv->x_charsize) * 8; |
198 | 306 | ||
199 | if (dev->seq) { | 307 | if (dev->seq) { |
200 | snprintf(sdev->name, sizeof(sdev->name), "vidconsole%d", | 308 | snprintf(sdev->name, sizeof(sdev->name), "vidconsole%d", |
201 | dev->seq); | 309 | dev->seq); |
202 | } else { | 310 | } else { |
203 | strcpy(sdev->name, "vidconsole"); | 311 | strcpy(sdev->name, "vidconsole"); |
204 | } | 312 | } |
205 | 313 | ||
206 | sdev->flags = DEV_FLAGS_OUTPUT; | 314 | sdev->flags = DEV_FLAGS_OUTPUT; |
207 | sdev->putc = vidconsole_putc; | 315 | sdev->putc = vidconsole_putc; |
208 | sdev->puts = vidconsole_puts; | 316 | sdev->puts = vidconsole_puts; |
209 | sdev->priv = dev; | 317 | sdev->priv = dev; |
210 | 318 | ||
211 | return stdio_register(sdev); | 319 | return stdio_register(sdev); |
212 | } | 320 | } |
213 | 321 | ||
214 | UCLASS_DRIVER(vidconsole) = { | 322 | UCLASS_DRIVER(vidconsole) = { |
215 | .id = UCLASS_VIDEO_CONSOLE, | 323 | .id = UCLASS_VIDEO_CONSOLE, |
216 | .name = "vidconsole0", | 324 | .name = "vidconsole0", |
217 | .pre_probe = vidconsole_pre_probe, | 325 | .pre_probe = vidconsole_pre_probe, |
218 | .post_probe = vidconsole_post_probe, | 326 | .post_probe = vidconsole_post_probe, |
219 | .per_device_auto_alloc_size = sizeof(struct vidconsole_priv), | 327 | .per_device_auto_alloc_size = sizeof(struct vidconsole_priv), |
220 | }; | 328 | }; |
221 | 329 | ||
222 | void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row) | 330 | void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row) |
223 | { | 331 | { |
224 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); | 332 | struct vidconsole_priv *priv = dev_get_uclass_priv(dev); |
225 | struct udevice *vid_dev = dev->parent; | 333 | struct udevice *vid_dev = dev->parent; |
226 | struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev); | 334 | struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev); |
227 | 335 | ||
228 | priv->xcur_frac = VID_TO_POS(min_t(short, col, vid_priv->xsize - 1)); | 336 | priv->xcur_frac = VID_TO_POS(min_t(short, col, vid_priv->xsize - 1)); |
229 | priv->ycur = min_t(short, row, vid_priv->ysize - 1); | 337 | priv->ycur = min_t(short, row, vid_priv->ysize - 1); |
230 | } | 338 | } |
231 | 339 | ||
232 | static int do_video_setcursor(cmd_tbl_t *cmdtp, int flag, int argc, | 340 | static int do_video_setcursor(cmd_tbl_t *cmdtp, int flag, int argc, |
233 | char *const argv[]) | 341 | char *const argv[]) |
234 | { | 342 | { |
235 | unsigned int col, row; | 343 | unsigned int col, row; |
236 | struct udevice *dev; | 344 | struct udevice *dev; |
237 | 345 | ||
238 | if (argc != 3) | 346 | if (argc != 3) |
239 | return CMD_RET_USAGE; | 347 | return CMD_RET_USAGE; |
240 | 348 | ||
241 | if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) | 349 | if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) |
242 | return CMD_RET_FAILURE; | 350 | return CMD_RET_FAILURE; |
243 | col = simple_strtoul(argv[1], NULL, 10); | 351 | col = simple_strtoul(argv[1], NULL, 10); |
244 | row = simple_strtoul(argv[2], NULL, 10); | 352 | row = simple_strtoul(argv[2], NULL, 10); |
245 | vidconsole_position_cursor(dev, col, row); | 353 | vidconsole_position_cursor(dev, col, row); |
246 | 354 | ||
247 | return 0; | 355 | return 0; |
248 | } | 356 | } |
249 | 357 | ||
250 | static int do_video_puts(cmd_tbl_t *cmdtp, int flag, int argc, | 358 | static int do_video_puts(cmd_tbl_t *cmdtp, int flag, int argc, |
251 | char *const argv[]) | 359 | char *const argv[]) |
252 | { | 360 | { |
253 | struct udevice *dev; | 361 | struct udevice *dev; |
254 | const char *s; | 362 | const char *s; |
255 | 363 | ||
256 | if (argc != 2) | 364 | if (argc != 2) |
257 | return CMD_RET_USAGE; | 365 | return CMD_RET_USAGE; |
258 | 366 | ||
259 | if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) | 367 | if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) |
260 | return CMD_RET_FAILURE; | 368 | return CMD_RET_FAILURE; |
261 | for (s = argv[1]; *s; s++) | 369 | for (s = argv[1]; *s; s++) |
262 | vidconsole_put_char(dev, *s); | 370 | vidconsole_put_char(dev, *s); |
263 | 371 | ||
264 | video_sync(dev->parent); | 372 | video_sync(dev->parent); |
265 | 373 | ||
266 | return 0; | 374 | return 0; |
267 | } | 375 | } |
268 | 376 | ||
269 | U_BOOT_CMD( | 377 | U_BOOT_CMD( |
270 | setcurs, 3, 1, do_video_setcursor, | 378 | setcurs, 3, 1, do_video_setcursor, |
271 | "set cursor position within screen", | 379 | "set cursor position within screen", |
272 | " <col> <row> in character" | 380 | " <col> <row> in character" |
273 | ); | 381 | ); |
274 | 382 | ||
275 | U_BOOT_CMD( | 383 | U_BOOT_CMD( |
276 | lcdputs, 2, 1, do_video_puts, | 384 | lcdputs, 2, 1, do_video_puts, |
277 | "print string on video framebuffer", | 385 | "print string on video framebuffer", |
278 | " <string>" | 386 | " <string>" |
279 | ); | 387 | ); |
280 | 388 |
drivers/video/video-uclass.c
1 | /* | 1 | /* |
2 | * Copyright (c) 2015 Google, Inc | 2 | * Copyright (c) 2015 Google, Inc |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: GPL-2.0+ | 4 | * SPDX-License-Identifier: GPL-2.0+ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <common.h> | 7 | #include <common.h> |
8 | #include <dm.h> | 8 | #include <dm.h> |
9 | #include <mapmem.h> | 9 | #include <mapmem.h> |
10 | #include <stdio_dev.h> | 10 | #include <stdio_dev.h> |
11 | #include <video.h> | 11 | #include <video.h> |
12 | #include <video_console.h> | 12 | #include <video_console.h> |
13 | #include <dm/lists.h> | 13 | #include <dm/lists.h> |
14 | #include <dm/device-internal.h> | 14 | #include <dm/device-internal.h> |
15 | #include <dm/uclass-internal.h> | 15 | #include <dm/uclass-internal.h> |
16 | #ifdef CONFIG_SANDBOX | 16 | #ifdef CONFIG_SANDBOX |
17 | #include <asm/sdl.h> | 17 | #include <asm/sdl.h> |
18 | #endif | 18 | #endif |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * Theory of operation: | 21 | * Theory of operation: |
22 | * | 22 | * |
23 | * Before relocation each device is bound. The driver for each device must | 23 | * Before relocation each device is bound. The driver for each device must |
24 | * set the @align and @size values in struct video_uc_platdata. This | 24 | * set the @align and @size values in struct video_uc_platdata. This |
25 | * information represents the requires size and alignment of the frame buffer | 25 | * information represents the requires size and alignment of the frame buffer |
26 | * for the device. The values can be an over-estimate but cannot be too | 26 | * for the device. The values can be an over-estimate but cannot be too |
27 | * small. The actual values will be suppled (in the same manner) by the bind() | 27 | * small. The actual values will be suppled (in the same manner) by the bind() |
28 | * method after relocation. | 28 | * method after relocation. |
29 | * | 29 | * |
30 | * This information is then picked up by video_reserve() which works out how | 30 | * This information is then picked up by video_reserve() which works out how |
31 | * much memory is needed for all devices. This is allocated between | 31 | * much memory is needed for all devices. This is allocated between |
32 | * gd->video_bottom and gd->video_top. | 32 | * gd->video_bottom and gd->video_top. |
33 | * | 33 | * |
34 | * After relocation the same process occurs. The driver supplies the same | 34 | * After relocation the same process occurs. The driver supplies the same |
35 | * @size and @align information and this time video_post_bind() checks that | 35 | * @size and @align information and this time video_post_bind() checks that |
36 | * the drivers does not overflow the allocated memory. | 36 | * the drivers does not overflow the allocated memory. |
37 | * | 37 | * |
38 | * The frame buffer address is actually set (to plat->base) in | 38 | * The frame buffer address is actually set (to plat->base) in |
39 | * video_post_probe(). This function also clears the frame buffer and | 39 | * video_post_probe(). This function also clears the frame buffer and |
40 | * allocates a suitable text console device. This can then be used to write | 40 | * allocates a suitable text console device. This can then be used to write |
41 | * text to the video device. | 41 | * text to the video device. |
42 | */ | 42 | */ |
43 | DECLARE_GLOBAL_DATA_PTR; | 43 | DECLARE_GLOBAL_DATA_PTR; |
44 | 44 | ||
45 | void video_set_flush_dcache(struct udevice *dev, bool flush) | 45 | void video_set_flush_dcache(struct udevice *dev, bool flush) |
46 | { | 46 | { |
47 | struct video_priv *priv = dev_get_uclass_priv(dev); | 47 | struct video_priv *priv = dev_get_uclass_priv(dev); |
48 | 48 | ||
49 | priv->flush_dcache = flush; | 49 | priv->flush_dcache = flush; |
50 | } | 50 | } |
51 | 51 | ||
52 | static ulong alloc_fb(struct udevice *dev, ulong *addrp) | 52 | static ulong alloc_fb(struct udevice *dev, ulong *addrp) |
53 | { | 53 | { |
54 | struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); | 54 | struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); |
55 | ulong base, align, size; | 55 | ulong base, align, size; |
56 | 56 | ||
57 | if (!plat->size) | 57 | if (!plat->size) |
58 | return 0; | 58 | return 0; |
59 | 59 | ||
60 | align = plat->align ? plat->align : 1 << 20; | 60 | align = plat->align ? plat->align : 1 << 20; |
61 | base = *addrp - plat->size; | 61 | base = *addrp - plat->size; |
62 | base &= ~(align - 1); | 62 | base &= ~(align - 1); |
63 | plat->base = base; | 63 | plat->base = base; |
64 | size = *addrp - base; | 64 | size = *addrp - base; |
65 | *addrp = base; | 65 | *addrp = base; |
66 | 66 | ||
67 | return size; | 67 | return size; |
68 | } | 68 | } |
69 | 69 | ||
70 | int video_reserve(ulong *addrp) | 70 | int video_reserve(ulong *addrp) |
71 | { | 71 | { |
72 | struct udevice *dev; | 72 | struct udevice *dev; |
73 | ulong size; | 73 | ulong size; |
74 | 74 | ||
75 | gd->video_top = *addrp; | 75 | gd->video_top = *addrp; |
76 | for (uclass_find_first_device(UCLASS_VIDEO, &dev); | 76 | for (uclass_find_first_device(UCLASS_VIDEO, &dev); |
77 | dev; | 77 | dev; |
78 | uclass_find_next_device(&dev)) { | 78 | uclass_find_next_device(&dev)) { |
79 | size = alloc_fb(dev, addrp); | 79 | size = alloc_fb(dev, addrp); |
80 | debug("%s: Reserving %lx bytes at %lx for video device '%s'\n", | 80 | debug("%s: Reserving %lx bytes at %lx for video device '%s'\n", |
81 | __func__, size, *addrp, dev->name); | 81 | __func__, size, *addrp, dev->name); |
82 | } | 82 | } |
83 | gd->video_bottom = *addrp; | 83 | gd->video_bottom = *addrp; |
84 | debug("Video frame buffers from %lx to %lx\n", gd->video_bottom, | 84 | debug("Video frame buffers from %lx to %lx\n", gd->video_bottom, |
85 | gd->video_top); | 85 | gd->video_top); |
86 | 86 | ||
87 | return 0; | 87 | return 0; |
88 | } | 88 | } |
89 | 89 | ||
90 | static int video_clear(struct udevice *dev) | 90 | void video_clear(struct udevice *dev) |
91 | { | 91 | { |
92 | struct video_priv *priv = dev_get_uclass_priv(dev); | 92 | struct video_priv *priv = dev_get_uclass_priv(dev); |
93 | 93 | ||
94 | if (priv->bpix == VIDEO_BPP32) { | 94 | if (priv->bpix == VIDEO_BPP32) { |
95 | u32 *ppix = priv->fb; | 95 | u32 *ppix = priv->fb; |
96 | u32 *end = priv->fb + priv->fb_size; | 96 | u32 *end = priv->fb + priv->fb_size; |
97 | 97 | ||
98 | while (ppix < end) | 98 | while (ppix < end) |
99 | *ppix++ = priv->colour_bg; | 99 | *ppix++ = priv->colour_bg; |
100 | } else { | 100 | } else { |
101 | memset(priv->fb, priv->colour_bg, priv->fb_size); | 101 | memset(priv->fb, priv->colour_bg, priv->fb_size); |
102 | } | 102 | } |
103 | |||
104 | return 0; | ||
105 | } | 103 | } |
106 | 104 | ||
107 | /* Flush video activity to the caches */ | 105 | /* Flush video activity to the caches */ |
108 | void video_sync(struct udevice *vid) | 106 | void video_sync(struct udevice *vid) |
109 | { | 107 | { |
110 | /* | 108 | /* |
111 | * flush_dcache_range() is declared in common.h but it seems that some | 109 | * flush_dcache_range() is declared in common.h but it seems that some |
112 | * architectures do not actually implement it. Is there a way to find | 110 | * architectures do not actually implement it. Is there a way to find |
113 | * out whether it exists? For now, ARM is safe. | 111 | * out whether it exists? For now, ARM is safe. |
114 | */ | 112 | */ |
115 | #if defined(CONFIG_ARM) && !defined(CONFIG_SYS_DCACHE_OFF) | 113 | #if defined(CONFIG_ARM) && !defined(CONFIG_SYS_DCACHE_OFF) |
116 | struct video_priv *priv = dev_get_uclass_priv(vid); | 114 | struct video_priv *priv = dev_get_uclass_priv(vid); |
117 | 115 | ||
118 | if (priv->flush_dcache) { | 116 | if (priv->flush_dcache) { |
119 | flush_dcache_range((ulong)priv->fb, | 117 | flush_dcache_range((ulong)priv->fb, |
120 | ALIGN((ulong)priv->fb + priv->fb_size, | 118 | ALIGN((ulong)priv->fb + priv->fb_size, |
121 | CONFIG_SYS_CACHELINE_SIZE)); | 119 | CONFIG_SYS_CACHELINE_SIZE)); |
122 | } | 120 | } |
123 | #elif defined(CONFIG_VIDEO_SANDBOX_SDL) | 121 | #elif defined(CONFIG_VIDEO_SANDBOX_SDL) |
124 | struct video_priv *priv = dev_get_uclass_priv(vid); | 122 | struct video_priv *priv = dev_get_uclass_priv(vid); |
125 | static ulong last_sync; | 123 | static ulong last_sync; |
126 | 124 | ||
127 | if (get_timer(last_sync) > 10) { | 125 | if (get_timer(last_sync) > 10) { |
128 | sandbox_sdl_sync(priv->fb); | 126 | sandbox_sdl_sync(priv->fb); |
129 | last_sync = get_timer(0); | 127 | last_sync = get_timer(0); |
130 | } | 128 | } |
131 | #endif | 129 | #endif |
132 | } | 130 | } |
133 | 131 | ||
134 | void video_sync_all(void) | 132 | void video_sync_all(void) |
135 | { | 133 | { |
136 | struct udevice *dev; | 134 | struct udevice *dev; |
137 | 135 | ||
138 | for (uclass_find_first_device(UCLASS_VIDEO, &dev); | 136 | for (uclass_find_first_device(UCLASS_VIDEO, &dev); |
139 | dev; | 137 | dev; |
140 | uclass_find_next_device(&dev)) { | 138 | uclass_find_next_device(&dev)) { |
141 | if (device_active(dev)) | 139 | if (device_active(dev)) |
142 | video_sync(dev); | 140 | video_sync(dev); |
143 | } | 141 | } |
144 | } | 142 | } |
145 | 143 | ||
146 | int video_get_xsize(struct udevice *dev) | 144 | int video_get_xsize(struct udevice *dev) |
147 | { | 145 | { |
148 | struct video_priv *priv = dev_get_uclass_priv(dev); | 146 | struct video_priv *priv = dev_get_uclass_priv(dev); |
149 | 147 | ||
150 | return priv->xsize; | 148 | return priv->xsize; |
151 | } | 149 | } |
152 | 150 | ||
153 | int video_get_ysize(struct udevice *dev) | 151 | int video_get_ysize(struct udevice *dev) |
154 | { | 152 | { |
155 | struct video_priv *priv = dev_get_uclass_priv(dev); | 153 | struct video_priv *priv = dev_get_uclass_priv(dev); |
156 | 154 | ||
157 | return priv->ysize; | 155 | return priv->ysize; |
158 | } | 156 | } |
159 | 157 | ||
160 | /* Set up the colour map */ | 158 | /* Set up the colour map */ |
161 | static int video_pre_probe(struct udevice *dev) | 159 | static int video_pre_probe(struct udevice *dev) |
162 | { | 160 | { |
163 | struct video_priv *priv = dev_get_uclass_priv(dev); | 161 | struct video_priv *priv = dev_get_uclass_priv(dev); |
164 | 162 | ||
165 | priv->cmap = calloc(256, sizeof(ushort)); | 163 | priv->cmap = calloc(256, sizeof(ushort)); |
166 | if (!priv->cmap) | 164 | if (!priv->cmap) |
167 | return -ENOMEM; | 165 | return -ENOMEM; |
168 | 166 | ||
169 | return 0; | 167 | return 0; |
170 | } | 168 | } |
171 | 169 | ||
172 | static int video_pre_remove(struct udevice *dev) | 170 | static int video_pre_remove(struct udevice *dev) |
173 | { | 171 | { |
174 | struct video_priv *priv = dev_get_uclass_priv(dev); | 172 | struct video_priv *priv = dev_get_uclass_priv(dev); |
175 | 173 | ||
176 | free(priv->cmap); | 174 | free(priv->cmap); |
177 | 175 | ||
178 | return 0; | 176 | return 0; |
179 | } | 177 | } |
180 | 178 | ||
181 | /* Set up the display ready for use */ | 179 | /* Set up the display ready for use */ |
182 | static int video_post_probe(struct udevice *dev) | 180 | static int video_post_probe(struct udevice *dev) |
183 | { | 181 | { |
184 | struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); | 182 | struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); |
185 | struct video_priv *priv = dev_get_uclass_priv(dev); | 183 | struct video_priv *priv = dev_get_uclass_priv(dev); |
186 | char name[30], drv[15], *str; | 184 | char name[30], drv[15], *str; |
187 | const char *drv_name = drv; | 185 | const char *drv_name = drv; |
188 | struct udevice *cons; | 186 | struct udevice *cons; |
189 | int ret; | 187 | int ret; |
190 | 188 | ||
191 | /* Set up the line and display size */ | 189 | /* Set up the line and display size */ |
192 | priv->fb = map_sysmem(plat->base, plat->size); | 190 | priv->fb = map_sysmem(plat->base, plat->size); |
193 | priv->line_length = priv->xsize * VNBYTES(priv->bpix); | 191 | priv->line_length = priv->xsize * VNBYTES(priv->bpix); |
194 | priv->fb_size = priv->line_length * priv->ysize; | 192 | priv->fb_size = priv->line_length * priv->ysize; |
195 | 193 | ||
196 | /* Set up colours - we could in future support other colours */ | 194 | /* Set up colours - we could in future support other colours */ |
197 | #ifdef CONFIG_SYS_WHITE_ON_BLACK | 195 | #ifdef CONFIG_SYS_WHITE_ON_BLACK |
198 | priv->colour_fg = 0xffffff; | 196 | priv->colour_fg = 0xffffff; |
199 | #else | 197 | #else |
200 | priv->colour_bg = 0xffffff; | 198 | priv->colour_bg = 0xffffff; |
201 | #endif | 199 | #endif |
202 | 200 | ||
203 | if (!CONFIG_IS_ENABLED(NO_FB_CLEAR)) | 201 | if (!CONFIG_IS_ENABLED(NO_FB_CLEAR)) |
204 | video_clear(dev); | 202 | video_clear(dev); |
205 | 203 | ||
206 | /* | 204 | /* |
207 | * Create a text console device. For now we always do this, although | 205 | * Create a text console device. For now we always do this, although |
208 | * it might be useful to support only bitmap drawing on the device | 206 | * it might be useful to support only bitmap drawing on the device |
209 | * for boards that don't need to display text. We create a TrueType | 207 | * for boards that don't need to display text. We create a TrueType |
210 | * console if enabled, a rotated console if the video driver requests | 208 | * console if enabled, a rotated console if the video driver requests |
211 | * it, otherwise a normal console. | 209 | * it, otherwise a normal console. |
212 | * | 210 | * |
213 | * The console can be override by setting vidconsole_drv_name before | 211 | * The console can be override by setting vidconsole_drv_name before |
214 | * probing this video driver, or in the probe() method. | 212 | * probing this video driver, or in the probe() method. |
215 | * | 213 | * |
216 | * TrueType does not support rotation at present so fall back to the | 214 | * TrueType does not support rotation at present so fall back to the |
217 | * rotated console in that case. | 215 | * rotated console in that case. |
218 | */ | 216 | */ |
219 | if (!priv->rot && IS_ENABLED(CONFIG_CONSOLE_TRUETYPE)) { | 217 | if (!priv->rot && IS_ENABLED(CONFIG_CONSOLE_TRUETYPE)) { |
220 | snprintf(name, sizeof(name), "%s.vidconsole_tt", dev->name); | 218 | snprintf(name, sizeof(name), "%s.vidconsole_tt", dev->name); |
221 | strcpy(drv, "vidconsole_tt"); | 219 | strcpy(drv, "vidconsole_tt"); |
222 | } else { | 220 | } else { |
223 | snprintf(name, sizeof(name), "%s.vidconsole%d", dev->name, | 221 | snprintf(name, sizeof(name), "%s.vidconsole%d", dev->name, |
224 | priv->rot); | 222 | priv->rot); |
225 | snprintf(drv, sizeof(drv), "vidconsole%d", priv->rot); | 223 | snprintf(drv, sizeof(drv), "vidconsole%d", priv->rot); |
226 | } | 224 | } |
227 | 225 | ||
228 | str = strdup(name); | 226 | str = strdup(name); |
229 | if (!str) | 227 | if (!str) |
230 | return -ENOMEM; | 228 | return -ENOMEM; |
231 | if (priv->vidconsole_drv_name) | 229 | if (priv->vidconsole_drv_name) |
232 | drv_name = priv->vidconsole_drv_name; | 230 | drv_name = priv->vidconsole_drv_name; |
233 | ret = device_bind_driver(dev, drv_name, str, &cons); | 231 | ret = device_bind_driver(dev, drv_name, str, &cons); |
234 | if (ret) { | 232 | if (ret) { |
235 | debug("%s: Cannot bind console driver\n", __func__); | 233 | debug("%s: Cannot bind console driver\n", __func__); |
236 | return ret; | 234 | return ret; |
237 | } | 235 | } |
238 | 236 | ||
239 | ret = device_probe(cons); | 237 | ret = device_probe(cons); |
240 | if (ret) { | 238 | if (ret) { |
241 | debug("%s: Cannot probe console driver\n", __func__); | 239 | debug("%s: Cannot probe console driver\n", __func__); |
242 | return ret; | 240 | return ret; |
243 | } | 241 | } |
244 | 242 | ||
245 | return 0; | 243 | return 0; |
246 | }; | 244 | }; |
247 | 245 | ||
248 | /* Post-relocation, allocate memory for the frame buffer */ | 246 | /* Post-relocation, allocate memory for the frame buffer */ |
249 | static int video_post_bind(struct udevice *dev) | 247 | static int video_post_bind(struct udevice *dev) |
250 | { | 248 | { |
251 | ulong addr = gd->video_top; | 249 | ulong addr = gd->video_top; |
252 | ulong size; | 250 | ulong size; |
253 | 251 | ||
254 | /* Before relocation there is nothing to do here */ | 252 | /* Before relocation there is nothing to do here */ |
255 | if ((!gd->flags & GD_FLG_RELOC)) | 253 | if ((!gd->flags & GD_FLG_RELOC)) |
256 | return 0; | 254 | return 0; |
257 | size = alloc_fb(dev, &addr); | 255 | size = alloc_fb(dev, &addr); |
258 | if (addr < gd->video_bottom) { | 256 | if (addr < gd->video_bottom) { |
259 | /* Device tree node may need the 'u-boot,dm-pre-reloc' tag */ | 257 | /* Device tree node may need the 'u-boot,dm-pre-reloc' tag */ |
260 | printf("Video device '%s' cannot allocate frame buffer memory -ensure the device is set up before relocation\n", | 258 | printf("Video device '%s' cannot allocate frame buffer memory -ensure the device is set up before relocation\n", |
261 | dev->name); | 259 | dev->name); |
262 | return -ENOSPC; | 260 | return -ENOSPC; |
263 | } | 261 | } |
264 | debug("%s: Claiming %lx bytes at %lx for video device '%s'\n", | 262 | debug("%s: Claiming %lx bytes at %lx for video device '%s'\n", |
265 | __func__, size, addr, dev->name); | 263 | __func__, size, addr, dev->name); |
266 | gd->video_bottom = addr; | 264 | gd->video_bottom = addr; |
267 | 265 | ||
268 | return 0; | 266 | return 0; |
269 | } | 267 | } |
270 | 268 | ||
271 | UCLASS_DRIVER(video) = { | 269 | UCLASS_DRIVER(video) = { |
272 | .id = UCLASS_VIDEO, | 270 | .id = UCLASS_VIDEO, |
273 | .name = "video", | 271 | .name = "video", |
274 | .flags = DM_UC_FLAG_SEQ_ALIAS, | 272 | .flags = DM_UC_FLAG_SEQ_ALIAS, |
275 | .post_bind = video_post_bind, | 273 | .post_bind = video_post_bind, |
276 | .pre_probe = video_pre_probe, | 274 | .pre_probe = video_pre_probe, |
277 | .post_probe = video_post_probe, | 275 | .post_probe = video_post_probe, |
278 | .pre_remove = video_pre_remove, | 276 | .pre_remove = video_pre_remove, |
279 | .per_device_auto_alloc_size = sizeof(struct video_priv), | 277 | .per_device_auto_alloc_size = sizeof(struct video_priv), |
280 | .per_device_platdata_auto_alloc_size = sizeof(struct video_uc_platdata), | 278 | .per_device_platdata_auto_alloc_size = sizeof(struct video_uc_platdata), |
281 | }; | 279 | }; |
282 | 280 |
include/video.h
1 | /* | 1 | /* |
2 | * Video uclass and legacy implementation | 2 | * Video uclass and legacy implementation |
3 | * | 3 | * |
4 | * Copyright (c) 2015 Google, Inc | 4 | * Copyright (c) 2015 Google, Inc |
5 | * | 5 | * |
6 | * MPC823 Video Controller | 6 | * MPC823 Video Controller |
7 | * ======================= | 7 | * ======================= |
8 | * (C) 2000 by Paolo Scaffardi (arsenio@tin.it) | 8 | * (C) 2000 by Paolo Scaffardi (arsenio@tin.it) |
9 | * AIRVENT SAM s.p.a - RIMINI(ITALY) | 9 | * AIRVENT SAM s.p.a - RIMINI(ITALY) |
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #ifndef _VIDEO_H_ | 13 | #ifndef _VIDEO_H_ |
14 | #define _VIDEO_H_ | 14 | #define _VIDEO_H_ |
15 | 15 | ||
16 | #ifdef CONFIG_DM_VIDEO | 16 | #ifdef CONFIG_DM_VIDEO |
17 | 17 | ||
18 | #include <stdio_dev.h> | 18 | #include <stdio_dev.h> |
19 | 19 | ||
20 | struct video_uc_platdata { | 20 | struct video_uc_platdata { |
21 | uint align; | 21 | uint align; |
22 | uint size; | 22 | uint size; |
23 | ulong base; | 23 | ulong base; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | enum video_polarity { | 26 | enum video_polarity { |
27 | VIDEO_ACTIVE_HIGH, /* Pins are active high */ | 27 | VIDEO_ACTIVE_HIGH, /* Pins are active high */ |
28 | VIDEO_ACTIVE_LOW, /* Pins are active low */ | 28 | VIDEO_ACTIVE_LOW, /* Pins are active low */ |
29 | }; | 29 | }; |
30 | 30 | ||
31 | /* | 31 | /* |
32 | * Bits per pixel selector. Each value n is such that the bits-per-pixel is | 32 | * Bits per pixel selector. Each value n is such that the bits-per-pixel is |
33 | * 2 ^ n | 33 | * 2 ^ n |
34 | */ | 34 | */ |
35 | enum video_log2_bpp { | 35 | enum video_log2_bpp { |
36 | VIDEO_BPP1 = 0, | 36 | VIDEO_BPP1 = 0, |
37 | VIDEO_BPP2, | 37 | VIDEO_BPP2, |
38 | VIDEO_BPP4, | 38 | VIDEO_BPP4, |
39 | VIDEO_BPP8, | 39 | VIDEO_BPP8, |
40 | VIDEO_BPP16, | 40 | VIDEO_BPP16, |
41 | VIDEO_BPP32, | 41 | VIDEO_BPP32, |
42 | }; | 42 | }; |
43 | 43 | ||
44 | /* | 44 | /* |
45 | * Convert enum video_log2_bpp to bytes and bits. Note we omit the outer | 45 | * Convert enum video_log2_bpp to bytes and bits. Note we omit the outer |
46 | * brackets to allow multiplication by fractional pixels. | 46 | * brackets to allow multiplication by fractional pixels. |
47 | */ | 47 | */ |
48 | #define VNBYTES(bpix) (1 << (bpix)) / 8 | 48 | #define VNBYTES(bpix) (1 << (bpix)) / 8 |
49 | 49 | ||
50 | #define VNBITS(bpix) (1 << (bpix)) | 50 | #define VNBITS(bpix) (1 << (bpix)) |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * struct video_priv - Device information used by the video uclass | 53 | * struct video_priv - Device information used by the video uclass |
54 | * | 54 | * |
55 | * @xsize: Number of pixel columns (e.g. 1366) | 55 | * @xsize: Number of pixel columns (e.g. 1366) |
56 | * @ysize: Number of pixels rows (e.g.. 768) | 56 | * @ysize: Number of pixels rows (e.g.. 768) |
57 | * @rot: Display rotation (0=none, 1=90 degrees clockwise, etc.) | 57 | * @rot: Display rotation (0=none, 1=90 degrees clockwise, etc.) |
58 | * @bpix: Encoded bits per pixel | 58 | * @bpix: Encoded bits per pixel |
59 | * @vidconsole_drv_name: Driver to use for the text console, NULL to | 59 | * @vidconsole_drv_name: Driver to use for the text console, NULL to |
60 | * select automatically | 60 | * select automatically |
61 | * @font_size: Font size in pixels (0 to use a default value) | 61 | * @font_size: Font size in pixels (0 to use a default value) |
62 | * @fb: Frame buffer | 62 | * @fb: Frame buffer |
63 | * @fb_size: Frame buffer size | 63 | * @fb_size: Frame buffer size |
64 | * @line_length: Length of each frame buffer line, in bytes | 64 | * @line_length: Length of each frame buffer line, in bytes |
65 | * @colour_fg: Foreground colour (pixel value) | 65 | * @colour_fg: Foreground colour (pixel value) |
66 | * @colour_bg: Background colour (pixel value) | 66 | * @colour_bg: Background colour (pixel value) |
67 | * @flush_dcache: true to enable flushing of the data cache after | 67 | * @flush_dcache: true to enable flushing of the data cache after |
68 | * the LCD is updated | 68 | * the LCD is updated |
69 | * @cmap: Colour map for 8-bit-per-pixel displays | 69 | * @cmap: Colour map for 8-bit-per-pixel displays |
70 | */ | 70 | */ |
71 | struct video_priv { | 71 | struct video_priv { |
72 | /* Things set up by the driver: */ | 72 | /* Things set up by the driver: */ |
73 | ushort xsize; | 73 | ushort xsize; |
74 | ushort ysize; | 74 | ushort ysize; |
75 | ushort rot; | 75 | ushort rot; |
76 | enum video_log2_bpp bpix; | 76 | enum video_log2_bpp bpix; |
77 | const char *vidconsole_drv_name; | 77 | const char *vidconsole_drv_name; |
78 | int font_size; | 78 | int font_size; |
79 | 79 | ||
80 | /* | 80 | /* |
81 | * Things that are private to the uclass: don't use these in the | 81 | * Things that are private to the uclass: don't use these in the |
82 | * driver | 82 | * driver |
83 | */ | 83 | */ |
84 | void *fb; | 84 | void *fb; |
85 | int fb_size; | 85 | int fb_size; |
86 | int line_length; | 86 | int line_length; |
87 | int colour_fg; | 87 | int colour_fg; |
88 | int colour_bg; | 88 | int colour_bg; |
89 | bool flush_dcache; | 89 | bool flush_dcache; |
90 | ushort *cmap; | 90 | ushort *cmap; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | /* Placeholder - there are no video operations at present */ | 93 | /* Placeholder - there are no video operations at present */ |
94 | struct video_ops { | 94 | struct video_ops { |
95 | }; | 95 | }; |
96 | 96 | ||
97 | #define video_get_ops(dev) ((struct video_ops *)(dev)->driver->ops) | 97 | #define video_get_ops(dev) ((struct video_ops *)(dev)->driver->ops) |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * video_reserve() - Reserve frame-buffer memory for video devices | 100 | * video_reserve() - Reserve frame-buffer memory for video devices |
101 | * | 101 | * |
102 | * Note: This function is for internal use. | 102 | * Note: This function is for internal use. |
103 | * | 103 | * |
104 | * This uses the uclass platdata's @size and @align members to figure out | 104 | * This uses the uclass platdata's @size and @align members to figure out |
105 | * a size and position for each frame buffer as part of the pre-relocation | 105 | * a size and position for each frame buffer as part of the pre-relocation |
106 | * process of determining the post-relocation memory layout. | 106 | * process of determining the post-relocation memory layout. |
107 | * | 107 | * |
108 | * gd->video_top is set to the initial value of *@addrp and gd->video_bottom | 108 | * gd->video_top is set to the initial value of *@addrp and gd->video_bottom |
109 | * is set to the final value. | 109 | * is set to the final value. |
110 | * | 110 | * |
111 | * @addrp: On entry, the top of available memory. On exit, the new top, | 111 | * @addrp: On entry, the top of available memory. On exit, the new top, |
112 | * after allocating the required memory. | 112 | * after allocating the required memory. |
113 | * @return 0 | 113 | * @return 0 |
114 | */ | 114 | */ |
115 | int video_reserve(ulong *addrp); | 115 | int video_reserve(ulong *addrp); |
116 | 116 | ||
117 | /** | 117 | /** |
118 | * video_clear() - Clear a device's frame buffer to background color. | ||
119 | * | ||
120 | * @dev: Device to clear | ||
121 | */ | ||
122 | void video_clear(struct udevice *dev); | ||
123 | |||
124 | /** | ||
118 | * video_sync() - Sync a device's frame buffer with its hardware | 125 | * video_sync() - Sync a device's frame buffer with its hardware |
119 | * | 126 | * |
120 | * Some frame buffers are cached or have a secondary frame buffer. This | 127 | * Some frame buffers are cached or have a secondary frame buffer. This |
121 | * function syncs these up so that the current contents of the U-Boot frame | 128 | * function syncs these up so that the current contents of the U-Boot frame |
122 | * buffer are displayed to the user. | 129 | * buffer are displayed to the user. |
123 | * | 130 | * |
124 | * @dev: Device to sync | 131 | * @dev: Device to sync |
125 | */ | 132 | */ |
126 | void video_sync(struct udevice *vid); | 133 | void video_sync(struct udevice *vid); |
127 | 134 | ||
128 | /** | 135 | /** |
129 | * video_sync_all() - Sync all devices' frame buffers with there hardware | 136 | * video_sync_all() - Sync all devices' frame buffers with there hardware |
130 | * | 137 | * |
131 | * This calls video_sync() on all active video devices. | 138 | * This calls video_sync() on all active video devices. |
132 | */ | 139 | */ |
133 | void video_sync_all(void); | 140 | void video_sync_all(void); |
134 | 141 | ||
135 | /** | 142 | /** |
136 | * video_bmp_display() - Display a BMP file | 143 | * video_bmp_display() - Display a BMP file |
137 | * | 144 | * |
138 | * @dev: Device to display the bitmap on | 145 | * @dev: Device to display the bitmap on |
139 | * @bmp_image: Address of bitmap image to display | 146 | * @bmp_image: Address of bitmap image to display |
140 | * @x: X position in pixels from the left | 147 | * @x: X position in pixels from the left |
141 | * @y: Y position in pixels from the top | 148 | * @y: Y position in pixels from the top |
142 | * @align: true to adjust the coordinates to centre the image. If false | 149 | * @align: true to adjust the coordinates to centre the image. If false |
143 | * the coordinates are used as is. If true: | 150 | * the coordinates are used as is. If true: |
144 | * | 151 | * |
145 | * - if a coordinate is 0x7fff then the image will be centred in | 152 | * - if a coordinate is 0x7fff then the image will be centred in |
146 | * that direction | 153 | * that direction |
147 | * - if a coordinate is -ve then it will be offset to the | 154 | * - if a coordinate is -ve then it will be offset to the |
148 | * left/top of the centre by that many pixels | 155 | * left/top of the centre by that many pixels |
149 | * - if a coordinate is positive it will be used unchnaged. | 156 | * - if a coordinate is positive it will be used unchnaged. |
150 | * @return 0 if OK, -ve on error | 157 | * @return 0 if OK, -ve on error |
151 | */ | 158 | */ |
152 | int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, | 159 | int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, |
153 | bool align); | 160 | bool align); |
154 | 161 | ||
155 | /** | 162 | /** |
156 | * video_get_xsize() - Get the width of the display in pixels | 163 | * video_get_xsize() - Get the width of the display in pixels |
157 | * | 164 | * |
158 | * @dev: Device to check | 165 | * @dev: Device to check |
159 | * @return device frame buffer width in pixels | 166 | * @return device frame buffer width in pixels |
160 | */ | 167 | */ |
161 | int video_get_xsize(struct udevice *dev); | 168 | int video_get_xsize(struct udevice *dev); |
162 | 169 | ||
163 | /** | 170 | /** |
164 | * video_get_ysize() - Get the height of the display in pixels | 171 | * video_get_ysize() - Get the height of the display in pixels |
165 | * | 172 | * |
166 | * @dev: Device to check | 173 | * @dev: Device to check |
167 | * @return device frame buffer height in pixels | 174 | * @return device frame buffer height in pixels |
168 | */ | 175 | */ |
169 | int video_get_ysize(struct udevice *dev); | 176 | int video_get_ysize(struct udevice *dev); |
170 | 177 | ||
171 | /** | 178 | /** |
172 | * Set whether we need to flush the dcache when changing the image. This | 179 | * Set whether we need to flush the dcache when changing the image. This |
173 | * defaults to off. | 180 | * defaults to off. |
174 | * | 181 | * |
175 | * @param flush non-zero to flush cache after update, 0 to skip | 182 | * @param flush non-zero to flush cache after update, 0 to skip |
176 | */ | 183 | */ |
177 | void video_set_flush_dcache(struct udevice *dev, bool flush); | 184 | void video_set_flush_dcache(struct udevice *dev, bool flush); |
178 | 185 | ||
179 | #endif /* CONFIG_DM_VIDEO */ | 186 | #endif /* CONFIG_DM_VIDEO */ |
180 | 187 | ||
181 | #ifndef CONFIG_DM_VIDEO | 188 | #ifndef CONFIG_DM_VIDEO |
182 | 189 | ||
183 | /* Video functions */ | 190 | /* Video functions */ |
184 | 191 | ||
185 | struct stdio_dev; | 192 | struct stdio_dev; |
186 | 193 | ||
187 | int video_init(void *videobase); | 194 | int video_init(void *videobase); |
188 | void video_putc(struct stdio_dev *dev, const char c); | 195 | void video_putc(struct stdio_dev *dev, const char c); |
189 | void video_puts(struct stdio_dev *dev, const char *s); | 196 | void video_puts(struct stdio_dev *dev, const char *s); |
190 | 197 | ||
191 | /** | 198 | /** |
192 | * Display a BMP format bitmap on the screen | 199 | * Display a BMP format bitmap on the screen |
193 | * | 200 | * |
194 | * @param bmp_image Address of BMP image | 201 | * @param bmp_image Address of BMP image |
195 | * @param x X position to draw image | 202 | * @param x X position to draw image |
196 | * @param y Y position to draw image | 203 | * @param y Y position to draw image |
197 | */ | 204 | */ |
198 | int video_display_bitmap(ulong bmp_image, int x, int y); | 205 | int video_display_bitmap(ulong bmp_image, int x, int y); |
199 | 206 | ||
200 | /** | 207 | /** |
201 | * Get the width of the screen in pixels | 208 | * Get the width of the screen in pixels |
202 | * | 209 | * |
203 | * @return width of screen in pixels | 210 | * @return width of screen in pixels |
204 | */ | 211 | */ |
205 | int video_get_pixel_width(void); | 212 | int video_get_pixel_width(void); |
206 | 213 | ||
207 | /** | 214 | /** |
208 | * Get the height of the screen in pixels | 215 | * Get the height of the screen in pixels |
209 | * | 216 | * |
210 | * @return height of screen in pixels | 217 | * @return height of screen in pixels |
211 | */ | 218 | */ |
212 | int video_get_pixel_height(void); | 219 | int video_get_pixel_height(void); |
213 | 220 | ||
214 | /** | 221 | /** |
215 | * Get the number of text lines/rows on the screen | 222 | * Get the number of text lines/rows on the screen |
216 | * | 223 | * |
217 | * @return number of rows | 224 | * @return number of rows |
218 | */ | 225 | */ |
219 | int video_get_screen_rows(void); | 226 | int video_get_screen_rows(void); |
220 | 227 | ||
221 | /** | 228 | /** |
222 | * Get the number of text columns on the screen | 229 | * Get the number of text columns on the screen |
223 | * | 230 | * |
224 | * @return number of columns | 231 | * @return number of columns |
225 | */ | 232 | */ |
226 | int video_get_screen_columns(void); | 233 | int video_get_screen_columns(void); |
227 | 234 | ||
228 | /** | 235 | /** |
229 | * Set the position of the text cursor | 236 | * Set the position of the text cursor |
230 | * | 237 | * |
231 | * @param col Column to place cursor (0 = left side) | 238 | * @param col Column to place cursor (0 = left side) |
232 | * @param row Row to place cursor (0 = top line) | 239 | * @param row Row to place cursor (0 = top line) |
233 | */ | 240 | */ |
234 | void video_position_cursor(unsigned col, unsigned row); | 241 | void video_position_cursor(unsigned col, unsigned row); |
235 | 242 | ||
236 | /* Clear the display */ | 243 | /* Clear the display */ |
237 | void video_clear(void); | 244 | void video_clear(void); |
238 | 245 | ||
239 | #if defined(CONFIG_FORMIKE) | 246 | #if defined(CONFIG_FORMIKE) |
240 | int kwh043st20_f01_spi_startup(unsigned int bus, unsigned int cs, | 247 | int kwh043st20_f01_spi_startup(unsigned int bus, unsigned int cs, |
241 | unsigned int max_hz, unsigned int spi_mode); | 248 | unsigned int max_hz, unsigned int spi_mode); |
242 | #endif | 249 | #endif |
243 | #if defined(CONFIG_LG4573) | 250 | #if defined(CONFIG_LG4573) |
244 | int lg4573_spi_startup(unsigned int bus, unsigned int cs, | 251 | int lg4573_spi_startup(unsigned int bus, unsigned int cs, |
245 | unsigned int max_hz, unsigned int spi_mode); | 252 | unsigned int max_hz, unsigned int spi_mode); |
246 | #endif | 253 | #endif |
247 | 254 | ||
248 | /* | 255 | /* |
249 | * video_get_info_str() - obtain a board string: type, speed, etc. | 256 | * video_get_info_str() - obtain a board string: type, speed, etc. |
250 | * | 257 | * |
251 | * This is called if CONFIG_CONSOLE_EXTRA_INFO is enabled. | 258 | * This is called if CONFIG_CONSOLE_EXTRA_INFO is enabled. |
252 | * | 259 | * |
253 | * line_number: location to place info string beside logo | 260 | * line_number: location to place info string beside logo |
254 | * info: buffer for info string (empty if nothing to display on this | 261 | * info: buffer for info string (empty if nothing to display on this |
255 | * line) | 262 | * line) |
256 | */ | 263 | */ |
257 | void video_get_info_str(int line_number, char *info); | 264 | void video_get_info_str(int line_number, char *info); |
258 | 265 | ||
259 | #endif /* CONFIG_DM_VIDEO */ | 266 | #endif /* CONFIG_DM_VIDEO */ |
260 | 267 | ||
261 | #endif | 268 | #endif |
262 | 269 |
include/video_console.h
1 | /* | 1 | /* |
2 | * Copyright (c) 2015 Google, Inc | 2 | * Copyright (c) 2015 Google, Inc |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: GPL-2.0+ | 4 | * SPDX-License-Identifier: GPL-2.0+ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #ifndef __video_console_h | 7 | #ifndef __video_console_h |
8 | #define __video_console_h | 8 | #define __video_console_h |
9 | 9 | ||
10 | #define VID_FRAC_DIV 256 | 10 | #define VID_FRAC_DIV 256 |
11 | 11 | ||
12 | #define VID_TO_PIXEL(x) ((x) / VID_FRAC_DIV) | 12 | #define VID_TO_PIXEL(x) ((x) / VID_FRAC_DIV) |
13 | #define VID_TO_POS(x) ((x) * VID_FRAC_DIV) | 13 | #define VID_TO_POS(x) ((x) * VID_FRAC_DIV) |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * struct vidconsole_priv - uclass-private data about a console device | 16 | * struct vidconsole_priv - uclass-private data about a console device |
17 | * | 17 | * |
18 | * Drivers must set up @rows, @cols, @x_charsize, @y_charsize in their probe() | 18 | * Drivers must set up @rows, @cols, @x_charsize, @y_charsize in their probe() |
19 | * method. Drivers may set up @xstart_frac if desired. | 19 | * method. Drivers may set up @xstart_frac if desired. |
20 | * | 20 | * |
21 | * @sdev: stdio device, acting as an output sink | 21 | * @sdev: stdio device, acting as an output sink |
22 | * @xcur_frac: Current X position, in fractional units (VID_TO_POS(x)) | 22 | * @xcur_frac: Current X position, in fractional units (VID_TO_POS(x)) |
23 | * @curr_row: Current Y position in pixels (0=top) | 23 | * @curr_row: Current Y position in pixels (0=top) |
24 | * @rows: Number of text rows | 24 | * @rows: Number of text rows |
25 | * @cols: Number of text columns | 25 | * @cols: Number of text columns |
26 | * @x_charsize: Character width in pixels | 26 | * @x_charsize: Character width in pixels |
27 | * @y_charsize: Character height in pixels | 27 | * @y_charsize: Character height in pixels |
28 | * @tab_width_frac: Tab width in fractional units | 28 | * @tab_width_frac: Tab width in fractional units |
29 | * @xsize_frac: Width of the display in fractional units | 29 | * @xsize_frac: Width of the display in fractional units |
30 | * @xstart_frac: Left margin for the text console in fractional units | 30 | * @xstart_frac: Left margin for the text console in fractional units |
31 | * @last_ch: Last character written to the text console on this line | 31 | * @last_ch: Last character written to the text console on this line |
32 | * @escape: TRUE if currently accumulating an ANSI escape sequence | ||
33 | * @escape_len: Length of accumulated escape sequence so far | ||
34 | * @escape_buf: Buffer to accumulate escape sequence | ||
32 | */ | 35 | */ |
33 | struct vidconsole_priv { | 36 | struct vidconsole_priv { |
34 | struct stdio_dev sdev; | 37 | struct stdio_dev sdev; |
35 | int xcur_frac; | 38 | int xcur_frac; |
36 | int ycur; | 39 | int ycur; |
37 | int rows; | 40 | int rows; |
38 | int cols; | 41 | int cols; |
39 | int x_charsize; | 42 | int x_charsize; |
40 | int y_charsize; | 43 | int y_charsize; |
41 | int tab_width_frac; | 44 | int tab_width_frac; |
42 | int xsize_frac; | 45 | int xsize_frac; |
43 | int xstart_frac; | 46 | int xstart_frac; |
44 | int last_ch; | 47 | int last_ch; |
48 | /* | ||
49 | * ANSI escape sequences are accumulated character by character, | ||
50 | * starting after the ESC char (0x1b) until the entire sequence | ||
51 | * is consumed at which point it is acted upon. | ||
52 | */ | ||
53 | int escape; | ||
54 | int escape_len; | ||
55 | char escape_buf[32]; | ||
45 | }; | 56 | }; |
46 | 57 | ||
47 | /** | 58 | /** |
48 | * struct vidconsole_ops - Video console operations | 59 | * struct vidconsole_ops - Video console operations |
49 | * | 60 | * |
50 | * These operations work on either an absolute console position (measured | 61 | * These operations work on either an absolute console position (measured |
51 | * in pixels) or a text row number (measured in rows, where each row consists | 62 | * in pixels) or a text row number (measured in rows, where each row consists |
52 | * of an entire line of text - typically 16 pixels). | 63 | * of an entire line of text - typically 16 pixels). |
53 | */ | 64 | */ |
54 | struct vidconsole_ops { | 65 | struct vidconsole_ops { |
55 | /** | 66 | /** |
56 | * putc_xy() - write a single character to a position | 67 | * putc_xy() - write a single character to a position |
57 | * | 68 | * |
58 | * @dev: Device to write to | 69 | * @dev: Device to write to |
59 | * @x_frac: Fractional pixel X position (0=left-most pixel) which | 70 | * @x_frac: Fractional pixel X position (0=left-most pixel) which |
60 | * is the X position multipled by VID_FRAC_DIV. | 71 | * is the X position multipled by VID_FRAC_DIV. |
61 | * @y: Pixel Y position (0=top-most pixel) | 72 | * @y: Pixel Y position (0=top-most pixel) |
62 | * @ch: Character to write | 73 | * @ch: Character to write |
63 | * @return number of fractional pixels that the cursor should move, | 74 | * @return number of fractional pixels that the cursor should move, |
64 | * if all is OK, -EAGAIN if we ran out of space on this line, other -ve | 75 | * if all is OK, -EAGAIN if we ran out of space on this line, other -ve |
65 | * on error | 76 | * on error |
66 | */ | 77 | */ |
67 | int (*putc_xy)(struct udevice *dev, uint x_frac, uint y, char ch); | 78 | int (*putc_xy)(struct udevice *dev, uint x_frac, uint y, char ch); |
68 | 79 | ||
69 | /** | 80 | /** |
70 | * move_rows() - Move text rows from one place to another | 81 | * move_rows() - Move text rows from one place to another |
71 | * | 82 | * |
72 | * @dev: Device to adjust | 83 | * @dev: Device to adjust |
73 | * @rowdst: Destination text row (0=top) | 84 | * @rowdst: Destination text row (0=top) |
74 | * @rowsrc: Source start text row | 85 | * @rowsrc: Source start text row |
75 | * @count: Number of text rows to move | 86 | * @count: Number of text rows to move |
76 | * @return 0 if OK, -ve on error | 87 | * @return 0 if OK, -ve on error |
77 | */ | 88 | */ |
78 | int (*move_rows)(struct udevice *dev, uint rowdst, uint rowsrc, | 89 | int (*move_rows)(struct udevice *dev, uint rowdst, uint rowsrc, |
79 | uint count); | 90 | uint count); |
80 | 91 | ||
81 | /** | 92 | /** |
82 | * set_row() - Set the colour of a text row | 93 | * set_row() - Set the colour of a text row |
83 | * | 94 | * |
84 | * Every pixel contained within the text row is adjusted | 95 | * Every pixel contained within the text row is adjusted |
85 | * | 96 | * |
86 | * @dev: Device to adjust | 97 | * @dev: Device to adjust |
87 | * @row: Text row to adjust (0=top) | 98 | * @row: Text row to adjust (0=top) |
88 | * @clr: Raw colour (pixel value) to write to each pixel | 99 | * @clr: Raw colour (pixel value) to write to each pixel |
89 | * @return 0 if OK, -ve on error | 100 | * @return 0 if OK, -ve on error |
90 | */ | 101 | */ |
91 | int (*set_row)(struct udevice *dev, uint row, int clr); | 102 | int (*set_row)(struct udevice *dev, uint row, int clr); |
92 | 103 | ||
93 | /** | 104 | /** |
94 | * entry_start() - Indicate that text entry is starting afresh | 105 | * entry_start() - Indicate that text entry is starting afresh |
95 | * | 106 | * |
96 | * Consoles which use proportional fonts need to track the position of | 107 | * Consoles which use proportional fonts need to track the position of |
97 | * each character output so that backspace will return to the correct | 108 | * each character output so that backspace will return to the correct |
98 | * place. This method signals to the console driver that a new entry | 109 | * place. This method signals to the console driver that a new entry |
99 | * line is being start (e.g. the user pressed return to start a new | 110 | * line is being start (e.g. the user pressed return to start a new |
100 | * command). The driver can use this signal to empty its list of | 111 | * command). The driver can use this signal to empty its list of |
101 | * positions. | 112 | * positions. |
102 | */ | 113 | */ |
103 | int (*entry_start)(struct udevice *dev); | 114 | int (*entry_start)(struct udevice *dev); |
104 | 115 | ||
105 | /** | 116 | /** |
106 | * backspace() - Handle erasing the last character | 117 | * backspace() - Handle erasing the last character |
107 | * | 118 | * |
108 | * With proportional fonts the vidconsole uclass cannot itself erase | 119 | * With proportional fonts the vidconsole uclass cannot itself erase |
109 | * the previous character. This optional method will be called when | 120 | * the previous character. This optional method will be called when |
110 | * a backspace is needed. The driver should erase the previous | 121 | * a backspace is needed. The driver should erase the previous |
111 | * character and update the cursor position (xcur_frac, ycur) to the | 122 | * character and update the cursor position (xcur_frac, ycur) to the |
112 | * start of the previous character. | 123 | * start of the previous character. |
113 | * | 124 | * |
114 | * If not implement, default behaviour will work for fixed-width | 125 | * If not implement, default behaviour will work for fixed-width |
115 | * characters. | 126 | * characters. |
116 | */ | 127 | */ |
117 | int (*backspace)(struct udevice *dev); | 128 | int (*backspace)(struct udevice *dev); |
118 | }; | 129 | }; |
119 | 130 | ||
120 | /* Get a pointer to the driver operations for a video console device */ | 131 | /* Get a pointer to the driver operations for a video console device */ |
121 | #define vidconsole_get_ops(dev) ((struct vidconsole_ops *)(dev)->driver->ops) | 132 | #define vidconsole_get_ops(dev) ((struct vidconsole_ops *)(dev)->driver->ops) |
122 | 133 | ||
123 | /** | 134 | /** |
124 | * vidconsole_putc_xy() - write a single character to a position | 135 | * vidconsole_putc_xy() - write a single character to a position |
125 | * | 136 | * |
126 | * @dev: Device to write to | 137 | * @dev: Device to write to |
127 | * @x_frac: Fractional pixel X position (0=left-most pixel) which | 138 | * @x_frac: Fractional pixel X position (0=left-most pixel) which |
128 | * is the X position multipled by VID_FRAC_DIV. | 139 | * is the X position multipled by VID_FRAC_DIV. |
129 | * @y: Pixel Y position (0=top-most pixel) | 140 | * @y: Pixel Y position (0=top-most pixel) |
130 | * @ch: Character to write | 141 | * @ch: Character to write |
131 | * @return number of fractional pixels that the cursor should move, | 142 | * @return number of fractional pixels that the cursor should move, |
132 | * if all is OK, -EAGAIN if we ran out of space on this line, other -ve | 143 | * if all is OK, -EAGAIN if we ran out of space on this line, other -ve |
133 | * on error | 144 | * on error |
134 | */ | 145 | */ |
135 | int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch); | 146 | int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch); |
136 | 147 | ||
137 | /** | 148 | /** |
138 | * vidconsole_move_rows() - Move text rows from one place to another | 149 | * vidconsole_move_rows() - Move text rows from one place to another |
139 | * | 150 | * |
140 | * @dev: Device to adjust | 151 | * @dev: Device to adjust |
141 | * @rowdst: Destination text row (0=top) | 152 | * @rowdst: Destination text row (0=top) |
142 | * @rowsrc: Source start text row | 153 | * @rowsrc: Source start text row |
143 | * @count: Number of text rows to move | 154 | * @count: Number of text rows to move |
144 | * @return 0 if OK, -ve on error | 155 | * @return 0 if OK, -ve on error |
145 | */ | 156 | */ |
146 | int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc, | 157 | int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc, |
147 | uint count); | 158 | uint count); |
148 | 159 | ||
149 | /** | 160 | /** |
150 | * vidconsole_set_row() - Set the colour of a text row | 161 | * vidconsole_set_row() - Set the colour of a text row |
151 | * | 162 | * |
152 | * Every pixel contained within the text row is adjusted | 163 | * Every pixel contained within the text row is adjusted |
153 | * | 164 | * |
154 | * @dev: Device to adjust | 165 | * @dev: Device to adjust |
155 | * @row: Text row to adjust (0=top) | 166 | * @row: Text row to adjust (0=top) |
156 | * @clr: Raw colour (pixel value) to write to each pixel | 167 | * @clr: Raw colour (pixel value) to write to each pixel |
157 | * @return 0 if OK, -ve on error | 168 | * @return 0 if OK, -ve on error |
158 | */ | 169 | */ |
159 | int vidconsole_set_row(struct udevice *dev, uint row, int clr); | 170 | int vidconsole_set_row(struct udevice *dev, uint row, int clr); |
160 | 171 | ||
161 | /** | 172 | /** |
162 | * vidconsole_put_char() - Output a character to the current console position | 173 | * vidconsole_put_char() - Output a character to the current console position |
163 | * | 174 | * |
164 | * Outputs a character to the console and advances the cursor. This function | 175 | * Outputs a character to the console and advances the cursor. This function |
165 | * handles wrapping to new lines and scrolling the console. Special | 176 | * handles wrapping to new lines and scrolling the console. Special |
166 | * characters are handled also: \n, \r, \b and \t. | 177 | * characters are handled also: \n, \r, \b and \t. |
167 | * | 178 | * |
168 | * The device always starts with the cursor at position 0,0 (top left). It | 179 | * The device always starts with the cursor at position 0,0 (top left). It |
169 | * can be adjusted manually using vidconsole_position_cursor(). | 180 | * can be adjusted manually using vidconsole_position_cursor(). |
170 | * | 181 | * |
171 | * @dev: Device to adjust | 182 | * @dev: Device to adjust |
172 | * @ch: Character to write | 183 | * @ch: Character to write |
173 | * @return 0 if OK, -ve on error | 184 | * @return 0 if OK, -ve on error |
174 | */ | 185 | */ |
175 | int vidconsole_put_char(struct udevice *dev, char ch); | 186 | int vidconsole_put_char(struct udevice *dev, char ch); |
176 | 187 | ||
177 | /** | 188 | /** |
178 | * vidconsole_position_cursor() - Move the text cursor | 189 | * vidconsole_position_cursor() - Move the text cursor |
179 | * | 190 | * |
180 | * @dev: Device to adjust | 191 | * @dev: Device to adjust |
181 | * @col: New cursor text column | 192 | * @col: New cursor text column |
182 | * @row: New cursor text row | 193 | * @row: New cursor text row |
183 | * @return 0 if OK, -ve on error | 194 | * @return 0 if OK, -ve on error |
184 | */ | 195 | */ |
185 | void vidconsole_position_cursor(struct udevice *dev, unsigned col, | 196 | void vidconsole_position_cursor(struct udevice *dev, unsigned col, |
186 | unsigned row); | 197 | unsigned row); |
187 | 198 | ||
188 | #endif | 199 | #endif |
189 | 200 |