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