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

Commit 46ce3639 authored by Kieran Bingham's avatar Kieran Bingham Committed by Mauro Carvalho Chehab
Browse files

media: vsp1: Refactor display list configure operations



The entities provide a single .configure operation which configures the
object into the target display list, based on the vsp1_entity_params
selection.

Split the configure function into three parts, '.configure_stream()',
'.configure_frame()', and '.configure_partition()' to facilitate
splitting the configuration of each parameter class into separate
display list bodies.

[laurent.pinchart+renesas@ideasonboard.com: Blank line reformatting, remote unneeded local variable initialization]

Signed-off-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 2d9445db
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -281,19 +281,15 @@ static const struct v4l2_subdev_ops brx_ops = {
 * VSP1 Entity Operations
 */

static void brx_configure(struct vsp1_entity *entity,
static void brx_configure_stream(struct vsp1_entity *entity,
				 struct vsp1_pipeline *pipe,
			  struct vsp1_dl_list *dl,
			  enum vsp1_entity_params params)
				 struct vsp1_dl_list *dl)
{
	struct vsp1_brx *brx = to_brx(&entity->subdev);
	struct v4l2_mbus_framefmt *format;
	unsigned int flags;
	unsigned int i;

	if (params != VSP1_ENTITY_PARAMS_INIT)
		return;

	format = vsp1_entity_get_pad_format(&brx->entity, brx->entity.config,
					    brx->entity.source_pad);

@@ -400,7 +396,7 @@ static void brx_configure(struct vsp1_entity *entity,
}

static const struct vsp1_entity_operations brx_entity_ops = {
	.configure = brx_configure,
	.configure_stream = brx_configure_stream,
};

/* -----------------------------------------------------------------------------
+36 −42
Original line number Diff line number Diff line
@@ -169,36 +169,32 @@ static const struct v4l2_subdev_ops clu_ops = {
 * VSP1 Entity Operations
 */

static void clu_configure(struct vsp1_entity *entity,
static void clu_configure_stream(struct vsp1_entity *entity,
				 struct vsp1_pipeline *pipe,
			  struct vsp1_dl_list *dl,
			  enum vsp1_entity_params params)
				 struct vsp1_dl_list *dl)
{
	struct vsp1_clu *clu = to_clu(&entity->subdev);
	struct vsp1_dl_body *dlb;
	unsigned long flags;
	u32 ctrl = VI6_CLU_CTRL_AAI | VI6_CLU_CTRL_MVS | VI6_CLU_CTRL_EN;
	struct v4l2_mbus_framefmt *format;

	switch (params) {
	case VSP1_ENTITY_PARAMS_INIT: {
	/*
		 * The format can't be changed during streaming, only verify it
		 * at setup time and store the information internally for future
		 * runtime configuration calls.
	 * The yuv_mode can't be changed during streaming. Cache it internally
	 * for future runtime configuration calls.
	 */
		struct v4l2_mbus_framefmt *format;

	format = vsp1_entity_get_pad_format(&clu->entity,
					    clu->entity.config,
					    CLU_PAD_SINK);
	clu->yuv_mode = format->code == MEDIA_BUS_FMT_AYUV8_1X32;
		break;
}

	case VSP1_ENTITY_PARAMS_PARTITION:
		break;
static void clu_configure_frame(struct vsp1_entity *entity,
				struct vsp1_pipeline *pipe,
				struct vsp1_dl_list *dl)
{
	struct vsp1_clu *clu = to_clu(&entity->subdev);
	struct vsp1_dl_body *dlb;
	unsigned long flags;
	u32 ctrl = VI6_CLU_CTRL_AAI | VI6_CLU_CTRL_MVS | VI6_CLU_CTRL_EN;

	case VSP1_ENTITY_PARAMS_RUNTIME:
	/* 2D mode can only be used with the YCbCr pixel encoding. */
	if (clu->mode == V4L2_CID_VSP1_CLU_MODE_2D && clu->yuv_mode)
		ctrl |= VI6_CLU_CTRL_AX1I_2D | VI6_CLU_CTRL_AX2I_2D
@@ -218,9 +214,6 @@ static void clu_configure(struct vsp1_entity *entity,
		/* Release our local reference. */
		vsp1_dl_body_put(dlb);
	}

		break;
	}
}

static void clu_destroy(struct vsp1_entity *entity)
@@ -231,7 +224,8 @@ static void clu_destroy(struct vsp1_entity *entity)
}

static const struct vsp1_entity_operations clu_entity_ops = {
	.configure = clu_configure,
	.configure_stream = clu_configure_stream,
	.configure_frame = clu_configure_frame,
	.destroy = clu_destroy,
};

+3 −9
Original line number Diff line number Diff line
@@ -552,15 +552,9 @@ static void vsp1_du_pipeline_configure(struct vsp1_pipeline *pipe)
		}

		vsp1_entity_route_setup(entity, pipe, dl);

		if (entity->ops->configure) {
			entity->ops->configure(entity, pipe, dl,
					       VSP1_ENTITY_PARAMS_INIT);
			entity->ops->configure(entity, pipe, dl,
					       VSP1_ENTITY_PARAMS_RUNTIME);
			entity->ops->configure(entity, pipe, dl,
					       VSP1_ENTITY_PARAMS_PARTITION);
		}
		vsp1_entity_configure_stream(entity, pipe, dl);
		vsp1_entity_configure_frame(entity, pipe, dl);
		vsp1_entity_configure_partition(entity, pipe, dl);
	}

	vsp1_dl_list_commit(dl, drm_pipe->force_brx_release);
