Skip to contentSkip to conversation

Siano's SMS core system upgrade

PATCH In review Uri Shkolnik 2 participants 3 messages Nov 19, 2008 – Nov 20, 2008 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 5/5 Siano's SMS core system upgrade

This patch provides the following:

A) Support for firmware download for kernel versions < 2.6.10

B) SPI and SDIO interface driver registration

C) DVB-API v5 (S2) and Siano's subsystem registration

D) Indentation

This patch provides the following:
A) Support for firmware download for kernel versions < 2.6.10
B) SPI and SDIO interface driver registration
C) DVB-API v5 (S2) and Siano's subsystem registration
D) Indentation

linux/drivers/media/dvb/siano/smscoreapi.c +398 -204
diff -uNr v4l-dvb-c5f976cab011/linux/drivers/media/dvb/siano/smscoreapi.c v4l-dvb-c5f976cab011_0003/linux/drivers/media/dvb/siano/smscoreapi.c
@@ -1,25 +1,23 @@
-/*
- *  Siano core API module
- *
- *  This file contains implementation for the interface to sms core component
- *
- *  author: Anatoly Greenblat
- *
- *  Copyright (c), 2005-2008 Siano Mobile Silicon, Inc.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2 as
- *  published by the Free Software Foundation;
- *
- *  Software distributed under the License is distributed on an "AS IS"
- *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
- *
- *  See the GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
+/****************************************************************
+
+Siano Mobile Silicon, Inc.
+MDTV receiver kernel modules.
+Copyright (C) 2006-2008, Uri Shkolnik
+
+This program 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.
+
+ This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+****************************************************************/
 
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -28,12 +26,19 @@
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/uaccess.h>
 
 #include <linux/firmware.h>
 
 #include "smscoreapi.h"
 #include "sms-cards.h"
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
+#define REQUEST_FIRMWARE_SUPPORTED
+#else
+#define DEFAULT_FW_FILE_PATH "/lib/firmware"
+#endif
+
 int sms_debug;
 module_param_named(debug, sms_debug, int, 0644);
 MODULE_PARM_DESC(debug, "set debug level (info=1, adv=2 (or-able))");
@@ -45,17 +50,17 @@
 
 struct smscore_idlist_t {
 	struct list_head entry;
-	int		id;
-	int		data_type;
+	int id;
+	int data_type;
 };
 
 struct smscore_client_t {
 	struct list_head entry;
 	struct smscore_device_t *coredev;
-	void			*context;
-	struct list_head 	idlist;
-	onresponse_t	onresponse_handler;
-	onremove_t		onremove_handler;
+	void *context;
+	struct list_head idlist;
+	onresponse_t onresponse_handler;
+	onremove_t onremove_handler;
 };
 
 struct smscore_device_t {
@@ -63,34 +68,37 @@
 
 	struct list_head clients;
 	struct list_head subclients;
-	spinlock_t		clientslock;
+	spinlock_t clientslock;
 
 	struct list_head buffers;
-	spinlock_t		bufferslock;
-	int				num_buffers;
+	spinlock_t bufferslock;
+	int num_buffers;
 
-	void			*common_buffer;
-	int				common_buffer_size;
-	dma_addr_t		common_buffer_phys;
-
-	void			*context;
-	struct device	*device;
-
-	char			devpath[32];
-	unsigned long	device_flags;
-
-	setmode_t		setmode_handler;
-	detectmode_t	detectmode_handler;
-	sendrequest_t	sendrequest_handler;
-	preload_t		preload_handler;
-	postload_t		postload_handler;
+	void *common_buffer;
+	int common_buffer_size;
+	dma_addr_t common_buffer_phys;
+
+	void *context;
+	struct device *device;
+
+	char devpath[32];
+	unsigned long device_flags;
+
+	setmode_t setmode_handler;
+	detectmode_t detectmode_handler;
+	sendrequest_t sendrequest_handler;
+	preload_t preload_handler;
+	postload_t postload_handler;
 
-	int				mode, modes_supported;
+	int mode, modes_supported;
 
 	struct completion version_ex_done, data_download_done, trigger_done;
 	struct completion init_device_done, reload_start_done, resume_done;
 
 	int board_id;
+
+	u8 *fw_buf;
+	u32 fw_buf_size;
 };
 
 void smscore_set_board_id(struct smscore_device_t *core, int id)
@@ -105,9 +113,9 @@
 
 struct smscore_registry_entry_t {
 	struct list_head entry;
-	char			devpath[32];
-	int				mode;
-	enum sms_device_type_st	type;
+	char devpath[32];
+	int mode;
+	enum sms_device_type_st type;
 };
 
 static struct list_head g_smscore_notifyees;
@@ -129,17 +137,15 @@
 
 	kmutex_lock(&g_smscore_registrylock);
 	for (next = g_smscore_registry.next;
-	     next != &g_smscore_registry;
-	     next = next->next) {
-		entry = (struct smscore_registry_entry_t *) next;
+	     next != &g_smscore_registry; next = next->next) {
+		entry = (struct smscore_registry_entry_t *)next;
 		if (!strcmp(entry->devpath, devpath)) {
 			kmutex_unlock(&g_smscore_registrylock);
 			return entry;
 		}
 	}
 	entry = (struct smscore_registry_entry_t *)
