Commit ff7e97c9 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] v4l: vsp1: Store pipeline pointer in rwpf

This prepares for dynamic pipeline allocation by providing a field that
can be used to store the pipeline pointer atomically under driver
control.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 83dd019d
...@@ -49,17 +49,15 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data) ...@@ -49,17 +49,15 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
for (i = 0; i < vsp1->info->wpf_count; ++i) { for (i = 0; i < vsp1->info->wpf_count; ++i) {
struct vsp1_rwpf *wpf = vsp1->wpf[i]; struct vsp1_rwpf *wpf = vsp1->wpf[i];
struct vsp1_pipeline *pipe;
if (wpf == NULL) if (wpf == NULL)
continue; continue;
pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
status = vsp1_read(vsp1, VI6_WPF_IRQ_STA(i)); status = vsp1_read(vsp1, VI6_WPF_IRQ_STA(i));
vsp1_write(vsp1, VI6_WPF_IRQ_STA(i), ~status & mask); vsp1_write(vsp1, VI6_WPF_IRQ_STA(i), ~status & mask);
if (status & VI6_WFP_IRQ_STA_FRE) { if (status & VI6_WFP_IRQ_STA_FRE) {
vsp1_pipeline_frame_end(pipe); vsp1_pipeline_frame_end(wpf->pipe);
ret = IRQ_HANDLED; ret = IRQ_HANDLED;
} }
} }
......
...@@ -172,14 +172,18 @@ void vsp1_pipeline_reset(struct vsp1_pipeline *pipe) ...@@ -172,14 +172,18 @@ void vsp1_pipeline_reset(struct vsp1_pipeline *pipe)
bru->inputs[i].rpf = NULL; bru->inputs[i].rpf = NULL;
} }
for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) for (i = 0; i < pipe->num_inputs; ++i) {
pipe->inputs[i]->pipe = NULL;
pipe->inputs[i] = NULL; pipe->inputs[i] = NULL;
}
pipe->output->pipe = NULL;
pipe->output = NULL;
INIT_LIST_HEAD(&pipe->entities); INIT_LIST_HEAD(&pipe->entities);
pipe->state = VSP1_PIPELINE_STOPPED; pipe->state = VSP1_PIPELINE_STOPPED;
pipe->buffers_ready = 0; pipe->buffers_ready = 0;
pipe->num_inputs = 0; pipe->num_inputs = 0;
pipe->output = NULL;
pipe->bru = NULL; pipe->bru = NULL;
pipe->lif = NULL; pipe->lif = NULL;
pipe->uds = NULL; pipe->uds = NULL;
...@@ -344,7 +348,7 @@ void vsp1_pipelines_suspend(struct vsp1_device *vsp1) ...@@ -344,7 +348,7 @@ void vsp1_pipelines_suspend(struct vsp1_device *vsp1)
if (wpf == NULL) if (wpf == NULL)
continue; continue;
pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); pipe = wpf->pipe;
if (pipe == NULL) if (pipe == NULL)
continue; continue;
...@@ -361,7 +365,7 @@ void vsp1_pipelines_suspend(struct vsp1_device *vsp1) ...@@ -361,7 +365,7 @@ void vsp1_pipelines_suspend(struct vsp1_device *vsp1)
if (wpf == NULL) if (wpf == NULL)
continue; continue;
pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); pipe = wpf->pipe;
if (pipe == NULL) if (pipe == NULL)
continue; continue;
...@@ -385,7 +389,7 @@ void vsp1_pipelines_resume(struct vsp1_device *vsp1) ...@@ -385,7 +389,7 @@ void vsp1_pipelines_resume(struct vsp1_device *vsp1)
if (wpf == NULL) if (wpf == NULL)
continue; continue;
pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); pipe = wpf->pipe;
if (pipe == NULL) if (pipe == NULL)
continue; continue;
......
...@@ -103,14 +103,6 @@ struct vsp1_pipeline { ...@@ -103,14 +103,6 @@ struct vsp1_pipeline {
struct vsp1_dl_list *dl; struct vsp1_dl_list *dl;
}; };
static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
{
if (likely(e->pipe))
return container_of(e->pipe, struct vsp1_pipeline, pipe);
else
return NULL;
}
void vsp1_pipeline_reset(struct vsp1_pipeline *pipe); void vsp1_pipeline_reset(struct vsp1_pipeline *pipe);
void vsp1_pipeline_init(struct vsp1_pipeline *pipe); void vsp1_pipeline_init(struct vsp1_pipeline *pipe);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
struct v4l2_ctrl; struct v4l2_ctrl;
struct vsp1_dl_manager; struct vsp1_dl_manager;
struct vsp1_pipeline;
struct vsp1_rwpf; struct vsp1_rwpf;
struct vsp1_video; struct vsp1_video;
...@@ -36,6 +37,7 @@ struct vsp1_rwpf { ...@@ -36,6 +37,7 @@ struct vsp1_rwpf {
struct vsp1_entity entity; struct vsp1_entity entity;
struct v4l2_ctrl_handler ctrls; struct v4l2_ctrl_handler ctrls;
struct vsp1_pipeline *pipe;
struct vsp1_video *video; struct vsp1_video *video;
unsigned int max_width; unsigned int max_width;
......
...@@ -293,10 +293,12 @@ static int vsp1_video_pipeline_build(struct vsp1_pipeline *pipe, ...@@ -293,10 +293,12 @@ static int vsp1_video_pipeline_build(struct vsp1_pipeline *pipe,
rwpf = to_rwpf(subdev); rwpf = to_rwpf(subdev);
pipe->inputs[rwpf->entity.index] = rwpf; pipe->inputs[rwpf->entity.index] = rwpf;
rwpf->video->pipe_index = ++pipe->num_inputs; rwpf->video->pipe_index = ++pipe->num_inputs;
rwpf->pipe = pipe;
} else if (e->type == VSP1_ENTITY_WPF) { } else if (e->type == VSP1_ENTITY_WPF) {
rwpf = to_rwpf(subdev); rwpf = to_rwpf(subdev);
pipe->output = rwpf; pipe->output = rwpf;
rwpf->video->pipe_index = 0; rwpf->video->pipe_index = 0;
rwpf->pipe = pipe;
} else if (e->type == VSP1_ENTITY_LIF) { } else if (e->type == VSP1_ENTITY_LIF) {
pipe->lif = e; pipe->lif = e;
} else if (e->type == VSP1_ENTITY_BRU) { } else if (e->type == VSP1_ENTITY_BRU) {
...@@ -384,7 +386,7 @@ static void vsp1_video_pipeline_cleanup(struct vsp1_pipeline *pipe) ...@@ -384,7 +386,7 @@ static void vsp1_video_pipeline_cleanup(struct vsp1_pipeline *pipe)
static struct vsp1_vb2_buffer * static struct vsp1_vb2_buffer *
vsp1_video_complete_buffer(struct vsp1_video *video) vsp1_video_complete_buffer(struct vsp1_video *video)
{ {
struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); struct vsp1_pipeline *pipe = video->rwpf->pipe;
struct vsp1_vb2_buffer *next = NULL; struct vsp1_vb2_buffer *next = NULL;
struct vsp1_vb2_buffer *done; struct vsp1_vb2_buffer *done;
unsigned long flags; unsigned long flags;
...@@ -563,7 +565,7 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb) ...@@ -563,7 +565,7 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb)
{ {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue); struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue);
struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); struct vsp1_pipeline *pipe = video->rwpf->pipe;
struct vsp1_vb2_buffer *buf = to_vsp1_vb2_buffer(vbuf); struct vsp1_vb2_buffer *buf = to_vsp1_vb2_buffer(vbuf);
unsigned long flags; unsigned long flags;
bool empty; bool empty;
...@@ -628,7 +630,7 @@ static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe) ...@@ -628,7 +630,7 @@ static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe)
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)
{ {
struct vsp1_video *video = vb2_get_drv_priv(vq); struct vsp1_video *video = vb2_get_drv_priv(vq);
struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); struct vsp1_pipeline *pipe = video->rwpf->pipe;
unsigned long flags; unsigned long flags;
int ret; int ret;
...@@ -655,7 +657,7 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count) ...@@ -655,7 +657,7 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
static void vsp1_video_stop_streaming(struct vb2_queue *vq) static void vsp1_video_stop_streaming(struct vb2_queue *vq)
{ {
struct vsp1_video *video = vb2_get_drv_priv(vq); struct vsp1_video *video = vb2_get_drv_priv(vq);
struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); struct vsp1_pipeline *pipe = video->rwpf->pipe;
struct vsp1_vb2_buffer *buffer; struct vsp1_vb2_buffer *buffer;
unsigned long flags; unsigned long flags;
int ret; int ret;
...@@ -802,8 +804,7 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) ...@@ -802,8 +804,7 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
* FIXME: This is racy, the ioctl is only protected by the video node * FIXME: This is racy, the ioctl is only protected by the video node
* lock. * lock.
*/ */
pipe = video->video.entity.pipe pipe = video->rwpf->pipe ? video->rwpf->pipe : &video->pipe;
? to_vsp1_pipeline(&video->video.entity) : &video->pipe;
ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe); ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe);
if (ret < 0) if (ret < 0)
......
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