Skip to contentSkip to conversation

SPI interface driver for Siano's SMS chip-set based devices.

PATCH In review Uri Shkolnik 4 participants 10 messages Nov 19, 2008 – Dec 6, 2008 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 2/5 SPI interface driver for Siano's SMS chip-set based devices.

This patch provides SPI interface driver for SMS chip-set based devices. The patch includes common SMS SPI code, and adapter driver for PXA310

This patch provides SPI interface driver for SMS chip-set based devices. The patch includes common SMS SPI code, and adapter driver for PXA310

linux/drivers/media/dvb/siano/smsdbg_prn.h +56 -0
diff -uNr v4l-dvb-c5f976cab011/linux/drivers/media/dvb/siano/smsdbg_prn.h v4l-dvb-c5f976cab011_0003/linux/drivers/media/dvb/siano/smsdbg_prn.h
@@ -0,0 +1,56 @@
+/****************************************************************
+
+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/>.
+
+****************************************************************/
+
+#ifndef _SMS_DBG_H_
+#define _SMS_DBG_H_
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+/************************************************************************/
+/* Debug Zones definitions.                                             */
+/************************************************************************/
+#undef PERROR
+#  define PERROR(fmt, args...) \
+	printk(KERN_ERR "spibus error: line %d- %s(): " fmt, __LINE__,\
+	  __func__, ## args)
+#undef PWARNING
+#  define PWARNING(fmt, args...) \
+	printk(KERN_WARNING "spibus warning: line %d- %s(): " fmt, __LINE__,  \
+	__func__, ## args)
+
+/* the debug macro - conditional compilation from the makefile */
+#undef PDEBUG			/* undef it, just in case */
+#ifdef SPIBUS_DEBUG
+#  define PDEBUG(fmt, args...) \
+	printk(KERN_DEBUG "spibus: line %d- %s(): " fmt, __LINE__, \
+	 __func__, ## args)
+#else
+#  define PDEBUG(fmt, args...)	/* not debugging: nothing */
+#endif
+
+/* The following defines are used for printing and
+are mandatory for compilation. */
+#define TXT(str) str
+#define PRN_DBG(str) PDEBUG str
+#define PRN_ERR(str) PERROR str
+
+#endif /*_SMS_DBG_H_*/
linux/drivers/media/dvb/siano/smsspicommon.c +326 -0

326 lines not on this page · raw message

linux/drivers/media/dvb/siano/smsspicommon.c~ +326 -0

326 lines not on this page · raw message

linux/drivers/media/dvb/siano/smsspicommon.h +96 -0

96 lines not on this page · raw message

linux/drivers/media/dvb/siano/smsspilog.c +446 -0

446 lines not on this page · raw message

linux/drivers/media/dvb/siano/smsspilog.c~ +446 -0

446 lines not on this page · raw message

linux/drivers/media/dvb/siano/smsspiphy.h +36 -0
diff -uNr v4l-dvb-c5f976cab011/linux/drivers/media/dvb/siano/smsspiphy.h v4l-dvb-c5f976cab011_0003/linux/drivers/media/dvb/siano/smsspiphy.h
@@ -0,0 +1,36 @@
+/****************************************************************
+
+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/>.
+
+****************************************************************/
+
+#ifndef __SMS_SPI_PHY_H__
+#define __SMS_SPI_PHY_H__
+
+void smsspibus_xfer(void *context, unsigned char *txbuf,
+		    unsigned long txbuf_phy_addr, unsigned char *rxbuf,
+		    unsigned long rxbuf_phy_addr, int len);
+void *smsspiphy_init(void *context, void (*smsspi_interruptHandler) (void *),
+		     void *intr_context);
+void smsspiphy_deinit(void *context);
+void smschipreset(void *context);
+void WriteFWtoStellar(void *pSpiPhy, unsigned char *pFW, unsigned long Len);
+void prepareForFWDnl(void *pSpiPhy);
+void fwDnlComplete(void *context, int App);
+
+#endif /* __SMS_SPI_PHY_H__ */
linux/drivers/media/dvb/siano/smsspiphy_pxa.c +435 -0

435 lines not on this page · raw message

linux/drivers/media/dvb/siano/smsspiphy_pxa.c~ +434 -0

434 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

Le mercredi 19 novembre 2008 10:03:04 Uri Shkolnik, vous avez écrit :

Quoted 5 lines

This patch provides SPI interface driver for SMS chip-set based devices. The patch includes common SMS SPI code, and adapter driver for PXA310

Hi Uri,

This patch also adds backup files ( e.g. smsspicommon.c~ ) ! Maybe others do also, haven't checked.

So, i guess it will be rejected :)

Signature · 7 lines
Christophe Thommeret


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

Please note that this specific patch should be ignored (the diff file contains temporary files) I submit a new patch.

Sorry about this silly silly mistake

Uri

Quoted 15 lines · Christophe Thommeret

From: Christophe Thommeret <[email protected]>
Subject: Re: [linux-dvb] [PATCH 2/5] SPI interface driver for Siano's SMS chip-set based devices.
To: [email protected]
Cc: "Uri Shkolnik" <[email protected]>
Date: Wednesday, November 19, 2008, 12:24 PM
Le mercredi 19 novembre 2008 10:03:04 Uri Shkolnik, vous
avez écrit :

Quoted 1 line

This patch provides SPI interface driver for SMS

chip-set based devices.

Quoted 1 line

The patch includes common SMS SPI code, and adapter

driver for PXA310

Quoted 3 lines
Quoted 10 lines

Hi Uri,

This patch also adds backup files ( e.g. smsspicommon.c~ ) !
Maybe others do also, haven't checked.

So, i guess it will be rejected :)

Signature · 1 line
Christophe Thommeret

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

#3 lore raw

PATCH 1/2 Siano's SMS subsystems API - SmsHost support

Siano DTV module works with three subsystem API (DVB-API v3, DVB-API v5 (S2) and SmsHost)

Until now, only the DVB-API v3 has been supported.
The following two patch's parts add the support for the two other APIs.

The first adds the SmsHost API support. This API supports DTV standards yet to be fully supported by the DVB-API (CMMB, T-DMB and more).

The second part adds support for the DVB-API v5 ("S2")

******

This patch adds Siano subsystem, which supports the CMMB, T-DMB, DVB-H and DAB-IPD TV standards.

This patch adds Siano subsystem, which supports the CMMB and T-DMB DTV standards.
The patch also adds Network interface (network drivers) in order to support the DVB-H and DAB-IP standards.

linux/drivers/media/dvb/siano/smschar.c +652 -0
diff -uNr v4l-dvb-c5f976cab011/linux/drivers/media/dvb/siano/smschar.c v4l-dvb-c5f976cab011_0003/linux/drivers/media/dvb/siano/smschar.c
@@ -0,0 +1,652 @@
+/****************************************************************
+
+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/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+
+#include <linux/kernel.h>	/* printk() */
+#include <linux/fs.h>		/* everything... */
+#include <linux/types.h>	/* size_t */
+#include <linux/cdev.h>
+#include <linux/sched.h>
+#include <linux/poll.h>
+#include <asm/system.h>		/* cli(), *_flags */
+#include <linux/uaccess.h>	/* copy_*_user */
+
+#include "smscoreapi.h"
+
+#include "smscharioctl.h"
+
+/* max number of packets allowed to be pending on queue*/
+#define SMS_CHR_MAX_Q_LEN	15
+#define SMSCHAR_NR_DEVS		7
+
+struct smschar_device_t {
+	struct cdev cdev;	/*!< Char device structure */
+	wait_queue_head_t waitq;	/* Processes waiting */
+	int cancel_waitq;
+	spinlock_t lock;	/*!< critical section */
+	int pending_count;
+	struct list_head pending_data;	/*!< list of pending data */
+	struct smscore_buffer_t *currentcb;
+	int device_index;
+	struct smscore_device_t *coredev;
+	struct smscore_client_t *smsclient;
+};
+
+/*!  Holds the major number of the device node. may be changed at load
+time.*/
+int smschar_major = 251;
+
+/*!  Holds the first minor number of the device node.
+may be changed at load time.*/
+int smschar_minor;  /*= 0*/
+
+/* macros that allow the load time parameters change*/
+module_param(smschar_major, int, S_IRUGO);
+module_param(smschar_minor, int, S_IRUGO);
+
+struct smschar_device_t smschar_devices[SMSCHAR_NR_DEVS];
+static int g_smschar_inuse;
+
+static int g_pnp_status_changed = 1;
+wait_queue_head_t g_pnp_event;
+
+/**
+ * unregisters sms client and returns all queued buffers
+ *
+ * @param dev pointer to the client context (smschar parameters block)
+ *
+ */
+static void smschar_unregister_client(struct smschar_device_t *dev)
+{
+	unsigned long flags;
+
+	if (dev->coredev && dev->smsclient) {
+		dev->cancel_waitq = 1;
+		wake_up_interruptible(&dev->waitq);
+
+		spin_lock_irqsave(&dev->lock, flags);
+
+		while (!list_empty(&dev->pending_data)) {
+			struct smscore_buffer_t *cb =
+			    (struct smscore_buffer_t *)dev->pending_data.next;
+			list_del(&cb->entry);
+
+			smscore_putbuffer(dev->coredev, cb);
+			dev->pending_count--;
+		}
+
+		if (dev->currentcb) {
+			smscore_putbuffer(dev->coredev, dev->currentcb);
+			dev->currentcb = NULL;
+			dev->pending_count--;
+		}
+
+		smscore_unregister_client(dev->smsclient);
+		dev->smsclient = NULL;
+
+		spin_unlock_irqrestore(&dev->lock, flags);
+	}
+}
+
+/**
+ * queues incoming buffers into buffers queue
+ *
+ * @param context pointer to the client context (smschar parameters block)
+ * @param cb pointer to incoming buffer descriptor
+ *
+ * @return 0 on success, <0 on queue overflow.
+ */
+static int smschar_onresponse(void *context, struct smscore_buffer_t *cb)
+{
+	struct smschar_device_t *dev = context;
+	unsigned long flags;
+
+	if (!dev) {
+		sms_err("recieved bad dev pointer\n");
+		return -EFAULT;
+	}
+	spin_lock_irqsave(&dev->lock, flags);
+
+	if (dev->pending_count > SMS_CHR_MAX_Q_LEN) {
+		spin_unlock_irqrestore(&dev->lock, flags);
+		return -EBUSY;
+	}
+
+	dev->pending_count++;
+	/* if data channel, remove header */
+	if (dev->device_index) {
+		cb->size -= sizeof(struct SmsMsgHdr_ST);
+		cb->offset += sizeof(struct SmsMsgHdr_ST);
+	}
+
+	list_add_tail(&cb->entry, &dev->pending_data);
+	spin_unlock_irqrestore(&dev->lock, flags);
+
+	if (waitqueue_active(&dev->waitq))
+		wake_up_interruptible(&dev->waitq);
+
+	return 0;
+}
+
+/**
+ * handles device removal event
+ *
+ * @param context pointer to the client context (smschar parameters block)
+ *
+ */
+static void smschar_onremove(void *context)
+{
+	struct smschar_device_t *dev = (struct smschar_device_t *)context;
+
+	smschar_unregister_client(dev);
+	dev->coredev = NULL;
+}
+
+/**
+ * registers client associated with the node
+ *
+ * @param inode Inode concerned.
+ * @param file File concerned.
+ *
+ * @return 0 on success, <0 on error.
+ */
+static int smschar_open(struct inode *inode, struct file *file)
+{
+	struct smschar_device_t *dev = container_of(inode->i_cdev,
+						    struct smschar_device_t,
+						    cdev);
+	int rc = -ENODEV;
+
+	sms_info("entering index %d\n", dev->device_index);
+	if (dev->coredev) {
+		struct smsclient_params_t params;
+		params.initial_id = dev->device_index ?
+		    dev->device_index : SMS_HOST_LIB;
+		params.data_type = dev->device_index ? MSG_SMS_DAB_CHANNEL : 0;
+		params.onresponse_handler = smschar_onresponse;
+		params.onremove_handler = smschar_onremove;
+		params.context = dev;
+
+		rc = smscore_register_client(dev->coredev, &params,
+					     &dev->smsclient);
+		if (!rc)
+			file->private_data = dev;
+		dev->cancel_waitq = 0;
+		g_pnp_status_changed = 1;
+	}
+
+	if (rc)
+		sms_err(" exiting, rc %d\n", rc);
+
+	return rc;
+}
+
+/**
+ * unregisters client associated with the node
+ *
+ * @param inode Inode concerned.
+ * @param file File concerned.
+ *
+ */
+static int smschar_release(struct inode *inode, struct file *file)
+{
+	smschar_unregister_client(file->private_data);
+
+	sms_info("exiting\n");
+
+	return 0;
+}
+
+/**
+ * copies data from buffers in incoming queue into a user buffer
+ *
+ * @param file File structure.
+ * @param buf Source buffer.
+ * @param count Size of source buffer.
+ * @param f_pos Position in file (ignored).
+ *
+ * @return Number of bytes read, or <0 on error.
+ */
+static ssize_t smschar_read(struct file *file, char __user *buf,
+			    size_t count, loff_t *f_pos)
+{
+	struct smschar_device_t *dev = file->private_data;
+	unsigned long flags;
+	int rc, copied = 0;
+
+	if (!buf) {
+		sms_err("Bad pointer recieved from user.\n");
+		return -EFAULT;
+	}
+	if (!dev->coredev || !dev->smsclient) {
+		sms_err("no client\n");
+		return -ENODEV;
+	}
+	rc = wait_event_interruptible(dev->waitq,
+				      !list_empty(&dev->pending_data)
+				      || (dev->cancel_waitq));
+	if (rc < 0) {
+		sms_err("wait_event_interruptible error %d\n", rc);
+		return rc;
+	}
+	if (dev->cancel_waitq)
+		return 0;
+	if (!dev->smsclient) {
+		sms_err("no client\n");
+		return -ENODEV;
+	}
+	spin_lock_irqsave(&dev->lock, flags);
+
+	while (!list_empty(&dev->pending_data) && (copied < count)) {
+		struct smscore_buffer_t *cb =
+		    (struct smscore_buffer_t *)dev->pending_data.next;
+		int actual_size = min(((int)count - copied), cb->size);
+		if (copy_to_user(&buf[copied], &((char *)cb->p)[cb->offset],
+				 actual_size)) {
+			sms_err("copy_to_user failed\n");
+			spin_unlock_irqrestore(&dev->lock, flags);
+			return -EFAULT;
+		}
+		copied += actual_size;
+		cb->offset += actual_size;
+		cb->size -= actual_size;
+
+		if (!cb->size) {
+			list_del(&cb->entry);
+			smscore_putbuffer(dev->coredev, cb);
+			dev->pending_count--;
+		}
+	}
+	spin_unlock_irqrestore(&dev->lock, flags);
+	return copied;
+}
+
+/**
+ * sends the buffer to the associated device
+ *
+ * @param file File structure.
+ * @param buf Source buffer.
+ * @param count Size of source buffer.
+ * @param f_pos Position in file (ignored).
+ *
+ * @return Number of bytes read, or <0 on error.
+ */
+static ssize_t smschar_write(struct file *file, const char __user *buf,
+			     size_t count, loff_t *f_pos)
+{
+	struct smschar_device_t *dev;
+	void *buffer;
+
+	if (file == NULL) {
+		sms_err("file is NULL\n");
+		return EINVAL;
+	}
+
+	if (file->private_data == NULL) {
+		sms_err("file->private_data is NULL\n");
+		return -EINVAL;
+	}
+
+	dev = file->private_data;
+	if (!dev->smsclient) {
+		sms_err("no client\n");
+		return -ENODEV;
+	}
+
+	buffer = kmalloc(ALIGN(count, SMS_ALLOC_ALIGNMENT) + SMS_DMA_ALIGNMENT,
+			 GFP_KERNEL | GFP_DMA);
+	if (buffer) {
+		void *msg_buffer = (void *)SMS_ALIGN_ADDRESS(buffer);
+
+		if (!copy_from_user(msg_buffer, buf, count))
+			smsclient_sendrequest(dev->smsclient,
+					      msg_buffer, count);
+		else
+			count = 0;
+
+		kfree(buffer);
+	}
+
+	return count;
+}
+
+static int smschar_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	struct smschar_device_t *dev = file->private_data;
+	return smscore_map_common_buffer(dev->coredev, vma);
+}
+
+/**
+ * waits until buffer inserted into a queue. when inserted buffer offset
+ * are reportedto the calling process. previously reported buffer is
+ * returned to smscore pool.
+ *
+ * @param dev pointer to smschar parameters block
+ * @param touser pointer to a structure that receives incoming buffer offsets
+ *
+ * @return 0 on success, <0 on error.
+ */
+static int smschar_wait_get_buffer(struct smschar_device_t *dev,
+				   struct smschar_buffer_t *touser)
+{
+	unsigned long flags;
+	int rc;
+
+	spin_lock_irqsave(&dev->lock, flags);
+
+	if (dev->currentcb) {
+		smscore_putbuffer(dev->coredev, dev->currentcb);
+		dev->currentcb = NULL;
+		dev->pending_count--;
+	}
+
+	spin_unlock_irqrestore(&dev->lock, flags);
+
+	rc = wait_event_interruptible(dev->waitq,
+				      !list_empty(&dev->pending_data)
+				      || (dev->cancel_waitq));
+	if (rc < 0) {
+		sms_err("wait_event_interruptible error, rc=%d\n", rc);
+		return rc;
+	}
+	if (dev->cancel_waitq) {
+		touser->offset = 0;
+		touser->size = 0;
+		return 0;
+	}
+	if (!dev->smsclient) {
+		sms_err("no client\n");
+		return -ENODEV;
+	}
+
+	spin_lock_irqsave(&dev->lock, flags);
+
+	if (!list_empty(&dev->pending_data)) {
+		struct smscore_buffer_t *cb =
+		    (struct smscore_buffer_t *)dev->pending_data.next;
+		touser->offset = cb->offset_in_common + cb->offset;
+		touser->size = cb->size;
+
+		list_del(&cb->entry);
+
+		dev->currentcb = cb;
+	} else {
+		touser->offset = 0;
+		touser->size = 0;
+	}
+
+	spin_unlock_irqrestore(&dev->lock, flags);
+
+	return 0;
+}
+
+/**
+ * poll for data availability
+ *
+ * @param file File structure.
+ * @param wait kernel polling table.
+ *
+ * @return POLLIN flag if read data is available.
+ */
+static unsigned int smschar_poll(struct file *file,
+				 struct poll_table_struct *wait)
+{
+	struct smschar_device_t *dev;
+	int mask = 0;
+
+	if (file == NULL) {
+		sms_err("file is NULL\n");
+		return EINVAL;
+	}
+
+	if (file->private_data == NULL) {
+		sms_err("file->private_data is NULL\n");
+		return -EINVAL;
+	}
+
+	dev = file->private_data;
+
+	if (list_empty(&dev->pending_data)) {
+		sms_info("No data is ready, waiting for data recieve.\n");
+		poll_wait(file, &dev->waitq, wait);
+	}
+
+	if (!list_empty(&dev->pending_data))
+		mask |= POLLIN | POLLRDNORM;
+	return mask;
+}
+
+static int smschar_ioctl(struct inode *inode, struct file *file,
+			 unsigned int cmd, unsigned long arg)
+{
+	struct smschar_device_t *dev = file->private_data;
+	void __user *up = (void __user *)arg;
+
+	if (!dev->coredev || !dev->smsclient) {
+		sms_err("no client\n");
+		return -ENODEV;
+	}
+
+	switch (cmd) {
+	case SMSCHAR_SET_DEVICE_MODE:
+		return smscore_set_device_mode(dev->coredev, (int)arg);
+
+	case SMSCHAR_GET_DEVICE_MODE:
+		{
+			if (put_user(smscore_get_device_mode(dev->coredev),
+				     (int *)up))
+				return -EFAULT;
+			break;
+		}
+	case SMSCHAR_IS_DEVICE_PNP_EVENT:
+		{
+			sms_info("Waiting for PnP event.\n");
+			wait_event_interruptible(g_pnp_event,
+						 !g_pnp_status_changed);
+			g_pnp_status_changed = 0;
+			sms_info("PnP Event %d.\n", g_smschar_inuse);
+			if (put_user(g_smschar_inuse, (int *)up))
+				return -EFAULT;
+			break;
+		}
+	case SMSCHAR_GET_BUFFER_SIZE:
+		{
+			if (put_user
+			    (smscore_get_common_buffer_size(dev->coredev),
+			     (int *)up))
+				return -EFAULT;
+
+			break;
+		}
+
+	case SMSCHAR_WAIT_GET_BUFFER:
+		{
+			struct smschar_buffer_t touser;
+			int rc;
+
+			rc = smschar_wait_get_buffer(dev, &touser);
+			if (rc < 0)
+				return rc;
+
+			if (copy_to_user(up, &touser,
+					 sizeof(struct smschar_buffer_t)))
+				return -EFAULT;
+
+			break;
+		}
+	case SMSCHAR_CANCEL_WAIT_BUFFER:
+		{
+			dev->cancel_waitq = 1;
+			wake_up_interruptible(&dev->waitq);
+			break;
+		}
+	case SMSCHAR_GET_FW_FILE_NAME:
+		{
+			if (!up)
+				return -EINVAL;
+			return smscore_get_fw_filename(dev->coredev,
+				       ((struct
+					 smschar_get_fw_filename_ioctl_t
+					 *)up)->mode,
+				       ((struct
+					 smschar_get_fw_filename_ioctl_t
+					 *)up)->filename);
+		}
+	case SMSCHAR_SEND_FW_FILE:
+		{
+			if (!up)
+				return -EINVAL;
+			return smscore_send_fw_file(dev->coredev,
+					((struct
+					smschar_send_fw_file_ioctl_t
+					*)up)->fw_buf,
+					((struct
+					smschar_send_fw_file_ioctl_t
+					*)up)->fw_size);
+		}
+
+	default:
+		return -ENOIOCTLCMD;
+	}
+
+	return 0;
+}
+
+struct file_operations smschar_fops = {
+	.owner = THIS_MODULE,
+	.read = smschar_read,
+	.write = smschar_write,
+	.open = smschar_open,
+	.release = smschar_release,
+	.mmap = smschar_mmap,
+	.poll = smschar_poll,
+	.ioctl = smschar_ioctl,
+};
+
+static int smschar_setup_cdev(struct smschar_device_t *dev, int index)
+{
+	int rc, devno = MKDEV(smschar_major, smschar_minor + index);
+
+	cdev_init(&dev->cdev, &smschar_fops);
+
+	dev->cdev.owner = THIS_MODULE;
+	dev->cdev.ops = &smschar_fops;
+
+	kobject_set_name(&dev->cdev.kobj, "Siano_sms%d", index);
+	rc = cdev_add(&dev->cdev, devno, 1);
+	sms_info("exiting %p %d, rc %d", dev, index, rc);
+
+	return rc;
+}
+
+/**
+ * smschar callback that called when device plugged in/out. the function
+ * register or unregisters char device interface according to plug in/out
+ *
+ * @param coredev pointer to device that is being plugged in/out
+ * @param device pointer to system device object
+ * @param arrival 1 on plug-on, 0 othewise
+ *
+ * @return 0 on success, <0 on error.
+ */
+static int smschar_hotplug(struct smscore_device_t *coredev,
+			   struct device *device, int arrival)
+{
+	int rc = 0, i;
+
+	sms_info("entering %d\n", arrival);
+
+	g_pnp_status_changed = 1;
+	if (arrival) {
+		/* currently only 1 instance supported */
+		if (!g_smschar_inuse) {
+			/* data notification callbacks assignment */
+			memset(smschar_devices, 0, SMSCHAR_NR_DEVS *
+			       sizeof(struct smschar_device_t));
+
+			/* Initialize each device. */
+			for (i = 0; i < SMSCHAR_NR_DEVS; i++) {
+				sms_info("create device %d", i);
+				smschar_setup_cdev(&smschar_devices[i], i);
+				INIT_LIST_HEAD(&smschar_devices[i].
+					       pending_data);
+				spin_lock_init(&smschar_devices[i].lock);
+				init_waitqueue_head(&smschar_devices[i].waitq);
+
+				smschar_devices[i].coredev = coredev;
+				smschar_devices[i].device_index = i;
+			}
+			g_smschar_inuse = 1;
+			wake_up_interruptible(&g_pnp_event);
+		}
+	} else {
+		/* currently only 1 instance supported */
+		if (g_smschar_inuse) {
+			/* Get rid of our char dev entries */
+			for (i = 0; i < SMSCHAR_NR_DEVS; i++) {
+				cdev_del(&smschar_devices[i].cdev);
+				sms_info("remove device %d\n", i);
+			}
+
+			g_smschar_inuse = 0;
+			wake_up_interruptible(&g_pnp_event);
+		}
+	}
+
+	sms_info("exiting, rc %d\n", rc);
+
+	return rc;		/* succeed */
+}
+
+int smschar_register(void)
+{
+	dev_t devno = MKDEV(smschar_major, smschar_minor);
+	int rc;
+
+	sms_info("registering device major=%d minor=%d\n", smschar_major,
+		 smschar_minor);
+	if (smschar_major) {
+		rc = register_chrdev_region(devno, SMSCHAR_NR_DEVS, "smschar");
+	} else {
+		rc = alloc_chrdev_region(&devno, smschar_minor,
+					 SMSCHAR_NR_DEVS, "smschar");
+		smschar_major = MAJOR(devno);
+	}
+
+	if (rc < 0) {
+		sms_warn("smschar: can't get major %d\n", smschar_major);
+		return rc;
+	}
+	init_waitqueue_head(&g_pnp_event);
+
+	return smscore_register_hotplug(smschar_hotplug);
+}
+
+void smschar_unregister(void)
+{
+	dev_t devno = MKDEV(smschar_major, smschar_minor);
+
+	unregister_chrdev_region(devno, SMSCHAR_NR_DEVS);
+	smscore_unregister_hotplug(smschar_hotplug);
+	sms_info("unregistered\n");
+}
linux/drivers/media/dvb/siano/smscharioctl.h +52 -0

