Commit 209ab695 authored by hudson@kremvax's avatar hudson@kremvax
Browse files

Auto-installed PTP handlers.

- Split PTP handlers into separate section.
- Moved lens focus PTP handler into focus.c
parent 82ac782d92b6
......@@ -11,6 +11,7 @@
#include "bmp.h"
#include "lens.h"
#include "config.h"
#include "ptp.h"
CONFIG_INT( "focus.step", focus_stack_step, 100 );
CONFIG_INT( "focus.count", focus_stack_count, 5 );
......@@ -345,5 +346,39 @@ focus_init( void )
}
static int
ptp_lens_focus(
void * priv,
struct ptp_context * context,
uint32_t opcode,
uint32_t session,
uint32_t transaction,
uint32_t param1,
uint32_t param2,
uint32_t param3,
uint32_t param4,
uint32_t param5
)
{
struct ptp_msg msg = {
.id = PTP_RC_OK,
.session = session,
.transaction = transaction,
};
lens_focus( 0x7, (int) param1 );
context->send(
context->handle,
&msg
);
return 0;
}
PTP_HANDLER( 0x9998, ptp_lens_focus, 0 );
INIT_FUNC( __FILE__, focus_init );
......@@ -62,6 +62,12 @@ SECTIONS
*(.init_funcs)
_init_funcs_end = .;
/* List of PTP handlers to be installed */
. = ALIGN(8);
_ptp_handlers_start = .;
*(.ptp_handlers)
_ptp_handlers_end = .;
/* Configuration parameters to be assigned */
. = ALIGN(8);
_config_vars_start = .;
......
......@@ -89,36 +89,8 @@ ptp_handler_9999(
}
PTP_HANDLER( 0x9999, ptp_handler_9999, 0 );
static int
ptp_handler_9998(
void * priv,
struct ptp_context * context,
uint32_t opcode,
uint32_t session,
uint32_t transaction,
uint32_t param1,
uint32_t param2,
uint32_t param3,
uint32_t param4,
uint32_t param5
)
{
struct ptp_msg msg = {
.id = PTP_RC_OK,
.session = session,
.transaction = transaction,
};
lens_focus( 0x7, (int) param1 );
context->send(
context->handle,
&msg
);
return 0;
}
static void
......@@ -163,17 +135,18 @@ static struct menu_entry ptp_menus[] = {
static void
ptp_init( void )
{
ptp_register_handler(
0x9999,
ptp_handler_9999,
0
);
extern struct ptp_handler _ptp_handlers_start[];
extern struct ptp_handler _ptp_handlers_end[];
struct ptp_handler * handler = _ptp_handlers_start;
ptp_register_handler(
0x9998,
ptp_handler_9998,
0
);
for( ; handler < _ptp_handlers_end ; handler++ )
{
ptp_register_handler(
handler->id,
handler->handler,
handler->priv
);
}
menu_add( "PTP", ptp_menus, COUNT(ptp_menus) );
}
......
......@@ -91,4 +91,21 @@ ptp_register_handler(
);
/* PTP handlers */
struct ptp_handler
{
uint32_t id;
void * handler;
void * priv;
};
#define PTP_HANDLER( ID, HANDLER, PRIV ) \
struct ptp_handler \
__attribute__((section(".ptp_handlers"))) \
__ptp_handler_##ID = { \
.id = ID, \
.handler = HANDLER, \
.priv = PRIV, \
}
#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