Skip to contentSkip to conversation

drm/mediatek: Add MT8195 dp_intf driver

PATCH In review Bo-Chen Chen 4 participants 33 messages Jun 13, 2022 – Jun 16, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v11 cover drm/mediatek: Add MT8195 dp_intf driver

The dpi/dpintf driver and the added helper functions are required for the DisplayPort driver to work.

This series is separated from [1] which is original from Guillaume. The display port driver is [2].

Changes for v11:
1. Rename ck_cg to pll_gate.
2. Add some commit message to clarify the modification reason.
3. Fix some driver order and modify for reviewers' comments.

[1]:https://lore.kernel.org/all/[email protected]/ [2]:https://lore.kernel.org/all/[email protected]/

Guillaume Ranquet (11):
drm/mediatek: dpi: move dpi limits to SoC config drm/mediatek: dpi: implement a CK/DE pol toggle in SoC config drm/mediatek: dpi: implement a swap_input toggle in SoC config drm/mediatek: dpi: move dimension mask to SoC config drm/mediatek: dpi: move hvsize_mask to SoC config drm/mediatek: dpi: move swap_shift to SoC config drm/mediatek: dpi: move the yuv422_en_bit to SoC config drm/mediatek: dpi: move the csc_enable bit to SoC config drm/mediatek: dpi: Add dpintf support
drm/mediatek: dpi: Only enable dpi after the bridge is enabled drm/mediatek: dpi: Add matrix_sel helper

Markus Schneider-Pargmann (1):
dt-bindings: mediatek,dpi: Add DP_INTF compatible

 .../display/mediatek/mediatek,dpi.yaml        |  13 +-
 drivers/gpu/drm/mediatek/mtk_dpi.c            | 262 +++++++++++++++---
 drivers/gpu/drm/mediatek/mtk_dpi_regs.h       |  16 ++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c   |   4 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h   |   1 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.c        |   3 +
 6 files changed, 251 insertions(+), 48 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH v11 1/12 dt-bindings: mediatek,dpi: Add DP_INTF compatible

From: Markus Schneider-Pargmann <[email protected]>

DP_INTF is similar to DPI but does not have the exact same feature set or register layouts.

DP_INTF is the sink of the display pipeline that is connected to the DisplayPort controller and encoder unit. It takes the same clocks as DPI.

In this patch, we also do these string replacement:
- s/mediatek/MediaTek/ in title.
- s/Mediatek/MediaTek/ in description.

---
 .../bindings/display/mediatek/mediatek,dpi.yaml     | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +8 -5
index 77ee1b923991..ca1b48e78581 100644
@@ -4,16 +4,16 @@
 $id: http://devicetree.org/schemas/display/mediatek/mediatek,dpi.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: mediatek DPI Controller Device Tree Bindings
+title: MediaTek DPI and DP_INTF Controller
 
 maintainers:
   - CK Hu <[email protected]>
   - Jitao shi <[email protected]>
 
 description: |
-  The Mediatek DPI function block is a sink of the display subsystem and
-  provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a parallel
-  output bus.
+  The MediaTek DPI and DP_INTF function blocks are a sink of the display
+  subsystem and provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a
+  parallel output bus.
 
 properties:
   compatible:
@@ -24,6 +24,7 @@ properties:
       - mediatek,mt8183-dpi
       - mediatek,mt8186-dpi
       - mediatek,mt8192-dpi
+      - mediatek,mt8195-dp_intf
 
   reg:
     maxItems: 1
@@ -36,12 +37,14 @@ properties:
       - description: Pixel Clock
       - description: Engine Clock
       - description: DPI PLL
+      - description: Clock gate for PLL
 
   clock-names:
     items:
       - const: pixel
       - const: engine
       - const: pll
+      - const: pll_gate
 
   pinctrl-0: true
   pinctrl-1: true
@@ -55,7 +58,7 @@ properties:
     $ref: /schemas/graph.yaml#/properties/port
     description:
       Output port node. This port should be connected to the input port of an
-      attached HDMI or LVDS encoder chip.
+      attached HDMI, LVDS or DisplayPort encoder chip.
 
 required:
   - compatible
Signature · 1 line
2.18.0
maintainer
#2 lore raw

Re: [PATCH v11 01/12] dt-bindings: mediatek,dpi: Add DP_INTF compatible

Quoted 13 lines · Bo-Chen Chen

From: Markus Schneider-Pargmann <[email protected]>

DP_INTF is similar to DPI but does not have the exact same feature set or register layouts.

DP_INTF is the sink of the display pipeline that is connected to the DisplayPort controller and encoder unit. It takes the same clocks as DPI.

In this patch, we also do these string replacement:
- s/mediatek/MediaTek/ in title.
- s/Mediatek/MediaTek/ in description.

Quoted 7 lines
---
 .../bindings/display/mediatek/mediatek,dpi.yaml     | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.example.dtb: dpi@1401d000: clocks: [[4294967295, 40], [4294967295, 41], [4294967295, 8]] is too short
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.example.dtb: dpi@1401d000: clock-names: ['pixel', 'engine', 'pll'] is too short
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

#3 lore raw

Re: [PATCH v11 01/12] dt-bindings: mediatek,dpi: Add DP_INTF compatible

In reply to Bo-Chen Chen

Hi, Bo-Chen:

Quoted 69 lines · Bo-Chen Chen

From: Markus Schneider-Pargmann <[email protected]>

DP_INTF is similar to DPI but does not have the exact same feature set
or register layouts.

DP_INTF is the sink of the display pipeline that is connected to the DisplayPort controller and encoder unit. It takes the same clocks as DPI.

In this patch, we also do these string replacement:
- s/mediatek/MediaTek/ in title.
- s/Mediatek/MediaTek/ in description.

---
 .../bindings/display/mediatek/mediatek,dpi.yaml     | 13 ++++++++---
--
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yam l b/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yam l
index 77ee1b923991..ca1b48e78581 100644
---
a/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yam l
+++
b/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yam l

(quoted diff) +0 -0
@@ -4,16 +4,16 @@
 $id: 

http://devicetree.org/schemas/display/mediatek/mediatek,dpi.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -2
-title: mediatek DPI Controller Device Tree Bindings
+title: MediaTek DPI and DP_INTF Controller
 
 maintainers:
   - CK Hu <[email protected]>
   - Jitao shi <[email protected]>
 
 description: |
-  The Mediatek DPI function block is a sink of the display subsystem

and
- provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a parallel

(quoted diff) +1 -1
-  output bus.
+  The MediaTek DPI and DP_INTF function blocks are a sink of the

display
+ subsystem and provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +2 -0
+  parallel output bus.
 
 properties:
   compatible:
@@ -24,6 +24,7 @@ properties:
       - mediatek,mt8183-dpi
       - mediatek,mt8186-dpi
       - mediatek,mt8192-dpi
+      - mediatek,mt8195-dp_intf
 
   reg:
     maxItems: 1

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml properties: · line 40

Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -0
@@ -36,12 +37,14 @@ properties:
       - description: Pixel Clock
       - description: Engine Clock
       - description: DPI PLL
+      - description: Clock gate for PLL

Why DP_INTF has this additional clock? What is the new hardware block (compared with DPI) need this clock? Why this is different than DPI?

Regards,
CK

Quoted 20 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -0
   clock-names:
     items:
       - const: pixel
       - const: engine
       - const: pll
+      - const: pll_gate
 
   pinctrl-0: true
   pinctrl-1: true
@@ -55,7 +58,7 @@ properties:
     $ref: /schemas/graph.yaml#/properties/port
     description:
       Output port node. This port should be connected to the input

port of an

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -1
-      attached HDMI or LVDS encoder chip.
+      attached HDMI, LVDS or DisplayPort encoder chip.
 
 required:
   - compatible
#4 lore raw

Re: [PATCH v11 01/12] dt-bindings: mediatek,dpi: Add DP_INTF compatible

Quoted 88 lines · CK Hu

Hi, Bo-Chen:

Quoted 77 lines · Bo-Chen Chen

From: Markus Schneider-Pargmann <[email protected]>

DP_INTF is similar to DPI but does not have the exact same feature set
or register layouts.

DP_INTF is the sink of the display pipeline that is connected to the
DisplayPort controller and encoder unit. It takes the same clocks as
DPI.

In this patch, we also do these string replacement:
- s/mediatek/MediaTek/ in title.
- s/Mediatek/MediaTek/ in description.

---
 .../bindings/display/mediatek/mediatek,dpi.yaml     | 13 ++++++++-
--
--
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.y am
l b/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.y am
l
index 77ee1b923991..ca1b48e78581 100644
---
a/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.y am
l
+++
b/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.y am
l

(quoted diff) +0 -0
@@ -4,16 +4,16 @@
 $id: 

http://devicetree.org/schemas/display/mediatek/mediatek,dpi.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -2
-title: mediatek DPI Controller Device Tree Bindings
+title: MediaTek DPI and DP_INTF Controller
 
 maintainers:
   - CK Hu <[email protected]>
   - Jitao shi <[email protected]>
 
 description: |
-  The Mediatek DPI function block is a sink of the display

subsystem
and
- provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a parallel

(quoted diff) +1 -1
-  output bus.
+  The MediaTek DPI and DP_INTF function blocks are a sink of the

display
+ subsystem and provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +2 -0
+  parallel output bus.
 
 properties:
   compatible:
@@ -24,6 +24,7 @@ properties:
       - mediatek,mt8183-dpi
       - mediatek,mt8186-dpi
       - mediatek,mt8192-dpi
+      - mediatek,mt8195-dp_intf
 
   reg:
     maxItems: 1

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml properties: · line 40

Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -0
@@ -36,12 +37,14 @@ properties:
       - description: Pixel Clock
       - description: Engine Clock
       - description: DPI PLL
+      - description: Clock gate for PLL

Why DP_INTF has this additional clock? What is the new hardware block (compared with DPI) need this clock? Why this is different than DPI?

Quoted 3 lines

Regards,
CK

Hello CK,

as previous reply, I will remove this clock.

BRs,
Bo-Chen

Quoted 22 lines
Quoted 20 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -0
   clock-names:
     items:
       - const: pixel
       - const: engine
       - const: pll
+      - const: pll_gate
 
   pinctrl-0: true
   pinctrl-1: true
@@ -55,7 +58,7 @@ properties:
     $ref: /schemas/graph.yaml#/properties/port
     description:
       Output port node. This port should be connected to the input

port of an

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -1
-      attached HDMI or LVDS encoder chip.
+      attached HDMI, LVDS or DisplayPort encoder chip.
 
 required:
   - compatible
maintainer
#5 lore raw

Re: [PATCH v11 01/12] dt-bindings: mediatek,dpi: Add DP_INTF compatible

In reply to Bo-Chen Chen
Quoted 55 lines · Bo-Chen Chen

From: Markus Schneider-Pargmann <[email protected]>

DP_INTF is similar to DPI but does not have the exact same feature set or register layouts.

DP_INTF is the sink of the display pipeline that is connected to the DisplayPort controller and encoder unit. It takes the same clocks as DPI.

In this patch, we also do these string replacement:
- s/mediatek/MediaTek/ in title.
- s/Mediatek/MediaTek/ in description.

---
 .../bindings/display/mediatek/mediatek,dpi.yaml     | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +5 -4
index 77ee1b923991..ca1b48e78581 100644
@@ -4,16 +4,16 @@
 $id: http://devicetree.org/schemas/display/mediatek/mediatek,dpi.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: mediatek DPI Controller Device Tree Bindings
+title: MediaTek DPI and DP_INTF Controller
 
 maintainers:
   - CK Hu <[email protected]>
   - Jitao shi <[email protected]>
 
 description: |
-  The Mediatek DPI function block is a sink of the display subsystem and
-  provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a parallel
-  output bus.
+  The MediaTek DPI and DP_INTF function blocks are a sink of the display
+  subsystem and provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a
+  parallel output bus.
 
 properties:
   compatible:
@@ -24,6 +24,7 @@ properties:
       - mediatek,mt8183-dpi
       - mediatek,mt8186-dpi
       - mediatek,mt8192-dpi
+      - mediatek,mt8195-dp_intf
 
   reg:
     maxItems: 1
@@ -36,12 +37,14 @@ properties:
       - description: Pixel Clock

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml properties: · line 47

Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +2 -0
       - description: Engine Clock
       - description: DPI PLL
+      - description: Clock gate for PLL
 
   clock-names:
     items:
       - const: pixel
       - const: engine
       - const: pll
+      - const: pll_gate

You just added a new required clock for everyone.

Quoted 16 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -1
   pinctrl-0: true
   pinctrl-1: true
@@ -55,7 +58,7 @@ properties:
     $ref: /schemas/graph.yaml#/properties/port
     description:
       Output port node. This port should be connected to the input port of an
-      attached HDMI or LVDS encoder chip.
+      attached HDMI, LVDS or DisplayPort encoder chip.
 
 required:
   - compatible
Signature · 1 line
2.18.0
#6 lore raw

Re: [PATCH v11 01/12] dt-bindings: mediatek,dpi: Add DP_INTF compatible

Quoted 80 lines · Rob Herring
Quoted 79 lines · Bo-Chen Chen

From: Markus Schneider-Pargmann <[email protected]>

DP_INTF is similar to DPI but does not have the exact same feature set
or register layouts.

DP_INTF is the sink of the display pipeline that is connected to the
DisplayPort controller and encoder unit. It takes the same clocks as
DPI.

In this patch, we also do these string replacement:
- s/mediatek/MediaTek/ in title.
- s/Mediatek/MediaTek/ in description.

---
 .../bindings/display/mediatek/mediatek,dpi.yaml     | 13 ++++++++-
----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.y aml b/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.y aml
index 77ee1b923991..ca1b48e78581 100644
---
a/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.y aml
+++
b/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.y aml

(quoted diff) +0 -0
@@ -4,16 +4,16 @@
 $id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/display/mediatek/mediatek,dpi.yaml*__;Iw!!CTRNKA9wMg0ARbw!0wzvKisC8j2vSMbYtNhgV1niXflyQgVHmgSPCVo94UQV-GiFqhMtdoowjpgIYMXH8wDn$

$schema:
https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!0wzvKisC8j2vSMbYtNhgV1niXflyQgVHmgSPCVo94UQV-GiFqhMtdoowjpgIYEfMUrSk$

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -2
-title: mediatek DPI Controller Device Tree Bindings
+title: MediaTek DPI and DP_INTF Controller
 
 maintainers:
   - CK Hu <[email protected]>
   - Jitao shi <[email protected]>
 
 description: |
-  The Mediatek DPI function block is a sink of the display

subsystem and
- provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a parallel

(quoted diff) +1 -1
-  output bus.
+  The MediaTek DPI and DP_INTF function blocks are a sink of the

display
+ subsystem and provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +3 -0
+  parallel output bus.
 
 properties:
   compatible:
@@ -24,6 +24,7 @@ properties:
       - mediatek,mt8183-dpi
       - mediatek,mt8186-dpi
       - mediatek,mt8192-dpi
+      - mediatek,mt8195-dp_intf
 
   reg:
     maxItems: 1
@@ -36,12 +37,14 @@ properties:
       - description: Pixel Clock
       - description: Engine Clock
       - description: DPI PLL
+      - description: Clock gate for PLL
 
Quoted 9 lines

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml properties: · line 47

Quoted 6 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -0
   clock-names:
     items:
       - const: pixel
       - const: engine
       - const: pll
+      - const: pll_gate

You just added a new required clock for everyone.

Hello Rob,

We can remove this clock and using clock framework to enable this pll gate, so I will remove this in next version.

BRs,
Bo-Chen

Quoted 17 lines
Quoted 17 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +0 -0
   pinctrl-0: true
   pinctrl-1: true
@@ -55,7 +58,7 @@ properties:
     $ref: /schemas/graph.yaml#/properties/port
     description:
       Output port node. This port should be connected to the input

port of an

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -1
-      attached HDMI or LVDS encoder chip.
+      attached HDMI, LVDS or DisplayPort encoder chip.
 
 required:
   - compatible
Signature · 1 line
2.18.0
#7 lore raw

PATCH v11 2/12 drm/mediatek: dpi: move dpi limits to SoC config

In reply to Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add flexibility by moving the dpi limits to the SoC specific config.

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +16 -9
index e61cd67b978f..ce8c5eefe5f1 100644
@@ -125,6 +125,7 @@ struct mtk_dpi_conf {
 	bool edge_sel_en;
 	const u32 *output_fmts;
 	u32 num_output_fmts;
+	const struct mtk_dpi_yc_limit *limit;
 };
 
 static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask)
@@ -235,9 +236,10 @@ static void mtk_dpi_config_fb_size(struct mtk_dpi *dpi, u32 width, u32 height)
 	mtk_dpi_mask(dpi, DPI_SIZE, height << VSIZE, VSIZE_MASK);
 }
 
