Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sn9c102.h
Go to the documentation of this file.
1 /***************************************************************************
2  * V4L2 driver for SN9C1xx PC Camera Controllers *
3  * *
4  * Copyright (C) 2004-2006 by Luca Risolia <[email protected]> *
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  ***************************************************************************/
20 
21 #ifndef _SN9C102_H_
22 #define _SN9C102_H_
23 
24 #include <linux/usb.h>
25 #include <linux/videodev2.h>
26 #include <media/v4l2-common.h>
27 #include <media/v4l2-ioctl.h>
28 #include <linux/device.h>
29 #include <linux/list.h>
30 #include <linux/spinlock.h>
31 #include <linux/time.h>
32 #include <linux/wait.h>
33 #include <linux/types.h>
34 #include <linux/param.h>
35 #include <linux/rwsem.h>
36 #include <linux/mutex.h>
37 #include <linux/string.h>
38 #include <linux/stddef.h>
39 #include <linux/kref.h>
40 
41 #include "sn9c102_config.h"
42 #include "sn9c102_sensor.h"
43 #include "sn9c102_devtable.h"
44 
45 
52 };
53 
55  void* bufmem;
56  struct v4l2_buffer buf;
58  struct list_head frame;
59  unsigned long vma_use_count;
60 };
61 
66 };
67 
72 };
73 
78 };
79 
80 typedef char sn9c102_sof_header_t[62];
81 
82 struct sn9c102_sof_t {
85 };
86 
90 };
91 
95 };
96 
97 static DEFINE_MUTEX(sn9c102_sysfs_lock);
98 static DECLARE_RWSEM(sn9c102_dev_lock);
99 
102 
105 
106  struct usb_device* usbdev;
107  struct urb* urb[SN9C102_URBS];
110 
112  struct list_head inqueue, outqueue;
114 
117 
119 
122  u16 reg[384];
123 
125 
126  struct kref kref;
129 
131  struct mutex open_mutex, fileop_mutex;
134 };
135 
136 /*****************************************************************************/
137 
138 struct sn9c102_device*
140 {
141  return usb_match_id(usb_ifnum_to_if(cam->usbdev, 0), id) ? cam : NULL;
142 }
143 
144 
145 void
147  const struct sn9c102_sensor* sensor)
148 {
149  memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor));
150 }
151 
152 
153 enum sn9c102_bridge
155 {
156  return cam->bridge;
157 }
158 
159 
161 {
162  return &cam->sensor;
163 }
164 
165 /*****************************************************************************/
166 
167 #undef DBG
168 #undef KDBG
169 #ifdef SN9C102_DEBUG
170 # define DBG(level, fmt, args...) \
171 do { \
172  if (debug >= (level)) { \
173  if ((level) == 1) \
174  dev_err(&cam->usbdev->dev, fmt "\n", ## args); \
175  else if ((level) == 2) \
176  dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
177  else if ((level) >= 3) \
178  dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
179  __func__, __LINE__ , ## args); \
180  } \
181 } while (0)
182 # define V4LDBG(level, name, cmd) \
183 do { \
184  if (debug >= (level)) \
185  v4l_printk_ioctl(name, cmd); \
186 } while (0)
187 # define KDBG(level, fmt, args...) \
188 do { \
189  if (debug >= (level)) { \
190  if ((level) == 1 || (level) == 2) \
191  pr_info("sn9c102: " fmt "\n", ## args); \
192  else if ((level) == 3) \
193  pr_debug("sn9c102: [%s:%d] " fmt "\n", \
194  __func__, __LINE__ , ## args); \
195  } \
196 } while (0)
197 #else
198 # define DBG(level, fmt, args...) do {;} while(0)
199 # define V4LDBG(level, name, cmd) do {;} while(0)
200 # define KDBG(level, fmt, args...) do {;} while(0)
201 #endif
202 
203 #undef PDBG
204 #define PDBG(fmt, args...) \
205 dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", __FILE__, __func__, \
206  __LINE__ , ## args)
207 
208 #undef PDBGG
209 #define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
210 
211 #endif /* _SN9C102_H_ */