52 lines not on this page · raw message

linux/drivers/media/dvb/siano/smsnet.c +455 -0

455 lines not on this page · raw message

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

#4 lore raw

Re: [linux-dvb] [PATCH 1/2] Siano's SMS subsystems API - SmsHost support

Quoted 7 lines · Uri Shkolnik

Siano DTV module works with three subsystem API (DVB-API v3, DVB-API v5 (S2) and SmsHost)

Until now, only the DVB-API v3 has been supported.
The following two patch's parts add the support for the two other APIs.

The first adds the SmsHost API support. This API supports DTV standards yet to be fully supported by the DVB-API (CMMB, T-DMB and more).

hi, as i live in italy under one of the few trials of T-DMB network, i'm interested in the T-DMB support.
i happen to own a Cinergy Terratec Piranha based on a SMS 100x chipset and under another OS i can lock and see the T-DMB services. i'd like to do the same under linux.

is there some public spec about this SmsHost API to hack a simple application to dump the TS from a T-DMB network?
google doesn't return with much interesting..

thanx

andrea venturi

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

#5 lore raw

Re: [linux-dvb] [PATCH 1/2] Siano's SMS subsystems API - SmsHost support

Quoted 34 lines · Andrea Venturi

From: Andrea Venturi <[email protected]>
Subject: Re: [linux-dvb] [PATCH 1/2] Siano's SMS subsystems API - SmsHost support To:
Cc: [email protected]
Date: Wednesday, November 19, 2008, 7:35 PM