-static void mtk_dpi_config_channel_limit(struct mtk_dpi *dpi,
-					 struct mtk_dpi_yc_limit *limit)
+static void mtk_dpi_config_channel_limit(struct mtk_dpi *dpi)
 {
+	const struct mtk_dpi_yc_limit *limit = dpi->conf->limit;
+
 	mtk_dpi_mask(dpi, DPI_Y_LIMIT, limit->y_bottom << Y_LIMINT_BOT,
 		     Y_LIMINT_BOT_MASK);
 	mtk_dpi_mask(dpi, DPI_Y_LIMIT, limit->y_top << Y_LIMINT_TOP,
@@ -449,7 +451,6 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)
 static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
 				    struct drm_display_mode *mode)
 {
-	struct mtk_dpi_yc_limit limit;
 	struct mtk_dpi_polarities dpi_pol;
 	struct mtk_dpi_sync_param hsync;
 	struct mtk_dpi_sync_param vsync_lodd = { 0 };
@@ -484,11 +485,6 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
 	dev_dbg(dpi->dev, "Got  PLL %lu Hz, pixel clock %lu Hz\n",
 		pll_rate, vm.pixelclock);
 
-	limit.c_bottom = 0x0010;
-	limit.c_top = 0x0FE0;
-	limit.y_bottom = 0x0010;
-	limit.y_top = 0x0FE0;
-
 	dpi_pol.ck_pol = MTK_DPI_POLARITY_FALLING;
 	dpi_pol.de_pol = MTK_DPI_POLARITY_RISING;
 	dpi_pol.hsync_pol = vm.flags & DISPLAY_FLAGS_HSYNC_HIGH ?
@@ -536,7 +532,7 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
 	else
 		mtk_dpi_config_fb_size(dpi, vm.hactive, vm.vactive);
 
-	mtk_dpi_config_channel_limit(dpi, &limit);
+	mtk_dpi_config_channel_limit(dpi);
 	mtk_dpi_config_bit_num(dpi, dpi->bit_num);
 	mtk_dpi_config_channel_swap(dpi, dpi->channel_swap);
 	mtk_dpi_config_yc_map(dpi, dpi->yc_map);
@@ -790,12 +786,20 @@ static const u32 mt8183_output_fmts[] = {
 	MEDIA_BUS_FMT_RGB888_2X12_BE,
 };
 
+static const struct mtk_dpi_yc_limit mtk_dpi_limit = {
+	.c_bottom = 0x0010,
+	.c_top = 0x0FE0,
+	.y_bottom = 0x0010,
+	.y_top = 0x0FE0,
+};
+
 static const struct mtk_dpi_conf mt8173_conf = {
 	.cal_factor = mt8173_calculate_factor,
 	.reg_h_fre_con = 0xe0,
 	.max_clock_khz = 300000,
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 
 static const struct mtk_dpi_conf mt2701_conf = {
@@ -805,6 +809,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.max_clock_khz = 150000,
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 
 static const struct mtk_dpi_conf mt8183_conf = {
@@ -813,6 +818,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.max_clock_khz = 100000,
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 
 static const struct mtk_dpi_conf mt8192_conf = {
@@ -821,6 +827,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.max_clock_khz = 150000,
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 
 static int mtk_dpi_probe(struct platform_device *pdev)
Signature · 1 line
2.18.0
#8 lore raw

Re: [PATCH v11 02/12] drm/mediatek: dpi: move dpi limits to SoC config

Hi, Bo-Chen:

Quoted 3 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add flexibility by moving the dpi limits to the SoC specific config.

What does this 'limit' mean? Why it's different in DPI vs DP_INTF?

The hardware design is so weird. If the limit is fixed for DPI and DP_INTF, why the hardware export register for software to assign any value which may be wrong.

Regards,
CK

Quoted 115 lines
Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
index e61cd67b978f..ce8c5eefe5f1 100644
@@ -125,6 +125,7 @@ struct mtk_dpi_conf {
 	bool edge_sel_en;
 	const u32 *output_fmts;
 	u32 num_output_fmts;
+	const struct mtk_dpi_yc_limit *limit;
 };
 
 static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val,

u32 mask)

drivers/gpu/drm/mediatek/mtk_dpi.c +3 -2
@@ -235,9 +236,10 @@ static void mtk_dpi_config_fb_size(struct
 mtk_dpi *dpi, u32 width, u32 height)
 	mtk_dpi_mask(dpi, DPI_SIZE, height << VSIZE, VSIZE_MASK);
 }
 
-static void mtk_dpi_config_channel_limit(struct mtk_dpi *dpi,
-					 struct mtk_dpi_yc_limit
 *limit)
+static void mtk_dpi_config_channel_limit(struct mtk_dpi *dpi)
 {
+	const struct mtk_dpi_yc_limit *limit = dpi->conf->limit;
+
 	mtk_dpi_mask(dpi, DPI_Y_LIMIT, limit->y_bottom << Y_LIMINT_BOT,
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -6
 		     Y_LIMINT_BOT_MASK);
 	mtk_dpi_mask(dpi, DPI_Y_LIMIT, limit->y_top << Y_LIMINT_TOP,
@@ -449,7 +451,6 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)
 static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
 				    struct drm_display_mode *mode)
 {
-	struct mtk_dpi_yc_limit limit;
 	struct mtk_dpi_polarities dpi_pol;
 	struct mtk_dpi_sync_param hsync;
 	struct mtk_dpi_sync_param vsync_lodd = { 0 };
@@ -484,11 +485,6 @@ static int mtk_dpi_set_display_mode(struct
 mtk_dpi *dpi,
 	dev_dbg(dpi->dev, "Got  PLL %lu Hz, pixel clock %lu Hz\n",
 		pll_rate, vm.pixelclock);
 
-	limit.c_bottom = 0x0010;
-	limit.c_top = 0x0FE0;
-	limit.y_bottom = 0x0010;
-	limit.y_top = 0x0FE0;
-
 	dpi_pol.ck_pol = MTK_DPI_POLARITY_FALLING;
 	dpi_pol.de_pol = MTK_DPI_POLARITY_RISING;
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -1
 	dpi_pol.hsync_pol = vm.flags & DISPLAY_FLAGS_HSYNC_HIGH ?
@@ -536,7 +532,7 @@ static int mtk_dpi_set_display_mode(struct
 mtk_dpi *dpi,
 	else
 		mtk_dpi_config_fb_size(dpi, vm.hactive, vm.vactive);
 
-	mtk_dpi_config_channel_limit(dpi, &limit);
+	mtk_dpi_config_channel_limit(dpi);
 	mtk_dpi_config_bit_num(dpi, dpi->bit_num);
 	mtk_dpi_config_channel_swap(dpi, dpi->channel_swap);
drivers/gpu/drm/mediatek/mtk_dpi.c +11 -0
 	mtk_dpi_config_yc_map(dpi, dpi->yc_map);
@@ -790,12 +786,20 @@ static const u32 mt8183_output_fmts[] = {
 	MEDIA_BUS_FMT_RGB888_2X12_BE,
 };
 
+static const struct mtk_dpi_yc_limit mtk_dpi_limit = {
+	.c_bottom = 0x0010,
+	.c_top = 0x0FE0,
+	.y_bottom = 0x0010,
+	.y_top = 0x0FE0,
+};
+
 static const struct mtk_dpi_conf mt8173_conf = {
 	.cal_factor = mt8173_calculate_factor,
 	.reg_h_fre_con = 0xe0,
 	.max_clock_khz = 300000,
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 
 static const struct mtk_dpi_conf mt2701_conf = {
@@ -805,6 +809,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.max_clock_khz = 150000,
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 
 static const struct mtk_dpi_conf mt8183_conf = {
@@ -813,6 +818,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.max_clock_khz = 100000,
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 
 static const struct mtk_dpi_conf mt8192_conf = {
@@ -821,6 +827,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.max_clock_khz = 150000,
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 
 static int mtk_dpi_probe(struct platform_device *pdev)
#9 lore raw

Re: [PATCH v11 02/12] drm/mediatek: dpi: move dpi limits to SoC config

Quoted 8 lines · CK Hu

Hi, Bo-Chen:

Quoted 4 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add flexibility by moving the dpi limits to the SoC specific config.

Quoted 9 lines

What does this 'limit' mean? Why it's different in DPI vs DP_INTF?

The hardware design is so weird. If the limit is fixed for DPI and DP_INTF, why the hardware export register for software to assign any value which may be wrong.

Regards,
CK

Hello CK,

For RGB colorimetry, CTA-861 support both limited and full range data when receiving video with RGB color space.

I will use drm_default_rgb_quant_range() to determine this and drop const struct mtk_dpi_yc_limit *limit;

BRs,
Bo-Chen

Quoted 121 lines
Quoted 119 lines
Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
index e61cd67b978f..ce8c5eefe5f1 100644
@@ -125,6 +125,7 @@ struct mtk_dpi_conf {
 	bool edge_sel_en;
 	const u32 *output_fmts;
 	u32 num_output_fmts;
+	const struct mtk_dpi_yc_limit *limit;
 };
 
 static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val,

u32 mask)

drivers/gpu/drm/mediatek/mtk_dpi.c +3 -2
@@ -235,9 +236,10 @@ static void mtk_dpi_config_fb_size(struct
 mtk_dpi *dpi, u32 width, u32 height)
 	mtk_dpi_mask(dpi, DPI_SIZE, height << VSIZE, VSIZE_MASK);
 }
 
-static void mtk_dpi_config_channel_limit(struct mtk_dpi *dpi,
-					 struct mtk_dpi_yc_limit
 *limit)
+static void mtk_dpi_config_channel_limit(struct mtk_dpi *dpi)
 {
+	const struct mtk_dpi_yc_limit *limit = dpi->conf->limit;
+
 	mtk_dpi_mask(dpi, DPI_Y_LIMIT, limit->y_bottom << Y_LIMINT_BOT,
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -1
 		     Y_LIMINT_BOT_MASK);
 	mtk_dpi_mask(dpi, DPI_Y_LIMIT, limit->y_top << Y_LIMINT_TOP,
@@ -449,7 +451,6 @@ static int mtk_dpi_power_on(struct mtk_dpi
 *dpi)
 static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
 				    struct drm_display_mode *mode)
 {
-	struct mtk_dpi_yc_limit limit;
 	struct mtk_dpi_polarities dpi_pol;
 	struct mtk_dpi_sync_param hsync;
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -5
 	struct mtk_dpi_sync_param vsync_lodd = { 0 };
@@ -484,11 +485,6 @@ static int mtk_dpi_set_display_mode(struct
 mtk_dpi *dpi,
 	dev_dbg(dpi->dev, "Got  PLL %lu Hz, pixel clock %lu Hz\n",
 		pll_rate, vm.pixelclock);
 
-	limit.c_bottom = 0x0010;
-	limit.c_top = 0x0FE0;
-	limit.y_bottom = 0x0010;
-	limit.y_top = 0x0FE0;
-
 	dpi_pol.ck_pol = MTK_DPI_POLARITY_FALLING;
 	dpi_pol.de_pol = MTK_DPI_POLARITY_RISING;
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -1
 	dpi_pol.hsync_pol = vm.flags & DISPLAY_FLAGS_HSYNC_HIGH ?
@@ -536,7 +532,7 @@ static int mtk_dpi_set_display_mode(struct
 mtk_dpi *dpi,
 	else
 		mtk_dpi_config_fb_size(dpi, vm.hactive, vm.vactive);
 
-	mtk_dpi_config_channel_limit(dpi, &limit);
+	mtk_dpi_config_channel_limit(dpi);
 	mtk_dpi_config_bit_num(dpi, dpi->bit_num);
 	mtk_dpi_config_channel_swap(dpi, dpi->channel_swap);
drivers/gpu/drm/mediatek/mtk_dpi.c +9 -0
 	mtk_dpi_config_yc_map(dpi, dpi->yc_map);
@@ -790,12 +786,20 @@ static const u32 mt8183_output_fmts[] = {
 	MEDIA_BUS_FMT_RGB888_2X12_BE,
 };
 
+static const struct mtk_dpi_yc_limit mtk_dpi_limit = {
+	.c_bottom = 0x0010,
+	.c_top = 0x0FE0,
+	.y_bottom = 0x0010,
+	.y_top = 0x0FE0,
+};
+
 static const struct mtk_dpi_conf mt8173_conf = {
 	.cal_factor = mt8173_calculate_factor,
 	.reg_h_fre_con = 0xe0,
 	.max_clock_khz = 300000,
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 
 static const struct mtk_dpi_conf mt2701_conf = {
@@ -805,6 +809,7 @@ static const struct mtk_dpi_conf mt2701_conf =
 {
 	.max_clock_khz = 150000,
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 

static const struct mtk_dpi_conf mt8183_conf = {

drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -813,6 +818,7 @@ static const struct mtk_dpi_conf mt8183_conf =
 {
 	.max_clock_khz = 100000,
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 

static const struct mtk_dpi_conf mt8192_conf = {

drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -821,6 +827,7 @@ static const struct mtk_dpi_conf mt8192_conf =
 {
 	.max_clock_khz = 150000,
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
+	.limit = &mtk_dpi_limit,
 };
 

static int mtk_dpi_probe(struct platform_device *pdev)

#10 lore raw

PATCH v11 3/12 drm/mediatek: dpi: implement a CK/DE pol toggle in SoC config

In reply to Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Dp_intf does not support CK/DE polarity because the polarity information is not used for eDP and DP while dp_intf is only for eDP and DP. Therefore, we add a bit of flexibility to support SoCs without CK/DE pol support.

[Bo-Chen: Add modification reason in commit message.]
---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +17 -5
index ce8c5eefe5f1..15218c1e8c11 100644
@@ -125,6 +125,7 @@ struct mtk_dpi_conf {
 	bool edge_sel_en;
 	const u32 *output_fmts;
 	u32 num_output_fmts;
+	bool is_ck_de_pol;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -211,13 +212,20 @@ static void mtk_dpi_config_pol(struct mtk_dpi *dpi,
 			       struct mtk_dpi_polarities *dpi_pol)
 {
 	unsigned int pol;
+	unsigned int mask;
 
-	pol = (dpi_pol->ck_pol == MTK_DPI_POLARITY_RISING ? 0 : CK_POL) |
-	      (dpi_pol->de_pol == MTK_DPI_POLARITY_RISING ? 0 : DE_POL) |
-	      (dpi_pol->hsync_pol == MTK_DPI_POLARITY_RISING ? 0 : HSYNC_POL) |
+	mask = HSYNC_POL | VSYNC_POL;
+	pol = (dpi_pol->hsync_pol == MTK_DPI_POLARITY_RISING ? 0 : HSYNC_POL) |
 	      (dpi_pol->vsync_pol == MTK_DPI_POLARITY_RISING ? 0 : VSYNC_POL);
-	mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, pol,
-		     CK_POL | DE_POL | HSYNC_POL | VSYNC_POL);
+	if (dpi->conf->is_ck_de_pol) {
+		mask |= CK_POL | DE_POL;
+		pol |= (dpi_pol->ck_pol == MTK_DPI_POLARITY_RISING ?
+			0 : CK_POL) |
+		       (dpi_pol->de_pol == MTK_DPI_POLARITY_RISING ?
+			0 : DE_POL);
+	}
+
+	mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, pol, mask);
 }
 
 static void mtk_dpi_config_3d(struct mtk_dpi *dpi, bool en_3d)
@@ -799,6 +807,7 @@ static const struct mtk_dpi_conf mt8173_conf = {
 	.max_clock_khz = 300000,
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
+	.is_ck_de_pol = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -809,6 +818,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.max_clock_khz = 150000,
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
+	.is_ck_de_pol = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -818,6 +828,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.max_clock_khz = 100000,
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
+	.is_ck_de_pol = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -827,6 +838,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.max_clock_khz = 150000,
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
+	.is_ck_de_pol = true,
 	.limit = &mtk_dpi_limit,
 };
 
Signature · 1 line
2.18.0
Reviewed-by on v11 3/12
#11 lore raw

Re: [PATCH v11 03/12] drm/mediatek: dpi: implement a CK/DE pol toggle in SoC config

Hi, Bo-Chen:

Quoted 8 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Dp_intf does not support CK/DE polarity because the polarity information
is not used for eDP and DP while dp_intf is only for eDP and DP. Therefore, we add a bit of flexibility to support SoCs without CK/DE pol
support.

Quoted 88 lines
[Bo-Chen: Add modification reason in commit message.]
Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +2 -1
index ce8c5eefe5f1..15218c1e8c11 100644
@@ -125,6 +125,7 @@ struct mtk_dpi_conf {
 	bool edge_sel_en;
 	const u32 *output_fmts;
 	u32 num_output_fmts;
+	bool is_ck_de_pol;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -211,13 +212,20 @@ static void mtk_dpi_config_pol(struct mtk_dpi
 *dpi,
 			       struct mtk_dpi_polarities *dpi_pol)
 {
 	unsigned int pol;
+	unsigned int mask;
 
-	pol = (dpi_pol->ck_pol == MTK_DPI_POLARITY_RISING ? 0 : CK_POL)

|

drivers/gpu/drm/mediatek/mtk_dpi.c +0 -1
-	      (dpi_pol->de_pol == MTK_DPI_POLARITY_RISING ? 0 : DE_POL)

|

drivers/gpu/drm/mediatek/mtk_dpi.c +0 -1
-	      (dpi_pol->hsync_pol == MTK_DPI_POLARITY_RISING ? 0 :

HSYNC_POL) |

drivers/gpu/drm/mediatek/mtk_dpi.c +2 -0
+	mask = HSYNC_POL | VSYNC_POL;
+	pol = (dpi_pol->hsync_pol == MTK_DPI_POLARITY_RISING ? 0 :

HSYNC_POL) |
(dpi_pol->vsync_pol == MTK_DPI_POLARITY_RISING ? 0 :
VSYNC_POL);

drivers/gpu/drm/mediatek/mtk_dpi.c +13 -2
-	mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, pol,
-		     CK_POL | DE_POL | HSYNC_POL | VSYNC_POL);
+	if (dpi->conf->is_ck_de_pol) {
+		mask |= CK_POL | DE_POL;
+		pol |= (dpi_pol->ck_pol == MTK_DPI_POLARITY_RISING ?
+			0 : CK_POL) |
+		       (dpi_pol->de_pol == MTK_DPI_POLARITY_RISING ?
+			0 : DE_POL);
+	}
+
+	mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, pol, mask);
 }
 
 static void mtk_dpi_config_3d(struct mtk_dpi *dpi, bool en_3d)
@@ -799,6 +807,7 @@ static const struct mtk_dpi_conf mt8173_conf = {
 	.max_clock_khz = 300000,
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
+	.is_ck_de_pol = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -809,6 +818,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.max_clock_khz = 150000,
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
+	.is_ck_de_pol = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -818,6 +828,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.max_clock_khz = 100000,
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
+	.is_ck_de_pol = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -827,6 +838,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.max_clock_khz = 150000,
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
+	.is_ck_de_pol = true,
 	.limit = &mtk_dpi_limit,
 };
 
#12 lore raw

PATCH v11 4/12 drm/mediatek: dpi: implement a swap_input toggle in SoC config

In reply to Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

The hardware design of dp_intf does not support input swap, so we add a bit of flexibility to support SoCs without swap_input support.

[Bo-Chen: Add modification reason in commit message.]
---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +11 -3
index 15218c1e8c11..c1438c744120 100644
@@ -126,6 +126,7 @@ struct mtk_dpi_conf {
 	const u32 *output_fmts;
 	u32 num_output_fmts;
 	bool is_ck_de_pol;
+	bool swap_input_support;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -378,18 +379,21 @@ static void mtk_dpi_config_color_format(struct mtk_dpi *dpi,
 	    (format == MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, false);
 		mtk_dpi_config_csc_enable(dpi, true);
-		mtk_dpi_config_swap_input(dpi, false);
+		if (dpi->conf->swap_input_support)
+			mtk_dpi_config_swap_input(dpi, false);
 		mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_BGR);
 	} else if ((format == MTK_DPI_COLOR_FORMAT_YCBCR_422) ||
 		   (format == MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, true);
 		mtk_dpi_config_csc_enable(dpi, true);
-		mtk_dpi_config_swap_input(dpi, true);
+		if (dpi->conf->swap_input_support)
+			mtk_dpi_config_swap_input(dpi, true);
 		mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_RGB);
 	} else {
 		mtk_dpi_config_yuv422_enable(dpi, false);
 		mtk_dpi_config_csc_enable(dpi, false);
-		mtk_dpi_config_swap_input(dpi, false);
+		if (dpi->conf->swap_input_support)
+			mtk_dpi_config_swap_input(dpi, false);
 		mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_RGB);
 	}
 }
@@ -808,6 +812,7 @@ static const struct mtk_dpi_conf mt8173_conf = {
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -819,6 +824,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -829,6 +835,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -839,6 +846,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
 
Signature · 1 line
2.18.0
#13 lore raw

Re: [PATCH v11 04/12] drm/mediatek: dpi: implement a swap_input toggle in SoC config

Hi, Bo-Chen:

Quoted 35 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

The hardware design of dp_intf does not support input swap, so we add a bit of flexibility to support SoCs without swap_input support.

[Bo-Chen: Add modification reason in commit message.]
Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +2 -1
index 15218c1e8c11..c1438c744120 100644
@@ -126,6 +126,7 @@ struct mtk_dpi_conf {
 	const u32 *output_fmts;
 	u32 num_output_fmts;
 	bool is_ck_de_pol;
+	bool swap_input_support;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -378,18 +379,21 @@ static void mtk_dpi_config_color_format(struct
 mtk_dpi *dpi,
 	    (format == MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, false);
 		mtk_dpi_config_csc_enable(dpi, true);
-		mtk_dpi_config_swap_input(dpi, false);
+		if (dpi->conf->swap_input_support)

drivers/gpu/drm/mediatek/mtk_dpi.c static void mtk_dpi_config_color_format(struct · line 392

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +3 -1
+			mtk_dpi_config_swap_input(dpi, false);
 		mtk_dpi_config_channel_swap(dpi,
 MTK_DPI_OUT_CHANNEL_SWAP_BGR);
 	} else if ((format == MTK_DPI_COLOR_FORMAT_YCBCR_422) ||
 		   (format == MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, true);
 		mtk_dpi_config_csc_enable(dpi, true);
-		mtk_dpi_config_swap_input(dpi, true);
+		if (dpi->conf->swap_input_support)
+			mtk_dpi_config_swap_input(dpi, true);

In this case, we need swap input, but hardware does not support, so just skip config hardware and everything works fine? Should print any error message?

Regards,
CK

Quoted 44 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +2 -1
 		mtk_dpi_config_channel_swap(dpi,
 MTK_DPI_OUT_CHANNEL_SWAP_RGB);
 	} else {
 		mtk_dpi_config_yuv422_enable(dpi, false);
 		mtk_dpi_config_csc_enable(dpi, false);
-		mtk_dpi_config_swap_input(dpi, false);
+		if (dpi->conf->swap_input_support)
+			mtk_dpi_config_swap_input(dpi, false);

mtk_dpi_config_channel_swap(dpi,
MTK_DPI_OUT_CHANNEL_SWAP_RGB);

drivers/gpu/drm/mediatek/mtk_dpi.c +4 -0
 	}
 }
@@ -808,6 +812,7 @@ static const struct mtk_dpi_conf mt8173_conf = {
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -819,6 +824,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -829,6 +835,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -839,6 +846,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
 
#14 lore raw

Re: [PATCH v11 04/12] drm/mediatek: dpi: implement a swap_input toggle in SoC config

Quoted 55 lines · CK Hu

Hi, Bo-Chen:

Quoted 40 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

The hardware design of dp_intf does not support input swap, so we add
a bit of flexibility to support SoCs without swap_input support.

[Bo-Chen: Add modification reason in commit message.]
Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
index 15218c1e8c11..c1438c744120 100644
@@ -126,6 +126,7 @@ struct mtk_dpi_conf {
 	const u32 *output_fmts;
 	u32 num_output_fmts;
 	bool is_ck_de_pol;
+	bool swap_input_support;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -378,18 +379,21 @@ static void

mtk_dpi_config_color_format(struct
mtk_dpi *dpi,

drivers/gpu/drm/mediatek/mtk_dpi.c +2 -1
 	    (format == MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, false);
 		mtk_dpi_config_csc_enable(dpi, true);
-		mtk_dpi_config_swap_input(dpi, false);
+		if (dpi->conf->swap_input_support)
+			mtk_dpi_config_swap_input(dpi, false);
 		mtk_dpi_config_channel_swap(dpi,

MTK_DPI_OUT_CHANNEL_SWAP_BGR);

drivers/gpu/drm/mediatek/mtk_dpi.c static void mtk_dpi_config_color_format(struct mtk_dpi *dpi, · line 390

Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +2 -1
 	} else if ((format == MTK_DPI_COLOR_FORMAT_YCBCR_422) ||
 		   (format == MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, true);
 		mtk_dpi_config_csc_enable(dpi, true);
-		mtk_dpi_config_swap_input(dpi, true);
+		if (dpi->conf->swap_input_support)
+			mtk_dpi_config_swap_input(dpi, true);

In this case, we need swap input, but hardware does not support, so just skip config hardware and everything works fine? Should print any error message?

Quoted 3 lines

Regards,
CK

ok, I will add warning message for this.

Quoted 50 lines
Quoted 48 lines

mtk_dpi_config_channel_swap(dpi,
MTK_DPI_OUT_CHANNEL_SWAP_RGB);

drivers/gpu/drm/mediatek/mtk_dpi.c +2 -1
 	} else {
 		mtk_dpi_config_yuv422_enable(dpi, false);
 		mtk_dpi_config_csc_enable(dpi, false);
-		mtk_dpi_config_swap_input(dpi, false);
+		if (dpi->conf->swap_input_support)
+			mtk_dpi_config_swap_input(dpi, false);
 		mtk_dpi_config_channel_swap(dpi,

MTK_DPI_OUT_CHANNEL_SWAP_RGB);

drivers/gpu/drm/mediatek/mtk_dpi.c +4 -0
 	}
 }
@@ -808,6 +812,7 @@ static const struct mtk_dpi_conf mt8173_conf =
 {
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
@@ -819,6 +824,7 @@ static const struct mtk_dpi_conf mt2701_conf =
 {
 	.output_fmts = mt8173_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
@@ -829,6 +835,7 @@ static const struct mtk_dpi_conf mt8183_conf =
 {
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
@@ -839,6 +846,7 @@ static const struct mtk_dpi_conf mt8192_conf =
 {
 	.output_fmts = mt8183_output_fmts,
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
 	.is_ck_de_pol = true,
+	.swap_input_support = true,
 	.limit = &mtk_dpi_limit,
 };
#15 lore raw

PATCH v11 5/12 drm/mediatek: dpi: move dimension mask to SoC config

In reply to Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add flexibility by moving the dimension mask to the SoC config

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +16 -10
index c1438c744120..0b6d959d878f 100644
@@ -127,6 +127,8 @@ struct mtk_dpi_conf {
 	u32 num_output_fmts;
 	bool is_ck_de_pol;
 	bool swap_input_support;
+	/* Mask used for HWIDTH, HPORCH, VSYNC_WIDTH and VSYNC_PORCH (no shift) */
+	u32 dimension_mask;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -156,30 +158,30 @@ static void mtk_dpi_disable(struct mtk_dpi *dpi)
 static void mtk_dpi_config_hsync(struct mtk_dpi *dpi,
 				 struct mtk_dpi_sync_param *sync)
 {
-	mtk_dpi_mask(dpi, DPI_TGEN_HWIDTH,
-		     sync->sync_width << HPW, HPW_MASK);
-	mtk_dpi_mask(dpi, DPI_TGEN_HPORCH,
-		     sync->back_porch << HBP, HBP_MASK);
+	mtk_dpi_mask(dpi, DPI_TGEN_HWIDTH, sync->sync_width << HPW,
+		     dpi->conf->dimension_mask << HPW);
+	mtk_dpi_mask(dpi, DPI_TGEN_HPORCH, sync->back_porch << HBP,
+		     dpi->conf->dimension_mask << HBP);
 	mtk_dpi_mask(dpi, DPI_TGEN_HPORCH, sync->front_porch << HFP,
-		     HFP_MASK);
+		     dpi->conf->dimension_mask << HFP);
 }
 
 static void mtk_dpi_config_vsync(struct mtk_dpi *dpi,
 				 struct mtk_dpi_sync_param *sync,
 				 u32 width_addr, u32 porch_addr)
 {
-	mtk_dpi_mask(dpi, width_addr,
-		     sync->sync_width << VSYNC_WIDTH_SHIFT,
-		     VSYNC_WIDTH_MASK);
 	mtk_dpi_mask(dpi, width_addr,
 		     sync->shift_half_line << VSYNC_HALF_LINE_SHIFT,
 		     VSYNC_HALF_LINE_MASK);
+	mtk_dpi_mask(dpi, width_addr,
+		     sync->sync_width << VSYNC_WIDTH_SHIFT,
+		     dpi->conf->dimension_mask << VSYNC_WIDTH_SHIFT);
 	mtk_dpi_mask(dpi, porch_addr,
 		     sync->back_porch << VSYNC_BACK_PORCH_SHIFT,
-		     VSYNC_BACK_PORCH_MASK);
+		     dpi->conf->dimension_mask << VSYNC_BACK_PORCH_SHIFT);
 	mtk_dpi_mask(dpi, porch_addr,
 		     sync->front_porch << VSYNC_FRONT_PORCH_SHIFT,
-		     VSYNC_FRONT_PORCH_MASK);
+		     dpi->conf->dimension_mask << VSYNC_FRONT_PORCH_SHIFT);
 }
 
 static void mtk_dpi_config_vsync_lodd(struct mtk_dpi *dpi,
@@ -813,6 +815,7 @@ static const struct mtk_dpi_conf mt8173_conf = {
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
 	.is_ck_de_pol = true,
 	.swap_input_support = true,
+	.dimension_mask = HPW_MASK,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -825,6 +828,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.num_output_fmts = ARRAY_SIZE(mt8173_output_fmts),
 	.is_ck_de_pol = true,
 	.swap_input_support = true,
+	.dimension_mask = HPW_MASK,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -836,6 +840,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
 	.is_ck_de_pol = true,
 	.swap_input_support = true,
+	.dimension_mask = HPW_MASK,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -847,6 +852,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts),
 	.is_ck_de_pol = true,
 	.swap_input_support = true,
+	.dimension_mask = HPW_MASK,
 	.limit = &mtk_dpi_limit,
 };
 
Signature · 1 line
2.18.0
#16 lore raw

PATCH v11 6/12 drm/mediatek: dpi: move hvsize_mask to SoC config

In reply to Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add flexibility by moving the hvsize mask to SoC specific config.

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +10 -2
index 0b6d959d878f..afd81ae307da 100644
@@ -129,6 +129,8 @@ struct mtk_dpi_conf {
 	bool swap_input_support;
 	/* Mask used for HWIDTH, HPORCH, VSYNC_WIDTH and VSYNC_PORCH (no shift) */
 	u32 dimension_mask;
+	/* HSIZE and VSIZE mask (no shift) */
+	u32 hvsize_mask;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -243,8 +245,10 @@ static void mtk_dpi_config_interface(struct mtk_dpi *dpi, bool inter)
 
 static void mtk_dpi_config_fb_size(struct mtk_dpi *dpi, u32 width, u32 height)
 {
-	mtk_dpi_mask(dpi, DPI_SIZE, width << HSIZE, HSIZE_MASK);
-	mtk_dpi_mask(dpi, DPI_SIZE, height << VSIZE, VSIZE_MASK);
+	mtk_dpi_mask(dpi, DPI_SIZE, width << HSIZE,
+		     dpi->conf->hvsize_mask << HSIZE);
+	mtk_dpi_mask(dpi, DPI_SIZE, height << VSIZE,
+		     dpi->conf->hvsize_mask << VSIZE);
 }
 
 static void mtk_dpi_config_channel_limit(struct mtk_dpi *dpi)
@@ -816,6 +820,7 @@ static const struct mtk_dpi_conf mt8173_conf = {
 	.is_ck_de_pol = true,
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
+	.hvsize_mask = HSIZE_MASK,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -829,6 +834,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.is_ck_de_pol = true,
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
+	.hvsize_mask = HSIZE_MASK,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -841,6 +847,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.is_ck_de_pol = true,
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
+	.hvsize_mask = HSIZE_MASK,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -853,6 +860,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.is_ck_de_pol = true,
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
+	.hvsize_mask = HSIZE_MASK,
 	.limit = &mtk_dpi_limit,
 };
 
Signature · 1 line
2.18.0
#17 lore raw

PATCH v11 7/12 drm/mediatek: dpi: move swap_shift to SoC config

In reply to Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add flexibility by moving the swap shift value to SoC specific config.

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +8 -1
index afd81ae307da..2c0e9670c209 100644
@@ -131,6 +131,7 @@ struct mtk_dpi_conf {
 	u32 dimension_mask;
 	/* HSIZE and VSIZE mask (no shift) */
 	u32 hvsize_mask;
+	u32 channel_swap_shift;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -349,7 +350,9 @@ static void mtk_dpi_config_channel_swap(struct mtk_dpi *dpi,
 		break;
 	}
 
-	mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, val << CH_SWAP, CH_SWAP_MASK);
+	mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING,
+		     val << dpi->conf->channel_swap_shift,
+		     CH_SWAP_MASK << dpi->conf->channel_swap_shift);
 }
 
 static void mtk_dpi_config_yuv422_enable(struct mtk_dpi *dpi, bool enable)
@@ -821,6 +824,7 @@ static const struct mtk_dpi_conf mt8173_conf = {
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
+	.channel_swap_shift = CH_SWAP,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -835,6 +839,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
+	.channel_swap_shift = CH_SWAP,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -848,6 +853,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
+	.channel_swap_shift = CH_SWAP,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -861,6 +867,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
+	.channel_swap_shift = CH_SWAP,
 	.limit = &mtk_dpi_limit,
 };
 
Signature · 1 line
2.18.0
Reviewed-by on v11 7/12
#18 lore raw

Re: [PATCH v11 07/12] drm/mediatek: dpi: move swap_shift to SoC config

Hi, Bo-Chen:

Quoted 4 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add flexibility by moving the swap shift value to SoC specific config.

Quoted 69 lines
Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +4 -1
index afd81ae307da..2c0e9670c209 100644
@@ -131,6 +131,7 @@ struct mtk_dpi_conf {
 	u32 dimension_mask;
 	/* HSIZE and VSIZE mask (no shift) */
 	u32 hvsize_mask;
+	u32 channel_swap_shift;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -349,7 +350,9 @@ static void mtk_dpi_config_channel_swap(struct
 mtk_dpi *dpi,
 		break;
 	}
 
-	mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, val << CH_SWAP,
 CH_SWAP_MASK);
+	mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING,
+		     val << dpi->conf->channel_swap_shift,
+		     CH_SWAP_MASK << dpi->conf->channel_swap_shift);
 }

static void mtk_dpi_config_yuv422_enable(struct mtk_dpi *dpi, bool
enable)

drivers/gpu/drm/mediatek/mtk_dpi.c +4 -0
@@ -821,6 +824,7 @@ static const struct mtk_dpi_conf mt8173_conf = {
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
+	.channel_swap_shift = CH_SWAP,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -835,6 +839,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
+	.channel_swap_shift = CH_SWAP,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -848,6 +853,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
+	.channel_swap_shift = CH_SWAP,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -861,6 +867,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.swap_input_support = true,
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
+	.channel_swap_shift = CH_SWAP,
 	.limit = &mtk_dpi_limit,
 };
 
#19 lore raw

PATCH v11 8/12 drm/mediatek: dpi: move the yuv422_en_bit to SoC config

In reply to Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add flexibility by moving the yuv422 en bit to SoC specific config

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +7 -1
index 2c0e9670c209..b709b7776848 100644
@@ -132,6 +132,7 @@ struct mtk_dpi_conf {
 	/* HSIZE and VSIZE mask (no shift) */
 	u32 hvsize_mask;
 	u32 channel_swap_shift;
+	u32 yuv422_en_bit;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -357,7 +358,8 @@ static void mtk_dpi_config_channel_swap(struct mtk_dpi *dpi,
 
 static void mtk_dpi_config_yuv422_enable(struct mtk_dpi *dpi, bool enable)
 {
-	mtk_dpi_mask(dpi, DPI_CON, enable ? YUV422_EN : 0, YUV422_EN);
+	mtk_dpi_mask(dpi, DPI_CON, enable ? dpi->conf->yuv422_en_bit : 0,
+		     dpi->conf->yuv422_en_bit);
 }
 
 static void mtk_dpi_config_csc_enable(struct mtk_dpi *dpi, bool enable)
@@ -825,6 +827,7 @@ static const struct mtk_dpi_conf mt8173_conf = {
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
+	.yuv422_en_bit = YUV422_EN,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -840,6 +843,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
+	.yuv422_en_bit = YUV422_EN,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -854,6 +858,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
+	.yuv422_en_bit = YUV422_EN,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -868,6 +873,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.dimension_mask = HPW_MASK,
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
+	.yuv422_en_bit = YUV422_EN,
 	.limit = &mtk_dpi_limit,
 };
 
Signature · 1 line
2.18.0
#20 lore raw

PATCH v11 9/12 drm/mediatek: dpi: move the csc_enable bit to SoC config

In reply to Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add flexibility by moving the csc_enable bit to SoC specific config

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +7 -1
index b709b7776848..6b8cf648a5b5 100644
@@ -133,6 +133,7 @@ struct mtk_dpi_conf {
 	u32 hvsize_mask;
 	u32 channel_swap_shift;
 	u32 yuv422_en_bit;
+	u32 csc_enable_bit;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -364,7 +365,8 @@ static void mtk_dpi_config_yuv422_enable(struct mtk_dpi *dpi, bool enable)
 
 static void mtk_dpi_config_csc_enable(struct mtk_dpi *dpi, bool enable)
 {
-	mtk_dpi_mask(dpi, DPI_CON, enable ? CSC_ENABLE : 0, CSC_ENABLE);
+	mtk_dpi_mask(dpi, DPI_CON, enable ? dpi->conf->csc_enable_bit : 0,
+		     dpi->conf->csc_enable_bit);
 }
 
 static void mtk_dpi_config_swap_input(struct mtk_dpi *dpi, bool enable)
@@ -828,6 +830,7 @@ static const struct mtk_dpi_conf mt8173_conf = {
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
 	.yuv422_en_bit = YUV422_EN,
+	.csc_enable_bit = CSC_ENABLE,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -844,6 +847,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
 	.yuv422_en_bit = YUV422_EN,
+	.csc_enable_bit = CSC_ENABLE,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -859,6 +863,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
 	.yuv422_en_bit = YUV422_EN,
+	.csc_enable_bit = CSC_ENABLE,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -874,6 +879,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
 	.yuv422_en_bit = YUV422_EN,
+	.csc_enable_bit = CSC_ENABLE,
 	.limit = &mtk_dpi_limit,
 };
 
Signature · 1 line
2.18.0
Reviewed-by on v11 9/12
#21 lore raw

Re: [PATCH v11 09/12] drm/mediatek: dpi: move the csc_enable bit to SoC config

Hi, Bo-Chen:

Quoted 3 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add flexibility by moving the csc_enable bit to SoC specific config

Quoted 69 lines
Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +2 -1
index b709b7776848..6b8cf648a5b5 100644
@@ -133,6 +133,7 @@ struct mtk_dpi_conf {
 	u32 hvsize_mask;
 	u32 channel_swap_shift;
 	u32 yuv422_en_bit;
+	u32 csc_enable_bit;
 	const struct mtk_dpi_yc_limit *limit;
 };
 
@@ -364,7 +365,8 @@ static void mtk_dpi_config_yuv422_enable(struct
 mtk_dpi *dpi, bool enable)
 
 static void mtk_dpi_config_csc_enable(struct mtk_dpi *dpi, bool
 enable)
 {
-	mtk_dpi_mask(dpi, DPI_CON, enable ? CSC_ENABLE : 0,
 CSC_ENABLE);
+	mtk_dpi_mask(dpi, DPI_CON, enable ? dpi->conf->csc_enable_bit :

0,

drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
+		     dpi->conf->csc_enable_bit);
 }
 
 static void mtk_dpi_config_swap_input(struct mtk_dpi *dpi, bool

enable)

drivers/gpu/drm/mediatek/mtk_dpi.c +4 -0
@@ -828,6 +830,7 @@ static const struct mtk_dpi_conf mt8173_conf = {
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
 	.yuv422_en_bit = YUV422_EN,
+	.csc_enable_bit = CSC_ENABLE,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -844,6 +847,7 @@ static const struct mtk_dpi_conf mt2701_conf = {
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
 	.yuv422_en_bit = YUV422_EN,
+	.csc_enable_bit = CSC_ENABLE,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -859,6 +863,7 @@ static const struct mtk_dpi_conf mt8183_conf = {
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
 	.yuv422_en_bit = YUV422_EN,
+	.csc_enable_bit = CSC_ENABLE,
 	.limit = &mtk_dpi_limit,
 };
 
@@ -874,6 +879,7 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.hvsize_mask = HSIZE_MASK,
 	.channel_swap_shift = CH_SWAP,
 	.yuv422_en_bit = YUV422_EN,
+	.csc_enable_bit = CSC_ENABLE,
 	.limit = &mtk_dpi_limit,
 };
 
#22 lore raw

PATCH v11 10/12 drm/mediatek: dpi: Add dpintf support

In reply to Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

dpintf is the displayport interface hardware unit. This unit is similar to dpi and can reuse most of the code.

This patch adds support for mt8195-dpintf to this dpi driver. Main differences are:
- Some features/functional components are not available for dpintf which are now excluded from code execution once is_dpintf is set
- dpintf can and needs to choose between different clockdividers based on the clockspeed. This is done by choosing a different clock parent.
- There are two additional clocks that need to be managed. These are only set for dpintf and will be set to NULL if not supplied. The clk_* calls handle these as normal clocks then.
- Some register contents differ slightly between the two components. To work around this I added register bits/masks with a DPINTF_ prefix and use them where different.

Based on a separate driver for dpintf created by
Jitao shi <[email protected]>.

[Bo-Chen: Modify reviewers' comments.]
---
 drivers/gpu/drm/mediatek/mtk_dpi.c          | 115 ++++++++++++++++++--
 drivers/gpu/drm/mediatek/mtk_dpi_regs.h     |  13 +++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c |   4 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h |   1 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.c      |   3 +
 5 files changed, 126 insertions(+), 10 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +105 -10
index 6b8cf648a5b5..08c8f21b4421 100644
@@ -71,6 +71,7 @@ struct mtk_dpi {
 	void __iomem *regs;
 	struct device *dev;
 	struct clk *engine_clk;
+	struct clk *pll_gate_clk;
 	struct clk *pixel_clk;
 	struct clk *tvd_clk;
 	int irq;
@@ -126,6 +127,7 @@ struct mtk_dpi_conf {
 	const u32 *output_fmts;
 	u32 num_output_fmts;
 	bool is_ck_de_pol;
+	bool is_dpintf;
 	bool swap_input_support;
 	/* Mask used for HWIDTH, HPORCH, VSYNC_WIDTH and VSYNC_PORCH (no shift) */
 	u32 dimension_mask;
@@ -439,6 +441,8 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi)
 	mtk_dpi_disable(dpi);
 	clk_disable_unprepare(dpi->pixel_clk);
 	clk_disable_unprepare(dpi->engine_clk);
+	clk_disable_unprepare(dpi->pll_gate_clk);
+	clk_disable_unprepare(dpi->tvd_clk);
 }
 
 static int mtk_dpi_power_on(struct mtk_dpi *dpi)
@@ -448,10 +452,23 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)
 	if (++dpi->refcount != 1)
 		return 0;
 
+	ret = clk_prepare_enable(dpi->tvd_clk);
+	if (ret) {
+		dev_err(dpi->dev, "Failed to enable tvd pll: %d\n", ret);
+		goto err_refcount;
+	}
+
 	ret = clk_prepare_enable(dpi->engine_clk);
 	if (ret) {
 		dev_err(dpi->dev, "Failed to enable engine clock: %d\n", ret);
-		goto err_refcount;
+		goto err_engine;
+	}
+
+	ret = clk_prepare_enable(dpi->pll_gate_clk);
+	if (ret) {
+		dev_err(dpi->dev,
+			"Failed to enable pll_gate_clk clock: %d\n", ret);
+		goto err_ck_cg;
 	}
 
 	ret = clk_prepare_enable(dpi->pixel_clk);
@@ -467,7 +484,11 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)
 	return 0;
 
 err_pixel:
+	clk_disable_unprepare(dpi->pll_gate_clk);
+err_ck_cg:
 	clk_disable_unprepare(dpi->engine_clk);
+err_engine:
+	clk_disable_unprepare(dpi->tvd_clk);
 err_refcount:
 	dpi->refcount--;
 	return ret;
@@ -498,12 +519,16 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
 	pll_rate = clk_get_rate(dpi->tvd_clk);
 
 	vm.pixelclock = pll_rate / factor;
+
+	if (dpi->conf->is_dpintf)
+		vm.pixelclock /= 4;
+
 	if ((dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_LE) ||
-	    (dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_BE))
+	    (dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_BE)) {
 		clk_set_rate(dpi->pixel_clk, vm.pixelclock * 2);
-	else
+	} else {
 		clk_set_rate(dpi->pixel_clk, vm.pixelclock);
-
+	}
 
 	vm.pixelclock = clk_get_rate(dpi->pixel_clk);
 
@@ -516,9 +541,21 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
 			    MTK_DPI_POLARITY_FALLING : MTK_DPI_POLARITY_RISING;
 	dpi_pol.vsync_pol = vm.flags & DISPLAY_FLAGS_VSYNC_HIGH ?
 			    MTK_DPI_POLARITY_FALLING : MTK_DPI_POLARITY_RISING;
+
 	hsync.sync_width = vm.hsync_len;
 	hsync.back_porch = vm.hback_porch;
 	hsync.front_porch = vm.hfront_porch;
+
+	/*
+	 * For dp_intf, we need to divide everything by 4 because it's
+	 * 4 pixels for one round while dpi is 1 pixel for one round.
+	 */
+	if (dpi->conf->is_dpintf) {
+		hsync.sync_width = vm.hsync_len / 4;
+		hsync.back_porch = vm.hback_porch / 4;
+		hsync.front_porch = vm.hfront_porch / 4;
+	}
+
 	hsync.shift_half_line = false;
 	vsync_lodd.sync_width = vm.vsync_len;
 	vsync_lodd.back_porch = vm.vback_porch;
@@ -560,13 +597,20 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
 	mtk_dpi_config_channel_limit(dpi);
 	mtk_dpi_config_bit_num(dpi, dpi->bit_num);
 	mtk_dpi_config_channel_swap(dpi, dpi->channel_swap);
-	mtk_dpi_config_yc_map(dpi, dpi->yc_map);
 	mtk_dpi_config_color_format(dpi, dpi->color_format);
-	mtk_dpi_config_2n_h_fre(dpi);
-	mtk_dpi_dual_edge(dpi);
-	mtk_dpi_config_disable_edge(dpi);
+	if (dpi->conf->is_dpintf) {
+		mtk_dpi_mask(dpi, DPI_CON, DPINTF_INPUT_2P_EN,
+			     DPINTF_INPUT_2P_EN);
+	} else {
+		mtk_dpi_config_yc_map(dpi, dpi->yc_map);
+		mtk_dpi_config_2n_h_fre(dpi);
+		mtk_dpi_dual_edge(dpi);
+		mtk_dpi_config_disable_edge(dpi);
+	}
 	mtk_dpi_sw_reset(dpi, false);
 
+	mtk_dpi_enable(dpi);
+
 	return 0;
 }
 
@@ -643,7 +687,10 @@ static int mtk_dpi_bridge_atomic_check(struct drm_bridge *bridge,
 	dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS;
 	dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB;
 	dpi->yc_map = MTK_DPI_OUT_YC_MAP_RGB;
-	dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB;
+	if (out_bus_format == MEDIA_BUS_FMT_YUYV8_1X16)
+		dpi->color_format = MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL;
+	else
+		dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB;
 
 	return 0;
 }
@@ -688,7 +735,7 @@ mtk_dpi_bridge_mode_valid(struct drm_bridge *bridge,
 {
 	struct mtk_dpi *dpi = bridge_to_dpi(bridge);
 
-	if (mode->clock > dpi->conf->max_clock_khz)
+	if (dpi->conf->max_clock_khz && mode->clock > dpi->conf->max_clock_khz)
 		return MODE_CLOCK_HIGH;
 
 	return MODE_OK;
@@ -802,6 +849,16 @@ static unsigned int mt8183_calculate_factor(int clock)
 		return 2;
 }
 
+static unsigned int mt8195_dpintf_calculate_factor(int clock)
+{
+	if (clock < 70000)
+		return 4;
+	else if (clock < 200000)
+		return 2;
+	else
+		return 1;
+}
+
 static const u32 mt8173_output_fmts[] = {
 	MEDIA_BUS_FMT_RGB888_1X24,
 };
@@ -811,6 +868,12 @@ static const u32 mt8183_output_fmts[] = {
 	MEDIA_BUS_FMT_RGB888_2X12_BE,
 };
 
+static const u32 mt8195_output_fmts[] = {
+	MEDIA_BUS_FMT_RGB888_1X24,
+	MEDIA_BUS_FMT_YUV8_1X24,
+	MEDIA_BUS_FMT_YUYV8_1X16,
+};
+
 static const struct mtk_dpi_yc_limit mtk_dpi_limit = {
 	.c_bottom = 0x0010,
 	.c_top = 0x0FE0,
@@ -818,6 +881,13 @@ static const struct mtk_dpi_yc_limit mtk_dpi_limit = {
 	.y_top = 0x0FE0,
 };
 
+static const struct mtk_dpi_yc_limit mtk_dpintf_limit = {
+	.c_bottom = 0x0000,
+	.c_top = 0xFFF,
+	.y_bottom = 0x0000,
+	.y_top = 0xFFF,
+};
+
 static const struct mtk_dpi_conf mt8173_conf = {
 	.cal_factor = mt8173_calculate_factor,
 	.reg_h_fre_con = 0xe0,
@@ -883,6 +953,19 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.limit = &mtk_dpi_limit,
 };
 
+static const struct mtk_dpi_conf mt8195_dpintf_conf = {
+	.cal_factor = mt8195_dpintf_calculate_factor,
+	.output_fmts = mt8195_output_fmts,
+	.num_output_fmts = ARRAY_SIZE(mt8195_output_fmts),
+	.is_dpintf = true,
+	.dimension_mask = DPINTF_HPW_MASK,
+	.hvsize_mask = DPINTF_HSIZE_MASK,
+	.channel_swap_shift = DPINTF_CH_SWAP,
+	.yuv422_en_bit = DPINTF_YUV422_EN,
+	.csc_enable_bit = DPINTF_CSC_ENABLE,
+	.limit = &mtk_dpintf_limit,
+};
+
 static int mtk_dpi_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -935,6 +1018,15 @@ static int mtk_dpi_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	dpi->pll_gate_clk = devm_clk_get_optional(dev, "pll_gate");
+	if (IS_ERR(dpi->pll_gate_clk)) {
+		ret = PTR_ERR(dpi->pll_gate_clk);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get dpi ck cg clock: %d\n", ret);
+
+		return ret;
+	}
+
 	dpi->pixel_clk = devm_clk_get(dev, "pixel");
 	if (IS_ERR(dpi->pixel_clk)) {
 		ret = PTR_ERR(dpi->pixel_clk);
@@ -1005,6 +1097,9 @@ static const struct of_device_id mtk_dpi_of_ids[] = {
 	{ .compatible = "mediatek,mt8192-dpi",
 	  .data = &mt8192_conf,
 	},
+	{ .compatible = "mediatek,mt8195-dp_intf",
+	  .data = &mt8195_dpintf_conf,
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, mtk_dpi_of_ids);
drivers/gpu/drm/mediatek/mtk_dpi_regs.h +13 -0
index 3a02fabe1662..f7f0272dbd6a 100644
@@ -40,9 +40,13 @@
 #define FAKE_DE_LEVEN			BIT(21)
 #define FAKE_DE_RODD			BIT(22)
 #define FAKE_DE_REVEN			BIT(23)
+#define DPINTF_YUV422_EN		BIT(24)
+#define DPINTF_CSC_ENABLE		BIT(26)
+#define DPINTF_INPUT_2P_EN		BIT(29)
 
 #define DPI_OUTPUT_SETTING	0x14
 #define CH_SWAP				0
+#define DPINTF_CH_SWAP			1
 #define CH_SWAP_MASK			(0x7 << 0)
 #define SWAP_RGB			0x00
 #define SWAP_GBR			0x01
@@ -80,8 +84,10 @@
 #define DPI_SIZE		0x18
 #define HSIZE				0
 #define HSIZE_MASK			(0x1FFF << 0)
+#define DPINTF_HSIZE_MASK		(0xFFFF << 0)
 #define VSIZE				16
 #define VSIZE_MASK			(0x1FFF << 16)
+#define DPINTF_VSIZE_MASK		(0xFFFF << 16)
 
 #define DPI_DDR_SETTING		0x1C
 #define DDR_EN				BIT(0)
@@ -93,24 +99,30 @@
 #define DPI_TGEN_HWIDTH		0x20
 #define HPW				0
 #define HPW_MASK			(0xFFF << 0)
+#define DPINTF_HPW_MASK			(0xFFFF << 0)
 
 #define DPI_TGEN_HPORCH		0x24
 #define HBP				0
 #define HBP_MASK			(0xFFF << 0)
+#define DPINTF_HBP_MASK			(0xFFFF << 0)
 #define HFP				16
 #define HFP_MASK			(0xFFF << 16)
+#define DPINTF_HFP_MASK			(0xFFFF << 16)
 
 #define DPI_TGEN_VWIDTH		0x28
 #define DPI_TGEN_VPORCH		0x2C
 
 #define VSYNC_WIDTH_SHIFT		0
 #define VSYNC_WIDTH_MASK		(0xFFF << 0)
+#define DPINTF_VSYNC_WIDTH_MASK		(0xFFFF << 0)
 #define VSYNC_HALF_LINE_SHIFT		16
 #define VSYNC_HALF_LINE_MASK		BIT(16)
 #define VSYNC_BACK_PORCH_SHIFT		0
 #define VSYNC_BACK_PORCH_MASK		(0xFFF << 0)
+#define DPINTF_VSYNC_BACK_PORCH_MASK	(0xFFFF << 0)
 #define VSYNC_FRONT_PORCH_SHIFT		16
 #define VSYNC_FRONT_PORCH_MASK		(0xFFF << 16)
+#define DPINTF_VSYNC_FRONT_PORCH_MASK	(0xFFFF << 16)
 
 #define DPI_BG_HCNTL		0x30
 #define BG_RIGHT			(0x1FFF << 0)
@@ -217,4 +229,5 @@
 
 #define EDGE_SEL_EN			BIT(5)
 #define H_FRE_2N			BIT(25)
+
 #endif /* __MTK_DPI_REGS_H */
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +4 -0
index 2aab1e1eda36..5bef085714a1 100644
@@ -427,6 +427,7 @@ static const char * const mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX] = {
 	[MTK_DISP_RDMA] = "rdma",
 	[MTK_DISP_UFOE] = "ufoe",
 	[MTK_DISP_WDMA] = "wdma",
+	[MTK_DP_INTF] = "dp-intf",
 	[MTK_DPI] = "dpi",
 	[MTK_DSI] = "dsi",
 };
@@ -450,6 +451,8 @@ static const struct mtk_ddp_comp_match mtk_ddp_matches[DDP_COMPONENT_DRM_ID_MAX]
 	[DDP_COMPONENT_DRM_OVL_ADAPTOR]	= { MTK_DISP_OVL_ADAPTOR,	0, &ddp_ovl_adaptor },
 	[DDP_COMPONENT_DSC0]		= { MTK_DISP_DSC,		0, &ddp_dsc },
 	[DDP_COMPONENT_DSC1]		= { MTK_DISP_DSC,		1, &ddp_dsc },
+	[DDP_COMPONENT_DP_INTF0]	= { MTK_DP_INTF,		0, &ddp_dpi },
+	[DDP_COMPONENT_DP_INTF1]	= { MTK_DP_INTF,		1, &ddp_dpi },
 	[DDP_COMPONENT_DSI0]		= { MTK_DSI,			0, &ddp_dsi },
 	[DDP_COMPONENT_DSI1]		= { MTK_DSI,			1, &ddp_dsi },
 	[DDP_COMPONENT_DSI2]		= { MTK_DSI,			2, &ddp_dsi },
@@ -575,6 +578,7 @@ int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
 	    type == MTK_DISP_PWM ||
 	    type == MTK_DISP_RDMA ||
 	    type == MTK_DPI ||
+	    type == MTK_DP_INTF ||
 	    type == MTK_DSI)
 		return 0;
 
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +1 -0
index af9a6671f9c4..3084cc4e2830 100644
@@ -38,6 +38,7 @@ enum mtk_ddp_comp_type {
 	MTK_DISP_UFOE,
 	MTK_DISP_WDMA,
 	MTK_DPI,
+	MTK_DP_INTF,
 	MTK_DSI,
 	MTK_DDP_COMP_TYPE_MAX,
 };
drivers/gpu/drm/mediatek/mtk_drm_drv.c +3 -0
index 78e79c8449c8..3b885ad61ac3 100644
@@ -788,6 +788,8 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
 	  .data = (void *)MTK_DPI },
 	{ .compatible = "mediatek,mt8192-dpi",
 	  .data = (void *)MTK_DPI },
+	{ .compatible = "mediatek,mt8195-dp_intf",
+	  .data = (void *)MTK_DP_INTF },
 	{ .compatible = "mediatek,mt2701-dsi",
 	  .data = (void *)MTK_DSI },
 	{ .compatible = "mediatek,mt8173-dsi",
@@ -931,6 +933,7 @@ static int mtk_drm_probe(struct platform_device *pdev)
 		    comp_type == MTK_DISP_OVL_2L ||
 		    comp_type == MTK_DISP_OVL_ADAPTOR ||
 		    comp_type == MTK_DISP_RDMA ||
+		    comp_type == MTK_DP_INTF ||
 		    comp_type == MTK_DPI ||
 		    comp_type == MTK_DSI) {
 			dev_info(dev, "Adding component match for %pOF\n",
Signature · 1 line
2.18.0
#23 lore raw

Re: [PATCH v11 10/12] drm/mediatek: dpi: Add dpintf support

Il 13/06/22 08:48, Bo-Chen Chen ha scritto:

Quoted 38 lines

From: Guillaume Ranquet <[email protected]>

dpintf is the displayport interface hardware unit. This unit is similar to dpi and can reuse most of the code.

This patch adds support for mt8195-dpintf to this dpi driver. Main differences are:
- Some features/functional components are not available for dpintf which are now excluded from code execution once is_dpintf is set
- dpintf can and needs to choose between different clockdividers based on the clockspeed. This is done by choosing a different clock parent.
- There are two additional clocks that need to be managed. These are only set for dpintf and will be set to NULL if not supplied. The clk_* calls handle these as normal clocks then.
- Some register contents differ slightly between the two components. To work around this I added register bits/masks with a DPINTF_ prefix and use them where different.

Based on a separate driver for dpintf created by
Jitao shi <[email protected]>.

[Bo-Chen: Modify reviewers' comments.]
---
  drivers/gpu/drm/mediatek/mtk_dpi.c          | 115 ++++++++++++++++++--
  drivers/gpu/drm/mediatek/mtk_dpi_regs.h     |  13 +++
  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c |   4 +
  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h |   1 +
  drivers/gpu/drm/mediatek/mtk_drm_drv.c      |   3 +
  5 files changed, 126 insertions(+), 10 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
index 6b8cf648a5b5..08c8f21b4421 100644

drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi { · line 74

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -71,6 +71,7 @@ struct mtk_dpi {
  	void __iomem *regs;
  	struct device *dev;
  	struct clk *engine_clk;
+	struct clk *pll_gate_clk;

You don't need this clock in this driver, at all.

pll_gate would be CLK_VDO0_DP_INTF0_DP_INTF (parent = CLK_TOP_EDP);

Currently, you're assigning CLK_TOP_EDP to "pixel", but you can, at this point, simply assign CLK_VDO0_DP_INTF0_DP_INTF to "pixel" instead... as when you call clk_prepare_enable() on it, that'll also take care of enabling its CLK_TOP_EDP parent for you.

You're not doing anything special if not taking care of enabling/disabling it.

Regards,
Angelo

#24 lore raw

Re: [PATCH v11 10/12] drm/mediatek: dpi: Add dpintf support

Quoted 67 lines · AngeloGioacchino Del Regno

Il 13/06/22 08:48, Bo-Chen Chen ha scritto:

Quoted 49 lines

From: Guillaume Ranquet <[email protected]>

dpintf is the displayport interface hardware unit. This unit is similar
to dpi and can reuse most of the code.

This patch adds support for mt8195-dpintf to this dpi driver. Main differences are:
- Some features/functional components are not available for
dpintf
which are now excluded from code execution once is_dpintf is
set
- dpintf can and needs to choose between different clockdividers
based
on the clockspeed. This is done by choosing a different clock
parent.
- There are two additional clocks that need to be managed. These
are
only set for dpintf and will be set to NULL if not supplied.
The
clk_* calls handle these as normal clocks then.
- Some register contents differ slightly between the two
components. To
work around this I added register bits/masks with a DPINTF_
prefix
and use them where different.

Based on a separate driver for dpintf created by Jitao shi <[email protected]>.

[Bo-Chen: Modify reviewers' comments.]
---
  drivers/gpu/drm/mediatek/mtk_dpi.c          | 115
++++++++++++++++++--
  drivers/gpu/drm/mediatek/mtk_dpi_regs.h     |  13 +++
  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c |   4 +
  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h |   1 +
  drivers/gpu/drm/mediatek/mtk_drm_drv.c      |   3 +
  5 files changed, 126 insertions(+), 10 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
index 6b8cf648a5b5..08c8f21b4421 100644

drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi { · line 74

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -71,6 +71,7 @@ struct mtk_dpi {
  	void __iomem *regs;
  	struct device *dev;
  	struct clk *engine_clk;
+	struct clk *pll_gate_clk;

You don't need this clock in this driver, at all.

pll_gate would be CLK_VDO0_DP_INTF0_DP_INTF (parent = CLK_TOP_EDP);

Currently, you're assigning CLK_TOP_EDP to "pixel", but you can, at this point,
simply assign CLK_VDO0_DP_INTF0_DP_INTF to "pixel" instead... as when you call
clk_prepare_enable() on it, that'll also take care of enabling its CLK_TOP_EDP
parent for you.

Quoted 6 lines

You're not doing anything special if not taking care of enabling/disabling it.

Regards,
Angelo

Hello Angelo,

Thanks for advice. I can use your patch[1] to do this and verify ok. I will remove pll_gate_clk in next version.

[1]:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

BRs,
Bo-Chen

#25 lore raw

Re: [PATCH v11 10/12] drm/mediatek: dpi: Add dpintf support

In reply to Bo-Chen Chen

Hi, Bo-Chen:

Quoted 44 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

dpintf is the displayport interface hardware unit. This unit is similar
to dpi and can reuse most of the code.

This patch adds support for mt8195-dpintf to this dpi driver. Main differences are:
- Some features/functional components are not available for dpintf which are now excluded from code execution once is_dpintf is set
- dpintf can and needs to choose between different clockdividers
based
on the clockspeed. This is done by choosing a different clock
parent.
- There are two additional clocks that need to be managed. These are only set for dpintf and will be set to NULL if not supplied. The clk_* calls handle these as normal clocks then.
- Some register contents differ slightly between the two components.
To
work around this I added register bits/masks with a DPINTF_ prefix and use them where different.

Based on a separate driver for dpintf created by Jitao shi <[email protected]>.

[Bo-Chen: Modify reviewers' comments.]
---
 drivers/gpu/drm/mediatek/mtk_dpi.c          | 115
++++++++++++++++++--
 drivers/gpu/drm/mediatek/mtk_dpi_regs.h     |  13 +++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c |   4 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h |   1 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.c      |   3 +
 5 files changed, 126 insertions(+), 10 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
index 6b8cf648a5b5..08c8f21b4421 100644

drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi { · line 74

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -71,6 +71,7 @@ struct mtk_dpi {
 	void __iomem *regs;
 	struct device *dev;
 	struct clk *engine_clk;
+	struct clk *pll_gate_clk;

Separate clock part to an independent patch.

Quoted 64 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
 	struct clk *pixel_clk;
 	struct clk *tvd_clk;
 	int irq;
@@ -126,6 +127,7 @@ struct mtk_dpi_conf {
 	const u32 *output_fmts;
 	u32 num_output_fmts;
 	bool is_ck_de_pol;
+	bool is_dpintf;
 	bool swap_input_support;
 	/* Mask used for HWIDTH, HPORCH, VSYNC_WIDTH and VSYNC_PORCH

(no shift) */

drivers/gpu/drm/mediatek/mtk_dpi.c +2 -0
 	u32 dimension_mask;
@@ -439,6 +441,8 @@ static void mtk_dpi_power_off(struct mtk_dpi
 *dpi)
 	mtk_dpi_disable(dpi);
 	clk_disable_unprepare(dpi->pixel_clk);
 	clk_disable_unprepare(dpi->engine_clk);
+	clk_disable_unprepare(dpi->pll_gate_clk);
+	clk_disable_unprepare(dpi->tvd_clk);
 }
 

static int mtk_dpi_power_on(struct mtk_dpi *dpi)

drivers/gpu/drm/mediatek/mtk_dpi.c +13 -1
@@ -448,10 +452,23 @@ static int mtk_dpi_power_on(struct mtk_dpi
 *dpi)
 	if (++dpi->refcount != 1)
 		return 0;
 
+	ret = clk_prepare_enable(dpi->tvd_clk);
+	if (ret) {
+		dev_err(dpi->dev, "Failed to enable tvd pll: %d\n",
 ret);
+		goto err_refcount;
+	}
+
 	ret = clk_prepare_enable(dpi->engine_clk);
 	if (ret) {
 		dev_err(dpi->dev, "Failed to enable engine clock:
 %d\n", ret);
-		goto err_refcount;
+		goto err_engine;
+	}
+
+	ret = clk_prepare_enable(dpi->pll_gate_clk);
+	if (ret) {
+		dev_err(dpi->dev,
+			"Failed to enable pll_gate_clk clock: %d\n",

ret);

drivers/gpu/drm/mediatek/mtk_dpi.c +5 -0
+		goto err_ck_cg;
 	}
 
 	ret = clk_prepare_enable(dpi->pixel_clk);
@@ -467,7 +484,11 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)
 	return 0;
 
 err_pixel:
+	clk_disable_unprepare(dpi->pll_gate_clk);
+err_ck_cg:
 	clk_disable_unprepare(dpi->engine_clk);
+err_engine:
+	clk_disable_unprepare(dpi->tvd_clk);
 err_refcount:
 	dpi->refcount--;
 	return ret;

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct · line 525

Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +3 -0
@@ -498,12 +519,16 @@ static int mtk_dpi_set_display_mode(struct
 mtk_dpi *dpi,
 	pll_rate = clk_get_rate(dpi->tvd_clk);
 
 	vm.pixelclock = pll_rate / factor;
+
+	if (dpi->conf->is_dpintf)
+		vm.pixelclock /= 4;

Separate this to an independent patch and explain why do this.

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, · line 529

Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +3 -2
+
 	if ((dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_LE) ||
-	    (dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_BE))
+	    (dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_BE)) {
 		clk_set_rate(dpi->pixel_clk, vm.pixelclock * 2);
-	else
+	} else {

This modification is not necessary.

Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -1
 		clk_set_rate(dpi->pixel_clk, vm.pixelclock);
-
+	}
 
 	vm.pixelclock = clk_get_rate(dpi->pixel_clk);

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct · line 547

Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -516,9 +541,21 @@ static int mtk_dpi_set_display_mode(struct
 mtk_dpi *dpi,
 			    MTK_DPI_POLARITY_FALLING :
 MTK_DPI_POLARITY_RISING;
 	dpi_pol.vsync_pol = vm.flags & DISPLAY_FLAGS_VSYNC_HIGH ?
 			    MTK_DPI_POLARITY_FALLING :
 MTK_DPI_POLARITY_RISING;
+

This modification is not necessary.

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, · line 553

Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +6 -0
 	hsync.sync_width = vm.hsync_len;
 	hsync.back_porch = vm.hback_porch;
 	hsync.front_porch = vm.hfront_porch;
+
+	/*
+	 * For dp_intf, we need to divide everything by 4 because it's
+	 * 4 pixels for one round while dpi is 1 pixel for one round.
+	 */
+	if (dpi->conf->is_dpintf) {

I this this should define dpi->conf->round_pixels rather than dpi-

Quoted 11 lines

conf->is_dpintf.

drivers/gpu/drm/mediatek/mtk_dpi.c +5 -0
+		hsync.sync_width = vm.hsync_len / 4;
+		hsync.back_porch = vm.hback_porch / 4;
+		hsync.front_porch = vm.hfront_porch / 4;
+	}
+
 	hsync.shift_half_line = false;
 	vsync_lodd.sync_width = vm.vsync_len;
 	vsync_lodd.back_porch = vm.vback_porch;

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct · line 602

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -4
@@ -560,13 +597,20 @@ static int mtk_dpi_set_display_mode(struct
 mtk_dpi *dpi,
 	mtk_dpi_config_channel_limit(dpi);
 	mtk_dpi_config_bit_num(dpi, dpi->bit_num);
 	mtk_dpi_config_channel_swap(dpi, dpi->channel_swap);
-	mtk_dpi_config_yc_map(dpi, dpi->yc_map);
 	mtk_dpi_config_color_format(dpi, dpi->color_format);
-	mtk_dpi_config_2n_h_fre(dpi);
-	mtk_dpi_dual_edge(dpi);
-	mtk_dpi_config_disable_edge(dpi);
+	if (dpi->conf->is_dpintf) {

Separate this to an independent patch and give a better config name rather than dpi->conf->is_dpintf.

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, · line 612

Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +9 -0
+		mtk_dpi_mask(dpi, DPI_CON, DPINTF_INPUT_2P_EN,
+			     DPINTF_INPUT_2P_EN);
+	} else {
+		mtk_dpi_config_yc_map(dpi, dpi->yc_map);
+		mtk_dpi_config_2n_h_fre(dpi);
+		mtk_dpi_dual_edge(dpi);
+		mtk_dpi_config_disable_edge(dpi);
+	}
 	mtk_dpi_sw_reset(dpi, false);
 
+	mtk_dpi_enable(dpi);

Why do this? If this is necessary, separate this to an independent patch.

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_bridge_atomic_check(struct · line 693

Quoted 13 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +3 -1
+
 	return 0;
 }
@@ -643,7 +687,10 @@ static int mtk_dpi_bridge_atomic_check(struct
 drm_bridge *bridge,
 	dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS;
 	dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB;
 	dpi->yc_map = MTK_DPI_OUT_YC_MAP_RGB;
-	dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB;
+	if (out_bus_format == MEDIA_BUS_FMT_YUYV8_1X16)
+		dpi->color_format =
 MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL;

Separate this to an independent patch.

drivers/gpu/drm/mediatek/mtk_dpi.c mtk_dpi_bridge_mode_valid(struct drm_bridge · line 740

Quoted 13 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +2 -0
+	else
+		dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB;
 
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -1
 	return 0;
 }
@@ -688,7 +735,7 @@ mtk_dpi_bridge_mode_valid(struct drm_bridge
 *bridge,
 {
 	struct mtk_dpi *dpi = bridge_to_dpi(bridge);
 
-	if (mode->clock > dpi->conf->max_clock_khz)
+	if (dpi->conf->max_clock_khz && mode->clock > dpi->conf-
 >max_clock_khz)

Why dp_intf has no max_clock_khz?

Regards,
CK

Quoted 244 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
 		return MODE_CLOCK_HIGH;
drivers/gpu/drm/mediatek/mtk_dpi.c +10 -0
 	return MODE_OK;
@@ -802,6 +849,16 @@ static unsigned int mt8183_calculate_factor(int
 clock)
 		return 2;
 }
 
+static unsigned int mt8195_dpintf_calculate_factor(int clock)
+{
+	if (clock < 70000)
+		return 4;
+	else if (clock < 200000)
+		return 2;
+	else
+		return 1;
+}
+
 static const u32 mt8173_output_fmts[] = {
 	MEDIA_BUS_FMT_RGB888_1X24,

};

drivers/gpu/drm/mediatek/mtk_dpi.c +13 -0
@@ -811,6 +868,12 @@ static const u32 mt8183_output_fmts[] = {
 	MEDIA_BUS_FMT_RGB888_2X12_BE,
 };
 
+static const u32 mt8195_output_fmts[] = {
+	MEDIA_BUS_FMT_RGB888_1X24,
+	MEDIA_BUS_FMT_YUV8_1X24,
+	MEDIA_BUS_FMT_YUYV8_1X16,
+};
+
 static const struct mtk_dpi_yc_limit mtk_dpi_limit = {
 	.c_bottom = 0x0010,
 	.c_top = 0x0FE0,
@@ -818,6 +881,13 @@ static const struct mtk_dpi_yc_limit
 mtk_dpi_limit = {
 	.y_top = 0x0FE0,
 };
 
+static const struct mtk_dpi_yc_limit mtk_dpintf_limit = {
+	.c_bottom = 0x0000,
+	.c_top = 0xFFF,
+	.y_bottom = 0x0000,
+	.y_top = 0xFFF,
+};
+
 static const struct mtk_dpi_conf mt8173_conf = {
 	.cal_factor = mt8173_calculate_factor,
drivers/gpu/drm/mediatek/mtk_dpi.c +22 -0
 	.reg_h_fre_con = 0xe0,
@@ -883,6 +953,19 @@ static const struct mtk_dpi_conf mt8192_conf = {
 	.limit = &mtk_dpi_limit,
 };
 
+static const struct mtk_dpi_conf mt8195_dpintf_conf = {
+	.cal_factor = mt8195_dpintf_calculate_factor,
+	.output_fmts = mt8195_output_fmts,
+	.num_output_fmts = ARRAY_SIZE(mt8195_output_fmts),
+	.is_dpintf = true,
+	.dimension_mask = DPINTF_HPW_MASK,
+	.hvsize_mask = DPINTF_HSIZE_MASK,
+	.channel_swap_shift = DPINTF_CH_SWAP,
+	.yuv422_en_bit = DPINTF_YUV422_EN,
+	.csc_enable_bit = DPINTF_CSC_ENABLE,
+	.limit = &mtk_dpintf_limit,
+};
+
 static int mtk_dpi_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -935,6 +1018,15 @@ static int mtk_dpi_probe(struct platform_device
 *pdev)
 		return ret;
 	}
 
+	dpi->pll_gate_clk = devm_clk_get_optional(dev, "pll_gate");
+	if (IS_ERR(dpi->pll_gate_clk)) {
+		ret = PTR_ERR(dpi->pll_gate_clk);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get dpi ck cg clock:
 %d\n", ret);
+
+		return ret;
+	}
+
 	dpi->pixel_clk = devm_clk_get(dev, "pixel");
drivers/gpu/drm/mediatek/mtk_dpi.c +3 -0
 	if (IS_ERR(dpi->pixel_clk)) {
 		ret = PTR_ERR(dpi->pixel_clk);
@@ -1005,6 +1097,9 @@ static const struct of_device_id
 mtk_dpi_of_ids[] = {
 	{ .compatible = "mediatek,mt8192-dpi",
 	  .data = &mt8192_conf,
 	},
+	{ .compatible = "mediatek,mt8195-dp_intf",
+	  .data = &mt8195_dpintf_conf,
+	},
 	{ },
 };

MODULE_DEVICE_TABLE(of, mtk_dpi_of_ids);

drivers/gpu/drm/mediatek/mtk_dpi_regs.h +13 -0
index 3a02fabe1662..f7f0272dbd6a 100644
@@ -40,9 +40,13 @@
 #define FAKE_DE_LEVEN			BIT(21)
 #define FAKE_DE_RODD			BIT(22)
 #define FAKE_DE_REVEN			BIT(23)
+#define DPINTF_YUV422_EN		BIT(24)
+#define DPINTF_CSC_ENABLE		BIT(26)
+#define DPINTF_INPUT_2P_EN		BIT(29)
 
 #define DPI_OUTPUT_SETTING	0x14
 #define CH_SWAP				0
+#define DPINTF_CH_SWAP			1
 #define CH_SWAP_MASK			(0x7 << 0)
 #define SWAP_RGB			0x00
 #define SWAP_GBR			0x01
@@ -80,8 +84,10 @@
 #define DPI_SIZE		0x18
 #define HSIZE				0
 #define HSIZE_MASK			(0x1FFF << 0)
+#define DPINTF_HSIZE_MASK		(0xFFFF << 0)
 #define VSIZE				16
 #define VSIZE_MASK			(0x1FFF << 16)
+#define DPINTF_VSIZE_MASK		(0xFFFF << 16)
 
 #define DPI_DDR_SETTING		0x1C
 #define DDR_EN				BIT(0)
@@ -93,24 +99,30 @@
 #define DPI_TGEN_HWIDTH		0x20
 #define HPW				0
 #define HPW_MASK			(0xFFF << 0)
+#define DPINTF_HPW_MASK			(0xFFFF << 0)
 
 #define DPI_TGEN_HPORCH		0x24
 #define HBP				0
 #define HBP_MASK			(0xFFF << 0)
+#define DPINTF_HBP_MASK			(0xFFFF << 0)
 #define HFP				16
 #define HFP_MASK			(0xFFF << 16)
+#define DPINTF_HFP_MASK			(0xFFFF << 16)
 
 #define DPI_TGEN_VWIDTH		0x28
 #define DPI_TGEN_VPORCH		0x2C
 
 #define VSYNC_WIDTH_SHIFT		0
 #define VSYNC_WIDTH_MASK		(0xFFF << 0)
+#define DPINTF_VSYNC_WIDTH_MASK		(0xFFFF << 0)
 #define VSYNC_HALF_LINE_SHIFT		16
 #define VSYNC_HALF_LINE_MASK		BIT(16)
 #define VSYNC_BACK_PORCH_SHIFT		0
 #define VSYNC_BACK_PORCH_MASK		(0xFFF << 0)
+#define DPINTF_VSYNC_BACK_PORCH_MASK	(0xFFFF << 0)
 #define VSYNC_FRONT_PORCH_SHIFT		16
 #define VSYNC_FRONT_PORCH_MASK		(0xFFF << 16)
+#define DPINTF_VSYNC_FRONT_PORCH_MASK	(0xFFFF << 16)
 
 #define DPI_BG_HCNTL		0x30
 #define BG_RIGHT			(0x1FFF << 0)
@@ -217,4 +229,5 @@
 
 #define EDGE_SEL_EN			BIT(5)
 #define H_FRE_2N			BIT(25)
+
 #endif /* __MTK_DPI_REGS_H */
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
index 2aab1e1eda36..5bef085714a1 100644
@@ -427,6 +427,7 @@ static const char * const
 mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX] = {
 	[MTK_DISP_RDMA] = "rdma",
 	[MTK_DISP_UFOE] = "ufoe",
 	[MTK_DISP_WDMA] = "wdma",
+	[MTK_DP_INTF] = "dp-intf",
 	[MTK_DPI] = "dpi",
 	[MTK_DSI] = "dsi",

};

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +0 -0
@@ -450,6 +451,8 @@ static const struct mtk_ddp_comp_match

mtk_ddp_matches[DDP_COMPONENT_DRM_ID_MAX]
[DDP_COMPONENT_DRM_OVL_ADAPTOR] = { MTK_DISP_OVL_ADAPTOR,
0, &ddp_ovl_adaptor },
[DDP_COMPONENT_DSC0] = { MTK_DISP_DSC,
0, &ddp_dsc },
[DDP_COMPONENT_DSC1] = { MTK_DISP_DSC,
1, &ddp_dsc },

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
+	[DDP_COMPONENT_DP_INTF0]	= { MTK_DP_INTF,		0,

&ddp_dpi },

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
+	[DDP_COMPONENT_DP_INTF1]	= { MTK_DP_INTF,		1,

&ddp_dpi },
[DDP_COMPONENT_DSI0] = { MTK_DSI,
0, &ddp_dsi },
[DDP_COMPONENT_DSI1] = { MTK_DSI,
1, &ddp_dsi },
[DDP_COMPONENT_DSI2] = { MTK_DSI,
2, &ddp_dsi },

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
@@ -575,6 +578,7 @@ int mtk_ddp_comp_init(struct device_node *node,
 struct mtk_ddp_comp *comp,
 	    type == MTK_DISP_PWM ||
 	    type == MTK_DISP_RDMA ||
 	    type == MTK_DPI ||
+	    type == MTK_DP_INTF ||
 	    type == MTK_DSI)
 		return 0;
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +1 -0
index af9a6671f9c4..3084cc4e2830 100644
@@ -38,6 +38,7 @@ enum mtk_ddp_comp_type {
 	MTK_DISP_UFOE,
 	MTK_DISP_WDMA,
 	MTK_DPI,
+	MTK_DP_INTF,
 	MTK_DSI,
 	MTK_DDP_COMP_TYPE_MAX,
 };
drivers/gpu/drm/mediatek/mtk_drm_drv.c +2 -0
index 78e79c8449c8..3b885ad61ac3 100644
@@ -788,6 +788,8 @@ static const struct of_device_id
 mtk_ddp_comp_dt_ids[] = {
 	  .data = (void *)MTK_DPI },
 	{ .compatible = "mediatek,mt8192-dpi",
 	  .data = (void *)MTK_DPI },
+	{ .compatible = "mediatek,mt8195-dp_intf",
+	  .data = (void *)MTK_DP_INTF },
 	{ .compatible = "mediatek,mt2701-dsi",
 	  .data = (void *)MTK_DSI },
drivers/gpu/drm/mediatek/mtk_drm_drv.c +1 -0
 	{ .compatible = "mediatek,mt8173-dsi",
@@ -931,6 +933,7 @@ static int mtk_drm_probe(struct platform_device
 *pdev)
 		    comp_type == MTK_DISP_OVL_2L ||
 		    comp_type == MTK_DISP_OVL_ADAPTOR ||
 		    comp_type == MTK_DISP_RDMA ||
+		    comp_type == MTK_DP_INTF ||
 		    comp_type == MTK_DPI ||
 		    comp_type == MTK_DSI) {

dev_info(dev, "Adding component match for
%pOF\n",

#26 lore raw

Re: [PATCH v11 10/12] drm/mediatek: dpi: Add dpintf support

Quoted 44 lines · CK Hu

Hi, Bo-Chen:

Quoted 41 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

dpintf is the displayport interface hardware unit. This unit is similar
to dpi and can reuse most of the code.

This patch adds support for mt8195-dpintf to this dpi driver. Main differences are:
- Some features/functional components are not available for dpintf which are now excluded from code execution once is_dpintf is set
- dpintf can and needs to choose between different clockdividers
based
on the clockspeed. This is done by choosing a different clock
parent.
- There are two additional clocks that need to be managed. These
are
only set for dpintf and will be set to NULL if not supplied. The clk_* calls handle these as normal clocks then.
- Some register contents differ slightly between the two
components.
To
work around this I added register bits/masks with a DPINTF_
prefix
and use them where different.

Based on a separate driver for dpintf created by Jitao shi <[email protected]>.

[Bo-Chen: Modify reviewers' comments.]
---
 drivers/gpu/drm/mediatek/mtk_dpi.c          | 115
++++++++++++++++++--
 drivers/gpu/drm/mediatek/mtk_dpi_regs.h     |  13 +++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c |   4 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h |   1 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.c      |   3 +
 5 files changed, 126 insertions(+), 10 deletions(-)
Quoted 13 lines

drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi { · line 74

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
index 6b8cf648a5b5..08c8f21b4421 100644
@@ -71,6 +71,7 @@ struct mtk_dpi {
 	void __iomem *regs;
 	struct device *dev;
 	struct clk *engine_clk;
+	struct clk *pll_gate_clk;

Separate clock part to an independent patch.

Hello CK,

as previous reply, I will drop this clock.

Quoted 68 lines
Quoted 68 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
 	struct clk *pixel_clk;
 	struct clk *tvd_clk;
 	int irq;
@@ -126,6 +127,7 @@ struct mtk_dpi_conf {
 	const u32 *output_fmts;
 	u32 num_output_fmts;
 	bool is_ck_de_pol;
+	bool is_dpintf;
 	bool swap_input_support;
 	/* Mask used for HWIDTH, HPORCH, VSYNC_WIDTH and VSYNC_PORCH

(no shift) */

drivers/gpu/drm/mediatek/mtk_dpi.c +2 -0
 	u32 dimension_mask;
@@ -439,6 +441,8 @@ static void mtk_dpi_power_off(struct mtk_dpi
 *dpi)
 	mtk_dpi_disable(dpi);
 	clk_disable_unprepare(dpi->pixel_clk);
 	clk_disable_unprepare(dpi->engine_clk);
+	clk_disable_unprepare(dpi->pll_gate_clk);
+	clk_disable_unprepare(dpi->tvd_clk);
 }
 

static int mtk_dpi_power_on(struct mtk_dpi *dpi)

drivers/gpu/drm/mediatek/mtk_dpi.c +13 -1
@@ -448,10 +452,23 @@ static int mtk_dpi_power_on(struct mtk_dpi
 *dpi)
 	if (++dpi->refcount != 1)
 		return 0;
 
+	ret = clk_prepare_enable(dpi->tvd_clk);
+	if (ret) {
+		dev_err(dpi->dev, "Failed to enable tvd pll: %d\n",
 ret);
+		goto err_refcount;
+	}
+
 	ret = clk_prepare_enable(dpi->engine_clk);
 	if (ret) {
 		dev_err(dpi->dev, "Failed to enable engine clock:
 %d\n", ret);
-		goto err_refcount;
+		goto err_engine;
+	}
+
+	ret = clk_prepare_enable(dpi->pll_gate_clk);
+	if (ret) {
+		dev_err(dpi->dev,
+			"Failed to enable pll_gate_clk clock: %d\n",

ret);

drivers/gpu/drm/mediatek/mtk_dpi.c +5 -0
+		goto err_ck_cg;
 	}
 
 	ret = clk_prepare_enable(dpi->pixel_clk);
@@ -467,7 +484,11 @@ static int mtk_dpi_power_on(struct mtk_dpi
 *dpi)
 	return 0;
 
 err_pixel:
+	clk_disable_unprepare(dpi->pll_gate_clk);
+err_ck_cg:
 	clk_disable_unprepare(dpi->engine_clk);
+err_engine:
+	clk_disable_unprepare(dpi->tvd_clk);
 err_refcount:
 	dpi->refcount--;
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
 	return ret;
@@ -498,12 +519,16 @@ static int mtk_dpi_set_display_mode(struct
 mtk_dpi *dpi,
 	pll_rate = clk_get_rate(dpi->tvd_clk);
 
Quoted 7 lines

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, · line 524

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +3 -0
 	vm.pixelclock = pll_rate / factor;
+
+	if (dpi->conf->is_dpintf)
+		vm.pixelclock /= 4;

Separate this to an independent patch and explain why do this.

This patch is for support dpintf, It think it should be placed in this patch. I will add comment for this.
/*
* For dp_intf, we need to divide clock by 4 because it's
* 4 pixels for one round while dpi is 1 pixel for one round. */

Quoted 10 lines

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, · line 529

Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +3 -2
+
 	if ((dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_LE) ||
-	    (dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_BE))
+	    (dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_BE)) {
 		clk_set_rate(dpi->pixel_clk, vm.pixelclock * 2);
-	else
+	} else {

This modification is not necessary.

ok.

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -1
 		clk_set_rate(dpi->pixel_clk, vm.pixelclock);
-
+	}
 
 	vm.pixelclock = clk_get_rate(dpi->pixel_clk);
Quoted 11 lines

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct · line 547

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -516,9 +541,21 @@ static int mtk_dpi_set_display_mode(struct
 mtk_dpi *dpi,
 			    MTK_DPI_POLARITY_FALLING :
 MTK_DPI_POLARITY_RISING;
 	dpi_pol.vsync_pol = vm.flags & DISPLAY_FLAGS_VSYNC_HIGH ?
 			    MTK_DPI_POLARITY_FALLING :
 MTK_DPI_POLARITY_RISING;
+

This modification is not necessary.

ok.

Quoted 11 lines

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, · line 553

Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +6 -0
 	hsync.sync_width = vm.hsync_len;
 	hsync.back_porch = vm.hback_porch;
 	hsync.front_porch = vm.hfront_porch;
+
+	/*
+	 * For dp_intf, we need to divide everything by 4 because it's
+	 * 4 pixels for one round while dpi is 1 pixel for one round.
+	 */
+	if (dpi->conf->is_dpintf) {

I this this should define dpi->conf->round_pixels rather than dpi-

Quoted 6 lines

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, · line 558

Quoted 6 lines

conf->is_dpintf.

drivers/gpu/drm/mediatek/mtk_dpi.c +5 -0
+		hsync.sync_width = vm.hsync_len / 4;
+		hsync.back_porch = vm.hback_porch / 4;
+		hsync.front_porch = vm.hfront_porch / 4;
+	}
+

I think is_dpintf is ok, it just for dpintf.

Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -1
 	hsync.shift_half_line = false;
 	vsync_lodd.sync_width = vm.vsync_len;
 	vsync_lodd.back_porch = vm.vback_porch;
@@ -560,13 +597,20 @@ static int mtk_dpi_set_display_mode(struct
 mtk_dpi *dpi,
 	mtk_dpi_config_channel_limit(dpi);
 	mtk_dpi_config_bit_num(dpi, dpi->bit_num);
 	mtk_dpi_config_channel_swap(dpi, dpi->channel_swap);
-	mtk_dpi_config_yc_map(dpi, dpi->yc_map);
Quoted 9 lines

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, · line 601

Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -3
 	mtk_dpi_config_color_format(dpi, dpi->color_format);
-	mtk_dpi_config_2n_h_fre(dpi);
-	mtk_dpi_dual_edge(dpi);
-	mtk_dpi_config_disable_edge(dpi);
+	if (dpi->conf->is_dpintf) {

Separate this to an independent patch and give a better config name rather than dpi->conf->is_dpintf.

This patch is for dpintf. I think it's better to remain in this patch.

Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +8 -0
+		mtk_dpi_mask(dpi, DPI_CON, DPINTF_INPUT_2P_EN,
+			     DPINTF_INPUT_2P_EN);
+	} else {
+		mtk_dpi_config_yc_map(dpi, dpi->yc_map);
+		mtk_dpi_config_2n_h_fre(dpi);
+		mtk_dpi_dual_edge(dpi);
+		mtk_dpi_config_disable_edge(dpi);
+	}
 	mtk_dpi_sw_reset(dpi, false);
 
Quoted 5 lines

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, · line 612

Quoted 1 line
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
+	mtk_dpi_enable(dpi);

Why do this? If this is necessary, separate this to an independent patch.

Yes, no need to do this.
I will drop this.

Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
+
 	return 0;
 }
Quoted 12 lines

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_bridge_atomic_check(struct · line 693

Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +2 -1
@@ -643,7 +687,10 @@ static int mtk_dpi_bridge_atomic_check(struct
 drm_bridge *bridge,
 	dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS;
 	dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB;
 	dpi->yc_map = MTK_DPI_OUT_YC_MAP_RGB;
-	dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB;
+	if (out_bus_format == MEDIA_BUS_FMT_YUYV8_1X16)
+		dpi->color_format =
 MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL;

Separate this to an independent patch.

ok

Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +2 -0
+	else
+		dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB;
 
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
 	return 0;
 }
@@ -688,7 +735,7 @@ mtk_dpi_bridge_mode_valid(struct drm_bridge
 *bridge,
 {
 	struct mtk_dpi *dpi = bridge_to_dpi(bridge);
 
Quoted 6 lines

drivers/gpu/drm/mediatek/mtk_dpi.c mtk_dpi_bridge_mode_valid(struct drm_bridge · line 740

Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -1
-	if (mode->clock > dpi->conf->max_clock_khz)
+	if (dpi->conf->max_clock_khz && mode->clock > dpi->conf-
 > max_clock_khz)

Why dp_intf has no max_clock_khz?

I will add max_clock_khz to 600MHz for dpintf

Quoted 252 lines

Regards,
CK

Quoted 247 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
 		return MODE_CLOCK_HIGH;
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
 	return MODE_OK;
@@ -802,6 +849,16 @@ static unsigned int

mt8183_calculate_factor(int
clock)

drivers/gpu/drm/mediatek/mtk_dpi.c +23 -0
 		return 2;
 }
 
+static unsigned int mt8195_dpintf_calculate_factor(int clock)
+{
+	if (clock < 70000)
+		return 4;
+	else if (clock < 200000)
+		return 2;
+	else
+		return 1;
+}
+
 static const u32 mt8173_output_fmts[] = {
 	MEDIA_BUS_FMT_RGB888_1X24,
 };
@@ -811,6 +868,12 @@ static const u32 mt8183_output_fmts[] = {
 	MEDIA_BUS_FMT_RGB888_2X12_BE,
 };
 
+static const u32 mt8195_output_fmts[] = {
+	MEDIA_BUS_FMT_RGB888_1X24,
+	MEDIA_BUS_FMT_YUV8_1X24,
+	MEDIA_BUS_FMT_YUYV8_1X16,
+};
+
 static const struct mtk_dpi_yc_limit mtk_dpi_limit = {
 	.c_bottom = 0x0010,
 	.c_top = 0x0FE0,
@@ -818,6 +881,13 @@ static const struct mtk_dpi_yc_limit
 mtk_dpi_limit = {
 	.y_top = 0x0FE0,
 };
 
+static const struct mtk_dpi_yc_limit mtk_dpintf_limit = {
+	.c_bottom = 0x0000,
+	.c_top = 0xFFF,
+	.y_bottom = 0x0000,
+	.y_top = 0xFFF,
+};
+
 static const struct mtk_dpi_conf mt8173_conf = {
 	.cal_factor = mt8173_calculate_factor,
drivers/gpu/drm/mediatek/mtk_dpi.c +13 -0
 	.reg_h_fre_con = 0xe0,
@@ -883,6 +953,19 @@ static const struct mtk_dpi_conf mt8192_conf =
 {
 	.limit = &mtk_dpi_limit,
 };
 
+static const struct mtk_dpi_conf mt8195_dpintf_conf = {
+	.cal_factor = mt8195_dpintf_calculate_factor,
+	.output_fmts = mt8195_output_fmts,
+	.num_output_fmts = ARRAY_SIZE(mt8195_output_fmts),
+	.is_dpintf = true,
+	.dimension_mask = DPINTF_HPW_MASK,
+	.hvsize_mask = DPINTF_HSIZE_MASK,
+	.channel_swap_shift = DPINTF_CH_SWAP,
+	.yuv422_en_bit = DPINTF_YUV422_EN,
+	.csc_enable_bit = DPINTF_CSC_ENABLE,
+	.limit = &mtk_dpintf_limit,
+};
+
 static int mtk_dpi_probe(struct platform_device *pdev)
 {
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
 	struct device *dev = &pdev->dev;
@@ -935,6 +1018,15 @@ static int mtk_dpi_probe(struct

platform_device
*pdev)

drivers/gpu/drm/mediatek/mtk_dpi.c +5 -0
 		return ret;
 	}
 
+	dpi->pll_gate_clk = devm_clk_get_optional(dev, "pll_gate");
+	if (IS_ERR(dpi->pll_gate_clk)) {
+		ret = PTR_ERR(dpi->pll_gate_clk);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get dpi ck cg clock:

%d\n", ret);

drivers/gpu/drm/mediatek/mtk_dpi.c +7 -0
+
+		return ret;
+	}
+
 	dpi->pixel_clk = devm_clk_get(dev, "pixel");
 	if (IS_ERR(dpi->pixel_clk)) {
 		ret = PTR_ERR(dpi->pixel_clk);
@@ -1005,6 +1097,9 @@ static const struct of_device_id
 mtk_dpi_of_ids[] = {
 	{ .compatible = "mediatek,mt8192-dpi",
 	  .data = &mt8192_conf,
 	},
+	{ .compatible = "mediatek,mt8195-dp_intf",
+	  .data = &mt8195_dpintf_conf,
+	},
 	{ },
 };

MODULE_DEVICE_TABLE(of, mtk_dpi_of_ids);

drivers/gpu/drm/mediatek/mtk_dpi_regs.h +13 -0
index 3a02fabe1662..f7f0272dbd6a 100644
@@ -40,9 +40,13 @@
 #define FAKE_DE_LEVEN			BIT(21)
 #define FAKE_DE_RODD			BIT(22)
 #define FAKE_DE_REVEN			BIT(23)
+#define DPINTF_YUV422_EN		BIT(24)
+#define DPINTF_CSC_ENABLE		BIT(26)
+#define DPINTF_INPUT_2P_EN		BIT(29)
 
 #define DPI_OUTPUT_SETTING	0x14
 #define CH_SWAP				0
+#define DPINTF_CH_SWAP			1
 #define CH_SWAP_MASK			(0x7 << 0)
 #define SWAP_RGB			0x00
 #define SWAP_GBR			0x01
@@ -80,8 +84,10 @@
 #define DPI_SIZE		0x18
 #define HSIZE				0
 #define HSIZE_MASK			(0x1FFF << 0)
+#define DPINTF_HSIZE_MASK		(0xFFFF << 0)
 #define VSIZE				16
 #define VSIZE_MASK			(0x1FFF << 16)
+#define DPINTF_VSIZE_MASK		(0xFFFF << 16)
 
 #define DPI_DDR_SETTING		0x1C
 #define DDR_EN				BIT(0)
@@ -93,24 +99,30 @@
 #define DPI_TGEN_HWIDTH		0x20
 #define HPW				0
 #define HPW_MASK			(0xFFF << 0)
+#define DPINTF_HPW_MASK			(0xFFFF << 0)
 
 #define DPI_TGEN_HPORCH		0x24
 #define HBP				0
 #define HBP_MASK			(0xFFF << 0)
+#define DPINTF_HBP_MASK			(0xFFFF << 0)
 #define HFP				16
 #define HFP_MASK			(0xFFF << 16)
+#define DPINTF_HFP_MASK			(0xFFFF << 16)
 
 #define DPI_TGEN_VWIDTH		0x28
 #define DPI_TGEN_VPORCH		0x2C
 
 #define VSYNC_WIDTH_SHIFT		0
 #define VSYNC_WIDTH_MASK		(0xFFF << 0)
+#define DPINTF_VSYNC_WIDTH_MASK		(0xFFFF << 0)
 #define VSYNC_HALF_LINE_SHIFT		16
 #define VSYNC_HALF_LINE_MASK		BIT(16)
 #define VSYNC_BACK_PORCH_SHIFT		0
 #define VSYNC_BACK_PORCH_MASK		(0xFFF << 0)
+#define DPINTF_VSYNC_BACK_PORCH_MASK	(0xFFFF << 0)
 #define VSYNC_FRONT_PORCH_SHIFT		16
 #define VSYNC_FRONT_PORCH_MASK		(0xFFF << 16)
+#define DPINTF_VSYNC_FRONT_PORCH_MASK	(0xFFFF << 16)
 
 #define DPI_BG_HCNTL		0x30
 #define BG_RIGHT			(0x1FFF << 0)
@@ -217,4 +229,5 @@
 
 #define EDGE_SEL_EN			BIT(5)
 #define H_FRE_2N			BIT(25)
+
 #endif /* __MTK_DPI_REGS_H */
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
index 2aab1e1eda36..5bef085714a1 100644
@@ -427,6 +427,7 @@ static const char * const
 mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX] = {
 	[MTK_DISP_RDMA] = "rdma",
 	[MTK_DISP_UFOE] = "ufoe",
 	[MTK_DISP_WDMA] = "wdma",
+	[MTK_DP_INTF] = "dp-intf",
 	[MTK_DPI] = "dpi",
 	[MTK_DSI] = "dsi",

};

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +0 -0
@@ -450,6 +451,8 @@ static const struct mtk_ddp_comp_match

mtk_ddp_matches[DDP_COMPONENT_DRM_ID_MAX]
[DDP_COMPONENT_DRM_OVL_ADAPTOR] = { MTK_DISP_OVL_ADAPTOR,
0, &ddp_ovl_adaptor },
[DDP_COMPONENT_DSC0] = { MTK_DISP_DSC,
0, &ddp_dsc },
[DDP_COMPONENT_DSC1] = { MTK_DISP_DSC,
1, &ddp_dsc },

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
+	[DDP_COMPONENT_DP_INTF0]	= { MTK_DP_INTF,		0,

&ddp_dpi },

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
+	[DDP_COMPONENT_DP_INTF1]	= { MTK_DP_INTF,		1,

&ddp_dpi },
[DDP_COMPONENT_DSI0] = { MTK_DSI,
0, &ddp_dsi },
[DDP_COMPONENT_DSI1] = { MTK_DSI,
1, &ddp_dsi },
[DDP_COMPONENT_DSI2] = { MTK_DSI,
2, &ddp_dsi },

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
@@ -575,6 +578,7 @@ int mtk_ddp_comp_init(struct device_node *node,
 struct mtk_ddp_comp *comp,
 	    type == MTK_DISP_PWM ||
 	    type == MTK_DISP_RDMA ||
 	    type == MTK_DPI ||
+	    type == MTK_DP_INTF ||
 	    type == MTK_DSI)
 		return 0;
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +1 -0
index af9a6671f9c4..3084cc4e2830 100644
@@ -38,6 +38,7 @@ enum mtk_ddp_comp_type {
 	MTK_DISP_UFOE,
 	MTK_DISP_WDMA,
 	MTK_DPI,
+	MTK_DP_INTF,
 	MTK_DSI,
 	MTK_DDP_COMP_TYPE_MAX,
 };
drivers/gpu/drm/mediatek/mtk_drm_drv.c +2 -0
index 78e79c8449c8..3b885ad61ac3 100644
@@ -788,6 +788,8 @@ static const struct of_device_id
 mtk_ddp_comp_dt_ids[] = {
 	  .data = (void *)MTK_DPI },
 	{ .compatible = "mediatek,mt8192-dpi",
 	  .data = (void *)MTK_DPI },
+	{ .compatible = "mediatek,mt8195-dp_intf",
+	  .data = (void *)MTK_DP_INTF },
 	{ .compatible = "mediatek,mt2701-dsi",
 	  .data = (void *)MTK_DSI },
drivers/gpu/drm/mediatek/mtk_drm_drv.c +1 -0
 	{ .compatible = "mediatek,mt8173-dsi",
@@ -931,6 +933,7 @@ static int mtk_drm_probe(struct platform_device
 *pdev)
 		    comp_type == MTK_DISP_OVL_2L ||
 		    comp_type == MTK_DISP_OVL_ADAPTOR ||
 		    comp_type == MTK_DISP_RDMA ||
+		    comp_type == MTK_DP_INTF ||
 		    comp_type == MTK_DPI ||
 		    comp_type == MTK_DSI) {

dev_info(dev, "Adding component match for
%pOF\n",

#27 lore raw

PATCH v11 11/12 drm/mediatek: dpi: Only enable dpi after the bridge is enabled

In reply to Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Enabling the dpi too early causes glitches on screen.

Move the call to mtk_dpi_enable() at the end of the bridge_enable callback to ensure everything is setup properly before enabling dpi.

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -1
index 08c8f21b4421..9668bd5dd14a 100644
@@ -480,7 +480,6 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)
 	if (dpi->pinctrl && dpi->pins_dpi)
 		pinctrl_select_state(dpi->pinctrl, dpi->pins_dpi);
 
-	mtk_dpi_enable(dpi);
 	return 0;
 
 err_pixel:
@@ -726,6 +725,7 @@ static void mtk_dpi_bridge_enable(struct drm_bridge *bridge)
 
 	mtk_dpi_power_on(dpi);
 	mtk_dpi_set_display_mode(dpi, &dpi->mode);
+	mtk_dpi_enable(dpi);
 }
 
 static enum drm_mode_status
Signature · 1 line
2.18.0
#28 lore raw

Re: [PATCH v11 11/12] drm/mediatek: dpi: Only enable dpi after the bridge is enabled

Hi, Bo-Chen:

Quoted 6 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Enabling the dpi too early causes glitches on screen.

Move the call to mtk_dpi_enable() at the end of the bridge_enable callback to ensure everything is setup properly before enabling dpi.

This seems a bug fix, so add Fixes tag on this patch.

Regards,
CK

Quoted 29 lines
---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -1
index 08c8f21b4421..9668bd5dd14a 100644
@@ -480,7 +480,6 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)
 	if (dpi->pinctrl && dpi->pins_dpi)
 		pinctrl_select_state(dpi->pinctrl, dpi->pins_dpi);
 
-	mtk_dpi_enable(dpi);
 	return 0;
 
 err_pixel:
@@ -726,6 +725,7 @@ static void mtk_dpi_bridge_enable(struct
 drm_bridge *bridge)
 
 	mtk_dpi_power_on(dpi);
 	mtk_dpi_set_display_mode(dpi, &dpi->mode);
+	mtk_dpi_enable(dpi);
 }
 

static enum drm_mode_status

#29 lore raw

Re: [PATCH v11 11/12] drm/mediatek: dpi: Only enable dpi after the bridge is enabled

Quoted 7 lines · CK Hu

Hi, Bo-Chen:

Quoted 4 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Enabling the dpi too early causes glitches on screen.

Quoted 9 lines
Quoted 3 lines

Move the call to mtk_dpi_enable() at the end of the bridge_enable callback to ensure everything is setup properly before enabling dpi.

This seems a bug fix, so add Fixes tag on this patch.

Regards,
CK

ok, I will do this using this patch:
f89c696e7f635487481eee0d196ab49730ce8664

Quoted 32 lines
Quoted 30 lines
---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -1
index 08c8f21b4421..9668bd5dd14a 100644
@@ -480,7 +480,6 @@ static int mtk_dpi_power_on(struct mtk_dpi
 *dpi)
 	if (dpi->pinctrl && dpi->pins_dpi)
 		pinctrl_select_state(dpi->pinctrl, dpi->pins_dpi);
 
-	mtk_dpi_enable(dpi);
 	return 0;
 

err_pixel:

drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -726,6 +725,7 @@ static void mtk_dpi_bridge_enable(struct
 drm_bridge *bridge)
 
 	mtk_dpi_power_on(dpi);
 	mtk_dpi_set_display_mode(dpi, &dpi->mode);
+	mtk_dpi_enable(dpi);
 }
 

static enum drm_mode_status

#30 lore raw

PATCH v11 12/12 drm/mediatek: dpi: Add matrix_sel helper

In reply to Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add a mtk_dpi_matrix_sel() helper to update the DPI_MATRIX_SET register depending on the color format.

---
 drivers/gpu/drm/mediatek/mtk_dpi.c      | 21 +++++++++++++++++++++
 drivers/gpu/drm/mediatek/mtk_dpi_regs.h |  3 +++
 2 files changed, 24 insertions(+)
drivers/gpu/drm/mediatek/mtk_dpi.c +21 -0
index 9668bd5dd14a..dc355a512963 100644
@@ -387,6 +387,25 @@ static void mtk_dpi_config_disable_edge(struct mtk_dpi *dpi)
 		mtk_dpi_mask(dpi, dpi->conf->reg_h_fre_con, 0, EDGE_SEL_EN);
 }
 
+static void mtk_dpi_matrix_sel(struct mtk_dpi *dpi, enum mtk_dpi_out_color_format format)
+{
+	u32 matrix_sel = 0;
+
+	switch (format) {
+	case MTK_DPI_COLOR_FORMAT_YCBCR_422:
+	case MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL:
+	case MTK_DPI_COLOR_FORMAT_YCBCR_444:
+	case MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL:
+	case MTK_DPI_COLOR_FORMAT_XV_YCC:
+		if (dpi->mode.hdisplay <= 720)
+			matrix_sel = 0x2;
+		break;
+	default:
+		break;
+	}
+	mtk_dpi_mask(dpi, DPI_MATRIX_SET, matrix_sel, INT_MATRIX_SEL_MASK);
+}
+
 static void mtk_dpi_config_color_format(struct mtk_dpi *dpi,
 					enum mtk_dpi_out_color_format format)
 {
@@ -394,6 +413,7 @@ static void mtk_dpi_config_color_format(struct mtk_dpi *dpi,
 	    (format == MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, false);
 		mtk_dpi_config_csc_enable(dpi, true);
+		mtk_dpi_matrix_sel(dpi, format);
 		if (dpi->conf->swap_input_support)
 			mtk_dpi_config_swap_input(dpi, false);
 		mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_BGR);
@@ -401,6 +421,7 @@ static void mtk_dpi_config_color_format(struct mtk_dpi *dpi,
 		   (format == MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, true);
 		mtk_dpi_config_csc_enable(dpi, true);
+		mtk_dpi_matrix_sel(dpi, format);
 		if (dpi->conf->swap_input_support)
 			mtk_dpi_config_swap_input(dpi, true);
 		mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_RGB);
drivers/gpu/drm/mediatek/mtk_dpi_regs.h +3 -0
index f7f0272dbd6a..96c117202d0d 100644
@@ -230,4 +230,7 @@
 #define EDGE_SEL_EN			BIT(5)
 #define H_FRE_2N			BIT(25)
 
+#define DPI_MATRIX_SET		0xB4
+#define INT_MATRIX_SEL_MASK	(0x1F << 0)
+
 #endif /* __MTK_DPI_REGS_H */
Signature · 1 line
2.18.0
#31 lore raw

Re: [PATCH v11 12/12] drm/mediatek: dpi: Add matrix_sel helper

Hi, Bo-Chen:

Quoted 4 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Add a mtk_dpi_matrix_sel() helper to update the DPI_MATRIX_SET register depending on the color format.

Why set DPI_MATRIX_SET? New feature or bug fix? What does this matrix work for?

Regards,
CK

Quoted 77 lines
---
 drivers/gpu/drm/mediatek/mtk_dpi.c      | 21 +++++++++++++++++++++
 drivers/gpu/drm/mediatek/mtk_dpi_regs.h |  3 +++
 2 files changed, 24 insertions(+)
drivers/gpu/drm/mediatek/mtk_dpi.c +17 -0
index 9668bd5dd14a..dc355a512963 100644
@@ -387,6 +387,25 @@ static void mtk_dpi_config_disable_edge(struct
 mtk_dpi *dpi)
 		mtk_dpi_mask(dpi, dpi->conf->reg_h_fre_con, 0,
 EDGE_SEL_EN);
 }
 
+static void mtk_dpi_matrix_sel(struct mtk_dpi *dpi, enum
 mtk_dpi_out_color_format format)
+{
+	u32 matrix_sel = 0;
+
+	switch (format) {
+	case MTK_DPI_COLOR_FORMAT_YCBCR_422:
+	case MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL:
+	case MTK_DPI_COLOR_FORMAT_YCBCR_444:
+	case MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL:
+	case MTK_DPI_COLOR_FORMAT_XV_YCC:
+		if (dpi->mode.hdisplay <= 720)
+			matrix_sel = 0x2;
+		break;
+	default:
+		break;
+	}
+	mtk_dpi_mask(dpi, DPI_MATRIX_SET, matrix_sel,

INT_MATRIX_SEL_MASK);

drivers/gpu/drm/mediatek/mtk_dpi.c +2 -0
+}
+
 static void mtk_dpi_config_color_format(struct mtk_dpi *dpi,
 					enum mtk_dpi_out_color_format

format)
{

drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -394,6 +413,7 @@ static void mtk_dpi_config_color_format(struct
 mtk_dpi *dpi,
 	    (format == MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, false);
 		mtk_dpi_config_csc_enable(dpi, true);
+		mtk_dpi_matrix_sel(dpi, format);
 		if (dpi->conf->swap_input_support)
 			mtk_dpi_config_swap_input(dpi, false);

mtk_dpi_config_channel_swap(dpi,
MTK_DPI_OUT_CHANNEL_SWAP_BGR);

drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -401,6 +421,7 @@ static void mtk_dpi_config_color_format(struct
 mtk_dpi *dpi,
 		   (format == MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, true);
 		mtk_dpi_config_csc_enable(dpi, true);
+		mtk_dpi_matrix_sel(dpi, format);
 		if (dpi->conf->swap_input_support)
 			mtk_dpi_config_swap_input(dpi, true);

mtk_dpi_config_channel_swap(dpi,
MTK_DPI_OUT_CHANNEL_SWAP_RGB);

drivers/gpu/drm/mediatek/mtk_dpi_regs.h +3 -0
index f7f0272dbd6a..96c117202d0d 100644
@@ -230,4 +230,7 @@
 #define EDGE_SEL_EN			BIT(5)
 #define H_FRE_2N			BIT(25)
 
+#define DPI_MATRIX_SET		0xB4
+#define INT_MATRIX_SEL_MASK	(0x1F << 0)
+
 #endif /* __MTK_DPI_REGS_H */
#32 lore raw

Re: [PATCH v11 12/12] drm/mediatek: dpi: Add matrix_sel helper

Quoted 5 lines · CK Hu

Hi, Bo-Chen:

Quoted 2 lines · Bo-Chen Chen

From: Guillaume Ranquet <[email protected]>

Quoted 9 lines
Quoted 2 lines

Add a mtk_dpi_matrix_sel() helper to update the DPI_MATRIX_SET register depending on the color format.

Why set DPI_MATRIX_SET? New feature or bug fix? What does this matrix work for?

Regards,
CK

Matrix selection is a new feature for both dpi and dpintf of MT8195. I will add this in next version.

Quoted 79 lines
Quoted 77 lines
---
 drivers/gpu/drm/mediatek/mtk_dpi.c      | 21 +++++++++++++++++++++
 drivers/gpu/drm/mediatek/mtk_dpi_regs.h |  3 +++
 2 files changed, 24 insertions(+)
drivers/gpu/drm/mediatek/mtk_dpi.c +17 -0
index 9668bd5dd14a..dc355a512963 100644
@@ -387,6 +387,25 @@ static void mtk_dpi_config_disable_edge(struct
 mtk_dpi *dpi)
 		mtk_dpi_mask(dpi, dpi->conf->reg_h_fre_con, 0,
 EDGE_SEL_EN);
 }
 
+static void mtk_dpi_matrix_sel(struct mtk_dpi *dpi, enum
 mtk_dpi_out_color_format format)
+{
+	u32 matrix_sel = 0;
+
+	switch (format) {
+	case MTK_DPI_COLOR_FORMAT_YCBCR_422:
+	case MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL:
+	case MTK_DPI_COLOR_FORMAT_YCBCR_444:
+	case MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL:
+	case MTK_DPI_COLOR_FORMAT_XV_YCC:
+		if (dpi->mode.hdisplay <= 720)
+			matrix_sel = 0x2;
+		break;
+	default:
+		break;
+	}
+	mtk_dpi_mask(dpi, DPI_MATRIX_SET, matrix_sel,

INT_MATRIX_SEL_MASK);

drivers/gpu/drm/mediatek/mtk_dpi.c +2 -0
+}
+
 static void mtk_dpi_config_color_format(struct mtk_dpi *dpi,
 					enum mtk_dpi_out_color_format

format)
{

drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -394,6 +413,7 @@ static void mtk_dpi_config_color_format(struct
 mtk_dpi *dpi,
 	    (format == MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, false);
 		mtk_dpi_config_csc_enable(dpi, true);
+		mtk_dpi_matrix_sel(dpi, format);
 		if (dpi->conf->swap_input_support)
 			mtk_dpi_config_swap_input(dpi, false);

mtk_dpi_config_channel_swap(dpi,
MTK_DPI_OUT_CHANNEL_SWAP_BGR);

drivers/gpu/drm/mediatek/mtk_dpi.c +1 -0
@@ -401,6 +421,7 @@ static void mtk_dpi_config_color_format(struct
 mtk_dpi *dpi,
 		   (format == MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL)) {
 		mtk_dpi_config_yuv422_enable(dpi, true);
 		mtk_dpi_config_csc_enable(dpi, true);
+		mtk_dpi_matrix_sel(dpi, format);
 		if (dpi->conf->swap_input_support)
 			mtk_dpi_config_swap_input(dpi, true);

mtk_dpi_config_channel_swap(dpi,
MTK_DPI_OUT_CHANNEL_SWAP_RGB);

drivers/gpu/drm/mediatek/mtk_dpi_regs.h +3 -0
index f7f0272dbd6a..96c117202d0d 100644
@@ -230,4 +230,7 @@
 #define EDGE_SEL_EN			BIT(5)
 #define H_FRE_2N			BIT(25)
 
+#define DPI_MATRIX_SET		0xB4
+#define INT_MATRIX_SEL_MASK	(0x1F << 0)
+
 #endif /* __MTK_DPI_REGS_H */