Skip to content

Commit b7fb767

Browse files
jason-jh.linChun-Kuang Hu
authored andcommitted
drm/mediatek: Add DSC support for mediatek-drm
DSC is designed for real-time systems with real-time compression, transmission, decompression and display. The DSC standard is a specification of the algorithms used for compressing and decompressing image display streams, including the specification of the syntax and semantics of the compressed video bit stream. Link: https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/ Signed-off-by: jason-jh.lin <[email protected]> Acked-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent f2906aa commit b7fb767

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
#define DITHER_LSB_ERR_SHIFT_G(x) (((x) & 0x7) << 12)
4141
#define DITHER_ADD_LSHIFT_G(x) (((x) & 0x7) << 4)
4242

43+
#define DISP_REG_DSC_CON 0x0000
44+
#define DSC_EN BIT(0)
45+
#define DSC_DUAL_INOUT BIT(2)
46+
#define DSC_BYPASS BIT(4)
47+
#define DSC_UFOE_SEL BIT(16)
48+
4349
#define DISP_REG_OD_EN 0x0000
4450
#define DISP_REG_OD_CFG 0x0020
4551
#define OD_RELAYMODE BIT(0)
@@ -181,6 +187,36 @@ static void mtk_dither_set(struct device *dev, unsigned int bpc,
181187
DISP_DITHERING, cmdq_pkt);
182188
}
183189

190+
static void mtk_dsc_config(struct device *dev, unsigned int w,
191+
unsigned int h, unsigned int vrefresh,
192+
unsigned int bpc, struct cmdq_pkt *cmdq_pkt)
193+
{
194+
struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev);
195+
196+
/* dsc bypass mode */
197+
mtk_ddp_write_mask(cmdq_pkt, DSC_BYPASS, &priv->cmdq_reg, priv->regs,
198+
DISP_REG_DSC_CON, DSC_BYPASS);
199+
mtk_ddp_write_mask(cmdq_pkt, DSC_UFOE_SEL, &priv->cmdq_reg, priv->regs,
200+
DISP_REG_DSC_CON, DSC_UFOE_SEL);
201+
mtk_ddp_write_mask(cmdq_pkt, DSC_DUAL_INOUT, &priv->cmdq_reg, priv->regs,
202+
DISP_REG_DSC_CON, DSC_DUAL_INOUT);
203+
}
204+
205+
static void mtk_dsc_start(struct device *dev)
206+
{
207+
struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev);
208+
209+
/* write with mask to reserve the value set in mtk_dsc_config */
210+
mtk_ddp_write_mask(NULL, DSC_EN, &priv->cmdq_reg, priv->regs, DISP_REG_DSC_CON, DSC_EN);
211+
}
212+
213+
static void mtk_dsc_stop(struct device *dev)
214+
{
215+
struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev);
216+
217+
writel_relaxed(0x0, priv->regs + DISP_REG_DSC_CON);
218+
}
219+
184220
static void mtk_od_config(struct device *dev, unsigned int w,
185221
unsigned int h, unsigned int vrefresh,
186222
unsigned int bpc, struct cmdq_pkt *cmdq_pkt)
@@ -270,6 +306,14 @@ static const struct mtk_ddp_comp_funcs ddp_dpi = {
270306
.stop = mtk_dpi_stop,
271307
};
272308

309+
static const struct mtk_ddp_comp_funcs ddp_dsc = {
310+
.clk_enable = mtk_ddp_clk_enable,
311+
.clk_disable = mtk_ddp_clk_disable,
312+
.config = mtk_dsc_config,
313+
.start = mtk_dsc_start,
314+
.stop = mtk_dsc_stop,
315+
};
316+
273317
static const struct mtk_ddp_comp_funcs ddp_dsi = {
274318
.start = mtk_dsi_ddp_start,
275319
.stop = mtk_dsi_ddp_stop,
@@ -343,6 +387,7 @@ static const char * const mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX] = {
343387
[MTK_DISP_CCORR] = "ccorr",
344388
[MTK_DISP_COLOR] = "color",
345389
[MTK_DISP_DITHER] = "dither",
390+
[MTK_DISP_DSC] = "dsc",
346391
[MTK_DISP_GAMMA] = "gamma",
347392
[MTK_DISP_MUTEX] = "mutex",
348393
[MTK_DISP_OD] = "od",
@@ -373,6 +418,8 @@ static const struct mtk_ddp_comp_match mtk_ddp_matches[DDP_COMPONENT_ID_MAX] = {
373418
[DDP_COMPONENT_DITHER] = { MTK_DISP_DITHER, 0, &ddp_dither },
374419
[DDP_COMPONENT_DPI0] = { MTK_DPI, 0, &ddp_dpi },
375420
[DDP_COMPONENT_DPI1] = { MTK_DPI, 1, &ddp_dpi },
421+
[DDP_COMPONENT_DSC0] = { MTK_DISP_DSC, 0, &ddp_dsc },
422+
[DDP_COMPONENT_DSC1] = { MTK_DISP_DSC, 1, &ddp_dsc },
376423
[DDP_COMPONENT_DSI0] = { MTK_DSI, 0, &ddp_dsi },
377424
[DDP_COMPONENT_DSI1] = { MTK_DSI, 1, &ddp_dsi },
378425
[DDP_COMPONENT_DSI2] = { MTK_DSI, 2, &ddp_dsi },

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum mtk_ddp_comp_type {
2323
MTK_DISP_CCORR,
2424
MTK_DISP_COLOR,
2525
MTK_DISP_DITHER,
26+
MTK_DISP_DSC,
2627
MTK_DISP_GAMMA,
2728
MTK_DISP_MUTEX,
2829
MTK_DISP_OD,

0 commit comments

Comments
 (0)