Commit 4a7b76f0 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] ov772x: Add ov772x_read() and ov772x_write() functions

And use them instead of calling SMBus access functions directly.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 47de502b
...@@ -530,13 +530,21 @@ static struct ov772x_priv *to_ov772x(struct v4l2_subdev *sd) ...@@ -530,13 +530,21 @@ static struct ov772x_priv *to_ov772x(struct v4l2_subdev *sd)
return container_of(sd, struct ov772x_priv, subdev); return container_of(sd, struct ov772x_priv, subdev);
} }
static inline int ov772x_read(struct i2c_client *client, u8 addr)
{
return i2c_smbus_read_byte_data(client, addr);
}
static inline int ov772x_write(struct i2c_client *client, u8 addr, u8 value)
{
return i2c_smbus_write_byte_data(client, addr, value);
}
static int ov772x_write_array(struct i2c_client *client, static int ov772x_write_array(struct i2c_client *client,
const struct regval_list *vals) const struct regval_list *vals)
{ {
while (vals->reg_num != 0xff) { while (vals->reg_num != 0xff) {
int ret = i2c_smbus_write_byte_data(client, int ret = ov772x_write(client, vals->reg_num, vals->value);
vals->reg_num,
vals->value);
if (ret < 0) if (ret < 0)
return ret; return ret;
vals++; vals++;
...@@ -544,24 +552,22 @@ static int ov772x_write_array(struct i2c_client *client, ...@@ -544,24 +552,22 @@ static int ov772x_write_array(struct i2c_client *client,
return 0; return 0;
} }
static int ov772x_mask_set(struct i2c_client *client, static int ov772x_mask_set(struct i2c_client *client, u8 command, u8 mask,
u8 command, u8 set)
u8 mask,
u8 set)
{ {
s32 val = i2c_smbus_read_byte_data(client, command); s32 val = ov772x_read(client, command);
if (val < 0) if (val < 0)
return val; return val;
val &= ~mask; val &= ~mask;
val |= set & mask; val |= set & mask;
return i2c_smbus_write_byte_data(client, command, val); return ov772x_write(client, command, val);
} }
static int ov772x_reset(struct i2c_client *client) static int ov772x_reset(struct i2c_client *client)
{ {
int ret = i2c_smbus_write_byte_data(client, COM7, SCCB_RESET); int ret = ov772x_write(client, COM7, SCCB_RESET);
msleep(1); msleep(1);
return ret; return ret;
} }
...@@ -656,7 +662,7 @@ static int ov772x_g_register(struct v4l2_subdev *sd, ...@@ -656,7 +662,7 @@ static int ov772x_g_register(struct v4l2_subdev *sd,
if (reg->reg > 0xff) if (reg->reg > 0xff)
return -EINVAL; return -EINVAL;
ret = i2c_smbus_read_byte_data(client, reg->reg); ret = ov772x_read(client, reg->reg);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -674,7 +680,7 @@ static int ov772x_s_register(struct v4l2_subdev *sd, ...@@ -674,7 +680,7 @@ static int ov772x_s_register(struct v4l2_subdev *sd,
reg->val > 0xff) reg->val > 0xff)
return -EINVAL; return -EINVAL;
return i2c_smbus_write_byte_data(client, reg->reg, reg->val); return ov772x_write(client, reg->reg, reg->val);
} }
#endif #endif
...@@ -946,8 +952,8 @@ static int ov772x_video_probe(struct ov772x_priv *priv) ...@@ -946,8 +952,8 @@ static int ov772x_video_probe(struct ov772x_priv *priv)
/* /*
* check and show product ID and manufacturer ID * check and show product ID and manufacturer ID
*/ */
pid = i2c_smbus_read_byte_data(client, PID); pid = ov772x_read(client, PID);
ver = i2c_smbus_read_byte_data(client, VER); ver = ov772x_read(client, VER);
switch (VERSION(pid, ver)) { switch (VERSION(pid, ver)) {
case OV7720: case OV7720:
...@@ -970,8 +976,8 @@ static int ov772x_video_probe(struct ov772x_priv *priv) ...@@ -970,8 +976,8 @@ static int ov772x_video_probe(struct ov772x_priv *priv)
devname, devname,
pid, pid,
ver, ver,
i2c_smbus_read_byte_data(client, MIDH), ov772x_read(client, MIDH),
i2c_smbus_read_byte_data(client, MIDL)); ov772x_read(client, MIDL));
ret = v4l2_ctrl_handler_setup(&priv->hdl); ret = v4l2_ctrl_handler_setup(&priv->hdl);
done: done:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment