aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2015-11-15 16:14:22 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-04-13 17:53:22 -0400
commitb7e5107eebb73d27affed95c20cedbf4784bf17c (patch)
treead15c9876450de10ce4d852eafda5f6cbf78b865 /drivers
parente790c3cb8d904c4bad0d4a37885bece2eb848eeb (diff)
[media] v4l: vsp1: Store active selection rectangles in a pad config structure
Use the pad config structure part of the vsp1_entity to store all active pad selection rectangles. This generalizes the code to operate on pad config structures. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/platform/vsp1/vsp1_bru.c24
-rw-r--r--drivers/media/platform/vsp1/vsp1_bru.h1
-rw-r--r--drivers/media/platform/vsp1/vsp1_drm.c5
-rw-r--r--drivers/media/platform/vsp1/vsp1_entity.c8
-rw-r--r--drivers/media/platform/vsp1/vsp1_entity.h4
-rw-r--r--drivers/media/platform/vsp1/vsp1_rpf.c20
-rw-r--r--drivers/media/platform/vsp1/vsp1_rwpf.c22
-rw-r--r--drivers/media/platform/vsp1/vsp1_rwpf.h8
-rw-r--r--drivers/media/platform/vsp1/vsp1_video.c13
-rw-r--r--drivers/media/platform/vsp1/vsp1_wpf.c4
10 files changed, 58 insertions, 51 deletions
diff --git a/drivers/media/platform/vsp1/vsp1_bru.c b/drivers/media/platform/vsp1/vsp1_bru.c
index a0aa0fb2a5e1..c1848a3ac010 100644
--- a/drivers/media/platform/vsp1/vsp1_bru.c
+++ b/drivers/media/platform/vsp1/vsp1_bru.c
@@ -231,17 +231,9 @@ static int bru_enum_frame_size(struct v4l2_subdev *subdev,
231 231
232static struct v4l2_rect *bru_get_compose(struct vsp1_bru *bru, 232static struct v4l2_rect *bru_get_compose(struct vsp1_bru *bru,
233 struct v4l2_subdev_pad_config *cfg, 233 struct v4l2_subdev_pad_config *cfg,
234 unsigned int pad, u32 which) 234 unsigned int pad)
235{ 235{
236 switch (which) { 236 return v4l2_subdev_get_try_compose(&bru->entity.subdev, cfg, pad);
237 case V4L2_SUBDEV_FORMAT_TRY:
238 return v4l2_subdev_get_try_compose(&bru->entity.subdev, cfg,
239 pad);
240 case V4L2_SUBDEV_FORMAT_ACTIVE:
241 return &bru->inputs[pad].compose;
242 default:
243 return NULL;
244 }
245} 237}
246 238
247static int bru_get_format(struct v4l2_subdev *subdev, 239static int bru_get_format(struct v4l2_subdev *subdev,
@@ -310,7 +302,7 @@ static int bru_set_format(struct v4l2_subdev *subdev,
310 if (fmt->pad != bru->entity.source_pad) { 302 if (fmt->pad != bru->entity.source_pad) {
311 struct v4l2_rect *compose; 303 struct v4l2_rect *compose;
312 304
313 compose = bru_get_compose(bru, cfg, fmt->pad, fmt->which); 305 compose = bru_get_compose(bru, config, fmt->pad);
314 compose->left = 0; 306 compose->left = 0;
315 compose->top = 0; 307 compose->top = 0;
316 compose->width = format->width; 308 compose->width = format->width;
@@ -336,6 +328,7 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
336 struct v4l2_subdev_selection *sel) 328 struct v4l2_subdev_selection *sel)
337{ 329{
338 struct vsp1_bru *bru = to_bru(subdev); 330 struct vsp1_bru *bru = to_bru(subdev);
331 struct v4l2_subdev_pad_config *config;
339 332
340 if (sel->pad == bru->entity.source_pad) 333 if (sel->pad == bru->entity.source_pad)
341 return -EINVAL; 334 return -EINVAL;
@@ -349,7 +342,12 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
349 return 0; 342 return 0;
350 343
351 case V4L2_SEL_TGT_COMPOSE: 344 case V4L2_SEL_TGT_COMPOSE:
352 sel->r = *bru_get_compose(bru, cfg, sel->pad, sel->which); 345 config = vsp1_entity_get_pad_config(&bru->entity, cfg,
346 sel->which);
347 if (!config)
348 return -EINVAL;
349
350 sel->r = *bru_get_compose(bru, config, sel->pad);
353 return 0; 351 return 0;
354 352
355 default: 353 default:
@@ -391,7 +389,7 @@ static int bru_set_selection(struct v4l2_subdev *subdev,
391 sel->r.width = format->width; 389 sel->r.width = format->width;
392 sel->r.height = format->height; 390 sel->r.height = format->height;
393 391
394 compose = bru_get_compose(bru, cfg, sel->pad, sel->which); 392 compose = bru_get_compose(bru, config, sel->pad);
395 *compose = sel->r; 393 *compose = sel->r;
396 394
397 return 0; 395 return 0;
diff --git a/drivers/media/platform/vsp1/vsp1_bru.h b/drivers/media/platform/vsp1/vsp1_bru.h
index 4e7d2e79b940..828a3fcadea8 100644
--- a/drivers/media/platform/vsp1/vsp1_bru.h
+++ b/drivers/media/platform/vsp1/vsp1_bru.h
@@ -31,7 +31,6 @@ struct vsp1_bru {
31 31
32 struct { 32 struct {
33 struct vsp1_rwpf *rpf; 33 struct vsp1_rwpf *rpf;
34 struct v4l2_rect compose;
35 } inputs[VSP1_MAX_RPF]; 34 } inputs[VSP1_MAX_RPF];
36 35
37 u32 bgcolor; 36 u32 bgcolor;
diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
index a73018c9e8b5..acbf36d315b9 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -410,9 +410,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
410 __func__, sel.r.left, sel.r.top, sel.r.width, sel.r.height, 410 __func__, sel.r.left, sel.r.top, sel.r.width, sel.r.height,
411 sel.pad); 411 sel.pad);
412 412
413 /* Store the compose rectangle coordinates in the RPF. */ 413 /* Store the BRU input pad number in the RPF. */
414 rpf->location.left = dst->left; 414 rpf->bru_input = rpf->entity.index;
415 rpf->location.top = dst->top;
416 415
417 /* Cache the memory buffer address but don't apply the values to the 416 /* Cache the memory buffer address but don't apply the values to the
418 * hardware as the crop offsets haven't been computed yet. 417 * hardware as the crop offsets haven't been computed yet.
diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c
index 5185a1f5d3b8..09c9a1b86e3a 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -88,6 +88,14 @@ vsp1_entity_get_pad_format(struct vsp1_entity *entity,
88 return v4l2_subdev_get_try_format(&entity->subdev, cfg, pad); 88 return v4l2_subdev_get_try_format(&entity->subdev, cfg, pad);
89} 89}
90 90
91struct v4l2_rect *
92vsp1_entity_get_pad_compose(struct vsp1_entity *entity,
93 struct v4l2_subdev_pad_config *cfg,
94 unsigned int pad)
95{
96 return v4l2_subdev_get_try_compose(&entity->subdev, cfg, pad);
97}
98
91/* 99/*
92 * vsp1_entity_init_cfg - Initialize formats on all pads 100 * vsp1_entity_init_cfg - Initialize formats on all pads
93 * @subdev: V4L2 subdevice 101 * @subdev: V4L2 subdevice
diff --git a/drivers/media/platform/vsp1/vsp1_entity.h b/drivers/media/platform/vsp1/vsp1_entity.h
index 7b2081aff869..f7a360823373 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.h
+++ b/drivers/media/platform/vsp1/vsp1_entity.h
@@ -111,6 +111,10 @@ struct v4l2_mbus_framefmt *
111vsp1_entity_get_pad_format(struct vsp1_entity *entity, 111vsp1_entity_get_pad_format(struct vsp1_entity *entity,
112 struct v4l2_subdev_pad_config *cfg, 112 struct v4l2_subdev_pad_config *cfg,
113 unsigned int pad); 113 unsigned int pad);
114struct v4l2_rect *
115vsp1_entity_get_pad_compose(struct vsp1_entity *entity,
116 struct v4l2_subdev_pad_config *cfg,
117 unsigned int pad);
114int vsp1_entity_init_cfg(struct v4l2_subdev *subdev, 118int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
115 struct v4l2_subdev_pad_config *cfg); 119 struct v4l2_subdev_pad_config *cfg);
116 120
diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c
index 3b55cd93983f..cb3d5ed148cc 100644
--- a/drivers/media/platform/vsp1/vsp1_rpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rpf.c
@@ -44,7 +44,9 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
44 const struct v4l2_pix_format_mplane *format = &rpf->format; 44 const struct v4l2_pix_format_mplane *format = &rpf->format;
45 const struct v4l2_mbus_framefmt *source_format; 45 const struct v4l2_mbus_framefmt *source_format;
46 const struct v4l2_mbus_framefmt *sink_format; 46 const struct v4l2_mbus_framefmt *sink_format;
47 const struct v4l2_rect *crop = &rpf->crop; 47 const struct v4l2_rect *crop;
48 unsigned int left = 0;
49 unsigned int top = 0;
48 u32 pstride; 50 u32 pstride;
49 u32 infmt; 51 u32 infmt;
50 52
@@ -57,6 +59,8 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
57 * left corner in the plane buffer. Only two offsets are needed, as 59 * left corner in the plane buffer. Only two offsets are needed, as
58 * planes 2 and 3 always have identical strides. 60 * planes 2 and 3 always have identical strides.
59 */ 61 */
62 crop = vsp1_rwpf_get_crop(rpf, rpf->entity.config);
63
60 vsp1_rpf_write(rpf, VI6_RPF_SRC_BSIZE, 64 vsp1_rpf_write(rpf, VI6_RPF_SRC_BSIZE,
61 (crop->width << VI6_RPF_SRC_BSIZE_BHSIZE_SHIFT) | 65 (crop->width << VI6_RPF_SRC_BSIZE_BHSIZE_SHIFT) |
62 (crop->height << VI6_RPF_SRC_BSIZE_BVSIZE_SHIFT)); 66 (crop->height << VI6_RPF_SRC_BSIZE_BVSIZE_SHIFT));
@@ -103,9 +107,19 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
103 vsp1_rpf_write(rpf, VI6_RPF_DSWAP, fmtinfo->swap); 107 vsp1_rpf_write(rpf, VI6_RPF_DSWAP, fmtinfo->swap);
104 108
105 /* Output location */ 109 /* Output location */
110 if (pipe->bru) {
111 const struct v4l2_rect *compose;
112
113 compose = vsp1_entity_get_pad_compose(pipe->bru,
114 pipe->bru->config,
115 rpf->bru_input);
116 left = compose->left;
117 top = compose->top;
118 }
119
106 vsp1_rpf_write(rpf, VI6_RPF_LOC, 120 vsp1_rpf_write(rpf, VI6_RPF_LOC,
107 (rpf->location.left << VI6_RPF_LOC_HCOORD_SHIFT) | 121 (left << VI6_RPF_LOC_HCOORD_SHIFT) |
108 (rpf->location.top << VI6_RPF_LOC_VCOORD_SHIFT)); 122 (top << VI6_RPF_LOC_VCOORD_SHIFT));
109 123
110 /* Use the alpha channel (extended to 8 bits) when available or an 124 /* Use the alpha channel (extended to 8 bits) when available or an
111 * alpha value set through the V4L2_CID_ALPHA_COMPONENT control 125 * alpha value set through the V4L2_CID_ALPHA_COMPONENT control
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.c b/drivers/media/platform/vsp1/vsp1_rwpf.c
index e5216d39723e..0c5ad023adfb 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.c
@@ -76,19 +76,11 @@ int vsp1_rwpf_enum_frame_size(struct v4l2_subdev *subdev,
76 return 0; 76 return 0;
77} 77}
78 78
79static struct v4l2_rect * 79struct v4l2_rect *vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf,
80vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf, struct v4l2_subdev_pad_config *cfg, 80 struct v4l2_subdev_pad_config *config)
81 u32 which)
82{ 81{
83 switch (which) { 82 return v4l2_subdev_get_try_crop(&rwpf->entity.subdev, config,
84 case V4L2_SUBDEV_FORMAT_TRY: 83 RWPF_PAD_SINK);
85 return v4l2_subdev_get_try_crop(&rwpf->entity.subdev, cfg,
86 RWPF_PAD_SINK);
87 case V4L2_SUBDEV_FORMAT_ACTIVE:
88 return &rwpf->crop;
89 default:
90 return NULL;
91 }
92} 84}
93 85
94int vsp1_rwpf_get_format(struct v4l2_subdev *subdev, 86int vsp1_rwpf_get_format(struct v4l2_subdev *subdev,
@@ -148,7 +140,7 @@ int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
148 fmt->format = *format; 140 fmt->format = *format;
149 141
150 /* Update the sink crop rectangle. */ 142 /* Update the sink crop rectangle. */
151 crop = vsp1_rwpf_get_crop(rwpf, cfg, fmt->which); 143 crop = vsp1_rwpf_get_crop(rwpf, config);
152 crop->left = 0; 144 crop->left = 0;
153 crop->top = 0; 145 crop->top = 0;
154 crop->width = fmt->format.width; 146 crop->width = fmt->format.width;
@@ -180,7 +172,7 @@ int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
180 172
181 switch (sel->target) { 173 switch (sel->target) {
182 case V4L2_SEL_TGT_CROP: 174 case V4L2_SEL_TGT_CROP:
183 sel->r = *vsp1_rwpf_get_crop(rwpf, cfg, sel->which); 175 sel->r = *vsp1_rwpf_get_crop(rwpf, config);
184 break; 176 break;
185 177
186 case V4L2_SEL_TGT_CROP_BOUNDS: 178 case V4L2_SEL_TGT_CROP_BOUNDS:
@@ -246,7 +238,7 @@ int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
246 sel->r.height = min_t(unsigned int, sel->r.height, 238 sel->r.height = min_t(unsigned int, sel->r.height,
247 format->height - sel->r.top); 239 format->height - sel->r.top);
248 240
249 crop = vsp1_rwpf_get_crop(rwpf, cfg, sel->which); 241 crop = vsp1_rwpf_get_crop(rwpf, config);
250 *crop = sel->r; 242 *crop = sel->r;
251 243
252 /* Propagate the format to the source pad. */ 244 /* Propagate the format to the source pad. */
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h b/drivers/media/platform/vsp1/vsp1_rwpf.h
index e8ca9b6ee689..4ebfab61e0ef 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.h
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.h
@@ -43,11 +43,7 @@ struct vsp1_rwpf {
43 43
44 struct v4l2_pix_format_mplane format; 44 struct v4l2_pix_format_mplane format;
45 const struct vsp1_format_info *fmtinfo; 45 const struct vsp1_format_info *fmtinfo;
46 struct { 46 unsigned int bru_input;
47 unsigned int left;
48 unsigned int top;
49 } location;
50 struct v4l2_rect crop;
51 47
52 unsigned int alpha; 48 unsigned int alpha;
53 49
@@ -91,6 +87,8 @@ int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
91 struct v4l2_subdev_pad_config *cfg, 87 struct v4l2_subdev_pad_config *cfg,
92 struct v4l2_subdev_selection *sel); 88 struct v4l2_subdev_selection *sel);
93 89
90struct v4l2_rect *vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf,
91 struct v4l2_subdev_pad_config *config);
94/** 92/**
95 * vsp1_rwpf_set_memory - Configure DMA addresses for a [RW]PF 93 * vsp1_rwpf_set_memory - Configure DMA addresses for a [RW]PF
96 * @rwpf: the [RW]PF instance 94 * @rwpf: the [RW]PF instance
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index 102977ae1daa..d4a092c8ece3 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -182,9 +182,6 @@ static int vsp1_video_pipeline_validate_branch(struct vsp1_pipeline *pipe,
182 bool bru_found = false; 182 bool bru_found = false;
183 int ret; 183 int ret;
184 184
185 input->location.left = 0;
186 input->location.top = 0;
187
188 ret = media_entity_enum_init(&ent_enum, &input->entity.vsp1->media_dev); 185 ret = media_entity_enum_init(&ent_enum, &input->entity.vsp1->media_dev);
189 if (ret < 0) 186 if (ret < 0)
190 return ret; 187 return ret;
@@ -206,18 +203,14 @@ static int vsp1_video_pipeline_validate_branch(struct vsp1_pipeline *pipe,
206 entity = to_vsp1_entity( 203 entity = to_vsp1_entity(
207 media_entity_to_v4l2_subdev(pad->entity)); 204 media_entity_to_v4l2_subdev(pad->entity));
208 205
209 /* A BRU is present in the pipeline, store the compose rectangle 206 /* A BRU is present in the pipeline, store the BRU input pad
210 * location in the input RPF for use when configuring the RPF. 207 * number in the input RPF for use when configuring the RPF.
211 */ 208 */
212 if (entity->type == VSP1_ENTITY_BRU) { 209 if (entity->type == VSP1_ENTITY_BRU) {
213 struct vsp1_bru *bru = to_bru(&entity->subdev); 210 struct vsp1_bru *bru = to_bru(&entity->subdev);
214 struct v4l2_rect *rect =
215 &bru->inputs[pad->index].compose;
216 211
217 bru->inputs[pad->index].rpf = input; 212 bru->inputs[pad->index].rpf = input;
218 213 input->bru_input = pad->index;
219 input->location.left = rect->left;
220 input->location.top = rect->top;
221 214
222 bru_found = true; 215 bru_found = true;
223 } 216 }
diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c
index c86d31f274bf..0797927d14cf 100644
--- a/drivers/media/platform/vsp1/vsp1_wpf.c
+++ b/drivers/media/platform/vsp1/vsp1_wpf.c
@@ -44,7 +44,7 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
44 struct vsp1_device *vsp1 = wpf->entity.vsp1; 44 struct vsp1_device *vsp1 = wpf->entity.vsp1;
45 const struct v4l2_mbus_framefmt *source_format; 45 const struct v4l2_mbus_framefmt *source_format;
46 const struct v4l2_mbus_framefmt *sink_format; 46 const struct v4l2_mbus_framefmt *sink_format;
47 const struct v4l2_rect *crop = &wpf->crop; 47 const struct v4l2_rect *crop;
48 unsigned int i; 48 unsigned int i;
49 u32 srcrpf = 0; 49 u32 srcrpf = 0;
50 u32 outfmt = 0; 50 u32 outfmt = 0;
@@ -88,6 +88,8 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
88 format->plane_fmt[1].bytesperline); 88 format->plane_fmt[1].bytesperline);
89 } 89 }
90 90
91 crop = vsp1_rwpf_get_crop(wpf, wpf->entity.config);
92
91 vsp1_wpf_write(wpf, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN | 93 vsp1_wpf_write(wpf, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN |
92 (crop->left << VI6_WPF_SZCLIP_OFST_SHIFT) | 94 (crop->left << VI6_WPF_SZCLIP_OFST_SHIFT) |
93 (crop->width << VI6_WPF_SZCLIP_SIZE_SHIFT)); 95 (crop->width << VI6_WPF_SZCLIP_SIZE_SHIFT));