[Replicant] [libsamsung-ipc] [PATCH 01/11] modems: xmm626: abstract xmm626_{hsic/mipi}_modem_data_send

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Sun Oct 11 22:22:12 UTC 2020


The only difference between xmm626_hsic_nv_data_send and
xmm626_mipi_nv_data_send is the use of xmm626_hsic_modem_data_send
instead of xmm626_mipi_modem_data_send.

Abstracting these functions would enable to use a common
xmm626_nv_data_send.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 Android.mk                              |  1 +
 samsung-ipc/Makefile.am                 |  2 ++
 samsung-ipc/devices/ipc_devices.c       | 11 ++++++++++
 samsung-ipc/devices/ipc_devices.h       |  1 +
 samsung-ipc/ipc.c                       |  1 +
 samsung-ipc/ipc.h                       |  6 ++++++
 samsung-ipc/modems/modem.c              | 27 ++++++++++++++++++++++++
 samsung-ipc/modems/modem.h              | 28 +++++++++++++++++++++++++
 samsung-ipc/modems/xmm626/xmm626_hsic.c |  5 +++++
 samsung-ipc/modems/xmm626/xmm626_hsic.h |  2 ++
 samsung-ipc/modems/xmm626/xmm626_mipi.c |  5 +++++
 samsung-ipc/modems/xmm626/xmm626_mipi.h |  2 ++
 12 files changed, 91 insertions(+)
 create mode 100644 samsung-ipc/modems/modem.c
 create mode 100644 samsung-ipc/modems/modem.h

diff --git a/Android.mk b/Android.mk
index b1aabbd..fb3b917 100644
--- a/Android.mk
+++ b/Android.mk
@@ -52,6 +52,7 @@ endif
 libsamsung_ipc_local_src_files := \
 	samsung-ipc/ipc.c \
 	samsung-ipc/ipc_utils.c \
+	samsung-ipc/modems/modem.c \
 	samsung-ipc/modems/xmm616/xmm616.c \
 	samsung-ipc/modems/xmm626/xmm626.c \
 	samsung-ipc/modems/xmm626/xmm626_hsic.c \
diff --git a/samsung-ipc/Makefile.am b/samsung-ipc/Makefile.am
index 87becdd..cd0cc5e 100644
--- a/samsung-ipc/Makefile.am
+++ b/samsung-ipc/Makefile.am
@@ -18,6 +18,8 @@ libsamsung_ipc_la_SOURCES = \
 	ipc.c \
 	ipc.h \
 	ipc_utils.c \
+	modems/modem.c \
+	modems/modem.h \
 	modems/xmm616/xmm616.c \
 	modems/xmm616/xmm616.h \
 	modems/xmm626/xmm626.c \
diff --git a/samsung-ipc/devices/ipc_devices.c b/samsung-ipc/devices/ipc_devices.c
index 91663f6..edf3b5a 100644
--- a/samsung-ipc/devices/ipc_devices.c
+++ b/samsung-ipc/devices/ipc_devices.c
@@ -22,6 +22,8 @@
 #include <samsung-ipc.h>
 
 #include "devices/ipc_devices.h"
