Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make wakelocks not crespo-specific and add for xmm6260

  • Loading branch information...
commit e4403cb5b5da34430356d1d7aedecfeca48d59e3 1 parent 89904c0
Alexander Tarasikov astarasikov authored
1  Android.mk
View
@@ -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 \
1  include/Makefile.am
View
@@ -16,6 +16,7 @@ samsung_ipcinclude_HEADERS = \
gprs.h \
snd.h \
rfs.h \
+ wakelock.h \
$(NULL)
samsung_ipc_v4includedir = $(includedir)/samsung-ipc-1.0/device/ipc-v4/
27 include/wakelock.h
View
@@ -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__
1  samsung-ipc/Makefile.am
View
@@ -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 \
36 samsung-ipc/device/crespo/crespo_ipc.c
View
@@ -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;
@@ -360,7 +334,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);
@@ -396,7 +370,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;
}
@@ -412,7 +386,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);
@@ -446,7 +420,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;
}
3  samsung-ipc/device/crespo/crespo_ipc.h
View
@@ -30,9 +30,6 @@
#define GPRS_IFACE "rmnet0"
-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
36 samsung-ipc/device/xmm6260/xmm6260_ipc.c
View
@@ -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;
}
6 samsung-ipc/rfs.c
View
@@ -113,7 +113,7 @@ int nv_data_size(struct ipc_client *client)
{
if (client == NULL ||
client->nv_data_specs == NULL ||
- client->nv_data_specs->nv_data_size == NULL)
+ client->nv_data_specs->nv_data_size == 0)
return NV_DATA_SIZE_DEFAULT;
return client->nv_data_specs->nv_data_size;
@@ -123,7 +123,7 @@ int nv_data_chunk_size(struct ipc_client *client)
{
if (client == NULL ||
client->nv_data_specs == NULL ||
- client->nv_data_specs->nv_data_chunk_size == NULL)
+ client->nv_data_specs->nv_data_chunk_size == 0)
return NV_DATA_CHUNK_SIZE_DEFAULT;
return client->nv_data_specs->nv_data_chunk_size;
@@ -714,7 +714,7 @@ void ipc_rfs_send_io_confirm_for_nv_read_item(struct ipc_client *client, struct
if (rfs_io == NULL)
{
ipc_client_log(client, "ERROR: Request message is invalid: aseq = %i", info->aseq);
- return NULL;
+ return;
}
rfs_io_conf = malloc(rfs_io->length + sizeof(struct ipc_rfs_io_confirm));
53 samsung-ipc/wakelock.c
View
@@ -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;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.