diff mbox series

[v2,15/20] media: ti-vpe: cal: Add subdev s_power hooks

Message ID 20191104193140.31145-16-bparrot@ti.com (mailing list archive)
State New, archived
Headers show
Series media: ti-vpe: cal: maintenance | expand

Commit Message

Benoit Parrot Nov. 4, 2019, 7:31 p.m. UTC
Based on V4L2 documentations bridge driver must power on and off sub
device explicitly if media-controller mode is not used.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
---
 drivers/media/platform/ti-vpe/cal.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Sakari Ailus Nov. 6, 2019, 9:08 a.m. UTC | #1
Hi Benoit,

On Mon, Nov 04, 2019 at 01:31:35PM -0600, Benoit Parrot wrote:
> Based on V4L2 documentations bridge driver must power on and off sub
> device explicitly if media-controller mode is not used.

This isn't really related to MC but the fact that V4L2 still uses a
V4L2-specific way to manage power state of devices that predates runtime
PM.
Benoit Parrot Nov. 6, 2019, 8:59 p.m. UTC | #2
Sakari Ailus <sakari.ailus@iki.fi> wrote on Wed [2019-Nov-06 11:08:39 +0200]:
> Hi Benoit,
> 
> On Mon, Nov 04, 2019 at 01:31:35PM -0600, Benoit Parrot wrote:
> > Based on V4L2 documentations bridge driver must power on and off sub
> > device explicitly if media-controller mode is not used.
> 
> This isn't really related to MC but the fact that V4L2 still uses a
> V4L2-specific way to manage power state of devices that predates runtime
> PM.

I'll fix the description.

> 
> -- 
> Regards,
> 
> Sakari Ailus
diff mbox series

Patch

diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 45653e9ed6cd..f0210a743bdc 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -1661,6 +1661,12 @@  static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)
 	if (ret < 0)
 		goto err;
 
+	ret = v4l2_subdev_call(ctx->sensor, core, s_power, 1);
+	if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) {
+		ctx_err(ctx, "power on failed in subdev\n");
+		goto err;
+	}
+
 	cal_runtime_get(ctx->dev);
 
 	csi2_ctx_config(ctx);
@@ -1674,6 +1680,7 @@  static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)
 
 	ret = v4l2_subdev_call(ctx->sensor, video, s_stream, 1);
 	if (ret) {
+		v4l2_subdev_call(ctx->sensor, core, s_power, 0);
 		ctx_err(ctx, "stream on failed in subdev\n");
 		cal_runtime_put(ctx->dev);
 		goto err;
@@ -1702,6 +1709,7 @@  static void cal_stop_streaming(struct vb2_queue *vq)
 	struct cal_dmaqueue *dma_q = &ctx->vidq;
 	struct cal_buffer *buf, *tmp;
 	unsigned long flags;
+	int ret;
 
 	csi2_ppi_disable(ctx);
 	disable_irqs(ctx);
@@ -1710,6 +1718,10 @@  static void cal_stop_streaming(struct vb2_queue *vq)
 	if (v4l2_subdev_call(ctx->sensor, video, s_stream, 0))
 		ctx_err(ctx, "stream off failed in subdev\n");
 
+	ret = v4l2_subdev_call(ctx->sensor, core, s_power, 0);
+	if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
+		ctx_err(ctx, "power off failed in subdev\n");
+
 	/* Release all active buffers */
 	spin_lock_irqsave(&ctx->slock, flags);
 	list_for_each_entry_safe(buf, tmp, &dma_q->active, list) {