Skip to content

Commit

Permalink
sx30 and g12 updates from philmoz in http://chdk.setepontos.com/index…
Browse files Browse the repository at this point in the history
….php?topic=650.msg62260#msg62260

- updates for exmem memory allocation to allow these cameras to exclude video buffer memory
- fixed set_zoom function to correctly wait until zoom is finished before returning
- fixed startup code for SX30 so that init_file_modules_task gets called correctly in all cases

SX30 startup button change NOT added at this time.

git-svn-id: http://tools.assembla.com/svn/chdk/trunk@1068 6794e30b-3f2a-0410-a806-a2bbca1c07ff
  • Loading branch information
reyalP authored and reyalP committed Feb 26, 2011
1 parent 597c997 commit 6f1c200
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 47 deletions.
2 changes: 1 addition & 1 deletion core/gui_draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
#define COLOR_BLUE_LT 0x10
#define COLOR_BLUE 0x14
#define COLOR_YELLOW 0x16
#define COLOR_BLACK 0x1d
#define COLOR_BLACK 0xFF
#define COLOR_BG 0x62
#define COLOR_FG COLOR_WHITE
#define COLOR_SELECTED_BG 0x0e
Expand Down
8 changes: 8 additions & 0 deletions include/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -3222,6 +3222,10 @@

#define CAM_DATE_FOLDER_NAMING 1

// EXMEM memory allocation values
#define EXMEM_HEAP_SKIP (0x08000000-0x07D08A00) // G12 & SX30 uses movie memory buffers at the top of the memory allocated by exmem_alloc
#define EXMEM_BUFFER_SIZE (1024*1024*2) // desired amount of exmem memory to allocate

//----------------------------------------------------------
#elif defined (CAMERA_g12)
#define CAM_PROPSET 4
Expand Down Expand Up @@ -3325,6 +3329,10 @@

#define CAM_CHDK_PTP 1

// EXMEM memory allocation values
#define EXMEM_HEAP_SKIP (0x08000000-0x07D08A00) // G12 & SX30 uses movie memory buffers at the top of the memory allocated by exmem_alloc
#define EXMEM_BUFFER_SIZE (1024*1024*2) // desired amount of exmem memory to allocate

//----------------------------------------------------------

#elif defined (CAMERA_ixus120_sd940)
Expand Down
28 changes: 21 additions & 7 deletions platform/generic/wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,22 @@ void lens_set_zoom_point(long newpt)
}
#if defined(CAMERA_sx30)
// SX30 - Can't find zoom_status, _MoveZoomLensWithPoint crashes camera
// _PT_MoveOpticalZoomAt works, and updates PROPCASE_OPTICAL_ZOOM_POSITION; but doesn't wait for zoom to finish
extern void _PT_MoveOpticalZoomAt(long*);
if (lens_get_zoom_point() != newpt)
{
_PT_MoveOpticalZoomAt(&newpt);
while (zoom_busy) msleep(10);
}
#elif defined(CAMERA_g12)
// G12 - Can't find zoom_status, _MoveZoomLensWithPoint works anyway, and updates PROPCASE_OPTICAL_ZOOM_POSITION; but doesn't wait for zoom to finish
// G12 - Can't find zoom_status, _MoveZoomLensWithPoint works anyway; but doesn't wait for zoom to finish
if (lens_get_zoom_point() != newpt)
{
_MoveZoomLensWithPoint((short*)&newpt);
#else
while (zoom_busy) msleep(10);
_SetPropertyCase(PROPCASE_OPTICAL_ZOOM_POSITION, &newpt, sizeof(newpt));
}
#else // !CAMERA_g12
_MoveZoomLensWithPoint((short*)&newpt);

#if defined (CAMERA_s95)
Expand All @@ -150,15 +158,15 @@ void lens_set_zoom_point(long newpt)
if (!zoom_busy)
break;
}
#else
#else // !CAMERA_s95
while (zoom_busy) ;
#endif
#endif // CAMERA_s95

if (newpt==0) zoom_status=ZOOM_OPTICAL_MIN;
else if (newpt >= zoom_points) zoom_status=ZOOM_OPTICAL_MAX;
else zoom_status=ZOOM_OPTICAL_MEDIUM;
_SetPropertyCase(PROPCASE_OPTICAL_ZOOM_POSITION, &newpt, sizeof(newpt));
#endif
#endif // CAMERA_g12
}

