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