From 764c8052ce21a56a55dc25dbc6ee0c075952cdeb Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Thu, 13 Aug 2020 17:04:53 +0100
Subject: [PATCH] staging: vc04_services: codec: Fix component
 enable/disable

start_streaming enabled the VPU component if ctx->component_enabled
was not set.
stop_streaming disabled the VPU component if both ports were
disabled. It didn't clear ctx->component_enabled.

If seeking, this meant that the component never got re-enabled,
and buffers never got processed afterwards.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 .../staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
+++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
@@ -2377,13 +2377,15 @@ static void bcm2835_codec_stop_streaming
 
 
 	/* If both ports disabled, then disable the component */
-	if (!ctx->component->input[0].enabled &&
+	if (ctx->component_enabled &&
+	    !ctx->component->input[0].enabled &&
 	    !ctx->component->output[0].enabled) {
 		ret = vchiq_mmal_component_disable(dev->instance,
 						   ctx->component);
 		if (ret)
 			v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed enabling component, ret %d\n",
 				 __func__, ret);
+		ctx->component_enabled = false;
 	}
 
 	if (V4L2_TYPE_IS_OUTPUT(q->type))
