aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/Makefile.am1
-rw-r--r--samsung-ipc/device/aries/aries_ipc.c6
-rw-r--r--samsung-ipc/device/crespo/crespo_ipc.c6
-rw-r--r--samsung-ipc/device/h1/h1_ipc.c4
-rw-r--r--samsung-ipc/ipc.c78
-rw-r--r--samsung-ipc/ipc_devices.c33
-rw-r--r--samsung-ipc/ipc_devices.h57
-rw-r--r--samsung-ipc/ipc_private.h6
8 files changed, 131 insertions, 60 deletions
diff --git a/samsung-ipc/Makefile.am b/samsung-ipc/Makefile.am
index 31c3934..df5dc22 100644
--- a/samsung-ipc/Makefile.am
+++ b/samsung-ipc/Makefile.am
@@ -17,6 +17,7 @@ lib_LTLIBRARIES = \
libsamsung_ipc_la_SOURCES = \
ipc.c \
ipc_util.c \
+ ipc_devices.c \
util.c \
\
rfs.c \
diff --git a/samsung-ipc/device/aries/aries_ipc.c b/samsung-ipc/device/aries/aries_ipc.c
index 5010017..7f6749d 100644
--- a/samsung-ipc/device/aries/aries_ipc.c
+++ b/samsung-ipc/device/aries/aries_ipc.c
@@ -941,10 +941,4 @@ struct ipc_ops aries_rfs_ops = {
.bootstrap = NULL,
};
-void aries_ipc_register(void)
-{
- ipc_register_device_client_handlers(IPC_DEVICE_ARIES, &aries_fmt_ops,
- &aries_rfs_ops, &aries_default_handlers);
-}
-
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/device/crespo/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c
index 0ce7830..556d77c 100644
--- a/samsung-ipc/device/crespo/crespo_ipc.c
+++ b/samsung-ipc/device/crespo/crespo_ipc.c
@@ -717,10 +717,4 @@ struct ipc_ops crespo_rfs_ops = {
.bootstrap = NULL,
};
-void crespo_ipc_register(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/device/h1/h1_ipc.c b/samsung-ipc/device/h1/h1_ipc.c
index 8363449..1f6b825 100644
--- a/samsung-ipc/device/h1/h1_ipc.c
+++ b/samsung-ipc/device/h1/h1_ipc.c
@@ -263,7 +263,7 @@ int h1_ipc_common_data_get_fd(void *io_data)
return (int) *(common_data);
}
-struct ipc_handlers ipc_default_handlers = {
+struct ipc_handlers h1_default_handlers = {
.open = h1_ipc_open,
.close = h1_ipc_close,
.power_on = h1_ipc_power_on,
@@ -277,7 +277,7 @@ struct ipc_handlers ipc_default_handlers = {
.common_data_get_fd = h1_ipc_common_data_get_fd,
};
-struct ipc_ops ipc_fmt_ops = {
+struct ipc_ops h1_fmt_ops = {
.send = h1_ipc_send,
.recv = h1_ipc_recv,
.bootstrap = NULL,
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c
index 60f5db0..970dfa1 100644
--- a/samsung-ipc/ipc.c
+++ b/samsung-ipc/ipc.c
@@ -38,35 +38,13 @@
#include <radio.h>
#include "ipc_private.h"
-
-struct ipc_device_desc devices[IPC_DEVICE_MAX+1];
-
-extern void crespo_ipc_register(void);
-extern void aries_ipc_register();
-
-void ipc_init(void)
-{
- crespo_ipc_register();
- aries_ipc_register();
-}
-
-void ipc_shutdown(void)
-{
-}
+#include "ipc_devices.h"
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);
@@ -80,9 +58,21 @@ void ipc_client_log(struct ipc_client *client, const char *message, ...)
va_end(args);
}
-struct ipc_client* ipc_client_new(int client_type)
+int ipc_device_detect(void)
{
- int device_type = -1, in_hardware = 0;
+ int index = -1;
+ int i;
+
+#ifdef IPC_DEVICE_EXPLICIT
+ for(i=0 ; i < ipc_devices_count ; i++)
+ {
+ if(strcmp(IPC_DEVICE_EXPLICIT, ipc_device[i].name) == 0)
+ {
+ index = i;
+ break;
+ }
+ }
+#else
char buf[4096];
// gather device type from /proc/cpuinfo
@@ -97,27 +87,34 @@ struct ipc_client* ipc_client_new(int client_type)
int rc;
if ((rc = strncmp(pch, "Hardware", 9)) == 9)
{
- if (strstr(pch, "herring") != NULL)
- device_type = IPC_DEVICE_CRESPO;
+ for(i=0 ; i < ipc_devices_count ; i++)
+ {
+ if(strcmp(pch, ipc_devices[i].board_name) == 0)
+ {
+ index = i;
+ break;
+ }
+ }
}
pch = strtok(NULL, "\n");
}
+#endif
- // validate that we have found any supported device
- if (device_type == -1)
- return NULL;
-
- return ipc_client_new_for_device(device_type, client_type);
+ return index;
}
-struct ipc_client* ipc_client_new_for_device(int device_type, int client_type)
+struct ipc_client* ipc_client_new(int client_type)
{
struct ipc_client *client;
+ int device_index = -1;
+
+ device_index = ipc_device_detect();
+
+ if(device_index < 0 || device_index > ipc_devices_count)
+ return NULL;
- if (device_type < 0 || device_type > IPC_DEVICE_MAX)
- return 0;
if (client_type < 0 || client_type > IPC_CLIENT_TYPE_RFS)
- return 0;
+ return NULL;
client = (struct ipc_client*) malloc(sizeof(struct ipc_client));
client->type = client_type;
@@ -125,17 +122,18 @@ struct ipc_client* ipc_client_new_for_device(int device_type, int client_type)
switch (client_type)
{
case IPC_CLIENT_TYPE_RFS:
- client->ops = devices[device_type].rfs_ops;
+ client->ops = ipc_devices[device_index].rfs_ops;
break;
case IPC_CLIENT_TYPE_FMT:
- client->ops = devices[device_type].fmt_ops;
+ client->ops = ipc_devices[device_index].fmt_ops;
break;
}
client->handlers = (struct ipc_handlers *) malloc(sizeof(struct ipc_handlers));
client->log_handler = log_handler_default;
- if (devices[device_type].handlers != 0)
- memcpy(client->handlers, devices[device_type].handlers , sizeof(struct ipc_handlers));
+
+ if (ipc_devices[device_index].handlers != 0)
+ memcpy(client->handlers, ipc_devices[device_index].handlers, sizeof(struct ipc_handlers));
return client;
}
diff --git a/samsung-ipc/ipc_devices.c b/samsung-ipc/ipc_devices.c
new file mode 100644
index 0000000..f3f2b17
--- /dev/null
+++ b/samsung-ipc/ipc_devices.c
@@ -0,0 +1,33 @@
+/**
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
+ *
+ * libsamsung-ipc is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libsamsung-ipc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <radio.h>
+
+#include "ipc_devices.h"
+
+struct ipc_device_desc ipc_devices[] = {
+ { "crespo", "herring", &crespo_default_handlers, &crespo_fmt_ops, &crespo_rfs_ops },
+ { "aries", "aries", &aries_default_handlers, &aries_fmt_ops, &aries_rfs_ops },
+ { "aries", "gt-p1000", &aries_default_handlers, &aries_fmt_ops, &aries_rfs_ops }
+};
+
+int ipc_devices_count = sizeof(ipc_devices) / sizeof(struct ipc_device_desc);
+
+// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/ipc_devices.h b/samsung-ipc/ipc_devices.h
new file mode 100644
index 0000000..baddb76
--- /dev/null
+++ b/samsung-ipc/ipc_devices.h
@@ -0,0 +1,57 @@
+/**
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
+ *
+ * libsamsung-ipc is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libsamsung-ipc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __IPC_DEVICES_H__
+#define __IPC_DEVICES_H__
+
+#include <radio.h>
+
+struct ipc_device_desc {
+ char *name;
+ char *board_name;
+
+ struct ipc_handlers *handlers;
+ struct ipc_ops *fmt_ops;
+ struct ipc_ops *rfs_ops;
+};
+
+extern struct ipc_device_desc ipc_devices[];
+extern int ipc_devices_count;
+
+// h1
+
+extern struct ipc_handlers h1_default_handlers;
+extern struct ipc_ops h1_fmt_ops;
+extern struct ipc_ops h1_rfs_ops;
+
+// crespo
+
+extern struct ipc_handlers crespo_default_handlers;
+extern struct ipc_ops crespo_fmt_ops;
+extern struct ipc_ops crespo_rfs_ops;
+
+// aries
+extern struct ipc_handlers aries_default_handlers;
+extern struct ipc_ops aries_fmt_ops;
+extern struct ipc_ops aries_rfs_ops;
+
+#endif
+
+// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/ipc_private.h b/samsung-ipc/ipc_private.h
index 1795def..ac8db78 100644
--- a/samsung-ipc/ipc_private.h
+++ b/samsung-ipc/ipc_private.h
@@ -65,12 +65,6 @@ 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);