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