2
* SPCA505 chip based cameras initialization data
8
#define SPCA50X_USB_CTRL 0x0 // spca505
9
#define SPCA50X_CUSB_ENABLE 0x1 // spca505
10
#define SPCA50X_REG_GLOBAL 0x3 // spca505
11
#define SPCA50X_GMISC0_IDSEL 0x1 // Global control device ID select spca505
12
#define SPCA50X_GLOBAL_MISC0 0x0 // Global control miscellaneous 0 spca505
14
#define SPCA50X_GLOBAL_MISC1 0x1 // 505
15
#define SPCA50X_GLOBAL_MISC3 0x3 // 505
16
#define SPCA50X_GMISC3_SAA7113RST 0x20 /* Not sure about this one spca505 */
18
#include "spca505.dat"
19
static int spca505_init(struct usb_spca50x *spca50x);
20
static void spca505_start(struct usb_spca50x *spca50x);
21
static void spca505_stopN(struct usb_spca50x *spca50x);
22
static void spca505_stop0(struct usb_spca50x *spca50x);
23
static __u16 spca505_getbrightness(struct usb_spca50x *spca50x);
24
static __u16 spca505_getcontrast(struct usb_spca50x *spca50x);
25
static __u16 spca505_getcolors(struct usb_spca50x *spca50x);
26
static void spca505_setbrightness(struct usb_spca50x *spca50x);
27
static void spca505_setcontrast(struct usb_spca50x *spca50x);
28
static void spca505_setcolors(struct usb_spca50x *spca50x);
29
static int spca505_config(struct usb_spca50x *spca50x);
30
static void spca505_shutdown(struct usb_spca50x *spca50x);
31
static void spca505_setAutobright(struct usb_spca50x *spca50x);
32
static void spca505_setquality(struct usb_spca50x *spca50x);
33
static int spca505_sofdetect(struct usb_spca50x *spca50x,struct spca50x_frame *frame, unsigned char *cdata,int *iPix, int seqnum, int *datalength);
34
/***************************************************************/
35
static void spca505_stop0(struct usb_spca50x *spca50x){}
36
static void spca505_setAutobright(struct usb_spca50x *spca50x){}
37
static void spca505_setquality(struct usb_spca50x *spca50x){}
38
/**************************************************************/
39
static struct cam_operation fspca505 = {
40
.initialize = spca505_init,
41
.configure = spca505_config,
42
.start = spca505_start,
43
.stopN = spca505_stopN,
44
.stop0 = spca505_stop0,
45
.get_bright = spca505_getbrightness,
46
.set_bright = spca505_setbrightness,
47
.get_contrast = spca505_getcontrast,
48
.set_contrast = spca505_setcontrast,
49
.get_colors = spca505_getcolors,
50
.set_colors = spca505_setcolors,
51
.set_autobright = spca505_setAutobright,
52
.set_quality = spca505_setquality,
53
.cam_shutdown = spca505_shutdown,
54
.sof_detect = spca505_sofdetect,
56
static int spca505_init(struct usb_spca50x *spca50x)
59
PDEBUG(2, "Initializing SPCA505");
60
if (spca50x->desc == Nxultra) {
62
spca50x_write_vector(spca50x, spca505b_open_data_ccd);
66
spca50x_write_vector(spca50x, spca505_open_data_ccd);
70
err_code = spca50x_reg_read(spca50x->dev, 6, (__u16) 0x16, 2);
74
"register read failed for after vector read err = %d",
79
"After vector read returns : 0x%x should be 0x0101",
84
spca50x_reg_write(spca50x->dev, 6, (__u16) 0x16, (__u16) 0xa);
86
PDEBUG(1, "register write failed for (6,0xa,0x16) err=%d",
91
spca50x_reg_write(spca50x->dev, 5, 0xc2, 18);
95
static void spca505_start(struct usb_spca50x *spca50x)
97
struct usb_device *dev = spca50x->dev;
99
//nessesary because without it we can see stream only once after loading module
100
//stopping usb registers Tomasz change
101
spca50x_reg_write(dev, 0x2, 0x0, 0x0);
102
switch(spca50x->mode){
104
spca50x_reg_write(dev, 0x04, 0x0,
106
spca50x_reg_write(dev, 0x04, 0x06,
108
spca50x_reg_write(dev, 0x04, 0x07,
112
spca50x_reg_write(dev, 0x04, 0x0,
114
spca50x_reg_write(dev, 0x04, 0x06,
116
spca50x_reg_write(dev, 0x04, 0x07,
120
spca50x_reg_write(dev, 0x04, 0x0,
122
spca50x_reg_write(dev, 0x04, 0x06,
124
spca50x_reg_write(dev, 0x04, 0x07,
128
spca50x_reg_write(dev, 0x04, 0x0,
130
spca50x_reg_write(dev, 0x04, 0x06,
132
spca50x_reg_write(dev, 0x04, 0x07,
136
spca50x_reg_write(dev, 0x04, 0x0,
138
spca50x_reg_write(dev, 0x04, 0x06,
140
spca50x_reg_write(dev, 0x04, 0x07,
144
spca50x_reg_write(dev, 0x04, 0x0,
146
spca50x_reg_write(dev, 0x04, 0x06,
148
spca50x_reg_write(dev, 0x04, 0x07,
152
/* Enable ISO packet machine - should we do this here or in ISOC init ? */
153
err_code = spca50x_reg_write(dev, SPCA50X_REG_USB,
155
SPCA50X_CUSB_ENABLE);
157
// spca50x_reg_write(dev, 0x5, 0x0, 0x0);
158
// spca50x_reg_write(dev, 0x5, 0x0, 0x1);
159
// spca50x_reg_write(dev, 0x5, 0x11, 0x2);
161
static void spca505_stopN(struct usb_spca50x *spca50x)
163
spca50x_reg_write(spca50x->dev, 0x2, 0x0, 0x0); //Disable ISO packet machine
165
static __u16 spca505_getbrightness(struct usb_spca50x *spca50x)
167
spca50x->brightness =
168
65535 - ((spca50x_reg_read(spca50x->dev, 5, 0x01, 1) >> 2) +
169
(spca50x_reg_read(spca50x->dev, 5, 0x0, 1) << 6));
170
return spca50x->brightness;
172
static __u16 spca505_getcontrast(struct usb_spca50x *spca50x)
174
spca50x->contrast = 0;
175
return spca50x->contrast;
177
static __u16 spca505_getcolors(struct usb_spca50x *spca50x)
180
return spca50x->colour;
182
static void spca505_setbrightness(struct usb_spca50x *spca50x)
184
__u8 brightness = spca50x->brightness >> 8;
185
spca50x_reg_write(spca50x->dev, 5, 0x0,
186
(255 - brightness) >> 6);
187
spca50x_reg_write(spca50x->dev, 5, 0x01,
188
(255 - brightness) << 2);
191
static void spca505_setcontrast(struct usb_spca50x *spca50x)
194
static void spca505_setcolors(struct usb_spca50x *spca50x)
197
static int spca505_config(struct usb_spca50x *spca50x)
199
memset(spca50x->mode_cam, 0x00, TOTMODE * sizeof(struct mwebcam));
200
if (spca50x->desc == Nxultra) {
201
spca50x->mode_cam[VGA].width = 640;
202
spca50x->mode_cam[VGA].height = 480;
203
spca50x->mode_cam[VGA].t_palette =
204
P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;
205
spca50x->mode_cam[VGA].pipe = 1023;
206
spca50x->mode_cam[VGA].method = 0;
207
spca50x->mode_cam[VGA].mode = 0;
209
spca50x->mode_cam[PAL].width = 384;
210
spca50x->mode_cam[PAL].height = 288;
211
spca50x->mode_cam[PAL].t_palette =
212
P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;
213
spca50x->mode_cam[PAL].pipe = 1023;
214
spca50x->mode_cam[PAL].method = 1;
215
spca50x->mode_cam[PAL].mode = 0;
217
spca50x->mode_cam[SIF].width = 352;
218
spca50x->mode_cam[SIF].height = 288;
219
spca50x->mode_cam[SIF].t_palette =
220
P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;
221
spca50x->mode_cam[SIF].pipe = 1023;
222
spca50x->mode_cam[SIF].method = 0;
223
spca50x->mode_cam[SIF].mode = 1;
225
spca50x->mode_cam[CIF].width = 320;
226
spca50x->mode_cam[CIF].height = 240;
227
spca50x->mode_cam[CIF].t_palette =
228
P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;
229
spca50x->mode_cam[CIF].pipe = 896;
230
spca50x->mode_cam[CIF].method = 0;
231
spca50x->mode_cam[CIF].mode = 2;
233
spca50x->mode_cam[QPAL].width = 192;
234
spca50x->mode_cam[QPAL].height = 144;
235
spca50x->mode_cam[QPAL].t_palette =
236
P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;
237
spca50x->mode_cam[QPAL].pipe = 896;
238
spca50x->mode_cam[QPAL].method = 1;
239
spca50x->mode_cam[QPAL].mode = 2;
241
spca50x->mode_cam[QSIF].width = 176;
242
spca50x->mode_cam[QSIF].height = 144;
243
spca50x->mode_cam[QSIF].t_palette =
244
P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;
245
spca50x->mode_cam[QSIF].pipe = 512;
246
spca50x->mode_cam[QSIF].method = 0;
247
spca50x->mode_cam[QSIF].mode = 4;
249
spca50x->mode_cam[QCIF].width = 160;
250
spca50x->mode_cam[QCIF].height = 120;
251
spca50x->mode_cam[QCIF].t_palette =
252
P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;
253
spca50x->mode_cam[QCIF].pipe = 384;
254
spca50x->mode_cam[QCIF].method = 0;
255
spca50x->mode_cam[QCIF].mode = 5;
257
if (spca50x->desc == Nxultra) {
258
if (spca50x_write_vector(spca50x, spca505b_init_data))
261
if (spca50x_write_vector(spca50x, spca505_init_data))
266
static void spca505_shutdown(struct usb_spca50x *spca50x)
268
spca50x_reg_write(spca50x->dev, 0x3, 0x3, 0x20); // This maybe reset or power control
269
spca50x_reg_write(spca50x->dev, 0x3, 0x1, 0x0);
270
spca50x_reg_write(spca50x->dev, 0x3, 0x0, 0x1);
271
spca50x_reg_write(spca50x->dev, 0x5, 0x10, 0x1);
272
spca50x_reg_write(spca50x->dev, 0x5, 0x11, 0xF);
274
static int spca505_sofdetect(struct usb_spca50x *spca50x,struct spca50x_frame *frame, unsigned char *cdata,int *iPix, int seqnum, int *datalength)
278
*iPix = SPCA50X_OFFSET_DATA;
279
*datalength -= *iPix;
281
case SPCA50X_SEQUENCE_DROP:
285
*datalength -= *iPix;
289
#endif /* SPCA505_INIT_H */