media: subdev: Support privacy led in v4l2_subdev_enable/disable_streams()

We support camera privacy leds with the .s_stream() operation, in
call_s_stream(), but we don't have that support when the subdevice
implements .enable/disable_streams() operations.

Add the support by enabling the led when the first stream for a
subdevice is enabled, and disabling the led then the last stream is
disabled.

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Tomi Valkeinen
2024-04-24 18:39:10 +03:00
committed by Hans Verkuil
parent 5f3ce14fae
commit 585d8fd5eb

View File

@@ -2205,6 +2205,7 @@ int v4l2_subdev_enable_streams(struct v4l2_subdev *sd, u32 pad,
{
struct device *dev = sd->entity.graph_obj.mdev->dev;
struct v4l2_subdev_state *state;
bool already_streaming;
u64 found_streams = 0;
unsigned int i;
int ret;
@@ -2253,6 +2254,8 @@ int v4l2_subdev_enable_streams(struct v4l2_subdev *sd, u32 pad,
dev_dbg(dev, "enable streams %u:%#llx\n", pad, streams_mask);
already_streaming = v4l2_subdev_is_streaming(sd);
/* Call the .enable_streams() operation. */
ret = v4l2_subdev_call(sd, pad, enable_streams, state, pad,
streams_mask);
@@ -2271,6 +2274,9 @@ int v4l2_subdev_enable_streams(struct v4l2_subdev *sd, u32 pad,
cfg->enabled = true;
}
if (!already_streaming)
v4l2_subdev_enable_privacy_led(sd);
done:
v4l2_subdev_unlock_state(state);
@@ -2395,6 +2401,9 @@ int v4l2_subdev_disable_streams(struct v4l2_subdev *sd, u32 pad,
}
done:
if (!v4l2_subdev_is_streaming(sd))
v4l2_subdev_disable_privacy_led(sd);
v4l2_subdev_unlock_state(state);
return ret;