Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /*************************************************************************** |
Luca Risolia | f327ebb | 2007-01-08 10:43:56 -0300 | [diff] [blame] | 2 | * Plug-in for MI-0343 image sensor connected to the SN9C1xx PC Camera * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Controllers * |
| 4 | * * |
Luca Risolia | f327ebb | 2007-01-08 10:43:56 -0300 | [diff] [blame] | 5 | * Copyright (C) 2004-2007 by Luca Risolia <luca.risolia@studio.unibo.it> * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * * |
| 7 | * This program is free software; you can redistribute it and/or modify * |
| 8 | * it under the terms of the GNU General Public License as published by * |
| 9 | * the Free Software Foundation; either version 2 of the License, or * |
| 10 | * (at your option) any later version. * |
| 11 | * * |
| 12 | * This program is distributed in the hope that it will be useful, * |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 15 | * GNU General Public License for more details. * |
| 16 | * * |
| 17 | * You should have received a copy of the GNU General Public License * |
| 18 | * along with this program; if not, write to the Free Software * |
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | #include "sn9c102_sensor.h" |
| 23 | |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | static int mi0343_init(struct sn9c102_device* cam) |
| 26 | { |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 27 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | int err = 0; |
| 29 | |
Trent Piepho | c680dd6 | 2007-04-04 17:11:04 -0300 | [diff] [blame] | 30 | err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, |
| 31 | {0x0a, 0x14}, {0x40, 0x01}, |
| 32 | {0x20, 0x17}, {0x07, 0x18}, |
| 33 | {0xa0, 0x19}); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 35 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d, |
| 36 | 0x00, 0x01, 0, 0); |
| 37 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d, |
| 38 | 0x00, 0x00, 0, 0); |
| 39 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x03, |
| 40 | 0x01, 0xe1, 0, 0); |
| 41 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x04, |
| 42 | 0x02, 0x81, 0, 0); |
| 43 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x05, |
| 44 | 0x00, 0x17, 0, 0); |
| 45 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x06, |
| 46 | 0x00, 0x11, 0, 0); |
| 47 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x62, |
| 48 | 0x04, 0x9a, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | return err; |
| 51 | } |
| 52 | |
| 53 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 54 | static int mi0343_get_ctrl(struct sn9c102_device* cam, |
| 55 | struct v4l2_control* ctrl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | { |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 57 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 58 | u8 data[2]; |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | switch (ctrl->id) { |
| 61 | case V4L2_CID_EXPOSURE: |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 62 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2, |
| 63 | data) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | return -EIO; |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 65 | ctrl->value = data[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | return 0; |
| 67 | case V4L2_CID_GAIN: |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 68 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2, |
| 69 | data) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | return -EIO; |
| 71 | break; |
| 72 | case V4L2_CID_HFLIP: |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 73 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, |
| 74 | data) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | return -EIO; |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 76 | ctrl->value = data[1] & 0x20 ? 1 : 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | return 0; |
| 78 | case V4L2_CID_VFLIP: |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 79 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2, |
| 80 | data) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | return -EIO; |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 82 | ctrl->value = data[1] & 0x80 ? 1 : 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | return 0; |
| 84 | case V4L2_CID_RED_BALANCE: |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 85 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2, |
| 86 | data) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | return -EIO; |
| 88 | break; |
| 89 | case V4L2_CID_BLUE_BALANCE: |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 90 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2, |
| 91 | data) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | return -EIO; |
| 93 | break; |
| 94 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 95 | if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2, |
| 96 | data) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | return -EIO; |
| 98 | break; |
| 99 | default: |
| 100 | return -EINVAL; |
| 101 | } |
| 102 | |
| 103 | switch (ctrl->id) { |
| 104 | case V4L2_CID_GAIN: |
| 105 | case V4L2_CID_RED_BALANCE: |
| 106 | case V4L2_CID_BLUE_BALANCE: |
| 107 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 108 | ctrl->value = data[1] | (data[0] << 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | if (ctrl->value >= 0x10 && ctrl->value <= 0x3f) |
| 110 | ctrl->value -= 0x10; |
| 111 | else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f) |
| 112 | ctrl->value -= 0x60; |
| 113 | else if (ctrl->value >= 0xe0 && ctrl->value <= 0xff) |
| 114 | ctrl->value -= 0xe0; |
| 115 | } |
| 116 | |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 121 | static int mi0343_set_ctrl(struct sn9c102_device* cam, |
| 122 | const struct v4l2_control* ctrl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | { |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 124 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | u16 reg = 0; |
| 126 | int err = 0; |
| 127 | |
| 128 | switch (ctrl->id) { |
| 129 | case V4L2_CID_GAIN: |
| 130 | case V4L2_CID_RED_BALANCE: |
| 131 | case V4L2_CID_BLUE_BALANCE: |
| 132 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
| 133 | if (ctrl->value <= (0x3f-0x10)) |
| 134 | reg = 0x10 + ctrl->value; |
| 135 | else if (ctrl->value <= ((0x3f-0x10) + (0x7f-0x60))) |
| 136 | reg = 0x60 + (ctrl->value - (0x3f-0x10)); |
| 137 | else |
| 138 | reg = 0xe0 + (ctrl->value - (0x3f-0x10) - (0x7f-0x60)); |
| 139 | break; |
| 140 | } |
| 141 | |
| 142 | switch (ctrl->id) { |
| 143 | case V4L2_CID_EXPOSURE: |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 144 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 145 | 0x09, ctrl->value, 0x00, |
| 146 | 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | break; |
| 148 | case V4L2_CID_GAIN: |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 149 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 150 | 0x35, reg >> 8, reg & 0xff, |
| 151 | 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | break; |
| 153 | case V4L2_CID_HFLIP: |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 154 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 155 | 0x20, ctrl->value ? 0x40:0x00, |
| 156 | ctrl->value ? 0x20:0x00, |
| 157 | 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | break; |
| 159 | case V4L2_CID_VFLIP: |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 160 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 161 | 0x20, ctrl->value ? 0x80:0x00, |
| 162 | ctrl->value ? 0x80:0x00, |
| 163 | 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | break; |
| 165 | case V4L2_CID_RED_BALANCE: |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 166 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 167 | 0x2d, reg >> 8, reg & 0xff, |
| 168 | 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | break; |
| 170 | case V4L2_CID_BLUE_BALANCE: |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 171 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 172 | 0x2c, reg >> 8, reg & 0xff, |
| 173 | 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | break; |
| 175 | case SN9C102_V4L2_CID_GREEN_BALANCE: |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 176 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 177 | 0x2b, reg >> 8, reg & 0xff, |
| 178 | 0, 0); |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 179 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 180 | 0x2e, reg >> 8, reg & 0xff, |
| 181 | 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | break; |
| 183 | default: |
| 184 | return -EINVAL; |
| 185 | } |
| 186 | |
| 187 | return err ? -EIO : 0; |
| 188 | } |
| 189 | |
| 190 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 191 | static int mi0343_set_crop(struct sn9c102_device* cam, |
| 192 | const struct v4l2_rect* rect) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | { |
Luca Risolia | f327ebb | 2007-01-08 10:43:56 -0300 | [diff] [blame] | 194 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | int err = 0; |
| 196 | u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 0, |
| 197 | v_start = (u8)(rect->top - s->cropcap.bounds.top) + 2; |
| 198 | |
| 199 | err += sn9c102_write_reg(cam, h_start, 0x12); |
| 200 | err += sn9c102_write_reg(cam, v_start, 0x13); |
| 201 | |
| 202 | return err; |
| 203 | } |
| 204 | |
| 205 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 206 | static int mi0343_set_pix_format(struct sn9c102_device* cam, |
| 207 | const struct v4l2_pix_format* pix) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | { |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 209 | struct sn9c102_sensor* s = sn9c102_get_sensor(cam); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | int err = 0; |
| 211 | |
| 212 | if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) { |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 213 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 214 | 0x0a, 0x00, 0x03, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | err += sn9c102_write_reg(cam, 0x20, 0x19); |
| 216 | } else { |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 217 | err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 218 | 0x0a, 0x00, 0x05, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | err += sn9c102_write_reg(cam, 0xa0, 0x19); |
| 220 | } |
| 221 | |
| 222 | return err; |
| 223 | } |
| 224 | |
| 225 | |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 226 | static const struct sn9c102_sensor mi0343 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | .name = "MI-0343", |
| 228 | .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 229 | .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | .frequency = SN9C102_I2C_100KHZ, |
| 231 | .interface = SN9C102_I2C_2WIRES, |
| 232 | .i2c_slave_id = 0x5d, |
| 233 | .init = &mi0343_init, |
| 234 | .qctrl = { |
| 235 | { |
| 236 | .id = V4L2_CID_EXPOSURE, |
| 237 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 238 | .name = "exposure", |
| 239 | .minimum = 0x00, |
| 240 | .maximum = 0x0f, |
| 241 | .step = 0x01, |
| 242 | .default_value = 0x06, |
| 243 | .flags = 0, |
| 244 | }, |
| 245 | { |
| 246 | .id = V4L2_CID_GAIN, |
| 247 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 248 | .name = "global gain", |
| 249 | .minimum = 0x00, |
| 250 | .maximum = (0x3f-0x10)+(0x7f-0x60)+(0xff-0xe0),/*0x6d*/ |
| 251 | .step = 0x01, |
| 252 | .default_value = 0x00, |
| 253 | .flags = 0, |
| 254 | }, |
| 255 | { |
| 256 | .id = V4L2_CID_HFLIP, |
| 257 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 258 | .name = "horizontal mirror", |
| 259 | .minimum = 0, |
| 260 | .maximum = 1, |
| 261 | .step = 1, |
| 262 | .default_value = 0, |
| 263 | .flags = 0, |
| 264 | }, |
| 265 | { |
| 266 | .id = V4L2_CID_VFLIP, |
| 267 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 268 | .name = "vertical mirror", |
| 269 | .minimum = 0, |
| 270 | .maximum = 1, |
| 271 | .step = 1, |
| 272 | .default_value = 0, |
| 273 | .flags = 0, |
| 274 | }, |
| 275 | { |
| 276 | .id = V4L2_CID_RED_BALANCE, |
| 277 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 278 | .name = "red balance", |
| 279 | .minimum = 0x00, |
| 280 | .maximum = (0x3f-0x10)+(0x7f-0x60)+(0xff-0xe0), |
| 281 | .step = 0x01, |
| 282 | .default_value = 0x00, |
| 283 | .flags = 0, |
| 284 | }, |
| 285 | { |
| 286 | .id = V4L2_CID_BLUE_BALANCE, |
| 287 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 288 | .name = "blue balance", |
| 289 | .minimum = 0x00, |
| 290 | .maximum = (0x3f-0x10)+(0x7f-0x60)+(0xff-0xe0), |
| 291 | .step = 0x01, |
| 292 | .default_value = 0x00, |
| 293 | .flags = 0, |
| 294 | }, |
| 295 | { |
| 296 | .id = SN9C102_V4L2_CID_GREEN_BALANCE, |
| 297 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 298 | .name = "green balance", |
| 299 | .minimum = 0x00, |
| 300 | .maximum = ((0x3f-0x10)+(0x7f-0x60)+(0xff-0xe0)), |
| 301 | .step = 0x01, |
| 302 | .default_value = 0x00, |
| 303 | .flags = 0, |
| 304 | }, |
| 305 | }, |
| 306 | .get_ctrl = &mi0343_get_ctrl, |
| 307 | .set_ctrl = &mi0343_set_ctrl, |
| 308 | .cropcap = { |
| 309 | .bounds = { |
| 310 | .left = 0, |
| 311 | .top = 0, |
| 312 | .width = 640, |
| 313 | .height = 480, |
| 314 | }, |
| 315 | .defrect = { |
| 316 | .left = 0, |
| 317 | .top = 0, |
| 318 | .width = 640, |
| 319 | .height = 480, |
| 320 | }, |
| 321 | }, |
| 322 | .set_crop = &mi0343_set_crop, |
| 323 | .pix_format = { |
| 324 | .width = 640, |
| 325 | .height = 480, |
| 326 | .pixelformat = V4L2_PIX_FMT_SBGGR8, |
| 327 | .priv = 8, |
| 328 | }, |
| 329 | .set_pix_format = &mi0343_set_pix_format |
| 330 | }; |
| 331 | |
| 332 | |
| 333 | int sn9c102_probe_mi0343(struct sn9c102_device* cam) |
| 334 | { |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 335 | u8 data[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 337 | if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, |
| 338 | {0x28, 0x17})) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | return -EIO; |
| 340 | |
| 341 | if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, |
Luca Risolia | f423b9a | 2007-03-26 16:12:04 -0300 | [diff] [blame] | 342 | 2, data) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | return -EIO; |
| 344 | |
Luca Risolia | 480b55c2 | 2007-05-02 10:04:03 -0300 | [diff] [blame^] | 345 | if (data[1] != 0x42 || data[0] != 0xe3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | return -ENODEV; |
| 347 | |
| 348 | sn9c102_attach_sensor(cam, &mi0343); |
| 349 | |
| 350 | return 0; |
| 351 | } |