Support IGT in display driver
Subsystems (3)
v7 cover Support IGT in display driver
From: Hsiao Chien Sung <[email protected]>
This series is based on [email protected]
This series adds support for running IGT (Intel GPU Tool) tests with MediaTek display driver. The following changes will be applied:
1. Add a new API for creating GCE thread loop to retrieve CRCs from the hardware component
2. Support hardware CRC calculation in both VDOSYS0 and VDOSYS1
3. Support alpha blending in both VDOSYS0 and VDOSYS1
Changes in v7:
- Separate the patch into smaller ones
Changes in v6:
- Use drm_vblank_work to deffer the CRC work into bottom halves
- Separate the patches for "Premultiplied" and "None" alpha blending
Changes in v5:
- Add more descriptions to the codes
- Add DRM mode configs to the driver data
- Squash and rearrange the commits
Changes in v4:
- Separate the patch into smaller ones
- Change the title of some patches
- Revert the changes that are not related to the series
Changes in v3:
- Modify the dt-binding document of Mediatek OVL
- Set DRM mode configs accroding to the hardware capabilities
- Replace cmdq_pkt_jump_absolute() with cmdq_pkt_jump()
Changes in v2:
- Simplify CMDQ by adding commands that are currently used only
- Integrate CRC related codes into new APIs for Mixer and OVL to reuse
- Add CPU version CRC retrieval when CMDQ is disabled
Hsiao Chien Sung (18):
soc: mediatek: Disable 9-bit alpha in ETHDR drm/mediatek: Add OVL compatible name for MT8195 drm/mediatek: Add missing plane settings when async update drm/mediatek: Add DRM_MODE_ROTATE_0 to rotation property drm/mediatek: Set DRM mode configs accordingly drm/mediatek: Turn off the layers with zero width or height drm/mediatek: Support more 10bit formats in OVL drm/mediatek: Support RGBA8888 and RGBX8888 in OVL drm/mediatek: Support constant blending in OVL drm/mediatek: Support constant blending in Mixer drm/mediatek: Support "Pre-multiplied" blending in OVL drm/mediatek: Support "Pre-multiplied" blending in Mixer drm/mediatek: Support "None" blending in OVL drm/mediatek: Support "None" blending in Mixer drm/mediatek: Support alpha blending in display driver drm/mediatek: Support CRC in display driver drm/mediatek: Support CRC in OVL
drm/mediatek: Support CRC in OVL adaptor
drivers/gpu/drm/mediatek/mtk_crtc.c | 260 +++++++++++++++ drivers/gpu/drm/mediatek/mtk_crtc.h | 38 +++ drivers/gpu/drm/mediatek/mtk_ddp_comp.c | 6 + drivers/gpu/drm/mediatek/mtk_ddp_comp.h | 9 +- drivers/gpu/drm/mediatek/mtk_disp_drv.h | 6 + drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 300 ++++++++++++++++-- .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 23 +- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 24 ++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 4 + drivers/gpu/drm/mediatek/mtk_ethdr.c | 96 +++++- drivers/gpu/drm/mediatek/mtk_ethdr.h | 5 + drivers/gpu/drm/mediatek/mtk_plane.c | 15 +- drivers/soc/mediatek/mtk-mmsys.c | 1 + 13 files changed, 743 insertions(+), 44 deletions(-)
--
2.18.0
PATCH v7 1/18 soc: mediatek: Disable 9-bit alpha in ETHDR
From: Hsiao Chien Sung <[email protected]>
ETHDR 9-bit alpha should be disabled by default,
otherwise alpha blending will not work.
--- drivers/soc/mediatek/mtk-mmsys.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/mediatek/mtk-mmsys.c +1 -0
@@ -236,6 +236,7 @@ void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool alpha_sel, u16mtk_mmsys_update_bits (mmsys,MT8195_VDO1_MIXER_IN1_ALPHA + (idx -1 ) *4 , ~0 , alpha <<16 | alpha, cmdq_pkt); +mtk_mmsys_update_bits (mmsys,MT8195_VDO1_HDR_TOP_CFG ,BIT (15 + idx),0 , cmdq_pkt);mtk_mmsys_update_bits (mmsys,MT8195_VDO1_HDR_TOP_CFG ,BIT (19 + idx), alpha_sel << (19 + idx), cmdq_pkt); mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_PAD + (idx - 1) * 4,
Signature · 1 line
2.18.0
Re: [PATCH v7 01/18] soc: mediatek: Disable 9-bit alpha in ETHDR
Hi, Shawn:
Quoted 4 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
ETHDR 9-bit alpha should be disabled by default,
otherwise alpha blending will not work.
Please explain what is 9-bit alpha. Is ARGB8888 8-bit alpha? I don't know there are 9-bit alpha. I would like to know which function would be disabled when you disable 9-bit alpha.
Regards,
CK
Quoted 26 lines
Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/soc/mediatek/mtk-mmsys.c | 1 + 1 file changed, 1 insertion(+)drivers/soc/mediatek/mtk-mmsys.c +1
-1@@ -236,6 +236,7 @@ void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool alpha_sel, u16 mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_ALPHA + (idx - 1) * 4, ~0, alpha << 16 | alpha, cmdq_pkt); +mtk_mmsys_update_bits (mmsys,MT8195_VDO1_HDR_TOP_CFG ,BIT (15 + idx),0 , cmdq_pkt); mtk_mmsys_update_bits(mmsys, MT8195_VDO1_HDR_TOP_CFG, BIT(19 +idx),
drivers/soc/mediatek/mtk-mmsys.c +0
-0alpha_sel << (19 + idx), cmdq_pkt); mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_PAD + (idx -1) * 4,
Re: [PATCH v7 01/18] soc: mediatek: Disable 9-bit alpha in ETHDR
Hi CK,
Quoted 12 lines · CK Hu (胡俊光)
Hi, Shawn:
Quoted 4 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
ETHDR 9-bit alpha should be disabled by default,
otherwise alpha blending will not work.Please explain what is 9-bit alpha. Is ARGB8888 8-bit alpha? I don't know there are 9-bit alpha. I would like to know which function would be disabled when you disable 9-bit alpha.
When 9-bit alpha is enabled, the original alpha range 0-255 will be remapped to 0-256 (255 = N/A) for some special case calculation. Checked with the designer, this setting should be always disabled and there will be no side effects.
Thanks,
Shawn
PATCH v7 2/18 drm/mediatek: Add OVL compatible name for MT8195
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Add OVL compatible name for MT8195.
Without this commit, DRM won't work after modifying the device tree.
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +2 -0
@@ -743,6 +743,8 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = { .data = (void *)MTK_DISP_OVL }, { .compatible = "mediatek,mt8192-disp-ovl", .data = (void *)MTK_DISP_OVL }, + { .compatible = "mediatek,mt8195-disp-ovl", + .data = (void *)MTK_DISP_OVL }, { .compatible = "mediatek,mt8183-disp-ovl-2l", .data = (void *)MTK_DISP_OVL_2L }, { .compatible = "mediatek,mt8192-disp-ovl-2l",
Signature · 1 line
2.18.0
PATCH v7 3/18 drm/mediatek: Add missing plane settings when async update
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Fix an issue that plane coordinate was not saved when calling async update.
--- drivers/gpu/drm/mediatek/mtk_plane.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/mediatek/mtk_plane.c +2 -0
@@ -227,6 +227,8 @@ static void mtk_plane_atomic_async_update(struct drm_plane *plane, plane->state->src_y = new_state->src_y; plane->state->src_h = new_state->src_h; plane->state->src_w = new_state->src_w; + plane->state->dst.x1 = new_state->dst.x1; + plane->state->dst.y1 = new_state->dst.y1;mtk_plane_update_new_state (new_state, new_plane_state);swap (plane->state->fb, new_state->fb);
Signature · 1 line
2.18.0
PATCH v7 4/18 drm/mediatek: Add DRM_MODE_ROTATE_0 to rotation property
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Always add DRM_MODE_ROTATE_0 to rotation property to meet IGT's (Intel GPU Tools) requirement.
--- drivers/gpu/drm/mediatek/mtk_ddp_comp.h | 6 +++++- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 17 +++++------------ drivers/gpu/drm/mediatek/mtk_plane.c | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-)
drivers/gpu/drm/mediatek/mtk_ddp_comp.h +5 -1
@@ -192,7 +192,11 @@ unsigned int mtk_ddp_comp_supported_rotations(struct mtk_ddp_comp *comp)if (comp->funcs && comp->funcs->supported_rotations)return comp->funcs->supported_rotations (comp->dev); -return 0 ; +/* +* In order to pass IGT tests, DRM_MODE_ROTATE_0 is required when +* rotation is not supported. +*/ +return DRM_MODE_ROTATE_0 ; }static inline unsigned int mtk_ddp_comp_layer_nr (struct mtk_ddp_comp *comp)
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +5 -12
@@ -296,27 +296,20 @@ int mtk_ovl_layer_check(struct device *dev, unsigned int idx, struct mtk_plane_state *mtk_state) {struct drm_plane_state *state = &mtk_state->base; -unsigned int rotation =0 ; - rotation =drm_rotation_simplify (state->rotation, -DRM_MODE_ROTATE_0 | -DRM_MODE_REFLECT_X | -DRM_MODE_REFLECT_Y ); - rotation &= ~DRM_MODE_ROTATE_0 ; - -/* We can only do reflection, not rotation */ -if ((rotation &DRM_MODE_ROTATE_MASK ) !=0 ) +/* check if any unsupported rotation is set */ +if (state->rotation & ~mtk_ovl_supported_rotations (dev))return -EINVAL ;/* * TODO: Rotating/reflecting YUV buffers is not supported at this time. * Only RGB[AX] variants are supported. +* Since DRM_MODE_ROTATE_0 means "no rotation", we should not +* reject layers with this property. */ -if (state->fb->format->is_yuv && rotation !=0 ) +if (state->fb->format->is_yuv && (state->rotation & ~DRM_MODE_ROTATE_0 ))return -EINVAL ; - state->rotation = rotation; -return 0 ; }
drivers/gpu/drm/mediatek/mtk_plane.c +1 -1
@@ -338,7 +338,7 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,return err; } -if (supported_rotations & ~DRM_MODE_ROTATE_0 ) { +if (supported_rotations) { err =drm_plane_create_rotation_property (plane,DRM_MODE_ROTATE_0 , supported_rotations);
Signature · 1 line
2.18.0
PATCH v7 5/18 drm/mediatek: Set DRM mode configs accordingly
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Set DRM mode configs limitation according to the hardware capabilities and pass the IGT checks as below:
- The test "graphics.IgtKms.kms_plane" requires a frame buffer with width of 4512 pixels (> 4096).
- The test "graphics.IgtKms.kms_cursor_crc" checks if the cursor size is defined, and run the test with cursor size from 1x1 to 512x512.
Please notice that the test conditions may change as IGT is updated.
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 4 ++++ 2 files changed, 26 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +22 -0
@@ -294,6 +294,9 @@ static const struct mtk_mmsys_driver_data mt8188_vdosys0_driver_data = { .conn_routes = mt8188_mtk_ddp_main_routes, .num_conn_routes = ARRAY_SIZE(mt8188_mtk_ddp_main_routes), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct mtk_mmsys_driver_data mt8192_mmsys_driver_data = {
@@ -308,6 +311,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = { .main_path = mt8195_mtk_ddp_main, .main_len = ARRAY_SIZE(mt8195_mtk_ddp_main), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {
@@ -315,6 +321,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = { .ext_len = ARRAY_SIZE(mt8195_mtk_ddp_ext), .mmsys_id = 1, .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 2, /* 2-pixel align when ethdr is bypassed */ + .min_height = 1, };static const struct of_device_id mtk_drm_of_ids[] = {
@@ -493,6 +502,15 @@ static int mtk_drm_kms_init(struct drm_device *drm)for (j =0 ; j < private->data->mmsys_dev_num; j++) { priv_n = private->all_drm_private[j]; +if (priv_n->data->max_width) + drm->mode_config.max_width = priv_n->data->max_width; + +if (priv_n->data->min_width) + drm->mode_config.min_width = priv_n->data->min_width; + +if (priv_n->data->min_height) + drm->mode_config.min_height = priv_n->data->min_height; +if (i ==CRTC_MAIN && priv_n->data->main_len) { ret = mtk_crtc_create(drm, priv_n->data->main_path, priv_n->data->main_len, j,
@@ -520,6 +538,10 @@ static int mtk_drm_kms_init(struct drm_device *drm) } } +/* IGT will check if the cursor size is configured */ + drm->mode_config.cursor_width = drm->mode_config.max_width; + drm->mode_config.cursor_height = drm->mode_config.max_height; +/* Use OVL device for all DMA memory allocations */ crtc =drm_crtc_from_index (drm,0 );if (crtc)
drivers/gpu/drm/mediatek/mtk_drm_drv.h +4 -0
@@ -46,6 +46,10 @@ struct mtk_mmsys_driver_data {bool shadow_register;unsigned int mmsys_id;unsigned int mmsys_dev_num; + +int max_width; +int min_width; +int min_height; };struct mtk_drm_private {
Signature · 1 line
2.18.0
Re: [PATCH v7 05/18] drm/mediatek: Set DRM mode configs accordingly
Hi, Shawn:
Quoted 6 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Set DRM mode configs limitation according to the hardware capabilities
and pass the IGT checks as below:
Quoted 7 lines
- The test "graphics.IgtKms.kms_plane" requires a frame buffer with width of 4512 pixels (> 4096).
- The test "graphics.IgtKms.kms_cursor_crc" checks if the cursor size is
defined, and run the test with cursor size from 1x1 to 512x512.Please notice that the test conditions may change as IGT is updated.
Quoted 97 lines
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 4 ++++ 2 files changed, 26 insertions(+)drivers/gpu/drm/mediatek/mtk_drm_drv.c +3
-0@@ -294,6 +294,9 @@ static const struct mtk_mmsys_driver_data mt8188_vdosys0_driver_data = { .conn_routes = mt8188_mtk_ddp_main_routes, .num_conn_routes = ARRAY_SIZE(mt8188_mtk_ddp_main_routes), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct
mtk_mmsys_driver_datamt8192_mmsys_driver_data=
{drivers/gpu/drm/mediatek/mtk_drm_drv.c +3
-0@@ -308,6 +311,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = { .main_path = mt8195_mtk_ddp_main, .main_len = ARRAY_SIZE(mt8195_mtk_ddp_main), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct
mtk_mmsys_driver_datamt8195_vdosys1_driver_data
= {drivers/gpu/drm/mediatek/mtk_drm_drv.c +3
-0@@ -315,6 +321,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = { .ext_len = ARRAY_SIZE(mt8195_mtk_ddp_ext), .mmsys_id = 1, .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 2, /* 2-pixel align when ethdr is bypassed */ + .min_height = 1, };static const struct
of_device_idmtk_drm_of_ids[] = {drivers/gpu/drm/mediatek/mtk_drm_drv.c +8
-0@@ -493,6 +502,15 @@ static int mtk_drm_kms_init(struct drm_device *drm)for (j =0 ; j < private->data->mmsys_dev_num; j++) { priv_n = private->all_drm_private[j]; +if (priv_n->data->max_width) + drm->mode_config.max_width = priv_n- >data->max_width; + +if (priv_n->data->min_width) + drm->mode_config.min_width = priv_n- >data->min_width; + +if (priv_n->data->min_height) + drm->mode_config.min_height = priv_n-Quoted 1 line
data->min_height;drivers/gpu/drm/mediatek/mtk_drm_drv.c +1
-0+if (i ==CRTC_MAIN && priv_n->data->main_len) { ret = mtk_crtc_create(drm, priv_n-Quoted 1 line
data->main_path,priv_n->data-
Quoted 1 line
main_len, j,drivers/gpu/drm/mediatek/mtk_drm_drv.c +4
-0@@ -520,6 +538,10 @@ static int mtk_drm_kms_init(struct drm_device *drm) } } +/* IGT will check if the cursor size is configured */ + drm->mode_config.cursor_width = drm->mode_config.max_width; + drm->mode_config.cursor_height = drm->mode_config.max_height; +/* Use OVL device for all DMA memory allocations */ crtc =drm_crtc_from_index (drm,0 );drivers/gpu/drm/mediatek/mtk_drm_drv.c +0
-0if (crtc)drivers/gpu/drm/mediatek/mtk_drm_drv.h +4
-0@@ -46,6 +46,10 @@ struct mtk_mmsys_driver_data {bool shadow_register;unsigned int mmsys_id;unsigned int mmsys_dev_num; + +int max_width; +int min_width; +int min_height; };struct mtk_drm_private {
Re: [PATCH v7 05/18] drm/mediatek: Set DRM mode configs accordingly
In reply to Shawn SungHi Shawn,
Quoted 70 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Set DRM mode configs limitation according to the hardware capabilities and pass the IGT checks as below:
- The test "graphics.IgtKms.kms_plane" requires a frame buffer with width of 4512 pixels (> 4096).
- The test "graphics.IgtKms.kms_cursor_crc" checks if the cursor size is defined, and run the test with cursor size from 1x1 to 512x512.Please notice that the test conditions may change as IGT is updated.
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 4 ++++ 2 files changed, 26 insertions(+)drivers/gpu/drm/mediatek/mtk_drm_drv.c +18
-0@@ -294,6 +294,9 @@ static const struct mtk_mmsys_driver_data mt8188_vdosys0_driver_data = { .conn_routes = mt8188_mtk_ddp_main_routes, .num_conn_routes = ARRAY_SIZE(mt8188_mtk_ddp_main_routes), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct mtk_mmsys_driver_data mt8192_mmsys_driver_data = {@@ -308,6 +311,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = { .main_path = mt8195_mtk_ddp_main, .main_len = ARRAY_SIZE(mt8195_mtk_ddp_main), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {@@ -315,6 +321,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = { .ext_len = ARRAY_SIZE(mt8195_mtk_ddp_ext), .mmsys_id = 1, .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 2, /* 2-pixel align when ethdr is bypassed */ + .min_height = 1, };static const struct of_device_id mtk_drm_of_ids[] = {@@ -493,6 +502,15 @@ static int mtk_drm_kms_init(struct drm_device *drm)for (j =0 ; j < private->data->mmsys_dev_num; j++) { priv_n = private->all_drm_private[j]; +if (priv_n->data->max_width) + drm->mode_config.max_width = priv_n->data->max_width; + +if (priv_n->data->min_width) + drm->mode_config.min_width = priv_n->data->min_width; + +if (priv_n->data->min_height) + drm->mode_config.min_height = priv_n->data->min_height; +if (i ==CRTC_MAIN && priv_n->data->main_len) { ret = mtk_crtc_create(drm, priv_n->data->main_path, priv_n->data->main_len, j,
drivers/gpu/drm/mediatek/mtk_drm_drv.c static int mtk_drm_kms_init(struct drm_device *drm) · line 543
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +3
-0@@ -520,6 +538,10 @@ static int mtk_drm_kms_init(struct drm_device *drm) } } +/* IGT will check if the cursor size is configured */ + drm->mode_config.cursor_width = drm->mode_config.max_width; + drm->mode_config.cursor_height = drm->mode_config.max_height;
I think you shouldn't set the cursor size to the maximum plane size. As you mentioned in the commit message, IGT tests the cursor sizes from 1x1 to 512x512, so just setting them to 512 (with a macro) should be enough.
Currently this tells the userspace "the supported cursor plane size is up to 4096x8191" on MT8195 and MT8188.
That means the userspace may allocate a buffer with 4096*8191*4 ~= 128MB for the cursor plane in the worst case, and most of the buffer will be wasted.
Note that the default value for DRM_CAP_CURSOR_WIDTH is 64.
In practice, when applying this on the MT8188 Chromebook, I see the userspace allocates two 64MB buffers for the cursor plane. But if I limit the cursor size to 512, the userspace only allocates two 1MB buffers i.e. 126MB is optimized for the DMA buffer allocation.
Regards,
Fei
Quoted 23 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +1
-0+/* Use OVL device for all DMA memory allocations */ crtc =drm_crtc_from_index (drm,0 );if (crtc)drivers/gpu/drm/mediatek/mtk_drm_drv.h +4
-1@@ -46,6 +46,10 @@ struct mtk_mmsys_driver_data {bool shadow_register;unsigned int mmsys_id;unsigned int mmsys_dev_num; + +int max_width; +int min_width; +int min_height; };struct mtk_drm_private { --2.18.0
Re: [PATCH v7 05/18] drm/mediatek: Set DRM mode configs accordingly
Quoted 93 lines · Fei Shao
Hi Shawn,
Quoted 70 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Set DRM mode configs limitation according to the hardware capabilities and pass the IGT checks as below:
- The test "graphics.IgtKms.kms_plane" requires a frame buffer with width of 4512 pixels (> 4096).
- The test "graphics.IgtKms.kms_cursor_crc" checks if the cursor size is defined, and run the test with cursor size from 1x1 to 512x512.Please notice that the test conditions may change as IGT is updated.
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 4 ++++ 2 files changed, 26 insertions(+)drivers/gpu/drm/mediatek/mtk_drm_drv.c +18
-0@@ -294,6 +294,9 @@ static const struct mtk_mmsys_driver_data mt8188_vdosys0_driver_data = { .conn_routes = mt8188_mtk_ddp_main_routes, .num_conn_routes = ARRAY_SIZE(mt8188_mtk_ddp_main_routes), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct mtk_mmsys_driver_data mt8192_mmsys_driver_data = {@@ -308,6 +311,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = { .main_path = mt8195_mtk_ddp_main, .main_len = ARRAY_SIZE(mt8195_mtk_ddp_main), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {@@ -315,6 +321,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = { .ext_len = ARRAY_SIZE(mt8195_mtk_ddp_ext), .mmsys_id = 1, .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 2, /* 2-pixel align when ethdr is bypassed */ + .min_height = 1, };static const struct of_device_id mtk_drm_of_ids[] = {@@ -493,6 +502,15 @@ static int mtk_drm_kms_init(struct drm_device *drm)for (j =0 ; j < private->data->mmsys_dev_num; j++) { priv_n = private->all_drm_private[j]; +if (priv_n->data->max_width) + drm->mode_config.max_width = priv_n->data->max_width; + +if (priv_n->data->min_width) + drm->mode_config.min_width = priv_n->data->min_width; + +if (priv_n->data->min_height) + drm->mode_config.min_height = priv_n->data->min_height; +if (i ==CRTC_MAIN && priv_n->data->main_len) { ret = mtk_crtc_create(drm, priv_n->data->main_path, priv_n->data->main_len, j,drivers/gpu/drm/mediatek/mtk_drm_drv.c static int mtk_drm_kms_init(struct drm_device *drm) · line 543
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +3
-0@@ -520,6 +538,10 @@ static int mtk_drm_kms_init(struct drm_device *drm) } } +/* IGT will check if the cursor size is configured */ + drm->mode_config.cursor_width = drm->mode_config.max_width; + drm->mode_config.cursor_height = drm->mode_config.max_height;I think you shouldn't set the cursor size to the maximum plane size. As you mentioned in the commit message, IGT tests the cursor sizes from 1x1 to 512x512, so just setting them to 512 (with a macro) should be enough.
Currently this tells the userspace "the supported cursor plane size is up to 4096x8191" on MT8195 and MT8188.
That means the userspace may allocate a buffer with 4096*8191*4 ~= 128MB for the cursor plane in the worst case, and most of the buffer will be wasted.
Note that the default value forDRM_CAP_CURSOR_WIDTHis 64.
Quoted 4 lines
In practice, when applying this on the MT8188 Chromebook, I see the userspace allocates two 64MB buffers for the cursor plane. But if I limit the cursor size to 512, the userspace only allocates two 1MB buffers i.e. 126MB is optimized for the DMA buffer allocation.
That seems more like an issue of ChromeOS not doing the most optimal thing though?
Quoted 27 lines
Regards,
FeiQuoted 23 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +1
-0+/* Use OVL device for all DMA memory allocations */ crtc =drm_crtc_from_index (drm,0 );if (crtc)drivers/gpu/drm/mediatek/mtk_drm_drv.h +4
-1@@ -46,6 +46,10 @@ struct mtk_mmsys_driver_data {bool shadow_register;unsigned int mmsys_id;unsigned int mmsys_dev_num; + +int max_width; +int min_width; +int min_height; };struct mtk_drm_private { --2.18.0
Re: [PATCH v7 05/18] drm/mediatek: Set DRM mode configs accordingly
Quoted 95 lines · Chen-Yu Tsai
Quoted 93 lines · Fei Shao
Hi Shawn,
Quoted 70 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Set DRM mode configs limitation according to the hardware capabilities and pass the IGT checks as below:
- The test "graphics.IgtKms.kms_plane" requires a frame buffer with width of 4512 pixels (> 4096).
- The test "graphics.IgtKms.kms_cursor_crc" checks if the cursor size is defined, and run the test with cursor size from 1x1 to 512x512.Please notice that the test conditions may change as IGT is updated.
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 4 ++++ 2 files changed, 26 insertions(+)drivers/gpu/drm/mediatek/mtk_drm_drv.c +18
-0@@ -294,6 +294,9 @@ static const struct mtk_mmsys_driver_data mt8188_vdosys0_driver_data = { .conn_routes = mt8188_mtk_ddp_main_routes, .num_conn_routes = ARRAY_SIZE(mt8188_mtk_ddp_main_routes), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct mtk_mmsys_driver_data mt8192_mmsys_driver_data = {@@ -308,6 +311,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = { .main_path = mt8195_mtk_ddp_main, .main_len = ARRAY_SIZE(mt8195_mtk_ddp_main), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {@@ -315,6 +321,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = { .ext_len = ARRAY_SIZE(mt8195_mtk_ddp_ext), .mmsys_id = 1, .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 2, /* 2-pixel align when ethdr is bypassed */ + .min_height = 1, };static const struct of_device_id mtk_drm_of_ids[] = {@@ -493,6 +502,15 @@ static int mtk_drm_kms_init(struct drm_device *drm)for (j =0 ; j < private->data->mmsys_dev_num; j++) { priv_n = private->all_drm_private[j]; +if (priv_n->data->max_width) + drm->mode_config.max_width = priv_n->data->max_width; + +if (priv_n->data->min_width) + drm->mode_config.min_width = priv_n->data->min_width; + +if (priv_n->data->min_height) + drm->mode_config.min_height = priv_n->data->min_height; +if (i ==CRTC_MAIN && priv_n->data->main_len) { ret = mtk_crtc_create(drm, priv_n->data->main_path, priv_n->data->main_len, j,drivers/gpu/drm/mediatek/mtk_drm_drv.c static int mtk_drm_kms_init(struct drm_device *drm) · line 543
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +3
-0@@ -520,6 +538,10 @@ static int mtk_drm_kms_init(struct drm_device *drm) } } +/* IGT will check if the cursor size is configured */ + drm->mode_config.cursor_width = drm->mode_config.max_width; + drm->mode_config.cursor_height = drm->mode_config.max_height;I think you shouldn't set the cursor size to the maximum plane size. As you mentioned in the commit message, IGT tests the cursor sizes from 1x1 to 512x512, so just setting them to 512 (with a macro) should be enough.
Currently this tells the userspace "the supported cursor plane size is up to 4096x8191" on MT8195 and MT8188.
That means the userspace may allocate a buffer with 4096*8191*4 ~= 128MB for the cursor plane in the worst case, and most of the buffer will be wasted.
Note that the default value forDRM_CAP_CURSOR_WIDTHis 64.
Quoted 7 lines
Quoted 4 lines
In practice, when applying this on the MT8188 Chromebook, I see the userspace allocates two 64MB buffers for the cursor plane. But if I limit the cursor size to 512, the userspace only allocates two 1MB buffers i.e. 126MB is optimized for the DMA buffer allocation.
That seems more like an issue of ChromeOS not doing the most optimal thing though?
I agree that we need to fix this on the ChromeOS side too, but I still think the driver doesn't need to set the capabilities like this because a full-screen size cursor is not practical anyway. The default cursor plane size is just 64x64.
Regard,
Fei
Quoted 28 lines
Quoted 28 lines
Regards,
FeiQuoted 23 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +1
-0+/* Use OVL device for all DMA memory allocations */ crtc =drm_crtc_from_index (drm,0 );if (crtc)drivers/gpu/drm/mediatek/mtk_drm_drv.h +4
-1@@ -46,6 +46,10 @@ struct mtk_mmsys_driver_data {bool shadow_register;unsigned int mmsys_id;unsigned int mmsys_dev_num; + +int max_width; +int min_width; +int min_height; };struct mtk_drm_private { --2.18.0
Re: [PATCH v7 05/18] drm/mediatek: Set DRM mode configs accordingly
Quoted 102 lines · Fei Shao
Quoted 100 lines · Chen-Yu Tsai
Quoted 97 lines · Fei Shao
Hi Shawn,
Quoted 70 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Set DRM mode configs limitation according to the hardware capabilities and pass the IGT checks as below:
- The test "graphics.IgtKms.kms_plane" requires a frame buffer with width of 4512 pixels (> 4096).
- The test "graphics.IgtKms.kms_cursor_crc" checks if the cursor size is defined, and run the test with cursor size from 1x1 to 512x512.Please notice that the test conditions may change as IGT is updated.
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 4 ++++ 2 files changed, 26 insertions(+)drivers/gpu/drm/mediatek/mtk_drm_drv.c +18
-0@@ -294,6 +294,9 @@ static const struct mtk_mmsys_driver_data mt8188_vdosys0_driver_data = { .conn_routes = mt8188_mtk_ddp_main_routes, .num_conn_routes = ARRAY_SIZE(mt8188_mtk_ddp_main_routes), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct mtk_mmsys_driver_data mt8192_mmsys_driver_data = {@@ -308,6 +311,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = { .main_path = mt8195_mtk_ddp_main, .main_len = ARRAY_SIZE(mt8195_mtk_ddp_main), .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 1, + .min_height = 1, };static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {@@ -315,6 +321,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = { .ext_len = ARRAY_SIZE(mt8195_mtk_ddp_ext), .mmsys_id = 1, .mmsys_dev_num = 2, + .max_width = 8191, + .min_width = 2, /* 2-pixel align when ethdr is bypassed */ + .min_height = 1, };static const struct of_device_id mtk_drm_of_ids[] = {@@ -493,6 +502,15 @@ static int mtk_drm_kms_init(struct drm_device *drm)for (j =0 ; j < private->data->mmsys_dev_num; j++) { priv_n = private->all_drm_private[j]; +if (priv_n->data->max_width) + drm->mode_config.max_width = priv_n->data->max_width; + +if (priv_n->data->min_width) + drm->mode_config.min_width = priv_n->data->min_width; + +if (priv_n->data->min_height) + drm->mode_config.min_height = priv_n->data->min_height; +if (i ==CRTC_MAIN && priv_n->data->main_len) { ret = mtk_crtc_create(drm, priv_n->data->main_path, priv_n->data->main_len, j,drivers/gpu/drm/mediatek/mtk_drm_drv.c static int mtk_drm_kms_init(struct drm_device *drm) · line 543
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +3
-0@@ -520,6 +538,10 @@ static int mtk_drm_kms_init(struct drm_device *drm) } } +/* IGT will check if the cursor size is configured */ + drm->mode_config.cursor_width = drm->mode_config.max_width; + drm->mode_config.cursor_height = drm->mode_config.max_height;I think you shouldn't set the cursor size to the maximum plane size. As you mentioned in the commit message, IGT tests the cursor sizes from 1x1 to 512x512, so just setting them to 512 (with a macro) should be enough.
Currently this tells the userspace "the supported cursor plane size is up to 4096x8191" on MT8195 and MT8188.
That means the userspace may allocate a buffer with 4096*8191*4 ~= 128MB for the cursor plane in the worst case, and most of the buffer will be wasted.
Note that the default value forDRM_CAP_CURSOR_WIDTHis 64.In practice, when applying this on the MT8188 Chromebook, I see the userspace allocates two 64MB buffers for the cursor plane. But if I limit the cursor size to 512, the userspace only allocates two 1MB buffers i.e. 126MB is optimized for the DMA buffer allocation.
Quoted 7 lines
Quoted 2 lines
That seems more like an issue of ChromeOS not doing the most optimal thing though?
I agree that we need to fix this on the ChromeOS side too, but I still think the driver doesn't need to set the capabilities like this because a full-screen size cursor is not practical anyway. The default cursor plane size is just 64x64.
Seems like a better solution was merged:
https://patchwork.freedesktop.org/patch/583298/
ChenYu
Quoted 33 lines
Regard,
FeiQuoted 28 lines
Quoted 28 lines
Regards,
FeiQuoted 23 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +1
-0+/* Use OVL device for all DMA memory allocations */ crtc =drm_crtc_from_index (drm,0 );if (crtc)drivers/gpu/drm/mediatek/mtk_drm_drv.h +4
-1@@ -46,6 +46,10 @@ struct mtk_mmsys_driver_data {bool shadow_register;unsigned int mmsys_id;unsigned int mmsys_dev_num; + +int max_width; +int min_width; +int min_height; };struct mtk_drm_private { --2.18.0
PATCH v7 6/18 drm/mediatek: Turn off the layers with zero width or height
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
We found that IGT (Intel GPU Tool) will try to commit layers with zero width or height and lead to undefined behaviors in hardware. Disable the layers in such a situation.
--- drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 2 +- drivers/gpu/drm/mediatek/mtk_ethdr.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +1 -1
@@ -158,7 +158,7 @@ void mtk_ovl_adaptor_layer_config(struct device *dev, unsigned int idx, merge = ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_MERGE0 + idx]; ethdr = ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ]; -if (!pending->enable) { +if (!pending->enable || !pending->width || !pending->height) {mtk_merge_stop_cmdq (merge, cmdq_pkt);mtk_mdp_rdma_stop (rdma_l, cmdq_pkt);mtk_mdp_rdma_stop (rdma_r, cmdq_pkt);
drivers/gpu/drm/mediatek/mtk_ethdr.c +6 -1
@@ -160,7 +160,12 @@ void mtk_ethdr_layer_config(struct device *dev, unsigned int idx,if (idx >=4 )return ; -if (!pending->enable) { +if (!pending->enable || !pending->width || !pending->height) { +/* +* instead of disabling layer with MIX_SRC_CON directly +* set the size to 0 to avoid screen shift due to mixer +* mode switch (hardware behavior) +*/ mtk_ddp_write (cmdq_pkt,0 , &mixer->cmdq_base, mixer->regs,MIX_L_SRC_SIZE (idx));return ; }
Signature · 1 line
2.18.0
PATCH v7 7/18 drm/mediatek: Support more 10bit formats in OVL
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Support more 10bit formats in OVL.
--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 32 ++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +29 -3
@@ -71,6 +71,22 @@#define OVL_CON_VIRT_FLIP BIT(9)#define OVL_CON_HORZ_FLIP BIT(10) +static inline bool is_10bit_rgb (u32 fmt) +{ +switch (fmt) { +case DRM_FORMAT_XRGB2101010 : +case DRM_FORMAT_ARGB2101010 : +case DRM_FORMAT_RGBX1010102 : +case DRM_FORMAT_RGBA1010102 : +case DRM_FORMAT_XBGR2101010 : +case DRM_FORMAT_ABGR2101010 : +case DRM_FORMAT_BGRX1010102 : +case DRM_FORMAT_BGRA1010102 : +return true; + } +return false; +} +static const u32 mt8173_formats[] = {DRM_FORMAT_XRGB8888 ,DRM_FORMAT_ARGB8888 ,
@@ -88,12 +104,18 @@ static const u32 mt8173_formats[] = {static const u32 mt8195_formats[] = {DRM_FORMAT_XRGB8888 ,DRM_FORMAT_ARGB8888 , +DRM_FORMAT_XRGB2101010 ,DRM_FORMAT_ARGB2101010 ,DRM_FORMAT_BGRX8888 ,DRM_FORMAT_BGRA8888 , +DRM_FORMAT_BGRX1010102 ,DRM_FORMAT_BGRA1010102 ,DRM_FORMAT_ABGR8888 ,DRM_FORMAT_XBGR8888 , +DRM_FORMAT_XBGR2101010 , +DRM_FORMAT_ABGR2101010 , +DRM_FORMAT_RGBX1010102 , +DRM_FORMAT_RGBA1010102 ,DRM_FORMAT_RGB888 ,DRM_FORMAT_BGR888 ,DRM_FORMAT_RGB565 ,
@@ -253,9 +275,7 @@ static void mtk_ovl_set_bit_depth(struct device *dev, int idx, u32 format, reg =readl (ovl->regs +DISP_REG_OVL_CLRFMT_EXT ); reg &= ~OVL_CON_CLRFMT_BIT_DEPTH_MASK (idx); -if (format ==DRM_FORMAT_RGBA1010102 || - format ==DRM_FORMAT_BGRA1010102 || - format ==DRM_FORMAT_ARGB2101010 ) +if (is_10bit_rgb (format)) bit_depth =OVL_CON_CLRFMT_10_BIT ; reg |=OVL_CON_CLRFMT_BIT_DEPTH (bit_depth, idx);
@@ -368,17 +388,23 @@ static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt)return OVL_CON_CLRFMT_RGB888 (ovl) |OVL_CON_BYTE_SWAP ;case DRM_FORMAT_RGBX8888 :case DRM_FORMAT_RGBA8888 : +case DRM_FORMAT_RGBX1010102 : +case DRM_FORMAT_RGBA1010102 :return OVL_CON_CLRFMT_ARGB8888 ;case DRM_FORMAT_BGRX8888 :case DRM_FORMAT_BGRA8888 : +case DRM_FORMAT_BGRX1010102 :case DRM_FORMAT_BGRA1010102 :return OVL_CON_CLRFMT_ARGB8888 |OVL_CON_BYTE_SWAP ;case DRM_FORMAT_XRGB8888 :case DRM_FORMAT_ARGB8888 : +case DRM_FORMAT_XRGB2101010 :case DRM_FORMAT_ARGB2101010 :return OVL_CON_CLRFMT_RGBA8888 ;case DRM_FORMAT_XBGR8888 :case DRM_FORMAT_ABGR8888 : +case DRM_FORMAT_XBGR2101010 : +case DRM_FORMAT_ABGR2101010 :return OVL_CON_CLRFMT_RGBA8888 |OVL_CON_BYTE_SWAP ;case DRM_FORMAT_UYVY :return OVL_CON_CLRFMT_UYVY |OVL_CON_MTX_YUV_TO_RGB ;
Signature · 1 line
2.18.0
Re: [PATCH v7 07/18] drm/mediatek: Support more 10bit formats in OVL
Hi, Shawn:
Quoted 3 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Support more 10bit formats in OVL.
Quoted 91 lines
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 32 ++++++++++++++++++++++- -- 1 file changed, 29 insertions(+), 3 deletions(-)drivers/gpu/drm/mediatek/mtk_disp_ovl.c +23
-3@@ -71,6 +71,22 @@#define OVL_CON_VIRT_FLIP BIT(9)#define OVL_CON_HORZ_FLIP BIT(10) +static inline bool is_10bit_rgb (u32 fmt) +{ +switch (fmt) { +case DRM_FORMAT_XRGB2101010 : +case DRM_FORMAT_ARGB2101010 : +case DRM_FORMAT_RGBX1010102 : +case DRM_FORMAT_RGBA1010102 : +case DRM_FORMAT_XBGR2101010 : +case DRM_FORMAT_ABGR2101010 : +case DRM_FORMAT_BGRX1010102 : +case DRM_FORMAT_BGRA1010102 : +return true; + } +return false; +} +static const u32 mt8173_formats[] = {DRM_FORMAT_XRGB8888 ,DRM_FORMAT_ARGB8888 ,@@ -88,12 +104,18 @@ static const u32 mt8173_formats[] = {static const u32 mt8195_formats[] = {DRM_FORMAT_XRGB8888 ,DRM_FORMAT_ARGB8888 , +DRM_FORMAT_XRGB2101010 ,DRM_FORMAT_ARGB2101010 ,DRM_FORMAT_BGRX8888 ,DRM_FORMAT_BGRA8888 , +DRM_FORMAT_BGRX1010102 ,DRM_FORMAT_BGRA1010102 ,DRM_FORMAT_ABGR8888 ,DRM_FORMAT_XBGR8888 , +DRM_FORMAT_XBGR2101010 , +DRM_FORMAT_ABGR2101010 , +DRM_FORMAT_RGBX1010102 , +DRM_FORMAT_RGBA1010102 ,DRM_FORMAT_RGB888 ,DRM_FORMAT_BGR888 ,DRM_FORMAT_RGB565 ,@@ -253,9 +275,7 @@ static void mtk_ovl_set_bit_depth(struct device *dev, int idx, u32 format, reg =readl (ovl->regs +DISP_REG_OVL_CLRFMT_EXT ); reg &= ~OVL_CON_CLRFMT_BIT_DEPTH_MASK (idx); -if (format ==DRM_FORMAT_RGBA1010102 || - format ==DRM_FORMAT_BGRA1010102 || - format ==DRM_FORMAT_ARGB2101010 ) +if (is_10bit_rgb (format)) bit_depth =OVL_CON_CLRFMT_10_BIT ;drivers/gpu/drm/mediatek/mtk_disp_ovl.c +6
-0reg |=OVL_CON_CLRFMT_BIT_DEPTH (bit_depth, idx);@@ -368,17 +388,23 @@ static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt) return OVL_CON_CLRFMT_RGB888(ovl) | OVL_CON_BYTE_SWAP;case DRM_FORMAT_RGBX8888 :case DRM_FORMAT_RGBA8888 : +case DRM_FORMAT_RGBX1010102 : +case DRM_FORMAT_RGBA1010102 :return OVL_CON_CLRFMT_ARGB8888 ;case DRM_FORMAT_BGRX8888 :case DRM_FORMAT_BGRA8888 : +case DRM_FORMAT_BGRX1010102 :case DRM_FORMAT_BGRA1010102 :return OVL_CON_CLRFMT_ARGB8888 |OVL_CON_BYTE_SWAP ;case DRM_FORMAT_XRGB8888 :case DRM_FORMAT_ARGB8888 : +case DRM_FORMAT_XRGB2101010 :case DRM_FORMAT_ARGB2101010 :return OVL_CON_CLRFMT_RGBA8888 ;case DRM_FORMAT_XBGR8888 :case DRM_FORMAT_ABGR8888 : +case DRM_FORMAT_XBGR2101010 : +case DRM_FORMAT_ABGR2101010 :return OVL_CON_CLRFMT_RGBA8888 |OVL_CON_BYTE_SWAP ;case DRM_FORMAT_UYVY :return
OVL_CON_CLRFMT_UYVY|OVL_CON_MTX_YUV_TO_RGB;
PATCH v7 8/18 drm/mediatek: Support RGBA8888 and RGBX8888 in OVL
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Support RGBA8888 and RGBX8888 formats in OVL.
--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +2 -0
@@ -114,6 +114,8 @@ static const u32 mt8195_formats[] = {DRM_FORMAT_XBGR8888 ,DRM_FORMAT_XBGR2101010 ,DRM_FORMAT_ABGR2101010 , +DRM_FORMAT_RGBX8888 , +DRM_FORMAT_RGBA8888 ,DRM_FORMAT_RGBX1010102 ,DRM_FORMAT_RGBA1010102 , DRM_FORMAT_RGB888,
Signature · 1 line
2.18.0
Re: [PATCH v7 08/18] drm/mediatek: Support RGBA8888 and RGBX8888 in OVL
Hi, Shawn:
OVL driver already implement setting for these format. This patch is to support these format for mt8195. So mention the mt8195.
Regards,
CK
Quoted 23 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Support RGBA8888 and RGBX8888 formats in OVL.
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/mediatek/mtk_disp_ovl.c +2
-0@@ -114,6 +114,8 @@ static const u32 mt8195_formats[] = {DRM_FORMAT_XBGR8888 ,DRM_FORMAT_XBGR2101010 ,DRM_FORMAT_ABGR2101010 , +DRM_FORMAT_RGBX8888 , +DRM_FORMAT_RGBA8888 ,DRM_FORMAT_RGBX1010102 ,DRM_FORMAT_RGBA1010102 , DRM_FORMAT_RGB888,
PATCH v7 9/18 drm/mediatek: Support constant blending in OVL
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Support constant alpha blending in OVL.
--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +7 -2
@@ -38,6 +38,7 @@#define DISP_REG_OVL_PITCH_MSB (n) (0x0040 + 0x20 * (n))#define OVL_PITCH_MSB_2ND_SUBBUF BIT(16)#define DISP_REG_OVL_PITCH (n) (0x0044 + 0x20 * (n)) +#define OVL_CONST_BLEND BIT(28)#define DISP_REG_OVL_RDMA_CTRL (n) (0x00c0 + 0x20 * (n))#define DISP_REG_OVL_RDMA_GMC (n) (0x00c8 + 0x20 * (n))#define DISP_REG_OVL_ADDR_MT2701 0x0040
@@ -428,6 +429,7 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,unsigned int fmt = pending->format;unsigned int offset = (pending->y <<16 ) | pending->x;unsigned int src_size = (pending->height <<16 ) | pending->width; +unsigned int ignore_pixel_alpha =0 ;unsigned int con;bool is_afbc = pending->modifier !=DRM_FORMAT_MOD_LINEAR ;union overlay_pitch {
@@ -449,6 +451,9 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,if (state->base.fb && state->base.fb->format->has_alpha) con |=OVL_CON_AEN |OVL_CON_ALPHA ; +if (state->base.fb && !state->base.fb->format->has_alpha) + ignore_pixel_alpha =OVL_CONST_BLEND ; +if (pending->rotation &DRM_MODE_REFLECT_Y ) { con |=OVL_CON_VIRT_FLIP ; addr += (pending->height -1 ) * pending->pitch;
@@ -464,8 +469,8 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,mtk_ddp_write_relaxed (cmdq_pkt, con, &ovl->cmdq_reg, ovl->regs,DISP_REG_OVL_CON (idx)); -mtk_ddp_write_relaxed (cmdq_pkt, overlay_pitch.split_pitch.lsb, &ovl->cmdq_reg, ovl->regs, -DISP_REG_OVL_PITCH (idx)); +mtk_ddp_write_relaxed (cmdq_pkt, overlay_pitch.split_pitch.lsb | ignore_pixel_alpha, + &ovl->cmdq_reg, ovl->regs,DISP_REG_OVL_PITCH (idx));mtk_ddp_write_relaxed (cmdq_pkt, src_size, &ovl->cmdq_reg, ovl->regs,DISP_REG_OVL_SRC_SIZE (idx)); mtk_ddp_write_relaxed(cmdq_pkt, offset, &ovl->cmdq_reg, ovl->regs,
Signature · 1 line
2.18.0
Re: [PATCH v7 09/18] drm/mediatek: Support constant blending in OVL
Hi, Shawn:
Quoted 3 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Support constant alpha blending in OVL.
What is constant alpha? I search in wikipedia but find nothing about constant alpha. This is not a common term, so explain it.
Regards,
CK
Quoted 58 lines
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1
-0@@ -38,6 +38,7 @@#define DISP_REG_OVL_PITCH_MSB (n) (0x0040 + 0x20 * (n))#define OVL_PITCH_MSB_2ND_SUBBUF BIT(16)#define DISP_REG_OVL_PITCH (n) (0x0044 + 0x20 * (n)) +#define OVL_CONST_BLEND BIT(28)#define DISP_REG_OVL_RDMA_CTRL (n) (0x00c0 + 0x20 * (n))#define DISP_REG_OVL_RDMA_GMC (n) (0x00c8 + 0x20 * (n))#define
DISP_REG_OVL_ADDR_MT27010x0040drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1
-0@@ -428,6 +429,7 @@ void mtk_ovl_layer_config(struct device *dev,unsigned int idx, unsigned int fmt = pending->format;unsigned int offset = (pending->y <<16 ) | pending->x;unsigned int src_size = (pending->height <<16 ) | pending- >width; +unsigned int ignore_pixel_alpha =0 ;unsigned int con;drivers/gpu/drm/mediatek/mtk_disp_ovl.c +3
-0bool is_afbc = pending->modifier !=DRM_FORMAT_MOD_LINEAR ;union overlay_pitch {@@ -449,6 +451,9 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx, if (state->base.fb && state->base.fb->format->has_alpha) con |= OVL_CON_AEN | OVL_CON_ALPHA; +if (state->base.fb && !state->base.fb->format->has_alpha) + ignore_pixel_alpha =OVL_CONST_BLEND ; +if (pending->rotation &DRM_MODE_REFLECT_Y ) { con |=OVL_CON_VIRT_FLIP ;drivers/gpu/drm/mediatek/mtk_disp_ovl.c +2
-2addr += (pending->height -1 ) * pending->pitch;@@ -464,8 +469,8 @@ void mtk_ovl_layer_config(struct device *dev,unsigned int idx, mtk_ddp_write_relaxed(cmdq_pkt, con, &ovl->cmdq_reg, ovl->regs,DISP_REG_OVL_CON (idx )); -mtk_ddp_write_relaxed (cmdq_pkt, overlay_pitch.split_pitch.lsb, &ovl->cmdq_reg, ovl->regs, -DISP_REG_OVL_PITCH (idx)); + mtk_ddp_write_relaxed(cmdq_pkt, overlay_pitch.split_pitch.lsb | ignore_pixel_alpha, + &ovl->cmdq_reg, ovl->regs,
DISP_REG_OVL_PITCH(idx));
mtk_ddp_write_relaxed(cmdq_pkt,src_size,&ovl->cmdq_reg, ovl-Quoted 1 line
regs,
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0
-0DISP_REG_OVL_SRC_SIZE(idx)); mtk_ddp_write_relaxed(cmdq_pkt, offset, &ovl->cmdq_reg, ovl-Quoted 1 line
regs,
Re: [PATCH v7 09/18] drm/mediatek: Support constant blending in OVL
In reply to Shawn SungHi, Shawn:
Quoted 45 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Support constant alpha blending in OVL.
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1
-0@@ -38,6 +38,7 @@#define DISP_REG_OVL_PITCH_MSB (n) (0x0040 + 0x20 * (n))#define OVL_PITCH_MSB_2ND_SUBBUF BIT(16)#define DISP_REG_OVL_PITCH (n) (0x0044 + 0x20 * (n)) +#define OVL_CONST_BLEND BIT(28)#define DISP_REG_OVL_RDMA_CTRL (n) (0x00c0 + 0x20 * (n))#define DISP_REG_OVL_RDMA_GMC (n) (0x00c8 + 0x20 * (n))#define
DISP_REG_OVL_ADDR_MT27010x0040drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1
-0@@ -428,6 +429,7 @@ void mtk_ovl_layer_config(struct device *dev,unsigned int idx, unsigned int fmt = pending->format;unsigned int offset = (pending->y <<16 ) | pending->x;unsigned int src_size = (pending->height <<16 ) | pending- >width; +unsigned int ignore_pixel_alpha =0 ;unsigned int con;drivers/gpu/drm/mediatek/mtk_disp_ovl.c +3
-0bool is_afbc = pending->modifier !=DRM_FORMAT_MOD_LINEAR ;union overlay_pitch {@@ -449,6 +451,9 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx, if (state->base.fb && state->base.fb->format->has_alpha) con |= OVL_CON_AEN | OVL_CON_ALPHA; +if (state->base.fb && !state->base.fb->format->has_alpha) + ignore_pixel_alpha =OVL_CONST_BLEND ; +if (pending->rotation &DRM_MODE_REFLECT_Y ) { con |=OVL_CON_VIRT_FLIP ;drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0
-0addr += (pending->height -1 ) * pending->pitch;
drivers/gpu/drm/mediatek/mtk_disp_ovl.c void mtk_ovl_layer_config(struct device *dev, · line 476
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +2
-2@@ -464,8 +469,8 @@ void mtk_ovl_layer_config(struct device *dev,unsigned int idx, mtk_ddp_write_relaxed(cmdq_pkt, con, &ovl->cmdq_reg, ovl->regs,DISP_REG_OVL_CON (idx )); -mtk_ddp_write_relaxed (cmdq_pkt, overlay_pitch.split_pitch.lsb, &ovl->cmdq_reg, ovl->regs, -DISP_REG_OVL_PITCH (idx)); + mtk_ddp_write_relaxed(cmdq_pkt, overlay_pitch.split_pitch.lsb | ignore_pixel_alpha, + &ovl->cmdq_reg, ovl->regs,
In original code, RGB888 or other pixel format without alpha works correctly. Why need to set this? If this is a bug fix, add Fixes tag.
Regards,
CK
Quoted 6 lines
DISP_REG_OVL_PITCH(idx));
mtk_ddp_write_relaxed(cmdq_pkt,src_size,&ovl->cmdq_reg, ovl-Quoted 1 line
regs,
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0
-0DISP_REG_OVL_SRC_SIZE(idx)); mtk_ddp_write_relaxed(cmdq_pkt, offset, &ovl->cmdq_reg, ovl-Quoted 1 line
regs,
PATCH v7 10/18 drm/mediatek: Support constant blending in Mixer
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Support constant blending in Mixer.
--- drivers/gpu/drm/mediatek/mtk_ethdr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_ethdr.c +10 -2
@@ -154,6 +154,7 @@ void mtk_ethdr_layer_config(struct device *dev, unsigned int idx,unsigned int offset = (pending->x &1 ) <<31 | pending->y <<16 | pending->x;unsigned int align_width =ALIGN_DOWN (pending->width,2 );unsigned int alpha_con =0 ; +bool replace_src_a = false;dev_dbg (dev,"%s+ idx:%d" , __func__, idx);
@@ -173,8 +174,15 @@ void mtk_ethdr_layer_config(struct device *dev, unsigned int idx,if (state->base.fb && state->base.fb->format->has_alpha) alpha_con =MIXER_ALPHA_AEN |MIXER_ALPHA ; -mtk_mmsys_mixer_in_config (priv->mmsys_dev, idx +1 , alpha_con ? false : true, -DEFAULT_9BIT_ALPHA , +if (state->base.fb && !state->base.fb->format->has_alpha) { +/* +* Mixer doesn't support CONST_BLD mode, +* use a trick to make the output equivalent +*/ + replace_src_a = true; + } + +mtk_mmsys_mixer_in_config (priv->mmsys_dev, idx +1 , replace_src_a,MIXER_ALPHA , pending->x &1 ?MIXER_INX_MODE_EVEN_EXTEND :MIXER_INX_MODE_BYPASS , align_width /2 -1 , cmdq_pkt);
Signature · 1 line
2.18.0
Re: [PATCH v7 10/18] drm/mediatek: Support constant blending in Mixer
Hi, Shawn:
Quoted 32 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Support constant blending in Mixer.
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_ethdr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)drivers/gpu/drm/mediatek/mtk_ethdr.c +1
-0@@ -154,6 +154,7 @@ void mtk_ethdr_layer_config(struct device *dev,unsigned int idx, unsigned int offset = (pending->x & 1) << 31 | pending->y << 16 | pending->x;unsigned int align_width =ALIGN_DOWN (pending->width,2 );unsigned int alpha_con =0 ; +bool replace_src_a = false;drivers/gpu/drm/mediatek/mtk_ethdr.c +0
-2dev_dbg (dev,"%s+ idx:%d" , __func__, idx);@@ -173,8 +174,15 @@ void mtk_ethdr_layer_config(struct device *dev,unsigned int idx, if (state->base.fb && state->base.fb->format->has_alpha) alpha_con =MIXER_ALPHA_AEN |MIXER_ALPHA ; - mtk_mmsys_mixer_in_config(priv->mmsys_dev, idx + 1, alpha_con ? false : true, - DEFAULT_9BIT_ALPHA,
drivers/gpu/drm/mediatek/mtk_ethdr.c void mtk_ethdr_layer_config(struct device *dev, · line 188
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_ethdr.c +9
-0+if (state->base.fb && !state->base.fb->format->has_alpha) { +/* +* Mixer doesn't support CONST_BLD mode, +* use a trick to make the output equivalent +*/ + replace_src_a = true; + } + + mtk_mmsys_mixer_in_config(priv->mmsys_dev, idx + 1, replace_src_a, MIXER_ALPHA,
In original code, mixer already support constant blending. If !state-
Quoted 1 line
base.fb->format->has_alpha,alpha_con= 0, and parameteralpha_selis
set to true. So this patch does not change any behavior. Drop this patch.
Regards,
CK
Quoted 5 lines
pending->x& 1 ?MIXER_INX_MODE_EVEN_EXTEND:
MIXER_INX_MODE_BYPASS,align_width/
2 - 1,cmdq_pkt);
PATCH v7 11/18 drm/mediatek: Support "Pre-multiplied" blending in OVL
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Support "Pre-multiplied" alpha blending mode on in OVL. Before this patch, only the "coverage" mode is supported.
--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 41 +++++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +35 -6
@@ -52,13 +52,16 @@#define GMC_THRESHOLD_HIGH ((1 << GMC_THRESHOLD_BITS) / 4)#define GMC_THRESHOLD_LOW ((1 << GMC_THRESHOLD_BITS) / 8) +#define OVL_CON_CLRFMT_MAN BIT(23)#define OVL_CON_BYTE_SWAP BIT(24) -#define OVL_CON_MTX_YUV_TO_RGB (6 << 16) +#define OVL_CON_RGB_SWAP BIT(25)#define OVL_CON_CLRFMT_RGB (1 << 12)#define OVL_CON_CLRFMT_RGBA8888 (2 << 12)#define OVL_CON_CLRFMT_ARGB8888 (3 << 12)#define OVL_CON_CLRFMT_UYVY (4 << 12)#define OVL_CON_CLRFMT_YUYV (5 << 12) +#define OVL_CON_MTX_YUV_TO_RGB (6 << 16) +#define OVL_CON_CLRFMT_PARGB8888 (OVL_CON_CLRFMT_ARGB8888 | OVL_CON_CLRFMT_MAN)#define OVL_CON_CLRFMT_RGB565 (ovl) ((ovl)->data->fmt_rgb565_is_0 ? \ 0 : OVL_CON_CLRFMT_RGB)#define OVL_CON_CLRFMT_RGB888 (ovl) ((ovl)->data->fmt_rgb565_is_0 ? \
@@ -72,6 +75,8 @@#define OVL_CON_VIRT_FLIP BIT(9)#define OVL_CON_HORZ_FLIP BIT(10) +#define OVL_COLOR_ALPHA GENMASK(31, 24) +static inline bool is_10bit_rgb (u32 fmt) {switch (fmt) {
@@ -296,7 +301,13 @@ void mtk_ovl_config(struct device *dev, unsigned int w,if (w !=0 && h !=0 )mtk_ddp_write_relaxed (cmdq_pkt, h <<16 | w, &ovl->cmdq_reg, ovl->regs,DISP_REG_OVL_ROI_SIZE ); -mtk_ddp_write_relaxed (cmdq_pkt,0x0 , &ovl->cmdq_reg, ovl->regs,DISP_REG_OVL_ROI_BGCLR ); + +/* +* The background color must be opaque black (ARGB), +* otherwise the alpha blending will have no effect +*/ +mtk_ddp_write_relaxed (cmdq_pkt,OVL_COLOR_ALPHA , &ovl->cmdq_reg, + ovl->regs,DISP_REG_OVL_ROI_BGCLR );mtk_ddp_write (cmdq_pkt,0x1 , &ovl->cmdq_reg, ovl->regs,DISP_REG_OVL_RST );mtk_ddp_write (cmdq_pkt,0x0 , &ovl->cmdq_reg, ovl->regs,DISP_REG_OVL_RST );
@@ -372,7 +383,8 @@ void mtk_ovl_layer_off(struct device *dev, unsigned int idx, DISP_REG_OVL_RDMA_CTRL(idx)); } -static unsigned int ovl_fmt_convert (struct mtk_disp_ovl *ovl,unsigned int fmt) +static unsigned int ovl_fmt_convert (struct mtk_disp_ovl *ovl,unsigned int fmt, +unsigned int blend_mode) {/* The return value in switch "MEM_MODE_INPUT_FORMAT_XXX" * is defined in mediatek HW data sheet.
@@ -391,21 +403,35 @@ static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt)return OVL_CON_CLRFMT_RGB888 (ovl) |OVL_CON_BYTE_SWAP ;case DRM_FORMAT_RGBX8888 :case DRM_FORMAT_RGBA8888 : +return blend_mode ==DRM_MODE_BLEND_COVERAGE ? +OVL_CON_CLRFMT_ARGB8888 : +OVL_CON_CLRFMT_PARGB8888 ;case DRM_FORMAT_RGBX1010102 :case DRM_FORMAT_RGBA1010102 :return OVL_CON_CLRFMT_ARGB8888 ;case DRM_FORMAT_BGRX8888 :case DRM_FORMAT_BGRA8888 : +return OVL_CON_BYTE_SWAP | + (blend_mode ==DRM_MODE_BLEND_COVERAGE ? +OVL_CON_CLRFMT_ARGB8888 : +OVL_CON_CLRFMT_PARGB8888 );case DRM_FORMAT_BGRX1010102 :case DRM_FORMAT_BGRA1010102 :return OVL_CON_CLRFMT_ARGB8888 |OVL_CON_BYTE_SWAP ;case DRM_FORMAT_XRGB8888 :case DRM_FORMAT_ARGB8888 : +return blend_mode ==DRM_MODE_BLEND_COVERAGE ? +OVL_CON_CLRFMT_RGBA8888 : +OVL_CON_CLRFMT_PARGB8888 ;case DRM_FORMAT_XRGB2101010 :case DRM_FORMAT_ARGB2101010 :return OVL_CON_CLRFMT_RGBA8888 ;case DRM_FORMAT_XBGR8888 :case DRM_FORMAT_ABGR8888 : +return OVL_CON_RGB_SWAP | + (blend_mode ==DRM_MODE_BLEND_COVERAGE ? +OVL_CON_CLRFMT_RGBA8888 : +OVL_CON_CLRFMT_PARGB8888 );case DRM_FORMAT_XBGR2101010 :case DRM_FORMAT_ABGR2101010 :return OVL_CON_CLRFMT_RGBA8888 |OVL_CON_BYTE_SWAP ;
@@ -429,6 +455,7 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,unsigned int fmt = pending->format;unsigned int offset = (pending->y <<16 ) | pending->x;unsigned int src_size = (pending->height <<16 ) | pending->width; +unsigned int blend_mode = state->base.pixel_blend_mode;unsigned int ignore_pixel_alpha =0 ;unsigned int con;bool is_afbc = pending->modifier !=DRM_FORMAT_MOD_LINEAR ;
@@ -447,9 +474,11 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,return ; } - con =ovl_fmt_convert (ovl, fmt); -if (state->base.fb && state->base.fb->format->has_alpha) - con |=OVL_CON_AEN |OVL_CON_ALPHA ; + con =ovl_fmt_convert (ovl, fmt, blend_mode); +if (state->base.fb) { + con |=OVL_CON_AEN ; + con |= state->base.alpha &OVL_CON_ALPHA ; + }if (state->base.fb && !state->base.fb->format->has_alpha) ignore_pixel_alpha =OVL_CONST_BLEND ;
Signature · 1 line
2.18.0
Re: [PATCH v7 11/18] drm/mediatek: Support "Pre-multiplied" blending in OVL
Hi, Shawn:
Quoted 104 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Support "Pre-multiplied" alpha blending mode on in OVL. Before this patch, only the "coverage" mode is supported.
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 41 +++++++++++++++++++++ ---- 1 file changed, 35 insertions(+), 6 deletions(-)drivers/gpu/drm/mediatek/mtk_disp_ovl.c +4
-1@@ -52,13 +52,16 @@#define GMC_THRESHOLD_HIGH ((1 << GMC_THRESHOLD_BITS) / 4)#define GMC_THRESHOLD_LOW ((1 << GMC_THRESHOLD_BITS) / 8) +#define OVL_CON_CLRFMT_MAN BIT(23)#define OVL_CON_BYTE_SWAP BIT(24) -#define OVL_CON_MTX_YUV_TO_RGB (6 << 16) +#define OVL_CON_RGB_SWAP BIT(25)#define OVL_CON_CLRFMT_RGB (1 << 12)#define OVL_CON_CLRFMT_RGBA8888 (2 << 12)#define OVL_CON_CLRFMT_ARGB8888 (3 << 12)#define OVL_CON_CLRFMT_UYVY (4 << 12)#define OVL_CON_CLRFMT_YUYV (5 << 12) +#define OVL_CON_MTX_YUV_TO_RGB (6 << 16) +#define OVL_CON_CLRFMT_PARGB8888 (OVL_CON_CLRFMT_ARGB8888 | OVL_CON_CLRFMT_MAN)#define OVL_CON_CLRFMT_RGB565 (ovl) ((ovl)->data->fmt_rgb565_is_0 ? \0 :
OVL_CON_CLRFMT_RGB)
#defineOVL_CON_CLRFMT_RGB888(ovl)((ovl)->data->fmt_rgb565_is_0 ?
\drivers/gpu/drm/mediatek/mtk_disp_ovl.c +8
-1@@ -72,6 +75,8 @@#define OVL_CON_VIRT_FLIP BIT(9)#define OVL_CON_HORZ_FLIP BIT(10) +#define OVL_COLOR_ALPHA GENMASK(31, 24) +static inline bool is_10bit_rgb (u32 fmt) {switch (fmt) {@@ -296,7 +301,13 @@ void mtk_ovl_config(struct device *dev, unsigned int w, if (w != 0 && h != 0) mtk_ddp_write_relaxed(cmdq_pkt, h << 16 | w, &ovl- >cmdq_reg, ovl->regs, DISP_REG_OVL_ROI_SIZE); -mtk_ddp_write_relaxed (cmdq_pkt,0x0 , &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_ROI_BGCLR); + +/* +* The background color must be opaque black (ARGB), +* otherwise the alpha blending will have no effect +*/ + mtk_ddp_write_relaxed(cmdq_pkt, OVL_COLOR_ALPHA, &ovl-Quoted 1 line
cmdq_reg,drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1
-0+ ovl->regs, DISP_REG_OVL_ROI_BGCLR); mtk_ddp_write(cmdq_pkt, 0x1, &ovl->cmdq_reg, ovl->regs,
DISP_REG_OVL_RST);
mtk_ddp_write(cmdq_pkt,0x0,&ovl->cmdq_reg,ovl->regs,DISP_REG_OVL_RST);drivers/gpu/drm/mediatek/mtk_disp_ovl.c +2
-1@@ -372,7 +383,8 @@ void mtk_ovl_layer_off(struct device *dev,unsigned int idx, DISP_REG_OVL_RDMA_CTRL(idx)); } -static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt) +static unsigned int ovl_fmt_convert (struct mtk_disp_ovl *ovl,unsigned int fmt, +unsigned int blend_mode){
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +9
-0/* The return value in switch "MEM_MODE_INPUT_FORMAT_XXX" * is defined in mediatek HW data sheet. @@ -391,21 +403,35 @@ static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt) return OVL_CON_CLRFMT_RGB888(ovl) | OVL_CON_BYTE_SWAP;case DRM_FORMAT_RGBX8888 :case DRM_FORMAT_RGBA8888 : +return blend_mode ==DRM_MODE_BLEND_COVERAGE ? +OVL_CON_CLRFMT_ARGB8888 : +OVL_CON_CLRFMT_PARGB8888 ;case DRM_FORMAT_RGBX1010102 :case DRM_FORMAT_RGBA1010102 :return OVL_CON_CLRFMT_ARGB8888 ;case DRM_FORMAT_BGRX8888 :case DRM_FORMAT_BGRA8888 : +return OVL_CON_BYTE_SWAP | + (blend_mode ==DRM_MODE_BLEND_COVERAGE ? +OVL_CON_CLRFMT_ARGB8888 : +OVL_CON_CLRFMT_PARGB8888 );case DRM_FORMAT_BGRX1010102 :case DRM_FORMAT_BGRA1010102 :return OVL_CON_CLRFMT_ARGB8888 |OVL_CON_BYTE_SWAP ;case DRM_FORMAT_XRGB8888 :case DRM_FORMAT_ARGB8888 : +return blend_mode ==DRM_MODE_BLEND_COVERAGE ? + OVL_CON_CLRFMT_RGBA8888 :
drivers/gpu/drm/mediatek/mtk_disp_ovl.c static unsigned int ovl_fmt_convert(struct · line 435
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +5
-0+OVL_CON_CLRFMT_PARGB8888 ;case DRM_FORMAT_XRGB2101010 :case DRM_FORMAT_ARGB2101010 :return OVL_CON_CLRFMT_RGBA8888 ;case DRM_FORMAT_XBGR8888 :case DRM_FORMAT_ABGR8888 : +return OVL_CON_RGB_SWAP | + (blend_mode ==DRM_MODE_BLEND_COVERAGE ? +OVL_CON_CLRFMT_RGBA8888 : +OVL_CON_CLRFMT_PARGB8888 );
Originally when coverage mode, XBGR8888 and ABGR8888 return
OVL_CON_CLRFMT_RGBA8888 | OVL_CON_BYTE_SWAP
but this patch return
OVL_CON_CLRFMT_RGBA8888 | OVL_CON_RGB_SWAP
This modification is not related to pre-multiplied blending, so separate to another patch.
Quoted 15 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0
-0case DRM_FORMAT_XBGR2101010 :case DRM_FORMAT_ABGR2101010 :drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1
-0return OVL_CON_CLRFMT_RGBA8888 |OVL_CON_BYTE_SWAP ;@@ -429,6 +455,7 @@ void mtk_ovl_layer_config(struct device *dev,unsigned int idx, unsigned int fmt = pending->format;unsigned int offset = (pending->y <<16 ) | pending->x;unsigned int src_size = (pending->height <<16 ) | pending- >width; +unsigned int blend_mode = state->base.pixel_blend_mode;unsigned int ignore_pixel_alpha =0 ;drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0
-0unsigned int con;bool is_afbc = pending->modifier !=DRM_FORMAT_MOD_LINEAR ;@@ -447,9 +474,11 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
drivers/gpu/drm/mediatek/mtk_disp_ovl.c void mtk_ovl_layer_config(struct device *dev, · line 481
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +4
-3return ; } - con =ovl_fmt_convert (ovl, fmt); -if (state->base.fb && state->base.fb->format->has_alpha) - con |=OVL_CON_AEN |OVL_CON_ALPHA ; + con =ovl_fmt_convert (ovl, fmt, blend_mode); +if (state->base.fb) { + con |=OVL_CON_AEN ; + con |= state->base.alpha &OVL_CON_ALPHA ;
This looks like plane alpha (The whole video plane use single alpha value), not related to pre-multiplied blending. So separate to another patch.
Regards,
CK
Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1
-0+ }if (state->base.fb && !state->base.fb->format->has_alpha)
ignore_pixel_alpha=OVL_CONST_BLEND;
PATCH v7 12/18 drm/mediatek: Support "Pre-multiplied" blending in Mixer
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Support "Pre-multiplied" alpha blending mode in Mixer. Before this patch, only the coverage mode is supported.
--- drivers/gpu/drm/mediatek/mtk_ethdr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/drm/mediatek/mtk_ethdr.c +10 -5
@@ -5,6 +5,7 @@#include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> +#include <drm/drm_blend.h> #include <linux/clk.h> #include <linux/component.h> #include <linux/of.h>
@@ -35,6 +36,7 @@#define MIX_SRC_L0_EN BIT(0)#define MIX_L_SRC_CON (n) (0x28 + 0x18 * (n))#define NON_PREMULTI_SOURCE (2 << 12) +#define PREMULTI_SOURCE (3 << 12)#define MIX_L_SRC_SIZE (n) (0x30 + 0x18 * (n))#define MIX_L_SRC_OFFSET (n) (0x34 + 0x18 * (n))#define MIX_FUNC_DCM0 0x120
@@ -153,7 +155,7 @@ void mtk_ethdr_layer_config(struct device *dev, unsigned int idx,struct mtk_plane_pending_state *pending = &state->pending;unsigned int offset = (pending->x &1 ) <<31 | pending->y <<16 | pending->x;unsigned int align_width =ALIGN_DOWN (pending->width,2 ); -unsigned int alpha_con =0 ; +unsigned int mix_con =0 ;bool replace_src_a = false;dev_dbg (dev,"%s+ idx:%d" , __func__, idx);
@@ -171,8 +173,12 @@ void mtk_ethdr_layer_config(struct device *dev, unsigned int idx,return ; } -if (state->base.fb && state->base.fb->format->has_alpha) - alpha_con =MIXER_ALPHA_AEN |MIXER_ALPHA ; + mix_con |=MIXER_ALPHA_AEN | (state->base.alpha &MIXER_ALPHA ); + +if (state->base.pixel_blend_mode !=DRM_MODE_BLEND_COVERAGE ) + mix_con |=PREMULTI_SOURCE ; +else + mix_con |=NON_PREMULTI_SOURCE ;if (state->base.fb && !state->base.fb->format->has_alpha) {/*
@@ -189,8 +195,7 @@ void mtk_ethdr_layer_config(struct device *dev, unsigned int idx,mtk_ddp_write (cmdq_pkt, pending->height <<16 | align_width, &mixer->cmdq_base, mixer->regs,MIX_L_SRC_SIZE (idx));mtk_ddp_write (cmdq_pkt, offset, &mixer->cmdq_base, mixer->regs,MIX_L_SRC_OFFSET (idx)); -mtk_ddp_write_mask (cmdq_pkt, alpha_con, &mixer->cmdq_base, mixer->regs,MIX_L_SRC_CON (idx), -0x1ff ); +mtk_ddp_write (cmdq_pkt, mix_con, &mixer->cmdq_base, mixer->regs,MIX_L_SRC_CON (idx));mtk_ddp_write_mask (cmdq_pkt,BIT (idx), &mixer->cmdq_base, mixer->regs,MIX_SRC_CON ,BIT (idx)); }
Signature · 1 line
2.18.0
Re: [PATCH v7 12/18] drm/mediatek: Support "Pre-multiplied" blending in Mixer
Hi, Shawn:
Quoted 43 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Support "Pre-multiplied" alpha blending mode in Mixer. Before this patch, only the coverage mode is supported.
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_ethdr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)drivers/gpu/drm/mediatek/mtk_ethdr.c +3
-1@@ -5,6 +5,7 @@#include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> +#include <drm/drm_blend.h> #include <linux/clk.h> #include <linux/component.h> #include <linux/of.h> @@ -35,6 +36,7 @@#define MIX_SRC_L0_EN BIT(0)#define MIX_L_SRC_CON (n) (0x28 + 0x18 * (n))#define NON_PREMULTI_SOURCE (2 << 12) +#define PREMULTI_SOURCE (3 << 12)#define MIX_L_SRC_SIZE (n) (0x30 + 0x18 * (n))#define MIX_L_SRC_OFFSET (n) (0x34 + 0x18 * (n))#define MIX_FUNC_DCM0 0x120@@ -153,7 +155,7 @@ void mtk_ethdr_layer_config(struct device *dev,unsigned int idx, struct mtk_plane_pending_state *pending = &state->pending;unsigned int offset = (pending->x &1 ) <<31 | pending->y <<16 | pending->x;unsigned int align_width =ALIGN_DOWN (pending->width,2 ); -unsigned int alpha_con =0 ; +unsigned int mix_con =0 ;bool replace_src_a = false;drivers/gpu/drm/mediatek/mtk_ethdr.c +0
-0dev_dbg (dev,"%s+ idx:%d" , __func__, idx);
drivers/gpu/drm/mediatek/mtk_ethdr.c void mtk_ethdr_layer_config(struct device *dev, · line 177
Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_ethdr.c +1
-2@@ -171,8 +173,12 @@ void mtk_ethdr_layer_config(struct device *dev,unsigned int idx, return; } -if (state->base.fb && state->base.fb->format->has_alpha) - alpha_con =MIXER_ALPHA_AEN |MIXER_ALPHA ; + mix_con |=MIXER_ALPHA_AEN | (state->base.alpha &MIXER_ALPHA );
This looks like plane alpha (the whole video plane use single alpha value), not related to pre-multiplied blending, so separate this to another patch.
For no alpha format, you change the setting. If this is bug fix, add fixes tag.
Quoted 24 lines
drivers/gpu/drm/mediatek/mtk_ethdr.c +5
-0+ +if (state->base.pixel_blend_mode !=DRM_MODE_BLEND_COVERAGE ) + mix_con |=PREMULTI_SOURCE ; +else + mix_con |=NON_PREMULTI_SOURCE ;if (state->base.fb && !state->base.fb->format->has_alpha) {drivers/gpu/drm/mediatek/mtk_ethdr.c +1
-2/* @@ -189,8 +195,7 @@ void mtk_ethdr_layer_config(struct device *dev,unsigned int idx, mtk_ddp_write(cmdq_pkt, pending->height << 16 | align_width, &mixer->cmdq_base, mixer->regs, MIX_L_SRC_SIZE(idx));mtk_ddp_write (cmdq_pkt, offset, &mixer->cmdq_base, mixer->regs,MIX_L_SRC_OFFSET (idx)); -mtk_ddp_write_mask (cmdq_pkt, alpha_con, &mixer->cmdq_base, mixer->regs,MIX_L_SRC_CON (idx), -0x1ff ); + mtk_ddp_write(cmdq_pkt, mix_con, &mixer->cmdq_base, mixer-Quoted 1 line
regs,
MIX_L_SRC_CON(idx));mtk_ddp_write_mask(cmdq_pkt, BIT(idx),
&mixer->cmdq_base,mixer->regs,MIX_SRC_CON,
BIT(idx));
}
PATCH v7 13/18 drm/mediatek: Support "None" blending in OVL
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Support "None" alpha blending mode on MediaTek's chips.
--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +2 -1
@@ -480,7 +480,8 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx, con |= state->base.alpha &OVL_CON_ALPHA ; } -if (state->base.fb && !state->base.fb->format->has_alpha) +if (blend_mode ==DRM_MODE_BLEND_PIXEL_NONE || + (state->base.fb && !state->base.fb->format->has_alpha)) ignore_pixel_alpha =OVL_CONST_BLEND ;if (pending->rotation &DRM_MODE_REFLECT_Y ) {
Signature · 1 line
2.18.0
PATCH v7 14/18 drm/mediatek: Support "None" blending in Mixer
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Support "None" alpha blending mode on MediaTek's chips.
--- drivers/gpu/drm/mediatek/mtk_ethdr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_ethdr.c +2 -1
@@ -180,7 +180,8 @@ void mtk_ethdr_layer_config(struct device *dev, unsigned int idx,else mix_con |=NON_PREMULTI_SOURCE ; -if (state->base.fb && !state->base.fb->format->has_alpha) { +if (state->base.pixel_blend_mode ==DRM_MODE_BLEND_PIXEL_NONE || + (state->base.fb && !state->base.fb->format->has_alpha)) {/* * Mixer doesn't support CONST_BLD mode, * use a trick to make the output equivalent
Signature · 1 line
2.18.0
Re: [PATCH v7 14/18] drm/mediatek: Support "None" blending in Mixer
Hi, Shawn:
Quoted 3 lines · Shawn Sung
From: Hsiao Chien Sung <[email protected]>
Support "None" alpha blending mode on MediaTek's chips.
Quoted 23 lines
Signed-off-by Hsiao Chien Sung <[email protected]>--- drivers/gpu/drm/mediatek/mtk_ethdr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/mediatek/mtk_ethdr.c +1
-1@@ -180,7 +180,8 @@ void mtk_ethdr_layer_config(struct device *dev,unsigned int idx, else mix_con |= NON_PREMULTI_SOURCE; -if (state->base.fb && !state->base.fb->format->has_alpha) { + if (state->base.pixel_blend_mode == DRM_MODE_BLEND_PIXEL_NONE||
drivers/gpu/drm/mediatek/mtk_ethdr.c +1
-0+ (state->base.fb && !state->base.fb->format->has_alpha)) {/* * Mixer doesn't support CONST_BLD mode, * use a trick to make the output equivalent
PATCH v7 15/18 drm/mediatek: Support alpha blending in display driver
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Support "Pre-multiplied" and "None" blend mode on MediaTek's chips by adding correct blend mode property when the planes init. Before this patch, only the "Coverage" mode (default) is supported.
For more information, there are three pixel blend modes in DRM driver:
"None", "Pre-multiplied", and "Coverage".
To understand the difference between these modes, let's take a look at the following two approaches to do alpha blending:
1. Straight:
dst.RGB = src.RGB * src.A + dst.RGB * (1 - src.A)
This is straightforward and easy to understand, when the source layer is compositing with the destination layer, it's alpha will affect the result. This is also known as "post-multiplied", or "Coverage" mode.
2. Pre-multiplied:
dst.RGB = src.RGB + dst.RGB * (1 - src.A)
Since the source RGB have already multiplied its alpha, only destination RGB need to multiply it. This is the "Pre-multiplied" mode in DRM.
For the "None" blend mode in DRM, it means the pixel alpha is ignored when compositing the layers, only the constant alpha for the composited layer will take effects.
--- drivers/gpu/drm/mediatek/mtk_plane.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/mediatek/mtk_plane.c +11 -0
@@ -346,6 +346,17 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,DRM_INFO ("Create rotation property failed\n" ); } + err =drm_plane_create_alpha_property (plane); +if (err) +DRM_ERROR ("failed to create property: alpha\n" ); + + err =drm_plane_create_blend_mode_property (plane, +BIT (DRM_MODE_BLEND_PREMULTI ) | +BIT (DRM_MODE_BLEND_COVERAGE ) | +BIT (DRM_MODE_BLEND_PIXEL_NONE )); +if (err) +DRM_ERROR ("failed to create property: blend_mode\n" ); +drm_plane_helper_add (plane, &mtk_plane_helper_funcs);return 0 ;
Signature · 1 line
2.18.0
PATCH v7 16/18 drm/mediatek: Support CRC in display driver
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
Register CRC related function pointers to support
CRC retrieval.
--- drivers/gpu/drm/mediatek/mtk_crtc.c | 260 ++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_crtc.h | 38 ++++ drivers/gpu/drm/mediatek/mtk_ddp_comp.h | 3 + 3 files changed, 301 insertions(+)
drivers/gpu/drm/mediatek/mtk_crtc.c +260 -0
@@ -18,6 +18,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_probe_helper.h> #include <drm/drm_vblank.h> +#include <drm/drm_vblank_work.h> #include "mtk_crtc.h" #include "mtk_ddp_comp.h"
@@ -69,6 +70,9 @@ struct mtk_crtc {/* lock for display hardware access */ struct mutex hw_lock;bool config_updating; + +struct mtk_ddp_comp *crc_provider; +struct drm_vblank_work crc_work; };struct mtk_crtc_state {
@@ -703,6 +707,71 @@ static void mtk_crtc_update_output(struct drm_crtc *crtc, } } +static void mtk_crtc_crc_work (struct kthread_work *base) +{ +struct drm_vblank_work *work =to_drm_vblank_work (base); +struct mtk_crtc *mtk_crtc = +container_of (work,typeof (*mtk_crtc), crc_work); + +if (mtk_crtc->base.crc.opened) { +struct mtk_ddp_comp *comp = mtk_crtc->crc_provider; +u64 vblank =drm_crtc_vblank_count (&mtk_crtc->base); + + comp->funcs->crc_read (comp->dev); + +/* could take more than 50ms to finish */ +drm_crtc_add_crc_entry (&mtk_crtc->base, true, vblank, + comp->funcs->crc_entry (comp->dev)); + +drm_vblank_work_schedule (&mtk_crtc->crc_work, vblank +1 , true); + } +} + +static int mtk_crtc_set_crc_source (struct drm_crtc *crtc,const char *src) +{ +struct mtk_crtc *mtk_crtc =to_mtk_crtc (crtc); + +if (!src) +return -EINVAL ; + +if (strcmp (src,"auto" ) !=0 ) { +DRM_ERROR ("%s(crtc-%d): unknown source '%s'\n" , + __func__,drm_crtc_index (crtc), src); +return -EINVAL ; + } + +/* +* skip the first crc because the first frame (vblank + 1) is configured +* by mtk_crtc_ddp_hw_init() when atomic enable +*/ +drm_vblank_work_schedule (&mtk_crtc->crc_work, +drm_crtc_vblank_count (crtc) +2 , false); +return 0 ; +} + +static int mtk_crtc_verify_crc_source (struct drm_crtc *crtc,const char *src, +size_t *cnt) +{ +struct mtk_crtc *mtk_crtc =to_mtk_crtc (crtc); +struct mtk_ddp_comp *comp = mtk_crtc->crc_provider; + +if (!comp) { +DRM_ERROR ("%s(crtc-%d): no crc provider\n" , + __func__,drm_crtc_index (crtc)); +return -ENOENT ; + } + +if (src &&strcmp (src,"auto" ) !=0 ) { +DRM_ERROR ("%s(crtc-%d): unknown source '%s'\n" , + __func__,drm_crtc_index (crtc), src); +return -EINVAL ; + } + + *cnt = comp->funcs->crc_cnt (comp->dev); + +return 0 ; +} +int mtk_crtc_plane_check (struct drm_crtc *crtc,struct drm_plane *plane,struct mtk_plane_state *state) {
@@ -751,6 +820,8 @@ static void mtk_crtc_atomic_enable(struct drm_crtc *crtc,drm_crtc_vblank_on (crtc); mtk_crtc->enabled = true; + +drm_vblank_work_init (&mtk_crtc->crc_work, crtc, mtk_crtc_crc_work); } static void mtk_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -840,6 +911,8 @@ static const struct drm_crtc_funcs mtk_crtc_funcs = { .atomic_destroy_state = mtk_crtc_destroy_state, .enable_vblank = mtk_crtc_enable_vblank, .disable_vblank = mtk_crtc_disable_vblank, + .set_crc_source = mtk_crtc_set_crc_source, + .verify_crc_source = mtk_crtc_verify_crc_source, };static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
@@ -1033,6 +1106,11 @@ int mtk_crtc_create(struct drm_device *drm_dev, const unsigned int *path,if (comp->funcs->ctm_set) has_ctm = true; + +if (comp->funcs->crc_cnt && + comp->funcs->crc_entry && + comp->funcs->crc_read) + mtk_crtc->crc_provider = comp; } mtk_ddp_comp_register_vblank_cb(comp, mtk_crtc_ddp_irq,
@@ -1136,3 +1214,185 @@ int mtk_crtc_create(struct drm_device *drm_dev, const unsigned int *path,return 0 ; } + +void mtk_crtc_init_crc (struct mtk_crtc_crc *crc,const u32 *crc_offset_table, +size_t crc_count,u32 reset_offset,u32 reset_mask) +{ + crc->ofs = crc_offset_table; + crc->cnt = crc_count; + crc->rst_ofs = reset_offset; + crc->rst_msk = reset_mask; + crc->va =kcalloc (crc->cnt,sizeof (*crc->va),GFP_KERNEL ); +if (!crc->va) { +DRM_ERROR ("failed to allocate memory for crc\n" ); + crc->cnt =0 ; + } +} + +void mtk_crtc_read_crc (struct mtk_crtc_crc *crc,void __iomem *reg) +{ +if (!crc->cnt || !crc->ofs || !crc->va) +return ; + +#if IS_REACHABLE (CONFIG_MTK_CMDQ ) +/* sync to see the most up-to-date copy of the DMA buffer */ +dma_sync_single_for_cpu (crc->cmdq_client.chan->mbox->dev, + crc->pa, crc->cnt *sizeof (*crc->va), +DMA_FROM_DEVICE ); +#endif +} + +void mtk_crtc_destroy_crc (struct mtk_crtc_crc *crc) +{ +if (!crc->cnt) +return ; + +#if IS_REACHABLE (CONFIG_MTK_CMDQ ) +if (crc->pa) { +dma_unmap_single (crc->cmdq_client.chan->mbox->dev, + crc->pa, crc->cnt *sizeof (*crc->va), +DMA_TO_DEVICE ); + crc->pa =0 ; + } +if (crc->cmdq_client.chan) { +mtk_drm_cmdq_pkt_destroy (&crc->cmdq_handle); +mbox_free_channel (crc->cmdq_client.chan); + crc->cmdq_client.chan =NULL ; + } +#endif +kfree (crc->va); + crc->va =NULL ; + crc->cnt =0 ; +} + +#if IS_REACHABLE (CONFIG_MTK_CMDQ ) +/** +* mtk_crtc_create_crc_cmdq - Create a CMDQ thread for syncing the CRCs +* @dev: Kernel device node of the CRC provider +* @crc: Pointer of the CRC to init +* +* This function will create a looping thread on GCE (Global Command Engine) to +* keep the CRC up to date by monitoring the assigned event (usually the frame +* done event) of the CRC provider, and read the CRCs from the registers to a +* shared memory for the workqueue to read. To start/stop the looping thread, +* please call `mtk_crtc_start_crc_cmdq()` and `mtk_crtc_stop_crc_cmdq()` +* defined blow. +* +* The reason why we don't update the CRCs with CPU is that the front porch of +* 4K60 timing in CEA-861 is less than 60us, and register read/write speed is +* relatively unreliable comparing to GCE due to the bus design. +* +* We must create a new thread instead of using the original one for plane +* update is because: +* 1. We cannot add another wait-for-event command at the end of cmdq packet, or +* the cmdq callback will delay for too long +* 2. Will get the CRC of the previous frame if using the existed wait-for-event +* command which is at the beginning of the packet +*/ +void mtk_crtc_create_crc_cmdq (struct device *dev,struct mtk_crtc_crc *crc) +{ +int i; + +if (!crc->cnt) { +dev_warn (dev,"%s: not support\n" , __func__); + goto cleanup; + } + +if (!crc->ofs) { +dev_warn (dev,"%s: not defined\n" , __func__); + goto cleanup; + } + + crc->cmdq_client.client.dev = dev; + crc->cmdq_client.client.tx_block = false; + crc->cmdq_client.client.knows_txdone = true; + crc->cmdq_client.client.rx_callback =NULL ; + crc->cmdq_client.chan =mbox_request_channel (&crc->cmdq_client.client,0 ); +if (IS_ERR (crc->cmdq_client.chan)) { +dev_warn (dev,"%s: failed to create mailbox client\n" , __func__); + crc->cmdq_client.chan =NULL ; + goto cleanup; + } + +if (mtk_drm_cmdq_pkt_create (&crc->cmdq_client, &crc->cmdq_handle,PAGE_SIZE )) { +dev_warn (dev,"%s: failed to create cmdq packet\n" , __func__); + goto cleanup; + } + +if (!crc->va) { +dev_warn (dev,"%s: no memory\n" , __func__); + goto cleanup; + } + +/* map the entry to get a dma address for cmdq to store the crc */ + crc->pa =dma_map_single (crc->cmdq_client.chan->mbox->dev, + crc->va, crc->cnt *sizeof (*crc->va), +DMA_FROM_DEVICE ); + +if (dma_mapping_error (crc->cmdq_client.chan->mbox->dev, crc->pa)) { +dev_err (dev,"%s: failed to map dma\n" , __func__); + goto cleanup; + } + +if (crc->cmdq_event) +cmdq_pkt_wfe (&crc->cmdq_handle, crc->cmdq_event, true); + +for (i =0 ; i < crc->cnt; i++) { +/* put crc to spr1 register */ +cmdq_pkt_read_s (&crc->cmdq_handle, crc->cmdq_reg->subsys, + crc->cmdq_reg->offset + crc->ofs[i], +CMDQ_THR_SPR_IDX1 ); + +/* copy spr1 register to physical address of the crc */ +cmdq_pkt_assign (&crc->cmdq_handle,CMDQ_THR_SPR_IDX0 , +CMDQ_ADDR_HIGH (crc->pa + i *sizeof (*crc->va))); +cmdq_pkt_write_s (&crc->cmdq_handle,CMDQ_THR_SPR_IDX0 , +CMDQ_ADDR_LOW (crc->pa + i *sizeof (*crc->va)), +CMDQ_THR_SPR_IDX1 ); + } +/* reset crc */ +mtk_ddp_write_mask (&crc->cmdq_handle, ~0 , crc->cmdq_reg,0 , + crc->rst_ofs, crc->rst_msk); + +/* clear reset bit */ +mtk_ddp_write_mask (&crc->cmdq_handle,0 , crc->cmdq_reg,0 , + crc->rst_ofs, crc->rst_msk); + +/* jump to head of the cmdq packet */ +cmdq_pkt_jump (&crc->cmdq_handle, crc->cmdq_handle.pa_base); + +return ; +cleanup: +mtk_crtc_destroy_crc (crc); +} + +/** +* mtk_crtc_start_crc_cmdq - Start the GCE looping thread for CRC update +* @crc: Pointer of the CRC information +*/ +void mtk_crtc_start_crc_cmdq (struct mtk_crtc_crc *crc) +{ +if (!crc->cmdq_client.chan) +return ; + +dma_sync_single_for_device (crc->cmdq_client.chan->mbox->dev, + crc->cmdq_handle.pa_base, + crc->cmdq_handle.cmd_buf_size, +DMA_TO_DEVICE ); +mbox_send_message (crc->cmdq_client.chan, &crc->cmdq_handle); +mbox_client_txdone (crc->cmdq_client.chan,0 ); +} + +/** +* mtk_crtc_stop_crc_cmdq - Stop the GCE looping thread for CRC update +* @crc: Pointer of the CRC information +*/ +void mtk_crtc_stop_crc_cmdq (struct mtk_crtc_crc *crc) +{ +if (!crc->cmdq_client.chan) +return ; + +/* remove all the commands from the cmdq packet */ +mbox_flush (crc->cmdq_client.chan,2000 ); +} +#endif
drivers/gpu/drm/mediatek/mtk_crtc.h +38 -0
@@ -14,6 +14,34 @@#define MTK_MAX_BPC 10#define MTK_MIN_BPC 3 +/** +* struct mtk_crtc_crc - crc related information +* @ofs: register offset of crc +* @rst_ofs: register offset of crc reset +* @rst_msk: register mask of crc reset +* @cnt: count of crc +* @va: pointer to the start of crc array +* @pa: physical address of the crc for gce to access +* @cmdq_event: the event to trigger the cmdq +* @cmdq_reg: address of the register that cmdq is going to access +* @cmdq_client: handler to control cmdq (mbox channel, thread ...etc.) +* @cmdq_handle: cmdq packet to store the commands +*/ +struct mtk_crtc_crc { +const u32 *ofs; +u32 rst_ofs; +u32 rst_msk; +size_t cnt; +u32 *va; +#if IS_REACHABLE (CONFIG_MTK_CMDQ ) +dma_addr_t pa; +u32 cmdq_event; +struct cmdq_client_reg *cmdq_reg; +struct cmdq_client cmdq_client; +struct cmdq_pkt cmdq_handle; +#endif +}; +void mtk_crtc_commit (struct drm_crtc *crtc); int mtk_crtc_create(struct drm_device *drm_dev, const unsigned int *path, unsigned int path_len, int priv_data_index,
@@ -25,4 +53,14 @@ void mtk_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane, struct drm_atomic_state *plane_state);struct device *mtk_crtc_dma_dev_get (struct drm_crtc *crtc); +void mtk_crtc_init_crc (struct mtk_crtc_crc *crc,const u32 *crc_offset_table, +size_t crc_count,u32 reset_offset,u32 reset_mask); +void mtk_crtc_read_crc (struct mtk_crtc_crc *crc,void __iomem *reg); +void mtk_crtc_destroy_crc (struct mtk_crtc_crc *crc); +#if IS_REACHABLE (CONFIG_MTK_CMDQ ) +void mtk_crtc_create_crc_cmdq (struct device *dev,struct mtk_crtc_crc *crc); +void mtk_crtc_start_crc_cmdq (struct mtk_crtc_crc *crc); +void mtk_crtc_stop_crc_cmdq (struct mtk_crtc_crc *crc); +#endif +#endif /* MTK_CRTC_H */
drivers/gpu/drm/mediatek/mtk_ddp_comp.h +3 -0
@@ -88,6 +88,9 @@ struct mtk_ddp_comp_funcs {void (*remove)(struct device *dev,struct mtk_mutex *mutex);unsigned int (*encoder_index)(struct device *dev);enum drm_mode_status (*mode_valid)(struct device *dev,const struct drm_display_mode *mode); +size_t (*crc_cnt)(struct device *dev); +u32 *(*crc_entry)(struct device *dev); +void (*crc_read)(struct device *dev); };struct mtk_ddp_comp {
Signature · 1 line
2.18.0
kernel test robot
build botRe: [PATCH v7 16/18] drm/mediatek: Support CRC in display driver
kernel test robot noticed the following build errors:
Hi Shawn,
kernel test robot noticed the following build errors:
[auto build test ERROR on next-20240501]
[cannot apply to v6.9-rc6 v6.9-rc5 v6.9-rc4 linus/master v6.9-rc6] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Shawn-Sung/soc-mediatek-Disable-9-bit-alpha-in-ETHDR/20240502-184103 base: next-20240501 patch link: https://lore.kernel.org/r/20240502103848.5845-17-shawn.sung%40mediatek.com patch subject: [PATCH v7 16/18] drm/mediatek: Support CRC in display driver config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240504/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240504/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/gpu/drm/mediatek/mtk_crtc.c: In function 'mtk_crtc_create_crc_cmdq':
>> drivers/gpu/drm/mediatek/mtk_crtc.c:1362:9: error: too few arguments to function 'cmdq_pkt_jump'
1362 | cmdq_pkt_jump(&crc->cmdq_handle, crc->cmdq_handle.pa_base);
| ^~~~~~~~~~~~~ In file included from drivers/gpu/drm/mediatek/mtk_crtc.c:11:
include/linux/soc/mediatek/mtk-cmdq.h:319:19: note: declared here
319 | static inline int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa)
| ^~~~~~~~~~~~~
vim +/cmdq_pkt_jump +1362 drivers/gpu/drm/mediatek/mtk_crtc.c
1267
1268 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
1269 /**
1270 * mtk_crtc_create_crc_cmdq - Create a CMDQ thread for syncing the CRCs
1271 * @dev: Kernel device node of the CRC provider
1272 * @crc: Pointer of the CRC to init
1273 *
1274 * This function will create a looping thread on GCE (Global Command Engine) to
1275 * keep the CRC up to date by monitoring the assigned event (usually the frame
1276 * done event) of the CRC provider, and read the CRCs from the registers to a
1277 * shared memory for the workqueue to read. To start/stop the looping thread,
1278 * please call mtk_crtc_start_crc_cmdq() and mtk_crtc_stop_crc_cmdq()
1279 * defined blow.
1280 *
1281 * The reason why we don't update the CRCs with CPU is that the front porch of
1282 * 4K60 timing in CEA-861 is less than 60us, and register read/write speed is
1283 * relatively unreliable comparing to GCE due to the bus design.
1284 *
1285 * We must create a new thread instead of using the original one for plane
1286 * update is because:
1287 * 1. We cannot add another wait-for-event command at the end of cmdq packet, or
1288 * the cmdq callback will delay for too long
1289 * 2. Will get the CRC of the previous frame if using the existed wait-for-event
1290 * command which is at the beginning of the packet
1291 */
1292 void mtk_crtc_create_crc_cmdq(struct device *dev, struct mtk_crtc_crc *crc)
1293 {
1294 int i;
1295
1296 if (!crc->cnt) {
1297 dev_warn(dev, "%s: not support\n", __func__);
1298 goto cleanup;
1299 }
1300
1301 if (!crc->ofs) {
1302 dev_warn(dev, "%s: not defined\n", __func__);
1303 goto cleanup;
1304 }
1305
1306 crc->cmdq_client.client.dev = dev;
1307 crc->cmdq_client.client.tx_block = false;
1308 crc->cmdq_client.client.knows_txdone = true;
1309 crc->cmdq_client.client.rx_callback = NULL;
1310 crc->cmdq_client.chan = mbox_request_channel(&crc->cmdq_client.client, 0);
1311 if (IS_ERR(crc->cmdq_client.chan)) {
1312 dev_warn(dev, "%s: failed to create mailbox client\n", __func__);
1313 crc->cmdq_client.chan = NULL;
1314 goto cleanup;
1315 }
1316
1317 if (mtk_drm_cmdq_pkt_create(&crc->cmdq_client, &crc->cmdq_handle, PAGE_SIZE)) {
1318 dev_warn(dev, "%s: failed to create cmdq packet\n", __func__);
1319 goto cleanup;
1320 }
1321
1322 if (!crc->va) {
1323 dev_warn(dev, "%s: no memory\n", __func__);
1324 goto cleanup;
1325 }
1326
1327 /* map the entry to get a dma address for cmdq to store the crc */
1328 crc->pa = dma_map_single(crc->cmdq_client.chan->mbox->dev,
1329 crc->va, crc->cnt * sizeof(*crc->va),
1330 DMA_FROM_DEVICE);
1331
1332 if (dma_mapping_error(crc->cmdq_client.chan->mbox->dev, crc->pa)) {
1333 dev_err(dev, "%s: failed to map dma\n", __func__);
1334 goto cleanup;
1335 }
1336
1337 if (crc->cmdq_event)
1338 cmdq_pkt_wfe(&crc->cmdq_handle, crc->cmdq_event, true);
1339
1340 for (i = 0; i < crc->cnt; i++) {
1341 /* put crc to spr1 register */
1342 cmdq_pkt_read_s(&crc->cmdq_handle, crc->cmdq_reg->subsys,
1343 crc->cmdq_reg->offset + crc->ofs[i],
1344 CMDQ_THR_SPR_IDX1);
1345
1346 /* copy spr1 register to physical address of the crc */
1347 cmdq_pkt_assign(&crc->cmdq_handle, CMDQ_THR_SPR_IDX0,
1348 CMDQ_ADDR_HIGH(crc->pa + i * sizeof(*crc->va)));
1349 cmdq_pkt_write_s(&crc->cmdq_handle, CMDQ_THR_SPR_IDX0,
1350 CMDQ_ADDR_LOW(crc->pa + i * sizeof(*crc->va)),
1351 CMDQ_THR_SPR_IDX1);
1352 }
1353 /* reset crc */
1354 mtk_ddp_write_mask(&crc->cmdq_handle, ~0, crc->cmdq_reg, 0,
1355 crc->rst_ofs, crc->rst_msk);
1356
1357 /* clear reset bit */
1358 mtk_ddp_write_mask(&crc->cmdq_handle, 0, crc->cmdq_reg, 0,
1359 crc->rst_ofs, crc->rst_msk);
1360
1361 /* jump to head of the cmdq packet */
> 1362 cmdq_pkt_jump(&crc->cmdq_handle, crc->cmdq_handle.pa_base);
1363
1364 return;
1365 cleanup:
1366 mtk_crtc_destroy_crc(crc);
1367 }
1368
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v7 17/18 drm/mediatek: Support CRC in OVL
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
We choose OVL as the CRC generator from other hardware components that are also capable of calculating CRCs, since its frame done event triggers vblanks, it can be used as a signal to know when is safe to retrieve CRC of the frame.
Please note that position of the hardware component that is chosen as CRC generator in the display path is significant. For example, while OVL is the first module in VDOSYS0, its CRC won't be affected by the modules after it, which means effects applied by PQ, Gamma, Dither or any other components after OVL won't be calculated in CRC generation.
--- drivers/gpu/drm/mediatek/mtk_ddp_comp.c | 3 + drivers/gpu/drm/mediatek/mtk_disp_drv.h | 3 + drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 198 ++++++++++++++++++++++-- 3 files changed, 194 insertions(+), 10 deletions(-)
drivers/gpu/drm/mediatek/mtk_ddp_comp.c +3 -0
@@ -351,6 +351,9 @@ static const struct mtk_ddp_comp_funcs ddp_ovl = { .clk_enable = mtk_ovl_clk_enable, .clk_disable = mtk_ovl_clk_disable, .config = mtk_ovl_config, + .crc_cnt = mtk_ovl_crc_cnt, + .crc_entry = mtk_ovl_crc_entry, + .crc_read = mtk_ovl_crc_read, .start = mtk_ovl_start, .stop = mtk_ovl_stop, .register_vblank_cb = mtk_ovl_register_vblank_cb,
drivers/gpu/drm/mediatek/mtk_disp_drv.h +3 -0
@@ -105,6 +105,9 @@ void mtk_ovl_enable_vblank(struct device *dev);void mtk_ovl_disable_vblank (struct device *dev);const u32 *mtk_ovl_get_formats (struct device *dev);size_t mtk_ovl_get_num_formats (struct device *dev); +size_t mtk_ovl_crc_cnt (struct device *dev); +u32 *mtk_ovl_crc_entry (struct device *dev); +void mtk_ovl_crc_read (struct device *dev);void mtk_ovl_adaptor_add_comp (struct device *dev,struct mtk_mutex *mutex);void mtk_ovl_adaptor_remove_comp (struct device *dev,struct mtk_mutex *mutex);
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +188 -10
299 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v7 18/18 drm/mediatek: Support CRC in OVL adaptor
In reply to Shawn SungFrom: Hsiao Chien Sung <[email protected]>
We choose Mixer as CRC generator in OVL adaptor since its frame done event will trigger vblanks, we can know when is safe to retrieve CRC of the frame.
In OVL adaptor, there's no image procession after Mixer, unlike the OVL in VDOSYS0, Mixer's CRC will include all the effects that are applied to the frame.
--- drivers/gpu/drm/mediatek/mtk_ddp_comp.c | 3 + drivers/gpu/drm/mediatek/mtk_disp_drv.h | 3 + .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 21 +++++++ drivers/gpu/drm/mediatek/mtk_ethdr.c | 61 +++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_ethdr.h | 5 ++ 5 files changed, 93 insertions(+)
drivers/gpu/drm/mediatek/mtk_ddp_comp.c +3 -0
@@ -406,6 +406,9 @@ static const struct mtk_ddp_comp_funcs ddp_ovl_adaptor = { .clk_enable = mtk_ovl_adaptor_clk_enable, .clk_disable = mtk_ovl_adaptor_clk_disable, .config = mtk_ovl_adaptor_config, + .crc_cnt = mtk_ovl_adaptor_crc_cnt, + .crc_entry = mtk_ovl_adaptor_crc_entry, + .crc_read = mtk_ovl_adaptor_crc_read, .start = mtk_ovl_adaptor_start, .stop = mtk_ovl_adaptor_stop, .layer_nr = mtk_ovl_adaptor_layer_nr,
drivers/gpu/drm/mediatek/mtk_disp_drv.h +3 -0
@@ -138,6 +138,9 @@ const u32 *mtk_ovl_adaptor_get_formats(struct device *dev);size_t mtk_ovl_adaptor_get_num_formats (struct device *dev);enum drm_mode_status mtk_ovl_adaptor_mode_valid (struct device *dev,const struct drm_display_mode *mode); +size_t mtk_ovl_adaptor_crc_cnt (struct device *dev); +u32 *mtk_ovl_adaptor_crc_entry (struct device *dev); +void mtk_ovl_adaptor_crc_read (struct device *dev);void mtk_rdma_bypass_shadow (struct device *dev);int mtk_rdma_clk_enable (struct device *dev);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +21 -0
@@ -207,6 +207,27 @@ void mtk_ovl_adaptor_layer_config(struct device *dev, unsigned int idx,mtk_ethdr_layer_config (ethdr, idx, state, cmdq_pkt); } +size_t mtk_ovl_adaptor_crc_cnt (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); + +return mtk_ethdr_crc_cnt (ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ]); +} + +u32 *mtk_ovl_adaptor_crc_entry (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); + +return mtk_ethdr_crc_entry (ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ]); +} + +void mtk_ovl_adaptor_crc_read (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); + +mtk_ethdr_crc_read (ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ]); +} +void mtk_ovl_adaptor_config (struct device *dev,unsigned int w,unsigned int h,unsigned int vrefresh,unsigned int bpc,struct cmdq_pkt *cmdq_pkt)
drivers/gpu/drm/mediatek/mtk_ethdr.c +61 -0
115 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_ethdr.h +5 -0
@@ -22,4 +22,9 @@ void mtk_ethdr_register_vblank_cb(struct device *dev,void mtk_ethdr_unregister_vblank_cb (struct device *dev);void mtk_ethdr_enable_vblank (struct device *dev);void mtk_ethdr_disable_vblank (struct device *dev); + +size_t mtk_ethdr_crc_cnt (struct device *dev); +u32 *mtk_ethdr_crc_entry (struct device *dev); +void mtk_ethdr_crc_read (struct device *dev); +#endif
Signature · 1 line
2.18.0