diff mbox series

[v6,1/3] media: ipu3-cio2: Toggle sensor streaming in pm runtime ops

Message ID 20211122235613.41682-2-djrscally@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add support for OV5693 sensor | expand

Commit Message

Daniel Scally Nov. 22, 2021, 11:56 p.m. UTC
The .suspend() and .resume() runtime_pm operations for the ipu3-cio2
driver currently do not handle the sensor's stream. Setting .s_stream() on
or off for the sensor subdev means that sensors will pause and resume the
stream at the appropriate time even if their drivers don't implement those
operations.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
---
Changes since v5:

	- None

 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Jean-Michel Hautbois Nov. 23, 2021, 6:24 a.m. UTC | #1
Hi Daniel,

On 23/11/2021 00:56, Daniel Scally wrote:
> The .suspend() and .resume() runtime_pm operations for the ipu3-cio2
> driver currently do not handle the sensor's stream. Setting .s_stream() on
> or off for the sensor subdev means that sensors will pause and resume the
> stream at the appropriate time even if their drivers don't implement those
> operations.
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Signed-off-by: Daniel Scally <djrscally@gmail.com>
Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
> ---
> Changes since v5:
> 
> 	- None
> 
>   drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 17 ++++++++++++++++-
>   1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
> index 356ea966cf8d..e2874fee9530 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
> @@ -1966,12 +1966,19 @@ static int __maybe_unused cio2_suspend(struct device *dev)
>   	struct pci_dev *pci_dev = to_pci_dev(dev);
>   	struct cio2_device *cio2 = pci_get_drvdata(pci_dev);
>   	struct cio2_queue *q = cio2->cur_queue;
> +	int r;
>   
>   	dev_dbg(dev, "cio2 suspend\n");
>   	if (!cio2->streaming)
>   		return 0;
>   
>   	/* Stop stream */
> +	r = v4l2_subdev_call(q->sensor, video, s_stream, 0);
> +	if (r) {
> +		dev_err(dev, "failed to stop sensor streaming\n");
> +		return r;
> +	}
> +
>   	cio2_hw_exit(cio2, q);
>   	synchronize_irq(pci_dev->irq);
>   
> @@ -2005,8 +2012,16 @@ static int __maybe_unused cio2_resume(struct device *dev)
>   	}
>   
>   	r = cio2_hw_init(cio2, q);
> -	if (r)
> +	if (r) {
>   		dev_err(dev, "fail to init cio2 hw\n");
> +		return r;
> +	}
> +
> +	r = v4l2_subdev_call(q->sensor, video, s_stream, 1);
> +	if (r) {
> +		dev_err(dev, "fail to start sensor streaming\n");
> +		cio2_hw_exit(cio2, q);
> +	}
>   
>   	return r;
>   }
>
diff mbox series

Patch

diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
index 356ea966cf8d..e2874fee9530 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
@@ -1966,12 +1966,19 @@  static int __maybe_unused cio2_suspend(struct device *dev)
 	struct pci_dev *pci_dev = to_pci_dev(dev);
 	struct cio2_device *cio2 = pci_get_drvdata(pci_dev);
 	struct cio2_queue *q = cio2->cur_queue;
+	int r;
 
 	dev_dbg(dev, "cio2 suspend\n");
 	if (!cio2->streaming)
 		return 0;
 
 	/* Stop stream */
+	r = v4l2_subdev_call(q->sensor, video, s_stream, 0);
+	if (r) {
+		dev_err(dev, "failed to stop sensor streaming\n");
+		return r;
+	}
+
 	cio2_hw_exit(cio2, q);
 	synchronize_irq(pci_dev->irq);
 
@@ -2005,8 +2012,16 @@  static int __maybe_unused cio2_resume(struct device *dev)
 	}
 
 	r = cio2_hw_init(cio2, q);
-	if (r)
+	if (r) {
 		dev_err(dev, "fail to init cio2 hw\n");
+		return r;
+	}
+
+	r = v4l2_subdev_call(q->sensor, video, s_stream, 1);
+	if (r) {
+		dev_err(dev, "fail to start sensor streaming\n");
+		cio2_hw_exit(cio2, q);
+	}
 
 	return r;
 }