[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>
This commit is contained in:
Laurent Pinchart 2015-11-15 19:14:22 -02:00 committed by Mauro Carvalho Chehab
parent e790c3cb8d
commit b7e5107eeb
10 changed files with 58 additions and 51 deletions

View file

@ -231,17 +231,9 @@ static int bru_enum_frame_size(struct v4l2_subdev *subdev,
static struct v4l2_rect *bru_get_compose(struct vsp1_bru *bru, static struct v4l2_rect *bru_get_compose(struct vsp1_bru *bru,
struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_pad_config *cfg,
unsigned int pad, u32 which) unsigned int pad)
{ {
switch (which) { return v4l2_subdev_get_try_compose(&bru->entity.subdev, cfg, pad);
case V4L2_SUBDEV_FORMAT_TRY:
return v4l2_subdev_get_try_compose(&bru->entity.subdev, cfg,
pad);
case V4L2_SUBDEV_FORMAT_ACTIVE:
return &bru->inputs[pad].compose;
default:
return NULL;
}
} }
static int bru_get_format(struct v4l2_subdev *subdev, static int bru_get_format(struct v4l2_subdev *subdev,
@ -310,7 +302,7 @@ static int bru_set_format(struct v4l2_subdev *subdev,
if (fmt->pad != bru->entity.source_pad) { if (fmt->pad != bru->entity.source_pad) {
struct v4l2_rect *compose; struct v4l2_rect *compose;
compose = bru_get_compose(bru, cfg, fmt->pad, fmt->which); compose = bru_get_compose(bru, config, fmt->pad);
compose->left = 0; compose->left = 0;
compose->top = 0; compose->top = 0;
compose->width = format->width; compose->width = format->width;
@ -336,6 +328,7 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
struct v4l2_subdev_selection *sel) struct v4l2_subdev_selection *sel)
{ {
struct vsp1_bru *bru = to_bru(subdev); struct vsp1_bru *bru = to_bru(subdev);
struct v4l2_subdev_pad_config *config;
if (sel->pad == bru->entity.source_pad) if (sel->pad == bru->entity.source_pad)
return -EINVAL; return -EINVAL;
@ -349,7 +342,12 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
return 0; return 0;
case V4L2_SEL_TGT_COMPOSE: case V4L2_SEL_TGT_COMPOSE:
sel->r = *bru_get_compose(bru, cfg, sel->pad, sel->which); config = vsp1_entity_get_pad_config(&bru->entity, cfg,
sel->which);
if (!config)
return -EINVAL;
sel->r = *bru_get_compose(bru, config, sel->pad);
return 0; return 0;
default: default:
@ -391,7 +389,7 @@ static int bru_set_selection(struct v4l2_subdev *subdev,
sel->r.width = format->width; sel->r.width = format->width;
sel->r.height = format->height; sel->r.height = format->height;
compose = bru_get_compose(bru, cfg, sel->pad, sel->which); compose = bru_get_compose(bru, config, sel->pad);
*compose = sel->r; *compose = sel->r;
return 0; return 0;

View file

@ -31,7 +31,6 @@ struct vsp1_bru {
struct { struct {
struct vsp1_rwpf *rpf; struct vsp1_rwpf *rpf;
struct v4l2_rect compose;
} inputs[VSP1_MAX_RPF]; } inputs[VSP1_MAX_RPF];
u32 bgcolor; u32 bgcolor;

View file

@ -410,9 +410,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
__func__, sel.r.left, sel.r.top, sel.r.width, sel.r.height, __func__, sel.r.left, sel.r.top, sel.r.width, sel.r.height,
sel.pad); sel.pad);
/* Store the compose rectangle coordinates in the RPF. */ /* Store the BRU input pad number in the RPF. */
rpf->location.left = dst->left; rpf->bru_input = rpf->entity.index;
rpf->location.top = dst->top;
/* Cache the memory buffer address but don't apply the values to the /* Cache the memory buffer address but don't apply the values to the
* hardware as the crop offsets haven't been computed yet. * hardware as the crop offsets haven't been computed yet.

View file

@ -88,6 +88,14 @@ vsp1_entity_get_pad_format(struct vsp1_entity *entity,
return v4l2_subdev_get_try_format(&entity->subdev, cfg, pad); return v4l2_subdev_get_try_format(&entity->subdev, cfg, pad);
} }
struct v4l2_rect *
vsp1_entity_get_pad_compose(struct vsp1_entity *entity,
struct v4l2_subdev_pad_config *cfg,
unsigned int pad)
{
return v4l2_subdev_get_try_compose(&entity->subdev, cfg, pad);
}
/* /*
* vsp1_entity_init_cfg - Initialize formats on all pads * vsp1_entity_init_cfg - Initialize formats on all pads
* @subdev: V4L2 subdevice * @subdev: V4L2 subdevice

View file

@ -111,6 +111,10 @@ struct v4l2_mbus_framefmt *
vsp1_entity_get_pad_format(struct vsp1_entity *entity, vsp1_entity_get_pad_format(struct vsp1_entity *entity,
struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_pad_config *cfg,
unsigned int pad); unsigned int pad);
struct v4l2_rect *
vsp1_entity_get_pad_compose(struct vsp1_entity *entity,
struct v4l2_subdev_pad_config *cfg,
unsigned int pad);
int vsp1_entity_init_cfg(struct v4l2_subdev *subdev, int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
struct v4l2_subdev_pad_config *cfg); struct v4l2_subdev_pad_config *cfg);

View file

@ -44,7 +44,9 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
const struct v4l2_pix_format_mplane *format = &rpf->format; const struct v4l2_pix_format_mplane *format = &rpf->format;
const struct v4l2_mbus_framefmt *source_format; const struct v4l2_mbus_framefmt *source_format;
const struct v4l2_mbus_framefmt *sink_format; const struct v4l2_mbus_framefmt *sink_format;
const struct v4l2_rect *crop = &rpf->crop; const struct v4l2_rect *crop;
unsigned int left = 0;
unsigned int top = 0;
u32 pstride; u32 pstride;
u32 infmt; u32 infmt;
@ -57,6 +59,8 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
* left corner in the plane buffer. Only two offsets are needed, as * left corner in the plane buffer. Only two offsets are needed, as
* planes 2 and 3 always have identical strides. * planes 2 and 3 always have identical strides.
*/ */
crop = vsp1_rwpf_get_crop(rpf, rpf->entity.config);
vsp1_rpf_write(rpf, VI6_RPF_SRC_BSIZE, vsp1_rpf_write(rpf, VI6_RPF_SRC_BSIZE,
(crop->width << VI6_RPF_SRC_BSIZE_BHSIZE_SHIFT) | (crop->width << VI6_RPF_SRC_BSIZE_BHSIZE_SHIFT) |
(crop->height << VI6_RPF_SRC_BSIZE_BVSIZE_SHIFT)); (crop->height << VI6_RPF_SRC_BSIZE_BVSIZE_SHIFT));
@ -103,9 +107,19 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
vsp1_rpf_write(rpf, VI6_RPF_DSWAP, fmtinfo->swap); vsp1_rpf_write(rpf, VI6_RPF_DSWAP, fmtinfo->swap);
/* Output location */ /* Output location */
if (pipe->bru) {
const struct v4l2_rect *compose;
compose = vsp1_entity_get_pad_compose(pipe->bru,
pipe->bru->config,
rpf->bru_input);
left = compose->left;
top = compose->top;
}
vsp1_rpf_write(rpf, VI6_RPF_LOC, vsp1_rpf_write(rpf, VI6_RPF_LOC,
(rpf->location.left << VI6_RPF_LOC_HCOORD_SHIFT) | (left << VI6_RPF_LOC_HCOORD_SHIFT) |
(rpf->location.top << VI6_RPF_LOC_VCOORD_SHIFT)); (top << VI6_RPF_LOC_VCOORD_SHIFT));
/* Use the alpha channel (extended to 8 bits) when available or an /* Use the alpha channel (extended to 8 bits) when available or an
* alpha value set through the V4L2_CID_ALPHA_COMPONENT control * alpha value set through the V4L2_CID_ALPHA_COMPONENT control

View file

@ -76,19 +76,11 @@ int vsp1_rwpf_enum_frame_size(struct v4l2_subdev *subdev,
return 0; return 0;
} }
static struct v4l2_rect * struct v4l2_rect *vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf,
vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_pad_config *config)
u32 which)
{ {
switch (which) { return v4l2_subdev_get_try_crop(&rwpf->entity.subdev, config,
case V4L2_SUBDEV_FORMAT_TRY: RWPF_PAD_SINK);
return v4l2_subdev_get_try_crop(&rwpf->entity.subdev, cfg,
RWPF_PAD_SINK);
case V4L2_SUBDEV_FORMAT_ACTIVE:
return &rwpf->crop;
default:
return NULL;
}
} }
int vsp1_rwpf_get_format(struct v4l2_subdev *subdev, int vsp1_rwpf_get_format(struct v4l2_subdev *subdev,
@ -148,7 +140,7 @@ int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
fmt->format = *format; fmt->format = *format;
/* Update the sink crop rectangle. */ /* Update the sink crop rectangle. */
crop = vsp1_rwpf_get_crop(rwpf, cfg, fmt->which); crop = vsp1_rwpf_get_crop(rwpf, config);
crop->left = 0; crop->left = 0;
crop->top = 0; crop->top = 0;
crop->width = fmt->format.width; crop->width = fmt->format.width;
@ -180,7 +172,7 @@ int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
switch (sel->target) { switch (sel->target) {
case V4L2_SEL_TGT_CROP: case V4L2_SEL_TGT_CROP:
sel->r = *vsp1_rwpf_get_crop(rwpf, cfg, sel->which); sel->r = *vsp1_rwpf_get_crop(rwpf, config);
break; break;
case V4L2_SEL_TGT_CROP_BOUNDS: case V4L2_SEL_TGT_CROP_BOUNDS:
@ -246,7 +238,7 @@ int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
sel->r.height = min_t(unsigned int, sel->r.height, sel->r.height = min_t(unsigned int, sel->r.height,
format->height - sel->r.top); format->height - sel->r.top);
crop = vsp1_rwpf_get_crop(rwpf, cfg, sel->which); crop = vsp1_rwpf_get_crop(rwpf, config);
*crop = sel->r; *crop = sel->r;
/* Propagate the format to the source pad. */ /* Propagate the format to the source pad. */

View file

@ -43,11 +43,7 @@ struct vsp1_rwpf {
struct v4l2_pix_format_mplane format; struct v4l2_pix_format_mplane format;
const struct vsp1_format_info *fmtinfo; const struct vsp1_format_info *fmtinfo;
struct { unsigned int bru_input;
unsigned int left;
unsigned int top;
} location;
struct v4l2_rect crop;
unsigned int alpha; unsigned int alpha;
@ -91,6 +87,8 @@ int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_selection *sel); struct v4l2_subdev_selection *sel);
struct v4l2_rect *vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf,
struct v4l2_subdev_pad_config *config);
/** /**
* vsp1_rwpf_set_memory - Configure DMA addresses for a [RW]PF * vsp1_rwpf_set_memory - Configure DMA addresses for a [RW]PF
* @rwpf: the [RW]PF instance * @rwpf: the [RW]PF instance

View file

@ -182,9 +182,6 @@ static int vsp1_video_pipeline_validate_branch(struct vsp1_pipeline *pipe,
bool bru_found = false; bool bru_found = false;
int ret; int ret;
input->location.left = 0;
input->location.top = 0;
ret = media_entity_enum_init(&ent_enum, &input->entity.vsp1->media_dev); ret = media_entity_enum_init(&ent_enum, &input->entity.vsp1->media_dev);
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -206,18 +203,14 @@ static int vsp1_video_pipeline_validate_branch(struct vsp1_pipeline *pipe,
entity = to_vsp1_entity( entity = to_vsp1_entity(
media_entity_to_v4l2_subdev(pad->entity)); media_entity_to_v4l2_subdev(pad->entity));
/* A BRU is present in the pipeline, store the compose rectangle /* A BRU is present in the pipeline, store the BRU input pad
* location in the input RPF for use when configuring the RPF. * number in the input RPF for use when configuring the RPF.
*/ */
if (entity->type == VSP1_ENTITY_BRU) { if (entity->type == VSP1_ENTITY_BRU) {
struct vsp1_bru *bru = to_bru(&entity->subdev); struct vsp1_bru *bru = to_bru(&entity->subdev);
struct v4l2_rect *rect =
&bru->inputs[pad->index].compose;
bru->inputs[pad->index].rpf = input; bru->inputs[pad->index].rpf = input;
input->bru_input = pad->index;
input->location.left = rect->left;
input->location.top = rect->top;
bru_found = true; bru_found = true;
} }

View file

@ -44,7 +44,7 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
struct vsp1_device *vsp1 = wpf->entity.vsp1; struct vsp1_device *vsp1 = wpf->entity.vsp1;
const struct v4l2_mbus_framefmt *source_format; const struct v4l2_mbus_framefmt *source_format;
const struct v4l2_mbus_framefmt *sink_format; const struct v4l2_mbus_framefmt *sink_format;
const struct v4l2_rect *crop = &wpf->crop; const struct v4l2_rect *crop;
unsigned int i; unsigned int i;
u32 srcrpf = 0; u32 srcrpf = 0;
u32 outfmt = 0; u32 outfmt = 0;
@ -88,6 +88,8 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
format->plane_fmt[1].bytesperline); format->plane_fmt[1].bytesperline);
} }
crop = vsp1_rwpf_get_crop(wpf, wpf->entity.config);
vsp1_wpf_write(wpf, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN | vsp1_wpf_write(wpf, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN |
(crop->left << VI6_WPF_SZCLIP_OFST_SHIFT) | (crop->left << VI6_WPF_SZCLIP_OFST_SHIFT) |
(crop->width << VI6_WPF_SZCLIP_SIZE_SHIFT)); (crop->width << VI6_WPF_SZCLIP_SIZE_SHIFT));