Quoted 1 line · Uri Shkolnik

Siano DTV module works with three subsystem API

(DVB-API v3, DVB-API v5 (S2) and SmsHost)

Quoted 3 lines

Until now, only the DVB-API v3 has been supported. The following two patch's parts add the support

for the two other APIs.

Quoted 2 lines

The first adds the SmsHost API support. This API

supports DTV standards yet to be fully supported by the DVB-API (CMMB, T-DMB and more).

Quoted 1 line

hi, as i live in italy under one of the few trials of T-DMB network,
i'm interested in the T-DMB support.
i happen to own a Cinergy Terratec Piranha based on a SMS 100x chipset
and under another OS i can lock and see the T-DMB services. i'd like to
do the same under linux.

is there some public spec about this SmsHost API to hack a simple
application to dump the TS from a T-DMB network? google doesn't return with much interesting..

thanx

Quoted 7 lines

andrea venturi

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

Hi Andrea,

In order to use T-DMB you need FIB parser to start with. Do you have such parser? Later on you'll need service and components manager and some other stuff as well.

Maybe I can provide you with user-space C library (binary, not source code) that does that and many other T-DMB tasks, if you'll provide me with you system characteristics.

Regards,

Uri

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

#6 lore raw

Re: [linux-dvb] [PATCH 1/2] Siano's SMS subsystems API - SmsHost support

