drm/mediatek: Add MT8195 DisplayPort driver
Subsystems (6)
v14 cover drm/mediatek: Add MT8195 DisplayPort driver
This patch is separated from v10 which is including dp driver, phy driver and dpintf driver. This series is only contained the DisplayPort driver.
This series can be tested using 5.19-rc2 kernel and I test it in MT8195 Tomato Chromebook. Modetest these modes:
for eDP:
#0 2256x1504 60.00 2256 2304 2336 2536 1504 1507 1513 1549 235690 flags: phsync, nvsync; type: preferred, driver #1 2256x1504 48.00 2256 2304 2336 2536 1504 1507 1513 1549 188550 flags: phsync, nvsync; type: driver
for DP:
#0 1920x1080 60.00 1920 2008 2052 2200 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: preferred, driver #1 1920x1080 59.94 1920 2008 2052 2200 1080 1084 1089 1125 148352 flags: phsync, pvsync; type: driver #2 1920x1080 50.00 1920 2448 2492 2640 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: driver #3 1680x1050 59.95 1680 1784 1960 2240 1050 1053 1059 1089 146250 flags: nhsync, pvsync; type: driver #4 1600x900 60.00 1600 1624 1704 1800 900 901 904 1000 108000 flags: phsync, pvsync; type: driver #5 1280x1024 60.02 1280 1328 1440 1688 1024 1025 1028 1066 108000 flags: phsync, pvsync; type: driver #6 1280x800 59.81 1280 1352 1480 1680 800 803 809 831 83500 flags: nhsync, pvsync; type: driver #7 1280x720 60.00 1280 1390 1430 1650 720 725 730 750 74250 flags: phsync, pvsync; type: driver #8 1280x720 59.94 1280 1390 1430 1650 720 725 730 750 74176 flags: phsync, pvsync; type: driver #9 1280x720 50.00 1280 1720 1760 1980 720 725 730 750 74250 flags: phsync, pvsync; type: driver #10 1024x768 60.00 1024 1048 1184 1344 768 771 777 806 65000 flags: nhsync, nvsync; type: driver #11 800x600 60.32 800 840 968 1056 600 601 605 628 40000 flags: phsync, pvsync; type: driver #12 720x576 50.00 720 732 796 864 576 581 586 625 27000 flags: nhsync, nvsync; type: driver #13 720x480 60.00 720 736 798 858 480 489 495 525 27027 flags: nhsync, nvsync; type: driver #14 720x480 59.94 720 736 798 858 480 489 495 525 27000 flags: nhsync, nvsync; type: driver #15 640x480 60.00 640 656 752 800 480 490 492 525 25200 flags: nhsync, nvsync; type: driver #16 640x480 59.94 640 656 752 800 480 490 492 525 25175 flags: nhsync, nvsync; type: driver
Changes from v13 for dp driver:
dt-binding:
- Move data-lanes to port.
dp drivers:
- Reporting for data-lanes using port.
- Remove unnecessary drivers.
- Refine mtk_dp_aux_transfer().
- Refine mtk_dp_hpd_isr_handler().
- Remove fec related drivers.
Changes from v12 for dp driver:
dt-binding:
- Fix build error.
embedded dp drivers:
- Revise Kconfig to let this driver independent.
- Drop some unused/redundant drivers.
- Move some features to patches of external dp and audio.
- Refine format error control flow.
- Add error control of write register functions.
- Use mtk sip common definitions.
Changes from v11 for dp driver:
dt-binding:
- Use data-lanes to determine the max supported lane numbers.
- Add mhz to max-linkrate to show the units.
embedded dp drivers:
- Modify Makefile.
- Drop some unused/redundant drivers.
- Move some features to patches of external dp and audio.
- Modify break condition of training loop to control cr/eq fail.
- Replace some function/definition with ones of common drm drivers.
- Remove dp_lock mutex because it's only locked in power_on/off.
- Add drm_dp_aux_(un)register in mtk_dp_bridge_(de)attach.
Changes from v10 for dp driver:
- Drop return value for write registers to make code more clear.
- Refine training state.
- Add property for dt-binding.
- Add new bug fix patches for audio and suspend.
- Rebase to v5.19-rc1.
Changes from v9:
- The DP-Phy is back to being a child device of the DP driver (as in v8)
- hot plug detection has been added back to Embedded Display Port... as after discussing with mediatek experts, this is needed eventhough the Embedded Display port is not un-pluggable
- rebased on linux-next
- simplified/split train_handler function, as suggested by Rex
- added comments on the sleep/delays present in the code
- removed previous patch introducing retries when receiving AUX_DEFER as this is already handled in the dp_aux framework
- added max-lane and max-linkrate device tree u8 properties instead of hardcoded #defines
Older revisions:
RFC - https://lore.kernel.org/linux-mediatek/[email protected]/
v1 - https://lore.kernel.org/linux-mediatek/[email protected]/ v2 - https://lore.kernel.org/linux-mediatek/[email protected]/ v3 - https://lore.kernel.org/linux-mediatek/[email protected]/ v4 - https://lore.kernel.org/linux-mediatek/[email protected]/ v5 - https://lore.kernel.org/all/[email protected]/ v6 - https://lore.kernel.org/linux-mediatek/[email protected]/ v7 - https://lore.kernel.org/linux-mediatek/[email protected]/ v8 - https://lore.kernel.org/linux-mediatek/[email protected]/ v9 - https://lore.kernel.org/all/[email protected]/
v10 - https://lore.kernel.org/all/[email protected]/
v11 - https://lore.kernel.org/r/[email protected]
v12 - https://lore.kernel.org/all/[email protected]/
v13 - https://lore.kernel.org/all/[email protected]/
Bo-Chen Chen (2):
drm/mediatek: set monitor to DP_SET_POWER_D3 to avoid garbage drm/mediatek: Use cached audio config when changing resolution
Guillaume Ranquet (4):
drm/edid: Convert cea_sad helper struct to kernelDoc drm/edid: Add cea_sad helpers for freq/length drm/mediatek: Add MT8195 External DisplayPort support drm/mediatek: DP audio support for MT8195
Jitao Shi (1):
drm/mediatek: add hpd debounce
Markus Schneider-Pargmann (3):
dt-bindings: mediatek,dp: Add Display Port binding video/hdmi: Add audio_infoframe packing for DP drm/mediatek: Add MT8195 Embedded DisplayPort driver
.../display/mediatek/mediatek,dp.yaml | 115 + drivers/gpu/drm/drm_edid.c | 73 + drivers/gpu/drm/mediatek/Kconfig | 9 + drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_dp.c | 2951 +++++++++++++++++ drivers/gpu/drm/mediatek/mtk_dp_reg.h | 545 +++ drivers/video/hdmi.c | 82 +- include/drm/display/drm_dp.h | 2 + include/drm/drm_edid.h | 26 +- include/linux/hdmi.h | 7 +- 10 files changed, 3789 insertions(+), 23 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml create mode 100644 drivers/gpu/drm/mediatek/mtk_dp.c create mode 100644 drivers/gpu/drm/mediatek/mtk_dp_reg.h
Signature · 1 line
2.18.0
PATCH v14 2/10 drm/edid: Convert cea_sad helper struct to kernelDoc
From: Guillaume Ranquet <[email protected]>
To illustrate the cea_sad helper struct more clear, we convert the driver comments to kernelDoc.
--- include/drm/drm_edid.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
include/drm/drm_edid.h +9 -3
@@ -359,12 +359,18 @@ struct edid {#define EDID_PRODUCT_ID (e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8)) -/* Short Audio Descriptor */ +/** +* struct cea_sad - CEA Short Audio Descriptor. +* @format: See HDMI_AUDIO_CODING_TYPE_*. +* @channels: max number of channels - 1. +* @freq: See CEA_SAD_FREQ_*. +* @byte2: meaning depends on format. +*/ struct cea_sad {u8 format; -u8 channels;/* max number of channels - 1 */ +u8 channels;u8 freq; -u8 byte2;/* meaning depends on format */ +u8 byte2; };struct drm_encoder ;
Signature · 1 line
2.18.0
PATCH v14 8/10 drm/mediatek: set monitor to DP_SET_POWER_D3 to avoid garbage
In reply to Bo-Chen ChenSet the monitor power state to DP_SET_POWER_D3 to avoid garbage.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/mediatek/mtk_dp.c +5 -0
@@ -1887,6 +1887,11 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge, {struct mtk_dp *mtk_dp =mtk_dp_from_bridge (bridge); +if (mtk_dp_plug_state (mtk_dp)) { +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D3 ); +usleep_range (2000 ,3000 ); + } +mtk_dp_video_mute (mtk_dp, true); mtk_dp->enabled = false;
Signature · 1 line
2.18.0
PATCH v14 10/10 drm/mediatek: Use cached audio config when changing resolution
In reply to Bo-Chen ChenWhen the audio is playing, we need to use the original configuration to set the audio instead of using new configuration. Therefore, use the cached audio configuration during a resolution switch to avoid loss of sound.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 54 ++++++++++--------------------- 1 file changed, 17 insertions(+), 37 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +17 -37
@@ -104,7 +104,7 @@ struct mtk_dp_audio_cfg {struct mtk_dp_info {u32 depth;enum dp_pixelformat format; -struct mtk_dp_audio_cfg audio_caps; +struct mtk_dp_audio_cfg audio_cur_cfg;struct mtk_dp_timings timings; };
@@ -1858,9 +1858,7 @@ static bool mtk_dp_edid_parse_audio_capabilities(struct mtk_dp *mtk_dp, struct mtk_dp_audio_cfg *cfg) {struct cea_sad *sads; -int sad_count; -int i; -bool ret = false; +int ret;if (mtk_dp_is_edp (mtk_dp))return false;
@@ -1871,36 +1869,16 @@ static bool mtk_dp_edid_parse_audio_capabilities(struct mtk_dp *mtk_dp,dev_err (mtk_dp->dev,"EDID not found!\n" );return false; } - sad_count =drm_edid_to_sad (mtk_dp->edid, &sads); -mutex_unlock (&mtk_dp->edid_lock); -if (sad_count <=0 ) { + ret =drm_edid_to_sad (mtk_dp->edid, &sads); +mutex_unlock (&mtk_dp->edid_lock); +if (ret <=0 ) {drm_info (mtk_dp->drm_dev,"The SADs is NULL\n" );return false; } - -for (i =0 ; i < sad_count; i++) { -int sample_rate, word_length; - -/* Only PCM supported at the moment */ -if (sads[i].format !=HDMI_AUDIO_CODING_TYPE_PCM ) -continue ; - - sample_rate =drm_cea_sad_get_sample_rate (&sads[i]); - word_length = -drm_cea_sad_get_uncompressed_word_length (&sads[i]); -if (sample_rate <=0 || word_length <=0 ) -continue ; - - cfg->channels = sads[i].channels; - cfg->word_length_bits = word_length; - cfg->sample_rate = sample_rate; - ret = true; -break ; - }kfree (sads); -return ret; +return true; }static void mtk_dp_train_change_mode (struct mtk_dp *mtk_dp)
@@ -2081,13 +2059,13 @@ static int mtk_dp_training(struct mtk_dp *mtk_dp) mtk_dp->audio_enable =mtk_dp_edid_parse_audio_capabilities (mtk_dp, - &mtk_dp->info.audio_caps); + &mtk_dp->info.audio_cur_cfg);if (mtk_dp->audio_enable) { -mtk_dp_audio_setup (mtk_dp, &mtk_dp->info.audio_caps); +mtk_dp_audio_setup (mtk_dp, &mtk_dp->info.audio_cur_cfg);mtk_dp_audio_mute (mtk_dp, false); }else { -memset (&mtk_dp->info.audio_caps,0 , -sizeof (mtk_dp->info.audio_caps)); +memset (&mtk_dp->info.audio_cur_cfg,0 , +sizeof (mtk_dp->info.audio_cur_cfg)); }return 0 ;
@@ -2491,6 +2469,9 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge,if (mtk_dp_plug_state (mtk_dp)) {drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D3 );usleep_range (2000 ,3000 ); + }else { +memset (&mtk_dp->info.audio_cur_cfg,0 , +sizeof (mtk_dp->info.audio_cur_cfg)); }mtk_dp_video_mute (mtk_dp, true);
@@ -2701,18 +2682,17 @@ static int mtk_dp_audio_hw_params(struct device *dev, void *data, struct hdmi_codec_params *params) {struct mtk_dp *mtk_dp =dev_get_drvdata (dev); -struct mtk_dp_audio_cfg cfg;if (!mtk_dp->enabled) {pr_err ("%s, DP is not ready!\n" , __func__);return -ENODEV ; } - cfg.channels = params->cea.channels; - cfg.sample_rate = params->sample_rate; - cfg.word_length_bits =24 ; + mtk_dp->info.audio_cur_cfg.channels = params->cea.channels; + mtk_dp->info.audio_cur_cfg.sample_rate = params->sample_rate; + mtk_dp->info.audio_cur_cfg.word_length_bits =24 ; -mtk_dp_audio_setup (mtk_dp, &cfg); +mtk_dp_audio_setup (mtk_dp, &mtk_dp->info.audio_cur_cfg);return 0 ; }
Signature · 1 line
2.18.0
PATCH v14 1/10 dt-bindings: mediatek,dp: Add Display Port binding
In reply to Bo-Chen ChenFrom: 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 | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +115 -0
@@ -0,0 +1,115 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/mediatek/mediatek,dp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek Display Port Controller + +maintainers: + - Chun-Kuang Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + Device tree bindings for the MediaTek display port TX (DP) and + embedded display port TX (eDP) controller present on some MediaTek SoCs. + MediaTek DP and eDP are different hardwares and they have different + base address for registers, so we need two different compatibles to + separate them. + +properties: + compatible: + enum: + - mediatek,mt8195-dp-tx + - mediatek,mt8195-edp-tx + + reg: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + description: efuse data for display port calibration + + nvmem-cell-names: + const: dp_calibration_data + + power-domains: + maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Input endpoint of the controller, usually dp_intf + + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: Output endpoint of the controller + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + properties: + data-lanes: + description: | + number of lanes supported by the hardware. + The possible values: + 0 - For 1 lane enabled in IP. + 0 1 - For 2 lanes enabled in IP. + 0 1 2 3 - For 4 lanes enabled in IP. + minItems: 1 + maxItems: 4 + required: + - data-lanes + + required: + - port@0 + - port@1 + + max-linkrate-mhz: + enum: [ 1620, 2700, 5400, 8100 ] + description: maximum link rate supported by the hardware. + +required: + - compatible + - reg + - interrupts + - ports + - max-linkrate-mhz + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/power/mt8195-power.h> + dp_tx@1c600000 { + compatible = "mediatek,mt8195-dp-tx"; + reg = <0x1c600000 0x8000>; + power-domains = <&spm MT8195_POWER_DOMAIN_DP_TX>; + interrupts = <GIC_SPI 458 IRQ_TYPE_LEVEL_HIGH 0>; + max-linkrate-mhz = <8100>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dptx_in: endpoint { + remote-endpoint = <&dp_intf0_out>; + }; + }; + port@1 { + reg = <1>; + dptx_out: endpoint { + data-lanes = <0 1 2 3>; + }; + }; + }; + };
Signature · 1 line
2.18.0
PATCH v14 3/10 drm/edid: Add cea_sad helpers for freq/length
In reply to Bo-Chen ChenFrom: Guillaume Ranquet <[email protected]>
This patch adds two helper functions that extract the frequency and word length from a struct cea_sad.
For these helper functions new defines are added that help translate the 'freq' and 'byte2' fields into real numbers.
--- drivers/gpu/drm/drm_edid.c | 73 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 14 ++++++++ 2 files changed, 87 insertions(+)
drivers/gpu/drm/drm_edid.c +73 -0
@@ -4916,6 +4916,79 @@ int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb) }EXPORT_SYMBOL (drm_edid_to_speaker_allocation); +/** +* drm_cea_sad_get_sample_rate - Extract the sample rate from cea_sad +* @sad: Pointer to the cea_sad struct +* +* Extracts the cea_sad frequency field and returns the sample rate in Hz. +* +* Return: Sample rate in Hz or a negative errno if parsing failed. +*/ +int drm_cea_sad_get_sample_rate (const struct cea_sad *sad) +{ +switch (sad->freq) { +case DRM_CEA_SAD_FREQ_32KHZ : +return 32000 ; +case DRM_CEA_SAD_FREQ_44KHZ : +return 44100 ; +case DRM_CEA_SAD_FREQ_48KHZ : +return 48000 ; +case DRM_CEA_SAD_FREQ_88KHZ : +return 88200 ; +case DRM_CEA_SAD_FREQ_96KHZ : +return 96000 ; +case DRM_CEA_SAD_FREQ_176KHZ : +return 176400 ; +case DRM_CEA_SAD_FREQ_192KHZ : +return 192000 ; +default : +return -EINVAL ; + } +} +EXPORT_SYMBOL (drm_cea_sad_get_sample_rate); + +static bool drm_cea_sad_is_pcm (const struct cea_sad *sad) +{ +switch (sad->format) { +case HDMI_AUDIO_CODING_TYPE_PCM : +return true; +default : +return false; + } +} + +/** +* drm_cea_sad_get_uncompressed_word_length - Extract word length +* @sad: Pointer to the cea_sad struct +* +* Extracts the cea_sad byte2 field and returns the word length for an +* uncompressed stream. +* +* Note: This function may only be called for uncompressed audio. +* +* Return: Word length in bits or a negative errno if parsing failed. +*/ +int drm_cea_sad_get_uncompressed_word_length (const struct cea_sad *sad) +{ +if (!drm_cea_sad_is_pcm (sad)) { +DRM_WARN ("Unable to get the uncompressed word length for format: %u\n" , + sad->format); +return -EINVAL ; + } + +switch (sad->byte2) { +case DRM_CEA_SAD_UNCOMPRESSED_WORD_16BIT : +return 16 ; +case DRM_CEA_SAD_UNCOMPRESSED_WORD_20BIT : +return 20 ; +case DRM_CEA_SAD_UNCOMPRESSED_WORD_24BIT : +return 24 ; +default : +return -EINVAL ; + } +} +EXPORT_SYMBOL (drm_cea_sad_get_uncompressed_word_length); +/** * drm_av_sync_delay - compute the HDMI/DP sink audio-video sync delay * @connector: connector associated with the HDMI/DP sink
include/drm/drm_edid.h +14 -0
@@ -373,6 +373,18 @@ struct cea_sad {u8 byte2; }; +#define DRM_CEA_SAD_FREQ_32KHZ BIT(0) +#define DRM_CEA_SAD_FREQ_44KHZ BIT(1) +#define DRM_CEA_SAD_FREQ_48KHZ BIT(2) +#define DRM_CEA_SAD_FREQ_88KHZ BIT(3) +#define DRM_CEA_SAD_FREQ_96KHZ BIT(4) +#define DRM_CEA_SAD_FREQ_176KHZ BIT(5) +#define DRM_CEA_SAD_FREQ_192KHZ BIT(6) + +#define DRM_CEA_SAD_UNCOMPRESSED_WORD_16BIT BIT(0) +#define DRM_CEA_SAD_UNCOMPRESSED_WORD_20BIT BIT(1) +#define DRM_CEA_SAD_UNCOMPRESSED_WORD_24BIT BIT(2) +struct drm_encoder ;struct drm_connector ;struct drm_connector_state ;
@@ -380,6 +392,8 @@ struct drm_display_mode;int drm_edid_to_sad (const struct edid *edid,struct cea_sad **sads);int drm_edid_to_speaker_allocation (const struct edid *edid,u8 **sadb); +int drm_cea_sad_get_sample_rate (const struct cea_sad *sad); +int drm_cea_sad_get_uncompressed_word_length (const struct cea_sad *sad);int drm_av_sync_delay (struct drm_connector *connector,const struct drm_display_mode *mode);
Signature · 1 line
2.18.0
PATCH v14 7/10 drm/mediatek: add hpd debounce
In reply to Bo-Chen ChenFrom: Jitao Shi <[email protected]>
From the DP spec 1.4a chapter 3.3, upstream devices should implement HPD signal de-bouncing on an external connection.
A period of 100ms should be used to detect an HPD connect event. To cover these cases, HPD de-bounce should be implemented only after HPD low has been detected for at least 100ms.
Therefore,
1. If HPD is low (which means plugging out) for longer than 100ms:
we need to do de-bouncing (which means we need to wait for 100ms).
2. If HPD low is for less than 100ms:
we don't need to care about the de-bouncing.
In this patch, we start a 100ms timer and use a need_debounce boolean to implement the feature.
Two cases when HPD is high:
1. If the timer is expired (>100ms):
- need_debounce is true.
- When HPD high (plugging event comes), need_debounce will be true and then we need to do de-bouncing (wait for 100ms).
2. If the timer is not expired (<100ms):
- need_debounce is false.
- When HPD high (plugging event comes), need_debounce will be false and no need to do de-bouncing.
HPD_______ __________________
| |<- 100ms ->
|____________|
<- 100ms ->Without HPD de-bouncing, USB-C to HDMI Adapaters will not be detected.
The change has been successfully tested with the following devices:
- Dell Adapter - USB-C to HDMI
- Acer 1in1 HDMI dongle
- Ugreen 1in1 HDMI dongle
- innowatt HDMI + USB3 hub
- Acer 2in1 HDMI dongle
- Apple 3in1 HDMI dongle (A2119)
- J5Create 3in1 HDMI dongle (JAC379)
--- drivers/gpu/drm/mediatek/mtk_dp.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/gpu/drm/mediatek/mtk_dp.c +23 -0
@@ -105,6 +105,8 @@ struct mtk_dp {bool enabled;struct drm_connector *conn; +bool need_debounce; +struct timer_list debounce_timer; };static struct regmap_config mtk_dp_regmap_config = {
@@ -1551,7 +1553,11 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev)if (event <0 )return IRQ_HANDLED ; +if (mtk_dp->need_debounce && mtk_dp->train_info.cable_plugged_in) +msleep (100 ); +dev_dbg (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) {
@@ -1614,6 +1620,12 @@ static irqreturn_t mtk_dp_hpd_isr_handler(struct mtk_dp *mtk_dp) train_info->cable_state_change = true; +if (!train_info->cable_plugged_in) { +mod_timer (&mtk_dp->debounce_timer, + jiffies +msecs_to_jiffies (100 ) -1 ); + mtk_dp->need_debounce = false; + } +return IRQ_WAKE_THREAD ; }
@@ -2058,6 +2070,13 @@ static const struct drm_bridge_funcs mtk_dp_bridge_funcs = { .detect = mtk_dp_bdg_detect, }; +static void mtk_dp_debounce_timer (struct timer_list *t) +{ +struct mtk_dp *mtk_dp =from_timer (mtk_dp, t, debounce_timer); + + mtk_dp->need_debounce = true; +} +static int mtk_dp_probe (struct platform_device *pdev) {struct mtk_dp *mtk_dp;
@@ -2135,6 +2154,9 @@ static int mtk_dp_probe(struct platform_device *pdev)drm_bridge_add (&mtk_dp->bridge); + mtk_dp->need_debounce = true; +timer_setup (&mtk_dp->debounce_timer, mtk_dp_debounce_timer,0 ); +pm_runtime_enable (dev);pm_runtime_get_sync (dev);
@@ -2147,6 +2169,7 @@ static int mtk_dp_remove(struct platform_device *pdev)platform_device_unregister (mtk_dp->phy_dev);mtk_dp_video_mute (mtk_dp, true); +del_timer_sync (&mtk_dp->debounce_timer);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.18.0
PATCH v14 9/10 drm/mediatek: DP audio support for MT8195
In reply to Bo-Chen ChenFrom: Guillaume Ranquet <[email protected]>
This patch adds audio support to the DP driver for MT8195 with up to 8 channels.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 723 ++++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_dp_reg.h | 2 + 2 files changed, 725 insertions(+)
drivers/gpu/drm/mediatek/mtk_dp.c +723 -0
@@ -44,9 +44,12 @@#define MTK_DP_TBC_BUF_READ_START_ADDR 0x08#define MTK_DP_TRAIN_RETRY_LIMIT 8#define MTK_DP_TRAIN_MAX_ITERATIONS 5 +#define MTK_DP_VERSION 0x11struct mtk_dp_timings {struct videomode vm; +u8 frame_rate; +u32 pix_rate_khz; };struct mtk_dp_irq_sta {
@@ -67,9 +70,41 @@ struct mtk_dp_train_info {struct mtk_dp_irq_sta irq_sta; }; +enum mtk_dp_sdp_type { +MTK_DP_SDP_NONE =0x00 , +MTK_DP_SDP_ACM =0x01 , +MTK_DP_SDP_ISRC =0x02 , +MTK_DP_SDP_AVI =0x03 , +MTK_DP_SDP_AUI =0x04 , +MTK_DP_SDP_SPD =0x05 , +MTK_DP_SDP_MPEG =0x06 , +MTK_DP_SDP_NTSC =0x07 , +MTK_DP_SDP_VSP =0x08 , +MTK_DP_SDP_VSC =0x09 , +MTK_DP_SDP_EXT =0x0A , +MTK_DP_SDP_PPS0 =0x0B , +MTK_DP_SDP_PPS1 =0x0C , +MTK_DP_SDP_PPS2 =0x0D , +MTK_DP_SDP_PPS3 =0x0E , +MTK_DP_SDP_DRM =0x10 , +MTK_DP_SDP_MAX_NUM +}; + +struct mtk_dp_sdp_packet { +enum mtk_dp_sdp_type type; +struct dp_sdp sdp; +}; + +struct mtk_dp_audio_cfg { +int sample_rate; +int word_length_bits; +int channels; +}; +struct mtk_dp_info {u32 depth;enum dp_pixelformat format; +struct mtk_dp_audio_cfg audio_caps;struct mtk_dp_timings timings; };
@@ -103,6 +138,19 @@ struct mtk_dp {struct regmap *regs;bool enabled; +bool audio_enable; + +/* protect the plugged_cb as it's used in both bridge ops and audio */ +struct mutex update_plugged_status_lock; +/* protect the eld data as it's used in both bridge ops and audio */ +struct mutex eld_lock; +/* protect edid as it is used in both bridge ops and IRQ handler */ +struct mutex edid_lock; +struct edid *edid; + +hdmi_codec_plugged_cb plugged_cb; +struct device *codec_dev; +u8 connector_eld[MAX_ELD_BYTES ];struct drm_connector *conn;bool need_debounce;
@@ -371,6 +419,125 @@ static void mtk_dp_pg_enable(struct mtk_dp *mtk_dp, bool enable) 4 << PGEN_PATTERN_SEL_SHIFT, PGEN_PATTERN_SEL_MASK); } +static void mtk_dp_audio_setup_channels (struct mtk_dp *mtk_dp, +struct mtk_dp_audio_cfg *cfg) +{ +u32 channel_enable_bits; + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3324 , +AUDIO_SOURCE_MUX_DP_ENC1_P0_DPRX , +AUDIO_SOURCE_MUX_DP_ENC1_P0_MASK ); + +/* audio channel count change reset */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_33F4 ,BIT (9 ),BIT (9 )); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3304 , +AU_PRTY_REGEN_DP_ENC1_P0_MASK , +AU_PRTY_REGEN_DP_ENC1_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3304 , +AU_CH_STS_REGEN_DP_ENC1_P0_MASK , +AU_CH_STS_REGEN_DP_ENC1_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3304 , +AUDIO_SAMPLE_PRSENT_REGEN_DP_ENC1_P0_MASK , +AUDIO_SAMPLE_PRSENT_REGEN_DP_ENC1_P0_MASK ); + +switch (cfg->channels) { +case 2 : + channel_enable_bits =AUDIO_2CH_SEL_DP_ENC0_P0_MASK | +AUDIO_2CH_EN_DP_ENC0_P0_MASK ; +break ; +case 8 : +default : + channel_enable_bits =AUDIO_8CH_SEL_DP_ENC0_P0_MASK | +AUDIO_8CH_EN_DP_ENC0_P0_MASK ; +break ; + } +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3088 , + channel_enable_bits |AU_EN_DP_ENC0_P0_MASK , +AUDIO_2CH_SEL_DP_ENC0_P0_MASK | +AUDIO_2CH_EN_DP_ENC0_P0_MASK | +AUDIO_8CH_SEL_DP_ENC0_P0_MASK | +AUDIO_8CH_EN_DP_ENC0_P0_MASK | +AU_EN_DP_ENC0_P0_MASK ); + +/* audio channel count change reset */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_33F4 ,0 ,BIT (9 )); + +/* enable audio reset */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_33F4 ,BIT (0 ),BIT (0 )); +} + +static void mtk_dp_audio_channel_status_set (struct mtk_dp *mtk_dp, +struct mtk_dp_audio_cfg *cfg) +{ +struct snd_aes_iec958 iec = {0 }; + +switch (cfg->sample_rate) { +case 32000 : + iec.status[3 ] =IEC958_AES3_CON_FS_32000 ; +break ; +case 44100 : + iec.status[3 ] =IEC958_AES3_CON_FS_44100 ; +break ; +case 48000 : + iec.status[3 ] =IEC958_AES3_CON_FS_48000 ; +break ; +case 88200 : + iec.status[3 ] =IEC958_AES3_CON_FS_88200 ; +break ; +case 96000 : + iec.status[3 ] =IEC958_AES3_CON_FS_96000 ; +break ; +case 192000 : + iec.status[3 ] =IEC958_AES3_CON_FS_192000 ; +break ; +default : + iec.status[3 ] =IEC958_AES3_CON_FS_NOTID ; +break ; + } + +switch (cfg->word_length_bits) { +case 16 : + iec.status[4 ] =IEC958_AES4_CON_WORDLEN_20_16 ; +break ; +case 20 : + iec.status[4 ] =IEC958_AES4_CON_WORDLEN_20_16 | +IEC958_AES4_CON_MAX_WORDLEN_24 ; +break ; +case 24 : + iec.status[4 ] =IEC958_AES4_CON_WORDLEN_24_20 | +IEC958_AES4_CON_MAX_WORDLEN_24 ; +break ; +default : + iec.status[4 ] =IEC958_AES4_CON_WORDLEN_NOTID ; + } + +/* IEC 60958 consumer channel status bits */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_308C , +0 ,CH_STATUS_0_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3090 , + iec.status[3 ] <<8 ,CH_STATUS_1_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3094 , + iec.status[4 ],CH_STATUS_2_DP_ENC0_P0_MASK ); +} + +static void mtk_dp_audio_sdp_asp_set_channels (struct mtk_dp *mtk_dp, +int channels) +{ +if (channels !=2 && channels !=8 ) + channels =8 ; + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_312C , + (channels -1 ) <<ASP_HB3_DP_ENC0_P0_SHIFT , +ASP_HB2_DP_ENC0_P0_MASK |ASP_HB3_DP_ENC0_P0_MASK ); +} + +static void mtk_dp_audio_set_divider (struct mtk_dp *mtk_dp) +{ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30BC , +AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_2 , +AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_MASK ); +} +static bool mtk_dp_plug_state (struct mtk_dp *mtk_dp) { return !!(mtk_dp_read(mtk_dp, MTK_DP_TRANS_P0_3414) &
@@ -385,6 +552,169 @@ static bool mtk_dp_plug_state_avoid_pulse(struct mtk_dp *mtk_dp) 4000, 7 * 4000)); } +static void mtk_dp_sdp_trigger_packet (struct mtk_dp *mtk_dp, +enum mtk_dp_sdp_type type) +{ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , + type,SDP_PACKET_TYPE_DP_ENC1_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , +SDP_PACKET_W_DP_ENC1_P0 ,SDP_PACKET_W_DP_ENC1_P0 ); +} + +static void mtk_dp_sdp_set_data (struct mtk_dp *mtk_dp,u8 *data_bytes) +{ +mtk_dp_bulk_16bit_write (mtk_dp,MTK_DP_ENC1_P0_3200 , + data_bytes,0x10 ); +} + +static void mtk_dp_sdp_set_header (struct mtk_dp *mtk_dp, +enum mtk_dp_sdp_type type, +struct dp_sdp_header *header) +{ +u32 db_addr; + +switch (type) { +case MTK_DP_SDP_DRM : + db_addr =MTK_DP_ENC0_P0_3138 ; +break ; +case MTK_DP_SDP_PPS0 : +case MTK_DP_SDP_PPS1 : +case MTK_DP_SDP_PPS2 : +case MTK_DP_SDP_PPS3 : + db_addr =MTK_DP_ENC0_P0_3130 ; +break ; +default : + db_addr =MTK_DP_ENC0_P0_30D8 + (type -MTK_DP_SDP_ACM ) *8 ; +break ; + } + +mtk_dp_bulk_16bit_write (mtk_dp, db_addr, (u8 *)header,4 ); +} + +static const u32 sdp_type_to_reg[MTK_DP_SDP_MAX_NUM ] = { + [MTK_DP_SDP_NONE ] =0x0 , + [MTK_DP_SDP_ACM ] =MTK_DP_ENC0_P0_30B4 , + [MTK_DP_SDP_ISRC ] =MTK_DP_ENC0_P0_30B4 +1 , + [MTK_DP_SDP_AVI ] =MTK_DP_ENC0_P0_30A4 +1 , + [MTK_DP_SDP_AUI ] =MTK_DP_ENC0_P0_30A8 , + [MTK_DP_SDP_SPD ] =MTK_DP_ENC0_P0_30A8 +1 , + [MTK_DP_SDP_MPEG ] =MTK_DP_ENC0_P0_30AC , + [MTK_DP_SDP_NTSC ] =MTK_DP_ENC0_P0_30AC +1 , + [MTK_DP_SDP_VSP ] =MTK_DP_ENC0_P0_30B0 , + [MTK_DP_SDP_VSC ] =MTK_DP_ENC0_P0_30B8 , + [MTK_DP_SDP_EXT ] =MTK_DP_ENC0_P0_30B0 +1 , + [MTK_DP_SDP_PPS0 ] =MTK_DP_ENC0_P0_31E8 , + [MTK_DP_SDP_PPS1 ] =MTK_DP_ENC0_P0_31E8 , + [MTK_DP_SDP_PPS2 ] =MTK_DP_ENC0_P0_31E8 , + [MTK_DP_SDP_PPS3 ] =MTK_DP_ENC0_P0_31E8 , + [MTK_DP_SDP_DRM ] =MTK_DP_ENC0_P0_31DC , +}; + +static void mtk_dp_disable_sdp (struct mtk_dp *mtk_dp,enum mtk_dp_sdp_type type) +{ +if (type ==MTK_DP_SDP_NONE ) +return ; + +/* Disable periodic send */ +mtk_dp_update_bits (mtk_dp, sdp_type_to_reg[type] &0xfffc ,0 , +0xFF << ((sdp_type_to_reg[type] &3 ) *8 )); +} + +static void mtk_dp_setup_sdp (struct mtk_dp *mtk_dp, +struct mtk_dp_sdp_packet *packet) +{ +u32 reg, shift; + +mtk_dp_sdp_set_data (mtk_dp, packet->sdp.db); +mtk_dp_sdp_set_header (mtk_dp, packet->type, &packet->sdp.sdp_header); + +mtk_dp_disable_sdp (mtk_dp, packet->type); + +switch (packet->type) { +case MTK_DP_SDP_ISRC : +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_31EC , +0x1C <<ISRC1_HB3_DP_ENC0_P0_SHIFT , +ISRC1_HB3_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , +MTK_DP_SDP_ISRC , +SDP_PACKET_TYPE_DP_ENC1_P0_MASK ); + +if (packet->sdp.sdp_header.HB3 &BIT (2 )) +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30BC , +BIT (ISRC_CONT_DP_ENC0_P0_SHIFT ), +ISRC_CONT_DP_ENC0_P0_MASK ); +else +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30BC , +0 ,ISRC_CONT_DP_ENC0_P0_MASK ); + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , +SDP_PACKET_W_DP_ENC1_P0 , +SDP_PACKET_W_DP_ENC1_P0 ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30B4 , +5 <<ISRC_CFG_DP_ENC0_P0_SHIFT , +ISRC_CFG_DP_ENC0_P0_MASK ); +break ; +case MTK_DP_SDP_DRM : +mtk_dp_sdp_trigger_packet (mtk_dp, packet->type); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_31DC , +5 <<HDR0_CFG_DP_ENC0_P0_SHIFT , +HDR0_CFG_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_31EC , +0x1C <<ISRC1_HB3_DP_ENC0_P0_SHIFT , +ISRC1_HB3_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , +MTK_DP_SDP_ISRC , +SDP_PACKET_TYPE_DP_ENC1_P0_MASK ); + +if (packet->sdp.sdp_header.HB3 &BIT (2 )) +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30BC , +BIT (ISRC_CONT_DP_ENC0_P0_SHIFT ), +ISRC_CONT_DP_ENC0_P0_MASK ); +else +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30BC , +0 ,ISRC_CONT_DP_ENC0_P0_MASK ); + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3280 , +SDP_PACKET_W_DP_ENC1_P0 , +SDP_PACKET_W_DP_ENC1_P0 ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30B4 , +5 <<ISRC_CFG_DP_ENC0_P0_SHIFT , +ISRC_CFG_DP_ENC0_P0_MASK ); +break ; +case MTK_DP_SDP_ACM : +case MTK_DP_SDP_AVI : +case MTK_DP_SDP_AUI : +case MTK_DP_SDP_SPD : +case MTK_DP_SDP_MPEG : +case MTK_DP_SDP_NTSC : +case MTK_DP_SDP_VSP : +case MTK_DP_SDP_VSC : +case MTK_DP_SDP_EXT : +case MTK_DP_SDP_PPS0 : +case MTK_DP_SDP_PPS1 : +case MTK_DP_SDP_PPS2 : +case MTK_DP_SDP_PPS3 : + reg = sdp_type_to_reg[packet->type]; + shift = (reg &3 ) *8 ; + +mtk_dp_sdp_trigger_packet (mtk_dp, packet->type); +/* Enable periodic sending */ +mtk_dp_update_bits (mtk_dp, reg &0xfffc , +0x05 << shift,0xff << shift); +break ; +case MTK_DP_SDP_NONE : +default : +break ; + } +} + +static void mtk_dp_sdp_vsc_ext_disable (struct mtk_dp *mtk_dp) +{ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30A0 , +0 ,BIT (7 ) |BIT (8 ) |BIT (12 )); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_328C ,0 ,BIT (7 )); +} +static void mtk_dp_aux_irq_clear (struct mtk_dp *mtk_dp) { mtk_dp_write(mtk_dp, MTK_DP_AUX_P0_3640,
@@ -1010,6 +1340,32 @@ static void mtk_dp_video_mute(struct mtk_dp *mtk_dp, bool enable) MTK_DP_SIP_ATF_VIDEO_UNMUTE, enable); } +static void mtk_dp_audio_mute (struct mtk_dp *mtk_dp,bool mute) +{ +u32 val[3 ]; + +if (mute) { + val[0 ] =BIT (VBID_AUDIO_MUTE_SW_DP_ENC0_P0_SHIFT ) | +BIT (VBID_AUDIO_MUTE_SEL_DP_ENC0_P0_SHIFT ); + val[1 ] =0 ; + val[2 ] =0 ; + }else { + val[0 ] =0 ; + val[1 ] =BIT (AU_EN_DP_ENC0_P0_SHIFT ); +/* Send one every two frames */ + val[2 ] =0x0F ; + } + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3030 , + val[0 ], +VBID_AUDIO_MUTE_FLAG_SW_DP_ENC0_P0_MASK | +VBID_AUDIO_MUTE_FLAG_SEL_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3088 , + val[1 ],AU_EN_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_30A4 , + val[2 ],AU_TS_CFG_DP_ENC0_P0_MASK ); +} +static void mtk_dp_power_enable (struct mtk_dp *mtk_dp) { mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_RESET_AND_PROBE,
@@ -1052,6 +1408,80 @@ static void mtk_dp_initialize_priv_data(struct mtk_dp *mtk_dp) mtk_dp->info.format =DP_PIXELFORMAT_RGB ; mtk_dp->info.depth =DP_MSA_MISC_8_BPC ;memset (&mtk_dp->info.timings,0 ,sizeof (struct mtk_dp_timings )); + mtk_dp->info.timings.frame_rate =60 ; + + mtk_dp->audio_enable = false; +} + +static void mtk_dp_sdp_set_down_cnt_init (struct mtk_dp *mtk_dp, +u32 sram_read_start) +{ +u32 sdp_down_cnt_init =0 ; +struct drm_display_mode mode; +struct mtk_dp_timings *timings = &mtk_dp->info.timings; + +drm_display_mode_from_videomode (&timings->vm, &mode); + +if (mtk_dp->info.timings.pix_rate_khz >0 ) + sdp_down_cnt_init = sram_read_start * + mtk_dp->train_info.link_rate *2700 *8 / + (timings->pix_rate_khz *4 ); + +switch (mtk_dp->train_info.lane_count) { +case 1 : + sdp_down_cnt_init =max_t (u32, sdp_down_cnt_init,0x1A ); +break ; +case 2 : +/* case for LowResolution && High Audio Sample Rate */ + sdp_down_cnt_init =max_t (u32, sdp_down_cnt_init,0x10 ); + sdp_down_cnt_init += mode.vtotal <=525 ?4 :0 ; +break ; +case 4 : +default : + sdp_down_cnt_init =max_t (u32, sdp_down_cnt_init,6 ); +break ; + } + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3040 , + sdp_down_cnt_init + <<SDP_DOWN_CNT_INIT_DP_ENC0_P0_SHIFT , +SDP_DOWN_CNT_INIT_DP_ENC0_P0_MASK ); +} + +static void mtk_dp_sdp_set_down_cnt_init_in_hblank (struct mtk_dp *mtk_dp) +{ +int pix_clk_mhz; +u32 dc_offset; +u32 spd_down_cnt_init =0 ; +struct drm_display_mode mode; +struct mtk_dp_timings *timings = &mtk_dp->info.timings; + +drm_display_mode_from_videomode (&timings->vm, &mode); + + pix_clk_mhz = mtk_dp->info.format ==DP_PIXELFORMAT_YUV420 ? + mtk_dp->info.timings.pix_rate_khz /2000 : + mtk_dp->info.timings.pix_rate_khz /1000 ; + +switch (mtk_dp->train_info.lane_count) { +case 1 : + spd_down_cnt_init =0x20 ; +break ; +case 2 : + dc_offset = (mode.vtotal <=525 ) ?0x14 :0x00 ; + spd_down_cnt_init =0x18 + dc_offset; +break ; +case 4 : +default : + dc_offset = (mode.vtotal <=525 ) ?0x08 :0x00 ; +if (pix_clk_mhz > mtk_dp->train_info.link_rate *27 ) + spd_down_cnt_init =0x8 ; +else + spd_down_cnt_init =0x10 + dc_offset; +break ; + } + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC1_P0_3364 , spd_down_cnt_init, +SDP_DOWN_CNT_INIT_IN_HBLANK_DP_ENC1_P0_MASK ); }static void mtk_dp_setup_tu (struct mtk_dp *mtk_dp)
@@ -1063,13 +1493,44 @@ static void mtk_dp_setup_tu(struct mtk_dp *mtk_dp) MTK_DP_PIX_PER_ADDR);mtk_dp_set_sram_read_start (mtk_dp, sram_read_start);mtk_dp_setup_encoder (mtk_dp); +mtk_dp_sdp_set_down_cnt_init_in_hblank (mtk_dp); +mtk_dp_sdp_set_down_cnt_init (mtk_dp, sram_read_start); +} + +static void mtk_dp_calculate_pixrate (struct mtk_dp *mtk_dp) +{ +u32 target_pixel_clk; +struct drm_display_mode mode; +struct mtk_dp_timings *timings = &mtk_dp->info.timings; + +drm_display_mode_from_videomode (&timings->vm, &mode); + +if (mtk_dp->info.timings.frame_rate >0 ) { + target_pixel_clk = mode.htotal * mode.vtotal * + mtk_dp->info.timings.frame_rate; + }else if (mtk_dp->info.timings.pix_rate_khz >0 ) { + target_pixel_clk = mtk_dp->info.timings.pix_rate_khz *1000 ; + }else { + target_pixel_clk = mode.htotal * mode.vtotal *60 ; + } + + mtk_dp->info.timings.pix_rate_khz = target_pixel_clk /1000 ; }static void mtk_dp_set_tx_out (struct mtk_dp *mtk_dp) { +mtk_dp_calculate_pixrate (mtk_dp);mtk_dp_setup_tu (mtk_dp); } +static void mtk_dp_edid_free (struct mtk_dp *mtk_dp) +{ +mutex_lock (&mtk_dp->edid_lock); +kfree (mtk_dp->edid); + mtk_dp->edid =NULL ; +mutex_unlock (&mtk_dp->edid_lock); +} +static void mtk_dp_hpd_sink_event (struct mtk_dp *mtk_dp) {ssize_t ret;
@@ -1104,6 +1565,17 @@ static void mtk_dp_hpd_sink_event(struct mtk_dp *mtk_dp) DP_REMOTE_CONTROL_COMMAND_PENDING); } +static void mtk_dp_sdp_stop_sending (struct mtk_dp *mtk_dp) +{ +u8 packet_type; + +for (packet_type =MTK_DP_SDP_ACM ; packet_type <MTK_DP_SDP_MAX_NUM ; + packet_type++) +mtk_dp_disable_sdp (mtk_dp, packet_type); + +mtk_dp_sdp_vsc_ext_disable (mtk_dp); +} +static void mtk_dp_train_update_swing_pre (struct mtk_dp *mtk_dp,int lanes,u8 dpcd_adjust_req[2 ]) {
@@ -1382,6 +1854,55 @@ static int mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp)return 0 ; } +static bool mtk_dp_edid_parse_audio_capabilities (struct mtk_dp *mtk_dp, +struct mtk_dp_audio_cfg *cfg) +{ +struct cea_sad *sads; +int sad_count; +int i; +bool ret = false; + +if (mtk_dp_is_edp (mtk_dp)) +return false; + +mutex_lock (&mtk_dp->edid_lock); +if (!mtk_dp->edid) { +mutex_unlock (&mtk_dp->edid_lock); +dev_err (mtk_dp->dev,"EDID not found!\n" ); +return false; + } + sad_count =drm_edid_to_sad (mtk_dp->edid, &sads); +mutex_unlock (&mtk_dp->edid_lock); + +if (sad_count <=0 ) { +drm_info (mtk_dp->drm_dev,"The SADs is NULL\n" ); +return false; + } + +for (i =0 ; i < sad_count; i++) { +int sample_rate, word_length; + +/* Only PCM supported at the moment */ +if (sads[i].format !=HDMI_AUDIO_CODING_TYPE_PCM ) +continue ; + + sample_rate =drm_cea_sad_get_sample_rate (&sads[i]); + word_length = +drm_cea_sad_get_uncompressed_word_length (&sads[i]); +if (sample_rate <=0 || word_length <=0 ) +continue ; + + cfg->channels = sads[i].channels; + cfg->word_length_bits = word_length; + cfg->sample_rate = sample_rate; + ret = true; +break ; + } +kfree (sads); + +return ret; +} +static void mtk_dp_train_change_mode (struct mtk_dp *mtk_dp) {phy_reset (mtk_dp->phy);
@@ -1479,6 +2000,47 @@ static void mtk_dp_video_enable(struct mtk_dp *mtk_dp, bool enable) } } +static void mtk_dp_audio_sdp_setup (struct mtk_dp *mtk_dp, +struct mtk_dp_audio_cfg *cfg) +{ +struct mtk_dp_sdp_packet packet; +struct hdmi_audio_infoframe frame; + +hdmi_audio_infoframe_init (&frame); + frame.coding_type =HDMI_AUDIO_CODING_TYPE_PCM ; + frame.channels = cfg->channels; + frame.sample_frequency = cfg->sample_rate; + +switch (cfg->word_length_bits) { +case 16 : + frame.sample_size =HDMI_AUDIO_SAMPLE_SIZE_16 ; +break ; +case 20 : + frame.sample_size =HDMI_AUDIO_SAMPLE_SIZE_20 ; +break ; +case 24 : +default : + frame.sample_size =HDMI_AUDIO_SAMPLE_SIZE_24 ; +break ; + } + + packet.type =MTK_DP_SDP_AUI ; +hdmi_audio_infoframe_pack_for_dp (&frame, &packet.sdp,MTK_DP_VERSION ); + +mtk_dp_audio_sdp_asp_set_channels (mtk_dp, cfg->channels); +mtk_dp_setup_sdp (mtk_dp, &packet); +} + +static void mtk_dp_audio_setup (struct mtk_dp *mtk_dp, +struct mtk_dp_audio_cfg *cfg) +{ +mtk_dp_audio_sdp_setup (mtk_dp, cfg); +mtk_dp_audio_channel_status_set (mtk_dp, cfg); + +mtk_dp_audio_setup_channels (mtk_dp, cfg); +mtk_dp_audio_set_divider (mtk_dp); +} +static int mtk_dp_video_config (struct mtk_dp *mtk_dp) {int ret;
@@ -1517,6 +2079,17 @@ static int mtk_dp_training(struct mtk_dp *mtk_dp)return ret;mtk_dp_video_enable (mtk_dp, true); + mtk_dp->audio_enable = +mtk_dp_edid_parse_audio_capabilities (mtk_dp, + &mtk_dp->info.audio_caps); +if (mtk_dp->audio_enable) { +mtk_dp_audio_setup (mtk_dp, &mtk_dp->info.audio_caps); +mtk_dp_audio_mute (mtk_dp, false); + }else { +memset (&mtk_dp->info.audio_caps,0 , +sizeof (mtk_dp->info.audio_caps)); + } +return 0 ; }
@@ -1565,10 +2138,13 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev)if (!mtk_dp->train_info.cable_plugged_in) {mtk_dp_video_mute (mtk_dp, true); +mtk_dp_audio_mute (mtk_dp, true);mtk_dp_initialize_priv_data (mtk_dp);mtk_dp_set_idle_pattern (mtk_dp, true); +mtk_dp_sdp_stop_sending (mtk_dp); +mtk_dp_edid_free (mtk_dp);mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE ,DP_PWR_STATE_BANDGAP_TPLL ,DP_PWR_STATE_MASK );
@@ -1684,6 +2260,18 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,return 0 ; } +static void mtk_dp_update_plugged_status (struct mtk_dp *mtk_dp) +{ +bool connected, has_audio; + +mutex_lock (&mtk_dp->update_plugged_status_lock); + connected =mtk_dp_plug_state_avoid_pulse (mtk_dp); + has_audio =drm_detect_monitor_audio (mtk_dp->edid); +if (mtk_dp->plugged_cb && mtk_dp->codec_dev) + mtk_dp->plugged_cb (mtk_dp->codec_dev, connected & has_audio); +mutex_unlock (&mtk_dp->update_plugged_status_lock); +} +static enum drm_connector_status mtk_dp_bdg_detect (struct drm_bridge *bridge) {struct mtk_dp *mtk_dp =mtk_dp_from_bridge (bridge);
@@ -1699,6 +2287,7 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge) ret = connector_status_connected; } +mtk_dp_update_plugged_status (mtk_dp);return ret; }
@@ -1721,6 +2310,18 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge,if (!enabled)drm_bridge_chain_post_disable (bridge); +mutex_lock (&mtk_dp->edid_lock); +kfree (mtk_dp->edid); + mtk_dp->edid =NULL ; + +if (!new_edid) { +mutex_unlock (&mtk_dp->edid_lock); +return NULL ; + } + + mtk_dp->edid =drm_edid_duplicate (new_edid); +mutex_unlock (&mtk_dp->edid_lock); +return new_edid; }
@@ -1893,6 +2494,7 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge, }mtk_dp_video_mute (mtk_dp, true); +mtk_dp_audio_mute (mtk_dp, true); mtk_dp->enabled = false;/* Ensure the sink is muted */
@@ -1905,6 +2507,7 @@ static void mtk_dp_parse_drm_mode_timings(struct mtk_dp *mtk_dp,struct mtk_dp_timings *timings = &mtk_dp->info.timings;drm_display_mode_to_videomode (mode, &timings->vm); + timings->frame_rate =drm_mode_vrefresh (mode); } static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge,
@@ -1922,6 +2525,8 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge, }mtk_dp_video_mute (mtk_dp, true); +mtk_dp_audio_mute (mtk_dp, true); +mtk_dp_sdp_stop_sending (mtk_dp);if (mtk_dp_parse_capabilities (mtk_dp)) {drm_err (mtk_dp->drm_dev,"Can't parse capabilities\n" );
@@ -1935,7 +2540,13 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge,return ; } +mutex_lock (&mtk_dp->eld_lock); +memcpy (mtk_dp->connector_eld, mtk_dp->conn->eld,MAX_ELD_BYTES ); +mutex_unlock (&mtk_dp->eld_lock); + mtk_dp->enabled = true; + +mtk_dp_update_plugged_status (mtk_dp); } static enum drm_mode_status
@@ -2082,6 +2693,104 @@ static void mtk_dp_debounce_timer(struct timer_list *t) mtk_dp->need_debounce = true; } +/* +* HDMI audio codec callbacks +*/ +static int mtk_dp_audio_hw_params (struct device *dev,void *data, +struct hdmi_codec_daifmt *daifmt, +struct hdmi_codec_params *params) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); +struct mtk_dp_audio_cfg cfg; + +if (!mtk_dp->enabled) { +pr_err ("%s, DP is not ready!\n" , __func__); +return -ENODEV ; + } + + cfg.channels = params->cea.channels; + cfg.sample_rate = params->sample_rate; + cfg.word_length_bits =24 ; + +mtk_dp_audio_setup (mtk_dp, &cfg); + +return 0 ; +} + +static int mtk_dp_audio_startup (struct device *dev,void *data) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); + +mtk_dp_audio_mute (mtk_dp, false); + +return 0 ; +} + +static void mtk_dp_audio_shutdown (struct device *dev,void *data) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); + +mtk_dp_audio_mute (mtk_dp, true); +} + +static int mtk_dp_audio_get_eld (struct device *dev,void *data,uint8_t *buf, +size_t len) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); + +if (mtk_dp->enabled) +memcpy (buf, mtk_dp->connector_eld, len); +else +memset (buf,0 , len); + +return 0 ; +} + +static int mtk_dp_audio_hook_plugged_cb (struct device *dev,void *data, +hdmi_codec_plugged_cb fn, +struct device *codec_dev) +{ +struct mtk_dp *mtk_dp = data; + +mutex_lock (&mtk_dp->update_plugged_status_lock); + mtk_dp->plugged_cb = fn; + mtk_dp->codec_dev = codec_dev; +mutex_unlock (&mtk_dp->update_plugged_status_lock); + +mtk_dp_update_plugged_status (mtk_dp); + +return 0 ; +} + +static const struct hdmi_codec_ops mtk_dp_audio_codec_ops = { + .hw_params = mtk_dp_audio_hw_params, + .audio_startup = mtk_dp_audio_startup, + .audio_shutdown = mtk_dp_audio_shutdown, + .get_eld = mtk_dp_audio_get_eld, + .hook_plugged_cb = mtk_dp_audio_hook_plugged_cb, + .no_capture_mute =1 , +}; + +static int mtk_dp_register_audio_driver (struct device *dev) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); +struct hdmi_codec_pdata codec_data = { + .ops = &mtk_dp_audio_codec_ops, + .max_i2s_channels =8 , + .i2s =1 , + .data = mtk_dp, + }; +struct platform_device *pdev; + + pdev =platform_device_register_data (dev,HDMI_CODEC_DRV_NAME , +PLATFORM_DEVID_AUTO , &codec_data, +sizeof (codec_data)); +if (IS_ERR (pdev)) +return PTR_ERR (pdev); + +return 0 ; +} +static int mtk_dp_probe (struct platform_device *pdev) {struct mtk_dp *mtk_dp;
@@ -2127,8 +2836,21 @@ static int mtk_dp_probe(struct platform_device *pdev)return dev_err_probe (dev, -EPROBE_DEFER ,"failed to request mediatek dptx irq\n" ); +mutex_init (&mtk_dp->edid_lock); +mutex_init (&mtk_dp->eld_lock); +mutex_init (&mtk_dp->update_plugged_status_lock); +platform_set_drvdata (pdev, mtk_dp); +if (!mtk_dp_is_edp (mtk_dp)) { + ret =mtk_dp_register_audio_driver (dev); +if (ret) { +dev_err (dev,"Failed to register audio driver: %d\n" , + ret); +return ret; + } + } + mtk_dp->phy_dev = platform_device_register_data(dev, "mediatek-dp-phy", PLATFORM_DEVID_AUTO, &mtk_dp->regs,
@@ -2174,6 +2896,7 @@ static int mtk_dp_remove(struct platform_device *pdev)platform_device_unregister (mtk_dp->phy_dev);mtk_dp_video_mute (mtk_dp, true); +mtk_dp_audio_mute (mtk_dp, true);del_timer_sync (&mtk_dp->debounce_timer);pm_runtime_disable (&pdev->dev);
drivers/gpu/drm/mediatek/mtk_dp_reg.h +2 -0
@@ -240,6 +240,8 @@#define ASP_HB3_DP_ENC0_P0_MASK GENMASK(15, 8)#define ASP_HB3_DP_ENC0_P0_SHIFT BIT(3) +#define MTK_DP_ENC0_P0_3130 (ENC0_OFFSET + 0x130) +#define MTK_DP_ENC0_P0_3138 (ENC0_OFFSET + 0x138)#define MTK_DP_ENC0_P0_3154 (ENC0_OFFSET + 0x154)#define PGEN_HTOTAL_DP_ENC0_P0_MASK GENMASK(13, 0)#define MTK_DP_ENC0_P0_3158 (ENC0_OFFSET + 0x158)
Signature · 1 line
2.18.0
PATCH v14 6/10 drm/mediatek: Add MT8195 External DisplayPort support
In reply to Bo-Chen ChenFrom: Guillaume Ranquet <[email protected]>
This patch adds External DisplayPort support to the mt8195 eDP driver.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 183 +++++++++++++++++++++----- drivers/gpu/drm/mediatek/mtk_dp_reg.h | 1 + 2 files changed, 148 insertions(+), 36 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +147 -36
@@ -115,6 +115,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);
@@ -370,6 +375,14 @@ static bool mtk_dp_plug_state(struct mtk_dp *mtk_dp) HPD_DB_DP_TRANS_P0_MASK); } +static bool mtk_dp_plug_state_avoid_pulse (struct mtk_dp *mtk_dp) +{ +bool ret; + +return !(readx_poll_timeout (mtk_dp_plug_state, mtk_dp, ret, ret, +4000 ,7 *4000 )); +} +static void mtk_dp_aux_irq_clear (struct mtk_dp *mtk_dp) { mtk_dp_write(mtk_dp, MTK_DP_AUX_P0_3640,
@@ -809,35 +822,67 @@ static void mtk_dp_get_calibration_data(struct mtk_dp *mtk_dp)return ; } - cal_data->glb_bias_trim = -check_cal_data_valid (mtk_dp,1 ,0x1e , - (buf[3 ] >>27 ) &0x1f ,0xf ); - cal_data->clktx_impse = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[0 ] >>9 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_pmos[0 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>28 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_nmos[0 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>24 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_pmos[1 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>20 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_nmos[1 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>16 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_pmos[2 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>12 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_nmos[2 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>8 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_pmos[3 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , - (buf[2 ] >>4 ) &0xf ,0x8 ); - cal_data->ln_tx_impsel_nmos[3 ] = -check_cal_data_valid (mtk_dp,1 ,0xe , buf[2 ] &0xf ,0x8 ); +if (mtk_dp_is_edp (mtk_dp)) { + cal_data->glb_bias_trim = +check_cal_data_valid (mtk_dp,1 ,0x1e , + (buf[3 ] >>27 ) &0x1f ,0xf ); + cal_data->clktx_impse = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[0 ] >>9 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[0 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>28 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[0 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>24 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[1 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>20 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[1 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>16 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[2 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>12 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[2 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>8 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[3 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[2 ] >>4 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[3 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , buf[2 ] &0xf ,0x8 ); + }else { + cal_data->glb_bias_trim = +check_cal_data_valid (mtk_dp,1 ,0x1e , + (buf[0 ] >>27 ) &0x1f ,0xf ); + cal_data->clktx_impse = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[0 ] >>13 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[0 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>28 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[0 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>24 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[1 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>20 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[1 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>16 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[2 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>12 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[2 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>8 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_pmos[3 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , + (buf[1 ] >>4 ) &0xf ,0x8 ); + cal_data->ln_tx_impsel_nmos[3 ] = +check_cal_data_valid (mtk_dp,1 ,0xe , buf[1 ] &0xf ,0x8 ); + }kfree (buf); }
@@ -957,7 +1002,10 @@ static void mtk_dp_video_mute(struct mtk_dp *mtk_dp, bool enable)VIDEO_MUTE_SEL_DP_ENC0_P0_MASK | VIDEO_MUTE_SW_DP_ENC0_P0_MASK); -mtk_dp_sip_atf_call (mtk_dp,MTK_DP_SIP_ATF_EDP_VIDEO_UNMUTE , enable); +mtk_dp_sip_atf_call (mtk_dp, +mtk_dp_is_edp (mtk_dp) ? +MTK_DP_SIP_ATF_EDP_VIDEO_UNMUTE : +MTK_DP_SIP_ATF_VIDEO_UNMUTE , enable); }static void mtk_dp_power_enable (struct mtk_dp *mtk_dp)
@@ -1292,6 +1340,9 @@ static int mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp)drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D0 );usleep_range (2000 ,5000 ); +if (!mtk_dp_plug_state (mtk_dp)) +return -ENODEV ; +drm_dp_read_dpcd_caps (&mtk_dp->aux, mtk_dp->rx_cap); train_info->link_rate = min_t(int, mtk_dp->max_linkrate,
@@ -1343,6 +1394,9 @@ static int mtk_dp_train_start(struct mtk_dp *mtk_dp)u8 train_limit;u8 max_link_rate; +if (!mtk_dp_plug_state_avoid_pulse (mtk_dp)) +return -ENODEV ; + link_rate = mtk_dp->rx_cap[1 ]; lane_count = mtk_dp->rx_cap[2 ] &0x1F ;
@@ -1489,13 +1543,34 @@ static int mtk_dp_init_port(struct mtk_dp *mtk_dp)static irqreturn_t mtk_dp_hpd_event_thread (int hpd,void *dev) {struct mtk_dp *mtk_dp = dev; +int event; + + event =mtk_dp_plug_state (mtk_dp) ? + connector_status_connected : connector_status_disconnected; + +if (event <0 ) +return IRQ_HANDLED ; + +dev_dbg (mtk_dp->dev,"drm_helper_hpd_irq_event\n" ); +drm_helper_hpd_irq_event (mtk_dp->bridge.dev);if (mtk_dp->train_info.cable_state_change) { mtk_dp->train_info.cable_state_change = false; -mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , -DP_PWR_STATE_BANDGAP_TPLL_LANE , -DP_PWR_STATE_MASK ); +if (!mtk_dp->train_info.cable_plugged_in) { +mtk_dp_video_mute (mtk_dp, true); + +mtk_dp_initialize_priv_data (mtk_dp); +mtk_dp_set_idle_pattern (mtk_dp, true); + +mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , +DP_PWR_STATE_BANDGAP_TPLL , +DP_PWR_STATE_MASK ); + }else { +mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , +DP_PWR_STATE_BANDGAP_TPLL_LANE , +DP_PWR_STATE_MASK ); + } }if (mtk_dp->train_info.irq_sta.hpd_inerrupt) {
@@ -1597,6 +1672,24 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,return 0 ; } +static enum drm_connector_status mtk_dp_bdg_detect (struct drm_bridge *bridge) +{ +struct mtk_dp *mtk_dp =mtk_dp_from_bridge (bridge); +enum drm_connector_status ret = connector_status_disconnected; +u8 sink_count =0 ; + +if (mtk_dp_is_edp (mtk_dp)) +return connector_status_connected; + +if (mtk_dp_plug_state_avoid_pulse (mtk_dp)) { +drm_dp_dpcd_readb (&mtk_dp->aux,DP_SINK_COUNT , &sink_count); +if (DP_GET_SINK_COUNT (sink_count)) + ret = connector_status_connected; + } + +return ret; +} +static struct edid *mtk_dp_get_edid (struct drm_bridge *bridge,struct drm_connector *connector) {
@@ -1610,7 +1703,8 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge,drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D0 );usleep_range (2000 ,5000 ); - new_edid =drm_get_edid (connector, &mtk_dp->aux.ddc); +if (mtk_dp_plug_state (mtk_dp)) + new_edid =drm_get_edid (connector, &mtk_dp->aux.ddc);if (!enabled)drm_bridge_chain_post_disable (bridge);
@@ -1961,6 +2055,7 @@ static const struct drm_bridge_funcs mtk_dp_bridge_funcs = { .atomic_disable = mtk_dp_bridge_atomic_disable, .mode_valid = mtk_dp_bridge_mode_valid, .get_edid = mtk_dp_get_edid, + .detect = mtk_dp_bdg_detect, };static int mtk_dp_probe (struct platform_device *pdev)
@@ -1982,9 +2077,15 @@ static int mtk_dp_probe(struct platform_device *pdev) "failed to request dp irq resource\n"); mtk_dp->next_bridge =devm_drm_of_get_bridge (dev, dev->of_node,1 ,0 ); -if (IS_ERR (mtk_dp->next_bridge)) +if (IS_ERR (mtk_dp->next_bridge) && +PTR_ERR (mtk_dp->next_bridge) == -ENODEV ) { +dev_info (dev, +"No panel connected in devicetree, continue as external DP\n" ); + mtk_dp->next_bridge =NULL ; + }else if (IS_ERR (mtk_dp->next_bridge)) {return dev_err_probe (dev,PTR_ERR (mtk_dp->next_bridge),"Failed to get bridge\n" ); + } ret =mtk_dp_dt_parse (mtk_dp, pdev);if (ret)
@@ -2027,7 +2128,10 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp->bridge.ops =DRM_BRIDGE_OP_DETECT |DRM_BRIDGE_OP_EDID |DRM_BRIDGE_OP_HPD ; - mtk_dp->bridge.type = DRM_MODE_CONNECTOR_eDP; +if (mtk_dp_is_edp (mtk_dp)) + mtk_dp->bridge.type = DRM_MODE_CONNECTOR_eDP; +else + mtk_dp->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;drm_bridge_add (&mtk_dp->bridge);
@@ -2054,6 +2158,12 @@ static int mtk_dp_suspend(struct device *dev) {struct mtk_dp *mtk_dp =dev_get_drvdata (dev); +if (mtk_dp_plug_state (mtk_dp)) { +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D3 ); +/* Ensure the sink is off before shutting down power */ +usleep_range (2000 ,3000 ); + } +mtk_dp_power_disable (mtk_dp);mtk_dp_hwirq_enable (mtk_dp, false);
@@ -2087,6 +2197,7 @@ static SIMPLE_DEV_PM_OPS(mtk_dp_pm_ops, mtk_dp_suspend, mtk_dp_resume);static const struct of_device_id mtk_dp_of_match[] = { { .compatible ="mediatek,mt8195-edp-tx" }, + { .compatible ="mediatek,mt8195-dp-tx" }, {}, };MODULE_DEVICE_TABLE (of, mtk_dp_of_match);
drivers/gpu/drm/mediatek/mtk_dp_reg.h +1 -0
@@ -14,6 +14,7 @@#define SEC_OFFSET 0x4000#define MTK_DP_SIP_ATF_EDP_VIDEO_UNMUTE (BIT(0) | BIT(5)) +#define MTK_DP_SIP_ATF_VIDEO_UNMUTE BIT(5)#define DP_PHY_GLB_BIAS_GEN_00 0#define RG_XTP_GLB_BIAS_INTR_CTRL GENMASK(20, 16)
Signature · 1 line
2.18.0
PATCH v14 4/10 video/hdmi: Add audio_infoframe packing for DP
In reply to Bo-Chen ChenFrom: Markus Schneider-Pargmann <[email protected]>
Similar to HDMI, DP uses audio infoframes as well which are structured very similar to the HDMI ones.
This patch adds a helper function to pack the HDMI audio infoframe for DP, called hdmi_audio_infoframe_pack_for_dp(). hdmi_audio_infoframe_pack_only() is split into two parts. One of them packs the payload only and can be used for HDMI and DP.
Also constify the frame parameter in hdmi_audio_infoframe_check() as it is passed to hdmi_audio_infoframe_check_only() which expects a const.
--- drivers/video/hdmi.c | 82 +++++++++++++++++++++++++++--------- include/drm/display/drm_dp.h | 2 + include/linux/hdmi.h | 7 ++- 3 files changed, 71 insertions(+), 20 deletions(-)
drivers/video/hdmi.c +63 -19
@@ -21,6 +21,7 @@* DEALINGS IN THE SOFTWARE. */ +#include <drm/display/drm_dp.h> #include <linux/bitops.h> #include <linux/bug.h> #include <linux/errno.h>
@@ -381,12 +382,34 @@ static int hdmi_audio_infoframe_check_only(const struct hdmi_audio_infoframe *fr* * Returns 0 on success or a negative error code on failure. */ -int hdmi_audio_infoframe_check (struct hdmi_audio_infoframe *frame) +int hdmi_audio_infoframe_check (const struct hdmi_audio_infoframe *frame) {return hdmi_audio_infoframe_check_only (frame); }EXPORT_SYMBOL (hdmi_audio_infoframe_check); +static void +hdmi_audio_infoframe_pack_payload (const struct hdmi_audio_infoframe *frame, +u8 *buffer) +{ +u8 channels; + +if (frame->channels >=2 ) + channels = frame->channels -1 ; +else + channels =0 ; + + buffer[0 ] = ((frame->coding_type &0xf ) <<4 ) | (channels &0x7 ); + buffer[1 ] = ((frame->sample_frequency &0x7 ) <<2 ) | + (frame->sample_size &0x3 ); + buffer[2 ] = frame->coding_type_ext &0x1f ; + buffer[3 ] = frame->channel_allocation; + buffer[4 ] = (frame->level_shift_value &0xf ) <<3 ; + +if (frame->downmix_inhibit) + buffer[4 ] |=BIT (7 ); +} +/** * hdmi_audio_infoframe_pack_only() - write HDMI audio infoframe to binary buffer * @frame: HDMI audio infoframe
@@ -404,7 +427,6 @@ EXPORT_SYMBOL(hdmi_audio_infoframe_check);ssize_t hdmi_audio_infoframe_pack_only (const struct hdmi_audio_infoframe *frame,void *buffer,size_t size) { -unsigned char channels;u8 *ptr = buffer;size_t length;int ret;
@@ -420,28 +442,13 @@ ssize_t hdmi_audio_infoframe_pack_only(const struct hdmi_audio_infoframe *frame,memset (buffer,0 , size); -if (frame->channels >=2 ) - channels = frame->channels -1 ; -else - channels =0 ; - ptr[0 ] = frame->type; ptr[1 ] = frame->version; ptr[2 ] = frame->length; ptr[3 ] =0 ;/* checksum */ -/* start infoframe payload */ - ptr +=HDMI_INFOFRAME_HEADER_SIZE ; - - ptr[0 ] = ((frame->coding_type &0xf ) <<4 ) | (channels &0x7 ); - ptr[1 ] = ((frame->sample_frequency &0x7 ) <<2 ) | - (frame->sample_size &0x3 ); - ptr[2 ] = frame->coding_type_ext &0x1f ; - ptr[3 ] = frame->channel_allocation; - ptr[4 ] = (frame->level_shift_value &0xf ) <<3 ; - -if (frame->downmix_inhibit) - ptr[4 ] |=BIT (7 ); +hdmi_audio_infoframe_pack_payload (frame, + ptr +HDMI_INFOFRAME_HEADER_SIZE );hdmi_infoframe_set_checksum (buffer, length);
@@ -479,6 +486,43 @@ ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, }EXPORT_SYMBOL (hdmi_audio_infoframe_pack); +/** +* hdmi_audio_infoframe_pack_for_dp - Pack a HDMI Audio infoframe for DisplayPort +* +* @frame: HDMI Audio infoframe +* @sdp: secondary data packet for display port. This is filled with the +* appropriate: data +* @dp_version: Display Port version to be encoded in the header +* +* Packs a HDMI Audio Infoframe to be sent over Display Port. This function +* fills the secondary data packet to be used for Display Port. +* +* Return: Number of total written bytes or a negative errno on failure. +*/ +ssize_t +hdmi_audio_infoframe_pack_for_dp (const struct hdmi_audio_infoframe *frame, +struct dp_sdp *sdp,u8 dp_version) +{ +int ret; + + ret =hdmi_audio_infoframe_check (frame); +if (ret) +return ret; + +memset (sdp->db,0 ,sizeof (sdp->db)); + +/* Secondary-data packet header */ + sdp->sdp_header.HB0 =0 ; + sdp->sdp_header.HB1 = frame->type; + sdp->sdp_header.HB2 =DP_SDP_AUDIO_INFOFRAME_HB2 ; + sdp->sdp_header.HB3 = (dp_version &0x3f ) <<2 ; + +hdmi_audio_infoframe_pack_payload (frame, sdp->db); + +return frame->length +4 ; +} +EXPORT_SYMBOL (hdmi_audio_infoframe_pack_for_dp); +/** * hdmi_vendor_infoframe_init() - initialize an HDMI vendor infoframe * @frame: HDMI vendor infoframe
include/drm/display/drm_dp.h +2 -0
@@ -1536,6 +1536,8 @@ enum drm_dp_phy {#define DP_SDP_VSC_EXT_CEA 0x21/* DP 1.4 */ /* 0x80+ CEA-861 infoframe types */ +#define DP_SDP_AUDIO_INFOFRAME_HB2 0x1b +/** * struct dp_sdp_header - DP secondary data packet header * @HB0: Secondary Data Packet ID
include/linux/hdmi.h +6 -1
@@ -336,7 +336,12 @@ ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, void *buffer, size_t size);ssize_t hdmi_audio_infoframe_pack_only (const struct hdmi_audio_infoframe *frame,void *buffer,size_t size); -int hdmi_audio_infoframe_check (struct hdmi_audio_infoframe *frame); +int hdmi_audio_infoframe_check (const struct hdmi_audio_infoframe *frame); + +struct dp_sdp ; +ssize_t +hdmi_audio_infoframe_pack_for_dp (const struct hdmi_audio_infoframe *frame, +struct dp_sdp *sdp,u8 dp_version);enum hdmi_3d_structure {HDMI_3D_STRUCTURE_INVALID =-1 ,
Signature · 1 line
2.18.0
PATCH v14 5/10 drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenFrom: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that both can work with the same register range. The phy driver sets device data that is read by the parent to get the phy device that can be used to control the phy properties.
This driver is based on an initial version by
Jitao shi <[email protected]>
--- drivers/gpu/drm/mediatek/Kconfig | 9 + drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_dp.c | 2109 +++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_dp_reg.h | 542 +++++++ 4 files changed, 2662 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 +9 -0
@@ -21,6 +21,15 @@ config DRM_MEDIATEK This driver provides kernel mode setting and buffer management to userspace. +config DRM_MEDIATEK_DP + tristate "DRM DPTX Support for MediaTek SoCs" + depends on DRM_MEDIATEK + select PHY_MTK_DP + select DRM_DISPLAY_HELPER + select DRM_DISPLAY_DP_HELPER + help + DRM/KMS Display Port driver for MediaTek SoCs. + config DRM_MEDIATEK_HDMI tristate "DRM HDMI Support for Mediatek SoCs" depends on DRM_MEDIATEK
drivers/gpu/drm/mediatek/Makefile +2 -0
@@ -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_DRM_MEDIATEK_DP) += mtk_dp.o
drivers/gpu/drm/mediatek/mtk_dp.c new file +2109 -0
2,109 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_dp_reg.h new file +542 -0
542 lines not on this page · raw message
Signature · 1 line
2.18.0
Re: [PATCH v14 01/10] dt-bindings: mediatek,dp: Add Display Port binding
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 120 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This controller is present on several mediatek hardware. Currently mt8195 and mt8395 have this controller without a functional difference,
so only one compatible field is added.The controller can have two forms, as a normal display port and as an embedded display port.
Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>--- .../display/mediatek/mediatek,dp.yaml | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yamldiff --git
a/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yamlb/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yamlnew file mode 100644
index 000000000000..e2d6cb314297
---/dev/null
+++b/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yamlDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +4
-0@@ -0,0 +1,115 @@ +# 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#Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +10
-0+ +title: MediaTek Display Port Controller + +maintainers: + - Chun-Kuang Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + Device tree bindings for the MediaTek display port TX (DP) and + embedded display port TX (eDP) controller present on some MediaTekSoCs.
+ MediaTek DP and eDP are different hardwares and they have different
+ base address for registers, so we need two different compatibles toDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +30
-0+ separate them. + +properties: + compatible: + enum: + - mediatek,mt8195-dp-tx + - mediatek,mt8195-edp-tx + + reg: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + description: efuse data for display port calibration + + nvmem-cell-names: + const: dp_calibration_data + + power-domains: + maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Input endpoint of the controller, usually
dp_intfDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +39
-0+ + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: Output endpoint of the controller + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + properties: + data-lanes: + description: | + number of lanes supported by the hardware. + The possible values: + 0 - For 1 lane enabled in IP. + 0 1 - For 2 lanes enabled in IP. + 0 1 2 3 - For 4 lanes enabled in IP. + minItems: 1 + maxItems: 4 + required: + - data-lanes + + required: + - port@0 + - port@1 + + max-linkrate-mhz: + enum: [ 1620, 2700, 5400, 8100 ] + description: maximum link rate supported by the hardware. + +required: + - compatible + - reg + - interrupts + - ports + - max-linkrate-mhz + +additionalProperties: false +
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml line 96
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +10
-0+examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/power/mt8195-power.h> + dp_tx@1c600000 { + compatible = "mediatek,mt8195-dp-tx"; + reg = <0x1c600000 0x8000>; + power-domains = <&spm MT8195_POWER_DOMAIN_DP_TX>; + interrupts = <GIC_SPI 458 IRQ_TYPE_LEVEL_HIGH 0>; + max-linkrate-mhz = <8100>;
Why dp-tx has no clock property? I think this device should work with a clock.
Regards,
CK
Quoted 19 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +19
-0+ + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dptx_in: endpoint { + remote-endpoint = <&dp_intf0_out>; + }; + }; + port@1 { + reg = <1>; + dptx_out: endpoint { + data-lanes = <0 1 2 3>; + }; + }; + }; + };
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c line 1498
Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+ +static irqreturn_t mtk_dp_hpd_event_thread (int hpd,void *dev) +{ +struct mtk_dp *mtk_dp = dev; + +if (mtk_dp->train_info.cable_state_change) { + mtk_dp->train_info.cable_state_change = false; + +mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , +DP_PWR_STATE_BANDGAP_TPLL_LANE , +DP_PWR_STATE_MASK );
You set cable_state_change to true in isr handler just to update a register in isr thread. I think you could just update this register in isr handler and drop cable_state_change.
Regards,
CK
Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+ } + +if (mtk_dp->train_info.irq_sta.hpd_inerrupt) { +dev_dbg (mtk_dp->dev,"MTK_DP_HPD_INTERRUPT\n" ); + mtk_dp->train_info.irq_sta.hpd_inerrupt = false; +mtk_dp_hpd_sink_event (mtk_dp); + } + +return IRQ_HANDLED ; +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+ +struct mtk_dp_timings { +struct videomode vm; +}; + +struct mtk_dp_irq_sta { +bool hpd_inerrupt; +}; + +struct mtk_dp_train_info { +bool tps3;
drivers/gpu/drm/mediatek/mtk_dp.c line 67
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+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; +struct mtk_dp_irq_sta irq_sta;
There is only one member in struct mtk_dp_irq_sta, so drop struct mtk_dp_irq_sta and use bool hpd_inerrupt directly here.
drivers/gpu/drm/mediatek/mtk_dp.c line 73
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+}; + +struct mtk_dp_info { +u32 depth; +enum dp_pixelformat format; +struct mtk_dp_timings timings;
There is only one member in struct mtk_dp_timings, so drop struct mtk_dp_timings and use struct videomode vm directly here.
Regards,
CK
Quoted 2 lines
(quoted diff) +2
-0+}; +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 34 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ +static int mtk_dp_bridge_atomic_check (struct drm_bridge *bridge, + struct drm_bridge_state
*bridge_state,(quoted diff) +1
-0+ struct drm_crtc_state
*crtc_state,(quoted diff) +1
-0+ struct drm_connector_state
*conn_state)drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+{ +struct mtk_dp *mtk_dp =mtk_dp_from_bridge (bridge); +struct drm_crtc *crtc = conn_state->crtc; +unsigned int input_bus_format; + + input_bus_format = bridge_state->input_bus_cfg.format; + + dev_dbg(mtk_dp->dev, "input format 0x%04x, output format0x%04x\n",
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+ bridge_state->input_bus_cfg.format, + bridge_state->output_bus_cfg.format); + +if (input_bus_format ==MEDIA_BUS_FMT_YUYV8_1X16 ) + mtk_dp->info.format =DP_PIXELFORMAT_YUV422 ; +else + mtk_dp->info.format =DP_PIXELFORMAT_RGB ; + +if (!crtc) { + drm_err(mtk_dp->drm_dev, + "Can't enable bridge as connector state doesn'thave a crtc\n");
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+return -EINVAL ; + } + + mtk_dp_parse_drm_mode_timings(mtk_dp, &crtc_state-Quoted 1 line
adjusted_mode);
Review
Quoted 1 line
(quoted diff) +1
-0+ if (mtk_dp_parse_capabilities(mtk_dp)) {
mtk_dp_bridge_atomic_enable() would call mtk_dp_parse_capabilities(), so this is redundant.
Regards,
CK
Quoted 9 lines
(quoted diff) +2
-0+ drm_err(mtk_dp->drm_dev, + "Can't enable bridge as nothing is pluggedin\n");
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+return -EINVAL ; + } + +return 0 ; +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c line 308
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ +static int mtk_dp_set_color_depth (struct mtk_dp *mtk_dp) +{ +/* Only support 8 bits currently */ + mtk_dp->info.depth =DP_MSA_MISC_8_BPC ;
Only support DP_MSA_MISC_8_BPC, so it's not necessary use a variable to store this information. Drop depth.
Regards,
CK
Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+ +/* Update MISC0 */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3034 , +DP_MSA_MISC_8_BPC ,DP_TEST_BIT_DEPTH_MASK ); + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_303C , +VIDEO_COLOR_DEPTH_DP_ENC0_P0_8BIT , +VIDEO_COLOR_DEPTH_DP_ENC0_P0_MASK ); +return 0 ; +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 4 lines
(quoted diff) +2
-0+ +static void mtk_dp_msa_bypass_enable(struct mtk_dp *mtk_dp, boolenable)
drivers/gpu/drm/mediatek/mtk_dp.c new file +1
-0+{
drivers/gpu/drm/mediatek/mtk_dp.c line 200
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+u32 mask =BIT (HTOTAL_SEL_DP_ENC0_P0_SHIFT ) | +BIT (VTOTAL_SEL_DP_ENC0_P0_SHIFT ) | +BIT (HSTART_SEL_DP_ENC0_P0_SHIFT ) | +BIT (VSTART_SEL_DP_ENC0_P0_SHIFT ) | +BIT (HWIDTH_SEL_DP_ENC0_P0_SHIFT ) | +BIT (VHEIGHT_SEL_DP_ENC0_P0_SHIFT ) | +BIT (HSP_SEL_DP_ENC0_P0_SHIFT ) | +BIT (HSW_SEL_DP_ENC0_P0_SHIFT ) | +BIT (VSP_SEL_DP_ENC0_P0_SHIFT ) | +BIT (VSW_SEL_DP_ENC0_P0_SHIFT );
I would like define a symbol like this
#define HTOTAL_SEL_DP_ENC0_P0 BIT(0)
#define VTOTAL_SEL_DP_ENC0_P0 BIT(1)
#define HSTART_SEL_DP_ENC0_P0 BIT(2)
Regards,
CK
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+u32 val = enable ?0 : mask; + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3030 , val, mask); +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Review
Quoted 4 lines
(quoted diff) +2
-0+ +static void mtk_dp_bulk_16bit_write(struct mtk_dp *mtk_dp, u32offset, u8 *buf,
(quoted diff) +1
-0+ size_t length)
The offset would always be MTK_DP_AUX_P0_3708, so drop offset and use MTK_DP_AUX_P0_3708 directly.
drivers/gpu/drm/mediatek/mtk_dp.c line 174
Quoted 13 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+{ +int i; +int num_regs = (length +1 ) /2 ; + +/* 2 bytes per register */ +for (i =0 ; i < num_regs; i++) { + u32 val = buf[i * 2] | + (i * 2 + 1 < length ? buf[i * 2 + 1] << 8 :0);
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ +if (mtk_dp_write (mtk_dp, offset + i *4 , val)) +return ; + }
for (i = 0; i < length; i += 2) {
val = buf[i] | (i + 1 < length ? buf[i + 1] << 8 : 0);
if (mtk_dp_write(mtk_dp, MTK_DP_AUX_P0_3708 + i * 2, val))
return;
}Regards,
CK
Quoted 2 lines
(quoted diff) +2
-0+} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 7 lines
(quoted diff) +2
-0+ +static void mtk_dp_aux_fill_write_fifo(struct mtk_dp *mtk_dp, u8*buf,
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ size_t length) +{ + mtk_dp_bulk_16bit_write(mtk_dp, MTK_DP_AUX_P0_3708, buf,length);
mtk_dp_aux_fill_write_fifo() directly call mtk_dp_bulk_16bit_write(), so I think we could just keep one of them and drop another one.
Regards,
CK
Quoted 2 lines
(quoted diff) +2
-0+} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 17 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +13
-0+ +static void mtk_dp_set_msa (struct mtk_dp *mtk_dp) +{ +struct drm_display_mode mode; +struct mtk_dp_timings *timings = &mtk_dp->info.timings; + +drm_display_mode_from_videomode (&timings->vm, &mode); + +/* horizontal */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3010 , + mode.htotal,HTOTAL_SW_DP_ENC0_P0_MASK ); + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3018, + timings->vm.hsync_len + timings-Quoted 1 line
vm.hback_porch,
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ HSTART_SW_DP_ENC0_P0_MASK); + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3028, + timings->vm.hsync_len <<
Quoted 1 line
HSW_SW_DP_ENC0_P0_SHIFT,
Directly use a number for shift because we know it's a shift, so it's not necessary to define a symbol for shift.
Quoted 16 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ HSW_SW_DP_ENC0_P0_MASK); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3028 , +0 ,HSP_SW_DP_ENC0_P0_MASK ); + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3020, + timings->vm.hactive,
HWIDTH_SW_DP_ENC0_P0_MASK);drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+ +/* vertical */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3014 , + mode.vtotal,VTOTAL_SW_DP_ENC0_P0_MASK ); + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_301C, + timings->vm.vsync_len + timings-Quoted 1 line
vm.vback_porch,
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ VSTART_SW_DP_ENC0_P0_MASK); + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_302C, + timings->vm.vsync_len <<
Quoted 1 line
VSW_SW_DP_ENC0_P0_SHIFT,
Ditto.
Regards,
CK
Quoted 46 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ VSW_SW_DP_ENC0_P0_MASK); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_302C , +0 ,VSP_SW_DP_ENC0_P0_MASK ); + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3024, + timings->vm.vactive,
VHEIGHT_SW_DP_ENC0_P0_MASK);drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ +/* horizontal */ + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3064, + timings->vm.hactive,
HDE_NUM_LAST_DP_ENC0_P0_MASK);drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3154 , + mode.htotal,PGEN_HTOTAL_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3158 , + timings->vm.hfront_porch, +PGEN_HSYNC_RISING_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_315C , + timings->vm.hsync_len, +PGEN_HSYNC_PULSE_WIDTH_DP_ENC0_P0_MASK ); + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3160, + timings->vm.hback_porch + timings-Quoted 1 line
vm.hsync_len,
drivers/gpu/drm/mediatek/mtk_dp.c new file +17
-0+ PGEN_HFDE_START_DP_ENC0_P0_MASK); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3164 , + timings->vm.hactive, +PGEN_HFDE_ACTIVE_WIDTH_DP_ENC0_P0_MASK ); + +/* vertical */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3168 , + mode.vtotal, +PGEN_VTOTAL_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_316C , + timings->vm.vfront_porch, +PGEN_VSYNC_RISING_DP_ENC0_P0_MASK ); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3170 , + timings->vm.vsync_len, +PGEN_VSYNC_PULSE_WIDTH_DP_ENC0_P0_MASK ); + mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3174, + timings->vm.vback_porch + timings-Quoted 1 line
vm.vsync_len,
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+ PGEN_VFDE_START_DP_ENC0_P0_MASK); +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3178 , + timings->vm.vactive, +PGEN_VFDE_ACTIVE_WIDTH_DP_ENC0_P0_MASK ); +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 39 lines
+static int mtk_dp_train_tps_2_3(struct
mtk_dp*mtk_dp, u8target_linkrate,(quoted diff) +1
-0+ u8 target_lane_count, int
*iteration_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +23
-0+ u8 *lane_adjust, int *status_control, + u8 *prev_lane_adjust) +{ +u8 val; +u8 link_status[DP_LINK_STATUS_SIZE ] = {}; + +if (*status_control ==1 ) { +if (mtk_dp->train_info.tps4) { +mtk_dp_train_set_pattern (mtk_dp,4 ); + val =DP_TRAINING_PATTERN_4 ; + }else if (mtk_dp->train_info.tps3) { +mtk_dp_train_set_pattern (mtk_dp,3 ); + val =DP_LINK_SCRAMBLING_DISABLE | +DP_TRAINING_PATTERN_3 ; + }else { +mtk_dp_train_set_pattern (mtk_dp,2 ); + val =DP_LINK_SCRAMBLING_DISABLE | +DP_TRAINING_PATTERN_2 ; + } +drm_dp_dpcd_writeb (&mtk_dp->aux, +DP_TRAINING_PATTERN_SET , val); + drm_dp_dpcd_read(&mtk_dp->aux, + DP_ADJUST_REQUEST_LANE0_1,
lane_adjust,drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ sizeof(*lane_adjust) * 2); + + mtk_dp_train_update_swing_pre(mtk_dp, + target_lane_count,
lane_adjust);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ *status_control =2 ; + (*iteration_count)++; + } + + drm_dp_link_train_channel_eq_delay(&mtk_dp->aux, mtk_dp-Quoted 1 line
rx_cap);
drivers/gpu/drm/mediatek/mtk_dp.c
Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ +drm_dp_dpcd_read_link_status (&mtk_dp->aux, link_status); + +if (!drm_dp_clock_recovery_ok (link_status, target_lane_count))
I think this checking is redundant. I think we could just keep drm_dp_channel_eq_ok() and drop drm_dp_clock_recovery_ok() here because if drm_dp_clock_recovery_ok() fail, it imply that drm_dp_channel_eq_ok() would fail. So just check drm_dp_channel_eq_ok() is enough.
Regards,
CK
Quoted 21 lines
{
drivers/gpu/drm/mediatek/mtk_dp.c new file +20
-0+ mtk_dp->train_info.cr_done = false; + mtk_dp->train_info.eq_done = false; +dev_dbg (mtk_dp->dev,"Link train EQ fail\n" ); +return -EINVAL ; + } + +if (drm_dp_channel_eq_ok (link_status, target_lane_count)) { + mtk_dp->train_info.eq_done = true; +dev_dbg (mtk_dp->dev,"Link train EQ pass\n" ); +return 0 ; + } + +if (*prev_lane_adjust == link_status[4 ]) + (*iteration_count)++; +else + *prev_lane_adjust = link_status[4 ]; + +return -EAGAIN ; +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 79 lines
(quoted diff) +2
-0+ +static int mtk_dp_train_flow(struct mtk_dp *mtk_dp, u8
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ u8 target_lane_count) +{ +u8 lane_adjust[2 ] = {}; +bool pass_tps1 = false; +bool pass_tps2_3 = false; +int train_retries; +int status_control; +int iteration_count; +int ret; +u8 prev_lane_adjust; + + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LINK_BW_SET,
target_link_rate);drivers/gpu/drm/mediatek/mtk_dp.c new file +2
-0+ drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LANE_COUNT_SET, + target_lane_count |
DP_LANE_COUNT_ENHANCED_FRAME_EN);drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ +if (mtk_dp->train_info.sink_ssc) +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_DOWNSPREAD_CTRL , +DP_SPREAD_AMP_0_5 ); + + train_retries =0 ; + status_control =0 ; + iteration_count =1 ; + prev_lane_adjust =0xFF ; + +mtk_dp_set_lanes (mtk_dp, target_lane_count /2 ); + ret = mtk_dp_phy_configure(mtk_dp, target_link_rate,
target_lane_count);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+if (ret) +return ret; + + dev_dbg(mtk_dp->dev, + "Link train target_link_rate = 0x%x, target_lane_count= 0x%x\n",
drivers/gpu/drm/mediatek/mtk_dp.c new file +9
-0+ target_link_rate, target_lane_count); + + do { + train_retries++; + if (!mtk_dp->train_info.cable_plugged_in) + return -ENODEV; + + if (!pass_tps1) { + ret = mtk_dp_train_tps_1(mtk_dp,
target_lane_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +1
-0+ &iteration_count,
lane_adjust,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &status_control, + &prev_lane_adjust); +if (!ret) { + pass_tps1 = true; + train_retries =0 ; + }else if (ret == -EINVAL ) { +break ; + } + }else { + ret = mtk_dp_train_tps_2_3(mtk_dp,
target_link_rate,drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ target_lane_count, + &iteration_count, + lane_adjust,
&status_control,drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+ &prev_lane_adjust); +if (!ret) { + pass_tps2_3 = true; +break ; + }else if (ret == -EINVAL ) { +break ; + } + } + + drm_dp_dpcd_read(&mtk_dp->aux,
DP_ADJUST_REQUEST_LANE0_1,(quoted diff) +2
-0+ lane_adjust, sizeof(lane_adjust)); + mtk_dp_train_update_swing_pre(mtk_dp,
target_lane_count,
drivers/gpu/drm/mediatek/mtk_dp.c line 1264
Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ lane_adjust); + }while (train_retries <MTK_DP_TRAIN_RETRY_LIMIT && + iteration_count <MTK_DP_TRAIN_MAX_ITERATIONS );
train_retries and iteration_count are the same thing, so keep one and drop another one.
Regards,
CK
Quoted 21 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +21
-0+ +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_TRAINING_PATTERN_SET , +DP_TRAINING_PATTERN_DISABLE ); +mtk_dp_train_set_pattern (mtk_dp,0 ); + +if (!pass_tps2_3) +return -ETIMEDOUT ; + + mtk_dp->train_info.link_rate = target_link_rate; + mtk_dp->train_info.lane_count = target_lane_count; + +mtk_dp_training_set_scramble (mtk_dp, true); + +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_LANE_COUNT_SET , + target_lane_count | +DP_LANE_COUNT_ENHANCED_FRAME_EN ); +mtk_dp_set_enhanced_frame_mode (mtk_dp, true); + +return ret; +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to CK HuQuoted 49 lines · CK Hu
Hi, Bo-Chen:
Quoted 27 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 16 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +16
-0+ +struct mtk_dp_timings { +struct videomode vm; +}; + +struct mtk_dp_irq_sta { +bool hpd_inerrupt; +}; + +struct mtk_dp_train_info { +bool tps3; +bool tps4; +bool sink_ssc; +bool cable_plugged_in; +bool cable_state_change; +bool cr_done;
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 67
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+bool eq_done; +/* link_rate is in multiple of 0.27Gbps */ +int link_rate; +int lane_count; +struct mtk_dp_irq_sta irq_sta;There is only one member in struct
mtk_dp_irq_sta, so drop structmtk_dp_irq_staand use boolhpd_inerruptdirectly here.
Hello CK,
ok, I will drop this.
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 73
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+}; + +struct mtk_dp_info { +u32 depth; +enum dp_pixelformat format; +struct mtk_dp_timings timings;There is only one member in struct
mtk_dp_timings, so drop structmtk_dp_timingsand use struct videomode vm directly here.
This structure will add more variable in following patch. whole struct is like,
struct mtk_dp_timings {
struct videomode vm;
u8 frame_rate;
u32 pix_rate_khz;
};I want to keep this.
BRs,
Bo-Chen
Quoted 7 lines
Regards,
CKQuoted 2 lines
(quoted diff) +2
-0+}; +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to CK HuQuoted 33 lines · CK Hu
Hi, Bo-Chen:
Quoted 27 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +2
-0+ +static void mtk_dp_bulk_16bit_write(struct mtk_dp *mtk_dp, u32offset, u8 *buf,
(quoted diff) +1
-0+ size_t length)The offset would always be
MTK_DP_AUX_P0_3708, so drop offset and useMTK_DP_AUX_P0_3708directly.
Hello CK,
I don't think it's a good idea. this function is a fucntion of writing registers. I want to keep the offset variable.
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+{ +int i; +int num_regs = (length +1 ) /2 ; + +/* 2 bytes per register */ +for (i =0 ; i < num_regs; i++) { + u32 val = buf[i * 2] | + (i * 2 + 1 < length ? buf[i * 2 + 1] << 8 :0);
(quoted diff) +2
-0+ + if (mtk_dp_write(mtk_dp, offset + i * 4, val))
Quoted 9 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ return; + }for (i = 0; i < length; i += 2) { val = buf[i] | (i + 1 < length ? buf[i + 1] << 8 : 0); if (mtk_dp_write(mtk_dp, MTK_DP_AUX_P0_3708 + i * 2, val)) return; }
ok.
BRs,
Bo-Chen
Quoted 7 lines
Regards,
CKQuoted 2 lines
(quoted diff) +2
-0+} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to CK HuQuoted 33 lines · CK Hu
Hi, Bo-Chen:
Quoted 27 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 11 lines
Quoted 7 lines
(quoted diff) +2
-0+ +static void mtk_dp_aux_fill_write_fifo(struct mtk_dp *mtk_dp, u8*buf,
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ size_t length) +{ + mtk_dp_bulk_16bit_write(mtk_dp, MTK_DP_AUX_P0_3708, buf,length);
mtk_dp_aux_fill_write_fifo()directly callmtk_dp_bulk_16bit_write(), so I think we could just keep one of them and drop another one.
Hello CK,
mtk_dp_bulk_16bit_write() will also be used in following patches. I want to keep the driver like this.
BRs,
Bo-Chen
Quoted 7 lines
Regards,
CKQuoted 2 lines
(quoted diff) +2
-0+} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to CK HuQuoted 89 lines · CK Hu
Hi, Bo-Chen:
Quoted 27 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 40 lines
+static int mtk_dp_train_tps_2_3(struct
mtk_dp*mtk_dp, u8target_linkrate,(quoted diff) +1
-0+ u8 target_lane_count, int
*iteration_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +23
-0+ u8 *lane_adjust, int *status_control, + u8 *prev_lane_adjust) +{ +u8 val; +u8 link_status[DP_LINK_STATUS_SIZE ] = {}; + +if (*status_control ==1 ) { +if (mtk_dp->train_info.tps4) { +mtk_dp_train_set_pattern (mtk_dp,4 ); + val =DP_TRAINING_PATTERN_4 ; + }else if (mtk_dp->train_info.tps3) { +mtk_dp_train_set_pattern (mtk_dp,3 ); + val =DP_LINK_SCRAMBLING_DISABLE | +DP_TRAINING_PATTERN_3 ; + }else { +mtk_dp_train_set_pattern (mtk_dp,2 ); + val =DP_LINK_SCRAMBLING_DISABLE | +DP_TRAINING_PATTERN_2 ; + } +drm_dp_dpcd_writeb (&mtk_dp->aux, +DP_TRAINING_PATTERN_SET , val); + drm_dp_dpcd_read(&mtk_dp->aux, + DP_ADJUST_REQUEST_LANE0_1,
lane_adjust,drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ sizeof(*lane_adjust) * 2); + + mtk_dp_train_update_swing_pre(mtk_dp, + target_lane_count,
lane_adjust);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ *status_control =2 ; + (*iteration_count)++; + } + + drm_dp_link_train_channel_eq_delay(&mtk_dp->aux, mtk_dp-Quoted 1 line
rx_cap);drivers/gpu/drm/mediatek/mtk_dp.c
Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ +drm_dp_dpcd_read_link_status (&mtk_dp->aux, link_status); + +if (!drm_dp_clock_recovery_ok (link_status, target_lane_count))I think this checking is redundant. I think we could just keep
drm_dp_channel_eq_ok()and dropdrm_dp_clock_recovery_ok()here because
ifdrm_dp_clock_recovery_ok()fail, it imply thatdrm_dp_channel_eq_ok()would fail. So just checkdrm_dp_channel_eq_ok()
is enough.Regards,
CK
Quoted 13 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1186
Quoted 13 lines
{
drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ mtk_dp->train_info.cr_done = false; + mtk_dp->train_info.eq_done = false; +dev_dbg (mtk_dp->dev,"Link train EQ fail\n" ); +return -EINVAL ; + } + +if (drm_dp_channel_eq_ok (link_status, target_lane_count)) { + mtk_dp->train_info.eq_done = true; +dev_dbg (mtk_dp->dev,"Link train EQ pass\n" ); +return 0 ; + } +
Hello CK,
do you mean like this?
if (drm_dp_channel_eq_ok(link_status, target_lane_count)) {
mtk_dp-
Quoted 1 line
train_info.eq_done = true;
dev_dbg(mtk_dp->dev, "Link train EQ pass\n");
return 0;
} else {
mtk_dp->train_info.cr_done = false;
mtk_dp->train_info.eq_done = false;
dev_dbg(mtk_dp->dev, "Link train EQ fail\n");
return -EINVAL;
}
BRs,
Bo-Chen
Quoted 10 lines
Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+if (*prev_lane_adjust == link_status[4 ]) + (*iteration_count)++; +else + *prev_lane_adjust = link_status[4 ]; + +return -EAGAIN ; +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Rex-BC ChenHi, Bo-Chen:
Quoted 79 lines · Rex-BC Chen
Quoted 51 lines · CK Hu
Hi, Bo-Chen:
Quoted 29 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a
register range, the parent passes a regmap pointer to the child so
that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 16 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +16
-0+ +struct mtk_dp_timings { +struct videomode vm; +}; + +struct mtk_dp_irq_sta { +bool hpd_inerrupt; +}; + +struct mtk_dp_train_info { +bool tps3; +bool tps4; +bool sink_ssc; +bool cable_plugged_in; +bool cable_state_change; +bool cr_done;Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 67
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+bool eq_done; +/* link_rate is in multiple of 0.27Gbps */ +int link_rate; +int lane_count; +struct mtk_dp_irq_sta irq_sta;There is only one member in struct
mtk_dp_irq_sta, so drop structmtk_dp_irq_staand use boolhpd_inerruptdirectly here.Hello CK,
ok, I will drop this.
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 73
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+}; + +struct mtk_dp_info { +u32 depth; +enum dp_pixelformat format; +struct mtk_dp_timings timings;There is only one member in struct
mtk_dp_timings, so drop structmtk_dp_timingsand use struct videomode vm directly here.This structure will add more variable in following patch. whole struct is like,
Quoted 7 lines
struct mtk_dp_timings { struct videomode vm; u8 frame_rate; u32 pix_rate_khz; };I want to keep this.
I think we could just drop struct mtk_dp_timings and place these member directly in struct mtk_dp_info.
Regards,
CK
Quoted 14 lines
BRs,
Bo-ChenQuoted 7 lines
Regards,
CKQuoted 2 lines
(quoted diff) +2
-0+}; +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Rex-BC ChenHi, Bo-Chen:
Quoted 113 lines · Rex-BC Chen
Quoted 91 lines · CK Hu
Hi, Bo-Chen:
Quoted 29 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a
register range, the parent passes a regmap pointer to the child so
that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 40 lines
+static int mtk_dp_train_tps_2_3(struct
mtk_dp*mtk_dp, u8target_linkrate,(quoted diff) +1
-0+ u8 target_lane_count, int
*iteration_count,drivers/gpu/drm/mediatek/mtk_dp.c new file +23
-0+ u8 *lane_adjust, int *status_control, + u8 *prev_lane_adjust) +{ +u8 val; +u8 link_status[DP_LINK_STATUS_SIZE ] = {}; + +if (*status_control ==1 ) { +if (mtk_dp->train_info.tps4) { +mtk_dp_train_set_pattern (mtk_dp,4 ); + val =DP_TRAINING_PATTERN_4 ; + }else if (mtk_dp->train_info.tps3) { +mtk_dp_train_set_pattern (mtk_dp,3 ); + val =DP_LINK_SCRAMBLING_DISABLE | +DP_TRAINING_PATTERN_3 ; + }else { +mtk_dp_train_set_pattern (mtk_dp,2 ); + val =DP_LINK_SCRAMBLING_DISABLE | +DP_TRAINING_PATTERN_2 ; + } +drm_dp_dpcd_writeb (&mtk_dp->aux, +DP_TRAINING_PATTERN_SET , val); + drm_dp_dpcd_read(&mtk_dp->aux, + DP_ADJUST_REQUEST_LANE0_1,
lane_adjust,drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ sizeof(*lane_adjust) * 2); + + mtk_dp_train_update_swing_pre(mtk_dp, + target_lane_count,
lane_adjust);drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ *status_control =2 ; + (*iteration_count)++; + } + + drm_dp_link_train_channel_eq_delay(&mtk_dp->aux, mtk_dp-Quoted 1 line
rx_cap);drivers/gpu/drm/mediatek/mtk_dp.c
Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ +drm_dp_dpcd_read_link_status (&mtk_dp->aux, link_status); + +if (!drm_dp_clock_recovery_ok (link_status, target_lane_count))I think this checking is redundant. I think we could just keep
drm_dp_channel_eq_ok()and dropdrm_dp_clock_recovery_ok()here because
ifdrm_dp_clock_recovery_ok()fail, it imply thatdrm_dp_channel_eq_ok()would fail. So just checkdrm_dp_channel_eq_ok()
is enough.Regards,
CKQuoted 13 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1186
Quoted 13 lines
{
drivers/gpu/drm/mediatek/mtk_dp.c new file +12
-0+ mtk_dp->train_info.cr_done = false; + mtk_dp->train_info.eq_done = false; +dev_dbg (mtk_dp->dev,"Link train EQ fail\n" ); +return -EINVAL ; + } + +if (drm_dp_channel_eq_ok (link_status, target_lane_count)) { + mtk_dp->train_info.eq_done = true; +dev_dbg (mtk_dp->dev,"Link train EQ pass\n" ); +return 0 ; + } +Hello CK,
do you mean like this?
if (drm_dp_channel_eq_ok(link_status, target_lane_count)) {
mtk_dp-Quoted 1 line
train_info.eq_done = true;
Quoted 8 lines
dev_dbg(mtk_dp->dev, "Link train EQ pass\n");
return 0;
} else {
mtk_dp->train_info.cr_done= false;
mtk_dp->train_info.eq_done= false;
dev_dbg(mtk_dp->dev, "Link train EQ fail\n");
return-EINVAL;
}
No, I mean just remove drm_dp_clock_recovery_ok() checking. When drm_dp_channel_eq_ok() fail, it should keep retry. If clock recovery has some problem, drm_dp_channel_eq_ok() would be finally out of retry count.
Regards,
CK
Quoted 16 lines
BRs,
Bo-ChenQuoted 10 lines
Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +8
-0+if (*prev_lane_adjust == link_status[4 ]) + (*iteration_count)++; +else + *prev_lane_adjust = link_status[4 ]; + +return -EAGAIN ; +} +
AngeloGioacchino Del Regno
maintainerRe: [PATCH v14 03/10] drm/edid: Add cea_sad helpers for freq/length
In reply to Bo-Chen ChenIl 12/07/22 13:12, Bo-Chen Chen ha scritto:
Quoted 53 lines
From: Guillaume Ranquet <[email protected]>
This patch adds two helper functions that extract the frequency and word length from a struct
cea_sad.For these helper functions new defines are added that help translate the 'freq' and 'byte2' fields into real numbers.
Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>--- drivers/gpu/drm/drm_edid.c | 73 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 14 ++++++++ 2 files changed, 87 insertions(+)drivers/gpu/drm/drm_edid.c +29
-0@@ -4916,6 +4916,79 @@ int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb) }EXPORT_SYMBOL (drm_edid_to_speaker_allocation); +/** +* drm_cea_sad_get_sample_rate - Extract the sample rate from cea_sad +* @sad: Pointer to the cea_sad struct +* +* Extracts the cea_sad frequency field and returns the sample rate in Hz. +* +* Return: Sample rate in Hz or a negative errno if parsing failed. +*/ +int drm_cea_sad_get_sample_rate (const struct cea_sad *sad) +{ +switch (sad->freq) { +case DRM_CEA_SAD_FREQ_32KHZ : +return 32000 ; +case DRM_CEA_SAD_FREQ_44KHZ : +return 44100 ; +case DRM_CEA_SAD_FREQ_48KHZ : +return 48000 ; +case DRM_CEA_SAD_FREQ_88KHZ : +return 88200 ; +case DRM_CEA_SAD_FREQ_96KHZ : +return 96000 ; +case DRM_CEA_SAD_FREQ_176KHZ : +return 176400 ; +case DRM_CEA_SAD_FREQ_192KHZ : +return 192000 ; +default : +return -EINVAL ; + } +}
drivers/gpu/drm/drm_edid.c int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb) · line 4957
Quoted 10 lines
drivers/gpu/drm/drm_edid.c +10
-0+EXPORT_SYMBOL (drm_cea_sad_get_sample_rate); + +static bool drm_cea_sad_is_pcm (const struct cea_sad *sad) +{ +switch (sad->format) { +case HDMI_AUDIO_CODING_TYPE_PCM : +return true; +default : +return false; + }
Are you sure that you need this helper? That's used only in one function... ...if you really need this one, though, I don't think that using a switch is the best option here.
Unless anyone is against that (please, reason?), I would be for doing it like:
return sad->format == HDMI_AUDIO_CODING_TYPE_PCM;
Everything else looks good to me (and working, too).
Cheers,
Angelo
Re: [PATCH v14 03/10] drm/edid: Add cea_sad helpers for freq/length
Quoted 82 lines · AngeloGioacchino Del Regno
Il 12/07/22 13:12, Bo-Chen Chen ha scritto:
Quoted 61 lines
From: Guillaume Ranquet <[email protected]>
This patch adds two helper functions that extract the frequency and word
length from a structcea_sad.For these helper functions new defines are added that help translate the
'freq' and 'byte2' fields into real numbers.Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>--- drivers/gpu/drm/drm_edid.c | 73 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 14 ++++++++ 2 files changed, 87 insertions(+)drivers/gpu/drm/drm_edid.c +2
-0@@ -4916,6 +4916,79 @@ int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb) }EXPORT_SYMBOL (drm_edid_to_speaker_allocation ); +/** +* drm_cea_sad_get_sample_rate - Extract the sample rate from
cea_sad
+ * @sad: Pointer to thecea_sadstruct
+ *
+ * Extracts thecea_sadfrequency field and returns the sample rate in Hz.
+ *
+ * Return: Sample rate in Hz or a negative errno if parsing failed.
+ */drivers/gpu/drm/drm_edid.c +21
-0+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 ; + } +}drivers/gpu/drm/drm_edid.c int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb) · line 4957
Quoted 10 lines
drivers/gpu/drm/drm_edid.c +10
-0+EXPORT_SYMBOL (drm_cea_sad_get_sample_rate); + +static bool drm_cea_sad_is_pcm (const struct cea_sad *sad) +{ +switch (sad->format) { +case HDMI_AUDIO_CODING_TYPE_PCM : +return true; +default : +return false; + }Are you sure that you need this helper? That's used only in one function...
...if you really need this one, though, I don't think that using a switch
is the best option here.Unless anyone is against that (please, reason?), I would be for doing it like:
Quoted 6 lines
return sad->format == HDMI_AUDIO_CODING_TYPE_PCM;Everything else looks good to me (and working, too).
Cheers,
Angelo
Hello Angelo,
I think you are right,
in this case, we don't need this help function.
I will merge this function intodrm_cea_sad_get_uncompressed_word_length()
BRs,
Bo-Chen
AngeloGioacchino Del Regno
maintainerRe: [PATCH v14 04/10] video/hdmi: Add audio_infoframe packing for DP
In reply to Bo-Chen ChenIl 12/07/22 13:12, Bo-Chen Chen ha scritto:
Quoted 110 lines
From: Markus Schneider-Pargmann <[email protected]>
Similar to HDMI, DP uses audio infoframes as well which are structured very similar to the HDMI ones.
This patch adds a helper function to pack the HDMI audio infoframe for DP, called
hdmi_audio_infoframe_pack_for_dp().hdmi_audio_infoframe_pack_only()is split into two parts. One of them packs the payload only and can be used for HDMI and DP.Also constify the frame parameter in
hdmi_audio_infoframe_check()as it is passed tohdmi_audio_infoframe_check_only()which expects a const.Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>--- drivers/video/hdmi.c | 82 +++++++++++++++++++++++++++--------- include/drm/display/drm_dp.h | 2 + include/linux/hdmi.h | 7 ++- 3 files changed, 71 insertions(+), 20 deletions(-)drivers/video/hdmi.c +26
-19@@ -21,6 +21,7 @@* DEALINGS IN THE SOFTWARE. */ +#include <drm/display/drm_dp.h> #include <linux/bitops.h> #include <linux/bug.h> #include <linux/errno.h> @@ -381,12 +382,34 @@ static int hdmi_audio_infoframe_check_only(const struct hdmi_audio_infoframe *fr* * Returns 0 on success or a negative error code on failure. */ -int hdmi_audio_infoframe_check (struct hdmi_audio_infoframe *frame) +int hdmi_audio_infoframe_check (const struct hdmi_audio_infoframe *frame) {return hdmi_audio_infoframe_check_only (frame); }EXPORT_SYMBOL (hdmi_audio_infoframe_check); +static void +hdmi_audio_infoframe_pack_payload (const struct hdmi_audio_infoframe *frame, +u8 *buffer) +{ +u8 channels; + +if (frame->channels >=2 ) + channels = frame->channels -1 ; +else + channels =0 ; + + buffer[0 ] = ((frame->coding_type &0xf ) <<4 ) | (channels &0x7 ); + buffer[1 ] = ((frame->sample_frequency &0x7 ) <<2 ) | + (frame->sample_size &0x3 ); + buffer[2 ] = frame->coding_type_ext &0x1f ; + buffer[3 ] = frame->channel_allocation; + buffer[4 ] = (frame->level_shift_value &0xf ) <<3 ; + +if (frame->downmix_inhibit) + buffer[4 ] |=BIT (7 ); +} +/** * hdmi_audio_infoframe_pack_only() - write HDMI audio infoframe to binary buffer * @frame: HDMI audio infoframe @@ -404,7 +427,6 @@ EXPORT_SYMBOL(hdmi_audio_infoframe_check);ssize_t hdmi_audio_infoframe_pack_only (const struct hdmi_audio_infoframe *frame,void *buffer,size_t size) { -unsigned char channels;u8 *ptr = buffer;size_t length;int ret;@@ -420,28 +442,13 @@ ssize_t hdmi_audio_infoframe_pack_only(const struct hdmi_audio_infoframe *frame,memset (buffer,0 , size); -if (frame->channels >=2 ) - channels = frame->channels -1 ; -else - channels =0 ; - ptr[0 ] = frame->type; ptr[1 ] = frame->version; ptr[2 ] = frame->length; ptr[3 ] =0 ;/* checksum */ -/* start infoframe payload */ - ptr +=HDMI_INFOFRAME_HEADER_SIZE ; - - ptr[0 ] = ((frame->coding_type &0xf ) <<4 ) | (channels &0x7 ); - ptr[1 ] = ((frame->sample_frequency &0x7 ) <<2 ) | - (frame->sample_size &0x3 ); - ptr[2 ] = frame->coding_type_ext &0x1f ; - ptr[3 ] = frame->channel_allocation; - ptr[4 ] = (frame->level_shift_value &0xf ) <<3 ; - -if (frame->downmix_inhibit) - ptr[4 ] |=BIT (7 ); +hdmi_audio_infoframe_pack_payload (frame, + ptr +HDMI_INFOFRAME_HEADER_SIZE );hdmi_infoframe_set_checksum (buffer, length);
drivers/video/hdmi.c ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, · line 494
Quoted 9 lines
drivers/video/hdmi.c +6
-0@@ -479,6 +486,43 @@ ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, }EXPORT_SYMBOL (hdmi_audio_infoframe_pack); +/** +* hdmi_audio_infoframe_pack_for_dp - Pack a HDMI Audio infoframe for DisplayPort +* +* @frame: HDMI Audio infoframe +* @sdp: secondary data packet for display port. This is filled with the +* appropriate: data
"This is filled with the appropriate data"
... well, that's pretty obvious, isn't it?
You're describing that this function is filling sdp in the description, so you can just remove that part.
Also, "Secondary data packet for DisplayPort", please.
drivers/video/hdmi.c ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, · line 495
Quoted 1 line
drivers/video/hdmi.c +1
-0+* @dp_version: Display Port version to be encoded in the header
We're not meaning "a display port", but really "DisplayPort": please remove the space between "Display" and "Port" :-)
(here and in the description below)
Quoted 17 lines
drivers/video/hdmi.c +17
-0+* +* 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));
drivers/video/hdmi.c ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, · line 522
Quoted 10 lines
drivers/video/hdmi.c +10
-0+ +/* 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 ;
What's this magic number 4 about?
Please use a definition for that.
Quoted 37 lines
drivers/video/hdmi.c +3
-0+} +EXPORT_SYMBOL (hdmi_audio_infoframe_pack_for_dp); +/** * hdmi_vendor_infoframe_init() - initialize an HDMI vendor infoframe * @frame: HDMI vendor infoframe include/drm/display/drm_dp.h +2
-0@@ -1536,6 +1536,8 @@ enum drm_dp_phy {#define DP_SDP_VSC_EXT_CEA 0x21/* DP 1.4 */ /* 0x80+ CEA-861 infoframe types */ +#define DP_SDP_AUDIO_INFOFRAME_HB2 0x1b +/** * struct dp_sdp_header - DP secondary data packet header * @HB0: Secondary Data Packet ID include/linux/hdmi.h +6
-1@@ -336,7 +336,12 @@ ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, void *buffer, size_t size);ssize_t hdmi_audio_infoframe_pack_only (const struct hdmi_audio_infoframe *frame,void *buffer,size_t size); -int hdmi_audio_infoframe_check (struct hdmi_audio_infoframe *frame); +int hdmi_audio_infoframe_check (const struct hdmi_audio_infoframe *frame); + +struct dp_sdp ; +ssize_t +hdmi_audio_infoframe_pack_for_dp (const struct hdmi_audio_infoframe *frame, +struct dp_sdp *sdp,u8 dp_version);enum hdmi_3d_structure {HDMI_3D_STRUCTURE_INVALID =-1 ,
AngeloGioacchino Del Regno
maintainerRe: [PATCH v14 09/10] drm/mediatek: DP audio support for MT8195
In reply to Bo-Chen ChenIl 12/07/22 13:12, Bo-Chen Chen ha scritto:
Quoted 16 lines
From: Guillaume Ranquet <[email protected]>
This patch adds audio support to the DP driver for MT8195 with up to 8 channels.
Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>--- drivers/gpu/drm/mediatek/mtk_dp.c | 723 ++++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_dp_reg.h | 2 + 2 files changed, 725 insertions(+)drivers/gpu/drm/mediatek/mtk_dp.c +0
-0
..snip..
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c +2
-0@@ -2082,6 +2693,104 @@ static void mtk_dp_debounce_timer(struct timer_list *t) mtk_dp->need_debounce = true; } +/* +* HDMI audio codec callbacks
drivers/gpu/drm/mediatek/mtk_dp.c static void mtk_dp_debounce_timer(struct timer_list *t) · line 2707
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c +10
-0+*/ +static int mtk_dp_audio_hw_params (struct device *dev,void *data, +struct hdmi_codec_daifmt *daifmt, +struct hdmi_codec_params *params) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); +struct mtk_dp_audio_cfg cfg; + +if (!mtk_dp->enabled) { +pr_err ("%s, DP is not ready!\n" , __func__);
drm_err() here please.
Quoted 12 lines
drivers/gpu/drm/mediatek/mtk_dp.c +12
-0+return -ENODEV ; + } + + cfg.channels = params->cea.channels; + cfg.sample_rate = params->sample_rate; + cfg.word_length_bits =24 ; + +mtk_dp_audio_setup (mtk_dp, &cfg); + +return 0 ; +} +
..snip..
Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dp.c +7
-0+ +static int mtk_dp_register_audio_driver (struct device *dev) +{ +struct mtk_dp *mtk_dp =dev_get_drvdata (dev); +struct hdmi_codec_pdata codec_data = { + .ops = &mtk_dp_audio_codec_ops, + .max_i2s_channels =8 ,
drivers/gpu/drm/mediatek/mtk_dp.c static void mtk_dp_debounce_timer(struct timer_list *t) · line 2789
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c +10
-0+ .i2s = 1, + .data = mtk_dp, + }; +struct platform_device *pdev; + + pdev =platform_device_register_data (dev,HDMI_CODEC_DRV_NAME , +PLATFORM_DEVID_AUTO , &codec_data, +sizeof (codec_data)); +if (IS_ERR (pdev)) +return PTR_ERR (pdev);
You're never unregistering this device, which is unacceptable.
Please add a platform device pointer in struct mtk_dp, so that this function becomes, simply:
mtk_dp->audio_pdev = platform_device_register_data(dev, HDMI_CODEC_DRV_NAME, PLATFORM_DEVID_AUTO, &codec_data, sizeof(codec_data)); return PTR_ERR_OR_ZERO(mtk_dp->audio_pdev);
Quoted 30 lines
drivers/gpu/drm/mediatek/mtk_dp.c +17
-0+ +return 0 ; +} +static int mtk_dp_probe (struct platform_device *pdev) {struct mtk_dp *mtk_dp;@@ -2127,8 +2836,21 @@ static int mtk_dp_probe(struct platform_device *pdev)return dev_err_probe (dev, -EPROBE_DEFER ,"failed to request mediatek dptx irq\n" ); +mutex_init (&mtk_dp->edid_lock); +mutex_init (&mtk_dp->eld_lock); +mutex_init (&mtk_dp->update_plugged_status_lock); +platform_set_drvdata (pdev, mtk_dp); +if (!mtk_dp_is_edp (mtk_dp)) { + ret =mtk_dp_register_audio_driver (dev); +if (ret) { +dev_err (dev,"Failed to register audio driver: %d\n" , + ret); +return ret; + } + } + mtk_dp->phy_dev = platform_device_register_data(dev, "mediatek-dp-phy", PLATFORM_DEVID_AUTO, &mtk_dp->regs,
drivers/gpu/drm/mediatek/mtk_dp.c static int mtk_dp_remove(struct platform_device *pdev) · line 2897
Quoted 2 lines
drivers/gpu/drm/mediatek/mtk_dp.c +0
-0@@ -2174,6 +2896,7 @@ static int mtk_dp_remove(struct platform_device *pdev)platform_device_unregister (mtk_dp->phy_dev);
... and unregister it here:
if (mtk_dp->audio_pdev) platform_device_unregister(mtk_dp->audio_pdev);
drivers/gpu/drm/mediatek/mtk_dp.c static int mtk_dp_remove(struct platform_device *pdev) · line 2902
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c +1
-0mtk_dp_video_mute (mtk_dp, true); +mtk_dp_audio_mute (mtk_dp, true);del_timer_sync (&mtk_dp->debounce_timer);pm_runtime_disable (&pdev->dev);
Regards,
Angelo
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +9
-0+static void mtk_dp_hpd_sink_event (struct mtk_dp *mtk_dp) +{ +ssize_t ret; +u8 sink_count; +u8 link_status[DP_LINK_STATUS_SIZE ] = {}; +u32 sink_count_reg =DP_SINK_COUNT_ESI ; +u32 link_status_reg =DP_LANE0_1_STATUS ; + + ret = drm_dp_dpcd_readb(&mtk_dp->aux, sink_count_reg,
&sink_count);
According to your last reply, if drm_dp_dpcd_readb() fail, we could skip below statement. So this just for error checking? If so, the next drm_dp_dpcd_read() would also do the error checking, so the checking here is redundant.
Regards,
CK
Quoted 28 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +9
-0+if (ret <1 ) { +drm_err (mtk_dp->drm_dev,"Read sink count failed\n" ); +return ; + } + +drm_dbg (mtk_dp->drm_dev, +"read sink count from dpcd: %d\n" , sink_count); + + ret = drm_dp_dpcd_read(&mtk_dp->aux, link_status_reg,
link_status,drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ sizeof(link_status)); +if (!ret) { +drm_err (mtk_dp->drm_dev,"Read link status failed\n" ); +return ; + } + + if (!drm_dp_channel_eq_ok(link_status, mtk_dp-Quoted 1 line
train_info.lane_count)) {
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+drm_err (mtk_dp->drm_dev,"Channel EQ failed\n" ); +return ; + } + +if (link_status[1 ] &DP_REMOTE_CONTROL_COMMAND_PENDING ) + drm_dp_dpcd_writeb(&mtk_dp->aux,
DP_DEVICE_SERVICE_IRQ_VECTOR,drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ DP_REMOTE_CONTROL_COMMAND_PENDING); +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c line 305
Quoted 2 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +2
-0+ +static int mtk_dp_set_color_depth (struct mtk_dp *mtk_dp)
This function just return 0, so let this function to be void.
Regards,
CK
Quoted 14 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +14
-0+{ +/* Only support 8 bits currently */ + mtk_dp->info.depth =DP_MSA_MISC_8_BPC ; + +/* Update MISC0 */ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3034 , +DP_MSA_MISC_8_BPC ,DP_TEST_BIT_DEPTH_MASK ); + +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_303C , +VIDEO_COLOR_DEPTH_DP_ENC0_P0_8BIT , +VIDEO_COLOR_DEPTH_DP_ENC0_P0_MASK ); +return 0 ; +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c line 324
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+ +static void mtk_dp_mn_overwrite_disable (struct mtk_dp *mtk_dp) +{ +mtk_dp_update_bits (mtk_dp,MTK_DP_ENC0_P0_3004 , +0 ,VIDEO_M_CODE_SEL_DP_ENC0_P0_MASK ); +}
Why has mtk_dp_mn_overwrite_disable() but nomtk_dp_mn_overwrite_enable()?
Regards,
CK
Quoted 1 line
+
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 13 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +9
-0+ +static enum drm_mode_status +mtk_dp_bridge_mode_valid (struct drm_bridge *bridge, +const struct drm_display_info *info, +const struct drm_display_mode *mode) +{ +struct mtk_dp *mtk_dp =mtk_dp_from_bridge (bridge); +u32 rx_linkrate = (u32 )mtk_dp->train_info.link_rate *27000 ; + u32 bpp = info->color_formats & DRM_COLOR_FORMAT_YCBCR422 ? 16: 24;
(quoted diff) +2
-0+ + if (rx_linkrate * mtk_dp->train_info.lane_count < mode->clock *bpp / 8)
drivers/gpu/drm/mediatek/mtk_dp.c line 1846
Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+return MODE_CLOCK_HIGH ; + +if (mode->clock >600000 ) +return MODE_CLOCK_HIGH ; + +if ((mode->clock *1000 ) / (mode->htotal * mode->vtotal) > +MTK_VDOSYS1_MAX_FRAMERATE )
Why limit frame rate to 60fps? If the resolution is small enough, why not support higher fps?
Regards,
CK
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+return MODE_CLOCK_HIGH ; + +return MODE_OK ; +} +
kernel test robot
build botRe: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenThank you for the patch! Perhaps something to improve:
Hi Bo-Chen,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on drm/drm-next pza/reset/next linus/master v5.19-rc6 next-20220715] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Bo-Chen-Chen/drm-mediatek-Add-MT8195-DisplayPort-driver/20220712-191341 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next config: arm-allyesconfig (https://download.01.org/0day-ci/archive/20220716/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/a3869f524e16c38015e0f124c6597927fc6d26b0
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Bo-Chen-Chen/drm-mediatek-Add-MT8195-DisplayPort-driver/20220712-191341
git checkout a3869f524e16c38015e0f124c6597927fc6d26b0
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/gpu/drm/mediatek/ drivers/pci/controller/dwc/
If you fix the issue, kindly add following tag where applicable
All warnings (new ones prefixed by >>):
drivers/gpu/drm/mediatek/mtk_dp.c: In function 'mtk_dp_train_tps_1':
>> drivers/gpu/drm/mediatek/mtk_dp.c:1092:12: warning: variable 'val' set but not used [-Wunused-but-set-variable]
1092 | u8 val;
| ^~~
drivers/gpu/drm/mediatek/mtk_dp.c: In function 'mtk_dp_bridge_atomic_get_output_bus_fmts':
drivers/gpu/drm/mediatek/mtk_dp.c:1865:26: error: 'MEDIA_BUS_FMT_FIXED' undeclared (first use in this function)
1865 | output_fmts[0] = MEDIA_BUS_FMT_FIXED;
| ^~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/mediatek/mtk_dp.c:1865:26: note: each undeclared identifier is reported only once for each function it appears in
drivers/gpu/drm/mediatek/mtk_dp.c: At top level:
drivers/gpu/drm/mediatek/mtk_dp.c:1870:9: error: 'MEDIA_BUS_FMT_RGB888_1X24' undeclared here (not in a function)
1870 | MEDIA_BUS_FMT_RGB888_1X24,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/mediatek/mtk_dp.c:1871:9: error: 'MEDIA_BUS_FMT_YUV8_1X24' undeclared here (not in a function)
1871 | MEDIA_BUS_FMT_YUV8_1X24,
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/mediatek/mtk_dp.c:1872:9: error: 'MEDIA_BUS_FMT_YUYV8_1X16' undeclared here (not in a function)
1872 | MEDIA_BUS_FMT_YUYV8_1X16,
| ^~~~~~~~~~~~~~~~~~~~~~~~vim +/val +1092 drivers/gpu/drm/mediatek/mtk_dp.c
1087
1088 static int mtk_dp_train_tps_1(struct mtk_dp *mtk_dp, u8 target_lane_count,
1089 int *iteration_count, u8 *lane_adjust,
1090 int *status_control, u8 *prev_lane_adjust)
1091 {
> 1092 u8 val;
1093 u8 link_status[DP_LINK_STATUS_SIZE] = {};
1094
1095 mtk_dp_training_set_scramble(mtk_dp, false);
1096
1097 if (*status_control == 0) {
1098 mtk_dp_train_set_pattern(mtk_dp, 1);
1099 val = DP_LINK_SCRAMBLING_DISABLE |
1100 DP_TRAINING_PATTERN_1;
1101 drm_dp_dpcd_writeb(&mtk_dp->aux,
1102 DP_TRAINING_PATTERN_SET,
1103 DP_LINK_SCRAMBLING_DISABLE |
1104 DP_TRAINING_PATTERN_1); 1105 drm_dp_dpcd_read(&mtk_dp->aux,
1106 DP_ADJUST_REQUEST_LANE0_1,
1107 lane_adjust,
1108 sizeof(*lane_adjust) * 2);
1109
1110 mtk_dp_train_update_swing_pre(mtk_dp,
1111 target_lane_count, lane_adjust);
1112 *status_control = 1;
1113 (*iteration_count)++;
1114 }
1115
1116 drm_dp_link_train_clock_recovery_delay(&mtk_dp->aux, mtk_dp->rx_cap);
1117 drm_dp_dpcd_read_link_status(&mtk_dp->aux, link_status);
1118
1119 if (drm_dp_clock_recovery_ok(link_status,
1120 target_lane_count)) {
1121 mtk_dp->train_info.cr_done = true;
1122 *iteration_count = 1;
1123 dev_dbg(mtk_dp->dev, "Link train CR pass\n");
1124 return 0;
1125 } else if (*prev_lane_adjust == link_status[4]) {
1126 (*iteration_count)++;
1127 if (*prev_lane_adjust & DP_ADJUST_VOLTAGE_SWING_LANE0_MASK) {
1128 dev_dbg(mtk_dp->dev, "Link train CQ fail\n");
1129 return -EINVAL;
1130 }
1131 } else {
1132 *prev_lane_adjust = link_status[4];
1133 }
1134 return -EAGAIN;
1135 }
1136
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
Rob Herring
maintainerRe: [PATCH v14 01/10] dt-bindings: mediatek,dp: Add Display Port binding
In reply to Bo-Chen ChenQuoted 31 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This controller is present on several mediatek hardware. Currently mt8195 and mt8395 have this controller without a functional difference, so only one compatible field is added.
The controller can have two forms, as a normal display port and as an embedded display port.
Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>--- .../display/mediatek/mediatek,dp.yaml | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yamlDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +8
-0@@ -0,0 +1,115 @@ +# 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 +
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml line 18
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +10
-0+maintainers: + - Chun-Kuang Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + Device tree bindings for the MediaTek display port TX (DP) and + embedded display port TX (eDP) controller present on some MediaTek SoCs. + MediaTek DP and eDP are different hardwares and they have different + base address for registers, so we need two different compatibles to + separate them.
As I said before, 'different base address for registers' is not a reason for different compatibles. If it was, then we'd never have a compatible string appear more than once in a DT.
Explain WHAT is different within the block. For example[1].
Rob
Quoted 101 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +97
-0+ +properties: + compatible: + enum: + - mediatek,mt8195-dp-tx + - mediatek,mt8195-edp-tx + + reg: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + description: efuse data for display port calibration + + nvmem-cell-names: + const: dp_calibration_data + + power-domains: + maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Input endpoint of the controller, usually dp_intf + + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: Output endpoint of the controller + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + properties: + data-lanes: + description: | + number of lanes supported by the hardware. + The possible values: + 0 - For 1 lane enabled in IP. + 0 1 - For 2 lanes enabled in IP. + 0 1 2 3 - For 4 lanes enabled in IP. + minItems: 1 + maxItems: 4 + required: + - data-lanes + + required: + - port@0 + - port@1 + + max-linkrate-mhz: + enum: [ 1620, 2700, 5400, 8100 ] + description: maximum link rate supported by the hardware. + +required: + - compatible + - reg + - interrupts + - ports + - max-linkrate-mhz + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/power/mt8195-power.h> + dp_tx@1c600000 { + compatible = "mediatek,mt8195-dp-tx"; + reg = <0x1c600000 0x8000>; + power-domains = <&spm MT8195_POWER_DOMAIN_DP_TX>; + interrupts = <GIC_SPI 458 IRQ_TYPE_LEVEL_HIGH 0>; + max-linkrate-mhz = <8100>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dptx_in: endpoint { + remote-endpoint = <&dp_intf0_out>; + }; + }; + port@1 { + reg = <1>; + dptx_out: endpoint { + data-lanes = <0 1 2 3>; + }; + }; + }; + };Signature · 1 line
2.18.0
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to CK HuQuoted 50 lines · CK Hu
Hi, Bo-Chen:
Quoted 27 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +9
-0+static void mtk_dp_hpd_sink_event (struct mtk_dp *mtk_dp) +{ +ssize_t ret; +u8 sink_count; +u8 link_status[DP_LINK_STATUS_SIZE ] = {}; +u32 sink_count_reg =DP_SINK_COUNT_ESI ; +u32 link_status_reg =DP_LANE0_1_STATUS ; + + ret = drm_dp_dpcd_readb(&mtk_dp->aux, sink_count_reg,
&sink_count);According to your last reply, if
drm_dp_dpcd_readb()fail, we could skip below statement. So this just for error checking? If so, the nextdrm_dp_dpcd_read()would also do the error checking, so the checking here is redundant.
Quoted 3 lines
Regards,
CK
Hello CK,
sorry, I don't get your point.
We use "drm_dp_dpcd_readb(&mtk_dp->aux, sink_count_reg, &sink_count)" to get sink count and use "drm_dp_dpcd_read(&mtk_dp->aux, link_status_reg, link_status, sizeof(link_status));" to get link status.
If we don't get any sink count, we don't need to check the link status. Therefore, we just return if we are failed to get sink count.
BRs,
Bo-Chen
Quoted 31 lines
Quoted 29 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +9
-0+if (ret <1 ) { +drm_err (mtk_dp->drm_dev,"Read sink count failed\n" ); +return ; + } + +drm_dbg (mtk_dp->drm_dev, +"read sink count from dpcd: %d\n" , sink_count); + + ret = drm_dp_dpcd_read(&mtk_dp->aux, link_status_reg,
link_status,drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ sizeof(link_status)); +if (!ret) { +drm_err (mtk_dp->drm_dev,"Read link status failed\n" ); +return ; + } + + if (!drm_dp_channel_eq_ok(link_status, mtk_dp-Quoted 1 line
train_info.lane_count)) {
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+drm_err (mtk_dp->drm_dev,"Channel EQ failed\n" ); +return ; + } + +if (link_status[1 ] &DP_REMOTE_CONTROL_COMMAND_PENDING ) + drm_dp_dpcd_writeb(&mtk_dp->aux,
DP_DEVICE_SERVICE_IRQ_VECTOR,drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ DP_REMOTE_CONTROL_COMMAND_PENDING); +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
Hi, Rex:
Quoted 66 lines · Rex-BC Chen
Quoted 53 lines · CK Hu
Hi, Bo-Chen:
Quoted 29 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a
register range, the parent passes a regmap pointer to the child so
that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +9
-0+static void mtk_dp_hpd_sink_event (struct mtk_dp *mtk_dp) +{ +ssize_t ret; +u8 sink_count; +u8 link_status[DP_LINK_STATUS_SIZE ] = {}; +u32 sink_count_reg =DP_SINK_COUNT_ESI ; +u32 link_status_reg =DP_LANE0_1_STATUS ; + + ret = drm_dp_dpcd_readb(&mtk_dp->aux, sink_count_reg,
&sink_count);According to your last reply, if
drm_dp_dpcd_readb()fail, we could skip below statement. So this just for error checking? If so, the nextdrm_dp_dpcd_read()would also do the error checking, so the checking
here is redundant.Quoted 3 lines
Regards,
CKHello CK,
sorry, I don't get your point.
We use "drm_dp_dpcd_readb(&mtk_dp->aux, sink_count_reg, &sink_count)" to get sink count and use "drm_dp_dpcd_read(&mtk_dp->aux, link_status_reg, link_status, sizeof(link_status));" to get link status.
Quoted 3 lines
If we don't get any sink count, we don't need to check the link status.
Therefore, we just return if we are failed to get sink count.
I assume that when error happen, both read sink_count and read link_status would fail, so you could directly read link_status. Do you think that when error happen, only read sink_count would fail and read link_status would success? It it is the later case, we should keep the checking of sink_count.
Regards,
CK
Quoted 37 lines
BRs,
Bo-ChenQuoted 31 lines
Quoted 29 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +9
-0+if (ret <1 ) { +drm_err (mtk_dp->drm_dev,"Read sink count failed\n" ); +return ; + } + +drm_dbg (mtk_dp->drm_dev, +"read sink count from dpcd: %d\n" , sink_count); + + ret = drm_dp_dpcd_read(&mtk_dp->aux, link_status_reg,
link_status,drivers/gpu/drm/mediatek/mtk_dp.c new file +7
-0+ sizeof(link_status)); +if (!ret) { +drm_err (mtk_dp->drm_dev,"Read link status failed\n" ); +return ; + } + + if (!drm_dp_channel_eq_ok(link_status, mtk_dp-Quoted 1 line
train_info.lane_count)) {
drivers/gpu/drm/mediatek/mtk_dp.c new file +6
-0+drm_err (mtk_dp->drm_dev,"Channel EQ failed\n" ); +return ; + } + +if (link_status[1 ] &DP_REMOTE_CONTROL_COMMAND_PENDING ) + drm_dp_dpcd_writeb(&mtk_dp->aux,
DP_DEVICE_SERVICE_IRQ_VECTOR,drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ DP_REMOTE_CONTROL_COMMAND_PENDING); +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c line 1454
Quoted 13 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +13
-0+ +static int mtk_dp_training (struct mtk_dp *mtk_dp) +{ +short max_retry =50 ; +int ret; + +do { + ret =mtk_dp_train_start (mtk_dp); +if (!ret) +break ; +else if (ret != -EAGAIN ) +return ret; + }while (--max_retry);
mtk_dp_train_start() would never return -EAGAIN, so drop this while loop.
Regards,
CK
Quoted 12 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+if (!max_retry) +return -ETIMEDOUT ; + + ret =mtk_dp_video_config (mtk_dp); +if (ret) +return ret; +mtk_dp_video_enable (mtk_dp, true); + +return 0 ; +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 25 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195 SoC.
It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 20 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ +/* +* We need to handle HPD signal in eDP even though eDP is a always connected
+ * device. Besides connected status, there is another feature for HPD signal -
+ * HPD pulse: it presents an IRQ from sink devices to source devices (Refer to
+ * 5.1.4 of DP1.4 spec).
+ */drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+static irqreturn_t mtk_dp_hpd_isr_handler (struct mtk_dp *mtk_dp) +{ +bool hpd_change = false; +u32 irq_status =mtk_dp_swirq_get_clear (mtk_dp) | +mtk_dp_hwirq_get_clear (mtk_dp); +struct mtk_dp_train_info *train_info = &mtk_dp->train_info; + +if (!irq_status) +return IRQ_HANDLED ; +
drivers/gpu/drm/mediatek/mtk_dp.c line 1535
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +10
-0+if (irq_status &MTK_DP_HPD_INTERRUPT ) + train_info->irq_sta.hpd_inerrupt = true; +if (irq_status &MTK_DP_HPD_CONNECT || + irq_status &MTK_DP_HPD_DISCONNECT ) + hpd_change = true; + +if (!(hpd_change)) +return IRQ_WAKE_THREAD ; + +if (mtk_dp_plug_state (mtk_dp))
mtk_dp_plug_state() is called only here, and prevent function call in isr handler, so squash mtk_dp_plug_state() into this function.
Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+ train_info->cable_plugged_in = true; + else + train_info->cable_plugged_in = false; + + 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/mtk_dp.c line 1556
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +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);
Prevent function call in isr handler, squash mtk_dp_hpd_isr_handler() into this function.
Regards,
CK
Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ +return IRQ_HANDLED ; +} +
Re: [PATCH v14 06/10] drm/mediatek: Add MT8195 External DisplayPort support
In reply to Bo-Chen ChenHi, Bo-Chen:
Quoted 8 lines · Bo-Chen Chen
From: Guillaume Ranquet <[email protected]>
This patch adds External DisplayPort support to the mt8195 eDP driver.
Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c static int mtk_dp_init_port(struct mtk_dp · line 1554
Quoted 13 lines
drivers/gpu/drm/mediatek/mtk_dp.c +7
-0@@ -1489,13 +1543,34 @@ static int mtk_dp_init_port(struct mtk_dp *mtk_dp)static irqreturn_t mtk_dp_hpd_event_thread (int hpd,void *dev) {struct mtk_dp *mtk_dp = dev; +int event; + + event =mtk_dp_plug_state (mtk_dp) ? + connector_status_connected : connector_status_disconnected; + +if (event <0 ) +return IRQ_HANDLED ;
event is useless, so drop it.
Regards,
CK
Quoted 35 lines
drivers/gpu/drm/mediatek/mtk_dp.c +14
-3+ +dev_dbg (mtk_dp->dev,"drm_helper_hpd_irq_event\n" ); +drm_helper_hpd_irq_event (mtk_dp->bridge.dev);if (mtk_dp->train_info.cable_state_change) { mtk_dp->train_info.cable_state_change = false; -mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , -DP_PWR_STATE_BANDGAP_TPLL_LANE , -DP_PWR_STATE_MASK ); +if (!mtk_dp->train_info.cable_plugged_in) { +mtk_dp_video_mute (mtk_dp, true); + +mtk_dp_initialize_priv_data (mtk_dp); +mtk_dp_set_idle_pattern (mtk_dp, true); + +mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , +DP_PWR_STATE_BANDGAP_TPLL , +DP_PWR_STATE_MASK ); + }else { + mtk_dp_update_bits(mtk_dp,
MTK_DP_TOP_PWR_STATE,(quoted diff) +1
-0+ DP_PWR_STATE_BANDGAP_TPLL_LANE,
drivers/gpu/drm/mediatek/mtk_dp.c +2
-0+ DP_PWR_STATE_MASK); + } }if (mtk_dp->train_info.irq_sta.hpd_inerrupt) {@@ -1597,6 +1672,24 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp, return 0; }
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to CK HuQuoted 59 lines · CK Hu
Hi, Bo-Chen:
Quoted 27 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 26 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ +/* +* We need to handle HPD signal in eDP even though eDP is a always connected
+ * device. Besides connected status, there is another feature for HPD signal -
+ * HPD pulse: it presents an IRQ from sink devices to source devices
(Refer to
+ * 5.1.4 of DP1.4 spec).
+ */drivers/gpu/drm/mediatek/mtk_dp.c new file +15
-0+static irqreturn_t mtk_dp_hpd_isr_handler (struct mtk_dp *mtk_dp) +{ +bool hpd_change = false; +u32 irq_status =mtk_dp_swirq_get_clear (mtk_dp) | +mtk_dp_hwirq_get_clear (mtk_dp); +struct mtk_dp_train_info *train_info = &mtk_dp->train_info; + +if (!irq_status) +return IRQ_HANDLED ; + +if (irq_status &MTK_DP_HPD_INTERRUPT ) + train_info->irq_sta.hpd_inerrupt = true; +if (irq_status &MTK_DP_HPD_CONNECT || + irq_status &MTK_DP_HPD_DISCONNECT ) + hpd_change = true;
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1535
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+ +if (!(hpd_change)) +return IRQ_WAKE_THREAD ; + +if (mtk_dp_plug_state (mtk_dp))
mtk_dp_plug_state()is called only here, and prevent function call in isr handler, so squashmtk_dp_plug_state()into this function.
Hello CK,
Thanks for review.
I would like to keep this because we will use this function for mtk_dp_plug_state_avoid_pulse() in dp patch.
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +16
-0+ train_info->cable_plugged_in = true; + else + train_info->cable_plugged_in = false; + + train_info->cable_state_change = true; + +return IRQ_WAKE_THREAD ; +} + +static irqreturn_t mtk_dp_hpd_event (int hpd,void *dev) +{ +struct mtk_dp *mtk_dp = dev; +u32 irq_status; + + irq_status =mtk_dp_read (mtk_dp,MTK_DP_TOP_IRQ_STATUS ); +
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1556
Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +5
-0+if (!irq_status) +return IRQ_HANDLED ; + +if (irq_status &RGS_IRQ_STATUS_TRANSMITTER ) +return mtk_dp_hpd_isr_handler (mtk_dp);Prevent function call in isr handler, squash
mtk_dp_hpd_isr_handler()into this function.
Is this really necessary? We also modify this function in following patches. I think it's not a good idea to expand this.
BRs,
Bo-Chen
Quoted 9 lines
Regards,
CKQuoted 4 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ +return IRQ_HANDLED ; +} +
Re: [PATCH v14 01/10] dt-bindings: mediatek,dp: Add Display Port binding
In reply to CK HuQuoted 143 lines · CK Hu
Hi, Bo-Chen:
Quoted 125 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This controller is present on several mediatek hardware. Currently mt8195 and mt8395 have this controller without a functional difference,
so only one compatible field is added.The controller can have two forms, as a normal display port and as an
embedded display port.Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>--- .../display/mediatek/mediatek,dp.yaml | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yamldiff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.ya ml b/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.ya ml
new file mode 100644
index 000000000000..e2d6cb314297
---/dev/null
+++
b/Documentation/devicetree/bindings/display/mediatek/mediatek,dp.ya mlDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +4
-0@@ -0,0 +1,115 @@ +# 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#Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +10
-0+ +title: MediaTek Display Port Controller + +maintainers: + - Chun-Kuang Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + Device tree bindings for the MediaTek display port TX (DP) and + embedded display port TX (eDP) controller present on someMediaTek
SoCs.
+ MediaTek DP and eDP are different hardwares and they have different
+ base address for registers, so we need two different compatibles toDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +30
-0+ separate them. + +properties: + compatible: + enum: + - mediatek,mt8195-dp-tx + - mediatek,mt8195-edp-tx + + reg: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + description: efuse data for display port calibration + + nvmem-cell-names: + const: dp_calibration_data + + power-domains: + maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Input endpoint of the controller, usually
dp_intfDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +39
-0+ + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: Output endpoint of the controller + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + properties: + data-lanes: + description: | + number of lanes supported by the hardware. + The possible values: + 0 - For 1 lane enabled in IP. + 0 1 - For 2 lanes enabled in IP. + 0 1 2 3 - For 4 lanes enabled in IP. + minItems: 1 + maxItems: 4 + required: + - data-lanes + + required: + - port@0 + - port@1 + + max-linkrate-mhz: + enum: [ 1620, 2700, 5400, 8100 ] + description: maximum link rate supported by the hardware. + +required: + - compatible + - reg + - interrupts + - ports + - max-linkrate-mhz + +additionalProperties: false +Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml line 96
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +10
-0+examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/power/mt8195-power.h> + dp_tx@1c600000 { + compatible = "mediatek,mt8195-dp-tx"; + reg = <0x1c600000 0x8000>; + power-domains = <&spm MT8195_POWER_DOMAIN_DP_TX>; + interrupts = <GIC_SPI 458 IRQ_TYPE_LEVEL_HIGH 0>; + max-linkrate-mhz = <8100>;Why dp-tx has no clock property? I think this device should work with a
clock.
Quoted 3 lines
Regards,
CK
Hello CK,
We just need to enable the power domain of dp.
The clock of dp is generated by itself and we are not using the global pll to generate clocks.
BRs,
Bo-Chen
Quoted 21 lines
Quoted 19 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +19
-0+ + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dptx_in: endpoint { + remote-endpoint = <&dp_intf0_out>; + }; + }; + port@1 { + reg = <1>; + dptx_out: endpoint { + data-lanes = <0 1 2 3>; + }; + }; + }; + };
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to CK HuQuoted 50 lines · CK Hu
Hi, Bo-Chen:
Quoted 27 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a register range, the parent passes a regmap pointer to the child so that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c line 1454
Quoted 13 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +13
-0+ +static int mtk_dp_training (struct mtk_dp *mtk_dp) +{ +short max_retry =50 ; +int ret; + +do { + ret =mtk_dp_train_start (mtk_dp); +if (!ret) +break ; +else if (ret != -EAGAIN ) +return ret; + }while (--max_retry);
mtk_dp_train_start()would never return-EAGAIN, so drop this while loop.
Quoted 3 lines
Regards,
CK
Hello CK,
the function will not return -EAGAIN, but we still want to retry 50 times if mtk_dp_train_start() is failed. If we retry 50 times and it is still failed. We can confirm there are some issues for the device.
I will remove the else if of -EAGAIN and keep th while loop.
BRs,
Bo-Chen
Quoted 14 lines
Quoted 12 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+if (!max_retry) +return -ETIMEDOUT ; + + ret =mtk_dp_video_config (mtk_dp); +if (ret) +return ret; +mtk_dp_video_enable (mtk_dp, true); + +return 0 ; +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Rex-BC ChenQuoted 75 lines · Rex-BC Chen
Quoted 64 lines · CK Hu
Hi, Bo-Chen:
Quoted 29 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a
register range, the parent passes a regmap pointer to the child so
that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
Quoted 29 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +3
-0+ +/* +* We need to handle HPD signal in eDP even though eDP is a always
connected
+ * device. Besides connected status, there is another feature for
HPD signal -
+ * HPD pulse: it presents an IRQ from sink devices to source devices
(Refer to
+ * 5.1.4 of DP1.4 spec).
+ */drivers/gpu/drm/mediatek/mtk_dp.c new file +16
-0+static irqreturn_t mtk_dp_hpd_isr_handler (struct mtk_dp *mtk_dp) +{ +bool hpd_change = false; +u32 irq_status =mtk_dp_swirq_get_clear (mtk_dp) | +mtk_dp_hwirq_get_clear (mtk_dp); +struct mtk_dp_train_info *train_info = &mtk_dp->train_info; + +if (!irq_status) +return IRQ_HANDLED ; + +if (irq_status &MTK_DP_HPD_INTERRUPT ) + train_info->irq_sta.hpd_inerrupt = true; +if (irq_status &MTK_DP_HPD_CONNECT || + irq_status &MTK_DP_HPD_DISCONNECT ) + hpd_change = true; +Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1535
Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+if (!(hpd_change)) +return IRQ_WAKE_THREAD ; + +if (mtk_dp_plug_state (mtk_dp))
mtk_dp_plug_state()is called only here, and prevent function call in
isr handler, so squashmtk_dp_plug_state()into this function.
Quoted 6 lines
Hello CK,
Thanks for review.
I would like to keep this because we will use this function for
mtk_dp_plug_state_avoid_pulse()in dp patch.
Use train_info->cable_plugged_in instead of calling mtk_dp_plug_state() because I think train_info->cable_plugged_in is synced with mtk_dp_plug_state().
Quoted 28 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +17
-0+ train_info->cable_plugged_in = true; + else + train_info->cable_plugged_in = false; + + train_info->cable_state_change = true; + +return IRQ_WAKE_THREAD ; +} + +static irqreturn_t mtk_dp_hpd_event (int hpd,void *dev) +{ +struct mtk_dp *mtk_dp = dev; +u32 irq_status; + + irq_status =mtk_dp_read (mtk_dp,MTK_DP_TOP_IRQ_STATUS ); + +if (!irq_status)Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dp.c line 1556
Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+return IRQ_HANDLED ; + +if (irq_status &RGS_IRQ_STATUS_TRANSMITTER ) +return mtk_dp_hpd_isr_handler (mtk_dp);Prevent function call in isr handler, squash
mtk_dp_hpd_isr_handler()
into this function.
Quoted 2 lines
Is this really necessary? We also modify this function in following patches. I think it's not a good idea to expand this.
mtk_dp_hpd_isr_handler() is only called in this function, is it really necessary to separate this to a independent function? The function call would increase jump instruction and stack push/pop instruction. I think we should not do many things in isr handler. I've reviewed the later patch and the later patch should be modified according to this.
Regards,
CK
Quoted 15 lines
BRs,
Bo-ChenQuoted 9 lines
Regards,
CKQuoted 4 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +4
-0+ +return IRQ_HANDLED ; +} +
Re: [PATCH v14 01/10] dt-bindings: mediatek,dp: Add Display Port binding
In reply to Rex-BC ChenQuoted 156 lines · Rex-BC Chen
Quoted 151 lines · CK Hu
Hi, Bo-Chen:
Quoted 132 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This controller is present on several mediatek hardware. Currently
mt8195 and mt8395 have this controller without a functional difference,
so only one compatible field is added.The controller can have two forms, as a normal display port and as
an
embedded display port.Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>--- .../display/mediatek/mediatek,dp.yaml | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yamldiff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,dp. ya
ml b/Documentation/devicetree/bindings/display/mediatek/mediatek,dp. ya
ml
new file mode 100644
index 000000000000..e2d6cb314297
---/dev/null
+++
b/Documentation/devicetree/bindings/display/mediatek/mediatek,dp. ya
mlDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +4
-0@@ -0,0 +1,115 @@ +# 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#Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +10
-0+ +title: MediaTek Display Port Controller + +maintainers: + - Chun-Kuang Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + Device tree bindings for the MediaTek display port TX (DP) and + embedded display port TX (eDP) controller present on someMediaTek
SoCs.
+ MediaTek DP and eDP are different hardwares and they have different
+ base address for registers, so we need two different compatibles
toDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +30
-0+ separate them. + +properties: + compatible: + enum: + - mediatek,mt8195-dp-tx + - mediatek,mt8195-edp-tx + + reg: + maxItems: 1 + + nvmem-cells: + maxItems: 1 + description: efuse data for display port calibration + + nvmem-cell-names: + const: dp_calibration_data + + power-domains: + maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Input endpoint of the controller, usually
dp_intfDocumentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +39
-0+ + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: Output endpoint of the controller + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + properties: + data-lanes: + description: | + number of lanes supported by the hardware. + The possible values: + 0 - For 1 lane enabled in IP. + 0 1 - For 2 lanes enabled in IP. + 0 1 2 3 - For 4 lanes enabled in IP. + minItems: 1 + maxItems: 4 + required: + - data-lanes + + required: + - port@0 + - port@1 + + max-linkrate-mhz: + enum: [ 1620, 2700, 5400, 8100 ] + description: maximum link rate supported by the hardware. + +required: + - compatible + - reg + - interrupts + - ports + - max-linkrate-mhz + +additionalProperties: false +Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml line 96
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +10
-0+examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/power/mt8195-power.h> + dp_tx@1c600000 { + compatible = "mediatek,mt8195-dp-tx"; + reg = <0x1c600000 0x8000>; + power-domains = <&spm MT8195_POWER_DOMAIN_DP_TX>; + interrupts = <GIC_SPI 458 IRQ_TYPE_LEVEL_HIGH 0>; + max-linkrate-mhz = <8100>;Why dp-tx has no clock property? I think this device should work with
a
clock.Quoted 3 lines
Regards,
CK
Quoted 6 lines
Hello CK,
We just need to enable the power domain of dp.
The clock of dp is generated by itself and we are not using the global
pll to generate clocks.
Add this to description because this is not trivial.
Regards,
CK
Quoted 27 lines
BRs,
Bo-ChenQuoted 21 lines
Quoted 19 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,dp.yaml new file +19
-0+ + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dptx_in: endpoint { + remote-endpoint = <&dp_intf0_out>; + }; + }; + port@1 { + reg = <1>; + dptx_out: endpoint { + data-lanes = <0 1 2 3>; + }; + }; + }; + };
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
In reply to Rex-BC ChenQuoted 57 lines · Rex-BC Chen
Quoted 52 lines · CK Hu
Hi, Bo-Chen:
Quoted 29 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers DisplayPort 1.4 with up to 4 lanes.
The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing a
register range, the parent passes a regmap pointer to the child so
that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c line 1454
Quoted 13 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +13
-0+ +static int mtk_dp_training (struct mtk_dp *mtk_dp) +{ +short max_retry =50 ; +int ret; + +do { + ret =mtk_dp_train_start (mtk_dp); +if (!ret) +break ; +else if (ret != -EAGAIN ) +return ret; + }while (--max_retry);
mtk_dp_train_start()would never return-EAGAIN, so drop this while loop.Quoted 3 lines
Regards,
CK
Quoted 8 lines
Hello CK,
the function will not return
-EAGAIN, but we still want to retry 50 times ifmtk_dp_train_start()is failed. If we retry 50 times and it is
still failed. We can confirm there are some issues for the device.I will remove the else if of
-EAGAINand keep th while loop.
In this version, it never retry. And I believe you've tested this no- retry version. If this no-retry version works fine, why do you insist on retry? If you really need retry, merge this retry into mtk_dp_train_start() because mtk_dp_train_start() have already retry.
Regards,
CK
Quoted 19 lines
BRs,
Bo-ChenQuoted 14 lines
Quoted 12 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+if (!max_retry) +return -ETIMEDOUT ; + + ret =mtk_dp_video_config (mtk_dp); +if (ret) +return ret; +mtk_dp_video_enable (mtk_dp, true); + +return 0 ; +} +
Re: [PATCH v14 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
Quoted 72 lines · CK Hu
Quoted 63 lines · Rex-BC Chen
Quoted 56 lines · CK Hu
Hi, Bo-Chen:
Quoted 32 lines · Bo-Chen Chen
From: Markus Schneider-Pargmann <[email protected]>
This patch adds a embedded displayport driver for the MediaTek mt8195
SoC.It supports the MT8195, the embedded DisplayPort units. It offers
DisplayPort 1.4 with up to 4 lanes.The driver creates a child device for the phy. The child device will
never exist without the parent being active. As they are sharing
a
register range, the parent passes a regmap pointer to the child so
that
both can work with the same register range. The phy driver sets device
data that is read by the parent to get the phy device that can be
used
to control the phy properties.This driver is based on an initial version by
Jitao shi <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>Signed-off-by Guillaume Ranquet <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_dp.c line 1454
Quoted 13 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +13
-0+ +static int mtk_dp_training (struct mtk_dp *mtk_dp) +{ +short max_retry =50 ; +int ret; + +do { + ret =mtk_dp_train_start (mtk_dp); +if (!ret) +break ; +else if (ret != -EAGAIN ) +return ret; + }while (--max_retry);
mtk_dp_train_start()would never return-EAGAIN, so drop this while
loop.Quoted 3 lines
Regards,
CKHello CK,
Quoted 7 lines
the function will not return
-EAGAIN, but we still want to retry 50 times ifmtk_dp_train_start()is failed. If we retry 50 times and it
is
still failed. We can confirm there are some issues for the device.I will remove the else if of
-EAGAINand keep th while loop.
Quoted 8 lines
In this version, it never retry. And I believe you've tested this no- retry version. If this no-retry version works fine, why do you insist on retry? If you really need retry, merge this retry into
mtk_dp_train_start()becausemtk_dp_train_start()have already retry.Regards,
CK
Hello Ck,
There are many different devices we are not testing for DP devices. I think we need to keep this.
This retry is for restart with init state.
I think it's better to keep it here and it's more clear.
I will remain the comments above, and I think it's enough.
BRs,
Bo-Chen
Quoted 21 lines
Quoted 19 lines
BRs,
Bo-ChenQuoted 14 lines
Quoted 12 lines
drivers/gpu/drm/mediatek/mtk_dp.c new file +11
-0+if (!max_retry) +return -ETIMEDOUT ; + + ret =mtk_dp_video_config (mtk_dp); +if (ret) +return ret; +mtk_dp_video_enable (mtk_dp, true); + +return 0 ; +} +