[XFRM]: skb_cow_data() does not set proper owner for new skbs.
[linux-2.6/verdex.git] / drivers / usb / media / sn9c102.h
blob8b8a4c8743f88032142a13f6b7fe63152da6a2f8
1 /***************************************************************************
2 * V4L2 driver for SN9C10x PC Camera Controllers *
3 * *
4 * Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
19 ***************************************************************************/
21 #ifndef _SN9C102_H_
22 #define _SN9C102_H_
24 #include <linux/version.h>
25 #include <linux/usb.h>
26 #include <linux/videodev.h>
27 #include <linux/device.h>
28 #include <linux/list.h>
29 #include <linux/spinlock.h>
30 #include <linux/time.h>
31 #include <linux/wait.h>
32 #include <linux/types.h>
33 #include <linux/param.h>
34 #include <linux/rwsem.h>
35 #include <asm/semaphore.h>
37 #include "sn9c102_sensor.h"
39 /*****************************************************************************/
41 #define SN9C102_DEBUG
42 #define SN9C102_DEBUG_LEVEL 2
43 #define SN9C102_MAX_DEVICES 64
44 #define SN9C102_PRESERVE_IMGSCALE 0
45 #define SN9C102_FORCE_MUNMAP 0
46 #define SN9C102_MAX_FRAMES 32
47 #define SN9C102_URBS 2
48 #define SN9C102_ISO_PACKETS 7
49 #define SN9C102_ALTERNATE_SETTING 8
50 #define SN9C102_URB_TIMEOUT msecs_to_jiffies(2 * SN9C102_ISO_PACKETS)
51 #define SN9C102_CTRL_TIMEOUT 300
53 /*****************************************************************************/
55 #define SN9C102_MODULE_NAME "V4L2 driver for SN9C10x PC Camera Controllers"
56 #define SN9C102_MODULE_AUTHOR "(C) 2004-2005 Luca Risolia"
57 #define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
58 #define SN9C102_MODULE_LICENSE "GPL"
59 #define SN9C102_MODULE_VERSION "1:1.24"
60 #define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 24)
62 enum sn9c102_bridge {
63 BRIDGE_SN9C101 = 0x01,
64 BRIDGE_SN9C102 = 0x02,
65 BRIDGE_SN9C103 = 0x04,
68 SN9C102_ID_TABLE
69 SN9C102_SENSOR_TABLE
71 enum sn9c102_frame_state {
72 F_UNUSED,
73 F_QUEUED,
74 F_GRABBING,
75 F_DONE,
76 F_ERROR,
79 struct sn9c102_frame_t {
80 void* bufmem;
81 struct v4l2_buffer buf;
82 enum sn9c102_frame_state state;
83 struct list_head frame;
84 unsigned long vma_use_count;
87 enum sn9c102_dev_state {
88 DEV_INITIALIZED = 0x01,
89 DEV_DISCONNECTED = 0x02,
90 DEV_MISCONFIGURED = 0x04,
93 enum sn9c102_io_method {
94 IO_NONE,
95 IO_READ,
96 IO_MMAP,
99 enum sn9c102_stream_state {
100 STREAM_OFF,
101 STREAM_INTERRUPT,
102 STREAM_ON,
105 typedef char sn9c102_sof_header_t[12];
106 typedef char sn9c102_eof_header_t[4];
108 struct sn9c102_sysfs_attr {
109 u8 reg, i2c_reg;
110 sn9c102_sof_header_t frame_header;
113 struct sn9c102_module_param {
114 u8 force_munmap;
117 static DECLARE_MUTEX(sn9c102_sysfs_lock);
118 static DECLARE_RWSEM(sn9c102_disconnect);
120 struct sn9c102_device {
121 struct device dev;
123 struct video_device* v4ldev;
125 enum sn9c102_bridge bridge;
126 struct sn9c102_sensor* sensor;
128 struct usb_device* usbdev;
129 struct urb* urb[SN9C102_URBS];
130 void* transfer_buffer[SN9C102_URBS];
131 u8* control_buffer;
133 struct sn9c102_frame_t *frame_current, frame[SN9C102_MAX_FRAMES];
134 struct list_head inqueue, outqueue;
135 u32 frame_count, nbuffers, nreadbuffers;
137 enum sn9c102_io_method io;
138 enum sn9c102_stream_state stream;
140 struct v4l2_jpegcompression compression;
142 struct sn9c102_sysfs_attr sysfs;
143 sn9c102_sof_header_t sof_header;
144 u16 reg[32];
146 struct sn9c102_module_param module_param;
148 enum sn9c102_dev_state state;
149 u8 users;
151 struct semaphore dev_sem, fileop_sem;
152 spinlock_t queue_lock;
153 wait_queue_head_t open, wait_frame, wait_stream;
156 /*****************************************************************************/
158 void
159 sn9c102_attach_sensor(struct sn9c102_device* cam,
160 struct sn9c102_sensor* sensor)
162 cam->sensor = sensor;
163 cam->sensor->dev = &cam->dev;
164 cam->sensor->usbdev = cam->usbdev;
167 /*****************************************************************************/
169 #undef DBG
170 #undef KDBG
171 #ifdef SN9C102_DEBUG
172 # define DBG(level, fmt, args...) \
174 if (debug >= (level)) { \
175 if ((level) == 1) \
176 dev_err(&cam->dev, fmt "\n", ## args); \
177 else if ((level) == 2) \
178 dev_info(&cam->dev, fmt "\n", ## args); \
179 else if ((level) >= 3) \
180 dev_info(&cam->dev, "[%s:%d] " fmt "\n", \
181 __FUNCTION__, __LINE__ , ## args); \
184 # define KDBG(level, fmt, args...) \
186 if (debug >= (level)) { \
187 if ((level) == 1 || (level) == 2) \
188 pr_info("sn9c102: " fmt "\n", ## args); \
189 else if ((level) == 3) \
190 pr_debug("sn9c102: [%s:%d] " fmt "\n", __FUNCTION__, \
191 __LINE__ , ## args); \
194 #else
195 # define KDBG(level, fmt, args...) do {;} while(0);
196 # define DBG(level, fmt, args...) do {;} while(0);
197 #endif
199 #undef PDBG
200 #define PDBG(fmt, args...) \
201 dev_info(&cam->dev, "[%s:%d] " fmt "\n", __FUNCTION__, __LINE__ , ## args);
203 #undef PDBGG
204 #define PDBGG(fmt, args...) do {;} while(0); /* placeholder */
206 #endif /* _SN9C102_H_ */