Read about our upcoming Code of Conduct on this issue

Commit ae225224 authored by hudson@kremvax.wan's avatar hudson@kremvax.wan
Browse files

Use the new automate property handler code and mark the prop handlers as used...

Use the new automate property handler code and mark the prop handlers as used so that they are forced to be emitted
parent c2af5468dbe9
......@@ -817,14 +817,14 @@ enable_meters(
PROP_HANDLER( PROP_LV_ACTION )
{
const unsigned mode = *(unsigned*) buf;
const unsigned mode = buf[0];
enable_meters( mode );
return prop_cleanup( token, property );
}
PROP_HANDLER( PROP_MVR_REC_START )
{
const unsigned mode = *(unsigned*) buf;
const unsigned mode = buf[0];
enable_recording( mode );
return prop_cleanup( token, property );
}
......
......@@ -104,43 +104,13 @@ void call_dispcheck( void * priv )
}
static PROP_INT( PROP_EFIC_TEMP, efic_temp );
static unsigned efic_temp;
static void * efic_temp_token;
static void
efic_temp_token_handler(
void * token
)
PROP_HANDLER( PROP_HDMI_CHANGE_CODE )
{
efic_temp_token = token;
}
static void
efic_temp_property_handler(
unsigned property,
void * UNUSED( priv ),
unsigned * addr,
unsigned len
)
{
switch( property )
{
case PROP_EFIC_TEMP:
efic_temp = *addr;
break;
case PROP_HDMI_CHANGE_CODE:
DebugMsg( DM_MAGIC, 3, "They try to set code to %d", *addr );
//*addr = 5;
break;
default:
break;
}
prop_cleanup( efic_temp_token, property );
DebugMsg( DM_MAGIC, 3, "They try to set code to %d", buf[0] );
return prop_cleanup( token, property );
}
......@@ -300,14 +270,16 @@ debug_token_handler(
);
}
static void
static void *
debug_property_handler(
unsigned property,
void * UNUSED( priv ),
unsigned * addr,
void * buf,
unsigned len
)
{
const uint32_t * const addr = buf;
DebugMsg( DM_MAGIC, 3, "Prop %08x: %d: %08x %08x %08x %08x",
property,
len,
......@@ -342,8 +314,7 @@ debug_property_handler(
y = 32;
ack:
prop_cleanup( debug_token, property );
return;
return prop_cleanup( debug_token, property );
}
......@@ -410,23 +381,10 @@ thats_all:
property_list,
actual_num_properties,
debug_property_handler,
0xdeadbeef,
(void*) 0xdeadbeef,
debug_token_handler
);
static unsigned efic_properties[] = {
PROP_EFIC_TEMP,
PROP_HDMI_CHANGE_CODE
};
prop_register_slave(
efic_properties,
COUNT(efic_properties),
efic_temp_property_handler,
0,
efic_temp_token_handler
);
menu_add( "Debug", debug_menus, COUNT(debug_menus) );
}
......
......@@ -473,28 +473,6 @@ mvr_create_logfile(
static unsigned lens_properties[] = {
PROP_MVR_REC_START,
PROP_LENS_NAME,
PROP_LV_LENS,
PROP_APERTURE,
PROP_SHUTTER,
PROP_ISO,
PROP_LVCAF_STATE,
PROP_LV_FOCUS,
PROP_LV_FOCUS_DONE,
PROP_LAST_JOB_STATE,
};
static void
lens_handle_token(
void * token
)
{
lens_info.token = token;
}
static inline uint16_t
bswap16(
uint16_t val
......@@ -504,99 +482,111 @@ bswap16(
}
static void
lens_handle_property(
unsigned property,
void * priv,
char * buf,
unsigned len
)
PROP_HANDLER( PROP_MVR_REC_START )
{
const uint32_t raw = *(uint32_t *) buf;
mvr_create_logfile( *(unsigned*) buf );
return prop_cleanup( token, property );
}
switch( property )
{
case PROP_MVR_REC_START:
mvr_create_logfile( *(unsigned*) buf );
break;
case PROP_LENS_NAME:
if( len > sizeof(lens_info.name) )
len = sizeof(lens_info.name);
memcpy( lens_info.name, buf, len );
break;
case PROP_APERTURE:
lens_info.raw_aperture = raw;
lens_info.aperture = raw/2 < COUNT(aperture_values)
? aperture_values[ raw / 2 ]
: 0;
break;
case PROP_SHUTTER:
lens_info.raw_shutter = raw;
lens_info.shutter = raw/2 < COUNT(shutter_values)
? shutter_values[ raw / 2 ]
: 0;
break;
case PROP_ISO:
lens_info.raw_iso = raw;
lens_info.iso = raw/2 < COUNT(iso_values)
? iso_values[ raw / 2 ]
: 0;
break;
case PROP_LV_LENS:
{
const struct prop_lv_lens * const lv_lens = (void*) buf;
lens_info.focal_len = bswap16( lv_lens->focal_len );
lens_info.focus_dist = bswap16( lv_lens->focus_dist );
give_semaphore( lens_sem );
//bmp_hexdump( 300, 88, buf, len );
break;
}
case PROP_LVCAF_STATE:
bmp_hexdump( FONT_SMALL, 200, 50, buf, len );
break;
case PROP_LV_FOCUS:
{
const struct prop_focus * const focus = (void*) buf;
const int16_t step = (focus->step_hi << 8) | focus->step_lo;
bmp_printf( FONT_SMALL, 200, 30,
"FOCUS: %08x active=%02x dir=%+5d (%04x) mode=%02x",
*(unsigned*)buf,
focus->active,
(int) step,
(unsigned) step & 0xFFFF,
focus->mode
);
break;
}
PROP_HANDLER( PROP_LENS_NAME )
{
if( len > sizeof(lens_info.name) )
len = sizeof(lens_info.name);
memcpy( lens_info.name, buf, len );
return prop_cleanup( token, property );
}
PROP_HANDLER( PROP_APERTURE )
{
const uint32_t raw = *(uint32_t *) buf;
lens_info.raw_aperture = raw;
lens_info.aperture = raw/2 < COUNT(aperture_values)
? aperture_values[ raw / 2 ]
: 0;
return prop_cleanup( token, property );
}
PROP_HANDLER( PROP_SHUTTER )
{
const uint32_t raw = *(uint32_t *) buf;
lens_info.raw_shutter = raw;
lens_info.shutter = raw/2 < COUNT(shutter_values)
? shutter_values[ raw / 2 ]
: 0;
return prop_cleanup( token, property );
}
PROP_HANDLER( PROP_ISO )
{
const uint32_t raw = *(uint32_t *) buf;
lens_info.raw_iso = raw;
lens_info.iso = raw/2 < COUNT(iso_values)
? iso_values[ raw / 2 ]
: 0;
return prop_cleanup( token, property );
}
PROP_HANDLER( PROP_LV_LENS )
{
const struct prop_lv_lens * const lv_lens = (void*) buf;
lens_info.focal_len = bswap16( lv_lens->focal_len );
lens_info.focus_dist = bswap16( lv_lens->focus_dist );
give_semaphore( lens_sem );
return prop_cleanup( token, property );
}
PROP_HANDLER( PROP_LVCAF_STATE )
{
bmp_hexdump( FONT_SMALL, 200, 50, buf, len );
return prop_cleanup( token, property );
}
PROP_HANDLER( PROP_LV_FOCUS )
{
const struct prop_focus * const focus = (void*) buf;
const int16_t step = (focus->step_hi << 8) | focus->step_lo;
bmp_printf( FONT_SMALL, 200, 30,
"FOCUS: %08x active=%02x dir=%+5d (%04x) mode=%02x",
*(unsigned*)buf,
focus->active,
(int) step,
(unsigned) step & 0xFFFF,
focus->mode
);
return prop_cleanup( token, property );
}
PROP_HANDLER( PROP_LV_FOCUS_DONE )
{
// The last focus command has completed
case PROP_LV_FOCUS_DONE:
give_semaphore( focus_done_sem );
break;
give_semaphore( focus_done_sem );
return prop_cleanup( token, property );
}
// Update the job state
case PROP_LAST_JOB_STATE:
{
const uint32_t state = *(uint32_t*) buf;
lens_info.job_state = state;
if( state == 0xA )
{
DebugMsg( DM_MAGIC, 3,
"%s: Unlocking job state=%x",
__func__,
state
);
give_semaphore( job_sem );
}
break;
}
default:
break;
PROP_HANDLER( PROP_LAST_JOB_STATE )
{
const uint32_t state = *(uint32_t*) buf;
lens_info.job_state = state;
if( state == 0xA )
{
DebugMsg( DM_MAGIC, 3,
"%s: Unlocking job state=%x",
__func__,
state
);
give_semaphore( job_sem );
}
prop_cleanup( lens_info.token, property );
return prop_cleanup( token, property );
}
......@@ -623,14 +613,6 @@ lens_init( void )
lens_sem = create_named_semaphore( "lens_info", 1 );
focus_done_sem = create_named_semaphore( "focus_sem", 1 );
job_sem = create_named_semaphore( "job", 1 );
prop_register_slave(
lens_properties,
COUNT(lens_properties),
lens_handle_property,
0,
lens_handle_token
);
}
INIT_FUNC( "lens", lens_init );
......@@ -203,7 +203,8 @@ struct prop_handler
/** Register a property handler with automated token function */
#define REGISTER_PROP_HANDLER( id, func ) \
__attribute__((section(".prop_handlers"))) \
struct prop_handler _prop_handler_##id##_block = { \
__attribute__((used)) \
static struct prop_handler _prop_handler_##id##_block = { \
.handler = func, \
.property = id, \
}
......@@ -214,9 +215,17 @@ REGISTER_PROP_HANDLER( id, _prop_handler_##id ); \
void * _prop_handler_##id( \
unsigned property, \
void * token, \
void * buf, \
uint32_t * buf, \
unsigned len \
) \
#define PROP_INT(id,name) \
uint32_t name; \
PROP_HANDLER(id) { \
name = buf[0]; \
return prop_cleanup( token, property ); \
}
#endif
......@@ -607,88 +607,63 @@ struct menu_entry zebra_menus[] = {
},
};
static void * lv_token;
static void
lv_token_handler(
void * token
)
PROP_HANDLER( PROP_LV_ACTION )
{
lv_token = token;
// LV_START==0, LV_STOP=1
lv_drawn = !buf[0];
return prop_cleanup( token, property );
}
static void
lv_prop_handler(
unsigned property,
void * priv,
unsigned * addr,
unsigned len
)
PROP_HANDLER( PROP_GUI_STATE )
{
// PLAYMENU==0, IDLE==1
lv_drawn = !buf[0];
return prop_cleanup( token, property );
}
PROP_HANDLER( PROP_ACTIVE_SWEEP_STATUS )
{
unsigned value = *addr;
// Let us know when the sensor is done cleaning
sensor_cleaning = buf[0];
return prop_cleanup( token, property );
}
switch( property )
{
case PROP_LV_ACTION:
// LV_START==0, LV_STOP=1
lv_drawn = !value;
break;
case PROP_GUI_STATE:
// PLAYMENU==0, IDLE==1
lv_drawn = !value;
break;
case PROP_ACTIVE_SWEEP_STATUS:
// Let us know when the sensor is done cleaning
sensor_cleaning = value;
break;
case PROP_MVR_REC_START:
if( value == 2 )
bmp_printf(
timecode_font,
timecode_x,
timecode_y,
"REC: "
);
break;
case PROP_REC_TIME:
value /= 200; // why? it seems to work out
PROP_HANDLER( PROP_MVR_REC_START )
{
if( buf[0] == 2 )
bmp_printf(
value < timecode_warning ? timecode_font : FONT_MED,
timecode_x + 5 * fontspec_font(timecode_font)->width,
timecode_font,
timecode_x,
timecode_y,
"%4d:%02d",
value / 60,
value % 60
"REC: "
);
break;
default:
break;
}
return prop_cleanup( token, property );
}
prop_cleanup( lv_token, property );
PROP_HANDLER( PROP_REC_TIME )
{
unsigned value = buf[0];
value /= 200; // why? it seems to work out
bmp_printf(
value < timecode_warning ? timecode_font : FONT_MED,
timecode_x + 5 * fontspec_font(timecode_font)->width,
timecode_y,
"%4d:%02d",
value / 60,
value % 60
);
return prop_cleanup( token, property );
}
static void
zebra_task( void )
{
static unsigned properties[] = {
PROP_LV_ACTION,
PROP_GUI_STATE,
PROP_ACTIVE_SWEEP_STATUS,
PROP_MVR_REC_START,
PROP_REC_TIME,
};
prop_register_slave(
properties,
COUNT(properties),
lv_prop_handler,
0,
lv_token_handler
);
lv_drawn = 0;
cropmarks = bmp_load( crop_file );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment