FreeCalypso > hg > fc-tourmaline
annotate src/cs/drivers/drv_app/r2d/lcds/luna/r2d_onoff_i.c @ 296:a927f030a4e0
add AT@VIBR and AT@VIBS commands for testing VIBR SWE
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 28 Mar 2022 00:43:11 +0000 |
parents | 75758d7a9be3 |
children |
rev | line source |
---|---|
217
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include "r2d/lcds/luna/r2d_luna_lcd.h" |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include "main/sys_types.h" |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include "armio.h" |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
277
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
5 static void lcd_suspend(void) |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
6 { |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
7 if (r2d_lcd_hw_suspend) |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
8 return; /* already in suspend */ |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
9 r2d_lcd_hw_suspend = 1; |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
10 LCD_REG_WR(0x0007, 0); /* display off */ |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
11 rvf_delay(RVF_MS_TO_TICKS(50)); |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
12 LCD_REG_WR(0x0010, 1); /* suspend mode */ |
278
75758d7a9be3
Luna: allow ABB superdeep sleep when the LCD is in suspend mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
277
diff
changeset
|
13 ABB_sleep_allowed = 1; |
277
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
14 } |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
15 |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
16 static void lcd_resume(void) |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
17 { |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
18 if (!r2d_lcd_hw_suspend) |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
19 return; /* already on */ |
278
75758d7a9be3
Luna: allow ABB superdeep sleep when the LCD is in suspend mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
277
diff
changeset
|
20 ABB_sleep_allowed = 0; |
277
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
21 LCD_REG_WR(0x0010, 0); /* out of suspend */ |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
22 rvf_delay(RVF_MS_TO_TICKS(50)); |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
23 LCD_REG_WR(0x0007, 0x1017); /* display on */ |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
24 r2d_lcd_hw_suspend = 0; |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
25 r2d_refresh(); |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
26 } |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
27 |
217
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 static void r2d_onoff_action(enum blrr_display_state set_state) |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 { |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 UBYTE on_off; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 /* |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 * PWL control: on our current Luna setups (Caramel2 or iWOW DSK) |
277
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
34 * PWL is only an indicator LED for developers. We use this PWL |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
35 * indicator to show the state of "virtual dimming", as there is |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
36 * no physical LCD backlight dimming control on Luna. |
217
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 */ |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 switch (set_state) { |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 case BLRR_DISPLAY_OFF: |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 *(volatile SYS_UWORD8 *)0xFFFE8000 = 0; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 *(volatile SYS_UWORD8 *)0xFFFE8001 = 0; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 on_off = 0; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 break; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 case BLRR_DISPLAY_ON: |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 *(volatile SYS_UWORD8 *)0xFFFE8000 = 255; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 *(volatile SYS_UWORD8 *)0xFFFE8001 = 1; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 on_off = 1; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 break; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 case BLRR_DISPLAY_INCALL: |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 *(volatile SYS_UWORD8 *)0xFFFE8000 = 16; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 *(volatile SYS_UWORD8 *)0xFFFE8001 = 1; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 on_off = 1; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 break; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 case BLRR_DISPLAY_CHG_BOOT: |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 *(volatile SYS_UWORD8 *)0xFFFE8000 = 64; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 *(volatile SYS_UWORD8 *)0xFFFE8001 = 1; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 on_off = 1; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 break; |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 default: |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 return; /* error, but we are a void function */ |
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
277
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
62 /* physical LCD and backlight on/off */ |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
63 if (on_off) { |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
64 lcd_resume(); |
217
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 AI_SetBit(9); |
277
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
66 } else { |
217
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 AI_ResetBit(9); |
277
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
68 lcd_suspend(); |
0196b6bf633c
R2D: LCD hardware suspend implemented for Luna
Mychaela Falconia <falcon@freecalypso.org>
parents:
217
diff
changeset
|
69 } |
217
6541e43f88e5
R2D display on/off control implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 } |