Add MT8195 HDMI support
Subsystems (5)
v4 cover Add MT8195 HDMI support
Add support for HDMI Tx on MT8195.
This includes a split of the current "legacy" hdmi driver into a common library of functions and two dedicated compilation units with specific code for mt8167 and another for the "v2" mt8195 SoC.
Support for the new mt8195 dpi/drm_drv adjustments to support hdmi.
Based on next-20230523
Still in my TODO-list for v5:
- Removal of the 'is_internal_hdmi' flag in mtk_dpi. [1]
I Couldn't find a way to get rid of it with the way things are done in mtk_drm_drv/mtk_ddp_comp.
- Do not use a "virtual" device for the ddc v2 hw as it is embedded in the hdmi IP. [2]
Seems that a lot of work is done by the framework when using a proper device-tree entry that can be linked as the ddc-i2c-bus of the hdmi-connector.
I will keep the virtual device unless I find a way to avoid rewriting the framework code that handles this.
[1] : https://lore.kernel.org/all/[email protected]/
[2] : https://lore.kernel.org/all/[email protected]/
---
Changes in v4:
- Split phy related patches to another series (merged)
- Removed regmap wrappers in mtk_hdmi
- Removed colorimetry related changes as this initial version only support one color depth
- Fixed dt-bindings properties
- Removed some now useless clocks from mtk_hdmi_v2 and mtk_dpi
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- phy: Grouped register and bit definition together to add clarity
- dt-bindings: Addressed comments
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Removed syscon requirement from the hdmi node
- Use as much as possible bit FIELD_PREP/FIELD_GET macros across all the patches
- Make cec optional dynamically instead of hardcoded with a flag
- Renamed hdmi variants to v1 (legacy) and v2 (mt8195) while waiting for a better name
- Rework hdmi v2 code to use a connector (same as v1)
- Remove "magic" 0x43 addr special handling in hdmi ddc code
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Guillaume Ranquet (8):
dt-bindings: display: mediatek: add MT8195 hdmi bindings drm/mediatek: hdmi: use a regmap instead of iomem drm/mediatek: extract common functions from the mtk hdmi driver drm/mediatek: hdmi: make the cec dev optional
drm/mediatek: hdmi: add v2 support
drm/mediatek: hdmi: v2: add audio support
dt-bindings: display: mediatek: dpi: Add compatible for MediaTek MT8195 drm/mediatek: dpi: Add mt8195 hdmi to DPI driver
.../bindings/display/mediatek/mediatek,dpi.yaml | 1 + .../bindings/display/mediatek/mediatek,hdmi.yaml | 59 +- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 45 + drivers/gpu/drm/mediatek/Kconfig | 2 + drivers/gpu/drm/mediatek/Makefile | 5 +- drivers/gpu/drm/mediatek/mtk_dpi.c | 121 +- drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 5 + drivers/gpu/drm/mediatek/mtk_hdmi.c | 773 ++---------- drivers/gpu/drm/mediatek/mtk_hdmi.h | 18 + drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 437 +++++++ drivers/gpu/drm/mediatek/mtk_hdmi_common.h | 208 ++++ drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c | 362 ++++++ drivers/gpu/drm/mediatek/mtk_hdmi_regs_v2.h | 276 +++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.c | 1303 ++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.h | 32 + 15 files changed, 2955 insertions(+), 692 deletions(-)
---
base-commit: c8a64c6a78c54887da437098d97dc2accc689e89
change-id: 20220919-hdmi_mtk
Best regards,
Signature · 1 line
Guillaume Ranquet <[email protected]>
PATCH v4 1/8 dt-bindings: display: mediatek: add MT8195 hdmi bindings
Add mt8195 SoC bindings for hdmi and hdmi-ddc
On mt8195 the ddc i2c controller is part of the hdmi IP block and thus has no specific register range, power domain or interrupt, making it simpler than the legacy "mediatek,hdmi-ddc" binding.
--- .../bindings/display/mediatek/mediatek,hdmi.yaml | 59 ++++++++++++++++++---- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 45 +++++++++++++++++ 2 files changed, 93 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +48 -11
@@ -21,6 +21,7 @@ properties: - mediatek,mt7623-hdmi - mediatek,mt8167-hdmi - mediatek,mt8173-hdmi + - mediatek,mt8195-hdmi reg: maxItems: 1
@@ -29,18 +30,10 @@ properties: maxItems: 1 clocks: - items: - - description: Pixel Clock - - description: HDMI PLL - - description: Bit Clock - - description: S/PDIF Clock + maxItems: 4 clock-names: - items: - - const: pixel - - const: pll - - const: bclk - - const: spdif + maxItems: 4 phys: maxItems: 1
@@ -58,6 +51,9 @@ properties: description: | phandle link and register offset to the system configuration registers. + power-domains: + maxItems: 1 + ports: $ref: /schemas/graph.yaml#/properties/ports
@@ -86,9 +82,50 @@ required: - clock-names - phys - phy-names - - mediatek,syscon-hdmi - ports +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt8195-hdmi + then: + properties: + clocks: + items: + - description: APB + - description: HDCP + - description: HDCP 24M + - description: Split HDMI + clock-names: + items: + - const: hdmi_apb_sel + - const: hdcp_sel + - const: hdcp24_sel + - const: split_hdmi + + required: + - power-domains + else: + properties: + clocks: + items: + - description: Pixel Clock + - description: HDMI PLL + - description: Bit Clock + - description: S/PDIF Clock + + clock-names: + items: + - const: pixel + - const: pll + - const: bclk + - const: spdif + + required: + - mediatek,syscon-hdmi + additionalProperties: false examples:
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.40.0
PATCH v4 2/8 drm/mediatek: hdmi: use a regmap instead of iomem
In reply to Guillaume RanquetTo prepare support for newer chips that need to share their address range with a dedicated ddc driver, use a regmap.
--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 173 ++++++++++++++---------------------- 1 file changed, 65 insertions(+), 108 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi.c +65 -108
@@ -171,7 +171,7 @@ struct mtk_hdmi {u32 ibias_up;struct regmap *sys_regmap;unsigned int sys_offset; -void __iomem *regs; +struct regmap *regs;enum hdmi_colorspace csp;struct hdmi_audio_param aud_param;bool audio_enable;
@@ -187,50 +187,10 @@ static inline struct mtk_hdmi *hdmi_ctx_from_bridge(struct drm_bridge *b) return container_of(b, struct mtk_hdmi, bridge); } -static u32 mtk_hdmi_read (struct mtk_hdmi *hdmi,u32 offset) -{ -return readl (hdmi->regs + offset); -} - -static void mtk_hdmi_write (struct mtk_hdmi *hdmi,u32 offset,u32 val) -{ -writel (val, hdmi->regs + offset); -} - -static void mtk_hdmi_clear_bits (struct mtk_hdmi *hdmi,u32 offset,u32 bits) -{ -void __iomem *reg = hdmi->regs + offset; -u32 tmp; - - tmp =readl (reg); - tmp &= ~bits; -writel (tmp, reg); -} - -static void mtk_hdmi_set_bits (struct mtk_hdmi *hdmi,u32 offset,u32 bits) -{ -void __iomem *reg = hdmi->regs + offset; -u32 tmp; - - tmp =readl (reg); - tmp |= bits; -writel (tmp, reg); -} - -static void mtk_hdmi_mask (struct mtk_hdmi *hdmi,u32 offset,u32 val,u32 mask) -{ -void __iomem *reg = hdmi->regs + offset; -u32 tmp; - - tmp =readl (reg); - tmp = (tmp & ~mask) | (val & mask); -writel (tmp, reg); -} -static void mtk_hdmi_hw_vid_black (struct mtk_hdmi *hdmi,bool black) { -mtk_hdmi_mask (hdmi,VIDEO_CFG_4 , black ?GEN_RGB :NORMAL_PATH , -VIDEO_SOURCE_SEL ); +regmap_update_bits (hdmi->regs,VIDEO_SOURCE_SEL , +VIDEO_CFG_4 , black ?GEN_RGB :NORMAL_PATH ); }static void mtk_hdmi_hw_make_reg_writable (struct mtk_hdmi *hdmi,bool enable)
@@ -265,12 +225,12 @@ static void mtk_hdmi_hw_1p4_version_enable(struct mtk_hdmi *hdmi, bool enable)static void mtk_hdmi_hw_aud_mute (struct mtk_hdmi *hdmi) { -mtk_hdmi_set_bits (hdmi,GRL_AUDIO_CFG ,AUDIO_ZERO ); +regmap_set_bits (hdmi->regs,GRL_AUDIO_CFG ,AUDIO_ZERO ); }static void mtk_hdmi_hw_aud_unmute (struct mtk_hdmi *hdmi) { -mtk_hdmi_clear_bits (hdmi,GRL_AUDIO_CFG ,AUDIO_ZERO ); +regmap_clear_bits (hdmi->regs,GRL_AUDIO_CFG ,AUDIO_ZERO ); }static void mtk_hdmi_hw_reset (struct mtk_hdmi *hdmi)
@@ -279,25 +239,25 @@ static void mtk_hdmi_hw_reset(struct mtk_hdmi *hdmi) HDMI_RST, HDMI_RST);regmap_update_bits (hdmi->sys_regmap, hdmi->sys_offset +HDMI_SYS_CFG1C ,HDMI_RST ,0 ); -mtk_hdmi_clear_bits (hdmi,GRL_CFG3 ,CFG3_CONTROL_PACKET_DELAY ); +regmap_clear_bits (hdmi->regs,GRL_CFG3 ,CFG3_CONTROL_PACKET_DELAY );regmap_update_bits (hdmi->sys_regmap, hdmi->sys_offset +HDMI_SYS_CFG1C ,ANLG_ON ,ANLG_ON ); }static void mtk_hdmi_hw_enable_notice (struct mtk_hdmi *hdmi,bool enable_notice) { -mtk_hdmi_mask (hdmi,GRL_CFG2 , enable_notice ?CFG2_NOTICE_EN :0 , -CFG2_NOTICE_EN ); +regmap_update_bits (hdmi->regs,GRL_CFG2 ,CFG2_NOTICE_EN , + enable_notice ?CFG2_NOTICE_EN :0 ); }static void mtk_hdmi_hw_write_int_mask (struct mtk_hdmi *hdmi,u32 int_mask) { -mtk_hdmi_write (hdmi,GRL_INT_MASK , int_mask); +regmap_write (hdmi->regs,GRL_INT_MASK , int_mask); }static void mtk_hdmi_hw_enable_dvi_mode (struct mtk_hdmi *hdmi,bool enable) { -mtk_hdmi_mask (hdmi,GRL_CFG1 , enable ?CFG1_DVI :0 ,CFG1_DVI ); +regmap_update_bits (hdmi->regs,GRL_CFG1 ,CFG1_DVI , enable ?CFG1_DVI :0 ); } static void mtk_hdmi_hw_send_info_frame(struct mtk_hdmi *hdmi, u8 *buffer,
@@ -343,22 +303,22 @@ static void mtk_hdmi_hw_send_info_frame(struct mtk_hdmi *hdmi, u8 *buffer,dev_err (hdmi->dev,"Unknown infoframe type %d\n" , frame_type);return ; } -mtk_hdmi_clear_bits (hdmi, ctrl_reg, ctrl_frame_en); -mtk_hdmi_write (hdmi,GRL_INFOFRM_TYPE , frame_type); -mtk_hdmi_write (hdmi,GRL_INFOFRM_VER , frame_ver); -mtk_hdmi_write (hdmi,GRL_INFOFRM_LNG , frame_len); +regmap_clear_bits (hdmi->regs, ctrl_reg, ctrl_frame_en); +regmap_write (hdmi->regs,GRL_INFOFRM_TYPE , frame_type); +regmap_write (hdmi->regs,GRL_INFOFRM_VER , frame_ver); +regmap_write (hdmi->regs,GRL_INFOFRM_LNG , frame_len); -mtk_hdmi_write (hdmi,GRL_IFM_PORT , checksum); +regmap_write (hdmi->regs,GRL_IFM_PORT , checksum);for (i =0 ; i < frame_len; i++) -mtk_hdmi_write (hdmi,GRL_IFM_PORT , frame_data[i]); +regmap_write (hdmi->regs,GRL_IFM_PORT , frame_data[i]); -mtk_hdmi_set_bits (hdmi, ctrl_reg, ctrl_frame_en); +regmap_set_bits (hdmi->regs, ctrl_reg, ctrl_frame_en); }static void mtk_hdmi_hw_send_aud_packet (struct mtk_hdmi *hdmi,bool enable) { -mtk_hdmi_mask (hdmi,GRL_SHIFT_R2 , enable ?0 :AUDIO_PACKET_OFF , -AUDIO_PACKET_OFF ); +regmap_update_bits (hdmi->regs,AUDIO_PACKET_OFF , +GRL_SHIFT_R2 , enable ?0 :AUDIO_PACKET_OFF ); }static void mtk_hdmi_hw_config_sys (struct mtk_hdmi *hdmi)
@@ -379,44 +339,44 @@ static void mtk_hdmi_hw_set_deep_color_mode(struct mtk_hdmi *hdmi)static void mtk_hdmi_hw_send_av_mute (struct mtk_hdmi *hdmi) { -mtk_hdmi_clear_bits (hdmi,GRL_CFG4 ,CTRL_AVMUTE ); +regmap_clear_bits (hdmi->regs,GRL_CFG4 ,CTRL_AVMUTE );usleep_range (2000 ,4000 ); -mtk_hdmi_set_bits (hdmi,GRL_CFG4 ,CTRL_AVMUTE ); +regmap_set_bits (hdmi->regs,GRL_CFG4 ,CTRL_AVMUTE ); }static void mtk_hdmi_hw_send_av_unmute (struct mtk_hdmi *hdmi) { -mtk_hdmi_mask (hdmi,GRL_CFG4 ,CFG4_AV_UNMUTE_EN , -CFG4_AV_UNMUTE_EN |CFG4_AV_UNMUTE_SET ); +regmap_update_bits (hdmi->regs,GRL_CFG4 ,CFG4_AV_UNMUTE_EN |CFG4_AV_UNMUTE_SET , +CFG4_AV_UNMUTE_EN );usleep_range (2000 ,4000 ); -mtk_hdmi_mask (hdmi,GRL_CFG4 ,CFG4_AV_UNMUTE_SET , -CFG4_AV_UNMUTE_EN |CFG4_AV_UNMUTE_SET ); +regmap_update_bits (hdmi->regs,GRL_CFG4 ,CFG4_AV_UNMUTE_EN |CFG4_AV_UNMUTE_SET , +CFG4_AV_UNMUTE_SET ); }static void mtk_hdmi_hw_ncts_enable (struct mtk_hdmi *hdmi,bool on) { -mtk_hdmi_mask (hdmi,GRL_CTS_CTRL , on ?0 :CTS_CTRL_SOFT , -CTS_CTRL_SOFT ); +regmap_update_bits (hdmi->regs,GRL_CTS_CTRL ,CTS_CTRL_SOFT , + on ?0 :CTS_CTRL_SOFT ); }static void mtk_hdmi_hw_ncts_auto_write_enable (struct mtk_hdmi *hdmi,bool enable) { -mtk_hdmi_mask (hdmi,GRL_CTS_CTRL , enable ?NCTS_WRI_ANYTIME :0 , -NCTS_WRI_ANYTIME ); +regmap_update_bits (hdmi->regs,GRL_CTS_CTRL ,NCTS_WRI_ANYTIME , + enable ?NCTS_WRI_ANYTIME :0 ); }static void mtk_hdmi_hw_msic_setting (struct mtk_hdmi *hdmi,struct drm_display_mode *mode) { -mtk_hdmi_clear_bits (hdmi,GRL_CFG4 ,CFG4_MHL_MODE ); +regmap_clear_bits (hdmi->regs,GRL_CFG4 ,CFG4_MHL_MODE );if (mode->flags &DRM_MODE_FLAG_INTERLACE && mode->clock ==74250 && mode->vdisplay ==1080 ) -mtk_hdmi_clear_bits (hdmi,GRL_CFG2 ,CFG2_MHL_DE_SEL ); +regmap_clear_bits (hdmi->regs,GRL_CFG2 ,CFG2_MHL_DE_SEL );else -mtk_hdmi_set_bits (hdmi,GRL_CFG2 ,CFG2_MHL_DE_SEL ); +regmap_set_bits (hdmi->regs,GRL_CFG2 ,CFG2_MHL_DE_SEL ); } static void mtk_hdmi_hw_aud_set_channel_swap(struct mtk_hdmi *hdmi,
@@ -444,7 +404,7 @@ static void mtk_hdmi_hw_aud_set_channel_swap(struct mtk_hdmi *hdmi, swap_bit =LFE_CC_SWAP ;break ; } -mtk_hdmi_mask (hdmi,GRL_CH_SWAP , swap_bit,0xff ); +regmap_update_bits (hdmi->regs,GRL_CH_SWAP ,0xff , swap_bit); } static void mtk_hdmi_hw_aud_set_bit_num(struct mtk_hdmi *hdmi,
@@ -465,7 +425,7 @@ static void mtk_hdmi_hw_aud_set_bit_num(struct mtk_hdmi *hdmi,break ; } -mtk_hdmi_mask (hdmi,GRL_AOUT_CFG , val,AOUT_BNUM_SEL_MASK ); +regmap_update_bits (hdmi->regs,GRL_AOUT_CFG ,AOUT_BNUM_SEL_MASK , val); } static void mtk_hdmi_hw_aud_set_i2s_fmt(struct mtk_hdmi *hdmi,
@@ -473,7 +433,7 @@ static void mtk_hdmi_hw_aud_set_i2s_fmt(struct mtk_hdmi *hdmi, {u32 val; - val =mtk_hdmi_read (hdmi,GRL_CFG0 ); +regmap_read (hdmi->regs,GRL_CFG0 , &val); val &= ~(CFG0_W_LENGTH_MASK |CFG0_I2S_MODE_MASK );switch (i2s_fmt) {
@@ -497,7 +457,7 @@ static void mtk_hdmi_hw_aud_set_i2s_fmt(struct mtk_hdmi *hdmi, val |=CFG0_I2S_MODE_I2S |CFG0_W_LENGTH_16BIT ;break ; } -mtk_hdmi_write (hdmi,GRL_CFG0 , val); +regmap_write (hdmi->regs,GRL_CFG0 , val); }static void mtk_hdmi_hw_audio_config (struct mtk_hdmi *hdmi,bool dst)
@@ -506,14 +466,14 @@ static void mtk_hdmi_hw_audio_config(struct mtk_hdmi *hdmi, bool dst)u8 val;/* Disable high bitrate, set DST packet normal/double */ -mtk_hdmi_clear_bits (hdmi,GRL_AOUT_CFG ,HIGH_BIT_RATE_PACKET_ALIGN ); +regmap_clear_bits (hdmi->regs,GRL_AOUT_CFG ,HIGH_BIT_RATE_PACKET_ALIGN );if (dst) val =DST_NORMAL_DOUBLE |SACD_DST ;else val =0 ; -mtk_hdmi_mask (hdmi,GRL_AUDIO_CFG , val, mask); +regmap_update_bits (hdmi->regs,GRL_AUDIO_CFG , mask, val); } static void mtk_hdmi_hw_aud_set_i2s_chan_num(struct mtk_hdmi *hdmi,
@@ -554,10 +514,10 @@ static void mtk_hdmi_hw_aud_set_i2s_chan_num(struct mtk_hdmi *hdmi, i2s_uv =I2S_UV_CH_EN (0 ); } -mtk_hdmi_write (hdmi,GRL_CH_SW0 , ch_switch &0xff ); -mtk_hdmi_write (hdmi,GRL_CH_SW1 , (ch_switch >>8 ) &0xff ); -mtk_hdmi_write (hdmi,GRL_CH_SW2 , (ch_switch >>16 ) &0xff ); -mtk_hdmi_write (hdmi,GRL_I2S_UV , i2s_uv); +regmap_write (hdmi->regs,GRL_CH_SW0 , ch_switch &0xff ); +regmap_write (hdmi->regs,GRL_CH_SW1 , (ch_switch >>8 ) &0xff ); +regmap_write (hdmi->regs,GRL_CH_SW2 , (ch_switch >>16 ) &0xff ); +regmap_write (hdmi->regs,GRL_I2S_UV , i2s_uv); } static void mtk_hdmi_hw_aud_set_input_type(struct mtk_hdmi *hdmi,
@@ -565,7 +525,7 @@ static void mtk_hdmi_hw_aud_set_input_type(struct mtk_hdmi *hdmi, {u32 val; - val =mtk_hdmi_read (hdmi,GRL_CFG1 ); +regmap_read (hdmi->regs,GRL_CFG1 , &val);if (input_type ==HDMI_AUD_INPUT_I2S && (val &CFG1_SPDIF ) ==CFG1_SPDIF ) { val &= ~CFG1_SPDIF ;
@@ -573,7 +533,7 @@ static void mtk_hdmi_hw_aud_set_input_type(struct mtk_hdmi *hdmi, (val & CFG1_SPDIF) == 0) { val |=CFG1_SPDIF ; } -mtk_hdmi_write (hdmi,GRL_CFG1 , val); +regmap_write (hdmi->regs,GRL_CFG1 , val); } static void mtk_hdmi_hw_aud_set_channel_status(struct mtk_hdmi *hdmi,
@@ -582,13 +542,13 @@ static void mtk_hdmi_hw_aud_set_channel_status(struct mtk_hdmi *hdmi,int i;for (i =0 ; i <5 ; i++) { -mtk_hdmi_write (hdmi,GRL_I2S_C_STA0 + i *4 , channel_status[i]); -mtk_hdmi_write (hdmi,GRL_L_STATUS_0 + i *4 , channel_status[i]); -mtk_hdmi_write (hdmi,GRL_R_STATUS_0 + i *4 , channel_status[i]); +regmap_write (hdmi->regs,GRL_I2S_C_STA0 + i *4 , channel_status[i]); +regmap_write (hdmi->regs,GRL_L_STATUS_0 + i *4 , channel_status[i]); +regmap_write (hdmi->regs,GRL_R_STATUS_0 + i *4 , channel_status[i]); }for (; i <24 ; i++) { -mtk_hdmi_write (hdmi,GRL_L_STATUS_0 + i *4 ,0 ); -mtk_hdmi_write (hdmi,GRL_R_STATUS_0 + i *4 ,0 ); +regmap_write (hdmi->regs,GRL_L_STATUS_0 + i *4 ,0 ); +regmap_write (hdmi->regs,GRL_R_STATUS_0 + i *4 ,0 ); } }
@@ -596,13 +556,13 @@ static void mtk_hdmi_hw_aud_src_reenable(struct mtk_hdmi *hdmi) {u32 val; - val =mtk_hdmi_read (hdmi,GRL_MIX_CTRL ); +regmap_read (hdmi->regs,GRL_MIX_CTRL , &val);if (val &MIX_CTRL_SRC_EN ) { val &= ~MIX_CTRL_SRC_EN ; -mtk_hdmi_write (hdmi,GRL_MIX_CTRL , val); +regmap_write (hdmi->regs,GRL_MIX_CTRL , val);usleep_range (255 ,512 ); val |=MIX_CTRL_SRC_EN ; -mtk_hdmi_write (hdmi,GRL_MIX_CTRL , val); +regmap_write (hdmi->regs,GRL_MIX_CTRL , val); } }
@@ -610,10 +570,10 @@ static void mtk_hdmi_hw_aud_src_disable(struct mtk_hdmi *hdmi) {u32 val; - val =mtk_hdmi_read (hdmi,GRL_MIX_CTRL ); +regmap_read (hdmi->regs,GRL_MIX_CTRL , &val); val &= ~MIX_CTRL_SRC_EN ; -mtk_hdmi_write (hdmi,GRL_MIX_CTRL , val); -mtk_hdmi_write (hdmi,GRL_SHIFT_L1 ,0x00 ); +regmap_write (hdmi->regs,GRL_MIX_CTRL , val); +regmap_write (hdmi->regs,GRL_SHIFT_L1 ,0x00 ); } static void mtk_hdmi_hw_aud_set_mclk(struct mtk_hdmi *hdmi,
@@ -621,7 +581,7 @@ static void mtk_hdmi_hw_aud_set_mclk(struct mtk_hdmi *hdmi, {u32 val; - val =mtk_hdmi_read (hdmi,GRL_CFG5 ); +regmap_read (hdmi->regs,GRL_CFG5 , &val); val &=CFG5_CD_RATIO_MASK ;switch (mclk) {
@@ -644,7 +604,7 @@ static void mtk_hdmi_hw_aud_set_mclk(struct mtk_hdmi *hdmi, val |=CFG5_FS256 ;break ; } -mtk_hdmi_write (hdmi,GRL_CFG5 , val); +regmap_write (hdmi->regs,GRL_CFG5 , val); }struct hdmi_acr_n {
@@ -728,9 +688,9 @@ static void do_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi, unsigned int n,unsigned char val[NCTS_BYTES ];int i; -mtk_hdmi_write (hdmi,GRL_NCTS ,0 ); -mtk_hdmi_write (hdmi,GRL_NCTS ,0 ); -mtk_hdmi_write (hdmi,GRL_NCTS ,0 ); +regmap_write (hdmi->regs,GRL_NCTS ,0 ); +regmap_write (hdmi->regs,GRL_NCTS ,0 ); +regmap_write (hdmi->regs,GRL_NCTS ,0 );memset (val,0 ,sizeof (val)); val[0 ] = (cts >>24 ) &0xff ;
@@ -743,7 +703,7 @@ static void do_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi, unsigned int n, val[6 ] = n &0xff ;for (i =0 ; i <NCTS_BYTES ; i++) -mtk_hdmi_write (hdmi,GRL_NCTS , val[i]); +regmap_write (hdmi->regs,GRL_NCTS , val[i]); } static void mtk_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi,
@@ -758,8 +718,7 @@ static void mtk_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi,dev_dbg (hdmi->dev,"%s: sample_rate=%u, clock=%d, cts=%u, n=%u\n" , __func__, sample_rate, clock, n, cts); -mtk_hdmi_mask (hdmi,DUMMY_304 ,AUDIO_I2S_NCTS_SEL_64 , -AUDIO_I2S_NCTS_SEL ); +regmap_update_bits (hdmi->regs,DUMMY_304 ,AUDIO_I2S_NCTS_SEL ,AUDIO_I2S_NCTS_SEL_64 );do_hdmi_hw_aud_set_ncts (hdmi, n, cts); }
@@ -879,7 +838,7 @@ static void mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi)bool dst;mtk_hdmi_hw_aud_set_channel_swap (hdmi,HDMI_AUD_SWAP_LFE_CC ); -mtk_hdmi_set_bits (hdmi,GRL_MIX_CTRL ,MIX_CTRL_FLAT ); +regmap_set_bits (hdmi->regs,GRL_MIX_CTRL ,MIX_CTRL_FLAT );if (hdmi->aud_param.aud_input_type ==HDMI_AUD_INPUT_SPDIF && hdmi->aud_param.aud_codec ==HDMI_AUDIO_CODING_TYPE_DST ) {
@@ -911,7 +870,7 @@ static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi,mtk_hdmi_hw_ncts_enable (hdmi, false);mtk_hdmi_hw_aud_src_disable (hdmi); -mtk_hdmi_clear_bits (hdmi,GRL_CFG2 ,CFG2_ACLK_INV ); +regmap_clear_bits (hdmi->regs,GRL_CFG2 ,CFG2_ACLK_INV );if (hdmi->aud_param.aud_input_type ==HDMI_AUD_INPUT_I2S ) {switch (sample_rate) {
@@ -1428,7 +1387,6 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,struct device_node *cec_np, *remote, *i2c_np;struct platform_device *cec_pdev;struct regmap *regmap; -struct resource *mem;int ret; ret =mtk_hdmi_get_all_clk (hdmi, np);
@@ -1474,8 +1432,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, } hdmi->sys_regmap = regmap; - mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - hdmi->regs =devm_ioremap_resource (dev, mem); + hdmi->regs =device_node_to_regmap (dev->of_node);if (IS_ERR (hdmi->regs)) { ret =PTR_ERR (hdmi->regs); goto put_device;
Signature · 1 line
2.40.0
PATCH v4 4/8 drm/mediatek: hdmi: make the cec dev optional
In reply to Guillaume RanquetMake cec device optional in order to support newer versions of the hdmi IP which doesn't require it
--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 8 +++-- drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 52 +++++++++++++++++++----------- 2 files changed, 39 insertions(+), 21 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi.c +5 -3
@@ -925,10 +925,11 @@ void mtk_hdmi_clk_disable_audio_mt8183(struct mtk_hdmi *hdmi)static enum drm_connector_status mtk_hdmi_update_plugged_status (struct mtk_hdmi *hdmi) { -bool connected; +bool connected = true;mutex_lock (&hdmi->update_plugged_status_lock); - connected =mtk_cec_hpd_high (hdmi->cec_dev); +if (hdmi->cec_dev) + connected =mtk_cec_hpd_high (hdmi->cec_dev);if (hdmi->plugged_cb && hdmi->codec_dev) hdmi->plugged_cb (hdmi->codec_dev, connected);mutex_unlock (&hdmi->update_plugged_status_lock);
@@ -1024,7 +1025,8 @@ static int mtk_hdmi_bridge_attach(struct drm_bridge *bridge,return ret; } -mtk_cec_set_hpd_event (hdmi->cec_dev, mtk_hdmi_hpd_event, hdmi->dev); +if (hdmi->cec_dev) +mtk_cec_set_hpd_event (hdmi->cec_dev, mtk_hdmi_hpd_event, hdmi->dev);return 0 ; }
drivers/gpu/drm/mediatek/mtk_hdmi_common.c +34 -18
81 lines not on this page · raw message
Signature · 1 line
2.40.0
PATCH v4 3/8 drm/mediatek: extract common functions from the mtk hdmi driver
In reply to Guillaume RanquetCreate a common "framework" that can be used to add support for different hdmi IPs within the mediatek range of products.
--- drivers/gpu/drm/mediatek/Makefile | 3 +- drivers/gpu/drm/mediatek/mtk_hdmi.c | 596 ++--------------------------- drivers/gpu/drm/mediatek/mtk_hdmi.h | 18 + drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 407 ++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_common.h | 207 ++++++++++ 5 files changed, 666 insertions(+), 565 deletions(-)
drivers/gpu/drm/mediatek/Makefile +2 -1
@@ -22,7 +22,8 @@ obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o mediatek-drm-hdmi-objs := mtk_cec.o \ mtk_hdmi.o \ - mtk_hdmi_ddc.o + mtk_hdmi_common.o \ + mtk_hdmi_ddc.o \ obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mediatek-drm-hdmi.o
drivers/gpu/drm/mediatek/mtk_hdmi.c +32 -564
725 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi.h +18 -0
@@ -6,9 +6,27 @@#ifndef _MTK_HDMI_CTRL_H#define _MTK_HDMI_CTRL_H +#include <sound/hdmi-codec.h> + +struct mtk_hdmi ;struct platform_driver ;extern struct platform_driver mtk_cec_driver;extern struct platform_driver mtk_hdmi_ddc_driver; +extern const struct drm_bridge_funcs mtk_mt8183_hdmi_bridge_funcs; + +void mtk_hdmi_output_init_mt8183 (struct mtk_hdmi *hdmi); +void mtk_hdmi_clk_disable_audio_mt8183 (struct mtk_hdmi *hdmi); +int mtk_hdmi_clk_enable_audio_mt8183 (struct mtk_hdmi *hdmi); +void mtk_hdmi_set_codec_pdata_mt8183 (struct hdmi_codec_pdata *codec_data); + +enum mtk_hdmi_clk_id_mt8183 { +MTK_HDMIV1_CLK_HDMI_PIXEL , +MTK_HDMIV1_CLK_HDMI_PLL , +MTK_HDMIV1_CLK_AUD_BCLK , +MTK_HDMIV1_CLK_AUD_SPDIF , +MTK_HDMIV1_CLK_COUNT , +}; +extern const char *const mtk_hdmi_clk_names_v1[MTK_HDMIV1_CLK_COUNT ];#endif /* _MTK_HDMI_CTRL_H */
drivers/gpu/drm/mediatek/mtk_hdmi_common.c new file +407 -0
407 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi_common.h new file +207 -0
207 lines not on this page · raw message
Signature · 1 line
2.40.0
PATCH v4 5/8 drm/mediatek: hdmi: add v2 support
In reply to Guillaume RanquetAdds hdmi and hdmi-ddc support for v2 IP.
--- drivers/gpu/drm/mediatek/Kconfig | 2 + drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 13 + drivers/gpu/drm/mediatek/mtk_hdmi_common.h | 1 + drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c | 362 +++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_regs_v2.h | 276 +++++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.c | 1105 +++++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.h | 30 + 8 files changed, 1791 insertions(+)
drivers/gpu/drm/mediatek/Kconfig +2 -0
@@ -34,5 +34,7 @@ config DRM_MEDIATEK_HDMI depends on DRM_MEDIATEK select SND_SOC_HDMI_CODEC if SND_SOC select PHY_MTK_HDMI + select DRM_DISPLAY_HDMI_HELPER + select DRM_DISPLAY_HELPER help DRM/KMS HDMI driver for Mediatek SoCs
drivers/gpu/drm/mediatek/Makefile +2 -0
@@ -24,6 +24,8 @@ mediatek-drm-hdmi-objs := mtk_cec.o \ mtk_hdmi.o \ mtk_hdmi_common.o \ mtk_hdmi_ddc.o \ + mtk_hdmi_ddc_v2.o \ + mtk_hdmi_v2.o \ obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mediatek-drm-hdmi.o
drivers/gpu/drm/mediatek/mtk_hdmi_common.c +13 -0
@@ -341,6 +341,15 @@ static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8173 = { .num_clocks = MTK_HDMIV1_CLK_COUNT, }; +static const struct mtk_hdmi_conf mtk_hdmi_conf_v2 = { + .bridge_funcs = &mtk_v2_hdmi_bridge_funcs, + .mtk_hdmi_output_init = mtk_hdmi_output_init_v2, + .mtk_hdmi_clk_disable = mtk_hdmi_clk_disable_v2, + .mtk_hdmi_clk_enable = mtk_hdmi_clk_enable_v2, + .mtk_hdmi_clock_names = mtk_hdmi_clk_names_v2, + .num_clocks =MTK_HDMIV2_CLK_COUNT , +}; +static const struct of_device_id mtk_drm_hdmi_of_ids[] = { { .compatible ="mediatek,mt2701-hdmi" , .data = &mtk_hdmi_conf_mt2701,
@@ -351,6 +360,9 @@ static const struct of_device_id mtk_drm_hdmi_of_ids[] = { { .compatible = "mediatek,mt8173-hdmi", .data = &mtk_hdmi_conf_mt8173, }, + { .compatible = "mediatek,mt8195-hdmi", + .data = &mtk_hdmi_conf_v2, + }, {} };MODULE_DEVICE_TABLE (of, mtk_drm_hdmi_of_ids);
@@ -399,6 +411,7 @@ static struct platform_driver mtk_hdmi_driver = {static struct platform_driver *const mtk_hdmi_drivers[] = { &mtk_hdmi_ddc_driver, &mtk_cec_driver, + &mtk_hdmi_ddc_v2_driver, &mtk_hdmi_driver, };
drivers/gpu/drm/mediatek/mtk_hdmi_common.h +1 -0
@@ -27,6 +27,7 @@#include "mtk_cec.h" #include "mtk_hdmi.h" +#include "mtk_hdmi_v2.h" struct mtk_hdmi_conf {bool tz_disabled;
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +362 -0
362 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi_regs_v2.h new file +276 -0
276 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c new file +1105 -0
1,105 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi_v2.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2022 MediaTek Inc. +* Copyright (c) 2022 BayLibre, SAS +*/ + +#ifndef _MTK_HDMI_V2_CTRL_H +#define _MTK_HDMI_V2_CTRL_H + +#include <linux/hdmi.h> +#include <drm/drm_bridge.h> + +struct mtk_hdmi ; + +extern struct platform_driver mtk_hdmi_ddc_v2_driver; +extern const struct drm_bridge_funcs mtk_v2_hdmi_bridge_funcs; +void mtk_hdmi_output_init_v2 (struct mtk_hdmi *hdmi); +int mtk_hdmi_clk_enable_v2 (struct mtk_hdmi *hdmi); +void mtk_hdmi_clk_disable_v2 (struct mtk_hdmi *hdmi); + +enum mtk_hdmi_clk_id_v2 { +MTK_HDMIV2_HDCP_SEL , +MTK_HDMIV2_HDCP_24M_SEL , +MTK_HDMIV2_VPP_SPLIT_HDMI , +MTK_HDMIV2_CLK_HDMI_APB_SEL , +MTK_HDMIV2_CLK_COUNT , +}; + +extern const char *const mtk_hdmi_clk_names_v2[MTK_HDMIV2_CLK_COUNT ]; +#endif /* _MTK_HDMI_V2_CTRL_H */
Signature · 1 line
2.40.0
PATCH v4 6/8 drm/mediatek: hdmi: v2: add audio support
In reply to Guillaume RanquetAdd HDMI audio support for v2
--- drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 1 + drivers/gpu/drm/mediatek/mtk_hdmi_v2.c | 198 +++++++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.h | 4 +- 3 files changed, 202 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_hdmi_common.c +1 -0
@@ -346,6 +346,7 @@ static const struct mtk_hdmi_conf mtk_hdmi_conf_v2 = { .mtk_hdmi_output_init = mtk_hdmi_output_init_v2, .mtk_hdmi_clk_disable = mtk_hdmi_clk_disable_v2, .mtk_hdmi_clk_enable = mtk_hdmi_clk_enable_v2, + .mtk_hdmi_set_codec_pdata = mtk_hdmi_set_codec_pdata_v2, .mtk_hdmi_clock_names = mtk_hdmi_clk_names_v2, .num_clocks = MTK_HDMIV2_CLK_COUNT, };
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c +198 -0
255 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi_v2.h +3 -1
@@ -7,8 +7,9 @@#ifndef _MTK_HDMI_V2_CTRL_H#define _MTK_HDMI_V2_CTRL_H -#include <linux/hdmi.h> #include <drm/drm_bridge.h> +#include <linux/hdmi.h> +#include <sound/hdmi-codec.h> struct mtk_hdmi ;
@@ -17,6 +18,7 @@ extern const struct drm_bridge_funcs mtk_v2_hdmi_bridge_funcs;void mtk_hdmi_output_init_v2 (struct mtk_hdmi *hdmi);int mtk_hdmi_clk_enable_v2 (struct mtk_hdmi *hdmi);void mtk_hdmi_clk_disable_v2 (struct mtk_hdmi *hdmi); +void mtk_hdmi_set_codec_pdata_v2 (struct hdmi_codec_pdata *codec_data);enum mtk_hdmi_clk_id_v2 {MTK_HDMIV2_HDCP_SEL ,
Signature · 1 line
2.40.0
PATCH v4 7/8 dt-bindings: display: mediatek: dpi: Add compatible for MediaTek MT8195
In reply to Guillaume RanquetAdd dt-binding documentation of dpi for MediaTek MT8195 SoC.
--- Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -0
@@ -25,6 +25,7 @@ properties: - mediatek,mt8186-dpi - mediatek,mt8188-dp-intf - mediatek,mt8192-dpi + - mediatek,mt8195-dpi - mediatek,mt8195-dp-intf reg:
Signature · 1 line
2.40.0
PATCH v4 8/8 drm/mediatek: dpi: Add mt8195 hdmi to DPI driver
In reply to Guillaume RanquetAdd the DPI1 hdmi path support in mtk dpi driver
--- drivers/gpu/drm/mediatek/mtk_dpi.c | 121 ++++++++++++++++++++++++++++++-- drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 5 ++ 2 files changed, 119 insertions(+), 7 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +114 -7
@@ -9,12 +9,15 @@#include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/media-bus-format.h> +#include <linux/mfd/syscon.h> #include <linux/of.h> #include <linux/of_device.h> #include <linux/of_graph.h> #include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/soc/mediatek/mtk-mmsys.h> +#include <linux/regmap.h> +#include <linux/reset.h> #include <linux/types.h> #include <video/videomode.h>
@@ -67,11 +70,14 @@ struct mtk_dpi {struct drm_bridge *next_bridge;struct drm_connector *connector;void __iomem *regs; +struct reset_control *reset_ctl;struct device *dev;struct device *mmsys_dev;struct clk *engine_clk; +struct clk *dpi_ck_cg;struct clk *pixel_clk;struct clk *tvd_clk; +struct clk *hdmi_cg;int irq;struct drm_display_mode mode;const struct mtk_dpi_conf *conf;
@@ -138,6 +144,7 @@ struct mtk_dpi_yc_limit {* @csc_enable_bit: Enable bit of CSC. * @pixels_per_iter: Quantity of transferred pixels per iteration. * @edge_cfg_in_mmsys: If the edge configuration for DPI's output needs to be set in MMSYS. +* @is_internal_hdmi: True if this DPI block is directly connected to SoC internal HDMI block. */ struct mtk_dpi_conf {unsigned int (*cal_factor)(int clock);
@@ -157,6 +164,7 @@ struct mtk_dpi_conf {u32 csc_enable_bit;u32 pixels_per_iter;bool edge_cfg_in_mmsys; +bool is_internal_hdmi; };static void mtk_dpi_mask (struct mtk_dpi *dpi,u32 offset,u32 val,u32 mask)
@@ -471,8 +479,14 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi)return ;mtk_dpi_disable (dpi); + +reset_control_rearm (dpi->reset_ctl); +clk_disable_unprepare (dpi->pixel_clk);clk_disable_unprepare (dpi->engine_clk); +clk_disable_unprepare (dpi->dpi_ck_cg); +clk_disable_unprepare (dpi->hdmi_cg); +clk_disable_unprepare (dpi->tvd_clk); }static int mtk_dpi_power_on (struct mtk_dpi *dpi)
@@ -488,15 +502,44 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) goto err_refcount; } + ret =clk_prepare_enable (dpi->tvd_clk); +if (ret) { +dev_err (dpi->dev,"Failed to enable tvd pll: %d\n" , ret); + goto err_engine; + } + + ret =clk_prepare_enable (dpi->hdmi_cg); +if (ret) { +dev_err (dpi->dev,"Failed to enable hdmi_cg clock: %d\n" , ret); + goto err_tvd; + } + + ret =clk_prepare_enable (dpi->dpi_ck_cg); +if (ret) { +dev_err (dpi->dev,"Failed to enable dpi_ck_cg clock: %d\n" , ret); + goto err_hdmi_cg; + } + ret =clk_prepare_enable (dpi->pixel_clk);if (ret) {dev_err (dpi->dev,"Failed to enable pixel clock: %d\n" , ret); goto err_pixel; } +reset_control_reset (dpi->reset_ctl); + +if (dpi->pinctrl && dpi->pins_dpi) +pinctrl_select_state (dpi->pinctrl, dpi->pins_dpi); +return 0 ; err_pixel: +clk_disable_unprepare (dpi->dpi_ck_cg); +err_hdmi_cg: +clk_disable_unprepare (dpi->hdmi_cg); +err_tvd: +clk_disable_unprepare (dpi->tvd_clk); +err_engine:clk_disable_unprepare (dpi->engine_clk); err_refcount: dpi->refcount--;
@@ -541,7 +584,6 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,else clk_set_rate (dpi->pixel_clk, vm.pixelclock); - vm.pixelclock =clk_get_rate (dpi->pixel_clk); dev_dbg(dpi->dev, "Got PLL %lu Hz, pixel clock %lu Hz\n",
@@ -608,7 +650,16 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,if (dpi->conf->support_direct_pin) {mtk_dpi_config_yc_map (dpi, dpi->yc_map);mtk_dpi_config_2n_h_fre (dpi); -mtk_dpi_dual_edge (dpi); +/* DPI could be connecting to external bridge +* or internal HDMI encoder. */ +if (dpi->conf->is_internal_hdmi) { +mtk_dpi_mask (dpi,DPI_CON ,DPI_OUTPUT_1T1P_EN , +DPI_OUTPUT_1T1P_EN ); +mtk_dpi_mask (dpi,DPI_CON ,DPI_INPUT_2P_EN , +DPI_INPUT_2P_EN ); + }else { +mtk_dpi_dual_edge (dpi); + }mtk_dpi_config_disable_edge (dpi); }if (dpi->conf->input_2pixel) {
@@ -723,7 +774,10 @@ static void mtk_dpi_bridge_disable(struct drm_bridge *bridge) {struct mtk_dpi *dpi =bridge_to_dpi (bridge); -mtk_dpi_power_off (dpi); +if (dpi->conf->is_internal_hdmi) +mtk_dpi_power_off (dpi); +else +mtk_dpi_disable (dpi);if (dpi->pinctrl && dpi->pins_gpio)pinctrl_select_state (dpi->pinctrl, dpi->pins_gpio);
@@ -772,14 +826,16 @@ void mtk_dpi_start(struct device *dev) {struct mtk_dpi *dpi =dev_get_drvdata (dev); -mtk_dpi_power_on (dpi); +if (!dpi->conf->is_internal_hdmi) +mtk_dpi_power_on (dpi); }void mtk_dpi_stop (struct device *dev) {struct mtk_dpi *dpi =dev_get_drvdata (dev); -mtk_dpi_power_off (dpi); +if (!dpi->conf->is_internal_hdmi) +mtk_dpi_power_off (dpi); }static int mtk_dpi_bind (struct device *dev,struct device *master,void *data)
@@ -864,6 +920,11 @@ static unsigned int mt8183_calculate_factor(int clock)return 2 ; } +static unsigned int mt8195_calculate_factor (int clock) +{ +return 1 ; +} +static unsigned int mt8195_dpintf_calculate_factor (int clock) {if (clock <70000 )
@@ -989,6 +1050,24 @@ static const struct mtk_dpi_conf mt8192_conf = { .csc_enable_bit = CSC_ENABLE, }; +static const struct mtk_dpi_conf mt8195_conf = { + .cal_factor = mt8195_calculate_factor, + .max_clock_khz =594000 , + .reg_h_fre_con =0xe0 , + .output_fmts = mt8183_output_fmts, + .num_output_fmts =ARRAY_SIZE (mt8183_output_fmts), + .pixels_per_iter =1 , + .is_ck_de_pol = true, + .swap_input_support = true, + .dimension_mask =HPW_MASK , + .hvsize_mask =HSIZE_MASK , + .channel_swap_shift =CH_SWAP , + .yuv422_en_bit =YUV422_EN , + .csc_enable_bit =CSC_ENABLE , + .is_internal_hdmi = true, + .support_direct_pin = true, +}; +static const struct mtk_dpi_conf mt8195_dpintf_conf = { .cal_factor = mt8195_dpintf_calculate_factor, .max_clock_khz =600000 ,
@@ -1046,6 +1125,12 @@ static int mtk_dpi_probe(struct platform_device *pdev)return ret; } + dpi->reset_ctl =devm_reset_control_get_optional_exclusive (dev,"dpi_on" ); +if (IS_ERR (dpi->reset_ctl)) { +dev_err (dev,"Failed to get reset_ctl: %ld\n" ,PTR_ERR (dpi->reset_ctl)); +return PTR_ERR (dpi->reset_ctl); + } + dpi->engine_clk =devm_clk_get (dev,"engine" );if (IS_ERR (dpi->engine_clk)) { ret =PTR_ERR (dpi->engine_clk);
@@ -1055,7 +1140,26 @@ static int mtk_dpi_probe(struct platform_device *pdev)return ret; } - dpi->pixel_clk =devm_clk_get (dev,"pixel" ); + dpi->hdmi_cg =devm_clk_get_optional (dev,"hdmi_cg" ); +if (IS_ERR (dpi->hdmi_cg)) { + ret =PTR_ERR (dpi->hdmi_cg); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get hdmi_cg clock: %d\n" , ret); + +return ret; + } + + dpi->dpi_ck_cg =devm_clk_get_optional (dev,"ck_cg" ); +if (IS_ERR (dpi->dpi_ck_cg)) { + ret =PTR_ERR (dpi->dpi_ck_cg); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get dpi ck cg clock: %d\n" , + ret); + +return ret; + } + + dpi->pixel_clk =devm_clk_get_optional (dev,"pixel" );if (IS_ERR (dpi->pixel_clk)) { ret =PTR_ERR (dpi->pixel_clk);if (ret != -EPROBE_DEFER )
@@ -1064,7 +1168,7 @@ static int mtk_dpi_probe(struct platform_device *pdev)return ret; } - dpi->tvd_clk =devm_clk_get (dev,"pll" ); + dpi->tvd_clk =devm_clk_get_optional (dev,"pll" );if (IS_ERR (dpi->tvd_clk)) { ret =PTR_ERR (dpi->tvd_clk);if (ret != -EPROBE_DEFER )
@@ -1134,6 +1238,9 @@ static const struct of_device_id mtk_dpi_of_ids[] = { { .compatible = "mediatek,mt8195-dp-intf", .data = &mt8195_dpintf_conf, }, + { .compatible = "mediatek,mt8195-dpi", + .data = &mt8195_conf, + }, { }, };MODULE_DEVICE_TABLE (of, mtk_dpi_of_ids);
drivers/gpu/drm/mediatek/mtk_dpi_regs.h +5 -0
@@ -43,6 +43,11 @@#define DPINTF_YUV422_EN BIT(24)#define DPINTF_CSC_ENABLE BIT(26)#define DPINTF_INPUT_2P_EN BIT(29) +#define DPI_OUTPUT_1T1P_EN BIT(24) +#define DPI_INPUT_2P_EN BIT(25) +#define DPI_EXT_VSYNC_EN BIT(26) +#define DPI_RGB565_EN BIT(27) +#define DPI_RGB880_EN BIT(28)#define DPI_OUTPUT_SETTING 0x14#define CH_SWAP 0
Signature · 1 line
2.40.0
Rob Herring
maintainerRe: [PATCH v4 1/8] dt-bindings: display: mediatek: add MT8195 hdmi bindings
In reply to Guillaume RanquetQuoted 90 lines · Guillaume Ranquet
Add mt8195 SoC bindings for hdmi and hdmi-ddc
On mt8195 the ddc i2c controller is part of the hdmi IP block and thus has no specific register range, power domain or interrupt, making it simpler than the legacy "mediatek,hdmi-ddc" binding.
Signed-off-by Guillaume Ranquet <[email protected]>--- .../bindings/display/mediatek/mediatek,hdmi.yaml | 59 ++++++++++++++++++---- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 45 +++++++++++++++++ 2 files changed, 93 insertions(+), 11 deletions(-)Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +34
-11@@ -21,6 +21,7 @@ properties: - mediatek,mt7623-hdmi - mediatek,mt8167-hdmi - mediatek,mt8173-hdmi + - mediatek,mt8195-hdmi reg: maxItems: 1@@ -29,18 +30,10 @@ properties: maxItems: 1 clocks: - items: - - description: Pixel Clock - - description: HDMI PLL - - description: Bit Clock - - description: S/PDIF Clock + maxItems: 4 clock-names: - items: - - const: pixel - - const: pll - - const: bclk - - const: spdif + maxItems: 4 phys: maxItems: 1@@ -58,6 +51,9 @@ properties: description: | phandle link and register offset to the system configuration registers. + power-domains: + maxItems: 1 + ports: $ref: /schemas/graph.yaml#/properties/ports@@ -86,9 +82,50 @@ required: - clock-names - phys - phy-names - - mediatek,syscon-hdmi - ports +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt8195-hdmi + then: + properties: + clocks: + items: + - description: APB + - description: HDCP + - description: HDCP 24M + - description: Split HDMI + clock-names: + items: + - const: hdmi_apb_sel + - const: hdcp_sel + - const: hdcp24_sel + - const: split_hdmi + + required: + - power-domains + else: + properties: + clocks: + items: + - description: Pixel Clock
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml required: · line 124
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +10
-0+ - description: HDMI PLL + - description: Bit Clock + - description: S/PDIF Clock + + clock-names: + items: + - const: pixel + - const: pll + - const: bclk + - const: spdif
I don't understand how the same h/w block can have completely different clocks. If not the same h/w or evolution of the same h/w, then do a separate schema.
Quoted 45 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +4
-0+ + required: + - mediatek,syscon-hdmi + additionalProperties: false examples:Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +32
-0@@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek HDMI DDC for mt8195 + +maintainers: + - CK Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + The HDMI DDC i2c controller is used to interface with the HDMI DDC pins. + +properties: + compatible: + enum: + - mediatek,mt8195-hdmi-ddc + + clocks: + maxItems: 1 + + mediatek,hdmi: + $ref: /schemas/types.yaml#/definitions/phandle + description: + A phandle to the mt8195 hdmi controller + +required: + - compatible + - clocks +
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 42
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +10
-0+additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + hdmiddc0: i2c { + compatible = "mediatek,mt8195-hdmi-ddc"; + mediatek,hdmi = <&hdmi0>; + clocks = <&clk26m>;
How does one access this h/w device? There is nothing described to access it.
Rob
Re: [PATCH v4 1/8] dt-bindings: display: mediatek: add MT8195 hdmi bindings
Quoted 97 lines · Rob Herring
Quoted 96 lines · Guillaume Ranquet
Add mt8195 SoC bindings for hdmi and hdmi-ddc
On mt8195 the ddc i2c controller is part of the hdmi IP block and thus has no specific register range, power domain or interrupt, making it simpler than the legacy "mediatek,hdmi-ddc" binding.
Signed-off-by Guillaume Ranquet <[email protected]>--- .../bindings/display/mediatek/mediatek,hdmi.yaml | 59 ++++++++++++++++++---- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 45 +++++++++++++++++ 2 files changed, 93 insertions(+), 11 deletions(-)Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +40
-11@@ -21,6 +21,7 @@ properties: - mediatek,mt7623-hdmi - mediatek,mt8167-hdmi - mediatek,mt8173-hdmi + - mediatek,mt8195-hdmi reg: maxItems: 1@@ -29,18 +30,10 @@ properties: maxItems: 1 clocks: - items: - - description: Pixel Clock - - description: HDMI PLL - - description: Bit Clock - - description: S/PDIF Clock + maxItems: 4 clock-names: - items: - - const: pixel - - const: pll - - const: bclk - - const: spdif + maxItems: 4 phys: maxItems: 1@@ -58,6 +51,9 @@ properties: description: | phandle link and register offset to the system configuration registers. + power-domains: + maxItems: 1 + ports: $ref: /schemas/graph.yaml#/properties/ports@@ -86,9 +82,50 @@ required: - clock-names - phys - phy-names - - mediatek,syscon-hdmi - ports +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt8195-hdmi + then: + properties: + clocks: + items: + - description: APB + - description: HDCP + - description: HDCP 24M + - description: Split HDMI + clock-names: + items: + - const: hdmi_apb_sel + - const: hdcp_sel + - const: hdcp24_sel + - const: split_hdmi + + required: + - power-domains + else: + properties: + clocks: + items: + - description: Pixel Clock + - description: HDMI PLL + - description: Bit Clock + - description: S/PDIF Clock + + clock-names: + items:
Quoted 9 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml required: · line 124
Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +4
-0+ - const: pixel + - const: pll + - const: bclk + - const: spdifI don't understand how the same h/w block can have completely different clocks. If not the same h/w or evolution of the same h/w, then do a separate schema.
Hi Rob,
I'm not entirely sure what's the best approach here.
The IPs are different enough to warrant a separate schema IMHO. Though CK asked me to merge both IPs together (for both schema and code).
CK might want to chime in and advocate his point of view?
Quoted 50 lines
Quoted 50 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +4
-0+ + required: + - mediatek,syscon-hdmi + additionalProperties: false examples:Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +37
-0@@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek HDMI DDC for mt8195 + +maintainers: + - CK Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + The HDMI DDC i2c controller is used to interface with the HDMI DDC pins. + +properties: + compatible: + enum: + - mediatek,mt8195-hdmi-ddc + + clocks: + maxItems: 1 + + mediatek,hdmi: + $ref: /schemas/types.yaml#/definitions/phandle + description: + A phandle to the mt8195 hdmi controller + +required: + - compatible + - clocks + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h>
Quoted 9 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 42
Quoted 5 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +5
-0+ #include <dt-bindings/interrupt-controller/irq.h> + hdmiddc0: i2c { + compatible = "mediatek,mt8195-hdmi-ddc"; + mediatek,hdmi = <&hdmi0>; + clocks = <&clk26m>;How does one access this h/w device? There is nothing described to access it.
The device is embedded into the HDMI block and thus uses the mediatek,hdmi phandle to access its sets of registers in the middle of the mediatek,hdmi register range.
Hope this clarifies things,
Guillaume.
Quoted 1 line
Rob
Chun-Kuang Hu
maintainerRe: [PATCH v4 1/8] dt-bindings: display: mediatek: add MT8195 hdmi bindings
Hi, Guillaume:
Guillaume Ranquet <[email protected]> 於 2023年6月9日 週五 下午11:50寫道:
Quoted 109 lines · Rob Herring
Quoted 97 lines · Guillaume Ranquet
Quoted 96 lines
Add mt8195 SoC bindings for hdmi and hdmi-ddc
On mt8195 the ddc i2c controller is part of the hdmi IP block and thus has no specific register range, power domain or interrupt, making it simpler than the legacy "mediatek,hdmi-ddc" binding.
Signed-off-by Guillaume Ranquet <[email protected]>--- .../bindings/display/mediatek/mediatek,hdmi.yaml | 59 ++++++++++++++++++---- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 45 +++++++++++++++++ 2 files changed, 93 insertions(+), 11 deletions(-)Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +40
-11@@ -21,6 +21,7 @@ properties: - mediatek,mt7623-hdmi - mediatek,mt8167-hdmi - mediatek,mt8173-hdmi + - mediatek,mt8195-hdmi reg: maxItems: 1@@ -29,18 +30,10 @@ properties: maxItems: 1 clocks: - items: - - description: Pixel Clock - - description: HDMI PLL - - description: Bit Clock - - description: S/PDIF Clock + maxItems: 4 clock-names: - items: - - const: pixel - - const: pll - - const: bclk - - const: spdif + maxItems: 4 phys: maxItems: 1@@ -58,6 +51,9 @@ properties: description: | phandle link and register offset to the system configuration registers. + power-domains: + maxItems: 1 + ports: $ref: /schemas/graph.yaml#/properties/ports@@ -86,9 +82,50 @@ required: - clock-names - phys - phy-names - - mediatek,syscon-hdmi - ports +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt8195-hdmi + then: + properties: + clocks: + items: + - description: APB + - description: HDCP + - description: HDCP 24M + - description: Split HDMI + clock-names: + items: + - const: hdmi_apb_sel + - const: hdcp_sel + - const: hdcp24_sel + - const: split_hdmi + + required: + - power-domains + else: + properties: + clocks: + items: + - description: Pixel Clock + - description: HDMI PLL + - description: Bit Clock + - description: S/PDIF Clock + + clock-names: + items:Quoted 9 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml required: · line 124
Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +4
-0+ - const: pixel + - const: pll + - const: bclk + - const: spdifI don't understand how the same h/w block can have completely different clocks. If not the same h/w or evolution of the same h/w, then do a separate schema.
Quoted 7 lines
Hi Rob,
I'm not entirely sure what's the best approach here.
The IPs are different enough to warrant a separate schema IMHO. Though CK asked me to merge both IPs together (for both schema and code).CK might want to chime in and advocate his point of view?
For all the mediatek hdmi device, input mediatek internal video signal, and output hdmi signal, so I'm curious about how mt8195-hdmi device is different with other mediatek hdmi device. I think pixel clock is an important clock which is related to resolution and fps. So I think every hdmi device should have a clock which related to pixel clock. I does not find it in mt8195 device. Is one of the clock the parent clock of pixel clock or one of the clock is pixel clock but you give it another naming? Please conduct with mediatek stuff and give us these information, so we have information to judge mt8195-hdmi is different with other mediatek hdmi device or similar to. For other three clocks, I still need these information.
Regards,
Chun-Kuang.
Quoted 69 lines
Quoted 51 lines
Quoted 51 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +4
-0+ + required: + - mediatek,syscon-hdmi + additionalProperties: false examples:Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +37
-0@@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek HDMI DDC for mt8195 + +maintainers: + - CK Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + The HDMI DDC i2c controller is used to interface with the HDMI DDC pins. + +properties: + compatible: + enum: + - mediatek,mt8195-hdmi-ddc + + clocks: + maxItems: 1 + + mediatek,hdmi: + $ref: /schemas/types.yaml#/definitions/phandle + description: + A phandle to the mt8195 hdmi controller + +required: + - compatible + - clocks + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h>Quoted 9 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 42
Quoted 5 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +5
-0+ #include <dt-bindings/interrupt-controller/irq.h> + hdmiddc0: i2c { + compatible = "mediatek,mt8195-hdmi-ddc"; + mediatek,hdmi = <&hdmi0>; + clocks = <&clk26m>;How does one access this h/w device? There is nothing described to access it.
The device is embedded into the HDMI block and thus uses the mediatek,hdmi phandle to access its sets of registers in the middle of the mediatek,hdmi register range.
Hope this clarifies things,
Guillaume.Quoted 1 line
Rob
Re: [PATCH v4 5/8] drm/mediatek: hdmi: add v2 support
In reply to Guillaume RanquetHi, Guillaume:
Quoted 7 lines · Guillaume Ranquet
External email : Please do not click links or open attachments until you have verified the sender or the content.
Adds hdmi and hdmi-ddc support for v2 IP.Signed-off-by Guillaume Ranquet <[email protected]>
[snip]
Quoted 4 lines
(quoted diff) +2
-0+ +static unsigned char vddc_read(struct mtk_hdmi_ddc *ddc, unsignedint
u4_clk_div,drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +1
-0+ unsigned char uc_dev, unsigned int u4_addr,
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c line 185
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +10
-0+enum sif_bit_t_hdmi uc_addr_type, + unsigned char *puc_value, unsigned int u4_count) +{ +unsigned int u4_read_count = 0; +unsigned char uc_return_value =0 ; + +if (!puc_value || !u4_count || !u4_clk_div || + uc_addr_type >SIF_16_BIT_HDMI || + (uc_addr_type ==SIF_8_BIT_HDMI && u4_addr >255 ) || + (uc_addr_type ==SIF_16_BIT_HDMI && u4_addr >65535 )) {
uc_addr_type would never be SIF_16_BIT_HDMI, so remove SIF_16_BIT_HDMI.
Regards,
CK
Quoted 35 lines
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +9
-0+return 0 ; +} + +if (uc_addr_type ==SIF_8_BIT_HDMI ) +u4_read_count =255 - u4_addr +1 ; +else if (uc_addr_type ==SIF_16_BIT_HDMI ) +u4_read_count =65535 - u4_addr +1 ; + +u4_read_count = (u4_read_count > u4_count) ? u4_count :
u4_read_count;drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +23
-0+uc_return_value =ddcm_read_hdmi (ddc, u4_clk_div, uc_dev, u4_addr, + uc_addr_type, puc_value, u4_read_count); +return uc_return_value; +} + +static bool fg_ddc_data_read (struct mtk_hdmi_ddc *ddc, +unsigned char b_dev, +unsigned char b_data_addr, +unsigned char b_data_count, +unsigned char *pr_data) +{ +int ret; + +mutex_lock (&ddc->mtx); + +hdmi_ddc_request (ddc); +ret =vddc_read (ddc,DDC2_CLOK , b_dev, b_data_addr,SIF_8_BIT_HDMI , + pr_data, b_data_count); +mutex_unlock (&ddc->mtx); + +return ret == b_data_count; +} +
Re: [PATCH v4 5/8] drm/mediatek: hdmi: add v2 support
In reply to Guillaume RanquetHi, Guillaume:
Quoted 7 lines · Guillaume Ranquet
External email : Please do not click links or open attachments until you have verified the sender or the content.
Adds hdmi and hdmi-ddc support for v2 IP.Signed-off-by Guillaume Ranquet <[email protected]>---
[snip]
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c line 208
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +10
-0+ +static bool fg_ddc_data_read (struct mtk_hdmi_ddc *ddc, +unsigned char b_dev, +unsigned char b_data_addr, +unsigned char b_data_count, +unsigned char *pr_data) +{ +int ret; + +mutex_lock (&ddc->mtx);
Why do you need this mutex? fg_ddc_data_read() and fg_ddc_data_write() are called by mtk_hdmi_ddc_xfer() which is the callback function of master_xfer. In original hdmi driver, it's not necessary to use a mutex to protect master_xfer, so I think this is not necessary.
Regards,
CK
Quoted 70 lines
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +27
-0+ +hdmi_ddc_request (ddc); +ret =vddc_read (ddc,DDC2_CLOK , b_dev, b_data_addr,SIF_8_BIT_HDMI , + pr_data, b_data_count); +mutex_unlock (&ddc->mtx); + +return ret == b_data_count; +} + +static void fg_ddc_data_write (struct mtk_hdmi_ddc *ddc, +unsigned char b_dev, +unsigned char b_data_addr, +unsigned char b_data_count, +unsigned char *pr_data) +{ +unsigned int i; + +mutex_lock (&ddc->mtx); + +hdmi_ddc_request (ddc); +for (i =0 ; i < b_data_count; i++) +mtk_ddc_wr_one (ddc, b_dev, b_data_addr + i, *(pr_data + i)); + +mutex_unlock (&ddc->mtx); +} + +static int mtk_hdmi_ddc_xfer(struct i2c_adapter *adapter, struct
i2c_msg*msgs,drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +42
-0+ int num) +{ +struct mtk_hdmi_ddc *ddc = adapter->algo_data; +struct device *dev = adapter->dev.parent; +bool ret; +int i; +unsigned char offset; + +if (!ddc) +return -EINVAL ; + +for (i =0 ; i < num; i++) { +struct i2c_msg *msg = &msgs[i]; + +if (msg->flags &I2C_M_RD ) { +/* The underlying DDC hardware always issue a write request +* that assigns the read offset as part of the read operation. +* Therefore we need to use the offset value assigned +* in the previous write request from the drm_edid.c +*/ +ret =fg_ddc_data_read (ddc, msg->addr, + offset,/* determined by previous write requests */ + (msg->len), &msg->buf[0 ]); +if (!ret) { +dev_err (dev,"ddc read failed : %d\n" , ret); +return ret; +} +}else { +fg_ddc_data_write (ddc, msg->addr, msg->buf[0 ], +(msg->len -1 ), &msg->buf[1 ]); + +/* we store the offset value requested by drm_edid framework +* to use in subsequent read requests. +*/ +if (DDC_ADDR == msg->addr &&1 == msg->len) +offset = msg->buf[0 ]; +} +} + +return i; +} +
Re: [PATCH v4 3/8] drm/mediatek: extract common functions from the mtk hdmi driver
In reply to Guillaume RanquetHi, Guillaume:
Quoted 7 lines · Guillaume Ranquet
External email : Please do not click links or open attachments until you have verified the sender or the content.
Create a common "framework" that can be used to add support for
different hdmi IPs within the mediatek range of products.Signed-off-by Guillaume Ranquet <[email protected]>
Quoted 11 lines
--- drivers/gpu/drm/mediatek/Makefile | 3 +- drivers/gpu/drm/mediatek/mtk_hdmi.c | 596 ++----------------- ---------- drivers/gpu/drm/mediatek/mtk_hdmi.h | 18 + drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 407 ++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_common.h | 207 ++++++++++ 5 files changed, 666 insertions(+), 565 deletions(-)
I would like the file naming as:
mtk_hdmi.c => mtk_hdmi_mt8173.cmtk_hdmi.h => mtk_hdmi_mt8173.hmtk_hdmi_common.c => mtk_hdmi.cmtk_hdmi_common.h => mtk_hdmi.h
and your v2 file naming as:
mtk_hdmi_mt8195.cmtk_hdmi_mt8195.h
Regards,
CK
Re: [PATCH v4 5/8] drm/mediatek: hdmi: add v2 support
In reply to Guillaume RanquetHi, Guillaume:
Quoted 8 lines · Guillaume Ranquet
External email : Please do not click links or open attachments until you have verified the sender or the content.
Adds hdmi and hdmi-ddc support for v2 IP.Signed-off-by Guillaume Ranquet <[email protected]>---
[snip]
Quoted 4 lines
(quoted diff) +2
-0+ +static unsigned char vddc_read(struct mtk_hdmi_ddc *ddc, unsignedint
u4_clk_div,
+ unsigned charuc_dev, unsigned intu4_addr,
Remove the type style in naming,
u4_addr => addr
Regards,
CK
Quoted 26 lines
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +19
-0+enum sif_bit_t_hdmi uc_addr_type, + unsigned char *puc_value, unsigned int u4_count) +{ +unsigned int u4_read_count = 0; +unsigned char uc_return_value =0 ; + +if (!puc_value || !u4_count || !u4_clk_div || + uc_addr_type >SIF_16_BIT_HDMI || + (uc_addr_type ==SIF_8_BIT_HDMI && u4_addr >255 ) || + (uc_addr_type ==SIF_16_BIT_HDMI && u4_addr >65535 )) { +return 0 ; +} + +if (uc_addr_type ==SIF_8_BIT_HDMI ) +u4_read_count =255 - u4_addr +1 ; +else if (uc_addr_type ==SIF_16_BIT_HDMI ) +u4_read_count =65535 - u4_addr +1 ; + +u4_read_count = (u4_read_count > u4_count) ? u4_count :
u4_read_count;drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +5
-0+uc_return_value =ddcm_read_hdmi (ddc, u4_clk_div, uc_dev, u4_addr, + uc_addr_type, puc_value, u4_read_count); +return uc_return_value; +} +
Re: [PATCH v4 5/8] drm/mediatek: hdmi: add v2 support
In reply to Guillaume RanquetHi, Guillaume:
Quoted 8 lines · Guillaume Ranquet
External email : Please do not click links or open attachments until you have verified the sender or the content.
Adds hdmi and hdmi-ddc support for v2 IP.Signed-off-by Guillaume Ranquet <[email protected]>---
[snip]
Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +4
-0+ +static unsigned char +ddcm_read_hdmi (struct mtk_hdmi_ddc *ddc, + unsigned int u4_clk_div, unsigned char uc_dev, unsigned int
u4_addr,drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +5
-0+ enum sif_bit_t_hdmi uc_addr_type, unsigned char *puc_value, + unsigned int u4_count) +{ +u32 val; +unsigned int i, temp_length, loop_counter, uc_read_count, uc_idx =0;
I would like the variable naming as mtk_hdmi_ddc_read_msg() so that it's easy to compare this two driver. So does the variable calculating way.
Quoted 73 lines
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +8
-0+ +if (!puc_value || !u4_count || !u4_clk_div) +return 0 ; + +uc_idx =0 ; +regmap_read (ddc->regs,HDCP2X_DDCM_STATUS , &val); +if (val &DDC_I2C_BUS_LOW ) { +regmap_update_bits(ddc->regs, DDC_CTRL, FIELD_PREP(DDC_CMD,
CLOCK_SCL),DDC_CMD);drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +4
-0+usleep_range (250 ,300 ); +} + +regmap_update_bits(ddc->regs, DDC_CTRL, FIELD_PREP(DDC_CMD,
CLEAR_FIFO),DDC_CMD);drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +14
-0+ +if (u4_count >=16 ) { +temp_length =16 ; +loop_counter = +u4_count /16 + (u4_count %16 ==0 ); +}else { +temp_length = u4_count; +loop_counter =1 ; +} +if (uc_dev >=EDID_ID ) { +if (u4_clk_div <DDC2_CLOK_EDID ) +u4_clk_div =DDC2_CLOK_EDID ; +} +regmap_update_bits(ddc->regs, HPD_DDC_CTRL,
FIELD_PREP(DDC_DELAY_CNT, u4_clk_div),DDC_DELAY_CNT);drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +6
-0+for (i =0 ; i < loop_counter; i++) { +if (i == (loop_counter -1 ) && i !=0 && +u4_count %16 ) +temp_length = u4_count %16 ; +if (uc_dev >EDID_ID ) { +regmap_update_bits(ddc->regs, SCDC_CTRL, FIELD_PREP(DDC_SEGMENT,
uc_dev-EDID_ID),DDC_SEGMENT); +regmap_write(ddc->regs,DDC_CTRL,FIELD_PREP(DDC_CMD, ENH_READ_NO_ACK)|drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +5
-0+FIELD_PREP (DDC_DIN_CNT , temp_length) | +FIELD_PREP (DDC_OFFSET , u4_addr + i * temp_length) | + (EDID_ID << 1)); +}else { +regmap_write(ddc->regs, DDC_CTRL, FIELD_PREP(DDC_CMD,
SEQ_READ_NO_ACK) |drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +29
-0+FIELD_PREP (DDC_DIN_CNT , temp_length) | +FIELD_PREP (DDC_OFFSET , u4_addr + i *16 ) | + (uc_dev << 1)); +} +usleep_range (5000 ,5500 ); +if (regmap_read_poll_timeout (ddc->regs,HPD_DDC_STATUS , val, +!(val &DDC_I2C_IN_PROG ),2000 , temp_length +5 )) { +dev_err (ddc->dev,"time out waiting for DDC I2C\n" ); +return 0 ; +} +regmap_read (ddc->regs,HDCP2X_DDCM_STATUS , &val); +if ((val & (DDC_I2C_NO_ACK |DDC_I2C_BUS_LOW ))) { +regmap_read (ddc->regs,HDCP2X_DDCM_STATUS , &val); +if (val &DDC_I2C_BUS_LOW ) { +regmap_update_bits (ddc->regs,DDC_CTRL , +FIELD_PREP (DDC_CMD ,CLOCK_SCL ),DDC_CMD ); +usleep_range (250 ,300 ); +} +return 0 ; +} +for (uc_idx =0 ; uc_idx < temp_length; uc_idx++) { +regmap_write (ddc->regs,SI2C_CTRL , +FIELD_PREP (SI2C_ADDR ,SI2C_ADDR_READ ) |SI2C_RD ); +regmap_write (ddc->regs,SI2C_CTRL , +FIELD_PREP (SI2C_ADDR ,SI2C_ADDR_READ ) |SI2C_CONFIRM_READ ); +regmap_read (ddc->regs,HPD_DDC_STATUS , &val); +puc_value[i *16 + uc_idx] =FIELD_GET (DDC_DATA_OUT , val); +/* +* when reading edid, if hdmi module been reset,
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c line 171
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +10
-0+* ddc will fail and it's speed will be set to 400. +*/ +regmap_read (ddc->regs,HPD_DDC_CTRL , &val); +if (((val >>16 ) &0xFFFF ) <DDC2_CLOK ) +return 0 ; + +uc_read_count = i *16 + uc_idx +1 ; +} +} +return uc_read_count;
uc_read_count is u4_count, isn't it? So you just return u4_count or 0, so I would like to return 0 for success or error code.
Quoted 24 lines
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +3
-0+} + +static unsigned char vddc_read(struct mtk_hdmi_ddc *ddc, unsignedint
u4_clk_div,drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +20
-0+ unsigned char uc_dev, unsigned int u4_addr, + enum sif_bit_t_hdmi uc_addr_type, + unsigned char *puc_value, unsigned int u4_count) +{ +unsigned int u4_read_count = 0; +unsigned char uc_return_value =0 ; + +if (!puc_value || !u4_count || !u4_clk_div || + uc_addr_type >SIF_16_BIT_HDMI || + (uc_addr_type ==SIF_8_BIT_HDMI && u4_addr >255 ) || + (uc_addr_type ==SIF_16_BIT_HDMI && u4_addr >65535 )) { +return 0 ; +} + +if (uc_addr_type ==SIF_8_BIT_HDMI ) +u4_read_count =255 - u4_addr +1 ; +else if (uc_addr_type ==SIF_16_BIT_HDMI ) +u4_read_count =65535 - u4_addr +1 ; + +u4_read_count = (u4_read_count > u4_count) ? u4_count :
Quoted 1 line
u4_read_count;
If u4_read_count < u4_count, the return value would not be u4_count, and the checking in mtk_hdmi_ddc_xfer() would fail. I would it's not necessary to do the next statement, just return 0 here. I'm curious about why do this? Why not read u4_count?
Regards,
CK
Quoted 85 lines
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +41
-0+uc_return_value =ddcm_read_hdmi (ddc, u4_clk_div, uc_dev, u4_addr, + uc_addr_type, puc_value, u4_read_count); +return uc_return_value; +} + +static bool fg_ddc_data_read (struct mtk_hdmi_ddc *ddc, +unsigned char b_dev, +unsigned char b_data_addr, +unsigned char b_data_count, +unsigned char *pr_data) +{ +int ret; + +mutex_lock (&ddc->mtx); + +hdmi_ddc_request (ddc); +ret =vddc_read (ddc,DDC2_CLOK , b_dev, b_data_addr,SIF_8_BIT_HDMI , + pr_data, b_data_count); +mutex_unlock (&ddc->mtx); + +return ret == b_data_count; +} + +static void fg_ddc_data_write (struct mtk_hdmi_ddc *ddc, +unsigned char b_dev, +unsigned char b_data_addr, +unsigned char b_data_count, +unsigned char *pr_data) +{ +unsigned int i; + +mutex_lock (&ddc->mtx); + +hdmi_ddc_request (ddc); +for (i =0 ; i < b_data_count; i++) +mtk_ddc_wr_one (ddc, b_dev, b_data_addr + i, *(pr_data + i)); + +mutex_unlock (&ddc->mtx); +} + +static int mtk_hdmi_ddc_xfer(struct i2c_adapter *adapter, struct
i2c_msg*msgs,drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +42
-0+ int num) +{ +struct mtk_hdmi_ddc *ddc = adapter->algo_data; +struct device *dev = adapter->dev.parent; +bool ret; +int i; +unsigned char offset; + +if (!ddc) +return -EINVAL ; + +for (i =0 ; i < num; i++) { +struct i2c_msg *msg = &msgs[i]; + +if (msg->flags &I2C_M_RD ) { +/* The underlying DDC hardware always issue a write request +* that assigns the read offset as part of the read operation. +* Therefore we need to use the offset value assigned +* in the previous write request from the drm_edid.c +*/ +ret =fg_ddc_data_read (ddc, msg->addr, + offset,/* determined by previous write requests */ + (msg->len), &msg->buf[0 ]); +if (!ret) { +dev_err (dev,"ddc read failed : %d\n" , ret); +return ret; +} +}else { +fg_ddc_data_write (ddc, msg->addr, msg->buf[0 ], +(msg->len -1 ), &msg->buf[1 ]); + +/* we store the offset value requested by drm_edid framework +* to use in subsequent read requests. +*/ +if (DDC_ADDR == msg->addr &&1 == msg->len) +offset = msg->buf[0 ]; +} +} + +return i; +} +
Re: [PATCH v4 5/8] drm/mediatek: hdmi: add v2 support
In reply to Guillaume RanquetHi, Guillaume:
Quoted 7 lines · Guillaume Ranquet
External email : Please do not click links or open attachments until you have verified the sender or the content.
Adds hdmi and hdmi-ddc support for v2 IP.Signed-off-by Guillaume Ranquet <[email protected]>---
[snip]
Quoted 42 lines
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c new file +42
-0+ +static void mtk_hdmi_bridge_disable (struct drm_bridge *bridge, +struct drm_bridge_state *old_bridge_state) +{ +struct mtk_hdmi *hdmi =hdmi_ctx_from_bridge (bridge); + +if (!hdmi->enabled) +return ; + +mtk_hdmi_hw_send_av_mute (hdmi); +usleep_range (50000 ,50050 ); +mtk_hdmi_hw_vid_black (hdmi, true); +mtk_hdmi_disable_hdcp_encrypt (hdmi); +usleep_range (50000 ,50050 ); + +phy_power_off (hdmi->phy); + +hdmi->enabled = false; +} + +static void mtk_hdmi_bridge_post_disable (struct drm_bridge *bridge, +struct drm_bridge_state *old_state) +{ +struct mtk_hdmi *hdmi =hdmi_ctx_from_bridge (bridge); + +if (!hdmi->powered) +return ; + +phy_power_off (hdmi->phy); + +hdmi->powered = false; +} + +static void mtk_hdmi_bridge_pre_enable (struct drm_bridge *bridge, +struct drm_bridge_state *old_state) +{ +struct mtk_hdmi *hdmi =hdmi_ctx_from_bridge (bridge); +struct drm_atomic_state *state = old_state->base.state; +union phy_configure_opts opts = { +.dp = { .link_rate = hdmi->mode.clock *KILO } +}; +
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c line 1064
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c new file +10
-0+/* Retrieve the connector through the atomic state. */ +hdmi->curr_conn =drm_atomic_get_new_connector_for_encoder (state, + bridge->encoder); + +mtk_hdmi_output_set_display_mode (hdmi, &hdmi->mode); +/* configuring phy clock link with appropriate rate */ +phy_configure (hdmi->phy, &opts); +phy_power_on (hdmi->phy); +hdmi->powered = true; +}
In mt8173 hdmi driver, only bridge_enable stage, no bridge_pre_enable stage, why mt8195 need to separate it?
Regards,
CK
Quoted 20 lines
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c new file +19
-0+ +static void mtk_hdmi_bridge_enable (struct drm_bridge *bridge, +struct drm_bridge_state *old_state) +{ +struct mtk_hdmi *hdmi =hdmi_ctx_from_bridge (bridge); +u8 buffer_spd[HDMI_INFOFRAME_SIZE (SPD )]; +u8 buffer_avi[HDMI_INFOFRAME_SIZE (AVI )]; + +phy_power_on (hdmi->phy); +mtk_hdmi_send_infoframe (hdmi, buffer_spd,sizeof (buffer_spd), +buffer_avi,sizeof (buffer_avi), &hdmi->mode); +mtk_hdmi_hw_spd_infoframe (hdmi, buffer_spd,sizeof (buffer_spd)); +mtk_hdmi_hw_avi_infoframe (hdmi, buffer_avi,sizeof (buffer_avi)); + +mtk_hdmi_hw_vid_black (hdmi, false); + +hdmi->enabled = true; +} +
Re: [PATCH v4 5/8] drm/mediatek: hdmi: add v2 support
In reply to Guillaume RanquetHi, Guillaume:
Quoted 7 lines · Guillaume Ranquet
External email : Please do not click links or open attachments until you have verified the sender or the content.
Adds hdmi and hdmi-ddc support for v2 IP.Signed-off-by Guillaume Ranquet <[email protected]>---
[snip]
Quoted 15 lines
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c new file +9
-0+ +static int mtk_hdmi_bridge_attach (struct drm_bridge *bridge, +enum drm_bridge_attach_flags flags) +{ +struct mtk_hdmi *hdmi =hdmi_ctx_from_bridge (bridge); +int ret; + +if (!(flags &DRM_BRIDGE_ATTACH_NO_CONNECTOR )) { +DRM_ERROR("The flag DRM_BRIDGE_ATTACH_NO_CONNECTOR must besupplied\n");
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c new file +4
-0+return -EINVAL ; +} +if (hdmi->next_bridge) { +ret = drm_bridge_attach(bridge->encoder, hdmi->next_bridge, bridge,flags);
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c line 1009
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c new file +6
-0+if (ret) +return ret; +} + +pm_runtime_enable (hdmi->dev); +mtk_hdmi_enable_disable (hdmi, true);
In mt8173 hdmi driver, the bridge attach function does not enable hdmi, could you align the enable timing with mt8173? If not, please explain.
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c line 104
Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +3
-0+ +return 0 ; +}
This function is almost the same as mt8173 one, try to merge them.
Regards,
CK
Quoted 2 lines
+
Re: [PATCH v4 8/8] drm/mediatek: dpi: Add mt8195 hdmi to DPI driver
In reply to Guillaume RanquetHi, Guillaume:
Quoted 213 lines · Guillaume Ranquet
External email : Please do not click links or open attachments until you have verified the sender or the content.
Add the DPI1 hdmi path support in mtk dpi driverSigned-off-by Guillaume Ranquet <[email protected]>--- drivers/gpu/drm/mediatek/mtk_dpi.c | 121 ++++++++++++++++++++++++++++++-- drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 5 ++ 2 files changed, 119 insertions(+), 7 deletions(-)drivers/gpu/drm/mediatek/mtk_dpi.c +6
-0@@ -9,12 +9,15 @@#include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/media-bus-format.h> +#include <linux/mfd/syscon.h> #include <linux/of.h> #include <linux/of_device.h> #include <linux/of_graph.h> #include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/soc/mediatek/mtk-mmsys.h> +#include <linux/regmap.h> +#include <linux/reset.h> #include <linux/types.h> #include <video/videomode.h> @@ -67,11 +70,14 @@ struct mtk_dpi {struct drm_bridge *next_bridge;struct drm_connector *connector;void __iomem *regs; +struct reset_control *reset_ctl;struct device *dev;struct device *mmsys_dev;struct clk *engine_clk; +struct clk *dpi_ck_cg;struct clk *pixel_clk;struct clk *tvd_clk; +struct clk *hdmi_cg;int irq;struct drm_display_mode mode;const struct mtk_dpi_conf *conf;@@ -138,6 +144,7 @@ struct mtk_dpi_yc_limit {* @csc_enable_bit: Enable bit of CSC. * @pixels_per_iter: Quantity of transferred pixels per iteration. * @edge_cfg_in_mmsys: If the edge configuration for DPI's output needs to be set in MMSYS.
+ * @is_internal_hdmi: True if this DPI block is directly connected to SoC internal HDMI block.
*/
structmtk_dpi_conf{
unsigned int (*cal_factor)(int clock);drivers/gpu/drm/mediatek/mtk_dpi.c +1
-0@@ -157,6 +164,7 @@ struct mtk_dpi_conf {u32 csc_enable_bit;u32 pixels_per_iter;bool edge_cfg_in_mmsys; +bool is_internal_hdmi; }; static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val,u32 mask)
drivers/gpu/drm/mediatek/mtk_dpi.c +6
-0@@ -471,8 +479,14 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi)return ;mtk_dpi_disable (dpi); + +reset_control_rearm (dpi->reset_ctl); +clk_disable_unprepare (dpi->pixel_clk);clk_disable_unprepare (dpi->engine_clk); +clk_disable_unprepare (dpi->dpi_ck_cg); +clk_disable_unprepare (dpi->hdmi_cg); +clk_disable_unprepare (dpi->tvd_clk); }static int
mtk_dpi_power_on(struct mtk_dpi *dpi)drivers/gpu/drm/mediatek/mtk_dpi.c +29
-0@@ -488,15 +502,44 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) goto err_refcount; } +ret =clk_prepare_enable (dpi->tvd_clk); +if (ret) { +dev_err (dpi->dev,"Failed to enable tvd pll: %d\n" , ret); +goto err_engine; +} + +ret =clk_prepare_enable (dpi->hdmi_cg); +if (ret) { +dev_err (dpi->dev,"Failed to enable hdmi_cg clock: %d\n" , ret); +goto err_tvd; +} + +ret =clk_prepare_enable (dpi->dpi_ck_cg); +if (ret) { +dev_err (dpi->dev,"Failed to enable dpi_ck_cg clock: %d\n" , ret); +goto err_hdmi_cg; +} + ret =clk_prepare_enable (dpi->pixel_clk);if (ret) {dev_err (dpi->dev,"Failed to enable pixel clock: %d\n" , ret); goto err_pixel; } +reset_control_reset (dpi->reset_ctl); + +if (dpi->pinctrl && dpi->pins_dpi) +pinctrl_select_state (dpi->pinctrl, dpi->pins_dpi); +return 0 ; err_pixel: +clk_disable_unprepare (dpi->dpi_ck_cg); +err_hdmi_cg: +clk_disable_unprepare (dpi->hdmi_cg); +err_tvd: +clk_disable_unprepare (dpi->tvd_clk); +err_engine:clk_disable_unprepare (dpi->engine_clk); err_refcount:dpi->refcount--;
drivers/gpu/drm/mediatek/mtk_dpi.c +0
-1@@ -541,7 +584,6 @@ static int mtk_dpi_set_display_mode(structmtk_dpi *dpi, else clk_set_rate(dpi->pixel_clk, vm.pixelclock); - vm.pixelclock =clk_get_rate (dpi->pixel_clk);dev_dbg(dpi->dev, "Got PLL %lu Hz, pixel clock %lu Hz\n",
drivers/gpu/drm/mediatek/mtk_dpi.c +10
-1@@ -608,7 +650,16 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, if (dpi->conf->support_direct_pin) {mtk_dpi_config_yc_map (dpi, dpi->yc_map);mtk_dpi_config_2n_h_fre (dpi); -mtk_dpi_dual_edge (dpi); +/* DPI could be connecting to external bridge +* or internal HDMI encoder. */ +if (dpi->conf->is_internal_hdmi) { +mtk_dpi_mask (dpi,DPI_CON ,DPI_OUTPUT_1T1P_EN , +DPI_OUTPUT_1T1P_EN ); +mtk_dpi_mask (dpi,DPI_CON ,DPI_INPUT_2P_EN , +DPI_INPUT_2P_EN ); +}else { +mtk_dpi_dual_edge (dpi); +}mtk_dpi_config_disable_edge (dpi); }if (
dpi->conf->input_2pixel) {drivers/gpu/drm/mediatek/mtk_dpi.c +4
-1@@ -723,7 +774,10 @@ static void mtk_dpi_bridge_disable(struct drm_bridge *bridge) {struct mtk_dpi *dpi =bridge_to_dpi (bridge); -mtk_dpi_power_off (dpi); +if (dpi->conf->is_internal_hdmi) +mtk_dpi_power_off (dpi); +else +mtk_dpi_disable (dpi);if (dpi->pinctrl && dpi->pins_gpio)
pinctrl_select_state(dpi->pinctrl, dpi->pins_gpio);drivers/gpu/drm/mediatek/mtk_dpi.c +4
-2@@ -772,14 +826,16 @@ void mtk_dpi_start(struct device *dev) {struct mtk_dpi *dpi =dev_get_drvdata (dev); -mtk_dpi_power_on (dpi); +if (!dpi->conf->is_internal_hdmi) +mtk_dpi_power_on (dpi); }void mtk_dpi_stop (struct device *dev) {struct mtk_dpi *dpi =dev_get_drvdata (dev); -mtk_dpi_power_off (dpi); +if (!dpi->conf->is_internal_hdmi) +mtk_dpi_power_off (dpi); } static int mtk_dpi_bind(struct device *dev, struct device *master,void *data)
drivers/gpu/drm/mediatek/mtk_dpi.c +5
-0@@ -864,6 +920,11 @@ static unsigned int mt8183_calculate_factor(int clock)return 2 ; } +static unsigned int mt8195_calculate_factor (int clock) +{ +return 1 ; +} +static unsigned int mt8195_dpintf_calculate_factor (int clock) {if (clock < 70000)
drivers/gpu/drm/mediatek/mtk_dpi.c +5
-0@@ -989,6 +1050,24 @@ static const struct mtk_dpi_conf mt8192_conf = { .csc_enable_bit = CSC_ENABLE, }; +static const struct mtk_dpi_conf mt8195_conf = { +.cal_factor = mt8195_calculate_factor, +.max_clock_khz =594000 , +.reg_h_fre_con =0xe0 , +.output_fmts = mt8183_output_fmts,
drivers/gpu/drm/mediatek/mtk_dpi.c static const struct mtk_dpi_conf mt8192_conf = · line 1068
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +10
-0+.num_output_fmts = ARRAY_SIZE(mt8183_output_fmts), +.pixels_per_iter = 1, +.is_ck_de_pol = true, +.swap_input_support = true, +.dimension_mask = HPW_MASK, +.hvsize_mask = HSIZE_MASK, +.channel_swap_shift = CH_SWAP, +.yuv422_en_bit = YUV422_EN, +.csc_enable_bit = CSC_ENABLE, +.is_internal_hdmi = true,
mt8173 dpi is also connect to internal mt8173 hdmi.
Quoted 23 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +3
-0+.support_direct_pin = true, +}; +static const struct mtk_dpi_conf mt8195_dpintf_conf = { .cal_factor = mt8195_dpintf_calculate_factor,.max_clock_khz = 600000,
drivers/gpu/drm/mediatek/mtk_dpi.c +6
-0@@ -1046,6 +1125,12 @@ static int mtk_dpi_probe(struct platform_device *pdev)return ret; } +dpi->reset_ctl =devm_reset_control_get_optional_exclusive (dev,"dpi_on" ); +if (IS_ERR (dpi->reset_ctl)) { +dev_err (dev,"Failed to get reset_ctl: %ld\n" ,PTR_ERR (dpi- >reset_ctl)); +return PTR_ERR (dpi->reset_ctl); +} +
dpi->engine_clk=devm_clk_get(dev, "engine");
if (IS_ERR(dpi->engine_clk)) {
ret =PTR_ERR(dpi->engine_clk);
drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_probe(struct · line 1144
Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-1@@ -1055,7 +1140,26 @@ static int mtk_dpi_probe(struct platform_device *pdev)return ret; } -dpi->pixel_clk =devm_clk_get (dev,"pixel" ); +dpi->hdmi_cg =devm_clk_get_optional (dev,"hdmi_cg" );
This clock is not defined in binding document.
drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_probe(struct platform_device *pdev) · line 1152
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +9
-0+if (IS_ERR (dpi->hdmi_cg)) { +ret =PTR_ERR (dpi->hdmi_cg); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get hdmi_cg clock: %d\n" , ret); + +return ret; +} + +dpi->dpi_ck_cg =devm_clk_get_optional (dev,"ck_cg" );
This clock is not defined in binding document.
Regards,
CK
Quoted 56 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +10
-0+if (IS_ERR (dpi->dpi_ck_cg)) { +ret =PTR_ERR (dpi->dpi_ck_cg); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get dpi ck cg clock: %d\n" , +ret); + +return ret; +} + +dpi->pixel_clk =devm_clk_get_optional (dev,"pixel" );if (IS_ERR (dpi->pixel_clk)) { ret =PTR_ERR (dpi->pixel_clk);if (ret != -EPROBE_DEFER)
drivers/gpu/drm/mediatek/mtk_dpi.c +1
-1@@ -1064,7 +1168,7 @@ static int mtk_dpi_probe(struct platform_device *pdev)return ret; } -dpi->tvd_clk =devm_clk_get (dev,"pll" ); +dpi->tvd_clk =devm_clk_get_optional (dev,"pll" );if (IS_ERR (dpi->tvd_clk)) { ret =PTR_ERR (dpi->tvd_clk);if (ret != -EPROBE_DEFER)
drivers/gpu/drm/mediatek/mtk_dpi.c +3
-0@@ -1134,6 +1238,9 @@ static const struct of_device_id mtk_dpi_of_ids[] = { { .compatible ="mediatek,mt8195-dp-intf" , .data = &mt8195_dpintf_conf, }, +{ .compatible ="mediatek,mt8195-dpi" , + .data = &mt8195_conf, +}, { }, };
MODULE_DEVICE_TABLE(of, mtk_dpi_of_ids);drivers/gpu/drm/mediatek/mtk_dpi_regs.h +5
-0@@ -43,6 +43,11 @@ #define DPINTF_YUV422_ENBIT(24) #define DPINTF_CSC_ENABLEBIT(26) #define DPINTF_INPUT_2P_ENBIT(29) +#define DPI_OUTPUT_1T1P_ENBIT(24) +#define DPI_INPUT_2P_ENBIT(25) +#define DPI_EXT_VSYNC_ENBIT(26) +#define DPI_RGB565_ENBIT(27) +#define DPI_RGB880_ENBIT(28)#define DPI_OUTPUT_SETTING0x14#define CH_SWAP0 Signature · 2 lines
-- 2.40.0
AngeloGioacchino Del Regno
maintainerIl 29/05/23 16:30, Guillaume Ranquet ha scritto:
Quoted 11 lines
Add support for HDMI Tx on MT8195.
This includes a split of the current "legacy" hdmi driver into a common library of functions and two dedicated compilation units with specific code for mt8167 and another for the "v2" mt8195 SoC.
Support for the new mt8195 dpi/drm_drv adjustments to support hdmi.
Based on next-20230523
Still in my TODO-list for v5:
Hello,
sorry for bumping a year old topic; are you still interested in upstreaming this?
Cheers,
Angelo
Quoted 75 lines
- Removal of the '
is_internal_hdmi' flag inmtk_dpi. [1]
I Couldn't find a way to get rid of it with the way things are done in mtk_drm_drv/mtk_ddp_comp.
- Do not use a "virtual" device for the ddc v2 hw as it is embedded in the hdmi IP. [2]
Seems that a lot of work is done by the framework when using a proper device-tree entry that can be linked as the ddc-i2c-bus of the hdmi-connector.
I will keep the virtual device unless I find a way to avoid rewriting the framework code that handles this.[1] : https://lore.kernel.org/all/[email protected]/
[2] : https://lore.kernel.org/all/[email protected]/Signed-off-by Guillaume Ranquet <[email protected]>---
Changes in v4:
- Split phy related patches to another series (merged)
- Removed regmap wrappers inmtk_hdmi
- Removed colorimetry related changes as this initial version only support one color depth
- Fixed dt-bindings properties
- Removed some now useless clocks frommtk_hdmi_v2andmtk_dpi
- Link to v3: https://lore.kernel.org/r/[email protected]Changes in v3:
- phy: Grouped register and bit definition together to add clarity
- dt-bindings: Addressed comments
- Link to v2: https://lore.kernel.org/r/[email protected]Changes in v2:
- Removed syscon requirement from the hdmi node
- Use as much as possible bit FIELD_PREP/FIELD_GET macros across all the patches
- Make cec optional dynamically instead of hardcoded with a flag
- Renamed hdmi variants to v1 (legacy) and v2 (mt8195) while waiting for a better name
- Rework hdmi v2 code to use a connector (same as v1)
- Remove "magic"0x43addr special handling in hdmi ddc code
- Link to v1: https://lore.kernel.org/r/[email protected]---
Guillaume Ranquet (8):
dt-bindings: display: mediatek: add MT8195 hdmi bindings drm/mediatek: hdmi: use a regmap instead of iomem drm/mediatek: extract common functions from the mtk hdmi driver drm/mediatek: hdmi: make the cec dev optional drm/mediatek: hdmi: add v2 support
drm/mediatek: hdmi: v2: add audio support
dt-bindings: display: mediatek: dpi: Add compatible for MediaTek MT8195 drm/mediatek: dpi: Add mt8195 hdmi to DPI driver.../bindings/display/mediatek/mediatek,dpi.yaml | 1 + .../bindings/display/mediatek/mediatek,hdmi.yaml | 59 +- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 45 + drivers/gpu/drm/mediatek/Kconfig | 2 + drivers/gpu/drm/mediatek/Makefile | 5 +- drivers/gpu/drm/mediatek/mtk_dpi.c | 121 +- drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 5 + drivers/gpu/drm/mediatek/mtk_hdmi.c | 773 ++---------- drivers/gpu/drm/mediatek/mtk_hdmi.h | 18 + drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 437 +++++++ drivers/gpu/drm/mediatek/mtk_hdmi_common.h | 208 ++++ drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c | 362 ++++++ drivers/gpu/drm/mediatek/mtk_hdmi_regs_v2.h | 276 +++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.c | 1303 ++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.h | 32 + 15 files changed, 2955 insertions(+), 692 deletions(-)---
base-commit:c8a64c6a78c54887da437098d97dc2accc689e89
change-id: 20220919-hdmi_mtkBest regards,