Skip to content

Commit e90561d

Browse files
kbinghammchehab
authored andcommitted
media: vsp1: Support Interlaced display pipelines
Calculate the top and bottom fields for the interlaced frames and utilise the extended display list command feature to implement the auto-field operations. This allows the DU to update the VSP2 registers dynamically based upon the currently processing field. Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
1 parent f3b98e3 commit e90561d

6 files changed

Lines changed: 90 additions & 5 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,8 @@ void vsp1_dl_list_commit(struct vsp1_dl_list *dl, bool internal)
947947
*/
948948
unsigned int vsp1_dlm_irq_frame_end(struct vsp1_dl_manager *dlm)
949949
{
950+
struct vsp1_device *vsp1 = dlm->vsp1;
951+
u32 status = vsp1_read(vsp1, VI6_STATUS);
950952
unsigned int flags = 0;
951953

952954
spin_lock(&dlm->lock);
@@ -971,6 +973,14 @@ unsigned int vsp1_dlm_irq_frame_end(struct vsp1_dl_manager *dlm)
971973
if (vsp1_dl_list_hw_update_pending(dlm))
972974
goto done;
973975

976+
/*
977+
* Progressive streams report only TOP fields. If we have a BOTTOM
978+
* field, we are interlaced, and expect the frame to complete on the
979+
* next frame end interrupt.
980+
*/
981+
if (status & VI6_STATUS_FLD_STD(dlm->index))
982+
goto done;
983+
974984
/*
975985
* The device starts processing the queued display list right after the
976986
* frame end interrupt. The display list thus becomes active.

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,11 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
670670

671671
drm_pipe->width = cfg->width;
672672
drm_pipe->height = cfg->height;
673+
pipe->interlaced = cfg->interlaced;
673674

674-
dev_dbg(vsp1->dev, "%s: configuring LIF%u with format %ux%u\n",
675-
__func__, pipe_index, cfg->width, cfg->height);
675+
dev_dbg(vsp1->dev, "%s: configuring LIF%u with format %ux%u%s\n",
676+
__func__, pipe_index, cfg->width, cfg->height,
677+
pipe->interlaced ? "i" : "");
676678

677679
mutex_lock(&vsp1->drm->lock);
678680

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct vsp1_partition {
104104
* @entities: list of entities in the pipeline
105105
* @stream_config: cached stream configuration for video pipelines
106106
* @configured: when false the @stream_config shall be written to the hardware
107+
* @interlaced: True when the pipeline is configured in interlaced mode
107108
* @partitions: The number of partitions used to process one frame
108109
* @partition: The current partition for configuration to process
109110
* @part_table: The pre-calculated partitions used by the pipeline
@@ -142,6 +143,7 @@ struct vsp1_pipeline {
142143

143144
struct vsp1_dl_body *stream_config;
144145
bool configured;
146+
bool interlaced;
145147

146148
unsigned int partitions;
147149
struct vsp1_partition *partition;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define VI6_SRESET_SRTS(n) (1 << (n))
2929

3030
#define VI6_STATUS 0x0038
31+
#define VI6_STATUS_FLD_STD(n) (1 << ((n) + 28))
3132
#define VI6_STATUS_SYS_ACT(n) (1 << ((n) + 8))
3233

3334
#define VI6_WPF_IRQ_ENB(n) (0x0048 + (n) * 12)
@@ -80,6 +81,8 @@
8081
#define VI6_DL_EXT_CTRL_EXPRI (1 << 4)
8182
#define VI6_DL_EXT_CTRL_EXT (1 << 0)
8283

84+
#define VI6_DL_EXT_AUTOFLD_INT BIT(0)
85+
8386
#define VI6_DL_BODY_SIZE 0x0120
8487
#define VI6_DL_BODY_SIZE_UPD (1 << 24)
8588
#define VI6_DL_BODY_SIZE_BS_MASK (0x1ffff << 0)

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

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@
2020
#define RPF_MAX_WIDTH 8190
2121
#define RPF_MAX_HEIGHT 8190
2222

23+
/* Pre extended display list command data structure. */
24+
struct vsp1_extcmd_auto_fld_body {
25+
u32 top_y0;
26+
u32 bottom_y0;
27+
u32 top_c0;
28+
u32 bottom_c0;
29+
u32 top_c1;
30+
u32 bottom_c1;
31+
u32 reserved0;
32+
u32 reserved1;
33+
} __packed;
34+
2335
/* -----------------------------------------------------------------------------
2436
* Device Access
2537
*/
@@ -64,6 +76,14 @@ static void rpf_configure_stream(struct vsp1_entity *entity,
6476
pstride |= format->plane_fmt[1].bytesperline
6577
<< VI6_RPF_SRCM_PSTRIDE_C_SHIFT;
6678

79+
/*
80+
* pstride has both STRIDE_Y and STRIDE_C, but multiplying the whole
81+
* of pstride by 2 is conveniently OK here as we are multiplying both
82+
* values.
83+
*/
84+
if (pipe->interlaced)
85+
pstride *= 2;
86+
6787
vsp1_rpf_write(rpf, dlb, VI6_RPF_SRCM_PSTRIDE, pstride);
6888

6989
/* Format */
@@ -100,6 +120,9 @@ static void rpf_configure_stream(struct vsp1_entity *entity,
100120
top = compose->top;
101121
}
102122

123+
if (pipe->interlaced)
124+
top /= 2;
125+
103126
vsp1_rpf_write(rpf, dlb, VI6_RPF_LOC,
104127
(left << VI6_RPF_LOC_HCOORD_SHIFT) |
105128
(top << VI6_RPF_LOC_VCOORD_SHIFT));
@@ -169,6 +192,36 @@ static void rpf_configure_stream(struct vsp1_entity *entity,
169192

170193
}
171194

195+
static void vsp1_rpf_configure_autofld(struct vsp1_rwpf *rpf,
196+
struct vsp1_dl_list *dl)
197+
{
198+
const struct v4l2_pix_format_mplane *format = &rpf->format;
199+
struct vsp1_dl_ext_cmd *cmd;
200+
struct vsp1_extcmd_auto_fld_body *auto_fld;
201+
u32 offset_y, offset_c;
202+
203+
cmd = vsp1_dl_get_pre_cmd(dl);
204+
if (WARN_ONCE(!cmd, "Failed to obtain an autofld cmd"))
205+
return;
206+
207+
/* Re-index our auto_fld to match the current RPF. */
208+
auto_fld = cmd->data;
209+
auto_fld = &auto_fld[rpf->entity.index];
210+
211+
auto_fld->top_y0 = rpf->mem.addr[0];
212+
auto_fld->top_c0 = rpf->mem.addr[1];
213+
auto_fld->top_c1 = rpf->mem.addr[2];
214+
215+
offset_y = format->plane_fmt[0].bytesperline;
216+
offset_c = format->plane_fmt[1].bytesperline;
217+
218+
auto_fld->bottom_y0 = rpf->mem.addr[0] + offset_y;
219+
auto_fld->bottom_c0 = rpf->mem.addr[1] + offset_c;
220+
auto_fld->bottom_c1 = rpf->mem.addr[2] + offset_c;
221+
222+
cmd->flags |= VI6_DL_EXT_AUTOFLD_INT | BIT(16 + rpf->entity.index);
223+
}
224+
172225
static void rpf_configure_frame(struct vsp1_entity *entity,
173226
struct vsp1_pipeline *pipe,
174227
struct vsp1_dl_list *dl,
@@ -221,6 +274,11 @@ static void rpf_configure_partition(struct vsp1_entity *entity,
221274
crop.left += pipe->partition->rpf.left;
222275
}
223276

277+
if (pipe->interlaced) {
278+
crop.height = round_down(crop.height / 2, fmtinfo->vsub);
279+
crop.top = round_down(crop.top / 2, fmtinfo->vsub);
280+
}
281+
224282
vsp1_rpf_write(rpf, dlb, VI6_RPF_SRC_BSIZE,
225283
(crop.width << VI6_RPF_SRC_BSIZE_BHSIZE_SHIFT) |
226284
(crop.height << VI6_RPF_SRC_BSIZE_BVSIZE_SHIFT));
@@ -249,9 +307,17 @@ static void rpf_configure_partition(struct vsp1_entity *entity,
249307
fmtinfo->swap_uv)
250308
swap(mem.addr[1], mem.addr[2]);
251309

252-
vsp1_rpf_write(rpf, dlb, VI6_RPF_SRCM_ADDR_Y, mem.addr[0]);
253-
vsp1_rpf_write(rpf, dlb, VI6_RPF_SRCM_ADDR_C0, mem.addr[1]);
254-
vsp1_rpf_write(rpf, dlb, VI6_RPF_SRCM_ADDR_C1, mem.addr[2]);
310+
/*
311+
* Interlaced pipelines will use the extended pre-cmd to process
312+
* SRCM_ADDR_{Y,C0,C1}
313+
*/
314+
if (pipe->interlaced) {
315+
vsp1_rpf_configure_autofld(rpf, dl);
316+
} else {
317+
vsp1_rpf_write(rpf, dlb, VI6_RPF_SRCM_ADDR_Y, mem.addr[0]);
318+
vsp1_rpf_write(rpf, dlb, VI6_RPF_SRCM_ADDR_C0, mem.addr[1]);
319+
vsp1_rpf_write(rpf, dlb, VI6_RPF_SRCM_ADDR_C1, mem.addr[2]);
320+
}
255321
}
256322

257323
static void rpf_partition(struct vsp1_entity *entity,

‎include/media/vsp1.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ int vsp1_du_init(struct device *dev);
2525
* struct vsp1_du_lif_config - VSP LIF configuration
2626
* @width: output frame width
2727
* @height: output frame height
28+
* @interlaced: true for interlaced pipelines
2829
* @callback: frame completion callback function (optional). When a callback
2930
* is provided, the VSP driver guarantees that it will be called once
3031
* and only once for each vsp1_du_atomic_flush() call.
@@ -33,6 +34,7 @@ int vsp1_du_init(struct device *dev);
3334
struct vsp1_du_lif_config {
3435
unsigned int width;
3536
unsigned int height;
37+
bool interlaced;
3638

3739
void (*callback)(void *data, bool completed, u32 crc);
3840
void *callback_data;

0 commit comments

Comments
 (0)