diff options
-rw-r--r-- | drivers/media/video/soc_camera.c | 71 | ||||
-rw-r--r-- | include/media/soc_camera.h | 5 |
2 files changed, 71 insertions, 5 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 2d341f537d54..2014e9e32b35 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -16,19 +16,21 @@ | |||
16 | * published by the Free Software Foundation. | 16 | * published by the Free Software Foundation. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/device.h> | 19 | #include <linux/device.h> |
22 | #include <linux/list.h> | ||
23 | #include <linux/err.h> | 20 | #include <linux/err.h> |
21 | #include <linux/i2c.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/list.h> | ||
24 | #include <linux/module.h> | ||
24 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/platform_device.h> | ||
25 | #include <linux/vmalloc.h> | 27 | #include <linux/vmalloc.h> |
26 | 28 | ||
29 | #include <media/soc_camera.h> | ||
27 | #include <media/v4l2-common.h> | 30 | #include <media/v4l2-common.h> |
28 | #include <media/v4l2-ioctl.h> | ||
29 | #include <media/v4l2-dev.h> | 31 | #include <media/v4l2-dev.h> |
32 | #include <media/v4l2-ioctl.h> | ||
30 | #include <media/videobuf-core.h> | 33 | #include <media/videobuf-core.h> |
31 | #include <media/soc_camera.h> | ||
32 | 34 | ||
33 | /* Default to VGA resolution */ | 35 | /* Default to VGA resolution */ |
34 | #define DEFAULT_WIDTH 640 | 36 | #define DEFAULT_WIDTH 640 |
@@ -1159,6 +1161,57 @@ void soc_camera_video_stop(struct soc_camera_device *icd) | |||
1159 | } | 1161 | } |
1160 | EXPORT_SYMBOL(soc_camera_video_stop); | 1162 | EXPORT_SYMBOL(soc_camera_video_stop); |
1161 | 1163 | ||
1164 | static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev) | ||
1165 | { | ||
1166 | struct soc_camera_link *icl = pdev->dev.platform_data; | ||
1167 | struct i2c_adapter *adap; | ||
1168 | struct i2c_client *client; | ||
1169 | |||
1170 | if (!icl) | ||
1171 | return -EINVAL; | ||
1172 | |||
1173 | adap = i2c_get_adapter(icl->i2c_adapter_id); | ||
1174 | if (!adap) { | ||
1175 | dev_warn(&pdev->dev, "Cannot get adapter #%d. No driver?\n", | ||
1176 | icl->i2c_adapter_id); | ||
1177 | /* -ENODEV and -ENXIO do not produce an error on probe()... */ | ||
1178 | return -ENOENT; | ||
1179 | } | ||
1180 | |||
1181 | icl->board_info->platform_data = icl; | ||
1182 | client = i2c_new_device(adap, icl->board_info); | ||
1183 | if (!client) { | ||
1184 | i2c_put_adapter(adap); | ||
1185 | return -ENOMEM; | ||
1186 | } | ||
1187 | |||
1188 | platform_set_drvdata(pdev, client); | ||
1189 | |||
1190 | return 0; | ||
1191 | } | ||
1192 | |||
1193 | static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev) | ||
1194 | { | ||
1195 | struct i2c_client *client = platform_get_drvdata(pdev); | ||
1196 | |||
1197 | if (!client) | ||
1198 | return -ENODEV; | ||
1199 | |||
1200 | i2c_unregister_device(client); | ||
1201 | i2c_put_adapter(client->adapter); | ||
1202 | |||
1203 | return 0; | ||
1204 | } | ||
1205 | |||
1206 | static struct platform_driver __refdata soc_camera_pdrv = { | ||
1207 | .probe = soc_camera_pdrv_probe, | ||
1208 | .remove = __exit_p(soc_camera_pdrv_remove), | ||
1209 | .driver = { | ||
1210 | .name = "soc-camera-pdrv", | ||
1211 | .owner = THIS_MODULE, | ||
1212 | }, | ||
1213 | }; | ||
1214 | |||
1162 | static int __init soc_camera_init(void) | 1215 | static int __init soc_camera_init(void) |
1163 | { | 1216 | { |
1164 | int ret = bus_register(&soc_camera_bus_type); | 1217 | int ret = bus_register(&soc_camera_bus_type); |
@@ -1168,8 +1221,14 @@ static int __init soc_camera_init(void) | |||
1168 | if (ret) | 1221 | if (ret) |
1169 | goto edrvr; | 1222 | goto edrvr; |
1170 | 1223 | ||
1224 | ret = platform_driver_register(&soc_camera_pdrv); | ||
1225 | if (ret) | ||
1226 | goto epdr; | ||
1227 | |||
1171 | return 0; | 1228 | return 0; |
1172 | 1229 | ||
1230 | epdr: | ||
1231 | driver_unregister(&ic_drv); | ||
1173 | edrvr: | 1232 | edrvr: |
1174 | bus_unregister(&soc_camera_bus_type); | 1233 | bus_unregister(&soc_camera_bus_type); |
1175 | return ret; | 1234 | return ret; |
@@ -1177,6 +1236,7 @@ edrvr: | |||
1177 | 1236 | ||
1178 | static void __exit soc_camera_exit(void) | 1237 | static void __exit soc_camera_exit(void) |
1179 | { | 1238 | { |
1239 | platform_driver_unregister(&soc_camera_pdrv); | ||
1180 | driver_unregister(&ic_drv); | 1240 | driver_unregister(&ic_drv); |
1181 | bus_unregister(&soc_camera_bus_type); | 1241 | bus_unregister(&soc_camera_bus_type); |
1182 | } | 1242 | } |
@@ -1187,3 +1247,4 @@ module_exit(soc_camera_exit); | |||
1187 | MODULE_DESCRIPTION("Image capture bus driver"); | 1247 | MODULE_DESCRIPTION("Image capture bus driver"); |
1188 | MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>"); | 1248 | MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>"); |
1189 | MODULE_LICENSE("GPL"); | 1249 | MODULE_LICENSE("GPL"); |
1250 | MODULE_ALIAS("platform:soc-camera-pdrv"); | ||
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index bef5e81d6935..23ecead35e7a 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h | |||
@@ -92,11 +92,16 @@ struct soc_camera_host_ops { | |||
92 | #define SOCAM_SENSOR_INVERT_VSYNC (1 << 3) | 92 | #define SOCAM_SENSOR_INVERT_VSYNC (1 << 3) |
93 | #define SOCAM_SENSOR_INVERT_DATA (1 << 4) | 93 | #define SOCAM_SENSOR_INVERT_DATA (1 << 4) |
94 | 94 | ||
95 | struct i2c_board_info; | ||
96 | |||
95 | struct soc_camera_link { | 97 | struct soc_camera_link { |
96 | /* Camera bus id, used to match a camera and a bus */ | 98 | /* Camera bus id, used to match a camera and a bus */ |
97 | int bus_id; | 99 | int bus_id; |
98 | /* Per camera SOCAM_SENSOR_* bus flags */ | 100 | /* Per camera SOCAM_SENSOR_* bus flags */ |
99 | unsigned long flags; | 101 | unsigned long flags; |
102 | int i2c_adapter_id; | ||
103 | struct i2c_board_info *board_info; | ||
104 | const char *module_name; | ||
100 | /* Optional callbacks to power on or off and reset the sensor */ | 105 | /* Optional callbacks to power on or off and reset the sensor */ |
101 | int (*power)(struct device *, int); | 106 | int (*power)(struct device *, int); |
102 | int (*reset)(struct device *); | 107 | int (*reset)(struct device *); |