Skip to content

Commit 02f9780

Browse files
committed
got CHDK initialised and the basic overlays
1 parent e954dd7 commit 02f9780

File tree

16 files changed

+271
-72
lines changed

16 files changed

+271
-72
lines changed

platform/m6/kbd.c

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,25 @@
55
#include "kbd_common.h"
66
#include "levent.h"
77

8+
#include "kbd.h"
9+
10+
// use by kbd_common
11+
long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
12+
long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
13+
long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
14+
815
KeyMap keymap[] = {
9-
{ 0, KEY_PLAYBACK, 0x00000002 }, // Found @0xe05e4cdc, levent 0x101 (uses inverted logic in physw_status)
10-
{ 0, KEY_WIFI, 0x00000004 }, // Found @0xe05e4ce4, levent 0x103 (uses inverted logic in physw_status)
11-
{ 1, KEY_MENU, 0x00000080 }, // Found @0xe05e4d1c, levent 0x15
12-
{ 1, KEY_UP, 0x00000100 }, // Found @0xe05e4d24, levent 0x06
13-
{ 1, KEY_DOWN, 0x00000200 }, // Found @0xe05e4d2c, levent 0x07
14-
{ 1, KEY_RIGHT, 0x00000400 }, // Found @0xe05e4d34, levent 0x09
15-
{ 1, KEY_LEFT, 0x00000800 }, // Found @0xe05e4d3c, levent 0x08
16-
{ 1, KEY_SET, 0x00001000 }, // Found @0xe05e4d44, levent 0x0a
17-
{ 1, KEY_ERASE, 0x00008000 }, // Found @0xe05e4d5c, levent 0x0b
18-
{ 2, KEY_VIDEO, 0x00002000 }, // Found @0xe05e4db4, levent 0x02
19-
{ 0, 0, 0 }
16+
{ 0, KEY_PLAYBACK, 0x00000002 }, // Found @0xe05e4cdc, levent 0x101 (uses inverted logic in physw_status)
17+
{ 0, KEY_WIFI, 0x00000004 }, // Found @0xe05e4ce4, levent 0x103 (uses inverted logic in physw_status)
18+
{ 1, KEY_MENU, 0x00000080 }, // Found @0xe05e4d1c, levent 0x15
19+
{ 1, KEY_UP, 0x00000100 }, // Found @0xe05e4d24, levent 0x06
20+
{ 1, KEY_DOWN, 0x00000200 }, // Found @0xe05e4d2c, levent 0x07
21+
{ 1, KEY_RIGHT, 0x00000400 }, // Found @0xe05e4d34, levent 0x09
22+
{ 1, KEY_LEFT, 0x00000800 }, // Found @0xe05e4d3c, levent 0x08
23+
{ 1, KEY_SET, 0x00001000 }, // Found @0xe05e4d44, levent 0x0a
24+
{ 1, KEY_ERASE, 0x00008000 }, // Found @0xe05e4d5c, levent 0x0b
25+
{ 2, KEY_VIDEO, 0x00002000 }, // Found @0xe05e4db4, levent 0x02
26+
{ 0, 0, 0 }
2027
};
2128

2229
/**
@@ -28,3 +35,11 @@ int get_usb_bit() {
2835
_kbd_read_keys_r2(usb_physw);
2936
return ((usb_physw[USB_IDX] & USB_MASK) == USB_MASK);
3037
}
38+
39+
/**
40+
* @header kbd_common.h
41+
*/
42+
void kbd_fetch_data(long *dst) {
43+
_GetKbdState(dst);
44+
_kbd_read_keys_r2(dst);
45+
}

platform/m6/kbd.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef M6_KBD_H
2+
#define M6_KBD_H
3+
4+
extern void _GetKbdState(long*);
5+
6+
#endif

platform/m6/lib.c

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "lolevel.h"
33
#include "live_view.h"
44

5-
#define LED 0xD20801E0 // green LED on the back
5+
#include "lib.h"
66

