Read about our upcoming Code of Conduct on this issue

Commit f65664ba authored by hudson@twcdns.fastsearch.net's avatar hudson@twcdns.fastsearch.net
Browse files

Added automated property handlers

parent de06a40da8ae
......@@ -155,6 +155,7 @@ ML_OBJS-y = \
config.o \
debug.o \
menu.o \
property.o \
bmp.o \
font-huge.o \
font-large.o \
......
......@@ -33,7 +33,6 @@
struct gain_struct
{
void * mvr_rec_token;
struct semaphore * sem;
unsigned alc1;
unsigned sig1;
......@@ -41,7 +40,6 @@ struct gain_struct
};
static struct gain_struct gain = {
.mvr_rec_token = (void*) 1,
.sem = (void*) 1,
};
......@@ -783,14 +781,6 @@ static struct menu_entry audio_menus[] = {
};
static void
handle_mvr_rec_token(
void * token
)
{
gain.mvr_rec_token = token;
}
static void
enable_recording(
......@@ -824,32 +814,23 @@ enable_meters(
}
static void
handle_mvr_rec_property(
unsigned property,
void * UNUSED( priv ),
void * buf,
unsigned len
)
{
const unsigned mode = *(unsigned*) buf;
switch( property )
{
case PROP_LV_ACTION:
enable_meters( mode );
break;
case PROP_MVR_REC_START:
enable_recording( mode );
break;
default:
break;
}
PROP_HANDLER( PROP_LV_ACTION )
{
const unsigned mode = *(unsigned*) buf;
enable_meters( mode );
return prop_cleanup( token, property );
}
prop_cleanup( gain.mvr_rec_token, property );
PROP_HANDLER( PROP_MVR_REC_START )
{
const unsigned mode = *(unsigned*) buf;
enable_recording( mode );
return prop_cleanup( token, property );
}
/** Replace the sound dev task with our own to disable AGC.
*
* This task disables the AGC when the sound device is activated.
......@@ -865,19 +846,6 @@ my_sounddev_task( void )
gain.sem = create_named_semaphore( "audio_gain", 1 );
static unsigned mvr_rec_events[] = {
PROP_MVR_REC_START,
PROP_LV_ACTION,
};
prop_register_slave(
mvr_rec_events,
COUNT(mvr_rec_events),
handle_mvr_rec_property,
NULL,
handle_mvr_rec_token
);
msleep( 2000 );
// Fake the sound dev task parameters
......
......@@ -74,6 +74,12 @@ SECTIONS
*(.config_vars)
_config_vars_end = .;
/* Property handlers */
. = ALIGN(8);
_prop_handlers_start = .;
*(.prop_handlers)
_prop_handlers_end = .;
/* Read/write data */
. = ALIGN(64);
*(.data)
......
/** \file
* Property handler installation
*
* These handlers are registered to allow Magic Lantern to interact with
* the Canon "properties" that are used to exchange globals.
*/
#include "dryos.h"
#include "property.h"
// This must be two instructions long!
static void
prop_token_handler_generic(
void * token
)
{
asm( "str r0, [pc, #-12]" );
}
static void
prop_init( void )
{
extern struct prop_handler _prop_handlers_start[];
extern struct prop_handler _prop_handlers_end[];
struct prop_handler * handler = _prop_handlers_start;
for( ; handler < _prop_handlers_end ; handler++ )
{
// Copy the generic token handler into the structure
memcpy(
handler->token_handler,
prop_token_handler_generic,
8
);
prop_register_slave(
&handler->property,
1,
handler->handler,
&handler->token,
&handler->token_handler
);
}
}
INIT_FUNC( __FILE__, prop_init );
......@@ -183,4 +183,40 @@ prop_get_value(
size_t * len
);
struct prop_handler
{
unsigned property;
void * (*handler)(
unsigned property,
void * priv,
void * addr,
unsigned len
);
void * token; // must be before token_handler
uint32_t token_handler[2]; // function goes here!
};
/** 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 = { \
.handler = func, \
.property = id, \
}
#define PROP_HANDLER(id) \
static void * _prop_handler_##id(); \
REGISTER_PROP_HANDLER( id, _prop_handler_##id ); \
void * _prop_handler_##id( \
unsigned property, \
void * token, \
void * buf, \
unsigned len \
) \
#endif
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