Quoted 4 lines · Uri Shkolnik

Hi Andrea,

In order to use T-DMB you need FIB parser to start with. Do you have such parser? Later on you'll need service and components manager and some other stuff as well.

hi, i didn't get that for T-DMB to be decoded you need to parse some other data structure.. maybe it's because the TS mux is piggybacked on a DAM mux scheme..

i suppose i need to download and read the relevant standards both for DAB and DMB like TS 102 427 and TS 102 428

anyway with regard some stuff about FIC decoding, there's already some source code to peruse and borrow, like this gnuradio software DAB receiver:

http://people.ee.ethz.ch/~andrmuel/files/gnuradio/dab-doc/thesis.pdf
http://people.ee.ethz.ch/~andrmuel/files/gnuradio/gr-dab.tgz

maybe it's a good starting point..

Quoted 2 lines

Maybe I can provide you with user-space C library (binary, not source code) that does that and many other T-DMB tasks, if you'll provide me with you system characteristics.

having a reference implementation, albeit binary, could be also another interesting starting point. thank you for the offering..

we run this stuff on x86 32 bit debian distro.. if you are so kind to provide some binary tools..

thank you again

andrea

Quoted 9 lines

Regards,

Uri

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

#7 lore raw

Re: [linux-dvb] [PATCH 1/2] Siano's SMS subsystems API - SmsHost support

