diff options
author | Erik Andrén <erik.andren@gmail.com> | 2008-11-26 02:01:40 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-12-30 06:39:51 -0500 |
commit | 4b8f393391c0492ebec1277d073203392c90677d (patch) | |
tree | 9cb9ab0899e3b3b15dcfad82616213e292603a07 /drivers | |
parent | d58626c21d8cafe56eb8cdf883d1d6710dc3fc81 (diff) |
V4L/DVB (10012): m5602: Start to unify read/write sensor functions
First step into unifying the read and write sensor functions
Signed-off-by: Erik Andrén <erik.andren@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_core.c | 44 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_mt9m111.h | 1 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_ov9650.h | 1 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_po1030.h | 1 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_s5k4aa.h | 1 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_s5k83a.h | 1 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_sensor.h | 3 |
7 files changed, 52 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_core.c b/drivers/media/video/gspca/m5602/m5602_core.c index b2a5ad4fea59..d69e3c4ff97d 100644 --- a/drivers/media/video/gspca/m5602/m5602_core.c +++ b/drivers/media/video/gspca/m5602/m5602_core.c | |||
@@ -80,6 +80,50 @@ 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_write_sensor(struct sd *sd, const u8 address, | ||
84 | u8 *i2c_data, const u8 len) | ||
85 | { | ||
86 | int err, i; | ||
87 | u8 *p; | ||
88 | struct usb_device *udev = sd->gspca_dev.dev; | ||
89 | __u8 *buf = sd->gspca_dev.usb_buf; | ||
90 | |||
91 | /* No sensor with a data width larger than 16 bits has yet been seen */ | ||
92 | if (len > sd->sensor->i2c_regW || !len) | ||
93 | return -EINVAL; | ||
94 | |||
95 | memcpy(buf, sensor_urb_skeleton, | ||
96 | sizeof(sensor_urb_skeleton)); | ||
97 | |||
98 | buf[11] = sd->sensor->i2c_slave_id; | ||
99 | buf[15] = address; | ||
100 | |||
101 | /* Special case larger sensor writes */ | ||
102 | p = buf + 16; | ||
103 | |||
104 | /* Copy a four byte write sequence for each byte to be written to */ | ||
105 | for (i = 0; i < len; i++) { | ||
106 | memcpy(p, sensor_urb_skeleton + 16, 4); | ||
107 | p[3] = i2c_data[i]; | ||
108 | p += 4; | ||
109 | PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", | ||
110 | address, i2c_data[i]); | ||
111 | } | ||
112 | |||
113 | /* Copy the tailer */ | ||
114 | memcpy(p, sensor_urb_skeleton + 20, 4); | ||
115 | |||
116 | /* Set the total length */ | ||
117 | p[3] = 0x10 + len; | ||
118 | |||
119 | err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
120 | 0x04, 0x40, 0x19, | ||
121 | 0x0000, buf, | ||
122 | 20 + len * 4, M5602_URB_MSG_TIMEOUT); | ||
123 | |||
124 | return (err < 0) ? err : 0; | ||
125 | } | ||
126 | |||
83 | /* Dump all the registers of the m5602 bridge, | 127 | /* Dump all the registers of the m5602 bridge, |
84 | unfortunately this breaks the camera until it's power cycled */ | 128 | unfortunately this breaks the camera until it's power cycled */ |
85 | static void m5602_dump_bridge(struct sd *sd) | 129 | static void m5602_dump_bridge(struct sd *sd) |
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.h b/drivers/media/video/gspca/m5602/m5602_mt9m111.h index 0fe4d6327897..2c7b2a49c44f 100644 --- a/drivers/media/video/gspca/m5602/m5602_mt9m111.h +++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.h | |||
@@ -104,6 +104,7 @@ static struct m5602_sensor mt9m111 = { | |||
104 | .name = "MT9M111", | 104 | .name = "MT9M111", |
105 | 105 | ||
106 | .i2c_slave_id = 0xba, | 106 | .i2c_slave_id = 0xba, |
107 | .i2c_regW = 2, | ||
107 | 108 | ||
108 | .probe = mt9m111_probe, | 109 | .probe = mt9m111_probe, |
109 | .init = mt9m111_init, | 110 | .init = mt9m111_init, |
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.h b/drivers/media/video/gspca/m5602/m5602_ov9650.h index 32fc440c5c13..293be3f7f761 100644 --- a/drivers/media/video/gspca/m5602/m5602_ov9650.h +++ b/drivers/media/video/gspca/m5602/m5602_ov9650.h | |||
@@ -153,6 +153,7 @@ int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val); | |||
153 | static struct m5602_sensor ov9650 = { | 153 | static struct m5602_sensor ov9650 = { |
154 | .name = "OV9650", | 154 | .name = "OV9650", |
155 | .i2c_slave_id = 0x60, | 155 | .i2c_slave_id = 0x60, |
156 | .i2c_regW = 1, | ||
156 | .probe = ov9650_probe, | 157 | .probe = ov9650_probe, |
157 | .init = ov9650_init, | 158 | .init = ov9650_init, |
158 | .power_down = ov9650_power_down, | 159 | .power_down = ov9650_power_down, |
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.h b/drivers/media/video/gspca/m5602/m5602_po1030.h index 02072ccf9258..3a49d15bd355 100644 --- a/drivers/media/video/gspca/m5602/m5602_po1030.h +++ b/drivers/media/video/gspca/m5602/m5602_po1030.h | |||
@@ -150,6 +150,7 @@ static struct m5602_sensor po1030 = { | |||
150 | .name = "PO1030", | 150 | .name = "PO1030", |
151 | 151 | ||
152 | .i2c_slave_id = 0xdc, | 152 | .i2c_slave_id = 0xdc, |
153 | .i2c_regW = 1, | ||
153 | 154 | ||
154 | .probe = po1030_probe, | 155 | .probe = po1030_probe, |
155 | .init = po1030_init, | 156 | .init = po1030_init, |
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h index 701d30292ac3..3d04ff9b264c 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h +++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h | |||
@@ -87,6 +87,7 @@ static struct m5602_sensor s5k4aa = { | |||
87 | .init = s5k4aa_init, | 87 | .init = s5k4aa_init, |
88 | .power_down = s5k4aa_power_down, | 88 | .power_down = s5k4aa_power_down, |
89 | .i2c_slave_id = 0x5a, | 89 | .i2c_slave_id = 0x5a, |
90 | .i2c_regW = 2, | ||
90 | .nctrls = 4, | 91 | .nctrls = 4, |
91 | .ctrls = { | 92 | .ctrls = { |
92 | { | 93 | { |
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.h b/drivers/media/video/gspca/m5602/m5602_s5k83a.h index 793c967875d7..6a884d73ee79 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k83a.h +++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.h | |||
@@ -69,6 +69,7 @@ static struct m5602_sensor s5k83a = { | |||
69 | .init = s5k83a_init, | 69 | .init = s5k83a_init, |
70 | .power_down = s5k83a_power_down, | 70 | .power_down = s5k83a_power_down, |
71 | .i2c_slave_id = 0x5a, | 71 | .i2c_slave_id = 0x5a, |
72 | .i2c_regW = 2, | ||
72 | .nctrls = 5, | 73 | .nctrls = 5, |
73 | .ctrls = { | 74 | .ctrls = { |
74 | { | 75 | { |
diff --git a/drivers/media/video/gspca/m5602/m5602_sensor.h b/drivers/media/video/gspca/m5602/m5602_sensor.h index c0900023680e..23c0ef9489fe 100644 --- a/drivers/media/video/gspca/m5602/m5602_sensor.h +++ b/drivers/media/video/gspca/m5602/m5602_sensor.h | |||
@@ -49,6 +49,9 @@ struct m5602_sensor { | |||
49 | /* What i2c address the sensor is connected to */ | 49 | /* What i2c address the sensor is connected to */ |
50 | u8 i2c_slave_id; | 50 | u8 i2c_slave_id; |
51 | 51 | ||
52 | /* Width of each i2c register (in bytes) */ | ||
53 | u8 i2c_regW; | ||
54 | |||
52 | /* Probes if the sensor is connected */ | 55 | /* Probes if the sensor is connected */ |
53 | int (*probe)(struct sd *sd); | 56 | int (*probe)(struct sd *sd); |
54 | 57 | ||