This source file includes following definitions.
- hook_raw_image_addr
- hook_alt_raw_image_addr
- camera_jpeg_count_str
- vid_bitmap_refresh
- shutdown
- debug_led
- camera_set_led
- get_flash_params_count
- JogDial_CW
- JogDial_CCW
- vid_get_viewport_fb
- vid_get_viewport_live_fb
- vid_get_viewport_fb_d
- vid_get_bitmap_fb
- vid_get_viewport_width
- vid_get_viewport_xoffset
- vid_get_viewport_display_xoffset
- vid_get_viewport_height
- vp_yoffset
- vid_get_viewport_yoffset
- vid_get_viewport_display_yoffset
- vid_get_viewport_height_proper
- vid_get_palette_type
- vid_get_palette_size
- vid_get_bitmap_active_buffer
- vid_get_bitmap_active_palette
- load_chdk_palette
1 #include "platform.h"
2 #include "platform_palette.h"
3 #include "lolevel.h"
4
5
6 extern int active_raw_buffer;
7 extern char* raw_buffers[];
8
9 char *hook_raw_image_addr()
10 {
11 return raw_buffers[active_raw_buffer];
12 }
13
14 char *hook_alt_raw_image_addr()
15 {
16 return raw_buffers[active_raw_buffer^1];
17 }
18
19
20 char *camera_jpeg_count_str()
21 {
22 extern char jpeg_count_str[];
23 return jpeg_count_str;
24 }
25
26
27 void vid_bitmap_refresh()
28 {
29 extern int full_screen_refresh;
30 extern void _ScreenUnlock();
31 extern void _ScreenLock();
32
33 full_screen_refresh |= 3;
34 _ScreenLock();
35 _ScreenUnlock();
36 }
37
38
39 void shutdown()
40 {
41 volatile long *p = (void*)0xC022001C;
42
43 asm(
44 "MRS R1, CPSR\n"
45 "AND R0, R1, #0x80\n"
46 "ORR R1, R1, #0x80\n"
47 "MSR CPSR_cf, R1\n"
48 :::"r1","r0");
49
50 *p = 0x44;
51
52 while(1);
53 }
54
55 #define LED_PR 0xC022C30C
56
57 void debug_led(int state)
58 {
59
60
61
62 volatile long *p = (void*)LED_PR;
63 *p = (*p & 0xFFFFFFCF) | ((state) ? 0x00 : 0x20);
64 }
65
66
67
68
69 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
70 static char led_table[2]={3,9};
71 _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
72 }
73
74 int get_flash_params_count(void) { return 0x9f; }
75
76 void JogDial_CW(void){
77 _PostLogicalEventToUI(0x872, 1);
78 }
79
80 void JogDial_CCW(void){
81 _PostLogicalEventToUI(0x873, 1);
82 }
83
84
85
86
87
88 extern char active_viewport_buffer;
89 extern void* viewport_buffers[];
90
91 void *vid_get_viewport_fb()
92 {
93
94 return viewport_buffers[0];
95 }
96
97 void *vid_get_viewport_live_fb()
98 {
99 int b = (active_viewport_buffer-1)&3;
100 if ((b == 3) && (camera_info.state.mode_video || ((camera_info.state.mode & MODE_SHOOTING_MASK) == MODE_VIDEO_MOVIE_DIGEST) || (get_movie_status()==VIDEO_RECORD_IN_PROGRESS)))
101 b = 2;
102
103
104 return viewport_buffers[b];
105 }
106
107 void *vid_get_viewport_fb_d()
108 {
109 extern char *viewport_fb_d;
110 return viewport_fb_d;
111 }
112
113
114 extern int active_bitmap_buffer;
115 extern char* bitmap_buffer[];
116
117 void *vid_get_bitmap_fb()
118 {
119
120 return bitmap_buffer[0];
121 }
122
123 int vid_get_viewport_width()
124 {
125 if (camera_info.state.mode_play)
126 {
127 return 360;
128 }
129 extern int _GetVRAMHPixelsSize();
130 return _GetVRAMHPixelsSize() >> 1;
131 }
132
133
134
135 static long vp_xo[5] = { 0, 0, 0, 44 };
136
137 int vid_get_viewport_xoffset()
138 {
139 if (camera_info.state.mode_play)
140 {
141 return 0;
142 }
143 else if (shooting_get_prop(PROPCASE_SHOOTING_MODE) == 16909)
144 {
145 return 0;
146 }
147 else
148 {
149 return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
150 }
151 }
152
153 int vid_get_viewport_display_xoffset()
154 {
155 if (camera_info.state.mode_play)
156 {
157 return 0;
158 }
159 else if (shooting_get_prop(PROPCASE_SHOOTING_MODE) == 16909)
160 {
161 if (shooting_get_prop(PROPCASE_STITCH_DIRECTION) == 0)
162 if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)
163 return 40;
164 else
165 return 140;
166 else
167 if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)
168 return 140;
169 else
170 return 40;
171 }
172 else
173 {
174 return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
175 }
176 }
177
178 long vid_get_viewport_height()
179 {
180 if (camera_info.state.mode_play)
181 {
182 return 240;
183 }
184 extern int _GetVRAMVPixelsSize();
185 return _GetVRAMVPixelsSize();
186 }
187
188 static int vp_yoffset(int stitch)
189 {
190
191
192 static long vp_yo[5] = { 0, 30, 13, 0 };
193
194 if (camera_info.state.mode_play)
195 {
196 return 0;
197 }
198 else if (shooting_get_prop(PROPCASE_SHOOTING_MODE) == 16908)
199 {
200 return stitch;
201 }
202 else if (camera_info.state.mode_video)
203 {
204 return 30;
205 }
206 else
207 {
208 return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
209 }
210 }
211
212 int vid_get_viewport_yoffset()
213 {
214 return vp_yoffset(0);
215 }
216
217 int vid_get_viewport_display_yoffset()
218 {
219 return vp_yoffset(72);
220 }
221
222
223
224 int vid_get_viewport_height_proper() { return vid_get_viewport_height(); }
225 int vid_get_palette_type() { return 3; }
226 int vid_get_palette_size() { return 256 * 4; }
227
228 void *vid_get_bitmap_active_buffer()
229 {
230 return bitmap_buffer[active_bitmap_buffer];
231 }
232
233 void *vid_get_bitmap_active_palette()
234 {
235 extern int active_palette_buffer;
236 extern char* palette_buffer[];
237 void* p = palette_buffer[active_palette_buffer];
238
239 if (p) p += 4;
240 return p;
241 }
242
243
244 void load_chdk_palette()
245 {
246 extern int active_palette_buffer;
247
248 if ((active_palette_buffer == 0) || (active_palette_buffer == 3) || (active_palette_buffer == 6))
249 {
250 int *pal = (int*)vid_get_bitmap_active_palette();
251 if (pal && pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
252 {
253 pal[CHDK_COLOR_BASE+0] = 0x33ADF62;
254 pal[CHDK_COLOR_BASE+1] = 0x326EA40;
255 pal[CHDK_COLOR_BASE+2] = 0x34CD57F;
256 pal[CHDK_COLOR_BASE+3] = 0x373BFAE;
257 pal[CHDK_COLOR_BASE+4] = 0x34BD6CA;
258 pal[CHDK_COLOR_BASE+5] = 0x395AB95;
259 pal[CHDK_COLOR_BASE+6] = 0x34766F0;
260 pal[CHDK_COLOR_BASE+7] = 0x31250F3;
261 pal[CHDK_COLOR_BASE+8] = 0x37F408F;
262 pal[CHDK_COLOR_BASE+9] = 0x3512D5B;
263 pal[CHDK_COLOR_BASE+10] = 0x3A9A917;
264 pal[CHDK_COLOR_BASE+11] = 0x3819137;
265 pal[CHDK_COLOR_BASE+12] = 0x3DED115;
266 pal[CHDK_COLOR_BASE+13] = 0x0090000;
267
268 extern char palette_control;
269 palette_control = 1;
270 vid_bitmap_refresh();
271 }
272 }
273 }