This source file includes following definitions.
- _time
- set_shooting_status
- _GetPropertyCase
- _SetPropertyCase
- shutdown
- dummy_nop
- led_on
- led_off
- debug_led
- get_flash_params_count
- set_led
- camera_set_led
- get_uiprop_value
1 #include "platform.h"
2 #include "lolevel.h"
3 #define PARAM_FILE_COUNTER 0x2A
4
5 extern void _sub_FF821D04(long mem, long *data);
6 extern long _GetPropertyCase_orig(long opt_id, void *buf, long bufsize);
7 extern long _SetPropertyCase_orig(long opt_id, void *buf, long bufsize);
8 extern void _SetAFBeamBrightness(long val);
9 extern void _SetAFBeamOff();
10 extern unsigned long _time_orig(unsigned long *timer);
11
12 static unsigned long bootuptime = 0;
13
14 unsigned long _time(__attribute__ ((unused))unsigned long *timer) {
15
16
17
18
19
20
21
22 unsigned long timer2;
23 _GetSystemTime((long*)&timer2);
24 if (bootuptime == 0) {
25 bootuptime = _time_orig((unsigned long*)0)-(timer2)/1000;
26 }
27 return bootuptime+(timer2)/1000;
28 }
29
30
31
32
33
34
35
36
37
38
39 volatile long shooting_status_=0;
40
41
42
43
44 void set_shooting_status(long l){
45
46
47
48
49
50
51
52
53
54 switch(l){
55 case(0x0):
56
57 shooting_status_=1;
58 break;
59 case(0x1):
60
61 shooting_status_=1;
62 break;
63 case(0x2):
64
65 shooting_status_=0;
66 break;
67 case(0x3):
68
69 shooting_status_=0;
70 break;
71 case(0x6):
72
73 shooting_status_=1;
74 break;
75 case(0x7):
76
77 shooting_status_=0;
78 break;
79 case (0xb):
80
81 shooting_status_=0;
82 break;
83
84 default:
85 shooting_status_=0;
86 break;
87 }
88 }
89
90
91 long _GetPropertyCase(long cse, void *ptr, long len){
92 if (cse == PROPCASE_SHOOTING){
93 if (len==sizeof(long)){
94 *(long*)ptr = shooting_status_;
95 }else if (len==sizeof(short)){
96 *(short*)ptr = shooting_status_;
97 }else{
98
99 }
100 }else{
101 return _GetPropertyCase_orig(cse, ptr, len);
102 }
103 return 0;
104 }
105
106 long _SetPropertyCase(long cse, void *ptr, long len){
107 if (cse == PROPCASE_SHOOTING){
108
109 return 0;
110 }else{
111 return _SetPropertyCase_orig(cse, ptr, len);
112 }
113 }
114
115 void shutdown()
116 {
117 volatile long *p = (void*)0xc022002c;
118
119 asm(
120 "MRS R1, CPSR\n"
121 "AND R0, R1, #0x80\n"
122 "ORR R1, R1, #0x80\n"
123 "MSR CPSR_cf, R1\n"
124 :::"r1","r0");
125
126 *p = 0x46;
127
128 while(1);
129 }
130
131
132
133
134
135
136
137
138
139
140
141
142
143 void dummy_nop(){
144 }
145
146
147 #define LED_PR 0xc0220088
148 #define LED_BRIGHTNESS 200
149 #define LED_GREEN 4
150 #define LED_YELLOW 5
151 #define LED_ORANGE 7
152 #define LED_BLUE 8
153 #define LED_AF_BEAM 9
154 #define LED_TIMER 10
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171 static void led_on(const int led, const int brightness)
172 {
173 if (led < 4 || led > 10 || led == 6) return;
174
175
176
177
178
179
180
181
182
183
184
185
186 volatile long *p;
187 switch(led){
188 case (LED_GREEN) : p=(void*)0xc02200D8; break;
189 case (LED_ORANGE): p=(void*)0xc02200DC; break;
190 case (LED_YELLOW): p=(void*)0xc02200E0; break;
191 case (LED_BLUE) : p=(void*)0xc02200E4; break;
192 case (LED_AF_BEAM): p=(void*)0xc02200EC; break;
193 default: return;
194 }
195
196 if (led == LED_AF_BEAM){
197 _SetAFBeamBrightness(brightness);
198 }else{
199 *p=0x46;
200 }
201 }
202
203
204 static void led_off(const int led)
205 {
206 if (led < 4 || led > 10 || led == 6) return;
207
208 volatile long *p;
209 switch(led){
210 case (LED_GREEN) : p=(void*)0xc02200D8; break;
211 case (LED_ORANGE): p=(void*)0xc02200DC; break;
212 case (LED_YELLOW): p=(void*)0xc02200E0; break;
213 case (LED_BLUE) : p=(void*)0xc02200E4; break;
214 case (LED_AF_BEAM): p=(void*)0xc02200EC; break;
215 default: return;
216 }
217
218 if (led == LED_AF_BEAM){
219 _SetAFBeamOff();
220 }else{
221 *p=0x44;
222 }
223
224 }
225
226 void debug_led(int state)
227 {
228 if (state)
229 led_on(LED_BLUE, LED_BRIGHTNESS);
230 else
231 led_off(LED_BLUE);
232 }
233
234 int get_flash_params_count(void){
235 return 70;
236 }
237
238 void set_led(int led, int state)
239 {
240 if (state)
241 led_on(led, LED_BRIGHTNESS);
242 else
243 led_off(led);
244 }
245 void camera_set_led(int led, int state, int bright)
246 {
247 if (state) {
248 if (bright > LED_BRIGHTNESS) bright = LED_BRIGHTNESS;
249 if (led == 6) {
250 led_on(4, bright);
251 led_on(5, bright);
252 } else
253 led_on(led, bright);
254 }
255 else
256 if (led == 6) {
257 led_off(4);
258 led_off(5);
259 } else
260 led_off(led);
261 }
262
263 short get_uiprop_value(unsigned long id)
264 {
265
266 if (id >= (unsigned)uiprop_count)
267 return 0;
268 return _PTM_GetCurrentItem(id);
269 }