From c3718de559294649fc20dbd28b0db04dbf24e857 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 2 Mar 2015 11:54:07 -0300 Subject: [media] media: drop call to v4l2_device_unregister_subdev() These drivers are moved to support asynchronous probing, v4l2_async_unregister_subdev() unregisters the subdev so there isn't a need to explicitly call v4l2_device_unregister_subdev(). Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/sh_mobile_csi2.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/media/platform/soc_camera') diff --git a/drivers/media/platform/soc_camera/sh_mobile_csi2.c b/drivers/media/platform/soc_camera/sh_mobile_csi2.c index c4e7aa0..cd93241 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_csi2.c +++ b/drivers/media/platform/soc_camera/sh_mobile_csi2.c @@ -380,7 +380,6 @@ static int sh_csi2_remove(struct platform_device *pdev) struct sh_csi2 *priv = container_of(subdev, struct sh_csi2, subdev); v4l2_async_unregister_subdev(&priv->subdev); - v4l2_device_unregister_subdev(subdev); pm_runtime_disable(&pdev->dev); return 0; -- cgit v1.1 From 17bef885249db5db921ac8cf6e23938a91a6cd7b Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 4 Mar 2015 01:48:00 -0800 Subject: [media] v4l2-subdev: add support for the new enum_frame_interval 'which' field Support the new 'which' field in the enum_frame_interval ops. Most drivers do not need to be changed since they always returns the same enumeration regardless of the 'which' field. Tested for ov7670 and marvell-ccic on a OLPC XO-1 laptop. Signed-off-by: Hans Verkuil Acked-by: Jonathan Corbet Acked-by: Laurent Pinchart Tested-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/soc_camera.c | 30 ++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'drivers/media/platform/soc_camera') diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index cee7b56..1ed0a0b 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -1888,22 +1888,34 @@ static int default_enum_framesizes(struct soc_camera_device *icd, int ret; struct v4l2_subdev *sd = soc_camera_to_subdev(icd); const struct soc_camera_format_xlate *xlate; - __u32 pixfmt = fsize->pixel_format; - struct v4l2_frmsizeenum fsize_mbus = *fsize; + struct v4l2_subdev_frame_size_enum fse = { + .index = fsize->index, + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + }; - xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); + xlate = soc_camera_xlate_by_fourcc(icd, fsize->pixel_format); if (!xlate) return -EINVAL; - /* map xlate-code to pixel_format, sensor only handle xlate-code*/ - fsize_mbus.pixel_format = xlate->code; + fse.code = xlate->code; - ret = v4l2_subdev_call(sd, video, enum_framesizes, &fsize_mbus); + ret = v4l2_subdev_call(sd, pad, enum_frame_size, NULL, &fse); if (ret < 0) return ret; - *fsize = fsize_mbus; - fsize->pixel_format = pixfmt; - + if (fse.min_width == fse.max_width && + fse.min_height == fse.max_height) { + fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; + fsize->discrete.width = fse.min_width; + fsize->discrete.height = fse.min_height; + return 0; + } + fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS; + fsize->stepwise.min_width = fse.min_width; + fsize->stepwise.max_width = fse.max_width; + fsize->stepwise.min_height = fse.min_height; + fsize->stepwise.max_height = fse.max_height; + fsize->stepwise.step_width = 1; + fsize->stepwise.step_height = 1; return 0; } -- cgit v1.1 From a37462b919e1368ea3cf4bb0cbdb00ca8e76959c Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Sat, 31 Jan 2015 20:21:32 -0300 Subject: [media] V4L: remove clock name from v4l2_clk API All uses of the v4l2_clk API so far only register one clock with a fixed name. This allows us to get rid of it, which also will make CCF and DT integration easier. Signed-off-by: Guennadi Liakhovetski Acked-by: Laurent Pinchart Tested-by: Josh Wu Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/soc_camera.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/media/platform/soc_camera') diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 1ed0a0b..2049037 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -1364,7 +1364,7 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd, snprintf(clk_name, sizeof(clk_name), "%d-%04x", shd->i2c_adapter_id, shd->board_info->addr); - icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd); + icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); if (IS_ERR(icd->clk)) { ret = PTR_ERR(icd->clk); goto eclkreg; @@ -1545,7 +1545,7 @@ static int scan_async_group(struct soc_camera_host *ici, snprintf(clk_name, sizeof(clk_name), "%d-%04x", sasd->asd.match.i2c.adapter_id, sasd->asd.match.i2c.address); - icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd); + icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); if (IS_ERR(icd->clk)) { ret = PTR_ERR(icd->clk); goto eclkreg; @@ -1650,7 +1650,7 @@ static int soc_of_bind(struct soc_camera_host *ici, snprintf(clk_name, sizeof(clk_name), "of-%s", of_node_full_name(remote)); - icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd); + icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); if (IS_ERR(icd->clk)) { ret = PTR_ERR(icd->clk); goto eclkreg; -- cgit v1.1 From 0b9508aa030f8119c20fcf64b4b36bc792b59d41 Mon Sep 17 00:00:00 2001 From: Josh Wu Date: Tue, 10 Feb 2015 06:31:33 -0300 Subject: [media] media: soc-camera: use icd->control instead of icd->pdev for reset() icd->control is the sub device dev, i.e. i2c device. icd->pdev is the soc camera device's device. To be consitent with power() function, we will call reset() with icd->control as well. Signed-off-by: Josh Wu Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/soc_camera.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/media/platform/soc_camera') diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 2049037..b26d4d4 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -688,7 +688,8 @@ static int soc_camera_open(struct file *file) /* The camera could have been already on, try to reset */ if (sdesc->subdev_desc.reset) - sdesc->subdev_desc.reset(icd->pdev); + if (icd->control) + sdesc->subdev_desc.reset(icd->control); ret = soc_camera_add_device(icd); if (ret < 0) { @@ -1159,7 +1160,8 @@ static void scan_add_host(struct soc_camera_host *ici) /* The camera could have been already on, try to reset */ if (ssdd->reset) - ssdd->reset(icd->pdev); + if (icd->control) + ssdd->reset(icd->control); icd->parent = ici->v4l2_dev.dev; @@ -1445,7 +1447,7 @@ static int soc_camera_async_bound(struct v4l2_async_notifier *notifier, memcpy(&sdesc->subdev_desc, ssdd, sizeof(sdesc->subdev_desc)); if (ssdd->reset) - ssdd->reset(icd->pdev); + ssdd->reset(&client->dev); } icd->control = &client->dev; -- cgit v1.1 From 2af12f025870f664244defab14796da2fdb5009e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 9 Mar 2015 03:39:33 -0300 Subject: [media] soc-camera: Unregister v4l2 clock in the OF bind error path The v4l2 clock registered in soc_of_bind() must be unregistered if an error occurs and makes the function fail. Signed-off-by: Laurent Pinchart Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/soc_camera.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/media/platform/soc_camera') diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index b26d4d4..2a400d4 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -1661,6 +1661,8 @@ static int soc_of_bind(struct soc_camera_host *ici, ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier); if (!ret) return 0; + + v4l2_clk_unregister(icd->clk); eclkreg: icd->clk = NULL; platform_device_del(sasc->pdev); -- cgit v1.1 From 3781760a3d2bed2df8ed4cc3d061f8541bf7bd1d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 9 Mar 2015 03:39:34 -0300 Subject: [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: Laurent Pinchart Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/soc_camera.c | 62 ++++++++++++++------------ 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'drivers/media/platform/soc_camera') diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 2a400d4..7825132 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -177,6 +177,30 @@ static int __soc_camera_power_off(struct soc_camera_device *icd) 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( struct soc_camera_device *icd, unsigned int fourcc) { @@ -584,9 +608,7 @@ static int soc_camera_add_device(struct soc_camera_device *icd) return -EBUSY; if (!icd->clk) { - mutex_lock(&ici->clk_lock); - ret = ici->ops->clock_start(ici); - mutex_unlock(&ici->clk_lock); + ret = soc_camera_clock_start(ici); if (ret < 0) return ret; } @@ -602,11 +624,8 @@ static int soc_camera_add_device(struct soc_camera_device *icd) return 0; eadd: - if (!icd->clk) { - mutex_lock(&ici->clk_lock); - ici->ops->clock_stop(ici); - mutex_unlock(&ici->clk_lock); - } + if (!icd->clk) + soc_camera_clock_stop(ici); return ret; } @@ -619,11 +638,8 @@ static void soc_camera_remove_device(struct soc_camera_device *icd) if (ici->ops->remove) ici->ops->remove(icd); - if (!icd->clk) { - mutex_lock(&ici->clk_lock); - ici->ops->clock_stop(ici); - mutex_unlock(&ici->clk_lock); - } + if (!icd->clk) + soc_camera_clock_stop(ici); ici->icd = NULL; } @@ -1180,7 +1196,6 @@ static int soc_camera_clk_enable(struct v4l2_clk *clk) { struct soc_camera_device *icd = clk->priv; struct soc_camera_host *ici; - int ret; if (!icd || !icd->parent) return -ENODEV; @@ -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 * you to go */ - mutex_lock(&ici->clk_lock); - ret = ici->ops->clock_start(ici); - mutex_unlock(&ici->clk_lock); - return ret; + return soc_camera_clock_start(ici); } 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); - mutex_lock(&ici->clk_lock); - ici->ops->clock_stop(ici); - mutex_unlock(&ici->clk_lock); + soc_camera_clock_stop(ici); module_put(ici->ops->owner); } @@ -1754,9 +1764,7 @@ static int soc_camera_probe(struct soc_camera_host *ici, ret = -EINVAL; goto eadd; } else { - mutex_lock(&ici->clk_lock); - ret = ici->ops->clock_start(ici); - mutex_unlock(&ici->clk_lock); + ret = soc_camera_clock_start(ici); if (ret < 0) goto eadd; @@ -1796,9 +1804,7 @@ efinish: module_put(control->driver->owner); enodrv: eadddev: - mutex_lock(&ici->clk_lock); - ici->ops->clock_stop(ici); - mutex_unlock(&ici->clk_lock); + soc_camera_clock_stop(ici); } eadd: if (icd->vdev) { @@ -1936,8 +1942,6 @@ int soc_camera_host_register(struct soc_camera_host *ici) ((!ici->ops->init_videobuf || !ici->ops->reqbufs) && !ici->ops->init_videobuf2) || - !ici->ops->clock_start || - !ici->ops->clock_stop || !ici->ops->poll || !ici->v4l2_dev.dev) return -EINVAL; -- cgit v1.1 From 739cfd9be9af6bbbe4c652077add59409adf2225 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 9 Mar 2015 03:39:35 -0300 Subject: [media] rcar-vin: Don't implement empty optional clock operations The clock_start and clock_stop operations are now optional, don't implement empty stubs. Signed-off-by: Laurent Pinchart Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/rcar_vin.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'drivers/media/platform/soc_camera') diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index 279ab9f..9351f64 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c @@ -977,19 +977,6 @@ static void rcar_vin_remove_device(struct soc_camera_device *icd) icd->devnum); } -/* Called with .host_lock held */ -static int rcar_vin_clock_start(struct soc_camera_host *ici) -{ - /* VIN does not have "mclk" */ - return 0; -} - -/* Called with .host_lock held */ -static void rcar_vin_clock_stop(struct soc_camera_host *ici) -{ - /* VIN does not have "mclk" */ -} - static void set_coeff(struct rcar_vin_priv *priv, unsigned short xs) { int i; @@ -1803,8 +1790,6 @@ static struct soc_camera_host_ops rcar_vin_host_ops = { .owner = THIS_MODULE, .add = rcar_vin_add_device, .remove = rcar_vin_remove_device, - .clock_start = rcar_vin_clock_start, - .clock_stop = rcar_vin_clock_stop, .get_formats = rcar_vin_get_formats, .put_formats = rcar_vin_put_formats, .get_crop = rcar_vin_get_crop, -- cgit v1.1