/*
 * AIRcable USB Bluetooth Dongle Driver.
 *
 * Copyright (C) 2006 Manuel Francisco Naranjo (naranjo.manuel@gmail.com)
 * 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.
 *
 * The device works as an standard CDC device, it has 2 interfaces, the first
 * one is for firmware access and the second is the serial one.
 * The protocol is very simply, there are two posibilities reading or writing.
 * When writting the first urb must have a Header that starts with 0x20 0x29 the
 * next two bytes must say how much data will be sended.
 * When reading the process is almost equal except that the header starts with
 * 0x00 0x20.
 *
 * The device simply need some stuff to understand data comming from the usb
 * buffer: The First and Second byte is used for a Header, the Third and Fourth
 * tells the  device the amount of information the package holds.
 * Packages are 60 bytes long Header Stuff.
 * When writting to the device the first two bytes of the header are 0x20 0x29
 * When reading the bytes are 0x00 0x20, or 0x00 0x10, there is an strange
 * situation, when too much data arrives to the device because it sends the data
 * but with out the header. I will use a simply hack to override this situation,
 * if there is data coming that does not contain any header, then that is data
 * that must go directly to the tty, as there is no documentation about if there
 * is any other control code, I will simply check for the first
 * one.
 *
 * The driver registers himself with the USB-serial core and the USB Core. I had
 * to implement a probe function agains USB-serial, because other way, the
 * driver was attaching himself to both interfaces. I have tryed with different
 * configurations of usb_serial_driver with out exit, only the probe function
 * could handle this correctly.
 *
 * I have taken some info from a Greg Kroah-Hartman article:
 * http://www.linuxjournal.com/article/6573
 * And from Linux Device Driver Kit CD, which is a great work, the authors taken
 * the work to recompile lots of information an knowladge in drivers development
 * and made it all avaible inside a cd.
 * URL: http://kernel.org/pub/linux/kernel/people/gregkh/ddk/
 *
 */

#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/circ_buf.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>

static int debug;

/* Vendor and Product ID */
#define AIRCABLE_VID		0x16CA
#define AIRCABLE_USB_PID	0x1502

/* write buffer size defines */
#define AIRCABLE_BUF_SIZE	2048

/* Protocol Stuff */
#define HCI_HEADER_LENGTH	0x4
#define TX_HEADER_0		0x20
#define TX_HEADER_1		0x29
#define RX_HEADER_0		0x00
#define RX_HEADER_1		0x20
#define MAX_HCI_FRAMESIZE	60
#define HCI_COMPLETE_FRAME	64

/* rx_flags */
#define THROTTLED		0x01
#define ACTUALLY_THROTTLED	0x02

/*
 * Version Information
 */
#define DRIVER_VERSION "v1.0b2"
#define DRIVER_AUTHOR "Naranjo, Manuel Francisco <naranjo.manuel@gmail.com>"
#define DRIVER_DESC "AIRcable USB Driver"

/* ID table that will be registered with USB core */
static struct usb_device_id id_table [] = {
	{ USB_DEVICE(AIRCABLE_VID, AIRCABLE_USB_PID) },
	{ },
};
MODULE_DEVICE_TABLE(usb, id_table);


/* Internal Structure */
struct aircable_private {
	spinlock_t rx_lock;		/* spinlock for the receive lines */
	struct circ_buf *tx_buf;	/* write buffer */
	struct circ_buf *rx_buf;	/* read buffer */
	int rx_flags;			/* for throttilng */
	struct work_struct rx_work;	/* work cue for the receiving line */
};

/* Private methods */

/* Circular Buffer Methods, code from ti_usb_3410_5052 used */
/*
 * serial_buf_clear
 *
 * Clear out all data in the circular buffer.
 */
static void serial_buf_clear(struct circ_buf *cb)
{
	cb->head = cb->tail = 0;
}

/*
 * serial_buf_alloc
 *
 * Allocate a circular buffer and all associated memory.
 */
static struct circ_buf *serial_buf_alloc(void)
{
	struct circ_buf *cb;
	cb = kmalloc(sizeof(struct circ_buf), GFP_KERNEL);
	if (cb == NULL)
		return NULL;
	cb->buf = kmalloc(AIRCABLE_BUF_SIZE, GFP_KERNEL);
	if (cb->buf == NULL) {
		kfree(cb);
		return NULL;
	}
	serial_buf_clear(cb);
	return cb;
}

/*
 * serial_buf_free
 *
 * Free the buffer and all associated memory.
 */
static void serial_buf_free(struct circ_buf *cb)
{
	kfree(cb->buf);
	kfree(cb);
}

/*
 * serial_buf_data_avail
 *
 * Return the number of bytes of data available in the circular
 * buffer.
 */
