aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2014-01-12 16:14:11 +0100
committerPaul Kocialkowski <contact@paulk.fr>2014-01-13 17:00:36 +0100
commitf8bc990449be8d9724826ce068645a40939ffbef (patch)
treed74abfa45a86c87a5dfb257c35f5e5d418c4ac90
parent0c33d964e0c14c0af80f830a3b1837597ddcd034 (diff)
downloadexternal_libsamsung-ipc-f8bc990449be8d9724826ce068645a40939ffbef.zip
external_libsamsung-ipc-f8bc990449be8d9724826ce068645a40939ffbef.tar.gz
external_libsamsung-ipc-f8bc990449be8d9724826ce068645a40939ffbef.tar.bz2
Device detection mechanism improvments and more constitant devices naming
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--Android.mk57
-rw-r--r--samsung-ipc/device/galaxys3/galaxys3_ipc.h49
-rw-r--r--samsung-ipc/device/i9300/i9300_ipc.c (renamed from samsung-ipc/device/galaxys3/galaxys3_ipc.c)122
-rw-r--r--samsung-ipc/device/i9300/i9300_ipc.h49
-rw-r--r--samsung-ipc/ipc.c113
-rw-r--r--samsung-ipc/ipc_devices.c26
-rw-r--r--samsung-ipc/ipc_devices.h2
7 files changed, 203 insertions, 215 deletions
diff --git a/Android.mk b/Android.mk
index a503059..1f3e4b9 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,57 +1,36 @@
-BUILD_IPC-MODEMCTRL := true
-DEBUG := true
-
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
+DEBUG := true
+
LOCAL_MODULE := libsamsung-ipc
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := external/openssl/include
LOCAL_LDFLAGS += -lcrypto
-ifeq ($(TARGET_DEVICE),crespo)
- board_name := herring
+ifneq (,$(filter crespo,$(TARGET_DEVICE)))
+ ipc_device_name := crespo
endif
-ifeq ($(TARGET_DEVICE),galaxysmtd)
- board_name := aries
+ifneq (,$(filter galaxysmtd galaxytab,$(TARGET_DEVICE)))
+ ipc_device_name := aries
endif
-ifeq ($(TARGET_DEVICE),galaxytab)
- board_name := gt-p1000
+ifneq (,$(filter maguro,$(TARGET_DEVICE)))
+ ipc_device_name := maguro
endif
-ifeq ($(TARGET_DEVICE),maguro)
- board_name := tuna
+ifneq (,$(filter p5100 p3100,$(TARGET_DEVICE)))
+ ipc_device_name := piranha
endif
-ifeq ($(TARGET_DEVICE),p5100)
- board_name := espresso10
+ifneq (,$(filter i9100 galaxys2 n7000,$(TARGET_DEVICE)))
+ ipc_device_name := galaxys2
endif
-ifeq ($(TARGET_DEVICE),p3100)
- board_name := espresso
-endif
-
-ifeq ($(TARGET_DEVICE),i9100)
- board_name := smdk4210
-endif
-
-ifeq ($(TARGET_DEVICE),galaxys2)
- board_name := smdk4210
-endif
-
-ifeq ($(TARGET_DEVICE),n7000)
- board_name := smdk4210
-endif
-
-ifeq ($(TARGET_DEVICE),i9300)
- board_name := smdk4x12
-endif
-
-ifeq ($(TARGET_DEVICE),galaxys3)
- board_name := smdk4x12
+ifneq (,$(filter i9300,$(TARGET_DEVICE)))
+ ipc_device_name := i9300
endif
ifeq ($(DEBUG),true)
@@ -80,12 +59,12 @@ samsung-ipc_files := \
samsung-ipc/device/crespo/crespo_ipc.c \
samsung-ipc/device/aries/aries_ipc.c \
samsung-ipc/device/galaxys2/galaxys2_ipc.c \
- samsung-ipc/device/galaxys3/galaxys3_ipc.c \
+ samsung-ipc/device/i9300/i9300_ipc.c \
samsung-ipc/device/maguro/maguro_ipc.c \
samsung-ipc/device/piranha/piranha_ipc.c
LOCAL_SRC_FILES := $(samsung-ipc_files)
-LOCAL_CFLAGS += -DIPC_BOARD_NAME_EXPLICIT=\"$(board_name)\"
+LOCAL_CFLAGS += -DIPC_DEVICE_NAME=\"$(ipc_device_name)\"
LOCAL_SHARED_LIBRARIES := libutils
LOCAL_C_INCLUDES += \
@@ -96,8 +75,6 @@ LOCAL_C_INCLUDES += \
include $(BUILD_STATIC_LIBRARY)
-ifeq ($(BUILD_IPC-MODEMCTRL),true)
-
include $(CLEAR_VARS)
LOCAL_MODULE := ipc-modemctrl
@@ -117,5 +94,3 @@ LOCAL_SHARED_LIBRARIES := libutils
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
include $(BUILD_EXECUTABLE)
-
-endif
diff --git a/samsung-ipc/device/galaxys3/galaxys3_ipc.h b/samsung-ipc/device/galaxys3/galaxys3_ipc.h
deleted file mode 100644
index 8e5f64a..0000000
--- a/samsung-ipc/device/galaxys3/galaxys3_ipc.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This file is part of libsamsung-ipc.
- *
- * Copyright (C) 2013 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 2 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 __GALAXYS3_IPC_H__
-#define __GALAXYS3_IPC_H__
-
-#define GALAXYS3_MODEM_IMAGE_SIZE 0x1000000
-#define GALAXYS3_PSI_OFFSET 0x1000
-#define GALAXYS3_PSI_SIZE 0xE000
-#define GALAXYS3_EBL_OFFSET 0xF000
-#define GALAXYS3_EBL_SIZE 0x19000
-#define GALAXYS3_SEC_START_OFFSET 0x9FF800
-#define GALAXYS3_SEC_START_SIZE 0x800
-#define GALAXYS3_FIRMWARE_OFFSET 0x28000
-#define GALAXYS3_FIRMWARE_SIZE 0x9D7800
-#define GALAXYS3_NV_DATA_OFFSET 0xA00000
-#define GALAXYS3_NV_DATA_SIZE 0x200000
-
-#define GALAXYS3_MODEM_IMAGE_DEVICE "/dev/block/mmcblk0p7"
-
-struct galaxys3_ipc_transport_data {
- int fd;
-};
-
-extern struct ipc_ops galaxys3_ipc_fmt_ops;
-extern struct ipc_ops galaxys3_ipc_rfs_ops;
-extern struct ipc_handlers galaxys3_ipc_handlers;
-extern struct ipc_gprs_specs galaxys3_ipc_gprs_specs;
-
-#endif
-
-// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/device/galaxys3/galaxys3_ipc.c b/samsung-ipc/device/i9300/i9300_ipc.c
index 39da41b..59c2eb5 100644
--- a/samsung-ipc/device/galaxys3/galaxys3_ipc.c
+++ b/samsung-ipc/device/i9300/i9300_ipc.c
@@ -29,9 +29,9 @@
#include "xmm6260.h"
#include "xmm6260_hsic.h"
#include "xmm6260_sec_modem.h"
-#include "galaxys3_ipc.h"
+#include "i9300_ipc.h"
-int galaxys3_ipc_bootstrap(struct ipc_client *client)
+int i9300_ipc_bootstrap(struct ipc_client *client)
{
void *modem_image_data = NULL;
int modem_image_fd = -1;
@@ -44,16 +44,16 @@ int galaxys3_ipc_bootstrap(struct ipc_client *client)
if (client == NULL)
return -1;
- ipc_client_log(client, "Starting galaxys3 modem bootstrap");
+ ipc_client_log(client, "Starting i9300 modem bootstrap");
- modem_image_fd = open(GALAXYS3_MODEM_IMAGE_DEVICE, O_RDONLY);
+ modem_image_fd = open(I9300_MODEM_IMAGE_DEVICE, O_RDONLY);
if (modem_image_fd < 0) {
ipc_client_log(client, "Opening modem image device failed");
goto error;
}
ipc_client_log(client, "Opened modem image device");
- modem_image_data = mmap(0, GALAXYS3_MODEM_IMAGE_SIZE, PROT_READ, MAP_SHARED, modem_image_fd, 0);
+ modem_image_data = mmap(0, I9300_MODEM_IMAGE_SIZE, PROT_READ, MAP_SHARED, modem_image_fd, 0);
if (modem_image_data == NULL || modem_image_data == (void *) 0xffffffff) {
ipc_client_log(client, "Mapping modem image data to memory failed");
goto error;
@@ -97,18 +97,18 @@ int galaxys3_ipc_bootstrap(struct ipc_client *client)
}
ipc_client_log(client, "Waited for link connected");
- p = (unsigned char *) modem_image_data + GALAXYS3_PSI_OFFSET;
+ p = (unsigned char *) modem_image_data + I9300_PSI_OFFSET;
- rc = xmm6260_hsic_psi_send(client, modem_boot_fd, (void *) p, GALAXYS3_PSI_SIZE);
+ rc = xmm6260_hsic_psi_send(client, modem_boot_fd, (void *) p, I9300_PSI_SIZE);
if (rc < 0) {
ipc_client_log(client, "Sending XMM6260 HSIC PSI failed");
goto error;
}
ipc_client_log(client, "Sent XMM6260 HSIC PSI");
- p = (unsigned char *) modem_image_data + GALAXYS3_EBL_OFFSET;
+ p = (unsigned char *) modem_image_data + I9300_EBL_OFFSET;
- rc = xmm6260_hsic_ebl_send(client, modem_boot_fd, (void *) p, GALAXYS3_EBL_SIZE);
+ rc = xmm6260_hsic_ebl_send(client, modem_boot_fd, (void *) p, I9300_EBL_SIZE);
if (rc < 0) {
ipc_client_log(client, "Sending XMM6260 HSIC EBL failed");
goto error;
@@ -122,18 +122,18 @@ int galaxys3_ipc_bootstrap(struct ipc_client *client)
}
ipc_client_log(client, "Sent XMM6260 HSIC port config");
- p = (unsigned char *) modem_image_data + GALAXYS3_SEC_START_OFFSET;
+ p = (unsigned char *) modem_image_data + I9300_SEC_START_OFFSET;
- rc = xmm6260_hsic_sec_start_send(client, modem_boot_fd, (void *) p, GALAXYS3_SEC_START_SIZE);
+ rc = xmm6260_hsic_sec_start_send(client, modem_boot_fd, (void *) p, I9300_SEC_START_SIZE);
if (rc < 0) {
ipc_client_log(client, "Sending XMM6260 HSIC SEC start failed");
goto error;
}
ipc_client_log(client, "Sent XMM6260 HSIC SEC start");
- p = (unsigned char *) modem_image_data + GALAXYS3_FIRMWARE_OFFSET;
+ p = (unsigned char *) modem_image_data + I9300_FIRMWARE_OFFSET;
- rc = xmm6260_hsic_firmware_send(client, modem_boot_fd, (void *) p, GALAXYS3_FIRMWARE_SIZE);
+ rc = xmm6260_hsic_firmware_send(client, modem_boot_fd, (void *) p, I9300_FIRMWARE_SIZE);
if (rc < 0) {
ipc_client_log(client, "Sending XMM6260 HSIC firmware failed");
goto error;
@@ -210,7 +210,7 @@ error:
complete:
if (modem_image_data != NULL)
- munmap(modem_image_data, GALAXYS3_MODEM_IMAGE_SIZE);
+ munmap(modem_image_data, I9300_MODEM_IMAGE_SIZE);
if (modem_image_fd >= 0)
close(modem_image_fd);
@@ -225,34 +225,34 @@ complete:
}
-int galaxys3_ipc_fmt_send(struct ipc_client *client, struct ipc_message_info *request)
+int i9300_ipc_fmt_send(struct ipc_client *client, struct ipc_message_info *request)
{
return xmm6260_sec_modem_ipc_fmt_send(client, request);
}
-int galaxys3_ipc_fmt_recv(struct ipc_client *client, struct ipc_message_info *response)
+int i9300_ipc_fmt_recv(struct ipc_client *client, struct ipc_message_info *response)
{
return xmm6260_sec_modem_ipc_fmt_recv(client, response);
}
-int galaxys3_ipc_rfs_send(struct ipc_client *client, struct ipc_message_info *request)
+int i9300_ipc_rfs_send(struct ipc_client *client, struct ipc_message_info *request)
{
return xmm6260_sec_modem_ipc_rfs_send(client, request);
}
-int galaxys3_ipc_rfs_recv(struct ipc_client *client, struct ipc_message_info *response)
+int i9300_ipc_rfs_recv(struct ipc_client *client, struct ipc_message_info *response)
{
return xmm6260_sec_modem_ipc_rfs_recv(client, response);
}
-int galaxys3_ipc_open(void *data, int type)
+int i9300_ipc_open(void *data, int type)
{
- struct galaxys3_ipc_transport_data *transport_data;
+ struct i9300_ipc_transport_data *transport_data;
if (data == NULL)
return -1;
- transport_data = (struct galaxys3_ipc_transport_data *) data;
+ transport_data = (struct i9300_ipc_transport_data *) data;
transport_data->fd = xmm6260_sec_modem_ipc_open(type);
if (transport_data->fd < 0)
@@ -261,14 +261,14 @@ int galaxys3_ipc_open(void *data, int type)
return 0;
}
-int galaxys3_ipc_close(void *data)
+int i9300_ipc_close(void *data)
{
- struct galaxys3_ipc_transport_data *transport_data;
+ struct i9300_ipc_transport_data *transport_data;
if (data == NULL)
return -1;
- transport_data = (struct galaxys3_ipc_transport_data *) data;
+ transport_data = (struct i9300_ipc_transport_data *) data;
xmm6260_sec_modem_ipc_close(transport_data->fd);
transport_data->fd = -1;
@@ -276,54 +276,54 @@ int galaxys3_ipc_close(void *data)
return 0;
}
-int galaxys3_ipc_read(void *data, void *buffer, unsigned int length)
+int i9300_ipc_read(void *data, void *buffer, unsigned int length)
{
- struct galaxys3_ipc_transport_data *transport_data;
+ struct i9300_ipc_transport_data *transport_data;
int rc;
if (data == NULL)
return -1;
- transport_data = (struct galaxys3_ipc_transport_data *) data;
+ transport_data = (struct i9300_ipc_transport_data *) data;
rc = xmm6260_sec_modem_ipc_read(transport_data->fd, buffer, length);
return rc;
}
-int galaxys3_ipc_write(void *data, void *buffer, unsigned int length)
+int i9300_ipc_write(void *data, void *buffer, unsigned int length)
{
- struct galaxys3_ipc_transport_data *transport_data;
+ struct i9300_ipc_transport_data *transport_data;
int rc;
if (data == NULL)
return -1;
- transport_data = (struct galaxys3_ipc_transport_data *) data;
+ transport_data = (struct i9300_ipc_transport_data *) data;
rc = xmm6260_sec_modem_ipc_write(transport_data->fd, buffer, length);
return rc;
}
-int galaxys3_ipc_poll(void *data, struct timeval *timeout)
+int i9300_ipc_poll(void *data, struct timeval *timeout)
{
- struct galaxys3_ipc_transport_data *transport_data;
+ struct i9300_ipc_transport_data *transport_data;
int rc;
if (data == NULL)
return -1;
- transport_data = (struct galaxys3_ipc_transport_data *) data;
+ transport_data = (struct i9300_ipc_transport_data *) data;
rc = xmm6260_sec_modem_ipc_poll(transport_data->fd, timeout);
return rc;
}
-int galaxys3_ipc_power_on(void *data)
+int i9300_ipc_power_on(void *data)
{
return 0;
}
-int galaxys3_ipc_power_off(void *data)
+int i9300_ipc_power_off(void *data)
{
int fd;
int rc;
@@ -342,18 +342,18 @@ int galaxys3_ipc_power_off(void *data)
return 0;
}
-int galaxys3_ipc_data_create(void **transport_data, void **power_data, void **gprs_data)
+int i9300_ipc_data_create(void **transport_data, void **power_data, void **gprs_data)
{
if (transport_data == NULL)
return -1;
- *transport_data = (void *) malloc(sizeof(struct galaxys3_ipc_transport_data));
- memset(*transport_data, 0, sizeof(struct galaxys3_ipc_transport_data));
+ *transport_data = (void *) malloc(sizeof(struct i9300_ipc_transport_data));
+ memset(*transport_data, 0, sizeof(struct i9300_ipc_transport_data));
return 0;
}
-int galaxys3_ipc_data_destroy(void *transport_data, void *power_data, void *gprs_data)
+int i9300_ipc_data_destroy(void *transport_data, void *power_data, void *gprs_data)
{
if (transport_data == NULL)
return -1;
@@ -363,49 +363,49 @@ int galaxys3_ipc_data_destroy(void *transport_data, void *power_data, void *gprs
return 0;
}
-char *galaxys3_ipc_gprs_get_iface(int cid)
+char *i9300_ipc_gprs_get_iface(int cid)
{
return xmm6260_sec_modem_ipc_gprs_get_iface(cid);
}
-int galaxys3_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *capabilities)
+int i9300_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *capabilities)
{
return xmm6260_sec_modem_ipc_gprs_get_capabilities(capabilities);
}
-struct ipc_ops galaxys3_ipc_fmt_ops = {
- .bootstrap = galaxys3_ipc_bootstrap,
- .send = galaxys3_ipc_fmt_send,
- .recv = galaxys3_ipc_fmt_recv,
+struct ipc_ops i9300_ipc_fmt_ops = {
+ .bootstrap = i9300_ipc_bootstrap,
+ .send = i9300_ipc_fmt_send,
+ .recv = i9300_ipc_fmt_recv,
};
-struct ipc_ops galaxys3_ipc_rfs_ops = {
+struct ipc_ops i9300_ipc_rfs_ops = {
.bootstrap = NULL,
- .send = galaxys3_ipc_rfs_send,
- .recv = galaxys3_ipc_rfs_recv,
+ .send = i9300_ipc_rfs_send,
+ .recv = i9300_ipc_rfs_recv,
};
-struct ipc_handlers galaxys3_ipc_handlers = {
- .read = galaxys3_ipc_read,
- .write = galaxys3_ipc_write,
- .open = galaxys3_ipc_open,
- .close = galaxys3_ipc_close,
- .poll = galaxys3_ipc_poll,
+struct ipc_handlers i9300_ipc_handlers = {
+ .read = i9300_ipc_read,
+ .write = i9300_ipc_write,
+ .open = i9300_ipc_open,
+ .close = i9300_ipc_close,
+ .poll = i9300_ipc_poll,
.transport_data = NULL,
- .power_on = galaxys3_ipc_power_on,
- .power_off = galaxys3_ipc_power_off,
+ .power_on = i9300_ipc_power_on,
+ .power_off = i9300_ipc_power_off,
.power_data = NULL,
.gprs_activate = NULL,
.gprs_deactivate = NULL,
.gprs_data = NULL,
- .data_create = galaxys3_ipc_data_create,
- .data_destroy = galaxys3_ipc_data_destroy,
+ .data_create = i9300_ipc_data_create,
+ .data_destroy = i9300_ipc_data_destroy,
};
-struct ipc_gprs_specs galaxys3_ipc_gprs_specs = {
- .gprs_get_iface = galaxys3_ipc_gprs_get_iface,
- .gprs_get_capabilities = galaxys3_ipc_gprs_get_capabilities,
+struct ipc_gprs_specs i9300_ipc_gprs_specs = {
+ .gprs_get_iface = i9300_ipc_gprs_get_iface,
+ .gprs_get_capabilities = i9300_ipc_gprs_get_capabilities,
};
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/device/i9300/i9300_ipc.h b/samsung-ipc/device/i9300/i9300_ipc.h
new file mode 100644
index 0000000..4ab80e7
--- /dev/null
+++ b/samsung-ipc/device/i9300/i9300_ipc.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2013 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 2 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 __I9300_IPC_H__
+#define __I9300_IPC_H__
+
+#define I9300_MODEM_IMAGE_SIZE 0x1000000
+#define I9300_PSI_OFFSET 0x1000
+#define I9300_PSI_SIZE 0xE000
+#define I9300_EBL_OFFSET 0xF000
+#define I9300_EBL_SIZE 0x19000
+#define I9300_SEC_START_OFFSET 0x9FF800
+#define I9300_SEC_START_SIZE 0x800
+#define I9300_FIRMWARE_OFFSET 0x28000
+#define I9300_FIRMWARE_SIZE 0x9D7800
+#define I9300_NV_DATA_OFFSET 0xA00000
+#define I9300_NV_DATA_SIZE 0x200000
+
+#define I9300_MODEM_IMAGE_DEVICE "/dev/block/mmcblk0p7"
+
+struct i9300_ipc_transport_data {
+ int fd;
+};
+
+extern struct ipc_ops i9300_ipc_fmt_ops;
+extern struct ipc_ops i9300_ipc_rfs_ops;
+extern struct ipc_handlers i9300_ipc_handlers;
+extern struct ipc_gprs_specs i9300_ipc_gprs_specs;
+
+#endif
+
+// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c
index 49027c3..c3add84 100644
--- a/samsung-ipc/ipc.c
+++ b/samsung-ipc/ipc.c
@@ -43,48 +43,61 @@
int ipc_device_detect(void)
{
+ char buffer[4096] = { 0 };
+ struct utsname utsname;
char *board_name = NULL;
char *kernel_version = NULL;
+ char *name = NULL;
+ char *line, *p, *c;
int index = -1;
+ int fd = -1;
+ int length;
+ int rc;
int i;
-#ifdef IPC_BOARD_NAME_EXPLICIT
- board_name = strdup(IPC_BOARD_NAME_EXPLICIT);
+#ifdef IPC_DEVICE_NAME
+ name = strdup(IPC_DEVICE_NAME);
+#endif
+
+#ifdef IPC_DEVICE_BOARD_NAME
+ board_name = strdup(IPC_DEVICE_BOARD_NAME);
#else
- char buf[4096];
+ // Read board name from cpuinfo
+
+ fd = open("/proc/cpuinfo", O_RDONLY);
+ if (fd < 0)
+ goto error;
+
+ length = sizeof(buffer);
+ length = read(fd, &buffer, length);
- // gather board name type from /proc/cpuinfo
- int fd = open("/proc/cpuinfo", O_RDONLY);
- int bytesread = read(fd, buf, 4096);
close(fd);
+ fd = -1;
- // match hardware name with our supported devices
- char *pch = strtok(buf, "\n");
- while (pch != NULL)
- {
- int rc;
- if ((rc = strncmp(pch, "Hardware", 9)) == 9)
- {
- char *str = (void *) (pch + 9);
- int len = strlen(str);
- char tmp;
-
- for (i=0; i < len; i++)
- {
- tmp = (char) tolower(str[i]);
- str[i] = tmp;
+ line = strtok(buffer, "\n");
+ while (line != NULL) {
+ if (strncmp(line, "Hardware", 9) == 9) {
+ p = line + 11;
+ c = p;
+
+ while (*c != '\n' && *c != '\0') {
+ *c = tolower(*c);
+ c++;
}
- board_name = strdup(pch);
+ *c = '\0';
+
+ board_name = strdup(p);
+ break;
}
- pch = strtok(NULL, "\n");
+
+ line = strtok(NULL, "\n");
}
#endif
-#ifdef IPC_KERNEL_VERSION_EXPLICIT
- kernel_version = strdup(IPC_KERNEL_VERSION_EXPLICIT);
+#ifdef IPC_DEVICE_KERNEL_VERSION
+ kernel_version = strdup(IPC_DEVICE_KERNEL_VERSION);
#else
- struct utsname utsname;
memset(&utsname, 0, sizeof(utsname));
uname(&utsname);
@@ -92,33 +105,43 @@ int ipc_device_detect(void)
kernel_version = strdup(utsname.release);
#endif
- for (i=0; i < ipc_devices_count; i++)
- {
- if (strstr(board_name, ipc_devices[i].board_name) != NULL)
- {
- if (ipc_devices[i].kernel_version != NULL)
- {
- if (strncmp(kernel_version, ipc_devices[i].kernel_version, strlen(ipc_devices[i].kernel_version)) == 0)
- {
- index = i;
- break;
- } else {
- // Kernel version didn't match but it may still work
- index = i;
- }
- } else {
- index = i;
- break;
- }
- }
+ for (i = 0; i < ipc_devices_count; i++) {
+ // Eliminate index if the name doesn't match
+ if (name != NULL && ipc_devices[i].name != NULL && strcmp(name, ipc_devices[i].name) != 0)
+ continue;
+
+ // Eliminate index if the board name doesn't match
+ if (board_name != NULL && ipc_devices[i].board_name != NULL && strcmp(board_name, ipc_devices[i].board_name) != 0)
+ continue;
+
+ // Keep index but don't break yet since we may have a better match with kernel version
+ index = i;
+
+ if (kernel_version == NULL || ipc_devices[i].kernel_version == NULL)
+ continue;
+
+ if (kernel_version != NULL && ipc_devices[i].kernel_version != NULL && strcmp(kernel_version, ipc_devices[i].kernel_version) != 0)
+ continue;
+
+ // Everything matches this particular index
+ break;
}
+ goto complete;
+
+error:
+ index = -1;
+
+complete:
if (board_name != NULL)
free(board_name);
if (kernel_version != NULL)
free(kernel_version);
+ if (fd >= 0)
+ close(fd);
+
return index;
}
diff --git a/samsung-ipc/ipc_devices.c b/samsung-ipc/ipc_devices.c
index 0b91fa0..138b2e9 100644
--- a/samsung-ipc/ipc_devices.c
+++ b/samsung-ipc/ipc_devices.c
@@ -67,7 +67,7 @@ struct ipc_device_desc ipc_devices[] = {
},
{
.name = "galaxys2",
- .board_name = "i9100",
+ .board_name = "smdk4210",
.kernel_version = NULL,
.fmt_ops = &galaxys2_ipc_fmt_ops,
.rfs_ops = &galaxys2_ipc_rfs_ops,
@@ -77,7 +77,7 @@ struct ipc_device_desc ipc_devices[] = {
},
{
.name = "galaxys2",
- .board_name = "smdk4210",
+ .board_name = "i9100",
.kernel_version = NULL,
.fmt_ops = &galaxys2_ipc_fmt_ops,
.rfs_ops = &galaxys2_ipc_rfs_ops,
@@ -86,23 +86,13 @@ struct ipc_device_desc ipc_devices[] = {
.nv_data_specs = NULL,
},
{
- .name = "galaxys3",
- .board_name = "i9300",
- .kernel_version = NULL,
- .fmt_ops = &galaxys3_ipc_fmt_ops,
- .rfs_ops = &galaxys3_ipc_rfs_ops,
- .handlers = &galaxys3_ipc_handlers,
- .gprs_specs = &galaxys3_ipc_gprs_specs,
- .nv_data_specs = NULL,
- },
- {
- .name = "galaxys3",
+ .name = "i9300",
.board_name = "smdk4x12",
.kernel_version = NULL,
- .fmt_ops = &galaxys3_ipc_fmt_ops,
- .rfs_ops = &galaxys3_ipc_rfs_ops,
- .handlers = &galaxys3_ipc_handlers,
- .gprs_specs = &galaxys3_ipc_gprs_specs,
+ .fmt_ops = &i9300_ipc_fmt_ops,
+ .rfs_ops = &i9300_ipc_rfs_ops,
+ .handlers = &i9300_ipc_handlers,
+ .gprs_specs = &i9300_ipc_gprs_specs,
.nv_data_specs = NULL,
},
{
@@ -134,7 +124,7 @@ struct ipc_device_desc ipc_devices[] = {
.handlers = &piranha_ipc_handlers,
.gprs_specs = &piranha_ipc_gprs_specs,
.nv_data_specs = NULL,
- }
+ },
};
int ipc_devices_count = sizeof(ipc_devices) / sizeof(struct ipc_device_desc);
diff --git a/samsung-ipc/ipc_devices.h b/samsung-ipc/ipc_devices.h
index 316f8f4..1dd5fab 100644
--- a/samsung-ipc/ipc_devices.h
+++ b/samsung-ipc/ipc_devices.h
@@ -23,7 +23,7 @@
#include "device/crespo/crespo_ipc.h"
#include "device/aries/aries_ipc.h"
#include "device/galaxys2/galaxys2_ipc.h"
-#include "device/galaxys3/galaxys3_ipc.h"
+#include "device/i9300/i9300_ipc.h"
#include "device/maguro/maguro_ipc.h"
#include "device/piranha/piranha_ipc.h"