summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/dvb-usb/dvb-usb.h
blob: 7f08936ce7ae8a67f932b453faf56a971beeae43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/* dvb-usb.h is part of the DVB USB library.
 *
 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
 * see dvb-usb-init.c for copyright information.
 *
 * the headerfile, all dvb-usb-drivers have to include.
 */
#ifndef __DVB_USB_H__
#define __DVB_USB_H__

#include <linux/config.h>
#include <linux/input.h>
#include <linux/usb.h>

#include "dvb_frontend.h"
#include "dvb_demux.h"
#include "dvb_net.h"
#include "dmxdev.h"

#include "dvb-usb-ids.h"

/* debug */
#ifdef CONFIG_DVB_USB_DEBUG
#define dprintk(var,level,args...) \
	    do { if ((var & level)) { printk(args); } } while (0)

#define debug_dump(b,l,func) {\
	int loop_; \
	for (loop_ = 0; loop_ < l; loop_++) func("%02x ", b[loop_]); \
	func("\n");\
}
#define DVB_USB_DEBUG_STATUS
#else
#define dprintk(args...)
#define debug_dump(b,l)

#define DVB_USB_DEBUG_STATUS " (debugging is not enabled)"

#endif

/* generic log methods - taken from usb.h */
#ifndef DVB_USB_LOG_PREFIX
 #define DVB_USB_LOG_PREFIX "dvb-usb (please define a log prefix)"
#endif

#undef err
#define err(format, arg...)  printk(KERN_ERR     DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
#undef info
#define info(format, arg...) printk(KERN_INFO    DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
#undef warn
#define warn(format, arg...) printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)

struct dvb_usb_device_description {
	const char *name;                                   /* real name of the box */

#define DVB_USB_ID_MAX_NUM 15
	struct usb_device_id *cold_ids[DVB_USB_ID_MAX_NUM]; /* list of USB ids when this device is at pre firmware state */
	struct usb_device_id *warm_ids[DVB_USB_ID_MAX_NUM]; /* list of USB ids when this device is at post firmware state */
};

struct dvb_usb_device;

/* properties of an dvb-usb-device */
struct dvb_usb_properties {

#define DVB_USB_HAS_PID_FILTER               0x01
#define DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF 0x02
#define DVB_USB_NEED_PID_FILTERING           0x04
#define DVB_USB_IS_AN_I2C_ADAPTER            0x08
	int caps;

#define CYPRESS_AN2135  0
#define CYPRESS_AN2235  1
#define CYPRESS_FX2     2
	int usb_ctrl;                                            /* usb controller */
	const char *firmware;                                    /* valid firmware filenames */

	int (*streaming_ctrl) (struct dvb_usb_device *, int); /* control the MPEG2-TS streaming of the device */
	int (*pid_filter) (struct dvb_usb_device *, int, u16, int); /* if the device has a hardware pid filter */
	int (*pid_filter_ctrl) (struct dvb_usb_device *, int); /* if the device has a hardware pid filter to en-/disable */

	int (*read_mac_address) (struct dvb_usb_device *, u8 []); /* callback for reading the MAC address */

	int (*power_ctrl) (struct dvb_usb_device *, int);    /* power control callback of the device */

	int (*frontend_attach) (struct dvb_usb_device *);        /* each device has to know about its frontends */


	struct dvb_usb_device_description * (*identify_desc_quirk) (void); /* the device is not distinuishable just by its USB IDs */

#define USB_REMOTE_PROTO_NO         1
#define USB_REMOTE_PROTO_NEC        2
#define USB_REMOTE_PROTO_HAUPPAUGE  3
	int remote_protocol;                   /* does this device have an ir-receiver */
	int rc_interval;

#define REMOTE_KEY_NO      0x01
#define REMOTE_KEY_REPEAT  0x02
#define REMOTE_KEY_PRESSED 0x03
	int (*query_rc) (struct dvb_usb_device *, u8 *, int *);  /* remote query callback */

/* i2c algorithm, if any */
	struct i2c_algorithm i2c_algo;

/* endpoint for generic bulk read/write operations (used by many drivers for controlling the device) */
	int generic_bulk_ctrl_endpoint;

/* MPEG2 TS transfer description */
	struct {
#define DVB_USB_BULK  1
#define DVB_USB_ISOC  2
		int type;
		int count;
		int endpoint;

		union {
			struct {
				int buffersize; /* per URB */
			} bulk;
			struct {
				int framesperurb;
				int framesize;
			} isoc;
		} u;

	} urb;

	int num_device_descs;
	struct dvb_usb_device_description devices[];
};

struct dvb_usb_device {
	struct dvb_usb_properties props;
	struct dvb_usb_device_description *desc;

#define DVB_USB_STATE_INIT        0x000
#define DVB_USB_STATE_URB_LIST    0x001
#define DVB_USB_STATE_URB_BUF     0x002
#define DVB_USB_STATE_DVB         0x004
#define DVB_USB_STATE_I2C         0x008
#define DVB_USB_STATE_REMOTE      0x010
#define DVB_USB_STATE_URB_SUBMIT  0x020
	int init_state;

	/* usb */
	struct usb_device *udev;
	struct urb **urb_list;
	u8 *buffer;
	dma_addr_t dma_handle;
	int urbs_initialized;
	int urbs_submitted;

	int feedcount;

	/* locking */
	struct semaphore usb_sem;

	/* i2c */
	struct semaphore i2c_sem;
	struct i2c_adapter i2c_adap;

	/* dvb */
	struct dvb_adapter dvb_adap;
	struct dmxdev dmxdev;
	struct dvb_demux demux;
	struct dvb_net dvb_net;
	struct dvb_frontend* fe;

	int (*fe_sleep) (struct dvb_frontend *);
	int (*fe_init)  (struct dvb_frontend *);

	/* remote control */
//	struct input_dev rc_input_dev;
//	struct work_struct rc_query_work;
//	int last_event;
//	int last_state; /* for Hauppauge RC protocol */
//	int repeat_key_count;
//	int rc_key_repeat_count; /* module parameter */

	int pid_filtering;
//	int rc_query_interval;

	void *priv;
};

extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *);
extern void dvb_usb_device_exit(struct usb_interface *);

/* the generic read/write method for device control */
extern int dvb_usb_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16);
extern int dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16);

#endif