In reply to Uri Shkolnik

Hello Uri; sorry that I have waited so long to reply to this...

Quoted 1 line · Uri Shkolnik

The first adds the SmsHost API support. This API supports DTV standards yet to be fully supported by the DVB-API (CMMB, T-DMB and more).

The patches have all applied cleanly, and built properly, thank you. (Or, at least, I had no problems.)

However, what I have is probably a complete-newbie question, that I should be ashamed to ask, because I *should* know better.

Is there a particular Linux distribution for which the Siano source code is intended, and, exactly what should I expect to see in /dev when I successfully load the module with my device?

I ask this because on my test system, /dev major number 251 appears to be used by `usbdev' -- I'm using ``udev'' on what I think is a sort-of-recent Debian system; whether I've updated udev' here I can't say without looking -- I know I updated udev' on an earlier Debian system if not the one I'm running now...

I see on the static /dev (before possible `udev') that I have mounted from my earlier Debian, before I decided that trying to keep up-to-date was best done by a fresh install -- that /dev major 251 is unused there.

I've updated `udev' independent of the rest of the OS in the past out of necessity, and while I have not been able to kill off the part of my brane that haunts me with the memory of glowing tubes/valves, I can no longer remember any details of my `udev' hacking.

Of course, I can use module-load-parameters to specify a different major number, but I don't see any anticipated character devices getting created upon module load -- if I need to physically disconnect and reconnect the device for this, then my apologies, as I didn't get around to that. Yet.

I am sure I'm either doing something stupid, or I've been to lazy to fix `udev' for myself, but I'm asking this to try to help me save a few hours re-learning everything I've forgotten about devices...

