xref: /linux/drivers/media/usb/as102/as102_drv.h (revision d6317c68f3324e086799e12e4864231bb71829cb)
1*d6317c68SMauro Carvalho Chehab /*
2*d6317c68SMauro Carvalho Chehab  * Abilis Systems Single DVB-T Receiver
3*d6317c68SMauro Carvalho Chehab  * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
4*d6317c68SMauro Carvalho Chehab  *
5*d6317c68SMauro Carvalho Chehab  * This program is free software; you can redistribute it and/or modify
6*d6317c68SMauro Carvalho Chehab  * it under the terms of the GNU General Public License as published by
7*d6317c68SMauro Carvalho Chehab  * the Free Software Foundation; either version 2, or (at your option)
8*d6317c68SMauro Carvalho Chehab  * any later version.
9*d6317c68SMauro Carvalho Chehab  *
10*d6317c68SMauro Carvalho Chehab  * This program is distributed in the hope that it will be useful,
11*d6317c68SMauro Carvalho Chehab  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*d6317c68SMauro Carvalho Chehab  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*d6317c68SMauro Carvalho Chehab  * GNU General Public License for more details.
14*d6317c68SMauro Carvalho Chehab  *
15*d6317c68SMauro Carvalho Chehab  * You should have received a copy of the GNU General Public License
16*d6317c68SMauro Carvalho Chehab  * along with this program; if not, write to the Free Software
17*d6317c68SMauro Carvalho Chehab  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*d6317c68SMauro Carvalho Chehab  */
19*d6317c68SMauro Carvalho Chehab 
20*d6317c68SMauro Carvalho Chehab #include <linux/usb.h>
21*d6317c68SMauro Carvalho Chehab #include <dvb_demux.h>
22*d6317c68SMauro Carvalho Chehab #include <dvb_frontend.h>
23*d6317c68SMauro Carvalho Chehab #include <dmxdev.h>
24*d6317c68SMauro Carvalho Chehab #include "as10x_cmd.h"
25*d6317c68SMauro Carvalho Chehab #include "as102_usb_drv.h"
26*d6317c68SMauro Carvalho Chehab 
27*d6317c68SMauro Carvalho Chehab #define DRIVER_FULL_NAME "Abilis Systems as10x usb driver"
28*d6317c68SMauro Carvalho Chehab #define DRIVER_NAME "as10x_usb"
29*d6317c68SMauro Carvalho Chehab 
30*d6317c68SMauro Carvalho Chehab #define debug	as102_debug
31*d6317c68SMauro Carvalho Chehab extern struct usb_driver as102_usb_driver;
32*d6317c68SMauro Carvalho Chehab extern int elna_enable;
33*d6317c68SMauro Carvalho Chehab 
34*d6317c68SMauro Carvalho Chehab #define AS102_DEVICE_MAJOR	192
35*d6317c68SMauro Carvalho Chehab 
36*d6317c68SMauro Carvalho Chehab #define AS102_USB_BUF_SIZE	512
37*d6317c68SMauro Carvalho Chehab #define MAX_STREAM_URB		32
38*d6317c68SMauro Carvalho Chehab 
39*d6317c68SMauro Carvalho Chehab struct as10x_bus_adapter_t {
40*d6317c68SMauro Carvalho Chehab 	struct usb_device *usb_dev;
41*d6317c68SMauro Carvalho Chehab 	/* bus token lock */
42*d6317c68SMauro Carvalho Chehab 	struct mutex lock;
43*d6317c68SMauro Carvalho Chehab 	/* low level interface for bus adapter */
44*d6317c68SMauro Carvalho Chehab 	union as10x_bus_token_t {
45*d6317c68SMauro Carvalho Chehab 		/* usb token */
46*d6317c68SMauro Carvalho Chehab 		struct as10x_usb_token_cmd_t usb;
47*d6317c68SMauro Carvalho Chehab 	} token;
48*d6317c68SMauro Carvalho Chehab 
49*d6317c68SMauro Carvalho Chehab 	/* token cmd xfer id */
50*d6317c68SMauro Carvalho Chehab 	uint16_t cmd_xid;
51*d6317c68SMauro Carvalho Chehab 
52*d6317c68SMauro Carvalho Chehab 	/* as10x command and response for dvb interface*/
53*d6317c68SMauro Carvalho Chehab 	struct as10x_cmd_t *cmd, *rsp;
54*d6317c68SMauro Carvalho Chehab 
55*d6317c68SMauro Carvalho Chehab 	/* bus adapter private ops callback */
56*d6317c68SMauro Carvalho Chehab 	struct as102_priv_ops_t *ops;
57*d6317c68SMauro Carvalho Chehab };
58*d6317c68SMauro Carvalho Chehab 
59*d6317c68SMauro Carvalho Chehab struct as102_dev_t {
60*d6317c68SMauro Carvalho Chehab 	const char *name;
61*d6317c68SMauro Carvalho Chehab 	struct as10x_bus_adapter_t bus_adap;
62*d6317c68SMauro Carvalho Chehab 	struct list_head device_entry;
63*d6317c68SMauro Carvalho Chehab 	struct kref kref;
64*d6317c68SMauro Carvalho Chehab 	uint8_t elna_cfg;
65*d6317c68SMauro Carvalho Chehab 
66*d6317c68SMauro Carvalho Chehab 	struct dvb_adapter dvb_adap;
67*d6317c68SMauro Carvalho Chehab 	struct dvb_frontend dvb_fe;
68*d6317c68SMauro Carvalho Chehab 	struct dvb_demux dvb_dmx;
69*d6317c68SMauro Carvalho Chehab 	struct dmxdev dvb_dmxdev;
70*d6317c68SMauro Carvalho Chehab 
71*d6317c68SMauro Carvalho Chehab 	/* demodulator stats */
72*d6317c68SMauro Carvalho Chehab 	struct as10x_demod_stats demod_stats;
73*d6317c68SMauro Carvalho Chehab 	/* signal strength */
74*d6317c68SMauro Carvalho Chehab 	uint16_t signal_strength;
75*d6317c68SMauro Carvalho Chehab 	/* bit error rate */
76*d6317c68SMauro Carvalho Chehab 	uint32_t ber;
77*d6317c68SMauro Carvalho Chehab 
78*d6317c68SMauro Carvalho Chehab 	/* timer handle to trig ts stream download */
79*d6317c68SMauro Carvalho Chehab 	struct timer_list timer_handle;
80*d6317c68SMauro Carvalho Chehab 
81*d6317c68SMauro Carvalho Chehab 	struct mutex sem;
82*d6317c68SMauro Carvalho Chehab 	dma_addr_t dma_addr;
83*d6317c68SMauro Carvalho Chehab 	void *stream;
84*d6317c68SMauro Carvalho Chehab 	int streaming;
85*d6317c68SMauro Carvalho Chehab 	struct urb *stream_urb[MAX_STREAM_URB];
86*d6317c68SMauro Carvalho Chehab };
87*d6317c68SMauro Carvalho Chehab 
88*d6317c68SMauro Carvalho Chehab int as102_dvb_register(struct as102_dev_t *dev);
89*d6317c68SMauro Carvalho Chehab void as102_dvb_unregister(struct as102_dev_t *dev);
90*d6317c68SMauro Carvalho Chehab 
91*d6317c68SMauro Carvalho Chehab int as102_dvb_register_fe(struct as102_dev_t *dev, struct dvb_frontend *fe);
92*d6317c68SMauro Carvalho Chehab int as102_dvb_unregister_fe(struct dvb_frontend *dev);
93