| 1 | #include "platform.h" |
|---|
| 2 | #include "lolevel.h" |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | void vid_bitmap_refresh() |
|---|
| 6 | { |
|---|
| 7 | extern int full_screen_refresh; |
|---|
| 8 | extern void _LockAndRefresh(); // wrapper function for screen lock |
|---|
| 9 | extern void _UnlockAndRefresh(); // wrapper function for screen unlock |
|---|
| 10 | |
|---|
| 11 | full_screen_refresh |= 3; //found in ScreenUnlock |
|---|
| 12 | _LockAndRefresh(); |
|---|
| 13 | _UnlockAndRefresh(); |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | void shutdown() |
|---|
| 18 | { |
|---|
| 19 | volatile long *p = (void*)0xC022001C; |
|---|
| 20 | |
|---|
| 21 | asm( |
|---|
| 22 | "MRS R1, CPSR\n" |
|---|
| 23 | "AND R0, R1, #0x80\n" |
|---|
| 24 | "ORR R1, R1, #0x80\n" |
|---|
| 25 | "MSR CPSR_cf, R1\n" |
|---|
| 26 | :::"r1","r0"); |
|---|
| 27 | |
|---|
| 28 | *p = 0x44; // power off. |
|---|
| 29 | |
|---|
| 30 | while(1); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | #define LED_PR 0xC0220130 |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | void debug_led(int state) |
|---|
| 37 | { |
|---|
| 38 | *(int*)LED_PR=state ? 0x46 : 0x44; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | void camera_set_led(int led, int state, int bright) { |
|---|
| 42 | static char led_table[2]={0,9}; |
|---|
| 43 | _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | int get_flash_params_count(void){ |
|---|
| 47 | return 0xA0; //@FF1B33A0 in GetParameterData |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | void JogDial_CW(void){ |
|---|
| 51 | _PostLogicalEventForNotPowerType(0x86E, 2); // @FF416880 |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | void JogDial_CCW(void){ |
|---|
| 55 | _PostLogicalEventForNotPowerType(0x86F, 2); // @FF41688C |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | // Viewport and Bitmap values that shouldn't change across firmware versions. |
|---|
| 60 | // Values that may change are in lib.c for each firmware version. |
|---|
| 61 | |
|---|
| 62 | long vid_get_bitmap_screen_width() { return 480; } |
|---|
| 63 | long vid_get_bitmap_screen_height() { return 240; } |
|---|
| 64 | |
|---|
| 65 | long vid_get_bitmap_buffer_width() { return 960; } |
|---|
| 66 | long vid_get_bitmap_buffer_height() { return 270; } |
|---|
| 67 | |
|---|
| 68 | // Physical width of viewport row in bytes |
|---|
| 69 | int vid_get_viewport_byte_width() { |
|---|
| 70 | return 960 * 6 / 4; // SX220HS - wide screen LCD is 960 pixels wide, each group of 4 pixels uses 6 bytes (UYVYYY) |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240) |
|---|
| 74 | int vid_get_viewport_yscale() { |
|---|
| 75 | return 2; // SX220HS viewport is 480 pixels high |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | int vid_get_viewport_width() |
|---|
| 80 | { |
|---|
| 81 | // viewport width table for each image size |
|---|
| 82 | // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1 |
|---|
| 83 | static long vp_w[4] = { 360, 480, 360, 272 }; |
|---|
| 84 | return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)]; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | int vid_get_viewport_xoffset() |
|---|
| 88 | { |
|---|
| 89 | // viewport width offset table for each image size |
|---|
| 90 | // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1 |
|---|
| 91 | static long vp_w[4] = { 60, 0, 36, 104 }; // should all be even values for edge overlay |
|---|
| 92 | return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)]; |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | long vid_get_viewport_height(){ return 240; } |
|---|