+#include "modems/xmm626/xmm626_hsic.h"
+#include "modems/xmm626/xmm626_mipi.h"
 
 struct ipc_device_desc ipc_devices[] = {
 	{
@@ -73,6 +75,7 @@ struct ipc_device_desc ipc_devices[] = {
 		.handlers = &galaxys2_handlers,
 		.gprs_specs = &galaxys2_gprs_specs,
 		.nv_data_specs = &galaxys2_nv_data_specs,
+		.modem_driver_ops = &xmm626_mipi_modem_driver_ops,
 	},
 	{
 		.name = "galaxys2",
@@ -83,6 +86,7 @@ struct ipc_device_desc ipc_devices[] = {
 		.handlers = &galaxys2_handlers,
 		.gprs_specs = &galaxys2_gprs_specs,
 		.nv_data_specs = &galaxys2_nv_data_specs,
+		.modem_driver_ops = &xmm626_hsic_modem_driver_ops,
 	},
 	{
 		.name = "maguro",
@@ -93,6 +97,7 @@ struct ipc_device_desc ipc_devices[] = {
 		.handlers = &maguro_handlers,
 		.gprs_specs = &maguro_gprs_specs,
 		.nv_data_specs = &maguro_nv_data_specs,
+		.modem_driver_ops = &xmm626_mipi_modem_driver_ops,
 	},
 	{
 		.name = "piranha",
@@ -103,6 +108,7 @@ struct ipc_device_desc ipc_devices[] = {
 		.handlers = &piranha_handlers,
 		.gprs_specs = &piranha_gprs_specs,
 		.nv_data_specs = &piranha_nv_data_specs,
+		.modem_driver_ops = &xmm626_mipi_modem_driver_ops,
 	},
 	{
 		.name = "piranha",
@@ -113,6 +119,7 @@ struct ipc_device_desc ipc_devices[] = {
 		.handlers = &piranha_handlers,
 		.gprs_specs = &piranha_gprs_specs,
 		.nv_data_specs = &piranha_nv_data_specs,
+		.modem_driver_ops = &xmm626_mipi_modem_driver_ops,
 	},
 	{
 		.name = "piranha",
@@ -123,6 +130,7 @@ struct ipc_device_desc ipc_devices[] = {
 		.handlers = &piranha_handlers,
 		.gprs_specs = &piranha_gprs_specs,
 		.nv_data_specs = &piranha_nv_data_specs,
+		.modem_driver_ops = &xmm626_mipi_modem_driver_ops,
 	},
 	{
 		.name = "i9300",
@@ -133,6 +141,7 @@ struct ipc_device_desc ipc_devices[] = {
 		.handlers = &i9300_handlers,
 		.gprs_specs = &i9300_gprs_specs,
 		.nv_data_specs = &i9300_nv_data_specs,
+		.modem_driver_ops = &xmm626_hsic_modem_driver_ops,
 	},
 	{
 		.name = "n7100",
@@ -143,6 +152,7 @@ struct ipc_device_desc ipc_devices[] = {
 		.handlers = &n7100_handlers,
 		.gprs_specs = &n7100_gprs_specs,
 		.nv_data_specs = &n7100_nv_data_specs,
+		.modem_driver_ops = &xmm626_hsic_modem_driver_ops,
 	},
 	{
 		.name = "n5100",
@@ -153,6 +163,7 @@ struct ipc_device_desc ipc_devices[] = {
 		.handlers = &n5100_handlers,
 		.gprs_specs = &n5100_gprs_specs,
 		.nv_data_specs = &n5100_nv_data_specs,
+		.modem_driver_ops = &xmm626_hsic_modem_driver_ops,
 	},
 };
 
diff --git a/samsung-ipc/devices/ipc_devices.h b/samsung-ipc/devices/ipc_devices.h
index 176607c..17a40b8 100644
--- a/samsung-ipc/devices/ipc_devices.h
+++ b/samsung-ipc/devices/ipc_devices.h
@@ -42,6 +42,7 @@ struct ipc_device_desc {
 	struct ipc_client_handlers *handlers;
 	struct ipc_client_gprs_specs *gprs_specs;
 	struct ipc_client_nv_data_specs *nv_data_specs;
+	struct ipc_client_modem_driver_ops *modem_driver_ops;
 };
 
 extern struct ipc_device_desc ipc_devices[];
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c
index c116fbb..efdd5d2 100644
--- a/samsung-ipc/ipc.c
+++ b/samsung-ipc/ipc.c
@@ -214,6 +214,7 @@ static struct ipc_client *ipc_transport_client_create(int type)
 
 	client->gprs_specs = ipc_devices[device_index].gprs_specs;
 	client->nv_data_specs = ipc_devices[device_index].nv_data_specs;
+	client->modem_driver_ops = ipc_devices[device_index].modem_driver_ops;
 
 	/* Handlers can be modified */
 	client->handlers = (struct ipc_client_handlers *) calloc(
diff --git a/samsung-ipc/ipc.h b/samsung-ipc/ipc.h
index 1cfa757..2135a23 100644
--- a/samsung-ipc/ipc.h
+++ b/samsung-ipc/ipc.h
@@ -78,6 +78,11 @@ struct ipc_client_gprs_specs {
 		struct ipc_client_gprs_capabilities *capabilities);
 };
 
+struct ipc_client_modem_driver_ops {
+	int (*data_send)(struct ipc_client *client, int device_fd,
+			 const void *data,  size_t size, int address);
+};
+
 struct ipc_client_nv_data_specs {
 	char *nv_data_path;
 	char *nv_data_md5_path;
@@ -98,6 +103,7 @@ struct ipc_client {
 	struct ipc_client_handlers *handlers;
 	struct ipc_client_gprs_specs *gprs_specs;
 	struct ipc_client_nv_data_specs *nv_data_specs;
+	struct ipc_client_modem_driver_ops *modem_driver_ops;
 };
 
 /*
diff --git a/samsung-ipc/modems/modem.c b/samsung-ipc/modems/modem.c
new file mode 100644
index 0000000..9bfd4ae
--- /dev/null
+++ b/samsung-ipc/modems/modem.c
@@ -0,0 +1,27 @@
+/*
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2020 Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
+ *
+ * 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/>.
+ */
+
+#include "ipc.h"
+
+int modem_data_send(struct ipc_client *client, int device_fd, const void *data,
+		    size_t size, int address)
+{
+	return client->modem_driver_ops->data_send(client, device_fd, data,
+						   size,  address);
+}
diff --git a/samsung-ipc/modems/modem.h b/samsung-ipc/modems/modem.h
new file mode 100644
index 0000000..c821760
--- /dev/null
+++ b/samsung-ipc/modems/modem.h
@@ -0,0 +1,28 @@
+/*
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2020 Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
+ *
+ * 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/>.
+ */
+
+#include "ipc.h"
+
+#ifndef __SAMSUNG_IPC_MODEM_H__
+#define __SAMSUNG_IPC_MODEM_H__
+
+int modem_data_send(struct ipc_client *client, int device_fd, const void *data,
+		    size_t size, int address);
+
+#endif /* __SAMSUNG_IPC_MODEM_H__ */
diff --git a/samsung-ipc/modems/xmm626/xmm626_hsic.c b/samsung-ipc/modems/xmm626/xmm626_hsic.c
index 0ec7347..50cfc0e 100644
--- a/samsung-ipc/modems/xmm626/xmm626_hsic.c
+++ b/samsung-ipc/modems/xmm626/xmm626_hsic.c
@@ -32,6 +32,7 @@
 #include "ipc.h"
 #include "modems/xmm626/xmm626.h"
 #include "modems/xmm626/xmm626_hsic.h"
+#include "modems/xmm626/xmm626_mipi.h"
 
 int xmm626_hsic_ack_read(__attribute__((unused)) struct ipc_client *client,
 			  int device_fd, unsigned short ack)
@@ -617,3 +618,7 @@ int xmm626_hsic_hw_reset_send(struct ipc_client *client, int device_fd)
 
 	return 0;
 }
+
+struct ipc_client_modem_driver_ops xmm626_hsic_modem_driver_ops = {
+	.data_send = xmm626_hsic_modem_data_send,
+};
diff --git a/samsung-ipc/modems/xmm626/xmm626_hsic.h b/samsung-ipc/modems/xmm626/xmm626_hsic.h
index 6385cdc..a55587c 100644
--- a/samsung-ipc/modems/xmm626/xmm626_hsic.h
+++ b/samsung-ipc/modems/xmm626/xmm626_hsic.h
@@ -64,4 +64,6 @@ int xmm626_hsic_firmware_send(struct ipc_client *client, int device_fd,
 int xmm626_hsic_nv_data_send(struct ipc_client *client, int device_fd);
 int xmm626_hsic_hw_reset_send(struct ipc_client *client, int device_fd);
 
+extern struct ipc_client_modem_driver_ops xmm626_hsic_modem_driver_ops;
+
 #endif /* __XMM626_HSIC_H__ */
diff --git a/samsung-ipc/modems/xmm626/xmm626_mipi.c b/samsung-ipc/modems/xmm626/xmm626_mipi.c
index f0c6ac2..0fedad6 100644
--- a/samsung-ipc/modems/xmm626/xmm626_mipi.c
+++ b/samsung-ipc/modems/xmm626/xmm626_mipi.c
@@ -29,6 +29,7 @@
 
 #include <samsung-ipc.h>
 
+#include "ipc.h"
 #include "modems/xmm626/xmm626.h"
 #include "modems/xmm626/xmm626_mipi.h"
 
@@ -678,3 +679,7 @@ int xmm626_mipi_hw_reset_send(struct ipc_client *client, int device_fd)
 
 	return 0;
 }
+
+struct ipc_client_modem_driver_ops xmm626_mipi_modem_driver_ops = {
+	.data_send = xmm626_mipi_modem_data_send,
+};
diff --git a/samsung-ipc/modems/xmm626/xmm626_mipi.h b/samsung-ipc/modems/xmm626/xmm626_mipi.h
index 1545a3e..9b54add 100644
--- a/samsung-ipc/modems/xmm626/xmm626_mipi.h
+++ b/samsung-ipc/modems/xmm626/xmm626_mipi.h
@@ -68,4 +68,6 @@ int xmm626_mipi_mps_data_send(struct ipc_client *client, int device_fd,
 			      const void *mps_data, size_t mps_size);
 int xmm626_mipi_hw_reset_send(struct ipc_client *client, int device_fd);
 
+extern struct ipc_client_modem_driver_ops xmm626_mipi_modem_driver_ops;
+
 #endif /* __XMM626_MIPI_H__ */
-- 
2.28.0



More information about the Replicant mailing list