diff options
author | Erik Andrén <erik.andren@gmail.com> | 2008-11-26 11:15:35 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-12-30 06:39:52 -0500 |
commit | e7a7f5103bddf2491760677cdd715a865b889072 (patch) | |
tree | 06148fd9af034bee748961491170ec7ac2e7f27a /drivers/media/video/gspca | |
parent | fce65f6515f049dea9451afaa0e85af01aecd190 (diff) |
V4L/DVB (10015): gspca - m5602: Add initial read sensor implementation
Signed-off-by: Erik Andrén <erik.andren@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_bridge.h | 3 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_core.c | 36 |
2 files changed, 39 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_bridge.h b/drivers/media/video/gspca/m5602/m5602_bridge.h index 51376e2a902d..a3f3b7a0c7e7 100644 --- a/drivers/media/video/gspca/m5602/m5602_bridge.h +++ b/drivers/media/video/gspca/m5602/m5602_bridge.h | |||
@@ -136,4 +136,7 @@ int m5602_write_bridge( | |||
136 | int m5602_write_sensor(struct sd *sd, const u8 address, | 136 | int m5602_write_sensor(struct sd *sd, const u8 address, |
137 | u8 *i2c_data, const u8 len); | 137 | u8 *i2c_data, const u8 len); |
138 | 138 | ||
139 | int m5602_read_sensor(struct sd *sd, const u8 address, | ||
140 | u8 *i2c_data, const u8 len); | ||
141 | |||
139 | #endif | 142 | #endif |
diff --git a/drivers/media/video/gspca/m5602/m5602_core.c b/drivers/media/video/gspca/m5602/m5602_core.c index d69e3c4ff97d..aaba42058181 100644 --- a/drivers/media/video/gspca/m5602/m5602_core.c +++ b/drivers/media/video/gspca/m5602/m5602_core.c | |||
@@ -80,6 +80,42 @@ int m5602_write_bridge(struct sd *sd, u8 address, u8 i2c_data) | |||
80 | return (err < 0) ? err : 0; | 80 | return (err < 0) ? err : 0; |
81 | } | 81 | } |
82 | 82 | ||
83 | int m5602_read_sensor(struct sd *sd, const u8 address, | ||
84 | u8 *i2c_data, const u8 len) | ||
85 | { | ||
86 | int err, i; | ||
87 | |||
88 | do { | ||
89 | err = m5602_read_bridge(sd, M5602_XB_I2C_STATUS, i2c_data); | ||
90 | } while ((*i2c_data & I2C_BUSY) && !err); | ||
91 | |||
92 | err = m5602_write_bridge(sd, M5602_XB_I2C_DEV_ADDR, | ||
93 | sd->sensor->i2c_slave_id); | ||
94 | if (err < 0) | ||
95 | goto out; | ||
96 | |||
97 | err = m5602_write_bridge(sd, M5602_XB_I2C_REG_ADDR, address); | ||
98 | if (err < 0) | ||
99 | goto out; | ||
100 | |||
101 | err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 0x10 + len); | ||
102 | if (err < 0) | ||
103 | goto out; | ||
104 | |||
105 | err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 0x08); | ||
106 | if (err < 0) | ||
107 | goto out; | ||
108 | |||
109 | for (i = 0; (i < len) && !err; i++) { | ||
110 | err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); | ||
111 | |||
112 | PDEBUG(D_CONF, "Reading sensor register " | ||
113 | "0x%x containing 0x%x ", address, *i2c_data); | ||
114 | } | ||
115 | out: | ||
116 | return err; | ||
117 | } | ||
118 | |||
83 | int m5602_write_sensor(struct sd *sd, const u8 address, | 119 | int m5602_write_sensor(struct sd *sd, const u8 address, |
84 | u8 *i2c_data, const u8 len) | 120 | u8 *i2c_data, const u8 len) |
85 | { | 121 | { |