drm/mediatek: Add mt8195 DisplayPort driver
Subsystems (8)
v7 cover drm/mediatek: Add mt8195 DisplayPort driver
this series is built around the DisplayPort driver. The dpi/dpintf driver and the added helper functions are required for the DisplayPort driver to work.
In v7 I've adressed the comments from the community:
- clean the checkpatch --strict output
- better split up of the patches (some bad fixup were done in v6...)
- use of devm_phy_get()
- make the "ck_cg" clock optional as to not break the other platforms.
There's still some leftover comments from Chun Kuang as can be seen in this thread:
https://lore.kernel.org/linux-mediatek/CABnWg9v-QBAaJ0MffNNSKCNyd8eb1zhETxoZjxQ5c7FNeUkBAg@mail.gmail.com/
- mtk_dp_poweron() stayed in mtk_dp_bridge_attach() as the change breaks eDP
- That request was left un-addressed as I'm not sure what to do with it. > > Refer to mtk_hdmi_bridge_atomic_enable() for getting the mode.
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]/
Functional dependencies are:
- Add Mediatek Soc DRM (vdosys0) support for mt8195
https://lore.kernel.org/all/[email protected]/
- Add MediaTek SoC DRM (vdosys1) support for mt8195
https://lore.kernel.org/all/[email protected]/
Guillaume Ranquet (1):
drm/mediatek: Add mt8195 eDP support
Markus Schneider-Pargmann (7):
dt-bindings: mediatek,dpi: Add DP_INTF compatible
dt-bindings: mediatek,dp: Add Display Port binding drm/edid: Add cea_sad helpers for freq/length video/hdmi: Add audio_infoframe packing for DP drm/mediatek: dpi: Add dpintf support
phy: phy-mtk-dp: Add driver for DP phy drm/mediatek: Add mt8195 DisplayPort driver
.../display/mediatek/mediatek,dp.yaml | 87 + .../display/mediatek/mediatek,dpi.yaml | 11 +- MAINTAINERS | 1 + drivers/gpu/drm/drm_edid.c | 74 + drivers/gpu/drm/mediatek/Kconfig | 7 + drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_dp.c | 3072 +++++++++++++++++ drivers/gpu/drm/mediatek/mtk_dp_reg.h | 568 +++ drivers/gpu/drm/mediatek/mtk_dpi.c | 304 +- drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 38 + drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 4 + drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 1 + drivers/gpu/drm/mediatek/mtk_drm_drv.c | 6 +- drivers/gpu/drm/mediatek/mtk_drm_drv.h | 1 + drivers/phy/mediatek/Kconfig | 8 + drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-dp.c | 219 ++ drivers/video/hdmi.c | 83 +- include/drm/drm_dp_helper.h | 2 + include/drm/drm_edid.h | 18 +- include/linux/hdmi.h | 7 +- include/linux/soc/mediatek/mtk-mmsys.h | 2 + 22 files changed, 4434 insertions(+), 82 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 create mode 100644 drivers/phy/mediatek/phy-mtk-dp.c
Signature · 7 lines
2.32.0 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v7 1/8 dt-bindings: mediatek,dpi: Add DP_INTF compatible
From: Markus Schneider-Pargmann <[email protected]>
DP_INTF is similar to DPI but does not have the exact same feature set or register layouts.
DP_INTF is the sink of the display pipeline that is connected to the DisplayPort controller and encoder unit. It takes the same clocks as DPI.
--- .../bindings/display/mediatek/mediatek,dpi.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +6 -5
@@ -4,16 +4,16 @@ $id: http://devicetree.org/schemas/display/mediatek/mediatek,dpi.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: mediatek DPI Controller Device Tree Bindings +title: mediatek DPI/DP_INTF Controller Device Tree Bindings maintainers: - CK Hu <[email protected]> - Jitao shi <[email protected]> description: | - The Mediatek DPI function block is a sink of the display subsystem and - provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a parallel - output bus. + The Mediatek DPI and DP_INTF function blocks are a sink of the display + subsystem and provides 8-bit RGB/YUV444 or 8/10/10-bit YUV422 pixel data on a + parallel output bus. properties: compatible:
@@ -23,6 +23,7 @@ properties: - mediatek,mt8173-dpi - mediatek,mt8183-dpi - mediatek,mt8192-dpi + - mediatek,mt8195-dpintf reg: maxItems: 1
@@ -54,7 +55,7 @@ properties: $ref: /schemas/graph.yaml#/properties/port description: Output port node. This port should be connected to the input port of an - attached HDMI or LVDS encoder chip. + attached HDMI, LVDS or DisplayPort encoder chip. required: - compatible
Signature · 1 line
2.32.0
PATCH v7 2/8 dt-bindings: mediatek,dp: Add Display Port binding
In reply to Guillaume RanquetFrom: 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 | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +87 -0
@@ -0,0 +1,87 @@ +# 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: + - CK Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + Device tree bindings for the Mediatek (embedded) Display Port controller + present on some Mediatek SoCs. + +properties: + compatible: + enum: + - mediatek,mt8195-dp-tx + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: faxi clock + + clock-names: + items: + - const: faxi + + power-domains: + 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: + - compatible + - reg + - interrupts + - ports + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/power/mt8195-power.h> + edp_tx: edp_tx@1c500000 { + compatible = "mediatek,mt8195-dp-tx"; + reg = <0 0x1c500000 0 0x8000>; + interrupts = <GIC_SPI 676 IRQ_TYPE_LEVEL_HIGH 0>; + power-domains = <&spm MT8195_POWER_DOMAIN_EPD_TX>; + pinctrl-names = "default"; + pinctrl-0 = <&edp_pin>; + + 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.32.0
Rob Herring
maintainerRe: [PATCH v7 2/8] dt-bindings: mediatek,dp: Add Display Port binding
Quoted 9 lines · Guillaume Ranquet
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 8 lines
Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Reviewed-by Rob Herring <[email protected]>--- .../display/mediatek/mediatek,dp.yaml | 87 +++++++++++++++++++ 1 file changed, 87 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:Documentation/devicetree/bindings/display/mediatek/mediatek,dp.example.dts:20:18: fatal error: dt-bindings/power/mt8195-power.h: No such file or directory
20 | #include <dt-bindings/power/mt8195-power.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [scripts/Makefile.lib:373: Documentation/devicetree/bindings/display/mediatek/mediatek,dp.example.dt.yaml] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1413: dt_binding_check] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/1570103
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.
PATCH v7 3/8 drm/edid: Add cea_sad helpers for freq/length
In reply to Guillaume RanquetFrom: Markus Schneider-Pargmann <[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 | 74 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 18 ++++++++-- 2 files changed, 90 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_edid.c +74 -0
@@ -4747,6 +4747,80 @@ int drm_edid_to_speaker_allocation(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_uncompressed (const struct cea_sad *sad) +{ +switch (sad->format) { +case HDMI_AUDIO_CODING_TYPE_STREAM : +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_uncompressed (sad)) { +DRM_WARN ("Unable to get the uncompressed word length for a compressed 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 +16 -2
@@ -361,12 +361,24 @@ struct edid {/* Short Audio Descriptor */ struct cea_sad { -u8 format; +u8 format;/* See HDMI_AUDIO_CODING_TYPE_* */ u8 channels;/* max number of channels - 1 */ -u8 freq; +u8 freq;/* See CEA_SAD_FREQ_* */ u8 byte2;/* meaning depends on format */ }; +#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 ;
@@ -374,6 +386,8 @@ struct drm_display_mode;int drm_edid_to_sad (struct edid *edid,struct cea_sad **sads);int drm_edid_to_speaker_allocation (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.32.0
PATCH v7 3/8 drm/edid: Add cea_sad helpers for freq/length
In reply to Guillaume RanquetFrom: Markus Schneider-Pargmann <[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 | 74 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 18 ++++++++-- 2 files changed, 90 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_edid.c +74 -0
@@ -4747,6 +4747,80 @@ int drm_edid_to_speaker_allocation(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_uncompressed (const struct cea_sad *sad) +{ +switch (sad->format) { +case HDMI_AUDIO_CODING_TYPE_STREAM : +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_uncompressed (sad)) { +DRM_WARN ("Unable to get the uncompressed word length for a compressed 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 +16 -2
@@ -361,12 +361,24 @@ struct edid {/* Short Audio Descriptor */ struct cea_sad { -u8 format; +u8 format;/* See HDMI_AUDIO_CODING_TYPE_* */ u8 channels;/* max number of channels - 1 */ -u8 freq; +u8 freq;/* See CEA_SAD_FREQ_* */ u8 byte2;/* meaning depends on format */ }; +#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 ;
@@ -374,6 +386,8 @@ struct drm_display_mode;int drm_edid_to_sad (struct edid *edid,struct cea_sad **sads);int drm_edid_to_speaker_allocation (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.32.0
PATCH v7 4/8 video/hdmi: Add audio_infoframe packing for DP
In reply to Guillaume RanquetFrom: 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.
--- drivers/video/hdmi.c | 83 ++++++++++++++++++++++++++++--------- include/drm/drm_dp_helper.h | 2 + include/linux/hdmi.h | 7 +++- 3 files changed, 72 insertions(+), 20 deletions(-)
drivers/video/hdmi.c +64 -19
@@ -21,6 +21,7 @@* DEALINGS IN THE SOFTWARE. */ +#include <drm/drm_dp_helper.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,44 @@ 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/drm_dp_helper.h +2 -0
@@ -1550,6 +1550,8 @@ int drm_dp_bw_code_to_link_rate(u8 link_bw);#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.32.0
PATCH v7 4/8 video/hdmi: Add audio_infoframe packing for DP
In reply to Guillaume RanquetFrom: 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.
--- drivers/video/hdmi.c | 83 ++++++++++++++++++++++++++++--------- include/drm/drm_dp_helper.h | 2 + include/linux/hdmi.h | 7 +++- 3 files changed, 72 insertions(+), 20 deletions(-)
drivers/video/hdmi.c +64 -19
@@ -21,6 +21,7 @@* DEALINGS IN THE SOFTWARE. */ +#include <drm/drm_dp_helper.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,44 @@ 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/drm_dp_helper.h +2 -0
@@ -1550,6 +1550,8 @@ int drm_dp_bw_code_to_link_rate(u8 link_bw);#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.32.0
PATCH v7 5/8 drm/mediatek: dpi: Add dpintf support
In reply to Guillaume RanquetFrom: Markus Schneider-Pargmann <[email protected]>
dpintf is the displayport interface hardware unit. This unit is similar to dpi and can reuse most of the code.
This patch adds support for mt8195-dpintf to this dpi driver. Main differences are:
- Some features/functional components are not available for dpintf which are now excluded from code execution once is_dpintf is set
- dpintf can and needs to choose between different clockdividers based on the clockspeed. This is done by choosing a different clock parent.
- There are two additional clocks that need to be managed. These are only set for dpintf and will be set to NULL if not supplied. The clk_* calls handle these as normal clocks then.
- Some register contents differ slightly between the two components. To work around this I added register bits/masks with a DPINTF_ prefix and use them where different.
Based on a separate driver for dpintf created by
Jason-JH.Lin <[email protected]>.
--- drivers/gpu/drm/mediatek/mtk_dpi.c | 304 ++++++++++++++++---- drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 38 +++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 4 + drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 1 + drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 +- include/linux/soc/mediatek/mtk-mmsys.h | 2 + 6 files changed, 299 insertions(+), 55 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +250 -54
@@ -63,6 +63,14 @@ enum mtk_dpi_out_color_format {MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL }; +enum TVDPLL_CLK { +TVDPLL_PLL =0 , +TVDPLL_D2 =2 , +TVDPLL_D4 =4 , +TVDPLL_D8 =8 , +TVDPLL_D16 =16 , +}; +struct mtk_dpi {struct drm_encoder encoder;struct drm_bridge bridge;
@@ -71,8 +79,10 @@ struct mtk_dpi {void __iomem *regs;struct device *dev;struct clk *engine_clk; +struct clk *dpi_ck_cg;struct clk *pixel_clk;struct clk *tvd_clk; +struct clk *pclk_src[5 ];int irq;struct drm_display_mode mode;const struct mtk_dpi_conf *conf;
@@ -125,6 +135,18 @@ struct mtk_dpi_conf {bool edge_sel_en;const u32 *output_fmts;u32 num_output_fmts; +bool is_ck_de_pol; +bool is_dpintf; +bool csc_support; +bool swap_input_support; +// Mask used for HWIDTH, HPORCH, VSYNC_WIDTH and VSYNC_PORCH (no shift) +u32 dimension_mask; +// Mask used for HSIZE and VSIZE (no shift) +u32 hvsize_mask; +u32 channel_swap_shift; +u32 yuv422_en_bit; +u32 csc_enable_bit; +const struct mtk_dpi_yc_limit *limit; };static void mtk_dpi_mask (struct mtk_dpi *dpi,u32 offset,u32 val,u32 mask)
@@ -153,30 +175,30 @@ static void mtk_dpi_disable(struct mtk_dpi *dpi)static void mtk_dpi_config_hsync (struct mtk_dpi *dpi,struct mtk_dpi_sync_param *sync) { -mtk_dpi_mask (dpi,DPI_TGEN_HWIDTH , - sync->sync_width <<HPW ,HPW_MASK ); -mtk_dpi_mask (dpi,DPI_TGEN_HPORCH , - sync->back_porch <<HBP ,HBP_MASK ); +mtk_dpi_mask (dpi,DPI_TGEN_HWIDTH , sync->sync_width <<HPW , + dpi->conf->dimension_mask <<HPW ); +mtk_dpi_mask (dpi,DPI_TGEN_HPORCH , sync->back_porch <<HBP , + dpi->conf->dimension_mask <<HBP );mtk_dpi_mask (dpi,DPI_TGEN_HPORCH , sync->front_porch <<HFP , -HFP_MASK ); + dpi->conf->dimension_mask <<HFP ); }static void mtk_dpi_config_vsync (struct mtk_dpi *dpi,struct mtk_dpi_sync_param *sync,u32 width_addr,u32 porch_addr) { -mtk_dpi_mask (dpi, width_addr, - sync->sync_width <<VSYNC_WIDTH_SHIFT , -VSYNC_WIDTH_MASK );mtk_dpi_mask (dpi, width_addr, sync->shift_half_line <<VSYNC_HALF_LINE_SHIFT ,VSYNC_HALF_LINE_MASK ); +mtk_dpi_mask (dpi, width_addr, + sync->sync_width <<VSYNC_WIDTH_SHIFT , + dpi->conf->dimension_mask <<VSYNC_WIDTH_SHIFT );mtk_dpi_mask (dpi, porch_addr, sync->back_porch <<VSYNC_BACK_PORCH_SHIFT , -VSYNC_BACK_PORCH_MASK ); + dpi->conf->dimension_mask <<VSYNC_BACK_PORCH_SHIFT );mtk_dpi_mask (dpi, porch_addr, sync->front_porch <<VSYNC_FRONT_PORCH_SHIFT , -VSYNC_FRONT_PORCH_MASK ); + dpi->conf->dimension_mask <<VSYNC_FRONT_PORCH_SHIFT ); } static void mtk_dpi_config_vsync_lodd(struct mtk_dpi *dpi,
@@ -210,13 +232,20 @@ static void mtk_dpi_config_pol(struct mtk_dpi *dpi, struct mtk_dpi_polarities *dpi_pol) {unsigned int pol; +unsigned int mask; - pol = (dpi_pol->ck_pol ==MTK_DPI_POLARITY_RISING ?0 :CK_POL ) | - (dpi_pol->de_pol ==MTK_DPI_POLARITY_RISING ?0 :DE_POL ) | - (dpi_pol->hsync_pol ==MTK_DPI_POLARITY_RISING ?0 :HSYNC_POL ) | + mask =HSYNC_POL |VSYNC_POL ; + pol = (dpi_pol->hsync_pol ==MTK_DPI_POLARITY_RISING ?0 :HSYNC_POL ) | (dpi_pol->vsync_pol ==MTK_DPI_POLARITY_RISING ?0 :VSYNC_POL ); -mtk_dpi_mask (dpi,DPI_OUTPUT_SETTING , pol, -CK_POL |DE_POL |HSYNC_POL |VSYNC_POL ); +if (dpi->conf->is_ck_de_pol) { + mask |=CK_POL |DE_POL ; + pol |= (dpi_pol->ck_pol ==MTK_DPI_POLARITY_RISING ? +0 :CK_POL ) | + (dpi_pol->de_pol ==MTK_DPI_POLARITY_RISING ? +0 :DE_POL ); + } + +mtk_dpi_mask (dpi,DPI_OUTPUT_SETTING , pol, mask); }static void mtk_dpi_config_3d (struct mtk_dpi *dpi,bool en_3d)
@@ -231,13 +260,16 @@ static void mtk_dpi_config_interface(struct mtk_dpi *dpi, bool inter)static void mtk_dpi_config_fb_size (struct mtk_dpi *dpi,u32 width,u32 height) { -mtk_dpi_mask (dpi,DPI_SIZE , width <<HSIZE ,HSIZE_MASK ); -mtk_dpi_mask (dpi,DPI_SIZE , height <<VSIZE ,VSIZE_MASK ); +mtk_dpi_mask (dpi,DPI_SIZE , width <<HSIZE , + dpi->conf->hvsize_mask <<HSIZE ); +mtk_dpi_mask (dpi,DPI_SIZE , height <<VSIZE , + dpi->conf->hvsize_mask <<VSIZE ); } -static void mtk_dpi_config_channel_limit (struct mtk_dpi *dpi, -struct mtk_dpi_yc_limit *limit) +static void mtk_dpi_config_channel_limit (struct mtk_dpi *dpi) { +const struct mtk_dpi_yc_limit *limit = dpi->conf->limit; +mtk_dpi_mask (dpi,DPI_Y_LIMIT , limit->y_bottom <<Y_LIMINT_BOT ,Y_LIMINT_BOT_MASK ); mtk_dpi_mask(dpi, DPI_Y_LIMIT, limit->y_top << Y_LIMINT_TOP,
@@ -332,17 +364,20 @@ static void mtk_dpi_config_channel_swap(struct mtk_dpi *dpi,break ; } -mtk_dpi_mask (dpi,DPI_OUTPUT_SETTING , val <<CH_SWAP ,CH_SWAP_MASK ); +mtk_dpi_mask (dpi,DPI_OUTPUT_SETTING , val <<CH_SWAP , +CH_SWAP_MASK << dpi->conf->channel_swap_shift); }static void mtk_dpi_config_yuv422_enable (struct mtk_dpi *dpi,bool enable) { -mtk_dpi_mask (dpi,DPI_CON , enable ?YUV422_EN :0 ,YUV422_EN ); +mtk_dpi_mask (dpi,DPI_CON , enable ? dpi->conf->yuv422_en_bit :0 , + dpi->conf->yuv422_en_bit); }static void mtk_dpi_config_csc_enable (struct mtk_dpi *dpi,bool enable) { -mtk_dpi_mask (dpi,DPI_CON , enable ?CSC_ENABLE :0 ,CSC_ENABLE ); +mtk_dpi_mask (dpi,DPI_CON , enable ? dpi->conf->csc_enable_bit :0 , + dpi->conf->csc_enable_bit); }static void mtk_dpi_config_swap_input (struct mtk_dpi *dpi,bool enable)
@@ -361,25 +396,54 @@ static void mtk_dpi_config_disable_edge(struct mtk_dpi *dpi)mtk_dpi_mask (dpi, dpi->conf->reg_h_fre_con,0 ,EDGE_SEL_EN ); } +static void mtk_dpi_matrix_sel (struct mtk_dpi *dpi,enum mtk_dpi_out_color_format format) +{ +u32 matrix_sel =0 ; + +switch (format) { +case MTK_DPI_COLOR_FORMAT_YCBCR_422 : +case MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL : +case MTK_DPI_COLOR_FORMAT_YCBCR_444 : +case MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL : +case MTK_DPI_COLOR_FORMAT_XV_YCC : +if (dpi->mode.hdisplay <=720 ) + matrix_sel =0x2 ; +break ; +default : +break ; + } +mtk_dpi_mask (dpi,DPI_MATRIX_SET , matrix_sel,INT_MATRIX_SEL_MASK ); +} +static void mtk_dpi_config_color_format (struct mtk_dpi *dpi,enum mtk_dpi_out_color_format format) {if ((format ==MTK_DPI_COLOR_FORMAT_YCBCR_444 ) || (format ==MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL )) {mtk_dpi_config_yuv422_enable (dpi, false); -mtk_dpi_config_csc_enable (dpi, true); -mtk_dpi_config_swap_input (dpi, false); +if (dpi->conf->csc_support) { +mtk_dpi_config_csc_enable (dpi, true); +mtk_dpi_matrix_sel (dpi, format); + } +if (dpi->conf->swap_input_support) +mtk_dpi_config_swap_input (dpi, false);mtk_dpi_config_channel_swap (dpi,MTK_DPI_OUT_CHANNEL_SWAP_BGR ); }else if ((format ==MTK_DPI_COLOR_FORMAT_YCBCR_422 ) || (format ==MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL )) {mtk_dpi_config_yuv422_enable (dpi, true); -mtk_dpi_config_csc_enable (dpi, true); -mtk_dpi_config_swap_input (dpi, true); +if (dpi->conf->csc_support) { +mtk_dpi_config_csc_enable (dpi, true); +mtk_dpi_matrix_sel (dpi, format); + } +if (dpi->conf->swap_input_support) +mtk_dpi_config_swap_input (dpi, true);mtk_dpi_config_channel_swap (dpi,MTK_DPI_OUT_CHANNEL_SWAP_RGB ); }else {mtk_dpi_config_yuv422_enable (dpi, false); -mtk_dpi_config_csc_enable (dpi, false); -mtk_dpi_config_swap_input (dpi, false); +if (dpi->conf->csc_support) +mtk_dpi_config_csc_enable (dpi, false); +if (dpi->conf->swap_input_support) +mtk_dpi_config_swap_input (dpi, false);mtk_dpi_config_channel_swap (dpi,MTK_DPI_OUT_CHANNEL_SWAP_RGB ); } }
@@ -412,6 +476,8 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi)mtk_dpi_disable (dpi);clk_disable_unprepare (dpi->pixel_clk);clk_disable_unprepare (dpi->engine_clk); +clk_disable_unprepare (dpi->dpi_ck_cg); +clk_disable_unprepare (dpi->tvd_clk); }static int mtk_dpi_power_on (struct mtk_dpi *dpi)
@@ -421,12 +487,24 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)if (++dpi->refcount !=1 )return 0 ; + ret =clk_prepare_enable (dpi->tvd_clk); +if (ret) { +dev_err (dpi->dev,"Failed to enable tvd pll: %d\n" , ret); + goto err_pixel; + } + ret =clk_prepare_enable (dpi->engine_clk);if (ret) {dev_err (dpi->dev,"Failed to enable engine clock: %d\n" , ret); goto err_refcount; } + ret =clk_prepare_enable (dpi->dpi_ck_cg); +if (ret) { +dev_err (dpi->dev,"Failed to enable dpi_ck_cg clock: %d\n" , ret); + goto err_ck_cg; + } + ret =clk_prepare_enable (dpi->pixel_clk);if (ret) {dev_err (dpi->dev,"Failed to enable pixel clock: %d\n" , ret);
@@ -436,10 +514,11 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)if (dpi->pinctrl && dpi->pins_dpi)pinctrl_select_state (dpi->pinctrl, dpi->pins_dpi); -mtk_dpi_enable (dpi);return 0 ; err_pixel: +clk_disable_unprepare (dpi->dpi_ck_cg); +err_ck_cg:clk_disable_unprepare (dpi->engine_clk); err_refcount: dpi->refcount--;
@@ -449,7 +528,6 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)static int mtk_dpi_set_display_mode (struct mtk_dpi *dpi,struct drm_display_mode *mode) { -struct mtk_dpi_yc_limit limit;struct mtk_dpi_polarities dpi_pol;struct mtk_dpi_sync_param hsync;struct mtk_dpi_sync_param vsync_lodd = {0 };
@@ -472,32 +550,42 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, pll_rate =clk_get_rate (dpi->tvd_clk); vm.pixelclock = pll_rate / factor; -if ((dpi->output_fmt ==MEDIA_BUS_FMT_RGB888_2X12_LE ) || - (dpi->output_fmt ==MEDIA_BUS_FMT_RGB888_2X12_BE )) +if (dpi->conf->is_dpintf) { +if (factor ==1 ) +clk_set_parent (dpi->pixel_clk, dpi->pclk_src[2 ]); +else if (factor ==2 ) +clk_set_parent (dpi->pixel_clk, dpi->pclk_src[3 ]); +else if (factor ==4 ) +clk_set_parent (dpi->pixel_clk, dpi->pclk_src[4 ]); +else +clk_set_parent (dpi->pixel_clk, dpi->pclk_src[2 ]); + } else if { ((dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_LE) || + (dpi->output_fmt ==MEDIA_BUS_FMT_RGB888_2X12_BE ))clk_set_rate (dpi->pixel_clk, vm.pixelclock *2 ); -else + } else {clk_set_rate (dpi->pixel_clk, vm.pixelclock); - + } vm.pixelclock =clk_get_rate (dpi->pixel_clk);dev_dbg (dpi->dev,"Got PLL %lu Hz, pixel clock %lu Hz\n" , pll_rate, vm.pixelclock); - limit.c_bottom =0x0010 ; - limit.c_top =0x0FE0 ; - limit.y_bottom =0x0010 ; - limit.y_top =0x0FE0 ; - dpi_pol.ck_pol =MTK_DPI_POLARITY_FALLING ; dpi_pol.de_pol =MTK_DPI_POLARITY_RISING ; dpi_pol.hsync_pol = vm.flags &DISPLAY_FLAGS_HSYNC_HIGH ?MTK_DPI_POLARITY_FALLING :MTK_DPI_POLARITY_RISING ; dpi_pol.vsync_pol = vm.flags &DISPLAY_FLAGS_VSYNC_HIGH ?MTK_DPI_POLARITY_FALLING :MTK_DPI_POLARITY_RISING ; - hsync.sync_width = vm.hsync_len; - hsync.back_porch = vm.hback_porch; - hsync.front_porch = vm.hfront_porch; +if (dpi->conf->is_dpintf) { + hsync.sync_width = vm.hsync_len /4 ; + hsync.back_porch = vm.hback_porch /4 ; + hsync.front_porch = vm.hfront_porch /4 ; + }else { + hsync.sync_width = vm.hsync_len; + hsync.back_porch = vm.hback_porch; + hsync.front_porch = vm.hfront_porch; + } hsync.shift_half_line = false; vsync_lodd.sync_width = vm.vsync_len; vsync_lodd.back_porch = vm.vback_porch;
@@ -536,16 +624,23 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,else mtk_dpi_config_fb_size (dpi, vm.hactive, vm.vactive); -mtk_dpi_config_channel_limit (dpi, &limit); +mtk_dpi_config_channel_limit (dpi);mtk_dpi_config_bit_num (dpi, dpi->bit_num);mtk_dpi_config_channel_swap (dpi, dpi->channel_swap); -mtk_dpi_config_yc_map (dpi, dpi->yc_map);mtk_dpi_config_color_format (dpi, dpi->color_format); -mtk_dpi_config_2n_h_fre (dpi); -mtk_dpi_dual_edge (dpi); -mtk_dpi_config_disable_edge (dpi); +if (dpi->conf->is_dpintf) { +mtk_dpi_mask (dpi,DPI_CON ,DPINTF_INPUT_2P_EN , +DPINTF_INPUT_2P_EN ); + }else { +mtk_dpi_config_yc_map (dpi, dpi->yc_map); +mtk_dpi_config_2n_h_fre (dpi); +mtk_dpi_dual_edge (dpi); +mtk_dpi_config_disable_edge (dpi); + }mtk_dpi_sw_reset (dpi, false); +mtk_dpi_enable (dpi); +return 0 ; }
@@ -588,7 +683,6 @@ static u32 *mtk_dpi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,u32 *input_fmts; *num_input_fmts =0 ; - input_fmts =kcalloc (1 ,sizeof (*input_fmts),GFP_KERNEL );if (!input_fmts)
@@ -614,15 +708,18 @@ static int mtk_dpi_bridge_atomic_check(struct drm_bridge *bridge,if (dpi->conf->num_output_fmts) out_bus_format = dpi->conf->output_fmts[0 ]; -dev_dbg (dpi->dev,"input format 0x%04x, output format 0x%04x\n" , - bridge_state->input_bus_cfg.format, - bridge_state->output_bus_cfg.format); +dev_info (dpi->dev,"input format 0x%04x, output format 0x%04x\n" , + bridge_state->input_bus_cfg.format, + bridge_state->output_bus_cfg.format); dpi->output_fmt = out_bus_format; dpi->bit_num =MTK_DPI_OUT_BIT_NUM_8BITS ; dpi->channel_swap =MTK_DPI_OUT_CHANNEL_SWAP_RGB ; dpi->yc_map =MTK_DPI_OUT_YC_MAP_RGB ; - dpi->color_format =MTK_DPI_COLOR_FORMAT_RGB ; +if (out_bus_format ==MEDIA_BUS_FMT_YUYV8_1X16 ) + dpi->color_format =MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL ; +else + dpi->color_format =MTK_DPI_COLOR_FORMAT_RGB ;return 0 ; }
@@ -667,7 +764,7 @@ mtk_dpi_bridge_mode_valid(struct drm_bridge *bridge, {struct mtk_dpi *dpi =bridge_to_dpi (bridge); -if (mode->clock > dpi->conf->max_clock_khz) +if (dpi->conf->max_clock_khz && mode->clock > dpi->conf->max_clock_khz)return MODE_CLOCK_HIGH ;return MODE_OK ;
@@ -781,6 +878,16 @@ static unsigned int mt8183_calculate_factor(int clock)return 2 ; } +static unsigned int mt8195_dpintf_calculate_factor (int clock) +{ +if (clock <70000 ) +return 4 ; +else if (clock <200000 ) +return 2 ; +else +return 1 ; +} +static const u32 mt8173_output_fmts[] = {MEDIA_BUS_FMT_RGB888_1X24 , };
@@ -790,12 +897,41 @@ static const u32 mt8183_output_fmts[] = { MEDIA_BUS_FMT_RGB888_2X12_BE, }; +static const u32 mt8195_output_fmts[] = { +MEDIA_BUS_FMT_RGB888_1X24 , +MEDIA_BUS_FMT_YUV8_1X24 , +MEDIA_BUS_FMT_YUYV8_1X16 , +}; + +static const struct mtk_dpi_yc_limit mtk_dpi_limit = { + .c_bottom =0x0010 , + .c_top =0x0FE0 , + .y_bottom =0x0010 , + .y_top =0x0FE0 , +}; + +static const struct mtk_dpi_yc_limit mtk_dpintf_limit = { + .c_bottom =0x0000 , + .c_top =0xFFF , + .y_bottom =0x0000 , + .y_top =0xFFF , +}; +static const struct mtk_dpi_conf mt8173_conf = { .cal_factor = mt8173_calculate_factor, .reg_h_fre_con =0xe0 , .max_clock_khz =300000 , .output_fmts = mt8173_output_fmts, .num_output_fmts =ARRAY_SIZE (mt8173_output_fmts), + .is_ck_de_pol = true, + .csc_support = true, + .swap_input_support = true, + .dimension_mask =HPW_MASK , + .hvsize_mask =HSIZE_MASK , + .channel_swap_shift =CH_SWAP , + .yuv422_en_bit =YUV422_EN , + .csc_enable_bit =CSC_ENABLE , + .limit = &mtk_dpi_limit, };static const struct mtk_dpi_conf mt2701_conf = {
@@ -805,6 +941,15 @@ static const struct mtk_dpi_conf mt2701_conf = { .max_clock_khz = 150000, .output_fmts = mt8173_output_fmts, .num_output_fmts = ARRAY_SIZE(mt8173_output_fmts), + .is_ck_de_pol = true, + .csc_support = true, + .swap_input_support = true, + .dimension_mask = HPW_MASK, + .hvsize_mask = HSIZE_MASK, + .channel_swap_shift = CH_SWAP, + .yuv422_en_bit = YUV422_EN, + .csc_enable_bit = CSC_ENABLE, + .limit = &mtk_dpi_limit, };static const struct mtk_dpi_conf mt8183_conf = {
@@ -813,6 +958,15 @@ static const struct mtk_dpi_conf mt8183_conf = { .max_clock_khz = 100000, .output_fmts = mt8183_output_fmts, .num_output_fmts = ARRAY_SIZE(mt8183_output_fmts), + .is_ck_de_pol = true, + .csc_support = true, + .swap_input_support = true, + .dimension_mask = HPW_MASK, + .hvsize_mask = HSIZE_MASK, + .channel_swap_shift = CH_SWAP, + .yuv422_en_bit = YUV422_EN, + .csc_enable_bit = CSC_ENABLE, + .limit = &mtk_dpi_limit, };static const struct mtk_dpi_conf mt8192_conf = {
@@ -821,6 +975,29 @@ static const struct mtk_dpi_conf mt8192_conf = { .max_clock_khz = 150000, .output_fmts = mt8173_output_fmts, .num_output_fmts = ARRAY_SIZE(mt8173_output_fmts), + .is_ck_de_pol = true, + .csc_support = true, + .swap_input_support = true, + .dimension_mask = HPW_MASK, + .hvsize_mask = HSIZE_MASK, + .channel_swap_shift = CH_SWAP, + .yuv422_en_bit = YUV422_EN, + .csc_enable_bit = CSC_ENABLE, + .limit = &mtk_dpi_limit, +}; + +static const struct mtk_dpi_conf mt8195_dpintf_conf = { + .cal_factor = mt8195_dpintf_calculate_factor, + .output_fmts = mt8195_output_fmts, + .num_output_fmts =ARRAY_SIZE (mt8195_output_fmts), + .is_dpintf = true, + .csc_support = true, + .dimension_mask =DPINTF_HPW_MASK , + .hvsize_mask =DPINTF_HSIZE_MASK , + .channel_swap_shift =DPINTF_CH_SWAP , + .yuv422_en_bit =DPINTF_YUV422_EN , + .csc_enable_bit =DPINTF_CSC_ENABLE , + .limit = &mtk_dpintf_limit, };static int mtk_dpi_probe (struct platform_device *pdev)
@@ -870,7 +1047,18 @@ static int mtk_dpi_probe(struct platform_device *pdev)if (IS_ERR (dpi->engine_clk)) { ret =PTR_ERR (dpi->engine_clk);if (ret != -EPROBE_DEFER ) -dev_err (dev,"Failed to get engine clock: %d\n" , ret); +dev_err (dev,"Failed to get engine clock: %d\n" , + ret); + +return ret; + } + + dpi->dpi_ck_cg =devm_clk_get_optional (dev,"ck_cg" ); +if (IS_ERR (dpi->dpi_ck_cg)) { + ret =PTR_ERR (dpi->dpi_ck_cg); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get dpi ck cg clock: %d\n" , + ret);return ret; }
@@ -893,6 +1081,11 @@ static int mtk_dpi_probe(struct platform_device *pdev)return ret; } + dpi->pclk_src[1 ] =devm_clk_get (dev,"TVDPLL_D2" ); + dpi->pclk_src[2 ] =devm_clk_get (dev,"TVDPLL_D4" ); + dpi->pclk_src[3 ] =devm_clk_get (dev,"TVDPLL_D8" ); + dpi->pclk_src[4 ] =devm_clk_get (dev,"TVDPLL_D16" ); + dpi->irq =platform_get_irq (pdev,0 );if (dpi->irq <=0 )return -EINVAL ;
@@ -945,6 +1138,9 @@ static const struct of_device_id mtk_dpi_of_ids[] = { { .compatible = "mediatek,mt8192-dpi", .data = &mt8192_conf, }, + { .compatible = "mediatek,mt8195-dpintf", + .data = &mt8195_dpintf_conf, + }, { }, };MODULE_DEVICE_TABLE (of, mtk_dpi_of_ids);
drivers/gpu/drm/mediatek/mtk_dpi_regs.h +38 -0
@@ -40,10 +40,15 @@#define FAKE_DE_LEVEN BIT(21)#define FAKE_DE_RODD BIT(22)#define FAKE_DE_REVEN BIT(23) +#define DPINTF_YUV422_EN BIT(24) +#define DPINTF_CSC_ENABLE BIT(26) +#define DPINTF_INPUT_2P_EN BIT(29)#define DPI_OUTPUT_SETTING 0x14#define CH_SWAP 0 +#define DPINTF_CH_SWAP BIT(1)#define CH_SWAP_MASK (0x7 << 0) +#define DPINTF_CH_SWAP_MASK (0x7 << 1)#define SWAP_RGB 0x00#define SWAP_GBR 0x01#define SWAP_BRG 0x02
@@ -80,8 +85,10 @@#define DPI_SIZE 0x18#define HSIZE 0#define HSIZE_MASK (0x1FFF << 0) +#define DPINTF_HSIZE_MASK (0xFFFF << 0)#define VSIZE 16#define VSIZE_MASK (0x1FFF << 16) +#define DPINTF_VSIZE_MASK (0xFFFF << 16)#define DPI_DDR_SETTING 0x1C#define DDR_EN BIT(0)
@@ -93,24 +100,30 @@#define DPI_TGEN_HWIDTH 0x20#define HPW 0#define HPW_MASK (0xFFF << 0) +#define DPINTF_HPW_MASK (0xFFFF << 0)#define DPI_TGEN_HPORCH 0x24#define HBP 0#define HBP_MASK (0xFFF << 0) +#define DPINTF_HBP_MASK (0xFFFF << 0)#define HFP 16#define HFP_MASK (0xFFF << 16) +#define DPINTF_HFP_MASK (0xFFFF << 16)#define DPI_TGEN_VWIDTH 0x28#define DPI_TGEN_VPORCH 0x2C#define VSYNC_WIDTH_SHIFT 0#define VSYNC_WIDTH_MASK (0xFFF << 0) +#define DPINTF_VSYNC_WIDTH_MASK (0xFFFF << 0)#define VSYNC_HALF_LINE_SHIFT 16#define VSYNC_HALF_LINE_MASK BIT(16)#define VSYNC_BACK_PORCH_SHIFT 0#define VSYNC_BACK_PORCH_MASK (0xFFF << 0) +#define DPINTF_VSYNC_BACK_PORCH_MASK (0xFFFF << 0)#define VSYNC_FRONT_PORCH_SHIFT 16#define VSYNC_FRONT_PORCH_MASK (0xFFF << 16) +#define DPINTF_VSYNC_FRONT_PORCH_MASK (0xFFFF << 16)#define DPI_BG_HCNTL 0x30#define BG_RIGHT (0x1FFF << 0)
@@ -217,4 +230,29 @@#define EDGE_SEL_EN BIT(5)#define H_FRE_2N BIT(25) + +#define DPI_MATRIX_SET 0xB4 +#define INT_MATRIX_SEL BIT(0) +#define INT_MATRIX_SEL_MASK (0x1F << 0) +#define RGB_TO_JPEG 0x00 +#define RGB_TO_FULL709 0x01 +#define RGB_TO_BT601 0x02 +#define RGB_TO_BT709 0x03 +#define JPEG_TO_RGB 0x04 +#define FULL709_TO_RGB 0x05 +#define BT601_TO_RGB 0x06 +#define BT709_TO_RGB 0x07 +#define JPEG_TO_BT601 0x08 +#define JPEG_TO_BT709 0x09 +#define BT601_TO_JPEG 0xA +#define BT709_TO_JPEG 0xB +#define BT709_TO_BT601 0xC +#define BT601_TO_BT709 0xD +#define JPEG_TO_CERGB 0x14 +#define FULL709_TO_CERGB 0x15 +#define BT601_TO_CERGB 0x16 +#define BT709_TO_CERGB 0x17 +#define RGB_TO_CERGB 0x1C +#define MATRIX_BIT BIT(8) +#define EXT_MATRIX_EN BIT(12)#endif /* __MTK_DPI_REGS_H */
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +4 -0
@@ -317,6 +317,7 @@ static const char * const mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX] = { [MTK_DISP_UFOE] = "ufoe", [MTK_DSI] = "dsi", [MTK_DPI] = "dpi", + [MTK_DP_INTF] = "dp-intf", [MTK_DISP_PWM] = "pwm", [MTK_DISP_MUTEX] = "mutex", [MTK_DISP_OD] = "od",
@@ -339,6 +340,8 @@ static const struct mtk_ddp_comp_match mtk_ddp_matches[DDP_COMPONENT_ID_MAX] = { [DDP_COMPONENT_DITHER] = { MTK_DISP_DITHER, 0, &ddp_dither }, [DDP_COMPONENT_DPI0] = { MTK_DPI, 0, &ddp_dpi }, [DDP_COMPONENT_DPI1] = { MTK_DPI, 1, &ddp_dpi }, + [DDP_COMPONENT_DP_INTF0] = { MTK_DP_INTF, 0, &ddp_dpi }, + [DDP_COMPONENT_DP_INTF1] = { MTK_DP_INTF, 1, &ddp_dpi }, [DDP_COMPONENT_DSI0] = { MTK_DSI, 0, &ddp_dsi }, [DDP_COMPONENT_DSI1] = { MTK_DSI, 1, &ddp_dsi }, [DDP_COMPONENT_DSI2] = { MTK_DSI, 2, &ddp_dsi },
@@ -476,6 +479,7 @@ int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp, type ==MTK_DISP_COLOR || type ==MTK_DISP_GAMMA || type ==MTK_DPI || + type ==MTK_DP_INTF || type ==MTK_DSI || type ==MTK_DISP_OVL || type == MTK_DISP_OVL_2L ||
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +1 -0
@@ -30,6 +30,7 @@ enum mtk_ddp_comp_type {MTK_DISP_UFOE ,MTK_DSI ,MTK_DPI , +MTK_DP_INTF ,MTK_DISP_PWM ,MTK_DISP_MUTEX , MTK_DISP_OD,
drivers/gpu/drm/mediatek/mtk_drm_drv.c +4 -1
@@ -459,6 +459,8 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = { .data = (void *)MTK_DPI }, { .compatible = "mediatek,mt8183-dpi", .data = (void *)MTK_DPI }, + { .compatible = "mediatek,mt8195-dpintf", + .data = (void *)MTK_DP_INTF }, { .compatible = "mediatek,mt2701-disp-mutex", .data = (void *)MTK_DISP_MUTEX }, { .compatible = "mediatek,mt2712-disp-mutex",
@@ -569,7 +571,8 @@ static int mtk_drm_probe(struct platform_device *pdev) comp_type == MTK_DISP_OVL_2L || comp_type == MTK_DISP_RDMA || comp_type == MTK_DSI || - comp_type == MTK_DPI) { + comp_type == MTK_DPI || + comp_type == MTK_DP_INTF) {dev_info (dev,"Adding component match for %pOF\n" , node); drm_of_component_match_add(dev, &match, compare_of,
include/linux/soc/mediatek/mtk-mmsys.h +2 -0
@@ -19,6 +19,8 @@ enum mtk_ddp_comp_id {DDP_COMPONENT_DITHER ,DDP_COMPONENT_DPI0 ,DDP_COMPONENT_DPI1 , +DDP_COMPONENT_DP_INTF0 , +DDP_COMPONENT_DP_INTF1 ,DDP_COMPONENT_DSI0 ,DDP_COMPONENT_DSI1 , DDP_COMPONENT_DSI2,
Signature · 1 line
2.32.0
Re: [PATCH v7 5/8] drm/mediatek: dpi: Add dpintf support
Hi, Guillaume:
Quoted 71 lines · Guillaume Ranquet
From: Markus Schneider-Pargmann <[email protected]>
dpintf is the displayport interface hardware unit. This unit is similar
to dpi and can reuse most of the code.This patch adds support for mt8195-dpintf to this dpi driver. Main differences are:
- Some features/functional components are not available for dpintf which are now excluded from code execution onceis_dpintfis set
- dpintf can and needs to choose between different clockdividers
based
on the clockspeed. This is done by choosing a different clock
parent.
- There are two additional clocks that need to be managed. These are only set for dpintf and will be set to NULL if not supplied. The clk_* calls handle these as normal clocks then.
- Some register contents differ slightly between the two components.
To
work around this I added register bits/masks with aDPINTF_prefix and use them where different.Based on a separate driver for dpintf created by
Jason-JH.Lin <[email protected]>.Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Reviewed-by AngeloGioacchino Del Regno <--- drivers/gpu/drm/mediatek/mtk_dpi.c | 304 ++++++++++++++++ ---- drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 38 +++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 4 + drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 1 + drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 +- include/linux/soc/mediatek/mtk-mmsys.h | 2 + 6 files changed, 299 insertions(+), 55 deletions(-)drivers/gpu/drm/mediatek/mtk_dpi.c +10
-0@@ -63,6 +63,14 @@ enum mtk_dpi_out_color_format {MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL }; +enum TVDPLL_CLK { +TVDPLL_PLL =0 , +TVDPLL_D2 =2 , +TVDPLL_D4 =4 , +TVDPLL_D8 =8 , +TVDPLL_D16 =16 , +}; +struct mtk_dpi {struct drm_encoder encoder;struct drm_bridge bridge;@@ -71,8 +79,10 @@ struct mtk_dpi {void __iomem *regs;struct device *dev;struct clk *engine_clk; +struct clk *dpi_ck_cg;struct clk *pixel_clk;struct clk *tvd_clk; +struct clk *pclk_src[5 ];int irq;struct drm_display_mode mode;const struct mtk_dpi_conf *conf;
drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi_conf { · line 138
Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-0@@ -125,6 +135,18 @@ struct mtk_dpi_conf {bool edge_sel_en;const u32 *output_fmts;u32 num_output_fmts; +bool is_ck_de_pol;
Seperate is_ck_de_pol to an independent patch.
drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi_conf { · line 139
Quoted 1 line
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-0+bool is_dpintf;
Ditto for is_dpintf. And I would like change the name to what this actually do.
drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi_conf { · line 140
Quoted 1 line
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-0+bool csc_support;
Ditto for csc_support.
drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi_conf { · line 141
Quoted 1 line
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-0+bool swap_input_support;
Ditto for swap_input_support.
drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi_conf { · line 142
Quoted 1 line
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-0+// Mask used for HWIDTH, HPORCH, VSYNC_WIDTH and VSYNC_PORCH
/* ... */
drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi_conf { · line 144
Quoted 2 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-0(no shift) + u32 dimension_mask;
Ditto for dimension_mask.
drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi_conf { · line 145
Quoted 2 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +2
-0+// Mask used for HSIZE and VSIZE (no shift) +u32 hvsize_mask;
Ditto for hvsize_mask.
drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi_conf { · line 146
Quoted 1 line
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-0+u32 channel_swap_shift;
Ditto for channel_swap_shift.
drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi_conf { · line 147
Quoted 1 line
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-0+u32 yuv422_en_bit;
Ditto for yuv422_en_bit.
drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi_conf { · line 148
Quoted 1 line
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-0+u32 csc_enable_bit;
Ditto for csc_enable_bit.
drivers/gpu/drm/mediatek/mtk_dpi.c struct mtk_dpi_conf { · line 149
Quoted 1 line
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-0+const struct mtk_dpi_yc_limit *limit;
Ditto for limit.
drivers/gpu/drm/mediatek/mtk_dpi.c static const struct mtk_dpi_conf mt8192_conf = { · line 994
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +7
-0}; + +static const struct mtk_dpi_conf mt8195_dpintf_conf = { + .cal_factor = mt8195_dpintf_calculate_factor, + .output_fmts = mt8195_output_fmts, + .num_output_fmts =ARRAY_SIZE (mt8195_output_fmts), + .is_dpintf = true, + .csc_support = true,
For every SoC, csc_support is true. Why do we need csc_support?
Regards,
CK
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +6
-0+ .dimension_mask = DPINTF_HPW_MASK, + .hvsize_mask = DPINTF_HSIZE_MASK, + .channel_swap_shift = DPINTF_CH_SWAP, + .yuv422_en_bit = DPINTF_YUV422_EN, + .csc_enable_bit = DPINTF_CSC_ENABLE, + .limit = &mtk_dpintf_limit, };
PATCH v7 6/8 phy: phy-mtk-dp: Add driver for DP phy
In reply to Guillaume RanquetFrom: Markus Schneider-Pargmann <[email protected]>
This is a new driver that supports the integrated DisplayPort phy for mediatek SoCs, especially the mt8195. The phy is integrated into the DisplayPort controller and will be created by the mtk-dp driver. This driver expects a struct regmap to be able to work on the same registers as the DisplayPort controller. It sets the device data to be the struct phy so that the DisplayPort controller can easily work with it.
The driver does not have any devicetree bindings because the datasheet does not list the controller and the phy as distinct units.
The interaction with the controller can be covered by the configure callback of the phy framework and its displayport parameters.
--- MAINTAINERS | 1 + drivers/phy/mediatek/Kconfig | 8 ++ drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-dp.c | 219 ++++++++++++++++++++++++++++++ 4 files changed, 229 insertions(+) create mode 100644 drivers/phy/mediatek/phy-mtk-dp.c
MAINTAINERS +1 -0
@@ -6394,6 +6394,7 @@ L: [email protected] (moderated for non-subscribers) S: Supported F: Documentation/devicetree/bindings/display/mediatek/ F: drivers/gpu/drm/mediatek/ +F: drivers/phy/mediatek/phy-mtk-dp.c F: drivers/phy/mediatek/phy-mtk-hdmi* F: drivers/phy/mediatek/phy-mtk-mipi*
drivers/phy/mediatek/Kconfig +8 -0
@@ -55,3 +55,11 @@ config PHY_MTK_MIPI_DSI select GENERIC_PHY help Support MIPI DSI for Mediatek SoCs. + +config PHY_MTK_DP + tristate "MediaTek DP-PHY Driver" + depends on ARCH_MEDIATEK || COMPILE_TEST + depends on OF + select GENERIC_PHY + help + Support DisplayPort PHY for Mediatek SoCs.
drivers/phy/mediatek/Makefile +1 -0
@@ -3,6 +3,7 @@ # Makefile for the phy drivers. # +obj-$(CONFIG_PHY_MTK_DP) += phy-mtk-dp.o obj-$(CONFIG_PHY_MTK_TPHY) += phy-mtk-tphy.o obj-$(CONFIG_PHY_MTK_UFS) += phy-mtk-ufs.o obj-$(CONFIG_PHY_MTK_XSPHY) += phy-mtk-xsphy.o
drivers/phy/mediatek/phy-mtk-dp.c new file +219 -0
219 lines not on this page · raw message
Signature · 1 line
2.32.0
Vinod Koul
maintainerRe: [PATCH v7 6/8] phy: phy-mtk-dp: Add driver for DP phy
Quoted 1 line · Guillaume Ranquet
From: Markus Schneider-Pargmann <[email protected]>
Pls cc relevant folks on cover so that they know what is going on in the series... Is this dependent on rest? It should not and can be sent and reviewed separately!
Quoted 94 lines
This is a new driver that supports the integrated DisplayPort phy for mediatek SoCs, especially the mt8195. The phy is integrated into the DisplayPort controller and will be created by the mtk-dp driver. This driver expects a struct regmap to be able to work on the same registers as the DisplayPort controller. It sets the device data to be the struct phy so that the DisplayPort controller can easily work with it.
The driver does not have any devicetree bindings because the datasheet does not list the controller and the phy as distinct units.
The interaction with the controller can be covered by the configure callback of the phy framework and its displayport parameters.
Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>--- MAINTAINERS | 1 + drivers/phy/mediatek/Kconfig | 8 ++ drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-dp.c | 219 ++++++++++++++++++++++++++++++ 4 files changed, 229 insertions(+) create mode 100644 drivers/phy/mediatek/phy-mtk-dp.cMAINTAINERS +1
-0@@ -6394,6 +6394,7 @@ L: [email protected] (moderated for non-subscribers) S: Supported F: Documentation/devicetree/bindings/display/mediatek/ F: drivers/gpu/drm/mediatek/ +F: drivers/phy/mediatek/phy-mtk-dp.c F: drivers/phy/mediatek/phy-mtk-hdmi* F: drivers/phy/mediatek/phy-mtk-mipi*drivers/phy/mediatek/Kconfig +8
-0@@ -55,3 +55,11 @@ config PHY_MTK_MIPI_DSI select GENERIC_PHY help Support MIPI DSI for Mediatek SoCs. + +config PHY_MTK_DP + tristate "MediaTek DP-PHY Driver" + depends on ARCH_MEDIATEK || COMPILE_TEST + depends on OF + select GENERIC_PHY + help + Support DisplayPort PHY for Mediatek SoCs.drivers/phy/mediatek/Makefile +1
-0@@ -3,6 +3,7 @@ # Makefile for the phy drivers. # +obj-$(CONFIG_PHY_MTK_DP) += phy-mtk-dp.o obj-$(CONFIG_PHY_MTK_TPHY) += phy-mtk-tphy.o obj-$(CONFIG_PHY_MTK_UFS) += phy-mtk-ufs.o obj-$(CONFIG_PHY_MTK_XSPHY) += phy-mtk-xsphy.odrivers/phy/mediatek/phy-mtk-dp.c new file +25
-0@@ -0,0 +1,219 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2021 BayLibre +* Author: Markus Schneider-Pargmann <[email protected]> +*/ + +#include <linux/delay.h> +#include <linux/io.h> +#include <linux/of.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> + +#define PHY_OFFSET 0x1000 + +#define MTK_DP_PHY_DIG_PLL_CTL_1 (PHY_OFFSET + 0x014) +# define TPLL_SSC_EN BIT(3) + +#define MTK_DP_PHY_DIG_BIT_RATE (PHY_OFFSET + 0x03C) +# define BIT_RATE_RBR 0 +# define BIT_RATE_HBR 1 +# define BIT_RATE_HBR2 2 +# define BIT_RATE_HBR3 3 + +#define MTK_DP_PHY_DIG_SW_RST (PHY_OFFSET + 0x038)
drivers/phy/mediatek/phy-mtk-dp.c line 35
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +10
-0+# define DP_GLB_SW_RST_PHYD BIT(0) + +#define MTK_DP_LANE0_DRIVING_PARAM_3 (PHY_OFFSET + 0x138) +#define MTK_DP_LANE1_DRIVING_PARAM_3 (PHY_OFFSET + 0x238) +#define MTK_DP_LANE2_DRIVING_PARAM_3 (PHY_OFFSET + 0x338) +#define MTK_DP_LANE3_DRIVING_PARAM_3 (PHY_OFFSET + 0x438) +# define XTP_LN_TX_LCTXC0_SW0_PRE0_DEFAULT 0x10 +# define XTP_LN_TX_LCTXC0_SW0_PRE1_DEFAULT (0x14 << 8) +# define XTP_LN_TX_LCTXC0_SW0_PRE2_DEFAULT (0x18 << 16) +# define XTP_LN_TX_LCTXC0_SW0_PRE3_DEFAULT (0x20 << 24)
how about defining constants and using FEILD_PREP() to set the value. Here and few other places!
Quoted 16 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +16
-0+static int mtk_dp_phy_configure (struct phy *phy,union phy_configure_opts *opts) +{ +struct mtk_dp_phy *dp_phy =phy_get_drvdata (phy); +u32 val; + +if (opts->dp.set_rate) { +switch (opts->dp.link_rate) { +default : +dev_err (&phy->dev, +"Implementation error, unknown linkrate %x\n" , + opts->dp.link_rate); +return -EINVAL ; +case 1620 : + val =BIT_RATE_RBR ; +break ; +case 2700 :
drivers/phy/mediatek/phy-mtk-dp.c line 151
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +10
-0+ val =BIT_RATE_HBR ; +break ; +case 5400 : + val =BIT_RATE_HBR2 ; +break ; +case 8100 : + val =BIT_RATE_HBR3 ; +break ; + } +regmap_write (dp_phy->regs,MTK_DP_PHY_DIG_BIT_RATE , val);
interesting use of default :) which is correct!
But why keep the regmap_write inside switch, you are anyway returning in default, so this write could be outside as well
Signature · 1 line
~Vinod
Re: [PATCH v7 6/8] phy: phy-mtk-dp: Add driver for DP phy
Hi Vinod,
Quoting Vinod Koul (2021-12-29 07:00:34)
Quoted 8 lines · Guillaume Ranquet
Quoted 1 line
From: Markus Schneider-Pargmann <[email protected]>
Pls cc relevant folks on cover so that they know what is going on in the series... Is this dependent on rest? It should not and can be sent and reviewed separately!
Sorry, I'm a bit of a noob...
I've used the get_maintainers.pl script to get the to: and cc: for each patch. I'll make sure the cover has everyone included in the next revision.
The phy is not dependant on the rest, but this phy cannot be used outside of the mt8195 Display Port context... as the phy is actually the same IP as the DP.
The DP driver has a functional dependency with the phy, they can be split into two series as they both merge/compile on their own.
Do you want me to split the series with the phy on one hand the the DP driver on the other?
Quoted 99 lines
Quoted 99 lines
This is a new driver that supports the integrated DisplayPort phy for mediatek SoCs, especially the mt8195. The phy is integrated into the DisplayPort controller and will be created by the mtk-dp driver. This driver expects a struct regmap to be able to work on the same registers as the DisplayPort controller. It sets the device data to be the struct phy so that the DisplayPort controller can easily work with it.
The driver does not have any devicetree bindings because the datasheet does not list the controller and the phy as distinct units.
The interaction with the controller can be covered by the configure callback of the phy framework and its displayport parameters.
Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>--- MAINTAINERS | 1 + drivers/phy/mediatek/Kconfig | 8 ++ drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-dp.c | 219 ++++++++++++++++++++++++++++++ 4 files changed, 229 insertions(+) create mode 100644 drivers/phy/mediatek/phy-mtk-dp.cMAINTAINERS +1
-0@@ -6394,6 +6394,7 @@ L: [email protected] (moderated for non-subscribers) S: Supported F: Documentation/devicetree/bindings/display/mediatek/ F: drivers/gpu/drm/mediatek/ +F: drivers/phy/mediatek/phy-mtk-dp.c F: drivers/phy/mediatek/phy-mtk-hdmi* F: drivers/phy/mediatek/phy-mtk-mipi*drivers/phy/mediatek/Kconfig +8
-0@@ -55,3 +55,11 @@ config PHY_MTK_MIPI_DSI select GENERIC_PHY help Support MIPI DSI for Mediatek SoCs. + +config PHY_MTK_DP + tristate "MediaTek DP-PHY Driver" + depends on ARCH_MEDIATEK || COMPILE_TEST + depends on OF + select GENERIC_PHY + help + Support DisplayPort PHY for Mediatek SoCs.drivers/phy/mediatek/Makefile +1
-0@@ -3,6 +3,7 @@ # Makefile for the phy drivers. # +obj-$(CONFIG_PHY_MTK_DP) += phy-mtk-dp.o obj-$(CONFIG_PHY_MTK_TPHY) += phy-mtk-tphy.o obj-$(CONFIG_PHY_MTK_UFS) += phy-mtk-ufs.o obj-$(CONFIG_PHY_MTK_XSPHY) += phy-mtk-xsphy.odrivers/phy/mediatek/phy-mtk-dp.c new file +30
-0@@ -0,0 +1,219 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2021 BayLibre +* Author: Markus Schneider-Pargmann <[email protected]> +*/ + +#include <linux/delay.h> +#include <linux/io.h> +#include <linux/of.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> + +#define PHY_OFFSET 0x1000 + +#define MTK_DP_PHY_DIG_PLL_CTL_1 (PHY_OFFSET + 0x014) +# define TPLL_SSC_EN BIT(3) + +#define MTK_DP_PHY_DIG_BIT_RATE (PHY_OFFSET + 0x03C) +# define BIT_RATE_RBR 0 +# define BIT_RATE_HBR 1 +# define BIT_RATE_HBR2 2 +# define BIT_RATE_HBR3 3 + +#define MTK_DP_PHY_DIG_SW_RST (PHY_OFFSET + 0x038) +# define DP_GLB_SW_RST_PHYD BIT(0) + +#define MTK_DP_LANE0_DRIVING_PARAM_3 (PHY_OFFSET + 0x138) +#define MTK_DP_LANE1_DRIVING_PARAM_3 (PHY_OFFSET + 0x238) +#define MTK_DP_LANE2_DRIVING_PARAM_3 (PHY_OFFSET + 0x338)
Quoted 9 lines
drivers/phy/mediatek/phy-mtk-dp.c line 35
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +5
-0+#define MTK_DP_LANE3_DRIVING_PARAM_3 (PHY_OFFSET + 0x438) +# define XTP_LN_TX_LCTXC0_SW0_PRE0_DEFAULT 0x10 +# define XTP_LN_TX_LCTXC0_SW0_PRE1_DEFAULT (0x14 << 8) +# define XTP_LN_TX_LCTXC0_SW0_PRE2_DEFAULT (0x18 << 16) +# define XTP_LN_TX_LCTXC0_SW0_PRE3_DEFAULT (0x20 << 24)how about defining constants and using
FEILD_PREP()to set the value. Here and few other places!
Noted for next revision,
Thanks.
Quoted 29 lines
Quoted 16 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +16
-0+static int mtk_dp_phy_configure (struct phy *phy,union phy_configure_opts *opts) +{ +struct mtk_dp_phy *dp_phy =phy_get_drvdata (phy); +u32 val; + +if (opts->dp.set_rate) { +switch (opts->dp.link_rate) { +default : +dev_err (&phy->dev, +"Implementation error, unknown linkrate %x\n" , + opts->dp.link_rate); +return -EINVAL ; +case 1620 : + val =BIT_RATE_RBR ; +break ; +case 2700 :drivers/phy/mediatek/phy-mtk-dp.c line 151
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +10
-0+ val =BIT_RATE_HBR ; +break ; +case 5400 : + val =BIT_RATE_HBR2 ; +break ; +case 8100 : + val =BIT_RATE_HBR3 ; +break ; + } +regmap_write (dp_phy->regs,MTK_DP_PHY_DIG_BIT_RATE , val);interesting use of default :) which is correct!
Quoted 2 lines
But why keep the
regmap_writeinside switch, you are anyway returning in default, so this write could be outside as well
Not my code here (as we are upstreaming code from the vendor tree). My understanding is that the regmap_write() shouldn't be called if dp.set_rate is false as val won't be set.
This doesn't actually happen because the only client for this phy is the DP driver and we make sure to call it with dp.set_rate to true.
Quoted 2 lines
--
~Vinod
Thx,
Guillaume.
Re: [PATCH v7 6/8] phy: phy-mtk-dp: Add driver for DP phy
In reply to Guillaume RanquetHi, Guillaume:
Quoted 99 lines · Guillaume Ranquet
From: Markus Schneider-Pargmann <[email protected]>
This is a new driver that supports the integrated DisplayPort phy for mediatek SoCs, especially the mt8195. The phy is integrated into the DisplayPort controller and will be created by the mtk-dp driver. This driver expects a struct regmap to be able to work on the same registers
as the DisplayPort controller. It sets the device data to be the struct
phy so that the DisplayPort controller can easily work with it.The driver does not have any devicetree bindings because the datasheet
does not list the controller and the phy as distinct units.The interaction with the controller can be covered by the configure callback of the phy framework and its displayport parameters.
Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>--- MAINTAINERS | 1 + drivers/phy/mediatek/Kconfig | 8 ++ drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-dp.c | 219 ++++++++++++++++++++++++++++++ 4 files changed, 229 insertions(+) create mode 100644 drivers/phy/mediatek/phy-mtk-dp.cMAINTAINERS +1
-0@@ -6394,6 +6394,7 @@ L: [email protected] (moderated for non-subscribers) S: Supported F: Documentation/devicetree/bindings/display/mediatek/ F: drivers/gpu/drm/mediatek/ +F: drivers/phy/mediatek/phy-mtk-dp.c F: drivers/phy/mediatek/phy-mtk-hdmi* F: drivers/phy/mediatek/phy-mtk-mipi*drivers/phy/mediatek/Kconfig +8
-0@@ -55,3 +55,11 @@ config PHY_MTK_MIPI_DSI select GENERIC_PHY help Support MIPI DSI for Mediatek SoCs. + +config PHY_MTK_DP + tristate "MediaTek DP-PHY Driver" + depends on ARCH_MEDIATEK || COMPILE_TEST + depends on OF + select GENERIC_PHY + help + Support DisplayPort PHY for Mediatek SoCs.drivers/phy/mediatek/Makefile +1
-0@@ -3,6 +3,7 @@ # Makefile for the phy drivers. # +obj-$(CONFIG_PHY_MTK_DP) += phy-mtk-dp.o obj-$(CONFIG_PHY_MTK_TPHY) += phy-mtk-tphy.o obj-$(CONFIG_PHY_MTK_UFS) += phy-mtk-ufs.o obj-$(CONFIG_PHY_MTK_XSPHY) += phy-mtk-xsphy.odrivers/phy/mediatek/phy-mtk-dp.c new file +19
-0@@ -0,0 +1,219 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2021 BayLibre +* Author: Markus Schneider-Pargmann <[email protected]> +*/ + +#include <linux/delay.h> +#include <linux/io.h> +#include <linux/of.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> + +#define PHY_OFFSET 0x1000 + +#define MTK_DP_PHY_DIG_PLL_CTL_1 (PHY_OFFSET + 0x014) +# define TPLL_SSC_EN BIT(3) + +#define MTK_DP_PHY_DIG_BIT_RATE (PHY_OFFSET +
0x03C)
drivers/phy/mediatek/phy-mtk-dp.c line 24
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +5
-0+# define BIT_RATE_RBR 0 +# define BIT_RATE_HBR 1 +# define BIT_RATE_HBR2 2 +# define BIT_RATE_HBR3 3 +
I would like to align the indent style to Mediatek mipi dsi phy driver and Mediatek hdmi phy driver. That means the bitwise definition value has one more indent.
Quoted 20 lines
+#define
MTK_DP_PHY_DIG_SW_RST(PHY_OFFSET+0x038)drivers/phy/mediatek/phy-mtk-dp.c new file +11
-0+# define DP_GLB_SW_RST_PHYD BIT(0) + +#define MTK_DP_LANE0_DRIVING_PARAM_3 (PHY_OFFSET + 0x138) +#define MTK_DP_LANE1_DRIVING_PARAM_3 (PHY_OFFSET + 0x238) +#define MTK_DP_LANE2_DRIVING_PARAM_3 (PHY_OFFSET + 0x338) +#define MTK_DP_LANE3_DRIVING_PARAM_3 (PHY_OFFSET + 0x438) +# define XTP_LN_TX_LCTXC0_SW0_PRE0_DEFAULT 0x10 +# define XTP_LN_TX_LCTXC0_SW0_PRE1_DEFAULT (0x14 << 8) +# define XTP_LN_TX_LCTXC0_SW0_PRE2_DEFAULT (0x18 << 16) +# define XTP_LN_TX_LCTXC0_SW0_PRE3_DEFAULT (0x20 << 24) +# define DRIVING_PARAM_3_DEFAULT (XTP_LN_TX_LCTXC0_SW0_P
RE0_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXC0_SW0_P
RE1_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXC0_SW0_P
RE2_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXC0_SW0_P
RE3_DEFAULT)
drivers/phy/mediatek/phy-mtk-dp.c line 44
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +5
-0+ +#define MTK_DP_LANE0_DRIVING_PARAM_4 (PHY_OFFSET + 0x13C) +#define MTK_DP_LANE1_DRIVING_PARAM_4 (PHY_OFFSET + 0x23C) +#define MTK_DP_LANE2_DRIVING_PARAM_4 (PHY_OFFSET + 0x33C) +#define MTK_DP_LANE3_DRIVING_PARAM_4 (PHY_OFFSET + 0x43C)
Useless, so remove.
Quoted 12 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +5
-0+# define XTP_LN_TX_LCTXC0_SW1_PRE0_DEFAULT 0x18 +# define XTP_LN_TX_LCTXC0_SW1_PRE1_DEFAULT (0x1e << 8) +# define XTP_LN_TX_LCTXC0_SW1_PRE2_DEFAULT (0x24 << 16) +# define XTP_LN_TX_LCTXC0_SW2_PRE0_DEFAULT (0x20 << 24) +# define DRIVING_PARAM_4_DEFAULT (XTP_LN_TX_LCTXC0_SW1_P
RE0_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXC0_SW1_P
RE1_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXC0_SW1_P
RE2_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXC0_SW2_P
RE0_DEFAULT)
drivers/phy/mediatek/phy-mtk-dp.c line 57
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +5
-0+ +#define MTK_DP_LANE0_DRIVING_PARAM_5 (PHY_OFFSET + 0x140) +#define MTK_DP_LANE1_DRIVING_PARAM_5 (PHY_OFFSET + 0x240) +#define MTK_DP_LANE2_DRIVING_PARAM_5 (PHY_OFFSET + 0x340) +#define MTK_DP_LANE3_DRIVING_PARAM_5 (PHY_OFFSET + 0x440)
Ditto.
drivers/phy/mediatek/phy-mtk-dp.c line 66
Quoted 11 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +3
-0+# define XTP_LN_TX_LCTXC0_SW2_PRE1_DEFAULT 0x28 +# define XTP_LN_TX_LCTXC0_SW3_PRE0_DEFAULT (0x30 << 8) +# define DRIVING_PARAM_5_DEFAULT (XTP_LN_TX_LCTXC0_SW2_P
RE1_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXC0_SW3_P
RE0_DEFAULT)drivers/phy/mediatek/phy-mtk-dp.c new file +5
-0+ +#define MTK_DP_LANE0_DRIVING_PARAM_6 (PHY_OFFSET + 0x144) +#define MTK_DP_LANE1_DRIVING_PARAM_6 (PHY_OFFSET + 0x244) +#define MTK_DP_LANE2_DRIVING_PARAM_6 (PHY_OFFSET + 0x344) +#define MTK_DP_LANE3_DRIVING_PARAM_6 (PHY_OFFSET + 0x444)
Ditto.
Quoted 12 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +5
-0+# define XTP_LN_TX_LCTXCP1_SW0_PRE0_DEFAULT 0x00 +# define XTP_LN_TX_LCTXCP1_SW0_PRE1_DEFAULT (0x04 << 8) +# define XTP_LN_TX_LCTXCP1_SW0_PRE2_DEFAULT (0x08 << 16) +# define XTP_LN_TX_LCTXCP1_SW0_PRE3_DEFAULT (0x10 << 24) +# define DRIVING_PARAM_6_DEFAULT (XTP_LN_TX_LCTXCP1_SW0_
PRE0_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXCP1_SW0_
PRE1_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXCP1_SW0_
PRE2_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXCP1_SW0_
PRE3_DEFAULT)
drivers/phy/mediatek/phy-mtk-dp.c line 79
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +5
-0+ +#define MTK_DP_LANE0_DRIVING_PARAM_7 (PHY_OFFSET + 0x148) +#define MTK_DP_LANE1_DRIVING_PARAM_7 (PHY_OFFSET + 0x248) +#define MTK_DP_LANE2_DRIVING_PARAM_7 (PHY_OFFSET + 0x348) +#define MTK_DP_LANE3_DRIVING_PARAM_7 (PHY_OFFSET + 0x448)
Ditto.
Quoted 12 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +5
-0+# define XTP_LN_TX_LCTXCP1_SW1_PRE0_DEFAULT 0x00 +# define XTP_LN_TX_LCTXCP1_SW1_PRE1_DEFAULT (0x06 << 8) +# define XTP_LN_TX_LCTXCP1_SW1_PRE2_DEFAULT (0x0c << 16) +# define XTP_LN_TX_LCTXCP1_SW2_PRE0_DEFAULT (0x00 << 24) +# define DRIVING_PARAM_7_DEFAULT (XTP_LN_TX_LCTXCP1_SW1_
PRE0_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXCP1_SW1_
PRE1_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXCP1_SW1_
PRE2_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXCP1_SW2_
PRE0_DEFAULT)
drivers/phy/mediatek/phy-mtk-dp.c line 92
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +5
-0+ +#define MTK_DP_LANE0_DRIVING_PARAM_8 (PHY_OFFSET + 0x14C) +#define MTK_DP_LANE1_DRIVING_PARAM_8 (PHY_OFFSET + 0x24C) +#define MTK_DP_LANE2_DRIVING_PARAM_8 (PHY_OFFSET + 0x34C) +#define MTK_DP_LANE3_DRIVING_PARAM_8 (PHY_OFFSET + 0x44C)
Ditto.
Quoted 81 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +3
-0+# define XTP_LN_TX_LCTXCP1_SW2_PRE1_DEFAULT 0x08 +# define XTP_LN_TX_LCTXCP1_SW3_PRE0_DEFAULT (0x00 << 8) +# define DRIVING_PARAM_8_DEFAULT (XTP_LN_TX_LCTXCP1_SW2_
PRE1_DEFAULT| \drivers/phy/mediatek/phy-mtk-dp.c new file +1
-0+XTP_LN_TX_LCTXCP1_SW3_
PRE0_DEFAULT)drivers/phy/mediatek/phy-mtk-dp.c new file +30
-0+ +struct mtk_dp_phy { +struct regmap *regs; +}; + +static int mtk_dp_phy_init (struct phy *phy) +{ +struct mtk_dp_phy *dp_phy =phy_get_drvdata (phy); +u32 driving_params[] = { +DRIVING_PARAM_3_DEFAULT , +DRIVING_PARAM_4_DEFAULT , +DRIVING_PARAM_5_DEFAULT , +DRIVING_PARAM_6_DEFAULT , +DRIVING_PARAM_7_DEFAULT , +DRIVING_PARAM_8_DEFAULT + }; + +regmap_bulk_write (dp_phy->regs,MTK_DP_LANE0_DRIVING_PARAM_3 , + driving_params,ARRAY_SIZE (driving_params)); +regmap_bulk_write (dp_phy->regs,MTK_DP_LANE1_DRIVING_PARAM_3 , + driving_params,ARRAY_SIZE (driving_params)); +regmap_bulk_write (dp_phy->regs,MTK_DP_LANE2_DRIVING_PARAM_3 , + driving_params,ARRAY_SIZE (driving_params)); +regmap_bulk_write (dp_phy->regs,MTK_DP_LANE3_DRIVING_PARAM_3 , + driving_params,ARRAY_SIZE (driving_params)); + +return 0 ; +} + +static int mtk_dp_phy_configure(struct phy *phy, union
phy_configure_opts*opts)drivers/phy/mediatek/phy-mtk-dp.c new file +9
-0+{ +struct mtk_dp_phy *dp_phy =phy_get_drvdata (phy); +u32 val; + +if (opts->dp.set_rate) { +switch (opts->dp.link_rate) { +default : + dev_err(&phy->dev, + "Implementation error, unknown linkrate%x\n",
drivers/phy/mediatek/phy-mtk-dp.c new file +16
-0+ opts->dp.link_rate); +return -EINVAL ; +case 1620 : + val =BIT_RATE_RBR ; +break ; +case 2700 : + val =BIT_RATE_HBR ; +break ; +case 5400 : + val =BIT_RATE_HBR2 ; +break ; +case 8100 : + val =BIT_RATE_HBR3 ; +break ; + } + regmap_write(dp_phy->regs, MTK_DP_PHY_DIG_BIT_RATE,val);
drivers/phy/mediatek/phy-mtk-dp.c new file +4
-0+ } + + regmap_update_bits(dp_phy->regs, MTK_DP_PHY_DIG_PLL_CTL_1, + TPLL_SSC_EN, opts->dp.ssc ? TPLL_SSC_EN :0);
drivers/phy/mediatek/phy-mtk-dp.c new file +11
-0+ +return 0 ; +} + +static int mtk_dp_phy_reset (struct phy *phy) +{ +struct mtk_dp_phy *dp_phy =phy_get_drvdata (phy); + +regmap_update_bits (dp_phy->regs,MTK_DP_PHY_DIG_SW_RST , +DP_GLB_SW_RST_PHYD ,0 ); +usleep_range (50 ,200 );
drivers/phy/mediatek/phy-mtk-dp.c line 176
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +10
-0+regmap_update_bits (dp_phy->regs,MTK_DP_PHY_DIG_SW_RST , +DP_GLB_SW_RST_PHYD ,1 ); + +return 0 ; +} + +static const struct phy_ops mtk_dp_phy_dev_ops = { + .init = mtk_dp_phy_init, + .configure = mtk_dp_phy_configure, + .reset = mtk_dp_phy_reset,
In Mediatek mipi dsi phy driver and Mediatek hdmi phy driver, implement power_on and power_off. I would like to align the behavior. If init is necessary for configure, would exit should be implement?
Quoted 4 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +4
-0+ .owner = THIS_MODULE, +}; + +static int mtk_dp_phy_probe (struct platform_device *pdev)
drivers/phy/mediatek/phy-mtk-dp.c line 190
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +10
-0+{ +struct device *dev = &pdev->dev; +struct mtk_dp_phy *dp_phy; +struct phy *phy; + + dp_phy =devm_kzalloc (dev,sizeof (*dp_phy),GFP_KERNEL ); +if (!dp_phy) +return -ENOMEM ; + + dp_phy->regs = *(struct regmap **)dev->platform_data;
Why not
mtk_dp->phy_dev = platform_device_register_data(dev, "mediatek- dp-phy", PLATFORM_DEVID_ AUTO, mtk_dp->regs, sizeof(struct
regmap *));
And
dp_phy->regs = (struct regmap *)dev->platform_data;
Regards,
CK
Quoted 31 lines
drivers/phy/mediatek/phy-mtk-dp.c new file +2
-0+if (!dp_phy->regs) { + dev_err(dev, "No data passed, requires structregmap**\n");
drivers/phy/mediatek/phy-mtk-dp.c new file +6
-0+return -EINVAL ; + } + + phy =devm_phy_create (dev,NULL , &mtk_dp_phy_dev_ops); +if (IS_ERR (phy)) { + dev_err(dev, "Failed to create DP PHY: %ld\n",
PTR_ERR(phy));drivers/phy/mediatek/phy-mtk-dp.c new file +21
-0+return PTR_ERR (phy); + } +phy_set_drvdata (phy, dp_phy); + +if (!dev->of_node) +phy_create_lookup (phy,"dp" ,dev_name (dev)); + +return 0 ; +} + +struct platform_driver mtk_dp_phy_driver = { + .probe = mtk_dp_phy_probe, + .driver = { + .name ="mediatek-dp-phy" , + }, +}; +module_platform_driver (mtk_dp_phy_driver); + +MODULE_AUTHOR ("Markus Schneider-Pargmann <[email protected]>" ); +MODULE_DESCRIPTION ("MediaTek DP PHY Driver" ); +MODULE_LICENSE ("GPL v2" );
PATCH v7 7/8 drm/mediatek: Add mt8195 DisplayPort driver
In reply to Guillaume RanquetFrom: Markus Schneider-Pargmann <[email protected]>
This patch adds a DisplayPort driver for the Mediatek mt8195 SoC.
It supports the mt8195, the external DisplayPort units. It offers hot-plug-detection, audio up to 8 channels, and 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
Jason-JH.Lin <[email protected]>.
--- drivers/gpu/drm/mediatek/Kconfig | 7 + drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_dp.c | 3028 ++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_dp_reg.h | 568 +++++ drivers/gpu/drm/mediatek/mtk_drm_drv.c | 1 + drivers/gpu/drm/mediatek/mtk_drm_drv.h | 1 + 6 files changed, 3607 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 +7 -0
@@ -28,3 +28,10 @@ config DRM_MEDIATEK_HDMI select PHY_MTK_HDMI help DRM/KMS HDMI driver for Mediatek SoCs + +config MTK_DPTX_SUPPORT + tristate "DRM DPTX Support for Mediatek SoCs" + depends on DRM_MEDIATEK + select PHY_MTK_DP + help + DRM/KMS Display Port driver for Mediatek SoCs.
drivers/gpu/drm/mediatek/Makefile +2 -0
@@ -21,3 +21,5 @@ mediatek-drm-hdmi-objs := mtk_cec.o \ mtk_hdmi_ddc.o obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mediatek-drm-hdmi.o + +obj-$(CONFIG_MTK_DPTX_SUPPORT) += mtk_dp.o
drivers/gpu/drm/mediatek/mtk_dp.c new file +3028 -0
2,985 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_dp_reg.h new file +568 -0
568 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.32.0
Part of the diff is not shown here. View the raw message.
Hi, Guillaume:
This is a big patch, so I give you some comment first, and I would continue to review this patch.
Quoted 65 lines · Guillaume Ranquet
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a DisplayPort driver for the Mediatek mt8195 SoC.
It supports the mt8195, the external DisplayPort units. It offers hot-plug-detection, audio up to 8 channels, and 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
Jason-JH.Lin <[email protected]>.Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Reported-by kernel test robot <[email protected]>--- drivers/gpu/drm/mediatek/Kconfig | 7 + drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_dp.c | 3028 ++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_dp_reg.h | 568 +++++ drivers/gpu/drm/mediatek/mtk_drm_drv.c | 1 + drivers/gpu/drm/mediatek/mtk_drm_drv.h | 1 + 6 files changed, 3607 insertions(+) create mode 100644 drivers/gpu/drm/mediatek/mtk_dp.c create mode 100644 drivers/gpu/drm/mediatek/mtk_dp_reg.hdrivers/gpu/drm/mediatek/Kconfig +7
-0@@ -28,3 +28,10 @@ config DRM_MEDIATEK_HDMI select PHY_MTK_HDMI help DRM/KMS HDMI driver for Mediatek SoCs + +config MTK_DPTX_SUPPORT + tristate "DRM DPTX Support for Mediatek SoCs" + depends on DRM_MEDIATEK + select PHY_MTK_DP + help + DRM/KMS Display Port driver for Mediatek SoCs.drivers/gpu/drm/mediatek/Makefile +2
-0@@ -21,3 +21,5 @@ mediatek-drm-hdmi-objs := mtk_cec.o \ mtk_hdmi_ddc.o obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mediatek-drm-hdmi.o + +obj-$(CONFIG_MTK_DPTX_SUPPORT) += mtk_dp.o
[snip]
drivers/gpu/drm/mediatek/Makefile
Quoted 10 lines
drivers/gpu/drm/mediatek/Makefile +10
-0+ +enum mtk_dp_train_state { + MTK_DP_TRAIN_STATE_STARTUP = 0, + MTK_DP_TRAIN_STATE_CHECKCAP, + MTK_DP_TRAIN_STATE_CHECKEDID, + MTK_DP_TRAIN_STATE_TRAINING_PRE, + MTK_DP_TRAIN_STATE_TRAINING, + MTK_DP_TRAIN_STATE_CHECKTIMING, + MTK_DP_TRAIN_STATE_NORMAL, + MTK_DP_TRAIN_STATE_POWERSAVE,
Never be this state, so remove it.
Quoted 30 lines
drivers/gpu/drm/mediatek/Makefile +29
-0+ MTK_DP_TRAIN_STATE_DPIDLE, +}; + +struct mtk_dp_timings { + struct videomode vm; + + u16 htotal; + u16 vtotal; + u8 frame_rate; + u32 pix_rate_khz; +}; + +struct mtk_dp_train_info { + bool tps3; + bool tps4; + bool sink_ssc; + bool cable_plugged_in; + bool cable_state_change; + bool cr_done; + bool eq_done; + + // link_rate is in multiple of 0.27Gbps + int link_rate; + int lane_count; + + int irq_status; + int check_cap_count; +}; +
[snip]
drivers/gpu/drm/mediatek/Makefile
Quoted 11 lines
drivers/gpu/drm/mediatek/Makefile +8
-0+ +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) & + SW_IRQ_FINAL_STATUS_DP_TRANS_P0_MASK; + + if (irq_status) { + mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_35C8,
irq_status,drivers/gpu/drm/mediatek/Makefile +1
-0+ SW_IRQ_CLR_DP_TRANS_P0_MASK);
SW_IRQ_CLR_DP_TRANS_P0_MASK is already set, so this setting is redundant, so remove this.
Quoted 16 lines
drivers/gpu/drm/mediatek/Makefile +15
-0+ mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_35C8, 0, + SW_IRQ_CLR_DP_TRANS_P0_MASK); + } + + return irq_status; +} + +static u32 mtk_dp_hwirq_get_clear(struct mtk_dp *mtk_dp) +{ + u8 irq_status = (mtk_dp_read(mtk_dp, MTK_DP_TRANS_P0_3418) & + IRQ_STATUS_DP_TRANS_P0_MASK) >> + IRQ_STATUS_DP_TRANS_P0_SHIFT; + + if (irq_status) { + mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_3418,
irq_status,
drivers/gpu/drm/mediatek/Makefile
Quoted 1 line
drivers/gpu/drm/mediatek/Makefile +1
-0+ IRQ_CLR_DP_TRANS_P0_MASK);
IRQ_CLR_DP_TRANS_P0_MASK is already set, so this setting is redundant, so remove this.
Quoted 39 lines
drivers/gpu/drm/mediatek/Makefile +33
-0+ mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_3418, 0, + IRQ_CLR_DP_TRANS_P0_MASK); + } + + return irq_status; +} + +static void mtk_dp_hwirq_enable(struct mtk_dp *mtk_dp, bool enable) +{ + u32 val = 0; + + if (!enable) + val = IRQ_MASK_DP_TRANS_P0_DISC_IRQ | + IRQ_MASK_DP_TRANS_P0_CONN_IRQ | + IRQ_MASK_DP_TRANS_P0_INT_IRQ; + mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_3418, val, + IRQ_MASK_DP_TRANS_P0_MASK); +} + +void mtk_dp_initialize_settings(struct mtk_dp *mtk_dp) +{ + mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_342C, + XTAL_FREQ_DP_TRANS_P0_DEFAULT, + XTAL_FREQ_DP_TRANS_P0_MASK); + mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_3540, + BIT(FEC_CLOCK_EN_MODE_DP_TRANS_P0_SHIFT), + FEC_CLOCK_EN_MODE_DP_TRANS_P0_MASK); + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_31EC, + BIT(AUDIO_CH_SRC_SEL_DP_ENC0_P0_SHIFT), + AUDIO_CH_SRC_SEL_DP_ENC0_P0_MASK); + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_304C, 0, + SDP_VSYNC_RISING_MASK_DP_ENC0_P0_MASK); + mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_IRQ_MASK,
IRQ_MASK_AUX_TOP_IRQ,drivers/gpu/drm/mediatek/Makefile +4
-0+ IRQ_MASK_AUX_TOP_IRQ); +} + +static void mtk_dp_initialize_hpd_detect_settings(struct mtk_dp
*mtk_dp)
drivers/gpu/drm/mediatek/Makefile
Quoted 2 lines
drivers/gpu/drm/mediatek/Makefile +2
-0+{ + // Debounce threshold
/* ... */
Quoted 23 lines
drivers/gpu/drm/mediatek/Makefile +14
-0+ mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_3410, + 8 << HPD_DEB_THD_DP_TRANS_P0_SHIFT, + HPD_DEB_THD_DP_TRANS_P0_MASK); + mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_3410, + (HPD_INT_THD_DP_TRANS_P0_LOWER_500US | + HPD_INT_THD_DP_TRANS_P0_UPPER_1100US) + << HPD_INT_THD_DP_TRANS_P0_SHIFT, + HPD_INT_THD_DP_TRANS_P0_MASK); + + // Connect threshold 1.5ms + 5 x 0.1ms = 2ms + // Disconnect threshold 1.5ms + 5 x 0.1ms = 2ms + mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_3410, + (5 << HPD_DISC_THD_DP_TRANS_P0_SHIFT) | + (5 <<
HPD_CONN_THD_DP_TRANS_P0_SHIFT),drivers/gpu/drm/mediatek/Makefile +7
-0+ HPD_DISC_THD_DP_TRANS_P0_MASK | + HPD_CONN_THD_DP_TRANS_P0_MASK); + mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_3430, + HPD_INT_THD_ECO_DP_TRANS_P0_HIGH_BOUND_EXT, + HPD_INT_THD_ECO_DP_TRANS_P0_MASK); +} +
[snip]
Quoted 59 lines
drivers/gpu/drm/mediatek/Makefile +17
-0+ +static int mtk_dp_train_handler(struct mtk_dp *mtk_dp) +{ + int ret = 0; + + if (mtk_dp->train_state == MTK_DP_TRAIN_STATE_NORMAL) + return ret; + + switch (mtk_dp->train_state) { + case MTK_DP_TRAIN_STATE_STARTUP: + mtk_dp->train_state = MTK_DP_TRAIN_STATE_CHECKCAP; + break; + + case MTK_DP_TRAIN_STATE_CHECKCAP: + if (mtk_dp_parse_capabilities(mtk_dp)) { + mtk_dp->train_info.check_cap_count = 0; + mtk_dp->train_state =
MTK_DP_TRAIN_STATE_CHECKEDID;drivers/gpu/drm/mediatek/Makefile +7
-0+ } else { + mtk_dp->train_info.check_cap_count++; + + if (mtk_dp->train_info.check_cap_count > + MTK_DP_CHECK_SINK_CAP_TIMEOUT_COUNT) { + mtk_dp->train_info.check_cap_count = 0; + mtk_dp->train_state =
MTK_DP_TRAIN_STATE_DPIDLE;drivers/gpu/drm/mediatek/Makefile +7
-0+ ret = -ETIMEDOUT; + } + } + break; + + case MTK_DP_TRAIN_STATE_CHECKEDID: { + int caps_found =mtk_dp_edid_parse_audio_capabilities(mtk_dp,
drivers/gpu/drm/mediatek/Makefile +20
-0+ &mtk_dp->info.audio_caps); + mtk_dp->audio_enable = caps_found > 0; + if (!mtk_dp->audio_enable) + memset(&mtk_dp->info.audio_caps, 0, + sizeof(mtk_dp->info.audio_caps)); + } + + mtk_dp->train_state = MTK_DP_TRAIN_STATE_TRAINING_PRE; + break; + + case MTK_DP_TRAIN_STATE_TRAINING_PRE: + mtk_dp->train_state = MTK_DP_TRAIN_STATE_TRAINING; + break; + + case MTK_DP_TRAIN_STATE_TRAINING: + ret = mtk_dp_train_start(mtk_dp); + if (!ret) { + mtk_dp_video_mute(mtk_dp, true); + mtk_dp_audio_mute(mtk_dp, true); + mtk_dp->train_state =
MTK_DP_TRAIN_STATE_CHECKTIMING;drivers/gpu/drm/mediatek/Makefile +3
-0+ mtk_dp_fec_enable(mtk_dp, mtk_dp->has_fec); + } else if (ret != -EAGAIN) { + mtk_dp->train_state =
MTK_DP_TRAIN_STATE_DPIDLE;
drivers/gpu/drm/mediatek/Makefile
Quoted 7 lines
drivers/gpu/drm/mediatek/Makefile +7
-0+ } + + ret = 0; + break; + + case MTK_DP_TRAIN_STATE_CHECKTIMING: + mtk_dp->train_state = MTK_DP_TRAIN_STATE_NORMAL;
If MTK_DP_TRAIN_STATE_CHECKTIMING does nothing,I think we should drop state MTK_DP_TRAIN_STATE_CHECKTIMING.
Quoted 15 lines
drivers/gpu/drm/mediatek/Makefile +14
-0+ break; + case MTK_DP_TRAIN_STATE_NORMAL: + break; + case MTK_DP_TRAIN_STATE_POWERSAVE: + break; + case MTK_DP_TRAIN_STATE_DPIDLE: + break; + default: + break; + } + + return ret; +} +
[snip]
drivers/gpu/drm/mediatek/Makefile
Quoted 12 lines
drivers/gpu/drm/mediatek/Makefile +12
-0+ +static void mtk_dp_video_config(struct mtk_dp *mtk_dp) +{ + mtk_dp_mn_overwrite_disable(mtk_dp); + + mtk_dp_set_msa(mtk_dp); + + mtk_dp_set_color_depth(mtk_dp, mtk_dp->info.depth); + mtk_dp_set_color_format(mtk_dp, mtk_dp->info.format); +} + +static int mtk_dp_state_handler(struct mtk_dp *mtk_dp)
Always return 0, so change to void.
Quoted 54 lines
drivers/gpu/drm/mediatek/Makefile +21
-0+{ + int ret = 0; + + switch (mtk_dp->state) { + case MTK_DP_STATE_INITIAL: + mtk_dp_video_mute(mtk_dp, true); + mtk_dp_audio_mute(mtk_dp, true); + mtk_dp->state = MTK_DP_STATE_IDLE; + break; + + case MTK_DP_STATE_IDLE: + if (mtk_dp->train_state == MTK_DP_TRAIN_STATE_NORMAL) + mtk_dp->state = MTK_DP_STATE_PREPARE; + break; + + case MTK_DP_STATE_PREPARE: + mtk_dp_video_config(mtk_dp); + mtk_dp_video_enable(mtk_dp, true); + + if (mtk_dp->audio_enable) { + mtk_dp_audio_setup(mtk_dp, &mtk_dp-Quoted 1 line
info.audio_caps);
drivers/gpu/drm/mediatek/Makefile +32
-0+ mtk_dp_audio_mute(mtk_dp, false); + } + + mtk_dp->state = MTK_DP_STATE_NORMAL; + break; + + case MTK_DP_STATE_NORMAL: + if (mtk_dp->train_state != MTK_DP_TRAIN_STATE_NORMAL) { + mtk_dp_video_mute(mtk_dp, true); + mtk_dp_audio_mute(mtk_dp, true); + mtk_dp_sdp_stop_sending(mtk_dp); + mtk_dp->state = MTK_DP_STATE_IDLE; + } + break; + + default: + break; + } + + return ret; +} + +static void mtk_dp_init_port(struct mtk_dp *mtk_dp) +{ + mtk_dp_set_idle_pattern(mtk_dp, true); + mtk_dp_initialize_priv_data(mtk_dp); + + mtk_dp_initialize_settings(mtk_dp); + mtk_dp_initialize_aux_settings(mtk_dp); + mtk_dp_initialize_digital_settings(mtk_dp); + mtk_dp_update_bits(mtk_dp, MTK_DP_AUX_P0_3690, + BIT(RX_REPLY_COMPLETE_MODE_AUX_TX_P0_SHIFT),
drivers/gpu/drm/mediatek/Makefile
Quoted 10 lines
drivers/gpu/drm/mediatek/Makefile +10
-0+ RX_REPLY_COMPLETE_MODE_AUX_TX_P0_MASK); + mtk_dp_initialize_hpd_detect_settings(mtk_dp); + + mtk_dp_digital_sw_reset(mtk_dp); +} + +static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev) +{ + struct mtk_dp *mtk_dp = dev; + int event;
event is useless, do drop it.
drivers/gpu/drm/mediatek/Makefile
Quoted 8 lines
drivers/gpu/drm/mediatek/Makefile +3
-0+ u8 buf[DP_RECEIVER_CAP_SIZE] = {}; + + event = mtk_dp_plug_state(mtk_dp) ? connector_status_connected:
drivers/gpu/drm/mediatek/Makefile +1
-0+ connector_status_disconnected;
drivers/gpu/drm/mediatek/Makefile +2
-0+ + if (event < 0)
Never happen, drop it.
Quoted 48 lines
drivers/gpu/drm/mediatek/Makefile +25
-0+ return IRQ_HANDLED; + + if (mtk_dp->drm_dev) { + 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->train_state = MTK_DP_TRAIN_STATE_STARTUP; + + if (!mtk_dp->train_info.cable_plugged_in || + !mtk_dp_plug_state(mtk_dp)) { + 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,drivers/gpu/drm/mediatek/Makefile +4
-0+ DP_PWR_STATE_BANDGAP_TPLL, + DP_PWR_STATE_MASK); + } else { + mtk_dp_update_bits(mtk_dp,
MTK_DP_TOP_PWR_STATE,drivers/gpu/drm/mediatek/Makefile +1
-0+ DP_PWR_STATE_BANDGAP_TPLL_LANE,
drivers/gpu/drm/mediatek/Makefile +15
-0+ 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_LINK_RATE, + buf[DP_MAX_LINK_RATE]); + 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_status & MTK_DP_HPD_INTERRUPT) { + dev_info(mtk_dp->dev, "MTK_DP_HPD_INTERRUPT\n"); + mtk_dp->train_info.irq_status &= ~MTK_DP_HPD_INTERRUPT; + mtk_dp_hpd_sink_event(mtk_dp);
drivers/gpu/drm/mediatek/Makefile
Quoted 10 lines
drivers/gpu/drm/mediatek/Makefile +10
-0+ } + + return IRQ_HANDLED; +} + +static irqreturn_t mtk_dp_hpd_isr_handler(struct mtk_dp *mtk_dp) +{ + bool connected; + u16 swirq_status = mtk_dp_swirq_get_clear(mtk_dp); + u8 hwirq_status = mtk_dp_hwirq_get_clear(mtk_dp);
mtk_dp_sw_irq_get_clear() and mtk_dp_hwirq_get_clear() is called once here, so I would like to merge that two function into this function.
drivers/gpu/drm/mediatek/Makefile
Quoted 7 lines
drivers/gpu/drm/mediatek/Makefile +7
-0+ struct mtk_dp_train_info *train_info = &mtk_dp->train_info; + + train_info->irq_status |= hwirq_status | swirq_status; + + if (!train_info->irq_status) + return IRQ_HANDLED; +
Drop below algorithm, and call mtk_dp_plug_state() in mtk_dp_hpd_event_thread(), and directly compare connected with train_info->cable_plugged_in.
Quoted 24 lines
drivers/gpu/drm/mediatek/Makefile +24
-0+ connected = mtk_dp_plug_state(mtk_dp); + if (connected || !train_info->cable_plugged_in) + train_info->irq_status &= ~MTK_DP_HPD_DISCONNECT; + else if (!connected || train_info->cable_plugged_in) + train_info->irq_status &= ~MTK_DP_HPD_CONNECT; + + if (!(train_info->irq_status & + (MTK_DP_HPD_CONNECT | MTK_DP_HPD_DISCONNECT))) + return IRQ_HANDLED; + + if (train_info->irq_status & MTK_DP_HPD_CONNECT) { + train_info->irq_status &= ~MTK_DP_HPD_CONNECT; + train_info->cable_plugged_in = true; + } else { + train_info->irq_status &= ~MTK_DP_HPD_DISCONNECT; + train_info->cable_plugged_in = false; + mtk_dp->train_state = MTK_DP_TRAIN_STATE_STARTUP; + } + train_info->cable_state_change = true; + return IRQ_WAKE_THREAD; +} + +static irqreturn_t mtk_dp_hpd_event(int hpd, void *dev) +{
drivers/gpu/drm/mediatek/Makefile
Quoted 10 lines
drivers/gpu/drm/mediatek/Makefile +10
-0+ struct mtk_dp *mtk_dp = dev; + u32 irq_status; + + irq_status = mtk_dp_read(mtk_dp, MTK_DP_TOP_IRQ_STATUS); + + if (!irq_status) + return IRQ_HANDLED; + + if (irq_status & RGS_IRQ_STATUS_TRANSMITTER) + return mtk_dp_hpd_isr_handler(mtk_dp);
mtk_dp_hpd_isr_handler() is called once here,
so I would like to mergemtk_dp_hpd_isr_handler() into this function,
and change mtk_dp_hpd_event() to mtk_dp_hpd_isr_handler().
Quoted 5 lines
drivers/gpu/drm/mediatek/Makefile +4
-0+ + return IRQ_HANDLED; +} +
[snip]
Quoted 11 lines
drivers/gpu/drm/mediatek/Makefile +11
-0+ +static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux, + struct drm_dp_aux_msg *msg) +{ + ssize_t err = -EAGAIN; + struct mtk_dp *mtk_dp; + bool is_read; + u8 request; + size_t accessed_bytes = 0; + int retry = 3, ret = 0; +
drivers/gpu/drm/mediatek/Makefile
Quoted 10 lines
drivers/gpu/drm/mediatek/Makefile +10
-0+ mtk_dp = container_of(mtk_aux, struct mtk_dp, aux); + + if (!mtk_dp->train_info.cable_plugged_in || + mtk_dp->train_info.irq_status & MTK_DP_HPD_DISCONNECT) { + mtk_dp->train_state = MTK_DP_TRAIN_STATE_CHECKCAP; + err = -EAGAIN; + goto err; + } + + switch (msg->request) {
In intel_dp_aux_transfer() [1], it is
switch (msg->request & ~DP_AUX_I2C_MOT) {
Would that be a better statement?
Quoted 69 lines
drivers/gpu/drm/mediatek/Makefile +6
-0+ 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/Makefile +19
-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); + err = -EINVAL; + goto err; + } + + if (msg->size == 0) { + mtk_dp_aux_do_transfer(mtk_dp, is_read, request, + msg->address + accessed_bytes, + msg->buffer + accessed_bytes,0);
drivers/gpu/drm/mediatek/Makefile +9
-0+ } else { + while (accessed_bytes < msg->size) { + size_t to_access = + min_t(size_t, DP_AUX_MAX_PAYLOAD_BYTES, + msg->size - accessed_bytes); + retry = 3; + while (retry--) { + ret = mtk_dp_aux_do_transfer(mtk_dp, + is_read,request,
drivers/gpu/drm/mediatek/Makefile +1
-0+ msg-Quoted 1 line
address +
accessed_bytes,drivers/gpu/drm/mediatek/Makefile +1
-0+ msg-Quoted 1 line
buffer +
accessed_bytes,drivers/gpu/drm/mediatek/Makefile +1
-0+ to_access);
drivers/gpu/drm/mediatek/Makefile +7
-0+ if (ret == 0) + break; + usleep_range(50, 100); + } + if (!retry && ret) { + drm_info(mtk_dp->drm_dev, + "Failed to do AUX transfer:%d\n",
drivers/gpu/drm/mediatek/Makefile +9
-0+ ret); + break; + } + accessed_bytes += to_access; + } + } +err: + if (ret) { + msg->reply = DP_AUX_NATIVE_REPLY_NACK |
DP_AUX_I2C_REPLY_NACK;drivers/gpu/drm/mediatek/Makefile +7
-0+ return err; + } + + msg->reply = DP_AUX_NATIVE_REPLY_ACK | DP_AUX_I2C_REPLY_ACK; + return msg->size; +} +
[snip]
Quoted 61 lines
drivers/gpu/drm/mediatek/Makefile +3
-0+ +static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge, + struct drm_bridge_state
*old_state)drivers/gpu/drm/mediatek/Makefile +9
-0+{ + struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge); + struct drm_connector_state *conn_state; + struct drm_crtc *crtc; + struct drm_crtc_state *crtc_state; + int ret = 0; + int i; + + mtk_dp->conn =drm_atomic_get_new_connector_for_encoder(old_state->base.state,
drivers/gpu/drm/mediatek/Makefile +1
-0+ bridge-Quoted 1 line
encoder);
drivers/gpu/drm/mediatek/Makefile +3
-0+ if (!mtk_dp->conn) { + drm_err(mtk_dp->drm_dev, + "Can't enable bridge as connector ismissing\n");
drivers/gpu/drm/mediatek/Makefile +5
-0+ return; + } + + mutex_lock(&mtk_dp->eld_lock); + memcpy(mtk_dp->connector_eld, mtk_dp->conn->eld,
MAX_ELD_BYTES);drivers/gpu/drm/mediatek/Makefile +4
-0+ mutex_unlock(&mtk_dp->eld_lock); + + conn_state = + drm_atomic_get_new_connector_state(old_state-Quoted 1 line
base.state,
mtk_dp->conn);drivers/gpu/drm/mediatek/Makefile +3
-0+ if (!conn_state) { + drm_err(mtk_dp->drm_dev, + "Can't enable bridge as connector state ismissing\n");
drivers/gpu/drm/mediatek/Makefile +7
-0+ return; + } + + crtc = conn_state->crtc; + if (!crtc) { + drm_err(mtk_dp->drm_dev, + "Can't enable bridge as connector state doesn'thave a crtc\n");
drivers/gpu/drm/mediatek/Makefile +4
-0+ return; + } + + crtc_state = drm_atomic_get_new_crtc_state(old_state-Quoted 1 line
base.state, crtc);
drivers/gpu/drm/mediatek/Makefile +3
-0+ if (!crtc_state) { + drm_err(mtk_dp->drm_dev, + "Can't enable bridge as crtc state ismissing\n");
drivers/gpu/drm/mediatek/Makefile +4
-0+ return; + } + + mtk_dp_parse_drm_mode_timings(mtk_dp, &crtc_state-Quoted 1 line
adjusted_mode);drivers/gpu/drm/mediatek/Makefile +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/Makefile
Quoted 6 lines
drivers/gpu/drm/mediatek/Makefile +6
-0+ return; + } + + /* Training */ + for (i = 0; i < 50; i++) { + ret = mtk_dp_train_handler(mtk_dp);
Why do you call mtk_dp_train_handler() many times? Call mtk_dp_train_handler() once and let all retry inside mtk_dp_train_handler().
Quoted 21 lines
drivers/gpu/drm/mediatek/Makefile +2
-0+ if (ret) { + drm_err(mtk_dp->drm_dev, "Train handler failed%d\n",
drivers/gpu/drm/mediatek/Makefile +7
-0+ ret); + return; + } + + ret = mtk_dp_state_handler(mtk_dp); + if (ret) { + drm_err(mtk_dp->drm_dev, "State handler failed%d\n",
drivers/gpu/drm/mediatek/Makefile +9
-0+ ret); + return; + } + } + + mtk_dp->enabled = true; + mtk_dp_update_plugged_status(mtk_dp); +} +
[snip]
Quoted 8 lines
drivers/gpu/drm/mediatek/Makefile +8
-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; +
drivers/gpu/drm/mediatek/Makefile
Quoted 10 lines
drivers/gpu/drm/mediatek/Makefile +10
-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) { + dev_err(dev, "failed to request dp irq resource\n"); + return -EPROBE_DEFER;
return irq_num;
Quoted 20 lines
drivers/gpu/drm/mediatek/Makefile +3
-0+ } + + mtk_dp->next_bridge = devm_drm_of_get_bridge(dev, dev->of_node,1, 0);
drivers/gpu/drm/mediatek/Makefile +15
-0+ if (IS_ERR(mtk_dp->next_bridge)) { + ret = PTR_ERR(mtk_dp->next_bridge); + dev_err_probe(dev, ret, "Failed to get bridge\n"); + return ret; + } + + ret = mtk_dp_dt_parse(mtk_dp, pdev); + if (ret) + return ret; + + mtk_dp_aux_init(mtk_dp); + + 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/Makefile
Quoted 4 lines
drivers/gpu/drm/mediatek/Makefile +4
-0+ mtk_dp); + if (ret) { + dev_err(dev, "failed to request mediatek dptx irq\n"); + return -EPROBE_DEFER;
return ret;
Quoted 56 lines
drivers/gpu/drm/mediatek/Makefile +17
-0+ } + + mutex_init(&mtk_dp->dp_lock); + mutex_init(&mtk_dp->edid_lock); + mutex_init(&mtk_dp->eld_lock); + + platform_set_drvdata(pdev, mtk_dp); + + mutex_init(&mtk_dp->update_plugged_status_lock); + 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",
drivers/gpu/drm/mediatek/Makefile +1
-0+ PLATFORM_DEVID_AUTO,
drivers/gpu/drm/mediatek/Makefile +2
-0+ &mtk_dp->regs, + sizeof(structregmap *));
drivers/gpu/drm/mediatek/Makefile +2
-0+ if (IS_ERR(mtk_dp->phy_dev)) { + dev_err(dev, "Failed to create device mediatek-dp-phy:%ld\n",
drivers/gpu/drm/mediatek/Makefile +9
-0+ PTR_ERR(mtk_dp->phy_dev)); + return PTR_ERR(mtk_dp->phy_dev); + } + + 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)) { + dev_err(dev, "Failed to get phy: %ld\n",
PTR_ERR(mtk_dp->phy));drivers/gpu/drm/mediatek/Makefile +10
-0+ platform_device_unregister(mtk_dp->phy_dev); + return PTR_ERR(mtk_dp->phy); + } + + mtk_dp->bridge.funcs = &mtk_dp_bridge_funcs; + mtk_dp->bridge.of_node = dev->of_node; + mtk_dp->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; + + mtk_dp->bridge.ops = + DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
DRM_BRIDGE_OP_HPD;drivers/gpu/drm/mediatek/Makefile +8
-0+ drm_bridge_add(&mtk_dp->bridge); + + pm_runtime_enable(dev); + pm_runtime_get_sync(dev); + + return 0; +} +
PATCH v7 8/8 drm/mediatek: Add mt8195 eDP support
In reply to Guillaume RanquetThis adds support of eDP panel to the mt8195 DP driver.
This driver is based on an initial version by
Jason-JH.Lin <[email protected]>.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 102 +++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 29 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +73 -29
@@ -228,6 +228,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);
@@ -1185,26 +1190,49 @@ static int mtk_dp_get_calibration_data(struct mtk_dp *mtk_dp)return PTR_ERR (buf); } - cal_data->glb_bias_trim = -check_cal_data_valid (1 ,0x1e , (buf[0 ] >>27 ) &0x1f ,0xf ); - cal_data->clktx_impse = -check_cal_data_valid (1 ,0xe , (buf[0 ] >>13 ) &0xf ,0x8 ); - cal_data->ln0_tx_impsel_pmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>28 ) &0xf ,0x8 ); - cal_data->ln0_tx_impsel_nmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>24 ) &0xf ,0x8 ); - cal_data->ln1_tx_impsel_pmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>20 ) &0xf ,0x8 ); - cal_data->ln1_tx_impsel_nmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>16 ) &0xf ,0x8 ); - cal_data->ln2_tx_impsel_pmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>12 ) &0xf ,0x8 ); - cal_data->ln2_tx_impsel_nmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>8 ) &0xf ,0x8 ); - cal_data->ln3_tx_impsel_pmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>4 ) &0xf ,0x8 ); - cal_data->ln3_tx_impsel_nmos = -check_cal_data_valid (1 ,0xe , buf[1 ] &0xf ,0x8 ); +if (mtk_dp_is_edp (mtk_dp)) { + cal_data->glb_bias_trim = +check_cal_data_valid (1 ,0x1e , (buf[3 ] >>27 ) &0x1f ,0xf ); + cal_data->clktx_impse = +check_cal_data_valid (1 ,0xe , (buf[0 ] >>9 ) &0xf ,0x8 ); + cal_data->ln0_tx_impsel_pmos = +check_cal_data_valid (1 ,0xe , (buf[2 ] >>28 ) &0xf ,0x8 ); + cal_data->ln0_tx_impsel_nmos = +check_cal_data_valid (1 ,0xe , (buf[2 ] >>24 ) &0xf ,0x8 ); + cal_data->ln1_tx_impsel_pmos = +check_cal_data_valid (1 ,0xe , (buf[2 ] >>20 ) &0xf ,0x8 ); + cal_data->ln1_tx_impsel_nmos = +check_cal_data_valid (1 ,0xe , (buf[2 ] >>16 ) &0xf ,0x8 ); + cal_data->ln2_tx_impsel_pmos = +check_cal_data_valid (1 ,0xe , (buf[2 ] >>12 ) &0xf ,0x8 ); + cal_data->ln2_tx_impsel_nmos = +check_cal_data_valid (1 ,0xe , (buf[2 ] >>8 ) &0xf ,0x8 ); + cal_data->ln3_tx_impsel_pmos = +check_cal_data_valid (1 ,0xe , (buf[2 ] >>4 ) &0xf ,0x8 ); + cal_data->ln3_tx_impsel_nmos = +check_cal_data_valid (1 ,0xe , buf[2 ] &0xf ,0x8 ); + }else { + cal_data->glb_bias_trim = +check_cal_data_valid (1 ,0x1e , (buf[0 ] >>27 ) &0x1f ,0xf ); + cal_data->clktx_impse = +check_cal_data_valid (1 ,0xe , (buf[0 ] >>13 ) &0xf ,0x8 ); + cal_data->ln0_tx_impsel_pmos = +check_cal_data_valid (1 ,0xe , (buf[1 ] >>28 ) &0xf ,0x8 ); + cal_data->ln0_tx_impsel_nmos = +check_cal_data_valid (1 ,0xe , (buf[1 ] >>24 ) &0xf ,0x8 ); + cal_data->ln1_tx_impsel_pmos = +check_cal_data_valid (1 ,0xe , (buf[1 ] >>20 ) &0xf ,0x8 ); + cal_data->ln1_tx_impsel_nmos = +check_cal_data_valid (1 ,0xe , (buf[1 ] >>16 ) &0xf ,0x8 ); + cal_data->ln2_tx_impsel_pmos = +check_cal_data_valid (1 ,0xe , (buf[1 ] >>12 ) &0xf ,0x8 ); + cal_data->ln2_tx_impsel_nmos = +check_cal_data_valid (1 ,0xe , (buf[1 ] >>8 ) &0xf ,0x8 ); + cal_data->ln3_tx_impsel_pmos = +check_cal_data_valid (1 ,0xe , (buf[1 ] >>4 ) &0xf ,0x8 ); + cal_data->ln3_tx_impsel_nmos = +check_cal_data_valid (1 ,0xe , buf[1 ] &0xf ,0x8 ); + }kfree (buf);
@@ -1322,7 +1350,11 @@ static void mtk_dp_video_mute(struct mtk_dp *mtk_dp, bool enable)mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3000 , val,VIDEO_MUTE_SEL_DP_ENC0_P0_MASK |VIDEO_MUTE_SW_DP_ENC0_P0_MASK ); -mtk_dp_sip_atf_call (MTK_DP_SIP_ATF_VIDEO_UNMUTE , enable); + +if (mtk_dp_is_edp (mtk_dp)) +mtk_dp_sip_atf_call (MTK_DP_SIP_ATF_EDP_VIDEO_UNMUTE , enable); +else +mtk_dp_sip_atf_call (MTK_DP_SIP_ATF_VIDEO_UNMUTE , enable); }static void mtk_dp_audio_mute (struct mtk_dp *mtk_dp,bool mute)
@@ -2326,6 +2358,9 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_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 (mtk_dp)) {drm_dp_dpcd_readb (&mtk_dp->aux,DP_SINK_COUNT , &sink_count);if (DP_GET_SINK_COUNT (sink_count))
@@ -2888,7 +2923,11 @@ static int mtk_dp_probe(struct platform_device *pdev) } 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, continuing as external DP\n" ); + mtk_dp->next_bridge =NULL ; + }else if (IS_ERR (mtk_dp->next_bridge)) { ret =PTR_ERR (mtk_dp->next_bridge);dev_err_probe (dev, ret,"Failed to get bridge\n" );return ret;
@@ -2915,12 +2954,14 @@ static int mtk_dp_probe(struct platform_device *pdev)platform_set_drvdata (pdev, mtk_dp); -mutex_init (&mtk_dp->update_plugged_status_lock); - ret =mtk_dp_register_audio_driver (dev); -if (ret) { -dev_err (dev,"Failed to register audio driver: %d\n" , - ret); -return ret; +if (!mtk_dp_is_edp (mtk_dp)) { +mutex_init (&mtk_dp->update_plugged_status_lock); + 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",
@@ -2944,7 +2985,10 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp->bridge.funcs = &mtk_dp_bridge_funcs; mtk_dp->bridge.of_node = dev->of_node; - mtk_dp->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; +if (mtk_dp_is_edp (mtk_dp)) + mtk_dp->bridge.type = DRM_MODE_CONNECTOR_eDP; +else + mtk_dp->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; mtk_dp->bridge.ops =DRM_BRIDGE_OP_DETECT |DRM_BRIDGE_OP_EDID |DRM_BRIDGE_OP_HPD ;
Signature · 1 line
2.32.0
Re: [PATCH v7 8/8] drm/mediatek: Add mt8195 eDP support
Hi, Guillaume:
Quoted 4 lines · Guillaume Ranquet
This adds support of eDP panel to the mt8195 DP driver.
This driver is based on an initial version by
Jason-JH.Lin <[email protected]>.
This patch looks good to me, but I've a question. Do you have both display port platform and eDP platform? If you have only one of these, why do you upstream the one which you never have?
Regards,
CK
Quoted 207 lines
Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>--- drivers/gpu/drm/mediatek/mtk_dp.c | 102 +++++++++++++++++++++------- -- 1 file changed, 73 insertions(+), 29 deletions(-)drivers/gpu/drm/mediatek/mtk_dp.c +5
-0@@ -228,6 +228,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) {drivers/gpu/drm/mediatek/mtk_dp.c +3
-20return container_of(b, struct mtk_dp, bridge);@@ -1185,26 +1190,49 @@ static int mtk_dp_get_calibration_data(struct mtk_dp *mtk_dp)return PTR_ERR (buf); } - cal_data->glb_bias_trim = -check_cal_data_valid (1 ,0x1e , (buf[0 ] >>27 ) &0x1f , 0xf); - cal_data->clktx_impse = -check_cal_data_valid (1 ,0xe , (buf[0 ] >>13 ) &0xf , 0x8); - cal_data->ln0_tx_impsel_pmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>28 ) &0xf , 0x8); - cal_data->ln0_tx_impsel_nmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>24 ) &0xf , 0x8); - cal_data->ln1_tx_impsel_pmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>20 ) &0xf , 0x8); - cal_data->ln1_tx_impsel_nmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>16 ) &0xf , 0x8); - cal_data->ln2_tx_impsel_pmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>12 ) &0xf , 0x8); - cal_data->ln2_tx_impsel_nmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>8 ) &0xf ,0x8 ); - cal_data->ln3_tx_impsel_pmos = -check_cal_data_valid (1 ,0xe , (buf[1 ] >>4 ) &0xf ,0x8 ); - cal_data->ln3_tx_impsel_nmos = -check_cal_data_valid (1 ,0xe , buf[1 ] &0xf ,0x8 ); +if (mtk_dp_is_edp (mtk_dp)) { + cal_data->glb_bias_trim = + check_cal_data_valid(1, 0x1e, (buf[3] >> 27) &
0x1f,0xf);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->clktx_impse = + check_cal_data_valid(1, 0xe, (buf[0] >> 9) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln0_tx_impsel_pmos = + check_cal_data_valid(1, 0xe, (buf[2] >> 28) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln0_tx_impsel_nmos = + check_cal_data_valid(1, 0xe, (buf[2] >> 24) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln1_tx_impsel_pmos = + check_cal_data_valid(1, 0xe, (buf[2] >> 20) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln1_tx_impsel_nmos = + check_cal_data_valid(1, 0xe, (buf[2] >> 16) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln2_tx_impsel_pmos = + check_cal_data_valid(1, 0xe, (buf[2] >> 12) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln2_tx_impsel_nmos = + check_cal_data_valid(1, 0xe, (buf[2] >> 8) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln3_tx_impsel_pmos = + check_cal_data_valid(1, 0xe, (buf[2] >> 4) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln3_tx_impsel_nmos = + check_cal_data_valid(1, 0xe, buf[2] & 0xf,
0x8);drivers/gpu/drm/mediatek/mtk_dp.c +3
-0+ }else { + cal_data->glb_bias_trim = + check_cal_data_valid(1, 0x1e, (buf[0] >> 27) &
0x1f,0xf);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->clktx_impse = + check_cal_data_valid(1, 0xe, (buf[0] >> 13) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln0_tx_impsel_pmos = + check_cal_data_valid(1, 0xe, (buf[1] >> 28) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln0_tx_impsel_nmos = + check_cal_data_valid(1, 0xe, (buf[1] >> 24) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln1_tx_impsel_pmos = + check_cal_data_valid(1, 0xe, (buf[1] >> 20) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln1_tx_impsel_nmos = + check_cal_data_valid(1, 0xe, (buf[1] >> 16) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln2_tx_impsel_pmos = + check_cal_data_valid(1, 0xe, (buf[1] >> 12) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln2_tx_impsel_nmos = + check_cal_data_valid(1, 0xe, (buf[1] >> 8) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln3_tx_impsel_pmos = + check_cal_data_valid(1, 0xe, (buf[1] >> 4) &
0xf,0x8);drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ cal_data->ln3_tx_impsel_nmos = + check_cal_data_valid(1, 0xe, buf[1] & 0xf,
0x8);drivers/gpu/drm/mediatek/mtk_dp.c +6
-1+ }kfree (buf);@@ -1322,7 +1350,11 @@ static void mtk_dp_video_mute(struct mtk_dp *mtk_dp, bool enable)mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3000 , val,VIDEO_MUTE_SEL_DP_ENC0_P0_MASK |VIDEO_MUTE_SW_DP_ENC0_P0_MASK ); -mtk_dp_sip_atf_call (MTK_DP_SIP_ATF_VIDEO_UNMUTE , enable); + +if (mtk_dp_is_edp (mtk_dp)) +mtk_dp_sip_atf_call (MTK_DP_SIP_ATF_EDP_VIDEO_UNMUTE , enable); +else +mtk_dp_sip_atf_call (MTK_DP_SIP_ATF_VIDEO_UNMUTE , enable);}
static void
mtk_dp_audio_mute(struct mtk_dp *mtk_dp, bool mute)drivers/gpu/drm/mediatek/mtk_dp.c +3
-0@@ -2326,6 +2358,9 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_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 (mtk_dp)) { drm_dp_dpcd_readb(&mtk_dp->aux, DP_SINK_COUNT,
&sink_count);drivers/gpu/drm/mediatek/mtk_dp.c +3
-1if (DP_GET_SINK_COUNT (sink_count))@@ -2888,7 +2923,11 @@ static int mtk_dp_probe(struct platform_device *pdev) } 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, continuingas external DP\n");
drivers/gpu/drm/mediatek/mtk_dp.c +10
-6+ mtk_dp->next_bridge =NULL ; + }else if (IS_ERR (mtk_dp->next_bridge)) { ret =PTR_ERR (mtk_dp->next_bridge);dev_err_probe (dev, ret,"Failed to get bridge\n" );return ret;@@ -2915,12 +2954,14 @@ static int mtk_dp_probe(struct platform_device *pdev)platform_set_drvdata (pdev ,mtk_dp ); -mutex_init (&mtk_dp->update_plugged_status_lock); - ret =mtk_dp_register_audio_driver (dev); -if (ret) { -dev_err (dev,"Failed to register audio driver: %d\n" , - ret); -return ret; +if (!mtk_dp_is_edp (mtk_dp)) { +mutex_init (&mtk_dp->update_plugged_status_lock); + 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",drivers/gpu/drm/mediatek/mtk_dp.c +4
-1@@ -2944,7 +2985,10 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp->bridge.funcs = &mtk_dp_bridge_funcs; mtk_dp->bridge.of_node = dev->of_node; - mtk_dp->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; +if (mtk_dp_is_edp (mtk_dp)) + mtk_dp->bridge.type = DRM_MODE_CONNECTOR_eDP; +else + mtk_dp->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; mtk_dp->bridge.ops =
DRM_BRIDGE_OP_DETECT|DRM_BRIDGE_OP_EDID|DRM_BRIDGE_OP_HPD;