+24 −0
Original line number Diff line number Diff line
@@ -69,6 +69,30 @@ void vsp1_entity_route_setup(struct vsp1_entity *entity,
	vsp1_dl_list_write(dl, source->route->reg, route);
}

void vsp1_entity_configure_stream(struct vsp1_entity *entity,
				  struct vsp1_pipeline *pipe,
				  struct vsp1_dl_list *dl)
{
	if (entity->ops->configure_stream)
		entity->ops->configure_stream(entity, pipe, dl);
}

void vsp1_entity_configure_frame(struct vsp1_entity *entity,
				 struct vsp1_pipeline *pipe,
				 struct vsp1_dl_list *dl)
{
	if (entity->ops->configure_frame)
		entity->ops->configure_frame(entity, pipe, dl);
}

void vsp1_entity_configure_partition(struct vsp1_entity *entity,
				     struct vsp1_pipeline *pipe,
				     struct vsp1_dl_list *dl)
{
	if (entity->ops->configure_partition)
		entity->ops->configure_partition(entity, pipe, dl);
}

/* -----------------------------------------------------------------------------
 * V4L2 Subdevice Operations
 */
+23 −16
Original line number Diff line number Diff line
@@ -37,18 +37,6 @@ enum vsp1_entity_type {
	VSP1_ENTITY_WPF,
};

/**
 * enum vsp1_entity_params - Entity configuration parameters class
 * @VSP1_ENTITY_PARAMS_INIT - Initial parameters
 * @VSP1_ENTITY_PARAMS_PARTITION - Per-image partition parameters
 * @VSP1_ENTITY_PARAMS_RUNTIME - Runtime-configurable parameters
 */
enum vsp1_entity_params {
	VSP1_ENTITY_PARAMS_INIT,
	VSP1_ENTITY_PARAMS_PARTITION,
	VSP1_ENTITY_PARAMS_RUNTIME,
};

#define VSP1_ENTITY_MAX_INPUTS		5	/* For the BRU */

/*
@@ -77,8 +65,10 @@ struct vsp1_route {
/**
 * struct vsp1_entity_operations - Entity operations
 * @destroy:	Destroy the entity.
 * @configure:	Setup the hardware based on the entity state (pipeline, formats,
 *		selection rectangles, ...)
 * @configure_stream:	Setup the hardware parameters for the stream which do
 *			not vary between frames (pipeline, formats).
 * @configure_frame:	Configure the runtime parameters for each frame.
 * @configure_partition: Configure partition specific parameters.
 * @max_width:	Return the max supported width of data that the entity can
 *		process in a single operation.
 * @partition:	Process the partition construction based on this entity's
@@ -86,8 +76,13 @@ struct vsp1_route {
 */
struct vsp1_entity_operations {
	void (*destroy)(struct vsp1_entity *);
	void (*configure)(struct vsp1_entity *, struct vsp1_pipeline *,
			  struct vsp1_dl_list *, enum vsp1_entity_params);
	void (*configure_stream)(struct vsp1_entity *, struct vsp1_pipeline *,
				 struct vsp1_dl_list *);
	void (*configure_frame)(struct vsp1_entity *, struct vsp1_pipeline *,
					struct vsp1_dl_list *);
	void (*configure_partition)(struct vsp1_entity *,
				    struct vsp1_pipeline *,
				    struct vsp1_dl_list *);
	unsigned int (*max_width)(struct vsp1_entity *, struct vsp1_pipeline *);
	void (*partition)(struct vsp1_entity *, struct vsp1_pipeline *,
			  struct vsp1_partition *, unsigned int,
@@ -156,6 +151,18 @@ void vsp1_entity_route_setup(struct vsp1_entity *entity,
			     struct vsp1_pipeline *pipe,
			     struct vsp1_dl_list *dl);

void vsp1_entity_configure_stream(struct vsp1_entity *entity,
				  struct vsp1_pipeline *pipe,
				  struct vsp1_dl_list *dl);

void vsp1_entity_configure_frame(struct vsp1_entity *entity,
				 struct vsp1_pipeline *pipe,
				 struct vsp1_dl_list *dl);

void vsp1_entity_configure_partition(struct vsp1_entity *entity,
				     struct vsp1_pipeline *pipe,
				     struct vsp1_dl_list *dl);

struct media_pad *vsp1_entity_remote_pad(struct media_pad *pad);

int vsp1_subdev_get_pad_format(struct v4l2_subdev *subdev,
Loading