Commit 25b6beab authored by Kieran Bingham's avatar Kieran Bingham Committed by Mauro Carvalho Chehab

media: v4l: vsp1: Calculate partition sizes at stream start

Previously the active window and partition sizes for each partition were
calculated for each partition every frame. This data is constant and
only needs to be calculated once at the start of the stream.

Extend the vsp1_pipe object to dynamically store the number of partitions
required and pre-calculate the partition sizes into this table.
Signed-off-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarHans Verkuil <hansverk@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 801c6a17
...@@ -82,7 +82,9 @@ enum vsp1_pipeline_state { ...@@ -82,7 +82,9 @@ enum vsp1_pipeline_state {
* @dl: display list associated with the pipeline * @dl: display list associated with the pipeline
* @div_size: The maximum allowed partition size for the pipeline * @div_size: The maximum allowed partition size for the pipeline
* @partitions: The number of partitions used to process one frame * @partitions: The number of partitions used to process one frame
* @partition: The current partition for configuration to process
* @current_partition: The partition number currently being configured * @current_partition: The partition number currently being configured
* @part_table: The pre-calculated partitions used by the pipeline
*/ */
struct vsp1_pipeline { struct vsp1_pipeline {
struct media_pipeline pipe; struct media_pipeline pipe;
...@@ -117,6 +119,7 @@ struct vsp1_pipeline { ...@@ -117,6 +119,7 @@ struct vsp1_pipeline {
unsigned int partitions; unsigned int partitions;
struct v4l2_rect partition; struct v4l2_rect partition;
unsigned int current_partition; unsigned int current_partition;
struct v4l2_rect *part_table;
}; };
void vsp1_pipeline_reset(struct vsp1_pipeline *pipe); void vsp1_pipeline_reset(struct vsp1_pipeline *pipe);
......
...@@ -256,12 +256,13 @@ static struct v4l2_rect vsp1_video_partition(struct vsp1_pipeline *pipe, ...@@ -256,12 +256,13 @@ static struct v4l2_rect vsp1_video_partition(struct vsp1_pipeline *pipe,
return partition; return partition;
} }
static void vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe) static int vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe)
{ {
struct vsp1_device *vsp1 = pipe->output->entity.vsp1; struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
const struct v4l2_mbus_framefmt *format; const struct v4l2_mbus_framefmt *format;
struct vsp1_entity *entity; struct vsp1_entity *entity;
unsigned int div_size; unsigned int div_size;
unsigned int i;
/* /*
* Partitions are computed on the size before rotation, use the format * Partitions are computed on the size before rotation, use the format
...@@ -272,17 +273,17 @@ static void vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe) ...@@ -272,17 +273,17 @@ static void vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe)
RWPF_PAD_SINK); RWPF_PAD_SINK);
div_size = format->width; div_size = format->width;
/* Gen2 hardware doesn't require image partitioning. */ /*
if (vsp1->info->gen == 2) { * Only Gen3 hardware requires image partitioning, Gen2 will operate
pipe->div_size = div_size; * with a single partition that covers the whole output.
pipe->partitions = 1; */
return; if (vsp1->info->gen == 3) {
} list_for_each_entry(entity, &pipe->entities, list_pipe) {
unsigned int entity_max;
list_for_each_entry(entity, &pipe->entities, list_pipe) { if (!entity->ops->max_width)
unsigned int entity_max = VSP1_VIDEO_MAX_WIDTH; continue;
if (entity->ops->max_width) {
entity_max = entity->ops->max_width(entity, pipe); entity_max = entity->ops->max_width(entity, pipe);
if (entity_max) if (entity_max)
div_size = min(div_size, entity_max); div_size = min(div_size, entity_max);
...@@ -291,6 +292,15 @@ static void vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe) ...@@ -291,6 +292,15 @@ static void vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe)
pipe->div_size = div_size; pipe->div_size = div_size;
pipe->partitions = DIV_ROUND_UP(format->width, div_size); pipe->partitions = DIV_ROUND_UP(format->width, div_size);
pipe->part_table = kcalloc(pipe->partitions, sizeof(*pipe->part_table),
GFP_KERNEL);
if (!pipe->part_table)
return -ENOMEM;
for (i = 0; i < pipe->partitions; ++i)
pipe->part_table[i] = vsp1_video_partition(pipe, div_size, i);
return 0;
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
...@@ -373,8 +383,7 @@ static void vsp1_video_pipeline_run_partition(struct vsp1_pipeline *pipe, ...@@ -373,8 +383,7 @@ static void vsp1_video_pipeline_run_partition(struct vsp1_pipeline *pipe,
{ {
struct vsp1_entity *entity; struct vsp1_entity *entity;
pipe->partition = vsp1_video_partition(pipe, pipe->div_size, pipe->partition = pipe->part_table[pipe->current_partition];
pipe->current_partition);
list_for_each_entry(entity, &pipe->entities, list_pipe) { list_for_each_entry(entity, &pipe->entities, list_pipe) {
if (entity->ops->configure) if (entity->ops->configure)
...@@ -783,9 +792,12 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb) ...@@ -783,9 +792,12 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb)
static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe) static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe)
{ {
struct vsp1_entity *entity; struct vsp1_entity *entity;
int ret;
/* Determine this pipelines sizes for image partitioning support. */ /* Determine this pipelines sizes for image partitioning support. */
vsp1_video_pipeline_setup_partitions(pipe); ret = vsp1_video_pipeline_setup_partitions(pipe);
if (ret < 0)
return ret;
/* Prepare the display list. */ /* Prepare the display list. */
pipe->dl = vsp1_dl_list_get(pipe->output->dlm); pipe->dl = vsp1_dl_list_get(pipe->output->dlm);
...@@ -834,6 +846,12 @@ static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe) ...@@ -834,6 +846,12 @@ static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe)
vb2_buffer_done(&buffer->buf.vb2_buf, VB2_BUF_STATE_ERROR); vb2_buffer_done(&buffer->buf.vb2_buf, VB2_BUF_STATE_ERROR);
INIT_LIST_HEAD(&video->irqqueue); INIT_LIST_HEAD(&video->irqqueue);
spin_unlock_irqrestore(&video->irqlock, flags); spin_unlock_irqrestore(&video->irqlock, flags);
/* Release our partition table allocation */
mutex_lock(&pipe->lock);
kfree(pipe->part_table);
pipe->part_table = NULL;
mutex_unlock(&pipe->lock);
} }
static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count) static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment