aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/m5mols
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/m5mols')
-rw-r--r--drivers/media/video/m5mols/m5mols.h57
-rw-r--r--drivers/media/video/m5mols/m5mols_capture.c22
-rw-r--r--drivers/media/video/m5mols/m5mols_controls.c6
-rw-r--r--drivers/media/video/m5mols/m5mols_core.c144
-rw-r--r--drivers/media/video/m5mols/m5mols_reg.h21
5 files changed, 150 insertions, 100 deletions
diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index 10b55c854487..89d09a8914f8 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -2,10 +2,10 @@
2 * Header for M-5MOLS 8M Pixel camera sensor with ISP 2 * Header for M-5MOLS 8M Pixel camera sensor with ISP
3 * 3 *
4 * Copyright (C) 2011 Samsung Electronics Co., Ltd. 4 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
5 * Author: HeungJun Kim, riverful.kim@samsung.com 5 * Author: HeungJun Kim <riverful.kim@samsung.com>
6 * 6 *
7 * Copyright (C) 2009 Samsung Electronics Co., Ltd. 7 * Copyright (C) 2009 Samsung Electronics Co., Ltd.
8 * Author: Dongsoo Nathaniel Kim, dongsoo45.kim@samsung.com 8 * Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -106,23 +106,23 @@ struct m5mols_capture {
106 * The each value according to each scenemode is recommended in the documents. 106 * The each value according to each scenemode is recommended in the documents.
107 */ 107 */
108struct m5mols_scenemode { 108struct m5mols_scenemode {
109 u32 metering; 109 u8 metering;
110 u32 ev_bias; 110 u8 ev_bias;
111 u32 wb_mode; 111 u8 wb_mode;
112 u32 wb_preset; 112 u8 wb_preset;
113 u32 chroma_en; 113 u8 chroma_en;
114 u32 chroma_lvl; 114 u8 chroma_lvl;
115 u32 edge_en; 115 u8 edge_en;
116 u32 edge_lvl; 116 u8 edge_lvl;
117 u32 af_range; 117 u8 af_range;
118 u32 fd_mode; 118 u8 fd_mode;
119 u32 mcc; 119 u8 mcc;
120 u32 light; 120 u8 light;
121 u32 flash; 121 u8 flash;
122 u32 tone; 122 u8 tone;
123 u32 iso; 123 u8 iso;
124 u32 capt_mode; 124 u8 capt_mode;
125 u32 wdr; 125 u8 wdr;
126}; 126};
127 127
128/** 128/**
@@ -154,7 +154,6 @@ struct m5mols_version {
154 u8 str[VERSION_STRING_SIZE]; 154 u8 str[VERSION_STRING_SIZE];
155 u8 af; 155 u8 af;
156}; 156};
157#define VERSION_SIZE sizeof(struct m5mols_version)
158 157
159/** 158/**
160 * struct m5mols_info - M-5MOLS driver data structure 159 * struct m5mols_info - M-5MOLS driver data structure
@@ -216,9 +215,9 @@ struct m5mols_info {
216 bool lock_ae; 215 bool lock_ae;
217 bool lock_awb; 216 bool lock_awb;
218 u8 resolution; 217 u8 resolution;
219 u32 interrupt; 218 u8 interrupt;
220 u32 mode; 219 u8 mode;
221 u32 mode_save; 220 u8 mode_save;
222 int (*set_power)(struct device *dev, int on); 221 int (*set_power)(struct device *dev, int on);
223}; 222};
224 223
@@ -256,9 +255,11 @@ struct m5mols_info {
256 * +-------+---+----------+-----+------+------+------+------+ 255 * +-------+---+----------+-----+------+------+------+------+
257 * - d[0..3]: according to size1 256 * - d[0..3]: according to size1
258 */ 257 */
259int m5mols_read(struct v4l2_subdev *sd, u32 reg_comb, u32 *val); 258int m5mols_read_u8(struct v4l2_subdev *sd, u32 reg_comb, u8 *val);
259int m5mols_read_u16(struct v4l2_subdev *sd, u32 reg_comb, u16 *val);
260int m5mols_read_u32(struct v4l2_subdev *sd, u32 reg_comb, u32 *val);
260int m5mols_write(struct v4l2_subdev *sd, u32 reg_comb, u32 val); 261int m5mols_write(struct v4l2_subdev *sd, u32 reg_comb, u32 val);
261int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u32 value); 262int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u8 value);
262 263
263/* 264/*
264 * Mode operation of the M-5MOLS 265 * Mode operation of the M-5MOLS
@@ -280,12 +281,12 @@ int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u32 value);
280 * The available executing order between each modes are as follows: 281 * The available executing order between each modes are as follows:
281 * PARAMETER <---> MONITOR <---> CAPTURE 282 * PARAMETER <---> MONITOR <---> CAPTURE
282 */ 283 */
283int m5mols_mode(struct m5mols_info *info, u32 mode); 284int m5mols_mode(struct m5mols_info *info, u8 mode);
284 285
285int m5mols_enable_interrupt(struct v4l2_subdev *sd, u32 reg); 286int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg);
286int m5mols_sync_controls(struct m5mols_info *info); 287int m5mols_sync_controls(struct m5mols_info *info);
287int m5mols_start_capture(struct m5mols_info *info); 288int m5mols_start_capture(struct m5mols_info *info);
288int m5mols_do_scenemode(struct m5mols_info *info, u32 mode); 289int m5mols_do_scenemode(struct m5mols_info *info, u8 mode);
289int m5mols_lock_3a(struct m5mols_info *info, bool lock); 290int m5mols_lock_3a(struct m5mols_info *info, bool lock);
290int m5mols_set_ctrl(struct v4l2_ctrl *ctrl); 291int m5mols_set_ctrl(struct v4l2_ctrl *ctrl);
291 292
diff --git a/drivers/media/video/m5mols/m5mols_capture.c b/drivers/media/video/m5mols/m5mols_capture.c
index d71a3903b60f..d9471928369d 100644
--- a/drivers/media/video/m5mols/m5mols_capture.c
+++ b/drivers/media/video/m5mols/m5mols_capture.c
@@ -2,10 +2,10 @@
2 * The Capture code for Fujitsu M-5MOLS ISP 2 * The Capture code for Fujitsu M-5MOLS ISP
3 * 3 *
4 * Copyright (C) 2011 Samsung Electronics Co., Ltd. 4 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
5 * Author: HeungJun Kim, riverful.kim@samsung.com 5 * Author: HeungJun Kim <riverful.kim@samsung.com>
6 * 6 *
7 * Copyright (C) 2009 Samsung Electronics Co., Ltd. 7 * Copyright (C) 2009 Samsung Electronics Co., Ltd.
8 * Author: Dongsoo Nathaniel Kim, dongsoo45.kim@samsung.com 8 * Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -58,9 +58,9 @@ static int m5mols_read_rational(struct v4l2_subdev *sd, u32 addr_num,
58{ 58{
59 u32 num, den; 59 u32 num, den;
60 60
61 int ret = m5mols_read(sd, addr_num, &num); 61 int ret = m5mols_read_u32(sd, addr_num, &num);
62 if (!ret) 62 if (!ret)
63 ret = m5mols_read(sd, addr_den, &den); 63 ret = m5mols_read_u32(sd, addr_den, &den);
64 if (ret) 64 if (ret)
65 return ret; 65 return ret;
66 *val = den == 0 ? 0 : num / den; 66 *val = den == 0 ? 0 : num / den;
@@ -99,20 +99,20 @@ static int m5mols_capture_info(struct m5mols_info *info)
99 if (ret) 99 if (ret)
100 return ret; 100 return ret;
101 101
102 ret = m5mols_read(sd, EXIF_INFO_ISO, (u32 *)&exif->iso_speed); 102 ret = m5mols_read_u16(sd, EXIF_INFO_ISO, &exif->iso_speed);
103 if (!ret) 103 if (!ret)
104 ret = m5mols_read(sd, EXIF_INFO_FLASH, (u32 *)&exif->flash); 104 ret = m5mols_read_u16(sd, EXIF_INFO_FLASH, &exif->flash);
105 if (!ret) 105 if (!ret)
106 ret = m5mols_read(sd, EXIF_INFO_SDR, (u32 *)&exif->sdr); 106 ret = m5mols_read_u16(sd, EXIF_INFO_SDR, &exif->sdr);
107 if (!ret) 107 if (!ret)
108 ret = m5mols_read(sd, EXIF_INFO_QVAL, (u32 *)&exif->qval); 108 ret = m5mols_read_u16(sd, EXIF_INFO_QVAL, &exif->qval);
109 if (ret) 109 if (ret)
110 return ret; 110 return ret;
111 111
112 if (!ret) 112 if (!ret)
113 ret = m5mols_read(sd, CAPC_IMAGE_SIZE, &info->cap.main); 113 ret = m5mols_read_u32(sd, CAPC_IMAGE_SIZE, &info->cap.main);
114 if (!ret) 114 if (!ret)
115 ret = m5mols_read(sd, CAPC_THUMB_SIZE, &info->cap.thumb); 115 ret = m5mols_read_u32(sd, CAPC_THUMB_SIZE, &info->cap.thumb);
116 if (!ret) 116 if (!ret)
117 info->cap.total = info->cap.main + info->cap.thumb; 117 info->cap.total = info->cap.main + info->cap.thumb;
118 118
@@ -122,7 +122,7 @@ static int m5mols_capture_info(struct m5mols_info *info)
122int m5mols_start_capture(struct m5mols_info *info) 122int m5mols_start_capture(struct m5mols_info *info)
123{ 123{
124 struct v4l2_subdev *sd = &info->sd; 124 struct v4l2_subdev *sd = &info->sd;
125 u32 resolution = info->resolution; 125 u8 resolution = info->resolution;
126 int timeout; 126 int timeout;
127 int ret; 127 int ret;
128 128
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index 817c16fec368..d135d20d09cf 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -2,10 +2,10 @@
2 * Controls for M-5MOLS 8M Pixel camera sensor with ISP 2 * Controls for M-5MOLS 8M Pixel camera sensor with ISP
3 * 3 *
4 * Copyright (C) 2011 Samsung Electronics Co., Ltd. 4 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
5 * Author: HeungJun Kim, riverful.kim@samsung.com 5 * Author: HeungJun Kim <riverful.kim@samsung.com>
6 * 6 *
7 * Copyright (C) 2009 Samsung Electronics Co., Ltd. 7 * Copyright (C) 2009 Samsung Electronics Co., Ltd.
8 * Author: Dongsoo Nathaniel Kim, dongsoo45.kim@samsung.com 8 * Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -130,7 +130,7 @@ static struct m5mols_scenemode m5mols_default_scenemode[] = {
130 * 130 *
131 * WARNING: The execution order is important. Do not change the order. 131 * WARNING: The execution order is important. Do not change the order.
132 */ 132 */
133int m5mols_do_scenemode(struct m5mols_info *info, u32 mode) 133int m5mols_do_scenemode(struct m5mols_info *info, u8 mode)
134{ 134{
135 struct v4l2_subdev *sd = &info->sd; 135 struct v4l2_subdev *sd = &info->sd;
136 struct m5mols_scenemode scenemode = m5mols_default_scenemode[mode]; 136 struct m5mols_scenemode scenemode = m5mols_default_scenemode[mode];
diff --git a/drivers/media/video/m5mols/m5mols_core.c b/drivers/media/video/m5mols/m5mols_core.c
index 76eac26e84ae..43c68f51c5ce 100644
--- a/drivers/media/video/m5mols/m5mols_core.c
+++ b/drivers/media/video/m5mols/m5mols_core.c
@@ -2,10 +2,10 @@
2 * Driver for M-5MOLS 8M Pixel camera sensor with ISP 2 * Driver for M-5MOLS 8M Pixel camera sensor with ISP
3 * 3 *
4 * Copyright (C) 2011 Samsung Electronics Co., Ltd. 4 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
5 * Author: HeungJun Kim, riverful.kim@samsung.com 5 * Author: HeungJun Kim <riverful.kim@samsung.com>
6 * 6 *
7 * Copyright (C) 2009 Samsung Electronics Co., Ltd. 7 * Copyright (C) 2009 Samsung Electronics Co., Ltd.
8 * Author: Dongsoo Nathaniel Kim, dongsoo45.kim@samsung.com 8 * Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -133,13 +133,13 @@ static u32 m5mols_swap_byte(u8 *data, u8 length)
133/** 133/**
134 * m5mols_read - I2C read function 134 * m5mols_read - I2C read function
135 * @reg: combination of size, category and command for the I2C packet 135 * @reg: combination of size, category and command for the I2C packet
136 * @size: desired size of I2C packet
136 * @val: read value 137 * @val: read value
137 */ 138 */
138int m5mols_read(struct v4l2_subdev *sd, u32 reg, u32 *val) 139static int m5mols_read(struct v4l2_subdev *sd, u32 size, u32 reg, u32 *val)
139{ 140{
140 struct i2c_client *client = v4l2_get_subdevdata(sd); 141 struct i2c_client *client = v4l2_get_subdevdata(sd);
141 u8 rbuf[M5MOLS_I2C_MAX_SIZE + 1]; 142 u8 rbuf[M5MOLS_I2C_MAX_SIZE + 1];
142 u8 size = I2C_SIZE(reg);
143 u8 category = I2C_CATEGORY(reg); 143 u8 category = I2C_CATEGORY(reg);
144 u8 cmd = I2C_COMMAND(reg); 144 u8 cmd = I2C_COMMAND(reg);
145 struct i2c_msg msg[2]; 145 struct i2c_msg msg[2];
@@ -149,11 +149,6 @@ int m5mols_read(struct v4l2_subdev *sd, u32 reg, u32 *val)
149 if (!client->adapter) 149 if (!client->adapter)
150 return -ENODEV; 150 return -ENODEV;
151 151
152 if (size != 1 && size != 2 && size != 4) {
153 v4l2_err(sd, "Wrong data size\n");
154 return -EINVAL;
155 }
156
157 msg[0].addr = client->addr; 152 msg[0].addr = client->addr;
158 msg[0].flags = 0; 153 msg[0].flags = 0;
159 msg[0].len = 5; 154 msg[0].len = 5;
@@ -184,6 +179,52 @@ int m5mols_read(struct v4l2_subdev *sd, u32 reg, u32 *val)
184 return 0; 179 return 0;
185} 180}
186 181
182int m5mols_read_u8(struct v4l2_subdev *sd, u32 reg, u8 *val)
183{
184 u32 val_32;
185 int ret;
186
187 if (I2C_SIZE(reg) != 1) {
188 v4l2_err(sd, "Wrong data size\n");
189 return -EINVAL;
190 }
191
192 ret = m5mols_read(sd, I2C_SIZE(reg), reg, &val_32);
193 if (ret)
194 return ret;
195
196 *val = (u8)val_32;
197 return ret;
198}
199
200int m5mols_read_u16(struct v4l2_subdev *sd, u32 reg, u16 *val)
201{
202 u32 val_32;
203 int ret;
204
205 if (I2C_SIZE(reg) != 2) {
206 v4l2_err(sd, "Wrong data size\n");
207 return -EINVAL;
208 }
209
210 ret = m5mols_read(sd, I2C_SIZE(reg), reg, &val_32);
211 if (ret)
212 return ret;
213
214 *val = (u16)val_32;
215 return ret;
216}
217
218int m5mols_read_u32(struct v4l2_subdev *sd, u32 reg, u32 *val)
219{
220 if (I2C_SIZE(reg) != 4) {
221 v4l2_err(sd, "Wrong data size\n");
222 return -EINVAL;
223 }
224
225 return m5mols_read(sd, I2C_SIZE(reg), reg, val);
226}
227
187/** 228/**
188 * m5mols_write - I2C command write function 229 * m5mols_write - I2C command write function
189 * @reg: combination of size, category and command for the I2C packet 230 * @reg: combination of size, category and command for the I2C packet
@@ -231,13 +272,14 @@ int m5mols_write(struct v4l2_subdev *sd, u32 reg, u32 val)
231 return 0; 272 return 0;
232} 273}
233 274
234int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u32 mask) 275int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u8 mask)
235{ 276{
236 u32 busy, i; 277 u8 busy;
278 int i;
237 int ret; 279 int ret;
238 280
239 for (i = 0; i < M5MOLS_I2C_CHECK_RETRY; i++) { 281 for (i = 0; i < M5MOLS_I2C_CHECK_RETRY; i++) {
240 ret = m5mols_read(sd, I2C_REG(category, cmd, 1), &busy); 282 ret = m5mols_read_u8(sd, I2C_REG(category, cmd, 1), &busy);
241 if (ret < 0) 283 if (ret < 0)
242 return ret; 284 return ret;
243 if ((busy & mask) == mask) 285 if ((busy & mask) == mask)
@@ -252,14 +294,14 @@ int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u32 mask)
252 * Before writing desired interrupt value the INT_FACTOR register should 294 * Before writing desired interrupt value the INT_FACTOR register should
253 * be read to clear pending interrupts. 295 * be read to clear pending interrupts.
254 */ 296 */
255int m5mols_enable_interrupt(struct v4l2_subdev *sd, u32 reg) 297int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg)
256{ 298{
257 struct m5mols_info *info = to_m5mols(sd); 299 struct m5mols_info *info = to_m5mols(sd);
258 u32 mask = is_available_af(info) ? REG_INT_AF : 0; 300 u8 mask = is_available_af(info) ? REG_INT_AF : 0;
259 u32 dummy; 301 u8 dummy;
260 int ret; 302 int ret;
261 303
262 ret = m5mols_read(sd, SYSTEM_INT_FACTOR, &dummy); 304 ret = m5mols_read_u8(sd, SYSTEM_INT_FACTOR, &dummy);
263 if (!ret) 305 if (!ret)
264 ret = m5mols_write(sd, SYSTEM_INT_ENABLE, reg & ~mask); 306 ret = m5mols_write(sd, SYSTEM_INT_ENABLE, reg & ~mask);
265 return ret; 307 return ret;
@@ -271,7 +313,7 @@ int m5mols_enable_interrupt(struct v4l2_subdev *sd, u32 reg)
271 * It always accompanies a little delay changing the M-5MOLS mode, so it is 313 * It always accompanies a little delay changing the M-5MOLS mode, so it is
272 * needed checking current busy status to guarantee right mode. 314 * needed checking current busy status to guarantee right mode.
273 */ 315 */
274static int m5mols_reg_mode(struct v4l2_subdev *sd, u32 mode) 316static int m5mols_reg_mode(struct v4l2_subdev *sd, u8 mode)
275{ 317{
276 int ret = m5mols_write(sd, SYSTEM_SYSMODE, mode); 318 int ret = m5mols_write(sd, SYSTEM_SYSMODE, mode);
277 319
@@ -286,16 +328,16 @@ static int m5mols_reg_mode(struct v4l2_subdev *sd, u32 mode)
286 * can be guaranteed only when the sensor is operating in mode which which 328 * can be guaranteed only when the sensor is operating in mode which which
287 * a command belongs to. 329 * a command belongs to.
288 */ 330 */
289int m5mols_mode(struct m5mols_info *info, u32 mode) 331int m5mols_mode(struct m5mols_info *info, u8 mode)
290{ 332{
291 struct v4l2_subdev *sd = &info->sd; 333 struct v4l2_subdev *sd = &info->sd;
292 int ret = -EINVAL; 334 int ret = -EINVAL;
293 u32 reg; 335 u8 reg;
294 336
295 if (mode < REG_PARAMETER && mode > REG_CAPTURE) 337 if (mode < REG_PARAMETER && mode > REG_CAPTURE)
296 return ret; 338 return ret;
297 339
298 ret = m5mols_read(sd, SYSTEM_SYSMODE, &reg); 340 ret = m5mols_read_u8(sd, SYSTEM_SYSMODE, &reg);
299 if ((!ret && reg == mode) || ret) 341 if ((!ret && reg == mode) || ret)
300 return ret; 342 return ret;
301 343
@@ -344,41 +386,37 @@ int m5mols_mode(struct m5mols_info *info, u32 mode)
344static int m5mols_get_version(struct v4l2_subdev *sd) 386static int m5mols_get_version(struct v4l2_subdev *sd)
345{ 387{
346 struct m5mols_info *info = to_m5mols(sd); 388 struct m5mols_info *info = to_m5mols(sd);
347 union { 389 struct m5mols_version *ver = &info->ver;
348 struct m5mols_version ver; 390 u8 *str = ver->str;
349 u8 bytes[VERSION_SIZE]; 391 int i;
350 } version;
351 u32 *value;
352 u8 cmd = CAT0_VER_CUSTOMER;
353 int ret; 392 int ret;
354 393
355 do { 394 ret = m5mols_read_u8(sd, SYSTEM_VER_CUSTOMER, &ver->customer);
356 value = (u32 *)&version.bytes[cmd]; 395 if (!ret)
357 ret = m5mols_read(sd, SYSTEM_CMD(cmd), value); 396 ret = m5mols_read_u8(sd, SYSTEM_VER_PROJECT, &ver->project);
358 if (ret) 397 if (!ret)
359 return ret; 398 ret = m5mols_read_u16(sd, SYSTEM_VER_FIRMWARE, &ver->fw);
360 } while (cmd++ != CAT0_VER_AWB); 399 if (!ret)
400 ret = m5mols_read_u16(sd, SYSTEM_VER_HARDWARE, &ver->hw);
401 if (!ret)
402 ret = m5mols_read_u16(sd, SYSTEM_VER_PARAMETER, &ver->param);
403 if (!ret)
404 ret = m5mols_read_u16(sd, SYSTEM_VER_AWB, &ver->awb);
405 if (!ret)
406 ret = m5mols_read_u8(sd, AF_VERSION, &ver->af);
407 if (ret)
408 return ret;
361 409
362 do { 410 for (i = 0; i < VERSION_STRING_SIZE; i++) {
363 value = (u32 *)&version.bytes[cmd]; 411 ret = m5mols_read_u8(sd, SYSTEM_VER_STRING, &str[i]);
364 ret = m5mols_read(sd, SYSTEM_VER_STRING, value);
365 if (ret) 412 if (ret)
366 return ret; 413 return ret;
367 if (cmd >= VERSION_SIZE - 1) 414 }
368 return -EINVAL;
369 } while (version.bytes[cmd++]);
370
371 value = (u32 *)&version.bytes[cmd];
372 ret = m5mols_read(sd, AF_VERSION, value);
373 if (ret)
374 return ret;
375 415
376 /* store version information swapped for being readable */ 416 ver->fw = be16_to_cpu(ver->fw);
377 info->ver = version.ver; 417 ver->hw = be16_to_cpu(ver->hw);
378 info->ver.fw = be16_to_cpu(info->ver.fw); 418 ver->param = be16_to_cpu(ver->param);
379 info->ver.hw = be16_to_cpu(info->ver.hw); 419 ver->awb = be16_to_cpu(ver->awb);
380 info->ver.param = be16_to_cpu(info->ver.param);
381 info->ver.awb = be16_to_cpu(info->ver.awb);
382 420
383 v4l2_info(sd, "Manufacturer\t[%s]\n", 421 v4l2_info(sd, "Manufacturer\t[%s]\n",
384 is_manufacturer(info, REG_SAMSUNG_ELECTRO) ? 422 is_manufacturer(info, REG_SAMSUNG_ELECTRO) ?
@@ -722,7 +760,7 @@ static int m5mols_init_controls(struct m5mols_info *info)
722 int ret; 760 int ret;
723 761
724 /* Determine value's range & step of controls for various FW version */ 762 /* Determine value's range & step of controls for various FW version */
725 ret = m5mols_read(sd, AE_MAX_GAIN_MON, (u32 *)&max_exposure); 763 ret = m5mols_read_u16(sd, AE_MAX_GAIN_MON, &max_exposure);
726 if (!ret) 764 if (!ret)
727 step_zoom = is_manufacturer(info, REG_SAMSUNG_OPTICS) ? 31 : 1; 765 step_zoom = is_manufacturer(info, REG_SAMSUNG_OPTICS) ? 31 : 1;
728 if (ret) 766 if (ret)
@@ -842,18 +880,18 @@ static void m5mols_irq_work(struct work_struct *work)
842 struct m5mols_info *info = 880 struct m5mols_info *info =
843 container_of(work, struct m5mols_info, work_irq); 881 container_of(work, struct m5mols_info, work_irq);
844 struct v4l2_subdev *sd = &info->sd; 882 struct v4l2_subdev *sd = &info->sd;
845 u32 reg; 883 u8 reg;
846 int ret; 884 int ret;
847 885
848 if (!is_powered(info) || 886 if (!is_powered(info) ||
849 m5mols_read(sd, SYSTEM_INT_FACTOR, &info->interrupt)) 887 m5mols_read_u8(sd, SYSTEM_INT_FACTOR, &info->interrupt))
850 return; 888 return;
851 889
852 switch (info->interrupt & REG_INT_MASK) { 890 switch (info->interrupt & REG_INT_MASK) {
853 case REG_INT_AF: 891 case REG_INT_AF:
854 if (!is_available_af(info)) 892 if (!is_available_af(info))
855 break; 893 break;
856 ret = m5mols_read(sd, AF_STATUS, &reg); 894 ret = m5mols_read_u8(sd, AF_STATUS, &reg);
857 v4l2_dbg(2, m5mols_debug, sd, "AF %s\n", 895 v4l2_dbg(2, m5mols_debug, sd, "AF %s\n",
858 reg == REG_AF_FAIL ? "Failed" : 896 reg == REG_AF_FAIL ? "Failed" :
859 reg == REG_AF_SUCCESS ? "Success" : 897 reg == REG_AF_SUCCESS ? "Success" :
diff --git a/drivers/media/video/m5mols/m5mols_reg.h b/drivers/media/video/m5mols/m5mols_reg.h
index b83e36fc6ac6..c755bd6edfe9 100644
--- a/drivers/media/video/m5mols/m5mols_reg.h
+++ b/drivers/media/video/m5mols/m5mols_reg.h
@@ -2,10 +2,10 @@
2 * Register map for M-5MOLS 8M Pixel camera sensor with ISP 2 * Register map for M-5MOLS 8M Pixel camera sensor with ISP
3 * 3 *
4 * Copyright (C) 2011 Samsung Electronics Co., Ltd. 4 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
5 * Author: HeungJun Kim, riverful.kim@samsung.com 5 * Author: HeungJun Kim <riverful.kim@samsung.com>
6 * 6 *
7 * Copyright (C) 2009 Samsung Electronics Co., Ltd. 7 * Copyright (C) 2009 Samsung Electronics Co., Ltd.
8 * Author: Dongsoo Nathaniel Kim, dongsoo45.kim@samsung.com 8 * Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -56,13 +56,24 @@
56 * more specific contents, see definition if file m5mols.h. 56 * more specific contents, see definition if file m5mols.h.
57 */ 57 */
58#define CAT0_VER_CUSTOMER 0x00 /* customer version */ 58#define CAT0_VER_CUSTOMER 0x00 /* customer version */
59#define CAT0_VER_AWB 0x09 /* Auto WB version */ 59#define CAT0_VER_PROJECT 0x01 /* project version */
60#define CAT0_VER_FIRMWARE 0x02 /* Firmware version */
61#define CAT0_VER_HARDWARE 0x04 /* Hardware version */
62#define CAT0_VER_PARAMETER 0x06 /* Parameter version */
63#define CAT0_VER_AWB 0x08 /* Auto WB version */
60#define CAT0_VER_STRING 0x0a /* string including M-5MOLS */ 64#define CAT0_VER_STRING 0x0a /* string including M-5MOLS */
61#define CAT0_SYSMODE 0x0b /* SYSTEM mode register */ 65#define CAT0_SYSMODE 0x0b /* SYSTEM mode register */
62#define CAT0_STATUS 0x0c /* SYSTEM mode status register */ 66#define CAT0_STATUS 0x0c /* SYSTEM mode status register */
63#define CAT0_INT_FACTOR 0x10 /* interrupt pending register */ 67#define CAT0_INT_FACTOR 0x10 /* interrupt pending register */
64#define CAT0_INT_ENABLE 0x11 /* interrupt enable register */ 68#define CAT0_INT_ENABLE 0x11 /* interrupt enable register */
65 69
70#define SYSTEM_VER_CUSTOMER I2C_REG(CAT_SYSTEM, CAT0_VER_CUSTOMER, 1)
71#define SYSTEM_VER_PROJECT I2C_REG(CAT_SYSTEM, CAT0_VER_PROJECT, 1)
72#define SYSTEM_VER_FIRMWARE I2C_REG(CAT_SYSTEM, CAT0_VER_FIRMWARE, 2)
73#define SYSTEM_VER_HARDWARE I2C_REG(CAT_SYSTEM, CAT0_VER_HARDWARE, 2)
74#define SYSTEM_VER_PARAMETER I2C_REG(CAT_SYSTEM, CAT0_VER_PARAMETER, 2)
75#define SYSTEM_VER_AWB I2C_REG(CAT_SYSTEM, CAT0_VER_AWB, 2)
76
66#define SYSTEM_SYSMODE I2C_REG(CAT_SYSTEM, CAT0_SYSMODE, 1) 77#define SYSTEM_SYSMODE I2C_REG(CAT_SYSTEM, CAT0_SYSMODE, 1)
67#define REG_SYSINIT 0x00 /* SYSTEM mode */ 78#define REG_SYSINIT 0x00 /* SYSTEM mode */
68#define REG_PARAMETER 0x01 /* PARAMETER mode */ 79#define REG_PARAMETER 0x01 /* PARAMETER mode */
@@ -382,8 +393,8 @@
382#define REG_CAP_START_MAIN 0x01 393#define REG_CAP_START_MAIN 0x01
383#define REG_CAP_START_THUMB 0x03 394#define REG_CAP_START_THUMB 0x03
384 395
385#define CAPC_IMAGE_SIZE I2C_REG(CAT_CAPT_CTRL, CATC_CAP_IMAGE_SIZE, 1) 396#define CAPC_IMAGE_SIZE I2C_REG(CAT_CAPT_CTRL, CATC_CAP_IMAGE_SIZE, 4)
386#define CAPC_THUMB_SIZE I2C_REG(CAT_CAPT_CTRL, CATC_CAP_THUMB_SIZE, 1) 397#define CAPC_THUMB_SIZE I2C_REG(CAT_CAPT_CTRL, CATC_CAP_THUMB_SIZE, 4)
387 398
388/* 399/*
389 * Category F - Flash 400 * Category F - Flash