Of course, if Sir Mkrufky@ already has a fix in the works for this, then I'll just shut up for a short spell.

Thanks!
barry bouwsma

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

#8 lore raw

Re: [linux-dvb] [PATCH 1/2] Siano's SMS subsystems API - SmsHost support

Quoted 8 lines · BOUWSMA Barry

From: BOUWSMA Barry <[email protected]>
Subject: Re: [linux-dvb] [PATCH 1/2] Siano's SMS subsystems API - SmsHost support
To: "Uri Shkolnik" <[email protected]>
Cc: [email protected]
Date: Friday, December 5, 2008, 9:08 PM
Hello Uri; sorry that I have waited so long to reply to
this...

Quoted 9 lines
Quoted 1 line · Uri Shkolnik

The first adds the SmsHost API support. This API

supports DTV standards yet to be fully supported by the DVB-API (CMMB, T-DMB and more).

The patches have all applied cleanly, and built properly, thank you. (Or, at least, I had no problems.)

Cool. 10x.

Quoted 6 lines

However, what I have is probably a complete-newbie question,
that I should be ashamed to ask, because I *should* know better.

Quoted 7 lines

Is there a particular Linux distribution for which the Siano
source code is intended, and, exactly what should I expect to
see in /dev when I successfully load the module with my device?

