diff options
author | Simon Busch <morphis@gravedo.de> | 2012-01-29 14:40:58 +0100 |
---|---|---|
committer | Simon Busch <morphis@gravedo.de> | 2012-01-30 08:15:52 +0100 |
commit | 9a87ce79876a7ba8ebeecf69e2ba30cb9b96bb29 (patch) | |
tree | 58732042c6713bf03516da22cd0dfe3e86dc17d1 /samsung-ipc | |
parent | 1464578767849d9b08f26c8024edf5f247be5cb8 (diff) | |
download | external_libsamsung-ipc-9a87ce79876a7ba8ebeecf69e2ba30cb9b96bb29.zip external_libsamsung-ipc-9a87ce79876a7ba8ebeecf69e2ba30cb9b96bb29.tar.gz external_libsamsung-ipc-9a87ce79876a7ba8ebeecf69e2ba30cb9b96bb29.tar.bz2 |
Rework device specific code so we can build one library for all devices now
Signed-off-by: Simon Busch <morphis@gravedo.de>
Diffstat (limited to 'samsung-ipc')
-rw-r--r-- | samsung-ipc/Makefile.am | 5 | ||||
-rw-r--r-- | samsung-ipc/device/crespo/crespo_ipc.c | 12 | ||||
-rw-r--r-- | samsung-ipc/ipc.c | 39 | ||||
-rw-r--r-- | samsung-ipc/ipc_private.h | 14 |
4 files changed, 44 insertions, 26 deletions
diff --git a/samsung-ipc/Makefile.am b/samsung-ipc/Makefile.am index 46e4e6c..48b9265 100644 --- a/samsung-ipc/Makefile.am +++ b/samsung-ipc/Makefile.am @@ -27,11 +27,10 @@ libsamsung_ipc_la_SOURCES = \ call.c \ net.c \ sms.c \ - $(NULL) - -libsamsung_ipc_la_SOURCES += \ + \ device/crespo/crespo_ipc.c \ $(NULL) + AM_CFLAGS += -DDEVICE_IPC_V4 libsamsung_ipc_la_LIBADD = \ diff --git a/samsung-ipc/device/crespo/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c index 65f144d..9666a03 100644 --- a/samsung-ipc/device/crespo/crespo_ipc.c +++ b/samsung-ipc/device/crespo/crespo_ipc.c @@ -691,7 +691,7 @@ int crespo_ipc_common_data_get_fd(void *io_data) return (int) *(common_data); } -struct ipc_handlers ipc_default_handlers = { +struct ipc_handlers crespo_default_handlers = { .read = crespo_ipc_read, .write = crespo_ipc_write, .open = crespo_ipc_open, @@ -705,16 +705,22 @@ struct ipc_handlers ipc_default_handlers = { .common_data_get_fd = crespo_ipc_common_data_get_fd, }; -struct ipc_ops ipc_fmt_ops = { +struct ipc_ops crespo_fmt_ops = { .send = crespo_ipc_fmt_client_send, .recv = crespo_ipc_fmt_client_recv, .bootstrap = crespo_modem_bootstrap, }; -struct ipc_ops ipc_rfs_ops = { +struct ipc_ops crespo_rfs_ops = { .send = crespo_ipc_rfs_client_send, .recv = crespo_ipc_rfs_client_recv, .bootstrap = NULL, }; +void crespo_ipc_init(void) +{ + ipc_register_device_client_handlers(IPC_DEVICE_CRESPO, &crespo_fmt_ops, + &crespo_rfs_ops, &crespo_default_handlers); +} + // vim:ts=4:sw=4:expandtab diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c index f7fbb6d..c4384ff 100644 --- a/samsung-ipc/ipc.c +++ b/samsung-ipc/ipc.c @@ -29,15 +29,21 @@ #include "ipc_private.h" -extern struct ipc_ops ipc_fmt_ops; -extern struct ipc_ops ipc_rfs_ops; -extern struct ipc_handlers ipc_default_handlers; +struct ipc_device_desc devices[IPC_DEVICE_MAX+1]; void log_handler_default(const char *message, void *user_data) { printf("%s\n", message); } +void ipc_register_device_client_handlers(int device, struct ipc_ops *fmt_ops, + struct ipc_ops *rfs_ops, struct ipc_handlers *handlers) +{ + devices[device].fmt_ops = fmt_ops; + devices[device].rfs_ops = rfs_ops; + devices[device].handlers = handlers; +} + void ipc_client_log(struct ipc_client *client, const char *message, ...) { assert(client->log_handler != NULL); @@ -51,30 +57,31 @@ void ipc_client_log(struct ipc_client *client, const char *message, ...) va_end(args); } -struct ipc_client* ipc_client_new(int client_type) +struct ipc_client* ipc_client_new(int device_type, int client_type) { struct ipc_client *client; - struct ipc_ops *ops = NULL; + + if (device_type < 0 || device_type > IPC_DEVICE_MAX) + return 0; + if (client_type < 0 || client_type > IPC_CLIENT_TYPE_RFS) + return 0; + + client = (struct ipc_client*) malloc(sizeof(struct ipc_client)); + client->type = client_type; switch (client_type) { - case IPC_CLIENT_TYPE_FMT: - ops = &ipc_fmt_ops; - break; case IPC_CLIENT_TYPE_RFS: - ops = &ipc_rfs_ops; + client->ops = devices[device_type].rfs_ops; + break; + case IPC_CLIENT_TYPE_FMT: + client->ops = devices[device_type].fmt_ops; break; - default: - return NULL; } - client = (struct ipc_client*) malloc(sizeof(struct ipc_client)); - client->type = client_type; - client->ops = ops; client->handlers = (struct ipc_handlers *) malloc(sizeof(struct ipc_handlers)); client->log_handler = log_handler_default; - - memcpy(client->handlers, &ipc_default_handlers, sizeof(struct ipc_handlers)); + memcpy(client->handlers, devices[device_type].handlers , sizeof(struct ipc_handlers)); return client; } diff --git a/samsung-ipc/ipc_private.h b/samsung-ipc/ipc_private.h index 5e374d0..1795def 100644 --- a/samsung-ipc/ipc_private.h +++ b/samsung-ipc/ipc_private.h @@ -23,10 +23,6 @@ #include <radio.h> -struct ipc_client; - -void ipc_client_log(struct ipc_client *client, const char *message, ...); - struct ipc_ops { int (*bootstrap)(struct ipc_client *client); int (*send)(struct ipc_client *client, struct ipc_message_info *); @@ -69,6 +65,16 @@ struct ipc_client { struct ipc_handlers *handlers; }; +struct ipc_device_desc { + struct ipc_ops *fmt_ops; + struct ipc_ops *rfs_ops; + struct ips_handlers *handlers; +}; + +void ipc_client_log(struct ipc_client *client, const char *message, ...); +void ipc_register_device_client_handlers(int device, struct ipc_ops *fmt_ops, + struct ipc_ops *rfs_ops, struct ipc_handlers *handlers); + #endif // vim:ts=4:sw=4:expandtab |