Skip to content

Commit

Permalink
[media] s5p-fimc: Rework the video pipeline control functions
Browse files Browse the repository at this point in the history
There is getting more entities to manage within single video pipeline
in newer SoCs. To simplify code put subdevs' pointer into an array
rather than adding new member in struct fimc_pipeline for each subdev.
This allows to easier handle subdev operations in proper order.

Additionally walk graph in one direction only in fimc_pipeline_prepare()
function to make sure we properly gather only media entities that below
to single data pipeline. This avoids wrong initialization in case where,
for example there are multiple active links from s5p-mipi-csis subdev
output pad.

struct fimc_pipeline declaration is moved to the driver's public header
to allow other drivers to reuse the fimc-lite driver added in subsequent
patches.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Sylwester Nawrocki authored and Mauro Carvalho Chehab committed May 20, 2012
1 parent 2b511ed commit 0f735f5
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 88 deletions.
32 changes: 17 additions & 15 deletions drivers/media/video/s5p-fimc/fimc-capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@
static int fimc_init_capture(struct fimc_dev *fimc)
{
struct fimc_ctx *ctx = fimc->vid_cap.ctx;
struct fimc_pipeline *p = &fimc->pipeline;
struct fimc_sensor_info *sensor;
unsigned long flags;
int ret = 0;

if (fimc->pipeline.sensor == NULL || ctx == NULL)
if (p->subdevs[IDX_SENSOR] == NULL || ctx == NULL)
return -ENXIO;
if (ctx->s_frame.fmt == NULL)
return -EINVAL;

sensor = v4l2_get_subdev_hostdata(fimc->pipeline.sensor);
sensor = v4l2_get_subdev_hostdata(p->subdevs[IDX_SENSOR]);

spin_lock_irqsave(&fimc->slock, flags);
fimc_prepare_dma_offset(ctx, &ctx->d_frame);
Expand Down Expand Up @@ -109,7 +110,7 @@ static int fimc_capture_state_cleanup(struct fimc_dev *fimc, bool suspend)
spin_unlock_irqrestore(&fimc->slock, flags);

if (streaming)
return fimc_pipeline_s_stream(fimc, 0);
return fimc_pipeline_s_stream(&fimc->pipeline, 0);
else
return 0;
}
Expand Down Expand Up @@ -254,7 +255,7 @@ static int start_streaming(struct vb2_queue *q, unsigned int count)
fimc_activate_capture(ctx);

if (!test_and_set_bit(ST_CAPT_ISP_STREAM, &fimc->state))
fimc_pipeline_s_stream(fimc, 1);
fimc_pipeline_s_stream(&fimc->pipeline, 1);
}

return 0;
Expand All @@ -281,7 +282,7 @@ int fimc_capture_suspend(struct fimc_dev *fimc)
int ret = fimc_stop_capture(fimc, suspend);
if (ret)
return ret;
return fimc_pipeline_shutdown(fimc);
return fimc_pipeline_shutdown(&fimc->pipeline);
}

static void buffer_queue(struct vb2_buffer *vb);
Expand All @@ -297,7 +298,7 @@ int fimc_capture_resume(struct fimc_dev *fimc)

INIT_LIST_HEAD(&fimc->vid_cap.active_buf_q);
vid_cap->buf_index = 0;
fimc_pipeline_initialize(fimc, &fimc->vid_cap.vfd->entity,
fimc_pipeline_initialize(&fimc->pipeline, &vid_cap->vfd->entity,
false);
fimc_init_capture(fimc);

Expand Down Expand Up @@ -414,7 +415,7 @@ static void buffer_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(&fimc->slock, flags);

if (!test_and_set_bit(ST_CAPT_ISP_STREAM, &fimc->state))
fimc_pipeline_s_stream(fimc, 1);
fimc_pipeline_s_stream(&fimc->pipeline, 1);
return;
}
spin_unlock_irqrestore(&fimc->slock, flags);
Expand Down Expand Up @@ -464,7 +465,7 @@ int fimc_capture_ctrls_create(struct fimc_dev *fimc)
return ret;

