Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hdpvr.h
Go to the documentation of this file.
1 /*
2  * Hauppauge HD PVR USB driver
3  *
4  * Copyright (C) 2008 Janne Grunau ([email protected])
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 {
52  u8 bitrate; /* in 100kbps */
53  u8 peak_bitrate; /* in 100kbps */
62 };
63 
64 /* Structure to hold all of our device specific stuff */
65 struct hdpvr_device {
66  /* the v4l device for this device */
68  /* the usb device for this device */
69  struct usb_device *udev;
70  /* v4l2-device unused */
72 
73  /* the max packet size of the bulk endpoint */
74  size_t bulk_in_size;
75  /* the address of the bulk in endpoint */
77 
78  /* holds the current device status */
80  /* count the number of openers */
82 
83  /* holds the cureent set options */
85 
87 
88  /* synchronize I/O */
89  struct mutex io_mutex;
90  /* available buffers */
92  /* in progress buffers */
94  /* waitqueue for buffers */
96  /* waitqueue for data */
98 
100 
102 
103  /* I2C adapter */
105  /* I2C lock */
106  struct mutex i2c_mutex;
107  /* I2C message buffer space */
109 
110  /* For passing data to ir-kbd-i2c */
112 
113  /* usb control transfer buffer and lock */
117 };
118 
119 static 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 /* buffer one bulk urb of data */
126 struct hdpvr_buffer {
128 
129  struct urb *urb;
130 
131  struct hdpvr_device *dev;
132 
134 
136 };
137 
138 /* */
139 
144 };
145 
146 enum {
154 };
155 
156 enum {
158 };
159 
160 enum {
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  /* :0 s 38 01 1000 0003 0004 4 = 0a00ca00
186  * BITRATE SETTING
187  * 1st and 2nd byte (little endian): average bitrate in 100 000 bit/s
188  * min: 1 mbit/s, max: 13.5 mbit/s
189  * 3rd and 4th byte (little endian): peak bitrate in 100 000 bit/s
190  * min: average + 100kbit/s,
191  * max: 20.2 mbit/s
192  */
193 
194  /* :0 s 38 01 1200 0003 0001 1 = 02
195  * BIT RATE MODE
196  * constant = 1, variable (peak) = 2, variable (average) = 3
197  */
198 
199  /* :0 s 38 01 1300 0003 0001 1 = 03
200  * GOP MODE (2 bit)
201  * low bit 0/1: advanced/simple GOP
202  * high bit 0/1: IDR(4/32/128) / no IDR (4/32/0)
203  */
204 
205  /* :0 s 38 01 1700 0003 0001 1 = 00
206  * VIDEO STANDARD or FREQUNCY 0 = 60hz, 1 = 50hz
207  */
208 
209  /* :0 s 38 01 3100 0003 0004 4 = 03030000
210  * FILTER CONTROL
211  * 1st byte luma low pass filter strength,
212  * 2nd byte chroma low pass filter strength,
213  * 3rd byte MF enable chroma, min=0, max=1
214  * 4th byte n
215  */
216 
217 
218  /* :0 s 38 b9 0001 0000 0000 0 */
219 
220 
221 
222 /* :0 s 38 d3 0000 0000 0001 1 = 00 */
223 /* ret = usb_control_msg(dev->udev, */
224 /* usb_sndctrlpipe(dev->udev, 0), */
225 /* 0xd3, 0x38, */
226 /* 0, 0, */
227 /* "\0", 1, */
228 /* 1000); */
229 
230 /* info("control request returned %d", ret); */
231 /* msleep(5000); */
232 
233 
234  /* :0 s b8 81 1400 0003 0005 5 <
235  * :0 0 5 = d0024002 19
236  * QUERY FRAME SIZE AND RATE
237  * 1st and 2nd byte (little endian): horizontal resolution
238  * 3rd and 4th byte (little endian): vertical resolution
239  * 5th byte: frame rate
240  */
241 
242  /* :0 s b8 81 1800 0003 0003 3 <
243  * :0 0 3 = 030104
244  * QUERY SIGNAL AND DETECTED LINES, maybe INPUT
245  */
246 
250 };
251 
257 };
258 
264 };
265 
270 };
271 
277 };
278 
279 void hdpvr_delete(struct hdpvr_device *dev);
280 
281 /*========================================================================*/
282 /* hardware control functions */
283 int hdpvr_set_options(struct hdpvr_device *dev);
284 
285 int hdpvr_set_bitrate(struct hdpvr_device *dev);
286 
289 
291  unsigned char valbuf);
292 
294 
295 /* :0 s b8 81 1800 0003 0003 3 < */
296 /* :0 0 3 = 0301ff */
298 
299 
300 /*========================================================================*/
301 /* v4l2 registration */
302 int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
303  int devnumber);
304 
305 int hdpvr_cancel_queue(struct hdpvr_device *dev);
306 
307 /*========================================================================*/
308 /* i2c adapter registration */
310 
313 
314 /*========================================================================*/
315 /* buffer management */
316 int hdpvr_free_buffers(struct hdpvr_device *dev);