diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/media/video/hdpvr/hdpvr.h | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'drivers/media/video/hdpvr/hdpvr.h')
-rw-r--r-- | drivers/media/video/hdpvr/hdpvr.h | 316 |
1 files changed, 316 insertions, 0 deletions
diff --git a/drivers/media/video/hdpvr/hdpvr.h b/drivers/media/video/hdpvr/hdpvr.h new file mode 100644 index 00000000000..d6439db1d18 --- /dev/null +++ b/drivers/media/video/hdpvr/hdpvr.h | |||
@@ -0,0 +1,316 @@ | |||
1 | /* | ||
2 | * Hauppauge HD PVR USB driver | ||
3 | * | ||
4 | * Copyright (C) 2008 Janne Grunau (j@jannau.net) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License as | ||
8 | * published by the Free Software Foundation, version 2. | ||
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 | /* Define these values to match your devices */ | ||
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 | /* #define HDPVR_DEBUG */ | ||
42 | |||
43 | extern int hdpvr_debug; | ||
44 | |||
45 | #define MSG_INFO 1 | ||
46 | #define MSG_BUFFER 2 | ||
47 | |||
48 | struct hdpvr_options { | ||
49 | u8 video_std; | ||
50 | u8 video_input; | ||
51 | u8 audio_input; | ||
52 | u8 bitrate; /* in 100kbps */ | ||
53 | u8 peak_bitrate; /* in 100kbps */ | ||
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 | /* Structure to hold all of our device specific stuff */ | ||
65 | struct hdpvr_device { | ||
66 | /* the v4l device for this device */ | ||
67 | struct video_device *video_dev; | ||
68 | /* the usb device for this device */ | ||
69 | struct usb_device *udev; | ||
70 | /* v4l2-device unused */ | ||
71 | struct v4l2_device v4l2_dev; | ||
72 | |||
73 | /* the max packet size of the bulk endpoint */ | ||
74 | size_t bulk_in_size; | ||
75 | /* the address of the bulk in endpoint */ | ||
76 | __u8 bulk_in_endpointAddr; | ||
77 | |||
78 | /* holds the current device status */ | ||
79 | __u8 status; | ||
80 | /* count the number of openers */ | ||
81 | uint open_count; | ||
82 | |||
83 | /* holds the cureent set options */ | ||
84 | struct hdpvr_options options; | ||
85 | |||
86 | uint flags; | ||
87 | |||
88 | /* synchronize I/O */ | ||
89 | struct mutex io_mutex; | ||
90 | /* available buffers */ | ||
91 | struct list_head free_buff_list; | ||
92 | /* in progress buffers */ | ||
93 | struct list_head rec_buff_list; | ||
94 | /* waitqueue for buffers */ | ||
95 | wait_queue_head_t wait_buffer; | ||
96 | /* waitqueue for data */ | ||
97 | wait_queue_head_t wait_data; | ||
98 | /**/ | ||
99 | struct workqueue_struct *workqueue; | ||
100 | /**/ | ||
101 | struct work_struct worker; | ||
102 | |||
103 | /* I2C adapter */ | ||
104 | struct i2c_adapter i2c_adapter; | ||
105 | /* I2C lock */ | ||
106 | struct mutex i2c_mutex; | ||
107 | /* I2C message buffer space */ | ||
108 | char i2c_buf[HDPVR_I2C_MAX_SIZE]; | ||
109 | |||
110 | /* For passing data to ir-kbd-i2c */ | ||
111 | struct IR_i2c_init_data ir_i2c_init_data; | ||
112 | |||
113 | /* usb control transfer buffer and lock */ | ||
114 | struct mutex usbc_mutex; | ||
115 | u8 *usbc_buf; | ||
116 | }; | ||
117 | |||
118 | static inline struct hdpvr_device *to_hdpvr_dev(struct v4l2_device *v4l2_dev) | ||
119 | { | ||
120 | return container_of(v4l2_dev, struct hdpvr_device, v4l2_dev); | ||
121 | } | ||
122 | |||
123 | |||
124 | /* buffer one bulk urb of data */ | ||
125 | struct hdpvr_buffer { | ||
126 | struct list_head buff_list; | ||
127 | |||
128 | struct urb *urb; | ||
129 | |||
130 | struct hdpvr_device *dev; | ||
131 | |||
132 | uint pos; | ||
133 | |||
134 | __u8 status; | ||
135 | }; | ||
136 | |||
137 | /* */ | ||
138 | |||
139 | struct hdpvr_video_info { | ||
140 | u16 width; | ||
141 | u16 height; | ||
142 | u8 fps; | ||
143 | }; | ||
144 | |||
145 | enum { | ||
146 | STATUS_UNINITIALIZED = 0, | ||
147 | STATUS_IDLE, | ||
148 | STATUS_STARTING, | ||
149 | STATUS_SHUTTING_DOWN, | ||
150 | STATUS_STREAMING, | ||
151 | STATUS_ERROR, | ||
152 | STATUS_DISCONNECTED, | ||
153 | }; | ||
154 | |||
155 | enum { | ||
156 | HDPVR_FLAG_AC3_CAP = 1, | ||
157 | }; | ||
158 | |||
159 | enum { | ||
160 | BUFSTAT_UNINITIALIZED = 0, | ||
161 | BUFSTAT_AVAILABLE, | ||
162 | BUFSTAT_INPROGRESS, | ||
163 | BUFSTAT_READY, | ||
164 | }; | ||
165 | |||
166 | #define CTRL_START_STREAMING_VALUE 0x0700 | ||
167 | #define CTRL_STOP_STREAMING_VALUE 0x0800 | ||
168 | #define CTRL_BITRATE_VALUE 0x1000 | ||
169 | #define CTRL_BITRATE_MODE_VALUE 0x1200 | ||
170 | #define CTRL_GOP_MODE_VALUE 0x1300 | ||
171 | #define CTRL_VIDEO_INPUT_VALUE 0x1500 | ||
172 | #define CTRL_VIDEO_STD_TYPE 0x1700 | ||
173 | #define CTRL_AUDIO_INPUT_VALUE 0x2500 | ||
174 | #define CTRL_BRIGHTNESS 0x2900 | ||
175 | #define CTRL_CONTRAST 0x2a00 | ||
176 | #define CTRL_HUE 0x2b00 | ||
177 | #define CTRL_SATURATION 0x2c00 | ||
178 | #define CTRL_SHARPNESS 0x2d00 | ||
179 | #define CTRL_LOW_PASS_FILTER_VALUE 0x3100 | ||
180 | |||
181 | #define CTRL_DEFAULT_INDEX 0x0003 | ||
182 | |||
183 | |||
184 | /* :0 s 38 01 1000 0003 0004 4 = 0a00ca00 | ||
185 | * BITRATE SETTING | ||
186 | * 1st and 2nd byte (little endian): average bitrate in 100 000 bit/s | ||
187 | * min: 1 mbit/s, max: 13.5 mbit/s | ||
188 | * 3rd and 4th byte (little endian): peak bitrate in 100 000 bit/s | ||
189 | * min: average + 100kbit/s, | ||
190 | * max: 20.2 mbit/s | ||
191 | */ | ||
192 | |||
193 | /* :0 s 38 01 1200 0003 0001 1 = 02 | ||
194 | * BIT RATE MODE | ||
195 | * constant = 1, variable (peak) = 2, variable (average) = 3 | ||
196 | */ | ||
197 | |||
198 | /* :0 s 38 01 1300 0003 0001 1 = 03 | ||
199 | * GOP MODE (2 bit) | ||
200 | * low bit 0/1: advanced/simple GOP | ||
201 | * high bit 0/1: IDR(4/32/128) / no IDR (4/32/0) | ||
202 | */ | ||
203 | |||
204 | /* :0 s 38 01 1700 0003 0001 1 = 00 | ||
205 | * VIDEO STANDARD or FREQUNCY 0 = 60hz, 1 = 50hz | ||
206 | */ | ||
207 | |||
208 | /* :0 s 38 01 3100 0003 0004 4 = 03030000 | ||
209 | * FILTER CONTROL | ||
210 | * 1st byte luma low pass filter strength, | ||
211 | * 2nd byte chroma low pass filter strength, | ||
212 | * 3rd byte MF enable chroma, min=0, max=1 | ||
213 | * 4th byte n | ||
214 | */ | ||
215 | |||
216 | |||
217 | /* :0 s 38 b9 0001 0000 0000 0 */ | ||
218 | |||
219 | |||
220 | |||
221 | /* :0 s 38 d3 0000 0000 0001 1 = 00 */ | ||
222 | /* ret = usb_control_msg(dev->udev, */ | ||
223 | /* usb_sndctrlpipe(dev->udev, 0), */ | ||
224 | /* 0xd3, 0x38, */ | ||
225 | /* 0, 0, */ | ||
226 | /* "\0", 1, */ | ||
227 | /* 1000); */ | ||
228 | |||
229 | /* info("control request returned %d", ret); */ | ||
230 | /* msleep(5000); */ | ||
231 | |||
232 | |||
233 | /* :0 s b8 81 1400 0003 0005 5 < | ||
234 | * :0 0 5 = d0024002 19 | ||
235 | * QUERY FRAME SIZE AND RATE | ||
236 | * 1st and 2nd byte (little endian): horizontal resolution | ||
237 | * 3rd and 4th byte (little endian): vertical resolution | ||
238 | * 5th byte: frame rate | ||
239 | */ | ||
240 | |||
241 | /* :0 s b8 81 1800 0003 0003 3 < | ||
242 | * :0 0 3 = 030104 | ||
243 | * QUERY SIGNAL AND DETECTED LINES, maybe INPUT | ||
244 | */ | ||
245 | |||
246 | enum hdpvr_video_std { | ||
247 | HDPVR_60HZ = 0, | ||
248 | HDPVR_50HZ, | ||
249 | }; | ||
250 | |||
251 | enum hdpvr_video_input { | ||
252 | HDPVR_COMPONENT = 0, | ||
253 | HDPVR_SVIDEO, | ||
254 | HDPVR_COMPOSITE, | ||
255 | HDPVR_VIDEO_INPUTS | ||
256 | }; | ||
257 | |||
258 | enum hdpvr_audio_inputs { | ||
259 | HDPVR_RCA_BACK = 0, | ||
260 | HDPVR_RCA_FRONT, | ||
261 | HDPVR_SPDIF, | ||
262 | HDPVR_AUDIO_INPUTS | ||
263 | }; | ||
264 | |||
265 | enum hdpvr_bitrate_mode { | ||
266 | HDPVR_CONSTANT = 1, | ||
267 | HDPVR_VARIABLE_PEAK, | ||
268 | HDPVR_VARIABLE_AVERAGE, | ||
269 | }; | ||
270 | |||
271 | enum hdpvr_gop_mode { | ||
272 | HDPVR_ADVANCED_IDR_GOP = 0, | ||
273 | HDPVR_SIMPLE_IDR_GOP, | ||
274 | HDPVR_ADVANCED_NOIDR_GOP, | ||
275 | HDPVR_SIMPLE_NOIDR_GOP, | ||
276 | }; | ||
277 | |||
278 | void hdpvr_delete(struct hdpvr_device *dev); | ||
279 | |||
280 | /*========================================================================*/ | ||
281 | /* hardware control functions */ | ||
282 | int hdpvr_set_options(struct hdpvr_device *dev); | ||
283 | |||
284 | int hdpvr_set_bitrate(struct hdpvr_device *dev); | ||
285 | |||
286 | int hdpvr_set_audio(struct hdpvr_device *dev, u8 input, | ||
287 | enum v4l2_mpeg_audio_encoding codec); | ||
288 | |||
289 | int hdpvr_config_call(struct hdpvr_device *dev, uint value, | ||
290 | unsigned char valbuf); | ||
291 | |||
292 | struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev); | ||
293 | |||
294 | /* :0 s b8 81 1800 0003 0003 3 < */ | ||
295 | /* :0 0 3 = 0301ff */ | ||
296 | int get_input_lines_info(struct hdpvr_device *dev); | ||
297 | |||
298 | |||
299 | /*========================================================================*/ | ||
300 | /* v4l2 registration */ | ||
301 | int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent, | ||
302 | int devnumber); | ||
303 | |||
304 | int hdpvr_cancel_queue(struct hdpvr_device *dev); | ||
305 | |||
306 | /*========================================================================*/ | ||
307 | /* i2c adapter registration */ | ||
308 | int hdpvr_register_i2c_adapter(struct hdpvr_device *dev); | ||
309 | |||
310 | struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev); | ||
311 | struct i2c_client *hdpvr_register_ir_tx_i2c(struct hdpvr_device *dev); | ||
312 | |||
313 | /*========================================================================*/ | ||
314 | /* buffer management */ | ||
315 | int hdpvr_free_buffers(struct hdpvr_device *dev); | ||
316 | int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count); | ||