diff mbox series

[v3,34/38] media: ti-vpe: cal: add camerarx enable/disable refcounting

Message ID 20210524110909.672432-35-tomi.valkeinen@ideasonboard.com
State Accepted
Commit 9eaca40c0d13a21848b5a35dc8c37dc3690a4ff1
Headers show
Series media: ti-vpe: cal: multistream & embedded data support | expand

Commit Message

Tomi Valkeinen May 24, 2021, 11:09 a.m. UTC
The following patches add multistream support and we will have multiple
video devices using the same camerarx instances. Thus we need
enable/disable refcounting for the camerarx.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/media/platform/ti-vpe/cal-camerarx.c | 10 ++++++++++
 drivers/media/platform/ti-vpe/cal.h          |  2 ++
 2 files changed, 12 insertions(+)

Comments

Laurent Pinchart June 4, 2021, 2:16 p.m. UTC | #1
Hi Tomi,

Thank you for the patch.

On Mon, May 24, 2021 at 02:09:05PM +0300, Tomi Valkeinen wrote:
> The following patches add multistream support and we will have multiple

> video devices using the same camerarx instances. Thus we need

> enable/disable refcounting for the camerarx.

> 

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

> ---

>  drivers/media/platform/ti-vpe/cal-camerarx.c | 10 ++++++++++

>  drivers/media/platform/ti-vpe/cal.h          |  2 ++

>  2 files changed, 12 insertions(+)

> 

> diff --git a/drivers/media/platform/ti-vpe/cal-camerarx.c b/drivers/media/platform/ti-vpe/cal-camerarx.c

> index b87ffc52feb6..803d53753e87 100644

> --- a/drivers/media/platform/ti-vpe/cal-camerarx.c

> +++ b/drivers/media/platform/ti-vpe/cal-camerarx.c

> @@ -285,6 +285,11 @@ static int cal_camerarx_start(struct cal_camerarx *phy)

>  	u32 val;

>  	int ret;

>  

> +	if (phy->enable_count > 0) {

> +		phy->enable_count++;

> +		return 0;

> +	}

> +

>  	link_freq = cal_camerarx_get_ext_link_freq(phy);

>  	if (link_freq < 0)

>  		return link_freq;

> @@ -409,6 +414,8 @@ static int cal_camerarx_start(struct cal_camerarx *phy)

>  	/* Finally, enable the PHY Protocol Interface (PPI). */

>  	cal_camerarx_ppi_enable(phy);

>  

> +	phy->enable_count++;

> +

>  	return 0;

>  }

>  

> @@ -416,6 +423,9 @@ static void cal_camerarx_stop(struct cal_camerarx *phy)

>  {

>  	int ret;

>  

> +	if (--phy->enable_count > 0)

> +		return;

> +

>  	cal_camerarx_ppi_disable(phy);

>  

>  	cal_camerarx_disable_irqs(phy);

> diff --git a/drivers/media/platform/ti-vpe/cal.h b/drivers/media/platform/ti-vpe/cal.h

> index 78bd2e041d9a..8608a2c6c01a 100644

> --- a/drivers/media/platform/ti-vpe/cal.h

> +++ b/drivers/media/platform/ti-vpe/cal.h

> @@ -166,6 +166,8 @@ struct cal_camerarx {

>  

>  	/* mutex for camerarx ops */

>  	struct mutex		mutex;

> +

> +	unsigned int enable_count;


Can you align this as the other fields ?

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>


>  };

>  

>  struct cal_dev {


-- 
Regards,

Laurent Pinchart
diff mbox series

Patch

diff --git a/drivers/media/platform/ti-vpe/cal-camerarx.c b/drivers/media/platform/ti-vpe/cal-camerarx.c
index b87ffc52feb6..803d53753e87 100644
--- a/drivers/media/platform/ti-vpe/cal-camerarx.c
+++ b/drivers/media/platform/ti-vpe/cal-camerarx.c
@@ -285,6 +285,11 @@  static int cal_camerarx_start(struct cal_camerarx *phy)
 	u32 val;
 	int ret;
 
+	if (phy->enable_count > 0) {
+		phy->enable_count++;
+		return 0;
+	}
+
 	link_freq = cal_camerarx_get_ext_link_freq(phy);
 	if (link_freq < 0)
 		return link_freq;
@@ -409,6 +414,8 @@  static int cal_camerarx_start(struct cal_camerarx *phy)
 	/* Finally, enable the PHY Protocol Interface (PPI). */
 	cal_camerarx_ppi_enable(phy);
 
+	phy->enable_count++;
+
 	return 0;
 }
 
@@ -416,6 +423,9 @@  static void cal_camerarx_stop(struct cal_camerarx *phy)
 {
 	int ret;
 
+	if (--phy->enable_count > 0)
+		return;
+
 	cal_camerarx_ppi_disable(phy);
 
 	cal_camerarx_disable_irqs(phy);
diff --git a/drivers/media/platform/ti-vpe/cal.h b/drivers/media/platform/ti-vpe/cal.h
index 78bd2e041d9a..8608a2c6c01a 100644
--- a/drivers/media/platform/ti-vpe/cal.h
+++ b/drivers/media/platform/ti-vpe/cal.h
@@ -166,6 +166,8 @@  struct cal_camerarx {
 
 	/* mutex for camerarx ops */
 	struct mutex		mutex;
+
+	unsigned int enable_count;
 };
 
 struct cal_dev {