aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc/ipc.c
diff options
context:
space:
mode:
authorSimon Busch <morphis@gravedo.de>2012-01-29 14:40:58 +0100
committerSimon Busch <morphis@gravedo.de>2012-01-30 08:15:52 +0100
commit9a87ce79876a7ba8ebeecf69e2ba30cb9b96bb29 (patch)
tree58732042c6713bf03516da22cd0dfe3e86dc17d1 /samsung-ipc/ipc.c
parent1464578767849d9b08f26c8024edf5f247be5cb8 (diff)
downloadexternal_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/ipc.c')
-rw-r--r--samsung-ipc/ipc.c39
1 files changed, 23 insertions, 16 deletions
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;
}