aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerie de Gram <j.de.gram@gmail.com>2011-10-28 13:38:23 +0200
committerJoerie de Gram <j.de.gram@gmail.com>2011-10-28 13:53:28 +0200
commit2b9aa23db0b9c0f395abca551414a3c3ecb6d63d (patch)
tree4a3c066a2f21692cde8f5ce70ef0cc88801a7d72
parent90b3b7de324debfec19829bcd77df5d8b8fba381 (diff)
downloadexternal_libsamsung-ipc-2b9aa23db0b9c0f395abca551414a3c3ecb6d63d.zip
external_libsamsung-ipc-2b9aa23db0b9c0f395abca551414a3c3ecb6d63d.tar.gz
external_libsamsung-ipc-2b9aa23db0b9c0f395abca551414a3c3ecb6d63d.tar.bz2
split devices, require compile-time device selection
-rw-r--r--include/radio.h5
-rw-r--r--samsung-ipc/device/crespo/crespo_ipc.c (renamed from samsung-ipc/crespo_ipc.c)4
-rw-r--r--samsung-ipc/device/crespo/crespo_ipc.h (renamed from samsung-ipc/crespo_ipc.h)0
-rw-r--r--samsung-ipc/device/crespo/crespo_modem_ctl.h (renamed from samsung-ipc/crespo_modem_ctl.h)0
-rw-r--r--samsung-ipc/device/crespo/crespo_nv_data.c (renamed from samsung-ipc/crespo_nv_data.c)0
-rw-r--r--samsung-ipc/device/crespo/crespo_nv_data.h (renamed from samsung-ipc/crespo_nv_data.h)0
-rw-r--r--samsung-ipc/device/h1/h1_ipc.c (renamed from samsung-ipc/h1_ipc.c)53
-rw-r--r--samsung-ipc/device/h1/h1_ipc.h (renamed from samsung-ipc/h1_ipc.h)0
-rw-r--r--samsung-ipc/ipc.c19
-rw-r--r--samsung-ipc/ipc_private.h2
-rw-r--r--tools/modemctrl.c6
11 files changed, 55 insertions, 34 deletions
diff --git a/include/radio.h b/include/radio.h
index ec903df..1d5ce0e 100644
--- a/include/radio.h
+++ b/include/radio.h
@@ -26,9 +26,8 @@
#include "types.h"
#include "util.h"
-#define IPC_CLIENT_TYPE_CRESPO_FMT 1
-#define IPC_CLIENT_TYPE_CRESPO_RFS 2
-#define IPC_CLIENT_TYPE_H1 3
+#define IPC_CLIENT_TYPE_FMT 0
+#define IPC_CLIENT_TYPE_RFS 1
#define IPC_COMMAND(f) ((f->group << 8) | f->index)
#define IPC_GROUP(m) (m >> 8)
diff --git a/samsung-ipc/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c
index 95a2321..cce64eb 100644
--- a/samsung-ipc/crespo_ipc.c
+++ b/samsung-ipc/device/crespo/crespo_ipc.c
@@ -556,7 +556,7 @@ int crespo_ipc_io_data_unreg(void *data)
return 0;
}
-struct ipc_handlers crespo_ipc_default_handlers = {
+struct ipc_handlers ipc_default_handlers = {
.read = crespo_ipc_read,
.write = crespo_ipc_write,
.open = crespo_ipc_open,
@@ -568,7 +568,7 @@ struct ipc_handlers crespo_ipc_default_handlers = {
.power_off = crespo_ipc_power_off,
};
-struct ipc_ops crespo_ipc_ops = {
+struct ipc_ops ipc_ops = {
.send = crespo_ipc_client_send,
.recv = crespo_ipc_client_recv,
.bootstrap = crespo_modem_bootstrap,
diff --git a/samsung-ipc/crespo_ipc.h b/samsung-ipc/device/crespo/crespo_ipc.h
index a6540b5..a6540b5 100644
--- a/samsung-ipc/crespo_ipc.h
+++ b/samsung-ipc/device/crespo/crespo_ipc.h
diff --git a/samsung-ipc/crespo_modem_ctl.h b/samsung-ipc/device/crespo/crespo_modem_ctl.h
index 7c23165..7c23165 100644
--- a/samsung-ipc/crespo_modem_ctl.h
+++ b/samsung-ipc/device/crespo/crespo_modem_ctl.h
diff --git a/samsung-ipc/crespo_nv_data.c b/samsung-ipc/device/crespo/crespo_nv_data.c
index 58b034e..58b034e 100644
--- a/samsung-ipc/crespo_nv_data.c
+++ b/samsung-ipc/device/crespo/crespo_nv_data.c
diff --git a/samsung-ipc/crespo_nv_data.h b/samsung-ipc/device/crespo/crespo_nv_data.h
index bc17416..bc17416 100644
--- a/samsung-ipc/crespo_nv_data.h
+++ b/samsung-ipc/device/crespo/crespo_nv_data.h
diff --git a/samsung-ipc/h1_ipc.c b/samsung-ipc/device/h1/h1_ipc.c
index 65f48bb..49408ba 100644
--- a/samsung-ipc/h1_ipc.c
+++ b/samsung-ipc/device/h1/h1_ipc.c
@@ -25,6 +25,7 @@
#include "ipc_private.h"
#include "h1_ipc.h"
+/* FIXME: move to io_data */
static int fd = 0;
int h1_ipc_open()
@@ -50,25 +51,24 @@ int h1_ipc_close()
return close(fd);
}
- return 1;
-}
-
-int h1_ipc_fd_get()
-{
- return fd;
+ return 0;
}
-void h1_ipc_power_on()
+int h1_ipc_power_on()
{
ioctl(fd, IOCTL_PHONE_ON);
+
+ return 0;
}
-void h1_ipc_power_off()
+int h1_ipc_power_off()
{
ioctl(fd, IOCTL_PHONE_OFF);
+
+ return 0;
}
-void h1_ipc_send(struct ipc_request *request)
+int h1_ipc_send(struct ipc_client *client, struct ipc_request *request)
{
struct hdlc_header *hdlc;
unsigned char *frame;
@@ -96,12 +96,15 @@ void h1_ipc_send(struct ipc_request *request)
hdlc->ipc.type = request->type;
hex_dump(frame, frame_length);
- write(fd, frame, frame_length);
+
+ client->handlers->write(frame, frame_length, client->handlers->io_data);
free(frame);
+
+ return 0;
}
-int h1_ipc_recv(struct ipc_response *response)
+int h1_ipc_recv(struct ipc_client *client, struct ipc_response *response)
{
unsigned char buf[4];
unsigned char *data;
@@ -110,14 +113,14 @@ int h1_ipc_recv(struct ipc_response *response)
int num_read;
int left;
- num_read = read(fd, buf, sizeof(buf));
+ num_read = client->handlers->read((void*)buf, sizeof(buf), client->handlers->io_data);
if(num_read == sizeof(buf) && *buf == FRAME_START) {
frame_length = (unsigned short*)&buf[1];
left = (*frame_length - 3 + 1);
data = (unsigned char*)malloc(left);
- num_read = read(fd, data, left);
+ num_read = client->handlers->read((void*)data, left, client->handlers->io_data);
if(num_read == left && data[left-1] == FRAME_END) {
ipc = (struct ipc_header*)data;
@@ -134,15 +137,33 @@ int h1_ipc_recv(struct ipc_response *response)
}
}
- return 1;
+ return 0;
+}
+
+int h1_ipc_read(void *data, unsigned int size, void *io_data)
+{
+ return read(fd, data, size);
+}
+
+int h1_ipc_write(void *data, unsigned int size, void *io_data)
+{
+ return write(fd, data, size);
}
-struct ipc_ops h1_ipc_ops = {
+struct ipc_handlers ipc_default_handlers = {
.open = h1_ipc_open,
.close = h1_ipc_close,
.power_on = h1_ipc_power_on,
.power_off = h1_ipc_power_off,
+ .read = h1_ipc_read,
+ .write = h1_ipc_write,
+ .io_data_reg = NULL,
+ .io_data_unreg = NULL,
+ .io_data = NULL,
+};
+
+struct ipc_ops ipc_ops = {
.send = h1_ipc_send,
.recv = h1_ipc_recv,
- .fd_get = h1_ipc_fd_get,
+ .bootstrap = NULL,
};
diff --git a/samsung-ipc/h1_ipc.h b/samsung-ipc/device/h1/h1_ipc.h
index 1bbc951..1bbc951 100644
--- a/samsung-ipc/h1_ipc.h
+++ b/samsung-ipc/device/h1/h1_ipc.h
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c
index b539d6d..15335a2 100644
--- a/samsung-ipc/ipc.c
+++ b/samsung-ipc/ipc.c
@@ -29,9 +29,8 @@
#include "ipc_private.h"
-extern struct ipc_ops crespo_ipc_ops;
-// extern struct ipc_ops h1_ipc_ops;
-
+extern struct ipc_ops ipc_ops;
+extern struct ipc_handlers ipc_default_handlers;
void log_handler_default(const char *message, void *user_data)
{
@@ -58,15 +57,12 @@ struct ipc_client* ipc_client_new(int client_type)
switch (client_type)
{
- case IPC_CLIENT_TYPE_CRESPO_FMT:
- case IPC_CLIENT_TYPE_CRESPO_RFS:
- ops = &crespo_ipc_ops;
- break;
- case IPC_CLIENT_TYPE_H1:
- // ops = &h1_ipc_ops;
+ case IPC_CLIENT_TYPE_FMT:
+ case IPC_CLIENT_TYPE_RFS:
+ ops = &ipc_ops;
break;
default:
- break;
+ return NULL;
}
client = (struct ipc_client*) malloc(sizeof(struct ipc_client));
@@ -75,6 +71,9 @@ struct ipc_client* ipc_client_new(int client_type)
client->handlers = (struct ipc_handlers *) malloc(sizeof(struct ipc_handlers));
client->log_handler = log_handler_default;
+ /* Set default handlers */
+ ipc_client_set_handlers(client, &ipc_default_handlers);
+
return client;
}
diff --git a/samsung-ipc/ipc_private.h b/samsung-ipc/ipc_private.h
index be74c74..4891772 100644
--- a/samsung-ipc/ipc_private.h
+++ b/samsung-ipc/ipc_private.h
@@ -21,6 +21,8 @@
#ifndef __IPC_PRIVATE_H__
#define __IPC_PRIVATE_H__
+#include <radio.h>
+
struct ipc_client;
void ipc_client_log(struct ipc_client *client, const char *message, ...);
diff --git a/tools/modemctrl.c b/tools/modemctrl.c
index 4460f7d..4109d9f 100644
--- a/tools/modemctrl.c
+++ b/tools/modemctrl.c
@@ -82,7 +82,7 @@ int modem_start(struct ipc_client *client)
{
int rc;
- ipc_client_set_handlers(client, &crespo_ipc_default_handlers);
+ ipc_client_set_handlers(client, &ipc_default_handlers);
ipc_client_bootstrap_modem(client);
rc = ipc_client_power_on(client);
@@ -116,8 +116,8 @@ int main(int argc, char *argv[])
exit(1);
}
- crespo_fmt_client = ipc_client_new(IPC_CLIENT_TYPE_CRESPO_FMT);
- crespo_rfs_client = ipc_client_new(IPC_CLIENT_TYPE_CRESPO_RFS);
+ crespo_fmt_client = ipc_client_new(IPC_CLIENT_TYPE_FMT);
+ crespo_rfs_client = ipc_client_new(IPC_CLIENT_TYPE_RFS);
if (!strncmp(argv[1], "power-on", sizeof("power-on"))) {
ipc_client_power_on(crespo_fmt_client);