Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164207
b: refs/heads/master
c: c41deba
h: refs/heads/master
i:
  164205: dbfe2bb
  164203: 5e7134d
  164199: be0fbfe
  164191: 32a468c
v: v3
  • Loading branch information
Guennadi Liakhovetski authored and Mauro Carvalho Chehab committed Sep 19, 2009
1 parent b4d8d7e commit 446de1d
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2639ead140aa7063188b6599a1a7398d60db2712
refs/heads/master: c41debafc6e396a8e15f1f017aec7c0cf67e1b54
43 changes: 32 additions & 11 deletions trunk/arch/sh/boards/board-ap325rxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ static int camera_set_capture(struct soc_camera_platform_info *info,
return ret;
}

static int ap325rxa_camera_add(struct soc_camera_link *icl, struct device *dev);
static void ap325rxa_camera_del(struct soc_camera_link *icl);

static struct soc_camera_platform_info camera_info = {
.iface = 0,
.format_name = "UYVY",
Expand All @@ -323,6 +326,10 @@ static struct soc_camera_platform_info camera_info = {
.bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8,
.set_capture = camera_set_capture,
.link = {
.add_device = ap325rxa_camera_add,
.del_device = ap325rxa_camera_del,
},
};

static struct platform_device camera_device = {
Expand All @@ -332,15 +339,20 @@ static struct platform_device camera_device = {
},
};

static int __init camera_setup(void)
static int ap325rxa_camera_add(struct soc_camera_link *icl,
struct device *dev)
{
if (camera_probe() > 0)
platform_device_register(&camera_device);
if (icl != &camera_info.link || camera_probe() <= 0)
return -ENODEV;

return 0;
return platform_device_register(&camera_device);
}
late_initcall(camera_setup);

static void ap325rxa_camera_del(struct soc_camera_link *icl)
{
if (icl == &camera_info.link)
platform_device_unregister(&camera_device);
}
#endif /* CONFIG_I2C */

static int ov7725_power(struct device *dev, int mode)
Expand Down Expand Up @@ -423,11 +435,19 @@ static struct ov772x_camera_info ov7725_info = {
},
};

static struct platform_device ap325rxa_camera = {
.name = "soc-camera-pdrv",
.id = 0,
.dev = {
.platform_data = &ov7725_info.link,
static struct platform_device ap325rxa_camera[] = {
{
.name = "soc-camera-pdrv",
.id = 0,
.dev = {
.platform_data = &ov7725_info.link,
},
}, {
.name = "soc-camera-pdrv",
.id = 1,
.dev = {
.platform_data = &camera_info.link,
},
},
};

Expand All @@ -438,7 +458,8 @@ static struct platform_device *ap325rxa_devices[] __initdata = {
&ceu_device,
&nand_flash_device,
&sdcard_cn3_device,
&ap325rxa_camera,
&ap325rxa_camera[0],
&ap325rxa_camera[1],
};

static struct spi_board_info ap325rxa_spi_devices[] = {
Expand Down
61 changes: 46 additions & 15 deletions trunk/drivers/media/video/soc_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,45 +1165,76 @@ 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)
#ifdef CONFIG_I2C_BOARDINFO
static int soc_camera_init_i2c(struct platform_device *pdev,
struct soc_camera_link *icl)
{
struct soc_camera_link *icl = pdev->dev.platform_data;
struct i2c_adapter *adap;
struct i2c_client *client;
struct i2c_adapter *adap = i2c_get_adapter(icl->i2c_adapter_id);
int ret;

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;
ret = -ENODEV;
dev_err(&pdev->dev, "Cannot get adapter #%d. No driver?\n",
icl->i2c_adapter_id);
goto ei2cga;
}

icl->board_info->platform_data = icl;
client = i2c_new_device(adap, icl->board_info);
if (!client) {
i2c_put_adapter(adap);
return -ENOMEM;
ret = -ENOMEM;
goto ei2cnd;
}

platform_set_drvdata(pdev, client);

return 0;
ei2cnd:
i2c_put_adapter(adap);
ei2cga:
return ret;
}

static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev)
static void soc_camera_free_i2c(struct platform_device *pdev)
{
struct i2c_client *client = platform_get_drvdata(pdev);

if (!client)
return -ENODEV;
return;

i2c_unregister_device(client);
i2c_put_adapter(client->adapter);
}
#else
#define soc_camera_init_i2c(d, icl) (-ENODEV)
#define soc_camera_free_i2c(d) do {} while (0)
#endif

static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev)
{
struct soc_camera_link *icl = pdev->dev.platform_data;

if (!icl)
return -EINVAL;

if (icl->board_info)
return soc_camera_init_i2c(pdev, icl);
else if (!icl->add_device || !icl->del_device)
return -EINVAL;

/* &pdev->dev will become &icd->dev */
return icl->add_device(icl, &pdev->dev);
}

static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev)
{
struct soc_camera_link *icl = pdev->dev.platform_data;

if (icl->board_info)
soc_camera_free_i2c(pdev);
else
icl->del_device(icl);
return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions trunk/include/media/soc_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ struct soc_camera_link {
int i2c_adapter_id;
struct i2c_board_info *board_info;
const char *module_name;
/*
* For non-I2C devices platform platform has to provide methods to
* add a device to the system and to remove
*/
int (*add_device)(struct soc_camera_link *, struct device *);
void (*del_device)(struct soc_camera_link *);
/* Optional callbacks to power on or off and reset the sensor */
int (*power)(struct device *, int);
int (*reset)(struct device *);
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/media/soc_camera_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define __SOC_CAMERA_H__

#include <linux/videodev2.h>
#include <media/soc_camera.h>

struct soc_camera_platform_info {
int iface;
Expand All @@ -21,6 +22,7 @@ struct soc_camera_platform_info {
unsigned long bus_param;
void (*power)(int);
int (*set_capture)(struct soc_camera_platform_info *info, int enable);
struct soc_camera_link link;
};

#endif /* __SOC_CAMERA_H__ */

0 comments on commit 446de1d

Please sign in to comment.