Changeset 948


Ignore:
Timestamp:
02/09/12 19:51:54 (17 months ago)
Author:
rudi_de
Message:

Wieder angleichen von CHDK und CHDK-DE (Teil 3)

Betrifft alle

  • beinhaltet teilweise CHDK Rev. 1175, 1178, 1183

http://trac.assembla.com/chdk/changeset/1175
http://trac.assembla.com/chdk/changeset/1178
http://trac.assembla.com/chdk/changeset/1183

  • verringerter Speicherbedarf der luascript.c
  • Doppeleintrag der LUA-Funktion get_av96 entfernt

+ neue LUA-Funktion get_meminfo([heapname])
+ neue Schalter CAM_FIRMWARE_MEMINFO, CAM_NO_MEMPARTINFO in [platform_]camera.h

Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/luascript.c

    r933 r948  
    1616#include "motion_detector.h" 
    1717#include "ptp.h" 
     18#include "core.h" 
    1819#include "gui_fselect.h" 
    1920#include "lang.h" 
     
    14031404} 
    14041405 
     1406static void set_number_field(lua_State* L, const char *key, int val) 
     1407{ 
     1408  lua_pushnumber(L, val); 
     1409  lua_setfield(L, -2, key); 
     1410} 
     1411 
    14051412static int luaCB_get_buildinfo( lua_State* L ) 
    14061413{ 
     
    20082015#endif 
    20092016 
     2017/* helper for meminfo to set table field only if valid */ 
     2018static void set_meminfo_num( lua_State* L,const char *name, int val) { 
     2019    if(val != -1) { 
     2020        set_number_field( L, name, val ); 
     2021    } 
     2022} 
     2023/* 
     2024meminfo=get_meminfo([heapname]) 
     2025get camera memory information 
     2026heapname="system" or "exmem" if not given, meminfo is returned for heap used by CHDK for malloc 
     2027meminfo is false if the requested heapname isn't valid ("exmem" when exmem is not enabled, or unknown) 
     2028otherwise, a table of the form 
     2029meminfo = { 
     2030    name -- string "system" or "exmem" 
     2031    chdk_malloc -- bool, this is the heap used by CHDK for malloc 
     2032    chdk_start -- number, load address of CHDK 
     2033    chdk_size -- number, size of CHDK image 
     2034    -- all the following are numbers, will not be set if not available 
     2035    start_address 
     2036    end_address 
     2037    total_size 
     2038    allocated_size 
     2039    allocated_peak 
     2040    allocated_count 
     2041    free_size 
     2042    free_block_max_size 
     2043    free_block_count 
     2044} 
     2045NOTES 
     2046* under vxworks and cameras without GetMemInfo only the only valid fields 
     2047  for the system heap will be those defined by chdk and free_block_max_size 
     2048* the meaning of fields may not correspond exactly between exmem and system 
     2049*/ 
     2050static int luaCB_get_meminfo( lua_State* L ) { 
     2051    // for memory info, duplicated from lowlevel 
     2052    extern const char _start,_end; 
     2053 
     2054#if defined(OPT_EXMEM_MALLOC) && !defined(OPT_EXMEM_TESTING) 
     2055    const char *default_heapname="exmem"; 
     2056#else 
     2057    const char *default_heapname="system"; 
     2058#endif 
     2059    const char *heapname = luaL_optstring( L, 1, default_heapname ); 
     2060    cam_meminfo meminfo; 
     2061 
     2062    if(strcmp(heapname,"system") == 0) { 
     2063#if defined(CAM_FIRMWARE_MEMINFO) 
     2064        GetMemInfo(&meminfo); 
     2065#else 
     2066        memset(&meminfo,0xFF,sizeof(cam_meminfo)); 
     2067        meminfo.free_block_max_size = core_get_free_memory(); 
     2068#endif 
     2069    } 
     2070#if defined(OPT_EXMEM_MALLOC) && !defined(OPT_EXMEM_TESTING) 
     2071    else if(strcmp(heapname,"exmem") == 0) { 
     2072        GetExMemInfo(&meminfo); 
     2073        meminfo.allocated_count = -1; // not implemented in suba 
     2074    } 
     2075#endif 
     2076    else { 
     2077        lua_pushboolean(L,0); 
     2078        return 1; 
     2079    } 
     2080    // adjust start and size, if CHDK is loaded at heap start 
     2081    if(meminfo.start_address == (int)(&_start)) { 
     2082        meminfo.start_address += MEMISOSIZE; 
     2083        meminfo.total_size -= MEMISOSIZE; 
     2084    } 
     2085    lua_createtable(L, 0, 13); // might not always use 13, but doesn't hurt 
     2086    set_string_field( L,"name", heapname ); 
     2087    lua_pushboolean( L, (strcmp(heapname,default_heapname)==0)); 
     2088    lua_setfield(L, -2, "chdk_malloc"); 
     2089    set_number_field( L, "chdk_start", (int)(&_start) ); 
     2090    set_number_field( L, "chdk_size", MEMISOSIZE ); 
     2091    set_meminfo_num( L, "start_address", meminfo.start_address ); 
     2092    set_meminfo_num( L, "end_address", meminfo.end_address); 
     2093    set_meminfo_num( L, "total_size", meminfo.total_size); 
     2094    set_meminfo_num( L, "allocated_size", meminfo.allocated_size); 
     2095    set_meminfo_num( L, "allocated_peak", meminfo.allocated_peak); 
     2096    set_meminfo_num( L, "allocated_count", meminfo.allocated_count); 
     2097    set_meminfo_num( L, "free_size", meminfo.free_size); 
     2098    set_meminfo_num( L, "free_block_max_size", meminfo.free_block_max_size); 
     2099    set_meminfo_num( L, "free_block_count", meminfo.free_block_count); 
     2100    return 1; 
     2101} 
     2102 
    20102103/* 
    20112104set scheduling parameters 
     
    20212114} 
    20222115 
     2116static void register_func( lua_State* L, const char *name, void *func) { 
     2117  lua_pushcfunction( L, func ); 
     2118  lua_setglobal( L, name ); 
     2119} 
     2120 
     2121#define FUNC( X ) { #X, luaCB_##X }, 
     2122static const luaL_Reg chdk_funcs[] = { 
     2123    FUNC(shoot) 
     2124    FUNC(sleep) 
     2125    FUNC(cls) 
     2126    FUNC(set_console_layout) 
     2127    FUNC(set_console_autoredraw) 
     2128    FUNC(console_redraw) 
     2129    FUNC(get_av96) 
     2130    FUNC(get_bv96) 
     2131    FUNC(get_day_seconds) 
     2132    FUNC(get_disk_size) 
     2133    FUNC(get_dofinfo) 
     2134    FUNC(get_free_disk_space) 
     2135    FUNC(get_focus) 
     2136    FUNC(get_iso_market) 
     2137    FUNC(get_iso_mode) 
     2138    FUNC(get_iso_real) 
     2139    FUNC(get_jpg_count) 
     2140    FUNC(get_prop) 
     2141    FUNC(get_prop_str) 
     2142    FUNC(get_raw_count) 
     2143    FUNC(get_raw_nr) 
     2144    FUNC(get_raw) 
     2145    FUNC(get_sv96) 
     2146    FUNC(get_tick_count) 
     2147    FUNC(get_tv96) 
     2148    FUNC(get_user_av_id) 
     2149    FUNC(get_user_av96) 
     2150    FUNC(get_user_tv_id) 
     2151    FUNC(get_user_tv96) 
     2152    FUNC(get_vbatt) 
     2153    FUNC(get_zoom) 
     2154    FUNC(get_exp_count) 
     2155    FUNC(get_flash_params_count) 
     2156    FUNC(get_parameter_data) 
     2157 
     2158    FUNC(set_av96_direct) 
     2159    FUNC(set_av96) 
     2160    FUNC(set_focus) 
     2161    FUNC(set_iso_mode) 
     2162    FUNC(set_iso_real) 
     2163    FUNC(set_led) 
     2164    FUNC(set_nd_filter) 
     2165    FUNC(set_prop) 
     2166    FUNC(set_prop_str) 
     2167    FUNC(set_raw_nr) 
     2168    FUNC(set_raw) 
     2169    FUNC(set_sv96) 
     2170    FUNC(set_tv96_direct) 
     2171    FUNC(set_tv96) 
     2172    FUNC(set_user_av_by_id_rel) 
     2173    FUNC(set_user_av_by_id) 
     2174    FUNC(set_user_av96) 
     2175    FUNC(set_user_tv_by_id_rel) 
     2176    FUNC(set_user_tv_by_id) 
     2177    FUNC(set_user_tv96) 
     2178    FUNC(set_zoom_speed) 
     2179    FUNC(set_zoom_rel) 
     2180    FUNC(set_zoom) 
     2181 
     2182    FUNC(wait_click) 
     2183    FUNC(is_pressed) 
     2184    FUNC(is_key) 
     2185#ifdef CAM_HAS_JOGDIAL 
     2186    FUNC(wheel_right) 
     2187    FUNC(wheel_left) 
     2188#endif 
     2189    FUNC(md_get_cell_diff) 
     2190    FUNC(md_detect_motion) 
     2191    FUNC(autostarted) 
     2192    FUNC(get_autostart) 
     2193    FUNC(set_autostart) 
     2194    FUNC(get_usb_power) 
     2195    FUNC(enter_alt) 
     2196    FUNC(exit_alt) 
     2197    FUNC(shut_down) 
     2198    FUNC(print_screen) 
     2199 
     2200#ifdef CAM_MULTIPART 
     2201    FUNC(get_partitionInfo) 
     2202    FUNC(swap_partitions) 
     2203#endif 
     2204 
     2205    FUNC(get_focus_mode) 
     2206    FUNC(get_focus_state) 
     2207    FUNC(get_focus_ok) 
     2208    FUNC(get_propset) 
     2209    FUNC(get_zoom_steps) 
     2210    FUNC(get_drive_mode) 
     2211    FUNC(get_flash_mode) 
     2212    FUNC(get_shooting) 
     2213    FUNC(get_flash_ready) 
     2214    FUNC(get_IS_mode) 
     2215    FUNC(set_ev) 
     2216    FUNC(get_ev) 
     2217    FUNC(get_orientation_sensor) 
     2218    FUNC(get_nd_present) 
     2219    FUNC(get_movie_status) 
     2220    FUNC(set_movie_status) 
     2221  
     2222    FUNC(get_histo_range) 
     2223    FUNC(shot_histo_enable) 
     2224    FUNC(play_sound) 
     2225    FUNC(get_temperature) 
     2226    FUNC(peek) 
     2227    FUNC(poke) 
     2228    FUNC(bitand) 
     2229    FUNC(bitor) 
     2230    FUNC(bitxor) 
     2231    FUNC(bitshl) 
     2232    FUNC(bitshri) 
     2233    FUNC(bitshru) 
     2234    FUNC(bitnot) 
     2235 
     2236    FUNC(get_time) 
     2237 
     2238    FUNC(get_buildinfo) 
     2239    FUNC(get_mode) 
     2240 
     2241    FUNC(set_raw_develop) 
     2242    // NOTE these functions normally run in the spytask. 
     2243    // called from lua they will run from kbd task instead 
     2244    FUNC(raw_merge_start) 
     2245    FUNC(raw_merge_add_file) 
     2246    FUNC(raw_merge_end) 
     2247    FUNC(set_backlight) 
     2248    FUNC(set_aflock) 
     2249#ifdef OPT_CURVES 
     2250    FUNC(set_curve_state) 
     2251    FUNC(get_curve_state) 
     2252    FUNC(set_curve_file) 
     2253    FUNC(get_curve_file) 
     2254#endif 
     2255    // get levent definition by name or id, nil if not found 
     2256    FUNC(get_levent_def) 
     2257    // get levent definition by index, nil if out of range 
     2258    FUNC(get_levent_def_by_index) 
     2259    // get levent index from name or ID 
     2260    FUNC(get_levent_index) 
     2261    FUNC(post_levent_to_ui) 
     2262    FUNC(post_levent_for_npt) 
     2263    FUNC(set_levent_active) 
     2264    FUNC(set_levent_script_mode) 
     2265 
     2266    FUNC(set_capture_mode) 
     2267    FUNC(set_capture_mode_canon) 
     2268    FUNC(is_capture_mode_valid) 
     2269 
     2270    FUNC(set_record) 
     2271 
     2272    FUNC(switch_mode_usb) 
     2273 
     2274#ifdef OPT_LUA_CALL_NATIVE 
     2275    FUNC(call_event_proc) 
     2276    FUNC(call_func_ptr) 
     2277#endif 
     2278    FUNC(reboot) 
     2279    FUNC(get_config_value) 
     2280    FUNC(set_config_value) 
     2281    FUNC(set_file_attributes) 
     2282    FUNC(get_meminfo) 
     2283    FUNC(file_browser) 
     2284    FUNC(draw_pixel) 
     2285    FUNC(draw_line) 
     2286    FUNC(draw_rect) 
     2287    FUNC(draw_rect_filled) 
     2288    FUNC(draw_ellipse) 
     2289    FUNC(draw_ellipse_filled) 
     2290    FUNC(draw_clear) 
     2291    FUNC(draw_string) 
     2292    FUNC(set_yield) 
     2293#ifdef CAM_CHDK_PTP 
     2294    FUNC(read_usb_msg) 
     2295    FUNC(write_usb_msg) 
     2296#endif 
     2297    {NULL, NULL}, 
     2298}; 
     2299 
    20232300void register_lua_funcs( lua_State* L ) 
    20242301{ 
    2025 #define FUNC( X )                       \ 
    2026   lua_pushcfunction( L, luaCB_##X );    \ 
    2027   lua_setglobal( L, #X ) 
    2028  
    2029   FUNC(shoot); 
    2030   FUNC(sleep); 
    2031   FUNC(cls); 
    2032   FUNC(set_console_layout); 
    2033   FUNC(set_console_autoredraw); 
    2034   FUNC(console_redraw); 
    2035  
     2302  const luaL_reg *r; 
    20362303  lua_pushlightuserdata( L, action_push_click ); 
    20372304  lua_pushcclosure( L, luaCB_keyfunc, 1 ); 
     
    20462313  lua_setglobal( L, "release" ); 
    20472314 
    2048   FUNC(get_av96); 
    2049   FUNC(get_av96); 
    2050   FUNC(get_bv96); 
    2051   FUNC(get_day_seconds); 
    2052   FUNC(get_disk_size); 
    2053   FUNC(get_dofinfo); 
    2054   FUNC(get_free_disk_space); 
    2055   FUNC(get_focus); 
    2056   FUNC(get_iso_market); 
    2057   FUNC(get_iso_mode); 
    2058   FUNC(get_iso_real); 
    2059   FUNC(get_jpg_count); 
    2060   FUNC(get_prop); 
    2061   FUNC(get_prop_str); 
    2062   FUNC(get_raw_count); 
    2063   FUNC(get_raw_nr); 
    2064   FUNC(get_raw); 
    2065   FUNC(get_sv96); 
    2066   FUNC(get_tick_count); 
    2067   FUNC(get_tv96); 
    2068   FUNC(get_user_av_id); 
    2069   FUNC(get_user_av96); 
    2070   FUNC(get_user_tv_id); 
    2071   FUNC(get_user_tv96); 
    2072   FUNC(get_vbatt); 
    2073   FUNC(get_zoom); 
    2074   FUNC(get_exp_count); 
    2075   FUNC(get_flash_params_count); 
    2076   FUNC(get_parameter_data); 
    2077  
    2078   FUNC(set_av96_direct); 
    2079   FUNC(set_av96); 
    2080   FUNC(set_focus); 
    2081   FUNC(set_iso_mode); 
    2082   FUNC(set_iso_real); 
    2083   FUNC(set_led); 
    2084   FUNC(set_nd_filter); 
    2085   FUNC(set_prop); 
    2086   FUNC(set_prop_str); 
    2087   FUNC(set_raw_nr); 
    2088   FUNC(set_raw); 
    2089   FUNC(set_sv96); 
    2090   FUNC(set_tv96_direct); 
    2091   FUNC(set_tv96); 
    2092   FUNC(set_user_av_by_id_rel); 
    2093   FUNC(set_user_av_by_id); 
    2094   FUNC(set_user_av96); 
    2095   FUNC(set_user_tv_by_id_rel); 
    2096   FUNC(set_user_tv_by_id); 
    2097   FUNC(set_user_tv96); 
    2098   FUNC(set_zoom_speed); 
    2099   FUNC(set_zoom_rel); 
    2100   FUNC(set_zoom); 
    2101  
    2102   FUNC(wait_click); 
    2103   FUNC(is_pressed); 
    2104   FUNC(is_key); 
    2105 #ifdef CAM_HAS_JOGDIAL 
    2106   FUNC(wheel_right); 
    2107   FUNC(wheel_left); 
    2108 #endif 
    2109   FUNC(md_get_cell_diff); 
    2110   FUNC(md_detect_motion); 
    2111   FUNC(autostarted); 
    2112   FUNC(get_autostart); 
    2113   FUNC(set_autostart); 
    2114   FUNC(get_usb_power); 
    2115   FUNC(enter_alt); 
    2116   FUNC(exit_alt); 
    2117   FUNC(shut_down); 
    2118   FUNC(print_screen); 
    2119  
    2120 #ifdef CAM_MULTIPART 
    2121   FUNC(get_partitionInfo); 
    2122   FUNC(swap_partitions); 
    2123 #endif 
    2124    
    2125   FUNC(get_focus_mode); 
    2126   FUNC(get_focus_state); 
    2127   FUNC(get_focus_ok); 
    2128   FUNC(get_propset); 
    2129   FUNC(get_zoom_steps); 
    2130   FUNC(get_drive_mode); 
    2131   FUNC(get_flash_mode); 
    2132   FUNC(get_shooting); 
    2133   FUNC(get_flash_ready); 
    2134   FUNC(get_IS_mode); 
    2135   FUNC(set_ev); 
    2136   FUNC(get_ev); 
    2137   FUNC(get_orientation_sensor); 
    2138   FUNC(get_nd_present); 
    2139   FUNC(get_movie_status); 
    2140   FUNC(set_movie_status); 
    2141    
    2142   FUNC(get_histo_range); 
    2143   FUNC(shot_histo_enable); 
    2144   FUNC(play_sound); 
    2145   FUNC(get_temperature); 
    2146   FUNC(peek); 
    2147   FUNC(poke); 
    2148   FUNC(bitand); 
    2149   FUNC(bitor); 
    2150   FUNC(bitxor); 
    2151   FUNC(bitshl); 
    2152   FUNC(bitshri); 
    2153   FUNC(bitshru); 
    2154   FUNC(bitnot); 
    2155  
    2156   FUNC(get_time); 
    2157  
    2158   FUNC(get_buildinfo); 
    2159   FUNC(get_mode); 
    2160    
    2161   FUNC(set_raw_develop); 
    2162   // NOTE these functions normally run in the spytask. 
    2163   // called from lua they will run from kbd task instead 
    2164   FUNC(raw_merge_start); 
    2165   FUNC(raw_merge_add_file); 
    2166   FUNC(raw_merge_end); 
    2167   FUNC(set_backlight); 
    2168    FUNC(set_aflock); 
    2169 #ifdef OPT_CURVES 
    2170    FUNC(set_curve_state); 
    2171    FUNC(get_curve_state); 
    2172    FUNC(set_curve_file); 
    2173    FUNC(get_curve_file); 
    2174 #endif 
    2175 // get levent definition by name or id, nil if not found 
    2176    FUNC(get_levent_def); 
    2177 // get levent definition by index, nil if out of range 
    2178    FUNC(get_levent_def_by_index); 
    2179 // get levent index from name or ID 
    2180    FUNC(get_levent_index); 
    2181    FUNC(post_levent_to_ui); 
    2182    FUNC(post_levent_for_npt); 
    2183    FUNC(set_levent_active); 
    2184    FUNC(set_levent_script_mode); 
    2185     
    2186    FUNC(set_capture_mode); 
    2187    FUNC(set_capture_mode_canon); 
    2188    FUNC(is_capture_mode_valid); 
    2189     
    2190    FUNC(set_record); 
    2191     
    2192    FUNC(switch_mode_usb); 
    2193     
    2194 #ifdef OPT_LUA_CALL_NATIVE 
    2195    FUNC(call_event_proc); 
    2196    FUNC(call_func_ptr); 
    2197 #endif 
    2198    FUNC(reboot); 
    2199    FUNC(get_config_value); 
    2200    FUNC(set_config_value); 
    2201    FUNC(set_file_attributes); 
    2202    FUNC(file_browser); 
    2203    FUNC(draw_pixel); 
    2204    FUNC(draw_line); 
    2205    FUNC(draw_rect); 
    2206    FUNC(draw_rect_filled); 
    2207    FUNC(draw_ellipse); 
    2208    FUNC(draw_ellipse_filled); 
    2209    FUNC(draw_clear); 
    2210    FUNC(draw_string); 
    2211    FUNC(set_yield); 
     2315  for(r=chdk_funcs;r->name;r++) { 
     2316    lua_pushcfunction( L, r->func ); 
     2317    lua_setglobal( L, r->name ); 
     2318  } 
    22122319#ifdef CAM_CHDK_PTP 
    2213    FUNC(read_usb_msg); 
    2214    FUNC(write_usb_msg); 
    22152320   luaL_dostring(L,"function usb_msg_table_to_string(t)" 
    22162321                    " local v2s=function(v)" 
     
    22362341 
    22372342#endif 
    2238  
    2239 } 
     2343} 
  • trunk/core/main.c

    r932 r948  
    5959    // to try allocating memory to find out how much is available 
    6060    // Call function to scan free list for the largest free block available. 
    61     extern int exmem_largest_block(); 
    62     return exmem_largest_block(); 
     61    cam_meminfo camera_meminfo; 
     62    GetExMemInfo(&camera_meminfo); 
     63    return camera_meminfo.free_block_max_size; 
     64#elif defined(CAM_FIRMWARE_MEMINFO) 
     65    // Call firmware function to fill memory info structure and return size of largest free block 
     66    cam_meminfo camera_meminfo; 
     67    GetMemInfo(&camera_meminfo); 
     68    return camera_meminfo.free_block_max_size; 
    6369#else 
    6470    int size, l_size, d; 
  • trunk/core/suba.c

    r614 r948  
    8686#define SUBA_MAGIC "\xFF\x15\x15\x15SUBA" 
    8787 
    88 int suba_largest_block(struct allocator *suba) 
    89 { 
    90         size_t sz = 0; 
     88void suba_getmeminfo(struct allocator *suba, int *allocated_size, int *allocated_peak, int *allocated_count, int *free_size, int *largest_block, int *free_block_count) 
     89{ 
     90        size_t largest = 0; 
     91    size_t free = 0; 
     92    size_t count = 0; 
    9193 
    9294        if (suba) 
    9395        { 
    9496                struct cell *c = SADR(suba, suba->tail); 
    95                 if (c->size > sz) sz = c->size; 
     97                if (c->size > largest) largest = c->size; 
     98        free += c->size; 
     99        count++; 
    96100                while (c->next != suba->tail) 
    97101                { 
    98102                        c = SADR(suba, c->next); 
    99                         if (c->size > sz) sz = c->size; 
    100                 } 
    101         } 
    102  
    103         return sz; 
     103                        if (c->size > largest) largest = c->size;    
     104            free += c->size; 
     105            count++; 
     106                } 
     107        } 
     108 
     109    *largest_block = largest; 
     110    *free_size = free; 
     111    *free_block_count = count; 
     112    *allocated_size = suba->size_total;     // TODO check this is a reasonable value for this field 
     113    *allocated_peak = suba->alloc_total;    // TODO check this is a reasonable value for this field 
     114    *allocated_count = 0;                   // TODO implement this 
    104115} 
    105116 
  • trunk/include/camera.h

    r933 r948  
    161161    #undef  PARAM_DISPLAY_MODE1                 // param number for LCD display mode when camera in playback 
    162162    #undef  PARAM_DISPLAY_MODE2                 // param number for LCD display mode when camera in record view hold mode 
    163  
    164     #undef CAM_DRIVE_MODE_FROM_TIMER_MODE       // use PROPCASE_TIMER_MODE to check for multiple shot custom timer. 
     163    #undef  CAM_FIRMWARE_MEMINFO                // Use 'GetMemInfo' (dryos) or 'memPartInfoGet'/'memPartFindMax' (vxworks) 
     164                                                // function in firmware to get free memory details 
     165                                                // GetMemInfo should be found correctly by the gensig/finsig signature 
     166                                                // finder for all dryos based cameras. 
     167 
     168    #undef  CAM_NO_MEMPARTINFO                  // VXWORKS camera does not have memPartInfoGet, fall back to memPartFindMax 
     169 
     170    #undef  CAM_DRIVE_MODE_FROM_TIMER_MODE      // use PROPCASE_TIMER_MODE to check for multiple shot custom timer. 
    165171                                                // Used to enabled bracketing in custom timer, required on many recent cameras 
    166172                                                // see http://chdk.setepontos.com/index.php/topic,3994.405.html 
     
    184190    #undef  CAM_NEED_SET_ZOOM_DELAY             // Define to add a delay after setting the zoom position before resetting the focus position in shooting_set_zoom  
    185191 
    186     #undef USE_REAL_AUTOISO                     // Define this to use real-iso instead of marketing-iso as values of autoiso mechanizm 
    187     #undef OVEREXP_COMPENSATE_OVERALL           // Define this to make overexposure_compensation work for all scenes, instead of day-light only 
     192    #undef  USE_REAL_AUTOISO                    // Define this to use real-iso instead of marketing-iso as values of autoiso mechanizm 
     193    #undef  OVEREXP_COMPENSATE_OVERALL          // Define this to make overexposure_compensation work for all scenes, instead of day-light only 
    188194 
    189195    #define CAMERA_MIN_DIST         0           // Define min distance that can be set in _MoveFocusLensToDistance (allow override - e.g. G12 min dist = 1) 
     
    200206// END of Camera-dependent settings 
    201207//========================================================== 
     208 
     209// For newer cameras where the screen bitmap is double the width we need to scale 
     210// the CHDK horizontal (X) co-ordinates 
     211#if CAM_USES_ASPECT_CORRECTION 
     212    #define ASPECT_XCORRECTION(x)   ((x)<<1)    // See comments for CAM_USES_ASPECT_CORRECTION above 
     213#else 
     214    #define ASPECT_XCORRECTION(x)   (x)         // See comments for CAM_USES_ASPECT_CORRECTION above 
     215#endif 
    202216 
    203217// curves only work in 10bpp for now 
     
    210224#endif 
    211225 
    212 // For newer cameras where the screen bitmap is double the width we need to scale 
    213 // the CHDK horizontal (X) co-ordinates 
    214 #if CAM_USES_ASPECT_CORRECTION 
    215 #define ASPECT_XCORRECTION(x)   ((x)<<1)    // See comments for CAM_USES_ASPECT_CORRECTION above 
    216 #else 
    217 #define ASPECT_XCORRECTION(x)   (x)         // See comments for CAM_USES_ASPECT_CORRECTION above 
    218 #endif 
    219  
    220226#endif /* CAMERA_H */ 
  • trunk/include/lolevel.h

    r942 r948  
    302302#endif 
    303303 
     304// vxworks only 
     305// used on a few cameras that don't have memPartInfoGet, see CAM_NO_MEMPARTINFO 
     306extern int _memPartFindMax(int mempart_id);  
     307extern int _memPartInfoGet(int mempart_id,int *info); 
     308 
     309// helpful for Eye-Fi cards 
    304310extern void _SetFileAttributes(int fd, int attr); 
    305311 
  • trunk/include/platform.h

    r933 r948  
    584584void ExitTask(); 
    585585 
     586// Data returned from GetMemInfo & GetExMemInfo functions stored in this data structure 
     587typedef struct { 
     588    int start_address; 
     589    int end_address; 
     590    int total_size; 
     591    int allocated_size; 
     592    int allocated_peak; 
     593    int allocated_count; 
     594    int free_size; 
     595    int free_block_max_size; 
     596    int free_block_count; 
     597} cam_meminfo; 
     598 
     599#if defined(CAM_FIRMWARE_MEMINFO) 
     600extern void GetMemInfo(cam_meminfo*); 
     601#endif 
     602 
    586603#ifdef OPT_EXMEM_MALLOC 
    587604    void exmem_malloc_init(void); 
     605    void GetExMemInfo(cam_meminfo*); 
    588606#endif 
    589607 
  • trunk/platform/a1100/platform_camera.h

    r945 r948  
    8383    #define CAM_ZEBRA_ASPECT_ADJUST         1 
    8484 
     85    #define CAM_FIRMWARE_MEMINFO            1   // Use 'GetMemInfo' to get free memory size. 
    8586//---------------------------------------------------------- 
    8687 
  • trunk/platform/a540/platform_camera.h

    r920 r948  
    5555 
    5656    #define CAM_EXT_TV_RANGE                1 
     57 
     58    #define CAM_FIRMWARE_MEMINFO            1       // Use 'GetMemInfo' to get free memory size. 
    5759//---------------------------------------------------------- 
  • trunk/platform/a590/platform_camera.h

    r933 r948  
    5757    #define CAM_MULTIPART                   1 
    5858    #define CAM_STARTUP_CRASH_FILE_OPEN_FIX 1       // enable fix for camera crash at startup when opening the conf / font files see http://chdk.setepontos.com/index.php?topic=6179.0 
     59    #define CAM_FIRMWARE_MEMINFO            1       // Use 'GetMemInfo' to get free memory size. 
     60 
    5961    #undef  CAMERA_MIN_DIST 
    6062    #define CAMERA_MIN_DIST                 100     // Override min subject distance 
  • trunk/platform/d10/platform_camera.h

    r920 r948  
    9393                                                // Used to enabled bracketing in custom timer, required on many recent cameras 
    9494                                                // see http://chdk.setepontos.com/index.php/topic,3994.405.html 
     95 
     96    #define CAM_FIRMWARE_MEMINFO            1   // Use 'GetMemInfo' to get free memory size. 
    9597//---------------------------------------------------------- 
  • trunk/platform/g10/platform_camera.h

    r920 r948  
    102102                                                    // see http://chdk.setepontos.com/index.php/topic,3994.405.html 
    103103 
     104    #define CAM_FIRMWARE_MEMINFO            1       // Use 'GetMemInfo' to get free memory size. 
    104105//---------------------------------------------------------- 
    105106 
  • trunk/platform/g12/platform_camera.h

    r933 r948  
    104104    #define CAM_STARTUP_CRASH_FILE_OPEN_FIX 1   // enable fix for camera crash at startup when opening the conf / font files see http://chdk.setepontos.com/index.php?topic=6179.0 
    105105 
     106    #define CAM_FIRMWARE_MEMINFO            1   // Use 'GetMemInfo' to get free memory size. 
     107 
    106108    #define CAM_DRIVE_MODE_FROM_TIMER_MODE  1   // use PROPCASE_TIMER_MODE to check for multiple shot custom timer. 
    107109                                                // Used to enabled bracketing in custom timer, required on many recent cameras 
  • trunk/platform/generic/wrappers.c

    r942 r948  
    680680                // round MEMISOSIZE up to next 4 byte boundary if needed (just in case) 
    681681                exmem_start = mem + ((MEMISOSIZE+3)&0xFFFFFFFC); 
    682                 exmem_size = EXMEM_HEAP_SIZE - EXMEM_HEAP_SKIP - ((MEMISOSIZE+3)&0xFFFFFFFC); 
     682                exmem_size = EXMEM_BUFFER_SIZE - ((MEMISOSIZE+3)&0xFFFFFFFC); 
    683683#else 
    684684                // Set start & size based on requested values 
    685685                exmem_start = mem; 
    686                 exmem_size = EXMEM_HEAP_SIZE - EXMEM_HEAP_SKIP; 
     686                exmem_size = EXMEM_BUFFER_SIZE; 
    687687#endif 
    688688                exmem_end = exmem_start + exmem_size; 
     
    717717} 
    718718 
    719 int exmem_largest_block() 
    720 { 
    721         extern int suba_largest_block(void*); 
    722         return suba_largest_block(exmem_heap); 
     719// Use suba functions to fill meminfo structure to match firmware GetMemInfo function 
     720 
     721void GetExMemInfo(cam_meminfo *camera_meminfo) 
     722{ 
     723        extern void suba_getmeminfo(void*, int*, int*, int*, int*, int*, int*); 
     724 
     725    camera_meminfo->start_address        = (int)exmem_start; 
     726    camera_meminfo->end_address          = (int)exmem_start + exmem_size; 
     727    camera_meminfo->total_size           = exmem_size; 
     728    suba_getmeminfo(exmem_heap, 
     729                    &camera_meminfo->allocated_size, &camera_meminfo->allocated_peak, &camera_meminfo->allocated_count, 
     730                    &camera_meminfo->free_size, &camera_meminfo->free_block_max_size, &camera_meminfo->free_block_count); 
    723731} 
    724732// regular malloc 
     
    765773#endif 
    766774} 
     775 
     776#if defined(CAM_FIRMWARE_MEMINFO) 
     777 
     778// Use firmware GetMemInfo function to retrieve info about Canon heap memory allocation 
     779 
     780void GetMemInfo(cam_meminfo *camera_meminfo) 
     781{ 
     782#if defined(CAM_DRYOS) 
     783    // Prior to dryos R39 GetMemInfo returns 9 values, after R39 it returns 10 (all but 1 are used in each case) 
     784    int fw_info[10]; 
     785    extern void _GetMemInfo(int*); 
     786    _GetMemInfo(fw_info); 
     787 
     788#if defined(CAM_DRYOS_2_3_R39) 
     789    // For newer dryos version copy all 9 used values to CHDK structure 
     790    camera_meminfo->start_address        = fw_info[0]; 
     791    camera_meminfo->end_address          = fw_info[1]; 
     792    camera_meminfo->total_size           = fw_info[2]; 
     793    camera_meminfo->allocated_size       = fw_info[3]; 
     794    camera_meminfo->allocated_peak       = fw_info[4]; 
     795    camera_meminfo->allocated_count      = fw_info[5]; 
     796    camera_meminfo->free_size            = fw_info[6]; 
     797    camera_meminfo->free_block_max_size  = fw_info[7]; 
     798    camera_meminfo->free_block_count     = fw_info[8]; 
     799#else 
     800    // For older dryos version copy 8 used values to CHDK structure and calculate missing value 
     801    camera_meminfo->start_address        = fw_info[0]; 
     802    camera_meminfo->end_address          = fw_info[0] + fw_info[1]; 
     803    camera_meminfo->total_size           = fw_info[1]; 
     804    camera_meminfo->allocated_size       = fw_info[2]; 
     805    camera_meminfo->allocated_peak       = fw_info[3]; 
     806    camera_meminfo->allocated_count      = fw_info[4]; 
     807    camera_meminfo->free_size            = fw_info[5]; 
     808    camera_meminfo->free_block_max_size  = fw_info[6]; 
     809    camera_meminfo->free_block_count     = fw_info[7]; 
     810#endif 
     811#else // vxworks 
     812extern int sys_mempart_id; 
     813    int fw_info[5]; 
     814    // -1 for invalid 
     815    memset(camera_meminfo,0xFF,sizeof(cam_meminfo)); 
     816#ifdef CAM_NO_MEMPARTINFO 
     817    camera_meminfo->free_block_max_size = _memPartFindMax(sys_mempart_id); 
     818#else 
     819    _memPartInfoGet(sys_mempart_id,fw_info); 
     820    // TODO we could fill in start address from _start + MEMISOSIZE, if chdk not in exmem 
     821    // these are guessed, look reasonable on a540 
     822    camera_meminfo->free_size = fw_info[0]; 
     823    camera_meminfo->free_block_count = fw_info[1]; 
     824    camera_meminfo->free_block_max_size = fw_info[2]; 
     825    camera_meminfo->allocated_size = fw_info[3]; 
     826    camera_meminfo->allocated_count = fw_info[4]; 
     827#endif 
     828#endif 
     829} 
     830 
     831#endif 
    767832 
    768833//---------------------------------------------------------------------------- 
  • trunk/platform/ixus310_elph500hs/platform_camera.h

    r933 r948  
    119119                                                // see http://chdk.setepontos.com/index.php?topic=6179.0 
    120120 
     121    #define CAM_FIRMWARE_MEMINFO            1   // Use 'GetMemInfo' to get free memory size. 
     122 
    121123    #define CAM_DRIVE_MODE_FROM_TIMER_MODE      // use PROPCASE_TIMER_MODE to check for multiple shot custom timer. 
    122124                                                // Used to enabled bracketing in custom timer, required on many recent cameras 
  • trunk/platform/ixus40_sd300/platform_camera.h

    r859 r948  
    5454    // camera name 
    5555    #define PARAM_CAMERA_NAME               2       // parameter number for GetParameterData 
     56    #define CAM_NO_MEMPARTINFO              1       // vxworks function missing 
    5657//---------------------------------------------------------- 
    5758 
  • trunk/platform/s95/platform_camera.h

    r920 r948  
    8383                                                // see http://chdk.setepontos.com/index.php?topic=6179.0 
    8484 
     85    #define CAM_FIRMWARE_MEMINFO            1   // Use 'GetMemInfo' to get free memory size. 
     86 
    8587    // todo - we may need this to save memory 
    8688    //#define CAM_ZEBRA_NOBUF                 1 
  • trunk/platform/sx20/platform_camera.h

    r943 r948  
    9191    #define CAM_STARTUP_CRASH_FILE_OPEN_FIX 1   // enable fix for camera crash at startup when opening the conf / font files see http://chdk.setepontos.com/index.php?topic=6179.0 
    9292 
     93    #define CAM_FIRMWARE_MEMINFO            1   // Use 'GetMemInfo' to get free memory size. 
     94 
    9395    #define CAM_DRIVE_MODE_FROM_TIMER_MODE  1   // use PROPCASE_TIMER_MODE to check for multiple shot custom timer. 
    9496                                                // Used to enabled bracketing in custom timer, required on many recent cameras 
  • trunk/platform/sx30/platform_camera.h

    r933 r948  
    108108                                                // see http://chdk.setepontos.com/index.php/topic,3994.405.html 
    109109 
     110    #define CAM_FIRMWARE_MEMINFO            1   // Use 'GetMemInfo' to get free memory size. 
     111 
    110112    #define CAM_AV_OVERRIDE_IRIS_FIX        1   // for cameras that require _MoveIrisWithAv function to override Av. 
    111113 
  • trunk/platform/sx40hs/platform_camera.h

    r933 r948  
    111111                                                        // see http://chdk.setepontos.com/index.php/topic,3994.405.html 
    112112 
     113    #define CAM_FIRMWARE_MEMINFO                1       // Use 'GetMemInfo' to get free memory size. 
     114 
    113115    #define CAM_AV_OVERRIDE_IRIS_FIX            1       // for cameras that require _MoveIrisWithAv function to override Av in bracketing. 
    114116 
Note: See TracChangeset for help on using the changeset viewer.