return v4l2_ctrl_add_handler(&vid_cap->ctx->ctrl_handler,
fimc->pipeline.sensor->ctrl_handler);
fimc->pipeline.subdevs[IDX_SENSOR]->ctrl_handler);
}

static int fimc_capture_set_default_format(struct fimc_dev *fimc);
Expand All @@ -487,7 +488,7 @@ static int fimc_capture_open(struct file *file)
pm_runtime_get_sync(&fimc->pdev->dev);

if (++fimc->vid_cap.refcnt == 1) {
ret = fimc_pipeline_initialize(fimc,
ret = fimc_pipeline_initialize(&fimc->pipeline,
&fimc->vid_cap.vfd->entity, true);
if (ret < 0) {
dev_err(&fimc->pdev->dev,
Expand Down Expand Up @@ -515,7 +516,7 @@ static int fimc_capture_close(struct file *file)
if (--fimc->vid_cap.refcnt == 0) {
clear_bit(ST_CAPT_BUSY, &fimc->state);
fimc_stop_capture(fimc, false);
fimc_pipeline_shutdown(fimc);
fimc_pipeline_shutdown(&fimc->pipeline);
clear_bit(ST_CAPT_SUSPENDED, &fimc->state);
}

Expand Down Expand Up @@ -736,8 +737,8 @@ static int fimc_pipeline_try_format(struct fimc_ctx *ctx,
bool set)
{
struct fimc_dev *fimc = ctx->fimc_dev;
struct v4l2_subdev *sd = fimc->pipeline.sensor;
struct v4l2_subdev *csis = fimc->pipeline.csis;
struct v4l2_subdev *sd = fimc->pipeline.subdevs[IDX_SENSOR];
struct v4l2_subdev *csis = fimc->pipeline.subdevs[IDX_CSIS];
struct v4l2_subdev_format sfmt;
struct v4l2_mbus_framefmt *mf = &sfmt.format;
struct fimc_fmt *ffmt = NULL;
Expand Down Expand Up @@ -945,7 +946,7 @@ static int fimc_cap_enum_input(struct file *file, void *priv,
struct v4l2_input *i)
{
struct fimc_dev *fimc = video_drvdata(file);
struct v4l2_subdev *sd = fimc->pipeline.sensor;
struct v4l2_subdev *sd = fimc->pipeline.subdevs[IDX_SENSOR];

if (i->index != 0)
return -EINVAL;
Expand Down Expand Up @@ -1037,7 +1038,8 @@ static int fimc_cap_streamon(struct file *file, void *priv,
if (fimc_capture_active(fimc))
return -EBUSY;

media_entity_pipeline_start(&p->sensor->entity, p->pipe);
media_entity_pipeline_start(&p->subdevs[IDX_SENSOR]->entity,
p->m_pipeline);

if (fimc->vid_cap.user_subdev_api) {
ret = fimc_pipeline_validate(fimc);
Expand All @@ -1051,7 +1053,7 @@ static int fimc_cap_streamoff(struct file *file, void *priv,
enum v4l2_buf_type type)
{
struct fimc_dev *fimc = video_drvdata(file);
struct v4l2_subdev *sd = fimc->pipeline.sensor;
struct v4l2_subdev *sd = fimc->pipeline.subdevs[IDX_SENSOR];
int ret;

ret = vb2_streamoff(&fimc->vid_cap.vbq, type);
Expand Down
5 changes: 0 additions & 5 deletions drivers/media/video/s5p-fimc/fimc-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,6 @@ struct samsung_fimc_driverdata {
int num_entities;
};

struct fimc_pipeline {
struct media_pipeline *pipe;
struct v4l2_subdev *sensor;
struct v4l2_subdev *csis;
};

struct fimc_ctx;

Expand Down
Loading

0 comments on commit 0f735f5

Please sign in to comment.