Commit 3781760a authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] soc-camera: Make clock_start and clock_stop operations optional

Instead of forcing drivers to implement empty clock operations, make
them optional.

v4l2 clock registration in the soc-camera core should probably be
conditionned on the availability of those operations, but careful
review and/or testing of all drivers would be needed, so that should be
a separate step.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 2af12f02
...@@ -177,6 +177,30 @@ static int __soc_camera_power_off(struct soc_camera_device *icd) ...@@ -177,6 +177,30 @@ static int __soc_camera_power_off(struct soc_camera_device *icd)
return 0; return 0;
} }
static int soc_camera_clock_start(struct soc_camera_host *ici)
{
int ret;
if (!ici->ops->clock_start)
return 0;
mutex_lock(&ici->clk_lock);
ret = ici->ops->clock_start(ici);
mutex_unlock(&ici->clk_lock);
return ret;
}
static void soc_camera_clock_stop(struct soc_camera_host *ici)
{
if (!ici->ops->clock_stop)
return;
mutex_lock(&ici->clk_lock);
ici->ops->clock_stop(ici);
mutex_unlock(&ici->clk_lock);
}
const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc( const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
struct soc_camera_device *icd, unsigned int fourcc) struct soc_camera_device *icd, unsigned int fourcc)
{ {
...@@ -584,9 +608,7 @@ static int soc_camera_add_device(struct soc_camera_device *icd) ...@@ -584,9 +608,7 @@ static int soc_camera_add_device(struct soc_camera_device *icd)
return -EBUSY; return -EBUSY;
if (!icd->clk) { if (!icd->clk) {
mutex_lock(&ici->clk_lock); ret = soc_camera_clock_start(ici);
ret = ici->ops->clock_start(ici);
mutex_unlock(&ici->clk_lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
...@@ -602,11 +624,8 @@ static int soc_camera_add_device(struct soc_camera_device *icd) ...@@ -602,11 +624,8 @@ static int soc_camera_add_device(struct soc_camera_device *icd)
return 0; return 0;
eadd: eadd:
if (!icd->clk) { if (!icd->clk)
mutex_lock(&ici->clk_lock); soc_camera_clock_stop(ici);
ici->ops->clock_stop(ici);
mutex_unlock(&ici->clk_lock);
}
return ret; return ret;
} }
...@@ -619,11 +638,8 @@ static void soc_camera_remove_device(struct soc_camera_device *icd) ...@@ -619,11 +638,8 @@ static void soc_camera_remove_device(struct soc_camera_device *icd)
if (ici->ops->remove) if (ici->ops->remove)
ici->ops->remove(icd); ici->ops->remove(icd);
if (!icd->clk) { if (!icd->clk)
mutex_lock(&ici->clk_lock); soc_camera_clock_stop(ici);
ici->ops->clock_stop(ici);
mutex_unlock(&ici->clk_lock);
}
ici->icd = NULL; ici->icd = NULL;
} }
...@@ -1180,7 +1196,6 @@ static int soc_camera_clk_enable(struct v4l2_clk *clk) ...@@ -1180,7 +1196,6 @@ static int soc_camera_clk_enable(struct v4l2_clk *clk)
{ {
struct soc_camera_device *icd = clk->priv; struct soc_camera_device *icd = clk->priv;
struct soc_camera_host *ici; struct soc_camera_host *ici;
int ret;
if (!icd || !icd->parent) if (!icd || !icd->parent)
return -ENODEV; return -ENODEV;
...@@ -1194,10 +1209,7 @@ static int soc_camera_clk_enable(struct v4l2_clk *clk) ...@@ -1194,10 +1209,7 @@ static int soc_camera_clk_enable(struct v4l2_clk *clk)
* If a different client is currently being probed, the host will tell * If a different client is currently being probed, the host will tell
* you to go * you to go
*/ */
mutex_lock(&ici->clk_lock); return soc_camera_clock_start(ici);
ret = ici->ops->clock_start(ici);
mutex_unlock(&ici->clk_lock);
return ret;
} }
static void soc_camera_clk_disable(struct v4l2_clk *clk) static void soc_camera_clk_disable(struct v4l2_clk *clk)
...@@ -1210,9 +1222,7 @@ static void soc_camera_clk_disable(struct v4l2_clk *clk) ...@@ -1210,9 +1222,7 @@ static void soc_camera_clk_disable(struct v4l2_clk *clk)
ici = to_soc_camera_host(icd->parent); ici = to_soc_camera_host(icd->parent);
mutex_lock(&ici->clk_lock); soc_camera_clock_stop(ici);
ici->ops->clock_stop(ici);
mutex_unlock(&ici->clk_lock);
module_put(ici->ops->owner); module_put(ici->ops->owner);
} }
...@@ -1754,9 +1764,7 @@ static int soc_camera_probe(struct soc_camera_host *ici, ...@@ -1754,9 +1764,7 @@ static int soc_camera_probe(struct soc_camera_host *ici,
ret = -EINVAL; ret = -EINVAL;
goto eadd; goto eadd;
} else { } else {
mutex_lock(&ici->clk_lock); ret = soc_camera_clock_start(ici);
ret = ici->ops->clock_start(ici);
mutex_unlock(&ici->clk_lock);
if (ret < 0) if (ret < 0)
goto eadd; goto eadd;
...@@ -1796,9 +1804,7 @@ static int soc_camera_probe(struct soc_camera_host *ici, ...@@ -1796,9 +1804,7 @@ static int soc_camera_probe(struct soc_camera_host *ici,
module_put(control->driver->owner); module_put(control->driver->owner);
enodrv: enodrv:
eadddev: eadddev:
mutex_lock(&ici->clk_lock); soc_camera_clock_stop(ici);
ici->ops->clock_stop(ici);
mutex_unlock(&ici->clk_lock);
} }
eadd: eadd:
if (icd->vdev) { if (icd->vdev) {
...@@ -1936,8 +1942,6 @@ int soc_camera_host_register(struct soc_camera_host *ici) ...@@ -1936,8 +1942,6 @@ int soc_camera_host_register(struct soc_camera_host *ici)
((!ici->ops->init_videobuf || ((!ici->ops->init_videobuf ||
!ici->ops->reqbufs) && !ici->ops->reqbufs) &&
!ici->ops->init_videobuf2) || !ici->ops->init_videobuf2) ||
!ici->ops->clock_start ||
!ici->ops->clock_stop ||
!ici->ops->poll || !ici->ops->poll ||
!ici->v4l2_dev.dev) !ici->v4l2_dev.dev)
return -EINVAL; return -EINVAL;
......
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