Commit 4dbfd040 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mauro Carvalho Chehab

[media] V4L2: mx3_camera: add support for asynchronous subdevice registration

The soc-camera core does all the work on supporting asynchronous
subdevice probing, host drivers only have to pass a subdevice list to
soc-camera. Typically this list is provided by the platform.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 2bcccaec
...@@ -1144,6 +1144,7 @@ static struct soc_camera_host_ops mx3_soc_camera_host_ops = { ...@@ -1144,6 +1144,7 @@ static struct soc_camera_host_ops mx3_soc_camera_host_ops = {
static int mx3_camera_probe(struct platform_device *pdev) static int mx3_camera_probe(struct platform_device *pdev)
{ {
struct mx3_camera_pdata *pdata = pdev->dev.platform_data;
struct mx3_camera_dev *mx3_cam; struct mx3_camera_dev *mx3_cam;
struct resource *res; struct resource *res;
void __iomem *base; void __iomem *base;
...@@ -1155,6 +1156,9 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1155,6 +1156,9 @@ static int mx3_camera_probe(struct platform_device *pdev)
if (IS_ERR(base)) if (IS_ERR(base))
return PTR_ERR(base); return PTR_ERR(base);
if (!pdata)
return -EINVAL;
mx3_cam = devm_kzalloc(&pdev->dev, sizeof(*mx3_cam), GFP_KERNEL); mx3_cam = devm_kzalloc(&pdev->dev, sizeof(*mx3_cam), GFP_KERNEL);
if (!mx3_cam) { if (!mx3_cam) {
dev_err(&pdev->dev, "Could not allocate mx3 camera object\n"); dev_err(&pdev->dev, "Could not allocate mx3 camera object\n");
...@@ -1165,8 +1169,8 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1165,8 +1169,8 @@ static int mx3_camera_probe(struct platform_device *pdev)
if (IS_ERR(mx3_cam->clk)) if (IS_ERR(mx3_cam->clk))
return PTR_ERR(mx3_cam->clk); return PTR_ERR(mx3_cam->clk);
mx3_cam->pdata = pdev->dev.platform_data; mx3_cam->pdata = pdata;
mx3_cam->platform_flags = mx3_cam->pdata->flags; mx3_cam->platform_flags = pdata->flags;
if (!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_MASK)) { if (!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_MASK)) {
/* /*
* Platform hasn't set available data widths. This is bad. * Platform hasn't set available data widths. This is bad.
...@@ -1185,7 +1189,7 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1185,7 +1189,7 @@ static int mx3_camera_probe(struct platform_device *pdev)
if (mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_15) if (mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_15)
mx3_cam->width_flags |= 1 << 14; mx3_cam->width_flags |= 1 << 14;
mx3_cam->mclk = mx3_cam->pdata->mclk_10khz * 10000; mx3_cam->mclk = pdata->mclk_10khz * 10000;
if (!mx3_cam->mclk) { if (!mx3_cam->mclk) {
dev_warn(&pdev->dev, dev_warn(&pdev->dev,
"mclk_10khz == 0! Please, fix your platform data. " "mclk_10khz == 0! Please, fix your platform data. "
...@@ -1210,6 +1214,11 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1210,6 +1214,11 @@ static int mx3_camera_probe(struct platform_device *pdev)
if (IS_ERR(mx3_cam->alloc_ctx)) if (IS_ERR(mx3_cam->alloc_ctx))
return PTR_ERR(mx3_cam->alloc_ctx); return PTR_ERR(mx3_cam->alloc_ctx);
if (pdata->asd_sizes) {
soc_host->asd = pdata->asd;
soc_host->asd_sizes = pdata->asd_sizes;
}
err = soc_camera_host_register(soc_host); err = soc_camera_host_register(soc_host);
if (err) if (err)
goto ecamhostreg; goto ecamhostreg;
...@@ -1249,6 +1258,7 @@ static int mx3_camera_remove(struct platform_device *pdev) ...@@ -1249,6 +1258,7 @@ static int mx3_camera_remove(struct platform_device *pdev)
static struct platform_driver mx3_camera_driver = { static struct platform_driver mx3_camera_driver = {
.driver = { .driver = {
.name = MX3_CAM_DRV_NAME, .name = MX3_CAM_DRV_NAME,
.owner = THIS_MODULE,
}, },
.probe = mx3_camera_probe, .probe = mx3_camera_probe,
.remove = mx3_camera_remove, .remove = mx3_camera_remove,
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#define MX3_CAMERA_DATAWIDTH_MASK (MX3_CAMERA_DATAWIDTH_4 | MX3_CAMERA_DATAWIDTH_8 | \ #define MX3_CAMERA_DATAWIDTH_MASK (MX3_CAMERA_DATAWIDTH_4 | MX3_CAMERA_DATAWIDTH_8 | \
MX3_CAMERA_DATAWIDTH_10 | MX3_CAMERA_DATAWIDTH_15) MX3_CAMERA_DATAWIDTH_10 | MX3_CAMERA_DATAWIDTH_15)
struct v4l2_async_subdev;
/** /**
* struct mx3_camera_pdata - i.MX3x camera platform data * struct mx3_camera_pdata - i.MX3x camera platform data
* @flags: MX3_CAMERA_* flags * @flags: MX3_CAMERA_* flags
...@@ -43,6 +45,8 @@ struct mx3_camera_pdata { ...@@ -43,6 +45,8 @@ struct mx3_camera_pdata {
unsigned long flags; unsigned long flags;
unsigned long mclk_10khz; unsigned long mclk_10khz;
struct device *dma_dev; struct device *dma_dev;
struct v4l2_async_subdev **asd; /* Flat array, arranged in groups */
int *asd_sizes; /* 0-terminated array of asd group sizes */
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment