Skip to content

Commit a63722a

Browse files
author
Laurent Pinchart
committed
media: vsp1: drm: Implement writeback support
Extend the vsp1_du_atomic_flush() API with writeback support by adding format, pitch and memory addresses of the writeback framebuffer. Writeback completion is reported through the existing frame completion callback with a new VSP1_DU_STATUS_WRITEBACK status flag. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Reviewed-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
1 parent 09e513e commit a63722a

4 files changed

Lines changed: 55 additions & 2 deletions

File tree

‎drivers/media/platform/vsp1/vsp1_dl.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,9 @@ void vsp1_dl_list_commit(struct vsp1_dl_list *dl, unsigned int dl_flags)
958958
*
959959
* The VSP1_DL_FRAME_END_INTERNAL flag indicates that the display list that just
960960
* became active had been queued with the internal notification flag.
961+
*
962+
* The VSP1_DL_FRAME_END_WRITEBACK flag indicates that the previously active
963+
* display list had been queued with the writeback flag.
961964
*/
962965
unsigned int vsp1_dlm_irq_frame_end(struct vsp1_dl_manager *dlm)
963966
{
@@ -995,6 +998,17 @@ unsigned int vsp1_dlm_irq_frame_end(struct vsp1_dl_manager *dlm)
995998
if (status & VI6_STATUS_FLD_STD(dlm->index))
996999
goto done;
9971000

1001+
/*
1002+
* If the active display list has the writeback flag set, the frame
1003+
* completion marks the end of the writeback capture. Return the
1004+
* VSP1_DL_FRAME_END_WRITEBACK flag and reset the display list's
1005+
* writeback flag.
1006+
*/
1007+
if (dlm->active && (dlm->active->flags & VSP1_DL_FRAME_END_WRITEBACK)) {
1008+
flags |= VSP1_DL_FRAME_END_WRITEBACK;
1009+
dlm->active->flags &= ~VSP1_DL_FRAME_END_WRITEBACK;
1010+
}
1011+
9981012
/*
9991013
* The device starts processing the queued display list right after the
10001014
* frame end interrupt. The display list thus becomes active.

‎drivers/media/platform/vsp1/vsp1_dl.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ struct vsp1_dl_manager;
1919

2020
/* Keep these flags in sync with VSP1_DU_STATUS_* in include/media/vsp1.h. */
2121
#define VSP1_DL_FRAME_END_COMPLETED BIT(0)
22-
#define VSP1_DL_FRAME_END_INTERNAL BIT(1)
22+
#define VSP1_DL_FRAME_END_WRITEBACK BIT(1)
23+
#define VSP1_DL_FRAME_END_INTERNAL BIT(2)
2324

2425
/**
2526
* struct vsp1_dl_ext_cmd - Extended Display command

‎drivers/media/platform/vsp1/vsp1_drm.c‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ static void vsp1_du_pipeline_frame_end(struct vsp1_pipeline *pipe,
3737

3838
if (drm_pipe->du_complete) {
3939
struct vsp1_entity *uif = drm_pipe->uif;
40-
unsigned int status = completion & VSP1_DU_STATUS_COMPLETE;
40+
unsigned int status = completion
41+
& (VSP1_DU_STATUS_COMPLETE |
42+
VSP1_DU_STATUS_WRITEBACK);
4143
u32 crc;
4244

4345
crc = uif ? vsp1_uif_get_crc(to_uif(&uif->subdev)) : 0;
@@ -541,6 +543,8 @@ static void vsp1_du_pipeline_configure(struct vsp1_pipeline *pipe)
541543

542544
if (drm_pipe->force_brx_release)
543545
dl_flags |= VSP1_DL_FRAME_END_INTERNAL;
546+
if (pipe->output->writeback)
547+
dl_flags |= VSP1_DL_FRAME_END_WRITEBACK;
544548

545549
dl = vsp1_dl_list_get(pipe->output->dlm);
546550
dlb = vsp1_dl_list_get_body0(dl);
@@ -870,12 +874,31 @@ void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index,
870874
struct vsp1_device *vsp1 = dev_get_drvdata(dev);
871875
struct vsp1_drm_pipeline *drm_pipe = &vsp1->drm->pipe[pipe_index];
872876
struct vsp1_pipeline *pipe = &drm_pipe->pipe;
877+
int ret;
873878

874879
drm_pipe->crc = cfg->crc;
875880

876881
mutex_lock(&vsp1->drm->lock);
882+
883+
if (cfg->writeback.pixelformat) {
884+
const struct vsp1_du_writeback_config *wb_cfg = &cfg->writeback;
885+
886+
ret = vsp1_du_pipeline_set_rwpf_format(vsp1, pipe->output,
887+
wb_cfg->pixelformat,
888+
wb_cfg->pitch);
889+
if (WARN_ON(ret < 0))
890+
goto done;
891+
892+
pipe->output->mem.addr[0] = wb_cfg->mem[0];
893+
pipe->output->mem.addr[1] = wb_cfg->mem[1];
894+
pipe->output->mem.addr[2] = wb_cfg->mem[2];
895+
pipe->output->writeback = true;
896+
}
897+
877898
vsp1_du_pipeline_setup_inputs(vsp1, pipe);
878899
vsp1_du_pipeline_configure(pipe);
900+
901+
done:
879902
mutex_unlock(&vsp1->drm->lock);
880903
}
881904
EXPORT_SYMBOL_GPL(vsp1_du_atomic_flush);

‎include/media/vsp1.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct device;
1818
int vsp1_du_init(struct device *dev);
1919

2020
#define VSP1_DU_STATUS_COMPLETE BIT(0)
21+
#define VSP1_DU_STATUS_WRITEBACK BIT(1)
2122

2223
/**
2324
* struct vsp1_du_lif_config - VSP LIF configuration
@@ -83,12 +84,26 @@ struct vsp1_du_crc_config {
8384
unsigned int index;
8485
};
8586

87+
/**
88+
* struct vsp1_du_writeback_config - VSP writeback configuration parameters
89+
* @pixelformat: plane pixel format (V4L2 4CC)
90+
* @pitch: line pitch in bytes for the first plane
91+
* @mem: DMA memory address for each plane of the frame buffer
92+
*/
93+
struct vsp1_du_writeback_config {
94+
u32 pixelformat;
95+
unsigned int pitch;
96+
dma_addr_t mem[3];
97+
};
98+
8699
/**
87100
* struct vsp1_du_atomic_pipe_config - VSP atomic pipe configuration parameters
88101
* @crc: CRC computation configuration
102+
* @writeback: writeback configuration
89103
*/
90104
struct vsp1_du_atomic_pipe_config {
91105
struct vsp1_du_crc_config crc;
106+
struct vsp1_du_writeback_config writeback;
92107
};
93108

94109
void vsp1_du_atomic_begin(struct device *dev, unsigned int pipe_index);

0 commit comments

Comments
 (0)