aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Busch <morphis@gravedo.de>2012-08-27 12:28:21 +0200
committerSimon Busch <morphis@gravedo.de>2012-08-27 12:28:21 +0200
commitaae7f36e70d164eaf4917281f816891807c37d27 (patch)
tree59350f68fb0f2c07e967ddcdb560216b5ec77e6a
parentd851f2bceb5813ba128ab31384bbec7f8cc72f07 (diff)
parenta6b8e7d405b16b33a9726ddd70346b5dbb6c845a (diff)
downloadexternal_libsamsung-ipc-aae7f36e70d164eaf4917281f816891807c37d27.zip
external_libsamsung-ipc-aae7f36e70d164eaf4917281f816891807c37d27.tar.gz
external_libsamsung-ipc-aae7f36e70d164eaf4917281f816891807c37d27.tar.bz2
Merge remote-tracking branch 'astarasikov/merge-24-aug'
Conflicts: include/Makefile.am
-rw-r--r--Android.mk1
-rw-r--r--include/Makefile.am1
-rw-r--r--include/wakelock.h27
-rw-r--r--samsung-ipc/Makefile.am1
-rw-r--r--samsung-ipc/device/crespo/crespo_ipc.c36
-rw-r--r--samsung-ipc/device/crespo/crespo_ipc.h3
-rw-r--r--samsung-ipc/device/maguro/maguro_ipc.c2
-rw-r--r--samsung-ipc/device/maguro/maguro_loader.c24
-rw-r--r--samsung-ipc/device/maguro/maguro_loader.h3
-rw-r--r--samsung-ipc/device/xmm6260/xmm6260_ipc.c49
-rw-r--r--samsung-ipc/ipc.c4
-rw-r--r--samsung-ipc/wakelock.c60
12 files changed, 164 insertions, 47 deletions
diff --git a/Android.mk b/Android.mk
index ceecbe3..196f1c7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -55,6 +55,7 @@ samsung-ipc_files := \
samsung-ipc/misc.c \
samsung-ipc/net.c \
samsung-ipc/sec.c \
+ samsung-ipc/wakelock.c \
samsung-ipc/device/h1/h1_ipc.c \
samsung-ipc/device/crespo/crespo_ipc.c \
samsung-ipc/device/aries/aries_ipc.c \
diff --git a/include/Makefile.am b/include/Makefile.am
index 1eb264d..09fecf8 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -16,6 +16,7 @@ samsung_ipcinclude_HEADERS = \
gprs.h \
snd.h \
rfs.h \
+ wakelock.h \
samsung-ipc.h \
$(NULL)
diff --git a/include/wakelock.h b/include/wakelock.h
new file mode 100644
index 0000000..db1815b
--- /dev/null
+++ b/include/wakelock.h
@@ -0,0 +1,27 @@
+/**
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2012 Alexander Tarasikov <alexander.tarasikov@gmail.com>
+ *
+ * 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 __WAKELOCK_H__
+#define __WAKELOCK_H__
+
+extern int wake_lock(char *lock_name);
+extern int wake_unlock(char *lock_name);
+
+#endif //__WAKELOCK_H__
diff --git a/samsung-ipc/Makefile.am b/samsung-ipc/Makefile.am
index bf3cecb..6f7c380 100644
--- a/samsung-ipc/Makefile.am
+++ b/samsung-ipc/Makefile.am
@@ -26,6 +26,7 @@ libsamsung_ipc_la_SOURCES = \
gprs.c \
call.c \
net.c \
+ wakelock.c \
ipc_private.h \
ipc_devices.h \
device/crespo/crespo_ipc.c \
diff --git a/samsung-ipc/device/crespo/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c
index 34a2000..33386d9 100644
--- a/samsung-ipc/device/crespo/crespo_ipc.c
+++ b/samsung-ipc/device/crespo/crespo_ipc.c
@@ -34,38 +34,12 @@
#include <assert.h>
#include <radio.h>
+#include <wakelock.h>
#include "crespo_modem_ctl.h"
#include "crespo_ipc.h"
#include "ipc_private.h"
-int wake_lock_fd = -1;
-int wake_unlock_fd = -1;
-
-int wake_lock(char *lock_name, int len)
-{
- int rc = 0;
-
- if(wake_lock_fd < 0)
- wake_lock_fd = open("/sys/power/wake_lock", O_RDWR);
-
- rc = write(wake_lock_fd, lock_name, len);
-
- return rc;
-}
-
-int wake_unlock(char *lock_name, int len)
-{
- int rc = 0;
-
- if(wake_unlock_fd < 0)
- wake_unlock_fd = open("/sys/power/wake_unlock", O_RDWR);
-
- rc = write(wake_unlock_fd, lock_name, len);
-
- return rc;
-}
-
int crespo_modem_bootstrap(struct ipc_client *client)
{
int s3c2410_serial3_fd = -1;
@@ -388,7 +362,7 @@ int crespo_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_inf
memset(response, 0, sizeof(struct ipc_message_info));
- wake_lock("secril_fmt-interface", 20);
+ wake_lock("secril_fmt-interface");
assert(client->handlers->read != NULL);
bread = client->handlers->read((uint8_t*) &modem_data, sizeof(struct modem_io) + MAX_MODEM_DATA_SIZE, client->handlers->read_data);
@@ -425,7 +399,7 @@ int crespo_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_inf
ipc_client_log_recv(client, response, __func__);
- wake_unlock("secril_fmt-interface", 20);
+ wake_unlock("secril_fmt-interface");
return 0;
}
@@ -441,7 +415,7 @@ int crespo_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_inf
memset(response, 0, sizeof(struct ipc_message_info));
- wake_lock("secril_rfs-interface", 20);
+ wake_lock("secril_rfs-interface");
assert(client->handlers->read != NULL);
bread = client->handlers->read((uint8_t*) &modem_data, sizeof(struct modem_io) + MAX_MODEM_DATA_SIZE, client->handlers->read_data);
@@ -475,7 +449,7 @@ int crespo_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_inf
ipc_client_log_recv(client, response, __func__);
- wake_unlock("secril_rfs-interface", 20);
+ wake_unlock("secril_rfs-interface");
return 0;
}
diff --git a/samsung-ipc/device/crespo/crespo_ipc.h b/samsung-ipc/device/crespo/crespo_ipc.h
index 2cc6ef3..47c8da8 100644
--- a/samsung-ipc/device/crespo/crespo_ipc.h
+++ b/samsung-ipc/device/crespo/crespo_ipc.h
@@ -30,9 +30,6 @@
#define GPRS_IFACE_PREFIX "rmnet"
-int wake_lock(char *lock_name, int len);
-int wake_unlock(char *lock_name, int len);
-
extern struct ipc_handlers crespo_ipc_default_handlers;
#endif
diff --git a/samsung-ipc/device/maguro/maguro_ipc.c b/samsung-ipc/device/maguro/maguro_ipc.c
index fb4121d..19b5ba4 100644
--- a/samsung-ipc/device/maguro/maguro_ipc.c
+++ b/samsung-ipc/device/maguro/maguro_ipc.c
@@ -48,7 +48,7 @@ struct ipc_handlers maguro_default_handlers = {
.open = xmm6260_ipc_open,
.close = xmm6260_ipc_close,
.power_on = xmm6260_ipc_power_on,
- .power_off = xmm6260_ipc_power_off,
+ .power_off = maguro_power_off,
.common_data = NULL,
.common_data_create = xmm6260_ipc_common_data_create,
.common_data_destroy = xmm6260_ipc_common_data_destroy,
diff --git a/samsung-ipc/device/maguro/maguro_loader.c b/samsung-ipc/device/maguro/maguro_loader.c
index 565c605..84de38d 100644
--- a/samsung-ipc/device/maguro/maguro_loader.c
+++ b/samsung-ipc/device/maguro/maguro_loader.c
@@ -628,6 +628,28 @@ fail:
return ret;
}
+int maguro_power_off(void *io_data_unused) {
+ int ret = -1;
+ struct modemctl_io_data io_data;
+
+ io_data.boot_fd = open(BOOT_DEV, O_RDWR | O_NOCTTY | O_NONBLOCK);
+ if (io_data.boot_fd < 0) {
+ ret = io_data.boot_fd;
+ goto fail;
+ }
+
+ if ((ret = modemctl_modem_power(NULL, &io_data, false)) < 0) {
+ goto fail_pwr;
+ }
+
+ ret = 0;
+
+fail_pwr:
+ close(io_data.boot_fd);
+fail:
+ return ret;
+}
+
int maguro_modem_bootstrap(struct ipc_client *client)
{
int ret = -1;
@@ -708,7 +730,7 @@ int maguro_modem_bootstrap(struct ipc_client *client)
goto fail;
}
ipc_client_log(client, "got bootloader reply %08x", id_buf);
- if (id_buf == I9250_BOOT_LAST_MARKER) {
+ if ((id_buf & I9250_BOOT_LAST_MASK) == I9250_BOOT_LAST_MASK) {
ret = 0;
break;
}
diff --git a/samsung-ipc/device/maguro/maguro_loader.h b/samsung-ipc/device/maguro/maguro_loader.h
index 7a47635..e8bb448 100644
--- a/samsung-ipc/device/maguro/maguro_loader.h
+++ b/samsung-ipc/device/maguro/maguro_loader.h
@@ -30,7 +30,7 @@
#define I9250_RADIO_IMAGE "/dev/block/platform/omap/omap_hsmmc.0/by-name/radio"
#define I9250_SECOND_BOOT_DEV "/dev/umts_boot1"
-#define I9250_BOOT_LAST_MARKER 0x0030ffff
+#define I9250_BOOT_LAST_MASK 0x0000ffff
#define I9250_BOOT_REPLY_MAX 20
#define I9250_GENERAL_ACK "\x02\x00\x00\x00"
@@ -98,6 +98,7 @@ struct maguro_boot_tail_header name = {\
}
int maguro_modem_bootstrap(struct ipc_client *client);
+int maguro_power_off(void *io_data);
#endif
diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.c b/samsung-ipc/device/xmm6260/xmm6260_ipc.c
index 8364ffc..b438c5d 100644
--- a/samsung-ipc/device/xmm6260/xmm6260_ipc.c
+++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.c
@@ -38,6 +38,7 @@
#include <assert.h>
#include <radio.h>
+#include <wakelock.h>
#include "ipc_private.h"
@@ -46,12 +47,17 @@
#include "xmm6260_modemctl.h"
#include "modem_prj.h"
+#define FMT_LOCK_NAME "xmm6260-fmt-lock"
+#define RFS_LOCK_NAME "xmm6260-rfs-lock"
+
int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info *request)
{
struct ipc_header *hdr;
unsigned char *frame;
unsigned char *payload;
size_t frame_length;
+
+ wake_lock(FMT_LOCK_NAME);
/* Frame IPC header + payload length */
frame_length = (sizeof(*hdr) + request->length);
@@ -77,6 +83,8 @@ int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_in
free(frame);
+ wake_unlock(FMT_LOCK_NAME);
+
return 0;
}
@@ -92,14 +100,19 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in
int num_read = 0;
int left = 0;
+ if (!client || !response)
+ return -1;
+
+ wake_lock(FMT_LOCK_NAME);
+
num_read = client->handlers->read(buf, IPC_MAX_XFER,
client->handlers->read_data);
- if (num_read < 0) {
+ if (num_read <= 0) {
ipc_client_log(client, "read failed to read ipc length: %d", num_read);
response->data = 0;
response->length = 0;
- return 0;
+ goto done;
}
memcpy(&ipc, buf, sizeof(ipc));
@@ -119,12 +132,16 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in
response->type = ipc.type;
response->cmd = IPC_COMMAND(response);
response->length = ipc.length - sizeof(ipc);
-
- response->data = (unsigned char*)malloc(response->length);
- memcpy(response->data, buf + sizeof(ipc), response->length);
+
+ if (response->length > 0) {
+ response->data = (unsigned char*)malloc(response->length);
+ memcpy(response->data, buf + sizeof(ipc), response->length);
+ }
ipc_client_log_recv(client, response, __func__);
+done:
+ wake_unlock(FMT_LOCK_NAME);
return 0;
}
@@ -136,12 +153,17 @@ int xmm6260_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_in
unsigned count=0;
int rc;
+ int ret = 0;
+
+ wake_lock(RFS_LOCK_NAME);
+
do {
rc = client->handlers->read(buf, IPC_MAX_XFER, client->handlers->read_data);
if (rc < 0) {
ipc_client_log(client, "Failed to read RFS data.");
- return -1;
+ ret = -1;
+ goto done;
}
ipc_client_log(client, "received %d bytes", rc);
@@ -149,14 +171,16 @@ int xmm6260_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_in
if (!header_recv) {
if ((unsigned)rc < sizeof(struct rfs_hdr)) {
ipc_client_log(client, "Failed to read RFS data.");
- return -1;
+ ret = -1;
+ goto done;
}
memcpy((void *) &header, (void *) buf, sizeof(struct rfs_hdr));
if (header.size < sizeof(struct rfs_hdr)) {
ipc_client_log(client, "Invalid size in header");
- return -1;
+ ret = -1;
+ goto done;
}
response->mseq = 0;
@@ -185,7 +209,10 @@ int xmm6260_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_in
ipc_client_log_recv(client, response, __func__);
- return 0;
+done:
+
+ wake_unlock(RFS_LOCK_NAME);
+ return ret;
}
int xmm6260_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_info *request)
@@ -195,6 +222,8 @@ int xmm6260_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_in
int data_length;
int rc;
+ wake_lock(RFS_LOCK_NAME);
+
data_length = sizeof(struct rfs_hdr) + request->length;
data = malloc(data_length);
memset(data, 0, data_length);
@@ -209,6 +238,8 @@ int xmm6260_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_in
ipc_client_log_send(client, request, __func__);
rc = client->handlers->write(data, data_length, client->handlers->write_data);
+
+ wake_unlock(RFS_LOCK_NAME);
return rc;
}
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c
index 91dbf15..993a3ab 100644
--- a/samsung-ipc/ipc.c
+++ b/samsung-ipc/ipc.c
@@ -48,7 +48,9 @@ void log_handler_default(const char *message, void *user_data)
void ipc_client_log(struct ipc_client *client, const char *message, ...)
{
- assert(client->log_handler != NULL);
+ if (!message || !client || !client->log_handler) {
+ return;
+ }
va_list args;
char buffer[4096];
diff --git a/samsung-ipc/wakelock.c b/samsung-ipc/wakelock.c
new file mode 100644
index 0000000..1daaec9
--- /dev/null
+++ b/samsung-ipc/wakelock.c
@@ -0,0 +1,60 @@
+/**
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2012 Alexander Tarasikov <alexander.tarasikov@gmail.com>
+ *
+ * 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 <assert.h>
+#include <fcntl.h>
+#include <wakelock.h>
+
+static int wake_lock_fd = -1;
+static int wake_unlock_fd = -1;
+
+int wake_lock(char *lock_name) {
+ int rc;
+ assert(lock_name != NULL);
+
+ if (wake_lock_fd < 0) {
+ wake_lock_fd = open("/sys/power/wake_lock", O_RDWR);
+ }
+
+ if (wake_lock_fd < 0) {
+ return wake_lock_fd;
+ }
+
+ rc = write(wake_lock_fd, lock_name, strlen(lock_name));
+
+ return rc;
+}
+
+int wake_unlock(char *lock_name) {
+ int rc;
+ assert(lock_name != NULL);
+
+ if (wake_unlock_fd < 0) {
+ wake_unlock_fd = open("/sys/power/wake_unlock", O_RDWR);
+ }
+
+ if (wake_unlock_fd < 0) {
+ return wake_lock_fd;
+ }
+
+ rc = write(wake_unlock_fd, lock_name, strlen(lock_name));
+
+ return rc;
+}