Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7e5107e authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab
Browse files

[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: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent e790c3cb
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
@@ -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,
					 struct v4l2_subdev_pad_config *cfg,
					 unsigned int pad, u32 which)
					 unsigned int pad)
{
	switch (which) {
	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;
	}
	return v4l2_subdev_get_try_compose(&bru->entity.subdev, cfg, pad);
}

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) {
		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->top = 0;
		compose->width = format->width;
@@ -336,6 +328,7 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
			     struct v4l2_subdev_selection *sel)
{
	struct vsp1_bru *bru = to_bru(subdev);
	struct v4l2_subdev_pad_config *config;

	if (sel->pad == bru->entity.source_pad)
		return -EINVAL;
@@ -349,7 +342,12 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
		return 0;

	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;

	default:
@@ -391,7 +389,7 @@ static int bru_set_selection(struct v4l2_subdev *subdev,
	sel->r.width = format->width;
	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;

	return 0;
+0 −1
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ struct vsp1_bru {

	struct {
		struct vsp1_rwpf *rpf;
		struct v4l2_rect compose;
	} inputs[VSP1_MAX_RPF];

	u32 bgcolor;
+2 −3
Original line number Diff line number Diff line
@@ -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,
		sel.pad);

	/* Store the compose rectangle coordinates in the RPF. */
	rpf->location.left = dst->left;
	rpf->location.top = dst->top;
	/* Store the BRU input pad number in the RPF. */
	rpf->bru_input = rpf->entity.index;

	/* Cache the memory buffer address but don't apply the values to the
	 * hardware as the crop offsets haven't been computed yet.
+8 −0
Original line number Diff line number Diff line
@@ -88,6 +88,14 @@ vsp1_entity_get_pad_format(struct vsp1_entity *entity,
	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
 * @subdev: V4L2 subdevice
+4 −0
Original line number Diff line number Diff line
@@ -111,6 +111,10 @@ struct v4l2_mbus_framefmt *
vsp1_entity_get_pad_format(struct vsp1_entity *entity,
			   struct v4l2_subdev_pad_config *cfg,
			   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,
			 struct v4l2_subdev_pad_config *cfg);

Loading