diff options
author | Luca Risolia <luca.risolia@studio.unibo.it> | 2007-03-26 15:12:04 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-04-27 14:45:08 -0400 |
commit | f423b9a86a6dd3d2bc08d78f4d21525a14c40a6b (patch) | |
tree | cac9dcd72bd298478559cdae7061b1a942cb4b0f /drivers/media/video/sn9c102/sn9c102_mi0343.c | |
parent | 9ab7e323af9f9efad3e20a14faa4d947adfac381 (diff) |
V4L/DVB (5474): SN9C1xx driver updates
@ Don't assume that SOF headers can't cross packets boundaries
@ Fix compression quality selection
+ Add support for MI-0360 image sensor
* Documentation updates
@ Fix sysfs
@ MI0343 rewritten
* HV7131R color fixes and add new ABLC control
* Rename the archive from "sn9c102" to "sn9c1xx"
* fix typos
* better support for TAS5110D
@ fix OV7630 wrong colors
@ Don't return an error if no input buffers are enqueued yet on VIDIOC_STREAMON
* Add informations about colorspaces
* More appropriate error codes in case of failure of some system calls
* More precise hardware detection
* Add more informations about supported hardware in the documentation
+ More supported devices
+ Add support for HV7131R image sensor
Signed-off-by: Luca Risolia <luca.risolia@studio.unibo.it>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/sn9c102/sn9c102_mi0343.c')
-rw-r--r-- | drivers/media/video/sn9c102/sn9c102_mi0343.c | 111 |
1 files changed, 52 insertions, 59 deletions
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0343.c b/drivers/media/video/sn9c102/sn9c102_mi0343.c index a33d1bc10f90..441156d61106 100644 --- a/drivers/media/video/sn9c102/sn9c102_mi0343.c +++ b/drivers/media/video/sn9c102/sn9c102_mi0343.c | |||
@@ -22,12 +22,9 @@ | |||
22 | #include "sn9c102_sensor.h" | 22 | #include "sn9c102_sensor.h" |
23 | 23 | ||
24 | 24 | ||
25 | static struct sn9c102_sensor mi0343; | ||
26 | static u8 mi0343_i2c_data[5+1]; | ||
27 | |||
28 | |||
29 | static int mi0343_init(struct sn9c102_device* cam) | 25 | static int mi0343_init(struct sn9c102_device* cam) |
30 | { | 26 | { |
27 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | ||
31 | int err = 0; | 28 | int err = 0; |
32 | 29 | ||
33 | err += sn9c102_write_reg(cam, 0x00, 0x10); | 30 | err += sn9c102_write_reg(cam, 0x00, 0x10); |
@@ -38,20 +35,20 @@ static int mi0343_init(struct sn9c102_device* cam) | |||
38 | err += sn9c102_write_reg(cam, 0x07, 0x18); | 35 | err += sn9c102_write_reg(cam, 0x07, 0x18); |
39 | err += sn9c102_write_reg(cam, 0xa0, 0x19); | 36 | err += sn9c102_write_reg(cam, 0xa0, 0x19); |
40 | 37 | ||
41 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, | 38 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d, |
42 | 0x0d, 0x00, 0x01, 0, 0); | 39 | 0x00, 0x01, 0, 0); |
43 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, | 40 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d, |
44 | 0x0d, 0x00, 0x00, 0, 0); | 41 | 0x00, 0x00, 0, 0); |
45 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, | 42 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x03, |
46 | 0x03, 0x01, 0xe1, 0, 0); | 43 | 0x01, 0xe1, 0, 0); |
47 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, | 44 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x04, |
48 | 0x04, 0x02, 0x81, 0, 0); | 45 | 0x02, 0x81, 0, 0); |
49 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, | 46 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x05, |
50 | 0x05, 0x00, 0x17, 0, 0); | 47 | 0x00, 0x17, 0, 0); |
51 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, | 48 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x06, |
52 | 0x06, 0x00, 0x11, 0, 0); | 49 | 0x00, 0x11, 0, 0); |
53 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, | 50 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x62, |
54 | 0x62, 0x04, 0x9a, 0, 0); | 51 | 0x04, 0x9a, 0, 0); |
55 | 52 | ||
56 | return err; | 53 | return err; |
57 | } | 54 | } |
@@ -60,43 +57,46 @@ static int mi0343_init(struct sn9c102_device* cam) | |||
60 | static int mi0343_get_ctrl(struct sn9c102_device* cam, | 57 | static int mi0343_get_ctrl(struct sn9c102_device* cam, |
61 | struct v4l2_control* ctrl) | 58 | struct v4l2_control* ctrl) |
62 | { | 59 | { |
60 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | ||
61 | u8 data[5+1]; | ||
62 | |||
63 | switch (ctrl->id) { | 63 | switch (ctrl->id) { |
64 | case V4L2_CID_EXPOSURE: | 64 | case V4L2_CID_EXPOSURE: |
65 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, | 65 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, |
66 | 0x09, 2+1, mi0343_i2c_data) < 0) | 66 | 2+1, data) < 0) |
67 | return -EIO; | 67 | return -EIO; |
68 | ctrl->value = mi0343_i2c_data[2]; | 68 | ctrl->value = data[2]; |
69 | return 0; | 69 | return 0; |
70 | case V4L2_CID_GAIN: | 70 | case V4L2_CID_GAIN: |
71 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, | 71 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, |
72 | 0x35, 2+1, mi0343_i2c_data) < 0) | 72 | 2+1, data) < 0) |
73 | return -EIO; | 73 | return -EIO; |
74 | break; | 74 | break; |
75 | case V4L2_CID_HFLIP: | 75 | case V4L2_CID_HFLIP: |
76 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, | 76 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, |
77 | 0x20, 2+1, mi0343_i2c_data) < 0) | 77 | 2+1, data) < 0) |
78 | return -EIO; | 78 | return -EIO; |
79 | ctrl->value = mi0343_i2c_data[3] & 0x20 ? 1 : 0; | 79 | ctrl->value = data[3] & 0x20 ? 1 : 0; |
80 | return 0; | 80 | return 0; |
81 | case V4L2_CID_VFLIP: | 81 | case V4L2_CID_VFLIP: |
82 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, | 82 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, |
83 | 0x20, 2+1, mi0343_i2c_data) < 0) | 83 | 2+1, data) < 0) |
84 | return -EIO; | 84 | return -EIO; |
85 | ctrl->value = mi0343_i2c_data[3] & 0x80 ? 1 : 0; | 85 | ctrl->value = data[3] & 0x80 ? 1 : 0; |
86 | return 0; | 86 | return 0; |
87 | case V4L2_CID_RED_BALANCE: | 87 | case V4L2_CID_RED_BALANCE: |
88 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, | 88 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, |
89 | 0x2d, 2+1, mi0343_i2c_data) < 0) | 89 | 2+1, data) < 0) |
90 | return -EIO; | 90 | return -EIO; |
91 | break; | 91 | break; |
92 | case V4L2_CID_BLUE_BALANCE: | 92 | case V4L2_CID_BLUE_BALANCE: |
93 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, | 93 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, |
94 | 0x2c, 2+1, mi0343_i2c_data) < 0) | 94 | 2+1, data) < 0) |
95 | return -EIO; | 95 | return -EIO; |
96 | break; | 96 | break; |
97 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 97 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
98 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, | 98 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, |
99 | 0x2e, 2+1, mi0343_i2c_data) < 0) | 99 | 2+1, data) < 0) |
100 | return -EIO; | 100 | return -EIO; |
101 | break; | 101 | break; |
102 | default: | 102 | default: |
@@ -108,7 +108,7 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam, | |||
108 | case V4L2_CID_RED_BALANCE: | 108 | case V4L2_CID_RED_BALANCE: |
109 | case V4L2_CID_BLUE_BALANCE: | 109 | case V4L2_CID_BLUE_BALANCE: |
110 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 110 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
111 | ctrl->value = mi0343_i2c_data[3] | (mi0343_i2c_data[2] << 8); | 111 | ctrl->value = data[3] | (data[2] << 8); |
112 | if (ctrl->value >= 0x10 && ctrl->value <= 0x3f) | 112 | if (ctrl->value >= 0x10 && ctrl->value <= 0x3f) |
113 | ctrl->value -= 0x10; | 113 | ctrl->value -= 0x10; |
114 | else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f) | 114 | else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f) |
@@ -124,6 +124,7 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam, | |||
124 | static int mi0343_set_ctrl(struct sn9c102_device* cam, | 124 | static int mi0343_set_ctrl(struct sn9c102_device* cam, |
125 | const struct v4l2_control* ctrl) | 125 | const struct v4l2_control* ctrl) |
126 | { | 126 | { |
127 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | ||
127 | u16 reg = 0; | 128 | u16 reg = 0; |
128 | int err = 0; | 129 | int err = 0; |
129 | 130 | ||
@@ -143,50 +144,42 @@ static int mi0343_set_ctrl(struct sn9c102_device* cam, | |||
143 | 144 | ||
144 | switch (ctrl->id) { | 145 | switch (ctrl->id) { |
145 | case V4L2_CID_EXPOSURE: | 146 | case V4L2_CID_EXPOSURE: |
146 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, | 147 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
147 | mi0343.i2c_slave_id, | ||
148 | 0x09, ctrl->value, 0x00, | 148 | 0x09, ctrl->value, 0x00, |
149 | 0, 0); | 149 | 0, 0); |
150 | break; | 150 | break; |
151 | case V4L2_CID_GAIN: | 151 | case V4L2_CID_GAIN: |
152 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, | 152 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
153 | mi0343.i2c_slave_id, | ||
154 | 0x35, reg >> 8, reg & 0xff, | 153 | 0x35, reg >> 8, reg & 0xff, |
155 | 0, 0); | 154 | 0, 0); |
156 | break; | 155 | break; |
157 | case V4L2_CID_HFLIP: | 156 | case V4L2_CID_HFLIP: |
158 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, | 157 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
159 | mi0343.i2c_slave_id, | ||
160 | 0x20, ctrl->value ? 0x40:0x00, | 158 | 0x20, ctrl->value ? 0x40:0x00, |
161 | ctrl->value ? 0x20:0x00, | 159 | ctrl->value ? 0x20:0x00, |
162 | 0, 0); | 160 | 0, 0); |
163 | break; | 161 | break; |
164 | case V4L2_CID_VFLIP: | 162 | case V4L2_CID_VFLIP: |
165 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, | 163 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
166 | mi0343.i2c_slave_id, | ||
167 | 0x20, ctrl->value ? 0x80:0x00, | 164 | 0x20, ctrl->value ? 0x80:0x00, |
168 | ctrl->value ? 0x80:0x00, | 165 | ctrl->value ? 0x80:0x00, |
169 | 0, 0); | 166 | 0, 0); |
170 | break; | 167 | break; |
171 | case V4L2_CID_RED_BALANCE: | 168 | case V4L2_CID_RED_BALANCE: |
172 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, | 169 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
173 | mi0343.i2c_slave_id, | ||
174 | 0x2d, reg >> 8, reg & 0xff, | 170 | 0x2d, reg >> 8, reg & 0xff, |
175 | 0, 0); | 171 | 0, 0); |
176 | break; | 172 | break; |
177 | case V4L2_CID_BLUE_BALANCE: | 173 | case V4L2_CID_BLUE_BALANCE: |
178 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, | 174 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
179 | mi0343.i2c_slave_id, | ||
180 | 0x2c, reg >> 8, reg & 0xff, | 175 | 0x2c, reg >> 8, reg & 0xff, |
181 | 0, 0); | 176 | 0, 0); |
182 | break; | 177 | break; |
183 | case SN9C102_V4L2_CID_GREEN_BALANCE: | 178 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
184 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, | 179 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
185 | mi0343.i2c_slave_id, | ||
186 | 0x2b, reg >> 8, reg & 0xff, | 180 | 0x2b, reg >> 8, reg & 0xff, |
187 | 0, 0); | 181 | 0, 0); |
188 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, | 182 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
189 | mi0343.i2c_slave_id, | ||
190 | 0x2e, reg >> 8, reg & 0xff, | 183 | 0x2e, reg >> 8, reg & 0xff, |
191 | 0, 0); | 184 | 0, 0); |
192 | break; | 185 | break; |
@@ -216,16 +209,15 @@ static int mi0343_set_crop(struct sn9c102_device* cam, | |||
216 | static int mi0343_set_pix_format(struct sn9c102_device* cam, | 209 | static int mi0343_set_pix_format(struct sn9c102_device* cam, |
217 | const struct v4l2_pix_format* pix) | 210 | const struct v4l2_pix_format* pix) |
218 | { | 211 | { |
212 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); | ||
219 | int err = 0; | 213 | int err = 0; |
220 | 214 | ||
221 | if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) { | 215 | if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) { |
222 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, | 216 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
223 | mi0343.i2c_slave_id, | ||
224 | 0x0a, 0x00, 0x03, 0, 0); | 217 | 0x0a, 0x00, 0x03, 0, 0); |
225 | err += sn9c102_write_reg(cam, 0x20, 0x19); | 218 | err += sn9c102_write_reg(cam, 0x20, 0x19); |
226 | } else { | 219 | } else { |
227 | err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, | 220 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
228 | mi0343.i2c_slave_id, | ||
229 | 0x0a, 0x00, 0x05, 0, 0); | 221 | 0x0a, 0x00, 0x05, 0, 0); |
230 | err += sn9c102_write_reg(cam, 0xa0, 0x19); | 222 | err += sn9c102_write_reg(cam, 0xa0, 0x19); |
231 | } | 223 | } |
@@ -237,7 +229,7 @@ static int mi0343_set_pix_format(struct sn9c102_device* cam, | |||
237 | static struct sn9c102_sensor mi0343 = { | 229 | static struct sn9c102_sensor mi0343 = { |
238 | .name = "MI-0343", | 230 | .name = "MI-0343", |
239 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", | 231 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
240 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, | 232 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
241 | .frequency = SN9C102_I2C_100KHZ, | 233 | .frequency = SN9C102_I2C_100KHZ, |
242 | .interface = SN9C102_I2C_2WIRES, | 234 | .interface = SN9C102_I2C_2WIRES, |
243 | .i2c_slave_id = 0x5d, | 235 | .i2c_slave_id = 0x5d, |
@@ -343,6 +335,7 @@ static struct sn9c102_sensor mi0343 = { | |||
343 | 335 | ||
344 | int sn9c102_probe_mi0343(struct sn9c102_device* cam) | 336 | int sn9c102_probe_mi0343(struct sn9c102_device* cam) |
345 | { | 337 | { |
338 | u8 data[5+1]; | ||
346 | int err = 0; | 339 | int err = 0; |
347 | 340 | ||
348 | err += sn9c102_write_reg(cam, 0x01, 0x01); | 341 | err += sn9c102_write_reg(cam, 0x01, 0x01); |
@@ -352,10 +345,10 @@ int sn9c102_probe_mi0343(struct sn9c102_device* cam) | |||
352 | return -EIO; | 345 | return -EIO; |
353 | 346 | ||
354 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, | 347 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, |
355 | 2, mi0343_i2c_data) < 0) | 348 | 2, data) < 0) |
356 | return -EIO; | 349 | return -EIO; |
357 | 350 | ||
358 | if (mi0343_i2c_data[4] != 0x32 && mi0343_i2c_data[3] != 0xe3) | 351 | if (data[4] != 0x32 || data[3] != 0xe3) |
359 | return -ENODEV; | 352 | return -ENODEV; |
360 | 353 | ||
361 | sn9c102_attach_sensor(cam, &mi0343); | 354 | sn9c102_attach_sensor(cam, &mi0343); |