static int serial_buf_data_avail(struct circ_buf *cb)
{
	return CIRC_CNT(cb->head,cb->tail,AIRCABLE_BUF_SIZE);
}

/*
 * serial_buf_put
 *
 * Copy data data from a user buffer and put it into the circular buffer.
 * Restrict to the amount of space available.
 *
 * Return the number of bytes copied.
 */
static int serial_buf_put(struct circ_buf *cb, const char *buf, int count)
{
	int c, ret = 0;
	while (1) {
		c = CIRC_SPACE_TO_END(cb->head, cb->tail, AIRCABLE_BUF_SIZE);
		if (count < c)
			c = count;
		if (c <= 0)
			break;
		memcpy(cb->buf + cb->head, buf, c);
		cb->head = (cb->head + c) & (AIRCABLE_BUF_SIZE-1);
		buf += c;
		count -= c;
		ret= c;
	}
	return ret;
}

/*
 * serial_buf_get
 *
 * Get data from the circular buffer and copy to the given buffer.
 * Restrict to the amount of data available.
 *
 * Return the number of bytes copied.
 */
static int serial_buf_get(struct circ_buf *cb, char *buf, int count)
{
	int c, ret = 0;
	while (1) {
		c = CIRC_CNT_TO_END(cb->head, cb->tail, AIRCABLE_BUF_SIZE);
		if (count < c)
			c = count;
		if (c <= 0)
			break;
		memcpy(buf, cb->buf + cb->tail, c);
		cb->tail = (cb->tail + c) & (AIRCABLE_BUF_SIZE-1);
		buf += c;
		count -= c;
		ret= c;
	}
	return ret;
}

/* End of circula buffer methods */

static void aircable_send(struct usb_serial_port *port)
{
	int count, result;
	struct aircable_private *priv = usb_get_serial_port_data(port);
	unsigned char* buf;
	dbg("%s - port %d", __FUNCTION__, port->number);
	if (port->write_urb_busy)
		return;

	count = min(serial_buf_data_avail(priv->tx_buf), MAX_HCI_FRAMESIZE);
	if (count == 0)
		return;

	buf = kzalloc(count + HCI_HEADER_LENGTH, GFP_ATOMIC);
	if (!buf) {
		err("%s- kzalloc(%d) failed.", __FUNCTION__,
		    count + HCI_HEADER_LENGTH);
		return;
	}

	buf[0] = TX_HEADER_0;
	buf[1] = TX_HEADER_1;
	buf[2] = (unsigned char)count;
	buf[3] = (unsigned char)(count >> 8);
	serial_buf_get(priv->tx_buf,buf + HCI_HEADER_LENGTH, MAX_HCI_FRAMESIZE);

	memcpy(port->write_urb->transfer_buffer, buf,
	       count + HCI_HEADER_LENGTH);

	kfree(buf);
	port->write_urb_busy = 1;
	usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
			      count + HCI_HEADER_LENGTH,
			      port->write_urb->transfer_buffer);
	port->write_urb->transfer_buffer_length = count + HCI_HEADER_LENGTH;
	port->write_urb->dev = port->serial->dev;
	result = usb_submit_urb(port->write_urb, GFP_ATOMIC);

	if (result) {
		dev_err(&port->dev,
			"%s - failed submitting write urb, error %d\n",
			__FUNCTION__, result);
		port->write_urb_busy = 0;
	}

	schedule_work(&port->work);
}

static void aircable_read(void *params)
{
	struct usb_serial_port *port = params;
	struct aircable_private *priv = usb_get_serial_port_data(port);
	struct tty_struct *tty;
	unsigned char *data;
	int count;
	if (priv->rx_flags & THROTTLED){
		if (priv->rx_flags & ACTUALLY_THROTTLED)
			schedule_work(&priv->rx_work);
		return;
	}

	/* By now I will flush data to the tty in packages of no more than
	 * 64 bytes, to ensure I do not get throttled.
	 * Ask USB mailing list for better aproach.
	 */
	tty = port->tty;

	if (!tty) {
		schedule_work(&priv->rx_work);
		err("%s - No tty available", __FUNCTION__);
		return ;
	}

	count = min(64, serial_buf_data_avail(priv->rx_buf));

	if (count <= 0)
		return; //We have finished sending everything.

	tty_prepare_flip_string(tty, &data, count);
	if (!data){
		err("%s- kzalloc(%d) failed.", __FUNCTION__, count);
		return;
	}

	serial_buf_get(priv->rx_buf, data, count);

	tty_flip_buffer_push(tty);

	if (serial_buf_data_avail(priv->rx_buf))
		schedule_work(&priv->rx_work);

	return;
}
/* End of private methods */

