aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/media/et61x251.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/media/et61x251.h')
-rw-r--r--drivers/usb/media/et61x251.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/usb/media/et61x251.h b/drivers/usb/media/et61x251.h
index 652238f329f3..eee8afc9be72 100644
--- a/drivers/usb/media/et61x251.h
+++ b/drivers/usb/media/et61x251.h
@@ -33,7 +33,9 @@
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/param.h> 34#include <linux/param.h>
35#include <linux/rwsem.h> 35#include <linux/rwsem.h>
36#include <asm/semaphore.h> 36#include <linux/mutex.h>
37#include <linux/stddef.h>
38#include <linux/string.h>
37 39
38#include "et61x251_sensor.h" 40#include "et61x251_sensor.h"
39 41
@@ -51,6 +53,7 @@
51#define ET61X251_ALTERNATE_SETTING 13 53#define ET61X251_ALTERNATE_SETTING 13
52#define ET61X251_URB_TIMEOUT msecs_to_jiffies(2 * ET61X251_ISO_PACKETS) 54#define ET61X251_URB_TIMEOUT msecs_to_jiffies(2 * ET61X251_ISO_PACKETS)
53#define ET61X251_CTRL_TIMEOUT 100 55#define ET61X251_CTRL_TIMEOUT 100
56#define ET61X251_FRAME_TIMEOUT 2
54 57
55/*****************************************************************************/ 58/*****************************************************************************/
56 59
@@ -127,15 +130,16 @@ struct et61x251_sysfs_attr {
127 130
128struct et61x251_module_param { 131struct et61x251_module_param {
129 u8 force_munmap; 132 u8 force_munmap;
133 u16 frame_timeout;
130}; 134};
131 135
132static DECLARE_MUTEX(et61x251_sysfs_lock); 136static DEFINE_MUTEX(et61x251_sysfs_lock);
133static DECLARE_RWSEM(et61x251_disconnect); 137static DECLARE_RWSEM(et61x251_disconnect);
134 138
135struct et61x251_device { 139struct et61x251_device {
136 struct video_device* v4ldev; 140 struct video_device* v4ldev;
137 141
138 struct et61x251_sensor* sensor; 142 struct et61x251_sensor sensor;
139 143
140 struct usb_device* usbdev; 144 struct usb_device* usbdev;
141 struct urb* urb[ET61X251_URBS]; 145 struct urb* urb[ET61X251_URBS];
@@ -157,19 +161,28 @@ struct et61x251_device {
157 enum et61x251_dev_state state; 161 enum et61x251_dev_state state;
158 u8 users; 162 u8 users;
159 163
160 struct semaphore dev_sem, fileop_sem; 164 struct mutex dev_mutex, fileop_mutex;
161 spinlock_t queue_lock; 165 spinlock_t queue_lock;
162 wait_queue_head_t open, wait_frame, wait_stream; 166 wait_queue_head_t open, wait_frame, wait_stream;
163}; 167};
164 168
165/*****************************************************************************/ 169/*****************************************************************************/
166 170
171struct et61x251_device*
172et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id)
173{
174 if (usb_match_id(usb_ifnum_to_if(cam->usbdev, 0), id))
175 return cam;
176
177 return NULL;
178}
179
180
167void 181void
168et61x251_attach_sensor(struct et61x251_device* cam, 182et61x251_attach_sensor(struct et61x251_device* cam,
169 struct et61x251_sensor* sensor) 183 struct et61x251_sensor* sensor)
170{ 184{
171 cam->sensor = sensor; 185 memcpy(&cam->sensor, sensor, sizeof(struct et61x251_sensor));
172 cam->sensor->usbdev = cam->usbdev;
173} 186}
174 187
175/*****************************************************************************/ 188/*****************************************************************************/
@@ -212,7 +225,8 @@ do { \
212 225
213#undef PDBG 226#undef PDBG
214#define PDBG(fmt, args...) \ 227#define PDBG(fmt, args...) \
215dev_info(&cam->dev, "[%s:%d] " fmt "\n", __FUNCTION__, __LINE__ , ## args) 228dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
229 __FUNCTION__, __LINE__ , ## args)
216 230
217#undef PDBGG 231#undef PDBGG
218#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ 232#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */