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