1
2
3
4
5
6
7
8
9
10
11
12#include <linux/usb.h>
13#include <linux/i2c.h>
14#include <linux/mutex.h>
15#include <linux/workqueue.h>
16#include <linux/videodev2.h>
17
18#include <media/v4l2-device.h>
19#include <media/ir-kbd-i2c.h>
20
21#define HDPVR_MAX 8
22#define HDPVR_I2C_MAX_SIZE 128
23
24
25#define HD_PVR_VENDOR_ID 0x2040
26#define HD_PVR_PRODUCT_ID 0x4900
27#define HD_PVR_PRODUCT_ID1 0x4901
28#define HD_PVR_PRODUCT_ID2 0x4902
29#define HD_PVR_PRODUCT_ID4 0x4903
30#define HD_PVR_PRODUCT_ID3 0x4982
31
32#define UNSET (-1U)
33
34#define NUM_BUFFERS 64
35
36#define HDPVR_FIRMWARE_VERSION 0x08
37#define HDPVR_FIRMWARE_VERSION_AC3 0x0d
38#define HDPVR_FIRMWARE_VERSION_0X12 0x12
39#define HDPVR_FIRMWARE_VERSION_0X15 0x15
40
41
42
43extern int hdpvr_debug;
44
45#define MSG_INFO 1
46#define MSG_BUFFER 2
47
48struct hdpvr_options {
49 u8 video_std;
50 u8 video_input;
51 u8 audio_input;
52 u8 bitrate;
53 u8 peak_bitrate;
54 u8 bitrate_mode;
55 u8 gop_mode;
56 enum v4l2_mpeg_audio_encoding audio_codec;
57 u8 brightness;
58 u8 contrast;
59 u8 hue;
60 u8 saturation;
61 u8 sharpness;
62};
63
64
65struct hdpvr_device {
66
67 struct video_device *video_dev;
68
69 struct usb_device *udev;
70
71 struct v4l2_device v4l2_dev;
72
73
74 size_t bulk_in_size;
75
76 __u8 bulk_in_endpointAddr;
77
78
79 __u8 status;
80
81 uint open_count;
82
83
84 struct hdpvr_options options;
85
86 uint flags;
87
88
89 struct mutex io_mutex;
90
91 struct list_head free_buff_list;
92
93 struct list_head rec_buff_list;
94
95 wait_queue_head_t wait_buffer;
96
97 wait_queue_head_t wait_data;
98
99 struct workqueue_struct *workqueue;
100
101 struct work_struct worker;
102
103
104 struct i2c_adapter i2c_adapter;
105
106 struct mutex i2c_mutex;
107
108 char i2c_buf[HDPVR_I2C_MAX_SIZE];
109
110
111 struct IR_i2c_init_data ir_i2c_init_data;
112
113
114 struct mutex usbc_mutex;
115 u8 *usbc_buf;
116 u8 fw_ver;
117};
118
119static inline struct hdpvr_device *to_hdpvr_dev(struct v4l2_device *v4l2_dev)
120{
121 return container_of(v4l2_dev, struct hdpvr_device, v4l2_dev);
122}
123
124
125
126struct hdpvr_buffer {
127 struct list_head buff_list;
128
129 struct urb *urb;
130
131 struct hdpvr_device *dev;
132
133 uint pos;
134
135 __u8 status;
136};
137
138
139
140struct hdpvr_video_info {
141 u16 width;
142 u16 height;
143 u8 fps;
144};
145
146enum {
147 STATUS_UNINITIALIZED = 0,
148 STATUS_IDLE,
149 STATUS_STARTING,
150 STATUS_SHUTTING_DOWN,
151 STATUS_STREAMING,
152 STATUS_ERROR,
153 STATUS_DISCONNECTED,
154};
155
156enum {
157 HDPVR_FLAG_AC3_CAP = 1,
158};
159
160enum {
161 BUFSTAT_UNINITIALIZED = 0,
162 BUFSTAT_AVAILABLE,
163 BUFSTAT_INPROGRESS,
164 BUFSTAT_READY,
165};
166
167#define CTRL_START_STREAMING_VALUE 0x0700
168#define CTRL_STOP_STREAMING_VALUE 0x0800
169#define CTRL_BITRATE_VALUE 0x1000
170#define CTRL_BITRATE_MODE_VALUE 0x1200
171#define CTRL_GOP_MODE_VALUE 0x1300
172#define CTRL_VIDEO_INPUT_VALUE 0x1500
173#define CTRL_VIDEO_STD_TYPE 0x1700
174#define CTRL_AUDIO_INPUT_VALUE 0x2500
175#define CTRL_BRIGHTNESS 0x2900
176#define CTRL_CONTRAST 0x2a00
177#define CTRL_HUE 0x2b00
178#define CTRL_SATURATION 0x2c00
179#define CTRL_SHARPNESS 0x2d00
180#define CTRL_LOW_PASS_FILTER_VALUE 0x3100
181
182#define CTRL_DEFAULT_INDEX 0x0003
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247enum hdpvr_video_std {
248 HDPVR_60HZ = 0,
249 HDPVR_50HZ,
250};
251
252enum hdpvr_video_input {
253 HDPVR_COMPONENT = 0,
254 HDPVR_SVIDEO,
255 HDPVR_COMPOSITE,
256 HDPVR_VIDEO_INPUTS
257};
258
259enum hdpvr_audio_inputs {
260 HDPVR_RCA_BACK = 0,
261 HDPVR_RCA_FRONT,
262 HDPVR_SPDIF,
263 HDPVR_AUDIO_INPUTS
264};
265
266enum hdpvr_bitrate_mode {
267 HDPVR_CONSTANT = 1,
268 HDPVR_VARIABLE_PEAK,
269 HDPVR_VARIABLE_AVERAGE,
270};
271
272enum hdpvr_gop_mode {
273 HDPVR_ADVANCED_IDR_GOP = 0,
274 HDPVR_SIMPLE_IDR_GOP,
275 HDPVR_ADVANCED_NOIDR_GOP,
276 HDPVR_SIMPLE_NOIDR_GOP,
277};
278
279void hdpvr_delete(struct hdpvr_device *dev);
280
281
282
283int hdpvr_set_options(struct hdpvr_device *dev);
284
285int hdpvr_set_bitrate(struct hdpvr_device *dev);
286
287int hdpvr_set_audio(struct hdpvr_device *dev, u8 input,
288 enum v4l2_mpeg_audio_encoding codec);
289
290int hdpvr_config_call(struct hdpvr_device *dev, uint value,
291 unsigned char valbuf);
292
293struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev);
294
295
296
297int get_input_lines_info(struct hdpvr_device *dev);
298
299
300
301
302int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
303 int devnumber);
304
305int hdpvr_cancel_queue(struct hdpvr_device *dev);
306
307
308
309int hdpvr_register_i2c_adapter(struct hdpvr_device *dev);
310
311struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev);
312struct i2c_client *hdpvr_register_ir_tx_i2c(struct hdpvr_device *dev);
313
314
315
316int hdpvr_free_buffers(struct hdpvr_device *dev);
317int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count);
318