splash.c revision 1.1.2.2 1 1.1.2.2 yamt /* $NetBSD: splash.c,v 1.1.2.2 2006/03/01 09:28:28 yamt Exp $ */
2 1.1.2.2 yamt
3 1.1.2.2 yamt /*-
4 1.1.2.2 yamt * Copyright (c) 2006 Jared D. McNeill <jmcneill (at) invisible.ca>
5 1.1.2.2 yamt * All rights reserved.
6 1.1.2.2 yamt *
7 1.1.2.2 yamt * Redistribution and use in source and binary forms, with or without
8 1.1.2.2 yamt * modification, are permitted provided that the following conditions
9 1.1.2.2 yamt * are met:
10 1.1.2.2 yamt * 1. Redistributions of source code must retain the above copyright
11 1.1.2.2 yamt * notice, this list of conditions and the following disclaimer.
12 1.1.2.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.2.2 yamt * notice, this list of conditions and the following disclaimer in the
14 1.1.2.2 yamt * documentation and/or other materials provided with the distribution.
15 1.1.2.2 yamt * 3. All advertising materials mentioning features or use of this software
16 1.1.2.2 yamt * must display the following acknowledgement:
17 1.1.2.2 yamt * This product includes software developed by the NetBSD
18 1.1.2.2 yamt * Foundation, Inc. and its contributors.
19 1.1.2.2 yamt * 4. Neither the name of The NetBSD Foundation nor the names of its
20 1.1.2.2 yamt * contributors may be used to endorse or promote products derived
21 1.1.2.2 yamt * from this software without specific prior written permission.
22 1.1.2.2 yamt *
23 1.1.2.2 yamt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 1.1.2.2 yamt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 1.1.2.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 1.1.2.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 1.1.2.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 1.1.2.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 1.1.2.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 1.1.2.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 1.1.2.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 1.1.2.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 1.1.2.2 yamt * POSSIBILITY OF SUCH DAMAGE.
34 1.1.2.2 yamt */
35 1.1.2.2 yamt
36 1.1.2.2 yamt #include <sys/cdefs.h>
37 1.1.2.2 yamt __KERNEL_RCSID(0, "$NetBSD: splash.c,v 1.1.2.2 2006/03/01 09:28:28 yamt Exp $");
38 1.1.2.2 yamt
39 1.1.2.2 yamt #include "opt_splash.h"
40 1.1.2.2 yamt
41 1.1.2.2 yamt /* XXX */
42 1.1.2.2 yamt #define NSPLASH8 1
43 1.1.2.2 yamt #define NSPLASH16 1
44 1.1.2.2 yamt #define NSPLASH32 1
45 1.1.2.2 yamt
46 1.1.2.2 yamt #include <sys/param.h>
47 1.1.2.2 yamt #include <sys/systm.h>
48 1.1.2.2 yamt #include <sys/types.h>
49 1.1.2.2 yamt #include <sys/kernel.h>
50 1.1.2.2 yamt #include <sys/kthread.h>
51 1.1.2.2 yamt
52 1.1.2.2 yamt #include <dev/splash/splash.h>
53 1.1.2.2 yamt
54 1.1.2.2 yamt #if !defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS)
55 1.1.2.2 yamt #error "options SPLASHSCREEN_PROGRESS requires SPLASHSCREEN"
56 1.1.2.2 yamt #endif
57 1.1.2.2 yamt
58 1.1.2.2 yamt #ifdef __HAVE_CPU_COUNTER
59 1.1.2.2 yamt #include <machine/cpu.h>
60 1.1.2.2 yamt #include <machine/cpu_counter.h>
61 1.1.2.2 yamt #endif
62 1.1.2.2 yamt
63 1.1.2.2 yamt #ifndef SPLASHSCREEN_IMAGE
64 1.1.2.2 yamt #define SPLASHSCREEN_IMAGE "dev/splash/images/netbsd.h"
65 1.1.2.2 yamt #endif
66 1.1.2.2 yamt
67 1.1.2.2 yamt #ifdef SPLASHSCREEN
68 1.1.2.2 yamt #include SPLASHSCREEN_IMAGE
69 1.1.2.2 yamt
70 1.1.2.2 yamt #ifdef SPLASHSCREEN_PROGRESS
71 1.1.2.2 yamt struct splash_progress *splash_progress_state;
72 1.1.2.2 yamt #ifdef __HAVE_CPU_COUNTER
73 1.1.2.2 yamt static uint64_t splash_last_update;
74 1.1.2.2 yamt #endif
75 1.1.2.2 yamt #endif
76 1.1.2.2 yamt
77 1.1.2.2 yamt #if NSPLASH8 > 0
78 1.1.2.2 yamt static void splash_render8(struct splash_info *, const char *, int,
79 1.1.2.2 yamt int, int, int, int);
80 1.1.2.2 yamt #endif
81 1.1.2.2 yamt #if NSPLASH16 > 0
82 1.1.2.2 yamt static void splash_render16(struct splash_info *, const char *, int,
83 1.1.2.2 yamt int, int, int, int);
84 1.1.2.2 yamt #endif
85 1.1.2.2 yamt #if NSPLASH32 > 0
86 1.1.2.2 yamt static void splash_render32(struct splash_info *, const char *, int,
87 1.1.2.2 yamt int, int, int, int);
88 1.1.2.2 yamt #endif
89 1.1.2.2 yamt
90 1.1.2.2 yamt void
91 1.1.2.2 yamt splash_render(struct splash_info *si, int flg)
92 1.1.2.2 yamt {
93 1.1.2.2 yamt int xoff, yoff;
94 1.1.2.2 yamt
95 1.1.2.2 yamt /* XXX */
96 1.1.2.2 yamt if (flg & SPLASH_F_CENTER) {
97 1.1.2.2 yamt xoff = (si->si_width - _splash_width) / 2;
98 1.1.2.2 yamt yoff = (si->si_height - _splash_height) / 2;
99 1.1.2.2 yamt } else
100 1.1.2.2 yamt xoff = yoff = 0;
101 1.1.2.2 yamt
102 1.1.2.2 yamt switch (si->si_depth) {
103 1.1.2.2 yamt #if NSPLASH8 > 0
104 1.1.2.2 yamt case 8:
105 1.1.2.2 yamt splash_render8(si, _splash_header_data, xoff, yoff,
106 1.1.2.2 yamt _splash_width, _splash_height, flg);
107 1.1.2.2 yamt break;
108 1.1.2.2 yamt #endif
109 1.1.2.2 yamt #if NSPLASH16 > 0
110 1.1.2.2 yamt case 16:
111 1.1.2.2 yamt splash_render16(si, _splash_header_data, xoff, yoff,
112 1.1.2.2 yamt _splash_width, _splash_height, flg);
113 1.1.2.2 yamt break;
114 1.1.2.2 yamt #endif
115 1.1.2.2 yamt #if NSPLASH32 > 0
116 1.1.2.2 yamt case 32:
117 1.1.2.2 yamt splash_render32(si, _splash_header_data, xoff, yoff,
118 1.1.2.2 yamt _splash_width, _splash_height, flg);
119 1.1.2.2 yamt break;
120 1.1.2.2 yamt #endif
121 1.1.2.2 yamt default:
122 1.1.2.2 yamt aprint_error("WARNING: Splash not supported at %dbpp\n",
123 1.1.2.2 yamt si->si_depth);
124 1.1.2.2 yamt break;
125 1.1.2.2 yamt }
126 1.1.2.2 yamt
127 1.1.2.2 yamt return;
128 1.1.2.2 yamt }
129 1.1.2.2 yamt
130 1.1.2.2 yamt #if NSPLASH8 > 0
131 1.1.2.2 yamt static void
132 1.1.2.2 yamt splash_render8(struct splash_info *si, const char *data, int xoff, int yoff,
133 1.1.2.2 yamt int swidth, int sheight, int flg)
134 1.1.2.2 yamt {
135 1.1.2.2 yamt const char *p;
136 1.1.2.2 yamt u_char *fb, pix;
137 1.1.2.2 yamt int x, y, i;
138 1.1.2.2 yamt int filled;
139 1.1.2.2 yamt
140 1.1.2.2 yamt fb = si->si_bits;
141 1.1.2.2 yamt if (flg & SPLASH_F_FILL)
142 1.1.2.2 yamt filled = 0;
143 1.1.2.2 yamt else
144 1.1.2.2 yamt filled = 1;
145 1.1.2.2 yamt
146 1.1.2.2 yamt p = data;
147 1.1.2.2 yamt fb += xoff + (yoff * si->si_width);
148 1.1.2.2 yamt for (y = 0; y < sheight; y++) {
149 1.1.2.2 yamt for (x = 0; x < swidth; x++) {
150 1.1.2.2 yamt pix = *p++;
151 1.1.2.2 yamt pix += SPLASH_CMAP_OFFSET;
152 1.1.2.2 yamt if (filled == 0) {
153 1.1.2.2 yamt for (i = 0; i < (si->si_width * si->si_height);
154 1.1.2.2 yamt i++)
155 1.1.2.2 yamt si->si_bits[i] = pix;
156 1.1.2.2 yamt filled = 1;
157 1.1.2.2 yamt }
158 1.1.2.2 yamt fb[x] = pix;
159 1.1.2.2 yamt }
160 1.1.2.2 yamt fb += si->si_width;
161 1.1.2.2 yamt }
162 1.1.2.2 yamt
163 1.1.2.2 yamt /* If we've just written to the shadow fb, copy it to the display */
164 1.1.2.2 yamt if (si->si_hwbits) {
165 1.1.2.2 yamt if (flg & SPLASH_F_FILL) {
166 1.1.2.2 yamt memcpy(si->si_hwbits, si->si_bits,
167 1.1.2.2 yamt si->si_width*si->si_height);
168 1.1.2.2 yamt } else {
169 1.1.2.2 yamt u_char *rp, *hrp;
170 1.1.2.2 yamt
171 1.1.2.2 yamt rp = si->si_bits + xoff + (yoff * si->si_width);
172 1.1.2.2 yamt hrp = si->si_hwbits + xoff + (yoff * si->si_width);
173 1.1.2.2 yamt
174 1.1.2.2 yamt for (y = 0; y < sheight; y++) {
175 1.1.2.2 yamt memcpy(hrp, rp, swidth);
176 1.1.2.2 yamt hrp += si->si_stride;
177 1.1.2.2 yamt rp += si->si_stride;
178 1.1.2.2 yamt }
179 1.1.2.2 yamt }
180 1.1.2.2 yamt }
181 1.1.2.2 yamt
182 1.1.2.2 yamt return;
183 1.1.2.2 yamt }
184 1.1.2.2 yamt #endif /* !NSPLASH8 > 0 */
185 1.1.2.2 yamt
186 1.1.2.2 yamt #if NSPLASH16 > 0
187 1.1.2.2 yamt #define RGBTO16(b, o, x, c) \
188 1.1.2.2 yamt do { \
189 1.1.2.2 yamt uint16_t *_ptr = (uint16_t *)(&(b)[(o)]); \
190 1.1.2.2 yamt *_ptr = (((c)[(x)*3+0] / 8) << 11) | \
191 1.1.2.2 yamt (((c)[(x)*3+1] / 4) << 5) | \
192 1.1.2.2 yamt (((c)[(x)*3+2] / 8) << 0); \
193 1.1.2.2 yamt } while (0)
194 1.1.2.2 yamt
195 1.1.2.2 yamt static void
196 1.1.2.2 yamt splash_render16(struct splash_info *si, const char *data, int xoff, int yoff,
197 1.1.2.2 yamt int swidth, int sheight, int flg)
198 1.1.2.2 yamt {
199 1.1.2.2 yamt const char *d;
200 1.1.2.2 yamt u_char *fb, *p;
201 1.1.2.2 yamt u_char pix[3];
202 1.1.2.2 yamt int x, y, i;
203 1.1.2.2 yamt int filled;
204 1.1.2.2 yamt
205 1.1.2.2 yamt fb = si->si_bits;
206 1.1.2.2 yamt
207 1.1.2.2 yamt if (flg & SPLASH_F_FILL)
208 1.1.2.2 yamt filled = 0;
209 1.1.2.2 yamt else
210 1.1.2.2 yamt filled = 1;
211 1.1.2.2 yamt
212 1.1.2.2 yamt d = data;
213 1.1.2.2 yamt fb += xoff * 2 + yoff * si->si_stride;
214 1.1.2.2 yamt
215 1.1.2.2 yamt for (y = 0; y < sheight; y++) {
216 1.1.2.2 yamt for (x = 0; x < swidth; x++) {
217 1.1.2.2 yamt _SPLASH_HEADER_PIXEL(d, pix);
218 1.1.2.2 yamt if (filled == 0) {
219 1.1.2.2 yamt p = si->si_bits;
220 1.1.2.2 yamt i = 0;
221 1.1.2.2 yamt while (i < si->si_height*si->si_stride) {
222 1.1.2.2 yamt RGBTO16(p, i, 0, pix);
223 1.1.2.2 yamt i += 2;
224 1.1.2.2 yamt }
225 1.1.2.2 yamt filled = 1;
226 1.1.2.2 yamt }
227 1.1.2.2 yamt RGBTO16(fb, x*2, 0, pix);
228 1.1.2.2 yamt }
229 1.1.2.2 yamt fb += si->si_stride;
230 1.1.2.2 yamt }
231 1.1.2.2 yamt
232 1.1.2.2 yamt /* If we've just written to the shadow fb, copy it to the display */
233 1.1.2.2 yamt if (si->si_hwbits) {
234 1.1.2.2 yamt if (flg & SPLASH_F_FILL) {
235 1.1.2.2 yamt memcpy(si->si_hwbits, si->si_bits,
236 1.1.2.2 yamt si->si_height*si->si_stride);
237 1.1.2.2 yamt } else {
238 1.1.2.2 yamt u_char *rp, *hrp;
239 1.1.2.2 yamt
240 1.1.2.2 yamt rp = si->si_bits + (xoff * 2) + (yoff * si->si_stride);
241 1.1.2.2 yamt hrp = si->si_hwbits + (xoff * 2) +
242 1.1.2.2 yamt (yoff * si->si_stride);
243 1.1.2.2 yamt
244 1.1.2.2 yamt for (y = 0; y < sheight; y++) {
245 1.1.2.2 yamt memcpy(hrp, rp, swidth * 2);
246 1.1.2.2 yamt rp += si->si_stride;
247 1.1.2.2 yamt hrp += si->si_stride;
248 1.1.2.2 yamt }
249 1.1.2.2 yamt }
250 1.1.2.2 yamt }
251 1.1.2.2 yamt
252 1.1.2.2 yamt return;
253 1.1.2.2 yamt }
254 1.1.2.2 yamt #undef RGBTO16
255 1.1.2.2 yamt #endif /* !NSPLASH16 > 0 */
256 1.1.2.2 yamt
257 1.1.2.2 yamt #if NSPLASH32 > 0
258 1.1.2.2 yamt static void
259 1.1.2.2 yamt splash_render32(struct splash_info *si, const char *data, int xoff, int yoff,
260 1.1.2.2 yamt int swidth, int sheight, int flg)
261 1.1.2.2 yamt {
262 1.1.2.2 yamt const char *d;
263 1.1.2.2 yamt u_char *fb, *p;
264 1.1.2.2 yamt u_char pix[3];
265 1.1.2.2 yamt int x, y, i;
266 1.1.2.2 yamt int filled;
267 1.1.2.2 yamt
268 1.1.2.2 yamt fb = si->si_bits;
269 1.1.2.2 yamt
270 1.1.2.2 yamt if (flg & SPLASH_F_FILL)
271 1.1.2.2 yamt filled = 0;
272 1.1.2.2 yamt else
273 1.1.2.2 yamt filled = 1;
274 1.1.2.2 yamt
275 1.1.2.2 yamt d = data;
276 1.1.2.2 yamt fb += xoff * 4 + yoff * si->si_stride;
277 1.1.2.2 yamt
278 1.1.2.2 yamt for (y = 0; y < sheight; y++) {
279 1.1.2.2 yamt for (x = 0; x < swidth; x++) {
280 1.1.2.2 yamt _SPLASH_HEADER_PIXEL(d, pix);
281 1.1.2.2 yamt if (filled == 0) {
282 1.1.2.2 yamt p = si->si_bits;
283 1.1.2.2 yamt i = 0;
284 1.1.2.2 yamt while (i < si->si_height*si->si_stride) {
285 1.1.2.2 yamt p[i++] = pix[2];
286 1.1.2.2 yamt p[i++] = pix[1];
287 1.1.2.2 yamt p[i++] = pix[0];
288 1.1.2.2 yamt p[i++] = 0;
289 1.1.2.2 yamt }
290 1.1.2.2 yamt filled = 1;
291 1.1.2.2 yamt }
292 1.1.2.2 yamt fb[x*4+0] = pix[2];
293 1.1.2.2 yamt fb[x*4+1] = pix[1];
294 1.1.2.2 yamt fb[x*4+2] = pix[0];
295 1.1.2.2 yamt fb[x*4+3] = 0;
296 1.1.2.2 yamt }
297 1.1.2.2 yamt fb += si->si_stride;
298 1.1.2.2 yamt }
299 1.1.2.2 yamt
300 1.1.2.2 yamt /* If we've just written to the shadow fb, copy it to the display */
301 1.1.2.2 yamt if (si->si_hwbits) {
302 1.1.2.2 yamt if (flg & SPLASH_F_FILL) {
303 1.1.2.2 yamt memcpy(si->si_hwbits, si->si_bits,
304 1.1.2.2 yamt si->si_height*si->si_stride);
305 1.1.2.2 yamt } else {
306 1.1.2.2 yamt u_char *rp, *hrp;
307 1.1.2.2 yamt
308 1.1.2.2 yamt rp = si->si_bits + (xoff * 4) + (yoff * si->si_stride);
309 1.1.2.2 yamt hrp = si->si_hwbits + (xoff * 4) +
310 1.1.2.2 yamt (yoff * si->si_stride);
311 1.1.2.2 yamt
312 1.1.2.2 yamt for (y = 0; y < sheight; y++) {
313 1.1.2.2 yamt memcpy(hrp, rp, swidth * 4);
314 1.1.2.2 yamt rp += si->si_stride;
315 1.1.2.2 yamt hrp += si->si_stride;
316 1.1.2.2 yamt }
317 1.1.2.2 yamt }
318 1.1.2.2 yamt }
319 1.1.2.2 yamt
320 1.1.2.2 yamt return;
321 1.1.2.2 yamt }
322 1.1.2.2 yamt #endif /* !NSPLASH32 > 0 */
323 1.1.2.2 yamt
324 1.1.2.2 yamt #ifdef SPLASHSCREEN_PROGRESS
325 1.1.2.2 yamt
326 1.1.2.2 yamt static void
327 1.1.2.2 yamt splash_progress_render(struct splash_progress *sp)
328 1.1.2.2 yamt {
329 1.1.2.2 yamt struct splash_info *si;
330 1.1.2.2 yamt int i;
331 1.1.2.2 yamt int w;
332 1.1.2.2 yamt int spacing;
333 1.1.2.2 yamt int xoff;
334 1.1.2.2 yamt int yoff;
335 1.1.2.2 yamt int flg;
336 1.1.2.2 yamt
337 1.1.2.2 yamt si = sp->sp_si;
338 1.1.2.2 yamt flg = 0;
339 1.1.2.2 yamt
340 1.1.2.2 yamt /* where should we draw the pulsers? */
341 1.1.2.2 yamt yoff = (si->si_height / 8) * 7;
342 1.1.2.2 yamt w = _pulse_off_width * SPLASH_PROGRESS_NSTATES;
343 1.1.2.2 yamt xoff = (si->si_width / 4) * 3;
344 1.1.2.2 yamt spacing = _pulse_off_width; /* XXX */
345 1.1.2.2 yamt
346 1.1.2.2 yamt for (i = 0; i < SPLASH_PROGRESS_NSTATES; i++) {
347 1.1.2.2 yamt const char *d = (sp->sp_state == i ? _pulse_on_header_data :
348 1.1.2.2 yamt _pulse_off_header_data);
349 1.1.2.2 yamt switch (si->si_depth) {
350 1.1.2.2 yamt #if NSPLASH8 > 0
351 1.1.2.2 yamt case 8:
352 1.1.2.2 yamt splash_render8(si, d, (xoff + (i * spacing)),
353 1.1.2.2 yamt yoff, _pulse_off_width, _pulse_off_height, flg);
354 1.1.2.2 yamt break;
355 1.1.2.2 yamt #endif
356 1.1.2.2 yamt #if NSPLASH16 > 0
357 1.1.2.2 yamt case 16:
358 1.1.2.2 yamt splash_render16(si, d, (xoff + (i * spacing)),
359 1.1.2.2 yamt yoff, _pulse_off_width, _pulse_off_height, flg);
360 1.1.2.2 yamt break;
361 1.1.2.2 yamt #endif
362 1.1.2.2 yamt #if NSPLASH32 > 0
363 1.1.2.2 yamt case 32:
364 1.1.2.2 yamt splash_render32(si, d, (xoff + (i * spacing)),
365 1.1.2.2 yamt yoff, _pulse_off_width, _pulse_off_height, flg);
366 1.1.2.2 yamt break;
367 1.1.2.2 yamt #endif
368 1.1.2.2 yamt default:
369 1.1.2.2 yamt /* do nothing */
370 1.1.2.2 yamt break;
371 1.1.2.2 yamt }
372 1.1.2.2 yamt }
373 1.1.2.2 yamt }
374 1.1.2.2 yamt
375 1.1.2.2 yamt static int
376 1.1.2.2 yamt splash_progress_stop(struct device *dev)
377 1.1.2.2 yamt {
378 1.1.2.2 yamt struct splash_progress *sp;
379 1.1.2.2 yamt
380 1.1.2.2 yamt sp = (struct splash_progress *)dev;
381 1.1.2.2 yamt sp->sp_running = 0;
382 1.1.2.2 yamt
383 1.1.2.2 yamt return 0;
384 1.1.2.2 yamt }
385 1.1.2.2 yamt
386 1.1.2.2 yamt void
387 1.1.2.2 yamt splash_progress_init(struct splash_progress *sp)
388 1.1.2.2 yamt {
389 1.1.2.2 yamt #ifdef __HAVE_CPU_COUNTER
390 1.1.2.2 yamt if (cpu_hascounter())
391 1.1.2.2 yamt splash_last_update = cpu_counter();
392 1.1.2.2 yamt else
393 1.1.2.2 yamt splash_last_update = 0;
394 1.1.2.2 yamt #endif
395 1.1.2.2 yamt
396 1.1.2.2 yamt sp->sp_running = 1;
397 1.1.2.2 yamt sp->sp_force = 0;
398 1.1.2.2 yamt splash_progress_state = sp;
399 1.1.2.2 yamt splash_progress_render(sp);
400 1.1.2.2 yamt config_finalize_register((struct device *)sp, splash_progress_stop);
401 1.1.2.2 yamt
402 1.1.2.2 yamt return;
403 1.1.2.2 yamt }
404 1.1.2.2 yamt
405 1.1.2.2 yamt void
406 1.1.2.2 yamt splash_progress_update(struct splash_progress *sp)
407 1.1.2.2 yamt {
408 1.1.2.2 yamt if (sp->sp_running == 0 && sp->sp_force == 0)
409 1.1.2.2 yamt return;
410 1.1.2.2 yamt
411 1.1.2.2 yamt #ifdef __HAVE_CPU_COUNTER
412 1.1.2.2 yamt #define UPDATE_INTERVAL (cpu_frequency(&cpu_info_primary) / 4)
413 1.1.2.2 yamt if (cpu_hascounter()) {
414 1.1.2.2 yamt uint64_t now;
415 1.1.2.2 yamt
416 1.1.2.2 yamt if (splash_last_update == 0) {
417 1.1.2.2 yamt splash_last_update = cpu_counter();
418 1.1.2.2 yamt } else {
419 1.1.2.2 yamt now = cpu_counter();
420 1.1.2.2 yamt if (splash_last_update + UPDATE_INTERVAL > now)
421 1.1.2.2 yamt return;
422 1.1.2.2 yamt splash_last_update = now;
423 1.1.2.2 yamt }
424 1.1.2.2 yamt }
425 1.1.2.2 yamt #undef UPDATE_INTERVAL
426 1.1.2.2 yamt #endif
427 1.1.2.2 yamt sp->sp_state++;
428 1.1.2.2 yamt if (sp->sp_state >= SPLASH_PROGRESS_NSTATES)
429 1.1.2.2 yamt sp->sp_state = 0;
430 1.1.2.2 yamt
431 1.1.2.2 yamt splash_progress_render(sp);
432 1.1.2.2 yamt }
433 1.1.2.2 yamt
434 1.1.2.2 yamt #endif /* !SPLASHSCREEN_PROGRESS */
435 1.1.2.2 yamt
436 1.1.2.2 yamt #endif /* !SPLASHSCREEN */
437