aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/sn9c102/sn9c102_ov7630.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/sn9c102/sn9c102_ov7630.c')
-rw-r--r--drivers/media/video/sn9c102/sn9c102_ov7630.c121
1 files changed, 50 insertions, 71 deletions
diff --git a/drivers/media/video/sn9c102/sn9c102_ov7630.c b/drivers/media/video/sn9c102/sn9c102_ov7630.c
index 7df09ff38e63..31b6080b0615 100644
--- a/drivers/media/video/sn9c102/sn9c102_ov7630.c
+++ b/drivers/media/video/sn9c102/sn9c102_ov7630.c
@@ -22,9 +22,6 @@
22#include "sn9c102_sensor.h" 22#include "sn9c102_sensor.h"
23 23
24 24
25static struct sn9c102_sensor ov7630;
26
27
28static int ov7630_init(struct sn9c102_device* cam) 25static int ov7630_init(struct sn9c102_device* cam)
29{ 26{
30 int err = 0; 27 int err = 0;
@@ -32,21 +29,20 @@ static int ov7630_init(struct sn9c102_device* cam)
32 switch (sn9c102_get_bridge(cam)) { 29 switch (sn9c102_get_bridge(cam)) {
33 case BRIDGE_SN9C101: 30 case BRIDGE_SN9C101:
34 case BRIDGE_SN9C102: 31 case BRIDGE_SN9C102:
35 err += sn9c102_write_reg(cam, 0x00, 0x14); 32 err = sn9c102_write_const_regs(cam, {0x00, 0x14},
36 err += sn9c102_write_reg(cam, 0x60, 0x17); 33 {0x60, 0x17}, {0x0f, 0x18},
37 err += sn9c102_write_reg(cam, 0x0f, 0x18); 34 {0x50, 0x19});
38 err += sn9c102_write_reg(cam, 0x50, 0x19);
39 35
40 err += sn9c102_i2c_write(cam, 0x12, 0x8d); 36 err += sn9c102_i2c_write(cam, 0x12, 0x8d);
41 err += sn9c102_i2c_write(cam, 0x12, 0x0d); 37 err += sn9c102_i2c_write(cam, 0x12, 0x0d);
42 err += sn9c102_i2c_write(cam, 0x11, 0x00); 38 err += sn9c102_i2c_write(cam, 0x11, 0x00);
43 err += sn9c102_i2c_write(cam, 0x15, 0x34); 39 err += sn9c102_i2c_write(cam, 0x15, 0x35);
44 err += sn9c102_i2c_write(cam, 0x16, 0x03); 40 err += sn9c102_i2c_write(cam, 0x16, 0x03);
45 err += sn9c102_i2c_write(cam, 0x17, 0x1c); 41 err += sn9c102_i2c_write(cam, 0x17, 0x1c);
46 err += sn9c102_i2c_write(cam, 0x18, 0xbd); 42 err += sn9c102_i2c_write(cam, 0x18, 0xbd);
47 err += sn9c102_i2c_write(cam, 0x19, 0x06); 43 err += sn9c102_i2c_write(cam, 0x19, 0x06);
48 err += sn9c102_i2c_write(cam, 0x1a, 0xf6); 44 err += sn9c102_i2c_write(cam, 0x1a, 0xf6);
49 err += sn9c102_i2c_write(cam, 0x1b, 0x04); 45 err += sn9c102_i2c_write(cam, 0x1b, 0x04);
50 err += sn9c102_i2c_write(cam, 0x20, 0x44); 46 err += sn9c102_i2c_write(cam, 0x20, 0x44);
51 err += sn9c102_i2c_write(cam, 0x23, 0xee); 47 err += sn9c102_i2c_write(cam, 0x23, 0xee);
52 err += sn9c102_i2c_write(cam, 0x26, 0xa0); 48 err += sn9c102_i2c_write(cam, 0x26, 0xa0);
@@ -65,42 +61,26 @@ static int ov7630_init(struct sn9c102_device* cam)
65 err += sn9c102_i2c_write(cam, 0x71, 0x00); 61 err += sn9c102_i2c_write(cam, 0x71, 0x00);
66 err += sn9c102_i2c_write(cam, 0x74, 0x21); 62 err += sn9c102_i2c_write(cam, 0x74, 0x21);
67 err += sn9c102_i2c_write(cam, 0x7d, 0xf7); 63 err += sn9c102_i2c_write(cam, 0x7d, 0xf7);
64
68 break; 65 break;
69 case BRIDGE_SN9C103: 66 case BRIDGE_SN9C103:
70 err += sn9c102_write_reg(cam, 0x00, 0x02); 67 err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03},
71 err += sn9c102_write_reg(cam, 0x00, 0x03); 68 {0x1a, 0x04}, {0x20, 0x05},
72 err += sn9c102_write_reg(cam, 0x1a, 0x04); 69 {0x20, 0x06}, {0x20, 0x07},
73 err += sn9c102_write_reg(cam, 0x20, 0x05); 70 {0x03, 0x10}, {0x0a, 0x14},
74 err += sn9c102_write_reg(cam, 0x20, 0x06); 71 {0x60, 0x17}, {0x0f, 0x18},
75 err += sn9c102_write_reg(cam, 0x20, 0x07); 72 {0x50, 0x19}, {0x1d, 0x1a},
76 err += sn9c102_write_reg(cam, 0x03, 0x10); 73 {0x10, 0x1b}, {0x02, 0x1c},
77 err += sn9c102_write_reg(cam, 0x0a, 0x14); 74 {0x03, 0x1d}, {0x0f, 0x1e},
78 err += sn9c102_write_reg(cam, 0x60, 0x17); 75 {0x0c, 0x1f}, {0x00, 0x20},
79 err += sn9c102_write_reg(cam, 0x0f, 0x18); 76 {0x10, 0x21}, {0x20, 0x22},
80 err += sn9c102_write_reg(cam, 0x50, 0x19); 77 {0x30, 0x23}, {0x40, 0x24},
81 err += sn9c102_write_reg(cam, 0x1d, 0x1a); 78 {0x50, 0x25}, {0x60, 0x26},
82 err += sn9c102_write_reg(cam, 0x10, 0x1b); 79 {0x70, 0x27}, {0x80, 0x28},
83 err += sn9c102_write_reg(cam, 0x02, 0x1c); 80 {0x90, 0x29}, {0xa0, 0x2a},
84 err += sn9c102_write_reg(cam, 0x03, 0x1d); 81 {0xb0, 0x2b}, {0xc0, 0x2c},
85 err += sn9c102_write_reg(cam, 0x0f, 0x1e); 82 {0xd0, 0x2d}, {0xe0, 0x2e},
86 err += sn9c102_write_reg(cam, 0x0c, 0x1f); 83 {0xf0, 0x2f}, {0xff, 0x30});
87 err += sn9c102_write_reg(cam, 0x00, 0x20);
88 err += sn9c102_write_reg(cam, 0x10, 0x21);
89 err += sn9c102_write_reg(cam, 0x20, 0x22);
90 err += sn9c102_write_reg(cam, 0x30, 0x23);
91 err += sn9c102_write_reg(cam, 0x40, 0x24);
92 err += sn9c102_write_reg(cam, 0x50, 0x25);
93 err += sn9c102_write_reg(cam, 0x60, 0x26);
94 err += sn9c102_write_reg(cam, 0x70, 0x27);
95 err += sn9c102_write_reg(cam, 0x80, 0x28);
96 err += sn9c102_write_reg(cam, 0x90, 0x29);
97 err += sn9c102_write_reg(cam, 0xa0, 0x2a);
98 err += sn9c102_write_reg(cam, 0xb0, 0x2b);
99 err += sn9c102_write_reg(cam, 0xc0, 0x2c);
100 err += sn9c102_write_reg(cam, 0xd0, 0x2d);
101 err += sn9c102_write_reg(cam, 0xe0, 0x2e);
102 err += sn9c102_write_reg(cam, 0xf0, 0x2f);
103 err += sn9c102_write_reg(cam, 0xff, 0x30);
104 84
105 err += sn9c102_i2c_write(cam, 0x12, 0x8d); 85 err += sn9c102_i2c_write(cam, 0x12, 0x8d);
106 err += sn9c102_i2c_write(cam, 0x12, 0x0d); 86 err += sn9c102_i2c_write(cam, 0x12, 0x0d);
@@ -108,23 +88,23 @@ static int ov7630_init(struct sn9c102_device* cam)
108 err += sn9c102_i2c_write(cam, 0x11, 0x01); 88 err += sn9c102_i2c_write(cam, 0x11, 0x01);
109 err += sn9c102_i2c_write(cam, 0x1b, 0x04); 89 err += sn9c102_i2c_write(cam, 0x1b, 0x04);
110 err += sn9c102_i2c_write(cam, 0x20, 0x44); 90 err += sn9c102_i2c_write(cam, 0x20, 0x44);
111 err += sn9c102_i2c_write(cam, 0x23, 0xee); 91 err += sn9c102_i2c_write(cam, 0x23, 0xee);
112 err += sn9c102_i2c_write(cam, 0x26, 0xa0); 92 err += sn9c102_i2c_write(cam, 0x26, 0xa0);
113 err += sn9c102_i2c_write(cam, 0x27, 0x9a); 93 err += sn9c102_i2c_write(cam, 0x27, 0x9a);
114 err += sn9c102_i2c_write(cam, 0x28, 0x20); 94 err += sn9c102_i2c_write(cam, 0x28, 0x20);
115 err += sn9c102_i2c_write(cam, 0x29, 0x30); 95 err += sn9c102_i2c_write(cam, 0x29, 0x30);
116 err += sn9c102_i2c_write(cam, 0x2f, 0x3d); 96 err += sn9c102_i2c_write(cam, 0x2f, 0x3d);
117 err += sn9c102_i2c_write(cam, 0x30, 0x24); 97 err += sn9c102_i2c_write(cam, 0x30, 0x24);
118 err += sn9c102_i2c_write(cam, 0x32, 0x86); 98 err += sn9c102_i2c_write(cam, 0x32, 0x86);
119 err += sn9c102_i2c_write(cam, 0x60, 0xa9); 99 err += sn9c102_i2c_write(cam, 0x60, 0xa9);
120 err += sn9c102_i2c_write(cam, 0x61, 0x42); 100 err += sn9c102_i2c_write(cam, 0x61, 0x42);
121 err += sn9c102_i2c_write(cam, 0x65, 0x00); 101 err += sn9c102_i2c_write(cam, 0x65, 0x00);
122 err += sn9c102_i2c_write(cam, 0x69, 0x38); 102 err += sn9c102_i2c_write(cam, 0x69, 0x38);
123 err += sn9c102_i2c_write(cam, 0x6f, 0x88); 103 err += sn9c102_i2c_write(cam, 0x6f, 0x88);
124 err += sn9c102_i2c_write(cam, 0x70, 0x0b); 104 err += sn9c102_i2c_write(cam, 0x70, 0x0b);
125 err += sn9c102_i2c_write(cam, 0x71, 0x00); 105 err += sn9c102_i2c_write(cam, 0x71, 0x00);
126 err += sn9c102_i2c_write(cam, 0x74, 0x21); 106 err += sn9c102_i2c_write(cam, 0x74, 0x21);
127 err += sn9c102_i2c_write(cam, 0x7d, 0xf7); 107 err += sn9c102_i2c_write(cam, 0x7d, 0xf7);
128 break; 108 break;
129 default: 109 default:
130 break; 110 break;
@@ -428,15 +408,14 @@ int sn9c102_probe_ov7630(struct sn9c102_device* cam)
428 switch (sn9c102_get_bridge(cam)) { 408 switch (sn9c102_get_bridge(cam)) {
429 case BRIDGE_SN9C101: 409 case BRIDGE_SN9C101:
430 case BRIDGE_SN9C102: 410 case BRIDGE_SN9C102:
431 err += sn9c102_write_reg(cam, 0x01, 0x01); 411 err = sn9c102_write_const_regs(cam, {0x01, 0x01},
432 err += sn9c102_write_reg(cam, 0x00, 0x01); 412 {0x00, 0x01}, {0x28, 0x17});
433 err += sn9c102_write_reg(cam, 0x28, 0x17); 413
434 break; 414 break;
435 case BRIDGE_SN9C103: /* do _not_ change anything! */ 415 case BRIDGE_SN9C103: /* do _not_ change anything! */
436 err += sn9c102_write_reg(cam, 0x09, 0x01); 416 err = sn9c102_write_const_regs(cam, {0x09, 0x01},
437 err += sn9c102_write_reg(cam, 0x42, 0x01); 417 {0x42, 0x01}, {0x28, 0x17},
438 err += sn9c102_write_reg(cam, 0x28, 0x17); 418 {0x44, 0x02});
439 err += sn9c102_write_reg(cam, 0x44, 0x02);
440 pid = sn9c102_i2c_try_read(cam, &ov7630, 0x0a); 419 pid = sn9c102_i2c_try_read(cam, &ov7630, 0x0a);
441 if (err || pid < 0) { /* try a different initialization */ 420 if (err || pid < 0) { /* try a different initialization */
442 err = sn9c102_write_reg(cam, 0x01, 0x01); 421 err = sn9c102_write_reg(cam, 0x01, 0x01);