aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/vsp1/vsp1_entity.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/platform/vsp1/vsp1_entity.c')
-rw-r--r--drivers/media/platform/vsp1/vsp1_entity.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c
index 44167834285d..79af71d5e270 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -20,6 +20,42 @@
20 20
21#include "vsp1.h" 21#include "vsp1.h"
22#include "vsp1_entity.h" 22#include "vsp1_entity.h"
23#include "vsp1_video.h"
24
25bool vsp1_entity_is_streaming(struct vsp1_entity *entity)
26{
27 bool streaming;
28
29 mutex_lock(&entity->lock);
30 streaming = entity->streaming;
31 mutex_unlock(&entity->lock);
32
33 return streaming;
34}
35
36int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming)
37{
38 int ret;
39
40 mutex_lock(&entity->lock);
41 entity->streaming = streaming;
42 mutex_unlock(&entity->lock);
43
44 if (!streaming)
45 return 0;
46
47 if (!entity->subdev.ctrl_handler)
48 return 0;
49
50 ret = v4l2_ctrl_handler_setup(entity->subdev.ctrl_handler);
51 if (ret < 0) {
52 mutex_lock(&entity->lock);
53 entity->streaming = false;
54 mutex_unlock(&entity->lock);
55 }
56
57 return ret;
58}
23 59
24/* ----------------------------------------------------------------------------- 60/* -----------------------------------------------------------------------------
25 * V4L2 Subdevice Operations 61 * V4L2 Subdevice Operations
@@ -157,6 +193,8 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
157 if (i == ARRAY_SIZE(vsp1_routes)) 193 if (i == ARRAY_SIZE(vsp1_routes))
158 return -EINVAL; 194 return -EINVAL;
159 195
196 mutex_init(&entity->lock);
197
160 entity->vsp1 = vsp1; 198 entity->vsp1 = vsp1;
161 entity->source_pad = num_pads - 1; 199 entity->source_pad = num_pads - 1;
162 200
@@ -185,7 +223,11 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
185 223
186void vsp1_entity_destroy(struct vsp1_entity *entity) 224void vsp1_entity_destroy(struct vsp1_entity *entity)
187{ 225{
226 if (entity->video)
227 vsp1_video_cleanup(entity->video);
188 if (entity->subdev.ctrl_handler) 228 if (entity->subdev.ctrl_handler)
189 v4l2_ctrl_handler_free(entity->subdev.ctrl_handler); 229 v4l2_ctrl_handler_free(entity->subdev.ctrl_handler);
190 media_entity_cleanup(&entity->subdev.entity); 230 media_entity_cleanup(&entity->subdev.entity);
231
232 mutex_destroy(&entity->lock);
191} 233}