Siano currently has dozens++ of customers using various flavors of Linux. Desktop systems (multiple distributions), embedded Linux (many types and targets) and some Linux derivative systems.

Some use Linux DVB v3 API, most don't (either their system are too small, and the kernel and user space are tailored to the specific target/product, or the DTV standards is unsupported by the DVB sub-system (CMMB, T-DMB and more)).

The Siano (mini/tini) sub-system comes to answer that need.

But....

In order to use the Siano sub-system you need to have C library in user space, and a compatible player (with most DTV standards, just DVB-H can be used with any RTP enabled multimedia player with the proper CODECs).

This C library is supplied usually only to commercial customer because that in many cases it evolve to a direct support given by Siano, simply because there is no other support resource... (as always, every rule has its own exceptions). Andrea Venturi asked this library about 10 days ago, and this request went up to Siano's VP of marketing....(still pending)

Siano is committed to support the LinuxTV community. But to support individual end-users its quite an overstretch...

Anyway, dev node 251 is defined as "experimental/test" node, and is used by Siano for communication between the kernel's sub-system and the user space library and multimedia player (e.g. both control and data paths).

Quoted 44 lines

I ask this because on my test system, /dev major number 251 appears to be used by `usbdev' -- I'm using ``udev'' on what
I think is a sort-of-recent Debian system; whether I've updated
`udev' here I can't say without looking -- I know I updated
`udev' on an earlier Debian system if not the one I'm running now...

I see on the static /dev (before possible `udev') that I have
mounted from my earlier Debian, before I decided that trying
to keep up-to-date was best done by a fresh install -- that /dev major 251 is unused there.

I've updated `udev' independent of the rest of the OS in
the past out of necessity, and while I have not been able to kill off the part of my brane that haunts me with the memory of glowing tubes/valves, I can no longer remember any details of my `udev' hacking.

Of course, I can use module-load-parameters to specify a different major number, but I don't see any anticipated character devices getting created upon module load -- if I need to physically disconnect and reconnect the device for this, then my apologies, as I didn't get around to that.
Yet.

I am sure I'm either doing something stupid, or I've been
to lazy to fix `udev' for myself, but I'm asking this to
try to help me save a few hours re-learning everything I've
forgotten about devices...

Quoted 3 lines

Of course, if Sir Mkrufky@ already has a fix in the works for this, then I'll just shut up for a short spell.

"Sir Mkrufky" ?
I like that... I'll ask Mike if I'm too have the privilege to refer him with that title....

Quoted 3 lines

Thanks!
barry bouwsma

Welcome...
Uri

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

#9 lore raw

Re: [linux-dvb] [PATCH 1/2] Siano's SMS subsystems API - SmsHost support

Quoted 11 lines · Uri Shkolnik
Quoted 10 lines
Quoted 1 line

The first adds the SmsHost API support. This API

supports DTV standards yet to be fully supported by the DVB-API (CMMB, T-DMB and more).

Is there a particular Linux distribution for which the Siano
source code is intended, and, exactly what should I expect to
see in /dev when I successfully load the module with my device?

Quoted 4 lines