-			kmalloc(sizeof(struct smscore_registry_entry_t),
-				GFP_KERNEL);
+	    kmalloc(sizeof(struct smscore_registry_entry_t), GFP_KERNEL);
 	if (entry) {
 		entry->mode = default_mode;
 		strcpy(entry->devpath, devpath);
@@ -199,7 +205,6 @@
 		sms_err("No registry found.");
 }
 
-
 static void list_add_locked(struct list_head *new, struct list_head *head,
 			    spinlock_t *lock)
 {
@@ -234,10 +239,9 @@
 		/* now notify callback about existing devices */
 		first = &g_smscore_devices;
 		for (next = first->next;
-		     next != first && !rc;
-		     next = next->next) {
+		     next != first && !rc; next = next->next) {
 			struct smscore_device_t *coredev =
-				(struct smscore_device_t *) next;
+			    (struct smscore_device_t *)next;
 			rc = hotplug(coredev, coredev->device, 1);
 		}
 
@@ -270,7 +274,7 @@
 
 	for (next = first->next; next != first;) {
 		struct smscore_device_notifyee_t *notifyee =
-			(struct smscore_device_notifyee_t *) next;
+		    (struct smscore_device_notifyee_t *)next;
 		next = next->next;
 
 		if (notifyee->hotplug == hotplug) {
@@ -288,7 +292,7 @@
 
 	/* the client must call smscore_unregister_client from remove handler */
 	while (!list_empty(&coredev->clients)) {
-		client = (struct smscore_client_t *) coredev->clients.next;
+		client = (struct smscore_client_t *)coredev->clients.next;
 		client->onremove_handler(client->context);
 	}
 }
@@ -304,8 +308,8 @@
 	first = &g_smscore_notifyees;
 
 	for (next = first->next; next != first; next = next->next) {
-		rc = ((struct smscore_device_notifyee_t *) next)->
-				hotplug(coredev, device, arrival);
+		rc = ((struct smscore_device_notifyee_t *)next)->
+		    hotplug(coredev, device, arrival);
 		if (rc < 0)
 			break;
 	}
@@ -318,7 +322,7 @@
 				       dma_addr_t common_buffer_phys)
 {
 	struct smscore_buffer_t *cb =
-		kmalloc(sizeof(struct smscore_buffer_t), GFP_KERNEL);
+	    kmalloc(sizeof(struct smscore_buffer_t), GFP_KERNEL);
 	if (!cb) {
 		sms_info("kmalloc(...) failed");
 		return NULL;
@@ -387,8 +391,8 @@
 	     dev->num_buffers < params->num_buffers;
 	     dev->num_buffers++, buffer += params->buffer_size) {
 		struct smscore_buffer_t *cb =
-			smscore_createbuffer(buffer, dev->common_buffer,
-					     dev->common_buffer_phys);
+		    smscore_createbuffer(buffer, dev->common_buffer,
+					 dev->common_buffer_phys);
 		if (!cb) {
 			smscore_unregister_device(dev);
 			return -ENOMEM;
@@ -435,12 +439,17 @@
  */
 int smscore_start_device(struct smscore_device_t *coredev)
 {
-	int rc = smscore_set_device_mode(
-			coredev, smscore_registry_getmode(coredev->devpath));
+	int rc;
+
+#ifdef REQUEST_FIRMWARE_SUPPORTED
+	rc = smscore_set_device_mode(coredev,
+				     smscore_registry_getmode(coredev->
+							      devpath));
 	if (rc < 0) {
 		sms_info("set device mode faile , rc %d", rc);
 		return rc;
 	}
+#endif
 
 	kmutex_lock(&g_smscore_deviceslock);
 
@@ -465,13 +474,13 @@
 
 	return wait_for_completion_timeout(completion,
 					   msecs_to_jiffies(10000)) ?
-						0 : -ETIME;
+	    0 : -ETIME;
 }
 
 static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
 					 void *buffer, size_t size)
 {
-	struct SmsFirmware_ST *firmware = (struct SmsFirmware_ST *) buffer;
+	struct SmsFirmware_ST *firmware = (struct SmsFirmware_ST *)buffer;
 	struct SmsMsgHdr_ST *msg;
 	u32 mem_address = firmware->StartAddress;
 	u8 *payload = firmware->Payload;
@@ -502,26 +511,28 @@
 
 	while (size && rc >= 0) {
 		struct SmsDataDownload_ST *DataMsg =
-			(struct SmsDataDownload_ST *) msg;
-		int payload_size = min((int) size, SMS_MAX_PAYLOAD_SIZE);
+		    (struct SmsDataDownload_ST *)msg;
+		int payload_size = min((int)size, SMS_MAX_PAYLOAD_SIZE);
 
 		SMS_INIT_MSG(msg, MSG_SMS_DATA_DOWNLOAD_REQ,
-			     (u16)(sizeof(struct SmsMsgHdr_ST) +
-				      sizeof(u32) + payload_size));
+			     (u16) (sizeof(struct SmsMsgHdr_ST) +
+				    sizeof(u32) + payload_size));
 
 		DataMsg->MemAddr = mem_address;
 		memcpy(DataMsg->Payload, payload, payload_size);
 
 		if ((coredev->device_flags & SMS_ROM_NO_RESPONSE) &&
 		    (coredev->mode == DEVICE_MODE_NONE))
-			rc = coredev->sendrequest_handler(
-				coredev->context, DataMsg,
-				DataMsg->xMsgHeader.msgLength);
+			rc = coredev->sendrequest_handler(coredev->context,
+							  DataMsg,
+							  DataMsg->xMsgHeader.
+							  msgLength);
 		else
-			rc = smscore_sendrequest_and_wait(
-				coredev, DataMsg,
-				DataMsg->xMsgHeader.msgLength,
-				&coredev->data_download_done);
+			rc = smscore_sendrequest_and_wait(coredev, DataMsg,
+							  DataMsg->xMsgHeader.
+							  msgLength,
+							  &coredev->
+							  data_download_done);
 
 		payload += payload_size;
 		size -= payload_size;
@@ -531,29 +542,35 @@
 	if (rc >= 0) {
 		if (coredev->mode == DEVICE_MODE_NONE) {
 			struct SmsMsgData_ST *TriggerMsg =
-				(struct SmsMsgData_ST *) msg;
+			    (struct SmsMsgData_ST *)msg;
 
 			SMS_INIT_MSG(msg, MSG_SMS_SWDOWNLOAD_TRIGGER_REQ,
 				     sizeof(struct SmsMsgHdr_ST) +
 				     sizeof(u32) * 5);
 
 			TriggerMsg->msgData[0] = firmware->StartAddress;
-						/* Entry point */
-			TriggerMsg->msgData[1] = 5; /* Priority */
-			TriggerMsg->msgData[2] = 0x200; /* Stack size */
-			TriggerMsg->msgData[3] = 0; /* Parameter */
-			TriggerMsg->msgData[4] = 4; /* Task ID */
+			/* Entry point */
+			TriggerMsg->msgData[1] = 5;	/* Priority */
+			TriggerMsg->msgData[2] = 0x200;	/* Stack size */
+			TriggerMsg->msgData[3] = 0;	/* Parameter */
+			TriggerMsg->msgData[4] = 4;	/* Task ID */
 
 			if (coredev->device_flags & SMS_ROM_NO_RESPONSE) {
-				rc = coredev->sendrequest_handler(
-					coredev->context, TriggerMsg,
-					TriggerMsg->xMsgHeader.msgLength);
+				rc = coredev->sendrequest_handler(coredev->
+								  context,
+								  TriggerMsg,
+								  TriggerMsg->
+								  xMsgHeader.
+								  msgLength);
 				msleep(100);
 			} else
-				rc = smscore_sendrequest_and_wait(
-					coredev, TriggerMsg,
-					TriggerMsg->xMsgHeader.msgLength,
-					&coredev->trigger_done);
+				rc = smscore_sendrequest_and_wait(coredev,
+								  TriggerMsg,
+								  TriggerMsg->
+								  xMsgHeader.
+								  msgLength,
+								  &coredev->
+								  trigger_done);
 		} else {
 			SMS_INIT_MSG(msg, MSG_SW_RELOAD_EXEC_REQ,
 				     sizeof(struct SmsMsgHdr_ST));
@@ -564,14 +581,12 @@
 		msleep(500);
 	}
 
-	sms_debug("rc=%d, postload=%p ", rc,
-		  coredev->postload_handler);
+	sms_debug("rc=%d, postload=%p ", rc, coredev->postload_handler);
 
 	kfree(msg);
 
 	return ((rc >= 0) && coredev->postload_handler) ?
-		coredev->postload_handler(coredev->context) :
-		rc;
+	    coredev->postload_handler(coredev->context) : rc;
 }
 
 /**
@@ -589,8 +604,11 @@
 					   loadfirmware_t loadfirmware_handler)
 {
 	int rc = -ENOENT;
+	u8 *fw_buf;
+	u32 fw_buf_size;
+
+#ifdef REQUEST_FIRMWARE_SUPPORTED
 	const struct firmware *fw;
-	u8 *fw_buffer;
 
 	if (loadfirmware_handler == NULL && !(coredev->device_flags &
 					      SMS_DEVICE_FAMILY2))
@@ -601,27 +619,38 @@
 		sms_info("failed to open \"%s\"", filename);
 		return rc;
 	}
-	sms_info("read FW %s, size=%zd", filename, fw->size);
-	fw_buffer = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT),
-			    GFP_KERNEL | GFP_DMA);
-	if (fw_buffer) {
-		memcpy(fw_buffer, fw->data, fw->size);
-
-		rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ?
-		      smscore_load_firmware_family2(coredev,
-						    fw_buffer,
-						    fw->size) :
-		      loadfirmware_handler(coredev->context,
-					   fw_buffer, fw->size);
-
-		kfree(fw_buffer);
-	} else {
+	sms_info("read FW %s, size=%d", filename, fw->size);
+	fw_buf = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT),
+			 GFP_KERNEL | GFP_DMA);
+	if (!fw_buf) {
 		sms_info("failed to allocate firmware buffer");
-		rc = -ENOMEM;
+		return -ENOMEM;
+	}
+	memcpy(fw_buf, fw->data, fw->size);
+	fw_buf_size = fw->size;
+#else
+	if (!coredev->fw_buf) {
+		sms_info("missing fw file buffer");
+		return -EINVAL;
 	}
+	fw_buf = coredev->fw_buf;
+	fw_buf_size = coredev->fw_buf_size;
+#endif
 
-	release_firmware(fw);
+	rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ?
+	    smscore_load_firmware_family2(coredev,
+					  fw_buf,
+					  fw_buf_size) :
+	    loadfirmware_handler(coredev->context, fw_buf, fw_buf_size);
+
+	kfree(fw_buf);
 
+#ifdef REQUEST_FIRMWARE_SUPPORTED
+	release_firmware(fw);
+#else
+	coredev->fw_buf = NULL;
+	coredev->fw_buf_size = 0;
+#endif
 	return rc;
 }
 
@@ -673,6 +702,9 @@
 				  coredev->common_buffer,
 				  coredev->common_buffer_phys);
 
+	if (coredev->fw_buf != NULL)
+		kfree(coredev->fw_buf);
+
 	list_del(&coredev->entry);
 	kfree(coredev);
 
@@ -686,7 +718,7 @@
 	void *buffer = kmalloc(sizeof(struct SmsMsgHdr_ST) + SMS_DMA_ALIGNMENT,
 			       GFP_KERNEL | GFP_DMA);
 	struct SmsMsgHdr_ST *msg =
-		(struct SmsMsgHdr_ST *) SMS_ALIGN_ADDRESS(buffer);
+	    (struct SmsMsgHdr_ST *)SMS_ALIGN_ADDRESS(buffer);
 	int rc;
 
 	if (!buffer)
@@ -702,9 +734,10 @@
 
 		if (wait_for_completion_timeout(&coredev->resume_done,
 						msecs_to_jiffies(5000))) {
-			rc = smscore_sendrequest_and_wait(
-				coredev, msg, msg->msgLength,
-				&coredev->version_ex_done);
+			rc = smscore_sendrequest_and_wait(coredev, msg,
+							  msg->msgLength,
+							  &coredev->
+							  version_ex_done);
 			if (rc < 0)
 				sms_err("MSG_SMS_GET_VERSION_EX_REQ failed "
 					"second try, rc %d", rc);
@@ -718,23 +751,21 @@
 }
 
 static char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = {
-	/*Stellar		NOVA A0		Nova B0		VEGA*/
-	/*DVBT*/
-	{"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
-	/*DVBH*/
-	{"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
-	/*TDMB*/
-	{"none", "tdmb_nova_12mhz.inp", "none", "none"},
-	/*DABIP*/
-	{"none", "none", "none", "none"},
-	/*BDA*/
-	{"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
-	/*ISDBT*/
-	{"none", "isdbt_nova_12mhz.inp", "dvb_nova_12mhz.inp", "none"},
-	/*ISDBTBDA*/
-	{"none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none"},
-	/*CMMB*/
-	{"none", "none", "none", "cmmb_vega_12mhz.inp"}
+	/*Stellar               NOVA A0         Nova B0         VEGA */
+	 /*DVBT*/
+	    {"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
+	 /*DVBH*/
+	    {"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
+	 /*TDMB*/
+	    {"none", "tdmb_nova_12mhz.inp", "tdmb_nova_12mhz_b0.inp", "none"},
+	 /*DABIP*/ {"none", "none", "none", "none"},
+	 /*BDA*/
+	    {"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
+	 /*ISDBT*/
+	    {"none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none"},
+	 /*ISDBTBDA*/
+	    {"none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none"},
+	 /*CMMB*/ {"none", "none", "none", "cmmb_vega_12mhz.inp"}
 };
 
 static inline char *sms_get_fw_name(struct smscore_device_t *coredev,
@@ -798,7 +829,8 @@
 				/* try again with the default firmware */
 				fw_filename = smscore_fw_lkup[mode][type];
 				rc = smscore_load_firmware_from_file(coredev,
-							     fw_filename, NULL);
+					fw_filename,
+					NULL);
 
 				if (rc < 0) {
 					sms_warn("error %d loading "
@@ -815,17 +847,18 @@
 		buffer = kmalloc(sizeof(struct SmsMsgData_ST) +
 				 SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA);
 		if (buffer) {
-			struct SmsMsgData_ST *msg =
-				(struct SmsMsgData_ST *)
-					SMS_ALIGN_ADDRESS(buffer);
+			struct SmsMsgData_ST *msg = (struct SmsMsgData_ST *)
+			    SMS_ALIGN_ADDRESS(buffer);
 
 			SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_INIT_DEVICE_REQ,
 				     sizeof(struct SmsMsgData_ST));
 			msg->msgData[0] = mode;
 
-			rc = smscore_sendrequest_and_wait(
-				coredev, msg, msg->xMsgHeader.msgLength,
-				&coredev->init_device_done);
+			rc = smscore_sendrequest_and_wait(coredev, msg,
+							  msg->xMsgHeader.
+							  msgLength,
+							  &coredev->
+							  init_device_done);
 
 			kfree(buffer);
 		} else {
@@ -860,6 +893,76 @@
 }
 
 /**
+ * calls device handler to get fw file name
+ *
+ * @param coredev pointer to a coredev object returned by
+ *                smscore_register_device
+ * @param filename pointer to user buffer to fill the file name
+ *
+ * @return 0 on success, <0 on error.
+ */
+int smscore_get_fw_filename(struct smscore_device_t *coredev, int mode,
+			    char *filename)
+{
+	int rc = 0;
+	enum sms_device_type_st type;
+	char tmpname[200];
+
+	type = smscore_registry_gettype(coredev->devpath);
+
+#ifdef REQUEST_FIRMWARE_SUPPORTED
+	/* driver not need file system services */
+	tmpname[0] = '\0';
+#else
+	sprintf(tmpname, "%s/%s", DEFAULT_FW_FILE_PATH,
+		smscore_fw_lkup[mode][type]);
+#endif
+	if (copy_to_user(filename, tmpname, strlen(tmpname) + 1)) {
+		sms_err("Failed copy file path to user buffer\n");
+		return -EFAULT;
+	}
+	return rc;
+}
+
+/**
+ * calls device handler to keep fw buff for later use
+ *
+ * @param coredev pointer to a coredev object returned by
+ *                smscore_register_device
+ * @param ufwbuf  pointer to user fw buffer
+ * @param size    size in bytes of buffer
+ *
+ * @return 0 on success, <0 on error.
+ */
+int smscore_send_fw_file(struct smscore_device_t *coredev, u8 *ufwbuf,
+			 int size)
+{
+	int rc = 0;
+
+	/* free old buffer */
+	if (coredev->fw_buf != NULL) {
+		kfree(coredev->fw_buf);
+		coredev->fw_buf = NULL;
+	}
+
+	coredev->fw_buf = kmalloc(ALIGN(size, SMS_ALLOC_ALIGNMENT),
+				  GFP_KERNEL | GFP_DMA);
+	if (!coredev->fw_buf) {
+		sms_err("Failed allocate FW buffer memory\n");
+		return -EFAULT;
+	}
+
+	if (copy_from_user(coredev->fw_buf, ufwbuf, size)) {
+		sms_err("Failed copy FW from user buffer\n");
+		kfree(coredev->fw_buf);
+		return -EFAULT;
+	}
+	coredev->fw_buf_size = size;
+
+	return rc;
+}
+
+/**
  * calls device handler to get current mode of operation
  *
  * @param coredev pointer to a coredev object returned by
@@ -891,20 +994,19 @@
 	unsigned long flags;
 	struct list_head *firstid, *nextid;
 
-
 	spin_lock_irqsave(&coredev->clientslock, flags);
 	first = &coredev->clients;
-	for (next = first->next;
-	     (next != first) && !client;
-	     next = next->next) {
+	for (next = first->next; (next != first)
+		&& !client; next = next->next) {
 		firstid = &((struct smscore_client_t *)next)->idlist;
 		for (nextid = firstid->next;
-		     nextid != firstid;
-		     nextid = nextid->next) {
+		     nextid != firstid; nextid = nextid->next) {
 			if ((((struct smscore_idlist_t *)nextid)->id == id) &&
-			    (((struct smscore_idlist_t *)nextid)->data_type == data_type ||
-			    (((struct smscore_idlist_t *)nextid)->data_type == 0))) {
-				client = (struct smscore_client_t *) next;
+			    (((struct smscore_idlist_t *)nextid)->data_type ==
+			     data_type
+			     || (((struct smscore_idlist_t *)nextid)->
+				 data_type == 0))) {
+				client = (struct smscore_client_t *)next;
 				break;
 			}
 		}
@@ -926,14 +1028,14 @@
 			struct smscore_buffer_t *cb)
 {
 	struct SmsMsgHdr_ST *phdr =
-		(struct SmsMsgHdr_ST *)((u8 *) cb->p + cb->offset);
+	    (struct SmsMsgHdr_ST *)((u8 *) cb->p + cb->offset);
 	struct smscore_client_t *client =
-		smscore_find_client(coredev, phdr->msgType, phdr->msgDstId);
+	    smscore_find_client(coredev, phdr->msgType, phdr->msgDstId);
 	int rc = -EBUSY;
 
 #if 1
-	static unsigned long last_sample_time; /* = 0; */
-	static int data_total; /* = 0; */
+	static unsigned long last_sample_time;	/* = 0; */
+	static int data_total;	/* = 0; */
 	unsigned long time_now = jiffies_to_msecs(jiffies);
 
 	if (!last_sample_time)
@@ -952,31 +1054,30 @@
 #endif
 	/* If no client registered for type & id,
 	 * check for control client where type is not registered */
-#if 0
-	if (!client)
-		client = smscore_find_client(coredev, 0, phdr->msgDstId);
-#endif
 	if (client)
 		rc = client->onresponse_handler(client->context, cb);
 
 	if (rc < 0) {
 		switch (phdr->msgType) {
 		case MSG_SMS_GET_VERSION_EX_RES:
-		{
-			struct SmsVersionRes_ST *ver =
-				(struct SmsVersionRes_ST *) phdr;
-			sms_debug("MSG_SMS_GET_VERSION_EX_RES "
-				  "id %d prots 0x%x ver %d.%d",
-				  ver->FirmwareId, ver->SupportedProtocols,
-				  ver->RomVersionMajor, ver->RomVersionMinor);
-
-			coredev->mode = ver->FirmwareId == 255 ?
-				DEVICE_MODE_NONE : ver->FirmwareId;
-			coredev->modes_supported = ver->SupportedProtocols;
+			{
+				struct SmsVersionRes_ST *ver =
+				    (struct SmsVersionRes_ST *)phdr;
+				sms_debug("MSG_SMS_GET_VERSION_EX_RES "
+					  "id %d prots 0x%x ver %d.%d",
+					  ver->FirmwareId,
+					  ver->SupportedProtocols,
+					  ver->RomVersionMajor,
+					  ver->RomVersionMinor);
+
+				coredev->mode = ver->FirmwareId == 255 ?
+				    DEVICE_MODE_NONE : ver->FirmwareId;
+				coredev->modes_supported =
+				    ver->SupportedProtocols;
 
-			complete(&coredev->version_ex_done);
-			break;
-		}
+				complete(&coredev->version_ex_done);
+				break;
+			}
 		case MSG_SMS_INIT_DEVICE_RES:
 			sms_debug("MSG_SMS_INIT_DEVICE_RES");
 			complete(&coredev->init_device_done);
@@ -1026,7 +1127,7 @@
 	spin_lock_irqsave(&coredev->bufferslock, flags);
 
 	if (!list_empty(&coredev->buffers)) {
-		cb = (struct smscore_buffer_t *) coredev->buffers.next;
+		cb = (struct smscore_buffer_t *)coredev->buffers.next;
 		list_del(&cb->entry);
 	}
 
@@ -1100,8 +1201,8 @@
 {
 	struct smscore_client_t *newclient;
 	/* check that no other channel with same parameters exists */
-	if (smscore_find_client(coredev, params->data_type,
-				params->initial_id)) {
+	if (smscore_find_client(coredev,
+		params->data_type, params->initial_id)) {
 		sms_err("Client already exist.");
 		return -EEXIST;
 	}
@@ -1142,10 +1243,9 @@
 
 	spin_lock_irqsave(&coredev->clientslock, flags);
 
-
 	while (!list_empty(&client->idlist)) {
 		struct smscore_idlist_t *identry =
-			(struct smscore_idlist_t *) client->idlist.next;
+		    (struct smscore_idlist_t *)client->idlist.next;
 		list_del(&identry->entry);
 		kfree(identry);
 	}
@@ -1173,7 +1273,7 @@
 			  void *buffer, size_t size)
 {
 	struct smscore_device_t *coredev;
-	struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *) buffer;
+	struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *)buffer;
 	int rc;
 
 	if (client == NULL) {
@@ -1197,7 +1297,7 @@
 	return coredev->sendrequest_handler(coredev->context, buffer, size);
 }
 
-#if 0
+#ifdef SMS_HOSTLIB_SUBSYS
 /**
  * return the size of large (common) buffer
  *
@@ -1218,22 +1318,22 @@
  *
  * @return 0 on success, <0 on error.
  */
-static int smscore_map_common_buffer(struct smscore_device_t *coredev,
-				     struct vm_area_struct *vma)
+int smscore_map_common_buffer(struct smscore_device_t *coredev,
+			      struct vm_area_struct *vma)
 {
 	unsigned long end = vma->vm_end,
-		      start = vma->vm_start,
-		      size = PAGE_ALIGN(coredev->common_buffer_size);
+	    start = vma->vm_start,
+	    size = PAGE_ALIGN(coredev->common_buffer_size);
 
 	if (!(vma->vm_flags & (VM_READ | VM_SHARED)) ||
-	     (vma->vm_flags & VM_WRITE)) {
+	    (vma->vm_flags & VM_WRITE)) {
 		sms_err("invalid vm flags");
 		return -EINVAL;
 	}
 
 	if ((end - start) != size) {
 		sms_err("invalid size %d expected %d",
-			 (int)(end - start), (int) size);
+			(int)(end - start), (int)size);
 		return -EINVAL;
 	}
 
@@ -1246,7 +1346,7 @@
 
 	return 0;
 }
-#endif
+#endif /* SMS_HOSTLIB_SUBSYS */
 
 static int __init smscore_module_init(void)
 {
@@ -1259,25 +1359,125 @@
 	INIT_LIST_HEAD(&g_smscore_registry);
 	kmutex_init(&g_smscore_registrylock);
 
+	/* Register sub system adapter objects */
+
+#ifdef SMS_NET_SUBSYS
+	/* NET Register */
+	rc = smsnet_register();
+	if (rc) {
+		sms_err("Error registering Siano's network client.\n");
+		goto smsnet_error;
+	}
+#endif
+
+#ifdef SMS_HOSTLIB_SUBSYS
+	/* Char interface Register */
+	rc = smschar_register();
+	if (rc) {
+		sms_err("Error registering Siano's char device client.\n");
+		goto smschar_error;
+	}
+#endif
+
+#ifdef SMS_DVB3_SUBSYS
+	/* DVB v.3 Register */
+	rc = smsdvb_register();
+	if (rc) {
+		sms_err("Error registering DVB client.\n");
+		goto smsdvb_error;
+	}
+#endif
+
+	/* Register interfaces objects */
+
+#ifdef SMS_USB_DRV
 	/* USB Register */
 	rc = smsusb_register();
+	if (rc) {
+		sms_err("Error registering USB bus driver.\n");
+		goto sms_bus_drv_error;
+	}
+#endif
 
-	/* DVB Register */
-	rc = smsdvb_register();
+#ifdef SMS_SDIO_DRV
+	/* SDIO Register */
+	rc = smssdio_register();
+	if (rc) {
+		sms_err("Error registering SDIO bus driver.\n");
+		goto sms_bus_drv_error;
+	}
+#endif
+
+#ifdef SMS_SPI_PXA310_DRV
+	/* Intel PXA310 SPI Register */
+	rc = smsspi_register();
+	if (rc) {
+		sms_err("Error registering Intel PXA310 SPI bus driver.\n");
+		goto sms_bus_drv_error;
+	}
+#endif
+
+	return rc;
+
+sms_bus_drv_error:
+#ifdef SMS_DVB3_SUBSYS
+	smsdvb_unregister();
+smsdvb_error:
+#endif
+
+#ifdef SMS_HOSTLIB_SUBSYS
+	smschar_unregister();
+smschar_error:
+#endif
+
+#ifdef SMS_NET_SUBSYS
+	smsnet_unregister();
+smsnet_error:
+#endif
 
-	sms_debug("rc %d", rc);
+	sms_err("rc %d", rc);
+	printk(KERN_INFO "%s, rc %d\n", __func__, rc);
 
 	return rc;
 }
 
 static void __exit smscore_module_exit(void)
 {
+#ifdef SMS_NET_SUBSYS
+	/* Net Unregister */
+	smsnet_unregister();
+#endif
+
+#ifdef SMS_HOSTLIB_SUBSYS
+	/* Char interface Unregister */
+	smschar_unregister();
+#endif
+
+#ifdef SMS_DVB3_SUBSYS
+	/* DVB v.3 unregister */
+	smsdvb_unregister();
+#endif
+
+	/* Unegister interfaces objects */
+#ifdef SMS_USB_DRV
+	/* USB unregister */
+	smsusb_unregister();
+#endif
+
+#ifdef SMS_SDIO_DRV
+	/* SDIO unegister */
+	smssdio_unregister();
+#endif
+#ifdef SMS_SPI_PXA310_DRV
+	/* Intel PXA310 SPI unegister */
+	smsspi_unregister();
+#endif
 
 	kmutex_lock(&g_smscore_deviceslock);
 	while (!list_empty(&g_smscore_notifyees)) {
 		struct smscore_device_notifyee_t *notifyee =
-			(struct smscore_device_notifyee_t *)
-				g_smscore_notifyees.next;
+		    (struct smscore_device_notifyee_t *)
+		    g_smscore_notifyees.next;
 
 		list_del(&notifyee->entry);
 		kfree(notifyee);
@@ -1287,26 +1487,20 @@
 	kmutex_lock(&g_smscore_registrylock);
 	while (!list_empty(&g_smscore_registry)) {
 		struct smscore_registry_entry_t *entry =
-			(struct smscore_registry_entry_t *)
-				g_smscore_registry.next;
+		    (struct smscore_registry_entry_t *)
+		    g_smscore_registry.next;
 
 		list_del(&entry->entry);
 		kfree(entry);
 	}
 	kmutex_unlock(&g_smscore_registrylock);
 
-	/* DVB UnRegister */
-	smsdvb_unregister();
-
-	/* Unregister USB */
-	smsusb_unregister();
-
 	sms_debug("");
 }
 
 module_init(smscore_module_init);
 module_exit(smscore_module_exit);
 
-MODULE_DESCRIPTION("Driver for the Siano SMS1XXX USB dongle");
-MODULE_AUTHOR("Siano Mobile Silicon,,, ([email protected])");
+MODULE_DESCRIPTION("Siano MDTV Core module");
+MODULE_AUTHOR("Siano Mobile Silicon, Inc. ([email protected])");
 MODULE_LICENSE("GPL");
linux/drivers/media/dvb/siano/smscoreapi.h +226 -361

760 lines not on this page · raw message

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#1 lore raw

Hello Uri, and thanks for all the patches!

Quoted 1 line · Uri Shkolnik

This patch provides the following:

[smscore_patch.diff]

Part of this patch appears to give problems, thanks to the use of 8-bit characters in the original smscoreapi.h file.

This may be made worse for me by my use of UTF8 encoding and possibly by data getting massaged by my mailer in ways that I do not know about. I haven't tried to solve that, as it would require thinking an' stuff. Anyway:

The part of the patch which failed for me appears to be limited to whitespace cleanup surrounding these lines (cut and pasted here):

- u8 FirmwareId; /* 0xFF ??? ROM, otherwise the
- * value indicated by
- * SMSHOSTLIB_DEVICE_MODES_E */

+ u8 FirmwareId; /* 0xFF ??? ROM, otherwise the
+ * value indicated by
+ * SMSHOSTLIB_DEVICE_MODES_E */

The original source file which I have contains three
bytes with 8th-bit-set where they are shown above as
???'. The original file passed through hd' gives
00000030 64 3b 20 2f 2a 20 30 78 46 46 20 ef bf bd 20 52 |d; /* 0xFF ... R|

                                            ^^^^^^^^

A quick google search shows this could be U+FFFD' which is REPLACEMENT CHARACTER' -- which means nothing to me, nor is displayed in my fonts, but it might be meaningful to someone else here.

Since I don't know how to preserve the intended meaning of the original author, I'll just suggest that if anyone runs into this problem and wants a quick workaround, to edit beforehand the original smscoreapi.h file, search for ROM', and replace the above series of 8-bit or single UTF8 character(s) with the series of three ASCII ?' question marks, then the patch should apply.

Whereupon the above character can be restored or replaced with an ASCII-equivalent to preserve its original meaning.

Just a FYI for anyone else.

thanks!
barry bouwsma

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#2 lore raw
Quoted 59 lines · BOUWSMA Barry

From: BOUWSMA Barry <[email protected]>
Subject: Re: [linux-dvb] [PATCH 5/5] Siano's SMS core system upgrade
To: "Uri Shkolnik" <[email protected]>
Cc: "Linux-dvb" <[email protected]>
Date: Thursday, November 20, 2008, 2:03 PM
Hello Uri, and thanks for all the patches!

Quoted 1 line · Uri Shkolnik

This patch provides the following:

[smscore_patch.diff]

Part of this patch appears to give problems, thanks to the use of 8-bit characters in the original smscoreapi.h file.

This may be made worse for me by my use of UTF8 encoding and possibly by data getting massaged by my mailer in ways that I do not know about. I haven't tried to solve that,
as it would require thinking an' stuff. Anyway:

The part of the patch which failed for me appears to be limited to whitespace cleanup surrounding these lines (cut and pasted here):

- u8 FirmwareId; /* 0xFF ??? ROM,
otherwise the

(quoted diff) +0 -2
-                                    * value indicated by
-                                    *

SMSHOSTLIB_DEVICE_MODES_E */

+ u8 FirmwareId; /* 0xFF ??? ROM, otherwise
the

(quoted diff) +2 -0
+                                * value indicated by
+                                *

SMSHOSTLIB_DEVICE_MODES_E */

The original source file which I have contains three bytes with 8th-bit-set where they are shown above as ???'. The original file passed through hd' gives 00000030 64 3b 20 2f 2a 20 30 78 46 46 20 ef bf bd 20 52 |d; /* 0xFF ... R|

                                            ^^^^^^^^

A quick google search shows this could be `U+FFFD' which
is `REPLACEMENT CHARACTER' -- which means nothing to me,
nor is displayed in my fonts, but it might be meaningful to someone else here.

Since I don't know how to preserve the intended meaning of the original author, I'll just suggest that if anyone runs into this problem and wants a quick workaround, to edit beforehand the original smscoreapi.h file, search for `ROM', and replace the above series of 8-bit or single
UTF8 character(s) with the series of three ASCII `?' question marks, then the patch should apply.

Quoted 8 lines

Whereupon the above character can be restored or replaced with an ASCII-equivalent to preserve its original meaning.

Just a FYI for anyone else.

thanks!
barry bouwsma

Hi Barry,

Thanks for the feedback, you are absolutely right. Anyway, the original string is "0xFF - ROM" (just space dash space) I'll commit a fix next week for this issue.

Thanks again,
Regards,

Uri

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb