aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/media/sn9c102.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/media/sn9c102.h')
-rw-r--r--drivers/usb/media/sn9c102.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/usb/media/sn9c102.h b/drivers/usb/media/sn9c102.h
index 17d60c1eea7e..1d70a62b9f23 100644
--- a/drivers/usb/media/sn9c102.h
+++ b/drivers/usb/media/sn9c102.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/string.h>
38#include <linux/stddef.h>
37 39
38#include "sn9c102_sensor.h" 40#include "sn9c102_sensor.h"
39 41
@@ -50,6 +52,7 @@
50#define SN9C102_ALTERNATE_SETTING 8 52#define SN9C102_ALTERNATE_SETTING 8
51#define SN9C102_URB_TIMEOUT msecs_to_jiffies(2 * SN9C102_ISO_PACKETS) 53#define SN9C102_URB_TIMEOUT msecs_to_jiffies(2 * SN9C102_ISO_PACKETS)
52#define SN9C102_CTRL_TIMEOUT 300 54#define SN9C102_CTRL_TIMEOUT 300
55#define SN9C102_FRAME_TIMEOUT 2
53 56
54/*****************************************************************************/ 57/*****************************************************************************/
55 58
@@ -107,16 +110,17 @@ struct sn9c102_sysfs_attr {
107 110
108struct sn9c102_module_param { 111struct sn9c102_module_param {
109 u8 force_munmap; 112 u8 force_munmap;
113 u16 frame_timeout;
110}; 114};
111 115
112static DECLARE_MUTEX(sn9c102_sysfs_lock); 116static DEFINE_MUTEX(sn9c102_sysfs_lock);
113static DECLARE_RWSEM(sn9c102_disconnect); 117static DECLARE_RWSEM(sn9c102_disconnect);
114 118
115struct sn9c102_device { 119struct sn9c102_device {
116 struct video_device* v4ldev; 120 struct video_device* v4ldev;
117 121
118 enum sn9c102_bridge bridge; 122 enum sn9c102_bridge bridge;
119 struct sn9c102_sensor* sensor; 123 struct sn9c102_sensor sensor;
120 124
121 struct usb_device* usbdev; 125 struct usb_device* usbdev;
122 struct urb* urb[SN9C102_URBS]; 126 struct urb* urb[SN9C102_URBS];
@@ -141,19 +145,28 @@ struct sn9c102_device {
141 enum sn9c102_dev_state state; 145 enum sn9c102_dev_state state;
142 u8 users; 146 u8 users;
143 147
144 struct semaphore dev_sem, fileop_sem; 148 struct mutex dev_mutex, fileop_mutex;
145 spinlock_t queue_lock; 149 spinlock_t queue_lock;
146 wait_queue_head_t open, wait_frame, wait_stream; 150 wait_queue_head_t open, wait_frame, wait_stream;
147}; 151};
148 152
149/*****************************************************************************/ 153/*****************************************************************************/
150 154
155struct sn9c102_device*
156sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id)
157{
158 if (usb_match_id(usb_ifnum_to_if(cam->usbdev, 0), id))
159 return cam;
160
161 return NULL;
162}
163
164
151void 165void
152sn9c102_attach_sensor(struct sn9c102_device* cam, 166sn9c102_attach_sensor(struct sn9c102_device* cam,
153 struct sn9c102_sensor* sensor) 167 struct sn9c102_sensor* sensor)
154{ 168{
155 cam->sensor = sensor; 169 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor));
156 cam->sensor->usbdev = cam->usbdev;
157} 170}
158 171
159/*****************************************************************************/ 172/*****************************************************************************/
@@ -196,7 +209,8 @@ do { \
196 209
197#undef PDBG 210#undef PDBG
198#define PDBG(fmt, args...) \ 211#define PDBG(fmt, args...) \
199dev_info(&cam->dev, "[%s:%d] " fmt "\n", __FUNCTION__, __LINE__ , ## args) 212dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
213 __FUNCTION__, __LINE__ , ## args)
200 214
201#undef PDBGG 215#undef PDBGG
202#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ 216#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */