aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/sn9c102/sn9c102_mi0343.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/sn9c102/sn9c102_mi0343.c')
-rw-r--r--drivers/media/video/sn9c102/sn9c102_mi0343.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0343.c b/drivers/media/video/sn9c102/sn9c102_mi0343.c
index 9200845d011b..00b134ca0a3d 100644
--- a/drivers/media/video/sn9c102/sn9c102_mi0343.c
+++ b/drivers/media/video/sn9c102/sn9c102_mi0343.c
@@ -55,45 +55,45 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam,
55 struct v4l2_control* ctrl) 55 struct v4l2_control* ctrl)
56{ 56{
57 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 57 struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
58 u8 data[5+1]; 58 u8 data[2];
59 59
60 switch (ctrl->id) { 60 switch (ctrl->id) {
61 case V4L2_CID_EXPOSURE: 61 case V4L2_CID_EXPOSURE:
62 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 62 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2,
63 2+1, data) < 0) 63 data) < 0)
64 return -EIO; 64 return -EIO;
65 ctrl->value = data[2]; 65 ctrl->value = data[0];
66 return 0; 66 return 0;
67 case V4L2_CID_GAIN: 67 case V4L2_CID_GAIN:
68 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 68 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2,
69 2+1, data) < 0) 69 data) < 0)
70 return -EIO; 70 return -EIO;
71 break; 71 break;
72 case V4L2_CID_HFLIP: 72 case V4L2_CID_HFLIP:
73 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 73 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2,
74 2+1, data) < 0) 74 data) < 0)
75 return -EIO; 75 return -EIO;
76 ctrl->value = data[3] & 0x20 ? 1 : 0; 76 ctrl->value = data[1] & 0x20 ? 1 : 0;
77 return 0; 77 return 0;
78 case V4L2_CID_VFLIP: 78 case V4L2_CID_VFLIP:
79 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 79 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2,
80 2+1, data) < 0) 80 data) < 0)
81 return -EIO; 81 return -EIO;
82 ctrl->value = data[3] & 0x80 ? 1 : 0; 82 ctrl->value = data[1] & 0x80 ? 1 : 0;
83 return 0; 83 return 0;
84 case V4L2_CID_RED_BALANCE: 84 case V4L2_CID_RED_BALANCE:
85 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 85 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2,
86 2+1, data) < 0) 86 data) < 0)
87 return -EIO; 87 return -EIO;
88 break; 88 break;
89 case V4L2_CID_BLUE_BALANCE: 89 case V4L2_CID_BLUE_BALANCE:
90 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 90 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2,
91 2+1, data) < 0) 91 data) < 0)
92 return -EIO; 92 return -EIO;
93 break; 93 break;
94 case SN9C102_V4L2_CID_GREEN_BALANCE: 94 case SN9C102_V4L2_CID_GREEN_BALANCE:
95 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 95 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2,
96 2+1, data) < 0) 96 data) < 0)
97 return -EIO; 97 return -EIO;
98 break; 98 break;
99 default: 99 default:
@@ -105,7 +105,7 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam,
105 case V4L2_CID_RED_BALANCE: 105 case V4L2_CID_RED_BALANCE:
106 case V4L2_CID_BLUE_BALANCE: 106 case V4L2_CID_BLUE_BALANCE:
107 case SN9C102_V4L2_CID_GREEN_BALANCE: 107 case SN9C102_V4L2_CID_GREEN_BALANCE:
108 ctrl->value = data[3] | (data[2] << 8); 108 ctrl->value = data[1] | (data[0] << 8);
109 if (ctrl->value >= 0x10 && ctrl->value <= 0x3f) 109 if (ctrl->value >= 0x10 && ctrl->value <= 0x3f)
110 ctrl->value -= 0x10; 110 ctrl->value -= 0x10;
111 else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f) 111 else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f)
@@ -223,7 +223,7 @@ static int mi0343_set_pix_format(struct sn9c102_device* cam,
223} 223}
224 224
225 225
226static struct sn9c102_sensor mi0343 = { 226static const struct sn9c102_sensor mi0343 = {
227 .name = "MI-0343", 227 .name = "MI-0343",
228 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 228 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
229 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 229 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
@@ -332,20 +332,17 @@ static struct sn9c102_sensor mi0343 = {
332 332
333int sn9c102_probe_mi0343(struct sn9c102_device* cam) 333int sn9c102_probe_mi0343(struct sn9c102_device* cam)
334{ 334{
335 u8 data[5+1]; 335 u8 data[2];
336 int err = 0;
337
338 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
339 {0x28, 0x17});
340 336
341 if (err) 337 if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
338 {0x28, 0x17}))
342 return -EIO; 339 return -EIO;
343 340
344 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, 341 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00,
345 2, data) < 0) 342 2, data) < 0)
346 return -EIO; 343 return -EIO;
347 344
348 if (data[4] != 0x32 || data[3] != 0xe3) 345 if (data[1] != 0x42 || data[0] != 0xe3)
349 return -ENODEV; 346 return -ENODEV;
350 347
351 sn9c102_attach_sensor(cam, &mi0343); 348 sn9c102_attach_sensor(cam, &mi0343);