source: trunk/platform/g12/lib.c @ 1145

Revision 1145, 3.3 KB checked in by reyalP, 2 years ago (diff)

g12 and sx30 updates from philmoz in http://chdk.setepontos.com/index.php?topic=650.msg64631#msg64631

  • Added code to override the -0.5 DNG exposure bias that is set in the dng.c code. If your DNG files are 1/2 stop underexposed this is why. Exposure bias set to 0 for G12 & SX30.
  • Changed logical screen width to 360 (from 320).
  • Cleanup old code in capt_seq.c & added some comments to boot.c
  • Aligned vid_bitmap_refresh logic on both cameras. It's still not perfect; but I get less problems with menus vanishing with this version.
  • Property svn:eol-style set to native
Line 
1#include "platform.h"
2#include "lolevel.h"
3
4void vid_bitmap_refresh()
5{
6        extern int full_screen_refresh;
7        extern void _ScreenUnlock();
8        extern void _ScreenLock();
9
10        full_screen_refresh |= 3;
11        _ScreenLock();
12        _ScreenUnlock();
13}
14
15
16void shutdown()
17{
18        volatile long *p = (void*)0xC022001C;   
19       
20        asm(
21                "MRS     R1, CPSR\n"
22                "AND     R0, R1, #0x80\n"
23                "ORR     R1, R1, #0x80\n"
24                "MSR     CPSR_cf, R1\n"
25                :::"r1","r0");
26       
27        *p = 0x44;  // power off.
28       
29        while(1);
30}
31
32#define LED_PR 0xC0220138       // Lower Indicator
33
34void debug_led(int state)
35{
36 *(int*)LED_PR=state ? 0x46 : 0x44;
37}
38
39// G12 has 7 led values
40// 0/0 - Upper indicator Green
41// 1/1 - Upper indicator Orange
42// 2/2 - Lower indicator Yellow
43// 3/3 - Power LED Green
44// 4/9 - AF Assist Lamp
45// 5/14 - ISO LED
46// 6/15 - EV LED
47void camera_set_led(int led, int state, int bright) {
48 static char led_table[7]={0,1,2,3,9,14,15};
49 _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
50}
51
52int get_flash_params_count(void){
53 return 0x9a;   // found in GetParameterData
54}
55
56void JogDial_CW(void){
57 _PostLogicalEventForNotPowerType(0x86E, 1);  // RotateJogDialRight (table @ FFC0BE90)
58}
59
60void JogDial_CCW(void){
61 _PostLogicalEventForNotPowerType(0x86F, 1);  // RotateJogDialLeft (table @ FFC0BE90)
62}
63
64// Viewport and Bitmap values that shouldn't change across firmware versions.
65// Values that may change are in lib.c for each firmware version.
66
67long vid_get_bitmap_screen_width() { return 360; }
68long vid_get_bitmap_screen_height() { return 240; }
69long vid_get_bitmap_buffer_width() { return 960; }
70long vid_get_bitmap_buffer_height() { return 270; }
71
72int vid_get_viewport_buffer_width() { return 720; }     // G12 - buffer is twice as wide as viewport
73
74int vid_get_viewport_width()
75{
76        // viewport width table for each image size
77        // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
78        static long vp_w[5] = { 360, 360, 360, 272, 216 };
79        return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
80}
81
82int vid_get_viewport_xoffset()
83{
84        // viewport width offset table for each image size
85        // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
86        static long vp_w[5] = { 0, 0, 0, 44, 72 };                              // should all be even values for edge overlay
87        return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
88}
89
90long vid_get_viewport_height()
91{
92        // viewport height table for each image size
93        // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
94        static long vp_h[5] = { 240, 180, 214, 240, 240 };
95        return vp_h[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
96}
97
98int vid_get_viewport_yoffset()
99{
100        // viewport height offset table for each image size
101        // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
102        static long vp_h[5] = { 0, 30, 13, 0, 0 };
103        return vp_h[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
104}
105
106// viewport image offset - used when image size != viewport size (zebra, histogram, motion detect & edge overlay)
107// returns the byte offset into the viewport buffer where the image pixels start (to skip any black borders)
108int vid_get_viewport_image_offset() {
109        return (vid_get_viewport_yoffset() * vid_get_viewport_buffer_width() + vid_get_viewport_xoffset()) * 3;
110}
111
112// viewport image offset - used when image size != viewport size (zebra, histogram, motion detect & edge overlay)
113// returns the byte offset to skip at the end of a viewport buffer row to get to the next row.
114int vid_get_viewport_row_offset() {
115        return (vid_get_viewport_buffer_width() - vid_get_viewport_width()) * 3;
116}
Note: See TracBrowser for help on using the repository browser.