~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/staging/se401/se401.h

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
#ifndef __LINUX_se401_H
3
 
#define __LINUX_se401_H
4
 
 
5
 
#include <linux/uaccess.h>
6
 
#include "videodev.h"
7
 
#include <media/v4l2-common.h>
8
 
#include <media/v4l2-ioctl.h>
9
 
#include <linux/mutex.h>
10
 
 
11
 
#define se401_DEBUG     /* Turn on debug messages */
12
 
 
13
 
#ifdef se401_DEBUG
14
 
#  define PDEBUG(level, fmt, args...) \
15
 
if (debug >= level) \
16
 
        info("[" __PRETTY_FUNCTION__ ":%d] " fmt, __LINE__ , ## args)
17
 
#else
18
 
#  define PDEBUG(level, fmt, args...) do {} while (0)
19
 
#endif
20
 
 
21
 
/* An almost drop-in replacement for sleep_on_interruptible */
22
 
#define wait_interruptible(test, queue, wait) \
23
 
{ \
24
 
        add_wait_queue(queue, wait); \
25
 
        set_current_state(TASK_INTERRUPTIBLE); \
26
 
        if (test) \
27
 
                schedule(); \
28
 
        remove_wait_queue(queue, wait); \
29
 
        set_current_state(TASK_RUNNING); \
30
 
        if (signal_pending(current)) \
31
 
                break; \
32
 
}
33
 
 
34
 
#define SE401_REQ_GET_CAMERA_DESCRIPTOR         0x06
35
 
#define SE401_REQ_START_CONTINUOUS_CAPTURE      0x41
36
 
#define SE401_REQ_STOP_CONTINUOUS_CAPTURE       0x42
37
 
#define SE401_REQ_CAPTURE_FRAME                 0x43
38
 
#define SE401_REQ_GET_BRT                       0x44
39
 
#define SE401_REQ_SET_BRT                       0x45
40
 
#define SE401_REQ_GET_WIDTH                     0x4c
41
 
#define SE401_REQ_SET_WIDTH                     0x4d
42
 
#define SE401_REQ_GET_HEIGHT                    0x4e
43
 
#define SE401_REQ_SET_HEIGHT                    0x4f
44
 
#define SE401_REQ_GET_OUTPUT_MODE               0x50
45
 
#define SE401_REQ_SET_OUTPUT_MODE               0x51
46
 
#define SE401_REQ_GET_EXT_FEATURE               0x52
47
 
#define SE401_REQ_SET_EXT_FEATURE               0x53
48
 
#define SE401_REQ_CAMERA_POWER                  0x56
49
 
#define SE401_REQ_LED_CONTROL                   0x57
50
 
#define SE401_REQ_BIOS                          0xff
51
 
 
52
 
#define SE401_BIOS_READ                         0x07
53
 
 
54
 
#define SE401_FORMAT_BAYER      0x40
55
 
 
56
 
/* Hyundai hv7131b registers
57
 
   7121 and 7141 should be the same (haven't really checked...) */
58
 
/* Mode registers: */
59
 
#define HV7131_REG_MODE_A               0x00
60
 
#define HV7131_REG_MODE_B               0x01
61
 
#define HV7131_REG_MODE_C               0x02
62
 
/* Frame registers: */
63
 
#define HV7131_REG_FRSU         0x10
64
 
#define HV7131_REG_FRSL         0x11
65
 
#define HV7131_REG_FCSU         0x12
66
 
#define HV7131_REG_FCSL         0x13
67
 
#define HV7131_REG_FWHU         0x14
68
 
#define HV7131_REG_FWHL         0x15
69
 
#define HV7131_REG_FWWU         0x16
70
 
#define HV7131_REG_FWWL         0x17
71
 
/* Timing registers: */
72
 
#define HV7131_REG_THBU         0x20
73
 
#define HV7131_REG_THBL         0x21
74
 
#define HV7131_REG_TVBU         0x22
75
 
#define HV7131_REG_TVBL         0x23
76
 
#define HV7131_REG_TITU         0x25
77
 
#define HV7131_REG_TITM         0x26
78
 
#define HV7131_REG_TITL         0x27
79
 
#define HV7131_REG_TMCD         0x28
80
 
/* Adjust Registers: */
81
 
#define HV7131_REG_ARLV         0x30
82
 
#define HV7131_REG_ARCG         0x31
83
 
#define HV7131_REG_AGCG         0x32
84
 
#define HV7131_REG_ABCG         0x33
85
 
#define HV7131_REG_APBV         0x34
86
 
#define HV7131_REG_ASLP         0x54
87
 
/* Offset Registers: */
88
 
#define HV7131_REG_OFSR         0x50
89
 
#define HV7131_REG_OFSG         0x51
90
 
#define HV7131_REG_OFSB         0x52
91
 
/* REset level statistics registers: */
92
 
#define HV7131_REG_LOREFNOH     0x57
93
 
#define HV7131_REG_LOREFNOL     0x58
94
 
#define HV7131_REG_HIREFNOH     0x59
95
 
#define HV7131_REG_HIREFNOL     0x5a
96
 
 
97
 
/* se401 registers */
98
 
#define SE401_OPERATINGMODE     0x2000
99
 
 
100
 
 
101
 
/* size of usb transfers */
102
 
#define SE401_PACKETSIZE        4096
103
 
/* number of queued bulk transfers to use, should be about 8 */
104
 
#define SE401_NUMSBUF           1
105
 
/* read the usb specs for this one :) */
106
 
#define SE401_VIDEO_ENDPOINT    1
107
 
#define SE401_BUTTON_ENDPOINT   2
108
 
/* number of frames supported by the v4l part */
109
 
#define SE401_NUMFRAMES         2
110
 
/* scratch buffers for passing data to the decoders */
111
 
#define SE401_NUMSCRATCH        32
112
 
/* maximum amount of data in a JangGu packet */
113
 
#define SE401_VLCDATALEN        1024
114
 
/* number of nul sized packets to receive before kicking the camera */
115
 
#define SE401_MAX_NULLPACKETS   4000
116
 
/* number of decoding errors before kicking the camera */
117
 
#define SE401_MAX_ERRORS        200
118
 
 
119
 
struct usb_device;
120
 
 
121
 
struct se401_sbuf {
122
 
        unsigned char *data;
123
 
};
124
 
 
125
 
enum {
126
 
        FRAME_UNUSED,           /* Unused (no MCAPTURE) */
127
 
        FRAME_READY,            /* Ready to start grabbing */
128
 
        FRAME_GRABBING,         /* In the process of being grabbed into */
129
 
        FRAME_DONE,             /* Finished grabbing, but not been synced yet */
130
 
        FRAME_ERROR,            /* Something bad happened while processing */
131
 
};
132
 
 
133
 
enum {
134
 
        FMT_BAYER,
135
 
        FMT_JANGGU,
136
 
};
137
 
 
138
 
enum {
139
 
        BUFFER_UNUSED,
140
 
        BUFFER_READY,
141
 
        BUFFER_BUSY,
142
 
        BUFFER_DONE,
143
 
};
144
 
 
145
 
struct se401_scratch {
146
 
        unsigned char *data;
147
 
        volatile int state;
148
 
        int offset;
149
 
        int length;
150
 
};
151
 
 
152
 
struct se401_frame {
153
 
        unsigned char *data;            /* Frame buffer */
154
 
 
155
 
        volatile int grabstate; /* State of grabbing */
156
 
 
157
 
        unsigned char *curline;
158
 
        int curlinepix;
159
 
        int curpix;
160
 
};
161
 
 
162
 
struct usb_se401 {
163
 
        struct video_device vdev;
164
 
 
165
 
        /* Device structure */
166
 
        struct usb_device *dev;
167
 
 
168
 
        unsigned char iface;
169
 
 
170
 
        char *camera_name;
171
 
 
172
 
        int change;
173
 
        int brightness;
174
 
        int hue;
175
 
        int rgain;
176
 
        int ggain;
177
 
        int bgain;
178
 
        int expose_h;
179
 
        int expose_m;
180
 
        int expose_l;
181
 
        int resetlevel;
182
 
 
183
 
        int enhance;
184
 
 
185
 
        int format;
186
 
        int sizes;
187
 
        int *width;
188
 
        int *height;
189
 
        int cwidth;             /* current width */
190
 
        int cheight;            /* current height */
191
 
        int palette;
192
 
        int maxframesize;
193
 
        int cframesize;         /* current framesize */
194
 
 
195
 
        struct mutex lock;
196
 
        int user;               /* user count for exclusive use */
197
 
        int removed;            /* device disconnected */
198
 
 
199
 
        int streaming;          /* Are we streaming video? */
200
 
 
201
 
        char *fbuf;             /* Videodev buffer area */
202
 
 
203
 
        struct urb *urb[SE401_NUMSBUF];
204
 
        struct urb *inturb;
205
 
 
206
 
        int button;
207
 
        int buttonpressed;
208
 
 
209
 
        int curframe;           /* Current receiving frame */
210
 
        struct se401_frame frame[SE401_NUMFRAMES];
211
 
        int readcount;
212
 
        int framecount;
213
 
        int error;
214
 
        int dropped;
215
 
 
216
 
        int scratch_next;
217
 
        int scratch_use;
218
 
        int scratch_overflow;
219
 
        struct se401_scratch scratch[SE401_NUMSCRATCH];
220
 
 
221
 
        /* Decoder specific data: */
222
 
        unsigned char vlcdata[SE401_VLCDATALEN];
223
 
        int vlcdatapos;
224
 
        int bayeroffset;
225
 
 
226
 
        struct se401_sbuf sbuf[SE401_NUMSBUF];
227
 
 
228
 
        wait_queue_head_t wq;   /* Processes waiting */
229
 
 
230
 
        int nullpackets;
231
 
};
232
 
 
233
 
 
234
 
 
235
 
#endif
236