static int aircable_probe(struct usb_serial *serial,
			  const struct usb_device_id *id)
{
	struct usb_host_interface *iface_desc = serial->interface->cur_altsetting;
	struct usb_endpoint_descriptor *endpoint;
	int num_bulk_out=0;
	int i;

	for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
		endpoint = &iface_desc->endpoint[i].desc;
		if (usb_endpoint_is_bulk_out(endpoint)) {
			dbg("found bulk out on endpoint %d", i);
			++num_bulk_out;
		}
	}

	if (num_bulk_out == 0) {
		dbg("Invalid interface, discarding");
		return -ENODEV;
	}

	return 0;
}

static int aircable_attach (struct usb_serial *serial)
{
	struct usb_serial_port *port = serial->port[0];
	struct aircable_private *priv;

	priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL);
	if (!priv){
		err("%s- kmalloc(%Zd) failed.", __FUNCTION__,
			sizeof(struct aircable_private));
		return -ENOMEM;
	}

	/* Allocation of Circular Buffers */
	priv->tx_buf = serial_buf_alloc();
	if (priv->tx_buf == NULL) {
		kfree(priv);
		return -ENOMEM;
	}

	priv->rx_buf = serial_buf_alloc();
	if (priv->rx_buf == NULL) {
		kfree(priv->tx_buf);
		kfree(priv);
		return -ENOMEM;
	}

	priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED);
	INIT_WORK(&priv->rx_work, aircable_read, port);

	usb_set_serial_port_data(serial->port[0], priv);

	return 0;
}

static void aircable_shutdown(struct usb_serial *serial)
{

	struct usb_serial_port *port = serial->port[0];
	struct aircable_private *priv = usb_get_serial_port_data(port);

	dbg("%s", __FUNCTION__);

	if (priv) {
		serial_buf_free(priv->tx_buf);
		serial_buf_free(priv->rx_buf);
		usb_set_serial_port_data(port, NULL);
		kfree(priv);
	}
}

static int aircable_write_room(struct usb_serial_port *port)
{
	struct aircable_private *priv = usb_get_serial_port_data(port);
	return serial_buf_data_avail(priv->tx_buf);
}

static int aircable_write(struct usb_serial_port *port,
			  const unsigned char *source, int count)
{
	struct aircable_private *priv = usb_get_serial_port_data(port);
	int temp;

	dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count);

	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, source);

	if (!count){
		dbg("%s - write request of 0 bytes", __FUNCTION__);
		return count;
	}

	temp = serial_buf_put(priv->tx_buf, source, count);

	aircable_send(port);

	if (count > AIRCABLE_BUF_SIZE)
		count = AIRCABLE_BUF_SIZE;

	return count;

}

static void aircable_write_bulk_callback(struct urb *urb)
{
	struct usb_serial_port *port = urb->context;
	int result;

	dbg("%s - urb->status: %d", __FUNCTION__ , urb->status);

	/* This has been taken from cypress_m8.c cypress_write_int_callback */
	switch (urb->status) {
		case 0:
			/* success */
			break;
		case -ECONNRESET:
		case -ENOENT:
		case -ESHUTDOWN:
			/* this urb is terminated, clean up */
			dbg("%s - urb shutting down with status: %d",
			    __FUNCTION__, urb->status);
			port->write_urb_busy = 0;
			return;
		default:
			/* error in the urb, so we have to resubmit it */
			dbg("%s - Overflow in write", __FUNCTION__);
			dbg("%s - nonzero write bulk status received: %d",
			    __FUNCTION__, urb->status);
			port->write_urb->transfer_buffer_length = 1;
			port->write_urb->dev = port->serial->dev;
			result = usb_submit_urb(port->write_urb, GFP_KERNEL);
			if (result)
				dev_err(&urb->dev->dev,
					"%s - failed resubmitting write urb, error %d\n",
					__FUNCTION__, result);
			else
				return;
	}

	port->write_urb_busy = 0;

	aircable_send(port);
}