Siano currently has dozens++ of customers using various flavors of Linux. Desktop systems (multiple distributions), embedded Linux (many types and targets) and some Linux derivative systems.

Okay, thanks. Now I see that I should not need to rely on features of a particular distribution...

Quoted 4 lines

Some use Linux DVB v3 API, most don't (either their system are too small, and the kernel and user space are tailored to the specific target/product, or the DTV standards is unsupported by the DVB sub-system (CMMB, T-DMB and more)).

You probably remember this, but just in case anyone else is at all concerned, my interest for now is in DAB/DAB+ radio reception, for which the v3 API obviously is of no help.

As far as I know, while the v5 API can include other norms than DVB/ATSC, such as ISDB, it does not yet have support for the DMB/DAB family -- and so, I will need to use the SmsHost and character devices. At least, until it is decided whether and how to fit DAB into v5...

(I do not expect that the other part of your patch, which will provide API v5 support, will resolve this, but I'll nonetheless wait to see...)

Quoted 2 lines

In order to use the Siano sub-system you need to have C library in user space

Understood. This is also the part which I am hoping to be able to avoid, hacking my own userspace tools to accomplish the minimum that I need to tune a particular DAB ensemble, and pull the data out and somehow parse it into an mp2 stream.

Of course, I must do this step-by-step. The easy part was to apply the diffs; now the next step seems to be for me to get the device nodes to appear, so that then I can ask about tuning...

Quoted 2 lines

Siano is committed to support the LinuxTV community. But to support individual end-users its quite an overstretch...

I appreciate this, especially with the bad experience that I and several other users and developers have just had with other products.

And I'm hoping that the Linux community can also work to help itself, so that you don't need to be bothered by individuals such as myself, instead supporting competent individuals such as The Honourable Mr Krufky and anyone else with whom you have been in developmental contact. So, I'll pass along to other readers some of the things I've learned so far, in hopes that others can benefit from them.

Quoted 4 lines

Anyway, dev node 251 is defined as "experimental/test" node, and is used by Siano for communication between the kernel's sub-system and the user space library and multimedia player (e.g. both control and data paths).

It appears that on my recent udev'-afflicted system, this assigned range of experimental majors 240-254 is dynamically allocated from the top down on a first-come, first-served basis. Here's what I see in part when I cat /proc/devices` ...

212 DVB
249 smschar
250 hidraw
251 usb_endpoint
252 usbmon
253 bsg
254 pcmcia

So, in my case, when loading the smsmdtv.ko module that I've built, I have needed to override the default -- while on my much older production system, nothing is seen above major 212.

By the way, if it's not obvious to anyone else wanting to play with this, move any
/lib/modules/uname -r/kernel/drivers/media/dvb/siano/sms1xxx.ko out of the way so that it doesn't get automagically loaded while you're playing...

However, when reading the patch you provided, I see that I can also specify this smschar_major' module parameter as 0; then a suitable value will be selected (however, apparently it doesn't get revealed in the dmesg' output, should I choose this -- I'll try to offer a debug patch later).

Other useful module parameters are `debug' (debug=3 for me), and default_mode -- the default being DVB-T BDA operation.

In my case, `default_mode=2' loads the firmware to support DAB and by extension T-DMB. Other values, seen in the siano/smscoreapi.h file, would be =1 for DVB-H, or =3 for T-DMB/DAB-IP -- how this differs from mode 2 I don't know, and I don't know which is the better choice for me yet. The default is =4; ISDB-T is likely to be =6 (BDA driver); and CMMB is =7. For those too lazy to look at the source.

There may be special attention needed to providing the firmware in the right place -- it ``just works'' for me so I've managed to get that right a long time ago. That is, I see `dmesg' output like
smsusb1_detectmode: 2 "SMS TDMB Receiver"
and I am momentarily at peace with the world.

So I see that smschar_register() succeeds and the major number is assigned appropriately. Additionally, smschar_setup_cdev() succeeds for the seven devices. At the moment for me, I don't get anything appearing anywhere in /dev with the proper major number, or for that matter, in /sys/dev/char or anywhere else in sysfs that I've seen.

I'm comparing the dvb-core source before I hack blindly, but if I may ask another stupid question, would creating the device at the appropriate major number also be handled by the C library to which you have referred, or perhaps by a user application to handle tuning? And, also, I suspect that as the source you posted allows me to handle the case where dev major 251 is already in use, as well as choosing a non-default minor, the userspace library will also handle this.

It's obvious that I'm not a device driver author, and I don't expect you to help with these simple questions that are purely Linux-related -- I've a google and I know how to use it! It just takes time...

Quoted 2 lines

"Sir Mkrufky" ? I like that... I'll ask Mike if I'm too have the privilege to refer him with that title....

I have heard it said that sweets work well to attract, well, something. So I prefer to address people the way I don't deserve to be treated. If nothing else, it's usually good to reduce the recipient to giggling helplessly.

On the other hand, I've experimented and set out a lump of sugar, along with some rotten month-old cheese, some apple vinegar, decaying liquefying vegetables, and the like, and strangely, all the bugs and flies were not drawn to the lump of sweetness. Draw your own conclusion, but, well, my dinner is waiting...

Anyway, Sir Shkolnik (I'm sorry, may I call you Sir?), thank you for your help, and I'll go back to hacking on the source to see what I can make appear...

barry bouwsma

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