aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/hdpvr/hdpvr.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/hdpvr/hdpvr.h')
-rw-r--r--drivers/media/video/hdpvr/hdpvr.h303
1 files changed, 303 insertions, 0 deletions
diff --git a/drivers/media/video/hdpvr/hdpvr.h b/drivers/media/video/hdpvr/hdpvr.h
new file mode 100644
index 000000000000..1edd8759121e
--- /dev/null
+++ b/drivers/media/video/hdpvr/hdpvr.h
@@ -0,0 +1,303 @@
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
20#define HDPVR_MAJOR_VERSION 0
21#define HDPVR_MINOR_VERSION 2
22#define HDPVR_RELEASE 0
23#define HDPVR_VERSION \
24 KERNEL_VERSION(HDPVR_MAJOR_VERSION, HDPVR_MINOR_VERSION, HDPVR_RELEASE)
25
26#define HDPVR_MAX 8
27
28/* Define these values to match your devices */
29#define HD_PVR_VENDOR_ID 0x2040
30#define HD_PVR_PRODUCT_ID 0x4900
31#define HD_PVR_PRODUCT_ID1 0x4901
32#define HD_PVR_PRODUCT_ID2 0x4902
33
34#define UNSET (-1U)
35
36#define NUM_BUFFERS 64
37
38#define HDPVR_FIRMWARE_VERSION 0x8
39#define HDPVR_FIRMWARE_VERSION_AC3 0xd
40
41/* #define HDPVR_DEBUG */
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; /* 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 */
65struct 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
108 /* usb control transfer buffer and lock */
109 struct mutex usbc_mutex;
110 u8 *usbc_buf;
111};
112
113
114/* buffer one bulk urb of data */
115struct hdpvr_buffer {
116 struct list_head buff_list;
117
118 struct urb *urb;
119
120 struct hdpvr_device *dev;
121
122 uint pos;
123
124 __u8 status;
125};
126
127/* */
128
129struct hdpvr_video_info {
130 u16 width;
131 u16 height;
132 u8 fps;
133};
134
135enum {
136 STATUS_UNINITIALIZED = 0,
137 STATUS_IDLE,
138 STATUS_STARTING,
139 STATUS_SHUTTING_DOWN,
140 STATUS_STREAMING,
141 STATUS_ERROR,
142 STATUS_DISCONNECTED,
143};
144
145enum {
146 HDPVR_FLAG_AC3_CAP = 1,
147};
148
149enum {
150 BUFSTAT_UNINITIALIZED = 0,
151 BUFSTAT_AVAILABLE,
152 BUFSTAT_INPROGRESS,
153 BUFSTAT_READY,
154};
155
156#define CTRL_START_STREAMING_VALUE 0x0700
157#define CTRL_STOP_STREAMING_VALUE 0x0800
158#define CTRL_BITRATE_VALUE 0x1000
159#define CTRL_BITRATE_MODE_VALUE 0x1200
160#define CTRL_GOP_MODE_VALUE 0x1300
161#define CTRL_VIDEO_INPUT_VALUE 0x1500
162#define CTRL_VIDEO_STD_TYPE 0x1700
163#define CTRL_AUDIO_INPUT_VALUE 0x2500
164#define CTRL_BRIGHTNESS 0x2900
165#define CTRL_CONTRAST 0x2a00
166#define CTRL_HUE 0x2b00
167#define CTRL_SATURATION 0x2c00
168#define CTRL_SHARPNESS 0x2d00
169#define CTRL_LOW_PASS_FILTER_VALUE 0x3100
170
171#define CTRL_DEFAULT_INDEX 0x0003
172
173
174 /* :0 s 38 01 1000 0003 0004 4 = 0a00ca00
175 * BITRATE SETTING
176 * 1st and 2nd byte (little endian): average bitrate in 100 000 bit/s
177 * min: 1 mbit/s, max: 13.5 mbit/s
178 * 3rd and 4th byte (little endian): peak bitrate in 100 000 bit/s
179 * min: average + 100kbit/s,
180 * max: 20.2 mbit/s
181 */
182
183 /* :0 s 38 01 1200 0003 0001 1 = 02
184 * BIT RATE MODE
185 * constant = 1, variable (peak) = 2, variable (average) = 3
186 */
187
188 /* :0 s 38 01 1300 0003 0001 1 = 03
189 * GOP MODE (2 bit)
190 * low bit 0/1: advanced/simple GOP
191 * high bit 0/1: IDR(4/32/128) / no IDR (4/32/0)
192 */
193
194 /* :0 s 38 01 1700 0003 0001 1 = 00
195 * VIDEO STANDARD or FREQUNCY 0 = 60hz, 1 = 50hz
196 */
197
198 /* :0 s 38 01 3100 0003 0004 4 = 03030000
199 * FILTER CONTROL
200 * 1st byte luma low pass filter strength,
201 * 2nd byte chroma low pass filter strength,
202 * 3rd byte MF enable chroma, min=0, max=1
203 * 4th byte n
204 */
205
206
207 /* :0 s 38 b9 0001 0000 0000 0 */
208
209
210
211/* :0 s 38 d3 0000 0000 0001 1 = 00 */
212/* ret = usb_control_msg(dev->udev, */
213/* usb_sndctrlpipe(dev->udev, 0), */
214/* 0xd3, 0x38, */
215/* 0, 0, */
216/* "\0", 1, */
217/* 1000); */
218
219/* info("control request returned %d", ret); */
220/* msleep(5000); */
221
222
223 /* :0 s b8 81 1400 0003 0005 5 <
224 * :0 0 5 = d0024002 19
225 * QUERY FRAME SIZE AND RATE
226 * 1st and 2nd byte (little endian): horizontal resolution
227 * 3rd and 4th byte (little endian): vertical resolution
228 * 5th byte: frame rate
229 */
230
231 /* :0 s b8 81 1800 0003 0003 3 <
232 * :0 0 3 = 030104
233 * QUERY SIGNAL AND DETECTED LINES, maybe INPUT
234 */
235
236enum hdpvr_video_std {
237 HDPVR_60HZ = 0,
238 HDPVR_50HZ,
239};
240
241enum hdpvr_video_input {
242 HDPVR_COMPONENT = 0,
243 HDPVR_SVIDEO,
244 HDPVR_COMPOSITE,
245 HDPVR_VIDEO_INPUTS
246};
247
248enum hdpvr_audio_inputs {
249 HDPVR_RCA_BACK = 0,
250 HDPVR_RCA_FRONT,
251 HDPVR_SPDIF,
252 HDPVR_AUDIO_INPUTS
253};
254
255enum hdpvr_bitrate_mode {
256 HDPVR_CONSTANT = 1,
257 HDPVR_VARIABLE_PEAK,
258 HDPVR_VARIABLE_AVERAGE,
259};
260
261enum hdpvr_gop_mode {
262 HDPVR_ADVANCED_IDR_GOP = 0,
263 HDPVR_SIMPLE_IDR_GOP,
264 HDPVR_ADVANCED_NOIDR_GOP,
265 HDPVR_SIMPLE_NOIDR_GOP,
266};
267
268void hdpvr_delete(struct hdpvr_device *dev);
269
270/*========================================================================*/
271/* hardware control functions */
272int hdpvr_set_options(struct hdpvr_device *dev);
273
274int hdpvr_set_bitrate(struct hdpvr_device *dev);
275
276int hdpvr_set_audio(struct hdpvr_device *dev, u8 input,
277 enum v4l2_mpeg_audio_encoding codec);
278
279int hdpvr_config_call(struct hdpvr_device *dev, uint value,
280 unsigned char valbuf);
281
282struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev);
283
284/* :0 s b8 81 1800 0003 0003 3 < */
285/* :0 0 3 = 0301ff */
286int get_input_lines_info(struct hdpvr_device *dev);
287
288
289/*========================================================================*/
290/* v4l2 registration */
291int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
292 int devnumber);
293
294int hdpvr_cancel_queue(struct hdpvr_device *dev);
295
296/*========================================================================*/
297/* i2c adapter registration */
298int hdpvr_register_i2c_adapter(struct hdpvr_device *dev);
299
300/*========================================================================*/
301/* buffer management */
302int hdpvr_free_buffers(struct hdpvr_device *dev);
303int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count);