Merge branch 'v6v7' into devel
[linux/fpc-iii.git] / drivers / media / video / hdpvr / hdpvr.h
blob072f23c570f343388e11582d504e07e7ae38ab74
1 /*
2 * Hauppauge HD PVR USB driver
4 * Copyright (C) 2008 Janne Grunau (j@jannau.net)
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.
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>
18 #include <media/v4l2-device.h>
19 #include <media/ir-kbd-i2c.h>
21 #define HDPVR_MAJOR_VERSION 0
22 #define HDPVR_MINOR_VERSION 2
23 #define HDPVR_RELEASE 0
24 #define HDPVR_VERSION \
25 KERNEL_VERSION(HDPVR_MAJOR_VERSION, HDPVR_MINOR_VERSION, HDPVR_RELEASE)
27 #define HDPVR_MAX 8
28 #define HDPVR_I2C_MAX_SIZE 128
30 /* Define these values to match your devices */
31 #define HD_PVR_VENDOR_ID 0x2040
32 #define HD_PVR_PRODUCT_ID 0x4900
33 #define HD_PVR_PRODUCT_ID1 0x4901
34 #define HD_PVR_PRODUCT_ID2 0x4902
35 #define HD_PVR_PRODUCT_ID4 0x4903
36 #define HD_PVR_PRODUCT_ID3 0x4982
38 #define UNSET (-1U)
40 #define NUM_BUFFERS 64
42 #define HDPVR_FIRMWARE_VERSION 0x08
43 #define HDPVR_FIRMWARE_VERSION_AC3 0x0d
44 #define HDPVR_FIRMWARE_VERSION_0X12 0x12
45 #define HDPVR_FIRMWARE_VERSION_0X15 0x15
47 /* #define HDPVR_DEBUG */
49 extern int hdpvr_debug;
51 #define MSG_INFO 1
52 #define MSG_BUFFER 2
54 struct hdpvr_options {
55 u8 video_std;
56 u8 video_input;
57 u8 audio_input;
58 u8 bitrate; /* in 100kbps */
59 u8 peak_bitrate; /* in 100kbps */
60 u8 bitrate_mode;
61 u8 gop_mode;
62 enum v4l2_mpeg_audio_encoding audio_codec;
63 u8 brightness;
64 u8 contrast;
65 u8 hue;
66 u8 saturation;
67 u8 sharpness;
70 /* Structure to hold all of our device specific stuff */
71 struct hdpvr_device {
72 /* the v4l device for this device */
73 struct video_device *video_dev;
74 /* the usb device for this device */
75 struct usb_device *udev;
76 /* v4l2-device unused */
77 struct v4l2_device v4l2_dev;
79 /* the max packet size of the bulk endpoint */
80 size_t bulk_in_size;
81 /* the address of the bulk in endpoint */
82 __u8 bulk_in_endpointAddr;
84 /* holds the current device status */
85 __u8 status;
86 /* count the number of openers */
87 uint open_count;
89 /* holds the cureent set options */
90 struct hdpvr_options options;
92 uint flags;
94 /* synchronize I/O */
95 struct mutex io_mutex;
96 /* available buffers */
97 struct list_head free_buff_list;
98 /* in progress buffers */
99 struct list_head rec_buff_list;
100 /* waitqueue for buffers */
101 wait_queue_head_t wait_buffer;
102 /* waitqueue for data */
103 wait_queue_head_t wait_data;
104 /**/
105 struct workqueue_struct *workqueue;
106 /**/
107 struct work_struct worker;
109 /* I2C adapter */
110 struct i2c_adapter i2c_adapter;
111 /* I2C lock */
112 struct mutex i2c_mutex;
113 /* I2C message buffer space */
114 char i2c_buf[HDPVR_I2C_MAX_SIZE];
116 /* For passing data to ir-kbd-i2c */
117 struct IR_i2c_init_data ir_i2c_init_data;
119 /* usb control transfer buffer and lock */
120 struct mutex usbc_mutex;
121 u8 *usbc_buf;
124 static inline struct hdpvr_device *to_hdpvr_dev(struct v4l2_device *v4l2_dev)
126 return container_of(v4l2_dev, struct hdpvr_device, v4l2_dev);
130 /* buffer one bulk urb of data */
131 struct hdpvr_buffer {
132 struct list_head buff_list;
134 struct urb *urb;
136 struct hdpvr_device *dev;
138 uint pos;
140 __u8 status;
143 /* */
145 struct hdpvr_video_info {
146 u16 width;
147 u16 height;
148 u8 fps;
151 enum {
152 STATUS_UNINITIALIZED = 0,
153 STATUS_IDLE,
154 STATUS_STARTING,
155 STATUS_SHUTTING_DOWN,
156 STATUS_STREAMING,
157 STATUS_ERROR,
158 STATUS_DISCONNECTED,
161 enum {
162 HDPVR_FLAG_AC3_CAP = 1,
165 enum {
166 BUFSTAT_UNINITIALIZED = 0,
167 BUFSTAT_AVAILABLE,
168 BUFSTAT_INPROGRESS,
169 BUFSTAT_READY,
172 #define CTRL_START_STREAMING_VALUE 0x0700
173 #define CTRL_STOP_STREAMING_VALUE 0x0800
174 #define CTRL_BITRATE_VALUE 0x1000
175 #define CTRL_BITRATE_MODE_VALUE 0x1200
176 #define CTRL_GOP_MODE_VALUE 0x1300
177 #define CTRL_VIDEO_INPUT_VALUE 0x1500
178 #define CTRL_VIDEO_STD_TYPE 0x1700
179 #define CTRL_AUDIO_INPUT_VALUE 0x2500
180 #define CTRL_BRIGHTNESS 0x2900
181 #define CTRL_CONTRAST 0x2a00
182 #define CTRL_HUE 0x2b00
183 #define CTRL_SATURATION 0x2c00
184 #define CTRL_SHARPNESS 0x2d00
185 #define CTRL_LOW_PASS_FILTER_VALUE 0x3100
187 #define CTRL_DEFAULT_INDEX 0x0003
190 /* :0 s 38 01 1000 0003 0004 4 = 0a00ca00
191 * BITRATE SETTING
192 * 1st and 2nd byte (little endian): average bitrate in 100 000 bit/s
193 * min: 1 mbit/s, max: 13.5 mbit/s
194 * 3rd and 4th byte (little endian): peak bitrate in 100 000 bit/s
195 * min: average + 100kbit/s,
196 * max: 20.2 mbit/s
199 /* :0 s 38 01 1200 0003 0001 1 = 02
200 * BIT RATE MODE
201 * constant = 1, variable (peak) = 2, variable (average) = 3
204 /* :0 s 38 01 1300 0003 0001 1 = 03
205 * GOP MODE (2 bit)
206 * low bit 0/1: advanced/simple GOP
207 * high bit 0/1: IDR(4/32/128) / no IDR (4/32/0)
210 /* :0 s 38 01 1700 0003 0001 1 = 00
211 * VIDEO STANDARD or FREQUNCY 0 = 60hz, 1 = 50hz
214 /* :0 s 38 01 3100 0003 0004 4 = 03030000
215 * FILTER CONTROL
216 * 1st byte luma low pass filter strength,
217 * 2nd byte chroma low pass filter strength,
218 * 3rd byte MF enable chroma, min=0, max=1
219 * 4th byte n
223 /* :0 s 38 b9 0001 0000 0000 0 */
227 /* :0 s 38 d3 0000 0000 0001 1 = 00 */
228 /* ret = usb_control_msg(dev->udev, */
229 /* usb_sndctrlpipe(dev->udev, 0), */
230 /* 0xd3, 0x38, */
231 /* 0, 0, */
232 /* "\0", 1, */
233 /* 1000); */
235 /* info("control request returned %d", ret); */
236 /* msleep(5000); */
239 /* :0 s b8 81 1400 0003 0005 5 <
240 * :0 0 5 = d0024002 19
241 * QUERY FRAME SIZE AND RATE
242 * 1st and 2nd byte (little endian): horizontal resolution
243 * 3rd and 4th byte (little endian): vertical resolution
244 * 5th byte: frame rate
247 /* :0 s b8 81 1800 0003 0003 3 <
248 * :0 0 3 = 030104
249 * QUERY SIGNAL AND DETECTED LINES, maybe INPUT
252 enum hdpvr_video_std {
253 HDPVR_60HZ = 0,
254 HDPVR_50HZ,
257 enum hdpvr_video_input {
258 HDPVR_COMPONENT = 0,
259 HDPVR_SVIDEO,
260 HDPVR_COMPOSITE,
261 HDPVR_VIDEO_INPUTS
264 enum hdpvr_audio_inputs {
265 HDPVR_RCA_BACK = 0,
266 HDPVR_RCA_FRONT,
267 HDPVR_SPDIF,
268 HDPVR_AUDIO_INPUTS
271 enum hdpvr_bitrate_mode {
272 HDPVR_CONSTANT = 1,
273 HDPVR_VARIABLE_PEAK,
274 HDPVR_VARIABLE_AVERAGE,
277 enum hdpvr_gop_mode {
278 HDPVR_ADVANCED_IDR_GOP = 0,
279 HDPVR_SIMPLE_IDR_GOP,
280 HDPVR_ADVANCED_NOIDR_GOP,
281 HDPVR_SIMPLE_NOIDR_GOP,
284 void hdpvr_delete(struct hdpvr_device *dev);
286 /*========================================================================*/
287 /* hardware control functions */
288 int hdpvr_set_options(struct hdpvr_device *dev);
290 int hdpvr_set_bitrate(struct hdpvr_device *dev);
292 int hdpvr_set_audio(struct hdpvr_device *dev, u8 input,
293 enum v4l2_mpeg_audio_encoding codec);
295 int hdpvr_config_call(struct hdpvr_device *dev, uint value,
296 unsigned char valbuf);
298 struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev);
300 /* :0 s b8 81 1800 0003 0003 3 < */
301 /* :0 0 3 = 0301ff */
302 int get_input_lines_info(struct hdpvr_device *dev);
305 /*========================================================================*/
306 /* v4l2 registration */
307 int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
308 int devnumber);
310 int hdpvr_cancel_queue(struct hdpvr_device *dev);
312 /*========================================================================*/
313 /* i2c adapter registration */
314 int hdpvr_register_i2c_adapter(struct hdpvr_device *dev);
316 struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev);
317 struct i2c_client *hdpvr_register_ir_tx_i2c(struct hdpvr_device *dev);
319 /*========================================================================*/
320 /* buffer management */
321 int hdpvr_free_buffers(struct hdpvr_device *dev);
322 int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count);