aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pwc/pwc.h
diff options
context:
space:
mode:
authorLuc Saillard <luc@saillard.org>2006-04-24 09:29:46 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-06-25 00:58:20 -0400
commit2b455db6d456ef2d44808a8377fd3bc832e08317 (patch)
treeb7b7bcabd53f9bb58d7f69eb6d012735dacd31c7 /drivers/media/video/pwc/pwc.h
parentd9e12f25cf538d103426946121d214dff332efbb (diff)
V4L/DVB (3835): [PATCH] update pwc driver
Add v4l2 compatibility Include the decompressor (legal problem has been resolv by Alan Cox) Faster decoder and easier to maintain, optimize, ... Can export to userland compressed stream Support more cameras, lot of bugs are fixed. Signed-off-by: Luc Saillard <luc@saillard.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pwc/pwc.h')
-rw-r--r--drivers/media/video/pwc/pwc.h176
1 files changed, 132 insertions, 44 deletions
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index 1b0ee0ced0ed..1fd8c34d1181 100644
--- a/drivers/media/video/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -1,5 +1,5 @@
1/* (C) 1999-2003 Nemosoft Unv. 1/* (C) 1999-2003 Nemosoft Unv.
2 (C) 2004 Luc Saillard (luc@saillard.org) 2 (C) 2004-2006 Luc Saillard (luc@saillard.org)
3 3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx 4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version. 5 driver and thus may have bugs that are not present in the original version.
@@ -29,51 +29,87 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/usb.h> 30#include <linux/usb.h>
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <linux/videodev.h>
33#include <linux/wait.h> 32#include <linux/wait.h>
34#include <linux/smp_lock.h> 33#include <linux/smp_lock.h>
34#include <linux/version.h>
35#include <asm/semaphore.h> 35#include <asm/semaphore.h>
36#include <asm/errno.h> 36#include <asm/errno.h>
37#include <linux/videodev.h>
38#include <linux/videodev2.h>
37 39
38#include "pwc-uncompress.h" 40#include "pwc-uncompress.h"
39#include "pwc-ioctl.h" 41#include <media/pwc-ioctl.h>
40
41/* Defines and structures for the Philips webcam */
42/* Used for checking memory corruption/pointer validation */
43#define PWC_MAGIC 0x89DC10ABUL
44#undef PWC_MAGIC
45 42
46/* Turn some debugging options on/off */ 43/* Turn some debugging options on/off */
47#define PWC_DEBUG 0 44#ifndef CONFIG_PWC_DEBUG
45#define CONFIG_PWC_DEBUG 1
46#endif
47
48/* Version block */
49#define PWC_MAJOR 10
50#define PWC_MINOR 0
51#define PWC_EXTRAMINOR 12
52#define PWC_VERSION_CODE KERNEL_VERSION(PWC_MAJOR,PWC_MINOR,PWC_EXTRAMINOR)
53#define PWC_VERSION "10.0.12"
54#define PWC_NAME "pwc"
55#define PFX PWC_NAME ": "
56
48 57
49/* Trace certain actions in the driver */ 58/* Trace certain actions in the driver */
50#define TRACE_MODULE 0x0001 59#define PWC_DEBUG_LEVEL_MODULE (1<<0)
51#define TRACE_PROBE 0x0002 60#define PWC_DEBUG_LEVEL_PROBE (1<<1)
52#define TRACE_OPEN 0x0004 61#define PWC_DEBUG_LEVEL_OPEN (1<<2)
53#define TRACE_READ 0x0008 62#define PWC_DEBUG_LEVEL_READ (1<<3)
54#define TRACE_MEMORY 0x0010 63#define PWC_DEBUG_LEVEL_MEMORY (1<<4)
55#define TRACE_FLOW 0x0020 64#define PWC_DEBUG_LEVEL_FLOW (1<<5)
56#define TRACE_SIZE 0x0040 65#define PWC_DEBUG_LEVEL_SIZE (1<<6)
57#define TRACE_PWCX 0x0080 66#define PWC_DEBUG_LEVEL_IOCTL (1<<7)
58#define TRACE_SEQUENCE 0x1000 67#define PWC_DEBUG_LEVEL_TRACE (1<<8)
59 68
60#define Trace(R, A...) if (pwc_trace & R) printk(KERN_DEBUG PWC_NAME " " A) 69#define PWC_DEBUG_MODULE(fmt, args...) PWC_DEBUG(MODULE, fmt, ##args)
61#define Debug(A...) printk(KERN_DEBUG PWC_NAME " " A) 70#define PWC_DEBUG_PROBE(fmt, args...) PWC_DEBUG(PROBE, fmt, ##args)
62#define Info(A...) printk(KERN_INFO PWC_NAME " " A) 71#define PWC_DEBUG_OPEN(fmt, args...) PWC_DEBUG(OPEN, fmt, ##args)
63#define Err(A...) printk(KERN_ERR PWC_NAME " " A) 72#define PWC_DEBUG_READ(fmt, args...) PWC_DEBUG(READ, fmt, ##args)
73#define PWC_DEBUG_MEMORY(fmt, args...) PWC_DEBUG(MEMORY, fmt, ##args)
74#define PWC_DEBUG_FLOW(fmt, args...) PWC_DEBUG(FLOW, fmt, ##args)
75#define PWC_DEBUG_SIZE(fmt, args...) PWC_DEBUG(SIZE, fmt, ##args)
76#define PWC_DEBUG_IOCTL(fmt, args...) PWC_DEBUG(IOCTL, fmt, ##args)
77#define PWC_DEBUG_TRACE(fmt, args...) PWC_DEBUG(TRACE, fmt, ##args)
78
79
80#if CONFIG_PWC_DEBUG
81
82#define PWC_DEBUG_LEVEL (PWC_DEBUG_LEVEL_MODULE)
83
84#define PWC_DEBUG(level, fmt, args...) do {\
85 if ((PWC_DEBUG_LEVEL_ ##level) & pwc_trace) \
86 printk(KERN_DEBUG PFX fmt, ##args); \
87 } while(0)
88
89#define PWC_ERROR(fmt, args...) printk(KERN_ERR PFX fmt, ##args)
90#define PWC_WARNING(fmt, args...) printk(KERN_WARNING PFX fmt, ##args)
91#define PWC_INFO(fmt, args...) printk(KERN_INFO PFX fmt, ##args)
92#define PWC_TRACE(fmt, args...) PWC_DEBUG(TRACE, fmt, ##args)
93
94#else /* if ! CONFIG_PWC_DEBUG */
95
96#define PWC_ERROR(fmt, args...) printk(KERN_ERR PFX fmt, ##args)
97#define PWC_WARNING(fmt, args...) printk(KERN_WARNING PFX fmt, ##args)
98#define PWC_INFO(fmt, args...) printk(KERN_INFO PFX fmt, ##args)
99#define PWC_TRACE(fmt, args...) do { } while(0)
100#define PWC_DEBUG(level, fmt, args...) do { } while(0)
101
102#define pwc_trace 0
64 103
104#endif
65 105
66/* Defines for ToUCam cameras */ 106/* Defines for ToUCam cameras */
67#define TOUCAM_HEADER_SIZE 8 107#define TOUCAM_HEADER_SIZE 8
68#define TOUCAM_TRAILER_SIZE 4 108#define TOUCAM_TRAILER_SIZE 4
69 109
70#define FEATURE_MOTOR_PANTILT 0x0001 110#define FEATURE_MOTOR_PANTILT 0x0001
71 111#define FEATURE_CODEC1 0x0002
72/* Version block */ 112#define FEATURE_CODEC2 0x0004
73#define PWC_MAJOR 9
74#define PWC_MINOR 0
75#define PWC_VERSION "9.0.2-unofficial"
76#define PWC_NAME "pwc"
77 113
78/* Turn certain features on/off */ 114/* Turn certain features on/off */
79#define PWC_INT_PIPE 0 115#define PWC_INT_PIPE 0
@@ -95,6 +131,18 @@
95/* Absolute maximum number of buffers available for mmap() */ 131/* Absolute maximum number of buffers available for mmap() */
96#define MAX_IMAGES 10 132#define MAX_IMAGES 10
97 133
134/* Some macros to quickly find the type of a webcam */
135#define DEVICE_USE_CODEC1(x) ((x)<675)
136#define DEVICE_USE_CODEC2(x) ((x)>=675 && (x)<700)
137#define DEVICE_USE_CODEC3(x) ((x)>=700)
138#define DEVICE_USE_CODEC23(x) ((x)>=675)
139
140
141#ifndef V4L2_PIX_FMT_PWC1
142#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1')
143#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2')
144#endif
145
98/* The following structures were based on cpia.h. Why reinvent the wheel? :-) */ 146/* The following structures were based on cpia.h. Why reinvent the wheel? :-) */
99struct pwc_iso_buf 147struct pwc_iso_buf
100{ 148{
@@ -110,17 +158,19 @@ struct pwc_frame_buf
110 void *data; 158 void *data;
111 volatile int filled; /* number of bytes filled */ 159 volatile int filled; /* number of bytes filled */
112 struct pwc_frame_buf *next; /* list */ 160 struct pwc_frame_buf *next; /* list */
113#if PWC_DEBUG 161};
114 int sequence; /* Sequence number */ 162
115#endif 163/* additionnal informations used when dealing image between kernel and userland */
164struct pwc_imgbuf
165{
166 unsigned long offset; /* offset of this buffer in the big array of image_data */
167 int vma_use_count; /* count the number of time this memory is mapped */
116}; 168};
117 169
118struct pwc_device 170struct pwc_device
119{ 171{
120 struct video_device *vdev; 172 struct video_device *vdev;
121#ifdef PWC_MAGIC 173
122 int magic;
123#endif
124 /* Pointer to our usb_device */ 174 /* Pointer to our usb_device */
125 struct usb_device *udev; 175 struct usb_device *udev;
126 176
@@ -177,12 +227,8 @@ struct pwc_device
177 int frame_size; 227 int frame_size;
178 int frame_total_size; /* including header & trailer */ 228 int frame_total_size; /* including header & trailer */
179 int drop_frames; 229 int drop_frames;
180#if PWC_DEBUG
181 int sequence; /* Debugging aid */
182#endif
183 230
184 /* 3: decompression */ 231 /* 3: decompression */
185 struct pwc_decompressor *decompressor; /* function block with decompression routines */
186 void *decompress_data; /* private data for decompression engine */ 232 void *decompress_data; /* private data for decompression engine */
187 233
188 /* 4: image */ 234 /* 4: image */
@@ -198,7 +244,7 @@ struct pwc_device
198 struct pwc_coord offset; /* offset within the viewport */ 244 struct pwc_coord offset; /* offset within the viewport */
199 245
200 void *image_data; /* total buffer, which is subdivided into ... */ 246 void *image_data; /* total buffer, which is subdivided into ... */
201 void *image_ptr[MAX_IMAGES]; /* ...several images... */ 247 struct pwc_imgbuf images[MAX_IMAGES];/* ...several images... */
202 int fill_image; /* ...which are rotated. */ 248 int fill_image; /* ...which are rotated. */
203 int len_per_image; /* length per image */ 249 int len_per_image; /* length per image */
204 int image_read_pos; /* In case we read data in pieces, keep track of were we are in the imagebuffer */ 250 int image_read_pos; /* In case we read data in pieces, keep track of were we are in the imagebuffer */
@@ -211,6 +257,7 @@ struct pwc_device
211 struct pwc_mpt_range angle_range; 257 struct pwc_mpt_range angle_range;
212 int pan_angle; /* in degrees * 100 */ 258 int pan_angle; /* in degrees * 100 */
213 int tilt_angle; /* absolute angle; 0,0 is home position */ 259 int tilt_angle; /* absolute angle; 0,0 is home position */
260 int snapshot_button_status; /* set to 1 when the user push the button, reset to 0 when this value is read */
214 261
215 /*** Misc. data ***/ 262 /*** Misc. data ***/
216 wait_queue_head_t frameq; /* When waiting for a frame to finish... */ 263 wait_queue_head_t frameq; /* When waiting for a frame to finish... */
@@ -219,20 +266,27 @@ struct pwc_device
219#endif 266#endif
220}; 267};
221 268
222
223#ifdef __cplusplus 269#ifdef __cplusplus
224extern "C" { 270extern "C" {
225#endif 271#endif
226 272
227/* Global variable */ 273/* Global variables */
274#if CONFIG_PWC_DEBUG
228extern int pwc_trace; 275extern int pwc_trace;
276#endif
277extern int pwc_preferred_compression;
278extern int pwc_mbufs;
229 279
230/** functions in pwc-if.c */ 280/** functions in pwc-if.c */
231int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_fps, int new_compression, int new_snapshot); 281int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_fps, int new_compression, int new_snapshot);
282int pwc_handle_frame(struct pwc_device *pdev);
283void pwc_next_image(struct pwc_device *pdev);
284int pwc_isoc_init(struct pwc_device *pdev);
285void pwc_isoc_cleanup(struct pwc_device *pdev);
232 286
233/** Functions in pwc-misc.c */ 287/** Functions in pwc-misc.c */
234/* sizes in pixels */ 288/* sizes in pixels */
235extern struct pwc_coord pwc_image_sizes[PSZ_MAX]; 289extern const struct pwc_coord pwc_image_sizes[PSZ_MAX];
236 290
237int pwc_decode_size(struct pwc_device *pdev, int width, int height); 291int pwc_decode_size(struct pwc_device *pdev, int width, int height);
238void pwc_construct(struct pwc_device *pdev); 292void pwc_construct(struct pwc_device *pdev);
@@ -240,6 +294,9 @@ void pwc_construct(struct pwc_device *pdev);
240/** Functions in pwc-ctrl.c */ 294/** Functions in pwc-ctrl.c */
241/* Request a certain video mode. Returns < 0 if not possible */ 295/* Request a certain video mode. Returns < 0 if not possible */
242extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot); 296extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot);
297/* Calculate the number of bytes per image (not frame) */
298extern int pwc_mpt_reset(struct pwc_device *pdev, int flags);
299extern int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt);
243 300
244/* Various controls; should be obvious. Value 0..65535, or < 0 on error */ 301/* Various controls; should be obvious. Value 0..65535, or < 0 on error */
245extern int pwc_get_brightness(struct pwc_device *pdev); 302extern int pwc_get_brightness(struct pwc_device *pdev);
@@ -248,10 +305,37 @@ extern int pwc_get_contrast(struct pwc_device *pdev);
248extern int pwc_set_contrast(struct pwc_device *pdev, int value); 305extern int pwc_set_contrast(struct pwc_device *pdev, int value);
249extern int pwc_get_gamma(struct pwc_device *pdev); 306extern int pwc_get_gamma(struct pwc_device *pdev);
250extern int pwc_set_gamma(struct pwc_device *pdev, int value); 307extern int pwc_set_gamma(struct pwc_device *pdev, int value);
251extern int pwc_get_saturation(struct pwc_device *pdev); 308extern int pwc_get_saturation(struct pwc_device *pdev, int *value);
252extern int pwc_set_saturation(struct pwc_device *pdev, int value); 309extern int pwc_set_saturation(struct pwc_device *pdev, int value);
253extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value); 310extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value);
311extern int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value);
254extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor); 312extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor);
313extern int pwc_restore_user(struct pwc_device *pdev);
314extern int pwc_save_user(struct pwc_device *pdev);
315extern int pwc_restore_factory(struct pwc_device *pdev);
316
317/* exported for use by v4l2 controls */
318extern int pwc_get_red_gain(struct pwc_device *pdev, int *value);
319extern int pwc_set_red_gain(struct pwc_device *pdev, int value);
320extern int pwc_get_blue_gain(struct pwc_device *pdev, int *value);
321extern int pwc_set_blue_gain(struct pwc_device *pdev, int value);
322extern int pwc_get_awb(struct pwc_device *pdev);
323extern int pwc_set_awb(struct pwc_device *pdev, int mode);
324extern int pwc_set_agc(struct pwc_device *pdev, int mode, int value);
325extern int pwc_get_agc(struct pwc_device *pdev, int *value);
326extern int pwc_set_shutter_speed(struct pwc_device *pdev, int mode, int value);
327extern int pwc_get_shutter_speed(struct pwc_device *pdev, int *value);
328
329extern int pwc_set_colour_mode(struct pwc_device *pdev, int colour);
330extern int pwc_get_colour_mode(struct pwc_device *pdev, int *colour);
331extern int pwc_set_contour(struct pwc_device *pdev, int contour);
332extern int pwc_get_contour(struct pwc_device *pdev, int *contour);
333extern int pwc_set_backlight(struct pwc_device *pdev, int backlight);
334extern int pwc_get_backlight(struct pwc_device *pdev, int *backlight);
335extern int pwc_set_flicker(struct pwc_device *pdev, int flicker);
336extern int pwc_get_flicker(struct pwc_device *pdev, int *flicker);
337extern int pwc_set_dynamic_noise(struct pwc_device *pdev, int noise);
338extern int pwc_get_dynamic_noise(struct pwc_device *pdev, int *noise);
255 339
256/* Power down or up the camera; not supported by all models */ 340/* Power down or up the camera; not supported by all models */
257extern int pwc_camera_power(struct pwc_device *pdev, int power); 341extern int pwc_camera_power(struct pwc_device *pdev, int power);
@@ -259,6 +343,9 @@ extern int pwc_camera_power(struct pwc_device *pdev, int power);
259/* Private ioctl()s; see pwc-ioctl.h */ 343/* Private ioctl()s; see pwc-ioctl.h */
260extern int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg); 344extern int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg);
261 345
346/** Functions in pwc-v4l.c */
347extern int pwc_video_do_ioctl(struct inode *inode, struct file *file,
348 unsigned int cmd, void *arg);
262 349
263/** pwc-uncompress.c */ 350/** pwc-uncompress.c */
264/* Expand frame to image, possibly including decompression. Uses read_frame and fill_image */ 351/* Expand frame to image, possibly including decompression. Uses read_frame and fill_image */
@@ -270,3 +357,4 @@ extern int pwc_decompress(struct pwc_device *pdev);
270 357
271 358
272#endif 359#endif
360/* vim: set cino= formatoptions=croql cindent shiftwidth=8 tabstop=8: */