Commit 2e63c4c5 authored by Tomi Valkeinen's avatar Tomi Valkeinen Committed by Mauro Carvalho Chehab

media: ti-vpe: cal: add cal_ctx_prepare/unprepare

In the following patches we need to do context configuration which might
fail. Add new functions, cal_ctx_prepare and cal_ctx_unprepare, to
handle such configuration.

[hverkuil: fix spurious newline checkpatch warning]
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent bbdb9ae8
...@@ -708,6 +708,12 @@ static int cal_start_streaming(struct vb2_queue *vq, unsigned int count) ...@@ -708,6 +708,12 @@ static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)
goto error_pipeline; goto error_pipeline;
} }
ret = cal_ctx_prepare(ctx);
if (ret) {
ctx_err(ctx, "Failed to prepare context: %d\n", ret);
goto error_pipeline;
}
spin_lock_irq(&ctx->dma.lock); spin_lock_irq(&ctx->dma.lock);
buf = list_first_entry(&ctx->dma.queue, struct cal_buffer, list); buf = list_first_entry(&ctx->dma.queue, struct cal_buffer, list);
ctx->dma.pending = buf; ctx->dma.pending = buf;
...@@ -735,6 +741,7 @@ static int cal_start_streaming(struct vb2_queue *vq, unsigned int count) ...@@ -735,6 +741,7 @@ static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)
error_stop: error_stop:
cal_ctx_stop(ctx); cal_ctx_stop(ctx);
pm_runtime_put_sync(ctx->cal->dev); pm_runtime_put_sync(ctx->cal->dev);
cal_ctx_unprepare(ctx);
error_pipeline: error_pipeline:
media_pipeline_stop(&ctx->vdev.entity); media_pipeline_stop(&ctx->vdev.entity);
...@@ -754,6 +761,8 @@ static void cal_stop_streaming(struct vb2_queue *vq) ...@@ -754,6 +761,8 @@ static void cal_stop_streaming(struct vb2_queue *vq)
pm_runtime_put_sync(ctx->cal->dev); pm_runtime_put_sync(ctx->cal->dev);
cal_ctx_unprepare(ctx);
cal_release_buffers(ctx, VB2_BUF_STATE_ERROR); cal_release_buffers(ctx, VB2_BUF_STATE_ERROR);
media_pipeline_stop(&ctx->vdev.entity); media_pipeline_stop(&ctx->vdev.entity);
......
...@@ -430,6 +430,15 @@ static bool cal_ctx_wr_dma_stopped(struct cal_ctx *ctx) ...@@ -430,6 +430,15 @@ static bool cal_ctx_wr_dma_stopped(struct cal_ctx *ctx)
return stopped; return stopped;
} }
int cal_ctx_prepare(struct cal_ctx *ctx)
{
return 0;
}
void cal_ctx_unprepare(struct cal_ctx *ctx)
{
}
void cal_ctx_start(struct cal_ctx *ctx) void cal_ctx_start(struct cal_ctx *ctx)
{ {
ctx->sequence = 0; ctx->sequence = 0;
......
...@@ -296,6 +296,8 @@ struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal, ...@@ -296,6 +296,8 @@ struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal,
unsigned int instance); unsigned int instance);
void cal_camerarx_destroy(struct cal_camerarx *phy); void cal_camerarx_destroy(struct cal_camerarx *phy);
int cal_ctx_prepare(struct cal_ctx *ctx);
void cal_ctx_unprepare(struct cal_ctx *ctx);
void cal_ctx_set_dma_addr(struct cal_ctx *ctx, dma_addr_t addr); void cal_ctx_set_dma_addr(struct cal_ctx *ctx, dma_addr_t addr);
void cal_ctx_start(struct cal_ctx *ctx); void cal_ctx_start(struct cal_ctx *ctx);
void cal_ctx_stop(struct cal_ctx *ctx); void cal_ctx_stop(struct cal_ctx *ctx);
......
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