summaryrefslogtreecommitdiff
path: root/package/lqtapi/src/include/linux
diff options
context:
space:
mode:
authorblogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-11-03 19:12:34 +0000
committerblogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-11-03 19:12:34 +0000
commit6ea7ec75d2fe0dd52bc3e86135412bfc92c3158c (patch)
tree1b900bd32ce90c62703905c460db950c7c2ba9ec /package/lqtapi/src/include/linux
parent74f6f2f5a244b9ba7aec5d7114fe763f8c20e96c (diff)
[ifxmips]
* adds a rewrite of the tapi drivers + sip app. this is the result of lars' gsoc 2010 project, Thanks ! git-svn-id: svn://svn.openwrt.org/openwrt/trunk@23840 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/lqtapi/src/include/linux')
-rw-r--r--package/lqtapi/src/include/linux/tapi/tapi-event.h37
-rw-r--r--package/lqtapi/src/include/linux/tapi/tapi-ioctl.h20
-rw-r--r--package/lqtapi/src/include/linux/tapi/tapi.h231
3 files changed, 288 insertions, 0 deletions
diff --git a/package/lqtapi/src/include/linux/tapi/tapi-event.h b/package/lqtapi/src/include/linux/tapi/tapi-event.h
new file mode 100644
index 0000000000..925c71369d
--- /dev/null
+++ b/package/lqtapi/src/include/linux/tapi/tapi-event.h
@@ -0,0 +1,37 @@
+#ifndef __LINUX_TAPI_TAPI_EVENT_H__
+#define __LINUX_TAPI_TAPI_EVENT_H__
+
+
+struct tapi_device;
+struct tapi_port;
+
+struct tapi_hook_event {
+ bool on;
+};
+
+struct tapi_dtmf_event {
+ unsigned char code;
+};
+
+enum tapi_event_type {
+ TAPI_EVENT_TYPE_HOOK,
+ TAPI_EVENT_TYPE_DTMF,
+};
+
+struct tapi_event {
+ struct timeval time;
+ enum tapi_event_type type;
+ unsigned int port;
+ union {
+ struct tapi_hook_event hook;
+ struct tapi_dtmf_event dtmf;
+ };
+};
+
+void tapi_report_event(struct tapi_device *tdev, struct tapi_event *event);
+void tapi_report_hook_event(struct tapi_device *tdev, struct tapi_port *port,
+ bool on);
+void tapi_report_dtmf_event(struct tapi_device *tdev, struct tapi_port *port,
+ unsigned char code);
+
+#endif
diff --git a/package/lqtapi/src/include/linux/tapi/tapi-ioctl.h b/package/lqtapi/src/include/linux/tapi/tapi-ioctl.h
new file mode 100644
index 0000000000..c43fac1e73
--- /dev/null
+++ b/package/lqtapi/src/include/linux/tapi/tapi-ioctl.h
@@ -0,0 +1,20 @@
+
+#include <linux/ioctl.h>
+
+#define TAPI_MAGIC 't'
+#define TAPI_IOCTL(x) _IO(TAPI_MAGIC, (x))
+
+#define TAPI_CONTROL_IOCTL_LINK_ALLOC TAPI_IOCTL(0)
+#define TAPI_CONTROL_IOCTL_LINK_FREE TAPI_IOCTL(1)
+#define TAPI_CONTROL_IOCTL_LINK_ENABLE TAPI_IOCTL(2)
+#define TAPI_CONTROL_IOCTL_LINK_DISABLE TAPI_IOCTL(3)
+
+#define TAPI_CONTROL_IOCTL_SYNC TAPI_IOCTL(4)
+
+#define TAPI_PORT_IOCTL_GET_ENDPOINT TAPI_IOCTL(5)
+#define TAPI_PORT_IOCTL_SET_RING TAPI_IOCTL(6)
+
+#define TAPI_STREAM_IOCTL_GET_ENDPOINT TAPI_IOCTL(7)
+#define TAPI_STREAM_IOCTL_CONFIGURE TAPI_IOCTL(8)
+#define TAPI_STREAM_IOCTL_START TAPI_IOCTL(9)
+#define TAPI_STREAM_IOCTL_STOP TAPI_IOCTL(10)
diff --git a/package/lqtapi/src/include/linux/tapi/tapi.h b/package/lqtapi/src/include/linux/tapi/tapi.h
new file mode 100644
index 0000000000..410655d4c9
--- /dev/null
+++ b/package/lqtapi/src/include/linux/tapi/tapi.h
@@ -0,0 +1,231 @@
+#ifndef __LINUX_TAPI_H__
+#define __LINUX_TAPI_H__
+
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/mutex.h>
+
+#include <linux/input.h>
+
+#include <asm/atomic.h>
+#include <linux/list.h>
+
+#include <linux/cdev.h>
+
+#include <linux/skbuff.h>
+#include <linux/wait.h>
+
+#include <linux/tapi/tapi-event.h>
+
+struct tapi_device;
+
+struct tapi_char_device {
+ struct tapi_device *tdev;
+ struct device dev;
+ struct cdev cdev;
+};
+
+static inline struct tapi_char_device *cdev_to_tapi_char_device(struct cdev *cdev)
+{
+ return container_of(cdev, struct tapi_char_device, cdev);
+}
+
+int tapi_char_device_register(struct tapi_device *tdev,
+ struct tapi_char_device *tchrdev, const struct file_operations *fops);
+
+
+struct tapi_endpoint {
+ unsigned int id;
+ void *data;
+};
+
+static inline void tapi_endpoint_set_data(struct tapi_endpoint *ep, void *data)
+{
+ ep->data = data;
+}
+
+static inline void *tapi_endpoint_get_data(struct tapi_endpoint *ep)
+{
+ return ep->data;
+}
+
+struct tapi_port {
+ unsigned int id;
+ struct tapi_endpoint ep;
+ struct input_dev *input;
+ struct tapi_char_device chrdev;
+};
+
+struct tapi_stream {
+ unsigned int id;
+ struct list_head head;
+ struct tapi_endpoint ep;
+
+ struct sk_buff_head recv_queue;
+ wait_queue_head_t recv_wait;
+ struct sk_buff_head send_queue;
+};
+
+struct tapi_link {
+ unsigned int id;
+ struct list_head head;
+};
+
+enum tapi_codec {
+ TAPI_CODEC_L16,
+};
+
+struct tapi_stream_config {
+ enum tapi_codec codec;
+ unsigned int buffer_size;
+};
+
+struct tapi_ops {
+ int (*send_dtmf_events)(struct tapi_device *, struct tapi_port *port,
+ struct tapi_dtmf_event *, size_t num_events, unsigned int dealy);
+ int (*send_dtmf_event)(struct tapi_device *, struct tapi_port *port,
+ struct tapi_dtmf_event *);
+ int (*ring)(struct tapi_device *, struct tapi_port *port, bool ring);
+
+ struct tapi_stream *(*stream_alloc)(struct tapi_device *);
+ void (*stream_free)(struct tapi_device *, struct tapi_stream *);
+ int (*stream_configure)(struct tapi_device *, struct tapi_stream *,
+ struct tapi_stream_config *);
+ int (*stream_start)(struct tapi_device *, struct tapi_stream *);
+ int (*stream_stop)(struct tapi_device *, struct tapi_stream *);
+ int (*stream_send)(struct tapi_device *, struct tapi_stream *,
+ struct sk_buff *);
+
+ struct tapi_link *(*link_alloc)(struct tapi_device *,
+ struct tapi_endpoint *ep1, struct tapi_endpoint *ep2);
+ void (*link_free)(struct tapi_device *, struct tapi_link *);
+ int (*link_enable)(struct tapi_device *, struct tapi_link *);
+ int (*link_disable)(struct tapi_device *, struct tapi_link *);
+
+ int (*sync)(struct tapi_device *);
+};
+
+int tapi_stream_recv(struct tapi_device *, struct tapi_stream *, struct sk_buff *);
+
+struct tapi_device {
+ unsigned int id;
+
+ const struct tapi_ops *ops;
+ unsigned int num_ports;
+
+ struct device dev;
+
+ struct mutex lock;
+
+ struct tapi_port *ports;
+ struct list_head streams;
+ struct list_head links;
+ atomic_t stream_id;
+ atomic_t link_id;
+
+ struct tapi_char_device stream_dev;
+ struct tapi_char_device control_dev;
+};
+
+static inline struct tapi_device *dev_to_tapi(struct device *dev)
+{
+ return container_of(dev, struct tapi_device, dev);
+}
+
+static inline struct tapi_stream *tapi_stream_from_id(struct tapi_device *tdev,
+ unsigned int id)
+{
+ struct tapi_stream *stream;
+
+ mutex_lock(&tdev->lock);
+
+ list_for_each_entry(stream, &tdev->streams, head) {
+ if (stream->id == id)
+ goto out;
+ }
+ stream = NULL;
+
+out:
+ mutex_unlock(&tdev->lock);
+ return stream;
+}
+
+struct tapi_link *tapi_link_alloc(struct tapi_device *, struct tapi_endpoint *,
+ struct tapi_endpoint *);
+void tapi_link_free(struct tapi_device *, struct tapi_link *);
+
+struct tapi_stream *tapi_stream_alloc(struct tapi_device *tdev);
+void tapi_stream_free(struct tapi_device *tdev, struct tapi_stream *stream);
+
+static inline int tapi_sync(struct tapi_device *tdev)
+{
+ if (!tdev->ops || !tdev->ops->sync)
+ return 0;
+
+ return tdev->ops->sync(tdev);
+}
+
+static inline int tapi_link_enable(struct tapi_device *tdev,
+ struct tapi_link *link)
+{
+ if (!tdev->ops || !tdev->ops->link_enable)
+ return 0;
+
+ return tdev->ops->link_enable(tdev, link);
+}
+
+static inline int tapi_link_disable(struct tapi_device *tdev,
+ struct tapi_link *link)
+{
+ if (!tdev->ops || !tdev->ops->link_disable)
+ return 0;
+
+ return tdev->ops->link_disable(tdev, link);
+}
+
+static inline int tapi_port_send_dtmf(struct tapi_device *tdev,
+ struct tapi_port *port, struct tapi_dtmf_event *dtmf)
+{
+ if (!tdev->ops || !tdev->ops->send_dtmf_event)
+ return -ENOSYS;
+
+ return tdev->ops->send_dtmf_event(tdev, port, dtmf);
+}
+
+static inline int tapi_port_set_ring(struct tapi_device *tdev,
+ struct tapi_port *port, bool ring)
+{
+ if (!tdev->ops || !tdev->ops->ring)
+ return -ENOSYS;
+
+ return tdev->ops->ring(tdev, port, ring);
+}
+
+static inline int tapi_stream_start(struct tapi_device *tdev,
+struct tapi_stream *stream)
+{
+ if (!tdev->ops || !tdev->ops->stream_start)
+ return -ENOSYS;
+
+ return tdev->ops->stream_start(tdev, stream);
+}
+
+static inline int tapi_stream_stop(struct tapi_device *tdev,
+struct tapi_stream *stream)
+{
+ if (!tdev->ops || !tdev->ops->stream_stop)
+ return -ENOSYS;
+
+ return tdev->ops->stream_stop(tdev, stream);
+}
+
+int tapi_device_register(struct tapi_device *tdev, const char *name,
+ struct device *parent);
+void tapi_device_unregister(struct tapi_device *tdev);
+
+struct tapi_sysfs_port;
+
+struct tapi_sysfs_port *tapi_port_alloc(struct tapi_device *tdev, unsigned int id);
+void tapi_port_delete(struct tapi_sysfs_port *);
+
+#endif