diff options
Diffstat (limited to 'firmware/target/arm/imx233/debug-imx233.c')
-rw-r--r-- | firmware/target/arm/imx233/debug-imx233.c | 367 |
1 files changed, 261 insertions, 106 deletions
diff --git a/firmware/target/arm/imx233/debug-imx233.c b/firmware/target/arm/imx233/debug-imx233.c index e350b5a8ba..ebef023c74 100644 --- a/firmware/target/arm/imx233/debug-imx233.c +++ b/firmware/target/arm/imx233/debug-imx233.c | |||
@@ -21,7 +21,6 @@ | |||
21 | 21 | ||
22 | #include "system.h" | 22 | #include "system.h" |
23 | #include "dma-imx233.h" | 23 | #include "dma-imx233.h" |
24 | #include "action.h" | ||
25 | #include "lcd.h" | 24 | #include "lcd.h" |
26 | #include "font.h" | 25 | #include "font.h" |
27 | #include "adc.h" | 26 | #include "adc.h" |
@@ -35,10 +34,54 @@ | |||
35 | #include "ocotp-imx233.h" | 34 | #include "ocotp-imx233.h" |
36 | #include "pwm-imx233.h" | 35 | #include "pwm-imx233.h" |
37 | #include "emi-imx233.h" | 36 | #include "emi-imx233.h" |
37 | #include "audioout-imx233.h" | ||
38 | #include "string.h" | 38 | #include "string.h" |
39 | #include "stdio.h" | 39 | #include "stdio.h" |
40 | 40 | #include "button.h" | |
41 | #define DEBUG_CANCEL BUTTON_BACK | 41 | |
42 | #define ACT_NONE 0 | ||
43 | #define ACT_CANCEL 1 | ||
44 | #define ACT_OK 2 | ||
45 | #define ACT_PREV 3 | ||
46 | #define ACT_NEXT 4 | ||
47 | #define ACT_LEFT 5 | ||
48 | #define ACT_RIGHT 6 | ||
49 | #define ACT_REPEAT 0x1000 | ||
50 | |||
51 | int my_get_action(int tmo) | ||
52 | { | ||
53 | int btn = button_get_w_tmo(tmo); | ||
54 | while(btn & BUTTON_REL) | ||
55 | btn = button_get_w_tmo(tmo); | ||
56 | bool repeat = btn & BUTTON_REPEAT; | ||
57 | int act = ACT_NONE; | ||
58 | switch(btn) | ||
59 | { | ||
60 | case BUTTON_POWER: | ||
61 | case BUTTON_BACK: | ||
62 | act = ACT_CANCEL; | ||
63 | break; | ||
64 | #ifdef BUTTON_SELECT | ||
65 | case BUTTON_SELECT: | ||
66 | #endif | ||
67 | #if !defined(BUTTON_SELECT) && defined(BUTTON_PLAYPAUSE) | ||
68 | case BUTTON_PLAYPAUSE: | ||
69 | #endif | ||
70 | act = ACT_OK; | ||
71 | break; | ||
72 | case BUTTON_UP: | ||
73 | act = ACT_PREV; | ||
74 | break; | ||
75 | case BUTTON_DOWN: | ||
76 | act = ACT_NEXT; | ||
77 | break; | ||
78 | default: | ||
79 | yield(); | ||
80 | } | ||
81 | if(repeat) | ||
82 | act |= ACT_REPEAT; | ||
83 | return act; | ||
84 | } | ||
42 | 85 | ||
43 | static struct | 86 | static struct |
44 | { | 87 | { |
@@ -97,23 +140,22 @@ static struct | |||
97 | bool dbg_hw_info_dma(void) | 140 | bool dbg_hw_info_dma(void) |
98 | { | 141 | { |
99 | lcd_setfont(FONT_SYSFIXED); | 142 | lcd_setfont(FONT_SYSFIXED); |
100 | 143 | ||
101 | while(1) | 144 | while(1) |
102 | { | 145 | { |
103 | int button = get_action(CONTEXT_STD, HZ / 25); | 146 | int button = my_get_action(HZ / 25); |
104 | switch(button) | 147 | switch(button) |
105 | { | 148 | { |
106 | case ACTION_STD_NEXT: | 149 | case ACT_NEXT: |
107 | case ACTION_STD_PREV: | 150 | case ACT_PREV: |
108 | case ACTION_STD_OK: | 151 | case ACT_OK: |
109 | case ACTION_STD_MENU: | ||
110 | lcd_setfont(FONT_UI); | 152 | lcd_setfont(FONT_UI); |
111 | return true; | 153 | return true; |
112 | case ACTION_STD_CANCEL: | 154 | case ACT_CANCEL: |
113 | lcd_setfont(FONT_UI); | 155 | lcd_setfont(FONT_UI); |
114 | return false; | 156 | return false; |
115 | } | 157 | } |
116 | 158 | ||
117 | lcd_clear_display(); | 159 | lcd_clear_display(); |
118 | 160 | ||
119 | lcd_putsf(0, 0, "S C name bar apb ahb una"); | 161 | lcd_putsf(0, 0, "S C name bar apb ahb una"); |
@@ -126,7 +168,7 @@ bool dbg_hw_info_dma(void) | |||
126 | dbg_channels[i].name, info.bar, info.apb_bytes, info.ahb_bytes, | 168 | dbg_channels[i].name, info.bar, info.apb_bytes, info.ahb_bytes, |
127 | info.nr_unaligned); | 169 | info.nr_unaligned); |
128 | } | 170 | } |
129 | 171 | ||
130 | lcd_update(); | 172 | lcd_update(); |
131 | yield(); | 173 | yield(); |
132 | } | 174 | } |
@@ -135,23 +177,22 @@ bool dbg_hw_info_dma(void) | |||
135 | bool dbg_hw_info_power(void) | 177 | bool dbg_hw_info_power(void) |
136 | { | 178 | { |
137 | lcd_setfont(FONT_SYSFIXED); | 179 | lcd_setfont(FONT_SYSFIXED); |
138 | 180 | ||
139 | while(1) | 181 | while(1) |
140 | { | 182 | { |
141 | int button = get_action(CONTEXT_STD, HZ / 10); | 183 | int button = my_get_action(HZ / 10); |
142 | switch(button) | 184 | switch(button) |
143 | { | 185 | { |
144 | case ACTION_STD_NEXT: | 186 | case ACT_NEXT: |
145 | case ACTION_STD_PREV: | 187 | case ACT_PREV: |
146 | case ACTION_STD_OK: | 188 | case ACT_OK: |
147 | case ACTION_STD_MENU: | ||
148 | lcd_setfont(FONT_UI); | 189 | lcd_setfont(FONT_UI); |
149 | return true; | 190 | return true; |
150 | case ACTION_STD_CANCEL: | 191 | case ACT_CANCEL: |
151 | lcd_setfont(FONT_UI); | 192 | lcd_setfont(FONT_UI); |
152 | return false; | 193 | return false; |
153 | } | 194 | } |
154 | 195 | ||
155 | lcd_clear_display(); | 196 | lcd_clear_display(); |
156 | 197 | ||
157 | struct imx233_power_info_t info = imx233_power_get_info(POWER_INFO_ALL); | 198 | struct imx233_power_info_t info = imx233_power_get_info(POWER_INFO_ALL); |
@@ -187,32 +228,31 @@ bool dbg_hw_info_power(void) | |||
187 | lcd_putsf(0, line++, "5V: dcdc: %d xfer: %d", info._5v_enable_dcdc, info._5v_dcdc_xfer); | 228 | lcd_putsf(0, line++, "5V: dcdc: %d xfer: %d", info._5v_enable_dcdc, info._5v_dcdc_xfer); |
188 | lcd_putsf(0, line++, "5V: thr: %d mV use: %d cmps: %d", info._5v_vbusvalid_thr, | 229 | lcd_putsf(0, line++, "5V: thr: %d mV use: %d cmps: %d", info._5v_vbusvalid_thr, |
189 | info._5v_vbusvalid_detect, info._5v_vbus_cmps); | 230 | info._5v_vbusvalid_detect, info._5v_vbus_cmps); |
190 | 231 | ||
191 | lcd_update(); | 232 | lcd_update(); |
192 | yield(); | 233 | yield(); |
193 | } | 234 | } |
194 | } | 235 | } |
195 | 236 | ||
196 | bool dbg_hw_info_adc(void) | 237 | bool dbg_hw_info_lradc(void) |
197 | { | 238 | { |
198 | lcd_setfont(FONT_SYSFIXED); | 239 | lcd_setfont(FONT_SYSFIXED); |
199 | 240 | ||
200 | while(1) | 241 | while(1) |
201 | { | 242 | { |
202 | int button = get_action(CONTEXT_STD, HZ / 25); | 243 | int button = my_get_action(HZ / 25); |
203 | switch(button) | 244 | switch(button) |
204 | { | 245 | { |
205 | case ACTION_STD_NEXT: | 246 | case ACT_NEXT: |
206 | case ACTION_STD_PREV: | 247 | case ACT_PREV: |
207 | case ACTION_STD_OK: | 248 | case ACT_OK: |
208 | case ACTION_STD_MENU: | ||
209 | lcd_setfont(FONT_UI); | 249 | lcd_setfont(FONT_UI); |
210 | return true; | 250 | return true; |
211 | case ACTION_STD_CANCEL: | 251 | case ACT_CANCEL: |
212 | lcd_setfont(FONT_UI); | 252 | lcd_setfont(FONT_UI); |
213 | return false; | 253 | return false; |
214 | } | 254 | } |
215 | 255 | ||
216 | lcd_clear_display(); | 256 | lcd_clear_display(); |
217 | 257 | ||
218 | /* add battery readout in mV, this it is not the direct output of a channel */ | 258 | /* add battery readout in mV, this it is not the direct output of a channel */ |
@@ -222,7 +262,7 @@ bool dbg_hw_info_adc(void) | |||
222 | lcd_putsf(0, i + 1, "%s %d", imx233_adc_channel_name[i], | 262 | lcd_putsf(0, i + 1, "%s %d", imx233_adc_channel_name[i], |
223 | adc_read(i)); | 263 | adc_read(i)); |
224 | } | 264 | } |
225 | 265 | ||
226 | lcd_update(); | 266 | lcd_update(); |
227 | yield(); | 267 | yield(); |
228 | } | 268 | } |
@@ -255,19 +295,18 @@ static struct | |||
255 | bool dbg_hw_info_clkctrl(void) | 295 | bool dbg_hw_info_clkctrl(void) |
256 | { | 296 | { |
257 | lcd_setfont(FONT_SYSFIXED); | 297 | lcd_setfont(FONT_SYSFIXED); |
258 | 298 | ||
259 | while(1) | 299 | while(1) |
260 | { | 300 | { |
261 | int button = get_action(CONTEXT_STD, HZ / 10); | 301 | int button = my_get_action(HZ / 10); |
262 | switch(button) | 302 | switch(button) |
263 | { | 303 | { |
264 | case ACTION_STD_NEXT: | 304 | case ACT_NEXT: |
265 | case ACTION_STD_PREV: | 305 | case ACT_PREV: |
266 | case ACTION_STD_OK: | 306 | case ACT_OK: |
267 | case ACTION_STD_MENU: | ||
268 | lcd_setfont(FONT_UI); | 307 | lcd_setfont(FONT_UI); |
269 | return true; | 308 | return true; |
270 | case ACTION_STD_CANCEL: | 309 | case ACT_CANCEL: |
271 | lcd_setfont(FONT_UI); | 310 | lcd_setfont(FONT_UI); |
272 | return false; | 311 | return false; |
273 | } | 312 | } |
@@ -313,23 +352,22 @@ bool dbg_hw_info_powermgmt(void) | |||
313 | 352 | ||
314 | while(1) | 353 | while(1) |
315 | { | 354 | { |
316 | int button = get_action(CONTEXT_STD, HZ / 10); | 355 | int button = my_get_action(HZ / 10); |
317 | switch(button) | 356 | switch(button) |
318 | { | 357 | { |
319 | case ACTION_STD_NEXT: | 358 | case ACT_NEXT: |
320 | case ACTION_STD_PREV: | 359 | case ACT_PREV: |
321 | case ACTION_STD_OK: | 360 | case ACT_OK: |
322 | case ACTION_STD_MENU: | ||
323 | lcd_setfont(FONT_UI); | 361 | lcd_setfont(FONT_UI); |
324 | return true; | 362 | return true; |
325 | case ACTION_STD_CANCEL: | 363 | case ACT_CANCEL: |
326 | lcd_setfont(FONT_UI); | 364 | lcd_setfont(FONT_UI); |
327 | return false; | 365 | return false; |
328 | } | 366 | } |
329 | 367 | ||
330 | lcd_clear_display(); | 368 | lcd_clear_display(); |
331 | struct imx233_powermgmt_info_t info = imx233_powermgmt_get_info(); | 369 | struct imx233_powermgmt_info_t info = imx233_powermgmt_get_info(); |
332 | 370 | ||
333 | lcd_putsf(0, 0, "state: %s", | 371 | lcd_putsf(0, 0, "state: %s", |
334 | info.state == DISCHARGING ? "discharging" : | 372 | info.state == DISCHARGING ? "discharging" : |
335 | #if CONFIG_CHARGING >= CHARGING_MONITOR | 373 | #if CONFIG_CHARGING >= CHARGING_MONITOR |
@@ -345,7 +383,7 @@ bool dbg_hw_info_powermgmt(void) | |||
345 | lcd_putsf(0, 1, "charging tmo: %d", info.charging_timeout); | 383 | lcd_putsf(0, 1, "charging tmo: %d", info.charging_timeout); |
346 | lcd_putsf(0, 2, "topoff tmo: %d", info.topoff_timeout); | 384 | lcd_putsf(0, 2, "topoff tmo: %d", info.topoff_timeout); |
347 | lcd_putsf(0, 3, "4p2ilimit tmo: %d", info.incr_4p2_ilimit_timeout); | 385 | lcd_putsf(0, 3, "4p2ilimit tmo: %d", info.incr_4p2_ilimit_timeout); |
348 | 386 | ||
349 | lcd_update(); | 387 | lcd_update(); |
350 | yield(); | 388 | yield(); |
351 | } | 389 | } |
@@ -354,30 +392,29 @@ bool dbg_hw_info_powermgmt(void) | |||
354 | bool dbg_hw_info_rtc(void) | 392 | bool dbg_hw_info_rtc(void) |
355 | { | 393 | { |
356 | lcd_setfont(FONT_SYSFIXED); | 394 | lcd_setfont(FONT_SYSFIXED); |
357 | 395 | ||
358 | while(1) | 396 | while(1) |
359 | { | 397 | { |
360 | int button = get_action(CONTEXT_STD, HZ / 10); | 398 | int button = my_get_action(HZ / 10); |
361 | switch(button) | 399 | switch(button) |
362 | { | 400 | { |
363 | case ACTION_STD_NEXT: | 401 | case ACT_NEXT: |
364 | case ACTION_STD_PREV: | 402 | case ACT_PREV: |
365 | case ACTION_STD_OK: | 403 | case ACT_OK: |
366 | case ACTION_STD_MENU: | ||
367 | lcd_setfont(FONT_UI); | 404 | lcd_setfont(FONT_UI); |
368 | return true; | 405 | return true; |
369 | case ACTION_STD_CANCEL: | 406 | case ACT_CANCEL: |
370 | lcd_setfont(FONT_UI); | 407 | lcd_setfont(FONT_UI); |
371 | return false; | 408 | return false; |
372 | } | 409 | } |
373 | 410 | ||
374 | lcd_clear_display(); | 411 | lcd_clear_display(); |
375 | struct imx233_rtc_info_t info = imx233_rtc_get_info(); | 412 | struct imx233_rtc_info_t info = imx233_rtc_get_info(); |
376 | 413 | ||
377 | lcd_putsf(0, 0, "seconds: %lu", info.seconds); | 414 | lcd_putsf(0, 0, "seconds: %lu", info.seconds); |
378 | for(int i = 0; i < 6; i++) | 415 | for(int i = 0; i < 6; i++) |
379 | lcd_putsf(0, i + 1, "persistent%d: 0x%lx", i, info.persistent[i]); | 416 | lcd_putsf(0, i + 1, "persistent%d: 0x%lx", i, info.persistent[i]); |
380 | 417 | ||
381 | lcd_update(); | 418 | lcd_update(); |
382 | yield(); | 419 | yield(); |
383 | } | 420 | } |
@@ -387,26 +424,25 @@ bool dbg_hw_info_rtc(void) | |||
387 | bool dbg_hw_info_dcp(void) | 424 | bool dbg_hw_info_dcp(void) |
388 | { | 425 | { |
389 | lcd_setfont(FONT_SYSFIXED); | 426 | lcd_setfont(FONT_SYSFIXED); |
390 | 427 | ||
391 | while(1) | 428 | while(1) |
392 | { | 429 | { |
393 | int button = get_action(CONTEXT_STD, HZ / 10); | 430 | int button = my_get_action(HZ / 10); |
394 | switch(button) | 431 | switch(button) |
395 | { | 432 | { |
396 | case ACTION_STD_NEXT: | 433 | case ACT_NEXT: |
397 | case ACTION_STD_PREV: | 434 | case ACT_PREV: |
398 | case ACTION_STD_OK: | 435 | case ACT_OK: |
399 | case ACTION_STD_MENU: | ||
400 | lcd_setfont(FONT_UI); | 436 | lcd_setfont(FONT_UI); |
401 | return true; | 437 | return true; |
402 | case ACTION_STD_CANCEL: | 438 | case ACT_CANCEL: |
403 | lcd_setfont(FONT_UI); | 439 | lcd_setfont(FONT_UI); |
404 | return false; | 440 | return false; |
405 | } | 441 | } |
406 | 442 | ||
407 | lcd_clear_display(); | 443 | lcd_clear_display(); |
408 | struct imx233_dcp_info_t info = imx233_dcp_get_info(DCP_INFO_ALL); | 444 | struct imx233_dcp_info_t info = imx233_dcp_get_info(DCP_INFO_ALL); |
409 | 445 | ||
410 | lcd_putsf(0, 0, "crypto: %d csc: %d", info.has_crypto, info.has_csc); | 446 | lcd_putsf(0, 0, "crypto: %d csc: %d", info.has_crypto, info.has_csc); |
411 | lcd_putsf(0, 1, "keys: %d channels: %d", info.num_keys, info.num_channels); | 447 | lcd_putsf(0, 1, "keys: %d channels: %d", info.num_keys, info.num_channels); |
412 | lcd_putsf(0, 2, "ciphers: 0x%lx hash: 0x%lx", info.ciphers, info.hashs); | 448 | lcd_putsf(0, 2, "ciphers: 0x%lx hash: 0x%lx", info.ciphers, info.hashs); |
@@ -446,24 +482,23 @@ bool dbg_hw_info_icoll(void) | |||
446 | 482 | ||
447 | while(1) | 483 | while(1) |
448 | { | 484 | { |
449 | int button = get_action(CONTEXT_STD, HZ / 10); | 485 | int button = my_get_action(HZ / 10); |
450 | switch(button) | 486 | switch(button) |
451 | { | 487 | { |
452 | case ACTION_STD_NEXT: | 488 | case ACT_NEXT: |
453 | first_irq++; | 489 | first_irq++; |
454 | if(first_irq >= dbg_irqs_count) | 490 | if(first_irq >= dbg_irqs_count) |
455 | first_irq = dbg_irqs_count - 1; | 491 | first_irq = dbg_irqs_count - 1; |
456 | break; | 492 | break; |
457 | case ACTION_STD_PREV: | 493 | case ACT_PREV: |
458 | first_irq--; | 494 | first_irq--; |
459 | if(first_irq < 0) | 495 | if(first_irq < 0) |
460 | first_irq = 0; | 496 | first_irq = 0; |
461 | break; | 497 | break; |
462 | case ACTION_STD_OK: | 498 | case ACT_OK: |
463 | case ACTION_STD_MENU: | ||
464 | lcd_setfont(FONT_UI); | 499 | lcd_setfont(FONT_UI); |
465 | return true; | 500 | return true; |
466 | case ACTION_STD_CANCEL: | 501 | case ACT_CANCEL: |
467 | lcd_setfont(FONT_UI); | 502 | lcd_setfont(FONT_UI); |
468 | return false; | 503 | return false; |
469 | } | 504 | } |
@@ -490,25 +525,24 @@ bool dbg_hw_info_pinctrl(void) | |||
490 | #endif | 525 | #endif |
491 | while(1) | 526 | while(1) |
492 | { | 527 | { |
493 | int button = get_action(CONTEXT_STD, HZ / 10); | 528 | int button = my_get_action(HZ / 10); |
494 | switch(button) | 529 | switch(button) |
495 | { | 530 | { |
496 | case ACTION_STD_NEXT: | 531 | case ACT_NEXT: |
497 | #ifdef IMX233_PINCTRL_DEBUG | 532 | #ifdef IMX233_PINCTRL_DEBUG |
498 | top_user++; | 533 | top_user++; |
499 | break; | 534 | break; |
500 | #endif | 535 | #endif |
501 | case ACTION_STD_PREV: | 536 | case ACT_PREV: |
502 | #ifdef IMX233_PINCTRL_DEBUG | 537 | #ifdef IMX233_PINCTRL_DEBUG |
503 | if(top_user > 0) | 538 | if(top_user > 0) |
504 | top_user--; | 539 | top_user--; |
505 | break; | 540 | break; |
506 | #endif | 541 | #endif |
507 | case ACTION_STD_OK: | 542 | case ACT_OK: |
508 | case ACTION_STD_MENU: | ||
509 | lcd_setfont(FONT_UI); | 543 | lcd_setfont(FONT_UI); |
510 | return true; | 544 | return true; |
511 | case ACTION_STD_CANCEL: | 545 | case ACT_CANCEL: |
512 | lcd_setfont(FONT_UI); | 546 | lcd_setfont(FONT_UI); |
513 | return false; | 547 | return false; |
514 | } | 548 | } |
@@ -587,21 +621,20 @@ bool dbg_hw_info_ocotp(void) | |||
587 | 621 | ||
588 | while(1) | 622 | while(1) |
589 | { | 623 | { |
590 | int button = get_action(CONTEXT_STD, HZ / 10); | 624 | int button = my_get_action(HZ / 10); |
591 | switch(button) | 625 | switch(button) |
592 | { | 626 | { |
593 | case ACTION_STD_NEXT: | 627 | case ACT_NEXT: |
594 | top_user++; | 628 | top_user++; |
595 | break; | 629 | break; |
596 | case ACTION_STD_PREV: | 630 | case ACT_PREV: |
597 | if(top_user > 0) | 631 | if(top_user > 0) |
598 | top_user--; | 632 | top_user--; |
599 | break; | 633 | break; |
600 | case ACTION_STD_OK: | 634 | case ACT_OK: |
601 | case ACTION_STD_MENU: | ||
602 | lcd_setfont(FONT_UI); | 635 | lcd_setfont(FONT_UI); |
603 | return true; | 636 | return true; |
604 | case ACTION_STD_CANCEL: | 637 | case ACT_CANCEL: |
605 | lcd_setfont(FONT_UI); | 638 | lcd_setfont(FONT_UI); |
606 | return false; | 639 | return false; |
607 | } | 640 | } |
@@ -634,18 +667,17 @@ bool dbg_hw_info_pwm(void) | |||
634 | 667 | ||
635 | while(1) | 668 | while(1) |
636 | { | 669 | { |
637 | int button = get_action(CONTEXT_STD, HZ / 10); | 670 | int button = my_get_action(HZ / 10); |
638 | switch(button) | 671 | switch(button) |
639 | { | 672 | { |
640 | case ACTION_STD_NEXT: | 673 | case ACT_NEXT: |
641 | case ACTION_STD_PREV: | 674 | case ACT_PREV: |
642 | detailled_view = !detailled_view; | 675 | detailled_view = !detailled_view; |
643 | break; | 676 | break; |
644 | case ACTION_STD_OK: | 677 | case ACT_OK: |
645 | case ACTION_STD_MENU: | ||
646 | lcd_setfont(FONT_UI); | 678 | lcd_setfont(FONT_UI); |
647 | return true; | 679 | return true; |
648 | case ACTION_STD_CANCEL: | 680 | case ACT_CANCEL: |
649 | lcd_setfont(FONT_UI); | 681 | lcd_setfont(FONT_UI); |
650 | return false; | 682 | return false; |
651 | } | 683 | } |
@@ -693,22 +725,21 @@ bool dbg_hw_info_usb(void) | |||
693 | 725 | ||
694 | while(1) | 726 | while(1) |
695 | { | 727 | { |
696 | int button = get_action(CONTEXT_STD, HZ / 10); | 728 | int button = my_get_action(HZ / 10); |
697 | switch(button) | 729 | switch(button) |
698 | { | 730 | { |
699 | case ACTION_STD_NEXT: | 731 | case ACT_NEXT: |
700 | BF_SET(USBPHY_CTRL, ENOTGIDDETECT); | 732 | BF_SET(USBPHY_CTRL, ENOTGIDDETECT); |
701 | BF_SET(USBPHY_CTRL, ENDEVPLUGINDETECT); | 733 | BF_SET(USBPHY_CTRL, ENDEVPLUGINDETECT); |
702 | break; | 734 | break; |
703 | case ACTION_STD_PREV: | 735 | case ACT_PREV: |
704 | BF_CLR(USBPHY_CTRL, ENOTGIDDETECT); | 736 | BF_CLR(USBPHY_CTRL, ENOTGIDDETECT); |
705 | BF_CLR(USBPHY_CTRL, ENDEVPLUGINDETECT); | 737 | BF_CLR(USBPHY_CTRL, ENDEVPLUGINDETECT); |
706 | break; | 738 | break; |
707 | case ACTION_STD_OK: | 739 | case ACT_OK: |
708 | case ACTION_STD_MENU: | ||
709 | lcd_setfont(FONT_UI); | 740 | lcd_setfont(FONT_UI); |
710 | return true; | 741 | return true; |
711 | case ACTION_STD_CANCEL: | 742 | case ACT_CANCEL: |
712 | lcd_setfont(FONT_UI); | 743 | lcd_setfont(FONT_UI); |
713 | return false; | 744 | return false; |
714 | } | 745 | } |
@@ -739,16 +770,15 @@ bool dbg_hw_info_emi(void) | |||
739 | 770 | ||
740 | while(1) | 771 | while(1) |
741 | { | 772 | { |
742 | int button = get_action(CONTEXT_STD, HZ / 10); | 773 | int button = my_get_action(HZ / 10); |
743 | switch(button) | 774 | switch(button) |
744 | { | 775 | { |
745 | case ACTION_STD_NEXT: | 776 | case ACT_NEXT: |
746 | case ACTION_STD_PREV: | 777 | case ACT_PREV: |
747 | case ACTION_STD_OK: | 778 | case ACT_OK: |
748 | case ACTION_STD_MENU: | ||
749 | lcd_setfont(FONT_UI); | 779 | lcd_setfont(FONT_UI); |
750 | return true; | 780 | return true; |
751 | case ACTION_STD_CANCEL: | 781 | case ACT_CANCEL: |
752 | lcd_setfont(FONT_UI); | 782 | lcd_setfont(FONT_UI); |
753 | return false; | 783 | return false; |
754 | } | 784 | } |
@@ -769,13 +799,138 @@ bool dbg_hw_info_emi(void) | |||
769 | } | 799 | } |
770 | } | 800 | } |
771 | 801 | ||
802 | bool dbg_hw_info_audioout(void) | ||
803 | { | ||
804 | lcd_setfont(FONT_SYSFIXED); | ||
805 | |||
806 | while(1) | ||
807 | { | ||
808 | int button = my_get_action(HZ / 10); | ||
809 | switch(button) | ||
810 | { | ||
811 | case ACT_NEXT: | ||
812 | case ACT_PREV: | ||
813 | case ACT_OK: | ||
814 | lcd_setfont(FONT_UI); | ||
815 | return true; | ||
816 | case ACT_CANCEL: | ||
817 | lcd_setfont(FONT_UI); | ||
818 | return false; | ||
819 | } | ||
820 | |||
821 | lcd_clear_display(); | ||
822 | struct imx233_audioout_info_t info = imx233_audioout_get_info(); | ||
823 | int line = 0; | ||
824 | #define display_sys(sys, name) \ | ||
825 | if(info.sys) \ | ||
826 | { \ | ||
827 | char buffer[64]; \ | ||
828 | snprintf(buffer, 64, "%s: ", name); \ | ||
829 | for(int i = 0; i < 2; i++) \ | ||
830 | { \ | ||
831 | if(info.sys##mute[i]) \ | ||
832 | strcat(buffer, "mute"); \ | ||
833 | else \ | ||
834 | snprintf(buffer + strlen(buffer), 64, "%d.%d", \ | ||
835 | /* properly handle negative values ! */ \ | ||
836 | info.sys##vol[i] / 10, (10 + (info.sys##vol[i]) % 10) % 10); \ | ||
837 | if(i == 0) \ | ||
838 | strcat(buffer, " / "); \ | ||
839 | else \ | ||
840 | strcat(buffer, " dB"); \ | ||
841 | } \ | ||
842 | lcd_putsf(0, line++, "%s", buffer); \ | ||
843 | } \ | ||
844 | else \ | ||
845 | lcd_putsf(0, line++, "%s: powered down", name); | ||
846 | display_sys(dac, "DAC"); | ||
847 | display_sys(hp, "HP"); | ||
848 | display_sys(spkr, "SPKR"); | ||
849 | #undef display_sys | ||
850 | lcd_putsf(0, line++, "capless: %d", info.capless); | ||
851 | |||
852 | lcd_update(); | ||
853 | yield(); | ||
854 | } | ||
855 | } | ||
856 | |||
857 | static struct | ||
858 | { | ||
859 | const char *name; | ||
860 | bool (*fn)(void); | ||
861 | } debug_screens[] = | ||
862 | { | ||
863 | {"clock", dbg_hw_info_clkctrl}, | ||
864 | {"dma", dbg_hw_info_dma}, | ||
865 | {"lradc", dbg_hw_info_lradc}, | ||
866 | {"power", dbg_hw_info_power}, | ||
867 | {"powermgmt", dbg_hw_info_powermgmt}, | ||
868 | {"rtc", dbg_hw_info_rtc}, | ||
869 | {"dcp", dbg_hw_info_dcp}, | ||
870 | {"pinctrl", dbg_hw_info_pinctrl}, | ||
871 | {"icoll", dbg_hw_info_icoll}, | ||
872 | {"ocotp", dbg_hw_info_ocotp}, | ||
873 | {"pwm", dbg_hw_info_pwm}, | ||
874 | {"usb", dbg_hw_info_usb}, | ||
875 | {"emi", dbg_hw_info_emi}, | ||
876 | {"audioout", dbg_hw_info_audioout}, | ||
877 | {"target", dbg_hw_target_info}, | ||
878 | }; | ||
879 | |||
772 | bool dbg_hw_info(void) | 880 | bool dbg_hw_info(void) |
773 | { | 881 | { |
774 | return dbg_hw_info_clkctrl() && dbg_hw_info_dma() && dbg_hw_info_adc() && | 882 | int nr_lines = lcd_getheight() / font_get(lcd_getfont())->height; |
775 | dbg_hw_info_power() && dbg_hw_info_powermgmt() && dbg_hw_info_rtc() && | 883 | int len = ARRAYLEN(debug_screens); |
776 | dbg_hw_info_dcp() && dbg_hw_info_pinctrl() && dbg_hw_info_icoll() && | 884 | int top_visible = 0; |
777 | dbg_hw_info_ocotp() && dbg_hw_info_pwm() && dbg_hw_info_usb() && dbg_hw_info_emi() && | 885 | int highlight = 0; |
778 | dbg_hw_target_info(); | 886 | while(1) |
887 | { | ||
888 | int button = my_get_action(HZ / 10); | ||
889 | switch(button) | ||
890 | { | ||
891 | case ACT_NEXT: | ||
892 | highlight = (highlight + 1) % len; | ||
893 | break; | ||
894 | case ACT_PREV: | ||
895 | highlight = (highlight + len - 1) % len; | ||
896 | break; | ||
897 | case ACT_OK: | ||
898 | // if the screen returns true, advance to next screen | ||
899 | while(debug_screens[highlight].fn()) | ||
900 | highlight = (highlight + 1) % len; | ||
901 | lcd_setfont(FONT_UI); | ||
902 | break; | ||
903 | case ACT_CANCEL: | ||
904 | return false; | ||
905 | } | ||
906 | // adjust top visible if needed | ||
907 | if(highlight < top_visible) | ||
908 | top_visible = highlight; | ||
909 | else if(highlight >= top_visible + nr_lines) | ||
910 | top_visible = highlight - nr_lines + 1; | ||
911 | |||
912 | lcd_clear_display(); | ||
913 | |||
914 | for(int i = top_visible; i < len && i < top_visible + nr_lines; i++) | ||
915 | { | ||
916 | if(i == highlight) | ||
917 | { | ||
918 | lcd_set_foreground(LCD_BLACK); | ||
919 | lcd_set_background(LCD_RGBPACK(255, 255, 0)); | ||
920 | } | ||
921 | else | ||
922 | { | ||
923 | lcd_set_foreground(LCD_WHITE); | ||
924 | lcd_set_background(LCD_BLACK); | ||
925 | } | ||
926 | lcd_putsf(0, i - top_visible, "%s", debug_screens[i].name); | ||
927 | } | ||
928 | lcd_set_foreground(LCD_WHITE); | ||
929 | lcd_set_background(LCD_BLACK); | ||
930 | |||
931 | lcd_update(); | ||
932 | yield(); | ||
933 | } | ||
779 | } | 934 | } |
780 | 935 | ||
781 | bool dbg_ports(void) | 936 | bool dbg_ports(void) |