diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-07-18 09:58:23 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-15 16:11:29 -0400 |
commit | 4a7b76f0725d1325334ae0063134544315b3bf6c (patch) | |
tree | f05296e4869ed9fed17b2c50815dd5a8adee73ce | |
parent | 47de502b04612824e9293ed0474882b461be49d9 (diff) |
[media] ov772x: Add ov772x_read() and ov772x_write() functions
And use them instead of calling SMBus access functions directly.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/i2c/soc_camera/ov772x.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c index 2b68f04578d2..4cd9b1c2f35d 100644 --- a/drivers/media/i2c/soc_camera/ov772x.c +++ b/drivers/media/i2c/soc_camera/ov772x.c | |||
@@ -530,13 +530,21 @@ static struct ov772x_priv *to_ov772x(struct v4l2_subdev *sd) | |||
530 | return container_of(sd, struct ov772x_priv, subdev); | 530 | return container_of(sd, struct ov772x_priv, subdev); |
531 | } | 531 | } |
532 | 532 | ||
533 | static inline int ov772x_read(struct i2c_client *client, u8 addr) | ||
534 | { | ||
535 | return i2c_smbus_read_byte_data(client, addr); | ||
536 | } | ||
537 | |||
538 | static inline int ov772x_write(struct i2c_client *client, u8 addr, u8 value) | ||
539 | { | ||
540 | return i2c_smbus_write_byte_data(client, addr, value); | ||
541 | } | ||
542 | |||
533 | static int ov772x_write_array(struct i2c_client *client, | 543 | static int ov772x_write_array(struct i2c_client *client, |
534 | const struct regval_list *vals) | 544 | const struct regval_list *vals) |
535 | { | 545 | { |
536 | while (vals->reg_num != 0xff) { | 546 | while (vals->reg_num != 0xff) { |
537 | int ret = i2c_smbus_write_byte_data(client, | 547 | int ret = ov772x_write(client, vals->reg_num, vals->value); |
538 | vals->reg_num, | ||
539 | vals->value); | ||
540 | if (ret < 0) | 548 | if (ret < 0) |
541 | return ret; | 549 | return ret; |
542 | vals++; | 550 | vals++; |
@@ -544,24 +552,22 @@ static int ov772x_write_array(struct i2c_client *client, | |||
544 | return 0; | 552 | return 0; |
545 | } | 553 | } |
546 | 554 | ||
547 | static int ov772x_mask_set(struct i2c_client *client, | 555 | static int ov772x_mask_set(struct i2c_client *client, u8 command, u8 mask, |
548 | u8 command, | 556 | u8 set) |
549 | u8 mask, | ||
550 | u8 set) | ||
551 | { | 557 | { |
552 | s32 val = i2c_smbus_read_byte_data(client, command); | 558 | s32 val = ov772x_read(client, command); |
553 | if (val < 0) | 559 | if (val < 0) |
554 | return val; | 560 | return val; |
555 | 561 | ||
556 | val &= ~mask; | 562 | val &= ~mask; |
557 | val |= set & mask; | 563 | val |= set & mask; |
558 | 564 | ||
559 | return i2c_smbus_write_byte_data(client, command, val); | 565 | return ov772x_write(client, command, val); |
560 | } | 566 | } |
561 | 567 | ||
562 | static int ov772x_reset(struct i2c_client *client) | 568 | static int ov772x_reset(struct i2c_client *client) |
563 | { | 569 | { |
564 | int ret = i2c_smbus_write_byte_data(client, COM7, SCCB_RESET); | 570 | int ret = ov772x_write(client, COM7, SCCB_RESET); |
565 | msleep(1); | 571 | msleep(1); |
566 | return ret; | 572 | return ret; |
567 | } | 573 | } |
@@ -656,7 +662,7 @@ static int ov772x_g_register(struct v4l2_subdev *sd, | |||
656 | if (reg->reg > 0xff) | 662 | if (reg->reg > 0xff) |
657 | return -EINVAL; | 663 | return -EINVAL; |
658 | 664 | ||
659 | ret = i2c_smbus_read_byte_data(client, reg->reg); | 665 | ret = ov772x_read(client, reg->reg); |
660 | if (ret < 0) | 666 | if (ret < 0) |
661 | return ret; | 667 | return ret; |
662 | 668 | ||
@@ -674,7 +680,7 @@ static int ov772x_s_register(struct v4l2_subdev *sd, | |||
674 | reg->val > 0xff) | 680 | reg->val > 0xff) |
675 | return -EINVAL; | 681 | return -EINVAL; |
676 | 682 | ||
677 | return i2c_smbus_write_byte_data(client, reg->reg, reg->val); | 683 | return ov772x_write(client, reg->reg, reg->val); |
678 | } | 684 | } |
679 | #endif | 685 | #endif |
680 | 686 | ||
@@ -946,8 +952,8 @@ static int ov772x_video_probe(struct ov772x_priv *priv) | |||
946 | /* | 952 | /* |
947 | * check and show product ID and manufacturer ID | 953 | * check and show product ID and manufacturer ID |
948 | */ | 954 | */ |
949 | pid = i2c_smbus_read_byte_data(client, PID); | 955 | pid = ov772x_read(client, PID); |
950 | ver = i2c_smbus_read_byte_data(client, VER); | 956 | ver = ov772x_read(client, VER); |
951 | 957 | ||
952 | switch (VERSION(pid, ver)) { | 958 | switch (VERSION(pid, ver)) { |
953 | case OV7720: | 959 | case OV7720: |
@@ -970,8 +976,8 @@ static int ov772x_video_probe(struct ov772x_priv *priv) | |||
970 | devname, | 976 | devname, |
971 | pid, | 977 | pid, |
972 | ver, | 978 | ver, |
973 | i2c_smbus_read_byte_data(client, MIDH), | 979 | ov772x_read(client, MIDH), |
974 | i2c_smbus_read_byte_data(client, MIDL)); | 980 | ov772x_read(client, MIDL)); |
975 | ret = v4l2_ctrl_handler_setup(&priv->hdl); | 981 | ret = v4l2_ctrl_handler_setup(&priv->hdl); |
976 | 982 | ||
977 | done: | 983 | done: |