Add MediaTek SoC DRM (vdosys1) support for mt8195
Subsystems (5)
v26 cover Add MediaTek SoC DRM (vdosys1) support for mt8195
The hardware path of vdosys1 with DPTx output need to go through by several modules, such as, OVL_ADAPTOR and MERGE.
Add DRM and these modules support by the patches below:
Changes in v26:
- rebase to next-20220819
- resend for patch corrupted in v25
Changes in v25:
- rebase to next-20220803
Changes in v24:
- fix ovl_adaptor binding issue (mtk_disp_ovl_adaptor.c)
- Since ovl_adaptor is an aggregated component, it should be bounded after all its child components are bounded.
- rebase to next-20220708
Changes in v23:
- separate[7] mmsys/mutex and drm patches into two series
Changes in v22:
- rebase to next-20220525
- rebase to vdosys0 series v22
- separate dts to a new patch
Changes in v21:
- fix reviewer comment
- fix rdma and ethdr binding doc and dts
Changes in v20:
- fix reviewer comment
- update mmsys update bit api name
- add mtk_mmsys_update_bits error message if lose gce property
- list all mt8195 vdosys1 reset bits
Changes in v19:
- fix reviewer comment
- separate mt8195 mmsys component to a new patch
- separate mt8195 vdo0 and vdo1 routing table
- separate mmsys_write_reg api to a new patch and simplify write reg code
- separate mmsys 64 bit reset to a new patch
- separate mtk-mutex dp_intf1 component to a new patch
Changes in v18:
- fix reviewer comment
- fix rdma binding doc
- fix ethdr binding doc
- refine mmsys config cmdq support
- refine merge reset control flow, get reset control in probe function
- add ethdr reset control error handling and remove dbg log
- rebase to vdosys0 series v20 (ref [5])
Changes in v17:
- fix reviewer comment in v16
- separate ovl adaptor comp in mtk-mmsys and mtk-mutex
- separate mmsys config API
- move mdp_rdma binding yaml
- fix ovl adaptor pm runtime get sync timing issue
- rebase to vdosys0 series v19 (ref [5])
- rebase to [7] for modify vblank register change
Changes in v16:
- fix reviewer comment in v 15
- fix mtk_drm_ddp_comp.c alignment
- fix vdosys0 mmsys num before adding vdosys1 patch
Changes in v15:
- fix ethdr uppercase hex number in dts
Changes in v14:
- remove MTK_MMSYS 64 bit dependency
- add ethdr.yaml back and fix dt_schema check fail
Resend v13
- add related maintainer in maillist
Changes in v13:
- fix reviewer comment in v12
- fix rdma dt-binding format
- fix dts node naming
- fix 32 bit build error
- modify 64bit dependency for mtk-mmsys
- rebase to vdosys0 series v16. (ref [5])
Changes in v12:
- fix reviewer comment in v11
- modify mbox index
- refine dma dev for ovl_adaptor sub driver
Changes in v11:
- remove ethdr vblank spin lock
- refine ovl_adaptor print message
Changes in v10:
- refine ethdr reset control using devm_reset_control_array_get_optional_exclusive
- fix ovl_adaptor mtk_ovl_adaptor_clk_enable error handle issue
Changes in v9:
- rebase on kernel-5.16-rc1
- rebase on vdosys0 series v13. (ref [5])
- fix ovl_adaptor sub driver is brought up unintentionally
- fix clang build test fail- duplicate ethdr/mdp_rdma init_module/cleanup_module symbol issue
Changes in v8:
- separate merge async reset to new patch.
- separate drm ovl_adaptor sub driver to new patch.
- fix reviewer comment in v7.
Changes in v7:
- rebase on vdosys0 series v12 (ref[5])
- add dma description in ethdr binding document.
- refine vdosys1 bit definition of mmsys routing table.
- separate merge modification into 3 pathces.
- separate mutex modification into 2 patches.
- add plane color coding for mdp_rdma csc.
- move mdp_rdma pm control to ovl_adaptor.
- fix reviewer comment in v6.
Changes in v6:
- rebase on kernel-5.15-rc1.
- change mbox label to gce0 for dts node of vdosys1.
- modify mmsys reset num for mt8195.
- rebase on vdosys0 series v10. (ref [5])
- use drm to bring up ovl_adaptor driver.
- move drm iommu/mutex check from kms init to drm bind.
- modify rdma binding doc location. (Documentation/devicetree/bindings/arm/)
- modify for reviewer's comment in v5.
Changes in v5:
- add mmsys reset controller reference.
Changes in v4:
- use merge common driver for merge1~4.
- refine ovl_adaptor rdma driver.
- use ovl_adaptor ddp_comp function instead of ethdr.
- modify for reviewer's comment in v3.
Changes in v3:
- modify for reviewer's comment in v2.
- add vdosys1 2 pixels align limit.
- add mixer odd offset support.
Changes in v2:
- Merge PSEUDO_OVL and ETHDR into one DRM component.
- Add mmsys config API for vdosys1 hardware setting.
- Add mmsys reset control using linux reset framework.
This series are based on the following patch:
[1] arm64: dts: Add mediatek SoC mt8195 and evaluation board
[email protected] [2] arm64: dts: mt8195: add IOMMU and smi nodes [email protected] [3] [v2] arm64: dts: mt8195: add display node for vdosys0 [email protected] [4] dt-bindings: mediatek: mt8195: Add binding for MM IOMMU [email protected] [5] Add MediaTek SoC DRM (vdosys1) support for mt8195 [email protected]
Nancy.Lin (7):
dt-bindings: mediatek: add ethdr definition for mt8195 drm/mediatek: add ETHDR support for MT8195 drm/mediatek: add ovl_adaptor support for MT8195 drm/mediatek: add dma dev get function
drm/mediatek: modify mediatek-drm for mt8195 multi mmsys support drm/mediatek: add drm ovl_adaptor sub driver for MT8195 drm/mediatek: add mediatek-drm of vdosys1 support for MT8195
.../display/mediatek/mediatek,ethdr.yaml | 188 +++++++ drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_disp_drv.h | 26 + .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 528 ++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 96 ++-- drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 6 +- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 129 +++-- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 58 +- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 359 ++++++++---- drivers/gpu/drm/mediatek/mtk_drm_drv.h | 24 +- drivers/gpu/drm/mediatek/mtk_ethdr.c | 370 ++++++++++++ drivers/gpu/drm/mediatek/mtk_ethdr.h | 26 + 12 files changed, 1615 insertions(+), 197 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/mediatek/mediatek,ethdr.yaml create mode 100644 drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c create mode 100644 drivers/gpu/drm/mediatek/mtk_ethdr.c create mode 100644 drivers/gpu/drm/mediatek/mtk_ethdr.h
Signature · 1 line
2.18.0
PATCH v26 1/7 dt-bindings: mediatek: add ethdr definition for mt8195
Add vdosys1 ETHDR definition.
--- .../display/mediatek/mediatek,ethdr.yaml | 188 ++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/mediatek/mediatek,ethdr.yaml
Documentation/devicetree/bindings/display/mediatek/mediatek,ethdr.yaml new file +188 -0
@@ -0,0 +1,188 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/mediatek/mediatek,ethdr.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek Ethdr Device + +maintainers: + - Chun-Kuang Hu <[email protected]> + - Philipp Zabel <[email protected]> + +description: + ETHDR (ET High Dynamic Range) is a MediaTek internal HDR engine and is + designed for HDR video and graphics conversion in the external display path. + It handles multiple HDR input types and performs tone mapping, color + space/color format conversion, and then combine different layers, + output the required HDR or SDR signal to the subsequent display path. + This engine is composed of two video frontends, two graphic frontends, + one video backend and a mixer. ETHDR has two DMA function blocks, DS and ADL. + These two function blocks read the pre-programmed registers from DRAM and + set them to HW in the v-blanking period. + +properties: + compatible: + const: mediatek,mt8195-disp-ethdr + + reg: + maxItems: 7 + + reg-names: + items: + - const: mixer + - const: vdo_fe0 + - const: vdo_fe1 + - const: gfx_fe0 + - const: gfx_fe1 + - const: vdo_be + - const: adl_ds + + interrupts: + maxItems: 1 + + iommus: + minItems: 1 + maxItems: 2 + + clocks: + items: + - description: mixer clock + - description: video frontend 0 clock + - description: video frontend 1 clock + - description: graphic frontend 0 clock + - description: graphic frontend 1 clock + - description: video backend clock + - description: autodownload and menuload clock + - description: video frontend 0 async clock + - description: video frontend 1 async clock + - description: graphic frontend 0 async clock + - description: graphic frontend 1 async clock + - description: video backend async clock + - description: ethdr top clock + + clock-names: + items: + - const: mixer + - const: vdo_fe0 + - const: vdo_fe1 + - const: gfx_fe0 + - const: gfx_fe1 + - const: vdo_be + - const: adl_ds + - const: vdo_fe0_async + - const: vdo_fe1_async + - const: gfx_fe0_async + - const: gfx_fe1_async + - const: vdo_be_async + - const: ethdr_top + + power-domains: + maxItems: 1 + + resets: + items: + - description: video frontend 0 async reset + - description: video frontend 1 async reset + - description: graphic frontend 0 async reset + - description: graphic frontend 1 async reset + - description: video backend async reset + + reset-names: + items: + - const: vdo_fe0_async + - const: vdo_fe1_async + - const: gfx_fe0_async + - const: gfx_fe1_async + - const: vdo_be_async + + mediatek,gce-client-reg: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: The register of display function block to be set by gce. + There are 4 arguments in this property, gce node, subsys id, offset and + register size. The subsys id is defined in the gce header of each chips + include/dt-bindings/gce/<chip>-gce.h, mapping to the register of display + function block. + items: + items: + - description: phandle of GCE + - description: GCE subsys id + - description: register offset + - description: register size + minItems: 7 + maxItems: 7 + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - power-domains + - resets + - mediatek,gce-client-reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/mt8195-clk.h> + #include <dt-bindings/gce/mt8195-gce.h> + #include <dt-bindings/memory/mt8195-memory-port.h> + #include <dt-bindings/power/mt8195-power.h> + #include <dt-bindings/reset/mt8195-resets.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + hdr-engine@1c114000 { + compatible = "mediatek,mt8195-disp-ethdr"; + reg = <0 0x1c114000 0 0x1000>, + <0 0x1c115000 0 0x1000>, + <0 0x1c117000 0 0x1000>, + <0 0x1c119000 0 0x1000>, + <0 0x1c11a000 0 0x1000>, + <0 0x1c11b000 0 0x1000>, + <0 0x1c11c000 0 0x1000>; + reg-names = "mixer", "vdo_fe0", "vdo_fe1", "gfx_fe0", "gfx_fe1", + "vdo_be", "adl_ds"; + mediatek,gce-client-reg = <&gce0 SUBSYS_1c11XXXX 0x4000 0x1000>, + <&gce0 SUBSYS_1c11XXXX 0x5000 0x1000>, + <&gce0 SUBSYS_1c11XXXX 0x7000 0x1000>, + <&gce0 SUBSYS_1c11XXXX 0x9000 0x1000>, + <&gce0 SUBSYS_1c11XXXX 0xa000 0x1000>, + <&gce0 SUBSYS_1c11XXXX 0xb000 0x1000>, + <&gce0 SUBSYS_1c11XXXX 0xc000 0x1000>; + clocks = <&vdosys1 CLK_VDO1_DISP_MIXER>, + <&vdosys1 CLK_VDO1_HDR_VDO_FE0>, + <&vdosys1 CLK_VDO1_HDR_VDO_FE1>, + <&vdosys1 CLK_VDO1_HDR_GFX_FE0>, + <&vdosys1 CLK_VDO1_HDR_GFX_FE1>, + <&vdosys1 CLK_VDO1_HDR_VDO_BE>, + <&vdosys1 CLK_VDO1_26M_SLOW>, + <&vdosys1 CLK_VDO1_HDR_VDO_FE0_DL_ASYNC>, + <&vdosys1 CLK_VDO1_HDR_VDO_FE1_DL_ASYNC>, + <&vdosys1 CLK_VDO1_HDR_GFX_FE0_DL_ASYNC>, + <&vdosys1 CLK_VDO1_HDR_GFX_FE1_DL_ASYNC>, + <&vdosys1 CLK_VDO1_HDR_VDO_BE_DL_ASYNC>, + <&topckgen CLK_TOP_ETHDR>; + clock-names = "mixer", "vdo_fe0", "vdo_fe1", "gfx_fe0", "gfx_fe1", + "vdo_be", "adl_ds", "vdo_fe0_async", "vdo_fe1_async", + "gfx_fe0_async", "gfx_fe1_async","vdo_be_async", + "ethdr_top"; + power-domains = <&spm MT8195_POWER_DOMAIN_VDOSYS1>; + iommus = <&iommu_vpp M4U_PORT_L3_HDR_DS>, + <&iommu_vpp M4U_PORT_L3_HDR_ADL>; + interrupts = <GIC_SPI 517 IRQ_TYPE_LEVEL_HIGH 0>; /* disp mixer */ + resets = <&vdosys1 MT8195_VDOSYS1_SW1_RST_B_HDR_VDO_FE0_DL_ASYNC>, + <&vdosys1 MT8195_VDOSYS1_SW1_RST_B_HDR_VDO_FE1_DL_ASYNC>, + <&vdosys1 MT8195_VDOSYS1_SW1_RST_B_HDR_GFX_FE0_DL_ASYNC>, + <&vdosys1 MT8195_VDOSYS1_SW1_RST_B_HDR_GFX_FE1_DL_ASYNC>, + <&vdosys1 MT8195_VDOSYS1_SW1_RST_B_HDR_VDO_BE_DL_ASYNC>; + reset-names = "vdo_fe0_async", "vdo_fe1_async", "gfx_fe0_async", + "gfx_fe1_async", "vdo_be_async"; + }; + }; +...
Signature · 1 line
2.18.0
PATCH v26 2/7 drm/mediatek: add ETHDR support for MT8195
In reply to Nancy.LinETHDR is a part of ovl_adaptor.
ETHDR is designed for HDR video and graphics conversion in the external display path. It handles multiple HDR input types and performs tone mapping, color space/color format conversion, and then combine different layers, output the required HDR or SDR signal to the subsequent display path.
--- drivers/gpu/drm/mediatek/Makefile | 1 + drivers/gpu/drm/mediatek/mtk_drm_drv.c | 1 + drivers/gpu/drm/mediatek/mtk_drm_drv.h | 1 + drivers/gpu/drm/mediatek/mtk_ethdr.c | 370 +++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_ethdr.h | 26 ++ 5 files changed, 399 insertions(+) create mode 100644 drivers/gpu/drm/mediatek/mtk_ethdr.c create mode 100644 drivers/gpu/drm/mediatek/mtk_ethdr.h
drivers/gpu/drm/mediatek/Makefile +1 -0
@@ -14,6 +14,7 @@ mediatek-drm-y := mtk_disp_aal.o \ mtk_drm_plane.o \ mtk_dsi.o \ mtk_dpi.o \ + mtk_ethdr.o \ mtk_mdp_rdma.o obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o
drivers/gpu/drm/mediatek/mtk_drm_drv.c +1 -0
@@ -876,6 +876,7 @@ static struct platform_driver * const mtk_drm_drivers[] = { &mtk_dpi_driver, &mtk_drm_platform_driver, &mtk_dsi_driver, + &mtk_ethdr_driver, &mtk_mdp_rdma_driver, };
drivers/gpu/drm/mediatek/mtk_drm_drv.h +1 -0
@@ -61,6 +61,7 @@ extern struct platform_driver mtk_disp_ovl_driver;extern struct platform_driver mtk_disp_rdma_driver;extern struct platform_driver mtk_dpi_driver;extern struct platform_driver mtk_dsi_driver; +extern struct platform_driver mtk_ethdr_driver;extern struct platform_driver mtk_mdp_rdma_driver;#endif /* MTK_DRM_DRV_H */
drivers/gpu/drm/mediatek/mtk_ethdr.c new file +370 -0
370 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_ethdr.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (c) 2021 MediaTek Inc. +*/ + +#ifndef __MTK_ETHDR_H__ +#define __MTK_ETHDR_H__ + +void mtk_ethdr_start (struct device *dev); +void mtk_ethdr_stop (struct device *dev); +int mtk_ethdr_clk_enable (struct device *dev); +void mtk_ethdr_clk_disable (struct device *dev); +void mtk_ethdr_config (struct device *dev,unsigned int w, +unsigned int h,unsigned int vrefresh, +unsigned int bpc,struct cmdq_pkt *cmdq_pkt); +void mtk_ethdr_layer_config (struct device *dev,unsigned int idx, +struct mtk_plane_state *state, +struct cmdq_pkt *cmdq_pkt); +void mtk_ethdr_register_vblank_cb (struct device *dev, +void (*vblank_cb)(void *), +void *vblank_cb_data); +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); +#endif +
Signature · 1 line
2.18.0
kernel test robot
build botRe: [PATCH v26 2/7] drm/mediatek: add ETHDR support for MT8195
Thank you for the patch! Yet something to improve:
Hi "Nancy.Lin",
Thank you for the patch! Yet something to improve:
[auto build test ERROR on drm-misc/drm-misc-next]
[cannot apply to robh/for-next mbgg-mediatek/for-next]
[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/Nancy-Lin/Add-MediaTek-SoC-DRM-vdosys1-support-for-mt8195/20220819-142314 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next config: arm-allyesconfig (https://download.01.org/0day-ci/archive/20220819/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/ec3724f819412feab6e61118e61e574a86aa4dc0
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Nancy-Lin/Add-MediaTek-SoC-DRM-vdosys1-support-for-mt8195/20220819-142314 git checkout ec3724f819412feab6e61118e61e574a86aa4dc0
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
All errors (new ones prefixed by >>):
drivers/gpu/drm/mediatek/mtk_ethdr.c: In function 'mtk_ethdr_layer_config':
>> drivers/gpu/drm/mediatek/mtk_ethdr.c:171:9: error: implicit declaration of function 'mtk_mmsys_mixer_in_config' [-Werror=implicit-function-declaration]
171 | mtk_mmsys_mixer_in_config(priv->mmsys_dev, idx + 1, alpha_con ? false : true,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/mediatek/mtk_ethdr.c: In function 'mtk_ethdr_config':
>> drivers/gpu/drm/mediatek/mtk_ethdr.c:232:9: error: implicit declaration of function 'mtk_mmsys_hdr_confing'; did you mean 'mtk_mmsys_ddp_connect'? [-Werror=implicit-function-declaration]
232 | mtk_mmsys_hdr_confing(priv->mmsys_dev, w / 2, h, cmdq_pkt);
| ^~~~~~~~~~~~~~~~~~~~~
| mtk_mmsys_ddp_connect
>> drivers/gpu/drm/mediatek/mtk_ethdr.c:233:9: error: implicit declaration of function 'mtk_mmsys_mixer_in_channel_swap' [-Werror=implicit-function-declaration]
233 | mtk_mmsys_mixer_in_channel_swap(priv->mmsys_dev, 4, 0, cmdq_pkt);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +/mtk_mmsys_mixer_in_config +171 drivers/gpu/drm/mediatek/mtk_ethdr.c
146
147 void mtk_ethdr_layer_config(struct device *dev, unsigned int idx,
148 struct mtk_plane_state *state,
149 struct cmdq_pkt *cmdq_pkt)
150 {
151 struct mtk_ethdr *priv = dev_get_drvdata(dev);
152 struct mtk_ethdr_comp *mixer = &priv->ethdr_comp[ETHDR_MIXER];
153 struct mtk_plane_pending_state *pending = &state->pending;
154 unsigned int offset = (pending->x & 1) << 31 | pending->y << 16 | pending->x;
155 unsigned int align_width = ALIGN_DOWN(pending->width, 2);
156 unsigned int alpha_con = 0;
157
158 dev_dbg(dev, "%s+ idx:%d", __func__, idx);
159
160 if (idx >= 4)
161 return;
162
163 if (!pending->enable) {
164 mtk_ddp_write(cmdq_pkt, 0, &mixer->cmdq_base, mixer->regs, MIX_L_SRC_SIZE(idx));
165 return;
166 }
167
168 if (state->base.fb && state->base.fb->format->has_alpha)
169 alpha_con = MIXER_ALPHA_AEN | MIXER_ALPHA;
170
> 171 mtk_mmsys_mixer_in_config(priv->mmsys_dev, idx + 1, alpha_con ? false : true,
172 DEFAULT_9BIT_ALPHA,
173 pending->x & 1 ? MIXER_INX_MODE_EVEN_EXTEND :
174 MIXER_INX_MODE_BYPASS, align_width / 2 - 1, cmdq_pkt);
175
176 mtk_ddp_write(cmdq_pkt, pending->height << 16 | align_width, &mixer->cmdq_base,
177 mixer->regs, MIX_L_SRC_SIZE(idx));
178 mtk_ddp_write(cmdq_pkt, offset, &mixer->cmdq_base, mixer->regs, MIX_L_SRC_OFFSET(idx));
179 mtk_ddp_write_mask(cmdq_pkt, alpha_con, &mixer->cmdq_base, mixer->regs, MIX_L_SRC_CON(idx),
180 0x1ff);
181 mtk_ddp_write_mask(cmdq_pkt, BIT(idx), &mixer->cmdq_base, mixer->regs, MIX_SRC_CON,
182 BIT(idx));
183 }
184
185 void mtk_ethdr_config(struct device *dev, unsigned int w,
186 unsigned int h, unsigned int vrefresh,
187 unsigned int bpc, struct cmdq_pkt *cmdq_pkt)
188 {
189 struct mtk_ethdr *priv = dev_get_drvdata(dev);
190 struct mtk_ethdr_comp *vdo_fe0 = &priv->ethdr_comp[ETHDR_VDO_FE0];
191 struct mtk_ethdr_comp *vdo_fe1 = &priv->ethdr_comp[ETHDR_VDO_FE1];
192 struct mtk_ethdr_comp *gfx_fe0 = &priv->ethdr_comp[ETHDR_GFX_FE0];
193 struct mtk_ethdr_comp *gfx_fe1 = &priv->ethdr_comp[ETHDR_GFX_FE1];
194 struct mtk_ethdr_comp *vdo_be = &priv->ethdr_comp[ETHDR_VDO_BE];
195 struct mtk_ethdr_comp *mixer = &priv->ethdr_comp[ETHDR_MIXER];
196
197 dev_dbg(dev, "%s-w:%d, h:%d\n", __func__, w, h);
198
199 mtk_ddp_write(cmdq_pkt, HDR_VDO_FE_0804_BYPASS_ALL, &vdo_fe0->cmdq_base,
200 vdo_fe0->regs, HDR_VDO_FE_0804_HDR_DM_FE);
201
202 mtk_ddp_write(cmdq_pkt, HDR_VDO_FE_0804_BYPASS_ALL, &vdo_fe1->cmdq_base,
203 vdo_fe1->regs, HDR_VDO_FE_0804_HDR_DM_FE);
204
205 mtk_ddp_write(cmdq_pkt, HDR_GFX_FE_0204_BYPASS_ALL, &gfx_fe0->cmdq_base,
206 gfx_fe0->regs, HDR_GFX_FE_0204_GFX_HDR_FE);
207
208 mtk_ddp_write(cmdq_pkt, HDR_GFX_FE_0204_BYPASS_ALL, &gfx_fe1->cmdq_base,
209 gfx_fe1->regs, HDR_GFX_FE_0204_GFX_HDR_FE);
210
211 mtk_ddp_write(cmdq_pkt, HDR_VDO_BE_0204_BYPASS_ALL, &vdo_be->cmdq_base,
212 vdo_be->regs, HDR_VDO_BE_0204_VDO_DM_BE);
213
214 mtk_ddp_write(cmdq_pkt, MIX_FUNC_DCM_ENABLE, &mixer->cmdq_base, mixer->regs, MIX_FUNC_DCM0);
215 mtk_ddp_write(cmdq_pkt, MIX_FUNC_DCM_ENABLE, &mixer->cmdq_base, mixer->regs, MIX_FUNC_DCM1);
216 mtk_ddp_write(cmdq_pkt, h << 16 | w, &mixer->cmdq_base, mixer->regs, MIX_ROI_SIZE);
217 mtk_ddp_write(cmdq_pkt, BGCLR_BLACK, &mixer->cmdq_base, mixer->regs, MIX_ROI_BGCLR);
218 mtk_ddp_write(cmdq_pkt, NON_PREMULTI_SOURCE, &mixer->cmdq_base, mixer->regs,
219 MIX_L_SRC_CON(0));
220 mtk_ddp_write(cmdq_pkt, NON_PREMULTI_SOURCE, &mixer->cmdq_base, mixer->regs,
221 MIX_L_SRC_CON(1));
222 mtk_ddp_write(cmdq_pkt, NON_PREMULTI_SOURCE, &mixer->cmdq_base, mixer->regs,
223 MIX_L_SRC_CON(2));
224 mtk_ddp_write(cmdq_pkt, NON_PREMULTI_SOURCE, &mixer->cmdq_base, mixer->regs,
225 MIX_L_SRC_CON(3));
226 mtk_ddp_write(cmdq_pkt, 0x0, &mixer->cmdq_base, mixer->regs, MIX_L_SRC_SIZE(0));
227 mtk_ddp_write(cmdq_pkt, OUTPUT_NO_RND | SOURCE_RGB_SEL | BACKGROUND_RELAY,
228 &mixer->cmdq_base, mixer->regs, MIX_DATAPATH_CON);
229 mtk_ddp_write_mask(cmdq_pkt, MIX_SRC_L0_EN, &mixer->cmdq_base, mixer->regs,
230 MIX_SRC_CON, MIX_SRC_L0_EN);
231
> 232 mtk_mmsys_hdr_confing(priv->mmsys_dev, w / 2, h, cmdq_pkt);
> 233 mtk_mmsys_mixer_in_channel_swap(priv->mmsys_dev, 4, 0, cmdq_pkt); 234 }
235
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
Re: [PATCH v26 2/7] drm/mediatek: add ETHDR support for MT8195
Hi,
Thanks for testing.
This series need to based on another mmsys series [1].
All the implicit-function-declaration functions are newly added in [2].
[1]
https://patchwork.kernel.org/project/linux-mediatek/list/?series=669098
[2]
https://patchwork.kernel.org/project/linux-mediatek/patch/20220819061011.7672-6-nancy.lin(a)mediatek.com/
Thanks,
Nancy
Quoted 11 lines · kernel test robot
Hi "Nancy.Lin",
Thank you for the patch! Yet something to improve:
[auto build test ERROR on drm-misc/drm-misc-next] [cannot apply to robh/for-next mbgg-mediatek/for-next] [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
Quoted 208 lines
]
base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next config: arm-allyesconfig (https://urldefense.com/v3/__https://download.01.org/0day-ci/archive/20220819/202208191837.iIwHfovs-lkp(a)intel.com/config__;!!CTRNKA9wMg0ARbw!wNjl5G7qt3vY_FW8w5Hhk8DfDRqU7QQLd0xm_MUAT7uF23DX0MvmaNio_vxbrlxE$
)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget
https://urldefense.com/v3/__https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross__;!!CTRNKA9wMg0ARbw!wNjl5G7qt3vY_FW8w5Hhk8DfDRqU7QQLd0xm_MUAT7uF23DX0MvmaNio_kKzkkvN$
-O ~/bin/make.cross
chmod +x ~/bin/make.cross
#
https://urldefense.com/v3/__https://github.com/intel-lab-lkp/linux/commit/ec3724f819412feab6e61118e61e574a86aa4dc0__;!!CTRNKA9wMg0ARbw!wNjl5G7qt3vY_FW8w5Hhk8DfDRqU7QQLd0xm_MUAT7uF23DX0MvmaNio_sBdpge9$git remote add linux-review
https://urldefense.com/v3/__https://github.com/intel-lab-lkp/linux__;!!CTRNKA9wMg0ARbw!wNjl5G7qt3vY_FW8w5Hhk8DfDRqU7QQLd0xm_MUAT7uF23DX0MvmaNio_iv3Tqqs$git fetch --no-tags linux-review Nancy-Lin/Add-MediaTek-SoC- DRM-vdosys1-support-for-mt8195/20220819-142314 git checkout ec3724f819412feab6e61118e61e574a86aa4dc0 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
Reported-by kernel test robot <[email protected]>All errors (new ones prefixed by >>):
drivers/gpu/drm/mediatek/mtk_ethdr.c: In function
'mtk_ethdr_layer_config':Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_ethdr.c:171:9: error: implicit declaration of function 'mtk_mmsys_mixer_in_config' [- Werror=implicit-function-declaration]171 | mtk_mmsys_mixer_in_config(priv->mmsys_dev, idx + 1, alpha_con ? false : true, | ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/mediatek/mtk_ethdr.c: In function
'mtk_ethdr_config':Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_ethdr.c:232:9: error: implicit declaration of function 'mtk_mmsys_hdr_confing'; did you mean 'mtk_mmsys_ddp_connect'? [-Werror=implicit-function-declaration]232 | mtk_mmsys_hdr_confing(priv->mmsys_dev, w / 2, h, cmdq_pkt); | ^~~~~~~~~~~~~~~~~~~~~ | mtk_mmsys_ddp_connectQuoted 3 lines
Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_ethdr.c:233:9: error: implicit declaration of function 'mtk_mmsys_mixer_in_channel_swap' [- Werror=implicit-function-declaration]233 | mtk_mmsys_mixer_in_channel_swap(priv->mmsys_dev, 4, 0, cmdq_pkt); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +/mtk_mmsys_mixer_in_config +171
drivers/gpu/drm/mediatek/mtk_ethdr.c146
147 void mtk_ethdr_layer_config(struct device *dev,
unsigned int idx,
148 structmtk_plane_state
*state,
149 structcmdq_pkt*cmdq_pkt)150 { 151 struct mtk_ethdr *priv = dev_get_drvdata(dev); 152 struct mtk_ethdr_comp *mixer = &priv-Quoted 1 line
ethdr_comp[ETHDR_MIXER];
153 struct
mtk_plane_pending_state*pending =&state->pending; 154 unsigned int offset = (pending->x & 1) << 31 |
pending->y<< 16 |pending->x;
155 unsigned intalign_width= ALIGN_DOWN(pending-Quoted 1 line
width, 2);
156 unsigned int alpha_con = 0; 157 158 dev_dbg(dev, "%s+ idx:%d", __func__, idx); 159 160 if (idx >= 4) 161 return; 162 163 if (!pending->enable) { 164 mtk_ddp_write(cmdq_pkt, 0, &mixer-Quoted 1 line
cmdq_base,mixer->regs,MIX_L_SRC_SIZE(idx));165 return; 166 } 167 168 if (state->base.fb && state->base.fb->format-Quoted 1 line
has_alpha)169
alpha_con=MIXER_ALPHA_AEN|MIXER_ALPHA; 170Quoted 1 line
171 mtk_mmsys_mixer_in_config(priv->mmsys_dev, idx
+ 1,
alpha_con? false : true,
172DEFAULT_9BIT_ALPHA,
173pending->x& 1 ?MIXER_INX_MODE_EVEN_EXTEND:174 MIXER_INX_MODE_BYPASS , align_width / 2 - 1, cmdq_pkt); 175 176 mtk_ddp_write(cmdq_pkt, pending->height << 16 | align_width, &mixer->cmdq_base, 177 mixer->regs, MIX_L_SRC_SIZE(idx)); 178 mtk_ddp_write(cmdq_pkt, offset, &mixer-Quoted 1 line
cmdq_base,mixer->regs,MIX_L_SRC_OFFSET(idx));179 mtk_ddp_write_mask(cmdq_pkt,
alpha_con, &mixer-Quoted 1 line
cmdq_base,mixer->regs,MIX_L_SRC_CON(idx),180 0x1ff); 181 mtk_ddp_write_mask(cmdq_pkt, BIT(idx), &mixer-Quoted 1 line
cmdq_base,mixer->regs,MIX_SRC_CON,182 BIT(idx)); 183 } 184 185 void mtk_ethdr_config(struct device *dev, unsigned intw,
186 unsigned int h, unsigned int
vrefresh,
187 unsigned int bpc, structcmdq_pkt*cmdq_pkt)188 { 189 struct mtk_ethdr *priv = dev_get_drvdata(dev); 190 struct mtk_ethdr_comp *vdo_fe0 = &priv-Quoted 1 line
ethdr_comp[ETHDR_VDO_FE0];
191 struct
mtk_ethdr_comp*vdo_fe1= &priv-Quoted 1 line
ethdr_comp[ETHDR_VDO_FE1];
192 struct
mtk_ethdr_comp*gfx_fe0= &priv-Quoted 1 line
ethdr_comp[ETHDR_GFX_FE0];
193 struct
mtk_ethdr_comp*gfx_fe1= &priv-Quoted 1 line
ethdr_comp[ETHDR_GFX_FE1];
194 struct
mtk_ethdr_comp*vdo_be= &priv-Quoted 1 line
ethdr_comp[ETHDR_VDO_BE];
195 struct
mtk_ethdr_comp*mixer = &priv-Quoted 1 line
ethdr_comp[ETHDR_MIXER];
196
197 dev_dbg(dev, "%s-w:%d, h:%d\n",__func__, w,h); 198 199 mtk_ddp_write(cmdq_pkt, HDR_VDO_FE_0804_BYPASS_ALL, &vdo_fe0->cmdq_base, 200 vdo_fe0->regs, HDR_VDO_FE_0804_HDR_DM_FE); 201 202 mtk_ddp_write(cmdq_pkt, HDR_VDO_FE_0804_BYPASS_ALL, &vdo_fe1->cmdq_base, 203 vdo_fe1->regs, HDR_VDO_FE_0804_HDR_DM_FE); 204 205 mtk_ddp_write(cmdq_pkt, HDR_GFX_FE_0204_BYPASS_ALL, &gfx_fe0->cmdq_base, 206 gfx_fe0->regs, HDR_GFX_FE_0204_GFX_HDR_FE); 207 208 mtk_ddp_write(cmdq_pkt, HDR_GFX_FE_0204_BYPASS_ALL, &gfx_fe1->cmdq_base, 209 gfx_fe1->regs, HDR_GFX_FE_0204_GFX_HDR_FE); 210 211 mtk_ddp_write(cmdq_pkt, HDR_VDO_BE_0204_BYPASS_ALL, &vdo_be->cmdq_base, 212 vdo_be->regs, HDR_VDO_BE_0204_VDO_DM_BE); 213 214 mtk_ddp_write(cmdq_pkt, MIX_FUNC_DCM_ENABLE, &mixer->cmdq_base, mixer->regs, MIX_FUNC_DCM0); 215 mtk_ddp_write(cmdq_pkt, MIX_FUNC_DCM_ENABLE, &mixer->cmdq_base, mixer->regs, MIX_FUNC_DCM1); 216 mtk_ddp_write(cmdq_pkt, h << 16 | w, &mixer-Quoted 1 line
cmdq_base,mixer->regs,MIX_ROI_SIZE);217 mtk_ddp_write(cmdq_pkt,
BGCLR_BLACK, &mixer-Quoted 1 line
cmdq_base,mixer->regs,MIX_ROI_BGCLR);218 mtk_ddp_write(cmdq_pkt,
NON_PREMULTI_SOURCE,&mixer->cmdq_base,mixer->regs,219 MIX_L_SRC_CON(0)); 220 mtk_ddp_write(cmdq_pkt, NON_PREMULTI_SOURCE, &mixer->cmdq_base, mixer->regs, 221 MIX_L_SRC_CON(1)); 222 mtk_ddp_write(cmdq_pkt, NON_PREMULTI_SOURCE, &mixer->cmdq_base, mixer->regs, 223 MIX_L_SRC_CON(2)); 224 mtk_ddp_write(cmdq_pkt, NON_PREMULTI_SOURCE, &mixer->cmdq_base, mixer->regs, 225 MIX_L_SRC_CON(3)); 226 mtk_ddp_write(cmdq_pkt, 0x0, &mixer->cmdq_base, mixer->regs, MIX_L_SRC_SIZE(0)); 227 mtk_ddp_write(cmdq_pkt, OUTPUT_NO_RND | SOURCE_RGB_SEL | BACKGROUND_RELAY, 228 &mixer->cmdq_base, mixer->regs, MIX_DATAPATH_CON); 229 mtk_ddp_write_mask(cmdq_pkt, MIX_SRC_L0_EN, &mixer->cmdq_base, mixer->regs, 230 MIX_SRC_CON, MIX_SRC_L0_EN); 231Quoted 1 line
232 mtk_mmsys_hdr_confing(priv->mmsys_dev, w / 2,
h,
cmdq_pkt);Quoted 2 lines
233 mtk_mmsys_mixer_in_channel_swap(priv-
mmsys_dev, 4, 0,cmdq_pkt);234 }
235
PATCH v26 3/7 drm/mediatek: add ovl_adaptor support for MT8195
In reply to Nancy.LinAdd ovl_adaptor driver for MT8195.Ovl_adaptor is an encapsulated module and designed for simplified DRM control flow. This module is composed of 8 RDMAs, 4 MERGEs and an ETHDR. Two RDMAs merge into one layer, so this module support 4 layers.
--- drivers/gpu/drm/mediatek/Makefile | 1 + drivers/gpu/drm/mediatek/mtk_disp_drv.h | 26 + .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 528 ++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 1 + 4 files changed, 556 insertions(+) create mode 100644 drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
drivers/gpu/drm/mediatek/Makefile +1 -0
@@ -6,6 +6,7 @@ mediatek-drm-y := mtk_disp_aal.o \ mtk_disp_gamma.o \ mtk_disp_merge.o \ mtk_disp_ovl.o \ + mtk_disp_ovl_adaptor.o \ mtk_disp_rdma.o \ mtk_drm_crtc.o \ mtk_drm_ddp_comp.o \
drivers/gpu/drm/mediatek/mtk_disp_drv.h +26 -0
@@ -7,6 +7,8 @@#define _MTK_DISP_DRV_H_#include <linux/soc/mediatek/mtk-cmdq.h> +#include <linux/soc/mediatek/mtk-mmsys.h> +#include <linux/soc/mediatek/mtk-mutex.h> #include "mtk_drm_plane.h" #include "mtk_mdp_rdma.h"
@@ -116,6 +118,30 @@ void mtk_rdma_unregister_vblank_cb(struct device *dev);void mtk_rdma_enable_vblank (struct device *dev);void mtk_rdma_disable_vblank (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); +void mtk_ovl_adaptor_connect (struct device *dev,struct device *mmsys_dev, +unsigned int next); +void mtk_ovl_adaptor_disconnect (struct device *dev,struct device *mmsys_dev, +unsigned int next); +int mtk_ovl_adaptor_clk_enable (struct device *dev); +void mtk_ovl_adaptor_clk_disable (struct device *dev); +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); +void mtk_ovl_adaptor_layer_config (struct device *dev,unsigned int idx, +struct mtk_plane_state *state, +struct cmdq_pkt *cmdq_pkt); +void mtk_ovl_adaptor_register_vblank_cb (struct device *dev,void (*vblank_cb)(void *), +void *vblank_cb_data); +void mtk_ovl_adaptor_unregister_vblank_cb (struct device *dev); +void mtk_ovl_adaptor_enable_vblank (struct device *dev); +void mtk_ovl_adaptor_disable_vblank (struct device *dev); +void mtk_ovl_adaptor_start (struct device *dev); +void mtk_ovl_adaptor_stop (struct device *dev); +unsigned int mtk_ovl_adaptor_layer_nr (struct device *dev); +struct device *mtk_ovl_adaptor_dma_dev_get (struct device *dev); +int mtk_mdp_rdma_clk_enable (struct device *dev);void mtk_mdp_rdma_clk_disable (struct device *dev);void mtk_mdp_rdma_start (struct device *dev,struct cmdq_pkt *cmdq_pkt);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +528 -0
528 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_drm_drv.h +1 -0
@@ -57,6 +57,7 @@ extern struct platform_driver mtk_disp_ccorr_driver;extern struct platform_driver mtk_disp_color_driver;extern struct platform_driver mtk_disp_gamma_driver;extern struct platform_driver mtk_disp_merge_driver; +extern struct platform_driver mtk_disp_ovl_adaptor_driver;extern struct platform_driver mtk_disp_ovl_driver;extern struct platform_driver mtk_disp_rdma_driver;extern struct platform_driver mtk_dpi_driver;
Signature · 1 line
2.18.0
Re: [PATCH v26 3/7] drm/mediatek: add ovl_adaptor support for MT8195
Quoted 6 lines · On Fri, 19 Aug 2022 08:14, "" wrote:
Add
ovl_adaptordriver for MT8195.Ovl_adaptoris an encapsulated module and designed for simplified DRM control flow. This module is composed of 8 RDMAs, 4 MERGEs and an ETHDR. Two RDMAs merge into one layer, so this module support 4 layers.
Hi Nancy, sorry I'm late in the review process, but I just applied your series and I stumbled upon a panic.
(see details inline)
This is due to the fact that my dts is missing the required ovl components, though, I think the driver
shouldn't cause a panic whenever the dts is not complete.
I'm testing this out with an mt8195-demo board.
Quoted 566 lines
Signed-off-by Nancy.Lin <[email protected]>Reviewed-by Chun-Kuang Hu <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Tested-by Bo-Chen Chen <[email protected]>---
drivers/gpu/drm/mediatek/Makefile | 1 + drivers/gpu/drm/mediatek/mtk_disp_drv.h | 26 + .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 528 ++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 1 + 4 files changed, 556 insertions(+)create mode 100644
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.cdrivers/gpu/drm/mediatek/Makefile +1
-0@@ -6,6 +6,7 @@ mediatek-drm-y := mtk_disp_aal.o \ mtk_disp_gamma.o \ mtk_disp_merge.o \ mtk_disp_ovl.o \ + mtk_disp_ovl_adaptor.o \ mtk_disp_rdma.o \ mtk_drm_crtc.o \ mtk_drm_ddp_comp.o \drivers/gpu/drm/mediatek/mtk_disp_drv.h +26
-0@@ -7,6 +7,8 @@#define _MTK_DISP_DRV_H_#include <linux/soc/mediatek/mtk-cmdq.h> +#include <linux/soc/mediatek/mtk-mmsys.h> +#include <linux/soc/mediatek/mtk-mutex.h> #include "mtk_drm_plane.h" #include "mtk_mdp_rdma.h" @@ -116,6 +118,30 @@ void mtk_rdma_unregister_vblank_cb(struct device *dev);void mtk_rdma_enable_vblank (struct device *dev);void mtk_rdma_disable_vblank (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); +void mtk_ovl_adaptor_connect (struct device *dev,struct device *mmsys_dev, +unsigned int next); +void mtk_ovl_adaptor_disconnect (struct device *dev,struct device *mmsys_dev, +unsigned int next); +int mtk_ovl_adaptor_clk_enable (struct device *dev); +void mtk_ovl_adaptor_clk_disable (struct device *dev); +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); +void mtk_ovl_adaptor_layer_config (struct device *dev,unsigned int idx, +struct mtk_plane_state *state, +struct cmdq_pkt *cmdq_pkt); +void mtk_ovl_adaptor_register_vblank_cb (struct device *dev,void (*vblank_cb)(void *), +void *vblank_cb_data); +void mtk_ovl_adaptor_unregister_vblank_cb (struct device *dev); +void mtk_ovl_adaptor_enable_vblank (struct device *dev); +void mtk_ovl_adaptor_disable_vblank (struct device *dev); +void mtk_ovl_adaptor_start (struct device *dev); +void mtk_ovl_adaptor_stop (struct device *dev); +unsigned int mtk_ovl_adaptor_layer_nr (struct device *dev); +struct device *mtk_ovl_adaptor_dma_dev_get (struct device *dev); +int mtk_mdp_rdma_clk_enable (struct device *dev);void mtk_mdp_rdma_clk_disable (struct device *dev);void mtk_mdp_rdma_start (struct device *dev,struct cmdq_pkt *cmdq_pkt);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +491
-0@@ -0,0 +1,528 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2021 MediaTek Inc. +*/ + +#include <drm/drm_fourcc.h> +#include <drm/drm_of.h> +#include <linux/clk.h> +#include <linux/component.h> +#include <linux/of_device.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> +#include <linux/pm_runtime.h> +#include <linux/reset.h> +#include <linux/soc/mediatek/mtk-cmdq.h> +#include <linux/soc/mediatek/mtk-mmsys.h> +#include <linux/soc/mediatek/mtk-mutex.h> + +#include "mtk_disp_drv.h" +#include "mtk_drm_crtc.h" +#include "mtk_drm_ddp_comp.h" +#include "mtk_drm_drv.h" +#include "mtk_ethdr.h" + +#define MTK_OVL_ADAPTOR_RDMA_MAX_WIDTH 1920 +#define MTK_OVL_ADAPTOR_LAYER_NUM 4 + +enum mtk_ovl_adaptor_comp_type { +OVL_ADAPTOR_TYPE_RDMA =0 , +OVL_ADAPTOR_TYPE_MERGE , +OVL_ADAPTOR_TYPE_ETHDR , +OVL_ADAPTOR_TYPE_NUM , +}; + +enum mtk_ovl_adaptor_comp_id { +OVL_ADAPTOR_MDP_RDMA0 , +OVL_ADAPTOR_MDP_RDMA1 , +OVL_ADAPTOR_MDP_RDMA2 , +OVL_ADAPTOR_MDP_RDMA3 , +OVL_ADAPTOR_MDP_RDMA4 , +OVL_ADAPTOR_MDP_RDMA5 , +OVL_ADAPTOR_MDP_RDMA6 , +OVL_ADAPTOR_MDP_RDMA7 , +OVL_ADAPTOR_MERGE0 , +OVL_ADAPTOR_MERGE1 , +OVL_ADAPTOR_MERGE2 , +OVL_ADAPTOR_MERGE3 , +OVL_ADAPTOR_ETHDR0 , +OVL_ADAPTOR_ID_MAX +}; + +struct ovl_adaptor_comp_match { +enum mtk_ovl_adaptor_comp_type type; +int alias_id; +}; + +struct mtk_disp_ovl_adaptor { +struct device *ovl_adaptor_comp[OVL_ADAPTOR_ID_MAX ]; +struct device *mmsys_dev; +bool children_bound; +}; + +static const char *const private_comp_stem[OVL_ADAPTOR_TYPE_NUM ] = { + [OVL_ADAPTOR_TYPE_RDMA ] ="vdo1-rdma" , + [OVL_ADAPTOR_TYPE_MERGE ] ="merge" , + [OVL_ADAPTOR_TYPE_ETHDR ] ="ethdr" , +}; + +static const struct ovl_adaptor_comp_match comp_matches[OVL_ADAPTOR_ID_MAX ] = { + [OVL_ADAPTOR_MDP_RDMA0 ] = {OVL_ADAPTOR_TYPE_RDMA ,0 }, + [OVL_ADAPTOR_MDP_RDMA1 ] = {OVL_ADAPTOR_TYPE_RDMA ,1 }, + [OVL_ADAPTOR_MDP_RDMA2 ] = {OVL_ADAPTOR_TYPE_RDMA ,2 }, + [OVL_ADAPTOR_MDP_RDMA3 ] = {OVL_ADAPTOR_TYPE_RDMA ,3 }, + [OVL_ADAPTOR_MDP_RDMA4 ] = {OVL_ADAPTOR_TYPE_RDMA ,4 }, + [OVL_ADAPTOR_MDP_RDMA5 ] = {OVL_ADAPTOR_TYPE_RDMA ,5 }, + [OVL_ADAPTOR_MDP_RDMA6 ] = {OVL_ADAPTOR_TYPE_RDMA ,6 }, + [OVL_ADAPTOR_MDP_RDMA7 ] = {OVL_ADAPTOR_TYPE_RDMA ,7 }, + [OVL_ADAPTOR_MERGE0 ] = {OVL_ADAPTOR_TYPE_MERGE ,1 }, + [OVL_ADAPTOR_MERGE1 ] = {OVL_ADAPTOR_TYPE_MERGE ,2 }, + [OVL_ADAPTOR_MERGE2 ] = {OVL_ADAPTOR_TYPE_MERGE ,3 }, + [OVL_ADAPTOR_MERGE3 ] = {OVL_ADAPTOR_TYPE_MERGE ,4 }, + [OVL_ADAPTOR_ETHDR0 ] = {OVL_ADAPTOR_TYPE_ETHDR ,0 }, +}; + +void mtk_ovl_adaptor_layer_config (struct device *dev,unsigned int idx, +struct mtk_plane_state *state, +struct cmdq_pkt *cmdq_pkt) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); +struct mtk_plane_pending_state *pending = &state->pending; +struct mtk_mdp_rdma_cfg rdma_config = {0 }; +struct device *rdma_l; +struct device *rdma_r; +struct device *merge; +struct device *ethdr; +const struct drm_format_info *fmt_info =drm_format_info (pending->format); +bool use_dual_pipe = false; +unsigned int align_width; +unsigned int l_w =0 ; +unsigned int r_w =0 ; + +dev_dbg (dev,"%s+ idx:%d, enable:%d, fmt:0x%x\n" , __func__, idx, + pending->enable, pending->format); +dev_dbg (dev,"addr 0x%pad, fb w:%d, {%d,%d,%d,%d}\n" , + &pending->addr, (pending->pitch / fmt_info->cpp[0 ]), + pending->x, pending->y, pending->width, pending->height); + + rdma_l = ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_MDP_RDMA0 +2 * idx]; + rdma_r = ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_MDP_RDMA0 +2 * idx +1 ]; + merge = ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_MERGE0 + idx]; + ethdr = ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ]; + +if (!pending->enable) { +mtk_merge_stop_cmdq (merge, cmdq_pkt); +mtk_mdp_rdma_stop (rdma_l, cmdq_pkt); +mtk_mdp_rdma_stop (rdma_r, cmdq_pkt); +mtk_ethdr_layer_config (ethdr, idx, state, cmdq_pkt); +return ; + } + +/* ETHDR is in 1T2P domain, width needs to be 2 pixels align */ + align_width =ALIGN_DOWN (pending->width,2 ); + +if (align_width >MTK_OVL_ADAPTOR_RDMA_MAX_WIDTH ) + use_dual_pipe = true; + +if (use_dual_pipe) { + l_w = (align_width /2 ) + ((pending->width /2 ) %2 ); + r_w = align_width - l_w; + }else { + l_w = align_width; + } +mtk_merge_advance_config (merge, l_w, r_w, pending->height,0 ,0 , cmdq_pkt); +mtk_mmsys_merge_async_config (ovl_adaptor->mmsys_dev, idx, align_width /2 , + pending->height, cmdq_pkt); + + rdma_config.width = l_w; + rdma_config.height = pending->height; + rdma_config.addr0 = pending->addr; + rdma_config.pitch = pending->pitch; + rdma_config.fmt = pending->format; + rdma_config.color_encoding = pending->color_encoding; +mtk_mdp_rdma_config (rdma_l, &rdma_config, cmdq_pkt); + +if (use_dual_pipe) { + rdma_config.x_left = l_w; + rdma_config.width = r_w; +mtk_mdp_rdma_config (rdma_r, &rdma_config, cmdq_pkt); + } + +mtk_merge_start_cmdq (merge, cmdq_pkt); + +mtk_mdp_rdma_start (rdma_l, cmdq_pkt); +if (use_dual_pipe) +mtk_mdp_rdma_start (rdma_r, cmdq_pkt); +else +mtk_mdp_rdma_stop (rdma_r, cmdq_pkt); + +mtk_ethdr_layer_config (ethdr, idx, state, cmdq_pkt); +} + +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) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); + +mtk_ethdr_config (ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ], w, h, + vrefresh, bpc, cmdq_pkt); +} + +void mtk_ovl_adaptor_start (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); + +mtk_ethdr_start (ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ]); +} + +void mtk_ovl_adaptor_stop (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); + +mtk_ethdr_stop (ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ]); +} + +int mtk_ovl_adaptor_clk_enable (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); +struct device *comp; +int ret; +int i; + +for (i =0 ; i <OVL_ADAPTOR_MERGE0 ; i++) { + comp = ovl_adaptor->ovl_adaptor_comp[i]; + ret =pm_runtime_get_sync (comp); +if (ret <0 ) { +dev_err (dev,"Failed to enable power domain %d, err %d\n" , i, ret); + goto pwr_err; + } + } + +for (i =0 ; i <OVL_ADAPTOR_ID_MAX ; i++) { + comp = ovl_adaptor->ovl_adaptor_comp[i]; + +if (i <OVL_ADAPTOR_MERGE0 ) + ret =mtk_mdp_rdma_clk_enable (comp); +else if (i <OVL_ADAPTOR_ETHDR0 ) + ret =mtk_merge_clk_enable (comp); +else + ret =mtk_ethdr_clk_enable (comp); +if (ret) { +dev_err (dev,"Failed to enable clock %d, err %d\n" , i, ret); + goto clk_err; + } + } + +return ret; + +clk_err: +while (--i >=0 ) { + comp = ovl_adaptor->ovl_adaptor_comp[i]; +if (i <OVL_ADAPTOR_MERGE0 ) +mtk_mdp_rdma_clk_disable (comp); +else if (i <OVL_ADAPTOR_ETHDR0 ) +mtk_merge_clk_disable (comp); +else +mtk_ethdr_clk_disable (comp); + } + i =OVL_ADAPTOR_MERGE0 ; + +pwr_err: +while (--i >=0 ) +pm_runtime_put (ovl_adaptor->ovl_adaptor_comp[i]); + +return ret; +} + +void mtk_ovl_adaptor_clk_disable (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); +struct device *comp; +int i; + +for (i =0 ; i <OVL_ADAPTOR_ID_MAX ; i++) { + comp = ovl_adaptor->ovl_adaptor_comp[i]; + +if (i <OVL_ADAPTOR_MERGE0 ) { +mtk_mdp_rdma_clk_disable (comp); +pm_runtime_put (comp); + }else if (i <OVL_ADAPTOR_ETHDR0 ) { +mtk_merge_clk_disable (comp); + }else { +mtk_ethdr_clk_disable (comp); + } + } +} + +unsigned int mtk_ovl_adaptor_layer_nr (struct device *dev) +{ +return MTK_OVL_ADAPTOR_LAYER_NUM ; +} + +struct device *mtk_ovl_adaptor_dma_dev_get (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); + +return ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_MDP_RDMA0 ]; +} + +void mtk_ovl_adaptor_register_vblank_cb (struct device *dev,void (*vblank_cb)(void *), +void *vblank_cb_data) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); + +mtk_ethdr_register_vblank_cb (ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ], + vblank_cb, vblank_cb_data); +} + +void mtk_ovl_adaptor_unregister_vblank_cb (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); + +mtk_ethdr_unregister_vblank_cb (ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ]); +} + +void mtk_ovl_adaptor_enable_vblank (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); + +mtk_ethdr_enable_vblank (ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ]); +} + +void mtk_ovl_adaptor_disable_vblank (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *ovl_adaptor =dev_get_drvdata (dev); + +mtk_ethdr_disable_vblank (ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ]); +} + +void mtk_ovl_adaptor_add_comp (struct device *dev,struct mtk_mutex *mutex) +{ +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA0 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA1 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA2 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA3 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA4 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA5 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA6 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA7 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MERGE1 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MERGE2 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MERGE3 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MERGE4 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_ETHDR_MIXER ); +} + +void mtk_ovl_adaptor_remove_comp (struct device *dev,struct mtk_mutex *mutex) +{ +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA0 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA1 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA2 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA3 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA4 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA5 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA6 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA7 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MERGE1 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MERGE2 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MERGE3 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MERGE4 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_ETHDR_MIXER ); +} + +void mtk_ovl_adaptor_connect (struct device *dev,struct device *mmsys_dev,unsigned int next) +{ +mtk_mmsys_ddp_connect (mmsys_dev,DDP_COMPONENT_MDP_RDMA0 ,DDP_COMPONENT_MERGE1 ); +mtk_mmsys_ddp_connect (mmsys_dev,DDP_COMPONENT_MDP_RDMA1 ,DDP_COMPONENT_MERGE1 ); +mtk_mmsys_ddp_connect (mmsys_dev,DDP_COMPONENT_MDP_RDMA2 ,DDP_COMPONENT_MERGE2 ); +mtk_mmsys_ddp_connect (mmsys_dev,DDP_COMPONENT_MERGE1 ,DDP_COMPONENT_ETHDR_MIXER ); +mtk_mmsys_ddp_connect (mmsys_dev,DDP_COMPONENT_MERGE2 ,DDP_COMPONENT_ETHDR_MIXER ); +mtk_mmsys_ddp_connect (mmsys_dev,DDP_COMPONENT_MERGE3 ,DDP_COMPONENT_ETHDR_MIXER ); +mtk_mmsys_ddp_connect (mmsys_dev,DDP_COMPONENT_MERGE4 ,DDP_COMPONENT_ETHDR_MIXER ); +mtk_mmsys_ddp_connect (mmsys_dev,DDP_COMPONENT_ETHDR_MIXER , next); +} + +void mtk_ovl_adaptor_disconnect (struct device *dev,struct device *mmsys_dev,unsigned int next) +{ +mtk_mmsys_ddp_disconnect (mmsys_dev,DDP_COMPONENT_MDP_RDMA0 ,DDP_COMPONENT_MERGE1 ); +mtk_mmsys_ddp_disconnect (mmsys_dev,DDP_COMPONENT_MDP_RDMA1 ,DDP_COMPONENT_MERGE1 ); +mtk_mmsys_ddp_disconnect (mmsys_dev,DDP_COMPONENT_MDP_RDMA2 ,DDP_COMPONENT_MERGE2 ); +mtk_mmsys_ddp_disconnect (mmsys_dev,DDP_COMPONENT_MERGE1 ,DDP_COMPONENT_ETHDR_MIXER ); +mtk_mmsys_ddp_disconnect (mmsys_dev,DDP_COMPONENT_MERGE2 ,DDP_COMPONENT_ETHDR_MIXER ); +mtk_mmsys_ddp_disconnect (mmsys_dev,DDP_COMPONENT_MERGE3 ,DDP_COMPONENT_ETHDR_MIXER ); +mtk_mmsys_ddp_disconnect (mmsys_dev,DDP_COMPONENT_MERGE4 ,DDP_COMPONENT_ETHDR_MIXER ); +mtk_mmsys_ddp_disconnect (mmsys_dev,DDP_COMPONENT_ETHDR_MIXER , next); +} + +static int ovl_adaptor_comp_get_id (struct device *dev,struct device_node *node, +enum mtk_ovl_adaptor_comp_type type) +{ +int alias_id =of_alias_get_id (node, private_comp_stem[type]); +int i; + +for (i =0 ; i <ARRAY_SIZE (comp_matches); i++) +if (comp_matches[i].type == type && + comp_matches[i].alias_id == alias_id) +return i; + +dev_warn (dev,"Failed to get id. type: %d, alias: %d\n" , type, alias_id); +return -EINVAL ; +} + +static const struct of_device_id mtk_ovl_adaptor_comp_dt_ids[] = { + { + .compatible ="mediatek,mt8195-vdo1-rdma" , + .data = (void *)OVL_ADAPTOR_TYPE_RDMA , + }, { + .compatible ="mediatek,mt8195-disp-merge" , + .data = (void *)OVL_ADAPTOR_TYPE_MERGE , + }, { + .compatible ="mediatek,mt8195-disp-ethdr" , + .data = (void *)OVL_ADAPTOR_TYPE_ETHDR , + }, + {}, +}; + +static int compare_of (struct device *dev,void *data) +{ +return dev->of_node == data; +} + +static int ovl_adaptor_comp_init (struct device *dev,struct component_match **match) +{ +struct mtk_disp_ovl_adaptor *priv =dev_get_drvdata (dev); +struct device_node *node, *parent; +struct platform_device *comp_pdev; + + parent = dev->parent->parent->of_node->parent; + +for_each_child_of_node (parent, node) { +const struct of_device_id *of_id; +enum mtk_ovl_adaptor_comp_type type; +int id; + + of_id =of_match_node (mtk_ovl_adaptor_comp_dt_ids, node); +if (!of_id) +continue ; + +if (!of_device_is_available (node)) { +dev_dbg (dev,"Skipping disabled component %pOF\n" , + node); +continue ; + } + + type = (enum mtk_ovl_adaptor_comp_type )of_id->data; + id =ovl_adaptor_comp_get_id (dev, node, type); +if (id <0 ) { +dev_warn (dev,"Skipping unknown component %pOF\n" , + node); +continue ; + } + + comp_pdev =of_find_device_by_node (node); +if (!comp_pdev) +return -EPROBE_DEFER ; + + priv->ovl_adaptor_comp[id] = &comp_pdev->dev; + +drm_of_component_match_add (dev, match, compare_of, node); +dev_dbg (dev,"Adding component match for %pOF\n" , node); + } + +return 0 ; +} + +static int mtk_disp_ovl_adaptor_comp_bind (struct device *dev,struct device *master, +void *data) +{ +struct mtk_disp_ovl_adaptor *priv =dev_get_drvdata (dev); + +if (!priv->children_bound) +return -EPROBE_DEFER ; + +return 0 ; +} + +static void mtk_disp_ovl_adaptor_comp_unbind (struct device *dev,struct device *master, +void *data) +{ +} + +static const struct component_ops mtk_disp_ovl_adaptor_comp_ops = { + .bind = mtk_disp_ovl_adaptor_comp_bind, + .unbind = mtk_disp_ovl_adaptor_comp_unbind, +}; + +static int mtk_disp_ovl_adaptor_master_bind (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *priv =dev_get_drvdata (dev); +int ret; + + ret =component_bind_all (dev, priv->mmsys_dev); +if (ret) +return dev_err_probe (dev, ret,"component_bind_all failed!\n" ); + + priv->children_bound = true; +return 0 ; +} + +static void mtk_disp_ovl_adaptor_master_unbind (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *priv =dev_get_drvdata (dev); + + priv->children_bound = false; +} + +static const struct component_master_ops mtk_disp_ovl_adaptor_master_ops = { + .bind = mtk_disp_ovl_adaptor_master_bind, + .unbind = mtk_disp_ovl_adaptor_master_unbind, +}; + +static int mtk_disp_ovl_adaptor_probe (struct platform_device *pdev) +{ +struct mtk_disp_ovl_adaptor *priv; +struct device *dev = &pdev->dev; +struct component_match *match =NULL ; +int ret; + + priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ;
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c line 501
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +10
-0+ +platform_set_drvdata (pdev, priv); + + ret =ovl_adaptor_comp_init (dev, &match); +if (ret <0 ) +return ret; + + priv->mmsys_dev = pdev->dev.platform_data; + +component_master_add_with_match (dev, &mtk_disp_ovl_adaptor_master_ops, match);
Here the code assumes match is not NULL and that ovl_adaptor_comp_init() allocated it
with a call to drm_of_component_match_add() which never happens in case of a buggy dts.
IMHO, ovl_adaptor_comp_init() should return an error in case no components have been found.
[ 0.936986] mediatek-disp-ovl-adaptor mediatek-disp-ovl-adaptor.2.auto: Failed to get id. type: 1, alias: -19 [ 0.938238] mediatek-disp-ovl-adaptor mediatek-disp-ovl-adaptor.2.auto: Skipping unknown component /soc/merge@1c014000 [ 0.939596] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 [ 0.940701] Mem abort info: [ 0.941064] ESR = 0x0000000096000004 [ 0.941538] EC = 0x25: DABT (current EL), IL = 32 bits [ 0.942208] SET = 0, FnV = 0 [ 0.942595] EA = 0, S1PTW = 0 [ 0.942993] FSC = 0x04: level 0 translation fault [ 0.943607] Data abort info: [ 0.943972] ISV = 0, ISS = 0x00000004 [ 0.944455] CM = 0, WnR = 0 [ 0.944835] [0000000000000000] user address but active_mm is swapper [ 0.945636] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 0.946340] CPU: 6 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc1-next-20220818-mtk #17 [ 0.947327] swapper/0[1] cmdline: b [ 0.947327] [ 0.947976] Hardware name: MediaTek MT8195 demo board (DT) [ 0.948666] pstate: 20400009 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.949545] pc : component_master_add_with_match+0x24/0x100 [ 0.950257] lr : mtk_disp_ovl_adaptor_probe+0x1d0/0x280 [ 0.950925] sp : ffff80000a62b720 [ 0.951344] x29: ffff80000a62b720 x28: 0000000000000000 x27: ffff0000048dac10 [ 0.952248] x26: ffff00007fbbdda0 x25: 0000000000000001 x24: 0000000000000000 [ 0.953149] x23: ffff0000048dac00 x22: ffff8000097e29d0 x21: ffff0000048dac10 [ 0.954050] x20: 0000000000000000 x19: 0000000000000000 x18: ffffffffffffffff [ 0.954951] x17: 70696b53203a6f74 x16: 75612e322e726f74 x15: 0720072007200720 [ 0.955852] x14: 0720072007200720 x13: ffff80000a3787e0 x12: 00000000000002af [ 0.956752] x11: 00000000000000e5 x10: ffff84000bfe5dc8 x9 : 0000000000000002 [ 0.957653] x8 : 0101010101010101 x7 : 7f7f7f7f7f7f7f7f x6 : 01fefefefefefeff [ 0.958553] x5 : 0000000000000014 x4 : 0000000000000000 x3 : ffff0000048db000 [ 0.959453] x2 : 0000000000000000 x1 : ffff8000097e29d0 x0 : ffff0000048dac10 [ 0.960354] Call trace: [ 0.960664] component_master_add_with_match+0x24/0x100 [ 0.961326] mtk_disp_ovl_adaptor_probe+0x1d0/0x280 [ 0.961945] platform_probe+0x6c/0xe0 [ 0.962411] really_probe+0xbc/0x2d4 [ 0.962864] __driver_probe_device+0x78/0xe0 [ 0.963404] driver_probe_device+0x40/0x12c [ 0.963933] __device_attach_driver+0xec/0x154 [ 0.964496] bus_for_each_drv+0x78/0xd0 [ 0.964982] __device_attach+0xa8/0x1c0 [ 0.965467] device_initial_probe+0x18/0x2c [ 0.965997] bus_probe_device+0x9c/0xa4 [ 0.966482] device_add+0x384/0x870 [ 0.966927] platform_device_add+0x118/0x23c [ 0.967470] platform_device_register_full+0x104/0x18c [ 0.968120] mtk_drm_probe+0x31c/0x440 [ 0.968596] platform_probe+0x6c/0xe0 [ 0.969061] really_probe+0xbc/0x2d4 [ 0.969515] __driver_probe_device+0x78/0xe0 [ 0.970055] driver_probe_device+0x40/0x12c [ 0.970584] __driver_attach+0x120/0x1d0 [ 0.971080] bus_for_each_dev+0x70/0xcc [ 0.971569] driver_attach+0x28/0x34 [ 0.972022] bus_add_driver+0x148/0x200 [ 0.972507] driver_register+0x7c/0x13c [ 0.972993] __platform_register_drivers+0x54/0xdc [ 0.973600] mtk_drm_init+0x24/0x30 [ 0.974044] do_one_initcall+0x6c/0x148 [ 0.974530] kernel_init_freeable+0x208/0x288 [ 0.975080] kernel_init+0x28/0x130 [ 0.975526] ret_from_fork+0x10/0x20 [ 0.975984] Code: aa0203f4 a9025bf5 aa0003f5 aa0103f6 (a9400440) [ 0.976753] ---[ end trace 0000000000000000 ]--- [ 0.977347] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 0.978311] SMP: stopping secondary CPUs [ 0.978811] Kernel Offset: disabled [ 0.979252] CPU features: 0x2000,0001c029,19801c82 [ 0.979856] Memory Limit: none [ 0.980243] ---[ end Kernel panic - not syncing: Attempted to kill
init! exitcode=0x0000000b ]---
Thx,
Guillaume.
Quoted 42 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +26
-0+pm_runtime_enable (dev); + + ret =component_add (dev, &mtk_disp_ovl_adaptor_comp_ops); +if (ret !=0 ) { +pm_runtime_disable (dev); +dev_err (dev,"Failed to add component: %d\n" , ret); + } + +return ret; +} + +static int mtk_disp_ovl_adaptor_remove (struct platform_device *pdev) +{ +component_master_del (&pdev->dev, &mtk_disp_ovl_adaptor_master_ops); +pm_runtime_disable (&pdev->dev); +return 0 ; +} + +struct platform_driver mtk_disp_ovl_adaptor_driver = { + .probe = mtk_disp_ovl_adaptor_probe, + .remove = mtk_disp_ovl_adaptor_remove, + .driver = { + .name ="mediatek-disp-ovl-adaptor" , + .owner =THIS_MODULE , + }, +};drivers/gpu/drm/mediatek/mtk_drm_drv.h +1
-1@@ -57,6 +57,7 @@ extern struct platform_driver mtk_disp_ccorr_driver;extern struct platform_driver mtk_disp_color_driver;extern struct platform_driver mtk_disp_gamma_driver;extern struct platform_driver mtk_disp_merge_driver; +extern struct platform_driver mtk_disp_ovl_adaptor_driver;extern struct platform_driver mtk_disp_ovl_driver;extern struct platform_driver mtk_disp_rdma_driver;extern struct platform_driver mtk_dpi_driver; --2.18.0
Re: [PATCH v26 3/7] drm/mediatek: add ovl_adaptor support for MT8195
Hi Guillaume,
Sorry for the late response and thanks for testing.
Quoted 775 lines · Guillaume Ranquet
Quoted 6 lines · On Fri, 19 Aug 2022 08:14, "" wrote:
Add
ovl_adaptordriver for MT8195.Ovl_adaptoris an encapsulated module and designed for simplified DRM control flow. This module is composed of 8 RDMAs, 4 MERGEs and an ETHDR. Two RDMAs merge into one layer, so this module support 4 layers.Hi Nancy, sorry I'm late in the review process, but I just applied your series and I stumbled upon a panic.
(see details inline)This is due to the fact that my dts is missing the required ovl components, though, I think the driver
shouldn't cause a panic whenever the dts is not complete.I'm testing this out with an mt8195-demo board.
Quoted 658 lines
Signed-off-by Nancy.Lin <[email protected]>Reviewed-by Chun-Kuang Hu <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>
Tested-by: AngeloGioacchino Del Regno <
[email protected]>Tested-by Bo-Chen Chen <[email protected]>---
drivers/gpu/drm/mediatek/Makefile | 1 + drivers/gpu/drm/mediatek/mtk_disp_drv.h | 26 + .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 528 ++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 1 + 4 files changed, 556 insertions(+)create mode 100644
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.cdrivers/gpu/drm/mediatek/Makefile +1
-0@@ -6,6 +6,7 @@ mediatek-drm-y := mtk_disp_aal.o \ mtk_disp_gamma.o \ mtk_disp_merge.o \ mtk_disp_ovl.o \ + mtk_disp_ovl_adaptor.o \ mtk_disp_rdma.o \ mtk_drm_crtc.o \ mtk_drm_ddp_comp.o \drivers/gpu/drm/mediatek/mtk_disp_drv.h +5
-0@@ -7,6 +7,8 @@#define _MTK_DISP_DRV_H_#include <linux/soc/mediatek/mtk-cmdq.h> +#include <linux/soc/mediatek/mtk-mmsys.h> +#include <linux/soc/mediatek/mtk-mutex.h> #include "mtk_drm_plane.h" #include "mtk_mdp_rdma.h" @@ -116,6 +118,30 @@ void mtk_rdma_unregister_vblank_cb(struct device *dev);void mtk_rdma_enable_vblank (struct device *dev);void mtk_rdma_disable_vblank (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); +void mtk_ovl_adaptor_connect(struct device *dev, struct device
*mmsys_dev,drivers/gpu/drm/mediatek/mtk_disp_drv.h +2
-0+ unsigned int next); +void mtk_ovl_adaptor_disconnect(struct device *dev, struct device
*mmsys_dev,drivers/gpu/drm/mediatek/mtk_disp_drv.h +6
-0+ unsigned int next); +int mtk_ovl_adaptor_clk_enable (struct device *dev); +void mtk_ovl_adaptor_clk_disable (struct device *dev); +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);
+void mtk_ovl_adaptor_layer_config(struct device *dev, unsigned int idx,drivers/gpu/drm/mediatek/mtk_disp_drv.h +3
-0+struct mtk_plane_state *state, + struct cmdq_pkt *cmdq_pkt); +void mtk_ovl_adaptor_register_vblank_cb(struct device *dev, void(*vblank_cb)(void *),
drivers/gpu/drm/mediatek/mtk_disp_drv.h +9
-0+ void *vblank_cb_data); +void mtk_ovl_adaptor_unregister_vblank_cb (struct device *dev); +void mtk_ovl_adaptor_enable_vblank (struct device *dev); +void mtk_ovl_adaptor_disable_vblank (struct device *dev); +void mtk_ovl_adaptor_start (struct device *dev); +void mtk_ovl_adaptor_stop (struct device *dev); +unsigned int mtk_ovl_adaptor_layer_nr (struct device *dev); +struct device *mtk_ovl_adaptor_dma_dev_get (struct device *dev); +int
mtk_mdp_rdma_clk_enable(struct device *dev); voidmtk_mdp_rdma_clk_disable(struct device *dev); voidmtk_mdp_rdma_start(struct device *dev, struct cmdq_pkt *cmdq_pkt);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +63
-0@@ -0,0 +1,528 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2021 MediaTek Inc. +*/ + +#include <drm/drm_fourcc.h> +#include <drm/drm_of.h> +#include <linux/clk.h> +#include <linux/component.h> +#include <linux/of_device.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> +#include <linux/pm_runtime.h> +#include <linux/reset.h> +#include <linux/soc/mediatek/mtk-cmdq.h> +#include <linux/soc/mediatek/mtk-mmsys.h> +#include <linux/soc/mediatek/mtk-mutex.h> + +#include "mtk_disp_drv.h" +#include "mtk_drm_crtc.h" +#include "mtk_drm_ddp_comp.h" +#include "mtk_drm_drv.h" +#include "mtk_ethdr.h" + +#define MTK_OVL_ADAPTOR_RDMA_MAX_WIDTH 1920 +#define MTK_OVL_ADAPTOR_LAYER_NUM 4 + +enum mtk_ovl_adaptor_comp_type { +OVL_ADAPTOR_TYPE_RDMA =0 , +OVL_ADAPTOR_TYPE_MERGE , +OVL_ADAPTOR_TYPE_ETHDR , +OVL_ADAPTOR_TYPE_NUM , +}; + +enum mtk_ovl_adaptor_comp_id { +OVL_ADAPTOR_MDP_RDMA0 , +OVL_ADAPTOR_MDP_RDMA1 , +OVL_ADAPTOR_MDP_RDMA2 , +OVL_ADAPTOR_MDP_RDMA3 , +OVL_ADAPTOR_MDP_RDMA4 , +OVL_ADAPTOR_MDP_RDMA5 , +OVL_ADAPTOR_MDP_RDMA6 , +OVL_ADAPTOR_MDP_RDMA7 , +OVL_ADAPTOR_MERGE0 , +OVL_ADAPTOR_MERGE1 , +OVL_ADAPTOR_MERGE2 , +OVL_ADAPTOR_MERGE3 , +OVL_ADAPTOR_ETHDR0 , +OVL_ADAPTOR_ID_MAX +}; + +struct ovl_adaptor_comp_match { +enum mtk_ovl_adaptor_comp_type type; +int alias_id; +}; + +struct mtk_disp_ovl_adaptor { +struct device *ovl_adaptor_comp[OVL_ADAPTOR_ID_MAX ]; +struct device *mmsys_dev; +bool children_bound; +}; + +static const char *const private_comp_stem[OVL_ADAPTOR_TYPE_NUM ]= {
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +6
-0+ [OVL_ADAPTOR_TYPE_RDMA] = "vdo1-rdma", + [OVL_ADAPTOR_TYPE_MERGE] = "merge", + [OVL_ADAPTOR_TYPE_ETHDR] = "ethdr", +}; + +static const struct ovl_adaptor_comp_matchcomp_matches[OVL_ADAPTOR_ID_MAX] = {
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +16
-0+ [OVL_ADAPTOR_MDP_RDMA0] = { OVL_ADAPTOR_TYPE_RDMA, 0 }, + [OVL_ADAPTOR_MDP_RDMA1] = { OVL_ADAPTOR_TYPE_RDMA, 1 }, + [OVL_ADAPTOR_MDP_RDMA2] = { OVL_ADAPTOR_TYPE_RDMA, 2 }, + [OVL_ADAPTOR_MDP_RDMA3] = { OVL_ADAPTOR_TYPE_RDMA, 3 }, + [OVL_ADAPTOR_MDP_RDMA4] = { OVL_ADAPTOR_TYPE_RDMA, 4 }, + [OVL_ADAPTOR_MDP_RDMA5] = { OVL_ADAPTOR_TYPE_RDMA, 5 }, + [OVL_ADAPTOR_MDP_RDMA6] = { OVL_ADAPTOR_TYPE_RDMA, 6 }, + [OVL_ADAPTOR_MDP_RDMA7] = { OVL_ADAPTOR_TYPE_RDMA, 7 }, + [OVL_ADAPTOR_MERGE0] = { OVL_ADAPTOR_TYPE_MERGE, 1 }, + [OVL_ADAPTOR_MERGE1] = { OVL_ADAPTOR_TYPE_MERGE, 2 }, + [OVL_ADAPTOR_MERGE2] = { OVL_ADAPTOR_TYPE_MERGE, 3 }, + [OVL_ADAPTOR_MERGE3] = { OVL_ADAPTOR_TYPE_MERGE, 4 }, + [OVL_ADAPTOR_ETHDR0] = { OVL_ADAPTOR_TYPE_ETHDR, 0 }, +}; + +void mtk_ovl_adaptor_layer_config(struct device *dev, unsigned intidx,
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +4
-0+struct mtk_plane_state *state, + struct cmdq_pkt *cmdq_pkt) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor =
dev_get_drvdata(dev);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +7
-0+struct mtk_plane_pending_state *pending = &state->pending; +struct mtk_mdp_rdma_cfg rdma_config = {0 }; +struct device *rdma_l; +struct device *rdma_r; +struct device *merge; +struct device *ethdr; + const struct drm_format_info *fmt_info =
drm_format_info(pending->format);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +6
-0+bool use_dual_pipe = false; +unsigned int align_width; +unsigned int l_w =0 ; +unsigned int r_w =0 ; + + dev_dbg(dev, "%s+ idx:%d, enable:%d, fmt:0x%x\n", __func__,idx,
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +4
-0+ pending->enable, pending->format); + dev_dbg(dev, "addr 0x%pad, fb w:%d, {%d,%d,%d,%d}\n", + &pending->addr, (pending->pitch / fmt_info->cpp[0]), + pending->x, pending->y, pending->width, pending-Quoted 1 line
height);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +2
-0+ + rdma_l = ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_MDP_RDMA0 +2 * idx];
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ rdma_r = ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_MDP_RDMA0 +2 * idx + 1];
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ merge = ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_MERGE0 +idx];
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +23
-0+ ethdr = ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0 ]; + +if (!pending->enable) { +mtk_merge_stop_cmdq (merge, cmdq_pkt); +mtk_mdp_rdma_stop (rdma_l, cmdq_pkt); +mtk_mdp_rdma_stop (rdma_r, cmdq_pkt); +mtk_ethdr_layer_config (ethdr, idx, state, cmdq_pkt); +return ; + } + +/* ETHDR is in 1T2P domain, width needs to be 2 pixels align */ + align_width =ALIGN_DOWN (pending->width,2 ); + +if (align_width >MTK_OVL_ADAPTOR_RDMA_MAX_WIDTH ) + use_dual_pipe = true; + +if (use_dual_pipe) { + l_w = (align_width /2 ) + ((pending->width /2 ) %2 ); + r_w = align_width - l_w; + }else { + l_w = align_width; + } + mtk_merge_advance_config(merge, l_w, r_w, pending->height, 0,0,
cmdq_pkt);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_merge_async_config(ovl_adaptor->mmsys_dev, idx,
align_width/ 2,drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +30
-0+ pending->height, cmdq_pkt); + + rdma_config.width = l_w; + rdma_config.height = pending->height; + rdma_config.addr0 = pending->addr; + rdma_config.pitch = pending->pitch; + rdma_config.fmt = pending->format; + rdma_config.color_encoding = pending->color_encoding; +mtk_mdp_rdma_config (rdma_l, &rdma_config, cmdq_pkt); + +if (use_dual_pipe) { + rdma_config.x_left = l_w; + rdma_config.width = r_w; +mtk_mdp_rdma_config (rdma_r, &rdma_config, cmdq_pkt); + } + +mtk_merge_start_cmdq (merge, cmdq_pkt); + +mtk_mdp_rdma_start (rdma_l, cmdq_pkt); +if (use_dual_pipe) +mtk_mdp_rdma_start (rdma_r, cmdq_pkt); +else +mtk_mdp_rdma_stop (rdma_r, cmdq_pkt); + +mtk_ethdr_layer_config (ethdr, idx, state, cmdq_pkt); +} + +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_disp_ovl_adaptor.c new file +2
-0+{ + struct mtk_disp_ovl_adaptor *ovl_adaptor =
dev_get_drvdata(dev);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +2
-0+ + mtk_ethdr_config(ovl_adaptor-Quoted 1 line
ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0], w, h,
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +6
-0+ vrefresh, bpc, cmdq_pkt); +} + +void mtk_ovl_adaptor_start (struct device *dev) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor =
dev_get_drvdata(dev);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +2
-0+ + mtk_ethdr_start(ovl_adaptor-Quoted 1 line
ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +5
-0+} + +void mtk_ovl_adaptor_stop (struct device *dev) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor =
dev_get_drvdata(dev);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +2
-0+ + mtk_ethdr_stop(ovl_adaptor-Quoted 1 line
ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +5
-0+} + +int mtk_ovl_adaptor_clk_enable (struct device *dev) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor =
dev_get_drvdata(dev);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +9
-0+struct device *comp; +int ret; +int i; + +for (i =0 ; i <OVL_ADAPTOR_MERGE0 ; i++) { + comp = ovl_adaptor->ovl_adaptor_comp[i]; + ret =pm_runtime_get_sync (comp); +if (ret <0 ) { + dev_err(dev, "Failed to enable power domain %d,err %d\n", i, ret);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +15
-0+ goto pwr_err; + } + } + +for (i =0 ; i <OVL_ADAPTOR_ID_MAX ; i++) { + comp = ovl_adaptor->ovl_adaptor_comp[i]; + +if (i <OVL_ADAPTOR_MERGE0 ) + ret =mtk_mdp_rdma_clk_enable (comp); +else if (i <OVL_ADAPTOR_ETHDR0 ) + ret =mtk_merge_clk_enable (comp); +else + ret =mtk_ethdr_clk_enable (comp); +if (ret) { + dev_err(dev, "Failed to enable clock %d, err%d\n", i, ret);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +28
-0+ goto clk_err; + } + } + +return ret; + +clk_err: +while (--i >=0 ) { + comp = ovl_adaptor->ovl_adaptor_comp[i]; +if (i <OVL_ADAPTOR_MERGE0 ) +mtk_mdp_rdma_clk_disable (comp); +else if (i <OVL_ADAPTOR_ETHDR0 ) +mtk_merge_clk_disable (comp); +else +mtk_ethdr_clk_disable (comp); + } + i =OVL_ADAPTOR_MERGE0 ; + +pwr_err: +while (--i >=0 ) +pm_runtime_put (ovl_adaptor->ovl_adaptor_comp[i]); + +return ret; +} + +void mtk_ovl_adaptor_clk_disable (struct device *dev) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor =
dev_get_drvdata(dev);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +25
-0+struct device *comp; +int i; + +for (i =0 ; i <OVL_ADAPTOR_ID_MAX ; i++) { + comp = ovl_adaptor->ovl_adaptor_comp[i]; + +if (i <OVL_ADAPTOR_MERGE0 ) { +mtk_mdp_rdma_clk_disable (comp); +pm_runtime_put (comp); + }else if (i <OVL_ADAPTOR_ETHDR0 ) { +mtk_merge_clk_disable (comp); + }else { +mtk_ethdr_clk_disable (comp); + } + } +} + +unsigned int mtk_ovl_adaptor_layer_nr (struct device *dev) +{ +return MTK_OVL_ADAPTOR_LAYER_NUM ; +} + +struct device *mtk_ovl_adaptor_dma_dev_get (struct device *dev) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor =
dev_get_drvdata(dev);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +5
-0+ +return ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_MDP_RDMA0 ]; +} + +void mtk_ovl_adaptor_register_vblank_cb(struct device *dev, void(*vblank_cb)(void *),
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +3
-0+ void *vblank_cb_data) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor =
dev_get_drvdata(dev);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +2
-0+ + mtk_ethdr_register_vblank_cb(ovl_adaptor-Quoted 1 line
ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0],
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +6
-0+ vblank_cb, vblank_cb_data); +} + +void mtk_ovl_adaptor_unregister_vblank_cb (struct device *dev) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor =
dev_get_drvdata(dev);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +2
-0+ + mtk_ethdr_unregister_vblank_cb(ovl_adaptor-Quoted 1 line
ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +5
-0+} + +void mtk_ovl_adaptor_enable_vblank (struct device *dev) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor =
dev_get_drvdata(dev);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +2
-0+ + mtk_ethdr_enable_vblank(ovl_adaptor-Quoted 1 line
ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +5
-0+} + +void mtk_ovl_adaptor_disable_vblank (struct device *dev) +{ + struct mtk_disp_ovl_adaptor *ovl_adaptor =
dev_get_drvdata(dev);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +2
-0+ + mtk_ethdr_disable_vblank(ovl_adaptor-Quoted 1 line
ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +3
-0+} + +void mtk_ovl_adaptor_add_comp(struct device *dev, struct mtk_mutex*mutex)
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +17
-0+{ +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA0 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA1 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA2 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA3 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA4 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA5 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA6 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MDP_RDMA7 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MERGE1 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MERGE2 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MERGE3 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_MERGE4 ); +mtk_mutex_add_comp (mutex,DDP_COMPONENT_ETHDR_MIXER ); +} + +void mtk_ovl_adaptor_remove_comp(struct device *dev, struct
mtk_mutex*mutex)drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +17
-0+{ +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA0 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA1 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA2 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA3 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA4 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA5 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA6 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MDP_RDMA7 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MERGE1 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MERGE2 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MERGE3 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_MERGE4 ); +mtk_mutex_remove_comp (mutex,DDP_COMPONENT_ETHDR_MIXER ); +} + +void mtk_ovl_adaptor_connect(struct device *dev, struct device
*mmsys_dev, unsigned int next)drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +2
-0+{ + mtk_mmsys_ddp_connect(mmsys_dev, DDP_COMPONENT_MDP_RDMA0,
DDP_COMPONENT_MERGE1);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_connect(mmsys_dev, DDP_COMPONENT_MDP_RDMA1,
DDP_COMPONENT_MERGE1);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_connect(mmsys_dev, DDP_COMPONENT_MDP_RDMA2,
DDP_COMPONENT_MERGE2);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_connect(mmsys_dev, DDP_COMPONENT_MERGE1,
DDP_COMPONENT_ETHDR_MIXER);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_connect(mmsys_dev, DDP_COMPONENT_MERGE2,
DDP_COMPONENT_ETHDR_MIXER);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_connect(mmsys_dev, DDP_COMPONENT_MERGE3,
DDP_COMPONENT_ETHDR_MIXER);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_connect(mmsys_dev, DDP_COMPONENT_MERGE4,
DDP_COMPONENT_ETHDR_MIXER);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_connect(mmsys_dev, DDP_COMPONENT_ETHDR_MIXER,next);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +3
-0+} + +void mtk_ovl_adaptor_disconnect(struct device *dev, struct device
*mmsys_dev, unsigned int next)drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +2
-0+{ + mtk_mmsys_ddp_disconnect(mmsys_dev, DDP_COMPONENT_MDP_RDMA0,
DDP_COMPONENT_MERGE1);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_disconnect(mmsys_dev, DDP_COMPONENT_MDP_RDMA1,
DDP_COMPONENT_MERGE1);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_disconnect(mmsys_dev, DDP_COMPONENT_MDP_RDMA2,
DDP_COMPONENT_MERGE2);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_disconnect(mmsys_dev, DDP_COMPONENT_MERGE1,
DDP_COMPONENT_ETHDR_MIXER);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_disconnect(mmsys_dev, DDP_COMPONENT_MERGE2,
DDP_COMPONENT_ETHDR_MIXER);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_disconnect(mmsys_dev, DDP_COMPONENT_MERGE3,
DDP_COMPONENT_ETHDR_MIXER);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_disconnect(mmsys_dev, DDP_COMPONENT_MERGE4,
DDP_COMPONENT_ETHDR_MIXER);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ mtk_mmsys_ddp_disconnect(mmsys_dev, DDP_COMPONENT_ETHDR_MIXER,next);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +3
-0+} + +static int ovl_adaptor_comp_get_id(struct device *dev, struct
device_node*node,drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +11
-0+ enum mtk_ovl_adaptor_comp_type type) +{ +int alias_id =of_alias_get_id (node, private_comp_stem[type]); +int i; + +for (i =0 ; i <ARRAY_SIZE (comp_matches); i++) +if (comp_matches[i].type == type && + comp_matches[i].alias_id == alias_id) +return i; + + dev_warn(dev, "Failed to get id. type: %d, alias: %d\n", type,
alias_id);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +23
-0+return -EINVAL ; +} + +static const struct of_device_id mtk_ovl_adaptor_comp_dt_ids[] = { + { + .compatible ="mediatek,mt8195-vdo1-rdma" , + .data = (void *)OVL_ADAPTOR_TYPE_RDMA , + }, { + .compatible ="mediatek,mt8195-disp-merge" , + .data = (void *)OVL_ADAPTOR_TYPE_MERGE , + }, { + .compatible ="mediatek,mt8195-disp-ethdr" , + .data = (void *)OVL_ADAPTOR_TYPE_ETHDR , + }, + {}, +}; + +static int compare_of (struct device *dev,void *data) +{ +return dev->of_node == data; +} + +static int ovl_adaptor_comp_init(struct device *dev, struct
component_match**match)drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +13
-0+{ +struct mtk_disp_ovl_adaptor *priv =dev_get_drvdata (dev); +struct device_node *node, *parent; +struct platform_device *comp_pdev; + + parent = dev->parent->parent->of_node->parent; + +for_each_child_of_node (parent, node) { +const struct of_device_id *of_id; +enum mtk_ovl_adaptor_comp_type type; +int id; + + of_id = of_match_node(mtk_ovl_adaptor_comp_dt_ids,node);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +5
-0+if (!of_id) +continue ; + +if (!of_device_is_available (node)) { + dev_dbg(dev, "Skipping disabled component%pOF\n",
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +8
-0+ node); +continue ; + } + + type = (enum mtk_ovl_adaptor_comp_type )of_id->data; + id =ovl_adaptor_comp_get_id (dev, node, type); +if (id <0 ) { + dev_warn(dev, "Skipping unknown component%pOF\n",
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +11
-0+ node); +continue ; + } + + comp_pdev =of_find_device_by_node (node); +if (!comp_pdev) +return -EPROBE_DEFER ; + + priv->ovl_adaptor_comp[id] = &comp_pdev->dev; + + drm_of_component_match_add(dev, match, compare_of,node);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +1
-0+ dev_dbg(dev, "Adding component match for %pOF\n",node);
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +6
-0+ } + +return 0 ; +} + +static int mtk_disp_ovl_adaptor_comp_bind(struct device *dev,struct device *master,
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +11
-0+ void *data) +{ +struct mtk_disp_ovl_adaptor *priv =dev_get_drvdata (dev); + +if (!priv->children_bound) +return -EPROBE_DEFER ; + +return 0 ; +} + +static void mtk_disp_ovl_adaptor_comp_unbind(struct device *dev,struct device *master,
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +5
-0+ void *data) +{ +} + +static const struct component_ops mtk_disp_ovl_adaptor_comp_ops ={
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +12
-0+ .bind = mtk_disp_ovl_adaptor_comp_bind, + .unbind = mtk_disp_ovl_adaptor_comp_unbind, +}; + +static int mtk_disp_ovl_adaptor_master_bind (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *priv =dev_get_drvdata (dev); +int ret; + + ret =component_bind_all (dev, priv->mmsys_dev); +if (ret) + return dev_err_probe(dev, ret, "component_bind_allfailed!\n");
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +13
-0+ + priv->children_bound = true; +return 0 ; +} + +static void mtk_disp_ovl_adaptor_master_unbind (struct device *dev) +{ +struct mtk_disp_ovl_adaptor *priv =dev_get_drvdata (dev); + + priv->children_bound = false; +} + +static const struct component_master_ops
mtk_disp_ovl_adaptor_master_ops= {drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +5
-0+ .bind = mtk_disp_ovl_adaptor_master_bind, + .unbind = mtk_disp_ovl_adaptor_master_unbind, +}; + +static int mtk_disp_ovl_adaptor_probe(struct platform_device*pdev)
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +19
-0+{ +struct mtk_disp_ovl_adaptor *priv; +struct device *dev = &pdev->dev; +struct component_match *match =NULL ; +int ret; + + priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +platform_set_drvdata (pdev, priv); + + ret =ovl_adaptor_comp_init (dev, &match); +if (ret <0 ) +return ret; + + priv->mmsys_dev = pdev->dev.platform_data; + + component_master_add_with_match(dev,Quoted 1 line
&mtk_disp_ovl_adaptor_master_ops, match);Here the code assumes match is not NULL and that
ovl_adaptor_comp_init()allocated it
with a call todrm_of_component_match_add()which never happens in case of a buggy dts.
IMHO,ovl_adaptor_comp_init()should return an error in case no components have been found.[ 0.936986] mediatek-disp-ovl-adaptor mediatek-disp-ovl-adaptor.2.auto: Failed to get id. type: 1, alias: -19 [ 0.938238] mediatek-disp-ovl-adaptor mediatek-disp-ovl-adaptor.2.auto: Skipping unknown component /soc/merge@1c014000 [ 0.939596] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 [ 0.940701] Mem abort info: [ 0.941064] ESR = 0x0000000096000004 [ 0.941538] EC = 0x25: DABT (current EL), IL = 32 bits [ 0.942208] SET = 0, FnV = 0 [ 0.942595] EA = 0, S1PTW = 0 [ 0.942993] FSC = 0x04: level 0 translation fault [ 0.943607] Data abort info: [ 0.943972] ISV = 0, ISS = 0x00000004 [ 0.944455] CM = 0, WnR = 0 [ 0.944835] [0000000000000000] user address but active_mm is swapper [ 0.945636] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 0.946340] CPU: 6 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc1-next-20220818-mtk #17 [ 0.947327] swapper/0[1] cmdline: b [ 0.947327] [ 0.947976] Hardware name: MediaTek MT8195 demo board (DT) [ 0.948666] pstate: 20400009 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.949545] pc : component_master_add_with_match+0x24/0x100 [ 0.950257] lr : mtk_disp_ovl_adaptor_probe+0x1d0/0x280 [ 0.950925] sp : ffff80000a62b720 [ 0.951344] x29: ffff80000a62b720 x28: 0000000000000000 x27: ffff0000048dac10 [ 0.952248] x26: ffff00007fbbdda0 x25: 0000000000000001 x24: 0000000000000000 [ 0.953149] x23: ffff0000048dac00 x22: ffff8000097e29d0 x21: ffff0000048dac10 [ 0.954050] x20: 0000000000000000 x19: 0000000000000000 x18: ffffffffffffffff [ 0.954951] x17: 70696b53203a6f74 x16: 75612e322e726f74 x15: 0720072007200720 [ 0.955852] x14: 0720072007200720 x13: ffff80000a3787e0 x12: 00000000000002af [ 0.956752] x11: 00000000000000e5 x10: ffff84000bfe5dc8 x9 : 0000000000000002 [ 0.957653] x8 : 0101010101010101 x7 : 7f7f7f7f7f7f7f7f x6 : 01fefefefefefeff [ 0.958553] x5 : 0000000000000014 x4 : 0000000000000000 x3 : ffff0000048db000 [ 0.959453] x2 : 0000000000000000 x1 : ffff8000097e29d0 x0 : ffff0000048dac10 [ 0.960354] Call trace: [ 0.960664] component_master_add_with_match+0x24/0x100 [ 0.961326] mtk_disp_ovl_adaptor_probe+0x1d0/0x280 [ 0.961945] platform_probe+0x6c/0xe0 [ 0.962411] really_probe+0xbc/0x2d4 [ 0.962864] __driver_probe_device+0x78/0xe0 [ 0.963404] driver_probe_device+0x40/0x12c [ 0.963933] __device_attach_driver+0xec/0x154 [ 0.964496] bus_for_each_drv+0x78/0xd0 [ 0.964982] __device_attach+0xa8/0x1c0 [ 0.965467] device_initial_probe+0x18/0x2c [ 0.965997] bus_probe_device+0x9c/0xa4 [ 0.966482] device_add+0x384/0x870 [ 0.966927] platform_device_add+0x118/0x23c [ 0.967470] platform_device_register_full+0x104/0x18c [ 0.968120] mtk_drm_probe+0x31c/0x440 [ 0.968596] platform_probe+0x6c/0xe0 [ 0.969061] really_probe+0xbc/0x2d4 [ 0.969515] __driver_probe_device+0x78/0xe0 [ 0.970055] driver_probe_device+0x40/0x12c [ 0.970584] __driver_attach+0x120/0x1d0 [ 0.971080] bus_for_each_dev+0x70/0xcc [ 0.971569] driver_attach+0x28/0x34 [ 0.972022] bus_add_driver+0x148/0x200 [ 0.972507] driver_register+0x7c/0x13c [ 0.972993] __platform_register_drivers+0x54/0xdc [ 0.973600] mtk_drm_init+0x24/0x30 [ 0.974044] do_one_initcall+0x6c/0x148 [ 0.974530] kernel_init_freeable+0x208/0x288 [ 0.975080] kernel_init+0x28/0x130 [ 0.975526] ret_from_fork+0x10/0x20 [ 0.975984] Code: aa0203f4 a9025bf5 aa0003f5 aa0103f6 (a9400440) [ 0.976753] ---[ end trace 0000000000000000 ]--- [ 0.977347] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 0.978311] SMP: stopping secondary CPUs [ 0.978811] Kernel Offset: disabled [ 0.979252] CPU features: 0x2000,0001c029,19801c82 [ 0.979856] Memory Limit: none [ 0.980243] ---[ end Kernel panic - not syncing: Attempted to kill
Quoted 5 lines
init! exitcode=0x0000000b ]---
Thx,
Guillaume.
I will add an error return code if no component is found.
Thanks,
Nancy
Quoted 48 lines
Quoted 46 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +12
-0+pm_runtime_enable (dev); + + ret =component_add (dev, &mtk_disp_ovl_adaptor_comp_ops); +if (ret !=0 ) { +pm_runtime_disable (dev); +dev_err (dev,"Failed to add component: %d\n" , ret); + } + +return ret; +} + +static int mtk_disp_ovl_adaptor_remove(struct platform_device*pdev)
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +2
-0+{ + component_master_del(&pdev->dev,
&mtk_disp_ovl_adaptor_master_ops);drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c new file +12
-0+pm_runtime_disable (&pdev->dev); +return 0 ; +} + +struct platform_driver mtk_disp_ovl_adaptor_driver = { + .probe = mtk_disp_ovl_adaptor_probe, + .remove = mtk_disp_ovl_adaptor_remove, + .driver = { + .name ="mediatek-disp-ovl-adaptor" , + .owner =THIS_MODULE , + }, +};drivers/gpu/drm/mediatek/mtk_drm_drv.h +1
-0@@ -57,6 +57,7 @@ extern struct platform_driver mtk_disp_ccorr_driver;extern struct platform_driver mtk_disp_color_driver;extern struct platform_driver mtk_disp_gamma_driver;extern struct platform_driver mtk_disp_merge_driver; +extern struct platform_driver mtk_disp_ovl_adaptor_driver;extern struct platform_driver mtk_disp_ovl_driver;extern struct platform_driver mtk_disp_rdma_driver;extern struct
platform_drivermtk_dpi_driver;
--
2.18.0
PATCH v26 4/7 drm/mediatek: add dma dev get function
In reply to Nancy.LinThis is a preparation for adding support for the ovl_adaptor sub driver Ovl_adaptor is a DRM sub driver, which doesn't have dma dev. Add dma_dev_get function for getting representative dma dev in ovl_adaptor.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 15 +++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 1 + drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 8 ++++++++ 3 files changed, 24 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +15 -0
@@ -58,6 +58,7 @@ struct mtk_drm_crtc {#endif struct device *mmsys_dev; +struct device *dma_dev;struct mtk_mutex *mutex;unsigned int ddp_comp_nr;struct mtk_ddp_comp **ddp_comp;
@@ -865,6 +866,13 @@ static int mtk_drm_crtc_init_comp_planes(struct drm_device *drm_dev,return 0 ; } +struct device *mtk_drm_crtc_dma_dev_get (struct drm_crtc *crtc) +{ +struct mtk_drm_crtc *mtk_crtc =to_mtk_crtc (crtc); + +return mtk_crtc->dma_dev; +} +int mtk_drm_crtc_create (struct drm_device *drm_dev,const enum mtk_ddp_comp_id *path,unsigned int path_len) {
@@ -953,6 +961,13 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,return ret; } +/* +* Default to use the first component as the dma dev. +* In the case of ovl_adaptor sub driver, it needs to use the +* dma_dev_get function to get representative dma dev. +*/ + mtk_crtc->dma_dev =mtk_ddp_comp_dma_dev_get (&priv->ddp_comp[path[0 ]]); + ret =mtk_drm_crtc_init (drm_dev, mtk_crtc, pipe);if (ret <0 )return ret;
drivers/gpu/drm/mediatek/mtk_drm_crtc.h +1 -0
@@ -22,5 +22,6 @@ int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane, struct mtk_plane_state *state);void mtk_drm_crtc_async_update (struct drm_crtc *crtc,struct drm_plane *plane,struct drm_atomic_state *plane_state); +struct device *mtk_drm_crtc_dma_dev_get (struct drm_crtc *crtc);#endif /* MTK_DRM_CRTC_H */
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +8 -0
@@ -71,6 +71,7 @@ struct mtk_ddp_comp_funcs {void (*bgclr_in_off)(struct device *dev);void (*ctm_set)(struct device *dev,struct drm_crtc_state *state); +struct device * (*dma_dev_get)(struct device *dev); };struct mtk_ddp_comp {
@@ -203,6 +204,13 @@ static inline void mtk_ddp_ctm_set(struct mtk_ddp_comp *comp, comp->funcs->ctm_set (comp->dev, state); } +static inline struct device *mtk_ddp_comp_dma_dev_get (struct mtk_ddp_comp *comp) +{ +if (comp->funcs && comp->funcs->dma_dev_get) +return comp->funcs->dma_dev_get (comp->dev); +return comp->dev; +} +int mtk_ddp_comp_get_id (struct device_node *node,enum mtk_ddp_comp_type comp_type); unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
Signature · 1 line
2.18.0
PATCH v26 5/7 drm/mediatek: modify mediatek-drm for mt8195 multi mmsys support
In reply to Nancy.LinMT8195 have two mmsys. Modify drm for MT8195 multi-mmsys support. The two mmsys (vdosys0 and vdosys1) will bring up two drm drivers, only one drm driver register as the drm device.
Each drm driver binds its own component. The last bind drm driver allocates and registers the drm device to drm core. Each crtc path is created with the corresponding drm driver data.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 24 +- drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 3 +- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 292 ++++++++++++++++++------ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 10 +- 4 files changed, 242 insertions(+), 87 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +15 -9
@@ -874,21 +874,28 @@ struct device *mtk_drm_crtc_dma_dev_get(struct drm_crtc *crtc) }int mtk_drm_crtc_create (struct drm_device *drm_dev, -const enum mtk_ddp_comp_id *path,unsigned int path_len) +const enum mtk_ddp_comp_id *path,unsigned int path_len, +int priv_data_index) {struct mtk_drm_private *priv = drm_dev->dev_private;struct device *dev = drm_dev->dev;struct mtk_drm_crtc *mtk_crtc;unsigned int num_comp_planes =0 ; -int pipe = priv->num_pipes;int ret;int i;bool has_ctm = false;uint gamma_lut_size =0 ; +struct drm_crtc *tmp; +int crtc_i =0 ;if (!path)return 0 ; + priv = priv->all_drm_private[priv_data_index]; + +drm_for_each_crtc (tmp, drm_dev) + crtc_i++; +for (i =0 ; i < path_len; i++) {enum mtk_ddp_comp_id comp_id = path[i];struct device_node *node;
@@ -900,7 +907,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,if (!node) {dev_info (dev,"Not creating crtc %d because component %d is disabled or missing\n" , - pipe, comp_id); + crtc_i, comp_id);return 0 ; }
@@ -956,7 +963,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,for (i =0 ; i < mtk_crtc->ddp_comp_nr; i++) { ret =mtk_drm_crtc_init_comp_planes (drm_dev, mtk_crtc, i, - pipe); + crtc_i);if (ret)return ret; }
@@ -968,24 +975,23 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,*/ mtk_crtc->dma_dev =mtk_ddp_comp_dma_dev_get (&priv->ddp_comp[path[0 ]]); - ret =mtk_drm_crtc_init (drm_dev, mtk_crtc, pipe); + ret =mtk_drm_crtc_init (drm_dev, mtk_crtc, crtc_i);if (ret <0 )return ret;if (gamma_lut_size)drm_mode_crtc_set_gamma_size (&mtk_crtc->base, gamma_lut_size);drm_crtc_enable_color_mgmt (&mtk_crtc->base,0 , has_ctm, gamma_lut_size); - priv->num_pipes++;mutex_init (&mtk_crtc->hw_lock);#if IS_REACHABLE (CONFIG_MTK_CMDQ ) + i = priv->mbox_index++; mtk_crtc->cmdq_client.client.dev = mtk_crtc->mmsys_dev; mtk_crtc->cmdq_client.client.tx_block = false; mtk_crtc->cmdq_client.client.knows_txdone = true; mtk_crtc->cmdq_client.client.rx_callback = ddp_cmdq_cb; mtk_crtc->cmdq_client.chan = -mbox_request_channel (&mtk_crtc->cmdq_client.client, -drm_crtc_index (&mtk_crtc->base)); +mbox_request_channel (&mtk_crtc->cmdq_client.client, i);if (IS_ERR (mtk_crtc->cmdq_client.chan)) {dev_dbg (dev,"mtk_crtc %d failed to create mailbox client, writing register by CPU now\n" ,drm_crtc_index (&mtk_crtc->base));
@@ -995,7 +1001,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,if (mtk_crtc->cmdq_client.chan) { ret =of_property_read_u32_index (priv->mutex_node,"mediatek,gce-events" , -drm_crtc_index (&mtk_crtc->base), + i, &mtk_crtc->cmdq_event);if (ret) { dev_dbg(dev, "mtk_crtc %d failed to get mediatek,gce-events property\n",
drivers/gpu/drm/mediatek/mtk_drm_crtc.h +2 -1
@@ -17,7 +17,8 @@void mtk_drm_crtc_commit (struct drm_crtc *crtc);int mtk_drm_crtc_create (struct drm_device *drm_dev,const enum mtk_ddp_comp_id *path, -unsigned int path_len); +unsigned int path_len, +int priv_data_index);int mtk_drm_crtc_plane_check (struct drm_crtc *crtc,struct drm_plane *plane,struct mtk_plane_state *state); void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
drivers/gpu/drm/mediatek/mtk_drm_drv.c +218 -74
441 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_drm_drv.h +7 -3
@@ -30,6 +30,8 @@ struct mtk_mmsys_driver_data {unsigned int third_len;bool shadow_register; +unsigned int mmsys_id; +unsigned int mmsys_dev_num; };struct mtk_mmsys_match_data {
@@ -40,9 +42,9 @@ struct mtk_mmsys_match_data {struct mtk_drm_private {struct drm_device *drm;struct device *dma_dev; - -unsigned int num_pipes; - +bool mtk_drm_bound; +bool drm_master; +struct device *dev;struct device_node *mutex_node;struct device *mutex_dev;struct device *mmsys_dev;
@@ -50,6 +52,8 @@ struct mtk_drm_private {struct mtk_ddp_comp ddp_comp[DDP_COMPONENT_ID_MAX ];const struct mtk_mmsys_driver_data *data;struct drm_atomic_state *suspend_state; +unsigned int mbox_index; +struct mtk_drm_private **all_drm_private; };extern struct platform_driver mtk_disp_aal_driver;
Signature · 1 line
2.18.0
Re: [PATCH v26 5/7] drm/mediatek: modify mediatek-drm for mt8195 multi mmsys support
Quoted 7 lines · Nancy.Lin
MT8195 have two mmsys. Modify drm for MT8195 multi-mmsys support. The two mmsys (vdosys0 and vdosys1) will bring up two drm drivers, only one drm driver register as the drm device.
Each drm driver binds its own component. The last bind drm driver allocates and registers the drm device to drm core. Each crtc path is created with the corresponding drm driver data.
Quoted 5 lines
Signed-off-by Nancy.Lin <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Reviewed-by CK Hu <[email protected]>Tested-by Bo-Chen Chen <[email protected]>
Display and external display still work on mt8192 as it should.
Thanks,
Nícolas
PATCH v26 6/7 drm/mediatek: add drm ovl_adaptor sub driver for MT8195
In reply to Nancy.LinAdd drm ovl_adaptor sub driver. Bring up ovl_adaptor sub driver if the component exists in the path.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 61 ++++----- drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 2 +- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 129 ++++++++++++-------- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 50 +++++++- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 78 ++++++------ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 12 +- 6 files changed, 209 insertions(+), 123 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +33 -28
@@ -379,13 +379,17 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) }for (i =0 ; i < mtk_crtc->ddp_comp_nr -1 ; i++) { -mtk_mmsys_ddp_connect (mtk_crtc->mmsys_dev, - mtk_crtc->ddp_comp[i]->id, - mtk_crtc->ddp_comp[i +1 ]->id); -mtk_mutex_add_comp (mtk_crtc->mutex, - mtk_crtc->ddp_comp[i]->id); +if (!mtk_ddp_comp_connect (mtk_crtc->ddp_comp[i], mtk_crtc->mmsys_dev, + mtk_crtc->ddp_comp[i +1 ]->id)) +mtk_mmsys_ddp_connect (mtk_crtc->mmsys_dev, + mtk_crtc->ddp_comp[i]->id, + mtk_crtc->ddp_comp[i +1 ]->id); +if (!mtk_ddp_comp_add (mtk_crtc->ddp_comp[i], mtk_crtc->mutex)) +mtk_mutex_add_comp (mtk_crtc->mutex, + mtk_crtc->ddp_comp[i]->id); } -mtk_mutex_add_comp (mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id); +if (!mtk_ddp_comp_add (mtk_crtc->ddp_comp[i], mtk_crtc->mutex)) +mtk_mutex_add_comp (mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id);mtk_mutex_enable (mtk_crtc->mutex);for (i =0 ; i < mtk_crtc->ddp_comp_nr; i++) {
@@ -434,17 +438,22 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc) }for (i =0 ; i < mtk_crtc->ddp_comp_nr; i++) -mtk_mutex_remove_comp (mtk_crtc->mutex, - mtk_crtc->ddp_comp[i]->id); +if (!mtk_ddp_comp_remove (mtk_crtc->ddp_comp[i], mtk_crtc->mutex)) +mtk_mutex_remove_comp (mtk_crtc->mutex, + mtk_crtc->ddp_comp[i]->id);mtk_mutex_disable (mtk_crtc->mutex);for (i =0 ; i < mtk_crtc->ddp_comp_nr -1 ; i++) { -mtk_mmsys_ddp_disconnect (mtk_crtc->mmsys_dev, - mtk_crtc->ddp_comp[i]->id, - mtk_crtc->ddp_comp[i +1 ]->id); -mtk_mutex_remove_comp (mtk_crtc->mutex, - mtk_crtc->ddp_comp[i]->id); +if (!mtk_ddp_comp_disconnect (mtk_crtc->ddp_comp[i], mtk_crtc->mmsys_dev, + mtk_crtc->ddp_comp[i +1 ]->id)) +mtk_mmsys_ddp_disconnect (mtk_crtc->mmsys_dev, + mtk_crtc->ddp_comp[i]->id, + mtk_crtc->ddp_comp[i +1 ]->id); +if (!mtk_ddp_comp_remove (mtk_crtc->ddp_comp[i], mtk_crtc->mutex)) +mtk_mutex_remove_comp (mtk_crtc->mutex, + mtk_crtc->ddp_comp[i]->id); } -mtk_mutex_remove_comp (mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id); +if (!mtk_ddp_comp_remove (mtk_crtc->ddp_comp[i], mtk_crtc->mutex)) +mtk_mutex_remove_comp (mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id);mtk_crtc_ddp_clk_disable (mtk_crtc);mtk_mutex_unprepare (mtk_crtc->mutex);
@@ -874,7 +883,7 @@ struct device *mtk_drm_crtc_dma_dev_get(struct drm_crtc *crtc) }int mtk_drm_crtc_create (struct drm_device *drm_dev, -const enum mtk_ddp_comp_id *path,unsigned int path_len, +const unsigned int *path,unsigned int path_len,int priv_data_index) {struct mtk_drm_private *priv = drm_dev->dev_private;
@@ -897,22 +906,18 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, crtc_i++;for (i =0 ; i < path_len; i++) { -enum mtk_ddp_comp_id comp_id = path[i]; +unsigned int comp_id = path[i];struct device_node *node; -struct mtk_ddp_comp *comp; node = priv->comp_node[comp_id]; - comp = &priv->ddp_comp[comp_id]; - -if (!node) { -dev_info (dev, -"Not creating crtc %d because component %d is disabled or missing\n" , - crtc_i, comp_id); -return 0 ; - } -if (!comp->dev) { -dev_err (dev,"Component %pOF not initialized\n" , node); +/* Not all drm components have a DTS device node, such as ovl_adaptor, +* which is the drm bring up sub driver +*/ +if (!node && comp_id !=DDP_COMPONENT_DRM_OVL_ADAPTOR ) { +dev_err (dev, +"Not creating crtc %d because component %d is disabled, missing or not initialized\n" , + crtc_i, comp_id);return -ENODEV ; } }
@@ -937,7 +942,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, }for (i =0 ; i < mtk_crtc->ddp_comp_nr; i++) { -enum mtk_ddp_comp_id comp_id = path[i]; +unsigned int comp_id = path[i];struct mtk_ddp_comp *comp; comp = &priv->ddp_comp[comp_id];
drivers/gpu/drm/mediatek/mtk_drm_crtc.h +1 -1
@@ -16,7 +16,7 @@void mtk_drm_crtc_commit (struct drm_crtc *crtc);int mtk_drm_crtc_create (struct drm_device *drm_dev, -const enum mtk_ddp_comp_id *path, +const unsigned int *path,unsigned int path_len,int priv_data_index); int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane,
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +78 -51
175 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +47 -3
84 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_drm_drv.c +43 -35
254 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_drm_drv.h +7 -5
@@ -11,6 +11,8 @@#define MAX_CRTC 3#define MAX_CONNECTOR 2 +#define DDP_COMPONENT_DRM_OVL_ADAPTOR (DDP_COMPONENT_ID_MAX + 1) +#define DDP_COMPONENT_DRM_ID_MAX (DDP_COMPONENT_DRM_OVL_ADAPTOR + 1)struct device ;struct device_node ;
@@ -22,11 +24,11 @@ struct regmap;struct mtk_mmsys_driver_data {const resource_size_t io_start; -const enum mtk_ddp_comp_id *main_path; +const unsigned int *main_path;unsigned int main_len; -const enum mtk_ddp_comp_id *ext_path; +const unsigned int *ext_path;unsigned int ext_len; -const enum mtk_ddp_comp_id *third_path; +const unsigned int *third_path;unsigned int third_len;bool shadow_register;
@@ -48,8 +50,8 @@ struct mtk_drm_private {struct device_node *mutex_node;struct device *mutex_dev;struct device *mmsys_dev; -struct device_node *comp_node[DDP_COMPONENT_ID_MAX ]; -struct mtk_ddp_comp ddp_comp[DDP_COMPONENT_ID_MAX ]; +struct device_node *comp_node[DDP_COMPONENT_DRM_ID_MAX ]; +struct mtk_ddp_comp ddp_comp[DDP_COMPONENT_DRM_ID_MAX ];const struct mtk_mmsys_driver_data *data;struct drm_atomic_state *suspend_state;unsigned int mbox_index;
Signature · 1 line
2.18.0
Re: [PATCH v26 6/7] drm/mediatek: add drm ovl_adaptor sub driver for MT8195
Quoted 8 lines · Nancy.Lin
Add drm
ovl_adaptorsub driver. Bring upovl_adaptorsub driver if the component exists in the path.Signed-off-by Nancy.Lin <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Reviewed-by CK Hu <[email protected]>Tested-by Bo-Chen Chen <[email protected]>
Display and external display still work on mt8192 as they should.
Thanks,
Nícolas
PATCH v26 7/7 drm/mediatek: add mediatek-drm of vdosys1 support for MT8195
In reply to Nancy.LinAdd driver data of mt8195 vdosys1 to mediatek-drm.
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +12 -2
@@ -210,6 +210,12 @@ static const unsigned int mt8195_mtk_ddp_main[] = { DDP_COMPONENT_DP_INTF0, }; +static const unsigned int mt8195_mtk_ddp_ext[] = { +DDP_COMPONENT_DRM_OVL_ADAPTOR , +DDP_COMPONENT_MERGE5 , +DDP_COMPONENT_DP_INTF1 , +}; +static const struct mtk_mmsys_driver_data mt2701_mmsys_driver_data = { .main_path = mt2701_mtk_ddp_main, .main_len =ARRAY_SIZE (mt2701_mtk_ddp_main),
@@ -336,15 +342,19 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = { .io_start = 0x1c01a000, .main_path = mt8195_mtk_ddp_main, .main_len = ARRAY_SIZE(mt8195_mtk_ddp_main), - .mmsys_dev_num = 1, + .mmsys_dev_num = 2, };static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = { .io_start =0x1c100000 , + .ext_path = mt8195_mtk_ddp_ext, + .ext_len =ARRAY_SIZE (mt8195_mtk_ddp_ext), + .mmsys_id =1 , + .mmsys_dev_num =2 , };static const struct mtk_mmsys_match_data mt8195_mmsys_match_data = { - .num_drv_data =1 , + .num_drv_data =2 , .drv_data = { &mt8195_vdosys0_driver_data, &mt8195_vdosys1_driver_data,
Signature · 1 line
2.18.0