void lens_set_zoom_speed(long newspd)
Expand Down Expand Up @@ -516,7 +524,13 @@ double _sqrt(double x) {

#ifdef OPT_EXMEM_MALLOC
// I set this up to 16 mb and it still booted...
#define EXMEM_HEAP_SIZE (1024*1024*2)
#ifndef EXMEM_HEAP_SKIP
#define EXMEM_HEAP_SKIP 0
#endif
#ifndef EXMEM_BUFFER_SIZE
#define EXMEM_BUFFER_SIZE (1024*1024*2) // default size if not specified by camera
#endif
#define EXMEM_HEAP_SIZE (EXMEM_BUFFER_SIZE+EXMEM_HEAP_SKIP) // desired space + amount to skip for the movie buffers (if needed)
// these aren't currently needed elsewhere
/*
void * exmem_alloc(unsigned pool_id, unsigned size)
Expand All @@ -540,7 +554,7 @@ void exmem_malloc_init() {
// pool zero is EXMEM_RAMDISK on d10
void *mem = _exmem_alloc(0,EXMEM_HEAP_SIZE,0);
if(mem) {
exmem_heap = suba_init(mem,EXMEM_HEAP_SIZE,1,1024);
exmem_heap = suba_init(mem,EXMEM_HEAP_SIZE-EXMEM_HEAP_SKIP,1,1024);
}
}

Expand Down
14 changes: 1 addition & 13 deletions platform/sx30/sub/100e/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,10 @@ void JogDial_task_my(void);
// );
//}

int done_delay = 0;

void taskHook(context_t **context)
{
task_t *tcb=(task_t*)((char*)context-offsetof(task_t, context));

if ((tcb->entry == (void*)mykbd_task) && (done_delay == 0))
{
done_delay = 1;
int i;
// Wait a while, otherwise init_file_modules_task doesn't get hooked when starting in play mode
for (i=0; i<0x100000; i++)
{
asm volatile ( "nop\n" );
}
}

extern void task_CaptSeq();
extern void task_InitFileModules();
extern void task_RotaryEncoder();
Expand Down Expand Up @@ -185,6 +172,7 @@ void __attribute__((naked,noinline)) sub_FF810354_my() {

//http://chdk.setepontos.com/index.php/topic,4194.0.html
*(int*)0x1938=(int)taskHook;
*(int*)0x193C=(int)taskHook; // need this for startup in Playback mode (otherwise init_file_modules_task doesn't hook properly)

// replacement of sub_FF834740 for correct power-on.
*(int*)(0x2574) = (*(int*)0xC0220128)&1 ? 0x200000 : 0x100000;
Expand Down
14 changes: 1 addition & 13 deletions platform/sx30/sub/100h/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,10 @@ void JogDial_task_my(void);
// );
//}

int done_delay = 0;

void taskHook(context_t **context)
{
task_t *tcb=(task_t*)((char*)context-offsetof(task_t, context));

if ((tcb->entry == (void*)mykbd_task) && (done_delay == 0))
{
done_delay = 1;
int i;
// Wait a while, otherwise init_file_modules_task doesn't get hooked when starting in play mode
for (i=0; i<0x100000; i++)
{
asm volatile ( "nop\n" );
}
}

extern void task_CaptSeq();
extern void task_InitFileModules();
extern void task_RotaryEncoder();
Expand Down Expand Up @@ -186,6 +173,7 @@ void __attribute__((naked,noinline)) sub_FF810354_my() {

//http://chdk.setepontos.com/index.php/topic,4194.0.html
*(int*)0x1938=(int)taskHook;
*(int*)0x193C=(int)taskHook; // need this for startup in Playback mode (otherwise init_file_modules_task doesn't hook properly)

// replacement of sub_FF834740 for correct power-on.
*(int*)(0x2574) = (*(int*)0xC0220128)&1 ? 0x200000 : 0x100000;
Expand Down
14 changes: 1 addition & 13 deletions platform/sx30/sub/100l/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,10 @@ void JogDial_task_my(void);
// );
//}

int done_delay = 0;

void taskHook(context_t **context)
{
task_t *tcb=(task_t*)((char*)context-offsetof(task_t, context));

if ((tcb->entry == (void*)mykbd_task) && (done_delay == 0))
{
done_delay = 1;
int i;
// Wait a while, otherwise init_file_modules_task doesn't get hooked when starting in play mode
for (i=0; i<0x100000; i++)
{
asm volatile ( "nop\n" );
}
}

extern void task_CaptSeq();
extern void task_InitFileModules();
extern void task_RotaryEncoder();
Expand Down Expand Up @@ -185,6 +172,7 @@ void __attribute__((naked,noinline)) sub_FF810354_my() {

//http://chdk.setepontos.com/index.php/topic,4194.0.html
*(int*)0x1938=(int)taskHook;
*(int*)0x193C=(int)taskHook; // need this for startup in Playback mode (otherwise init_file_modules_task doesn't hook properly)

// replacement of sub_FF834740 for correct power-on.
*(int*)(0x2574) = (*(int*)0xC0220128)&1 ? 0x200000 : 0x100000;
Expand Down

0 comments on commit 6f1c200

Please sign in to comment.