2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-18 18:23:53 +08:00

V4L/DVB (11705): soc-camera: prepare for the platform driver conversion

Add a platform driver to soc_camera.c. This way we preserve backwards
compatibility with existing platforms and can start converting them one by one
to the new platform-device soc-camera interface.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Guennadi Liakhovetski 2009-05-07 13:25:32 -03:00 committed by Mauro Carvalho Chehab
parent f4672dffa1
commit 0fd327bd0d
2 changed files with 73 additions and 7 deletions

View File

@ -16,19 +16,21 @@
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/vmalloc.h>
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-dev.h>
#include <media/videobuf-core.h>
#include <media/soc_camera.h>
#include <media/v4l2-common.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-ioctl.h>
#include <media/videobuf-core.h>
/* Default to VGA resolution */
#define DEFAULT_WIDTH 640
@ -1159,6 +1161,57 @@ void soc_camera_video_stop(struct soc_camera_device *icd)
}
EXPORT_SYMBOL(soc_camera_video_stop);
static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev)
{
struct soc_camera_link *icl = pdev->dev.platform_data;
struct i2c_adapter *adap;
struct i2c_client *client;
if (!icl)
return -EINVAL;
adap = i2c_get_adapter(icl->i2c_adapter_id);
if (!adap) {
dev_warn(&pdev->dev, "Cannot get adapter #%d. No driver?\n",
icl->i2c_adapter_id);
/* -ENODEV and -ENXIO do not produce an error on probe()... */
return -ENOENT;
}
icl->board_info->platform_data = icl;
client = i2c_new_device(adap, icl->board_info);
if (!client) {
i2c_put_adapter(adap);
return -ENOMEM;
}
platform_set_drvdata(pdev, client);
return 0;
}
static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev)
{
struct i2c_client *client = platform_get_drvdata(pdev);
if (!client)
return -ENODEV;
i2c_unregister_device(client);
i2c_put_adapter(client->adapter);
return 0;
}
static struct platform_driver __refdata soc_camera_pdrv = {
.probe = soc_camera_pdrv_probe,
.remove = __exit_p(soc_camera_pdrv_remove),
.driver = {
.name = "soc-camera-pdrv",
.owner = THIS_MODULE,
},
};
static int __init soc_camera_init(void)
{
int ret = bus_register(&soc_camera_bus_type);
@ -1168,8 +1221,14 @@ static int __init soc_camera_init(void)
if (ret)
goto edrvr;
ret = platform_driver_register(&soc_camera_pdrv);
if (ret)
goto epdr;
return 0;
epdr:
driver_unregister(&ic_drv);
edrvr:
bus_unregister(&soc_camera_bus_type);
return ret;
@ -1177,6 +1236,7 @@ edrvr:
static void __exit soc_camera_exit(void)
{
platform_driver_unregister(&soc_camera_pdrv);
driver_unregister(&ic_drv);
bus_unregister(&soc_camera_bus_type);
}
@ -1187,3 +1247,4 @@ module_exit(soc_camera_exit);
MODULE_DESCRIPTION("Image capture bus driver");
MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:soc-camera-pdrv");

View File

@ -92,11 +92,16 @@ struct soc_camera_host_ops {
#define SOCAM_SENSOR_INVERT_VSYNC (1 << 3)
#define SOCAM_SENSOR_INVERT_DATA (1 << 4)
struct i2c_board_info;
struct soc_camera_link {
/* Camera bus id, used to match a camera and a bus */
int bus_id;
/* Per camera SOCAM_SENSOR_* bus flags */
unsigned long flags;
int i2c_adapter_id;
struct i2c_board_info *board_info;
const char *module_name;
/* Optional callbacks to power on or off and reset the sensor */
int (*power)(struct device *, int);
int (*reset)(struct device *);