static void aircable_read_bulk_callback(struct urb *urb)
{
	struct usb_serial_port *port = urb->context;
	struct aircable_private *priv = usb_get_serial_port_data(port);
	struct tty_struct *tty;
	unsigned long no_packages, remaining, package_length, i;
	int result, shift = 0;
	unsigned char *temp;

	dbg("%s - port %d", __FUNCTION__, port->number);

	if (urb->status) {
		dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
		if (!port->open_count) {
			dbg("%s - port is closed, exiting.", __FUNCTION__);
			return;
		}
		if (urb->status == -EPROTO) {
			dbg("%s - caught -EPROTO, resubmitting the urb",
			    __FUNCTION__);
			usb_fill_bulk_urb(port->read_urb, port->serial->dev,
					  usb_rcvbulkpipe(port->serial->dev,
					  		  port->bulk_in_endpointAddress),
					  port->read_urb->transfer_buffer,
					  port->read_urb->transfer_buffer_length,
					  aircable_read_bulk_callback, port);

			result = usb_submit_urb(urb, GFP_ATOMIC);
			if (result)
				dev_err(&urb->dev->dev,
					"%s - failed resubmitting read urb, error %d\n",
					__FUNCTION__, result);
			return;
		}
		dbg("%s - unable to handle the error, exiting.", __FUNCTION__);
		return;
	}

	usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
				urb->actual_length,urb->transfer_buffer);

	tty = port->tty;
	if (tty && urb->actual_length) {
		if (urb->actual_length <= 2) {
			/* This is an incomplete package */
			serial_buf_put(priv->rx_buf, urb->transfer_buffer,
				       urb->actual_length);
		} else {
			temp = urb->transfer_buffer;
			if (temp[0] == RX_HEADER_0)
				shift = HCI_HEADER_LENGTH;

			remaining = urb->actual_length;
			no_packages = urb->actual_length / (HCI_COMPLETE_FRAME);

			if (urb->actual_length % HCI_COMPLETE_FRAME != 0)
				no_packages+=1;

			for (i = 0; i < no_packages ;i++) {
				if (remaining > (HCI_COMPLETE_FRAME))
					package_length = HCI_COMPLETE_FRAME;
				else
					package_length = remaining;
				remaining -= package_length;

				serial_buf_put(priv->rx_buf,
					urb->transfer_buffer + shift +
					(HCI_COMPLETE_FRAME) * (i),
					package_length - shift);
			}
		}
		aircable_read(port);
	}

	/* Schedule the next read _if_ we are still open */
	if (port->open_count) {
		usb_fill_bulk_urb(port->read_urb, port->serial->dev,
				  usb_rcvbulkpipe(port->serial->dev,
				  		  port->bulk_in_endpointAddress),
				  port->read_urb->transfer_buffer,
				  port->read_urb->transfer_buffer_length,
				  aircable_read_bulk_callback, port);

		result = usb_submit_urb(urb, GFP_ATOMIC);
		if (result)
			dev_err(&urb->dev->dev,
				"%s - failed resubmitting read urb, error %d\n",
				__FUNCTION__, result);
	}

	return;
}

/* Based on ftdi_sio.c throttle */
static void aircable_throttle(struct usb_serial_port *port)
{
	struct aircable_private *priv = usb_get_serial_port_data(port);
	unsigned long flags;

	dbg("%s - port %d", __FUNCTION__, port->number);

	spin_lock_irqsave(&priv->rx_lock, flags);
	priv->rx_flags |= THROTTLED;
	spin_unlock_irqrestore(&priv->rx_lock, flags);
}

/* Based on ftdi_sio.c unthrottle */
static void aircable_unthrottle(struct usb_serial_port *port)
{
	struct aircable_private *priv = usb_get_serial_port_data(port);
	int actually_throttled;
	unsigned long flags;

	dbg("%s - port %d", __FUNCTION__, port->number);

	spin_lock_irqsave(&priv->rx_lock, flags);
	actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED;
	priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED);
	spin_unlock_irqrestore(&priv->rx_lock, flags);

	if (actually_throttled)
		schedule_work(&priv->rx_work);
}

static struct usb_serial_driver aircable_device = {
	.description =		"aircable",
	.id_table = 		id_table,
	.num_ports =		1,
	.attach =		aircable_attach,
	.probe =		aircable_probe,
	.shutdown =		aircable_shutdown,
	.write =		aircable_write,
	.write_room =		aircable_write_room,
	.write_bulk_callback =	aircable_write_bulk_callback,
	.read_bulk_callback =	aircable_read_bulk_callback,
	.throttle =		aircable_throttle,
	.unthrottle =		aircable_unthrottle,
};

static struct usb_driver aircable_driver = {
	.name =		"aircable",
	.probe =	usb_serial_probe,
	.disconnect =	usb_serial_disconnect,
	.id_table =	id_table,
};

static int __init aircable_init (void)
{
	int retval;
	retval = usb_serial_register(&aircable_device);
	if (retval)
		goto failed_serial_register;
	retval = usb_register(&aircable_driver);
	if (retval)
		goto failed_usb_register;
	return 0;

failed_serial_register:
	usb_serial_deregister(&aircable_device);
failed_usb_register:
	return retval;
}

static void __exit aircable_exit (void)
{
	usb_deregister(&aircable_driver);
	usb_serial_deregister(&aircable_device);
}

MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_VERSION(DRIVER_VERSION);
MODULE_LICENSE("GPL");

module_init(aircable_init);
module_exit(aircable_exit);

module_param(debug, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Debug enabled or not");
