bcda635b5a9967454f95c843ccf4ae4c42a22d15
[pandora-kernel.git] / drivers / staging / media / as102 / as102_drv.h
1 /*
2  * Abilis Systems Single DVB-T Receiver
3  * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #if defined(CONFIG_AS102_USB)
21 #include <linux/usb.h>
22 extern struct usb_driver as102_usb_driver;
23 #endif
24
25 #if defined(CONFIG_AS102_SPI)
26 #include <linux/platform_device.h>
27 #include <linux/spi/spi.h>
28 #include <linux/cdev.h>
29
30 extern struct spi_driver as102_spi_driver;
31 #endif
32
33 #include "dvb_demux.h"
34 #include "dvb_frontend.h"
35 #include "dmxdev.h"
36
37 #define DRIVER_FULL_NAME "Abilis Systems as10x usb driver"
38 #define DRIVER_NAME "as10x_usb"
39
40 extern int debug;
41
42 #define dprintk(debug, args...) \
43         do { if (debug) {       \
44                 printk(KERN_DEBUG "%s: ",__FUNCTION__); \
45                 printk(args);   \
46         } } while (0)
47
48 #ifdef TRACE
49 #define ENTER()                 printk(">> enter %s\n", __FUNCTION__)
50 #define LEAVE()                 printk("<< leave %s\n", __FUNCTION__)
51 #else
52 #define ENTER()
53 #define LEAVE()
54 #endif
55
56 #define AS102_DEVICE_MAJOR      192
57
58 #define AS102_USB_BUF_SIZE      512
59 #define MAX_STREAM_URB          32
60
61 #include "as10x_cmd.h"
62
63 #if defined(CONFIG_AS102_USB)
64 #include "as102_usb_drv.h"
65 #endif
66
67 #if defined(CONFIG_AS102_SPI)
68 #include "as10x_spi_drv.h"
69 #endif
70
71
72 struct as102_bus_adapter_t {
73 #if defined(CONFIG_AS102_USB)
74         struct usb_device *usb_dev;
75 #elif defined(CONFIG_AS102_SPI)
76         struct spi_device *spi_dev;
77         struct cdev cdev; /* spidev raw device */
78
79         struct timer_list timer;
80         struct completion xfer_done;
81 #endif
82         /* bus token lock */
83         struct mutex lock;
84         /* low level interface for bus adapter */
85         union as10x_bus_token_t {
86 #if defined(CONFIG_AS102_USB)
87                 /* usb token */
88                 struct as10x_usb_token_cmd_t usb;
89 #endif
90 #if defined(CONFIG_AS102_SPI)
91                 /* spi token */
92                 struct as10x_spi_token_cmd_t spi;
93 #endif
94         } token;
95
96         /* token cmd xfer id */
97         uint16_t cmd_xid;
98
99         /* as10x command and response for dvb interface*/
100         struct as10x_cmd_t *cmd, *rsp;
101
102         /* bus adapter private ops callback */
103         struct as102_priv_ops_t *ops;
104 };
105
106 struct as102_dev_t {
107         const char *name;
108         struct as102_bus_adapter_t bus_adap;
109         struct list_head device_entry;
110         struct kref kref;
111         unsigned long minor;
112
113         struct dvb_adapter dvb_adap;
114         struct dvb_frontend dvb_fe;
115         struct dvb_demux dvb_dmx;
116         struct dmxdev dvb_dmxdev;
117
118         /* demodulator stats */
119         struct as10x_demod_stats demod_stats;
120         /* signal strength */
121         uint16_t signal_strength;
122         /* bit error rate */
123         uint32_t ber;
124
125         /* timer handle to trig ts stream download */
126         struct timer_list timer_handle;
127
128         struct mutex sem;
129         dma_addr_t dma_addr;
130         void *stream;
131         int streaming;
132         struct urb *stream_urb[MAX_STREAM_URB];
133 };
134
135 int as102_dvb_register(struct as102_dev_t *dev);
136 void as102_dvb_unregister(struct as102_dev_t *dev);
137
138 int as102_dvb_register_fe(struct as102_dev_t *dev, struct dvb_frontend *fe);
139 int as102_dvb_unregister_fe(struct dvb_frontend *dev);
140
141 /* EOF - vim: set textwidth=80 ts=8 sw=8 sts=8 noet: */