77
void shutdown_soft() {
88
_PostLogicalEventForNotPowerType(0x1005, 0);
@@ -48,3 +48,95 @@ void JogDial_CW(void) {
4848
void JogDial_CCW(void) {
4949
_PostLogicalEventToUI(0x873, 1); // RotateJogDialLeft
5050
}
51+
52+
/**
53+
* @header properties.h
54+
*/
55+
int get_flash_params_count(void) {
56+
return 0x113; // see j_PTM_BackupUIProperty_FW
57+
}
58+
59+
/**
60+
* @header raw_buffer.h
61+
*/
62+
char* hook_raw_image_addr() {
63+
if (current_raw_addr) {
64+
return current_raw_addr;
65+
}
66+
return (char*) 0x48c57740; // TODO
67+
}
68+
69+
/**
70+
* @header viewport.h
71+
*/
72+
void vid_bitmap_refresh() {
73+
_VTMLock();
74+
_transfer_src_overlay(active_bitmap_buffer & 1);
75+
_VTMUnlock();
76+
}
77+
78+
/**
79+
* @header viewport.h
80+
*/
81+
void* vid_get_viewport_live_fb() {
82+
int i;
83+
for (i = 0; i < 4; i++) {
84+
if (current_viewport_buffer == viewport_buffers[i]) {
85+
return viewport_buffers[(i + 1) & 3];
86+
}
87+
}
88+
return 0;
89+
}
90+
91+
/**
92+
* @header viewport.h
93+
*/
94+
void* vid_get_bitmap_fb() {
95+
// for live view send YUV instead of RGBA
96+
return bitmap_buffer[active_bitmap_buffer & 1];
97+
}
98+
99+
/**
100+
* @header viewport.h
101+
*/
102+
void* vid_get_viewport_fb_d() {
103+
return current_fb_d;
104+
}
105+
106+
/**
107+
* @header viewport.h
108+
*/
109+
void* vid_get_viewport_fb() {
110+
return viewport_buffers[0];
111+
}
112+
113+
/**
114+
* @header viewport.h
115+
*/
116+
long vid_get_viewport_height() {
117+
if (camera_info.state.mode_play) {
118+
return CAM_SCREEN_HEIGHT;
119+
}
120+
return _GetVRAMVPixelsSize();
121+
}
122+
123+
/**
124+
* @header viewport.h
125+
*/
126+
int vid_get_viewport_type() {
127+
return LV_FB_YUV8B;
128+
}
129+
130+
/**
131+
* @header viewport.h
132+
*/
133+
void* vid_get_opacity_active_buffer() {
134+
return opacity_buffer[active_bitmap_buffer & 1];
135+
}
136+
137+
/**
138+
* @header sd_card.h
139+
*/
140+
char* camera_jpeg_count_str() {
141+
return jpeg_count_str;
142+
}

platform/m6/lib.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef M6_LIB_H
2+
#define M6_LIB_H
3+
4+
#define LED 0xD20801E0 // green LED on the back
5+
6+
extern int active_bitmap_buffer;
7+
extern void *viewport_buffers[];
8+
extern void *current_viewport_buffer;
9+
extern char *current_raw_addr;
10+
extern void *current_fb_d;
11+
extern char jpeg_count_str[];
12+
13+
extern void _transfer_src_overlay(int);
14+
extern void _VTMLock();
15+
extern void _VTMUnlock();
16+
extern int _GetVRAMVPixelsSize();
17+
18+
char *bitmap_buffer[2] = { (char*) 0x7FE80000, (char*) 0x7FD00000 };
19+
void *opacity_buffer[2] = { (void*) 0x7FC40000, (void*) 0x7FB80000 };
20+
21+
#endif

platform/m6/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "main.h"
77

8+
const int zoom_points = 1; // used usb_module
9+
810
void startup(int core) {
911
if (!core) { // core 0 only
1012
long *bss = &link_bss_start;

platform/m6/platform_camera.h

Lines changed: 58 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,59 +23,76 @@
2323
*/
2424

2525
// from signature finder
26-
#define CAM_DRYOS 1
27-
#define CAM_DRYOS_2_3_R39 1 // Defined for cameras with DryOS version R39 or higher
28-
#define CAM_DRYOS_2_3_R47 1 // Defined for cameras with DryOS version R47 or higher
29-
#define CAM_DRYOS_2_3_R59 1 // Defined for cameras with DryOS version R59 or higher
30-
#define CAM_ILC 1 // Camera has interchangeable lens
31-
#define CAM_HAS_WIFI 1 // Firmware has wifi support
26+
#define CAM_DRYOS 1
27+
#define CAM_DRYOS_2_3_R39 1 // Defined for cameras with DryOS version R39 or higher
28+
#define CAM_DRYOS_2_3_R47 1 // Defined for cameras with DryOS version R47 or higher
29+
#define CAM_DRYOS_2_3_R59 1 // Defined for cameras with DryOS version R59 or higher
30+
#define CAM_ILC 1 // Camera has interchangeable lens
31+
#define CAM_HAS_WIFI 1 // Firmware has wifi support
3232
#undef CAM_UNCACHED_BIT
33-
#define CAM_UNCACHED_BIT 0x40000000 // Found @0xe01e8654
34-
#undef CAM_HAS_ND_FILTER // Camera does not have an ND filter
33+
#define CAM_UNCACHED_BIT 0x40000000 // Found @0xe01e8654
34+
#undef CAM_HAS_ND_FILTER // Camera does not have an ND filter
3535

3636
// handwritten
37-
#define CAM_PROPSET 12
38-
#define CAM_HAS_CMOS 1
37+
#define CAM_PROPSET 12
38+
#define CAM_HAS_CMOS 1
3939

40-
#define CAM_RAW_ROWPIX 6112
41-
#define CAM_RAW_ROWS 4060
42-
#define CAM_JPEG_WIDTH 6000
43-
#define CAM_JPEG_HEIGHT 4000
44-
#define CAM_ACTIVE_AREA_X1 84
45-
#define CAM_ACTIVE_AREA_Y1 46
46-
#define CAM_ACTIVE_AREA_X2 6084
47-
#define CAM_ACTIVE_AREA_Y2 4046
40+
#define CAM_RAW_ROWPIX 6112
41+
#define CAM_RAW_ROWS 4060
42+
#define CAM_JPEG_WIDTH 6000
43+
#define CAM_JPEG_HEIGHT 4000
44+
#define CAM_ACTIVE_AREA_X1 84
45+
#define CAM_ACTIVE_AREA_Y1 46
46+
#define CAM_ACTIVE_AREA_X2 6084
47+
#define CAM_ACTIVE_AREA_Y2 4046
4848
#undef CAM_SENSOR_BITS_PER_PIXEL
49-
#define CAM_SENSOR_BITS_PER_PIXEL 14
50-
#define CAM_DNG_LENS_INFO { 180,10,550,10,35,10,56,10 } // 18-55mm
51-
#define cam_CFAPattern 0x02010100
52-
#define cam_CalibrationIlluminant1 17 // Standard light A
53-
#define cam_CalibrationIlluminant2 21 // D65
49+
#define CAM_SENSOR_BITS_PER_PIXEL 14
50+
#define CAM_DNG_LENS_INFO { 180,10,550,10,35,10,56,10 } // 18-55mm
51+
#define cam_CFAPattern 0x02010100
52+
#define cam_CalibrationIlluminant1 17 // Standard light A
53+
#define cam_CalibrationIlluminant2 21 // D65
5454

55-
#define CAM_HAS_CANON_RAW 1
56-
#define CAM_ADJUSTABLE_ALT_BUTTON 1
57-
#define CAM_ALT_BUTTON_NAMES { "Playback", "WiFi" }
58-
#define CAM_ALT_BUTTON_OPTIONS { KEY_PLAYBACK, KEY_WIFI }
59-
#define CAM_HAS_VIDEO_BUTTON 1
55+
#define DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY 1
56+
#undef CAM_BITMAP_WIDTH
57+
#undef CAM_BITMAP_HEIGHT
58+
#undef CAM_SCREEN_WIDTH
59+
#undef CAM_SCREEN_HEIGHT
60+
#define CAM_BITMAP_WIDTH 736
61+
#define CAM_BITMAP_HEIGHT 480
62+
#define CAM_SCREEN_WIDTH 720
63+
#define CAM_SCREEN_HEIGHT 480
64+
65+
#define CAM_HAS_CANON_RAW 1
66+
#define CAM_ADJUSTABLE_ALT_BUTTON 1
67+
#define CAM_ALT_BUTTON_NAMES { "Playback", "WiFi" }
68+
#define CAM_ALT_BUTTON_OPTIONS { KEY_PLAYBACK, KEY_WIFI }
69+
#define CAM_HAS_VIDEO_BUTTON 1
6070
#undef CAM_HAS_ERASE_BUTTON
71+
#undef CAM_USE_ZOOM_FOR_MF
72+
73+
#define CAM_3ARG_DebugAssert 1
74+
#define CAM_FILE_COUNTER_IS_VAR 1
75+
#define CAM_DATE_FOLDER_NAMING 0x80
76+
#define CAM_QUALITY_OVERRIDE 1
77+
#define CAM_CALC_BLACK_LEVEL 1
78+
#define CAM_SHOW_OSD_IN_SHOOT_MENU 1
79+
#define CAM_AV_OVERRIDE_IRIS_FIX 1
80+
#define CAM_DRIVE_MODE_FROM_TIMER_MODE 1
6181

62-
#define CAM_3ARG_DebugAssert 1 // confirmed with Ghidra
63-
#define CAM_FILE_COUNTER_IS_VAR 1
64-
#define CAM_DATE_FOLDER_NAMING 0x80
65-
#define CAM_QUALITY_OVERRIDE 1
66-
#define CAM_CALC_BLACK_LEVEL 1
67-
#define CAM_SHOW_OSD_IN_SHOOT_MENU 1
68-
#define CAM_AV_OVERRIDE_IRIS_FIX 1
69-
#define CAM_DRIVE_MODE_FROM_TIMER_MODE 1
82+
#undef CAM_CAN_UNLOCK_OPTICAL_ZOOM_IN_VIDEO
83+
#undef CAM_CHDK_HAS_EXT_VIDEO_MENU
84+
#undef CAM_VIDEO_CONTROL
85+
#define CAM_SIMPLE_MOVIE_STATUS 1
86+
#define CAM_IS_VID_REC_WORKS 1
7087

7188
#undef CAM_AF_LED
72-
#define CAM_AF_LED 1
89+
#define CAM_AF_LED 1
7390

7491
#undef CAM_CIRCLE_OF_CONFUSION
75-
#define CAM_CIRCLE_OF_CONFUSION 19 // APSC - CoC value for camera/sensor (see http://www.dofmaster.com/digital_coc.html)
92+
#define CAM_CIRCLE_OF_CONFUSION 19 // APSC - CoC value for camera/sensor (see http://www.dofmaster.com/digital_coc.html)
7693

77-
#define CAM_SD_OVER_IN_AF 1
78-
#define CAM_SD_OVER_IN_MF 1
94+
#define CAM_SD_OVER_IN_AF 1
95+
#define CAM_SD_OVER_IN_MF 1
7996

8097
#undef CAM_USB_EVENTID
81-
#define CAM_USB_EVENTID 0x302 // Levent ID for USB control
98+
#define CAM_USB_EVENTID 0x302 // Levent ID for USB control

platform/m6/platform_shooting.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "shooting.h"
55
#include "modes.h"
66

7+
extern void _GetImageFolder(char*out, int filecount, int flags, int time);
8+
79
const ApertureSize aperture_sizes_table[] = {
810
{ 6, 64, "1.2" },
911
{ 7, 96, "1.4" },

platform/m6/shooting.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "camera.h"
33
#include "time.h"
44
#include "platform_shooting.h"
5+
#include "../generic/shooting.c"
56

67
/**
78
* @header file_counter.h
@@ -24,8 +25,7 @@ void get_target_dir_name(char *out) {
2425
if (!out) {
2526
return;
2627
}
27-
extern void _GetImageFolder(char*, int, int, int);
28-
_GetImageFolder(out, get_file_next_counter(), CAM_DATE_FOLDER_NAMING,
29-
time(NULL));
28+
29+
_GetImageFolder(out, get_file_next_counter(), CAM_DATE_FOLDER_NAMING, time(NULL));
3030
}
3131

platform/m6/sub/101a/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
OBJS=boot.o stubs_auto.o stubs_entry.o stubs_entry_2.o mmu_utils.o debug.o
1+
OBJS=boot.o stubs_auto.o stubs_entry.o stubs_entry_2.o mmu_utils.o capt_seq.o
22
STUBS_AUTO_DEPS=boot.c
33

44
include ../../../makefile_sub.inc
55

66
mmu_utils.o: $(platform)/generic/mmu_utils.c
77
@echo $< '->' $@
8-
$(CC) $(CFLAGS) -nostdinc -c -o $@ $<
8+
$(CC) $(CFLAGS) -nostdinc -c -o $@ $<

platform/m6/sub/101a/boot.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "cache.h"
2+
#include "core.h"
23

34
#include "../../../generic/mmu_utils.h"
45
#include "boot.h"
5-
#include "debug.h"
66

77
#define CHDK_MMUTBL_START 0xdffda400
88
#define CHDK_PAGES_START 0x11d0000
@@ -11,16 +11,19 @@
1111
static int no_chdk_please = 0;
1212

1313
void CreateTask_spytask() {
14-
14+
if (!no_chdk_please) {
15+
_CreateTask("SpyTask", 0x19, 0x2000, core_spytask, 0);
16+
}
1517
}
1618

1719
void startup_mode_fix(void) {
1820
int startupmode = *(int*) 0x9eb0;
1921
switch (startupmode) {
20-
case 0x1000000: // rec
21-
break;
22-
default:
22+
case 0x80000:
23+
case 0x400000:
24+
case 0x200000:
2325
no_chdk_please = 1;
26+
break;
2427
}
2528
}
2629

@@ -242,7 +245,7 @@ void __attribute__((naked,noinline)) boot() {
242245
" ldr r0, =0xdffc4900\n"
243246
" ldr r1, =0x000152a0\n"
244247
" bl _icache_branchpr_invalidate\n"
245-
" b loc_e0020032\n"// +
248+
" b loc_e0020032\n" // +
246249
);
247250

248251
}

0 commit comments

Comments
 (0)