Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
[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 as102_debug;
41 #define debug   as102_debug
42
43 #define dprintk(debug, args...) \
44         do { if (debug) {       \
45                 printk(KERN_DEBUG "%s: ",__FUNCTION__); \
46                 printk(args);   \
47         } } while (0)
48
49 #ifdef TRACE
50 #define ENTER()                 printk(">> enter %s\n", __FUNCTION__)
51 #define LEAVE()                 printk("<< leave %s\n", __FUNCTION__)
52 #else
53 #define ENTER()
54 #define LEAVE()
55 #endif
56
57 #define AS102_DEVICE_MAJOR      192
58
59 #define AS102_USB_BUF_SIZE      512
60 #define MAX_STREAM_URB          32
61
62 #include "as10x_cmd.h"
63
64 #if defined(CONFIG_AS102_USB)
65 #include "as102_usb_drv.h"
66 #endif
67
68 #if defined(CONFIG_AS102_SPI)
69 #include "as10x_spi_drv.h"
70 #endif
71
72
73 struct as102_bus_adapter_t {
74 #if defined(CONFIG_AS102_USB)
75         struct usb_device *usb_dev;
76 #elif defined(CONFIG_AS102_SPI)
77         struct spi_device *spi_dev;
78         struct cdev cdev; /* spidev raw device */
79
80         struct timer_list timer;
81         struct completion xfer_done;
82 #endif
83         /* bus token lock */
84         struct mutex lock;
85         /* low level interface for bus adapter */
86         union as10x_bus_token_t {
87 #if defined(CONFIG_AS102_USB)
88                 /* usb token */
89                 struct as10x_usb_token_cmd_t usb;
90 #endif
91 #if defined(CONFIG_AS102_SPI)
92                 /* spi token */
93                 struct as10x_spi_token_cmd_t spi;
94 #endif
95         } token;
96
97         /* token cmd xfer id */
98         uint16_t cmd_xid;
99
100         /* as10x command and response for dvb interface*/
101         struct as10x_cmd_t *cmd, *rsp;
102
103         /* bus adapter private ops callback */
104         struct as102_priv_ops_t *ops;
105 };
106
107 struct as102_dev_t {
108         const char *name;
109         struct as102_bus_adapter_t bus_adap;
110         struct list_head device_entry;
111         struct kref kref;
112         unsigned long minor;
113
114         struct dvb_adapter dvb_adap;
115         struct dvb_frontend dvb_fe;
116         struct dvb_demux dvb_dmx;
117         struct dmxdev dvb_dmxdev;
118
119         /* demodulator stats */
120         struct as10x_demod_stats demod_stats;
121         /* signal strength */
122         uint16_t signal_strength;
123         /* bit error rate */
124         uint32_t ber;
125
126         /* timer handle to trig ts stream download */
127         struct timer_list timer_handle;
128
129         struct mutex sem;
130         dma_addr_t dma_addr;
131         void *stream;
132         int streaming;
133         struct urb *stream_urb[MAX_STREAM_URB];
134 };
135
136 int as102_dvb_register(struct as102_dev_t *dev);
137 void as102_dvb_unregister(struct as102_dev_t *dev);
138
139 int as102_dvb_register_fe(struct as102_dev_t *dev, struct dvb_frontend *fe);
140 int as102_dvb_unregister_fe(struct dvb_frontend *dev);
141
142 /* EOF - vim: set textwidth=80 ts=8 sw=8 sts=8 noet: */