50 #define STK_IIC_BASE (0x0200)
51 # define STK_IIC_OP (STK_IIC_BASE)
52 # define STK_IIC_OP_TX (0x05)
53 # define STK_IIC_OP_RX (0x70)
54 # define STK_IIC_STAT (STK_IIC_BASE+1)
55 # define STK_IIC_STAT_TX_OK (0x04)
56 # define STK_IIC_STAT_RX_OK (0x01)
60 # define STK_IIC_ENABLE (STK_IIC_BASE+2)
61 # define STK_IIC_ENABLE_NO (0x00)
63 # define STK_IIC_ENABLE_YES (0x1e)
69 # define STK_IIC_ADDR (STK_IIC_BASE+3)
70 # define STK_IIC_TX_INDEX (STK_IIC_BASE+4)
71 # define STK_IIC_TX_VALUE (STK_IIC_BASE+5)
72 # define STK_IIC_RX_INDEX (STK_IIC_BASE+8)
73 # define STK_IIC_RX_VALUE (STK_IIC_BASE+9)
75 #define MAX_RETRIES (50)
77 #define SENSOR_ADDRESS (0x60)
87 #define COM1_CCIR656 0x40
88 #define COM1_QFMT 0x20
89 #define COM1_SKIP_0 0x00
90 #define COM1_SKIP_2 0x04
91 #define COM1_SKIP_3 0x08
93 #define REG_GbAVE 0x06
94 #define REG_AECHH 0x07
97 #define COM2_SSLEEP 0x10
100 #define REG_COM3 0x0c
101 #define COM3_SWAP 0x40
102 #define COM3_SCALEEN 0x08
103 #define COM3_DCWEN 0x04
104 #define REG_COM4 0x0d
105 #define REG_COM5 0x0e
106 #define REG_COM6 0x0f
107 #define REG_AECH 0x10
108 #define REG_CLKRC 0x11
111 #define CLK_SCALE 0x3f
112 #define REG_COM7 0x12
113 #define COM7_RESET 0x80
114 #define COM7_FMT_MASK 0x38
115 #define COM7_FMT_SXGA 0x00
116 #define COM7_FMT_VGA 0x40
117 #define COM7_FMT_CIF 0x20
118 #define COM7_FMT_QVGA 0x10
119 #define COM7_FMT_QCIF 0x08
120 #define COM7_RGB 0x04
121 #define COM7_YUV 0x00
122 #define COM7_BAYER 0x01
123 #define COM7_PBAYER 0x05
124 #define REG_COM8 0x13
125 #define COM8_FASTAEC 0x80
126 #define COM8_AECSTEP 0x40
127 #define COM8_BFILT 0x20
128 #define COM8_AGC 0x04
129 #define COM8_AWB 0x02
130 #define COM8_AEC 0x01
131 #define REG_COM9 0x14
132 #define REG_COM10 0x15
133 #define COM10_HSYNC 0x40
134 #define COM10_PCLK_HB 0x20
135 #define COM10_HREF_REV 0x08
136 #define COM10_VS_LEAD 0x04
137 #define COM10_VS_NEG 0x02
138 #define COM10_HS_NEG 0x01
139 #define REG_HSTART 0x17
140 #define REG_HSTOP 0x18
141 #define REG_VSTART 0x19
142 #define REG_VSTOP 0x1a
143 #define REG_PSHFT 0x1b
144 #define REG_MIDH 0x1c
145 #define REG_MIDL 0x1d
146 #define REG_MVFP 0x1e
147 #define MVFP_MIRROR 0x20
148 #define MVFP_FLIP 0x10
153 #define REG_ADVFL 0x2d
154 #define REG_ADVFH 0x2e
155 #define REG_HSYST 0x30
156 #define REG_HSYEN 0x31
157 #define REG_HREF 0x32
158 #define REG_TSLB 0x3a
159 #define TSLB_YLAST 0x04
160 #define TSLB_BYTEORD 0x08
161 #define REG_COM11 0x3b
162 #define COM11_NIGHT 0x80
163 #define COM11_NMFR 0x60
164 #define COM11_HZAUTO 0x10
165 #define COM11_50HZ 0x08
166 #define COM11_EXP 0x02
167 #define REG_COM12 0x3c
168 #define COM12_HREF 0x80
169 #define REG_COM13 0x3d
170 #define COM13_GAMMA 0x80
171 #define COM13_UVSAT 0x40
172 #define COM13_CMATRIX 0x10
173 #define COM13_UVSWAP 0x01
174 #define REG_COM14 0x3e
175 #define COM14_DCWEN 0x10
176 #define REG_EDGE 0x3f
177 #define REG_COM15 0x40
178 #define COM15_R10F0 0x00
179 #define COM15_R01FE 0x80
180 #define COM15_R00FF 0xc0
181 #define COM15_RGB565 0x10
182 #define COM15_RGBFIXME 0x20
183 #define COM15_RGB555 0x30
184 #define REG_COM16 0x41
185 #define COM16_AWBGAIN 0x08
186 #define REG_COM17 0x42
187 #define COM17_AECWIN 0xc0
188 #define COM17_CBAR 0x08
199 #define REG_CMATRIX_BASE 0x4f
200 #define CMATRIX_LEN 6
201 #define REG_CMATRIX_SIGN 0x58
204 #define REG_BRIGHT 0x55
205 #define REG_CONTRAS 0x56
207 #define REG_GFIX 0x69
209 #define REG_RGB444 0x8c
210 #define R444_ENABLE 0x02
211 #define R444_RGBX 0x01
213 #define REG_HAECC1 0x9f
214 #define REG_HAECC2 0xa0
216 #define REG_BD50MAX 0xa5
217 #define REG_HAECC3 0xa6
218 #define REG_HAECC4 0xa7
219 #define REG_HAECC5 0xa8
220 #define REG_HAECC6 0xa9
221 #define REG_HAECC7 0xaa
222 #define REG_BD60MAX 0xab
246 STK_ERROR(
"stk_sensor_outb failed, status=0x%02x\n",
269 STK_ERROR(
"stk_sensor_inb failed, status=0x%02x\n",
281 static int stk_sensor_write_regvals(
struct stk_camera *dev,
287 while (rv->
reg != 0xff || rv->
val != 0xff) {
288 ret = stk_sensor_outb(dev, rv->
reg, rv->
val);
299 return stk_sensor_inb(dev,
REG_COM2, &tmp)
306 return stk_sensor_inb(dev,
REG_COM2, &tmp)
310 static struct regval ov_initvals[] = {
321 {0x39, 0x50}, {0x38, 0x93},
322 {0x37, 0x00}, {0x35, 0x81},
329 {0x33, 0xe2}, {0x34, 0xbf},
345 {0x8f, 0xdf}, {0x8b, 0x06},
347 {0x94, 0x88}, {0x95, 0x88},
354 {0x90, 0x00}, {0x91, 0x00},
359 {0x2a, 0x00}, {0x2b, 0x00},
378 if (stk_sensor_inb(dev,
REG_MIDH, &idh)
379 || stk_sensor_inb(dev,
REG_MIDL, &idl)) {
380 STK_ERROR(
"Strange error reading sensor ID\n");
383 if (idh != 0x7f || idl != 0xa2) {
384 STK_ERROR(
"Huh? you don't have a sensor from ovt\n");
387 if (stk_sensor_inb(dev,
REG_PID, &idh)
388 || stk_sensor_inb(dev,
REG_VER, &idl)) {
389 STK_ERROR(
"Could not read sensor model\n");
392 stk_sensor_write_regvals(dev, ov_initvals);
394 STK_INFO(
"OmniVision sensor detected, id %02X%02X"
400 static struct regval ov_fmt_uyvy[] = {
413 static struct regval ov_fmt_yuyv[] = {
427 static struct regval ov_fmt_rgbr[] = {
444 static struct regval ov_fmt_rgbp[] = {
461 static struct regval ov_fmt_bayer[] = {
471 static int stk_sensor_set_hw(
struct stk_camera *dev,
472 int hstart,
int hstop,
int vstart,
int vstop)
481 ret = stk_sensor_outb(dev,
REG_HSTART, (hstart >> 3) & 0xff);
482 ret += stk_sensor_outb(dev,
REG_HSTOP, (hstop >> 3) & 0xff);
483 ret += stk_sensor_inb(dev,
REG_HREF, &v);
484 v = (v & 0xc0) | ((hstop & 0x7) << 3) | (hstart & 0x7);
486 ret += stk_sensor_outb(dev,
REG_HREF, v);
490 ret += stk_sensor_outb(dev,
REG_VSTART, (vstart >> 3) & 0xff);
491 ret += stk_sensor_outb(dev,
REG_VSTOP, (vstop >> 3) & 0xff);
492 ret += stk_sensor_inb(dev,
REG_VREF, &v);
493 v = (v & 0xc0) | ((vstop & 0x7) << 3) | (vstart & 0x7);
495 ret += stk_sensor_outb(dev,
REG_VREF, v);
551 default:
STK_ERROR(
"Unsupported colorspace\n");
556 stk_sensor_outb(dev,
REG_COM7, com7);
558 stk_sensor_write_regvals(dev, rv);
561 stk_sensor_outb(dev,
REG_MVFP, flip);
564 stk_sensor_outb(dev,
REG_TSLB, 0x08);
565 stk_sensor_outb(dev,
REG_ADVFH, dummylines >> 8);
566 stk_sensor_outb(dev,
REG_ADVFL, dummylines & 0xff);
570 if (stk_sensor_set_hw(dev, 302, 1582, 6, 486))
571 STK_ERROR(
"stk_sensor_set_hw failed (VGA)\n");
589 if (br < 0 || br > 0xff)
591 stk_sensor_outb(dev,
REG_AEB,
max(0x00, br - 6));
592 stk_sensor_outb(dev,
REG_AEW,
min(0xff, br + 6));