diff options
author | Alexander Tarasikov <alexander.tarasikov@gmail.com> | 2012-08-24 20:52:39 +0400 |
---|---|---|
committer | Alexander Tarasikov <alexander.tarasikov@gmail.com> | 2012-08-24 20:52:39 +0400 |
commit | 74f505ceb284bf2d286c834b588f5cbf73cf2731 (patch) | |
tree | 99b2fd07d1ffa211c123514840a48d9fbee20ee7 /samsung-ipc | |
parent | 5999a66ad4405527dfca6c823bce2ce5b0eef0e1 (diff) | |
parent | 4bd59903ac2a4697241730d1d30476f2be088414 (diff) | |
download | external_libsamsung-ipc-74f505ceb284bf2d286c834b588f5cbf73cf2731.zip external_libsamsung-ipc-74f505ceb284bf2d286c834b588f5cbf73cf2731.tar.gz external_libsamsung-ipc-74f505ceb284bf2d286c834b588f5cbf73cf2731.tar.bz2 |
Merge tag 'tuna-stc-jb-v1' into morphis-master
Conflicts:
samsung-ipc/device/maguro/maguro_loader.c
Diffstat (limited to 'samsung-ipc')
-rw-r--r-- | samsung-ipc/Makefile.am | 1 | ||||
-rw-r--r-- | samsung-ipc/device/crespo/crespo_ipc.c | 36 | ||||
-rw-r--r-- | samsung-ipc/device/crespo/crespo_ipc.h | 3 | ||||
-rw-r--r-- | samsung-ipc/device/maguro/maguro_ipc.c | 2 | ||||
-rw-r--r-- | samsung-ipc/device/maguro/maguro_loader.c | 22 | ||||
-rw-r--r-- | samsung-ipc/device/maguro/maguro_loader.h | 1 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_ipc.c | 36 | ||||
-rw-r--r-- | samsung-ipc/ipc.c | 4 | ||||
-rw-r--r-- | samsung-ipc/wakelock.c | 53 |
9 files changed, 117 insertions, 41 deletions
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 576fd92..83e7877 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); @@ -424,7 +398,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; } @@ -440,7 +414,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); @@ -474,7 +448,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..cd1e1ac 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; diff --git a/samsung-ipc/device/maguro/maguro_loader.h b/samsung-ipc/device/maguro/maguro_loader.h index 7a47635..cb059fc 100644 --- a/samsung-ipc/device/maguro/maguro_loader.h +++ b/samsung-ipc/device/maguro/maguro_loader.h @@ -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 5f4aad1..9e595e9 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,6 +100,8 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in int num_read = 0; int left = 0; + wake_lock(FMT_LOCK_NAME); + num_read = client->handlers->read(buf, IPC_MAX_XFER, client->handlers->read_data); @@ -99,7 +109,7 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in 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)); @@ -124,6 +134,8 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in ipc_client_log_recv(client, response, __func__); +done: + wake_unlock(FMT_LOCK_NAME); return 0; } @@ -135,12 +147,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); @@ -148,14 +165,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; @@ -184,7 +203,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) @@ -194,6 +216,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); @@ -208,6 +232,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 ee27c4d..8cd2488 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..ea28048 --- /dev/null +++ b/samsung-ipc/wakelock.c @@ -0,0 +1,53 @@ +/** + * 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> + +int wake_lock(char *lock_name) { + int rc; + assert(lock_name != NULL); + + int fd = open("/sys/power/wake_lock", O_RDWR); + if (fd < 0) { + return fd; + } + + rc = write(fd, lock_name, strlen(lock_name)); + close(fd); + + return rc; +} + +int wake_unlock(char *lock_name) { + int rc; + assert(lock_name != NULL); + + int fd = open("/sys/power/wake_unlock", O_RDWR); + if (fd < 0) { + return fd; + } + + rc = write(fd, lock_name, strlen(lock_name)); + close(fd); + + return rc; +} |