drm/mediatek: Add MT8195 DisplayPort driver
Subsystems (6)
v11 cover drm/mediatek: Add MT8195 DisplayPort driver
This patch is separate from v10 which is including dp driver, phy driver and dpintf driver. This series is only contained the DisplayPort driver.
This series can be tested using 5.19-rc kernel and I test it in MT8195 Tomato Chromebook. Modetest these modes:
for eDP:
#0 2256x1504 60.00 2256 2304 2336 2536 1504 1507 1513 1549 235690 flags: phsync, nvsync; type: preferred, driver #1 2256x1504 48.00 2256 2304 2336 2536 1504 1507 1513 1549 188550 flags: phsync, nvsync; type: driver
for DP:
#0 1920x1080 60.00 1920 2008 2052 2200 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: preferred, driver #1 1920x1080 59.94 1920 2008 2052 2200 1080 1084 1089 1125 148352 flags: phsync, pvsync; type: driver #2 1920x1080 50.00 1920 2448 2492 2640 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: driver #3 1680x1050 59.95 1680 1784 1960 2240 1050 1053 1059 1089 146250 flags: nhsync, pvsync; type: driver #4 1600x900 60.00 1600 1624 1704 1800 900 901 904 1000 108000 flags: phsync, pvsync; type: driver #5 1280x1024 60.02 1280 1328 1440 1688 1024 1025 1028 1066 108000 flags: phsync, pvsync; type: driver #6 1280x800 59.81 1280 1352 1480 1680 800 803 809 831 83500 flags: nhsync, pvsync; type: driver #7 1280x720 60.00 1280 1390 1430 1650 720 725 730 750 74250 flags: phsync, pvsync; type: driver #8 1280x720 59.94 1280 1390 1430 1650 720 725 730 750 74176 flags: phsync, pvsync; type: driver #9 1280x720 50.00 1280 1720 1760 1980 720 725 730 750 74250 flags: phsync, pvsync; type: driver #10 1024x768 60.00 1024 1048 1184 1344 768 771 777 806 65000 flags: nhsync, nvsync; type: driver #11 800x600 60.32 800 840 968 1056 600 601 605 628 40000 flags: phsync, pvsync; type: driver #12 720x576 50.00 720 732 796 864 576 581 586 625 27000 flags: nhsync, nvsync; type: driver #13 720x480 60.00 720 736 798 858 480 489 495 525 27027 flags: nhsync, nvsync; type: driver #14 720x480 59.94 720 736 798 858 480 489 495 525 27000 flags: nhsync, nvsync; type: driver #15 640x480 60.00 640 656 752 800 480 490 492 525 25200 flags: nhsync, nvsync; type: driver #16 640x480 59.94 640 656 752 800 480 490 492 525 25175 flags: nhsync, nvsync; type: driver
Changes from v10 for dp driver:
- Drop return value for write registers to make code more clear.
- Refine training state.
- Add property for dt-binding.
- Add new bug fix patches for audio and suspend.
- Rebase to v5.19-rc1.
Changes from v9:
- The DP-Phy is back to being a child device of the DP driver (as in v8)
- hot plug detection has been added back to Embedded Display Port... as after discussing with mediatek experts, this is needed eventhough the Embedded Display port is not un-pluggable
- rebased on linux-next
- simplified/split train_handler function, as suggested by Rex
- added comments on the sleep/delays present in the code
- removed previous patch introducing retries when receiving AUX_DEFER as this is already handled in the dp_aux framework
- added max-lane and max-linkrate device tree u8 properties instead of hardcoded #defines
Things that are in my todolist for v11:
- retrieve CK/DE support from panel driver instead of hardcoding it into the dpi driver
- refcount the dp driver "enabled" status for "future proofing"
- review the drm_dp_helpers for features/functions that have been re-implemented in the mediatek dp drivers
Older revisions:
RFC - https://lore.kernel.org/linux-mediatek/[email protected]/
v1 - https://lore.kernel.org/linux-mediatek/[email protected]/ v2 - https://lore.kernel.org/linux-mediatek/[email protected]/ v3 - https://lore.kernel.org/linux-mediatek/[email protected]/ v4 - https://lore.kernel.org/linux-mediatek/[email protected]/ v5 - https://lore.kernel.org/all/[email protected]/ v6 - https://lore.kernel.org/linux-mediatek/[email protected]/ v7 - https://lore.kernel.org/linux-mediatek/[email protected]/ v8 - https://lore.kernel.org/linux-mediatek/[email protected]/ v9 - https://lore.kernel.org/all/[email protected]/
v10 - https://lore.kernel.org/all/[email protected]/
Functional dependencies are:
- Add Mediatek Soc DRM (vdosys0) support for mt8195
https://lore.kernel.org/linux-mediatek/[email protected]/
- Add MediaTek SoC DRM (vdosys1) support for mt8195
https://lore.kernel.org/linux-mediatek/[email protected]/
Bo-Chen Chen (2):
drm/mediatek: set monitor to DP_SET_POWER_D3 to avoid garbage drm/mediatek: fix no audio when resolution change
Guillaume Ranquet (4):
drm/edid: Convert cea_sad helper struct to kernelDoc drm/edid: Add cea_sad helpers for freq/length drm/mediatek: Add MT8195 External DisplayPort support drm/mediatek: DP audio support for MT8195
Jitao Shi (1):
drm/mediatek: add hpd debounce
Markus Schneider-Pargmann (3):
dt-bindings: mediatek,dp: Add Display Port binding video/hdmi: Add audio_infoframe packing for DP drm/mediatek: Add MT8195 Embedded DisplayPort driver
.../display/mediatek/mediatek,dp.yaml | 101 + drivers/gpu/drm/drm_edid.c | 73 + drivers/gpu/drm/mediatek/Kconfig | 8 + drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_dp.c | 3078 +++++++++++++++++ drivers/gpu/drm/mediatek/mtk_dp_reg.h | 545 +++ drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 + drivers/gpu/drm/mediatek/mtk_drm_drv.h | 3 + drivers/video/hdmi.c | 82 +- include/drm/display/drm_dp.h | 2 + include/drm/drm_edid.h | 26 +- include/linux/hdmi.h | 7 +- 12 files changed, 3907 insertions(+), 23 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml create mode 100644 drivers/gpu/drm/mediatek/mtk_dp.c create mode 100644 drivers/gpu/drm/mediatek/mtk_dp_reg.h
Signature · 1 line
2.18.0
PATCH v11 1/10 dt-bindings: mediatek,dp: Add Display Port binding
From: Markus Schneider-Pargmann <[email protected]>
This controller is present on several mediatek hardware. Currently mt8195 and mt8395 have this controller without a functional difference, so only one compatible field is added.
The controller can have two forms, as a normal display port and as an embedded display port.
--- .../display/mediatek/mediatek,dp.yaml | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +101 -0
@@ -0,0 +1,101 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/mediatek/mediatek,dp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek Display Port Controller + +maintainers: + - Chun-Kuang Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + Device tree bindings for the MediaTek display port and + embedded display port controller present on some MediaTek SoCs. + +properties: + compatible: + enum: + - mediatek,mt8195-dp-tx + - mediatek,mt8195-edp-tx + + reg: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + description: efuse data for display port calibration + + nvmem-cell-names: + const: dp_calibration_data + + power-domains: + maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Input endpoint of the controller, usually dp_intf + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: Output endpoint of the controller + + required: + - port@0 + - port@1 + + max-lanes: + maxItems: 1 + description: maximum number of lanes supported by the hardware. + + max-linkrate: + maxItems: 1 + description: maximum link rate supported by the hardware and unit is MHz. + +required: + - compatible + - reg + - interrupts + - ports + - max-lanes + - max-linkrate + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/power/mt8195-power.h> + dp_tx@1c600000 { + compatible = "mediatek,mt8195-dp-tx"; + reg = <0x1c600000 0x8000>; + power-domains = <&spm MT8195_POWER_DOMAIN_DP_TX>; + interrupts = <GIC_SPI 458 IRQ_TYPE_LEVEL_HIGH 0>; + max-lanes = /bits/ 8 <4>; + max-linkrate = /bits/ 16 <8100>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + edp_in: endpoint { + remote-endpoint = <&dp_intf0_out>; + }; + }; + port@1 { + reg = <1>; + edp_out: endpoint { + remote-endpoint = <&panel_in>; + }; + }; + }; + };
Signature · 1 line
2.18.0
Rob Herring
maintainerRe: [PATCH v11 01/10] dt-bindings: mediatek,dp: Add Display Port binding
Quoted 9 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This controller is present on several mediatek hardware. Currently mt8195 and mt8395 have this controller without a functional difference, so only one compatible field is added.
The controller can have two forms, as a normal display port and as an embedded display port.
Quoted 9 lines
Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Fix reviewers' comment]Signed-off-by Bo-Chen Chen <[email protected]>--- .../display/mediatek/mediatek,dp.yaml | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml
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,dp.example.dtb: dp_tx@1c600000: max-lanes: b'\x04' is not of type 'object', 'array', 'boolean', 'null'
From schema: /usr/local/lib/python3.10/dist-packages/dtschema/schemas/dt-core.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.example.dtb: dp_tx@1c600000: max-linkrate: b'\x1f\xa4' is not of type 'object', 'array', 'boolean', 'null'
From schema: /usr/local/lib/python3.10/dist-packages/dtschema/schemas/dt-core.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.
Rob Herring
maintainerRe: [PATCH v11 01/10] dt-bindings: mediatek,dp: Add Display Port binding
In reply to Bo-Chen ChenQuoted 70 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This controller is present on several mediatek hardware. Currently mt8195 and mt8395 have this controller without a functional difference, so only one compatible field is added.
The controller can have two forms, as a normal display port and as an embedded display port.
Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Fix reviewers' comment]Signed-off-by Bo-Chen Chen <[email protected]>--- .../display/mediatek/mediatek,dp.yaml | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yamlDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +46
-0@@ -0,0 +1,101 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/mediatek/mediatek,dp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek Display Port Controller + +maintainers: + - Chun-Kuang Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + Device tree bindings for the MediaTek display port and + embedded display port controller present on some MediaTek SoCs. + +properties: + compatible: + enum: + - mediatek,mt8195-dp-tx + - mediatek,mt8195-edp-tx + + reg: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + description: efuse data for display port calibration + + nvmem-cell-names: + const: dp_calibration_data + + power-domains: + maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Input endpoint of the controller, usually dp_intf + + port@1:
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml line 56
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +10
-0+ $ref: /schemas/graph.yaml#/properties/port + description: Output endpoint of the controller + + required: + - port@0 + - port@1 + + max-lanes: + maxItems: 1 + description: maximum number of lanes supported by the hardware.
We already have a 'data-lanes' property defined in 'video-interfaces.yaml' that can serve this purpose.
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml line 60
Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +4
-0+ + max-linkrate: + maxItems: 1 + description: maximum link rate supported by the hardware and unit is MHz.
Then use '-mhz' suffix on the property name. Then you don't need a type (or maxItems).
Re: [PATCH v11 01/10] dt-bindings: mediatek,dp: Add Display Port binding
Quoted 92 lines · Rob Herring
Quoted 91 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This controller is present on several mediatek hardware. Currently mt8195 and mt8395 have this controller without a functional difference,
so only one compatible field is added.The controller can have two forms, as a normal display port and as an
embedded display port.Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Fix reviewers' comment]Signed-off-by Bo-Chen Chen <[email protected]>--- .../display/mediatek/mediatek,dp.yaml | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yamldiff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.ya ml b/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.ya ml
new file mode 100644
index 000000000000..10f50a0dcf49
---/dev/null
+++
b/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.ya mlDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +4
-0@@ -0,0 +1,101 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id:Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +39
-0+ +title: MediaTek Display Port Controller + +maintainers: + - Chun-Kuang Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + Device tree bindings for the MediaTek display port and + embedded display port controller present on some MediaTek SoCs. + +properties: + compatible: + enum: + - mediatek,mt8195-dp-tx + - mediatek,mt8195-edp-tx + + reg: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + description: efuse data for display port calibration + + nvmem-cell-names: + const: dp_calibration_data + + power-domains: + maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Input endpoint of the controller, usually
dp_intfDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +8
-0+ + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: Output endpoint of the controller + + required: + - port@0 + - port@1
Quoted 9 lines
Quoted 5 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +4
-0+ + max-lanes: + maxItems: 1 + description: maximum number of lanes supported by thehardware.
We already have a 'data-lanes' property defined in '
video-interfaces.yaml' that can serve this purpose.
Hello Rob,
Thanks for review.
From the description of video-interfaces.yaml, I think it's not quite match what we need. We only need this value be one of "1,2,4".
Any other suggestion?
Quoted 9 lines
Quoted 5 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +4
-0+ + max-linkrate: + maxItems: 1 + description: maximum link rate supported by the hardware andunit is MHz.
Then use '-mhz' suffix on the property name. Then you don't need a type
(or maxItems).
OK, I will write like this:
max-linkrate-mhz:
enum: [ 1620, 2700, 5400, 8100 ]
description: maximum link rate supported by the hardware.
BRs,
Bo-Chen
Rob Herring
maintainerRe: [PATCH v11 01/10] dt-bindings: mediatek,dp: Add Display Port binding
Quoted 103 lines · Rex-BC Chen
Quoted 92 lines · Rob Herring
Quoted 91 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This controller is present on several mediatek hardware. Currently mt8195 and mt8395 have this controller without a functional difference,
so only one compatible field is added.The controller can have two forms, as a normal display port and as an
embedded display port.Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Fix reviewers' comment]Signed-off-by Bo-Chen Chen <[email protected]>--- .../display/mediatek/mediatek,dp.yaml | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yamldiff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.ya ml b/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.ya ml
new file mode 100644
index 000000000000..10f50a0dcf49
---/dev/null
+++
b/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.ya mlDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +4
-0@@ -0,0 +1,101 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id:Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +39
-0+ +title: MediaTek Display Port Controller + +maintainers: + - Chun-Kuang Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + Device tree bindings for the MediaTek display port and + embedded display port controller present on some MediaTek SoCs. + +properties: + compatible: + enum: + - mediatek,mt8195-dp-tx + - mediatek,mt8195-edp-tx + + reg: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + description: efuse data for display port calibration + + nvmem-cell-names: + const: dp_calibration_data + + power-domains: + maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Input endpoint of the controller, usually
dp_intfDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +8
-0+ + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: Output endpoint of the controller + + required: + - port@0 + - port@1Quoted 9 lines
Quoted 5 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +4
-0+ + max-lanes: + maxItems: 1 + description: maximum number of lanes supported by thehardware.
We already have a 'data-lanes' property defined in '
video-interfaces.yaml' that can serve this purpose.
Quoted 5 lines
Hello Rob,
Thanks for review.
From the description ofvideo-interfaces.yaml, I think it's not quite match what we need. We only need this value be one of "1,2,4".
data-lanes = <0>;
data-lanes = <0 1>;
data-lanes = <0 1 2 3>;
Limiting the number of lanes to something less than the max is exactly how this property is used in addition to being able to show the mapping of lanes.
Rob
Re: [PATCH v11 01/10] dt-bindings: mediatek,dp: Add Display Port binding
Quoted 40 lines · Rob Herring
Quoted 39 lines · Rex-BC Chen
Quoted 38 lines · Rob Herring
Quoted 37 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This controller is present on several mediatek hardware. Currently
mt8195 and mt8395 have this controller without a functional difference,
so only one compatible field is added.The controller can have two forms, as a normal display port and as
an
embedded display port.Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Fix reviewers' comment]Signed-off-by Bo-Chen Chen <[email protected]>--- .../display/mediatek/mediatek,dp.yaml | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644
Documentation/devicetree/bindings/display/mediatek/mediatek,dp. yamldiff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,d p.ya
ml b/Documentation/devicetree/bindings/display/mediatek/mediatek,d p.ya
ml
new file mode 100644
index 000000000000..10f50a0dcf49
---/dev/null
+++
b/Documentation/devicetree/bindings/display/mediatek/mediatek,d
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml line 4
Quoted 8 lines
p.ya
mlDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +4
-0@@ -0,0 +1,101 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review line 5
Quoted 3 lines
(quoted diff) +1
-0+$schema:
Quoted 71 lines
Quoted 60 lines
Quoted 50 lines
Quoted 50 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +10
-0+ +title: MediaTek Display Port Controller + +maintainers: + - Chun-Kuang Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + Device tree bindings for the MediaTek display port and + embedded display port controller present on some MediaTekSoCs.
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +29
-0+ +properties: + compatible: + enum: + - mediatek,mt8195-dp-tx + - mediatek,mt8195-edp-tx + + reg: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + description: efuse data for display port calibration + + nvmem-cell-names: + const: dp_calibration_data + + power-domains: + maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Input endpoint of the controller, usually
dp_intfDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +8
-0+ + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: Output endpoint of the controller + + required: + - port@0 + - port@1Quoted 9 lines
Quoted 5 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +4
-0+ + max-lanes: + maxItems: 1 + description: maximum number of lanes supported by thehardware.
We already have a 'data-lanes' property defined in '
video-interfaces.yaml' that can serve this purpose.Quoted 6 lines
Hello Rob,
Thanks for review.
From the description ofvideo-interfaces.yaml, I think it's not quite
match what we need. We only need this value be one of "1,2,4".data-lanes = <0>;
data-lanes = <0 1>;
data-lanes = <0 1 2 3>;
Quoted 7 lines
Limiting the number of lanes to something less than the max is exactly
how this property is used in addition to being able to show the mapping
of lanes.Rob
Hello Rob,
I modify like this:
data-lanes:
$ref: /schemas/media/video-interfaces.yaml#
description: |
number of lanes supported by the hardware.
The possible values:
1 - For 1 lane enabled in IP.
1 2 - For 2 lanes enabled in IP.
1 2 4 - For 4 lanes enabled in IP.
minItems: 1
maxItems: 3
example:
data-lanes = <1 2 4>;
But I encounter errorr:Documentation/devicetree/bindings/display/mediatek/mediatek,dp.example.
dtb: dp_tx@1c600000: data-lanes: [[1, 2, 4]] is not of type 'object' Documentation/devicetree/bindings/display/mediatek/mediatek,dp.example.
dtb: dp_tx@1c600000: data-lanes: [[1, 2, 4]] is not of type 'object'
can you kindly give me some hint for this?
Thanks
BRs,
Bo-Chen
PATCH v11 2/10 drm/edid: Convert cea_sad helper struct to kernelDoc
In reply to Bo-Chen ChenFrom: Guillaume Ranquet <[email protected]>
To illustrate the cea_sad helper struct more clear, we convert the driver comments to kernelDoc.
--- include/drm/drm_edid.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
include/drm/drm_edid.h +9 -3
@@ -359,12 +359,18 @@ struct edid {#define EDID_PRODUCT_ID (e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8)) -/* Short Audio Descriptor */ +/** +* struct cea_sad - CEA Short Audio Descriptor. +* @format: See HDMI_AUDIO_CODING_TYPE_*. +* @channels: max number of channels - 1. +* @freq: See CEA_SAD_FREQ_*. +* @byte2: meaning depends on format. +*/ struct cea_sad {u8 format; -u8 channels;/* max number of channels - 1 */ +u8 channels;u8 freq; -u8 byte2;/* meaning depends on format */ +u8 byte2; };struct drm_encoder ;
Signature · 1 line
2.18.0
PATCH v11 3/10 drm/edid: Add cea_sad helpers for freq/length
In reply to Bo-Chen ChenFrom: Guillaume Ranquet <[email protected]>
This patch adds two helper functions that extract the frequency and word length from a struct cea_sad.
For these helper functions new defines are added that help translate the 'freq' and 'byte2' fields into real numbers.
--- drivers/gpu/drm/drm_edid.c | 73 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 14 ++++++++ 2 files changed, 87 insertions(+)
drivers/gpu/drm/drm_edid.c +73 -0
@@ -4916,6 +4916,79 @@ int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb) }EXPORT_SYMBOL (drm_edid_to_speaker_allocation); +/** +* drm_cea_sad_get_sample_rate - Extract the sample rate from cea_sad +* @sad: Pointer to the cea_sad struct +* +* Extracts the cea_sad frequency field and returns the sample rate in Hz. +* +* Return: Sample rate in Hz or a negative errno if parsing failed. +*/ +int drm_cea_sad_get_sample_rate (const struct cea_sad *sad) +{ +switch (sad->freq) { +case DRM_CEA_SAD_FREQ_32KHZ : +return 32000 ; +case DRM_CEA_SAD_FREQ_44KHZ : +return 44100 ; +case DRM_CEA_SAD_FREQ_48KHZ : +return 48000 ; +case DRM_CEA_SAD_FREQ_88KHZ : +return 88200 ; +case DRM_CEA_SAD_FREQ_96KHZ : +return 96000 ; +case DRM_CEA_SAD_FREQ_176KHZ : +return 176400 ; +case DRM_CEA_SAD_FREQ_192KHZ : +return 192000 ; +default : +return -EINVAL ; + } +} +EXPORT_SYMBOL (drm_cea_sad_get_sample_rate); + +static bool drm_cea_sad_is_pcm (const struct cea_sad *sad) +{ +switch (sad->format) { +case HDMI_AUDIO_CODING_TYPE_PCM : +return true; +default : +return false; + } +} + +/** +* drm_cea_sad_get_uncompressed_word_length - Extract word length +* @sad: Pointer to the cea_sad struct +* +* Extracts the cea_sad byte2 field and returns the word length for an +* uncompressed stream. +* +* Note: This function may only be called for uncompressed audio. +* +* Return: Word length in bits or a negative errno if parsing failed. +*/ +int drm_cea_sad_get_uncompressed_word_length (const struct cea_sad *sad) +{ +if (!drm_cea_sad_is_pcm (sad)) { +DRM_WARN ("Unable to get the uncompressed word length for format: %u\n" , + sad->format); +return -EINVAL ; + } + +switch (sad->byte2) { +case DRM_CEA_SAD_UNCOMPRESSED_WORD_16BIT : +return 16 ; +case DRM_CEA_SAD_UNCOMPRESSED_WORD_20BIT : +return 20 ; +case DRM_CEA_SAD_UNCOMPRESSED_WORD_24BIT : +return 24 ; +default : +return -EINVAL ; + } +} +EXPORT_SYMBOL (drm_cea_sad_get_uncompressed_word_length); +/** * drm_av_sync_delay - compute the HDMI/DP sink audio-video sync delay * @connector: connector associated with the HDMI/DP sink
include/drm/drm_edid.h +14 -0
@@ -373,6 +373,18 @@ struct cea_sad {u8 byte2; }; +#define DRM_CEA_SAD_FREQ_32KHZ BIT(0) +#define DRM_CEA_SAD_FREQ_44KHZ BIT(1) +#define DRM_CEA_SAD_FREQ_48KHZ BIT(2) +#define DRM_CEA_SAD_FREQ_88KHZ BIT(3) +#define DRM_CEA_SAD_FREQ_96KHZ BIT(4) +#define DRM_CEA_SAD_FREQ_176KHZ BIT(5) +#define DRM_CEA_SAD_FREQ_192KHZ BIT(6) + +#define DRM_CEA_SAD_UNCOMPRESSED_WORD_16BIT BIT(0) +#define DRM_CEA_SAD_UNCOMPRESSED_WORD_20BIT BIT(1) +#define DRM_CEA_SAD_UNCOMPRESSED_WORD_24BIT BIT(2) +struct drm_encoder ;struct drm_connector ;struct drm_connector_state ;
@@ -380,6 +392,8 @@ struct drm_display_mode;int drm_edid_to_sad (const struct edid *edid,struct cea_sad **sads);int drm_edid_to_speaker_allocation (const struct edid *edid,u8 **sadb); +int drm_cea_sad_get_sample_rate (const struct cea_sad *sad); +int drm_cea_sad_get_uncompressed_word_length (const struct cea_sad *sad);int drm_av_sync_delay (struct drm_connector *connector,const struct drm_display_mode *mode);
Signature · 1 line
2.18.0
PATCH v11 4/10 video/hdmi: Add audio_infoframe packing for DP
In reply to Bo-Chen ChenFrom: Markus Schneider-Pargmann <[email protected]>
Similar to HDMI, DP uses audio infoframes as well which are structured very similar to the HDMI ones.
This patch adds a helper function to pack the HDMI audio infoframe for DP, called hdmi_audio_infoframe_pack_for_dp(). hdmi_audio_infoframe_pack_only() is split into two parts. One of them packs the payload only and can be used for HDMI and DP.
Also constify the frame parameter in hdmi_audio_infoframe_check() as it is passed to hdmi_audio_infoframe_check_only() which expects a const.
--- drivers/video/hdmi.c | 82 +++++++++++++++++++++++++++--------- include/drm/display/drm_dp.h | 2 + include/linux/hdmi.h | 7 ++- 3 files changed, 71 insertions(+), 20 deletions(-)
drivers/video/hdmi.c +63 -19
@@ -21,6 +21,7 @@* DEALINGS IN THE SOFTWARE. */ +#include <drm/display/drm_dp.h> #include <linux/bitops.h> #include <linux/bug.h> #include <linux/errno.h>
@@ -381,12 +382,34 @@ static int hdmi_audio_infoframe_check_only(const struct hdmi_audio_infoframe *fr* * Returns 0 on success or a negative error code on failure. */ -int hdmi_audio_infoframe_check (struct hdmi_audio_infoframe *frame) +int hdmi_audio_infoframe_check (const struct hdmi_audio_infoframe *frame) {return hdmi_audio_infoframe_check_only (frame); }EXPORT_SYMBOL (hdmi_audio_infoframe_check); +static void +hdmi_audio_infoframe_pack_payload (const struct hdmi_audio_infoframe *frame, +u8 *buffer) +{ +u8 channels; + +if (frame->channels >=2 ) + channels = frame->channels -1 ; +else + channels =0 ; + + buffer[0 ] = ((frame->coding_type &0xf ) <<4 ) | (channels &0x7 ); + buffer[1 ] = ((frame->sample_frequency &0x7 ) <<2 ) | + (frame->sample_size &0x3 ); + buffer[2 ] = frame->coding_type_ext &0x1f ; + buffer[3 ] = frame->channel_allocation; + buffer[4 ] = (frame->level_shift_value &0xf ) <<3 ; + +if (frame->downmix_inhibit) + buffer[4 ] |=BIT (7 ); +} +/** * hdmi_audio_infoframe_pack_only() - write HDMI audio infoframe to binary buffer * @frame: HDMI audio infoframe
@@ -404,7 +427,6 @@ EXPORT_SYMBOL(hdmi_audio_infoframe_check);ssize_t hdmi_audio_infoframe_pack_only (const struct hdmi_audio_infoframe *frame,void *buffer,size_t size) { -unsigned char channels;u8 *ptr = buffer;size_t length;int ret;
@@ -420,28 +442,13 @@ ssize_t hdmi_audio_infoframe_pack_only(const struct hdmi_audio_infoframe *frame,memset (buffer,0 , size); -if (frame->channels >=2 ) - channels = frame->channels -1 ; -else - channels =0 ; - ptr[0 ] = frame->type; ptr[1 ] = frame->version; ptr[2 ] = frame->length; ptr[3 ] =0 ;/* checksum */ -/* start infoframe payload */ - ptr +=HDMI_INFOFRAME_HEADER_SIZE ; - - ptr[0 ] = ((frame->coding_type &0xf ) <<4 ) | (channels &0x7 ); - ptr[1 ] = ((frame->sample_frequency &0x7 ) <<2 ) | - (frame->sample_size &0x3 ); - ptr[2 ] = frame->coding_type_ext &0x1f ; - ptr[3 ] = frame->channel_allocation; - ptr[4 ] = (frame->level_shift_value &0xf ) <<3 ; - -if (frame->downmix_inhibit) - ptr[4 ] |=BIT (7 ); +hdmi_audio_infoframe_pack_payload (frame, + ptr +HDMI_INFOFRAME_HEADER_SIZE );hdmi_infoframe_set_checksum (buffer, length);
@@ -479,6 +486,43 @@ ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, }EXPORT_SYMBOL (hdmi_audio_infoframe_pack); +/** +* hdmi_audio_infoframe_pack_for_dp - Pack a HDMI Audio infoframe for DisplayPort +* +* @frame: HDMI Audio infoframe +* @sdp: secondary data packet for display port. This is filled with the +* appropriate: data +* @dp_version: Display Port version to be encoded in the header +* +* Packs a HDMI Audio Infoframe to be sent over Display Port. This function +* fills the secondary data packet to be used for Display Port. +* +* Return: Number of total written bytes or a negative errno on failure. +*/ +ssize_t +hdmi_audio_infoframe_pack_for_dp (const struct hdmi_audio_infoframe *frame, +struct dp_sdp *sdp,u8 dp_version) +{ +int ret; + + ret =hdmi_audio_infoframe_check (frame); +if (ret) +return ret; + +memset (sdp->db,0 ,sizeof (sdp->db)); + +/* Secondary-data packet header */ + sdp->sdp_header.HB0 =0 ; + sdp->sdp_header.HB1 = frame->type; + sdp->sdp_header.HB2 =DP_SDP_AUDIO_INFOFRAME_HB2 ; + sdp->sdp_header.HB3 = (dp_version &0x3f ) <<2 ; + +hdmi_audio_infoframe_pack_payload (frame, sdp->db); + +return frame->length +4 ; +} +EXPORT_SYMBOL (hdmi_audio_infoframe_pack_for_dp); +/** * hdmi_vendor_infoframe_init() - initialize an HDMI vendor infoframe * @frame: HDMI vendor infoframe
include/drm/display/drm_dp.h +2 -0
@@ -1536,6 +1536,8 @@ enum drm_dp_phy {#define DP_SDP_VSC_EXT_CEA 0x21/* DP 1.4 */ /* 0x80+ CEA-861 infoframe types */ +#define DP_SDP_AUDIO_INFOFRAME_HB2 0x1b +/** * struct dp_sdp_header - DP secondary data packet header * @HB0: Secondary Data Packet ID
include/linux/hdmi.h +6 -1
@@ -336,7 +336,12 @@ ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, void *buffer, size_t size);ssize_t hdmi_audio_infoframe_pack_only (const struct hdmi_audio_infoframe *frame,void *buffer,size_t size); -int hdmi_audio_infoframe_check (struct hdmi_audio_infoframe *frame); +int hdmi_audio_infoframe_check (const struct hdmi_audio_infoframe *frame); + +struct dp_sdp ; +ssize_t +hdmi_audio_infoframe_pack_for_dp (const struct hdmi_audio_infoframe *frame, +struct dp_sdp *sdp,u8 dp_version);enum hdmi_3d_structure {HDMI_3D_STRUCTURE_INVALID =-1 ,
Signature · 1 line
2.18.0
PATCH v11 5/10 drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenFrom: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that both can work with the same register range. The phy driver sets device data that is read by the parent to get the phy device that can be used to control the phy properties.
This driver is based on an initial version by
Jitao shi <[email protected]>
--- drivers/gpu/drm/mediatek/Kconfig | 8 + drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_dp.c | 2241 ++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_dp_reg.h | 545 ++++++ drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 + drivers/gpu/drm/mediatek/mtk_drm_drv.h | 3 + 6 files changed, 2802 insertions(+) create mode 100644 drivers/gpu/drm/mediatek/mtk_dp.c create mode 100644 drivers/gpu/drm/mediatek/mtk_dp_reg.h
drivers/gpu/drm/mediatek/Kconfig +8 -0
@@ -21,6 +21,14 @@ config DRM_MEDIATEK This driver provides kernel mode setting and buffer management to userspace. +config DRM_MEDIATEK_DP + tristate "DRM DPTX Support for MediaTek SoCs" + depends on DRM_MEDIATEK + select PHY_MTK_DP + select DRM_DP_HELPER + help + DRM/KMS Display Port driver for MediaTek SoCs. + config DRM_MEDIATEK_HDMI tristate "DRM HDMI Support for Mediatek SoCs" depends on DRM_MEDIATEK
drivers/gpu/drm/mediatek/Makefile +2 -0
@@ -25,3 +25,5 @@ mediatek-drm-hdmi-objs := mtk_cec.o \ mtk_hdmi_ddc.o obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mediatek-drm-hdmi.o + +obj-$(CONFIG_DRM_MEDIATEK_DP) += mtk_dp.o
drivers/gpu/drm/mediatek/mtk_dp.c new file +2241 -0
2,241 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_dp_reg.h new file +545 -0
545 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_drm_drv.c +3 -0
@@ -1033,6 +1033,9 @@ static struct platform_driver * const mtk_drm_drivers[] = { &mtk_disp_ovl_driver, &mtk_disp_rdma_driver, &mtk_dpi_driver, +#if IS_REACHABLE(CONFIG_DRM_MEDIATEK_DP) + &mtk_dp_driver, +#endif &mtk_drm_platform_driver, &mtk_dsi_driver, &mtk_ethdr_driver,
drivers/gpu/drm/mediatek/mtk_drm_drv.h +3 -0
@@ -67,6 +67,9 @@ extern struct platform_driver mtk_disp_ovl_adaptor_driver;extern struct platform_driver mtk_disp_ovl_driver;extern struct platform_driver mtk_disp_rdma_driver;extern struct platform_driver mtk_dpi_driver; +#if IS_REACHABLE (CONFIG_DRM_MEDIATEK_DP ) +extern struct platform_driver mtk_dp_driver; +#endif extern struct platform_driver mtk_dsi_driver;extern struct platform_driver mtk_ethdr_driver;extern struct platform_driver mtk_mdp_rdma_driver;
Signature · 1 line
2.18.0
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
Hi, Bo-Chen:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 38 lines
(quoted diff) +2
-0+ +static int mtk_dp_train_flow(struct mtk_dp *mtk_dp, u8
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ u8 target_lane_count) +{ +u8 lane_adjust[2 ] = {}; +bool pass_tps1 = false; +bool pass_tps2_3 = false; +int train_retries; +int status_control; +int iteration_count; +int ret; +u8 prev_lane_adjust; + + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LINK_BW_SET,
target_link_rate);drivers/gpu/drm/mediatek/mtk_dp.c new file +2
-0+ drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LANE_COUNT_SET, + target_lane_count |
DP_LANE_COUNT_ENHANCED_FRAME_EN);drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ +if (mtk_dp->train_info.sink_ssc) +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_DOWNSPREAD_CTRL , +DP_SPREAD_AMP_0_5 ); + + train_retries =0 ; + status_control =0 ; + iteration_count =1 ; + prev_lane_adjust =0xFF ; + +mtk_dp_set_lanes (mtk_dp, target_lane_count /2 ); + ret = mtk_dp_phy_configure(mtk_dp, target_link_rate,
target_lane_count);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+if (ret) +return -EINVAL ; + + dev_dbg(mtk_dp->dev, + "Link train target_link_rate = 0x%x, target_lane_count= 0x%x\n",
drivers/gpu/drm/mediatek/mtk_dp.c line 1350
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+ target_link_rate, target_lane_count); + + do { + train_retries++; + if (!mtk_dp->train_info.cable_plugged_in || + mtk_dp->train_info.irq_sta.hpd_disconnect) {
In mtk_dp_hpd_isr_handler(), train_info.irq_sta.hpd_disconnect would finally be set to false, so you need not to check it here. So remove it here.
Quoted 66 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+return -ENODEV ; + } + +if (mtk_dp->train_state <MTK_DP_TRAIN_STATE_TRAINING ) +return -EAGAIN ; + +if (!pass_tps1) { + ret = mtk_dp_train_tps_1(mtk_dp,
target_lane_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +1
-0+ &iteration_count,
lane_adjust,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &status_control, + &prev_lane_adjust); +if (!ret) { + pass_tps1 = true; + train_retries =0 ; + }else if (ret == -EINVAL ) { +break ; + } + }else { + ret = mtk_dp_train_tps_2_3(mtk_dp,
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ target_lane_count, + &iteration_count, + lane_adjust,
&status_control,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &prev_lane_adjust); +if (!ret) { + pass_tps2_3 = true; +break ; + }else if (ret == -EINVAL ) { +break ; + } + } + + drm_dp_dpcd_read(&mtk_dp->aux,
DP_ADJUST_REQUEST_LANE0_1,(quoted diff) +2
-0+ lane_adjust, sizeof(lane_adjust)); + mtk_dp_train_update_swing_pre(mtk_dp,
target_lane_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +26
-0+ lane_adjust); + }while (train_retries <MTK_DP_TRAIN_RETRY_LIMIT && + iteration_count <MTK_DP_TRAIN_MAX_ITERATIONS ); + +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_TRAINING_PATTERN_SET , +DP_TRAINING_PATTERN_DISABLE ); + ret =mtk_dp_train_set_pattern (mtk_dp,0 ); +if (ret) +return -EINVAL ; + +if (!pass_tps2_3) +return -ETIMEDOUT ; + + mtk_dp->train_info.link_rate = target_link_rate; + mtk_dp->train_info.lane_count = target_lane_count; + +mtk_dp_training_set_scramble (mtk_dp, true); + +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_LANE_COUNT_SET , + target_lane_count | +DP_LANE_COUNT_ENHANCED_FRAME_EN ); +mtk_dp_set_enhanced_frame_mode (mtk_dp, true); + +return ret; +} +
[snip]
Quoted 14 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ +/* +* We need to handle HPD signal in eDP even though eDP is a always connected
+ * device. Besides connected status, there is another feature for HPD signal -
+ * HPD pulse: it presents an IRQ from sink devices to source devices (Refer to
+ * 5.1.4 of DP1.4 spec).
+ */drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+static irqreturn_t mtk_dp_hpd_isr_handler (struct mtk_dp *mtk_dp) +{ +bool connected; + u32 irq_status = mtk_dp_swirq_get_clear(mtk_dp) |
drivers/gpu/drm/mediatek/mtk_dp.c line 1650
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+mtk_dp_hwirq_get_clear (mtk_dp); +struct mtk_dp_train_info *train_info = &mtk_dp->train_info; + +if (irq_status &MTK_DP_HPD_INTERRUPT ) + train_info->irq_sta.hpd_inerrupt = true; +if (irq_status &MTK_DP_HPD_CONNECT ) + train_info->irq_sta.hpd_connect = true; +if (irq_status &MTK_DP_HPD_DISCONNECT ) + train_info->irq_sta.hpd_disconnect = true; +
train_info->irq_sta.hpd_connect is used only in this function, so let hpd_connect to be local variable.
Quoted 26 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +26
-0+if (!irq_status) +return IRQ_HANDLED ; + + connected =mtk_dp_plug_state (mtk_dp); +if (connected || !train_info->cable_plugged_in) + train_info->irq_sta.hpd_disconnect = false; +else if (!connected || train_info->cable_plugged_in) + train_info->irq_sta.hpd_connect = false; + +if (!(train_info->irq_sta.hpd_connect || + train_info->irq_sta.hpd_disconnect)) +return IRQ_WAKE_THREAD ; + +if (train_info->irq_sta.hpd_connect) { + train_info->irq_sta.hpd_connect = false; + train_info->cable_plugged_in = true; + }else { + train_info->irq_sta.hpd_disconnect = false; + train_info->cable_plugged_in = false; + mtk_dp->train_state =MTK_DP_TRAIN_STATE_TRAINING ; + } + train_info->cable_state_change = true; + +return IRQ_WAKE_THREAD ; +} +
[snip]
Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ +static ssize_t mtk_dp_aux_transfer (struct drm_dp_aux *mtk_aux, +struct drm_dp_aux_msg *msg) +{
drivers/gpu/drm/mediatek/mtk_dp.c line 1771
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+struct mtk_dp *mtk_dp; +bool is_read; +u8 request; +size_t accessed_bytes =0 ; +int ret =0 ; + + mtk_dp = container_of(mtk_aux, struct mtk_dp, aux); + +if (!mtk_dp->train_info.cable_plugged_in || + mtk_dp->train_info.irq_sta.hpd_disconnect) {
In mtk_dp_hpd_isr_handler(), train_info.irq_sta.hpd_disconnect would finally be set to false, so you need not to check it here. So remove it here.
Regards,
CK
Quoted 67 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+ ret = -EAGAIN ; + goto err; + } + +switch (msg->request) { +case DP_AUX_I2C_MOT : +case DP_AUX_I2C_WRITE : +case DP_AUX_NATIVE_WRITE : +case DP_AUX_I2C_WRITE_STATUS_UPDATE : +case DP_AUX_I2C_WRITE_STATUS_UPDATE |DP_AUX_I2C_MOT : + request = msg->request &~DP_AUX_I2C_WRITE_STATUS_UPDATE;
drivers/gpu/drm/mediatek/mtk_dp.c new file +18
-0+ is_read = false; +break ; +case DP_AUX_I2C_READ : +case DP_AUX_NATIVE_READ : +case DP_AUX_I2C_READ |DP_AUX_I2C_MOT : + request = msg->request; + is_read = true; +break ; +default : +drm_err (mtk_aux->drm_dev,"invalid aux cmd = %d\n" , + msg->request); + ret = -EINVAL ; + goto err; + } + +if (msg->size ==0 ) { + ret = mtk_dp_aux_do_transfer(mtk_dp, is_read, request, + msg->address +
accessed_bytes,(quoted diff) +1
-0+ msg->buffer +
accessed_bytes, 0);drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ }else { +while (accessed_bytes < msg->size) { +size_t to_access = +min_t (size_t,DP_AUX_MAX_PAYLOAD_BYTES , + msg->size - accessed_bytes); + + ret = mtk_dp_aux_do_transfer(mtk_dp, is_read,request,
(quoted diff) +1
-0+ msg->address +
accessed_bytes,(quoted diff) +1
-0+ msg->buffer +
accessed_bytes,drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ to_access); + +if (ret) { + drm_info(mtk_dp->drm_dev, + "Failed to do AUX transfer:%d\n", ret);
drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+break ; + } + accessed_bytes += to_access; + } + } +err: +if (ret) { + msg->reply = DP_AUX_NATIVE_REPLY_NACK |
DP_AUX_I2C_REPLY_NACK;drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+return ret; + } + + msg->reply =DP_AUX_NATIVE_REPLY_ACK |DP_AUX_I2C_REPLY_ACK ; +return msg->size; +} +
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
Quoted 75 lines · CK Hu
Hi, Bo-Chen:
Quoted 28 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 41 lines
(quoted diff) +2
-0+ +static int mtk_dp_train_flow(struct mtk_dp *mtk_dp, u8
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ u8 target_lane_count) +{ +u8 lane_adjust[2 ] = {}; +bool pass_tps1 = false; +bool pass_tps2_3 = false; +int train_retries; +int status_control; +int iteration_count; +int ret; +u8 prev_lane_adjust; + + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LINK_BW_SET,
target_link_rate);drivers/gpu/drm/mediatek/mtk_dp.c new file +2
-0+ drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LANE_COUNT_SET, + target_lane_count |
DP_LANE_COUNT_ENHANCED_FRAME_EN);drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ +if (mtk_dp->train_info.sink_ssc) +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_DOWNSPREAD_CTRL , +DP_SPREAD_AMP_0_5 ); + + train_retries =0 ; + status_control =0 ; + iteration_count =1 ; + prev_lane_adjust =0xFF ; + +mtk_dp_set_lanes (mtk_dp, target_lane_count /2 ); + ret = mtk_dp_phy_configure(mtk_dp, target_link_rate,
target_lane_count);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+if (ret) +return -EINVAL ; + + dev_dbg(mtk_dp->dev, + "Link train target_link_rate = 0x%x, target_lane_count= 0x%x\n",
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ target_link_rate, target_lane_count); + + do {
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1350
Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ train_retries++; +if (!mtk_dp->train_info.cable_plugged_in || + mtk_dp->train_info.irq_sta.hpd_disconnect) {In
mtk_dp_hpd_isr_handler(), train_info.irq_sta.hpd_disconnect would finally be set to false, so you need not to check it here. So remove it
here.
Hello CK,
ok, I will drop this.
Quoted 89 lines
Quoted 66 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+return -ENODEV ; + } + +if (mtk_dp->train_state <MTK_DP_TRAIN_STATE_TRAINING ) +return -EAGAIN ; + +if (!pass_tps1) { + ret = mtk_dp_train_tps_1(mtk_dp,
target_lane_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +1
-0+ &iteration_count,
lane_adjust,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &status_control, + &prev_lane_adjust); +if (!ret) { + pass_tps1 = true; + train_retries =0 ; + }else if (ret == -EINVAL ) { +break ; + } + }else { + ret = mtk_dp_train_tps_2_3(mtk_dp,
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ target_lane_count, + &iteration_count, + lane_adjust,
&status_control,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &prev_lane_adjust); +if (!ret) { + pass_tps2_3 = true; +break ; + }else if (ret == -EINVAL ) { +break ; + } + } + + drm_dp_dpcd_read(&mtk_dp->aux,
DP_ADJUST_REQUEST_LANE0_1,(quoted diff) +2
-0+ lane_adjust, sizeof(lane_adjust)); + mtk_dp_train_update_swing_pre(mtk_dp,
target_lane_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +26
-0+ lane_adjust); + }while (train_retries <MTK_DP_TRAIN_RETRY_LIMIT && + iteration_count <MTK_DP_TRAIN_MAX_ITERATIONS ); + +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_TRAINING_PATTERN_SET , +DP_TRAINING_PATTERN_DISABLE ); + ret =mtk_dp_train_set_pattern (mtk_dp,0 ); +if (ret) +return -EINVAL ; + +if (!pass_tps2_3) +return -ETIMEDOUT ; + + mtk_dp->train_info.link_rate = target_link_rate; + mtk_dp->train_info.lane_count = target_lane_count; + +mtk_dp_training_set_scramble (mtk_dp, true); + +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_LANE_COUNT_SET , + target_lane_count | +DP_LANE_COUNT_ENHANCED_FRAME_EN ); +mtk_dp_set_enhanced_frame_mode (mtk_dp, true); + +return ret; +} +[snip]
Quoted 20 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ +/* +* We need to handle HPD signal in eDP even though eDP is a always connected
+ * device. Besides connected status, there is another feature for HPD signal -
+ * HPD pulse: it presents an IRQ from sink devices to source devices
(Refer to
+ * 5.1.4 of DP1.4 spec).
+ */drivers/gpu/drm/mediatek/mtk_dp.c new file +9
-0+static irqreturn_t mtk_dp_hpd_isr_handler (struct mtk_dp *mtk_dp) +{ +bool connected; +u32 irq_status =mtk_dp_swirq_get_clear (mtk_dp) | +mtk_dp_hwirq_get_clear (mtk_dp); +struct mtk_dp_train_info *train_info = &mtk_dp->train_info; + +if (irq_status &MTK_DP_HPD_INTERRUPT ) + train_info->irq_sta.hpd_inerrupt = true;
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1650
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+if (irq_status &MTK_DP_HPD_CONNECT ) + train_info->irq_sta.hpd_connect = true; +if (irq_status &MTK_DP_HPD_DISCONNECT ) + train_info->irq_sta.hpd_disconnect = true; +
train_info->irq_sta.hpd_connectis used only in this function, so lethpd_connectto be local variable.
ok
Quoted 40 lines
Quoted 26 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +26
-0+if (!irq_status) +return IRQ_HANDLED ; + + connected =mtk_dp_plug_state (mtk_dp); +if (connected || !train_info->cable_plugged_in) + train_info->irq_sta.hpd_disconnect = false; +else if (!connected || train_info->cable_plugged_in) + train_info->irq_sta.hpd_connect = false; + +if (!(train_info->irq_sta.hpd_connect || + train_info->irq_sta.hpd_disconnect)) +return IRQ_WAKE_THREAD ; + +if (train_info->irq_sta.hpd_connect) { + train_info->irq_sta.hpd_connect = false; + train_info->cable_plugged_in = true; + }else { + train_info->irq_sta.hpd_disconnect = false; + train_info->cable_plugged_in = false; + mtk_dp->train_state =MTK_DP_TRAIN_STATE_TRAINING ; + } + train_info->cable_state_change = true; + +return IRQ_WAKE_THREAD ; +} +[snip]
Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+ +static ssize_t mtk_dp_aux_transfer (struct drm_dp_aux *mtk_aux, +struct drm_dp_aux_msg *msg) +{ +struct mtk_dp *mtk_dp; +bool is_read; +u8 request; +size_t accessed_bytes =0 ; +int ret =0 ; + + mtk_dp = container_of(mtk_aux, struct mtk_dp, aux);
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1350
Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ +if (!mtk_dp->train_info.cable_plugged_in || + mtk_dp->train_info.irq_sta.hpd_disconnect) {In
mtk_dp_hpd_isr_handler(), train_info.irq_sta.hpd_disconnect would finally be set to false, so you need not to check it here. So remove it
here.
ok, I will drop this
BRs,
Bo-Chen
Quoted 72 lines
Regards,
CKQuoted 67 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+ ret = -EAGAIN ; + goto err; + } + +switch (msg->request) { +case DP_AUX_I2C_MOT : +case DP_AUX_I2C_WRITE : +case DP_AUX_NATIVE_WRITE : +case DP_AUX_I2C_WRITE_STATUS_UPDATE : +case DP_AUX_I2C_WRITE_STATUS_UPDATE |DP_AUX_I2C_MOT : + request = msg->request &~DP_AUX_I2C_WRITE_STATUS_UPDATE;
drivers/gpu/drm/mediatek/mtk_dp.c new file +18
-0+ is_read = false; +break ; +case DP_AUX_I2C_READ : +case DP_AUX_NATIVE_READ : +case DP_AUX_I2C_READ |DP_AUX_I2C_MOT : + request = msg->request; + is_read = true; +break ; +default : +drm_err (mtk_aux->drm_dev,"invalid aux cmd = %d\n" , + msg->request); + ret = -EINVAL ; + goto err; + } + +if (msg->size ==0 ) { + ret = mtk_dp_aux_do_transfer(mtk_dp, is_read, request, + msg->address +
accessed_bytes,(quoted diff) +1
-0+ msg->buffer +
accessed_bytes, 0);drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ }else { +while (accessed_bytes < msg->size) { +size_t to_access = +min_t (size_t,DP_AUX_MAX_PAYLOAD_BYTES , + msg->size - accessed_bytes); + + ret = mtk_dp_aux_do_transfer(mtk_dp, is_read,request,
(quoted diff) +1
-0+ msg->address +
accessed_bytes,(quoted diff) +1
-0+ msg->buffer +
accessed_bytes,drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ to_access); + +if (ret) { + drm_info(mtk_dp->drm_dev, + "Failed to do AUX transfer:%d\n", ret);
drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+break ; + } + accessed_bytes += to_access; + } + } +err: +if (ret) { + msg->reply = DP_AUX_NATIVE_REPLY_NACK |
DP_AUX_I2C_REPLY_NACK;drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+return ret; + } + + msg->reply =DP_AUX_NATIVE_REPLY_ACK |DP_AUX_I2C_REPLY_ACK ; +return msg->size; +} +
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 21 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ +static int mtk_dp_parse_capabilities (struct mtk_dp *mtk_dp) +{ +u8 val; +struct mtk_dp_train_info *train_info = &mtk_dp->train_info; + + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER,
DP_SET_POWER_D0);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+usleep_range (2000 ,5000 ); + +drm_dp_read_dpcd_caps (&mtk_dp->aux, mtk_dp->rx_cap); + + mtk_dp->rx_cap[DP_TRAINING_AUX_RD_INTERVAL] &=
DP_TRAINING_AUX_RD_MASK;drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ + train_info->link_rate = min_t(int, mtk_dp->max_linkrate, + mtk_dp->rx_cap[mtk_dp-Quoted 1 line
max_linkrate]);(quoted diff) +2
-0+ train_info->lane_count = min_t(int, mtk_dp->max_lanes, + drm_dp_max_lane_count(mtk_dp-Quoted 1 line
rx_cap));
drivers/gpu/drm/mediatek/mtk_dp.c line 1432
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+ + train_info->tps3 =drm_dp_tps3_supported (mtk_dp->rx_cap); + train_info->tps4 =drm_dp_tps4_supported (mtk_dp->rx_cap); + + train_info->sink_ssc = !!(mtk_dp->rx_cap[DP_MAX_DOWNSPREAD ] & +DP_MAX_DOWNSPREAD_0_5 );
I think this is redundant because next statement would set sink_scc to false.
Regards,
CK
Quoted 18 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+ + train_info->sink_ssc = false; + +drm_dp_dpcd_readb (&mtk_dp->aux,DP_MSTM_CAP , &val); +if (val &DP_MST_CAP ) { +/* Clear DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0 */ + drm_dp_dpcd_readb(&mtk_dp->aux, + DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0,&val);
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+if (val) +drm_dp_dpcd_writeb (&mtk_dp->aux, + DP_DEVICE_SERVICE_IRQ_VECTOR
_ESI0,drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ val); + } + +return 0 ; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
Quoted 68 lines · CK Hu
Hi, Bo-Chen:
Quoted 28 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 23 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ +static int mtk_dp_parse_capabilities (struct mtk_dp *mtk_dp) +{ +u8 val; +struct mtk_dp_train_info *train_info = &mtk_dp->train_info; + + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER,
DP_SET_POWER_D0);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+usleep_range (2000 ,5000 ); + +drm_dp_read_dpcd_caps (&mtk_dp->aux, mtk_dp->rx_cap); + + mtk_dp->rx_cap[DP_TRAINING_AUX_RD_INTERVAL] &=
DP_TRAINING_AUX_RD_MASK;drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ + train_info->link_rate = min_t(int, mtk_dp->max_linkrate, + mtk_dp->rx_cap[mtk_dp-Quoted 1 line
max_linkrate]);(quoted diff) +2
-0+ train_info->lane_count = min_t(int, mtk_dp->max_lanes, + drm_dp_max_lane_count(mtk_dp-Quoted 1 line
rx_cap));drivers/gpu/drm/mediatek/mtk_dp.c line 1432
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+ + train_info->tps3 =drm_dp_tps3_supported (mtk_dp->rx_cap); + train_info->tps4 =drm_dp_tps4_supported (mtk_dp->rx_cap); + + train_info->sink_ssc = !!(mtk_dp->rx_cap[DP_MAX_DOWNSPREAD ] & +DP_MAX_DOWNSPREAD_0_5 );I think this is redundant because next statement would set
sink_sccto
false.
Quoted 3 lines
Regards,
CK
Hello Ck,
I will remove "train_info->sink_ssc = false;"
BRs,
Bo-Chen
Quoted 20 lines
Quoted 18 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+ + train_info->sink_ssc = false; + +drm_dp_dpcd_readb (&mtk_dp->aux,DP_MSTM_CAP , &val); +if (val &DP_MST_CAP ) { +/* Clear DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0 */ + drm_dp_dpcd_readb(&mtk_dp->aux, + DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0,&val);
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+if (val) +drm_dp_dpcd_writeb (&mtk_dp->aux, + DP_DEVICE_SERVICE_IRQ_VECTOR
_ESI0,drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ val); + } + +return 0 ; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 38 lines
(quoted diff) +2
-0+ +static int mtk_dp_train_flow(struct mtk_dp *mtk_dp, u8
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ u8 target_lane_count) +{ +u8 lane_adjust[2 ] = {}; +bool pass_tps1 = false; +bool pass_tps2_3 = false; +int train_retries; +int status_control; +int iteration_count; +int ret; +u8 prev_lane_adjust; + + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LINK_BW_SET,
target_link_rate);drivers/gpu/drm/mediatek/mtk_dp.c new file +2
-0+ drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LANE_COUNT_SET, + target_lane_count |
DP_LANE_COUNT_ENHANCED_FRAME_EN);drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ +if (mtk_dp->train_info.sink_ssc) +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_DOWNSPREAD_CTRL , +DP_SPREAD_AMP_0_5 ); + + train_retries =0 ; + status_control =0 ; + iteration_count =1 ; + prev_lane_adjust =0xFF ; + +mtk_dp_set_lanes (mtk_dp, target_lane_count /2 ); + ret = mtk_dp_phy_configure(mtk_dp, target_link_rate,
target_lane_count);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+if (ret) +return -EINVAL ; + + dev_dbg(mtk_dp->dev, + "Link train target_link_rate = 0x%x, target_lane_count= 0x%x\n",
drivers/gpu/drm/mediatek/mtk_dp.c line 1354
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ target_link_rate, target_lane_count); + + do { + train_retries++; + if (!mtk_dp->train_info.cable_plugged_in || + mtk_dp->train_info.irq_sta.hpd_disconnect) { + return -ENODEV; + } + + if (mtk_dp->train_state < MTK_DP_TRAIN_STATE_TRAINING)
This checking would never be true, so remove it.
Quoted 36 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+return -EAGAIN ; + +if (!pass_tps1) { + ret = mtk_dp_train_tps_1(mtk_dp,
target_lane_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +1
-0+ &iteration_count,
lane_adjust,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &status_control, + &prev_lane_adjust); +if (!ret) { + pass_tps1 = true; + train_retries =0 ; + }else if (ret == -EINVAL ) { +break ; + } + }else { + ret = mtk_dp_train_tps_2_3(mtk_dp,
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ target_lane_count, + &iteration_count, + lane_adjust,
&status_control,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &prev_lane_adjust); +if (!ret) { + pass_tps2_3 = true; +break ; + }else if (ret == -EINVAL ) { +break ; + } + } + + drm_dp_dpcd_read(&mtk_dp->aux,
DP_ADJUST_REQUEST_LANE0_1,(quoted diff) +2
-0+ lane_adjust, sizeof(lane_adjust)); + mtk_dp_train_update_swing_pre(mtk_dp,
target_lane_count,
drivers/gpu/drm/mediatek/mtk_dp.c line 1387
Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ lane_adjust); + }while (train_retries <MTK_DP_TRAIN_RETRY_LIMIT && + iteration_count <MTK_DP_TRAIN_MAX_ITERATIONS );
mtk_dp_train_tps_1() & mtk_dp_train_tps_2_3() would only be called once and never be called twice, so remove this loop.
Regards,
CK
Quoted 22 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +22
-0+ +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_TRAINING_PATTERN_SET , +DP_TRAINING_PATTERN_DISABLE ); + ret =mtk_dp_train_set_pattern (mtk_dp,0 ); +if (ret) +return -EINVAL ; + +if (!pass_tps2_3) +return -ETIMEDOUT ; + + mtk_dp->train_info.link_rate = target_link_rate; + mtk_dp->train_info.lane_count = target_lane_count; + +mtk_dp_training_set_scramble (mtk_dp, true); + +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_LANE_COUNT_SET , + target_lane_count | +DP_LANE_COUNT_ENHANCED_FRAME_EN ); +mtk_dp_set_enhanced_frame_mode (mtk_dp, true); + +return ret; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
Hi, Bo-Chen:
Quoted 120 lines · CK Hu
Hi, Bo-Chen:
Quoted 28 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 38 lines
(quoted diff) +2
-0+ +static int mtk_dp_train_flow(struct mtk_dp *mtk_dp, u8
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ u8 target_lane_count) +{ +u8 lane_adjust[2 ] = {}; +bool pass_tps1 = false; +bool pass_tps2_3 = false; +int train_retries; +int status_control; +int iteration_count; +int ret; +u8 prev_lane_adjust; + + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LINK_BW_SET,
target_link_rate);drivers/gpu/drm/mediatek/mtk_dp.c new file +2
-0+ drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LANE_COUNT_SET, + target_lane_count |
DP_LANE_COUNT_ENHANCED_FRAME_EN);drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ +if (mtk_dp->train_info.sink_ssc) +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_DOWNSPREAD_CTRL , +DP_SPREAD_AMP_0_5 ); + + train_retries =0 ; + status_control =0 ; + iteration_count =1 ; + prev_lane_adjust =0xFF ; + +mtk_dp_set_lanes (mtk_dp, target_lane_count /2 ); + ret = mtk_dp_phy_configure(mtk_dp, target_link_rate,
target_lane_count);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+if (ret) +return -EINVAL ; + + dev_dbg(mtk_dp->dev, + "Link train target_link_rate = 0x%x, target_lane_count= 0x%x\n",
drivers/gpu/drm/mediatek/mtk_dp.c line 1354
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ target_link_rate, target_lane_count); + + do { + train_retries++; + if (!mtk_dp->train_info.cable_plugged_in || + mtk_dp->train_info.irq_sta.hpd_disconnect) { + return -ENODEV; + } + + if (mtk_dp->train_state < MTK_DP_TRAIN_STATE_TRAINING)This checking would never be true, so remove it.
Quoted 35 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+return -EAGAIN ; + +if (!pass_tps1) { + ret = mtk_dp_train_tps_1(mtk_dp,
target_lane_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +1
-0+ &iteration_count,
lane_adjust,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &status_control, + &prev_lane_adjust); +if (!ret) { + pass_tps1 = true; + train_retries =0 ; + }else if (ret == -EINVAL ) { +break ; + } + }else { + ret = mtk_dp_train_tps_2_3(mtk_dp,
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ target_lane_count, + &iteration_count, + lane_adjust,
&status_control,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &prev_lane_adjust); +if (!ret) { + pass_tps2_3 = true; +break ; + }else if (ret == -EINVAL ) { +break ; + } + } + + drm_dp_dpcd_read(&mtk_dp->aux,
DP_ADJUST_REQUEST_LANE0_1,(quoted diff) +2
-0+ lane_adjust, sizeof(lane_adjust)); + mtk_dp_train_update_swing_pre(mtk_dp,
Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1387
Quoted 4 lines
target_lane_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ lane_adjust); + }while (train_retries <MTK_DP_TRAIN_RETRY_LIMIT && + iteration_count <MTK_DP_TRAIN_MAX_ITERATIONS );
mtk_dp_train_tps_1()&mtk_dp_train_tps_2_3()would only be called once
and never be called twice, so remove this loop.
Sorry, mtk_dp_train_tps_1() & mtk_dp_train_tps_2_3() may return -EAGAIN, so keep this loop.
Quoted 26 lines
Regards,
CKQuoted 22 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +22
-0+ +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_TRAINING_PATTERN_SET , +DP_TRAINING_PATTERN_DISABLE ); + ret =mtk_dp_train_set_pattern (mtk_dp,0 ); +if (ret) +return -EINVAL ; + +if (!pass_tps2_3) +return -ETIMEDOUT ; + + mtk_dp->train_info.link_rate = target_link_rate; + mtk_dp->train_info.lane_count = target_lane_count; + +mtk_dp_training_set_scramble (mtk_dp, true); + +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_LANE_COUNT_SET , + target_lane_count | +DP_LANE_COUNT_ENHANCED_FRAME_EN ); +mtk_dp_set_enhanced_frame_mode (mtk_dp, true); + +return ret; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to CK HuQuoted 76 lines · CK Hu
Hi, Bo-Chen:
Quoted 28 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 42 lines
(quoted diff) +2
-0+ +static int mtk_dp_train_flow(struct mtk_dp *mtk_dp, u8
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ u8 target_lane_count) +{ +u8 lane_adjust[2 ] = {}; +bool pass_tps1 = false; +bool pass_tps2_3 = false; +int train_retries; +int status_control; +int iteration_count; +int ret; +u8 prev_lane_adjust; + + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LINK_BW_SET,
target_link_rate);drivers/gpu/drm/mediatek/mtk_dp.c new file +2
-0+ drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LANE_COUNT_SET, + target_lane_count |
DP_LANE_COUNT_ENHANCED_FRAME_EN);drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ +if (mtk_dp->train_info.sink_ssc) +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_DOWNSPREAD_CTRL , +DP_SPREAD_AMP_0_5 ); + + train_retries =0 ; + status_control =0 ; + iteration_count =1 ; + prev_lane_adjust =0xFF ; + +mtk_dp_set_lanes (mtk_dp, target_lane_count /2 ); + ret = mtk_dp_phy_configure(mtk_dp, target_link_rate,
target_lane_count);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+if (ret) +return -EINVAL ; + + dev_dbg(mtk_dp->dev, + "Link train target_link_rate = 0x%x, target_lane_count= 0x%x\n",
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ target_link_rate, target_lane_count); + + do { + train_retries++;
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1354
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+if (!mtk_dp->train_info.cable_plugged_in || + mtk_dp->train_info.irq_sta.hpd_disconnect) { +return -ENODEV ; + } + +if (mtk_dp->train_state <MTK_DP_TRAIN_STATE_TRAINING )This checking would never be true, so remove it.
Hello CK,
ok, I will do this.
Quoted 71 lines
Quoted 36 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+return -EAGAIN ; + +if (!pass_tps1) { + ret = mtk_dp_train_tps_1(mtk_dp,
target_lane_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +1
-0+ &iteration_count,
lane_adjust,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &status_control, + &prev_lane_adjust); +if (!ret) { + pass_tps1 = true; + train_retries =0 ; + }else if (ret == -EINVAL ) { +break ; + } + }else { + ret = mtk_dp_train_tps_2_3(mtk_dp,
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ target_lane_count, + &iteration_count, + lane_adjust,
&status_control,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &prev_lane_adjust); +if (!ret) { + pass_tps2_3 = true; +break ; + }else if (ret == -EINVAL ) { +break ; + } + } + + drm_dp_dpcd_read(&mtk_dp->aux,
DP_ADJUST_REQUEST_LANE0_1,(quoted diff) +2
-0+ lane_adjust, sizeof(lane_adjust)); + mtk_dp_train_update_swing_pre(mtk_dp,
target_lane_count,drivers/gpu/drm/mediatek/mtk_dp.c line 1387
Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ lane_adjust); + }while (train_retries <MTK_DP_TRAIN_RETRY_LIMIT && + iteration_count <MTK_DP_TRAIN_MAX_ITERATIONS );
mtk_dp_train_tps_1()&mtk_dp_train_tps_2_3()would only be called once
and never be called twice, so remove this loop.Regards,
CKQuoted 22 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +22
-0+ +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_TRAINING_PATTERN_SET , +DP_TRAINING_PATTERN_DISABLE ); + ret =mtk_dp_train_set_pattern (mtk_dp,0 ); +if (ret) +return -EINVAL ; + +if (!pass_tps2_3) +return -ETIMEDOUT ; + + mtk_dp->train_info.link_rate = target_link_rate; + mtk_dp->train_info.lane_count = target_lane_count; + +mtk_dp_training_set_scramble (mtk_dp, true); + +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_LANE_COUNT_SET , + target_lane_count | +DP_LANE_COUNT_ENHANCED_FRAME_EN ); +mtk_dp_set_enhanced_frame_mode (mtk_dp, true); + +return ret; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c line 978
Quoted 5 lines
(quoted diff) +2
-0+ +static int mtk_dp_train_set_pattern(struct mtk_dp *mtk_dp, intpattern)
drivers/gpu/drm/mediatek/mtk_dp.c new file +2
-0+{ +if (pattern <0 || pattern >4 ) {
The caller would pass pattern from 0 to 4, so this checking is redundant. Remove it and this function would always return true, so let this function be void.
Regards,
CK
Quoted 22 lines
(quoted diff) +2
-0+ drm_err(mtk_dp->drm_dev, + "Implementation error, no such pattern %d\n",pattern);
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+return -EINVAL ; + } + +/* TPS1 */ +if (pattern ==1 ) +mtk_dp_set_idle_pattern (mtk_dp, false); + + mtk_dp_update_bits(mtk_dp, + MTK_DP_TRANS_P0_3400, + pattern ? + BIT(pattern - 1) <<
PATTERN1_EN_DP_TRANS_P0_SHIFT:drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+0 , +PATTERN1_EN_DP_TRANS_P0_MASK | +PATTERN2_EN_DP_TRANS_P0_MASK | +PATTERN3_EN_DP_TRANS_P0_MASK | + PATTERN4_EN_DP_TRANS_P0_MASK); +return 0 ; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
Quoted 45 lines · CK Hu
Hi, Bo-Chen:
Quoted 28 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c line 978
Quoted 5 lines
(quoted diff) +2
-0+ +static int mtk_dp_train_set_pattern(struct mtk_dp *mtk_dp, intpattern)
drivers/gpu/drm/mediatek/mtk_dp.c new file +2
-0+{ +if (pattern <0 || pattern >4 ) {The caller would pass pattern from 0 to 4, so this checking is redundant. Remove it and this function would always return true, so let
this function be void.
Quoted 3 lines
Regards,
CK
Hello CK,
ok, I will do this.
BRs,
Bo-Chen
Quoted 24 lines
Quoted 22 lines
(quoted diff) +2
-0+ drm_err(mtk_dp->drm_dev, + "Implementation error, no such pattern %d\n",pattern);
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+return -EINVAL ; + } + +/* TPS1 */ +if (pattern ==1 ) +mtk_dp_set_idle_pattern (mtk_dp, false); + + mtk_dp_update_bits(mtk_dp, + MTK_DP_TRANS_P0_3400, + pattern ? + BIT(pattern - 1) <<
PATTERN1_EN_DP_TRANS_P0_SHIFT:drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+0 , +PATTERN1_EN_DP_TRANS_P0_MASK | +PATTERN2_EN_DP_TRANS_P0_MASK | +PATTERN3_EN_DP_TRANS_P0_MASK | + PATTERN4_EN_DP_TRANS_P0_MASK); +return 0 ; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 32 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +13
-0+ +static int mtk_dp_train_start (struct mtk_dp *mtk_dp) +{ +int ret =0 ; +u8 lane_count; +u8 link_rate; +u8 train_limit; +u8 max_link_rate; + + link_rate = mtk_dp->rx_cap[1 ]; + lane_count = mtk_dp->rx_cap[2 ] &0x1F ; + + mtk_dp->train_info.link_rate = min(mtk_dp->max_linkrate,
link_rate);(quoted diff) +1
-0+ mtk_dp->train_info.lane_count = min(mtk_dp->max_lanes,
lane_count);drivers/gpu/drm/mediatek/mtk_dp.c new file +16
-0+ link_rate = mtk_dp->train_info.link_rate; + lane_count = mtk_dp->train_info.lane_count; + +switch (link_rate) { +case MTK_DP_LINKRATE_RBR : +case MTK_DP_LINKRATE_HBR : +case MTK_DP_LINKRATE_HBR2 : +case MTK_DP_LINKRATE_HBR25 : +case MTK_DP_LINKRATE_HBR3 : +break ; +default : + mtk_dp->train_info.link_rate =MTK_DP_LINKRATE_HBR3 ; +break ; + }; + + max_link_rate = link_rate;
drivers/gpu/drm/mediatek/mtk_dp.c line 1494
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+for (train_limit =6 ; train_limit >0 ; train_limit--) { + mtk_dp->train_info.cr_done = false; + mtk_dp->train_info.eq_done = false; + +mtk_dp_train_change_mode (mtk_dp); + ret =mtk_dp_train_flow (mtk_dp, link_rate, lane_count); +if (ret) +return ret; + +if (!mtk_dp->train_info.cr_done) {
When mtk_dp_train_flow() return 0, it imply train_info.cr_done is true, isn't it?
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+switch (link_rate) { +case MTK_DP_LINKRATE_RBR : + lane_count = lane_count /2 ; + link_rate = max_link_rate; +if (lane_count ==0 ) +return -EIO ; +break ; +case MTK_DP_LINKRATE_HBR : + link_rate =MTK_DP_LINKRATE_RBR ; +break ;
drivers/gpu/drm/mediatek/mtk_dp.c line 1514
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+case MTK_DP_LINKRATE_HBR2 : + link_rate =MTK_DP_LINKRATE_HBR ; +break ; +case MTK_DP_LINKRATE_HBR3 : + link_rate =MTK_DP_LINKRATE_HBR2 ; +break ; +default : +return -EINVAL ; + }; + }else if (!mtk_dp->train_info.eq_done) {
When mtk_dp_train_flow() return 0, it imply train_info.eq_done is true, isn't it?
Regards,
CK
Quoted 14 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +14
-0+if (lane_count ==0 ) +return -EIO ; + + lane_count /=2 ; + }else { +break ; + } + } + +if (train_limit ==0 ) +return -ETIMEDOUT ; + +return 0 ; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenQuoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 17 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +16
-0+ +static void mtk_dp_calculate_pixrate (struct mtk_dp *mtk_dp) +{ +u8 target_frame_rate =60 ; +u32 target_pixel_clk; +struct drm_display_mode mode; +struct mtk_dp_timings *timings = &mtk_dp->info.timings; + +drm_display_mode_from_videomode (&timings->vm, &mode); + +if (mtk_dp->info.timings.frame_rate >0 ) { + target_frame_rate = mtk_dp->info.timings.frame_rate; + target_pixel_clk = mode.htotal * mode.vtotal * + target_frame_rate; + }else if (mtk_dp->info.timings.pix_rate_khz >0 ) { + target_pixel_clk = mtk_dp->info.timings.pix_rate_khz *1000;
drivers/gpu/drm/mediatek/mtk_dp.c line 1110
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+ }else { + target_pixel_clk = mode.htotal * mode.vtotal * + target_frame_rate; + } + + mtk_dp->info.timings.pix_rate_khz = target_pixel_clk /1000 ;
It seems that pix_rate_khz is used only here and does not used in another place, so pix_rate_khz is useless, remove it.
Regards,
CK
Quoted 2 lines
(quoted diff) +2
-0+} +
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
Quoted 50 lines · CK Hu
Quoted 28 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 18 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +16
-0+ +static void mtk_dp_calculate_pixrate (struct mtk_dp *mtk_dp) +{ +u8 target_frame_rate =60 ; +u32 target_pixel_clk; +struct drm_display_mode mode; +struct mtk_dp_timings *timings = &mtk_dp->info.timings; + +drm_display_mode_from_videomode (&timings->vm, &mode); + +if (mtk_dp->info.timings.frame_rate >0 ) { + target_frame_rate = mtk_dp->info.timings.frame_rate; + target_pixel_clk = mode.htotal * mode.vtotal * + target_frame_rate; + }else if (mtk_dp->info.timings.pix_rate_khz >0 ) { + target_pixel_clk = mtk_dp->info.timings.pix_rate_khz *1000;
(quoted diff) +1
-0+ } else {
Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1110
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ target_pixel_clk = mode.htotal * mode.vtotal * + target_frame_rate; + } + + mtk_dp->info.timings.pix_rate_khz = target_pixel_clk /1000 ;It seems that
pix_rate_khzis used only here and does not used in another place, sopix_rate_khzis useless, remove it.
It seems that frame_rate is also redundant, so remove it.
Regards,
CK
Quoted 6 lines
Regards,
CKQuoted 2 lines
(quoted diff) +2
-0+} +
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
Quoted 62 lines · CK Hu
Quoted 52 lines · CK Hu
Quoted 30 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a
register range, the parent passes a regmap pointer to the child so
that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 18 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +16
-0+ +static void mtk_dp_calculate_pixrate (struct mtk_dp *mtk_dp) +{ +u8 target_frame_rate =60 ; +u32 target_pixel_clk; +struct drm_display_mode mode; +struct mtk_dp_timings *timings = &mtk_dp->info.timings; + +drm_display_mode_from_videomode (&timings->vm, &mode); + +if (mtk_dp->info.timings.frame_rate >0 ) { + target_frame_rate = mtk_dp->info.timings.frame_rate; + target_pixel_clk = mode.htotal * mode.vtotal * + target_frame_rate; + }else if (mtk_dp->info.timings.pix_rate_khz >0 ) { + target_pixel_clk = mtk_dp->info.timings.pix_rate_khz *1000;
(quoted diff) +1
-0+ } else {Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1110
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ target_pixel_clk = mode.htotal * mode.vtotal * + target_frame_rate; + } + + mtk_dp->info.timings.pix_rate_khz = target_pixel_clk /1000 ;It seems that
pix_rate_khzis used only here and does not used in another place, sopix_rate_khzis useless, remove it.
Quoted 5 lines
It seems that
frame_rateis also redundant, so remove it.Regards,
CK
I think we do use this variable in mtk_dp_parse_drm_mode_timings() We use this variable to get target framerate.
BRs,
Bo-Chen
Quoted 8 lines
Quoted 6 lines
Regards,
CKQuoted 2 lines
(quoted diff) +2
-0+} +
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to CK HuQuoted 59 lines · CK Hu
Quoted 28 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 17 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +16
-0+ +static void mtk_dp_calculate_pixrate (struct mtk_dp *mtk_dp) +{ +u8 target_frame_rate =60 ; +u32 target_pixel_clk; +struct drm_display_mode mode; +struct mtk_dp_timings *timings = &mtk_dp->info.timings; + +drm_display_mode_from_videomode (&timings->vm, &mode); + +if (mtk_dp->info.timings.frame_rate >0 ) { + target_frame_rate = mtk_dp->info.timings.frame_rate; + target_pixel_clk = mode.htotal * mode.vtotal * + target_frame_rate; + }else if (mtk_dp->info.timings.pix_rate_khz >0 ) { + target_pixel_clk = mtk_dp->info.timings.pix_rate_khz *1000;
drivers/gpu/drm/mediatek/mtk_dp.c line 1110
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+ }else { + target_pixel_clk = mode.htotal * mode.vtotal * + target_frame_rate; + } + + mtk_dp->info.timings.pix_rate_khz = target_pixel_clk /1000 ;It seems that
pix_rate_khzis used only here and does not used in another place, sopix_rate_khzis useless, remove it.
Quoted 3 lines
Regards,
CK
this variable will be used in audio patch.
I will move it to audio patch.
BRs,
Bo-Chen
Quoted 4 lines
Quoted 2 lines
(quoted diff) +2
-0+} +
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Rex:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 3 lines
(quoted diff) +2
-0+ +static void mtk_dp_set_color_depth(struct mtk_dp *mtk_dp, u32
color_depth)
In the whole driver, the color_depth would only be DP_MSA_MISC_8_BPC, so remove the parameter color_depth and fix the color depth to DP_MSA_MISC_8_BPC in this function.
Regards,
CK
Quoted 36 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +27
-0+{ +u32 val; + + mtk_dp->info.depth = color_depth; + +/* Update MISC0 */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3034 , + color_depth,DP_TEST_BIT_DEPTH_MASK ); + +switch (color_depth) { +case DP_MSA_MISC_6_BPC : + val =VIDEO_COLOR_DEPTH_DP_ENC0_P0_6BIT ; +break ; +case DP_MSA_MISC_8_BPC : + val =VIDEO_COLOR_DEPTH_DP_ENC0_P0_8BIT ; +break ; +case DP_MSA_MISC_10_BPC : + val =VIDEO_COLOR_DEPTH_DP_ENC0_P0_10BIT ; +break ; +case DP_MSA_MISC_12_BPC : + val =VIDEO_COLOR_DEPTH_DP_ENC0_P0_12BIT ; +break ; +case DP_MSA_MISC_16_BPC : + val =VIDEO_COLOR_DEPTH_DP_ENC0_P0_16BIT ; +break ; +default : + drm_warn(mtk_dp->drm_dev, "Unsupported color depth%d\n",
drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+ color_depth); +return ; + } + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_303C , val, +VIDEO_COLOR_DEPTH_DP_ENC0_P0_MASK ); +} +
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Rex:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ +static void mtk_dp_poweroff (struct mtk_dp *mtk_dp) +{ +mutex_lock (&mtk_dp->dp_lock); + +mtk_dp_hwirq_enable (mtk_dp, false); +mtk_dp_power_disable (mtk_dp);
drivers/gpu/drm/mediatek/mtk_dp.c line 1846
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+phy_exit (mtk_dp->phy); + +mutex_unlock (&mtk_dp->dp_lock); +} + +static int mtk_dp_poweron (struct mtk_dp *mtk_dp) +{ +int ret =0 ; + +mutex_lock (&mtk_dp->dp_lock);
The dp_poweron/off is only called by bridge_attach/detach, and I think drm core would not call attach/detach concurrently, so this mutex is redundant. Remove it.
Regards,
CK
Quoted 23 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ + ret =phy_init (mtk_dp->phy); +if (ret) { + dev_err(mtk_dp->dev, "Failed to initialize phy: %d\n",ret);
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ goto err_phy_init; + } + ret =mtk_dp_phy_configure (mtk_dp,MTK_DP_LINKRATE_RBR ,1 ); +if (ret) { + dev_err(mtk_dp->dev, "Failed to configure phy: %d\n",ret);
drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ goto err_phy_config; + } + +mtk_dp_init_port (mtk_dp); +mtk_dp_power_enable (mtk_dp); + +err_phy_config: +phy_exit (mtk_dp->phy); +err_phy_init: +mutex_unlock (&mtk_dp->dp_lock); +return ret; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Rex:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 17 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ +static int mtk_dp_bridge_atomic_check (struct drm_bridge *bridge, + struct drm_bridge_state
*bridge_state,(quoted diff) +1
-0+ struct drm_crtc_state
*crtc_state,(quoted diff) +1
-0+ struct drm_connector_state
*conn_state)drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+{ +struct mtk_dp *mtk_dp =mtk_dp_from_bridge (bridge); +struct drm_crtc *crtc = conn_state->crtc; +unsigned int input_bus_format; + + input_bus_format = bridge_state->input_bus_cfg.format; + + dev_dbg(mtk_dp->dev, "input format 0x%04x, output format0x%04x\n",
drivers/gpu/drm/mediatek/mtk_dp.c line 2068
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ bridge_state->input_bus_cfg.format, + bridge_state->output_bus_cfg.format); + + mtk_dp->input_fmt = input_bus_format; +if (mtk_dp->input_fmt ==MEDIA_BUS_FMT_YUYV8_1X16 )
input_fmt is used only in this function, so let it be local variable.
Regards,
CK
Quoted 22 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ mtk_dp->info.format =DP_PIXELFORMAT_YUV422 ; + else + mtk_dp->info.format = DP_PIXELFORMAT_RGB; + +if (!crtc) { + drm_err(mtk_dp->drm_dev, + "Can't enable bridge as connector state doesn'thave a crtc\n");
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+return -EINVAL ; + } + + mtk_dp_parse_drm_mode_timings(mtk_dp, &crtc_state-Quoted 1 line
adjusted_mode);drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+if (mtk_dp_parse_capabilities (mtk_dp)) { + drm_err(mtk_dp->drm_dev, + "Can't enable bridge as nothing is pluggedin\n");
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+return -EINVAL ; + } + +return 0 ; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
Quoted 59 lines · CK Hu
Hi, Rex:
Quoted 28 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 17 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ +static int mtk_dp_bridge_atomic_check (struct drm_bridge *bridge, + struct drm_bridge_state
*bridge_state,(quoted diff) +1
-0+ struct drm_crtc_state
*crtc_state,(quoted diff) +1
-0+ struct drm_connector_state
*conn_state)drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+{ +struct mtk_dp *mtk_dp =mtk_dp_from_bridge (bridge); +struct drm_crtc *crtc = conn_state->crtc; +unsigned int input_bus_format; + + input_bus_format = bridge_state->input_bus_cfg.format; + + dev_dbg(mtk_dp->dev, "input format 0x%04x, output format0x%04x\n",
drivers/gpu/drm/mediatek/mtk_dp.c line 2068
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ bridge_state->input_bus_cfg.format, + bridge_state->output_bus_cfg.format); + + mtk_dp->input_fmt = input_bus_format; +if (mtk_dp->input_fmt ==MEDIA_BUS_FMT_YUYV8_1X16 )
input_fmtis used only in this function, so let it be local variable.
Quoted 3 lines
Regards,
CK
ok, I will do this.
BRs,
Bo-Chen
Quoted 25 lines
Quoted 23 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ mtk_dp->info.format =DP_PIXELFORMAT_YUV422 ; + else + mtk_dp->info.format = DP_PIXELFORMAT_RGB; + +if (!crtc) { + drm_err(mtk_dp->drm_dev, + "Can't enable bridge as connector state doesn'thave a crtc\n");
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+return -EINVAL ; + } + + mtk_dp_parse_drm_mode_timings(mtk_dp, &crtc_state-Quoted 1 line
adjusted_mode);drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+if (mtk_dp_parse_capabilities (mtk_dp)) { + drm_err(mtk_dp->drm_dev, + "Can't enable bridge as nothing is pluggedin\n");
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+return -EINVAL ; + } + +return 0 ; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 23 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +18
-0+ +static int mtk_dp_probe (struct platform_device *pdev) +{ +struct mtk_dp *mtk_dp; +struct device *dev = &pdev->dev; +int ret; +int irq_num =0 ; + + mtk_dp =devm_kzalloc (dev,sizeof (*mtk_dp),GFP_KERNEL ); +if (!mtk_dp) +return -ENOMEM ; + + mtk_dp->dev = dev; + + irq_num =platform_get_irq (pdev,0 ); +if (irq_num <0 ) + return dev_err_probe(dev, irq_num, + "failed to request dp irqresource\n");
(quoted diff) +2
-0+ + mtk_dp->next_bridge = devm_drm_of_get_bridge(dev, dev->of_node,1, 0);
drivers/gpu/drm/mediatek/mtk_dp.c new file +1
-0+if (IS_ERR (mtk_dp->next_bridge))
drivers/gpu/drm/mediatek/mtk_dp.c line 2133
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+return dev_err_probe (dev,PTR_ERR (mtk_dp->next_bridge), +"Failed to get bridge\n" ); + + ret =mtk_dp_dt_parse (mtk_dp, pdev); +if (ret) +return dev_err_probe (dev, ret,"Failed to parse dt\n" ); + +drm_dp_aux_init (&mtk_dp->aux); + mtk_dp->aux.name ="aux_mtk_dp" ; + mtk_dp->aux.transfer = mtk_dp_aux_transfer;
In the comment of drm_dp_aux_init(), drm_dp_aux_init() is used before drm_dp_aux_register(). So I think we still need to call drm_dp_aux_register().
Regards,
CK
Quoted 52 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ + ret = devm_request_threaded_irq(dev, irq_num, mtk_dp_hpd_event, + mtk_dp_hpd_event_thread, + IRQ_TYPE_LEVEL_HIGH,
dev_name(dev),drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ mtk_dp); +if (ret) + return dev_err_probe(dev, -EPROBE_DEFER, + "failed to request mediatek dptxirq\n");
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+ +mutex_init (&mtk_dp->dp_lock); + +platform_set_drvdata (pdev, mtk_dp); + + mtk_dp->phy_dev = platform_device_register_data(dev, "mediatek-dp-phy",
(quoted diff) +1
-0+ PLATFORM_DEVID_AUTO,
(quoted diff) +2
-0+ &mtk_dp->regs, + sizeof(structregmap *));
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+if (IS_ERR (mtk_dp->phy_dev)) + return dev_err_probe(dev, PTR_ERR(mtk_dp->phy_dev), + "Failed to create device mediatek-dp-phy\n");
drivers/gpu/drm/mediatek/mtk_dp.c new file +16
-0+ +mtk_dp_get_calibration_data (mtk_dp); + + mtk_dp->phy =devm_phy_get (&mtk_dp->phy_dev->dev,"dp" ); + +if (IS_ERR (mtk_dp->phy)) { +platform_device_unregister (mtk_dp->phy_dev); +return dev_err_probe (dev,PTR_ERR (mtk_dp->phy), +"Failed to get phy\n" ); + } + + mtk_dp->bridge.funcs = &mtk_dp_bridge_funcs; + mtk_dp->bridge.of_node = dev->of_node; + + mtk_dp->bridge.ops = + DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
DRM_BRIDGE_OP_HPD;drivers/gpu/drm/mediatek/mtk_dp.c new file +9
-0+ mtk_dp->bridge.type = DRM_MODE_CONNECTOR_eDP; + +drm_bridge_add (&mtk_dp->bridge); + +pm_runtime_enable (dev); +pm_runtime_get_sync (dev); + +return 0 ; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp_reg.h line 243
Quoted 2 lines
drivers/gpu/drm/mediatek/mtk_dp_reg.h new file +2
-0+ +#define MTK_DP_ENC0_P0_3130 (ENC0_OFFSET + 0x130)
This is useless in this patch, so remove it.
If this is used in later patch, add this back in that patch.
Quoted 1 line
+#define
MTK_DP_ENC0_P0_3138(ENC0_OFFSET+0x138)
Ditto.
Regards,
CK
Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dp_reg.h new file +3
-0+#define MTK_DP_ENC0_P0_3154 (ENC0_OFFSET + 0x154) +#define PGEN_HTOTAL_DP_ENC0_P0_MASK GENMASK(13, 0) +#define MTK_DP_ENC0_P0_3158 (ENC0_OFFSET + 0x158)
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 17 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ +static int mtk_dp_parse_capabilities (struct mtk_dp *mtk_dp) +{ +u8 val; +struct mtk_dp_train_info *train_info = &mtk_dp->train_info; + + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER,
DP_SET_POWER_D0);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+usleep_range (2000 ,5000 ); + +drm_dp_read_dpcd_caps (&mtk_dp->aux, mtk_dp->rx_cap); + + mtk_dp->rx_cap[DP_TRAINING_AUX_RD_INTERVAL] &=
DP_TRAINING_AUX_RD_MASK;drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ + train_info->link_rate = min_t(int, mtk_dp->max_linkrate, + mtk_dp->rx_cap[mtk_dp-
Quoted 1 line
Quoted 1 line
max_linkrate]);
drm_dp_max_link_rate(mtk_dp->rx_cap)
Regards,
CK
Quoted 27 lines
(quoted diff) +2
-0+ train_info->lane_count = min_t(int, mtk_dp->max_lanes, + drm_dp_max_lane_count(mtk_dp-Quoted 1 line
rx_cap));drivers/gpu/drm/mediatek/mtk_dp.c new file +14
-0+ + train_info->tps3 =drm_dp_tps3_supported (mtk_dp->rx_cap); + train_info->tps4 =drm_dp_tps4_supported (mtk_dp->rx_cap); + + train_info->sink_ssc = !!(mtk_dp->rx_cap[DP_MAX_DOWNSPREAD ] & +DP_MAX_DOWNSPREAD_0_5 ); + + train_info->sink_ssc = false; + +drm_dp_dpcd_readb (&mtk_dp->aux,DP_MSTM_CAP , &val); +if (val &DP_MST_CAP ) { +/* Clear DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0 */ + drm_dp_dpcd_readb(&mtk_dp->aux, + DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0,&val);
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+if (val) +drm_dp_dpcd_writeb (&mtk_dp->aux, + DP_DEVICE_SERVICE_IRQ_VECTOR
_ESI0,drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ val); + } + +return 0 ; +}
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c line 86
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +9
-0+ +/* multiple of 0.27Gbps */ +enum mtk_dp_linkrate { +MTK_DP_LINKRATE_RBR =0x6 , +MTK_DP_LINKRATE_HBR =0xA , +MTK_DP_LINKRATE_HBR2 =0x14 , +MTK_DP_LINKRATE_HBR25 =0x19 , +MTK_DP_LINKRATE_HBR3 =0x1E , +};
Use the definition in drm_dp.h:
/* Link Configuration */
#define DP_LINK_BW_SET 0x100
# define DP_LINK_RATE_TABLE 0x00 /* eDP 1.4 */ # define DP_LINK_BW_1_62 0x06 # define DP_LINK_BW_2_7 0x0a # define DP_LINK_BW_5_4 0x14 /* 1.2 */ # define DP_LINK_BW_8_1 0x1e /* 1.4 */ # define DP_LINK_BW_10 0x01 /* 2.0 128b/132b Link Layer */ # define DP_LINK_BW_13_5 0x04 /* 2.0 128b/132b Link Layer */ # define DP_LINK_BW_20 0x02 /* 2.0 128b/132b Link Layer */
Regards,
CK
Quoted 2 lines
Re: [PATCH v11 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 26 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>[Bo-Chen: Cleanup the drivers and modify comments from reviewers]Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 13 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ +static int mtk_dp_parse_capabilities (struct mtk_dp *mtk_dp) +{ +u8 val; +struct mtk_dp_train_info *train_info = &mtk_dp->train_info; + + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER,
DP_SET_POWER_D0);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+usleep_range (2000 ,5000 ); + +drm_dp_read_dpcd_caps (&mtk_dp->aux, mtk_dp->rx_cap); + + mtk_dp->rx_cap[DP_TRAINING_AUX_RD_INTERVAL] &=
Quoted 1 line
DP_TRAINING_AUX_RD_MASK;
You never use mtk_dp->rx_cap[DP_TRAINING_AUX_RD_INTERVAL], why do you modify it?
Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ + train_info->link_rate = min_t(int, mtk_dp->max_linkrate, + mtk_dp->rx_cap[mtk_dp-Quoted 1 line
max_linkrate]);(quoted diff) +2
-0+ train_info->lane_count = min_t(int, mtk_dp->max_lanes, + drm_dp_max_lane_count(mtk_dp-Quoted 1 line
rx_cap));
drivers/gpu/drm/mediatek/mtk_dp.c line 1433
Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ + train_info->tps3 =drm_dp_tps3_supported (mtk_dp->rx_cap); + train_info->tps4 =drm_dp_tps4_supported (mtk_dp->rx_cap); + + train_info->sink_ssc = !!(mtk_dp->rx_cap[DP_MAX_DOWNSPREAD ] & +DP_MAX_DOWNSPREAD_0_5 ); +
train_info->sink_ssc = drm_dp_max_downspread(mtk_dp->rx_cap);
Regards,
CK
Quoted 17 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ train_info->sink_ssc = false; + +drm_dp_dpcd_readb (&mtk_dp->aux,DP_MSTM_CAP , &val); +if (val &DP_MST_CAP ) { +/* Clear DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0 */ + drm_dp_dpcd_readb(&mtk_dp->aux, + DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0,&val);
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+if (val) +drm_dp_dpcd_writeb (&mtk_dp->aux, + DP_DEVICE_SERVICE_IRQ_VECTOR
_ESI0,drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ val); + } + +return 0 ; +}
PATCH v11 6/10 drm/mediatek: Add MT8195 External DisplayPort support
In reply to Bo-Chen ChenFrom: Guillaume Ranquet <[email protected]>
This patch adds External DisplayPort support to the mt8195 eDP driver.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 217 ++++++++++++++++++++++++------ 1 file changed, 174 insertions(+), 43 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +174 -43
@@ -124,6 +124,7 @@ struct mtk_dp {bool enabled; +bool has_fec;/* protect the mtk_dp struct */ struct mutex dp_lock;
@@ -138,6 +139,11 @@ static struct regmap_config mtk_dp_regmap_config = { .name = "mtk-dp-registers", }; +static bool mtk_dp_is_edp (struct mtk_dp *mtk_dp) +{ +return mtk_dp->next_bridge; +} +static struct mtk_dp *mtk_dp_from_bridge (struct drm_bridge *b) { return container_of(b, struct mtk_dp, bridge);
@@ -414,6 +420,20 @@ static bool mtk_dp_plug_state(struct mtk_dp *mtk_dp) HPD_DB_DP_TRANS_P0_MASK); } +static bool mtk_dp_plug_state_avoid_pulse (struct mtk_dp *mtk_dp) +{ +int wait; + +for (wait =7 ; !mtk_dp_plug_state (mtk_dp) && wait >0 ; --wait) +/* Avoid short pulses on the HPD isr */ +usleep_range (1000 ,5000 ); + +if (wait ==0 ) +return false; + +return true; +} +static void mtk_dp_aux_irq_clear (struct mtk_dp *mtk_dp) { mtk_dp_write(mtk_dp, MTK_DP_AUX_P0_3640,
@@ -638,6 +658,13 @@ static void mtk_dp_reset_swing_pre_emphasis(struct mtk_dp *mtk_dp) DP_TX3_PRE_EMPH_MASK); } +static void mtk_dp_fec_enable (struct mtk_dp *mtk_dp,bool enable) +{ +mtk_dp_update_bits (mtk_dp,MTK_DP_TRANS_P0_3540 , + enable ?BIT (FEC_EN_DP_TRANS_P0_SHIFT ) :0 , +FEC_EN_DP_TRANS_P0_MASK ); +} +static u32 mtk_dp_swirq_get_clear (struct mtk_dp *mtk_dp) { u32 irq_status = mtk_dp_read(mtk_dp, MTK_DP_TRANS_P0_35D0) &
@@ -865,35 +892,67 @@ static void mtk_dp_get_calibration_data(struct mtk_dp *mtk_dp)return ; } - cal_data->glb_bias_trim = -check_cal_data_valid (mtk_dp,1 ,0x1e , - (buf[3 ] >>27 ) &0x1f ,0xf ); - cal_data->clktx_impse = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[0 ] >>9 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_pmos[0 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>28 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_nmos[0 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>24 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_pmos[1 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>20 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_nmos[1 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>16 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_pmos[2 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>12 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_nmos[2 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>8 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_pmos[3 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>4 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_nmos[3 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , buf[2 ] &0xf ,0x8 ); +if (mtk_dp_is_edp (mtk_dp)) { + cal_data->glb_bias_trim = +check_cal_data_valid (mtk_dp,1 ,0x1e , + (buf[3 ] >>27 ) &0x1f ,0xf ); + cal_data->clktx_impse = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[0 ] >>9 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[0 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>28 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[0 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>24 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[1 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>20 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[1 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>16 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[2 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>12 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[2 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>8 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[3 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>4 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[3 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , buf[2 ] &0xf ,0x8 ); + }else { + cal_data->glb_bias_trim = +check_cal_data_valid (mtk_dp,1 ,0x1e , + (buf[0 ] >>27 ) &0x1f ,0xf ); + cal_data->clktx_impse = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[0 ] >>13 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[0 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>28 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[0 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>24 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[1 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>20 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[1 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>16 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[2 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>12 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[2 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>8 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[3 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>4 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[3 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , buf[1 ] &0xf ,0x8 ); + }kfree (buf); }
@@ -1021,7 +1080,10 @@ static void mtk_dp_video_mute(struct mtk_dp *mtk_dp, bool enable)VIDEO_MUTE_SEL_DP_ENC0_P0_MASK | VIDEO_MUTE_SW_DP_ENC0_P0_MASK); -mtk_dp_sip_atf_call (mtk_dp,MTK_DP_SIP_ATF_EDP_VIDEO_UNMUTE , enable); +mtk_dp_sip_atf_call (mtk_dp, +mtk_dp_is_edp (mtk_dp) ? +MTK_DP_SIP_ATF_EDP_VIDEO_UNMUTE : +MTK_DP_SIP_ATF_VIDEO_UNMUTE , enable); }static void mtk_dp_power_enable (struct mtk_dp *mtk_dp)
@@ -1069,6 +1131,8 @@ static void mtk_dp_initialize_priv_data(struct mtk_dp *mtk_dp) mtk_dp->info.depth =DP_MSA_MISC_8_BPC ;memset (&mtk_dp->info.timings,0 ,sizeof (struct mtk_dp_timings )); mtk_dp->info.timings.frame_rate =60 ; + + mtk_dp->has_fec = false; }static void mtk_dp_setup_tu (struct mtk_dp *mtk_dp)
@@ -1416,6 +1480,9 @@ static int mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp)drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D0 );usleep_range (2000 ,5000 ); +if (!mtk_dp_plug_state (mtk_dp)) +return -ENODEV ; +drm_dp_read_dpcd_caps (&mtk_dp->aux, mtk_dp->rx_cap); mtk_dp->rx_cap[DP_TRAINING_AUX_RD_INTERVAL ] &=DP_TRAINING_AUX_RD_MASK ;
@@ -1461,6 +1528,9 @@ static int mtk_dp_train_start(struct mtk_dp *mtk_dp)u8 train_limit;u8 max_link_rate; +if (!mtk_dp_plug_state_avoid_pulse (mtk_dp)) +return -ENODEV ; + link_rate = mtk_dp->rx_cap[1 ]; lane_count = mtk_dp->rx_cap[2 ] &0x1F ;
@@ -1602,21 +1672,46 @@ static void mtk_dp_init_port(struct mtk_dp *mtk_dp)static irqreturn_t mtk_dp_hpd_event_thread (int hpd,void *dev) {struct mtk_dp *mtk_dp = dev; +int event;u8 buf[DP_RECEIVER_CAP_SIZE ] = {}; + event =mtk_dp_plug_state (mtk_dp) ? + connector_status_connected : connector_status_disconnected; + +if (event <0 ) +return IRQ_HANDLED ; + +dev_info (mtk_dp->dev,"drm_helper_hpd_irq_event\n" ); +drm_helper_hpd_irq_event (mtk_dp->bridge.dev); +if (mtk_dp->train_info.cable_state_change) { mtk_dp->train_info.cable_state_change = false; -mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , -DP_PWR_STATE_BANDGAP_TPLL_LANE , -DP_PWR_STATE_MASK ); -drm_dp_read_dpcd_caps (&mtk_dp->aux, buf); - mtk_dp->train_info.link_rate = -min_t (int, mtk_dp->max_linkrate, - buf[mtk_dp->max_linkrate]); - mtk_dp->train_info.lane_count = -min_t (int, mtk_dp->max_lanes, -drm_dp_max_lane_count (buf)); + mtk_dp->train_state =MTK_DP_TRAIN_STATE_TRAINING ; + +if (!mtk_dp->train_info.cable_plugged_in) { +mtk_dp_video_mute (mtk_dp, true); + +mtk_dp_initialize_priv_data (mtk_dp); +mtk_dp_set_idle_pattern (mtk_dp, true); +if (mtk_dp->has_fec) +mtk_dp_fec_enable (mtk_dp, false); + +mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , +DP_PWR_STATE_BANDGAP_TPLL , +DP_PWR_STATE_MASK ); + }else { +mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , +DP_PWR_STATE_BANDGAP_TPLL_LANE , +DP_PWR_STATE_MASK ); +drm_dp_read_dpcd_caps (&mtk_dp->aux, buf); + mtk_dp->train_info.link_rate = +min_t (int, mtk_dp->max_linkrate, + buf[mtk_dp->max_linkrate]); + mtk_dp->train_info.lane_count = +min_t (int, mtk_dp->max_lanes, +drm_dp_max_lane_count (buf)); + } }if (mtk_dp->train_info.irq_sta.hpd_inerrupt) {
@@ -1735,6 +1830,24 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,return ret; } +static enum drm_connector_status mtk_dp_bdg_detect (struct drm_bridge *bridge) +{ +struct mtk_dp *mtk_dp =mtk_dp_from_bridge (bridge); +enum drm_connector_status ret = connector_status_disconnected; +u8 sink_count =0 ; + +if (mtk_dp_is_edp (mtk_dp)) +return connector_status_connected; + +if (mtk_dp_plug_state_avoid_pulse (mtk_dp)) { +drm_dp_dpcd_readb (&mtk_dp->aux,DP_SINK_COUNT , &sink_count); +if (DP_GET_SINK_COUNT (sink_count)) + ret = connector_status_connected; + } + +return ret; +} +static struct edid *mtk_dp_get_edid (struct drm_bridge *bridge,struct drm_connector *connector) {
@@ -1748,7 +1861,8 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge,drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D0 );usleep_range (2000 ,5000 ); - new_edid =drm_get_edid (connector, &mtk_dp->aux.ddc); +if (mtk_dp_plug_state (mtk_dp)) + new_edid =drm_get_edid (connector, &mtk_dp->aux.ddc);if (!enabled)drm_bridge_chain_post_disable (bridge);
@@ -2099,6 +2213,7 @@ static const struct drm_bridge_funcs mtk_dp_bridge_funcs = { .atomic_disable = mtk_dp_bridge_atomic_disable, .mode_valid = mtk_dp_bridge_mode_valid, .get_edid = mtk_dp_get_edid, + .detect = mtk_dp_bdg_detect, };static int mtk_dp_probe (struct platform_device *pdev)
@@ -2120,9 +2235,15 @@ static int mtk_dp_probe(struct platform_device *pdev) "failed to request dp irq resource\n"); mtk_dp->next_bridge =devm_drm_of_get_bridge (dev, dev->of_node,1 ,0 ); -if (IS_ERR (mtk_dp->next_bridge)) +if (IS_ERR (mtk_dp->next_bridge) && +PTR_ERR (mtk_dp->next_bridge) == -ENODEV ) { +dev_info (dev, +"No panel connected in devicetree, continue as external DP\n" ); + mtk_dp->next_bridge =NULL ; + }else if (IS_ERR (mtk_dp->next_bridge)) {return dev_err_probe (dev,PTR_ERR (mtk_dp->next_bridge),"Failed to get bridge\n" ); + } ret =mtk_dp_dt_parse (mtk_dp, pdev);if (ret)
@@ -2167,7 +2288,10 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp->bridge.ops =DRM_BRIDGE_OP_DETECT |DRM_BRIDGE_OP_EDID |DRM_BRIDGE_OP_HPD ; - mtk_dp->bridge.type = DRM_MODE_CONNECTOR_eDP; +if (mtk_dp_is_edp (mtk_dp)) + mtk_dp->bridge.type = DRM_MODE_CONNECTOR_eDP; +else + mtk_dp->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;drm_bridge_add (&mtk_dp->bridge);
@@ -2194,6 +2318,12 @@ static int mtk_dp_suspend(struct device *dev) {struct mtk_dp *mtk_dp =dev_get_drvdata (dev); +if (mtk_dp_plug_state (mtk_dp)) { +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D3 ); +/* Ensure the sink is off before shutting down power */ +usleep_range (2000 ,3000 ); + } +mtk_dp_power_disable (mtk_dp);mtk_dp_hwirq_enable (mtk_dp, false);
@@ -2221,6 +2351,7 @@ static SIMPLE_DEV_PM_OPS(mtk_dp_pm_ops, mtk_dp_suspend, mtk_dp_resume);static const struct of_device_id mtk_dp_of_match[] = { { .compatible ="mediatek,mt8195-edp-tx" }, + { .compatible ="mediatek,mt8195-dp-tx" }, {}, };MODULE_DEVICE_TABLE (of, mtk_dp_of_match);
Signature · 1 line
2.18.0
PATCH v11 7/10 drm/mediatek: add hpd debounce
In reply to Bo-Chen ChenFrom: Jitao Shi <[email protected]>
From the DP spec 1.4a chapter 3.3, upstream devices should implement HPD signal de-bouncing on an external connection.
A period of 100ms should be used to detect an HPD connect event. To cover these cases, HPD de-bounce should be implemented only after HPD low has been detected for at least 100ms.
Therefore,
1. If HPD is low (which means plugging out) for longer than 100ms:
we need to do de-bouncing (which means we need to wait for 100ms).
2. If HPD low is for less than 100ms:
we don't need to care about the de-bouncing.
In this patch, we start a 100ms timer and use a need_debounce boolean to implement the feature.
Two cases when HPD is high:
1. If the timer is expired (>100ms):
- need_debounce is true.
- When HPD high (plugging event comes), need_debounce will be true and then we need to do de-bouncing (wait for 100ms).
2. If the timer is not expired (<100ms):
- need_debounce is false.
- When HPD high (plugging event comes), need_debounce will be false and no need to do de-bouncing.
HPD_______ __________________
| |<- 100ms ->
|____________|
<- 100ms ->Without HPD de-bouncing, USB-C to HDMI Adapaters will not be detected.
The change has been successfully tested with the following devices:
- Dell Adapter - USB-C to HDMI
- Acer 1in1 HDMI dongle
- Ugreen 1in1 HDMI dongle
- innowatt HDMI + USB3 hub
- Acer 2in1 HDMI dongle
- Apple 3in1 HDMI dongle (A2119)
- J5Create 3in1 HDMI dongle (JAC379)
--- drivers/gpu/drm/mediatek/mtk_dp.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/gpu/drm/mediatek/mtk_dp.c +22 -0
@@ -129,6 +129,8 @@ struct mtk_dp {struct mutex dp_lock;struct drm_connector *conn; +bool need_debounce; +struct timer_list debounce_timer; };static struct regmap_config mtk_dp_regmap_config = {
@@ -1681,6 +1683,9 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev)if (event <0 )return IRQ_HANDLED ; +if (mtk_dp->need_debounce && mtk_dp->train_info.cable_plugged_in) +msleep (100 ); +dev_info (mtk_dp->dev,"drm_helper_hpd_irq_event\n" );drm_helper_hpd_irq_event (mtk_dp->bridge.dev);
@@ -1766,6 +1771,12 @@ static irqreturn_t mtk_dp_hpd_isr_handler(struct mtk_dp *mtk_dp) } train_info->cable_state_change = true; +if (!train_info->cable_plugged_in) { +mod_timer (&mtk_dp->debounce_timer, + jiffies +msecs_to_jiffies (100 ) -1 ); + mtk_dp->need_debounce = false; + } +return IRQ_WAKE_THREAD ; }
@@ -2216,6 +2227,13 @@ static const struct drm_bridge_funcs mtk_dp_bridge_funcs = { .detect = mtk_dp_bdg_detect, }; +static void mtk_dp_debounce_timer (struct timer_list *t) +{ +struct mtk_dp *mtk_dp =from_timer (mtk_dp, t, debounce_timer); + + mtk_dp->need_debounce = true; +} +static int mtk_dp_probe (struct platform_device *pdev) {struct mtk_dp *mtk_dp;
@@ -2295,6 +2313,9 @@ static int mtk_dp_probe(struct platform_device *pdev)drm_bridge_add (&mtk_dp->bridge); + mtk_dp->need_debounce = true; +timer_setup (&mtk_dp->debounce_timer, mtk_dp_debounce_timer,0 ); +pm_runtime_enable (dev);pm_runtime_get_sync (dev);
@@ -2307,6 +2328,7 @@ static int mtk_dp_remove(struct platform_device *pdev)platform_device_unregister (mtk_dp->phy_dev);mtk_dp_video_mute (mtk_dp, true); +del_timer_sync (&mtk_dp->debounce_timer);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.18.0
PATCH v11 8/10 drm/mediatek: set monitor to DP_SET_POWER_D3 to avoid garbage
In reply to Bo-Chen ChenSet the monitor power state to DP_SET_POWER_D3 to avoid garbage.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/mediatek/mtk_dp.c +5 -0
@@ -2043,6 +2043,11 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge, {struct mtk_dp *mtk_dp =mtk_dp_from_bridge (bridge); +if (mtk_dp_plug_state (mtk_dp)) { +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D3 ); +usleep_range (2000 ,3000 ); + } +mtk_dp_video_mute (mtk_dp, true); mtk_dp->train_state =MTK_DP_TRAIN_STATE_TRAINING ;
Signature · 1 line
2.18.0
PATCH v11 9/10 drm/mediatek: DP audio support for MT8195
In reply to Bo-Chen ChenFrom: Guillaume Ranquet <[email protected]>
This patch adds audio support to the DP driver for MT8195 with up to 8 channels.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 698 ++++++++++++++++++++++++++++++ 1 file changed, 698 insertions(+)
drivers/gpu/drm/mediatek/mtk_dp.c +698 -0
@@ -85,9 +85,41 @@ enum mtk_dp_linkrate { MTK_DP_LINKRATE_HBR3 = 0x1E, }; +enum mtk_dp_sdp_type { +MTK_DP_SDP_NONE =0x00 , +MTK_DP_SDP_ACM =0x01 , +MTK_DP_SDP_ISRC =0x02 , +MTK_DP_SDP_AVI =0x03 , +MTK_DP_SDP_AUI =0x04 , +MTK_DP_SDP_SPD =0x05 , +MTK_DP_SDP_MPEG =0x06 , +MTK_DP_SDP_NTSC =0x07 , +MTK_DP_SDP_VSP =0x08 , +MTK_DP_SDP_VSC =0x09 , +MTK_DP_SDP_EXT =0x0A , +MTK_DP_SDP_PPS0 =0x0B , +MTK_DP_SDP_PPS1 =0x0C , +MTK_DP_SDP_PPS2 =0x0D , +MTK_DP_SDP_PPS3 =0x0E , +MTK_DP_SDP_DRM =0x10 , +MTK_DP_SDP_MAX_NUM +}; + +struct mtk_dp_sdp_packet { +enum mtk_dp_sdp_type type; +struct dp_sdp sdp; +}; + +struct mtk_dp_audio_cfg { +int sample_rate; +int word_length_bits; +int channels; +}; +struct mtk_dp_info {u32 depth;enum dp_pixelformat format; +struct mtk_dp_audio_cfg audio_caps;struct mtk_dp_timings timings; };
@@ -123,10 +155,22 @@ struct mtk_dp {struct regmap *regs;bool enabled; +bool audio_enable;bool has_fec;/* protect the mtk_dp struct */ struct mutex dp_lock; +/* protect the plugged_cb as it's used in both bridge ops and audio */ +struct mutex update_plugged_status_lock; +/* protect the eld data as it's used in both bridge ops and audio */ +struct mutex eld_lock; +/* protect edid as it is used in both bridge ops and IRQ handler */ +struct mutex edid_lock; +struct edid *edid; + +hdmi_codec_plugged_cb plugged_cb; +struct device *codec_dev; +u8 connector_eld[MAX_ELD_BYTES ];struct drm_connector *conn;bool need_debounce;
@@ -416,6 +460,125 @@ static void mtk_dp_pg_disable(struct mtk_dp *mtk_dp) 4 << PGEN_PATTERN_SEL_SHIFT, PGEN_PATTERN_SEL_MASK); } +static void mtk_dp_audio_setup_channels (struct mtk_dp *mtk_dp, +struct mtk_dp_audio_cfg *cfg) +{ +u32 channel_enable_bits; + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3324 , +AUDIO_SOURCE_MUX_DP_ENC1_P0_DPRX , +AUDIO_SOURCE_MUX_DP_ENC1_P0_MASK ); + +/* audio channel count change reset */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_33F4 ,BIT (9 ),BIT (9 )); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3304 , +AU_PRTY_REGEN_DP_ENC1_P0_MASK , +AU_PRTY_REGEN_DP_ENC1_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3304 , +AU_CH_STS_REGEN_DP_ENC1_P0_MASK , +AU_CH_STS_REGEN_DP_ENC1_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3304 , +AUDIO_SAMPLE_PRSENT_REGEN_DP_ENC1_P0_MASK , +AUDIO_SAMPLE_PRSENT_REGEN_DP_ENC1_P0_MASK ); + +switch (cfg->channels) { +case 2 : + channel_enable_bits =AUDIO_2CH_SEL_DP_ENC0_P0_MASK | +AUDIO_2CH_EN_DP_ENC0_P0_MASK ; +break ; +case 8 : +default : + channel_enable_bits =AUDIO_8CH_SEL_DP_ENC0_P0_MASK | +AUDIO_8CH_EN_DP_ENC0_P0_MASK ; +break ; + } +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3088 , + channel_enable_bits |AU_EN_DP_ENC0_P0_MASK , +AUDIO_2CH_SEL_DP_ENC0_P0_MASK | +AUDIO_2CH_EN_DP_ENC0_P0_MASK | +AUDIO_8CH_SEL_DP_ENC0_P0_MASK | +AUDIO_8CH_EN_DP_ENC0_P0_MASK | +AU_EN_DP_ENC0_P0_MASK ); + +/* audio channel count change reset */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_33F4 ,0 ,BIT (9 )); + +/* enable audio reset */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_33F4 ,BIT (0 ),BIT (0 )); +} + +static void mtk_dp_audio_channel_status_set (struct mtk_dp *mtk_dp, +struct mtk_dp_audio_cfg *cfg) +{ +struct snd_aes_iec958 iec = {0 }; + +switch (cfg->sample_rate) { +case 32000 : + iec.status[3 ] =IEC958_AES3_CON_FS_32000 ; +break ; +case 44100 : + iec.status[3 ] =IEC958_AES3_CON_FS_44100 ; +break ; +case 48000 : + iec.status[3 ] =IEC958_AES3_CON_FS_48000 ; +break ; +case 88200 : + iec.status[3 ] =IEC958_AES3_CON_FS_88200 ; +break ; +case 96000 : + iec.status[3 ] =IEC958_AES3_CON_FS_96000 ; +break ; +case 192000 : + iec.status[3 ] =IEC958_AES3_CON_FS_192000 ; +break ; +default : + iec.status[3 ] =IEC958_AES3_CON_FS_NOTID ; +break ; + } + +switch (cfg->word_length_bits) { +case 16 : + iec.status[4 ] =IEC958_AES4_CON_WORDLEN_20_16 ; +break ; +case 20 : + iec.status[4 ] =IEC958_AES4_CON_WORDLEN_20_16 | +IEC958_AES4_CON_MAX_WORDLEN_24 ; +break ; +case 24 : + iec.status[4 ] =IEC958_AES4_CON_WORDLEN_24_20 | +IEC958_AES4_CON_MAX_WORDLEN_24 ; +break ; +default : + iec.status[4 ] =IEC958_AES4_CON_WORDLEN_NOTID ; + } + +/* IEC 60958 consumer channel status bits */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_308C , +0 ,CH_STATUS_0_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3090 , + iec.status[3 ] <<8 ,CH_STATUS_1_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3094 , + iec.status[4 ],CH_STATUS_2_DP_ENC0_P0_MASK ); +} + +static void mtk_dp_audio_sdp_asp_set_channels (struct mtk_dp *mtk_dp, +int channels) +{ +if (channels !=2 && channels !=8 ) + channels =8 ; + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_312C , + (channels -1 ) <<ASP_HB3_DP_ENC0_P0_SHIFT , +ASP_HB2_DP_ENC0_P0_MASK |ASP_HB3_DP_ENC0_P0_MASK ); +} + +static void mtk_dp_audio_set_divider (struct mtk_dp *mtk_dp) +{ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30BC , +AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_2 , +AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_MASK ); +} +static bool mtk_dp_plug_state (struct mtk_dp *mtk_dp) { return !!(mtk_dp_read(mtk_dp, MTK_DP_TRANS_P0_3414) &
@@ -436,6 +599,169 @@ static bool mtk_dp_plug_state_avoid_pulse(struct mtk_dp *mtk_dp)return true; } +static void mtk_dp_sdp_trigger_packet (struct mtk_dp *mtk_dp, +enum mtk_dp_sdp_type type) +{ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , + type,SDP_PACKET_TYPE_DP_ENC1_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , +SDP_PACKET_W_DP_ENC1_P0 ,SDP_PACKET_W_DP_ENC1_P0 ); +} + +static void mtk_dp_sdp_set_data (struct mtk_dp *mtk_dp,u8 *data_bytes) +{ +mtk_dp_bulk_16bit_write (mtk_dp,MTK_DP_ENC1_P0_3200 , + data_bytes,0x10 ); +} + +static void mtk_dp_sdp_set_header (struct mtk_dp *mtk_dp, +enum mtk_dp_sdp_type type, +struct dp_sdp_header *header) +{ +u32 db_addr; + +switch (type) { +case MTK_DP_SDP_DRM : + db_addr =MTK_DP_ENC0_P0_3138 ; +break ; +case MTK_DP_SDP_PPS0 : +case MTK_DP_SDP_PPS1 : +case MTK_DP_SDP_PPS2 : +case MTK_DP_SDP_PPS3 : + db_addr =MTK_DP_ENC0_P0_3130 ; +break ; +default : + db_addr =MTK_DP_ENC0_P0_30D8 + (type -MTK_DP_SDP_ACM ) *8 ; +break ; + } + +mtk_dp_bulk_16bit_write (mtk_dp, db_addr, (u8 *)header,4 ); +} + +static const u32 sdp_type_to_reg[MTK_DP_SDP_MAX_NUM ] = { + [MTK_DP_SDP_NONE ] =0x0 , + [MTK_DP_SDP_ACM ] =MTK_DP_ENC0_P0_30B4 , + [MTK_DP_SDP_ISRC ] =MTK_DP_ENC0_P0_30B4 +1 , + [MTK_DP_SDP_AVI ] =MTK_DP_ENC0_P0_30A4 +1 , + [MTK_DP_SDP_AUI ] =MTK_DP_ENC0_P0_30A8 , + [MTK_DP_SDP_SPD ] =MTK_DP_ENC0_P0_30A8 +1 , + [MTK_DP_SDP_MPEG ] =MTK_DP_ENC0_P0_30AC , + [MTK_DP_SDP_NTSC ] =MTK_DP_ENC0_P0_30AC +1 , + [MTK_DP_SDP_VSP ] =MTK_DP_ENC0_P0_30B0 , + [MTK_DP_SDP_VSC ] =MTK_DP_ENC0_P0_30B8 , + [MTK_DP_SDP_EXT ] =MTK_DP_ENC0_P0_30B0 +1 , + [MTK_DP_SDP_PPS0 ] =MTK_DP_ENC0_P0_31E8 , + [MTK_DP_SDP_PPS1 ] =MTK_DP_ENC0_P0_31E8 , + [MTK_DP_SDP_PPS2 ] =MTK_DP_ENC0_P0_31E8 , + [MTK_DP_SDP_PPS3 ] =MTK_DP_ENC0_P0_31E8 , + [MTK_DP_SDP_DRM ] =MTK_DP_ENC0_P0_31DC , +}; + +static void mtk_dp_disable_sdp (struct mtk_dp *mtk_dp,enum mtk_dp_sdp_type type) +{ +if (type ==MTK_DP_SDP_NONE ) +return ; + +/* Disable periodic send */ +mtk_dp_update_bits (mtk_dp, sdp_type_to_reg[type] &0xfffc ,0 , +0xFF << ((sdp_type_to_reg[type] &3 ) *8 )); +} + +static void mtk_dp_setup_sdp (struct mtk_dp *mtk_dp, +struct mtk_dp_sdp_packet *packet) +{ +u32 reg, shift; + +mtk_dp_sdp_set_data (mtk_dp, packet->sdp.db); +mtk_dp_sdp_set_header (mtk_dp, packet->type, &packet->sdp.sdp_header); + +mtk_dp_disable_sdp (mtk_dp, packet->type); + +switch (packet->type) { +case MTK_DP_SDP_ISRC : +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_31EC , +0x1C <<ISRC1_HB3_DP_ENC0_P0_SHIFT , +ISRC1_HB3_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , +MTK_DP_SDP_ISRC , +SDP_PACKET_TYPE_DP_ENC1_P0_MASK ); + +if (packet->sdp.sdp_header.HB3 &BIT (2 )) +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30BC , +BIT (ISRC_CONT_DP_ENC0_P0_SHIFT ), +ISRC_CONT_DP_ENC0_P0_MASK ); +else +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30BC , +0 ,ISRC_CONT_DP_ENC0_P0_MASK ); + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , +SDP_PACKET_W_DP_ENC1_P0 , +SDP_PACKET_W_DP_ENC1_P0 ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30B4 , +5 <<ISRC_CFG_DP_ENC0_P0_SHIFT , +ISRC_CFG_DP_ENC0_P0_MASK ); +break ; +case MTK_DP_SDP_DRM : +mtk_dp_sdp_trigger_packet (mtk_dp, packet->type); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_31DC , +5 <<HDR0_CFG_DP_ENC0_P0_SHIFT , +HDR0_CFG_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_31EC , +0x1C <<ISRC1_HB3_DP_ENC0_P0_SHIFT , +ISRC1_HB3_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , +MTK_DP_SDP_ISRC , +SDP_PACKET_TYPE_DP_ENC1_P0_MASK ); + +if (packet->sdp.sdp_header.HB3 &BIT (2 )) +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30BC , +BIT (ISRC_CONT_DP_ENC0_P0_SHIFT ), +ISRC_CONT_DP_ENC0_P0_MASK ); +else +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30BC , +0 ,ISRC_CONT_DP_ENC0_P0_MASK ); + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , +SDP_PACKET_W_DP_ENC1_P0 , +SDP_PACKET_W_DP_ENC1_P0 ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30B4 , +5 <<ISRC_CFG_DP_ENC0_P0_SHIFT , +ISRC_CFG_DP_ENC0_P0_MASK ); +break ; +case MTK_DP_SDP_ACM : +case MTK_DP_SDP_AVI : +case MTK_DP_SDP_AUI : +case MTK_DP_SDP_SPD : +case MTK_DP_SDP_MPEG : +case MTK_DP_SDP_NTSC : +case MTK_DP_SDP_VSP : +case MTK_DP_SDP_VSC : +case MTK_DP_SDP_EXT : +case MTK_DP_SDP_PPS0 : +case MTK_DP_SDP_PPS1 : +case MTK_DP_SDP_PPS2 : +case MTK_DP_SDP_PPS3 : + reg = sdp_type_to_reg[packet->type]; + shift = (reg &3 ) *8 ; + +mtk_dp_sdp_trigger_packet (mtk_dp, packet->type); +/* Enable periodic sending */ +mtk_dp_update_bits (mtk_dp, reg &0xfffc , +0x05 << shift,0xff << shift); +break ; +case MTK_DP_SDP_NONE : +default : +break ; + } +} + +static void mtk_dp_sdp_vsc_ext_disable (struct mtk_dp *mtk_dp) +{ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30A0 , +0 ,BIT (7 ) |BIT (8 ) |BIT (12 )); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_328C ,0 ,BIT (7 )); +} +static void mtk_dp_aux_irq_clear (struct mtk_dp *mtk_dp) { mtk_dp_write(mtk_dp, MTK_DP_AUX_P0_3640,
@@ -1088,6 +1414,32 @@ static void mtk_dp_video_mute(struct mtk_dp *mtk_dp, bool enable) MTK_DP_SIP_ATF_VIDEO_UNMUTE, enable); } +static void mtk_dp_audio_mute (struct mtk_dp *mtk_dp,bool mute) +{ +u32 val[3 ]; + +if (mute) { + val[0 ] =BIT (VBID_AUDIO_MUTE_SW_DP_ENC0_P0_SHIFT ) | +BIT (VBID_AUDIO_MUTE_SEL_DP_ENC0_P0_SHIFT ); + val[1 ] =0 ; + val[2 ] =0 ; + }else { + val[0 ] =0 ; + val[1 ] =BIT (AU_EN_DP_ENC0_P0_SHIFT ); +/* Send one every two frames */ + val[2 ] =0x0F ; + } + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3030 , + val[0 ], +VBID_AUDIO_MUTE_FLAG_SW_DP_ENC0_P0_MASK | +VBID_AUDIO_MUTE_FLAG_SEL_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3088 , + val[1 ],AU_EN_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30A4 , + val[2 ],AU_TS_CFG_DP_ENC0_P0_MASK ); +} +static void mtk_dp_power_enable (struct mtk_dp *mtk_dp) { mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_RESET_AND_PROBE,
@@ -1135,6 +1487,78 @@ static void mtk_dp_initialize_priv_data(struct mtk_dp *mtk_dp) mtk_dp->info.timings.frame_rate =60 ; mtk_dp->has_fec = false; + mtk_dp->audio_enable = false; +} + +static void mtk_dp_sdp_set_down_cnt_init (struct mtk_dp *mtk_dp, +u32 sram_read_start) +{ +u32 sdp_down_cnt_init =0 ; +struct drm_display_mode mode; +struct mtk_dp_timings *timings = &mtk_dp->info.timings; + +drm_display_mode_from_videomode (&timings->vm, &mode); + +if (mtk_dp->info.timings.pix_rate_khz >0 ) + sdp_down_cnt_init = sram_read_start * + mtk_dp->train_info.link_rate *2700 *8 / + (timings->pix_rate_khz *4 ); + +switch (mtk_dp->train_info.lane_count) { +case 1 : + sdp_down_cnt_init =max_t (u32, sdp_down_cnt_init,0x1A ); +break ; +case 2 : +/* case for LowResolution && High Audio Sample Rate */ + sdp_down_cnt_init =max_t (u32, sdp_down_cnt_init,0x10 ); + sdp_down_cnt_init += mode.vtotal <=525 ?4 :0 ; +break ; +case 4 : +default : + sdp_down_cnt_init =max_t (u32, sdp_down_cnt_init,6 ); +break ; + } + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3040 , + sdp_down_cnt_init + <<SDP_DOWN_CNT_INIT_DP_ENC0_P0_SHIFT , +SDP_DOWN_CNT_INIT_DP_ENC0_P0_MASK ); +} + +static void mtk_dp_sdp_set_down_cnt_init_in_hblank (struct mtk_dp *mtk_dp) +{ +int pix_clk_mhz; +u32 dc_offset; +u32 spd_down_cnt_init =0 ; +struct drm_display_mode mode; +struct mtk_dp_timings *timings = &mtk_dp->info.timings; + +drm_display_mode_from_videomode (&timings->vm, &mode); + + pix_clk_mhz = mtk_dp->info.format ==DP_PIXELFORMAT_YUV420 ? + mtk_dp->info.timings.pix_rate_khz /2000 : + mtk_dp->info.timings.pix_rate_khz /1000 ; + +switch (mtk_dp->train_info.lane_count) { +case 1 : + spd_down_cnt_init =0x20 ; +break ; +case 2 : + dc_offset = (mode.vtotal <=525 ) ?0x14 :0x00 ; + spd_down_cnt_init =0x18 + dc_offset; +break ; +case 4 : +default : + dc_offset = (mode.vtotal <=525 ) ?0x08 :0x00 ; +if (pix_clk_mhz > mtk_dp->train_info.link_rate *27 ) + spd_down_cnt_init =0x8 ; +else + spd_down_cnt_init =0x10 + dc_offset; +break ; + } + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3364 , spd_down_cnt_init, +SDP_DOWN_CNT_INIT_IN_HBLANK_DP_ENC1_P0_MASK ); }static void mtk_dp_setup_tu (struct mtk_dp *mtk_dp)
@@ -1151,6 +1575,8 @@ static void mtk_dp_setup_tu(struct mtk_dp *mtk_dp) }mtk_dp_setup_encoder (mtk_dp); +mtk_dp_sdp_set_down_cnt_init_in_hblank (mtk_dp); +mtk_dp_sdp_set_down_cnt_init (mtk_dp, sram_read_start); }static void mtk_dp_calculate_pixrate (struct mtk_dp *mtk_dp)
@@ -1184,6 +1610,14 @@ static void mtk_dp_set_tx_out(struct mtk_dp *mtk_dp)mtk_dp_setup_tu (mtk_dp); } +static void mtk_dp_edid_free (struct mtk_dp *mtk_dp) +{ +mutex_lock (&mtk_dp->edid_lock); +kfree (mtk_dp->edid); + mtk_dp->edid =NULL ; +mutex_unlock (&mtk_dp->edid_lock); +} +static ssize_t mtk_dp_hpd_sink_event (struct mtk_dp *mtk_dp) {ssize_t ret;
@@ -1217,6 +1651,7 @@ static ssize_t mtk_dp_hpd_sink_event(struct mtk_dp *mtk_dp)if (DP_GET_SINK_COUNT (sink_count) && (link_status[2 ] &DP_DOWNSTREAM_PORT_STATUS_CHANGED )) { +mtk_dp_edid_free (mtk_dp); mtk_dp->train_state =MTK_DP_TRAIN_STATE_TRAINING ;msleep (20 ); }
@@ -1224,6 +1659,17 @@ static ssize_t mtk_dp_hpd_sink_event(struct mtk_dp *mtk_dp)return 0 ; } +static void mtk_dp_sdp_stop_sending (struct mtk_dp *mtk_dp) +{ +u8 packet_type; + +for (packet_type =MTK_DP_SDP_ACM ; packet_type <MTK_DP_SDP_MAX_NUM ; + packet_type++) +mtk_dp_disable_sdp (mtk_dp, packet_type); + +mtk_dp_sdp_vsc_ext_disable (mtk_dp); +} +static void mtk_dp_train_update_swing_pre (struct mtk_dp *mtk_dp,int lanes,u8 dpcd_adjust_req[2 ]) {
@@ -1516,6 +1962,55 @@ static int mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp)return 0 ; } +static bool mtk_dp_edid_parse_audio_capabilities (struct mtk_dp *mtk_dp, +struct mtk_dp_audio_cfg *cfg) +{ +struct cea_sad *sads; +int sad_count; +int i; +bool ret = false; + +if (mtk_dp_is_edp (mtk_dp)) +return false; + +mutex_lock (&mtk_dp->edid_lock); +if (!mtk_dp->edid) { +mutex_unlock (&mtk_dp->edid_lock); +dev_err (mtk_dp->dev,"EDID not found!\n" ); +return false; + } + sad_count =drm_edid_to_sad (mtk_dp->edid, &sads); +mutex_unlock (&mtk_dp->edid_lock); + +if (sad_count <=0 ) { +drm_info (mtk_dp->drm_dev,"The SADs is NULL\n" ); +return false; + } + +for (i =0 ; i < sad_count; i++) { +int sample_rate, word_length; + +/* Only PCM supported at the moment */ +if (sads[i].format !=HDMI_AUDIO_CODING_TYPE_PCM ) +continue ; + + sample_rate =drm_cea_sad_get_sample_rate (&sads[i]); + word_length = +drm_cea_sad_get_uncompressed_word_length (&sads[i]); +if (sample_rate <=0 || word_length <=0 ) +continue ; + + cfg->channels = sads[i].channels; + cfg->word_length_bits = word_length; + cfg->sample_rate = sample_rate; + ret = true; +break ; + } +kfree (sads); + +return ret; +} +static void mtk_dp_train_change_mode (struct mtk_dp *mtk_dp) {phy_reset (mtk_dp->phy);
@@ -1609,6 +2104,48 @@ static void mtk_dp_video_enable(struct mtk_dp *mtk_dp, bool enable) } } +static void mtk_dp_audio_sdp_setup (struct mtk_dp *mtk_dp, +struct mtk_dp_audio_cfg *cfg) +{ +struct mtk_dp_sdp_packet packet; +struct hdmi_audio_infoframe frame; + +hdmi_audio_infoframe_init (&frame); + frame.coding_type =HDMI_AUDIO_CODING_TYPE_PCM ; + frame.channels = cfg->channels; + frame.sample_frequency = cfg->sample_rate; + +switch (cfg->word_length_bits) { +case 16 : + frame.sample_size =HDMI_AUDIO_SAMPLE_SIZE_16 ; +break ; +case 20 : + frame.sample_size =HDMI_AUDIO_SAMPLE_SIZE_20 ; +break ; +case 24 : +default : + frame.sample_size =HDMI_AUDIO_SAMPLE_SIZE_24 ; +break ; + } + + packet.type =MTK_DP_SDP_AUI ; +hdmi_audio_infoframe_pack_for_dp (&frame, &packet.sdp, +MTK_DP_DP_VERSION_11 ); + +mtk_dp_audio_sdp_asp_set_channels (mtk_dp, cfg->channels); +mtk_dp_setup_sdp (mtk_dp, &packet); +} + +static void mtk_dp_audio_setup (struct mtk_dp *mtk_dp, +struct mtk_dp_audio_cfg *cfg) +{ +mtk_dp_audio_sdp_setup (mtk_dp, cfg); +mtk_dp_audio_channel_status_set (mtk_dp, cfg); + +mtk_dp_audio_setup_channels (mtk_dp, cfg); +mtk_dp_audio_set_divider (mtk_dp); +} +static void mtk_dp_video_config (struct mtk_dp *mtk_dp) {mtk_dp_mn_overwrite_disable (mtk_dp);
@@ -1635,6 +2172,19 @@ static int mtk_dp_training(struct mtk_dp *mtk_dp)case MTK_DP_TRAIN_STATE_NORMAL :mtk_dp_video_config (mtk_dp);mtk_dp_video_enable (mtk_dp, true); + + mtk_dp->audio_enable = +mtk_dp_edid_parse_audio_capabilities (mtk_dp, + &mtk_dp->info.audio_caps); + +if (mtk_dp->audio_enable) { +mtk_dp_audio_setup (mtk_dp, &mtk_dp->info.audio_caps); +mtk_dp_audio_mute (mtk_dp, false); + }else { +memset (&mtk_dp->info.audio_caps,0 , +sizeof (mtk_dp->info.audio_caps)); + } + training_done = true;break ;default :
@@ -1696,12 +2246,15 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev)if (!mtk_dp->train_info.cable_plugged_in) {mtk_dp_video_mute (mtk_dp, true); +mtk_dp_audio_mute (mtk_dp, true);mtk_dp_initialize_priv_data (mtk_dp);mtk_dp_set_idle_pattern (mtk_dp, true);if (mtk_dp->has_fec)mtk_dp_fec_enable (mtk_dp, false); +mtk_dp_sdp_stop_sending (mtk_dp); +mtk_dp_edid_free (mtk_dp);mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE ,DP_PWR_STATE_BANDGAP_TPLL ,DP_PWR_STATE_MASK );
@@ -1841,6 +2394,18 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,return ret; } +static void mtk_dp_update_plugged_status (struct mtk_dp *mtk_dp) +{ +bool connected, has_audio; + +mutex_lock (&mtk_dp->update_plugged_status_lock); + connected =mtk_dp_plug_state_avoid_pulse (mtk_dp); + has_audio =drm_detect_monitor_audio (mtk_dp->edid); +if (mtk_dp->plugged_cb && mtk_dp->codec_dev) + mtk_dp->plugged_cb (mtk_dp->codec_dev, connected & has_audio); +mutex_unlock (&mtk_dp->update_plugged_status_lock); +} +static enum drm_connector_status mtk_dp_bdg_detect (struct drm_bridge *bridge) {struct mtk_dp *mtk_dp =mtk_dp_from_bridge (bridge);
@@ -1856,6 +2421,7 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge) ret = connector_status_connected; } +mtk_dp_update_plugged_status (mtk_dp);return ret; }
@@ -1878,6 +2444,18 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge,if (!enabled)drm_bridge_chain_post_disable (bridge); +mutex_lock (&mtk_dp->edid_lock); +kfree (mtk_dp->edid); + mtk_dp->edid =NULL ; + +if (!new_edid) { +mutex_unlock (&mtk_dp->edid_lock); +return NULL ; + } + + mtk_dp->edid =drm_edid_duplicate (new_edid); +mutex_unlock (&mtk_dp->edid_lock); +return new_edid; }
@@ -2049,6 +2627,7 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge, }mtk_dp_video_mute (mtk_dp, true); +mtk_dp_audio_mute (mtk_dp, true); mtk_dp->train_state =MTK_DP_TRAIN_STATE_TRAINING ; mtk_dp->enabled = false;
@@ -2079,6 +2658,8 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge, }mtk_dp_video_mute (mtk_dp, true); +mtk_dp_audio_mute (mtk_dp, true); +mtk_dp_sdp_stop_sending (mtk_dp);if (mtk_dp_parse_capabilities (mtk_dp)) {drm_err (mtk_dp->drm_dev,"Can't parse capabilities\n" );
@@ -2091,7 +2672,13 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge,return ; } +mutex_lock (&mtk_dp->eld_lock); +memcpy (mtk_dp->connector_eld, mtk_dp->conn->eld,MAX_ELD_BYTES ); +mutex_unlock (&mtk_dp->eld_lock); + mtk_dp->enabled = true; + +mtk_dp_update_plugged_status (mtk_dp); } static enum drm_mode_status
@@ -2239,6 +2826,104 @@ static void mtk_dp_debounce_timer(struct timer_list *t) mtk_dp->need_debounce = true; } +/* +* HDMI audio codec callbacks +*/ +static int mtk_dp_audio_hw_params (struct device *dev,void *data, +struct hdmi_codec_daifmt *daifmt, +struct hdmi_codec_params *params) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); +struct mtk_dp_audio_cfg cfg; + +if (!mtk_dp->enabled) { +pr_err ("%s, DP is not ready!\n" , __func__); +return -ENODEV ; + } + + cfg.channels = params->cea.channels; + cfg.sample_rate = params->sample_rate; + cfg.word_length_bits =24 ; + +mtk_dp_audio_setup (mtk_dp, &cfg); + +return 0 ; +} + +static int mtk_dp_audio_startup (struct device *dev,void *data) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); + +mtk_dp_audio_mute (mtk_dp, false); + +return 0 ; +} + +static void mtk_dp_audio_shutdown (struct device *dev,void *data) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); + +mtk_dp_audio_mute (mtk_dp, true); +} + +static int mtk_dp_audio_get_eld (struct device *dev,void *data,uint8_t *buf, +size_t len) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); + +if (mtk_dp->enabled) +memcpy (buf, mtk_dp->connector_eld, len); +else +memset (buf,0 , len); + +return 0 ; +} + +static int mtk_dp_audio_hook_plugged_cb (struct device *dev,void *data, +hdmi_codec_plugged_cb fn, +struct device *codec_dev) +{ +struct mtk_dp *mtk_dp = data; + +mutex_lock (&mtk_dp->update_plugged_status_lock); + mtk_dp->plugged_cb = fn; + mtk_dp->codec_dev = codec_dev; +mutex_unlock (&mtk_dp->update_plugged_status_lock); + +mtk_dp_update_plugged_status (mtk_dp); + +return 0 ; +} + +static const struct hdmi_codec_ops mtk_dp_audio_codec_ops = { + .hw_params = mtk_dp_audio_hw_params, + .audio_startup = mtk_dp_audio_startup, + .audio_shutdown = mtk_dp_audio_shutdown, + .get_eld = mtk_dp_audio_get_eld, + .hook_plugged_cb = mtk_dp_audio_hook_plugged_cb, + .no_capture_mute =1 , +}; + +static int mtk_dp_register_audio_driver (struct device *dev) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); +struct hdmi_codec_pdata codec_data = { + .ops = &mtk_dp_audio_codec_ops, + .max_i2s_channels =8 , + .i2s =1 , + .data = mtk_dp, + }; +struct platform_device *pdev; + + pdev =platform_device_register_data (dev,HDMI_CODEC_DRV_NAME , +PLATFORM_DEVID_AUTO , &codec_data, +sizeof (codec_data)); +if (IS_ERR (pdev)) +return PTR_ERR (pdev); + +return 0 ; +} +static int mtk_dp_probe (struct platform_device *pdev) {struct mtk_dp *mtk_dp;
@@ -2285,9 +2970,21 @@ static int mtk_dp_probe(struct platform_device *pdev) "failed to request mediatek dptx irq\n");mutex_init (&mtk_dp->dp_lock); +mutex_init (&mtk_dp->edid_lock); +mutex_init (&mtk_dp->eld_lock); +mutex_init (&mtk_dp->update_plugged_status_lock);platform_set_drvdata (pdev, mtk_dp); +if (!mtk_dp_is_edp (mtk_dp)) { + ret =mtk_dp_register_audio_driver (dev); +if (ret) { +dev_err (dev,"Failed to register audio driver: %d\n" , + ret); +return ret; + } + } + mtk_dp->phy_dev = platform_device_register_data(dev, "mediatek-dp-phy", PLATFORM_DEVID_AUTO, &mtk_dp->regs,
@@ -2333,6 +3030,7 @@ static int mtk_dp_remove(struct platform_device *pdev)platform_device_unregister (mtk_dp->phy_dev);mtk_dp_video_mute (mtk_dp, true); +mtk_dp_audio_mute (mtk_dp, true);del_timer_sync (&mtk_dp->debounce_timer);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.18.0
PATCH v11 10/10 drm/mediatek: fix no audio when resolution change
In reply to Bo-Chen ChenWhen switching resolutions, config the audio setting with the previous audio parameters.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 51 ++++++++++--------------------- 1 file changed, 16 insertions(+), 35 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +16 -35
@@ -119,7 +119,7 @@ struct mtk_dp_audio_cfg {struct mtk_dp_info {u32 depth;enum dp_pixelformat format; -struct mtk_dp_audio_cfg audio_caps; +struct mtk_dp_audio_cfg audio_cur_cfg;struct mtk_dp_timings timings; };
@@ -1966,8 +1966,6 @@ static bool mtk_dp_edid_parse_audio_capabilities(struct mtk_dp *mtk_dp, struct mtk_dp_audio_cfg *cfg) {struct cea_sad *sads; -int sad_count; -int i;bool ret = false;if (mtk_dp_is_edp (mtk_dp))
@@ -1979,33 +1977,13 @@ static bool mtk_dp_edid_parse_audio_capabilities(struct mtk_dp *mtk_dp,dev_err (mtk_dp->dev,"EDID not found!\n" );return false; } - sad_count =drm_edid_to_sad (mtk_dp->edid, &sads); -mutex_unlock (&mtk_dp->edid_lock); -if (sad_count <=0 ) { + ret =drm_edid_to_sad (mtk_dp->edid, &sads); +mutex_unlock (&mtk_dp->edid_lock); +if (ret <=0 ) {drm_info (mtk_dp->drm_dev,"The SADs is NULL\n" );return false; } - -for (i =0 ; i < sad_count; i++) { -int sample_rate, word_length; - -/* Only PCM supported at the moment */ -if (sads[i].format !=HDMI_AUDIO_CODING_TYPE_PCM ) -continue ; - - sample_rate =drm_cea_sad_get_sample_rate (&sads[i]); - word_length = -drm_cea_sad_get_uncompressed_word_length (&sads[i]); -if (sample_rate <=0 || word_length <=0 ) -continue ; - - cfg->channels = sads[i].channels; - cfg->word_length_bits = word_length; - cfg->sample_rate = sample_rate; - ret = true; -break ; - }kfree (sads);return ret;
@@ -2175,14 +2153,15 @@ static int mtk_dp_training(struct mtk_dp *mtk_dp) mtk_dp->audio_enable =mtk_dp_edid_parse_audio_capabilities (mtk_dp, - &mtk_dp->info.audio_caps); + &mtk_dp->info.audio_cur_cfg);if (mtk_dp->audio_enable) { -mtk_dp_audio_setup (mtk_dp, &mtk_dp->info.audio_caps); +mtk_dp_audio_setup (mtk_dp, + &mtk_dp->info.audio_cur_cfg);mtk_dp_audio_mute (mtk_dp, false); }else { -memset (&mtk_dp->info.audio_caps,0 , -sizeof (mtk_dp->info.audio_caps)); +memset (&mtk_dp->info.audio_cur_cfg,0 , +sizeof (mtk_dp->info.audio_cur_cfg)); } training_done = true;
@@ -2624,6 +2603,9 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge,if (mtk_dp_plug_state (mtk_dp)) {drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D3 );usleep_range (2000 ,3000 ); + }else { +memset (&mtk_dp->info.audio_cur_cfg,0 , +sizeof (mtk_dp->info.audio_cur_cfg)); }mtk_dp_video_mute (mtk_dp, true);
@@ -2834,18 +2816,17 @@ static int mtk_dp_audio_hw_params(struct device *dev, void *data, struct hdmi_codec_params *params) {struct mtk_dp *mtk_dp =dev_get_drvdata (dev); -struct mtk_dp_audio_cfg cfg;if (!mtk_dp->enabled) {pr_err ("%s, DP is not ready!\n" , __func__);return -ENODEV ; } - cfg.channels = params->cea.channels; - cfg.sample_rate = params->sample_rate; - cfg.word_length_bits =24 ; + mtk_dp->info.audio_cur_cfg.channels = params->cea.channels; + mtk_dp->info.audio_cur_cfg.sample_rate = params->sample_rate; + mtk_dp->info.audio_cur_cfg.word_length_bits =24 ; -mtk_dp_audio_setup (mtk_dp, &cfg); +mtk_dp_audio_setup (mtk_dp, &mtk_dp->info.audio_cur_cfg);return 0 ; }
Signature · 1 line
2.18.0