xref: /linux/drivers/media/usb/as102/as102_drv.h (revision 3e0a4e85803345e31ae2d0009bedf252e43278cb)
1*3e0a4e85SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2d6317c68SMauro Carvalho Chehab /*
3d6317c68SMauro Carvalho Chehab  * Abilis Systems Single DVB-T Receiver
4d6317c68SMauro Carvalho Chehab  * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
5d6317c68SMauro Carvalho Chehab  */
6d6317c68SMauro Carvalho Chehab 
747f79129SMauro Carvalho Chehab #ifndef _AS102_DRV_H
847f79129SMauro Carvalho Chehab #define _AS102_DRV_H
9d6317c68SMauro Carvalho Chehab #include <linux/usb.h>
10fada1935SMauro Carvalho Chehab #include <media/dvb_demux.h>
11fada1935SMauro Carvalho Chehab #include <media/dvb_frontend.h>
12fada1935SMauro Carvalho Chehab #include <media/dmxdev.h>
1347f79129SMauro Carvalho Chehab #include "as10x_handle.h"
14d6317c68SMauro Carvalho Chehab #include "as10x_cmd.h"
15d6317c68SMauro Carvalho Chehab #include "as102_usb_drv.h"
16d6317c68SMauro Carvalho Chehab 
17d6317c68SMauro Carvalho Chehab #define DRIVER_FULL_NAME "Abilis Systems as10x usb driver"
18d6317c68SMauro Carvalho Chehab #define DRIVER_NAME "as10x_usb"
19d6317c68SMauro Carvalho Chehab 
20d6317c68SMauro Carvalho Chehab #define debug	as102_debug
21d6317c68SMauro Carvalho Chehab extern struct usb_driver as102_usb_driver;
22d6317c68SMauro Carvalho Chehab extern int elna_enable;
23d6317c68SMauro Carvalho Chehab 
24d6317c68SMauro Carvalho Chehab #define AS102_DEVICE_MAJOR	192
25d6317c68SMauro Carvalho Chehab 
26d6317c68SMauro Carvalho Chehab #define AS102_USB_BUF_SIZE	512
27d6317c68SMauro Carvalho Chehab #define MAX_STREAM_URB		32
28d6317c68SMauro Carvalho Chehab 
29d6317c68SMauro Carvalho Chehab struct as10x_bus_adapter_t {
30d6317c68SMauro Carvalho Chehab 	struct usb_device *usb_dev;
31d6317c68SMauro Carvalho Chehab 	/* bus token lock */
32d6317c68SMauro Carvalho Chehab 	struct mutex lock;
33d6317c68SMauro Carvalho Chehab 	/* low level interface for bus adapter */
34d6317c68SMauro Carvalho Chehab 	union as10x_bus_token_t {
35d6317c68SMauro Carvalho Chehab 		/* usb token */
36d6317c68SMauro Carvalho Chehab 		struct as10x_usb_token_cmd_t usb;
37d6317c68SMauro Carvalho Chehab 	} token;
38d6317c68SMauro Carvalho Chehab 
39d6317c68SMauro Carvalho Chehab 	/* token cmd xfer id */
40d6317c68SMauro Carvalho Chehab 	uint16_t cmd_xid;
41d6317c68SMauro Carvalho Chehab 
42d6317c68SMauro Carvalho Chehab 	/* as10x command and response for dvb interface*/
43d6317c68SMauro Carvalho Chehab 	struct as10x_cmd_t *cmd, *rsp;
44d6317c68SMauro Carvalho Chehab 
45d6317c68SMauro Carvalho Chehab 	/* bus adapter private ops callback */
46f691ba98SJulia Lawall 	const struct as102_priv_ops_t *ops;
47d6317c68SMauro Carvalho Chehab };
48d6317c68SMauro Carvalho Chehab 
49d6317c68SMauro Carvalho Chehab struct as102_dev_t {
50d6317c68SMauro Carvalho Chehab 	const char *name;
51d6317c68SMauro Carvalho Chehab 	struct as10x_bus_adapter_t bus_adap;
52d6317c68SMauro Carvalho Chehab 	struct list_head device_entry;
53d6317c68SMauro Carvalho Chehab 	struct kref kref;
54d6317c68SMauro Carvalho Chehab 	uint8_t elna_cfg;
55d6317c68SMauro Carvalho Chehab 
56d6317c68SMauro Carvalho Chehab 	struct dvb_adapter dvb_adap;
57b601d9a5SMauro Carvalho Chehab 	struct dvb_frontend *dvb_fe;
58d6317c68SMauro Carvalho Chehab 	struct dvb_demux dvb_dmx;
59d6317c68SMauro Carvalho Chehab 	struct dmxdev dvb_dmxdev;
60d6317c68SMauro Carvalho Chehab 
61d6317c68SMauro Carvalho Chehab 	/* timer handle to trig ts stream download */
62d6317c68SMauro Carvalho Chehab 	struct timer_list timer_handle;
63d6317c68SMauro Carvalho Chehab 
64d6317c68SMauro Carvalho Chehab 	struct mutex sem;
65d6317c68SMauro Carvalho Chehab 	dma_addr_t dma_addr;
66d6317c68SMauro Carvalho Chehab 	void *stream;
67d6317c68SMauro Carvalho Chehab 	int streaming;
68d6317c68SMauro Carvalho Chehab 	struct urb *stream_urb[MAX_STREAM_URB];
69d6317c68SMauro Carvalho Chehab };
70d6317c68SMauro Carvalho Chehab 
71d6317c68SMauro Carvalho Chehab int as102_dvb_register(struct as102_dev_t *dev);
72d6317c68SMauro Carvalho Chehab void as102_dvb_unregister(struct as102_dev_t *dev);
73d6317c68SMauro Carvalho Chehab 
7447f79129SMauro Carvalho Chehab #endif
75